sys

package
v7.0.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupTestCerts

func SetupTestCerts(dir string) error

SetupTestCerts populates the given test directory with server certificates.

Since generating certificates is CPU intensive, they will be simply symlink'ed from the test/deps/ directory.

FIXME: this function is exported because some tests use it
	directly. Eventually we should rework those tests to use NewTestOS
	instead.

Types

type InotifyInfo

type InotifyInfo struct {
	Fd int
	sync.RWMutex
	Targets map[string]*InotifyTargetInfo
}

InotifyInfo records the inotify information associated with a given inotify instance.

type InotifyTargetInfo

type InotifyTargetInfo struct {
	Mask uint32
	Wd   int
	Path string
}

InotifyTargetInfo records the inotify information associated with a given inotify target.

type OS

type OS struct {
	// Directories
	CacheDir string // Cache directory (e.g. /var/cache/incus/).
	LogDir   string // Log directory (e.g. /var/log/incus/).
	RunDir   string // Runtime directory (e.g. /run/incus/).
	VarDir   string // Data directory (e.g. /var/lib/incus/).

	// Daemon environment
	Architectures   []int      // Cache of detected system architectures
	BackingFS       string     // Backing filesystem of $INCUS_DIR/containers
	ExecPath        string     // Absolute path to the daemon
	IdmapSet        *idmap.Set // Information about user/group ID mapping
	InotifyWatch    InotifyInfo
	LxcPath         string // Path to the $INCUS_DIR/containers directory
	MockMode        bool   // If true some APIs will be mocked (for testing)
	Nodev           bool
	RunningInUserNS bool
	Hostname        string

	// Privilege dropping
	UnprivUser  string
	UnprivUID   uint32
	UnprivGroup string
	UnprivGID   uint32

	// Apparmor features
	AppArmorAdmin     bool
	AppArmorAvailable bool
	AppArmorConfined  bool
	AppArmorStacked   bool
	AppArmorStacking  bool

	// SELinux features
	SELinuxAvailable          bool
	SELinuxContextDaemon      string
	SELinuxContextInstanceLXC string

	// LXC features
	LXCFeatures map[string]bool

	// OS info
	ReleaseInfo map[string]string
	Uname       *linux.Utsname
	BootTime    time.Time
	IncusOS     *incusos.Client
}

OS is a high-level facade for accessing operating-system level functionalities.

func DefaultOS

func DefaultOS() *OS

DefaultOS returns a fresh uninitialized OS instance with default values.

func NewTestOS

func NewTestOS(t *testing.T) (*OS, func())

NewTestOS returns a new OS instance initialized with test values.

func (*OS) GetUnixSocket

func (s *OS) GetUnixSocket() string

GetUnixSocket returns the full path to the unix.socket file that this daemon is listening on. Used by tests.

func (*OS) GlobalDatabaseDir

func (s *OS) GlobalDatabaseDir() string

GlobalDatabaseDir returns the path of the global database directory.

func (*OS) GlobalDatabasePath

func (s *OS) GlobalDatabasePath() string

GlobalDatabasePath returns the path of the global database SQLite file managed by dqlite.

func (*OS) Init

func (s *OS) Init() ([]cluster.Warning, error)

Init our internal data structures.

func (*OS) InitStorage

func (s *OS) InitStorage() error

InitStorage initializes the storage layer after it has been mounted.

func (*OS) LocalDatabasePath

func (s *OS) LocalDatabasePath() string

LocalDatabasePath returns the path of the local database file.

Jump to

Keyboard shortcuts

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