summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-12-21 00:59:00 +0000
committergVisor bot <gvisor-bot@google.com>2019-12-21 00:59:00 +0000
commitde92b4cf45fee923595e8d19a432ed2bee3232fd (patch)
treec950dcd9f85a97aaaf8275ab6974a1c083cc79f4 /pkg
parent24009971224663fbe1095bd110d36526b4b952b3 (diff)
parent21a14e9532365fc5eb51a5796ab66cf7f007ede3 (diff)
Merge release-20191213.0-40-g21a14e9 (automated)
Diffstat (limited to 'pkg')
-rwxr-xr-xpkg/sentry/vfs/dentry.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/pkg/sentry/vfs/dentry.go b/pkg/sentry/vfs/dentry.go
index 40f4c1d09..6209eb053 100755
--- a/pkg/sentry/vfs/dentry.go
+++ b/pkg/sentry/vfs/dentry.go
@@ -85,12 +85,12 @@ type Dentry struct {
// mounts is accessed using atomic memory operations.
mounts uint32
- // mu synchronizes disowning and mounting over this Dentry.
- mu sync.Mutex
-
// children are child Dentries.
children map[string]*Dentry
+ // mu synchronizes disowning and mounting over this Dentry.
+ mu sync.Mutex
+
// impl is the DentryImpl associated with this Dentry. impl is immutable.
// This should be the last field in Dentry.
impl DentryImpl
@@ -199,6 +199,18 @@ func (d *Dentry) HasChildren() bool {
return len(d.children) != 0
}
+// Children returns a map containing all of d's children.
+func (d *Dentry) Children() map[string]*Dentry {
+ if !d.HasChildren() {
+ return nil
+ }
+ m := make(map[string]*Dentry)
+ for name, child := range d.children {
+ m[name] = child
+ }
+ return m
+}
+
// InsertChild makes child a child of d with the given name.
//
// InsertChild is a mutator of d and child.