linux

package
v0.0.0-...-224ba89 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	O_ACCMODE  = 000000003
	O_RDONLY   = 000000000
	O_WRONLY   = 000000001
	O_RDWR     = 000000002
	O_CREAT    = 000000100
	O_EXCL     = 000000200
	O_NOCTTY   = 000000400
	O_TRUNC    = 000001000
	O_APPEND   = 000002000
	O_NONBLOCK = 000004000
	O_DSYNC    = 000010000
	O_ASYNC    = 000020000
	O_NOATIME  = 001000000
	O_CLOEXEC  = 002000000
	O_SYNC     = 004000000 // __O_SYNC in Linux
	O_PATH     = 010000000
	O_TMPFILE  = 020000000 // __O_TMPFILE in Linux
)

Constants for open(2).

View Source
const (
	MS_RDONLY      = 0x1
	MS_NOSUID      = 0x2
	MS_NODEV       = 0x4
	MS_NOEXEC      = 0x8
	MS_SYNCHRONOUS = 0x10
	MS_REMOUNT     = 0x20
	MS_MANDLOCK    = 0x40
	MS_DIRSYNC     = 0x80
	MS_NOATIME     = 0x400
	MS_NODIRATIME  = 0x800
	MS_BIND        = 0x1000
	MS_MOVE        = 0x2000
	MS_REC         = 0x4000

	MS_POSIXACL    = 0x10000
	MS_UNBINDABLE  = 0x20000
	MS_PRIVATE     = 0x40000
	MS_SLAVE       = 0x80000
	MS_SHARED      = 0x100000
	MS_RELATIME    = 0x200000
	MS_KERNMOUNT   = 0x400000
	MS_I_VERSION   = 0x800000
	MS_STRICTATIME = 0x1000000

	MS_MGC_VAL = 0xC0ED0000
	MS_MGC_MSK = 0xffff0000
)

Constants for mount(2).

View Source
const (
	MNT_FORCE       = 0x1
	MNT_DETACH      = 0x2
	MNT_EXPIRE      = 0x4
	UMOUNT_NOFOLLOW = 0x8
)

Constants for umount2(2).

View Source
const (
	AT_SYMLINK_FOLLOW = 0x400
	AT_EMPTY_PATH     = 0x1000
)

Constants for linkat(2) and fchownat(2).

View Source
const (
	UTIME_NOW  = ((1 << 30) - 1)
	UTIME_OMIT = ((1 << 30) - 2)
)

Special values for the ns field in utimensat(2).

View Source
const (
	LOCK_SH = 1 // shared lock
	LOCK_EX = 2 // exclusive lock
	LOCK_NB = 4 // or'd with one of the above to prevent blocking
	LOCK_UN = 8 // remove lock
)

Constants for flock(2).

View Source
const (
	S_IFMT   = 0170000
	S_IFSOCK = 0140000
	S_IFLNK  = 0120000
	S_IFREG  = 0100000
	S_IFBLK  = 060000
	S_IFDIR  = 040000
	S_IFCHR  = 020000
	S_IFIFO  = 010000

	FileTypeMask        = S_IFMT
	ModeSocket          = S_IFSOCK
	ModeSymlink         = S_IFLNK
	ModeRegular         = S_IFREG
	ModeBlockDevice     = S_IFBLK
	ModeDirectory       = S_IFDIR
	ModeCharacterDevice = S_IFCHR
	ModeNamedPipe       = S_IFIFO

	S_ISUID = 04000
	S_ISGID = 02000
	S_ISVTX = 01000

	ModeSetUID = S_ISUID
	ModeSetGID = S_ISGID
	ModeSticky = S_ISVTX

	ModeUserAll     = 0700
	ModeUserRead    = 0400
	ModeUserWrite   = 0200
	ModeUserExec    = 0100
	ModeGroupAll    = 0070
	ModeGroupRead   = 0040
	ModeGroupWrite  = 0020
	ModeGroupExec   = 0010
	ModeOtherAll    = 0007
	ModeOtherRead   = 0004
	ModeOtherWrite  = 0002
	ModeOtherExec   = 0001
	PermissionsMask = 0777
)

Values for mode_t.

View Source
const (
	DT_UNKNOWN = 0
	DT_FIFO    = 1
	DT_CHR     = 2
	DT_DIR     = 4
	DT_BLK     = 6
	DT_REG     = 8
	DT_LNK     = 10
	DT_SOCK    = 12
	DT_WHT     = 14
)

Values for linux_dirent64.d_type.

