package
0.0.0-20250312152250-ea85ec9d2454
Repository: https://github.com/snapcore/snapd.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
Package epoll contains a thin wrapper around the epoll(7) facility.
No description provided by the author
Package inotify implements a wrapper for the Linux inotify system.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddUser uses the Debian/Ubuntu/derivative 'adduser' command for creating regular login users on Ubuntu Core.
AtomicLink attempts to atomically create a hardlink at linkPath, referencing the given target.
AtomicRename attempts to rename a path from oldName to newName atomically.
AtomicSymlink attempts to atomically create a symlink at linkPath, pointing to a given target.
The AtomicWrite* family of functions work like os.WriteFile(), but the file created is an AtomicWriter, which is Committed before returning.
No description provided by the author
No description provided by the author
No description provided by the author
AtomicWriteFileCopy writes to dst a copy of src using AtomicFile internally to create the destination.
BootID returns the unique system-generated boot identifier.
ChDir runs runs "f" inside the given directory Note that this will only work reliable in a single-threaded context.
CheckFreeSpace checks if there is enough disk space for the given path.
CombineStdOutErr combines stdout and stderr byte arrays into a single one.
ComparePathsByDeviceInode compares the devices and inodes of the given paths, following symlinks.
ContextWriter returns a discarding io.Writer which Write method returns an error once the context is done.
CopyFile copies src to dst.
CopySpecialFile is used to copy all the things that are not files (like device nodes, named pipes etc).
DelUser removes a "regular login user" from the system, including their home.
DirExists checks whether a given path exists, and if so whether it is a directory.
EnsureDirState ensures that directory content matches expectations.
EnsureDirStateGlobs ensures that directory content matches expectations.
EnsureFileState ensures that the file is in the expected state.
EnsureSnapUserGroup uses the standard shadow utilities' 'useradd' and 'groupadd' commands for creating non-login system users and groups that is portable cross-distro.
EnsureTreeState ensures that a directory tree content matches expectations.
Escape returns the given path with space, tab, newline and forward slash escaped.
ExecutableExists returns whether there an exists an executable with the given name somewhere on $PATH.
ExitCode extract the exit code from the error of a failed cmd.Run() or the original error if its not a exec.ExitError.
FileDigest computes a hash digest of the file using the given hash.
FileExists return true if given path can be stat()ed by us.
FilesAreEqual compares the two files' contents and returns whether they are the same.
FindGidOwning obtains UNIX group ID and name owning file `path`.
GetAttr retrieves the attributes of a file on a linux filesystem.
GetenvBool returns whether the given key may be considered "set" in the environment (i.e.
GetenvInt64 interprets the value of the given environment variable as an int64 and returns the corresponding value.
GetTermWinsize performs the TIOCGWINSZ ioctl on stdout.
IsDevice checks if the given os.FileMode coresponds to a device (char/block).
IsDirectory return true if the given path can be stat()ed by us and is a directory.
IsDirNotExist tells you whether the given error is due to a directory not existing.
IsExecutable returns true when given path points to an executable file.
No description provided by the author
IsMounted checks if a given directory is a mount point.
No description provided by the author
IsSymlink returns true if the given file is a symlink.
IsTestBinary checks whether the current process is a go test binary.
No description provided by the author
No description provided by the author
IsWritable checks if the given file/directory can be written by the current user.
KillProcessGroup kills the process group associated with the given command.
LoadMountInfo loads list of mounted entries from /proc/self/mountinfo.
LoadMountProfile loads a mount profile from a given file.
LoadMountProfileText loads a mount profile from a given string.
LookPathDefault searches for a given command name in all directories listed in the environment variable PATH and returns the found path or the provided default path.
No description provided by the author
MaybeInjectFault is an empty implementation for builds with fault injection disabled.
MkdirAllChown is like os.MkdirAll but it calls os.Chown on any directories it creates.
No description provided by the author
No description provided by the author
MockIsHomeUsingRemoteFS mocks the real implementation of osutil.IsHomeUsingRemoteFS.
MockIsRootWritableOverlay mocks the real implementation of osutil.IsRootWritableOverlay.
MockKernelVersion replaces the function that returns the kernel version string.
No description provided by the author
No description provided by the author
this should not be used except to test the actual implementation logic of LoadMountInfo, if you are trying to mock /proc/self/mountinfo in a test, use MockMountInfo(), which is exported and the right way to do that.
Allow other test suites to mock this functionality.
MountOptsToCommonFlags converts mount options strings to a mount flag, returning unparsed flags.
MountOptsToFlags converts mount options strings to a mount flag.
MustBeTestBinary checks whether the executing process is a go test binary, panics otherwise.
MyBuildID return the build-id of the currently running executable.
NewAtomicFile builds an AtomicFile backed by an *os.File that will have the given filename, permissions and uid/gid when Committed.
NewExpandableEnv returns a new expandable environment comprised of given pairs.
NewFileLock creates and opens the lock file given by "path" with mode 0600.
NewFileLockWithFile wraps an open file with a file lock which can be used for locking.
NewFileLockWithMode creates and opens the lock file given by "path" with the given mode.
OpenExistingLockForReading opens an existing lock file given by "path".
OSEnvironment returns the environment of the calling process.
OSEnvironmentUnescapeUnsafe returns the environment of the calling process.
OutputErr formats an error based on output if its length is not zero, or returns err otherwise.
OutputErr formats an error based on output if its length is not zero, or returns err otherwise.
ParseMountEntry parses a fstab-like entry.
ParseMountInfoEntry parses a single line of /proc/$PID/mountinfo file.
ReadBuildID returns the build ID of a given binary.
Readlinkat is a direct pass-through to the readlinkat(2) system call.
ReadMountInfo reads and parses a mountinfo file.
ReadMountProfile reads and parses a mount profile.
RegularFileExists checks whether a given path exists, and if so whether it is a regular file.
ReplaceMountEntryOption replaces the first mount entry option that has the same prefix as the given option with the given option.
ResolvePathInSysroot resolves a path within a sysroot In a sysroot, abolute symlinks should be relative to the sysroot rather than `/`.
ResolvePathNoEscape resolves a path within a pseudo sysroot Like ResolvePathInSysroot(), it resolves path as if it was a sysroot.
RunAndWait runs a command for the given argv with the given environ added to os.Environ, killing it if it reaches timeout, or if the tomb is dying.
RunCmd runs a command and returns separately stdout and stderr output, and an error.
RunSplitOutput runs name command with arg arguments and returns stdout, stderr, and an error.
RunWithContext runs the given command, but kills it if the context becomes done before the command finishes.
No description provided by the author
SetAttr sets the attributes of a file on a linux filesystem to the given value.
SetTime sets the time of the system using settimeofday().
StreamCommand runs a the named program with the given arguments, streaming its standard output over the returned io.ReadCloser.
StreamsEqual compares two streams and returns true if both have the same content.
SwapDirs swaps oldpath with newpath in an atomic way from the point of view of the running system.
Symlinkat is a direct pass-through to the symlinkat(2) system call.
TotalUsableMemory returns the total usable memory in the system in bytes.
UidGid returns the uid and gid of the given user, as uint32s XXX this should go away soon.
Unescape returns the given path with space, tab, newline and forward slash unescaped.
UnlinkMany removes multiple files from a single directory.
UnlinkManyAt is like UnlinkMany but takes an open directory *os.File instead of a dirname.
UserMaybeSudoUser finds the user behind a sudo invocation when root, if applicable and possible.
UsernamesToUids converts a list of usernames to map indexed by their UID, i.e the call UsernamesToUids([]string{"root"}) may return { 0, "root" }.
XSnapdDetach returns the string "x-snapd.detach".
XSnapdGroup returns the string "x-snapd.group=%d".
XSnapdIgnoreMissing returns the string "x-snapd.ignore-missing".
XSnapdKindEnsureDir returns the string "x-snapd.kind=ensure-dir".
XSnapdKindFile returns the string "x-snapd.kind=file".
XSnapdKindSymlink returns the string "x-snapd.kind=symlink".
XSnapdMode returns the string "x-snapd.mode=%#o".
XSnapdMustExistDir returns the string "x-snapd.must-exist-dir=%s".
XSnapdNeededBy returns the string "x-snapd.needed-by=..." with the given path appended.
XSnapdOriginLayout returns the string "x-snapd.origin=layout".
XSnapdOriginOvername returns the string "x-snapd.origin=overname".
XSnapdSymlink returns the string "x-snapd.symlink=%s".
XSnapdSynthetic returns the string "x-snapd.synthetic".
XSnapdUser returns the string "x-snapd.user=%d".

# Constants

AtomicWriteFollow makes AtomicWriteFile follow symlinks.
CopyFlagDefault is the default behaviour.
CopyFlagOverwrite overwrites the target if it exists.
CopyFlagPreserveAll preserves mode,owner,time attributes.
CopyFlagSync does a sync after copying the files.
writes to file may only append */.
btree format dir */.
Compress file */.
One or more compressed clusters */.
Use direct i/o */.
dirsync behaviour (directories only) */.
No description provided by the author
Compression error */.
Extents */.
AFS directory */.
Immutable file */.
hash-indexed directory */.
Reserved for ext3 */.
do not update atime */.
Don't compress */.
Do not cow file */.
do not dump file */.
file tail should not be merged */.
Create with parents projid */.
reserved for ext2 lib */.
Secure deletion */.
Synchronous updates */.
Top of directory hierarchies*/.
Undelete */.
No description provided by the author

# Variables

No description provided by the author
ErrCannotCancel means the Commit operation failed at the last step, and your luck has run out.
ErrNoBuildID is returned when an executable does not contain a Build-ID.
ErrSameState is returned when the state of a file has not changed.
FindGid returns the identifier of the given UNIX group name.
FindUid returns the identifier of the given UNIX user name.
IsValidSnapSystemUsername defines what is valid for the "system-usernames" stanza in the snap.yaml.
We check the (user)name ourselves, adduser is a bit too strict (i.e.
No description provided by the author

# Structs

No description provided by the author
An AtomicFile is similar to an os.File but it has an additional Commit() method that does whatever needs to be done so the modification is "atomic": an AtomicFile will do its best to leave either the previous content or the new content in permanent storage.
CopySpecialFileError is returned if a special file copy fails.
No description provided by the author
ExpandableEnv represents alterations to an environment as ordered key, value entries.
FileLock describes a file system lock.
FileReference describes the desired content by referencing an existing file.
FileReferencePlusMode describes the desired content by referencing an existing file and providing custom mode.
MemoryFileState describes the desired content by providing an in-memory copy.
MountEntry describes an /etc/fstab-like mount entry.
MountInfoEntry contains data from /proc/$PID/mountinfo For details please refer to mountinfo documentation at https://www.kernel.org/doc/Documentation/filesystems/proc.txt.
MountProfile represents an array of mount entries.
No description provided by the author
No description provided by the author
SymlinkFileState describes the desired symlink by providing its target.
Winsize is from tty_ioctl(4).

# Interfaces

FileState is an interface for conveying the desired state of a some file.

# Type aliases

AtomicWriteFlags are a bitfield of flags for AtomicWriteFile.
CopyFlag is used to tweak the behaviour of CopyFile.
Environment is an unordered map of key=value strings.