mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
MountSource.Root() should return a refernce on the dirent.
PiperOrigin-RevId: 202038397 Change-Id: I074d525f2e2d9bcd43b247b62f86f9129c101b78
This commit is contained in:
committed by
Shentubot
parent
478f0ac003
commit
1a9917d14d
@@ -198,10 +198,12 @@ func (msrc *MountSource) Submounts() []*MountSource {
|
||||
return ms
|
||||
}
|
||||
|
||||
// Root returns the root dirent of this mount.
|
||||
// Root returns the root dirent of this mount. Callers must call DecRef on the
|
||||
// returned dirent.
|
||||
func (msrc *MountSource) Root() *Dirent {
|
||||
msrc.mu.Lock()
|
||||
defer msrc.mu.Unlock()
|
||||
msrc.root.IncRef()
|
||||
return msrc.root
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,9 @@ func mountPathsAre(root *Dirent, got []*MountSource, want ...string) error {
|
||||
}
|
||||
gotPaths := make(map[string]struct{}, len(got))
|
||||
for _, g := range got {
|
||||
n, _ := g.Root().FullName(root)
|
||||
groot := g.Root()
|
||||
n, _ := groot.FullName(root)
|
||||
groot.DecRef()
|
||||
gotPaths[n] = struct{}{}
|
||||
}
|
||||
for _, w := range want {
|
||||
|
||||
@@ -44,7 +44,9 @@ func forEachMountSource(t *kernel.Task, fn func(string, *fs.MountSource)) {
|
||||
return ms[i].ID() < ms[j].ID()
|
||||
})
|
||||
for _, m := range ms {
|
||||
mountPath, desc := m.Root().FullName(rootDir)
|
||||
mroot := m.Root()
|
||||
mountPath, desc := mroot.FullName(rootDir)
|
||||
mroot.DecRef()
|
||||
if !desc {
|
||||
// MountSources that are not descendants of the chroot jail are ignored.
|
||||
continue
|
||||
@@ -88,7 +90,9 @@ func (mif *mountInfoFile) ReadSeqFileData(handle seqfile.SeqHandle) ([]seqfile.S
|
||||
|
||||
// (3) Major:Minor device ID. We don't have a superblock, so we
|
||||
// just use the root inode device number.
|
||||
sa := m.Root().Inode.StableAttr
|
||||
mroot := m.Root()
|
||||
sa := mroot.Inode.StableAttr
|
||||
mroot.DecRef()
|
||||
fmt.Fprintf(&buf, "%d:%d ", sa.DeviceFileMajor, sa.DeviceFileMinor)
|
||||
|
||||
// (4) Root: the pathname of the directory in the filesystem
|
||||
|
||||
Reference in New Issue
Block a user