mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add vfs.Dentry.Children().
PiperOrigin-RevId: 286660774
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user