vfs

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package vfs provides bindings and iterators over proc_pid_mountinfo(5).

Index

Constants

View Source
const (
	MS_NOSYMFOLLOW = 0x100
)

Variables

View Source
var (
	ErrMountInfoFields = errors.New("unexpected field count")
	ErrMountInfoEmpty  = errors.New("unexpected empty field")
	ErrMountInfoDevno  = errors.New("bad maj:min field")
	ErrMountInfoSep    = errors.New("bad optional fields separator")
)

Functions

func Unmangle

func Unmangle(s string) string

Types

type DecoderError added in v0.2.2

type DecoderError struct {
	Op   string
	Line int
	Err  error
}

func (*DecoderError) Error added in v0.2.2

func (e *DecoderError) Error() string

func (*DecoderError) Unwrap added in v0.2.2

func (e *DecoderError) Unwrap() error

type DevT

type DevT [2]int

type MountInfo

type MountInfo struct {
	Next *MountInfo
	MountInfoEntry
}

MountInfo represents the contents of a proc_pid_mountinfo(5) document.

type MountInfoDecoder

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

A MountInfoDecoder reads and decodes proc_pid_mountinfo(5) entries from an input stream.

func NewMountInfoDecoder

func NewMountInfoDecoder(r io.Reader) *MountInfoDecoder

NewMountInfoDecoder returns a new decoder that reads from r.

The decoder introduces its own buffering and may read data from r beyond the mountinfo entries requested.

func (*MountInfoDecoder) Decode

func (d *MountInfoDecoder) Decode(v **MountInfo) (err error)

func (*MountInfoDecoder) Entries

func (d *MountInfoDecoder) Entries() iter.Seq[*MountInfoEntry]

Entries returns an iterator over mountinfo entries.

func (*MountInfoDecoder) Err

func (d *MountInfoDecoder) Err() error

func (*MountInfoDecoder) Unfold

func (d *MountInfoDecoder) Unfold(target string) (*MountInfoNode, error)

Unfold unfolds the mount hierarchy and resolves covered paths.

type MountInfoEntry

type MountInfoEntry struct {
	// mount ID: a unique ID for the mount (may be reused after umount(2)).
	ID int `json:"id"`
	// parent ID: the ID of the parent mount (or of self for the root of this mount namespace's mount tree).
	Parent int `json:"parent"`
	// major:minor: the value of st_dev for files on this filesystem (see stat(2)).
	Devno DevT `json:"devno"`
	// root: the pathname of the directory in the filesystem which forms the root of this mount.
	Root string `json:"root"`
	// mount point: the pathname of the mount point relative to the process's root directory.
	Target string `json:"target"`
	// mount options: per-mount options (see mount(2)).
	VfsOptstr string `json:"vfs_optstr"`
	// optional fields: zero or more fields of the form "tag[:value]"; see below.
	// separator: the end of the optional fields is marked by a single hyphen.
	OptFields []string `json:"opt_fields"`
	// filesystem type: the filesystem type in the form "type[.subtype]".
	FsType string `json:"fstype"`
	// mount source: filesystem-specific information or "none".
	Source string `json:"source"`
	// super options: per-superblock options (see mount(2)).
	FsOptstr string `json:"fs_optstr"`
}

MountInfoEntry represents a proc_pid_mountinfo(5) entry.

func (*MountInfoEntry) EqualWithIgnore

func (e *MountInfoEntry) EqualWithIgnore(want *MountInfoEntry, ignore string) bool

func (*MountInfoEntry) Flags

func (e *MountInfoEntry) Flags() (flags uintptr, unmatched []string)

Flags interprets VfsOptstr and returns the resulting flags and unmatched options.

func (*MountInfoEntry) String

func (e *MountInfoEntry) String() string

type MountInfoNode

type MountInfoNode struct {
	*MountInfoEntry
	FirstChild  *MountInfoNode `json:"first_child"`
	NextSibling *MountInfoNode `json:"next_sibling"`

	Clean   string `json:"clean"`
	Covered bool   `json:"covered"`
}

MountInfoNode positions a MountInfoEntry in its mount hierarchy.

func (*MountInfoNode) Collective

func (n *MountInfoNode) Collective() iter.Seq[*MountInfoNode]

Collective returns an iterator over visible mountinfo nodes.

type UnfoldTargetError added in v0.2.2

type UnfoldTargetError string

func (UnfoldTargetError) Error added in v0.2.2

func (e UnfoldTargetError) Error() string

Jump to

Keyboard shortcuts

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