efstest

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package efstest builds tiny synthetic EFS images for tests. Everything instigator serves in CI is generated here — no SGI-derived bytes enter the tree. Geometry is fixed small: one cylinder group, 2 inode blocks (8 inodes), 64 blocks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder assembles an EFS image in memory. The zero value is not usable; call New.

func New

func New() *Builder

New returns a Builder holding a valid superblock. Inode 2 is reserved for the root directory; populate it with SetRoot.

func (*Builder) AddData

func (b *Builder) AddData(data []byte) (bn int64, nblocks uint32)

AddData writes raw bytes into consecutive data blocks and returns the run's first block and block count.

func (*Builder) AddDir

func (b *Builder) AddDir(entries map[string]uint32) uint32

AddDir stores a directory and returns its inode number.

func (*Builder) AddFIFO

func (b *Builder) AddFIFO() uint32

AddFIFO stores a named pipe and returns its inode number. It exists so a test can aim a symlink at something that is neither a directory nor a regular file, which is the one shape real media occasionally carries and the tree refuses to serve.

func (*Builder) AddFile

func (b *Builder) AddFile(perm uint16, data []byte) uint32

AddFile stores data as a regular file in one extent and returns its inode number.

func (*Builder) AddFileExtents

func (b *Builder) AddFileExtents(size int32, extents [][3]uint32) uint32

AddFileExtents stores a file whose extent list is given explicitly.

func (*Builder) AddFileIndirect

func (b *Builder) AddFileIndirect(size int32, extents [][3]uint32) uint32

AddFileIndirect stores a file with its extent table in an indirect block, EFS's layout once a file has more than 12 extents.

func (b *Builder) AddSymlink(target string) uint32

AddSymlink stores a symlink and returns its inode number.

func (*Builder) Bytes

func (b *Builder) Bytes() []byte

Bytes lays the image out contiguously, filesystem block 0 first.

func (*Builder) CDImage

func (b *Builder) CDImage(base int64, bootFiles map[string][]byte) []byte

CDImage wraps the filesystem in an SGI volume header the way install media are laid out: header at block 0, EFS partition in slot 7 at base, optional raw boot files in the volume directory.

func (*Builder) PutInode

func (b *Builder) PutInode(ino uint32, mode uint16, size int32, mtime uint32, extents [][3]uint32)

PutInode writes a raw 128-byte inode. Extents are {block, length, logical offset} triples.

func (*Builder) SetRoot

func (b *Builder) SetRoot(entries map[string]uint32)

SetRoot writes the root directory (inode 2).

Jump to

Keyboard shortcuts

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