summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/ext/disklayout
diff options
context:
space:
mode:
authorAyush Ranjan <ayushranjan@google.com>2019-07-23 15:50:35 -0700
committergVisor bot <gvisor-bot@google.com>2019-07-23 15:51:50 -0700
commitbd7708956f0c9e00e88eff9b35b22eea75e71f5f (patch)
tree08d110a027a067f202d672d524d09546c68dd6fc /pkg/sentry/fs/ext/disklayout
parent04cbb13ce9b151cf906f42e3f18ce3a875f01f63 (diff)
ext: Added extent tree building logic.
PiperOrigin-RevId: 259628657
Diffstat (limited to 'pkg/sentry/fs/ext/disklayout')
-rw-r--r--pkg/sentry/fs/ext/disklayout/inode.go11
-rw-r--r--pkg/sentry/fs/ext/disklayout/inode_old.go6
2 files changed, 9 insertions, 8 deletions
diff --git a/pkg/sentry/fs/ext/disklayout/inode.go b/pkg/sentry/fs/ext/disklayout/inode.go
index b48001910..9ab9a4988 100644
--- a/pkg/sentry/fs/ext/disklayout/inode.go
+++ b/pkg/sentry/fs/ext/disklayout/inode.go
@@ -107,16 +107,17 @@ type Inode interface {
// Flags returns InodeFlags which represents the inode flags.
Flags() InodeFlags
- // Blocks returns the underlying inode.i_block array. This field is special
- // and is used to store various kinds of things depending on the filesystem
- // version and inode type.
+ // Data returns the underlying inode.i_block array as a slice so it's
+ // modifiable. This field is special and is used to store various kinds of
+ // things depending on the filesystem version and inode type. The underlying
+ // field name in Linux is a little misleading.
// - In ext2/ext3, it contains the block map.
- // - In ext4, it contains the extent tree.
+ // - In ext4, it contains the extent tree root node.
// - For inline files, it contains the file contents.
// - For symlinks, it contains the link path (if it fits here).
//
// See https://www.kernel.org/doc/html/latest/filesystems/ext4/dynamic.html#the-contents-of-inode-i-block.
- Blocks() [60]byte
+ Data() []byte
}
// Inode flags. This is not comprehensive and flags which were not used in
diff --git a/pkg/sentry/fs/ext/disklayout/inode_old.go b/pkg/sentry/fs/ext/disklayout/inode_old.go
index dc4c9d8e4..7d7cc9143 100644
--- a/pkg/sentry/fs/ext/disklayout/inode_old.go
+++ b/pkg/sentry/fs/ext/disklayout/inode_old.go
@@ -47,7 +47,7 @@ type InodeOld struct {
BlocksCountLo uint32
FlagsRaw uint32
VersionLo uint32 // This is OS dependent.
- BlocksRaw [60]byte
+ DataRaw [60]byte
Generation uint32
FileACLLo uint32
SizeHi uint32
@@ -113,5 +113,5 @@ func (in *InodeOld) LinksCount() uint16 { return in.LinksCountRaw }
// Flags implements Inode.Flags.
func (in *InodeOld) Flags() InodeFlags { return InodeFlagsFromInt(in.FlagsRaw) }
-// Blocks implements Inode.Blocks.
-func (in *InodeOld) Blocks() [60]byte { return in.BlocksRaw }
+// Data implements Inode.Data.
+func (in *InodeOld) Data() []byte { return in.DataRaw[:] }