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.
Index ¶
- Constants
- Variables
- func Create(dst io.WriterAt, src fs.FS) error
- type Dirent
- type Filesystem
- func (fsys *Filesystem) Open(name string) (fs.File, error)
- func (fsys *Filesystem) ReadDir(name string) ([]fs.DirEntry, error)
- func (fsys *Filesystem) ReadLink(name string) (string, error)
- func (fsys *Filesystem) Stat(name string) (fs.FileInfo, error)
- func (fsys *Filesystem) StatLink(name string) (fs.FileInfo, error)
- type Image
- type Inode
- func (ino *Inode) Data() (io.Reader, error)
- func (ino *Inode) DataLayout() uint16
- func (ino *Inode) GID() uint32
- func (ino *Inode) IsBlockDev() bool
- func (ino *Inode) IsCharDev() bool
- func (ino *Inode) IsDir() bool
- func (ino *Inode) IsFIFO() bool
- func (ino *Inode) IsRegular() bool
- func (ino *Inode) IsSocket() bool
- func (ino *Inode) IsSymlink() bool
- func (ino *Inode) IterDirents(cb func(name string, typ uint8, nid uint64) error) error
- func (ino *Inode) Layout() uint16
- func (ino *Inode) Lookup(name string) (Dirent, error)
- func (ino *Inode) Mode() fs.FileMode
- func (ino *Inode) Mtime() uint64
- func (ino *Inode) MtimeNsec() uint32
- func (ino *Inode) Nid() uint64
- func (ino *Inode) Nlink() uint32
- func (ino *Inode) Readlink() (string, error)
- func (ino *Inode) Size() uint64
- func (ino *Inode) UID() uint32
- type InodeCompact
- type InodeExtended
- type SuperBlock
Constants ¶
const ( FT_REG_FILE = 1 FT_DIR = 2 FT_CHRDEV = 3 FT_BLKDEV = 4 FT_FIFO = 5 FT_SOCK = 6 FT_SYMLINK = 7 )
Linux values for fs on-disk file types.
const ( S_IFMT = 0170000 S_IFSOCK = 0140000 S_IFLNK = 0120000 S_IFREG = 0100000 S_IFBLK = 060000 S_IFDIR = 040000 S_IFCHR = 020000 S_IFIFO = 010000 S_ISUID = 04000 S_ISGID = 02000 S_ISVTX = 01000 )
Values for mode_t.
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 ( BlockSize = 4096 BlockSizeBits = 12 InodeSlotSize = 1 << InodeSlotBits MaxInlineDataSize = BlockSize / 4 )
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 ¶
var DirentSize = int64(binary.Size(Dirent{}))
Functions ¶
Types ¶
type Dirent ¶
type Dirent struct { Nid uint64 // Inode number NameOff uint16 // Offset of file name FileType uint8 // File type Reserved uint8 // Reserved for future use }
Dirent represents on-disk directory entry.
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
func (*Filesystem) ReadLink ¶
func (fsys *Filesystem) ReadLink(name string) (string, error)
ReadLink returns the destination of the named symbolic link. Experimental implementation of: https://github.com/golang/go/issues/49580
func (*Filesystem) StatLink ¶
func (fsys *Filesystem) StatLink(name string) (fs.FileInfo, error)
StatLink returns a FileInfo describing the file without following any symbolic links. Experimental implementation of: https://github.com/golang/go/issues/49580
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents an open EROFS image.
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 an inode object.
func (*Inode) DataLayout ¶
DataLayout returns the inode data layout.
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.
type InodeCompact ¶
type InodeCompact struct { Format uint16 // Inode format hints XattrCount uint16 // Xattr entry count Mode uint16 // File mode Nlink uint16 // Number of hard links Size uint32 // File size in bytes Reserved uint32 // Reserved for future use RawBlockAddr uint32 // Raw block address Ino uint32 // Inode number UID uint16 // User ID of owner GID uint16 // Group ID of owner Reserved2 uint32 // Reserved for future use }
InodeCompact represents 32-byte reduced form of on-disk inode.
type InodeExtended ¶
type InodeExtended struct { Format uint16 // Inode format hints XattrCount uint16 // Xattr entry count Mode uint16 // File mode Reserved uint16 // Reserved for future use Size uint64 // File size in bytes RawBlockAddr uint32 // Raw block address Ino uint32 // Inode number UID uint32 // User ID of owner GID uint32 // Group ID of owner Mtime uint64 // Last modification time MtimeNsec uint32 // Nanoseconds part of Mtime Nlink uint32 // Number of hard links Reserved2 [16]uint8 // Reserved for future use }
InodeExtended represents 64-byte complete form of on-disk inode.
type SuperBlock ¶
type SuperBlock struct { Magic uint32 // Filesystem magic number Checksum uint32 // CRC32C checksum of the superblock FeatureCompat uint32 // Compatible feature flags BlockSizeBits uint8 // Filesystem block size in bit shift ExtSlots uint8 // Superblock extension slots RootNid uint16 // Root directory inode number Inodes uint64 // Total valid inodes BuildTime uint64 // Build time of the filesystem BuildTimeNsec uint32 // Nanoseconds part of build time Blocks uint32 // Total number of blocks MetaBlockAddr uint32 // Start block address of metadata area XattrBlockAddr uint32 // Start block address of shared xattr area UUID [16]uint8 // UUID for volume VolumeName [16]uint8 // Volume name FeatureIncompat uint32 // Incompatible feature flags Union1 uint16 // Union for additional features ExtraDevices uint16 // Number of extra devices DevTableSlotOff uint16 // Device table slot offset Reserved [38]uint8 // Reserved for future use }
SuperBlock represents on-disk superblock.
func (*SuperBlock) BlockAddrToOffset ¶
func (sb *SuperBlock) BlockAddrToOffset(addr uint32) int64
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() int64
MetaOffset returns the offset of metadata area in image file.
func (*SuperBlock) NidToOffset ¶
func (sb *SuperBlock) NidToOffset(nid uint64) int64
NidToOffset converts inode number to the offset in image file.