core/sys/linux

linux

Types

351

Branch_Sample_Type_Bits

Branch_Sample_Type_Bits :: enum int { USER = 0, KERNEL = 1, HV = 2, ANY = 3, ANY_CALL = 4, ANY_RETURN = 5, IND_CALL = 6, ABORT_TX = 7, IN_TX = 8, NO_TX = 9, COND = 10, CALL_STACK = 11, IND_JUMP = 12, CALL = 13, NO_FLAGS = 14, NO_CYCLES = 15, TYPE_SAVE = 16, HW_INDEX = 17, PRIV_SAVE = 18, }Source

Bits for Branch_Sample_Type

Clock_Id

Clock_Id :: enum int { REALTIME = 0, MONOTONIC = 1, PROCESS_CPUTIME_ID = 2, THREAD_CPUTIME_ID = 3, MONOTONIC_RAW = 4, REALTIME_COARSE = 5, MONOTONIC_COARSE = 6, BOOTTIME = 7, REALTIME_ALARM = 8, BOOTTIME_ALARM = 9, }Source

Clock IDs for various system clocks.

Dirent

Dirent :: struct { ino: Inode, off: i64, reclen: u16, type: Dirent_Type, name: [0]u8, }Source

Directory entry record.

Recommended to iterate these with `dirent_iterate_buf()`,
	and obtain the name via `dirent_name()`.

Dirent_Type

Dirent_Type :: enum u8 { UNKNOWN = 0, FIFO = 1, CHR = 2, DIR = 4, BLK = 6, REG = 8, LNK = 10, SOCK = 12, WHT = 14, }Source

Type of the file in a directory entry

EPoll_Event_Kind

EPoll_Event_Kind :: enum u32 { IN = log2(0x001), PRI = log2(0x002), OUT = log2(0x004), RDNORM = log2(0x040), RDBAND = log2(0x080), WRNORM = log2(0x100), WRBAND = log2(0x200), MSG = log2(0x400), ERR = log2(0x008), HUP = log2(0x010), RDHUP = log2(0x2000), EXCLUSIVE = log2(1<<28), WAKEUP = log2(1<<29), ONESHOT = log2(1<<30), ET = log2(1<<31), }Source

Errno

