ext4

package
v0.0.0-...-79a645e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FTypeRegularFile = 0x1 // FTYPE_REGULAR_FILE
	FTypeDir         = 0x2 // FTYPE_DIR
	FTypeSymlink     = 0x7 // FTYPE_SYMLINK
)

FTYPE constants are used in directory entries to identify file types without requiring inode lookups.

View Source
const (
	InodeTypeDirectory                 = 0x4000
	InodeTypeRegularFile               = 0x8000
	InodeTypeSymlink                   = 0xA000
	InodeTypeMask                      = 0xF000
	InodePermissionsMask               = 0777
	DefaultInodePermissions            = 0700
	InodeDefaultDirectoryPermissions   = InodeTypeDirectory | DefaultInodePermissions
	InodeDefaultRegularFilePermissions = InodeTypeRegularFile | DefaultInodePermissions
	InodeDefaultSymlinkPermissions     = InodeTypeSymlink | DefaultInodePermissions
)
View Source
const (
	ExtentMagic      = 0xF30A
	Ext4IndexFL      = 0x00001000 // EXT4_INDEX_FL
	Ext4ExtentsFL    = 0x00080000 // EXT4_EXTENTS_FL
	Ext4EAInodeFL    = 0x00200000 // EXT4_EA_INODE_FL
	Ext4InlineDataFL = 0x10000000 // EXT4_INLINE_DATA_FL
)
View Source
const (
	MinJournalBlocks = 1024
	MaxJournalBlocks = 32768
)
View Source
const (
	JBD2FeatureIncompatRevoke      = 0x1
	JBD2FeatureIncompat64Bit       = 0x2
	JBD2FeatureIncompatAsyncCommit = 0x4
)
View Source
const (
	Signature    = 0xEF53
	RootDirInode = 2
	JournalInode = 8
)
View Source
const (
	SectorSize          = 512
	BlockSize           = 0x1000
	BlocksPerGroup      = BlockSize * 8
	DescriptorSize      = 32
	InodeSize           = 128
	SectorsPerBlock     = BlockSize / SectorSize
	DescriptorsPerBlock = BlockSize / DescriptorSize
	InodesPerBlock      = BlockSize / InodeSize
	PreallocFileBlocks  = 0
	PreallocDirBlocks   = 0
	SuperUID            = 1000
	SuperGID            = 1000
	MaxGroupDescriptors = (BlocksPerGroup / 2) * DescriptorsPerBlock // NOTE: capped to 128 TiB because we're not using meta block groups (META_BG) this is half the documented limit, but bg 0 can't be 100% group descriptors so I've cut it in half for safety
)
View Source
const (
	CompatDirPrealloc  = 0x1   // COMPAT_DIR_PREALLOC
	CompatHasJournal   = 0x4   // COMPAT_HAS_JOURNAL
	CompatResizeInode  = 0x10  // COMPAT_RESIZE_INODE
	CompatDirIndex     = 0x20  // COMPAT_DIR_INDEX
	CompatSparseSuper2 = 0x200 // COMPAT_SPARSE_SUPER2
)
View Source
const (
	IncompatFiletype   = 0x2    // INCOMPAT_FILETYPE
	IncompatExtents    = 0x40   // INCOMPAT_EXTENTS
	IncompatFlexBG     = 0x200  // INCOMPAT_FLEX_BG
	IncompatInlineData = 0x8000 // INCOMPAT_INLINE_DATA
)
View Source
const (
	ROCompatSparseSuper = 0x1 // RO_COMPAT_SPARSE_SUPER
	ROCompatLargeFile   = 0x2 // RO_COMPAT_LARGE_FILE
)
View Source
const (
	DirentHashVersion = 0x2
)
View Source
const (
	InodeMaximumInlineBytes = 60
)
View Source
const (
	ResizeInode = 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockGroupDescriptor

type BlockGroupDescriptor struct {
	BlockBitmapAddr uint32 // 0x0
	InodeBitmapAddr uint32 // 0x4
	InodeTableAddr  uint32 // 0x8
	FreeBlocks      uint16 // 0xC
	FreeInodes      uint16 // 0xE
	Directories     uint16 // 0x10
	Flags           uint16 // 0x12

	UnusedInodes uint16 // 0x1C
	// contains filtered or unexported fields

} // 0x20

BlockGroupDescriptor is the structure of a single block group descriptor as written to the disk.

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

func NewCompiler

func NewCompiler(args *CompilerArgs) *Compiler

func (*Compiler) AddFile

func (c *Compiler) AddFile(path string, r io.ReadCloser, size int64, force bool) error

func (*Compiler) Commit

func (c *Compiler) Commit(ctx context.Context) error

func (*Compiler) Compile

func (c *Compiler) Compile(ctx context.Context, w io.WriteSeeker) error

func (*Compiler) IncreaseMinimumFreeSpace

func (c *Compiler) IncreaseMinimumFreeSpace(space int64)

func (*Compiler) IncreaseMinimumInodes

func (c *Compiler) IncreaseMinimumInodes(inodes int64)

func (*Compiler) MinimumSize

func (c *Compiler) MinimumSize() int64

func (*Compiler) Mkdir

func (c *Compiler) Mkdir(path string) error

func (*Compiler) Precompile

func (c *Compiler) Precompile(ctx context.Context, size int64) error

func (*Compiler) RegionIsHole

func (c *Compiler) RegionIsHole(begin, size int64) bool

func (*Compiler) SetMinimumInodes

func (c *Compiler) SetMinimumInodes(inodes int64)

func (*Compiler) SetMinimumInodesPer64MiB

func (c *Compiler) SetMinimumInodesPer64MiB(inodes int64)

type CompilerArgs

type CompilerArgs struct {
	FileTree vio.FileTree
	Logger   elog.Logger
}

type Extent

type Extent struct {
	Block   uint32
	Len     uint16
	StartHi uint16
	StartLo uint32
}

type ExtentHeader

type ExtentHeader struct {
	Magic      uint16
	Entries    uint16
	Max        uint16
	Depth      uint16
	Generation uint32
}

type ExtentIndex

type ExtentIndex struct {
	Block  uint32
	LeafLo uint32
	LeafHi uint16
	Unused uint16
}

type HashDirectoryEntry

type HashDirectoryEntry struct {
	Hash  uint32
	Block uint32
}

HashDirectoryEntry is one entry in a hash table within an indexed directory.

type HashDirectoryRoot

type HashDirectoryRoot struct {
	DotInode      uint32  // 0x0
	DotRecLen     uint16  // 0x4
	DotNameLen    uint8   // 0x6
	DotFType      uint8   // 0x7
	DotName       [4]byte // 0x8
	DotDotInode   uint32  // 0xC
	DotDotRecLen  uint16  // 0x10
	DotDotNameLen uint8   // 0x12
	DotDotFType   uint8   // 0x13
	DotDotName    [4]byte // 0x14

	HashVersion    uint8 // 0x1C
	InfoLength     uint8 // 0x1D
	IndirectLevels uint8 // 0x1E

	Limit   uint16                  // 0x20
	Count   uint16                  // 0x22
	Block   uint32                  // 0x24
	Entries [507]HashDirectoryEntry // 0x28
	// contains filtered or unexported fields
}

HashDirectoryRoot is the struct containing the full layout of the zeroth block for any indexed directory.

type Inode

type Inode struct {
	Permissions      uint16   // 0x0
	UID              uint16   // 0x2
	SizeLower        uint32   // 0x4
	LastAccessTime   uint32   // 0x8
	CreationTime     uint32   // 0xC
	ModificationTime uint32   // 0x10
	DeletionTime     uint32   // 0x14
	GID              uint16   // 0x18
	Links            uint16   // 0x1A
	Sectors          uint32   // 0x1C
	Flags            uint32   // 0x20
	OSV              uint32   // 0x24
	Block            [60]byte // 0x28
	GenNo            uint32   // 0x64
	FileACL          uint32   // 0x68
	SizeUpper        uint32   // 0x6C
	FragAddr         uint32   // 0x70
	OSStuff          [12]byte // 0x74

} // 0x80

type JournalBlockHeader

type JournalBlockHeader struct {
	Magic     uint32
	Type      uint32
	Seq       uint32
	BlockSize uint32
	MaxLen    uint32
	First     uint32
	SuperSeq  uint32
	Start     uint32
	Errno     uint32

	// v2
	FeatureCompat   uint32
	FeatureInCompat uint32
	FeatureRoCompat uint32

	UUID            [16]byte
	NrUsers         uint32
	DynSuper        uint32
	MaxTransactions uint32
	MaxTransData    uint32
	ChecksumType    uint8
	Padding2        [3]byte
	Padding         [42]uint32
	Checksum        uint32
	Users           [16 * 48]byte
}

type Superblock

type Superblock struct {
	TotalInodes uint32
	TotalBlocks uint32

	UnallocatedBlocks uint32
	UnallocatedInodes uint32 // 0x10

	LogBlockSize     uint32
	LogClusterSize   uint32
	BlocksPerGroup   uint32 // 0x20
	ClustersPerGroup uint32
	InodesPerGroup   uint32
	LastMountTime    uint32
	LastWrittenTime  uint32 // 0x30

	MountsCheckInterval uint16
	Signature           uint16
	State               uint16
	ErrorProtocol       uint16
	VersionMinor        uint16
	TimeLastCheck       uint32 // 0x40
	TimeCheckInterval   uint32

	VersionMajor     uint32
	ResUID           uint16 // 0x50
	ResGID           uint16
	FirstIno         uint32
	InodeSize        uint16
	BlockGroupNumber uint16
	FeatureCompat    uint32
	FeatureIncompat  uint32 // 0x60
	FeatureROCompat  uint32
	UUID             [16]byte

	PreallocBlocks    uint8
	PreallocDirBlocks uint8
	ReservedGDTBlocks uint16
	JournalUUID       [16]byte // 0xD0
	JournalInum       uint32

	HashSeed         [4]uint32
	DefHashVersion   uint8
	JnlBackupType    uint8
	DescSize         uint16
	DefaultMountOpts uint32 // 0x100

	Flags uint32 // 0x160

	LogGroupsPerFlex uint8
	ChecksumType     uint8

	MountOptions [64]uint8 // 0x200

	BackupBGs [2]uint32
	// contains filtered or unexported fields
}

Superblock is the structure of a superblock as written to the disk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL