From bd7708956f0c9e00e88eff9b35b22eea75e71f5f Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Tue, 23 Jul 2019 15:50:35 -0700 Subject: ext: Added extent tree building logic. PiperOrigin-RevId: 259628657 --- pkg/sentry/fs/ext/disklayout/inode.go | 11 ++++++----- pkg/sentry/fs/ext/disklayout/inode_old.go | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'pkg/sentry/fs/ext/disklayout') 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[:] } -- cgit v1.2.3