summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/sockfs
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-04-27 23:05:22 +0000
committergVisor bot <gvisor-bot@google.com>2020-04-27 23:05:22 +0000
commitfe0e756ca8cca14bd299659e4cb43b4262980bb1 (patch)
tree0ce3a9aaea6c9c52bc675a816cf39aa7f0466bb1 /pkg/sentry/fsimpl/sockfs
parent6e672a4a9f5947562f6557c9d0997fa2bedd6b59 (diff)
parent1c2ecbb1a03ffaa3bcdb2ee69c879da5e7076fa5 (diff)
Merge release-20200413.0-7-g1c2ecbb (automated)
Diffstat (limited to 'pkg/sentry/fsimpl/sockfs')
-rwxr-xr-xpkg/sentry/fsimpl/sockfs/sockfs.go20
1 files changed, 4 insertions, 16 deletions
diff --git a/pkg/sentry/fsimpl/sockfs/sockfs.go b/pkg/sentry/fsimpl/sockfs/sockfs.go
index 5ce50625b..271134af8 100755
--- a/pkg/sentry/fsimpl/sockfs/sockfs.go
+++ b/pkg/sentry/fsimpl/sockfs/sockfs.go
@@ -73,26 +73,14 @@ func (i *inode) Open(ctx context.Context, rp *vfs.ResolvingPath, vfsd *vfs.Dentr
return nil, syserror.ENXIO
}
-// InitSocket initializes a socket FileDescription, with a corresponding
-// Dentry in mnt.
-//
-// fd should be the FileDescription associated with socketImpl, i.e. its first
-// field. mnt should be the global socket mount, Kernel.socketMount.
-func InitSocket(socketImpl vfs.FileDescriptionImpl, fd *vfs.FileDescription, mnt *vfs.Mount, creds *auth.Credentials) error {
- fsimpl := mnt.Filesystem().Impl()
- fs := fsimpl.(*kernfs.Filesystem)
-
+// NewDentry constructs and returns a sockfs dentry.
+func NewDentry(creds *auth.Credentials, ino uint64) *vfs.Dentry {
// File mode matches net/socket.c:sock_alloc.
filemode := linux.FileMode(linux.S_IFSOCK | 0600)
i := &inode{}
- i.Init(creds, fs.NextIno(), filemode)
+ i.Init(creds, ino, filemode)
d := &kernfs.Dentry{}
d.Init(i)
-
- opts := &vfs.FileDescriptionOptions{UseDentryMetadata: true}
- if err := fd.Init(socketImpl, linux.O_RDWR, mnt, d.VFSDentry(), opts); err != nil {
- return err
- }
- return nil
+ return d.VFSDentry()
}