View Source
const (
	// NOTE(b/120162627): not implemented the RWF_HIPRI feature, but
	// the flag is accepted as a valid flag argument for preadv2/pwritev2 and
	// silently ignored.
	RWF_HIPRI = 0x00000001
	RWF_DSYNC = 0x00000002
	RWF_SYNC  = 0x00000004
	RWF_VALID = RWF_HIPRI | RWF_DSYNC | RWF_SYNC
)

Values for preadv2/pwritev2.

View Source
const (
	AT_STATX_SYNC_TYPE    = 0x6000
	AT_STATX_SYNC_AS_STAT = 0x0000
	AT_STATX_FORCE_SYNC   = 0x2000
	AT_STATX_DONT_SYNC    = 0x4000
)

Flags for statx.

View Source
const (
	STATX_TYPE        = 0x00000001
	STATX_MODE        = 0x00000002
	STATX_NLINK       = 0x00000004
	STATX_UID         = 0x00000008
	STATX_GID         = 0x00000010
	STATX_ATIME       = 0x00000020
	STATX_MTIME       = 0x00000040
	STATX_CTIME       = 0x00000080
	STATX_INO         = 0x00000100
	STATX_SIZE        = 0x00000200
	STATX_BLOCKS      = 0x00000400
	STATX_BASIC_STATS = 0x000007ff
	STATX_BTIME       = 0x00000800
	STATX_ALL         = 0x00000fff
	STATX__RESERVED   = 0x80000000
)

Mask values for statx.

View Source
const (
	STATX_ATTR_COMPRESSED = 0x00000004
	STATX_ATTR_IMMUTABLE  = 0x00000010
	STATX_ATTR_APPEND     = 0x00000020
	STATX_ATTR_NODUMP     = 0x00000040
	STATX_ATTR_ENCRYPTED  = 0x00000800
	STATX_ATTR_AUTOMOUNT  = 0x00001000
)

Bitmasks for Statx.Attributes and Statx.AttributesMask, from include/uapi/linux/stat.h.

View Source
const (
	AT_FDCWD = -100
)

Constants for all file-related ...at(2) syscalls.

View Source
const (
	AT_REMOVEDIR = 0x200
)

Constants for unlinkat(2).

View Source
const (
	AT_SYMLINK_NOFOLLOW = 0x100
)

Constants for fstatat(2).

View Source
const MaxSymlinkTraversals = 40

MaxSymlinkTraversals is the maximum number of links that will be followed by the kernel to resolve a symlink.

Variables

View Source
var DirentType = ValueSet{
	DT_UNKNOWN: "DT_UNKNOWN",
	DT_FIFO:    "DT_FIFO",
	DT_CHR:     "DT_CHR",
	DT_DIR:     "DT_DIR",
	DT_BLK:     "DT_BLK",
	DT_REG:     "DT_REG",
	DT_LNK:     "DT_LNK",
	DT_SOCK:    "DT_SOCK",
	DT_WHT:     "DT_WHT",
}

DirentType are the friendly strings for linux_dirent64.d_type.

Functions

This section is empty.

Types

type FileMode

type FileMode uint16

FileMode represents a mode_t.

func (FileMode) DirentType

func (m FileMode) DirentType() uint8

DirentType maps file types to dirent types appropriate for (struct dirent)::d_type.

func (FileMode) ExtraBits

func (m FileMode) ExtraBits() FileMode

ExtraBits returns everything but the file type and permission bits.

func (FileMode) FSMode

func (m FileMode) FSMode() fs.FileMode

Mode returns fs.FileMode

func (FileMode) FileType

func (m FileMode) FileType() FileMode

FileType returns just the file type bits.

func (FileMode) IsDir

func (m FileMode) IsDir() bool

IsDir returns true if file type represents a directory.

func (FileMode) Permissions

func (m FileMode) Permissions() FileMode

Permissions returns just the permission bits.

func (FileMode) String

func (m FileMode) String() string

String returns a string representation of m.

type FlagSet

type FlagSet []struct {
	Flag uint64
	Name string
}

A FlagSet is a slice of bit-flags and their name.

func (FlagSet) Parse

func (s FlagSet) Parse(val uint64) string

Parse returns a pretty version of val, using the flag names for known flags. Unknown flags remain numeric.

type ValueSet

type ValueSet map[uint64]string

func (ValueSet) Parse

func (s ValueSet) Parse(val uint64) string

Parse returns the name of the value associated with `val`. Unknown values are converted to hex.

func (ValueSet) ParseDecimal

func (s ValueSet) ParseDecimal(val uint64) string

ParseDecimal returns the name of the value associated with `val`. Unknown values are converted to decimal.

func (ValueSet) ParseName

func (s ValueSet) ParseName(name string) (uint64, bool)

ParseName returns the flag value associated with 'name'. Returns false if no value is found.

Jump to

Keyboard shortcuts

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