efs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 9 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

View Source
var ErrNotFound = errors.New("efs: not found")

ErrNotFound reports that a path component does not name an entry. It is distinct from an I/O or corruption error reading the filesystem, so a caller can map a genuine absence to fs.ErrNotExist while surfacing a real read failure as itself rather than a misleading "not found".

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) FSys added in v0.2.0

func (fs *FS) FSys() fs.FS

FSys returns an io/fs.FS view of the filesystem: path-addressed and read only. It also satisfies fs.ReadDirFS, fs.StatFS and fs.ReadLinkFS. Symlinks are left unfollowed, exactly as Lookup leaves them, so a caller resolves them through ReadLink; opened regular files also satisfy io.ReaderAt, so a server random-accesses a product file without buffering it.

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.

type Stat added in v0.2.0

type Stat struct {
	UID   uint16
	GID   uint16
	Nlink int16
	Mode  uint16
}

Stat is the FileInfo.Sys() value for every entry an EFS fs view returns: the owner, link count, and full mode io/fs.FileInfo cannot carry on its own. Mode is the raw inode mode, including the setuid, setgid, and sticky bits that FileInfo.Mode() masks away, so a caller that serves those bits can recover them.

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