efs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package efs reads the SGI EFS filesystem: 512-byte basic blocks, 128-byte inodes grouped in cylinder groups, extent-mapped files. Read only — this package serves install media, it never writes.

Index

Constants

View Source
const (
	SuperMagic      = 0x00072959
	SuperMagicGrown = 0x0007295a
)

SuperMagic is the classic EFS superblock magic. SuperMagicGrown marks a grown filesystem; both are accepted.

View Source
const RootIno uint32 = 2

RootIno is the inode number of the filesystem root directory.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry

type DirEntry struct {
	Name string
	Ino  uint32
}

DirEntry is one directory entry.

type Extent

type Extent struct {
	Block  uint32 // first basic block, filesystem-relative
	Len    uint32 // run length in blocks
	Offset uint32 // logical block offset within the file
}

Extent is one contiguous run of basic blocks. Offset is the logical block position within the file; a gap between extents is a hole that reads as zeros.

type FS

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

FS is an open EFS filesystem over a block image.

func Open

func Open(r io.ReaderAt, baseBlock int64) (*FS, error)

Open reads and validates the superblock of the EFS filesystem starting at baseBlock (in 512-byte blocks) within r.

func (*FS) Inode

func (fs *FS) Inode(ino uint32) (*Inode, error)

Inode reads inode number ino.

func (*FS) Lookup

func (fs *FS) Lookup(path string) (*Inode, error)

Lookup resolves a slash-separated path from the root. Symlinks in the path are not followed; install media use them rarely and the callers serve them as links.

func (*FS) ReadAt

func (fs *FS) ReadAt(ino *Inode, p []byte, off int64) (int, error)

ReadAt reads from the file at byte offset off into p, returning io.EOF past the end as io.ReaderAt requires. Holes between extents read as zeros.

func (*FS) ReadDir

func (fs *FS) ReadDir(ino *Inode) ([]DirEntry, error)

ReadDir parses directory blocks: magic 0xbeef, a slot-offset table, and entries of inode number, name length, name.

func (fs *FS) Readlink(ino *Inode) (string, error)

Readlink returns a symlink's target, stored as the link's file content.

type Inode

type Inode struct {
	Num   uint32
	Mode  uint16
	Nlink int16
	UID   uint16
	GID   uint16
	Size  int32
	Atime uint32
	Mtime uint32
	Ctime uint32
	Gen   int32

	Extents []Extent // sorted by Offset
}

Inode is a parsed EFS inode.

func (*Inode) IsDir

func (i *Inode) IsDir() bool

IsDir reports whether the inode is a directory.

func (*Inode) IsRegular

func (i *Inode) IsRegular() bool

IsRegular reports whether the inode is a regular file.

func (i *Inode) IsSymlink() bool

IsSymlink reports whether the inode is a symbolic link.

Directories

Path Synopsis
Package efstest builds tiny synthetic EFS images for tests.
Package efstest builds tiny synthetic EFS images for tests.

Jump to

Keyboard shortcuts

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