mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Plumbing context.Context to DecRef() and Release().
context is passed to DecRef() and Release() which is needed for SO_LINGER implementation. PiperOrigin-RevId: 324672584
This commit is contained in:
committed by
gVisor bot
parent
ef11bb936b
commit
b2ae7ea1bb
@@ -83,7 +83,7 @@ func fileOpOn(ctx context.Context, mntns *fs.MountNamespace, root, wd *fs.Dirent
|
||||
}
|
||||
|
||||
err = fn(root, d)
|
||||
d.DecRef()
|
||||
d.DecRef(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -105,17 +105,17 @@ func BenchmarkVFS1TmpfsStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create mount namespace: %v", err)
|
||||
}
|
||||
defer mntns.DecRef()
|
||||
defer mntns.DecRef(ctx)
|
||||
|
||||
var filePathBuilder strings.Builder
|
||||
filePathBuilder.WriteByte('/')
|
||||
|
||||
// Create nested directories with given depth.
|
||||
root := mntns.Root()
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
d := root
|
||||
d.IncRef()
|
||||
defer d.DecRef()
|
||||
defer d.DecRef(ctx)
|
||||
for i := depth; i > 0; i-- {
|
||||
name := fmt.Sprintf("%d", i)
|
||||
if err := d.Inode.CreateDirectory(ctx, d, name, fs.FilePermsFromMode(0755)); err != nil {
|
||||
@@ -125,7 +125,7 @@ func BenchmarkVFS1TmpfsStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to walk to directory %q: %v", name, err)
|
||||
}
|
||||
d.DecRef()
|
||||
d.DecRef(ctx)
|
||||
d = next
|
||||
filePathBuilder.WriteString(name)
|
||||
filePathBuilder.WriteByte('/')
|
||||
@@ -136,7 +136,7 @@ func BenchmarkVFS1TmpfsStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create file %q: %v", filename, err)
|
||||
}
|
||||
file.DecRef()
|
||||
file.DecRef(ctx)
|
||||
filePathBuilder.WriteString(filename)
|
||||
filePath := filePathBuilder.String()
|
||||
|
||||
@@ -176,7 +176,7 @@ func BenchmarkVFS2TmpfsStat(b *testing.B) {
|
||||
|
||||
// Create VFS.
|
||||
vfsObj := vfs.VirtualFilesystem{}
|
||||
if err := vfsObj.Init(); err != nil {
|
||||
if err := vfsObj.Init(ctx); err != nil {
|
||||
b.Fatalf("VFS init: %v", err)
|
||||
}
|
||||
vfsObj.MustRegisterFilesystemType("tmpfs", tmpfs.FilesystemType{}, &vfs.RegisterFilesystemTypeOptions{
|
||||
@@ -186,14 +186,14 @@ func BenchmarkVFS2TmpfsStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create tmpfs root mount: %v", err)
|
||||
}
|
||||
defer mntns.DecRef()
|
||||
defer mntns.DecRef(ctx)
|
||||
|
||||
var filePathBuilder strings.Builder
|
||||
filePathBuilder.WriteByte('/')
|
||||
|
||||
// Create nested directories with given depth.
|
||||
root := mntns.Root()
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
vd := root
|
||||
vd.IncRef()
|
||||
for i := depth; i > 0; i-- {
|
||||
@@ -212,7 +212,7 @@ func BenchmarkVFS2TmpfsStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to walk to directory %q: %v", name, err)
|
||||
}
|
||||
vd.DecRef()
|
||||
vd.DecRef(ctx)
|
||||
vd = nextVD
|
||||
filePathBuilder.WriteString(name)
|
||||
filePathBuilder.WriteByte('/')
|
||||
@@ -228,12 +228,12 @@ func BenchmarkVFS2TmpfsStat(b *testing.B) {
|
||||
Flags: linux.O_RDWR | linux.O_CREAT | linux.O_EXCL,
|
||||
Mode: 0644,
|
||||
})
|
||||
vd.DecRef()
|
||||
vd.DecRef(ctx)
|
||||
vd = vfs.VirtualDentry{}
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create file %q: %v", filename, err)
|
||||
}
|
||||
defer fd.DecRef()
|
||||
defer fd.DecRef(ctx)
|
||||
filePathBuilder.WriteString(filename)
|
||||
filePath := filePathBuilder.String()
|
||||
|
||||
@@ -278,14 +278,14 @@ func BenchmarkVFS1TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create mount namespace: %v", err)
|
||||
}
|
||||
defer mntns.DecRef()
|
||||
defer mntns.DecRef(ctx)
|
||||
|
||||
var filePathBuilder strings.Builder
|
||||
filePathBuilder.WriteByte('/')
|
||||
|
||||
// Create and mount the submount.
|
||||
root := mntns.Root()
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
if err := root.Inode.CreateDirectory(ctx, root, mountPointName, fs.FilePermsFromMode(0755)); err != nil {
|
||||
b.Fatalf("failed to create mount point: %v", err)
|
||||
}
|
||||
@@ -293,7 +293,7 @@ func BenchmarkVFS1TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to walk to mount point: %v", err)
|
||||
}
|
||||
defer mountPoint.DecRef()
|
||||
defer mountPoint.DecRef(ctx)
|
||||
submountInode, err := tmpfsFS.Mount(ctx, "tmpfs", fs.MountSourceFlags{}, "", nil)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create tmpfs submount: %v", err)
|
||||
@@ -309,7 +309,7 @@ func BenchmarkVFS1TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to walk to mount root: %v", err)
|
||||
}
|
||||
defer d.DecRef()
|
||||
defer d.DecRef(ctx)
|
||||
for i := depth; i > 0; i-- {
|
||||
name := fmt.Sprintf("%d", i)
|
||||
if err := d.Inode.CreateDirectory(ctx, d, name, fs.FilePermsFromMode(0755)); err != nil {
|
||||
@@ -319,7 +319,7 @@ func BenchmarkVFS1TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to walk to directory %q: %v", name, err)
|
||||
}
|
||||
d.DecRef()
|
||||
d.DecRef(ctx)
|
||||
d = next
|
||||
filePathBuilder.WriteString(name)
|
||||
filePathBuilder.WriteByte('/')
|
||||
@@ -330,7 +330,7 @@ func BenchmarkVFS1TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create file %q: %v", filename, err)
|
||||
}
|
||||
file.DecRef()
|
||||
file.DecRef(ctx)
|
||||
filePathBuilder.WriteString(filename)
|
||||
filePath := filePathBuilder.String()
|
||||
|
||||
@@ -370,7 +370,7 @@ func BenchmarkVFS2TmpfsMountStat(b *testing.B) {
|
||||
|
||||
// Create VFS.
|
||||
vfsObj := vfs.VirtualFilesystem{}
|
||||
if err := vfsObj.Init(); err != nil {
|
||||
if err := vfsObj.Init(ctx); err != nil {
|
||||
b.Fatalf("VFS init: %v", err)
|
||||
}
|
||||
vfsObj.MustRegisterFilesystemType("tmpfs", tmpfs.FilesystemType{}, &vfs.RegisterFilesystemTypeOptions{
|
||||
@@ -380,14 +380,14 @@ func BenchmarkVFS2TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create tmpfs root mount: %v", err)
|
||||
}
|
||||
defer mntns.DecRef()
|
||||
defer mntns.DecRef(ctx)
|
||||
|
||||
var filePathBuilder strings.Builder
|
||||
filePathBuilder.WriteByte('/')
|
||||
|
||||
// Create the mount point.
|
||||
root := mntns.Root()
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
pop := vfs.PathOperation{
|
||||
Root: root,
|
||||
Start: root,
|
||||
@@ -403,7 +403,7 @@ func BenchmarkVFS2TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to walk to mount point: %v", err)
|
||||
}
|
||||
defer mountPoint.DecRef()
|
||||
defer mountPoint.DecRef(ctx)
|
||||
// Create and mount the submount.
|
||||
if err := vfsObj.MountAt(ctx, creds, "", &pop, "tmpfs", &vfs.MountOptions{}); err != nil {
|
||||
b.Fatalf("failed to mount tmpfs submount: %v", err)
|
||||
@@ -432,7 +432,7 @@ func BenchmarkVFS2TmpfsMountStat(b *testing.B) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to walk to directory %q: %v", name, err)
|
||||
}
|
||||
vd.DecRef()
|
||||
vd.DecRef(ctx)
|
||||
vd = nextVD
|
||||
filePathBuilder.WriteString(name)
|
||||
filePathBuilder.WriteByte('/')
|
||||
@@ -448,11 +448,11 @@ func BenchmarkVFS2TmpfsMountStat(b *testing.B) {
|
||||
Flags: linux.O_RDWR | linux.O_CREAT | linux.O_EXCL,
|
||||
Mode: 0644,
|
||||
})
|
||||
vd.DecRef()
|
||||
vd.DecRef(ctx)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create file %q: %v", filename, err)
|
||||
}
|
||||
fd.DecRef()
|
||||
fd.DecRef(ctx)
|
||||
filePathBuilder.WriteString(filename)
|
||||
filePath := filePathBuilder.String()
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ type directoryFD struct {
|
||||
}
|
||||
|
||||
// Release implements vfs.FileDescriptionImpl.Release.
|
||||
func (fd *directoryFD) Release() {
|
||||
func (fd *directoryFD) Release(ctx context.Context) {
|
||||
if fd.iter != nil {
|
||||
dir := fd.inode().impl.(*directory)
|
||||
dir.iterMu.Lock()
|
||||
@@ -110,7 +110,7 @@ func (fd *directoryFD) IterDirents(ctx context.Context, cb vfs.IterDirentsCallba
|
||||
fs := fd.filesystem()
|
||||
dir := fd.inode().impl.(*directory)
|
||||
|
||||
defer fd.dentry().InotifyWithParent(linux.IN_ACCESS, 0, vfs.PathEvent)
|
||||
defer fd.dentry().InotifyWithParent(ctx, linux.IN_ACCESS, 0, vfs.PathEvent)
|
||||
|
||||
// fs.mu is required to read d.parent and dentry.name.
|
||||
fs.mu.RLock()
|
||||
|
||||
@@ -40,7 +40,7 @@ func (fs *filesystem) Sync(ctx context.Context) error {
|
||||
// stepLocked is loosely analogous to fs/namei.c:walk_component().
|
||||
//
|
||||
// Preconditions: filesystem.mu must be locked. !rp.Done().
|
||||
func stepLocked(rp *vfs.ResolvingPath, d *dentry) (*dentry, error) {
|
||||
func stepLocked(ctx context.Context, rp *vfs.ResolvingPath, d *dentry) (*dentry, error) {
|
||||
dir, ok := d.inode.impl.(*directory)
|
||||
if !ok {
|
||||
return nil, syserror.ENOTDIR
|
||||
@@ -55,13 +55,13 @@ afterSymlink:
|
||||
return d, nil
|
||||
}
|
||||
if name == ".." {
|
||||
if isRoot, err := rp.CheckRoot(&d.vfsd); err != nil {
|
||||
if isRoot, err := rp.CheckRoot(ctx, &d.vfsd); err != nil {
|
||||
return nil, err
|
||||
} else if isRoot || d.parent == nil {
|
||||
rp.Advance()
|
||||
return d, nil
|
||||
}
|
||||
if err := rp.CheckMount(&d.parent.vfsd); err != nil {
|
||||
if err := rp.CheckMount(ctx, &d.parent.vfsd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rp.Advance()
|
||||
@@ -74,7 +74,7 @@ afterSymlink:
|
||||
if !ok {
|
||||
return nil, syserror.ENOENT
|
||||
}
|
||||
if err := rp.CheckMount(&child.vfsd); err != nil {
|
||||
if err := rp.CheckMount(ctx, &child.vfsd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if symlink, ok := child.inode.impl.(*symlink); ok && rp.ShouldFollowSymlink() {
|
||||
@@ -98,9 +98,9 @@ afterSymlink:
|
||||
// fs/namei.c:path_parentat().
|
||||
//
|
||||
// Preconditions: filesystem.mu must be locked. !rp.Done().
|
||||
func walkParentDirLocked(rp *vfs.ResolvingPath, d *dentry) (*directory, error) {
|
||||
func walkParentDirLocked(ctx context.Context, rp *vfs.ResolvingPath, d *dentry) (*directory, error) {
|
||||
for !rp.Final() {
|
||||
next, err := stepLocked(rp, d)
|
||||
next, err := stepLocked(ctx, rp, d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -118,10 +118,10 @@ func walkParentDirLocked(rp *vfs.ResolvingPath, d *dentry) (*directory, error) {
|
||||
// resolveLocked is loosely analogous to Linux's fs/namei.c:path_lookupat().
|
||||
//
|
||||
// Preconditions: filesystem.mu must be locked.
|
||||
func resolveLocked(rp *vfs.ResolvingPath) (*dentry, error) {
|
||||
func resolveLocked(ctx context.Context, rp *vfs.ResolvingPath) (*dentry, error) {
|
||||
d := rp.Start().Impl().(*dentry)
|
||||
for !rp.Done() {
|
||||
next, err := stepLocked(rp, d)
|
||||
next, err := stepLocked(ctx, rp, d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -141,10 +141,10 @@ func resolveLocked(rp *vfs.ResolvingPath) (*dentry, error) {
|
||||
//
|
||||
// Preconditions: !rp.Done(). For the final path component in rp,
|
||||
// !rp.ShouldFollowSymlink().
|
||||
func (fs *filesystem) doCreateAt(rp *vfs.ResolvingPath, dir bool, create func(parentDir *directory, name string) error) error {
|
||||
func (fs *filesystem) doCreateAt(ctx context.Context, rp *vfs.ResolvingPath, dir bool, create func(parentDir *directory, name string) error) error {
|
||||
fs.mu.Lock()
|
||||
defer fs.mu.Unlock()
|
||||
parentDir, err := walkParentDirLocked(rp, rp.Start().Impl().(*dentry))
|
||||
parentDir, err := walkParentDirLocked(ctx, rp, rp.Start().Impl().(*dentry))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func (fs *filesystem) doCreateAt(rp *vfs.ResolvingPath, dir bool, create func(pa
|
||||
if dir {
|
||||
ev |= linux.IN_ISDIR
|
||||
}
|
||||
parentDir.inode.watches.Notify(name, uint32(ev), 0, vfs.InodeEvent, false /* unlinked */)
|
||||
parentDir.inode.watches.Notify(ctx, name, uint32(ev), 0, vfs.InodeEvent, false /* unlinked */)
|
||||
parentDir.inode.touchCMtime()
|
||||
return nil
|
||||
}
|
||||
@@ -191,7 +191,7 @@ func (fs *filesystem) doCreateAt(rp *vfs.ResolvingPath, dir bool, create func(pa
|
||||
func (fs *filesystem) AccessAt(ctx context.Context, rp *vfs.ResolvingPath, creds *auth.Credentials, ats vfs.AccessTypes) error {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -202,7 +202,7 @@ func (fs *filesystem) AccessAt(ctx context.Context, rp *vfs.ResolvingPath, creds
|
||||
func (fs *filesystem) GetDentryAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.GetDentryOptions) (*vfs.Dentry, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -222,7 +222,7 @@ func (fs *filesystem) GetDentryAt(ctx context.Context, rp *vfs.ResolvingPath, op
|
||||
func (fs *filesystem) GetParentDentryAt(ctx context.Context, rp *vfs.ResolvingPath) (*vfs.Dentry, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
dir, err := walkParentDirLocked(rp, rp.Start().Impl().(*dentry))
|
||||
dir, err := walkParentDirLocked(ctx, rp, rp.Start().Impl().(*dentry))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -232,7 +232,7 @@ func (fs *filesystem) GetParentDentryAt(ctx context.Context, rp *vfs.ResolvingPa
|
||||
|
||||
// LinkAt implements vfs.FilesystemImpl.LinkAt.
|
||||
func (fs *filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.VirtualDentry) error {
|
||||
return fs.doCreateAt(rp, false /* dir */, func(parentDir *directory, name string) error {
|
||||
return fs.doCreateAt(ctx, rp, false /* dir */, func(parentDir *directory, name string) error {
|
||||
if rp.Mount() != vd.Mount() {
|
||||
return syserror.EXDEV
|
||||
}
|
||||
@@ -251,7 +251,7 @@ func (fs *filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.
|
||||
return syserror.EMLINK
|
||||
}
|
||||
i.incLinksLocked()
|
||||
i.watches.Notify("", linux.IN_ATTRIB, 0, vfs.InodeEvent, false /* unlinked */)
|
||||
i.watches.Notify(ctx, "", linux.IN_ATTRIB, 0, vfs.InodeEvent, false /* unlinked */)
|
||||
parentDir.insertChildLocked(fs.newDentry(i), name)
|
||||
return nil
|
||||
})
|
||||
@@ -259,7 +259,7 @@ func (fs *filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.
|
||||
|
||||
// MkdirAt implements vfs.FilesystemImpl.MkdirAt.
|
||||
func (fs *filesystem) MkdirAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.MkdirOptions) error {
|
||||
return fs.doCreateAt(rp, true /* dir */, func(parentDir *directory, name string) error {
|
||||
return fs.doCreateAt(ctx, rp, true /* dir */, func(parentDir *directory, name string) error {
|
||||
creds := rp.Credentials()
|
||||
if parentDir.inode.nlink == maxLinks {
|
||||
return syserror.EMLINK
|
||||
@@ -273,7 +273,7 @@ func (fs *filesystem) MkdirAt(ctx context.Context, rp *vfs.ResolvingPath, opts v
|
||||
|
||||
// MknodAt implements vfs.FilesystemImpl.MknodAt.
|
||||
func (fs *filesystem) MknodAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.MknodOptions) error {
|
||||
return fs.doCreateAt(rp, false /* dir */, func(parentDir *directory, name string) error {
|
||||
return fs.doCreateAt(ctx, rp, false /* dir */, func(parentDir *directory, name string) error {
|
||||
creds := rp.Credentials()
|
||||
var childInode *inode
|
||||
switch opts.Mode.FileType() {
|
||||
@@ -308,7 +308,7 @@ func (fs *filesystem) OpenAt(ctx context.Context, rp *vfs.ResolvingPath, opts vf
|
||||
if opts.Flags&linux.O_CREAT == 0 {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -330,7 +330,7 @@ func (fs *filesystem) OpenAt(ctx context.Context, rp *vfs.ResolvingPath, opts vf
|
||||
return start.open(ctx, rp, &opts, false /* afterCreate */)
|
||||
}
|
||||
afterTrailingSymlink:
|
||||
parentDir, err := walkParentDirLocked(rp, start)
|
||||
parentDir, err := walkParentDirLocked(ctx, rp, start)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -368,7 +368,7 @@ afterTrailingSymlink:
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
parentDir.inode.watches.Notify(name, linux.IN_CREATE, 0, vfs.PathEvent, false /* unlinked */)
|
||||
parentDir.inode.watches.Notify(ctx, name, linux.IN_CREATE, 0, vfs.PathEvent, false /* unlinked */)
|
||||
parentDir.inode.touchCMtime()
|
||||
return fd, nil
|
||||
}
|
||||
@@ -376,7 +376,7 @@ afterTrailingSymlink:
|
||||
return nil, syserror.EEXIST
|
||||
}
|
||||
// Is the file mounted over?
|
||||
if err := rp.CheckMount(&child.vfsd); err != nil {
|
||||
if err := rp.CheckMount(ctx, &child.vfsd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Do we need to resolve a trailing symlink?
|
||||
@@ -445,7 +445,7 @@ func (d *dentry) open(ctx context.Context, rp *vfs.ResolvingPath, opts *vfs.Open
|
||||
func (fs *filesystem) ReadlinkAt(ctx context.Context, rp *vfs.ResolvingPath) (string, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -467,7 +467,7 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa
|
||||
// Resolve newParent first to verify that it's on this Mount.
|
||||
fs.mu.Lock()
|
||||
defer fs.mu.Unlock()
|
||||
newParentDir, err := walkParentDirLocked(rp, rp.Start().Impl().(*dentry))
|
||||
newParentDir, err := walkParentDirLocked(ctx, rp, rp.Start().Impl().(*dentry))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -555,7 +555,7 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa
|
||||
}
|
||||
vfsObj := rp.VirtualFilesystem()
|
||||
mntns := vfs.MountNamespaceFromContext(ctx)
|
||||
defer mntns.DecRef()
|
||||
defer mntns.DecRef(ctx)
|
||||
var replacedVFSD *vfs.Dentry
|
||||
if replaced != nil {
|
||||
replacedVFSD = &replaced.vfsd
|
||||
@@ -566,17 +566,17 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa
|
||||
if replaced != nil {
|
||||
newParentDir.removeChildLocked(replaced)
|
||||
if replaced.inode.isDir() {
|
||||
newParentDir.inode.decLinksLocked() // from replaced's ".."
|
||||
newParentDir.inode.decLinksLocked(ctx) // from replaced's ".."
|
||||
}
|
||||
replaced.inode.decLinksLocked()
|
||||
replaced.inode.decLinksLocked(ctx)
|
||||
}
|
||||
oldParentDir.removeChildLocked(renamed)
|
||||
newParentDir.insertChildLocked(renamed, newName)
|
||||
vfsObj.CommitRenameReplaceDentry(&renamed.vfsd, replacedVFSD)
|
||||
vfsObj.CommitRenameReplaceDentry(ctx, &renamed.vfsd, replacedVFSD)
|
||||
oldParentDir.inode.touchCMtime()
|
||||
if oldParentDir != newParentDir {
|
||||
if renamed.inode.isDir() {
|
||||
oldParentDir.inode.decLinksLocked()
|
||||
oldParentDir.inode.decLinksLocked(ctx)
|
||||
newParentDir.inode.incLinksLocked()
|
||||
}
|
||||
newParentDir.inode.touchCMtime()
|
||||
@@ -591,7 +591,7 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa
|
||||
func (fs *filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error {
|
||||
fs.mu.Lock()
|
||||
defer fs.mu.Unlock()
|
||||
parentDir, err := walkParentDirLocked(rp, rp.Start().Impl().(*dentry))
|
||||
parentDir, err := walkParentDirLocked(ctx, rp, rp.Start().Impl().(*dentry))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -626,17 +626,17 @@ func (fs *filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error
|
||||
defer mnt.EndWrite()
|
||||
vfsObj := rp.VirtualFilesystem()
|
||||
mntns := vfs.MountNamespaceFromContext(ctx)
|
||||
defer mntns.DecRef()
|
||||
defer mntns.DecRef(ctx)
|
||||
if err := vfsObj.PrepareDeleteDentry(mntns, &child.vfsd); err != nil {
|
||||
return err
|
||||
}
|
||||
parentDir.removeChildLocked(child)
|
||||
parentDir.inode.watches.Notify(name, linux.IN_DELETE|linux.IN_ISDIR, 0, vfs.InodeEvent, true /* unlinked */)
|
||||
parentDir.inode.watches.Notify(ctx, name, linux.IN_DELETE|linux.IN_ISDIR, 0, vfs.InodeEvent, true /* unlinked */)
|
||||
// Remove links for child, child/., and child/..
|
||||
child.inode.decLinksLocked()
|
||||
child.inode.decLinksLocked()
|
||||
parentDir.inode.decLinksLocked()
|
||||
vfsObj.CommitDeleteDentry(&child.vfsd)
|
||||
child.inode.decLinksLocked(ctx)
|
||||
child.inode.decLinksLocked(ctx)
|
||||
parentDir.inode.decLinksLocked(ctx)
|
||||
vfsObj.CommitDeleteDentry(ctx, &child.vfsd)
|
||||
parentDir.inode.touchCMtime()
|
||||
return nil
|
||||
}
|
||||
@@ -644,7 +644,7 @@ func (fs *filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error
|
||||
// SetStatAt implements vfs.FilesystemImpl.SetStatAt.
|
||||
func (fs *filesystem) SetStatAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.SetStatOptions) error {
|
||||
fs.mu.RLock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
fs.mu.RUnlock()
|
||||
return err
|
||||
@@ -656,7 +656,7 @@ func (fs *filesystem) SetStatAt(ctx context.Context, rp *vfs.ResolvingPath, opts
|
||||
fs.mu.RUnlock()
|
||||
|
||||
if ev := vfs.InotifyEventFromStatMask(opts.Stat.Mask); ev != 0 {
|
||||
d.InotifyWithParent(ev, 0, vfs.InodeEvent)
|
||||
d.InotifyWithParent(ctx, ev, 0, vfs.InodeEvent)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -665,7 +665,7 @@ func (fs *filesystem) SetStatAt(ctx context.Context, rp *vfs.ResolvingPath, opts
|
||||
func (fs *filesystem) StatAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.StatOptions) (linux.Statx, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return linux.Statx{}, err
|
||||
}
|
||||
@@ -678,7 +678,7 @@ func (fs *filesystem) StatAt(ctx context.Context, rp *vfs.ResolvingPath, opts vf
|
||||
func (fs *filesystem) StatFSAt(ctx context.Context, rp *vfs.ResolvingPath) (linux.Statfs, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
if _, err := resolveLocked(rp); err != nil {
|
||||
if _, err := resolveLocked(ctx, rp); err != nil {
|
||||
return linux.Statfs{}, err
|
||||
}
|
||||
statfs := linux.Statfs{
|
||||
@@ -695,7 +695,7 @@ func (fs *filesystem) StatFSAt(ctx context.Context, rp *vfs.ResolvingPath) (linu
|
||||
|
||||
// SymlinkAt implements vfs.FilesystemImpl.SymlinkAt.
|
||||
func (fs *filesystem) SymlinkAt(ctx context.Context, rp *vfs.ResolvingPath, target string) error {
|
||||
return fs.doCreateAt(rp, false /* dir */, func(parentDir *directory, name string) error {
|
||||
return fs.doCreateAt(ctx, rp, false /* dir */, func(parentDir *directory, name string) error {
|
||||
creds := rp.Credentials()
|
||||
child := fs.newDentry(fs.newSymlink(creds.EffectiveKUID, creds.EffectiveKGID, 0777, target))
|
||||
parentDir.insertChildLocked(child, name)
|
||||
@@ -707,7 +707,7 @@ func (fs *filesystem) SymlinkAt(ctx context.Context, rp *vfs.ResolvingPath, targ
|
||||
func (fs *filesystem) UnlinkAt(ctx context.Context, rp *vfs.ResolvingPath) error {
|
||||
fs.mu.Lock()
|
||||
defer fs.mu.Unlock()
|
||||
parentDir, err := walkParentDirLocked(rp, rp.Start().Impl().(*dentry))
|
||||
parentDir, err := walkParentDirLocked(ctx, rp, rp.Start().Impl().(*dentry))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -738,7 +738,7 @@ func (fs *filesystem) UnlinkAt(ctx context.Context, rp *vfs.ResolvingPath) error
|
||||
defer mnt.EndWrite()
|
||||
vfsObj := rp.VirtualFilesystem()
|
||||
mntns := vfs.MountNamespaceFromContext(ctx)
|
||||
defer mntns.DecRef()
|
||||
defer mntns.DecRef(ctx)
|
||||
if err := vfsObj.PrepareDeleteDentry(mntns, &child.vfsd); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -746,11 +746,11 @@ func (fs *filesystem) UnlinkAt(ctx context.Context, rp *vfs.ResolvingPath) error
|
||||
// Generate inotify events. Note that this must take place before the link
|
||||
// count of the child is decremented, or else the watches may be dropped
|
||||
// before these events are added.
|
||||
vfs.InotifyRemoveChild(&child.inode.watches, &parentDir.inode.watches, name)
|
||||
vfs.InotifyRemoveChild(ctx, &child.inode.watches, &parentDir.inode.watches, name)
|
||||
|
||||
parentDir.removeChildLocked(child)
|
||||
child.inode.decLinksLocked()
|
||||
vfsObj.CommitDeleteDentry(&child.vfsd)
|
||||
child.inode.decLinksLocked(ctx)
|
||||
vfsObj.CommitDeleteDentry(ctx, &child.vfsd)
|
||||
parentDir.inode.touchCMtime()
|
||||
return nil
|
||||
}
|
||||
@@ -759,7 +759,7 @@ func (fs *filesystem) UnlinkAt(ctx context.Context, rp *vfs.ResolvingPath) error
|
||||
func (fs *filesystem) BoundEndpointAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.BoundEndpointOptions) (transport.BoundEndpoint, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -778,7 +778,7 @@ func (fs *filesystem) BoundEndpointAt(ctx context.Context, rp *vfs.ResolvingPath
|
||||
func (fs *filesystem) ListxattrAt(ctx context.Context, rp *vfs.ResolvingPath, size uint64) ([]string, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -789,7 +789,7 @@ func (fs *filesystem) ListxattrAt(ctx context.Context, rp *vfs.ResolvingPath, si
|
||||
func (fs *filesystem) GetxattrAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.GetxattrOptions) (string, error) {
|
||||
fs.mu.RLock()
|
||||
defer fs.mu.RUnlock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -799,7 +799,7 @@ func (fs *filesystem) GetxattrAt(ctx context.Context, rp *vfs.ResolvingPath, opt
|
||||
// SetxattrAt implements vfs.FilesystemImpl.SetxattrAt.
|
||||
func (fs *filesystem) SetxattrAt(ctx context.Context, rp *vfs.ResolvingPath, opts vfs.SetxattrOptions) error {
|
||||
fs.mu.RLock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
fs.mu.RUnlock()
|
||||
return err
|
||||
@@ -810,14 +810,14 @@ func (fs *filesystem) SetxattrAt(ctx context.Context, rp *vfs.ResolvingPath, opt
|
||||
}
|
||||
fs.mu.RUnlock()
|
||||
|
||||
d.InotifyWithParent(linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
d.InotifyWithParent(ctx, linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemovexattrAt implements vfs.FilesystemImpl.RemovexattrAt.
|
||||
func (fs *filesystem) RemovexattrAt(ctx context.Context, rp *vfs.ResolvingPath, name string) error {
|
||||
fs.mu.RLock()
|
||||
d, err := resolveLocked(rp)
|
||||
d, err := resolveLocked(ctx, rp)
|
||||
if err != nil {
|
||||
fs.mu.RUnlock()
|
||||
return err
|
||||
@@ -828,7 +828,7 @@ func (fs *filesystem) RemovexattrAt(ctx context.Context, rp *vfs.ResolvingPath,
|
||||
}
|
||||
fs.mu.RUnlock()
|
||||
|
||||
d.InotifyWithParent(linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
d.InotifyWithParent(ctx, linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ const fileName = "mypipe"
|
||||
|
||||
func TestSeparateFDs(t *testing.T) {
|
||||
ctx, creds, vfsObj, root := setup(t)
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
|
||||
// Open the read side. This is done in a concurrently because opening
|
||||
// One end the pipe blocks until the other end is opened.
|
||||
@@ -55,13 +55,13 @@ func TestSeparateFDs(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pipe for writing %q: %v", fileName, err)
|
||||
}
|
||||
defer wfd.DecRef()
|
||||
defer wfd.DecRef(ctx)
|
||||
|
||||
rfd, ok := <-rfdchan
|
||||
if !ok {
|
||||
t.Fatalf("failed to open pipe for reading %q", fileName)
|
||||
}
|
||||
defer rfd.DecRef()
|
||||
defer rfd.DecRef(ctx)
|
||||
|
||||
const msg = "vamos azul"
|
||||
checkEmpty(ctx, t, rfd)
|
||||
@@ -71,7 +71,7 @@ func TestSeparateFDs(t *testing.T) {
|
||||
|
||||
func TestNonblockingRead(t *testing.T) {
|
||||
ctx, creds, vfsObj, root := setup(t)
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
|
||||
// Open the read side as nonblocking.
|
||||
pop := vfs.PathOperation{
|
||||
@@ -85,7 +85,7 @@ func TestNonblockingRead(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pipe for reading %q: %v", fileName, err)
|
||||
}
|
||||
defer rfd.DecRef()
|
||||
defer rfd.DecRef(ctx)
|
||||
|
||||
// Open the write side.
|
||||
openOpts = vfs.OpenOptions{Flags: linux.O_WRONLY}
|
||||
@@ -93,7 +93,7 @@ func TestNonblockingRead(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pipe for writing %q: %v", fileName, err)
|
||||
}
|
||||
defer wfd.DecRef()
|
||||
defer wfd.DecRef(ctx)
|
||||
|
||||
const msg = "geh blau"
|
||||
checkEmpty(ctx, t, rfd)
|
||||
@@ -103,7 +103,7 @@ func TestNonblockingRead(t *testing.T) {
|
||||
|
||||
func TestNonblockingWriteError(t *testing.T) {
|
||||
ctx, creds, vfsObj, root := setup(t)
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
|
||||
// Open the write side as nonblocking, which should return ENXIO.
|
||||
pop := vfs.PathOperation{
|
||||
@@ -121,7 +121,7 @@ func TestNonblockingWriteError(t *testing.T) {
|
||||
|
||||
func TestSingleFD(t *testing.T) {
|
||||
ctx, creds, vfsObj, root := setup(t)
|
||||
defer root.DecRef()
|
||||
defer root.DecRef(ctx)
|
||||
|
||||
// Open the pipe as readable and writable.
|
||||
pop := vfs.PathOperation{
|
||||
@@ -135,7 +135,7 @@ func TestSingleFD(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pipe for writing %q: %v", fileName, err)
|
||||
}
|
||||
defer fd.DecRef()
|
||||
defer fd.DecRef(ctx)
|
||||
|
||||
const msg = "forza blu"
|
||||
checkEmpty(ctx, t, fd)
|
||||
@@ -152,7 +152,7 @@ func setup(t *testing.T) (context.Context, *auth.Credentials, *vfs.VirtualFilesy
|
||||
|
||||
// Create VFS.
|
||||
vfsObj := &vfs.VirtualFilesystem{}
|
||||
if err := vfsObj.Init(); err != nil {
|
||||
if err := vfsObj.Init(ctx); err != nil {
|
||||
t.Fatalf("VFS init: %v", err)
|
||||
}
|
||||
vfsObj.MustRegisterFilesystemType("tmpfs", FilesystemType{}, &vfs.RegisterFilesystemTypeOptions{
|
||||
|
||||
@@ -270,7 +270,7 @@ type regularFileFD struct {
|
||||
}
|
||||
|
||||
// Release implements vfs.FileDescriptionImpl.Release.
|
||||
func (fd *regularFileFD) Release() {
|
||||
func (fd *regularFileFD) Release(context.Context) {
|
||||
// noop
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt
|
||||
case linux.S_IFDIR:
|
||||
root = &fs.newDirectory(rootKUID, rootKGID, rootMode).dentry
|
||||
default:
|
||||
fs.vfsfs.DecRef()
|
||||
fs.vfsfs.DecRef(ctx)
|
||||
return nil, nil, fmt.Errorf("invalid tmpfs root file type: %#o", rootFileType)
|
||||
}
|
||||
return &fs.vfsfs, &root.vfsd, nil
|
||||
@@ -197,7 +197,7 @@ func NewFilesystem(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *au
|
||||
}
|
||||
|
||||
// Release implements vfs.FilesystemImpl.Release.
|
||||
func (fs *filesystem) Release() {
|
||||
func (fs *filesystem) Release(ctx context.Context) {
|
||||
fs.vfsfs.VirtualFilesystem().PutAnonBlockDevMinor(fs.devMinor)
|
||||
}
|
||||
|
||||
@@ -249,12 +249,12 @@ func (d *dentry) TryIncRef() bool {
|
||||
}
|
||||
|
||||
// DecRef implements vfs.DentryImpl.DecRef.
|
||||
func (d *dentry) DecRef() {
|
||||
d.inode.decRef()
|
||||
func (d *dentry) DecRef(ctx context.Context) {
|
||||
d.inode.decRef(ctx)
|
||||
}
|
||||
|
||||
// InotifyWithParent implements vfs.DentryImpl.InotifyWithParent.
|
||||
func (d *dentry) InotifyWithParent(events, cookie uint32, et vfs.EventType) {
|
||||
func (d *dentry) InotifyWithParent(ctx context.Context, events, cookie uint32, et vfs.EventType) {
|
||||
if d.inode.isDir() {
|
||||
events |= linux.IN_ISDIR
|
||||
}
|
||||
@@ -266,9 +266,9 @@ func (d *dentry) InotifyWithParent(events, cookie uint32, et vfs.EventType) {
|
||||
d.inode.fs.mu.RLock()
|
||||
// The ordering below is important, Linux always notifies the parent first.
|
||||
if d.parent != nil {
|
||||
d.parent.inode.watches.Notify(d.name, events, cookie, et, deleted)
|
||||
d.parent.inode.watches.Notify(ctx, d.name, events, cookie, et, deleted)
|
||||
}
|
||||
d.inode.watches.Notify("", events, cookie, et, deleted)
|
||||
d.inode.watches.Notify(ctx, "", events, cookie, et, deleted)
|
||||
d.inode.fs.mu.RUnlock()
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ func (d *dentry) Watches() *vfs.Watches {
|
||||
}
|
||||
|
||||
// OnZeroWatches implements vfs.Dentry.OnZeroWatches.
|
||||
func (d *dentry) OnZeroWatches() {}
|
||||
func (d *dentry) OnZeroWatches(context.Context) {}
|
||||
|
||||
// inode represents a filesystem object.
|
||||
type inode struct {
|
||||
@@ -359,12 +359,12 @@ func (i *inode) incLinksLocked() {
|
||||
// remove a reference on i as well.
|
||||
//
|
||||
// Preconditions: filesystem.mu must be locked for writing. i.nlink != 0.
|
||||
func (i *inode) decLinksLocked() {
|
||||
func (i *inode) decLinksLocked(ctx context.Context) {
|
||||
if i.nlink == 0 {
|
||||
panic("tmpfs.inode.decLinksLocked() called with no existing links")
|
||||
}
|
||||
if atomic.AddUint32(&i.nlink, ^uint32(0)) == 0 {
|
||||
i.decRef()
|
||||
i.decRef(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,9 +386,9 @@ func (i *inode) tryIncRef() bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *inode) decRef() {
|
||||
func (i *inode) decRef(ctx context.Context) {
|
||||
if refs := atomic.AddInt64(&i.refs, -1); refs == 0 {
|
||||
i.watches.HandleDeletion()
|
||||
i.watches.HandleDeletion(ctx)
|
||||
if regFile, ok := i.impl.(*regularFile); ok {
|
||||
// Release memory used by regFile to store data. Since regFile is
|
||||
// no longer usable, we don't need to grab any locks or update any
|
||||
@@ -701,7 +701,7 @@ func (fd *fileDescription) SetStat(ctx context.Context, opts vfs.SetStatOptions)
|
||||
}
|
||||
|
||||
if ev := vfs.InotifyEventFromStatMask(opts.Stat.Mask); ev != 0 {
|
||||
d.InotifyWithParent(ev, 0, vfs.InodeEvent)
|
||||
d.InotifyWithParent(ctx, ev, 0, vfs.InodeEvent)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -724,7 +724,7 @@ func (fd *fileDescription) Setxattr(ctx context.Context, opts vfs.SetxattrOption
|
||||
}
|
||||
|
||||
// Generate inotify events.
|
||||
d.InotifyWithParent(linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
d.InotifyWithParent(ctx, linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -736,13 +736,13 @@ func (fd *fileDescription) Removexattr(ctx context.Context, name string) error {
|
||||
}
|
||||
|
||||
// Generate inotify events.
|
||||
d.InotifyWithParent(linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
d.InotifyWithParent(ctx, linux.IN_ATTRIB, 0, vfs.InodeEvent)
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewMemfd creates a new tmpfs regular file and file description that can back
|
||||
// an anonymous fd created by memfd_create.
|
||||
func NewMemfd(mount *vfs.Mount, creds *auth.Credentials, allowSeals bool, name string) (*vfs.FileDescription, error) {
|
||||
func NewMemfd(ctx context.Context, creds *auth.Credentials, mount *vfs.Mount, allowSeals bool, name string) (*vfs.FileDescription, error) {
|
||||
fs, ok := mount.Filesystem().Impl().(*filesystem)
|
||||
if !ok {
|
||||
panic("NewMemfd() called with non-tmpfs mount")
|
||||
@@ -757,7 +757,7 @@ func NewMemfd(mount *vfs.Mount, creds *auth.Credentials, allowSeals bool, name s
|
||||
}
|
||||
|
||||
d := fs.newDentry(inode)
|
||||
defer d.DecRef()
|
||||
defer d.DecRef(ctx)
|
||||
d.name = name
|
||||
|
||||
// Per Linux, mm/shmem.c:__shmem_file_setup(), memfd files are set up with
|
||||
|
||||
@@ -34,7 +34,7 @@ func newTmpfsRoot(ctx context.Context) (*vfs.VirtualFilesystem, vfs.VirtualDentr
|
||||
creds := auth.CredentialsFromContext(ctx)
|
||||
|
||||
vfsObj := &vfs.VirtualFilesystem{}
|
||||
if err := vfsObj.Init(); err != nil {
|
||||
if err := vfsObj.Init(ctx); err != nil {
|
||||
return nil, vfs.VirtualDentry{}, nil, fmt.Errorf("VFS init: %v", err)
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ func newTmpfsRoot(ctx context.Context) (*vfs.VirtualFilesystem, vfs.VirtualDentr
|
||||
}
|
||||
root := mntns.Root()
|
||||
return vfsObj, root, func() {
|
||||
root.DecRef()
|
||||
mntns.DecRef()
|
||||
root.DecRef(ctx)
|
||||
mntns.DecRef(ctx)
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user