diff options
author | Ayush Ranjan <ayushranjan@google.com> | 2019-07-11 15:04:23 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-07-11 15:05:36 -0700 |
commit | 5242face2eea968f5e3f367f7edfebdd3ae60430 (patch) | |
tree | d9f257d50b35fa179542300e8b9c98634952ac54 /pkg | |
parent | a018b229b57dff92ca0d99079180aa556dacbabc (diff) |
ext: boilerplate code.
Renamed ext4 to ext since we are targeting ext(2/3/4).
Removed fs.go since we are targeting VFS2.
Added ext.go with filesystem struct.
PiperOrigin-RevId: 257689775
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/fs/ext/BUILD | 11 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/BUILD (renamed from pkg/sentry/fs/ext4/disklayout/BUILD) | 3 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/block_group.go (renamed from pkg/sentry/fs/ext4/disklayout/block_group.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/block_group_32.go (renamed from pkg/sentry/fs/ext4/disklayout/block_group_32.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/block_group_64.go (renamed from pkg/sentry/fs/ext4/disklayout/block_group_64.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/block_group_test.go (renamed from pkg/sentry/fs/ext4/disklayout/block_group_test.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/dirent.go (renamed from pkg/sentry/fs/ext4/disklayout/dirent.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/dirent_new.go (renamed from pkg/sentry/fs/ext4/disklayout/dirent_new.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/dirent_old.go (renamed from pkg/sentry/fs/ext4/disklayout/dirent_old.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/dirent_test.go (renamed from pkg/sentry/fs/ext4/disklayout/dirent_test.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/disklayout.go (renamed from pkg/sentry/fs/ext4/disklayout/disklayout.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/inode.go (renamed from pkg/sentry/fs/ext4/disklayout/inode.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/inode_new.go (renamed from pkg/sentry/fs/ext4/disklayout/inode_new.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/inode_old.go (renamed from pkg/sentry/fs/ext4/disklayout/inode_old.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/inode_test.go (renamed from pkg/sentry/fs/ext4/disklayout/inode_test.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/superblock.go (renamed from pkg/sentry/fs/ext4/disklayout/superblock.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/superblock_32.go (renamed from pkg/sentry/fs/ext4/disklayout/superblock_32.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/superblock_64.go (renamed from pkg/sentry/fs/ext4/disklayout/superblock_64.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/superblock_old.go (renamed from pkg/sentry/fs/ext4/disklayout/superblock_old.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/superblock_test.go (renamed from pkg/sentry/fs/ext4/disklayout/superblock_test.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/disklayout/test_utils.go (renamed from pkg/sentry/fs/ext4/disklayout/test_utils.go) | 0 | ||||
-rw-r--r-- | pkg/sentry/fs/ext/ext.go | 49 | ||||
-rw-r--r-- | pkg/sentry/fs/ext4/BUILD | 14 | ||||
-rw-r--r-- | pkg/sentry/fs/ext4/fs.go | 61 |
24 files changed, 62 insertions, 76 deletions
diff --git a/pkg/sentry/fs/ext/BUILD b/pkg/sentry/fs/ext/BUILD new file mode 100644 index 000000000..3c2a02eac --- /dev/null +++ b/pkg/sentry/fs/ext/BUILD @@ -0,0 +1,11 @@ +package(licenses = ["notice"]) + +load("//tools/go_stateify:defs.bzl", "go_library") + +go_library( + name = "ext", + srcs = ["ext.go"], + importpath = "gvisor.dev/gvisor/pkg/sentry/fs/ext", + visibility = ["//pkg/sentry:internal"], + deps = ["//pkg/sentry/fs/ext/disklayout"], +) diff --git a/pkg/sentry/fs/ext4/disklayout/BUILD b/pkg/sentry/fs/ext/disklayout/BUILD index 2920bfb52..e4cb26645 100644 --- a/pkg/sentry/fs/ext4/disklayout/BUILD +++ b/pkg/sentry/fs/ext/disklayout/BUILD @@ -21,7 +21,8 @@ go_library( "superblock_old.go", "test_utils.go", ], - importpath = "gvisor.dev/gvisor/pkg/sentry/fs/ext4/disklayout", + importpath = "gvisor.dev/gvisor/pkg/sentry/fs/ext/disklayout", + visibility = ["//pkg/sentry:internal"], deps = [ "//pkg/abi/linux", "//pkg/binary", diff --git a/pkg/sentry/fs/ext4/disklayout/block_group.go b/pkg/sentry/fs/ext/disklayout/block_group.go index 32ea3d97d..32ea3d97d 100644 --- a/pkg/sentry/fs/ext4/disklayout/block_group.go +++ b/pkg/sentry/fs/ext/disklayout/block_group.go diff --git a/pkg/sentry/fs/ext4/disklayout/block_group_32.go b/pkg/sentry/fs/ext/disklayout/block_group_32.go index 3e16c76db..3e16c76db 100644 --- a/pkg/sentry/fs/ext4/disklayout/block_group_32.go +++ b/pkg/sentry/fs/ext/disklayout/block_group_32.go diff --git a/pkg/sentry/fs/ext4/disklayout/block_group_64.go b/pkg/sentry/fs/ext/disklayout/block_group_64.go index 9a809197a..9a809197a 100644 --- a/pkg/sentry/fs/ext4/disklayout/block_group_64.go +++ b/pkg/sentry/fs/ext/disklayout/block_group_64.go diff --git a/pkg/sentry/fs/ext4/disklayout/block_group_test.go b/pkg/sentry/fs/ext/disklayout/block_group_test.go index 0ef4294c0..0ef4294c0 100644 --- a/pkg/sentry/fs/ext4/disklayout/block_group_test.go +++ b/pkg/sentry/fs/ext/disklayout/block_group_test.go diff --git a/pkg/sentry/fs/ext4/disklayout/dirent.go b/pkg/sentry/fs/ext/disklayout/dirent.go index 685bf57b8..685bf57b8 100644 --- a/pkg/sentry/fs/ext4/disklayout/dirent.go +++ b/pkg/sentry/fs/ext/disklayout/dirent.go diff --git a/pkg/sentry/fs/ext4/disklayout/dirent_new.go b/pkg/sentry/fs/ext/disklayout/dirent_new.go index 29ae4a5c2..29ae4a5c2 100644 --- a/pkg/sentry/fs/ext4/disklayout/dirent_new.go +++ b/pkg/sentry/fs/ext/disklayout/dirent_new.go diff --git a/pkg/sentry/fs/ext4/disklayout/dirent_old.go b/pkg/sentry/fs/ext/disklayout/dirent_old.go index 2e0f9c812..2e0f9c812 100644 --- a/pkg/sentry/fs/ext4/disklayout/dirent_old.go +++ b/pkg/sentry/fs/ext/disklayout/dirent_old.go diff --git a/pkg/sentry/fs/ext4/disklayout/dirent_test.go b/pkg/sentry/fs/ext/disklayout/dirent_test.go index cc6dff2c9..cc6dff2c9 100644 --- a/pkg/sentry/fs/ext4/disklayout/dirent_test.go +++ b/pkg/sentry/fs/ext/disklayout/dirent_test.go diff --git a/pkg/sentry/fs/ext4/disklayout/disklayout.go b/pkg/sentry/fs/ext/disklayout/disklayout.go index bdf4e2132..bdf4e2132 100644 --- a/pkg/sentry/fs/ext4/disklayout/disklayout.go +++ b/pkg/sentry/fs/ext/disklayout/disklayout.go diff --git a/pkg/sentry/fs/ext4/disklayout/inode.go b/pkg/sentry/fs/ext/disklayout/inode.go index b48001910..b48001910 100644 --- a/pkg/sentry/fs/ext4/disklayout/inode.go +++ b/pkg/sentry/fs/ext/disklayout/inode.go diff --git a/pkg/sentry/fs/ext4/disklayout/inode_new.go b/pkg/sentry/fs/ext/disklayout/inode_new.go index 4f5348372..4f5348372 100644 --- a/pkg/sentry/fs/ext4/disklayout/inode_new.go +++ b/pkg/sentry/fs/ext/disklayout/inode_new.go diff --git a/pkg/sentry/fs/ext4/disklayout/inode_old.go b/pkg/sentry/fs/ext/disklayout/inode_old.go index dc4c9d8e4..dc4c9d8e4 100644 --- a/pkg/sentry/fs/ext4/disklayout/inode_old.go +++ b/pkg/sentry/fs/ext/disklayout/inode_old.go diff --git a/pkg/sentry/fs/ext4/disklayout/inode_test.go b/pkg/sentry/fs/ext/disklayout/inode_test.go index 9cae9e4f0..9cae9e4f0 100644 --- a/pkg/sentry/fs/ext4/disklayout/inode_test.go +++ b/pkg/sentry/fs/ext/disklayout/inode_test.go diff --git a/pkg/sentry/fs/ext4/disklayout/superblock.go b/pkg/sentry/fs/ext/disklayout/superblock.go index e4b8f46fb..e4b8f46fb 100644 --- a/pkg/sentry/fs/ext4/disklayout/superblock.go +++ b/pkg/sentry/fs/ext/disklayout/superblock.go diff --git a/pkg/sentry/fs/ext4/disklayout/superblock_32.go b/pkg/sentry/fs/ext/disklayout/superblock_32.go index 587e4afaa..587e4afaa 100644 --- a/pkg/sentry/fs/ext4/disklayout/superblock_32.go +++ b/pkg/sentry/fs/ext/disklayout/superblock_32.go diff --git a/pkg/sentry/fs/ext4/disklayout/superblock_64.go b/pkg/sentry/fs/ext/disklayout/superblock_64.go index a2c2278fb..a2c2278fb 100644 --- a/pkg/sentry/fs/ext4/disklayout/superblock_64.go +++ b/pkg/sentry/fs/ext/disklayout/superblock_64.go diff --git a/pkg/sentry/fs/ext4/disklayout/superblock_old.go b/pkg/sentry/fs/ext/disklayout/superblock_old.go index c74953610..c74953610 100644 --- a/pkg/sentry/fs/ext4/disklayout/superblock_old.go +++ b/pkg/sentry/fs/ext/disklayout/superblock_old.go diff --git a/pkg/sentry/fs/ext4/disklayout/superblock_test.go b/pkg/sentry/fs/ext/disklayout/superblock_test.go index 463b5ba21..463b5ba21 100644 --- a/pkg/sentry/fs/ext4/disklayout/superblock_test.go +++ b/pkg/sentry/fs/ext/disklayout/superblock_test.go diff --git a/pkg/sentry/fs/ext4/disklayout/test_utils.go b/pkg/sentry/fs/ext/disklayout/test_utils.go index 9c63f04c0..9c63f04c0 100644 --- a/pkg/sentry/fs/ext4/disklayout/test_utils.go +++ b/pkg/sentry/fs/ext/disklayout/test_utils.go diff --git a/pkg/sentry/fs/ext/ext.go b/pkg/sentry/fs/ext/ext.go new file mode 100644 index 000000000..7602e2bf0 --- /dev/null +++ b/pkg/sentry/fs/ext/ext.go @@ -0,0 +1,49 @@ +// Copyright 2019 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package ext implements readonly ext(2/3/4) filesystems. +package ext + +import ( + "io" + "sync" + + "gvisor.dev/gvisor/pkg/sentry/fs/ext/disklayout" +) + +// Filesystem implements vfs.FilesystemImpl. +type Filesystem struct { + // dev is the ReadSeeker for the underlying fs device and is protected by mu. + dev io.ReadSeeker + + // mu synchronizes the usage of dev. The ext filesystems take locality into + // condsideration, i.e. data blocks of a file will tend to be placed close + // together. On a spinning disk, locality reduces the amount of movement of + // the head hence speeding up IO operations. On an SSD there are no moving + // parts but locality increases the size of each transer request. Hence, + // having mutual exclusion on the read seeker while reading a file *should* + // help in achieving the intended performance gains. + // + // Note: This synchronization was not coupled with the ReadSeeker itself + // because we want to synchronize across read/seek operations for the + // performance gains mentioned above. Helps enforcing one-file-at-a-time IO. + mu sync.Mutex + + // sb represents the filesystem superblock. Immutable after initialization. + sb disklayout.SuperBlock + + // bgs represents all the block group descriptors for the filesystem. + // Immutable after initialization. + bgs []disklayout.BlockGroup +} diff --git a/pkg/sentry/fs/ext4/BUILD b/pkg/sentry/fs/ext4/BUILD deleted file mode 100644 index 9dce67635..000000000 --- a/pkg/sentry/fs/ext4/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -package(licenses = ["notice"]) - -load("//tools/go_stateify:defs.bzl", "go_library") - -go_library( - name = "ext4", - srcs = ["fs.go"], - importpath = "gvisor.dev/gvisor/pkg/sentry/fs/ext4", - visibility = ["//pkg/sentry:internal"], - deps = [ - "//pkg/sentry/context", - "//pkg/sentry/fs", - ], -) diff --git a/pkg/sentry/fs/ext4/fs.go b/pkg/sentry/fs/ext4/fs.go deleted file mode 100644 index 5c7274821..000000000 --- a/pkg/sentry/fs/ext4/fs.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2019 The gVisor Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package ext4 implements the ext4 filesystem. -package ext4 - -import ( - "gvisor.dev/gvisor/pkg/sentry/context" - "gvisor.dev/gvisor/pkg/sentry/fs" -) - -// filesystem implements fs.Filesystem for ext4. -// -// +stateify savable -type filesystem struct{} - -func init() { - fs.RegisterFilesystem(&filesystem{}) -} - -// FilesystemName is the name under which the filesystem is registered. -// Name matches fs/ext4/super.c:ext4_fs_type.name. -const FilesystemName = "ext4" - -// Name is the name of the file system. -func (*filesystem) Name() string { - return FilesystemName -} - -// AllowUserMount prohibits users from using mount(2) with this file system. -func (*filesystem) AllowUserMount() bool { - return false -} - -// AllowUserList prohibits this filesystem to be listed in /proc/filesystems. -func (*filesystem) AllowUserList() bool { - return false -} - -// Flags returns properties of the filesystem. -// -// In Linux, ext4 returns FS_REQUIRES_DEV. See fs/ext4/super.c -func (*filesystem) Flags() fs.FilesystemFlags { - return fs.FilesystemRequiresDev -} - -// Mount returns the root inode of the ext4 fs. -func (f *filesystem) Mount(ctx context.Context, device string, flags fs.MountSourceFlags, data string, cgroupsInt interface{}) (*fs.Inode, error) { - panic("unimplemented") -} |