Documentation
¶
Index ¶
- Constants
- Variables
- func Check(r io.Reader) bool
- type BlockAddressing
- type Cache
- type DirectoryEntry2
- type DirectoryEntryCsum
- type Extent
- type ExtentHeader
- type ExtentInternal
- type File
- type FileInfo
- type FileSystem
- func (ext4 *FileSystem) Extents(inode *Inode) ([]Extent, error)
- func (ext4 *FileSystem) GetSuperBlock() Superblock
- func (ext4 *FileSystem) Open(name string) (fs.File, error)
- func (ext4 *FileSystem) ReadDir(path string) ([]fs.DirEntry, error)
- func (ext4 *FileSystem) ReadDirInfo(name string) (fs.FileInfo, error)
- func (ext4 *FileSystem) Stat(name string) (fs.FileInfo, error)
- type GroupDescriptor
- type GroupDescriptor32
- type Inode
- func (i *Inode) GetBlockAddresses(ext4 *FileSystem) ([]uint32, error)
- func (i *Inode) GetSize() int64
- func (i Inode) IsDir() bool
- func (i Inode) IsRegular() bool
- func (i Inode) IsSocket() bool
- func (i Inode) IsSymlink() bool
- func (i *Inode) UsesDirectoryHashTree() bool
- func (i *Inode) UsesExtents() bool
- type MoveExtent
- type Superblock
- func (sb *Superblock) FeatureCompatDirIndex() bool
- func (sb *Superblock) FeatureCompatDirPrealloc() bool
- func (sb *Superblock) FeatureCompatExtAttr() bool
- func (sb *Superblock) FeatureCompatHas_journal() bool
- func (sb *Superblock) FeatureCompatImagicInodes() bool
- func (sb *Superblock) FeatureCompatResizeInode() bool
- func (sb *Superblock) FeatureCompatSparseSuper2() bool
- func (sb *Superblock) FeatureInCompat64bit() bool
- func (sb *Superblock) FeatureIncompatCompression() bool
- func (sb *Superblock) FeatureIncompatCsumSeed() bool
- func (sb *Superblock) FeatureIncompatDirdata() bool
- func (sb *Superblock) FeatureIncompatEaInode() bool
- func (sb *Superblock) FeatureIncompatEncrypt() bool
- func (sb *Superblock) FeatureIncompatExtents() bool
- func (sb *Superblock) FeatureIncompatFiletype() bool
- func (sb *Superblock) FeatureIncompatFlexBg() bool
- func (sb *Superblock) FeatureIncompatInlineData() bool
- func (sb *Superblock) FeatureIncompatJournalDev() bool
- func (sb *Superblock) FeatureIncompatLargedir() bool
- func (sb *Superblock) FeatureIncompatMetaBg() bool
- func (sb *Superblock) FeatureIncompatMmp() bool
- func (sb *Superblock) FeatureIncompatRecover() bool
- func (sb *Superblock) FeatureRoCompatBigalloc() bool
- func (sb *Superblock) FeatureRoCompatBtreeDir() bool
- func (sb *Superblock) FeatureRoCompatDirNlink() bool
- func (sb *Superblock) FeatureRoCompatExtraIsize() bool
- func (sb *Superblock) FeatureRoCompatGdtCsum() bool
- func (sb *Superblock) FeatureRoCompatHugeFile() bool
- func (sb *Superblock) FeatureRoCompatLargeFile() bool
- func (sb *Superblock) FeatureRoCompatMetadataCsum() bool
- func (sb *Superblock) FeatureRoCompatProject() bool
- func (sb *Superblock) FeatureRoCompatQuota() bool
- func (sb *Superblock) FeatureRoCompatReadonly() bool
- func (sb *Superblock) FeatureRoCompatSparseSuper() bool
- func (sb *Superblock) GetBlockCount() int64
- func (sb *Superblock) GetBlockSize() int64
- func (sb *Superblock) GetGroupDescriptorCount() uint32
- func (sb *Superblock) GetGroupDescriptorTableCount() uint32
- func (sb *Superblock) GetGroupsPerFlex() int64
Constants ¶
View Source
const ( SectorSize = 0x200 SuperBlockSize = 0x400 GroupZeroPadding = 0x400 INDEX_FL = 0x00001000 EXTENTS_FL = 0x00080000 FEATURE_COMPAT_DIR_PREALLOC = 0x0001 FEATURE_COMPAT_IMAGIC_INODES = 0x0002 FEATURE_COMPAT_HAS_JOURNAL = 0x0004 FEATURE_COMPAT_EXT_ATTR = 0x0008 FEATURE_COMPAT_RESIZE_INODE = 0x0010 FEATURE_COMPAT_DIR_INDEX = 0x0020 FEATURE_COMPAT_SPARSE_SUPER2 = 0x0200 FEATURE_RO_COMPAT_SPARSE_SUPER = 0x0001 FEATURE_RO_COMPAT_LARGE_FILE = 0x0002 FEATURE_RO_COMPAT_BTREE_DIR = 0x0004 FEATURE_RO_COMPAT_HUGE_FILE = 0x0008 FEATURE_RO_COMPAT_GDT_CSUM = 0x0010 FEATURE_RO_COMPAT_DIR_NLINK = 0x0020 FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x0040 FEATURE_RO_COMPAT_QUOTA = 0x0100 FEATURE_RO_COMPAT_BIGALLOC = 0x0200 FEATURE_RO_COMPAT_METADATA_CSUM = 0x0400 FEATURE_RO_COMPAT_READONLY = 0x1000 FEATURE_RO_COMPAT_PROJECT = 0x2000 FEATURE_INCOMPAT_COMPRESSION = 0x0001 FEATURE_INCOMPAT_FILETYPE = 0x0002 FEATURE_INCOMPAT_RECOVER = 0x0004 FEATURE_INCOMPAT_JOURNAL_DEV = 0x0008 FEATURE_INCOMPAT_META_BG = 0x0010 FEATURE_INCOMPAT_EXTENTS = 0x0040 FEATURE_INCOMPAT_64BIT = 0x0080 FEATURE_INCOMPAT_MMP = 0x0100 FEATURE_INCOMPAT_FLEX_BG = 0x0200 FEATURE_INCOMPAT_EA_INODE = 0x0400 FEATURE_INCOMPAT_DIRDATA = 0x1000 FEATURE_INCOMPAT_CSUM_SEED = 0x2000 FEATURE_INCOMPAT_LARGEDIR = 0x4000 FEATURE_INCOMPAT_INLINE_DATA = 0x8000 FEATURE_INCOMPAT_ENCRYPT = 0x10000 )
Variables ¶
View Source
var (
ErrInodeNotFound = xerrors.New("inode not found")
)
View Source
var (
ErrOpenSymlink = xerrors.New("open symlink does not support")
)
Functions ¶
Types ¶
type BlockAddressing ¶
type Cache ¶
type Cache[K comparable, V any] interface { // Add cache data Add(key K, value V) bool // Get returns key's value from the cache Get(key K) (value V, ok bool) }
type DirectoryEntry2 ¶
type DirectoryEntry2 struct {
Inode uint32 `struc:"uint32,little"`
RecLen uint16 `struc:"uint16,little"`
NameLen uint8 `struc:"uint8,sizeof=Name"`
Flags uint8 `struc:"uint8"`
Name string `struc:"[]byte"`
}
DirectoryEntry2 is more or less a flat file that maps an arbitrary byte string
type DirectoryEntryCsum ¶
type DirectoryEntryCsum struct {
FakeInodeZero uint32 `struc:"uint32,little"`
RecLen uint16 `struc:"uint16,little"`
FakeNameLen uint8 `struc:"uint8"`
FakeFileType uint8 `struc:"uint8"`
Checksum uint32 `struc:"uint32,little"`
}
DirectoryEntryCsum is not use
type Extent ¶
type Extent struct {
Block uint32 `struc:"uint32,little"`
Len uint16 `struc:"uint16,little"`
StartHi uint16 `struc:"uint16,little"`
StartLo uint32 `struc:"uint32,little"`
}
Extent is extent tree leaf nodes
type ExtentHeader ¶
type ExtentHeader struct {
Magic uint16 `struc:"uint16,little"`
Entries uint16 `struc:"uint16,little"`
Max uint16 `struc:"uint16,little"`
Depth uint16 `struc:"uint16,little"`
Generation uint32 `struc:"uint32,little"`
}
ExtentHeader is ...
type ExtentInternal ¶
type ExtentInternal struct {
Block uint32 `struc:"uint32,little"`
LeafLow uint32 `struc:"uint32,little"`
LeafHigh uint16 `struc:"uint16,little"`
Unused uint16 `struc:"uint16,little"`
}
ExtentInternal
type File ¶
type File struct {
FileInfo
// contains filtered or unexported fields
}
File is implemented io/fs File interface
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo is implemented io/fs FileInfo interface
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is implemented io/fs interface
func NewFS ¶
func NewFS(r io.SectionReader, cache Cache[string, any]) (*FileSystem, error)
NewFS is created io/fs.FS for ext4 filesystem
func (*FileSystem) GetSuperBlock ¶
func (ext4 *FileSystem) GetSuperBlock() Superblock
func (*FileSystem) ReadDirInfo ¶
func (ext4 *FileSystem) ReadDirInfo(name string) (fs.FileInfo, error)
type GroupDescriptor ¶
type GroupDescriptor struct {
GroupDescriptor32
BlockBitmapHi uint32 `struc:"uint32,little"`
InodeBitmapHi uint32 `struc:"uint32,little"`
InodeTableHi uint32 `struc:"uint32,little"`
FreeBlocksCountHi uint16 `struc:"uint16,little"`
FreeInodesCountHi uint16 `struc:"uint16,little"`
UsedDirsCountHi uint16 `struc:"uint16,little"`
ItableUnusedHi uint16 `struc:"uint16,little"`
ExcludeBitmapHi uint32 `struc:"uint32,little"`
BlockBitmapCsumHi uint16 `struc:"uint16,little"`
InodeBitmapCsumHi uint16 `struc:"uint16,little"`
Reserved uint32 `struc:"uint32,little"`
}
GroupDescriptor is 64 byte
func (*GroupDescriptor) GetBlockBitmapLoc ¶
func (gd *GroupDescriptor) GetBlockBitmapLoc(featureInCompat64bit bool) int64
GetBlockBitmapLoc is ...
func (*GroupDescriptor) GetInodeBitmapLoc ¶
func (gd *GroupDescriptor) GetInodeBitmapLoc(featureInCompat64bit bool) int64
GetInodeBitmapLoc is ...
func (*GroupDescriptor) GetInodeTableLoc ¶
func (gd *GroupDescriptor) GetInodeTableLoc(featureInCompat64bit bool) int64
GetInodeTableLoc is ...
type GroupDescriptor32 ¶
type GroupDescriptor32 struct {
BlockBitmapLo uint32 `struc:"uint32,little"`
InodeBitmapLo uint32 `struc:"uint32,little"`
InodeTableLo uint32 `struc:"uint32,little"`
FreeBlocksCountLo uint16 `struc:"uint16,little"`
FreeInodesCountLo uint16 `struc:"uint16,little"`
UsedDirsCountLo uint16 `struc:"uint16,little"`
Flags uint16 `struc:"uint16,little"`
ExcludeBitmapLo uint32 `struc:"uint32,little"`
BlockBitmapCsumLo uint16 `struc:"uint16,little"`
InodeBitmapCsumLo uint16 `struc:"uint16,little"`
ItableUnusedLo uint16 `struc:"uint16,little"`
Checksum uint16 `struc:"uint16,little"`
}
GroupDescriptor32 is 32 byte
type Inode ¶
type Inode struct {
Mode uint16 `struc:"uint16,little"`
UID uint16 `struc:"uint16,little"`
SizeLo uint32 `struc:"uint32,little"`
Atime uint32 `struc:"uint32,little"`
Ctime uint32 `struc:"uint32,little"`
Mtime uint32 `struc:"uint32,little"`
Dtime uint32 `struc:"uint32,little"`
GID uint16 `struc:"uint16,little"`
LinksCount uint16 `struc:"uint16,little"`
BlocksLo uint32 `struc:"uint32,little"`
Flags uint32 `struc:"uint32,little"`
Osd1 uint32 `struc:"uint32,little"`
BlockOrExtents [60]byte `struc:"[60]byte,little"`
Generation uint32 `struc:"uint32,little"`
FileACLLo uint32 `struc:"uint32,little"`
SizeHigh uint32 `struc:"uint32,little"`
ObsoFaddr uint32 `struc:"uint32,little"`
// OSD2 - linux only starts
BlocksHigh uint16 `struc:"uint16,little"`
FileACLHigh uint16 `struc:"uint16,little"`
UIDHigh uint16 `struc:"uint16,little"`
GIDHigh uint16 `struc:"uint16,little"`
ChecksumLow uint16 `struc:"uint16,little"`
Unused uint16 `struc:"uint16,little"`
// OSD2 - linux only ends
ExtraIsize uint16 `struc:"uint16,little"`
ChecksumHi uint16 `struc:"uint16,little"`
CtimeExtra uint32 `struc:"uint32,little"`
MtimeExtra uint32 `struc:"uint32,little"`
AtimeExtra uint32 `struc:"uint32,little"`
Crtime uint32 `struc:"uint32,little"`
CrtimeExtra uint32 `struc:"uint32,little"`
VersionHi uint32 `struc:"uint32,little"`
Projid uint32 `struc:"uint32,little"`
// padding
Reserved [96]uint8 `struc:"[96]uint32,little"`
}
Inode is index-node
func (*Inode) GetBlockAddresses ¶
func (i *Inode) GetBlockAddresses(ext4 *FileSystem) ([]uint32, error)
func (*Inode) UsesDirectoryHashTree ¶
UsesDirectoryHashTree
type MoveExtent ¶
type MoveExtent struct {
Reserved uint32 `struc:"uint32,little"`
DonorFd uint32 `struc:"uint32,little"`
OrigStart uint64 `struc:"uint64,little"`
DonorStart uint64 `struc:"uint64,little"`
Len uint64 `struc:"uint64,little"`
MovedLen uint64 `struc:"uint64,little"`
}
MoveExtent is not use
type Superblock ¶
type Superblock struct {
InodeCount uint32 `struc:"uint32,little"`
BlockCountLo uint32 `struc:"uint32,little"`
RBlockCountLo uint32 `struc:"uint32,little"`
FreeBlockCountLo uint32 `struc:"uint32,little"`
FreeInodeCount uint32 `struc:"uint32,little"`
FirstDataBlock uint32 `struc:"uint32,little"`
LogBlockSize uint32 `struc:"uint32,little"`
LogClusterSize uint32 `struc:"uint32,little"`
BlockPerGroup uint32 `struc:"uint32,little"`
ClusterPerGroup uint32 `struc:"uint32,little"`
InodePerGroup uint32 `struc:"uint32,little"`
Mtime uint32 `struc:"uint32,little"`
Wtime uint32 `struc:"uint32,little"`
MntCount uint16 `struc:"uint16,little"`
MaxMntCount uint16 `struc:"uint16,little"`
Magic uint16 `struc:"uint16,little"`
State uint16 `struc:"uint16,little"`
Errors uint16 `struc:"uint16,little"`
MinorRevLevel uint16 `struc:"uint16,little"`
Lastcheck uint32 `struc:"uint32,little"`
Checkinterval uint32 `struc:"uint32,little"`
CreatorOs uint32 `struc:"uint32,little"`
RevLevel uint32 `struc:"uint32,little"`
DefResuid uint16 `struc:"uint16,little"`
DefResgid uint16 `struc:"uint16,little"`
FirstIno uint32 `struc:"uint32,little"`
InodeSize uint16 `struc:"uint16,little"`
BlockGroupNr uint16 `struc:"uint16,little"`
FeatureCompat uint32 `struc:"uint32,little"`
FeatureIncompat uint32 `struc:"uint32,little"`
FeatureRoCompat uint32 `struc:"uint32,little"`
UUID [16]byte `struc:"[16]byte"`
VolumeName [16]byte `struc:"[16]byte"`
LastMounted [64]byte `struc:"[64]byte"`
AlgorithmUsageBitmap uint32 `struc:"uint32,little"`
PreallocBlocks byte `struc:"byte"`
PreallocDirBlocks byte `struc:"byte"`
ReservedGdtBlocks uint16 `struc:"uint16,little"`
JournalUUID [16]byte `struc:"[16]byte"`
JournalInum uint32 `struc:"uint32,little"`
JournalDev uint32 `struc:"uint32,little"`
LastOrphan uint32 `struc:"uint32,little"`
HashSeed [4]uint32 `struc:"[4]uint32,little"`
DefHashVersion byte `struc:"byte"`
JnlBackupType byte `struc:"byte"`
DescSize uint16 `struc:"uint16,little"`
DefaultMountOpts uint32 `struc:"uint32,little"`
FirstMetaBg uint32 `struc:"uint32,little"`
MkfTime uint32 `struc:"uint32,little"`
JnlBlocks [17]uint32 `struc:"[17]uint32,little"`
BlockCountHi uint32 `struc:"uint32,little"`
RBlockCountHi uint32 `struc:"uint32,little"`
FreeBlockCountHi uint32 `struc:"uint32,little"`
MinExtraIsize uint16 `struc:"uint16,little"`
WantExtraIsize uint16 `struc:"uint16,little"`
Flags uint32 `struc:"uint32,little"`
RaidStride uint16 `struc:"uint16,little"`
MmpUpdateInterval uint16 `struc:"uint16,little"`
MmpBlock uint64 `struc:"uint64,little"`
RaidStripeWidth uint32 `struc:"uint32,little"`
LogGroupPerFlex byte `struc:"byte"`
ChecksumType byte `struc:"byte"`
EncryptionLevel byte `struc:"byte"`
ReservedPad byte `struc:"byte"`
KbyteWritten uint64 `struc:"uint64,little"`
SnapshotInum uint32 `struc:"uint32,little"`
SnapshotID uint32 `struc:"uint32,little"`
SnapshotRBlockCount uint64 `struc:"uint64,little"`
SnapshotList uint32 `struc:"uint32,little"`
ErrorCount uint32 `struc:"uint32,little"`
FirstErrorTime uint32 `struc:"uint32,little"`
FirstErrorIno uint32 `struc:"uint32,little"`
FirstErrorBlock uint64 `struc:"uint64,little"`
FirstErrorFunc [32]byte `struc:"[32]pad"`
FirstErrorLine uint32 `struc:"uint32,little"`
LastErrorTime uint32 `struc:"uint32,little"`
LastErrorIno uint32 `struc:"uint32,little"`
LastErrorLine uint32 `struc:"uint32,little"`
LastErrorBlock uint64 `struc:"uint64,little"`
LastErrorFunc [32]byte `struc:"[32]pad"`
MountOpts [64]byte `struc:"[64]pad"`
UsrQuotaInum uint32 `struc:"uint32,little"`
GrpQuotaInum uint32 `struc:"uint32,little"`
OverheadClusters uint32 `struc:"uint32,little"`
BackupBgs [2]uint32 `struc:"[2]uint32,little"`
EncryptAlgos [4]byte `struc:"[4]pad"`
EncryptPwSalt [16]byte `struc:"[16]pad"`
LpfIno uint32 `struc:"uint32,little"`
PrjQuotaInum uint32 `struc:"uint32,little"`
ChecksumSeed uint32 `struc:"uint32,little"`
Reserved [98]uint32 `struc:"[98]uint32,little"`
Checksum uint32 `struc:"uint32,little"`
}
func (*Superblock) FeatureCompatDirIndex ¶
func (sb *Superblock) FeatureCompatDirIndex() bool
func (*Superblock) FeatureCompatDirPrealloc ¶
func (sb *Superblock) FeatureCompatDirPrealloc() bool
func (*Superblock) FeatureCompatExtAttr ¶
func (sb *Superblock) FeatureCompatExtAttr() bool
func (*Superblock) FeatureCompatHas_journal ¶
func (sb *Superblock) FeatureCompatHas_journal() bool
func (*Superblock) FeatureCompatImagicInodes ¶
func (sb *Superblock) FeatureCompatImagicInodes() bool
func (*Superblock) FeatureCompatResizeInode ¶
func (sb *Superblock) FeatureCompatResizeInode() bool
func (*Superblock) FeatureCompatSparseSuper2 ¶
func (sb *Superblock) FeatureCompatSparseSuper2() bool
func (*Superblock) FeatureInCompat64bit ¶
func (sb *Superblock) FeatureInCompat64bit() bool
func (*Superblock) FeatureIncompatCompression ¶
func (sb *Superblock) FeatureIncompatCompression() bool
func (*Superblock) FeatureIncompatCsumSeed ¶
func (sb *Superblock) FeatureIncompatCsumSeed() bool
func (*Superblock) FeatureIncompatDirdata ¶
func (sb *Superblock) FeatureIncompatDirdata() bool
func (*Superblock) FeatureIncompatEaInode ¶
func (sb *Superblock) FeatureIncompatEaInode() bool
func (*Superblock) FeatureIncompatEncrypt ¶
func (sb *Superblock) FeatureIncompatEncrypt() bool
func (*Superblock) FeatureIncompatExtents ¶
func (sb *Superblock) FeatureIncompatExtents() bool
func (*Superblock) FeatureIncompatFiletype ¶
func (sb *Superblock) FeatureIncompatFiletype() bool
func (*Superblock) FeatureIncompatFlexBg ¶
func (sb *Superblock) FeatureIncompatFlexBg() bool
func (*Superblock) FeatureIncompatInlineData ¶
func (sb *Superblock) FeatureIncompatInlineData() bool
func (*Superblock) FeatureIncompatJournalDev ¶
func (sb *Superblock) FeatureIncompatJournalDev() bool
func (*Superblock) FeatureIncompatLargedir ¶
func (sb *Superblock) FeatureIncompatLargedir() bool
func (*Superblock) FeatureIncompatMetaBg ¶
func (sb *Superblock) FeatureIncompatMetaBg() bool
func (*Superblock) FeatureIncompatMmp ¶
func (sb *Superblock) FeatureIncompatMmp() bool
func (*Superblock) FeatureIncompatRecover ¶
func (sb *Superblock) FeatureIncompatRecover() bool
func (*Superblock) FeatureRoCompatBigalloc ¶
func (sb *Superblock) FeatureRoCompatBigalloc() bool
func (*Superblock) FeatureRoCompatBtreeDir ¶
func (sb *Superblock) FeatureRoCompatBtreeDir() bool
func (*Superblock) FeatureRoCompatDirNlink ¶
func (sb *Superblock) FeatureRoCompatDirNlink() bool
func (*Superblock) FeatureRoCompatExtraIsize ¶
func (sb *Superblock) FeatureRoCompatExtraIsize() bool
func (*Superblock) FeatureRoCompatGdtCsum ¶
func (sb *Superblock) FeatureRoCompatGdtCsum() bool
func (*Superblock) FeatureRoCompatHugeFile ¶
func (sb *Superblock) FeatureRoCompatHugeFile() bool
func (*Superblock) FeatureRoCompatLargeFile ¶
func (sb *Superblock) FeatureRoCompatLargeFile() bool
func (*Superblock) FeatureRoCompatMetadataCsum ¶
func (sb *Superblock) FeatureRoCompatMetadataCsum() bool
func (*Superblock) FeatureRoCompatProject ¶
func (sb *Superblock) FeatureRoCompatProject() bool
func (*Superblock) FeatureRoCompatQuota ¶
func (sb *Superblock) FeatureRoCompatQuota() bool
func (*Superblock) FeatureRoCompatReadonly ¶
func (sb *Superblock) FeatureRoCompatReadonly() bool
func (*Superblock) FeatureRoCompatSparseSuper ¶
func (sb *Superblock) FeatureRoCompatSparseSuper() bool
func (*Superblock) GetBlockCount ¶
func (sb *Superblock) GetBlockCount() int64
func (*Superblock) GetBlockSize ¶
func (sb *Superblock) GetBlockSize() int64
func (*Superblock) GetGroupDescriptorCount ¶
func (sb *Superblock) GetGroupDescriptorCount() uint32
func (*Superblock) GetGroupDescriptorTableCount ¶
func (sb *Superblock) GetGroupDescriptorTableCount() uint32
func (*Superblock) GetGroupsPerFlex ¶
func (sb *Superblock) GetGroupsPerFlex() int64
Click to show internal directories.
Click to hide internal directories.