summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-04-04 01:39:59 +0000
committergVisor bot <gvisor-bot@google.com>2020-04-04 01:39:59 +0000
commit078753e0fe85dbcc047aaa5607a2bbc209491672 (patch)
tree14790716c79a7318214f1dc9293b6158a47851c3 /pkg/sentry/fs
parent818a047ab6deabe5a75a5452cdb950cc0e22d722 (diff)
parentfc99a7ebf0c24b6f7b3cfd6351436373ed54548b (diff)
Merge release-20200323.0-69-gfc99a7e (automated)
Diffstat (limited to 'pkg/sentry/fs')
-rwxr-xr-xpkg/sentry/fs/dirent_list.go13
-rwxr-xr-xpkg/sentry/fs/event_list.go13
2 files changed, 20 insertions, 6 deletions
diff --git a/pkg/sentry/fs/dirent_list.go b/pkg/sentry/fs/dirent_list.go
index acdce100c..ecbbd7883 100755
--- a/pkg/sentry/fs/dirent_list.go
+++ b/pkg/sentry/fs/dirent_list.go
@@ -52,12 +52,21 @@ func (l *direntList) Back() *Dirent {
return l.tail
}
+// Len returns the number of elements in the list.
+//
+// NOTE: This is an O(n) operation.
+func (l *direntList) Len() (count int) {
+ for e := l.Front(); e != nil; e = e.Next() {
+ count++
+ }
+ return count
+}
+
// PushFront inserts the element e at the front of list l.
func (l *direntList) PushFront(e *Dirent) {
linker := direntElementMapper{}.linkerFor(e)
linker.SetNext(l.head)
linker.SetPrev(nil)
-
if l.head != nil {
direntElementMapper{}.linkerFor(l.head).SetPrev(e)
} else {
@@ -72,7 +81,6 @@ func (l *direntList) PushBack(e *Dirent) {
linker := direntElementMapper{}.linkerFor(e)
linker.SetNext(nil)
linker.SetPrev(l.tail)
-
if l.tail != nil {
direntElementMapper{}.linkerFor(l.tail).SetNext(e)
} else {
@@ -93,7 +101,6 @@ func (l *direntList) PushBackList(m *direntList) {
l.tail = m.tail
}
-
m.head = nil
m.tail = nil
}
diff --git a/pkg/sentry/fs/event_list.go b/pkg/sentry/fs/event_list.go
index 0274f41a2..167fdf906 100755
--- a/pkg/sentry/fs/event_list.go
+++ b/pkg/sentry/fs/event_list.go
@@ -52,12 +52,21 @@ func (l *eventList) Back() *Event {
return l.tail
}
+// Len returns the number of elements in the list.
+//
+// NOTE: This is an O(n) operation.
+func (l *eventList) Len() (count int) {
+ for e := l.Front(); e != nil; e = e.Next() {
+ count++
+ }
+ return count
+}
+
// PushFront inserts the element e at the front of list l.
func (l *eventList) PushFront(e *Event) {
linker := eventElementMapper{}.linkerFor(e)
linker.SetNext(l.head)
linker.SetPrev(nil)
-
if l.head != nil {
eventElementMapper{}.linkerFor(l.head).SetPrev(e)
} else {
@@ -72,7 +81,6 @@ func (l *eventList) PushBack(e *Event) {
linker := eventElementMapper{}.linkerFor(e)
linker.SetNext(nil)
linker.SetPrev(l.tail)
-
if l.tail != nil {
eventElementMapper{}.linkerFor(l.tail).SetNext(e)
} else {
@@ -93,7 +101,6 @@ func (l *eventList) PushBackList(m *eventList) {
l.tail = m.tail
}
-
m.head = nil
m.tail = nil
}