summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/fuse/fusefs.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-09-21 21:51:32 +0000
committergVisor bot <gvisor-bot@google.com>2020-09-21 21:51:32 +0000
commit3ad7c376eba1b00ddf2a9c3907f5fa12edf137c8 (patch)
tree37c9ec625932dd37ad983e79a0f644b696948383 /pkg/sentry/fsimpl/fuse/fusefs.go
parentcfe23681046fdf67b4423ecbf797a084802eb1a1 (diff)
parent10dcefbc77815314d56e45f01b8c9986a2c56778 (diff)
Merge release-20200914.0-124-g10dcefbc7 (automated)
Diffstat (limited to 'pkg/sentry/fsimpl/fuse/fusefs.go')
-rw-r--r--pkg/sentry/fsimpl/fuse/fusefs.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/pkg/sentry/fsimpl/fuse/fusefs.go b/pkg/sentry/fsimpl/fuse/fusefs.go
index b3573f80d..2144e72bd 100644
--- a/pkg/sentry/fsimpl/fuse/fusefs.go
+++ b/pkg/sentry/fsimpl/fuse/fusefs.go
@@ -402,7 +402,7 @@ func (i *inode) Open(ctx context.Context, rp *vfs.ResolvingPath, vfsd *vfs.Dentr
}
// Lookup implements kernfs.Inode.Lookup.
-func (i *inode) Lookup(ctx context.Context, name string) (*vfs.Dentry, error) {
+func (i *inode) Lookup(ctx context.Context, name string) (*kernfs.Dentry, error) {
in := linux.FUSELookupIn{Name: name}
return i.newEntry(ctx, name, 0, linux.FUSE_LOOKUP, &in)
}
@@ -432,7 +432,11 @@ func (i *inode) NewFile(ctx context.Context, name string, opts vfs.OpenOptions)
},
Name: name,
}
- return i.newEntry(ctx, name, linux.S_IFREG, linux.FUSE_CREATE, &in)
+ d, err := i.newEntry(ctx, name, linux.S_IFREG, linux.FUSE_CREATE, &in)
+ if err != nil {
+ return nil, err
+ }
+ return d.VFSDentry(), nil
}
// NewNode implements kernfs.Inode.NewNode.
@@ -445,7 +449,11 @@ func (i *inode) NewNode(ctx context.Context, name string, opts vfs.MknodOptions)
},
Name: name,
}
- return i.newEntry(ctx, name, opts.Mode.FileType(), linux.FUSE_MKNOD, &in)
+ d, err := i.newEntry(ctx, name, opts.Mode.FileType(), linux.FUSE_MKNOD, &in)
+ if err != nil {
+ return nil, err
+ }
+ return d.VFSDentry(), nil
}
// NewSymlink implements kernfs.Inode.NewSymlink.
@@ -454,7 +462,11 @@ func (i *inode) NewSymlink(ctx context.Context, name, target string) (*vfs.Dentr
Name: name,
Target: target,
}
- return i.newEntry(ctx, name, linux.S_IFLNK, linux.FUSE_SYMLINK, &in)
+ d, err := i.newEntry(ctx, name, linux.S_IFLNK, linux.FUSE_SYMLINK, &in)
+ if err != nil {
+ return nil, err
+ }
+ return d.VFSDentry(), nil
}
// Unlink implements kernfs.Inode.Unlink.
@@ -489,7 +501,11 @@ func (i *inode) NewDir(ctx context.Context, name string, opts vfs.MkdirOptions)
},
Name: name,
}
- return i.newEntry(ctx, name, linux.S_IFDIR, linux.FUSE_MKDIR, &in)
+ d, err := i.newEntry(ctx, name, linux.S_IFDIR, linux.FUSE_MKDIR, &in)
+ if err != nil {
+ return nil, err
+ }
+ return d.VFSDentry(), nil
}
// RmDir implements kernfs.Inode.RmDir.
@@ -521,7 +537,7 @@ func (i *inode) RmDir(ctx context.Context, name string, child *vfs.Dentry) error
// newEntry calls FUSE server for entry creation and allocates corresponding entry according to response.
// Shared by FUSE_MKNOD, FUSE_MKDIR, FUSE_SYMLINK, FUSE_LINK and FUSE_LOOKUP.
-func (i *inode) newEntry(ctx context.Context, name string, fileType linux.FileMode, opcode linux.FUSEOpcode, payload marshal.Marshallable) (*vfs.Dentry, error) {
+func (i *inode) newEntry(ctx context.Context, name string, fileType linux.FileMode, opcode linux.FUSEOpcode, payload marshal.Marshallable) (*kernfs.Dentry, error) {
kernelTask := kernel.TaskFromContext(ctx)
if kernelTask == nil {
log.Warningf("fusefs.Inode.newEntry: couldn't get kernel task from context", i.nodeID)
@@ -551,7 +567,7 @@ func (i *inode) newEntry(ctx context.Context, name string, fileType linux.FileMo
} else {
i.dentry.InsertChild(name, child)
}
- return child.VFSDentry(), nil
+ return child, nil
}
// Getlink implements kernfs.Inode.Getlink.