Merge pull request #2917 from flysand7/sys-linux-additions

[sys/linux]: Fixes and additions
This commit is contained in:
gingerBill
2024-01-02 14:23:40 +00:00
committed by GitHub
4 changed files with 2688 additions and 618 deletions
+423 -65
View File
@@ -1,7 +1,9 @@
package linux package linux
/// Represents an error returned by most of syscalls /*
Represents an error returned by most of syscalls
*/
Errno :: enum i32 { Errno :: enum i32 {
NONE = 0, NONE = 0,
// Errno-base // Errno-base
@@ -142,8 +144,9 @@ Errno :: enum i32 {
EDEADLOCK = EDEADLK, EDEADLOCK = EDEADLK,
} }
/*
/// Bits for Open_Flags Bits for Open_Flags
*/
Open_Flags_Bits :: enum { Open_Flags_Bits :: enum {
RDONLY = 0, RDONLY = 0,
WRONLY = 1, WRONLY = 1,
@@ -164,7 +167,9 @@ Open_Flags_Bits :: enum {
PATH = 21, PATH = 21,
} }
/// Bits for FD_Flags bitset /*
Bits for FD_Flags bitset
*/
FD_Flags_Bits :: enum { FD_Flags_Bits :: enum {
SYMLINK_NOFOLLOW = 8, SYMLINK_NOFOLLOW = 8,
REMOVEDIR = 9, REMOVEDIR = 9,
@@ -177,7 +182,9 @@ FD_Flags_Bits :: enum {
RECURSIVE = 15, RECURSIVE = 15,
} }
/// The bits for the Mode bitset. /*
The bits for the Mode bitset.
*/
Mode_Bits :: enum { Mode_Bits :: enum {
IXOTH = 0, // 0o0000001 IXOTH = 0, // 0o0000001
IWOTH = 1, // 0o0000002 IWOTH = 1, // 0o0000002
@@ -197,7 +204,9 @@ Mode_Bits :: enum {
IFREG = 15, // 0o0100000 IFREG = 15, // 0o0100000
} }
/// The bits used by the Statx_Mask bitset /*
The bits used by the Statx_Mask bitset
*/
Statx_Mask_Bits :: enum { Statx_Mask_Bits :: enum {
TYPE = 0, TYPE = 0,
MODE = 1, MODE = 1,
@@ -215,8 +224,10 @@ Statx_Mask_Bits :: enum {
DIOALIGN = 13, DIOALIGN = 13,
} }
/// Bits found in Statx_Attr bitset /*
/// You should not use these directly Bits found in Statx_Attr bitset
You should not use these directly
*/
Statx_Attr_Bits :: enum { Statx_Attr_Bits :: enum {
COMPRESSED = 2, // 0x00000004 COMPRESSED = 2, // 0x00000004
IMMUTABLE = 4, // 0x00000010 IMMUTABLE = 4, // 0x00000010
@@ -229,7 +240,9 @@ Statx_Attr_Bits :: enum {
DAX = 21, // 0x00200000 DAX = 21, // 0x00200000
} }
/// Magic bits for filesystems returned by Stat_FS /*
Magic bits for filesystems returned by Stat_FS
*/
FS_Magic :: enum u32 { FS_Magic :: enum u32 {
ADFS_SUPER_MAGIC = 0xadf5, ADFS_SUPER_MAGIC = 0xadf5,
AFFS_SUPER_MAGIC = 0xadff, AFFS_SUPER_MAGIC = 0xadff,
@@ -317,7 +330,9 @@ FS_Magic :: enum u32 {
_XIAFS_SUPER_MAGIC = 0x012fd16d, _XIAFS_SUPER_MAGIC = 0x012fd16d,
} }
/// Bits for FS_Flags bitset /*
Bits for FS_Flags bitset
*/
FS_Flags_Bits :: enum { FS_Flags_Bits :: enum {
RDONLY = 0, RDONLY = 0,
NOSUID = 1, NOSUID = 1,
@@ -340,20 +355,26 @@ Seek_Whence :: enum i16 {
HOLE = 4, HOLE = 4,
} }
/// Bits for Close_Range_Flags /*
Bits for Close_Range_Flags
*/
Close_Range_Flags_Bits :: enum { Close_Range_Flags_Bits :: enum {
CLOEXEC = 2, CLOEXEC = 2,
UNSHARE = 1, UNSHARE = 1,
} }
/// Bits for Rename_Flags /*
Bits for Rename_Flags
*/
Rename_Flags_Bits :: enum { Rename_Flags_Bits :: enum {
EXCHANGE = 1, EXCHANGE = 1,
NOREPLACE = 0, NOREPLACE = 0,
WHITEOUT = 2, WHITEOUT = 2,
} }
/// Type of the file in a directory entry /*
Type of the file in a directory entry
*/
Dirent_Type :: enum u8 { Dirent_Type :: enum u8 {
UNKNOWN = 0, UNKNOWN = 0,
FIFO = 1, FIFO = 1,
@@ -366,14 +387,18 @@ Dirent_Type :: enum u8 {
WHT = 14, WHT = 14,
} }
/// Type of a lock for fcntl.2 /*
Type of a lock for fcntl(2)
*/
FLock_Type :: enum i16 { FLock_Type :: enum i16 {
RDLCK = 0, RDLCK = 0,
WRLCK = 1, WRLCK = 1,
UNLCK = 2, UNLCK = 2,
} }
/// Bits for FD_Notifications /*
Bits for FD_Notifications
*/
FD_Notifications_Bits :: enum { FD_Notifications_Bits :: enum {
ACCESS = 0, ACCESS = 0,
MODIFY = 1, MODIFY = 1,
@@ -384,7 +409,9 @@ FD_Notifications_Bits :: enum {
MULTISHOT = 31, MULTISHOT = 31,
} }
/// Bits for seal /*
Bits for seal
*/
Seal_Bits :: enum { Seal_Bits :: enum {
SEAL = 0, SEAL = 0,
SHRINK = 1, SHRINK = 1,
@@ -408,14 +435,18 @@ FD_Lease :: enum {
UNLCK = 2, UNLCK = 2,
} }
/// Kind of owner for FD_Owner /*
Kind of owner for FD_Owner
*/
F_Owner_Type :: enum i32 { F_Owner_Type :: enum i32 {
OWNER_TID = 0, OWNER_TID = 0,
OWNER_PID = 1, OWNER_PID = 1,
OWNER_PGRP = 2, OWNER_PGRP = 2,
} }
/// Command for fcntl.2 /*
Command for fcntl(2)
*/
FCntl_Command :: enum { FCntl_Command :: enum {
DUPFD = 0, DUPFD = 0,
GETFD = 1, GETFD = 1,
@@ -465,7 +496,9 @@ Fd_Poll_Events_Bits :: enum {
RDHUP = 13, RDHUP = 13,
} }
/// Bits for Mem_Protection bitfield /*
Bits for Mem_Protection bitfield
*/
Mem_Protection_Bits :: enum{ Mem_Protection_Bits :: enum{
READ = 0, READ = 0,
WRITE = 1, WRITE = 1,
@@ -479,7 +512,9 @@ Mem_Protection_Bits :: enum{
GROWSUP = 25, GROWSUP = 25,
} }
/// Bits for Map_Flags /*
Bits for Map_Flags
*/
Map_Flags_Bits :: enum { Map_Flags_Bits :: enum {
SHARED = 0, SHARED = 0,
PRIVATE = 1, PRIVATE = 1,
@@ -504,19 +539,25 @@ Map_Flags_Bits :: enum {
UNINITIALIZED = 26, UNINITIALIZED = 26,
} }
/// Bits for MLock_Flags /*
Bits for MLock_Flags
*/
MLock_Flags_Bits :: enum { MLock_Flags_Bits :: enum {
ONFAULT = 0, ONFAULT = 0,
} }
/// Bits for MSync_Flags /*
Bits for MSync_Flags
*/
MSync_Flags_Bits :: enum { MSync_Flags_Bits :: enum {
ASYNC = 0, ASYNC = 0,
INVALIDATE = 1, INVALIDATE = 1,
SYNC = 2, SYNC = 2,
} }
/// Argument for madvice.2 /*
Argument for madvice(2)
*/
MAdvice :: enum { MAdvice :: enum {
NORMAL = 0, NORMAL = 0,
RANDOM = 1, RANDOM = 1,
@@ -545,27 +586,35 @@ MAdvice :: enum {
SOFT_OFFLINE = 101, SOFT_OFFLINE = 101,
} }
/// Bits for PKey_Access_Rights /*
Bits for PKey_Access_Rights
*/
PKey_Access_Bits :: enum { PKey_Access_Bits :: enum {
DISABLE_ACCESS = 0, DISABLE_ACCESS = 0,
DISABLE_WRITE = 2, DISABLE_WRITE = 2,
} }
/// Bits for MRemap_Flags /*
Bits for MRemap_Flags
*/
MRemap_Flags_Bits :: enum { MRemap_Flags_Bits :: enum {
MAYMOVE = 0, MAYMOVE = 0,
FIXED = 1, FIXED = 1,
DONTUNMAP = 2, DONTUNMAP = 2,
} }
/// Bits for Get_Random_Flags /*
Bits for Get_Random_Flags
*/
Get_Random_Flags_Bits :: enum { Get_Random_Flags_Bits :: enum {
RANDOM = 0, RANDOM = 0,
NONBLOCK = 1, NONBLOCK = 1,
INSECURE = 2, INSECURE = 2,
} }
/// Bits for Perf_Flags /*
Bits for Perf_Flags
*/
Perf_Flags_Bits :: enum { Perf_Flags_Bits :: enum {
FD_NO_GROUP = 0, FD_NO_GROUP = 0,
FD_OUTPUT = 1, FD_OUTPUT = 1,
@@ -573,7 +622,9 @@ Perf_Flags_Bits :: enum {
FD_CLOEXEC = 3, FD_CLOEXEC = 3,
} }
/// Union tag for Perf_Event_Attr struct /*
Union tag for Perf_Event_Attr struct
*/
Perf_Event_Type :: enum u32 { Perf_Event_Type :: enum u32 {
HARDWARE = 0, HARDWARE = 0,
SOFTWARE = 1, SOFTWARE = 1,
@@ -633,7 +684,9 @@ Perf_Cap_Flags_Bits :: enum u64 {
User_Time_Short = 5, User_Time_Short = 5,
} }
/// Specifies the type of the hardware event that you want to get info about /*
Specifies the type of the hardware event that you want to get info about
*/
Perf_Hardware_Id :: enum u64 { Perf_Hardware_Id :: enum u64 {
CPU_CYCLES = 0, CPU_CYCLES = 0,
INSTRUCTIONS = 1, INSTRUCTIONS = 1,
@@ -647,7 +700,9 @@ Perf_Hardware_Id :: enum u64 {
REF_CPU_CYCLES = 9, REF_CPU_CYCLES = 9,
} }
/// Specifies the cache for the particular cache event that you want to get info about /*
Specifies the cache for the particular cache event that you want to get info about
*/
Perf_Hardware_Cache_Id :: enum u64 { Perf_Hardware_Cache_Id :: enum u64 {
L1D = 0, L1D = 0,
L1I = 1, L1I = 1,
@@ -658,20 +713,26 @@ Perf_Hardware_Cache_Id :: enum u64 {
NODE = 6, NODE = 6,
} }
/// Specifies the cache op that you want to get info about /*
Specifies the cache op that you want to get info about
*/
Perf_Hardware_Cache_Op_Id :: enum u64 { Perf_Hardware_Cache_Op_Id :: enum u64 {
READ = 0, READ = 0,
WRITE = 1, WRITE = 1,
PREFETCH = 2, PREFETCH = 2,
} }
/// Specifies the cache operation result that you want to get info about /*
Specifies the cache operation result that you want to get info about
*/
Perf_Hardware_Cache_Result_Id :: enum u64 { Perf_Hardware_Cache_Result_Id :: enum u64 {
ACCESS = 0, ACCESS = 0,
MISS = 1, MISS = 1,
} }
/// Specifies the particular software event that you want to get info about /*
Specifies the particular software event that you want to get info about
*/
Perf_Software_Id :: enum u64 { Perf_Software_Id :: enum u64 {
CPU_CLOCK = 0, CPU_CLOCK = 0,
TASK_CLOCK = 1, TASK_CLOCK = 1,
@@ -688,7 +749,9 @@ Perf_Software_Id :: enum u64 {
} }
/// Specifies which values to include in the sample /*
Specifies which values to include in the sample
*/
Perf_Event_Sample_Type_Bits :: enum { Perf_Event_Sample_Type_Bits :: enum {
IP = 0, IP = 0,
TID = 1, TID = 1,
@@ -726,7 +789,9 @@ Perf_Read_Format_Bits :: enum {
LOST = 4, LOST = 4,
} }
/// Chooses the breakpoint type /*
Chooses the breakpoint type
*/
Hardware_Breakpoint_Type :: enum u32 { Hardware_Breakpoint_Type :: enum u32 {
EMPTY = 0, EMPTY = 0,
R = 1, R = 1,
@@ -736,7 +801,9 @@ Hardware_Breakpoint_Type :: enum u32 {
INVALID = RW | X, INVALID = RW | X,
} }
/// Bits for Branch_Sample_Type /*
Bits for Branch_Sample_Type
*/
Branch_Sample_Type_Bits :: enum { Branch_Sample_Type_Bits :: enum {
USER = 0, USER = 0,
KERNEL = 1, KERNEL = 1,
@@ -759,7 +826,9 @@ Branch_Sample_Type_Bits :: enum {
PRIV_SAVE = 18, PRIV_SAVE = 18,
} }
/// Represent the type of Id /*
Represent the type of Id
*/
Id_Type :: enum uint { Id_Type :: enum uint {
ALL = 0, ALL = 0,
PID = 1, PID = 1,
@@ -767,7 +836,9 @@ Id_Type :: enum uint {
PIDFD = 3, PIDFD = 3,
} }
/// Options for wait syscalls /*
Options for wait syscalls
*/
Wait_Option :: enum { Wait_Option :: enum {
WNOHANG = 0, WNOHANG = 0,
WUNTRACED = 1, WUNTRACED = 1,
@@ -781,12 +852,16 @@ Wait_Option :: enum {
__WCLONE = 31, __WCLONE = 31,
} }
/// Bits for flags for pidfd /*
Bits for flags for pidfd
*/
Pid_FD_Flags_Bits :: enum { Pid_FD_Flags_Bits :: enum {
NONBLOCK = 11, NONBLOCK = 11,
} }
/// Priority for process, process group, user /*
Priority for process, process group, user
*/
Priority_Which :: enum i32 { Priority_Which :: enum i32 {
PROCESS = 0, PROCESS = 0,
PGRP = 1, PGRP = 1,
@@ -849,10 +924,12 @@ Sig_Stack_Flag :: enum i32 {
AUTODISARM = 31, AUTODISARM = 31,
} }
/// Type of socket to create /*
/// For TCP you want to use SOCK_STREAM Type of socket to create
/// For UDP you want to use SOCK_DGRAM - For TCP you want to use SOCK_STREAM
/// Also see Protocol - For UDP you want to use SOCK_DGRAM
Also see `Protocol`
*/
Socket_Type :: enum { Socket_Type :: enum {
STREAM = 1, STREAM = 1,
DGRAM = 2, DGRAM = 2,
@@ -863,13 +940,17 @@ Socket_Type :: enum {
PACKET = 10, PACKET = 10,
} }
/// Bits for Socket_FD_Flags /*
Bits for Socket_FD_Flags
*/
Socket_FD_Flags_Bits :: enum { Socket_FD_Flags_Bits :: enum {
NONBLOCK = 14, NONBLOCK = 14,
CLOEXEC = 25, CLOEXEC = 25,
} }
/// Protocol family /*
Protocol family
*/
Protocol_Family :: enum u16 { Protocol_Family :: enum u16 {
UNSPEC = 0, UNSPEC = 0,
LOCAL = 1, LOCAL = 1,
@@ -922,11 +1003,13 @@ Protocol_Family :: enum u16 {
MCTP = 45, MCTP = 45,
} }
/// The protocol number according to IANA protocol number list /*
/// Full list of protocol numbers: The protocol number according to IANA protocol number list
/// https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml Full list of protocol numbers:
/// Supported by the OS protocols can be queried by reading: https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
/// /etc/protocols Supported by the OS protocols can be queried by reading:
/etc/protocols
*/
Protocol :: enum { Protocol :: enum {
HOPOPT = 0, HOPOPT = 0,
ICMP = 1, ICMP = 1,
@@ -1066,7 +1149,9 @@ Protocol :: enum {
Reserved = 255, Reserved = 255,
} }
/// API Level for get/setsockopt.2 /*
API Level for getsockopt(2)/setsockopt(2)
*/
Socket_API_Level :: enum { Socket_API_Level :: enum {
// Comes from <bits/socket-constants.h> // Comes from <bits/socket-constants.h>
SOCKET = 1, SOCKET = 1,
@@ -1103,8 +1188,10 @@ Socket_API_Level :: enum {
SMC = 286, SMC = 286,
} }
/// If Socket_API_Level == .SOCKET, these are the options /*
/// you can specify in get/setsockopt.2 If Socket_API_Level == .SOCKET, these are the options
you can specify in getsockopt(2)/setsockopt(2)
*/
Socket_Option :: enum { Socket_Option :: enum {
DEBUG = 1, DEBUG = 1,
REUSEADDR = 2, REUSEADDR = 2,
@@ -1249,7 +1336,9 @@ Socket_TCP_Option :: enum {
TX_DELAY = 37, TX_DELAY = 37,
} }
/// Bits for Socket_Msg /*
Bits for Socket_Msg
*/
Socket_Msg_Bits :: enum { Socket_Msg_Bits :: enum {
OOB = 0, OOB = 0,
PEEK = 1, PEEK = 1,
@@ -1275,14 +1364,18 @@ Socket_Msg_Bits :: enum {
CMSG_CLOEXEC = 30, CMSG_CLOEXEC = 30,
} }
/// Argument to shutdown.2 /*
Argument to shutdown(2)
*/
Shutdown_How :: enum i32 { Shutdown_How :: enum i32 {
RD = 0, RD = 0,
WR = 1, WR = 1,
RDWR = 2, RDWR = 2,
} }
/// Second argument to futex.2 syscall /*
Second argument to futex(2) syscall
*/
Futex_Op :: enum u32 { Futex_Op :: enum u32 {
WAIT = 0, WAIT = 0,
WAKE = 1, WAKE = 1,
@@ -1300,13 +1393,17 @@ Futex_Op :: enum u32 {
LOCK_PI2 = 13, LOCK_PI2 = 13,
} }
/// Bits for Futex_Flags /*
Bits for Futex_Flags
*/
Futex_Flags_Bits :: enum { Futex_Flags_Bits :: enum {
PRIVATE = 7, PRIVATE = 7,
REALTIME = 8, REALTIME = 8,
} }
/// Kind of operation on futex, see FUTEX_WAKE_OP /*
Kind of operation on futex, see FUTEX_WAKE_OP
*/
Futex_Arg_Op :: enum { Futex_Arg_Op :: enum {
SET = 0, /* uaddr2 = oparg; */ SET = 0, /* uaddr2 = oparg; */
ADD = 1, /* uaddr2 += oparg; */ ADD = 1, /* uaddr2 += oparg; */
@@ -1320,7 +1417,9 @@ Futex_Arg_Op :: enum {
PO2_XOR = 4, /* uaddr2 ^= 1<<oparg; */ PO2_XOR = 4, /* uaddr2 ^= 1<<oparg; */
} }
/// Kind of comparison operation on futex, see FUTEX_WAKE_OP /*
Kind of comparison operation on futex, see FUTEX_WAKE_OP
*/
Futex_Cmp_Op :: enum { Futex_Cmp_Op :: enum {
EQ = 0, /* if (oldval == cmparg) wake */ EQ = 0, /* if (oldval == cmparg) wake */
NE = 1, /* if (oldval != cmparg) wake */ NE = 1, /* if (oldval != cmparg) wake */
@@ -1330,7 +1429,9 @@ Futex_Cmp_Op :: enum {
GE = 5, /* if (oldval >= cmparg) wake */ GE = 5, /* if (oldval >= cmparg) wake */
} }
/// The kind of resource limits /*
The kind of resource limits
*/
RLimit_Kind :: enum i32 { RLimit_Kind :: enum i32 {
CPU = 0, CPU = 0,
FSIZE = 1, FSIZE = 1,
@@ -1351,7 +1452,9 @@ RLimit_Kind :: enum i32 {
NLIMITS = 16, NLIMITS = 16,
} }
/// Represents the user of resources /*
Represents the user of resources
*/
RUsage_Who :: enum i32 { RUsage_Who :: enum i32 {
CHILDREN = -1, CHILDREN = -1,
SELF = 0, SELF = 0,
@@ -1359,7 +1462,9 @@ RUsage_Who :: enum i32 {
LWP = THREAD, LWP = THREAD,
} }
/// Bits for Personality_Flags /*
Bits for Personality_Flags
*/
UNAME26 :: 17 UNAME26 :: 17
ADDR_NO_RANDOMIZE :: 18 ADDR_NO_RANDOMIZE :: 18
FDPIC_FUNCPTRS :: 19 FDPIC_FUNCPTRS :: 19
@@ -1372,8 +1477,10 @@ WHOLE_SECONDS :: 25
STICKY_TIMEOUTS :: 26 STICKY_TIMEOUTS :: 26
ADDR_LIMIT_3GB :: 27 ADDR_LIMIT_3GB :: 27
/// Personality type /*
/// These go into the bottom 8 bits of the personality value Personality type
These go into the bottom 8 bits of the personality value
*/
PER_LINUX :: 0x0000 PER_LINUX :: 0x0000
PER_LINUX_32BIT :: 0x0000 | ADDR_LIMIT_32BIT PER_LINUX_32BIT :: 0x0000 | ADDR_LIMIT_32BIT
PER_LINUX_FDPIC :: 0x0000 | FDPIC_FUNCPTRS PER_LINUX_FDPIC :: 0x0000 | FDPIC_FUNCPTRS
@@ -1398,3 +1505,254 @@ PER_OSF4 :: 0x000f
PER_HPUX :: 0x0010 PER_HPUX :: 0x0010
PER_MASK :: 0x00ff PER_MASK :: 0x00ff
/*
Bits for access modes for shared memory
*/
IPC_Mode_Bits :: enum {
WROTH = 1,
RDOTH = 2,
WRGRP = 4,
RDGRP = 5,
WRUSR = 7,
RDUSR = 8,
DEST = 9,
LOCKED = 10,
}
/*
Shared memory flags bits
*/
IPC_Flags_Bits :: enum {
IPC_CREAT = 9,
IPC_EXCL = 10,
IPC_NOWAIT = 11,
// Semaphore
SEM_UNDO = 9,
// Shared memory
SHM_HUGETLB = 11,
SHM_NORESERVE = 12,
SHM_RDONLY = 12,
SHM_RND = 13,
SHM_REMAP = 14,
SHM_EXEC = 15,
// Message queue
MSG_NOERROR = 12,
MSG_EXCEPT = 13,
MSG_COPY = 14,
}
/*
IPC memory commands
*/
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,
}
/*
File locking operation bits
*/
FLock_Op_Bits :: enum {
SH = 1,
EX = 2,
NB = 4,
UN = 8,
}
/*
ptrace requests
*/
PTrace_Request :: enum {
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 = 0x4200,
GETEVENTMSG = 0x4201,
GETSIGINFO = 0x4202,
SETSIGINFO = 0x4203,
GETREGSET = 0x4204,
SETREGSET = 0x4205,
SEIZE = 0x4206,
INTERRUPT = 0x4207,
LISTEN = 0x4208,
PEEKSIGINFO = 0x4209,
GETSIGMASK = 0x420a,
SETSIGMASK = 0x420b,
SECCOMP_GET_FILTER = 0x420c,
SECCOMP_GET_METADATA = 0x420d,
GET_SYSCALL_INFO = 0x420e,
GET_RSEQ_CONFIGURATION = 0x420f,
}
/*
ptrace options
*/
PTrace_Options_Bits :: enum {
TRACESYSGOOD = 0,
TRACEFORK = 1,
TRACEVFORK = 2,
TRACECLONE = 3,
TRACEEXEC = 4,
TRACEVFORKDONE = 5,
TRACEEXIT = 6,
TRACESECCOMP = 7,
EXITKILL = 20,
SUSPEND_SECCOMP = 21,
}
/*
ptrace event codes.
*/
PTrace_Event_Code :: enum {
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,
}
/*
ptrace's get syscall info operation.
*/
PTrace_Get_Syscall_Info_Op :: enum u8 {
NONE = 0,
ENTRY = 1,
EXIT = 2,
SECCOMP = 3,
}
/*
ptrace's PEEKSIGINFO flags bits
*/
PTrace_Peek_Sig_Info_Flags_Bits :: enum {
SHARED = 0,
}
/*
Syslog actions.
*/
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,
}
/*
Bits for splice flags.
*/
Splice_Flags_Bits :: enum {
MOVE = 0x01,
NONBLOCK = 0x02,
MORE = 0x04,
GIFT = 0x08,
}
/*
Clock IDs for various system clocks.
*/
Clock_Id :: enum {
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,
}
/*
Bits for POSIX interval timer flags.
*/
ITimer_Flags_Bits :: enum {
ABSTIME = 1,
}
/*
Bits for epoll_create(2) flags.
*/
EPoll_Flags_Bits :: enum {
FDCLOEXEC = 19,
}
EPoll_Event_Kind :: enum u32 {
IN = 0x001,
PRI = 0x002,
OUT = 0x004,
RDNORM = 0x040,
RDBAND = 0x080,
WRNORM = 0x100,
WRBAND = 0x200,
MSG = 0x400,
ERR = 0x008,
HUP = 0x010,
RDHUP = 0x2000,
EXCLUSIVE = 1<<28,
WAKEUP = 1<<29,
ONESHOT = 1<<30,
ET = 1<<31,
}
EPoll_Ctl_Opcode :: enum i32 {
ADD = 1,
DEL = 2,
MOD = 3,
}
+166 -29
View File
@@ -1,26 +1,40 @@
package linux package linux
/// Special file descriptor to pass to `*at` functions to specify /*
/// that relative paths are relative to current directory Special file descriptor to pass to `*at` functions to specify
that relative paths are relative to current directory.
*/
AT_FDCWD :: Fd(-100) AT_FDCWD :: Fd(-100)
/// Special value to put into timespec for utimensat() to set timestamp to the current time /*
Special value to put into timespec for utimensat() to set timestamp to the current time.
*/
UTIME_NOW :: uint((1 << 30) - 1) UTIME_NOW :: uint((1 << 30) - 1)
/// Special value to put into the timespec for utimensat() to leave the corresponding field of the timestamp unchanged /*
Special value to put into the timespec for utimensat() to leave the corresponding field of the timestamp unchanged.
*/
UTIME_OMIT :: uint((1 << 30) - 2) UTIME_OMIT :: uint((1 << 30) - 2)
/// For wait4: Pass this pid to wait for any process /*
For wait4: Pass this pid to wait for any process.
*/
WAIT_ANY :: Pid(-1) WAIT_ANY :: Pid(-1)
/// For wait4: Pass this pid to wait for any process in current process group /*
For wait4: Pass this pid to wait for any process in current process group.
*/
WAIT_MYPGRP :: Pid(0) WAIT_MYPGRP :: Pid(0)
/// Maximum priority (aka nice value) for the process /*
Maximum priority (aka nice value) for the process.
*/
PRIO_MAX :: 20 PRIO_MAX :: 20
/// Minimum priority (aka nice value) for the process /*
Minimum priority (aka nice value) for the process.
*/
PRIO_MIN :: -20 PRIO_MIN :: -20
SIGRTMIN :: Signal(32) SIGRTMIN :: Signal(32)
@@ -35,40 +49,64 @@ S_IFCHR :: Mode{.IFCHR}
S_IFDIR :: Mode{.IFDIR} S_IFDIR :: Mode{.IFDIR}
S_IFREG :: Mode{.IFREG} S_IFREG :: Mode{.IFREG}
/// Checks the Mode bits to see if the file is a named pipe (FIFO) /*
Checks the Mode bits to see if the file is a named pipe (FIFO).
*/
S_ISFIFO :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFFIFO == (m & S_IFMT))} S_ISFIFO :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFFIFO == (m & S_IFMT))}
/// Check the Mode bits to see if the file is a character device /*
Check the Mode bits to see if the file is a character device.
*/
S_ISCHR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFCHR == (m & S_IFMT))} S_ISCHR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFCHR == (m & S_IFMT))}
/// Check the Mode bits to see if the file is a directory /*
Check the Mode bits to see if the file is a directory.
*/
S_ISDIR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFDIR == (m & S_IFMT))} S_ISDIR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFDIR == (m & S_IFMT))}
/// Check the Mode bits to see if the file is a register /*
Check the Mode bits to see if the file is a register.
*/
S_ISREG :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFREG == (m & S_IFMT))} S_ISREG :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFREG == (m & S_IFMT))}
/// Check the Mode bits to see if the file is a socket /*
Check the Mode bits to see if the file is a socket.
*/
S_ISSOCK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFSOCK == (m & S_IFMT))} S_ISSOCK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFSOCK == (m & S_IFMT))}
/// Check the Mode bits to see if the file is a symlink /*
Check the Mode bits to see if the file is a symlink.
*/
S_ISLNK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFLNK == (m & S_IFMT))} S_ISLNK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFLNK == (m & S_IFMT))}
/// Check the Mode bits to see if the file is a block device /*
Check the Mode bits to see if the file is a block device.
*/
S_ISBLK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFBLK == (m & S_IFMT))} S_ISBLK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFBLK == (m & S_IFMT))}
/// For access.2 syscall family: instruct to check if the file exists /*
For access.2 syscall family: instruct to check if the file exists.
*/
F_OK :: Mode{} F_OK :: Mode{}
/// For access.2 syscall family: instruct to check if the file is executable /*
For access.2 syscall family: instruct to check if the file is executable.
*/
X_OK :: Mode{.IXOTH} X_OK :: Mode{.IXOTH}
/// For access.2 syscall family: instruct to check if the file is writeable /*
For access.2 syscall family: instruct to check if the file is writeable.
*/
W_OK :: Mode{.IWOTH} W_OK :: Mode{.IWOTH}
/// For access.2 syscall family: instruct to check if the file is readable /*
For access.2 syscall family: instruct to check if the file is readable.
*/
R_OK :: Mode{.IROTH} R_OK :: Mode{.IROTH}
/// The stats you get by calling `stat` /*
The stats you get by calling `stat`.
*/
STATX_BASIC_STATS :: Statx_Mask { STATX_BASIC_STATS :: Statx_Mask {
.TYPE, .TYPE,
.MODE, .MODE,
@@ -83,6 +121,10 @@ STATX_BASIC_STATS :: Statx_Mask {
.BLOCKS, .BLOCKS,
} }
/*
Tell `shmget` to create a new key
*/
IPC_PRIVATE :: Key(0)
FCntl_Command_DUPFD :: distinct FCntl_Command FCntl_Command_DUPFD :: distinct FCntl_Command
FCntl_Command_GETFD :: distinct FCntl_Command FCntl_Command_GETFD :: distinct FCntl_Command
@@ -165,28 +207,44 @@ Futex_Wait_requeue_Pi_Type :: distinct Futex_Op
Futex_Cmp_requeue_Pi_Type :: distinct Futex_Op Futex_Cmp_requeue_Pi_Type :: distinct Futex_Op
Futex_Lock_Pi2_Type :: distinct Futex_Op Futex_Lock_Pi2_Type :: distinct Futex_Op
/// Wait on futex wakeup signal /*
Wait on futex wakeup signal.
*/
FUTEX_WAIT :: Futex_Wait_Type(.WAIT) FUTEX_WAIT :: Futex_Wait_Type(.WAIT)
/// Wake up other processes waiting on the futex /*
Wake up other processes waiting on the futex.
*/
FUTEX_WAKE :: Futex_Wake_Type(.WAKE) FUTEX_WAKE :: Futex_Wake_Type(.WAKE)
/// Not implemented. Basically, since /*
Not implemented. Basically, since.
*/
FUTEX_FD :: Futex_Fd_Type(.FD) FUTEX_FD :: Futex_Fd_Type(.FD)
/// Requeue waiters from one futex to another /*
Requeue waiters from one futex to another.
*/
FUTEX_REQUEUE :: Futex_Requeue_Type(.REQUEUE) FUTEX_REQUEUE :: Futex_Requeue_Type(.REQUEUE)
/// Requeue waiters from one futex to another if the value at mutex matches /*
Requeue waiters from one futex to another if the value at mutex matches.
*/
FUTEX_CMP_REQUEUE :: Futex_Cmp_Requeue_Type(.CMP_REQUEUE) FUTEX_CMP_REQUEUE :: Futex_Cmp_Requeue_Type(.CMP_REQUEUE)
/// See man pages, I'm not describing it here /*
See man pages, I'm not describing it here.
*/
FUTEX_WAKE_OP :: Futex_Wake_Op_Type(.WAKE_OP) FUTEX_WAKE_OP :: Futex_Wake_Op_Type(.WAKE_OP)
/// Wait on a futex, but the value is a bitset /*
Wait on a futex, but the value is a bitset.
*/
FUTEX_WAIT_BITSET :: Futex_Wait_Bitset_Type(.WAIT_BITSET) FUTEX_WAIT_BITSET :: Futex_Wait_Bitset_Type(.WAIT_BITSET)
/// Wait on a futex, but the value is a bitset /*
Wait on a futex, but the value is a bitset.
*/
FUTEX_WAKE_BITSET :: Futex_Wake_Bitset_Type(.WAKE_BITSET) FUTEX_WAKE_BITSET :: Futex_Wake_Bitset_Type(.WAKE_BITSET)
// TODO(flysand): Priority inversion futexes // TODO(flysand): Priority inversion futexes
@@ -197,3 +255,82 @@ FUTEX_WAIT_REQUEUE_PI :: Futex_Wait_requeue_Pi_Type(.WAIT_REQUEUE_PI)
FUTEX_CMP_REQUEUE_PI :: Futex_Cmp_requeue_Pi_Type(.CMP_REQUEUE_PI) FUTEX_CMP_REQUEUE_PI :: Futex_Cmp_requeue_Pi_Type(.CMP_REQUEUE_PI)
FUTEX_LOCK_PI2 :: Futex_Lock_Pi2_Type(.LOCK_PI2) FUTEX_LOCK_PI2 :: Futex_Lock_Pi2_Type(.LOCK_PI2)
PTrace_Traceme_Type :: distinct PTrace_Request
PTrace_Peek_Type :: distinct PTrace_Request
PTrace_Poke_Type :: distinct PTrace_Request
PTrace_Cont_Type :: distinct PTrace_Request
PTrace_Kill_Type :: distinct PTrace_Request
PTrace_Singlestep_Type :: distinct PTrace_Request
PTrace_Getregs_Type :: distinct PTrace_Request
PTrace_Setregs_Type :: distinct PTrace_Request
PTrace_Getfpregs_Type :: distinct PTrace_Request
PTrace_Setfpregs_Type :: distinct PTrace_Request
PTrace_Attach_Type :: distinct PTrace_Request
PTrace_Detach_Type :: distinct PTrace_Request
PTrace_Getfpxregs_Type :: distinct PTrace_Request
PTrace_Setfpxregs_Type :: distinct PTrace_Request
PTrace_Syscall_Type :: distinct PTrace_Request
PTrace_Get_Thread_Area_Type :: distinct PTrace_Request
PTrace_Set_Thread_Area_Type :: distinct PTrace_Request
PTrace_Arch_Prctl_Type :: distinct PTrace_Request
PTrace_Sysemu_Type :: distinct PTrace_Request
PTrace_Sysemu_Singlestep_Type :: distinct PTrace_Request
PTrace_Singleblock_Type :: distinct PTrace_Request
PTrace_Setoptions_Type :: distinct PTrace_Request
PTrace_Geteventmsg_Type :: distinct PTrace_Request
PTrace_Getsiginfo_Type :: distinct PTrace_Request
PTrace_Setsiginfo_Type :: distinct PTrace_Request
PTrace_Getregset_Type :: distinct PTrace_Request
PTrace_Setregset_Type :: distinct PTrace_Request
PTrace_Seize_Type :: distinct PTrace_Request
PTrace_Interrupt_Type :: distinct PTrace_Request
PTrace_Listen_Type :: distinct PTrace_Request
PTrace_Peeksiginfo_Type :: distinct PTrace_Request
PTrace_Getsigmask_Type :: distinct PTrace_Request
PTrace_Setsigmask_Type :: distinct PTrace_Request
PTrace_Seccomp_Get_Filter_Type :: distinct PTrace_Request
PTrace_Seccomp_Get_Metadata_Type :: distinct PTrace_Request
PTrace_Get_Syscall_Info_Type :: distinct PTrace_Request
PTrace_Get_RSeq_Configuration_Type :: distinct PTrace_Request
PTRACE_TRACEME :: PTrace_Traceme_Type(.TRACEME)
PTRACE_PEEKTEXT :: PTrace_Peek_Type(.PEEKTEXT)
PTRACE_PEEKDATA :: PTrace_Peek_Type(.PEEKDATA)
PTRACE_PEEKUSER :: PTrace_Peek_Type(.PEEKUSER)
PTRACE_POKETEXT :: PTrace_Poke_Type(.POKETEXT)
PTRACE_POKEDATA :: PTrace_Poke_Type(.POKEDATA)
PTRACE_POKEUSER :: PTrace_Poke_Type(.POKEUSER)
PTRACE_CONT :: PTrace_Cont_Type(.CONT)
PTRACE_KILL :: PTrace_Kill_Type(.KILL)
PTRACE_SINGLESTEP :: PTrace_Singlestep_Type(.SINGLESTEP)
PTRACE_GETREGS :: PTrace_Getregs_Type(.GETREGS)
PTRACE_SETREGS :: PTrace_Setregs_Type(.SETREGS)
PTRACE_GETFPREGS :: PTrace_Getfpregs_Type(.GETFPREGS)
PTRACE_SETFPREGS :: PTrace_Setfpregs_Type(.SETFPREGS)
PTRACE_ATTACH :: PTrace_Attach_Type(.ATTACH)
PTRACE_DETACH :: PTrace_Detach_Type(.DETACH)
PTRACE_GETFPXREGS :: PTrace_Getfpxregs_Type(.GETFPXREGS)
PTRACE_SETFPXREGS :: PTrace_Setfpxregs_Type(.SETFPXREGS)
PTRACE_SYSCALL :: PTrace_Syscall_Type(.SYSCALL)
PTRACE_GET_THREAD_AREA :: PTrace_Get_Thread_Area_Type(.GET_THREAD_AREA)
PTRACE_SET_THREAD_AREA :: PTrace_Set_Thread_Area_Type(.SET_THREAD_AREA)
PTRACE_ARCH_PRCTL :: PTrace_Arch_Prctl_Type(.ARCH_PRCTL)
PTRACE_SYSEMU :: PTrace_Sysemu_Type(.SYSEMU)
PTRACE_SYSEMU_SINGLESTEP :: PTrace_Sysemu_Singlestep_Type(.SYSEMU_SINGLESTEP)
PTRACE_SINGLEBLOCK :: PTrace_Singleblock_Type(.SINGLEBLOCK)
PTRACE_SETOPTIONS :: PTrace_Setoptions_Type(.SETOPTIONS)
PTRACE_GETEVENTMSG :: PTrace_Geteventmsg_Type(.GETEVENTMSG)
PTRACE_GETSIGINFO :: PTrace_Getsiginfo_Type(.GETSIGINFO)
PTRACE_SETSIGINFO :: PTrace_Setsiginfo_Type(.SETSIGINFO)
PTRACE_GETREGSET :: PTrace_Getregset_Type(.GETREGSET)
PTRACE_SETREGSET :: PTrace_Setregset_Type(.SETREGSET)
PTRACE_SEIZE :: PTrace_Seize_Type(.SEIZE)
PTRACE_INTERRUPT :: PTrace_Interrupt_Type(.INTERRUPT)
PTRACE_LISTEN :: PTrace_Listen_Type(.LISTEN)
PTRACE_PEEKSIGINFO :: PTrace_Peeksiginfo_Type(.PEEKSIGINFO)
PTRACE_GETSIGMASK :: PTrace_Getsigmask_Type(.GETSIGMASK)
PTRACE_SETSIGMASK :: PTrace_Setsigmask_Type(.SETSIGMASK)
PTRACE_SECCOMP_GET_FILTER :: PTrace_Seccomp_Get_Filter_Type(.SECCOMP_GET_FILTER)
PTRACE_SECCOMP_GET_METADATA :: PTrace_Seccomp_Get_Metadata_Type(.SECCOMP_GET_METADATA)
PTRACE_GET_SYSCALL_INFO :: PTrace_Get_Syscall_Info_Type(.GET_SYSCALL_INFO)
PTRACE_GET_RSEQ_CONFIGURATION :: PTrace_Get_RSeq_Configuration_Type(.GET_RSEQ_CONFIGURATION)
+1353 -451
View File
File diff suppressed because it is too large Load Diff
+746 -73
View File
File diff suppressed because it is too large Load Diff