From a63db7d90303280de9431f369e5a9c8db351a9e8 Mon Sep 17 00:00:00 2001 From: Ridwan Sharif Date: Wed, 17 Jun 2020 16:23:27 -0400 Subject: Moved FUSE device under the fuse directory --- runsc/boot/BUILD | 1 + runsc/boot/vfs.go | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'runsc') diff --git a/runsc/boot/BUILD b/runsc/boot/BUILD index 45d7f7d09..aad2a41de 100644 --- a/runsc/boot/BUILD +++ b/runsc/boot/BUILD @@ -55,6 +55,7 @@ go_library( "//pkg/sentry/fs/user", "//pkg/sentry/fsimpl/devpts", "//pkg/sentry/fsimpl/devtmpfs", + "//pkg/sentry/fsimpl/fuse", "//pkg/sentry/fsimpl/gofer", "//pkg/sentry/fsimpl/host", "//pkg/sentry/fsimpl/overlay", diff --git a/runsc/boot/vfs.go b/runsc/boot/vfs.go index 9ba5e9cd9..0f5ad1e05 100644 --- a/runsc/boot/vfs.go +++ b/runsc/boot/vfs.go @@ -31,6 +31,7 @@ import ( "gvisor.dev/gvisor/pkg/sentry/fs/user" "gvisor.dev/gvisor/pkg/sentry/fsimpl/devpts" "gvisor.dev/gvisor/pkg/sentry/fsimpl/devtmpfs" + "gvisor.dev/gvisor/pkg/sentry/fsimpl/fuse" "gvisor.dev/gvisor/pkg/sentry/fsimpl/gofer" "gvisor.dev/gvisor/pkg/sentry/fsimpl/overlay" "gvisor.dev/gvisor/pkg/sentry/fsimpl/proc" @@ -79,6 +80,9 @@ func registerFilesystems(ctx context.Context, vfsObj *vfs.VirtualFilesystem, cre } if err := ttydev.Register(vfsObj); err != nil { return fmt.Errorf("registering ttydev: %w", err) + + if err := fuse.Register(vfsObj); err != nil { + return fmt.Errorf("registering /dev/fuse: %w", err) } if err := tundev.Register(vfsObj); err != nil { return fmt.Errorf("registering tundev: %v", err) @@ -101,6 +105,9 @@ func registerFilesystems(ctx context.Context, vfsObj *vfs.VirtualFilesystem, cre if err := tundev.CreateDevtmpfsFiles(ctx, a); err != nil { return fmt.Errorf("creating tundev devtmpfs files: %v", err) } + if err := fuse.CreateDevtmpfsFile(ctx, a); err != nil { + return fmt.Errorf("creating devtmpfs fuse device file: %w", err) + } return nil } -- cgit v1.2.3 From 2828806fb015bbbec0f4a48670d1eb048f21099a Mon Sep 17 00:00:00 2001 From: Ridwan Sharif Date: Tue, 23 Jun 2020 14:25:38 -0400 Subject: Test that the fuse device can be opened --- runsc/boot/vfs.go | 5 +++-- test/syscalls/linux/dev.cc | 29 ++++++++--------------------- 2 files changed, 11 insertions(+), 23 deletions(-) (limited to 'runsc') diff --git a/runsc/boot/vfs.go b/runsc/boot/vfs.go index 0f5ad1e05..b68117867 100644 --- a/runsc/boot/vfs.go +++ b/runsc/boot/vfs.go @@ -80,9 +80,10 @@ func registerFilesystems(ctx context.Context, vfsObj *vfs.VirtualFilesystem, cre } if err := ttydev.Register(vfsObj); err != nil { return fmt.Errorf("registering ttydev: %w", err) + } if err := fuse.Register(vfsObj); err != nil { - return fmt.Errorf("registering /dev/fuse: %w", err) + return fmt.Errorf("registering fusedev: %w", err) } if err := tundev.Register(vfsObj); err != nil { return fmt.Errorf("registering tundev: %v", err) @@ -106,7 +107,7 @@ func registerFilesystems(ctx context.Context, vfsObj *vfs.VirtualFilesystem, cre return fmt.Errorf("creating tundev devtmpfs files: %v", err) } if err := fuse.CreateDevtmpfsFile(ctx, a); err != nil { - return fmt.Errorf("creating devtmpfs fuse device file: %w", err) + return fmt.Errorf("creating fusedev devtmpfs files: %w", err) } return nil } diff --git a/test/syscalls/linux/dev.cc b/test/syscalls/linux/dev.cc index 6be173c14..3c88c4cbd 100644 --- a/test/syscalls/linux/dev.cc +++ b/test/syscalls/linux/dev.cc @@ -146,34 +146,21 @@ TEST(DevTest, WriteDevFull) { EXPECT_THAT(WriteFd(fd.get(), "a", 1), SyscallFailsWithErrno(ENOSPC)); } -TEST(DevTest, ReadDevFuse) { - SKIP_IF(IsRunningWithVFS1()); - - const FileDescriptor fd = - ASSERT_NO_ERRNO_AND_VALUE(Open("/dev/fuse", O_RDONLY)); - std::vector buf(1); - EXPECT_THAT(ReadFd(fd.get(), buf.data(), sizeof(buf)), SyscallFailsWithErrno(ENOSYS)); -} - -TEST(DevTest, WriteDevFuse) { - SKIP_IF(IsRunningWithVFS1()); - - const FileDescriptor fd = - ASSERT_NO_ERRNO_AND_VALUE(Open("/dev/fuse", O_WRONLY)); - const char* testStr = "test"; - EXPECT_THAT(WriteFd(fd.get(), testStr, sizeof(testStr)), SyscallFailsWithErrno(ENOSYS)); -} - TEST(DevTest, TTYExists) { - // Run test if running on VFS1 or on Linux. - SKIP_IF(!IsRunningWithVFS1() && IsRunningOnGvisor()); - struct stat statbuf = {}; ASSERT_THAT(stat("/dev/tty", &statbuf), SyscallSucceeds()); // Check that it's a character device with rw-rw-rw- permissions. EXPECT_EQ(statbuf.st_mode, S_IFCHR | 0666); } +TEST(DevTest, OpenDevFuse) { + // Note(gvisor.dev/issue/3076) This won't work in the sentry until the new + // device registration is complete. + SKIP_IF(IsRunningWithVFS1() || IsRunningOnGvisor()); + + ASSERT_NO_ERRNO_AND_VALUE(Open("/dev/fuse", O_RDONLY)); +} + } // namespace } // namespace testing -- cgit v1.2.3