Errno :: enum i32 { NONE = 0, // Errno-base EPERM = 1, ENOENT = 2, ESRCH = 3, EINTR = 4, EIO = 5, ENXIO = 6, E2BIG = 7, ENOEXEC = 8, EBADF = 9, ECHILD = 10, EAGAIN = 11, ENOMEM = 12, EACCES = 13, EFAULT = 14, ENOTBLK = 15, EBUSY = 16, EEXIST = 17, EXDEV = 18, ENODEV = 19, ENOTDIR = 20, EISDIR = 21, EINVAL = 22, ENFILE = 23, EMFILE = 24, ENOTTY = 25, ETXTBSY = 26, EFBIG = 27, ENOSPC = 28, ESPIPE = 29, EROFS = 30, EMLINK = 31, EPIPE = 32, EDOM = 33, ERANGE = 34, // Linux EDEADLK = 35, ENAMETOOLONG = 36, ENOLCK = 37, ENOSYS = 38, ENOTEMPTY = 39, ELOOP = 40, EUNKNOWN_41 = 41, ENOMSG = 42, EIDRM = 43, ECHRNG = 44, EL2NSYNC = 45, EL3HLT = 46, EL3RST = 47, ELNRNG = 48, EUNATCH = 49, ENOCSI = 50, EL2HLT = 51, EBADE = 52, EBADR = 53, EXFULL = 54, ENOANO = 55, EBADRQC = 56, EBADSLT = 57, EUNKNOWN_58 = 58, EBFONT = 59, ENOSTR = 60, ENODATA = 61, ETIME = 62, ENOSR = 63, ENONET = 64, ENOPKG = 65, EREMOTE = 66, ENOLINK = 67, EADV = 68, ESRMNT = 69, ECOMM = 70, EPROTO = 71, EMULTIHOP = 72, EDOTDOT = 73, EBADMSG = 74, EOVERFLOW = 75, ENOTUNIQ = 76, EBADFD = 77, EREMCHG = 78, ELIBACC = 79, ELIBBAD = 80, ELIBSCN = 81, ELIBMAX = 82, ELIBEXEC = 83, EILSEQ = 84, ERESTART = 85, ESTRPIPE = 86, EUSERS = 87, ENOTSOCK = 88, EDESTADDRREQ = 89, EMSGSIZE = 90, EPROTOTYPE = 91, ENOPROTOOPT = 92, EPROTONOSUPPORT = 93, ESOCKTNOSUPPORT = 94, EOPNOTSUPP = 95, EPFNOSUPPORT = 96, EAFNOSUPPORT = 97, EADDRINUSE = 98, EADDRNOTAVAIL = 99, ENETDOWN = 100, ENETUNREACH = 101, ENETRESET = 102, ECONNABORTED = 103, ECONNRESET = 104, ENOBUFS = 105, EISCONN = 106, ENOTCONN = 107, ESHUTDOWN = 108, ETOOMANYREFS = 109, ETIMEDOUT = 110, ECONNREFUSED = 111, EHOSTDOWN = 112, EHOSTUNREACH = 113, EALREADY = 114, EINPROGRESS = 115, ESTALE = 116, EUCLEAN = 117, ENOTNAM = 118, ENAVAIL = 119, EISNAM = 120, EREMOTEIO = 121, EDQUOT = 122, ENOMEDIUM = 123, EMEDIUMTYPE = 124, ECANCELED = 125, ENOKEY = 126, EKEYEXPIRED = 127, EKEYREVOKED = 128, EKEYREJECTED = 129, EOWNERDEAD = 130, ENOTRECOVERABLE = 131, ERFKILL = 132, EHWPOISON = 133, // Errno aliases EWOULDBLOCK = EAGAIN, EDEADLOCK = EDEADLK, }Source

Represents an error returned by most of syscalls

FCntl_Command

FCntl_Command :: enum int { DUPFD = 0, GETFD = 1, SETFD = 2, GETFL = 3, SETFL = 4, GETLK = 5, SETLK = 6, SETLKW = 7, SETOWN = 8, GETOWN = 9, SETSIG = 10, GETSIG = 11, SETOWN_EX = 15, GETOWN_EX = 16, // OFD_GETLK = 36, // OFD_SETLK = 37, // OFD_SETLKW = 38, SETLEASE = 1024, GETLEASE = 1025, NOTIFY = 1026, DUPFD_CLOEXEC = 1030, SETPIPE_SZ = 1031, GETPIPE_SZ = 1032, ADD_SEALS = 1033, GET_SEALS = 1034, GET_RW_HINT = 1035, SET_RW_HINT = 1036, GET_FILE_RW_HINT = 1037, SET_FILE_RW_HINT = 1038, }Source

Command for fcntl(2)

FD_Flags_Bits

FD_Flags_Bits :: enum int { SYMLINK_NOFOLLOW = 8, REMOVEDIR = 9, EACCESS = 9, SYMLINK_FOLLOW = 10, NO_AUTOMOUNT = 11, EMPTY_PATH = 12, STATX_FORCE_SYNC = 13, STATX_DONT_SYNC = 14, RECURSIVE = 15, }Source

Bits for FD_Flags bitset

FS_Flags_Bits

FS_Flags_Bits :: enum int { RDONLY = 0, NOSUID = 1, NODEV = 2, NOEXEC = 3, SYNCHRONOUS = 4, VALID = 5, MANDLOCK = 6, NOATIME = 10, NODIRATIME = 11, RELATIME = 12, NOSYMFOLLOW = 13, }Source

Bits for FS_Flags bitset

FS_Magic

FS_Magic :: enum u32 { ADFS_SUPER_MAGIC = 44533, AFFS_SUPER_MAGIC = 44543, AFS_SUPER_MAGIC = 1397113167, ANON_INODE_FS_MAGIC = 151263540, AUTOFS_SUPER_MAGIC = 391, BDEVFS_MAGIC = 1650746742, BEFS_SUPER_MAGIC = 1111905073, BFS_MAGIC = 464386766, BINFMTFS_MAGIC = 1112100429, BPF_FS_MAGIC = 3405662737, BTRFS_SUPER_MAGIC = 2435016766, BTRFS_TEST_MAGIC = 1936880249, CGROUP_SUPER_MAGIC = 2613483, CGROUP2_SUPER_MAGIC = 1667723888, CIFS_MAGIC_NUMBER = 4283649346, CODA_SUPER_MAGIC = 1937076805, COH_SUPER_MAGIC = 19920823, CRAMFS_MAGIC = 684539205, DEBUGFS_MAGIC = 1684170528, DEVFS_SUPER_MAGIC = 4979, DEVPTS_SUPER_MAGIC = 7377, ECRYPTFS_SUPER_MAGIC = 61791, EFIVARFS_MAGIC = 3730735588, EFS_SUPER_MAGIC = 4278867, EXT_SUPER_MAGIC = 4989, EXT2_OLD_SUPER_MAGIC = 61265, EXT2_SUPER_MAGIC = 61267, EXT3_SUPER_MAGIC = 61267, EXT4_SUPER_MAGIC = 61267, F2FS_SUPER_MAGIC = 4076150800, FUSE_SUPER_MAGIC = 1702057286, FUTEXFS_SUPER_MAGIC = 195894762, HFS_SUPER_MAGIC = 16964, HOSTFS_SUPER_MAGIC = 12648430, HPFS_SUPER_MAGIC = 4187351113, HUGETLBFS_MAGIC = 2508478710, ISOFS_SUPER_MAGIC = 38496, JFFS2_SUPER_MAGIC = 29366, JFS_SUPER_MAGIC = 827541066, MINIX_SUPER_MAGIC = 4991, MINIX_SUPER_MAGIC2 = 5007, MINIX2_SUPER_MAGIC = 9320, MINIX2_SUPER_MAGIC2 = 9336, MINIX3_SUPER_MAGIC = 19802, MQUEUE_MAGIC = 427819522, MSDOS_SUPER_MAGIC = 19780, MTD_INODE_FS_MAGIC = 288389204, NCP_SUPER_MAGIC = 22092, NFS_SUPER_MAGIC = 26985, NILFS_SUPER_MAGIC = 13364, NSFS_MAGIC = 1853056627, NTFS_SB_MAGIC = 1397118030, OCFS2_SUPER_MAGIC = 1952539503, OPENPROM_SUPER_MAGIC = 40865, OVERLAYFS_SUPER_MAGIC = 2035054128, PIPEFS_MAGIC = 1346981957, PROC_SUPER_MAGIC = 40864, PSTOREFS_MAGIC = 1634035564, QNX4_SUPER_MAGIC = 47, QNX6_SUPER_MAGIC = 1746473250, RAMFS_MAGIC = 2240043254, REISERFS_SUPER_MAGIC = 1382369651, ROMFS_MAGIC = 29301, SECURITYFS_MAGIC = 1935894131, SELINUX_MAGIC = 4185718668, SMACK_MAGIC = 1128357203, SMB_SUPER_MAGIC = 20859, SMB2_MAGIC_NUMBER = 4266872130, SOCKFS_MAGIC = 1397703499, SQUASHFS_MAGIC = 1936814952, SYSFS_MAGIC = 1650812274, SYSV2_SUPER_MAGIC = 19920822, SYSV4_SUPER_MAGIC = 19920821, TMPFS_MAGIC = 16914836, TRACEFS_MAGIC = 1953653091, UDF_SUPER_MAGIC = 352400198, UFS_MAGIC = 72020, USBDEVICE_SUPER_MAGIC = 40866, V9FS_MAGIC = 16914839, VXFS_SUPER_MAGIC = 2768370933, XENFS_SUPER_MAGIC = 2881100148, XENIX_SUPER_MAGIC = 19920820, XFS_SUPER_MAGIC = 1481003842, _XIAFS_SUPER_MAGIC = 19911021, }Source

Magic bits for filesystems returned by Stat_FS

Futex_Arg_Op

Futex_Arg_Op :: enum int { SET = 0, // uaddr2 = oparg ADD = 1, // uaddr2 += oparg OR = 2, // uaddr2 |= oparg ANDN = 3, // uaddr2 &= ~oparg XOR = 4, // uaddr2 ^= oparg PO2_SET = 0, // uaddr2 = 1<<oparg PO2_ADD = 1, // uaddr2 += 1<<oparg PO2_OR = 2, // uaddr2 |= 1<<oparg PO2_ANDN = 3, // uaddr2 &~= 1<<oparg PO2_XOR = 4, // uaddr2 ^= 1<<oparg }Source

Kind of operation on futex, see FUTEX_WAKE_OP

Futex_Cmp_Op

Futex_Cmp_Op :: enum int { EQ = 0, // if (oldval == cmparg) wake NE = 1, // if (oldval != cmparg) wake LT = 2, // if (oldval < cmparg) wake LE = 3, // if (oldval <= cmparg) wake GT = 4, // if (oldval > cmparg) wake GE = 5, // if (oldval >= cmparg) wake }Source

Kind of comparison operation on futex, see FUTEX_WAKE_OP

Futex_Op

Futex_Op :: enum u32 { WAIT = 0, WAKE = 1, FD = 2, REQUEUE = 3, CMP_REQUEUE = 4, WAKE_OP = 5, LOCK_PI = 6, UNLOCK_PI = 7, TRYLOCK_PI = 8, WAIT_BITSET = 9, WAKE_BITSET = 10, WAIT_REQUEUE_PI = 11, CMP_REQUEUE_PI = 12, LOCK_PI2 = 13, }Source

Second argument to futex(2) syscall

IO_Uring_CQE_Flags_Bits

IO_Uring_CQE_Flags_Bits :: enum int { // If set, the upper 16 bits are the buffer ID. BUFFER = 0, // If set, parent SQE will generate more CQE entries. MORE = 1, // If set, more data to read after socket recv. SOCK_NONEMPTY = 2, // Set for notification CQEs. Can be used to distinct them from sends. NOTIF = 3, }Source

IO_Uring_OP

IO_Uring_OP :: enum u8 { NOP = 0, READV = 1, WRITEV = 2, FSYNC = 3, READ_FIXED = 4, WRITE_FIXED = 5, POLL_ADD = 6, POLL_REMOVE = 7, SYNC_FILE_RANGE = 8, SENDMSG = 9, RECVMSG = 10, TIMEOUT = 11, TIMEOUT_REMOVE = 12, ACCEPT = 13, ASYNC_CANCEL = 14, LINK_TIMEOUT = 15, CONNECT = 16, FALLOCATE = 17, OPENAT = 18, CLOSE = 19, FILES_UPDATE = 20, STATX = 21, READ = 22, WRITE = 23, FADVISE = 24, MADVISE = 25, SEND = 26, RECV = 27, OPENAT2 = 28, EPOLL_CTL = 29, SPLICE = 30, PROVIDE_BUFFERS = 31, REMOVE_BUFFERS = 32, TEE = 33, SHUTDOWN = 34, RENAMEAT = 35, UNLINKAT = 36, MKDIRAT = 37, SYMLINKAT = 38, LINKAT = 39, MSG_RING = 40, FSETXATTR = 41, SETXATTR = 42, FGETXATTR = 43, GETXATTR = 44, SOCKET = 45, URING_CMD = 46, SEND_ZC = 47, SENDMSG_ZC = 48, READ_MULTISHOT = 49, WAITID = 50, FUTEX_WAIT = 51, FUTEX_WAKE = 52, FUTEX_WAITV = 53, FIXED_FD_INSTALL = 54, FTRUNCATE = 55, BIND = 56, LISTEN = 57, }Source

IO_Uring_Register_Opcode

IO_Uring_Register_Opcode :: enum uint { REGISTER_BUFFERS = 0, UNREGISTER_BUFFERS = 1, REGISTER_FILES = 2, UNREGISTER_FILES = 3, REGISTER_EVENTFD = 4, UNREGISTER_EVENTFD = 5, REGISTER_FILES_UPDATE = 6, REGISTER_EVENTFD_ASYNC = 7, REGISTER_PROBE = 8, REGISTER_PERSONALITY = 9, UNREGISTER_PERSONALITY = 10, REGISTER_RESTRICTIONS = 11, REGISTER_ENABLE_RINGS = 12, // extended with tagging REGISTER_FILES2 = 13, REGISTER_FILES_UPDATE2 = 14, REGISTER_BUFFERS2 = 15, REGISTER_BUFFERS_UPDATE = 16, // set/clear io-wq thread affinities REGISTER_IOWQ_AFF = 17, UNREGISTER_IOWQ_AFF = 18, // set/get max number of io-wq workers REGISTER_IOWQ_MAX_WORKERS = 19, // register/unregister io_uring fd with the ring REGISTER_RING_FDS = 20, UNREGISTER_RING_FDS = 21, // register ring based provide buffer group REGISTER_PBUF_RING = 22, UNREGISTER_PBUF_RING = 23, // sync cancelation API REGISTER_SYNC_CANCEL = 24, // register a range of fixed file slots for automatic slot allocation REGISTER_FILE_ALLOC_RANGE = 25, // this goes last REGISTER_LAST = 26, // flag added to the opcode to use a registered ring fd REGISTER_USE_REGISTERED_RING = 1 << 31, }Source

IO_Uring_SQE

IO_Uring_SQE :: struct { opcode: IO_Uring_OP, flags: IO_Uring_SQE_Flags, __ioprio: struct #raw_union { ioprio: u16, sq_accept_flags: IO_Uring_Accept_Flags, sq_send_recv_flags: IO_Uring_Send_Recv_Flags, }, fd: Fd, __offset: struct #raw_union { // Offset into file. off: u64, addr2: u64, _: struct { cmd_op: u32, __pad1: u32, }, statx: ^Statx, }, __iovecs: struct #raw_union { // Pointer to buffer or iovecs. addr: u64, splice_off_in: u64, _: struct { level: u32, optname: u32, }, }, __len: struct #raw_union { // Buffer size or number of iovecs. len: u32, poll_flags: IO_Uring_Poll_Add_Flags, statx_mask: Statx_Mask, epoll_ctl_op: EPoll_Ctl_Opcode, shutdown_how: Shutdown_How, }, __contents: struct #raw_union { rw_flags: i32, fsync_flags: IO_Uring_Fsync_Flags, // compatibility. poll_events: Fd_Poll_Events, // word-reversed for BE. poll32_events: u32, sync_range_flags: u32, msg_flags: Socket_Msg, timeout_flags: IO_Uring_Timeout_Flags, accept_flags: Socket_FD_Flags, cancel_flags: u32, open_flags: Open_Flags, statx_flags: FD_Flags, fadvise_advice: u32, splice_flags: IO_Uring_Splice_Flags, rename_flags: u32, unlink_flags: u32, hardlink_flags: u32, xattr_flags: u32, msg_ring_flags: u32, uring_cmd_flags: IO_Uring_Cmd_Flags, }, // Data to be passed back at completion time. user_data: u64, __buffer: struct #raw_union { // Index into fixed buffers, if used. buf_index: u16, // For grouped buffer selection. buf_group: u16, }, // Personality to use, if used. personality: u16, _: struct #raw_union { splice_fd_in: Fd, file_index: u32, _: struct { addr_len: u16, __pad3: [1]u16, }, }, __: struct #raw_union { _: struct { addr3: u64, __pad2: [1]u64, }, }, }Source

The submission queue entry when the .SQE128 flag is not set on setup.

IO_Uring_SQE_Flags_Bits

IO_Uring_SQE_Flags_Bits :: enum int { // Use fixed fileset. FIXED_FILE = 0, // Issue after inflight IO. IO_DRAIN = 1, // Links next sqe. IO_LINK = 2, // Like LINK, but stronger. IO_HARDLINK = 3, // Always go async. ASYNC = 4, // Select buffer from sq.buf_group. BUFFER_SELECT = 5, // Don't post CQE if request succeeded. CQE_SKIP_SUCCESS = 6, }Source

IO_Uring_Send_Recv_Flags_Bits

IO_Uring_Send_Recv_Flags_Bits :: enum int { // If set, instead of first attempting to send // or receive and arm poll if that yields an // -EAGAIN result, arm poll upfront and skip // the initial transfer attempt. RECVSEND_POLL_FIRST = 0, // Multishot recv. Sets IORING_CQE_F_MORE if // the handler will continue to report // CQEs on behalf of the same SQE. RECV_MULTISHOT = 1, // Use registered buffers, the index is stored in // the buf_index field. RECVSEND_FIXED_BUF = 2, // If set, SEND[MSG]_ZC should report // the zerocopy usage in cqe.res // for the IORING_CQE_F_NOTIF cqe. // 0 is reported if zerocopy was actually possible. // IORING_NOTIF_USAGE_ZC_COPIED if data was copied // (at least partially). SEND_ZC_REPORT_USAGE = 3, }Source

IO_Uring_Setup_Flags_Bits

IO_Uring_Setup_Flags_Bits :: enum int { // io_context is polled. IOPOLL = 0, // SQ poll thread. SQPOLL = 1, // sq_thread_cpu is valid. SQ_AFF = 2, // app defines CQ size. CQSIZE = 3, // clamp SQ/CQ ring sizes. CLAMP = 4, // attach to existing wq. ATTACH_WQ = 5, // start with ring disabled. R_DISABLED = 6, // continue submit on error. SUBMIT_ALL = 7, // Cooperative task running. When requests complete, they often require // forcing the submitter to transition to the kernel to complete. If this // flag is set, work will be done when the task transitions anyway, rather // than force an inter-processor interrupt reschedule. This avoids interrupting // a task running in userspace, and saves an IPI. COOP_TASKRUN = 8, // If COOP_TASKRUN is set, get notified if task work is available for // running and a kernel transition would be needed to run it. This sets // IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN. TASKRUN_FLAG = 9, // SQEs are 128 bytes. SQE128 = 10, // CQEs are 32 bytes. CQE32 = 11, // Only one task is allowed to submit requests SINGLE_ISSUER = 12, // Defer running task work to get events. // Rather than running bits of task work whenever the task transitions // try to do it just before it is needed. DEFER_TASKRUN = 13, }Source

IPC_Cmd

IPC_Cmd :: enum i16 { // IPC common IPC_RMID = 0, IPC_SET = 1, IPC_STAT = 2, // Shared memory SHM_LOCK = 11, SHM_UNLOCK = 12, SHM_STAT = 13, SHM_INFO = 14, SHM_STAT_ANY = 15, // Semaphore GETPID = 11, GETVAL = 12, GETALL = 13, GETNCNT = 14, GETZCNT = 15, SETVAL = 16, SETALL = 17, SEM_STAT = 18, SEM_INFO = 19, SEM_STAT_ANY = 20, // Message queue MSG_STAT = 11, MSG_INFO = 12, MSG_STAT_ANY = 13, }Source

IPC memory commands

IPC_Flags_Bits

IPC_Flags_Bits :: enum int { // Access modes for shared memory. WROTH = 1, RDOTH = 2, WRGRP = 4, RDGRP = 5, WRUSR = 7, RDUSR = 8, // Creation flags for shared memory. IPC_CREAT = 9, IPC_EXCL = 10, SHM_HUGETLB = 11, SHM_NORESERVE = 12, // Usage flags for shared memory. IPC_NOWAIT = 11, SEM_UNDO = 9, SHM_RDONLY = 12, SHM_RND = 13, SHM_REMAP = 14, SHM_EXEC = 15, MSG_NOERROR = 12, MSG_EXCEPT = 13, MSG_COPY = 14, }Source

Bits for SystemV IPC flags.

In this enum, access modes are common for any shared memory. Prefixed
	entries (i.e. `IPC_` or `SHM_`) denote flags, where `IPC_` are common flags
	for all SystemV IPC primitives, and `SHM_`, `SEM_` and `MSG_` are specific
	to shared memory segments, semaphores and message queues respectively.
	
	These bits overlap, because they are meant to be used within the
	context of specific procedures. Creation flags, used for `*get` procedures,
	and usage flags used by all other IPC procedures. Do not mix creation and
	usage flags, as well as flags prefixed differently (excluding `IPC_`
	prefix).

Inode

Inode :: u64Source

Type for 64-bit inode number for files.

Used pretty much only in struct Stat64 for 32-bit platforms.

Inotify_Event_Bits

Inotify_Event_Bits :: enum u32 { ACCESS = 0, MODIFY = 1, ATTRIB = 2, CLOSE_WRITE = 3, CLOSE_NOWRITE = 4, OPEN = 5, MOVED_FROM = 6, MOVED_TO = 7, CREATE = 8, DELETE = 9, DELETE_SELF = 10, MOVE_SELF = 11, UNMOUNT = 13, Q_OVERFLOW = 14, IGNORED = 15, ONLYDIR = 24, DONT_FOLLOW = 25, EXCL_UNLINK = 26, MASK_CREATE = 28, MASK_ADD = 29, ISDIR = 30, ONESHOT = 31, }Source

Key

Key :: i32Source

Shared memory identifiers used by shmget(2) and other calls.

MAdvice

MAdvice :: enum int { NORMAL = 0, RANDOM = 1, SEQUENTIAL = 2, WILLNEED = 3, DONTNEED = 4, FREE = 8, REMOVE = 9, DONTFORK = 10, DOFORK = 11, MERGEABLE = 12, UNMERGEABLE = 13, HUGEPAGE = 14, NOHUGEPAGE = 15, DONTDUMP = 16, DODUMP = 17, WIPEONFORK = 18, KEEPONFORK = 19, COLD = 20, PAGEOUT = 21, POPULATE_READ = 22, POPULATE_WRITE = 23, DONTNEED_LOCKED = 24, COLLAPSE = 25, HWPOISON = 100, SOFT_OFFLINE = 101, }Source

Argument for madvice(2)

Map_Flags_Bits

Map_Flags_Bits :: enum int { SHARED = 0, PRIVATE = 1, DROPPABLE = 3, FIXED = 4, ANONYMOUS = 5, // platform-dependent section start X86_32BIT = 6, X86_ABOVE4G = 7, // platform-dependent section end GROWSDOWN = 8, DENYWRITE = 11, EXECUTABLE = 12, LOCKED = 13, NORESERVE = 14, POPULATE = 15, NONBLOCK = 16, STACK = 17, HUGETLB = 18, SYNC = 19, FIXED_NOREPLACE = 20, UNINITIALIZED = 26, }Source

Bits for Map_Flags

See `constants.odin` for `MAP_SHARED_VALIDATE` and `MAP_HUGE_16KB`, et al.

Mem_Protection_Bits

Mem_Protection_Bits :: enum int { READ = 0, WRITE = 1, EXEC = 2, SEM = 3, // platform-specific section start ARM64_BTI = 4, ARM64_MTE = 5, // platform-specific section end GROWSDOWN = 24, GROWSUP = 25, }Source

Bits for Mem_Protection bitfield

Mode

Mode :: bit_set[Mode_Bits; u32]Source

Represents file's permission and status bits Example:

When you're passing a value of this type the recommended usage is:
  linux.Mode{.S_IXOTH, .S_IROTH} | linux.S_IRWXU | linux.S_IRWXG
This would generate a mode that has full permissions for the
	file's owner and group, and only "read" and "execute" bits
	for others.

Mode_Bits

Mode_Bits :: enum int { IXOTH = 0, // 0o0000001 IWOTH = 1, // 0o0000002 IROTH = 2, // 0o0000004 IXGRP = 3, // 0o0000010 IWGRP = 4, // 0o0000020 IRGRP = 5, // 0o0000040 IXUSR = 6, // 0o0000100 IWUSR = 7, // 0o0000200 IRUSR = 8, // 0o0000400 ISVTX = 9, // 0o0001000 ISGID = 10, // 0o0002000 ISUID = 11, // 0o0004000 IFIFO = 12, // 0o0010000 IFCHR = 13, // 0o0020000 IFDIR = 14, // 0o0040000 IFREG = 15, // 0o0100000 }Source

The bits for the Mode bitset.

Mount_Flags_Bits

Mount_Flags_Bits :: enum int { RDONLY = log2(1), NOSUID = log2(2), NODEV = log2(4), NOEXEC = log2(8), SYNCHRONOUS = log2(16), REMOUNT = log2(32), MANDLOCK = log2(64), DIRSYNC = log2(128), NOATIME = log2(1024), NODIRATIME = log2(2048), BIND = log2(4096), MOVE = log2(8192), REC = log2(16384), SILENT = log2(32768), POSIXACL = log2(1<<16), UNBINDABLE = log2(1<<17), PRIVATE = log2(1<<18), SLAVE = log2(1<<19), SHARED = log2(1<<20), RELATIME = log2(1<<21), KERNMOUNT = log2(1<<22), I_VERSION = log2(1<<23), STRICTATIME = log2(1<<24), LAZYTIME = log2(1<<25), ACTIVE = log2(1<<30), NOUSER = log2(1<<31), NOSYMFOLLOW = log2(256), }Source

PTrace_Event_Code

PTrace_Event_Code :: enum int { EVENT_FORK = 1, EVENT_VFORK = 2, EVENT_CLONE = 3, EVENT_EXEC = 4, EVENT_VFORK_DONE = 5, EVENT_EXIT = 6, EVENT_SECCOMP = 7, EVENT_STOP = 128, }Source

ptrace event codes.

PTrace_Note_Type

PTrace_Note_Type :: enum int { NT_PRSTATUS = 1, NT_PRFPREG = 2, NT_PRPSINFO = 3, NT_TASKSTRUCT = 4, NT_AUXV = 6, NT_SIGINFO = 1397311305, NT_FILE = 1179208773, NT_PRXFPREG = 1189489535, NT_386_TLS = 512, NT_386_IOPERM = 513, NT_X86_XSTATE = 514, NT_X86_SHSTK = 516, NT_ARM_VFP = 1024, NT_ARM_TLS = 1025, NT_ARM_HW_BREAK = 1026, NT_ARM_HW_WATCH = 1027, NT_ARM_SYSTEM_CALL = 1028, NT_ARM_SVE = 1029, NT_ARM_PAC_MASK = 1030, NT_ARM_PACA_KEYS = 1031, NT_ARM_PACG_KEYS = 1032, NT_ARM_TAGGED_ADDR_CTRL = 1033, NT_ARM_PAC_ENABLED_KEYS = 1034, NT_ARM_SSVE = 1035, NT_ARM_ZA = 1036, NT_ARM_ZT = 1037, }Source

Note types for PTRACE_GETREGSET. Mirrors constants in elf definition,

files though this enum only contains the constants defined for architectures
	Odin can compile to.

PTrace_Options_Bits

PTrace_Options_Bits :: enum i32 { TRACESYSGOOD = 0, TRACEFORK = 1, TRACEVFORK = 2, TRACECLONE = 3, TRACEEXEC = 4, TRACEVFORKDONE = 5, TRACEEXIT = 6, TRACESECCOMP = 7, EXITKILL = 20, SUSPEND_SECCOMP = 21, }Source

ptrace options

PTrace_Request

PTrace_Request :: enum i32 { TRACEME = 0, PEEKTEXT = 1, PEEKDATA = 2, PEEKUSER = 3, POKETEXT = 4, POKEDATA = 5, POKEUSER = 6, CONT = 7, KILL = 8, SINGLESTEP = 9, GETREGS = 12, SETREGS = 13, GETFPREGS = 14, SETFPREGS = 15, ATTACH = 16, DETACH = 17, GETFPXREGS = 18, SETFPXREGS = 19, SYSCALL = 24, GET_THREAD_AREA = 25, SET_THREAD_AREA = 26, ARCH_PRCTL = 30, SYSEMU = 31, SYSEMU_SINGLESTEP = 32, SINGLEBLOCK = 33, SETOPTIONS = 16896, GETEVENTMSG = 16897, GETSIGINFO = 16898, SETSIGINFO = 16899, GETREGSET = 16900, SETREGSET = 16901, SEIZE = 16902, INTERRUPT = 16903, LISTEN = 16904, PEEKSIGINFO = 16905, GETSIGMASK = 16906, SETSIGMASK = 16907, SECCOMP_GET_FILTER = 16908, SECCOMP_GET_METADATA = 16909, GET_SYSCALL_INFO = 16910, GET_RSEQ_CONFIGURATION = 16911, }Source

ptrace requests

Perf_Event_Attr

Perf_Event_Attr :: struct #packed { type: Perf_Event_Type, size: u32, config: struct #raw_union { hw: Perf_Hardware_Id, sw: Perf_Software_Id, cache: u64, other: u64, }, sample: struct #raw_union { period: u64, frequency: u64, }, sample_type: Perf_Event_Sample_Type, read_format: Perf_Read_Format, flags: Perf_Event_Flags, wakeup: struct #raw_union { events: u32, watermark: u32, }, breakpoint_type: Hardware_Breakpoint_Type, _: struct #raw_union { breakpoint_addr: u64, kprobe_func: u64, uprobe_path: u64, config1: u64, }, _: struct #raw_union { breakpoint_len: u64, kprobe_addr: u64, uprobe_offset: u64, config2: u64, }, branch_sample_type: Branch_Sample_Type, sample_regs_user: u64, sample_stack_user: u32, clock_id: i32, sample_regs_intr: u64, aux_watermark: u32, sample_max_stack: u16, _: u16, }Source

The struct for perf_event_open.

Perf_Event_Flags_Bits

Perf_Event_Flags_Bits :: enum u64 { Disabled = 0, Inherit = 1, Pinned = 2, Exclusive = 3, Exclude_User = 4, Exclude_Kernel = 5, Exclude_HV = 6, Exclude_Idle = 7, Mmap = 8, Comm = 9, Freq = 10, Inherit_Stat = 11, Enable_On_Exec = 12, Task = 13, Watermark = 14, Precise_IP_0 = 15, Precise_IP_1 = 16, Mmap_Data = 17, Sample_Id_All = 18, Exclude_Host = 19, Exclude_Guest = 20, Exclude_Callchain_Kernel = 21, Exclude_Callchain_User = 22, Mmap2 = 23, Comm_Exec = 24, Use_Clockid = 25, Context_Switch = 26, Write_Backward = 27, Namespaces = 28, KSymbol = 29, BPF_Event = 30, Aux_Output = 31, CGroup = 32, Text_Poke = 33, Build_Id = 34, Inherit_Thread = 35, Remove_On_Exec = 36, Sigtrap = 37, }Source

Perf_Event_Mmap_Page

Perf_Event_Mmap_Page :: struct #packed { version: u32, compat_version: u32, lock: u32, index: u32, offset: i64, time_enabled: u64, time_running: u64, cap: struct #raw_union { capabilities: u64, flags: Perf_Cap_Flags, }, pmc_width: u16, time_shift: u16, time_mult: u32, time_offset: u64, time_zero: u64, size: u32, reserved1: u32, time_cycles: u64, time_mask: u64, reserved2: [928]u8, data_head: u64, data_tail: u64, data_offset: u64, data_size: u64, aux_head: u64, aux_tail: u64, aux_offset: u64, aux_size: u64, }Source

The ring buffer structure when mmaping Perf_Event_Attr.

Perf_Event_Sample_Type_Bits

Perf_Event_Sample_Type_Bits :: enum int { IP = 0, TID = 1, TIME = 2, ADDR = 3, READ = 4, CALLCHAIN = 5, ID = 6, CPU = 7, PERIOD = 8, STREAM_ID = 9, RAW = 10, BRANCH_STACK = 11, REGS_USER = 12, STACK_USER = 13, WEIGHT = 14, DATA_SRC = 15, IDENTIFIER = 16, TRANSACTION = 17, REGS_INTR = 18, PHYS_ADDR = 19, AUX = 20, CGROUP = 21, DATA_PAGE_SIZE = 22, CODE_PAGE_SIZE = 23, WEIGHT_STRUCT = 24, }Source

Specifies which values to include in the sample

Perf_Hardware_Id

Perf_Hardware_Id :: enum u64 { CPU_CYCLES = 0, INSTRUCTIONS = 1, CACHE_REFERENCES = 2, CACHE_MISSES = 3, BRANCH_INSTRUCTIONS = 4, BRANCH_MISSES = 5, BUS_CYCLES = 6, STALLED_CYCLES_FRONTEND = 7, STALLED_CYCLES_BACKEND = 8, REF_CPU_CYCLES = 9, }Source

Specifies the type of the hardware event that you want to get info about

Perf_Software_Id

Perf_Software_Id :: enum u64 { CPU_CLOCK = 0, TASK_CLOCK = 1, PAGE_FAULTS = 2, CONTEXT_SWITCHES = 3, CPU_MIGRATIONS = 4, PAGE_FAULTS_MIN = 5, PAGE_FAULTS_MAJ = 6, ALIGNMENT_FAULTS = 7, EMULATION_FAULTS = 8, DUMMY = 9, BPF_OUTPUT = 10, CGROUP_SWITCHES = 11, }Source

Specifies the particular software event that you want to get info about

Protocol

Protocol :: enum int { HOPOPT = 0, ICMP = 1, IGMP = 2, GGP = 3, IPv4 = 4, ST = 5, TCP = 6, CBT = 7, EGP = 8, IGP = 9, BBN_RCC_MON = 10, NVP_II = 11, PUP = 12, EMCON = 14, XNET = 15, CHAOS = 16, UDP = 17, MUX = 18, DCN_MEAS = 19, HMP = 20, PRM = 21, XNS_IDP = 22, TRUNK_1 = 23, TRUNK_2 = 24, LEAF_1 = 25, LEAF_2 = 26, RDP = 27, IRTP = 28, ISO_TP4 = 29, NETBLT = 30, MFE_NSP = 31, MERIT_INP = 32, DCCP = 33, THREE_PC = 34, IDPR = 35, XTP = 36, DDP = 37, IDPR_CMTP = 38, TP_PlusPlus = 39, IL = 40, IPv6 = 41, SDRP = 42, IPv6_Route = 43, IPv6_Frag = 44, IDRP = 45, RSVP = 46, GRE = 47, DSR = 48, BNA = 49, ESP = 50, AH = 51, I_NLSP = 52, NARP = 54, MOBILE = 55, TLSP = 56, SKIP = 57, IPv6_ICMP = 58, IPv6_NoNxt = 59, IPv6_Opts = 60, CFTP = 62, SAT_EXPAK = 64, KRYPTOLAN = 65, RVD = 66, IPPC = 67, SAT_MON = 69, VISA = 70, IPCV = 71, CPNX = 72, CPHB = 73, WSN = 74, PVP = 75, BR_SAT_MON = 76, SUN_ND = 77, WB_MON = 78, WB_EXPAK = 79, ISO_IP = 80, VMTP = 81, SECURE_VMTP = 82, VINES = 83, IPTM = 84, NSFNET_IGP = 85, DGP = 86, TCF = 87, EIGRP = 88, OSPFIGP = 89, Sprite_RPC = 90, LARP = 91, MTP = 92, AX_25 = 93, IPIP = 94, SCC_SP = 96, ETHERIP = 97, ENCAP = 98, GMTP = 100, IFMP = 101, PNNI = 102, PIM = 103, ARIS = 104, SCPS = 105, QNX = 106, A_N = 107, IPComp = 108, SNP = 109, Compaq_Peer = 110, IPX_in_IP = 111, VRRP = 112, PGM = 113, L2TP = 115, DDX = 116, IATP = 117, STP = 118, SRP = 119, UTI = 120, SMP = 121, PTP = 123, FIRE = 125, CRTP = 126, CRUDP = 127, SSCOPMCE = 128, IPLT = 129, SPS = 130, PIPE = 131, SCTP = 132, FC = 133, RSVP_E2E_IGNORE = 134, UDPLite = 136, MPLS_in_IP = 137, manet = 138, HIP = 139, Shim6 = 140, WESP = 141, ROHC = 142, Ethernet = 143, AGGFRAG = 144, NSH = 145, Reserved = 255, }Source

The protocol number according to IANA protocol number list

Full list of protocol numbers:
	  https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
	Supported by the OS protocols can be queried by reading:
	  /etc/protocols

Protocol_Family

Protocol_Family :: enum u16 { UNSPEC = 0, LOCAL = 1, UNIX = LOCAL, FILE = LOCAL, INET = 2, AX25 = 3, IPX = 4, APPLETALK = 5, NETROM = 6, BRIDGE = 7, ATMPVC = 8, X25 = 9, INET6 = 10, ROSE = 11, DECnet = 12, NETBEUI = 13, SECURITY = 14, KEY = 15, NETLINK = 16, ROUTE = NETLINK, PACKET = 17, ASH = 18, ECONET = 19, ATMSVC = 20, RDS = 21, SNA = 22, IRDA = 23, PPPOX = 24, WANPIPE = 25, LLC = 26, IB = 27, MPLS = 28, CAN = 29, TIPC = 30, BLUETOOTH = 31, IUCV = 32, RXRPC = 33, ISDN = 34, PHONET = 35, IEEE802154 = 36, CAIF = 37, ALG = 38, NFC = 39, VSOCK = 40, KCM = 41, QIPCRTR = 42, SMC = 43, XDP = 44, MCTP = 45, }Source

Protocol family

RISCV_HWProbe_IMA_Ext_0_Bits

RISCV_HWProbe_IMA_Ext_0_Bits :: enum int { FD = 0, C = 1, V = 2, EXT_ZBA = 3, EXT_ZBB = 4, EXT_ZBS = 5, EXT_ZICBOZ = 6, EXT_ZBC = 7, EXT_ZBKB = 8, EXT_ZBKC = 9, EXT_ZBKX = 10, EXT_ZKND = 11, EXT_ZKNE = 12, EXT_ZKNH = 13, EXT_ZKSED = 14, EXT_ZKSH = 15, EXT_ZKT = 16, EXT_ZVBB = 17, EXT_ZVBC = 18, EXT_ZVKB = 19, EXT_ZVKG = 20, EXT_ZVKNED = 21, EXT_ZVKNHA = 22, EXT_ZVKNHB = 23, EXT_ZVKSED = 24, EXT_ZVKSH = 25, EXT_ZVKT = 26, EXT_ZFH = 27, EXT_ZFHMIN = 28, EXT_ZIHINTNTL = 29, EXT_ZVFH = 30, EXT_ZVFHMIN = 31, EXT_ZFA = 32, EXT_ZTSO = 33, EXT_ZACAS = 34, EXT_ZICOND = 35, EXT_ZIHINTPAUSE = 36, EXT_ZVE32X = 37, EXT_ZVE32F = 38, EXT_ZVE64X = 39, EXT_ZVE64F = 40, EXT_ZVE64D = 41, EXT_ZIMOP = 42, EXT_ZCA = 43, EXT_ZCB = 44, EXT_ZCD = 45, EXT_ZCF = 46, EXT_ZCMOP = 47, EXT_ZAWRS = 48, }Source

RISCV_HWProbe_Key

RISCV_HWProbe_Key :: enum i64 { UNSUPPORTED = -1, MVENDORID = 0, MARCHID = 1, MIMPID = 2, BASE_BEHAVIOR = 3, IMA_EXT_0 = 4, // Deprecated, try `.MISALIGNED_SCALAR_PERF` first, if that is `.UNSUPPORTED`, use this. CPUPERF_0 = 5, ZICBOZ_BLOCK_SIZE = 6, HIGHEST_VIRT_ADDRESS = 7, TIME_CSR_FREQ = 8, MISALIGNED_SCALAR_PERF = 9, }Source

RLimit_Kind

RLimit_Kind :: enum i32 { CPU = 0, FSIZE = 1, DATA = 2, STACK = 3, CORE = 4, RSS = 5, NOFILE = 7, AS = 9, NPROC = 6, MEMLOCK = 8, LOCKS = 10, SIGPENDING = 11, MSGQUEUE = 12, NICE = 13, RTPRIO = 14, RTTIME = 15, NLIMITS = 16, }Source

The kind of resource limits

RW_Hint

RW_Hint :: enum u64 { WRITE_LIFE_NOT_SET = 0, WRITE_LIFE_NONE = 1, WRITE_LIFE_SHORT = 2, WRITE_LIFE_MEDIUM = 3, WRITE_LIFE_LONG = 4, WRITE_LIFE_EXTREME = 5, }Source

Reboot_Magic

Reboot_Magic :: enum u64 { RB_MAGIC_1 = 4276215469, RB_MAGIC_2 = 672274793, RB_MAGIC_2A = 85072278, // Since Linux 2.1.17 RB_MAGIC_2B = 369367448, // Since Linux 2.1.97 RB_MAGIC_2C = 537993216, // Since Linux 2.5.71 }Source

Reboot_Operation

Reboot_Operation :: enum u64 { RB_DISABLE_CAD = 0, RB_ENABLE_CAD = 2309737967, RB_HALT_SYSTEM = 3454992675, RB_KEXEC = 1163412803, RB_POWER_OFF = 1126301404, RB_AUTOBOOT = 19088743, RB_AUTOBOOT_2 = 2712847316, RB_SW_SUSPEND = 3489725666, }Source

Sched_Flag_Bits

Sched_Flag_Bits :: enum int { RESET_ON_FORK = log2(0x01), RECLAIM = log2(0x02), DL_OVERRUN = log2(0x04), KEEP_POLICY = log2(0x08), KEEP_PARAMS = log2(0x10), UTIL_CLAMP_MIN = log2(0x20), UTIL_CLAMP_MAX = log2(0x40), }Source

Sig_Action_Flag

Sig_Action_Flag :: enum u32 { NOCLDSTOP = 0, NOCLDWAIT = 1, SIGINFO = 2, UNSUPPORTED = 10, EXPOSE_TAGBITS = 11, RESTORER = 26, ONSTACK = 27, RESTART = 28, NODEFER = 30, RESETHAND = 31, }Source

Sig_Child_Code

Sig_Child_Code :: enum int { NONE = 0, EXITED = 1, KILLED = 2, DUMPED = 3, TRAPPED = 4, STOPPED = 5, CONTINUED = 6, }Source

Translation of code in Sig_Info for when signo is SIGCHLD

Signal

Signal :: enum i32 { // POSIX-defined signals SIGINT = 2, // Interactive attention signal. SIGILL = 4, // Illegal instruction. SIGABRT = 6, // Abnormal termination. SIGFPE = 8, // Erroneous arithmetic operation. SIGSEGV = 11, // Invalid access to storage. SIGTERM = 15, // Termination request. // Other POSIX signals SIGHUP = 1, // Hangup. SIGQUIT = 3, // Quit. SIGTRAP = 5, // Trace/breakpoint trap. SIGKILL = 9, // Killed. SIGPIPE = 13, // Broken pipe. SIGALRM = 14, // Alarm clock. // Adjustments needed for most linux systems SIGSTKFLT = 16, // Stack fault (obsolete). SIGPWR = 30, // Power failure imminent. // Historical signals specified by POSIX. SIGBUS = 7, // Bus error. SIGSYS = 31, // Bad system call. // New(er) POSIX signals (1003.1-2008, 1003.1-2013). SIGURG = 23, // Urgent data is available at a socket. SIGSTOP = 19, // Stop, unblockable. SIGTSTP = 20, // Keyboard stop. SIGCONT = 18, // Continue. SIGCHLD = 17, // Child terminated or stopped. SIGTTIN = 21, // Background read from control terminal. SIGTTOU = 22, // Background write to control terminal. SIGPOLL = 29, // Pollable event occurred (System V). SIGXFSZ = 25, // File size limit exceeded. SIGXCPU = 24, // CPU time limit exceeded. SIGVTALRM = 26, // Virtual timer expired. SIGPROF = 27, // Profiling timer expired. SIGUSR1 = 10, // User-defined signal 1. SIGUSR2 = 12, // User-defined signal 2. // Nonstandard signals found in all modern POSIX systems (including both BSD and Linux). SIGWINCH = 28, // Window size change (4.3 BSD, Sun). // Archaic names for compatibility. SIGIO = SIGPOLL, // I/O now possible (4.2 BSD). SIGIOT = SIGABRT, // IOT instruction, abort() on a PDP-11. SIGCLD = SIGCHLD, // Old System V name }Source

Socket_API_Level

Socket_API_Level :: enum int { // Comes from <bits/socket-constants.h> SOCKET = 1, // Copy-pasted from protocol numbers TCP = 6, UDP = 17, // Comes from <bits/socket.h> RAW = 255, DECNET = 261, X25 = 262, PACKET = 263, ATM = 264, AAL = 265, IRDA = 266, NETBEUI = 267, LLC = 268, DCCP = 269, NETLINK = 270, TIPC = 271, RXRPC = 272, PPPOL2TP = 273, BLUETOOTH = 274, PNPIPE = 275, RDS = 276, IUCV = 277, CAIF = 278, ALG = 279, NFC = 280, KCM = 281, TLS = 282, XDP = 283, MPTCP = 284, MCTP = 285, SMC = 286, }Source

API Level for getsockopt(2)/setsockopt(2)

Socket_Msg_Bits

Socket_Msg_Bits :: enum int { OOB = 0, PEEK = 1, DONTROUTE = 2, TRYHARD = DONTROUTE, CTRUNC = 3, PROXY = 4, TRUNC = 5, DONTWAIT = 6, EOR = 7, WAITALL = 8, FIN = 9, SYN = 10, CONFIRM = 11, RST = 12, ERRQUEUE = 13, NOSIGNAL = 14, MORE = 15, WAITFORONE = 16, BATCH = 18, ZEROCOPY = 22, FASTOPEN = 29, CMSG_CLOEXEC = 30, }Source

Bits for Socket_Msg

Socket_Option

Socket_Option :: enum int { DEBUG = 1, REUSEADDR = 2, TYPE = 3, ERROR = 4, DONTROUTE = 5, BROADCAST = 6, SNDBUF = 7, RCVBUF = 8, SNDBUFFORCE = 32, RCVBUFFORCE = 33, KEEPALIVE = 9, OOBINLINE = 10, NO_CHECK = 11, PRIORITY = 12, LINGER = 13, BSDCOMPAT = 14, REUSEPORT = 15, PASSCRED = 16, PEERCRED = 17, RCVLOWAT = 18, SNDLOWAT = 19, RCVTIMEO_OLD = 20, SNDTIMEO_OLD = 21, SECURITY_AUTHENTICATION = 22, SECURITY_ENCRYPTION_TRANSPORT = 23, SECURITY_ENCRYPTION_NETWORK = 24, BINDTODEVICE = 25, ATTACH_FILTER = 26, DETACH_FILTER = 27, GET_FILTER = ATTACH_FILTER, PEERNAME = 28, ACCEPTCONN = 30, PEERSEC = 31, PASSSEC = 34, IP_ADD_MEMBERSHIP = 35, MARK = 36, PROTOCOL = 38, DOMAIN = 39, RXQ_OVFL = 40, WIFI_STATUS = 41, PEEK_OFF = 42, NOFCS = 43, LOCK_FILTER = 44, SELECT_ERR_QUEUE = 45, BUSY_POLL = 46, MAX_PACING_RATE = 47, BPF_EXTENSIONS = 48, INCOMING_CPU = 49, ATTACH_BPF = 50, DETACH_BPF = DETACH_FILTER, ATTACH_REUSEPORT_CBPF = 51, ATTACH_REUSEPORT_EBPF = 52, CNX_ADVICE = 53, TIMESTAMPING_OPT_STATS = 54, MEMINFO = 55, INCOMING_NAPI_ID = 56, COOKIE = 57, TIMESTAMPING_PKTINFO = 58, PEERGROUPS = 59, ZEROCOPY = 60, TXTIME = 61, BINDTOIFINDEX = 62, TIMESTAMP_OLD = 29, TIMESTAMPNS_OLD = 35, TIMESTAMPING_OLD = 37, TIMESTAMP_NEW = 63, TIMESTAMPNS_NEW = 64, TIMESTAMPING_NEW = 65, RCVTIMEO_NEW = 66, SNDTIMEO_NEW = 67, DETACH_REUSEPORT_BPF = 68, PREFER_BUSY_POLL = 69, BUSY_POLL_BUDGET = 70, NETNS_COOKIE = 71, BUF_LOCK = 72, RESERVE_MEM = 73, TXREHASH = 74, RCVMARK = 75, TIMESTAMP = TIMESTAMP_OLD when _SOCKET_OPTION_OLD else TIMESTAMP_NEW, TIMESTAMPNS = TIMESTAMPNS_OLD when _SOCKET_OPTION_OLD else TIMESTAMPNS_NEW, TIMESTAMPING = TIMESTAMPING_OLD when _SOCKET_OPTION_OLD else TIMESTAMPING_NEW, RCVTIMEO = RCVTIMEO_OLD when _SOCKET_OPTION_OLD else RCVTIMEO_NEW, SNDTIMEO = SNDTIMEO_OLD when _SOCKET_OPTION_OLD else SNDTIMEO_NEW, }Source

If Socket_API_Level == .SOCKET, these are the options

you can specify in getsockopt(2)/setsockopt(2)

Socket_TCP_Option

Socket_TCP_Option :: enum int { NODELAY = 1, MAXSEG = 2, CORK = 3, KEEPIDLE = 4, KEEPINTVL = 5, KEEPCNT = 6, SYNCNT = 7, LINGER2 = 8, DEFER_ACCEPT = 9, WINDOW_CLAMP = 10, INFO = 11, QUICKACK = 12, CONGESTION = 13, MD5SIG = 14, COOKIE_TRANSACTIONS = 15, THIN_LINEAR_TIMEOUTS = 16, THIN_DUPACK = 17, USER_TIMEOUT = 18, REPAIR = 19, REPAIR_QUEUE = 20, QUEUE_SEQ = 21, REPAIR_OPTIONS = 22, FASTOPEN = 23, TIMESTAMP = 24, NOTSENT_LOWAT = 25, CC_INFO = 26, SAVE_SYN = 27, SAVED_SYN = 28, REPAIR_WINDOW = 29, FASTOPEN_CONNECT = 30, ULP = 31, MD5SIG_EXT = 32, FASTOPEN_KEY = 33, FASTOPEN_NO_COOKIE = 34, ZEROCOPY_RECEIVE = 35, INQ = 36, CM_INQ = INQ, TX_DELAY = 37, }Source

Socket_Type

Socket_Type :: enum int { STREAM = 1, DGRAM = 2, RAW = 3, RDM = 4, SEQPACKET = 5, DCCP = 6, PACKET = 10, }Source

Type of socket to create

  • For TCP you want to use SOCK_STREAM
  • For UDP you want to use SOCK_DGRAM
Also see `Protocol`

Stat

Stat :: struct { _impl_stat: _Arch_Stat, }Source

Represents the file state.

If you're on 32-bit platform, consider using Stat64 instead.

Statx

Statx :: struct { mask: Statx_Mask, blksize: u32, attributes: Statx_Attr, nlink: u32, uid: Uid, gid: Gid, // Note(flysand): mode is 16-bit on linux + there's // 16-bit padding following it. Since our mode is 32-bits, // we're using the padding. This should be fine because // the placement of that padding suggests it was going to // be used for the Mode bits anyway. mode: Mode, ino: Inode, size: u64, blocks: u64, attributes_mask: Statx_Attr, atime: Statx_Timestamp, btime: Statx_Timestamp, ctime: Statx_Timestamp, mtime: Statx_Timestamp, rdev_major: u32, rdev_minor: u32, dev_major: u32, dev_minor: u32, mnt_id: u64, dio_mem_align: u32, dio_offset_align: u32, _: [12]u64, }Source

The extended Stat struct, the argument to statx(2) syscall.

Statx_Attr_Bits

Statx_Attr_Bits :: enum int { COMPRESSED = 2, // 0x00000004 IMMUTABLE = 4, // 0x00000010 APPEND = 5, // 0x00000020 NODUMP = 6, // 0x00000040 ENCRYPTED = 11, // 0x00000800 AUTOMOUNT = 12, // 0x00001000 MOUNT_ROOT = 13, // 0x00002000 VERITY = 20, // 0x00100000 DAX = 21, // 0x00200000 }Source

Bits found in Statx_Attr bitset

You should not use these directly

Statx_Mask_Bits

Statx_Mask_Bits :: enum int { TYPE = 0, MODE = 1, NLINK = 2, UID = 3, GID = 4, ATIME = 5, MTIME = 6, CTIME = 7, INO = 8, SIZE = 9, BLOCKS = 10, BTIME = 11, MNT_ID = 12, DIOALIGN = 13, }Source

The bits used by the Statx_Mask bitset

Syslog_Action

Syslog_Action :: enum i32 { CLOSE = 0, OPEN = 1, READ = 2, READ_ALL = 3, READ_CLEAR = 4, CLEAR = 5, CONSOLE_OFF = 6, CONSOLE_ON = 7, CONSOLE_LEVEL = 8, SIZE_UNREAD = 9, SIZE_BUFFER = 10, }Source

Syslog actions.

UTS_Name

UTS_Name :: struct { sysname: [65]u8, nodename: [65]u8, release: [65]u8, version: [65]u8, machine: [65]u8, domainname: [65]u8, }Source

"Unix time-sharing system name", allegedly.

Basically system info.

Wait_Option

Wait_Option :: enum int { WNOHANG = 0, WUNTRACED = 1, WSTOPPED = 1, WEXITED = 2, WCONTINUED = 3, WNOWAIT = 24, // // For processes created using clone __WNOTHREAD = 29, __WALL = 30, __WCLONE = 31, }Source

Options for wait syscalls

_Arch_User_Regs

_Arch_User_Regs :: struct { // Callee-preserved, may not be correct if the syscall doesn't need // these registers r15: uint, r14: uint, r13: uint, r12: uint, rbp: uint, rbx: uint, // Always saved r11: uint, r10: uint, r9: uint, r8: uint, rax: uint, rcx: uint, rdx: uint, rsi: uint, rdi: uint, // On syscall entry this is the syscall number, on CPU exception this // is the error code, on hardware interrupt this is its IRQ number orig_rax: uint, // Return frame for iretq rip: uint, cs: uint, eflags: uint, rsp: uint, ss: uint, fs_base: uint, gs_base: uint, ds: uint, es: uint, fs: uint, gs: uint, }Source

Constants

557

AT_FDCWD

AT_FDCWD :: Fd = Fd(-100)Source

Special file descriptor to pass to *at functions to specify

that relative paths are relative to current directory.

F_GETLK

F_GETLK :: FCntl_Command_GETLK = FCntl_Command_GETLK(.GETLK)Source

F_GETLK64 :: FCntl_Command_GETLK64(.GETLK64) F_SETLK64 :: FCntl_Command_SETLK64(.SETLK64) F_SETLKW64 :: FCntl_Command_SETLKW64(.SETLKW64)

F_OK

F_OK :: Mode = Mode{}Source

For access.2 syscall family: instruct to check if the file exists.

R_OK

R_OK :: Mode = Mode{.IROTH}Source

For access.2 syscall family: instruct to check if the file is readable.

SYS_read

SYS_read :: uintptr = uintptr(0)Source

AMD64 uses the new way to define syscalls, i.e. one that is different from the other architectures. Instead of using a .tbl file, they define constants to tell which syscalls they want and then include a generic unistd.h file.

UTIME_NOW

UTIME_NOW :: uint = uint((1 << 30) - 1)Source

Special value to put into timespec for utimensat() to set timestamp to the current time.

UTIME_OMIT

UTIME_OMIT :: uint = uint((1 << 30) - 2)Source

Special value to put into the timespec for utimensat() to leave the corresponding field of the timestamp unchanged.

W_OK

W_OK :: Mode = Mode{.IWOTH}Source

For access.2 syscall family: instruct to check if the file is writeable.

X_OK

X_OK :: Mode = Mode{.IXOTH}Source

For access.2 syscall family: instruct to check if the file is executable.

Procedures

330

accept

accept :: proc(sock: Fd, addr: ^T, sockflags: Socket_FD_Flags) -> (Errno, Fd)Source

Accept a pending connection or block until new connection appears.

Depends on Sock_FD_Flags of the `sock` parameter.
	Available since Linux 2.0.

access

access :: proc(name: cstring, mode: Mode) -> (Errno)Source

Check user permissions for a file.

If Mode is F_OK, checks whether the file exists.
	Similarly, X_OK, W_OK, R_OK check if the file is executable, writeable, readable respectively.
	Available since Linux 1.0.
	For ARM64 available since Linux 2.6.16.

alarm

alarm :: proc(seconds: u32) -> (u32)Source

Set an alarm clock for delivery of a signal.

Available since Linux 1.0.

bind

bind :: proc(sock: Fd, addr: ^T) -> (Errno)Source

Bind a socket to the given local address.

Available since Linux 2.0.

brk

brk :: proc(addr: uintptr) -> (Errno)Source

Extend the data segment size until the address addr. Note: you may be

familiar with sbrk(), which is not actually a syscall, so is not
	implemented here.
	Available since Linux 1.0.

chown

chown :: proc(name: cstring, uid: Uid, gid: Gid) -> (Errno)Source

Change ownership of a file.

Available since Linux 2.2.
	On 32-bit architectures available since Linux 2.4.
	On ARM64 available since Linux 2.6.16.

close_range

close_range :: proc(lo: Fd, hi: Fd, flags: Close_Range_Flags) -> (Errno)Source

TODO(flysand): clone3 (probably not this PR) Close the range of files as an atomic operation.

The range of file descriptors is inclusive, and may contain invalid file descriptors.
	Available since Linux 5.9.

dirent_iterate_buf

dirent_iterate_buf :: proc(buf: []u8, offs: ^int) -> (d: ^Dirent, cont: bool)Source

Iterate the results of getdents().

This procedure extracts a directory entry from buf at the offset offs. offs will be modified to store an offset to the possible next directory entry in buf. The procedure only iterates as much data as loaded in the buffer and does not automatically make a request for the buffer to be refilled.

  • buf: A byte buffer with data from getdents()
  • offs: An offset to the next possible directory entry in buf
  • A pointer to a directory entry in buf, or nil
  • A bool value denoting if a valid directory entry is returned

import "core:fmt" import "core:sys/linux"

print_names :: proc(dirfd: linux.Fd) { // Get dirents into a buffer. buf: [128]u8 // Loop until there are no more entries. for { written, err := linux.getdents(dirfd, buf[:]) if err != .NONE || written == 0 { break } // Print the names of the files. offset : int for dir in linux.dirent_iterate_buf(buf[:written], &offset) { name := linux.dirent_name(dir) fmt.println(name) } } }

dirent_name

dirent_name :: proc(dirent: ^Dirent) -> (string)Source

Obtain the name of dirent as a string.

The lifetime of the returned string is bound to the lifetime of the provided dirent structure.

  • dirent: A directory entry
  • A name of the entry

dup

dup :: proc(fd: Fd) -> (Errno, Fd)Source

Allocate a new file descriptor that refers to the same file as the one provided.

Available since Linux 1.0.

dup2

dup2 :: proc(old: Fd, new: Fd) -> (Errno, Fd)Source

Adjust an existing file descriptor to point to the same file as old.

Available since Linux 1.0.
	On ARM64 available since Linux 2.6.27.

dup3

dup3 :: proc(old: Fd, new: Fd, flags: Open_Flags) -> (Errno, Fd)Source

Adjust an existing file descriptor to point to the same file as old.

In addition to dup2 allows to pass O_CLOEXEC flag.
	Available since Linux 2.6.27.

epoll_create

epoll_create :: proc(size: i32) -> (Errno, Fd)Source

TODO(flysand): set_thread_area TODO(flysand): io_setup TODO(flysand): io_destroy TODO(flysand): io_getevents TODO(flysand): io_submit TODO(flysand): io_cancel TODO(flysand): get_thread_area TODO(flysand): lookup_dcookie Open an epoll file descriptor.

The `size` argument is ignored but must be greater than zero.
	
	Available since Linux 2.6.

exit

exit :: proc(code: i32) -> ()Source

Exit the thread with a given exit code.

Available since Linux 1.0.

fchdir

fchdir :: proc(fd: Fd) -> (Errno)Source

Change working directory to the directory specified by dirfd.

Available since Linux 1.0.

fchown

fchown :: proc(fd: Fd, uid: Uid, gid: Gid) -> (Errno)Source

Change ownership of a file by file descriptor.

Available since Linux 1.0.
	On 32-bit architecvtures available since Linux 2.4.

fdatasync

fdatasync :: proc(fd: Fd) -> (Errno)Source

Synchronize the state of the file with the storage device. Similar to fsync,

except does not flush the metadata.
	Available since Linux 2.0.

fstat

fstat :: proc(fd: Fd, stat: ^Stat) -> (Errno)Source

Get file status from file descriptor.

Returns information about the file in struct pointed to by `stat` parameter.

	Available since Linux 1.0.
	For 32-bit systems a different syscall is used that became available since 2.4.

fstatfs

fstatfs :: proc(fd: Fd, statfs: ^Stat_FS) -> (Errno)Source

Query information about filesystem by file descriptor.

Available since Linux 1.0.
	For 32-bit systems a different syscall is used that became available since 2.6.

fsync

fsync :: proc(fd: Fd) -> (Errno)Source

Sync state of the file with the storage device.

Available since Linux 1.0.

ftruncate

ftruncate :: proc(fd: Fd, length: i64) -> (Errno)Source

Truncate a file specified by file descriptor to specified length.

On 32-bit architectures available since 2.4.

futex_cmp_requeue

futex_cmp_requeue :: proc( futex: ^Futex, op: Futex_Cmp_Requeue_Type, flags: Futex_Flags, requeue_threshold: u32, requeue_max: i32, requeue_futex: ^Futex, val: i32, ) -> (Errno, int)Source

NOTE(flysand): futex_fd is racy, so not implemented Requeues processes waiting on futex futex to wait on futex requeue_futex

`requeue_threshold` specifies the maximum amount of waiters to wake up, the rest of the waiters will be requeued
	`requeue_max` specifies the maximum amount of waiters that are required at `requeue_futex`
	The operation blocks until the `requeue_max` requirement is satisfied
	If the value of the mutex is not equal to `val`, fails with EAGAIN before any further checks
	Returns the total number of waiters that have been woken up plus the number of waiters requeued.

getcpu

getcpu :: proc(cpu: ^u32, node: ^u32) -> (Errno)Source

TODO(flysand): setns Determine CPU and NUMA node on which the calling thread is running.

Available since Linux 2.6.19.

getdents

getdents :: proc(dirfd: Fd, buf: []u8) -> (Errno, int)Source

Retrieve the contents of the directory specified by dirfd.

Returns the number of bytes written.
	Available since Linux 2.4.

getegid

getegid :: proc() -> (Gid)Source

Get effective group ID.

Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

geteuid

geteuid :: proc() -> (Uid)Source

Get effective user ID.

Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

getgid

getgid :: proc() -> (Gid)Source

Get real group ID.

Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

getpid

getpid :: proc() -> (Pid)Source

Returns the thread group ID of the current process.

Note that it doesn't return the pid, despite it's name.
	Available since Linux 1.0.

getresgid

getresgid :: proc(real: ^Gid, effective: ^Gid, saved: ^Gid) -> (Errno)Source

Get real, effective and saved group id.

Available since Linux 2.2.
	On 32-bit platforms available since Linux 2.4.

getresuid

getresuid :: proc(real: ^Uid, effective: ^Uid, saved: ^Uid) -> (Errno)Source

Get real, effective and saved user id.

Available since Linux 2.2.
	On 32-bit platforms available since Linux 2.4.

gettid

gettid :: proc() -> (Pid)Source

TODO(flysand): nfsservctl / No longer present after 3.1 TODO(flysand): getpmsg TODO(flysand): putpmsg TODO(flysand): afs_syscall TODO(flysand): tuxcall TODO(flysand): security Returns the thread ID of the current process

This is what the kernel calls "pid".
	Let me insert a tiny rant here, this terminology is confusing:
	sometimes pid refers to a thread, and other times it refers
	to a thread group (process group?)
	Anyway, this syscall is available since Linux 1.0

getuid

getuid :: proc() -> (Uid)Source

Get real user ID.

Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

ioctl

ioctl :: proc(fd: Fd, request: u32, arg: uintptr) -> (uintptr)Source

Control devices. The ioctl syscall is a bit special because

its argument is usually a pointer to some driver-specific structure.
	The request value is device-specific. Consult your LibC implementation's
	ioctls.h file to learn more. The returned value of ioctl *may* be an error
	code value instead of a memory address depending on the request type.
	Available since Linux 1.0.

lchown

lchown :: proc(name: cstring, uid: Uid, gid: Gid) -> (Errno)Source

Change ownership of a file. Unlike chown, if a file is a symlink dooesn't dereference it.

Available since Linux 1.0.
	On 32-bit architectures available since Linux 2.4.
	On ARM64 available since Linux 2.6.16.

listen

listen :: proc(sock: Fd, queue_len: i32) -> (Errno)Source

Marks the socket as a socket that listen to connections using accept(2).

Available since Linux 2.0.

lstat

lstat :: proc(filename: cstring, stat: ^Stat) -> (Errno)Source

Get information about the file that's potentially a symbolic link

The information is returned in a struct pointed to by `stat` parameter.
	The difference with stat, fstat is that if the file is a symbolic link,
	stat and fstat will dereference the link. lstat doesn't dereference symlinks.
	
	Available since Linux 1.0.
	For 32-bit systems a different syscall is used that became available since 2.4.
	Not available on arm64.

mknod

mknod :: proc(name: cstring, mode: Mode, dev: Dev) -> (Errno)Source

Create a special or ordinary file.

`mode` parameter contains both the the file mode and the type of the node to create.
	 ->  Add one of S_IFSOCK, S_IFBLK, S_IFFIFO, S_IFCHR to mode.
	 
	Available since Linux 1.0.
	On ARM64 available since Linux 2.6.16.

pause

pause :: proc()Source

Wait until the next signal is delivered.

Available since Linux 1.0.
	On ARM64 available since Linux 2.6.16.

pidfd_getfd

pidfd_getfd :: proc(pidfd: Pid_FD, fd: Fd, flags: i32) -> (Errno, Fd)Source

TODO(flysand): openat2 Get a file descriptor from another process.

  • fd refers to a file descriptor number to get.
  • flags must be zero.
Available since Linux 5.3.

pidfd_open

pidfd_open :: proc(pid: Pid, flags: Pid_FD_Flags) -> (Errno, Pid_FD)Source

TODO(flysand): open_tree TODO(flysand): move_mount TODO(flysand): fsopen TODO(flysand): fsconfig TODO(flysand): fsmount TODO(flysand): fspick Creates a new PID file descriptor.

The process identified by `pid` must be a pid group leader.
	The returned `pidfd` has `CLOEXEC` semantics.
	Available since Linux 5.3.

prctl

prctl :: proc(op: i32, args) -> (Errno)Source

TODO(flysand): _sysctl Deprecated and discouraged Operations on a process or thread

Available since Linux 2.1.57

pread

pread :: proc(fd: Fd, buf: []u8, offset: i64) -> (Errno, int)Source

Read the file at a specified offset.

Note, it is not an error to return less bytes than requested.
	Available since Linux 2.2.

pwrite

pwrite :: proc(fd: Fd, buf: []u8, offset: i64) -> (Errno, int)Source

Read the file at a specified offset.

Note, it is not an error to return less bytes than requested.
	Available since Linux 2.2.

read

read :: proc(fd: Fd, buf: []u8) -> (Errno, int)Source

Read data from file into the buffer

Returns the number of bytes successfully read, which may be less than the size
	of the buffer even if the termination is successfull.
	Available since Linux 1.0.
	Before Linux 3.14, this operation is not atomic (i.e. not thread safe).

rmdir

rmdir :: proc(name: cstring) -> (Errno)Source

Remove a directory specified by name.

Available since Linux 1.0.
	On ARM64 available since Linux 2.6.16.

sched_getaffinity

sched_getaffinity :: proc(pid: Pid, cpusetsize: uint, mask: rawptr) -> (Errno, int)Source

Get a thread's CPU affinity mask.

Available since Linux 2.6.
	
	If you are running on a system with less than 128 cores you can use `linux.Cpu_Set` as the type for the mask argument.
	Otherwise use an array of integers.

sched_setaffinity

sched_setaffinity :: proc(pid: Pid, cpusetsize: uint, mask: rawptr) -> (Errno, int)Source

Set a thread's CPU affinity mask.

Available since Linux 2.6.
	
	If you are running on a system with less than 128 cores you can use `linux.Cpu_Set` as the type for the mask argument.
	Otherwise use an array of integers.

sendfile

sendfile :: proc(out_fd: Fd, in_fd: Fd, offset: ^i64, count: uint) -> (Errno, int)Source

Transfer the data between file descriptors.

Available since Linux 2.2.
	On 32-bit platforms available since Linux 2.6.

sendmmsg

sendmmsg :: proc(sock: Fd, msg_vec: []MMsg_Hdr, flags: Socket_Msg) -> (Errno, int)Source

TODO(flysand): fanotify_init TODO(flysand): fanotify_mark TODO(flysand): prlimit64 TODO(flysand): name_to_handle_at TODO(flysand): open_by_handle_at TODO(flysand): clock_adjtime TODO(flysand): syncfs Send multiple messages on a socket.

Available since Linux 3.0.

set_tid_address

set_tid_address :: proc(tidptr: ^u32)Source

TODO(flysand): remap_file_pages Set the address of the futex that's gonna be waken when.

current thread terminates.
	Available since Linux 2.6.

setgid

setgid :: proc(gid: Gid) -> (Errno)Source

Set effective group id.

If the process is privileged also sets real group id.
	Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

setregid

setregid :: proc(real: Gid, effective: Gid) -> (Errno)Source

Set real and/or effective group id.

If any of the arguments is -1, the corresponding id is not changed.
	Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

setresgid

setresgid :: proc(real: Gid, effective: Gid, saved: Uid) -> (Errno)Source

Set real, effective and/or saved group id.

If any of the arguments is -1, the corresponding id is not changed.
	Available since Linux 2.2.
	On 32-bit platforms available since Linux 2.4.

setresuid

setresuid :: proc(real: Uid, effective: Uid, saved: Uid) -> (Errno)Source

Set real, effective and/or saved user id.

If any of the arguments is -1, the corresponding id is not changed.
	Available since Linux 2.2.
	On 32-bit platforms available since Linux 2.4.

setreuid

setreuid :: proc(real: Uid, effective: Uid) -> (Errno)Source

Set real and/or effective user id.

If any of the arguments is -1, the corresponding id is not changed.
	Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

setsockopt_base

setsockopt_base :: proc(sock: Fd, level: int, opt: int, val: T) -> (Errno)Source

TODO(flysand): the parameters are the same, maybe there's a way to make it into a single proc, sacrificing type safety slightly TODO(flysand): add ability to specify slices

setuid

setuid :: proc(uid: Uid) -> (Errno)Source

Set effective User ID.

Available since Linux 1.0.
	On 32-bit platforms available since Linux 2.4.

splice

splice :: proc( fd_in: Fd, off_in: ^i64, fd_out: Fd, off_out: ^i64, len: uint, flags: Splice_Flags, ) -> (Errno, int)Source

TODO(flysand): unshare TODO(flysand): set_robust_list TODO(flysand): get_robust_list Transfer the data between file descriptors.

Available since Linux 2.6.17.

stat

stat :: proc(filename: cstring, stat: ^Stat) -> (Errno)Source

Get file status.

Returns information about the file in struct pointed to by `stat` parameter.

	Available since Linux 1.0
	For 32-bit systems a different syscall is used that became available since 2.4.
	Not available on ARM64.

statfs

statfs :: proc(path: cstring, statfs: ^Stat_FS) -> (Errno)Source

TODO(flysand): ustat Query information about filesystem.

Available since Linux 1.0.
	For 32-bit systems a different syscall is used that became available since 2.6.

statx

statx :: proc(dir: Fd, pathname: cstring, flags: FD_Flags, mask: Statx_Mask, statx: ^Statx) -> (Errno)Source

TODO(flysand): userfaultfd TODO(flysand): membarrier TODO(flysand): mlock2 TODO(flysand): copy_file_range TODO(flysand): preadv2 TODO(flysand): pwritev2 TODO(flysand): pkey_mprotect TODO(flysand): pkey_alloc TODO(flysand): pkey_free Query extended information about the file

The file can be specified as:
	- absolute pathname: `dir` parameter is ignored
	- relatvie pathname: `dir` parameter specifies the base directory's fd
	- file descriptor:   `AT_EMPTY_PATH` is passed in flags, pathname is empty, `dir` specifies the file descriptor

	Available since Linux 4.11

utimensat

utimensat :: proc(dirfd: Fd, name: cstring, utimes: [^]Time_Spec, flags: FD_Flags) -> (Errno)Source

TODO(flysand): sync_file_range TODO(flysand): vmsplice TODO(flysand): move_pages Change file timestamps with nanosecond precision.

**utimes** must point to an array of two `Time_Spec`'s. The "utime" is the
	last access time, the second is last modification time.
	Available since Linux 2.6.22.

vfork

vfork :: proc() -> (Pid)Source

Create a child process and block parent.

Available since Linux 2.2.

waitid

waitid :: proc(id_type: Id_Type, id: Id, sig_info: ^Sig_Info, options: Wait_Options, rusage: ^RUsage) -> (Errno)Source

TODO(flysand): utimes TODO(flysand): vserver TODO(flysand): mbind TODO(flysand): set_mempolicy TODO(flysand): get_mempolicy TODO(flysand): mq_open TODO(flysand): mq_unlink TODO(flysand): mq_timedsend TODO(flysand): mq_timedreceive TODO(flysand): mq_notify TODO(flysand): mq_getsetattr TODO(flysand): kexec_load Wait on process, process group or pid file descriptor.

Available since Linux 2.6.10.

write

write :: proc(fd: Fd, buf: []u8) -> (Errno, int)Source

Write the data from a buffer into the file

Returns the number of bytes successfully written, which may be less than the size
	of the buffer, even if the termination is successfull
	When using direct I/O, error doesn't mean the write has failed. Partial data may
	have been written.
	If .Eintr is returned, the write operation has failed due to interrupt. You'll probably
	need to restart this syscall

	Available since Linux 1.0
	Before Linux 3.14 this operation is not atomic (i.e. not thread safe)

Procedure Groups

10

ptrace

ptrace :: proc{ptrace_traceme, ptrace_peek, ptrace_poke, ptrace_getregs, ptrace_getfpregs, ptrace_getfpxregs, ptrace_setregs, ptrace_setfpregs, ptrace_setfpxregs, ptrace_getregset, ptrace_setregset, ptrace_getsiginfo, ptrace_peeksiginfo, ptrace_getsigmask, ptrace_setsigmask, ptrace_setoptions, ptrace_geteventmsg, ptrace_cont, ptrace_singlestep, ptrace_syscall, ptrace_sysemu, ptrace_sysemu_singlestep, ptrace_listen, ptrace_interrupt, ptrace_attach, ptrace_seize, ptrace_detach}Source

TODO(flysand): ptrace_get_thread_area TODO(flysand): ptrace_set_thread_area TODO(flysand): ptrace_get_syscall_info Trace process.

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.