instcmd

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: 18 Imported by: 0

Documentation

Overview

Package instcmd executes the shell session IRIX inst opens over rsh. inst runs "exec /bin/sh" and streams real shell grammar to it - pipes, subshells, trap, $? - so RunShell (shell.go) serves an actual POSIX interpreter wired to a constrained read-only command set rather than pattern-matching the grammar inst is expected to send.

Index

Constants

This section is empty.

Variables

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

ErrNotFound is returned by a FileSystem for missing paths.

Functions

func RunShell

func RunShell(fsys FileSystem, stdin io.Reader, stdout, stderr io.Writer, logger *logging.Logger, sess *capture.Session) error

RunShell serves the shell inst opens over rsh with "exec /bin/sh": one mvdan/sh Runner for the life of the connection, fed one line at a time so state (variables, trap registrations, $?) persists across lines the way a real shell's does. logger, when set, records every line at DEBUG for observability and ERROR/WARN for anything a leaf command refuses or fails - see shellEnv's own comment for that distinction. A command that fails writes its own diagnostic to stderr and the shell keeps going - a real shell continues past a ';'-separated failure - matching inst's expectation that the trailing marker wrapper always still runs.

Types

type File

type File interface {
	io.ReaderAt
	Size() int64
}

File is an open, random-access file.

type FileInfo

type FileInfo struct {
	Ino   uint64
	IsDir bool
	Perm  uint32 // permission bits incl. setuid/setgid/sticky, e.g. 0o4755
	Nlink int
	UID   uint32
	GID   uint32
	Size  int64
	Mtime time.Time
}

FileInfo is a path's metadata: what the rsh shell needs to answer ls -l/-i and cd/test's file-type checks, not a full stat(2). A path above the real filesystem's own boundary (a synthetic tree level) carries plausible placeholder values instead of a real inode's.

type FileSystem

type FileSystem interface {
	Open(path string) (File, error)
	ReadDir(path string) ([]string, error)
	Stat(path string) (FileInfo, error)
}

FileSystem is the tree commands read from.

type ImageResolver

type ImageResolver interface {
	ResolveImage(path string) (Resolved, error)
}

ImageResolver is optionally implemented by a FileSystem that can say which image file and in-image path a served path came from, for the steady-state served-file manifest line dd and cat emit at INFO. A FileSystem that doesn't back onto named media (a test double, say) need not implement it; a leaf command that wants it type-asserts and only logs the manifest line when it can.

type Resolved

type Resolved struct {
	Image string
	Path  string
}

Resolved is what ImageResolver reports: Image is the backing image's filename, Path is the location within that image's own filesystem.

Jump to

Keyboard shortcuts

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