Documentation
¶
Overview ¶
Package erofs provides the ability to access the contents in an EROFS [1] image.
The design principle of this package is that, it will just provide the ability to access the contents in the image, and it will never cache any objects internally. The whole disk image is mapped via a read-only/shared mapping, and it relies on host kernel to cache the blocks/pages transparently.
Index ¶
- Constants
- type Dirent
- type Image
- type Inode
- func (i *Inode) Data() (safemem.BlockSeq, error)
- func (i *Inode) DataLayout() uint16
- func (i *Inode) DataOffset() (uint64, error)
- func (i *Inode) GID() uint32
- func (i *Inode) IsBlockDev() bool
- func (i *Inode) IsCharDev() bool
- func (i *Inode) IsDir() bool
- func (i *Inode) IsFIFO() bool
- func (i *Inode) IsRegular() bool
- func (i *Inode) IsSocket() bool
- func (i *Inode) IsSymlink() bool
- func (i *Inode) IterDirents(cb func(name string, typ uint8, nid uint64) error) error
- func (i *Inode) Layout() uint16
- func (i *Inode) Lookup(name string) (uint64, error)
- func (i *Inode) Mode() uint16
- func (i *Inode) Mtime() uint64
- func (i *Inode) MtimeNsec() uint32
- func (i *Inode) Nid() uint64
- func (i *Inode) Nlink() uint32
- func (i *Inode) Readlink() (string, error)
- func (i *Inode) Size() uint64
- func (i *Inode) UID() uint32
- type InodeCompact
- type InodeExtended
- type SuperBlock
Constants ¶
const ( // Definitions for superblock. SuperBlockMagicV1 = 0xe0f5e1e2 SuperBlockOffset = 1024 // Inode slot size in bit shift. InodeSlotBits = 5 // Max file name length. MaxNameLen = 255 )
const ( InodeLayoutBit = 0 InodeLayoutBits = 1 InodeDataLayoutBit = 1 InodeDataLayoutBits = 3 )
Bit definitions for Inode*::Format.
const ( InodeLayoutCompact = 0 InodeLayoutExtended = 1 )
Inode layouts.
const ( InodeDataLayoutFlatPlain = iota InodeDataLayoutFlatCompressionLegacy InodeDataLayoutFlatInline InodeDataLayoutFlatCompression InodeDataLayoutChunkBased InodeDataLayoutMax )
Inode data layouts.
const ( SuperBlockSize = 128 InodeCompactSize = 32 InodeExtendedSize = 64 DirentSize = 12 )
Sizes of on-disk structures in bytes.
const (
FeatureCompatSuperBlockChecksum = 0x00000001
)
Features w/ backward compatibility. This is not exhaustive, unused features are not listed.
const (
FeatureIncompatSupported = 0x0
)
Features w/o backward compatibility.
Any features that aren't in FeatureIncompatSupported are incompatible with this implementation.
This is not exhaustive, unused features are not listed.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents an open EROFS image.
+stateify savable
func OpenImage ¶
OpenImage returns an Image providing access to the contents in the image file src.
On success, the ownership of src is transferred to Image.
func (*Image) SuperBlock ¶
func (i *Image) SuperBlock() SuperBlock
SuperBlock returns a copy of the image's superblock.
type Inode ¶
type Inode struct {
// contains filtered or unexported fields
}
Inode represents in-memory inode object.
+stateify savable
func (*Inode) DataLayout ¶
DataLayout returns the inode data layout.
func (*Inode) DataOffset ¶
DataOffset returns the data offset of this inode in image file.
func (*Inode) IsBlockDev ¶
IsBlockDev indicates whether i represents a block device.
func (*Inode) IterDirents ¶
IterDirents invokes cb on each entry in the directory represented by this inode. The directory entries will be iterated in alphabetical order.
func (*Inode) Lookup ¶
Lookup looks up a child by the name. The child inode number will be returned on success.
type InodeCompact ¶
type InodeCompact struct {
Format uint16
XattrCount uint16
Mode uint16
Nlink uint16
Size uint32
Reserved uint32
RawBlockAddr uint32
Ino uint32
UID uint16
GID uint16
Reserved2 uint32
}
InodeCompact represents 32-byte reduced form of on-disk inode.
+marshal
type InodeExtended ¶
type InodeExtended struct {
Format uint16
XattrCount uint16
Mode uint16
Reserved uint16
Size uint64
RawBlockAddr uint32
Ino uint32
UID uint32
GID uint32
Mtime uint64
MtimeNsec uint32
Nlink uint32
Reserved2 [16]uint8
}
InodeExtended represents 64-byte complete form of on-disk inode.
+marshal
type SuperBlock ¶
type SuperBlock struct {
Magic uint32
Checksum uint32
FeatureCompat uint32
BlockSizeBits uint8
ExtSlots uint8
RootNid uint16
Inodes uint64
BuildTime uint64
BuildTimeNsec uint32
Blocks uint32
MetaBlockAddr uint32
XattrBlockAddr uint32
UUID [16]uint8
VolumeName [16]uint8
FeatureIncompat uint32
Union1 uint16
ExtraDevices uint16
DevTableSlotOff uint16
Reserved [38]uint8
}
SuperBlock represents on-disk superblock.
+marshal +stateify savable
func (*SuperBlock) BlockAddrToOffset ¶
func (sb *SuperBlock) BlockAddrToOffset(addr uint32) uint64
BlockAddrToOffset converts block addr to the offset in image file.
func (*SuperBlock) BlockSize ¶
func (sb *SuperBlock) BlockSize() uint32
BlockSize returns the block size.
func (*SuperBlock) MetaOffset ¶
func (sb *SuperBlock) MetaOffset() uint64
MetaOffset returns the offset of metadata area in image file.
func (*SuperBlock) NidToOffset ¶
func (sb *SuperBlock) NidToOffset(nid uint64) uint64
NidToOffset converts inode number to the offset in image file.