From 7b8f19dc76a9fecbf4d2e5f43a47c6d47d53e100 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Tue, 26 Oct 2021 16:57:12 -0700 Subject: Simplify vfs.NewDisconnectedMount signature and callpoints. vfs.NewDisconnectedMount has no error paths. Its much prettier without the error return value. Also simplify MountDisconnected which would immediately drop the refs taken by NewDisconnectedMount. Instead make it directly call newMount. PiperOrigin-RevId: 405767966 --- pkg/sentry/kernel/kernel.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'pkg/sentry/kernel') diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index d4851ccda..83299a9fb 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -418,10 +418,7 @@ func (k *Kernel) Init(args InitKernelArgs) error { return fmt.Errorf("failed to create pipefs filesystem: %v", err) } defer pipeFilesystem.DecRef(ctx) - pipeMount, err := k.vfs.NewDisconnectedMount(pipeFilesystem, nil, &vfs.MountOptions{}) - if err != nil { - return fmt.Errorf("failed to create pipefs mount: %v", err) - } + pipeMount := k.vfs.NewDisconnectedMount(pipeFilesystem, nil, &vfs.MountOptions{}) k.pipeMount = pipeMount tmpfsFilesystem, tmpfsRoot, err := tmpfs.NewFilesystem(ctx, &k.vfs, auth.NewRootCredentials(k.rootUserNamespace)) @@ -430,22 +427,14 @@ func (k *Kernel) Init(args InitKernelArgs) error { } defer tmpfsFilesystem.DecRef(ctx) defer tmpfsRoot.DecRef(ctx) - shmMount, err := k.vfs.NewDisconnectedMount(tmpfsFilesystem, tmpfsRoot, &vfs.MountOptions{}) - if err != nil { - return fmt.Errorf("failed to create tmpfs mount: %v", err) - } - k.shmMount = shmMount + k.shmMount = k.vfs.NewDisconnectedMount(tmpfsFilesystem, tmpfsRoot, &vfs.MountOptions{}) socketFilesystem, err := sockfs.NewFilesystem(&k.vfs) if err != nil { return fmt.Errorf("failed to create sockfs filesystem: %v", err) } defer socketFilesystem.DecRef(ctx) - socketMount, err := k.vfs.NewDisconnectedMount(socketFilesystem, nil, &vfs.MountOptions{}) - if err != nil { - return fmt.Errorf("failed to create sockfs mount: %v", err) - } - k.socketMount = socketMount + k.socketMount = k.vfs.NewDisconnectedMount(socketFilesystem, nil, &vfs.MountOptions{}) k.socketsVFS2 = make(map[*vfs.FileDescription]*SocketRecord) -- cgit v1.2.3