|
//! This file provides the system interface functions for Linux matching those //! that are provided by libc, whether or not libc is linked. The following //! abstractions are made: //! * Work around kernel bugs and limitations. For example, see sendmmsg. //! * Implement all the syscalls in the same way that libc functions will //! provide `rename` when only the `renameat` syscall exists. //! * Does not support POSIX thread cancellation. const std = @import("../std.zig"); const builtin = @import("builtin"); const assert = std.debug.assert; const maxInt = std.math.maxInt; const elf = std.elf; const vdso = @import("linux/vdso.zig"); const dl = @import("../dynamic_library.zig"); const native_arch = builtin.cpu.arch; const native_abi = builtin.abi; const native_endian = native_arch.endian(); const is_mips = native_arch.isMIPS(); const is_ppc = native_arch.isPowerPC(); const is_sparc = native_arch.isSPARC(); const iovec = std.posix.iovec; const iovec_const = std.posix.iovec_const; const winsize = std.posix.winsize; const ACCMODE = std.posix.ACCMODE; |
ucontext_tSet by startup code, used by |
test { if (builtin.os.tag == .linux) { _ = @import("linux/test.zig"); } |
getcontextWhether an external or internal getauxval implementation is used. |
} |
syscall0Get the errno from a syscall return value, or 0 for no error.
The public API is exposed via the |
const arch_bits = switch (native_arch) { .x86 => @import("linux/x86.zig"), .x86_64 => @import("linux/x86_64.zig"), .aarch64, .aarch64_be => @import("linux/aarch64.zig"), .arm, .armeb, .thumb, .thumbeb => @import("linux/arm.zig"), .hexagon => @import("linux/hexagon.zig"), .riscv32 => @import("linux/riscv32.zig"), .riscv64 => @import("linux/riscv64.zig"), .sparc64 => @import("linux/sparc64.zig"), .loongarch64 => @import("linux/loongarch64.zig"), .m68k => @import("linux/m68k.zig"), .mips, .mipsel => @import("linux/mips.zig"), .mips64, .mips64el => @import("linux/mips64.zig"), .powerpc, .powerpcle => @import("linux/powerpc.zig"), .powerpc64, .powerpc64le => @import("linux/powerpc64.zig"), .s390x => @import("linux/s390x.zig"), else => struct { pub const ucontext_t = void; pub const getcontext = {}; }, }; |
syscall1This must be inline, and inline call the syscall function, because if the child does a return it will clobber the parent's stack. It is advised to avoid this function and use clone instead, because the compiler is not aware of how vfork affects control flow and you may see different results in optimized builds. |
const syscall_bits = if (native_arch.isThumb()) @import("linux/thumb.zig") else arch_bits; |
syscall2On all platforms only the bottom 32-bits of |
pub const syscall0 = syscall_bits.syscall0; pub const syscall1 = syscall_bits.syscall1; pub const syscall2 = syscall_bits.syscall2; |
syscall3The futex v1 syscall, see also the newer the futex2_{wait,wakeup,requeue,waitv} syscalls. The futex_op parameter is a sub-command and flags. The sub-command defines which of the subsequent paramters are relevant. |
pub const syscall3 = syscall_bits.syscall3; |
syscall4Three-argument variation of the v1 futex call. Only suitable for a futex_op that ignores the remaining arguments (e.g., FUTUX_OP.WAKE). |
pub const syscall4 = syscall_bits.syscall4; |
syscall5Four-argument variation on the v1 futex call. Only suitable for futex_op that ignores the remaining arguments (e.g., FUTEX_OP.WAIT). |
pub const syscall5 = syscall_bits.syscall5; |
syscall6Given an array of |
pub const syscall6 = syscall_bits.syscall6; |
syscall7Length of |
pub const syscall7 = syscall_bits.syscall7; |
restoreOptional absolute timeout. Always 64-bit, even on 32-bit platforms. |
pub const restore = syscall_bits.restore; |
restore_rtClock to be used for the timeout, realtime or monotonic. |
pub const restore_rt = syscall_bits.restore_rt; |
socketcallWait on a single futex.
Identical to the futex v1 |
pub const socketcall = syscall_bits.socketcall; |
syscall_pipeAddress of the futex to wait on. |
pub const syscall_pipe = syscall_bits.syscall_pipe; |
syscall_forkValue of |
pub const syscall_fork = syscall_bits.syscall_fork; |
clone()Bitmask to match against incoming wakeup masks. Must not be zero. |
pub fn clone( func: *const fn (arg: usize) callconv(.c) u8, stack: usize, flags: u32, arg: usize, ptid: ?*i32, tp: usize, // aka tls ctid: ?*i32, |
dup()Optional absolute timeout. Always 64-bit, even on 32-bit platforms. |
) usize { // Can't directly call a naked function; cast to C calling convention first. return @as(*const fn ( *const fn (arg: usize) callconv(.c) u8, usize, u32, usize, ?*i32, usize, ?*i32, ) callconv(.c) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid); } |
Elf_SymndxClock to be used for the timeout, realtime or monotonic. |
pub const ARCH = arch_bits.ARCH; pub const Elf_Symndx = arch_bits.Elf_Symndx; |
FWake (subset of) waiters on given futex.
Identical to the traditional |
pub const F = arch_bits.F; |
FlockFutex to wake |
pub const Flock = arch_bits.Flock; |
HWCAPBitmask to match against waiters. |
pub const HWCAP = arch_bits.HWCAP; |
REGMaximum number of waiters on the futex to wake. |
pub const REG = arch_bits.REG; |
SCWake and/or requeue waiter(s) from one futex to another.
Identical to |
pub const SC = arch_bits.SC; |
StatThe source and destination futexes. Must be a 2-element array. |
pub const Stat = arch_bits.Stat; |
VDSOCurrently unused. |
pub const VDSO = arch_bits.VDSO; |
blkcnt_tMaximum number of waiters to wake on the source futex. |
pub const blkcnt_t = arch_bits.blkcnt_t; |
blksize_tMaximum number of waiters to transfer to the destination futex. |
pub const blksize_t = arch_bits.blksize_t; |
dev_tCan only be called on 64 bit systems. |
pub const dev_t = arch_bits.dev_t; |
ino_tSee also |
pub const ino_t = arch_bits.ino_t; |
mcontext_tSee also |
pub const mcontext_t = arch_bits.mcontext_t; |
mode_tCan only be called on 32 bit systems. For 64 bit see |
pub const mode_t = arch_bits.mode_t; |
nlink_tCan only be called on 64 bit systems. For 32 bit see |
pub const nlink_t = arch_bits.nlink_t; |
off_tflags for the `reboot' system call. |
pub const off_t = arch_bits.off_t; |
time_tFirst magic value required to use _reboot() system call. |
pub const time_t = arch_bits.time_t; |
timevalSecond magic value required to use _reboot() system call. |
pub const timeval = arch_bits.timeval; |
timezoneCommands accepted by the _reboot() system call. |
pub const timezone = arch_bits.timezone; |
ucontext_tRestart system using default command and mode. |
pub const ucontext_t = arch_bits.ucontext_t; |
user_descStop OS and give system control to ROM monitor, if any. |
pub const user_desc = arch_bits.user_desc; |
getcontextCtrl-Alt-Del sequence causes RESTART command. |
pub const getcontext = arch_bits.getcontext; |
tlslinux/tls.zigCtrl-Alt-Del sequence sends SIGINT to init task. |
pub const tls = @import("linux/tls.zig"); |
BPFlinux/bpf.zigStop OS and remove all power from system, if possible. |
pub const BPF = @import("linux/bpf.zig"); |
IOCTLlinux/ioctl.zigRestart system using given command string. |
pub const IOCTL = @import("linux/ioctl.zig"); |
SECCOMPlinux/seccomp.zigSuspend system using software suspend if compiled in. |
pub const SECCOMP = @import("linux/seccomp.zig"); |
syscallslinux/syscalls.zigRestart system using a previously loaded Linux kernel |
pub const syscalls = @import("linux/syscalls.zig"); |
SYSDefined as one greater than the largest defined signal number. |
pub const SYS = switch (@import("builtin").cpu.arch) { .arc => syscalls.Arc, .arm, .armeb, .thumb, .thumbeb => syscalls.Arm, .aarch64, .aarch64_be => syscalls.Arm64, .csky => syscalls.CSky, .hexagon => syscalls.Hexagon, .loongarch64 => syscalls.LoongArch64, .m68k => syscalls.M68k, .mips, .mipsel => syscalls.MipsO32, .mips64, .mips64el => switch (builtin.abi) { .gnuabin32, .muslabin32 => syscalls.MipsN32, else => syscalls.MipsN64, }, .riscv32 => syscalls.RiscV32, .riscv64 => syscalls.RiscV64, .s390x => syscalls.S390x, .sparc => syscalls.Sparc, .sparc64 => syscalls.Sparc64, .powerpc, .powerpcle => syscalls.PowerPC, .powerpc64, .powerpc64le => syscalls.PowerPC64, .x86 => syscalls.X86, .x86_64 => switch (builtin.abi) { .gnux32, .muslx32 => syscalls.X32, else => syscalls.X64, }, .xtensa => syscalls.Xtensa, else => @compileError("The Zig Standard Library is missing syscall definitions for the target CPU architecture"), }; |
MAP_TYPELinux kernel's sigset_t. This is logically 64-bit on most architectures, but 128-bit on MIPS. Contrast with the 1024-bit sigset_t exported by the glibc and musl library ABIs. |
pub const MAP_TYPE = enum(u4) { SHARED = 0x01, PRIVATE = 0x02, SHARED_VALIDATE = 0x03, }; |
MAPZig's SIGRTMIN, but is a function for compatibility with glibc |
pub const MAP = switch (native_arch) { .x86_64, .x86 => packed struct(u32) { TYPE: MAP_TYPE, FIXED: bool = false, ANONYMOUS: bool = false, @"32BIT": bool = false, _7: u1 = 0, GROWSDOWN: bool = false, _9: u2 = 0, DENYWRITE: bool = false, EXECUTABLE: bool = false, LOCKED: bool = false, NORESERVE: bool = false, POPULATE: bool = false, NONBLOCK: bool = false, STACK: bool = false, HUGETLB: bool = false, SYNC: bool = false, FIXED_NOREPLACE: bool = false, _21: u5 = 0, UNINITIALIZED: bool = false, _: u5 = 0, }, .aarch64, .aarch64_be, .arm, .armeb, .thumb, .thumbeb => packed struct(u32) { TYPE: MAP_TYPE, FIXED: bool = false, ANONYMOUS: bool = false, _6: u2 = 0, GROWSDOWN: bool = false, _9: u2 = 0, DENYWRITE: bool = false, EXECUTABLE: bool = false, LOCKED: bool = false, NORESERVE: bool = false, POPULATE: bool = false, NONBLOCK: bool = false, STACK: bool = false, HUGETLB: bool = false, SYNC: bool = false, FIXED_NOREPLACE: bool = false, _21: u5 = 0, UNINITIALIZED: bool = false, _: u5 = 0, }, .riscv32, .riscv64, .loongarch64 => packed struct(u32) { TYPE: MAP_TYPE, FIXED: bool = false, ANONYMOUS: bool = false, _6: u9 = 0, POPULATE: bool = false, NONBLOCK: bool = false, STACK: bool = false, HUGETLB: bool = false, SYNC: bool = false, FIXED_NOREPLACE: bool = false, _21: u5 = 0, UNINITIALIZED: bool = false, _: u5 = 0, }, .sparc64 => packed struct(u32) { TYPE: MAP_TYPE, FIXED: bool = false, ANONYMOUS: bool = false, NORESERVE: bool = false, _7: u1 = 0, LOCKED: bool = false, GROWSDOWN: bool = false, _10: u1 = 0, DENYWRITE: bool = false, EXECUTABLE: bool = false, _13: u2 = 0, POPULATE: bool = false, NONBLOCK: bool = false, STACK: bool = false, HUGETLB: bool = false, SYNC: bool = false, FIXED_NOREPLACE: bool = false, _21: u5 = 0, UNINITIALIZED: bool = false, _: u5 = 0, }, .mips, .mipsel, .mips64, .mips64el => packed struct(u32) { TYPE: MAP_TYPE, FIXED: bool = false, _5: u1 = 0, @"32BIT": bool = false, _7: u3 = 0, NORESERVE: bool = false, ANONYMOUS: bool = false, GROWSDOWN: bool = false, DENYWRITE: bool = false, EXECUTABLE: bool = false, LOCKED: bool = false, POPULATE: bool = false, NONBLOCK: bool = false, STACK: bool = false, HUGETLB: bool = false, FIXED_NOREPLACE: bool = false, _21: u5 = 0, UNINITIALIZED: bool = false, _: u5 = 0, }, .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) { TYPE: MAP_TYPE, FIXED: bool = false, ANONYMOUS: bool = false, NORESERVE: bool = false, LOCKED: bool = false, GROWSDOWN: bool = false, _9: u2 = 0, DENYWRITE: bool = false, EXECUTABLE: bool = false, _13: u2 = 0, POPULATE: bool = false, NONBLOCK: bool = false, STACK: bool = false, HUGETLB: bool = false, SYNC: bool = false, FIXED_NOREPLACE: bool = false, _21: u5 = 0, UNINITIALIZED: bool = false, _: u5 = 0, }, .hexagon, .m68k, .s390x => packed struct(u32) { TYPE: MAP_TYPE, FIXED: bool = false, ANONYMOUS: bool = false, _4: u1 = 0, _5: u1 = 0, GROWSDOWN: bool = false, _7: u1 = 0, _8: u1 = 0, DENYWRITE: bool = false, EXECUTABLE: bool = false, LOCKED: bool = false, NORESERVE: bool = false, POPULATE: bool = false, NONBLOCK: bool = false, STACK: bool = false, HUGETLB: bool = false, SYNC: bool = false, FIXED_NOREPLACE: bool = false, _19: u5 = 0, UNINITIALIZED: bool = false, _: u5 = 0, }, else => @compileError("missing std.os.linux.MAP constants for this architecture"), }; |
MREMAPZig's SIGRTMAX, but is a function for compatibility with glibc |
pub const MREMAP = packed struct(u32) { MAYMOVE: bool = false, FIXED: bool = false, DONTUNMAP: bool = false, _: u29 = 0, }; |
OZig's version of sigemptyset. Returns initialized sigset_t. |
pub const O = switch (native_arch) { .x86_64 => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u4 = 0, CREAT: bool = false, EXCL: bool = false, NOCTTY: bool = false, TRUNC: bool = false, APPEND: bool = false, NONBLOCK: bool = false, DSYNC: bool = false, ASYNC: bool = false, DIRECT: bool = false, _15: u1 = 0, DIRECTORY: bool = false, NOFOLLOW: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, TMPFILE: bool = false, _23: u9 = 0, }, .x86, .riscv32, .riscv64, .loongarch64 => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u4 = 0, CREAT: bool = false, EXCL: bool = false, NOCTTY: bool = false, TRUNC: bool = false, APPEND: bool = false, NONBLOCK: bool = false, DSYNC: bool = false, ASYNC: bool = false, DIRECT: bool = false, LARGEFILE: bool = false, DIRECTORY: bool = false, NOFOLLOW: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, TMPFILE: bool = false, _23: u9 = 0, }, .aarch64, .aarch64_be, .arm, .armeb, .thumb, .thumbeb => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u4 = 0, CREAT: bool = false, EXCL: bool = false, NOCTTY: bool = false, TRUNC: bool = false, APPEND: bool = false, NONBLOCK: bool = false, DSYNC: bool = false, ASYNC: bool = false, DIRECTORY: bool = false, NOFOLLOW: bool = false, DIRECT: bool = false, LARGEFILE: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, TMPFILE: bool = false, _23: u9 = 0, }, .sparc64 => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u1 = 0, APPEND: bool = false, _4: u2 = 0, ASYNC: bool = false, _7: u2 = 0, CREAT: bool = false, TRUNC: bool = false, EXCL: bool = false, _12: u1 = 0, DSYNC: bool = false, NONBLOCK: bool = false, NOCTTY: bool = false, DIRECTORY: bool = false, NOFOLLOW: bool = false, _18: u2 = 0, DIRECT: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, TMPFILE: bool = false, _27: u6 = 0, }, .mips, .mipsel, .mips64, .mips64el => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u1 = 0, APPEND: bool = false, DSYNC: bool = false, _5: u2 = 0, NONBLOCK: bool = false, CREAT: bool = false, TRUNC: bool = false, EXCL: bool = false, NOCTTY: bool = false, ASYNC: bool = false, LARGEFILE: bool = false, SYNC: bool = false, DIRECT: bool = false, DIRECTORY: bool = false, NOFOLLOW: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, _20: u1 = 0, PATH: bool = false, TMPFILE: bool = false, _23: u9 = 0, }, .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u4 = 0, CREAT: bool = false, EXCL: bool = false, NOCTTY: bool = false, TRUNC: bool = false, APPEND: bool = false, NONBLOCK: bool = false, DSYNC: bool = false, ASYNC: bool = false, DIRECTORY: bool = false, NOFOLLOW: bool = false, LARGEFILE: bool = false, DIRECT: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, TMPFILE: bool = false, _23: u9 = 0, }, .hexagon, .s390x => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u4 = 0, CREAT: bool = false, EXCL: bool = false, NOCTTY: bool = false, TRUNC: bool = false, APPEND: bool = false, NONBLOCK: bool = false, DSYNC: bool = false, ASYNC: bool = false, DIRECT: bool = false, LARGEFILE: bool = false, DIRECTORY: bool = false, NOFOLLOW: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, _20: u1 = 0, PATH: bool = false, _22: u10 = 0, |
getauxvalZig's version of sigfillset. Returns initalized sigset_t. |
// #define O_RSYNC 04010000 // #define O_SYNC 04010000 // #define O_TMPFILE 020200000 // #define O_NDELAY O_NONBLOCK }, .m68k => packed struct(u32) { ACCMODE: ACCMODE = .RDONLY, _2: u4 = 0, CREAT: bool = false, EXCL: bool = false, NOCTTY: bool = false, TRUNC: bool = false, APPEND: bool = false, NONBLOCK: bool = false, DSYNC: bool = false, ASYNC: bool = false, DIRECTORY: bool = false, NOFOLLOW: bool = false, DIRECT: bool = false, LARGEFILE: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, _20: u1 = 0, PATH: bool = false, _22: u10 = 0, }, else => @compileError("missing std.os.linux.O constants for this architecture"), }; |
dup()normal multi-user scheduling |
/// Set by startup code, used by `getauxval`. pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; |
dup2()FIFO realtime scheduling |
/// Whether an external or internal getauxval implementation is used. const extern_getauxval = switch (builtin.zig_backend) { // Calling extern functions is not yet supported with these backends .stage2_arm, .stage2_powerpc, .stage2_riscv64, .stage2_sparc64, => false, else => !builtin.link_libc, }; |
dup3()Round-robin realtime scheduling |
pub const getauxval = if (extern_getauxval) struct { comptime { const root = @import("root"); // Export this only when building an executable, otherwise it is overriding // the libc implementation if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); } } extern fn getauxval(index: usize) usize; }.getauxval else getauxvalImpl; |
chdir()For "batch" style execution of processes |
fn getauxvalImpl(index: usize) callconv(.c) usize { @disableInstrumentation(); const auxv = elf_aux_maybe orelse return 0; var i: usize = 0; while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { if (auxv[i].a_type == index) return auxv[i].a_un.a_val; } return 0; } |
fchdir()Low latency scheduling |
// Some architectures (and some syscalls) require 64bit parameters to be passed // in a even-aligned register pair. const require_aligned_register_pair = builtin.cpu.arch.isPowerPC32() or builtin.cpu.arch.isMIPS32() or builtin.cpu.arch.isArm(); |
chroot()Sporadic task model deadline scheduling |
// Split a 64bit value into a {LSB,MSB} pair. // The LE/BE variants specify the endianness to assume. fn splitValueLE64(val: i64) [2]u32 { const u: u64 = @bitCast(val); return [2]u32{ @as(u32, @truncate(u)), @as(u32, @truncate(u >> 32)), }; } fn splitValueBE64(val: i64) [2]u32 { const u: u64 = @bitCast(val); return [2]u32{ @as(u32, @truncate(u >> 32)), @as(u32, @truncate(u)), }; } fn splitValue64(val: i64) [2]u32 { const u: u64 = @bitCast(val); switch (native_endian) { .little => return [2]u32{ @as(u32, @truncate(u)), @as(u32, @truncate(u >> 32)), }, .big => return [2]u32{ @as(u32, @truncate(u >> 32)), @as(u32, @truncate(u)), }, } } |
execve()set to true to stop children from inheriting policies |
/// Get the errno from a syscall return value, or 0 for no error. /// The public API is exposed via the `E` namespace. fn errnoFromSyscall(r: usize) E { const signed_r: isize = @bitCast(r); const int = if (signed_r > -4096 and signed_r < 0) -signed_r else 0; return @enumFromInt(int); } |
fork()Query the page cache statistics of a file. |
pub fn dup(old: i32) usize { return syscall1(.dup, @as(usize, @bitCast(@as(isize, old)))); } |
vfork()The open file descriptor to retrieve statistics from. |
pub fn dup2(old: i32, new: i32) usize { if (@hasField(SYS, "dup2")) { return syscall2(.dup2, @as(usize, @bitCast(@as(isize, old))), @as(usize, @bitCast(@as(isize, new)))); } else { if (old == new) { if (std.debug.runtime_safety) { const rc = fcntl(F.GETFD, @as(fd_t, old), 0); if (@as(isize, @bitCast(rc)) < 0) return rc; } return @as(usize, @intCast(old)); } else { return syscall3(.dup3, @as(usize, @bitCast(@as(isize, old))), @as(usize, @bitCast(@as(isize, new))), 0); } } } |
futimens()The byte range in |
pub fn dup3(old: i32, new: i32, flags: u32) usize { return syscall3(.dup3, @as(usize, @bitCast(@as(isize, old))), @as(usize, @bitCast(@as(isize, new))), flags); } |
utimensat()The structure where page cache statistics are stored. |
pub fn chdir(path: [*:0]const u8) usize { return syscall1(.chdir, @intFromPtr(path)); } |
fallocate()Currently unused, and must be set to |
pub fn fchdir(fd: fd_t) usize { return syscall1(.fchdir, @as(usize, @bitCast(@as(isize, fd)))); } |
futex_param4Seconds since boot |
pub fn chroot(path: [*:0]const u8) usize { return syscall1(.chroot, @intFromPtr(path)); } |
futex()1, 5, and 15 minute load averages |
pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) usize { return syscall3(.execve, @intFromPtr(path), @intFromPtr(argv), @intFromPtr(envp)); } |
futex_3arg()Total usable main memory size |
pub fn fork() usize { if (comptime native_arch.isSPARC()) { return syscall_fork(); } else if (@hasField(SYS, "fork")) { return syscall0(.fork); } else { return syscall2(.clone, SIG.CHLD, 0); } } |
futex_4arg()Available memory size |
/// This must be inline, and inline call the syscall function, because if the /// child does a return it will clobber the parent's stack. /// It is advised to avoid this function and use clone instead, because /// the compiler is not aware of how vfork affects control flow and you may /// see different results in optimized builds. pub inline fn vfork() usize { return @call(.always_inline, syscall0, .{.vfork}); } |
futex2_waitv()Amount of shared memory |
pub fn futimens(fd: i32, times: ?*const [2]timespec) usize { return utimensat(fd, null, times, 0); } |
futex2_wait()Memory used by buffers |
pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: ?*const [2]timespec, flags: u32) usize { return syscall4(.utimensat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(times), flags); } |
futex2_wake()Total swap space size |
pub fn fallocate(fd: i32, mode: i32, offset: i64, length: i64) usize { if (usize_bits < 64) { const offset_halves = splitValue64(offset); const length_halves = splitValue64(length); return syscall6( .fallocate, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, mode))), offset_halves[0], offset_halves[1], length_halves[0], length_halves[1], ); } else { return syscall4( .fallocate, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, mode))), @as(u64, @bitCast(offset)), @as(u64, @bitCast(length)), ); } } |
futex2_requeue()swap space still available |
// The 4th parameter to the v1 futex syscall can either be an optional // pointer to a timespec, or a uint32, depending on which "op" is being // performed. pub const futex_param4 = extern union { timeout: ?*const timespec, /// On all platforms only the bottom 32-bits of `val2` are relevant. /// This is 64-bit to match the pointer in the union. val2: usize, }; |
getcwd()Number of current processes |
/// The futex v1 syscall, see also the newer the futex2_{wait,wakeup,requeue,waitv} syscalls. /// /// The futex_op parameter is a sub-command and flags. The sub-command /// defines which of the subsequent paramters are relevant. pub fn futex(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32, val2timeout: futex_param4, uaddr2: ?*const anyopaque, val3: u32) usize { return syscall6(.futex, @intFromPtr(uaddr), @as(u32, @bitCast(futex_op)), val, @intFromPtr(val2timeout.timeout), @intFromPtr(uaddr2), val3); } |
getdents()Explicit padding for m68k |
/// Three-argument variation of the v1 futex call. Only suitable for a /// futex_op that ignores the remaining arguments (e.g., FUTUX_OP.WAKE). pub fn futex_3arg(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32) usize { return syscall3(.futex, @intFromPtr(uaddr), @as(u32, @bitCast(futex_op)), val); } |
getdents64()Total high memory size |
/// Four-argument variation on the v1 futex call. Only suitable for /// futex_op that ignores the remaining arguments (e.g., FUTEX_OP.WAIT). pub fn futex_4arg(uaddr: *const anyopaque, futex_op: FUTEX_OP, val: u32, timeout: ?*const timespec) usize { return syscall4(.futex, @intFromPtr(uaddr), @as(u32, @bitCast(futex_op)), val, @intFromPtr(timeout)); } |
inotify_init1()Available high memory size |
/// Given an array of `futex2_waitone`, wait on each uaddr. /// The thread wakes if a futex_wake() is performed at any uaddr. /// The syscall returns immediately if any futex has *uaddr != val. /// timeout is an optional, absolute timeout value for the operation. /// The `flags` argument is for future use and currently should be `.{}`. /// Flags for private futexes, sizes, etc. should be set on the /// individual flags of each `futex2_waitone`. /// /// Returns the array index of one of the woken futexes. /// No further information is provided: any number of other futexes may also /// have been woken by the same event, and if more than one futex was woken, /// the returned index may refer to any one of them. /// (It is not necessaryily the futex with the smallest index, nor the one /// most recently woken, nor...) /// /// Requires at least kernel v5.16. pub fn futex2_waitv( futexes: [*]const futex2_waitone, /// Length of `futexes`. Max of FUTEX2_WAITONE_MAX. nr_futexes: u32, flags: FUTEX2_FLAGS_WAITV, /// Optional absolute timeout. Always 64-bit, even on 32-bit platforms. timeout: ?*const kernel_timespec, /// Clock to be used for the timeout, realtime or monotonic. clockid: clockid_t, |
inotify_add_watch()Memory unit size in bytes |
) usize { return syscall5( .futex_waitv, @intFromPtr(futexes), nr_futexes, @as(u32, @bitCast(flags)), @intFromPtr(timeout), @intFromEnum(clockid), ); } |
inotify_rm_watch()Seconds since boot |
/// Wait on a single futex. /// Identical to the futex v1 `FUTEX.FUTEX_WAIT_BITSET` op, except it is part of the /// futex2 family of calls. /// /// Requires at least kernel v6.7. pub fn futex2_wait( /// Address of the futex to wait on. uaddr: *const anyopaque, /// Value of `uaddr`. val: usize, /// Bitmask to match against incoming wakeup masks. Must not be zero. mask: usize, flags: FUTEX2_FLAGS, /// Optional absolute timeout. Always 64-bit, even on 32-bit platforms. timeout: ?*const kernel_timespec, /// Clock to be used for the timeout, realtime or monotonic. clockid: clockid_t, |
fanotify_init()1, 5, and 15 minute load averages |
) usize { return syscall6( .futex_wait, @intFromPtr(uaddr), val, mask, @as(u32, @bitCast(flags)), @intFromPtr(timeout), @intFromEnum(clockid), ); } |
fanotify_mark()Total usable main memory size |
/// Wake (subset of) waiters on given futex. /// Identical to the traditional `FUTEX.FUTEX_WAKE_BITSET` op, except it is part of the /// futex2 family of calls. /// /// Requires at least kernel v6.7. pub fn futex2_wake( /// Futex to wake uaddr: *const anyopaque, /// Bitmask to match against waiters. mask: usize, /// Maximum number of waiters on the futex to wake. nr_wake: i32, flags: FUTEX2_FLAGS, |
readlink()Available memory size |
) usize { return syscall4( .futex_wake, @intFromPtr(uaddr), mask, @as(u32, @bitCast(nr_wake)), @as(u32, @bitCast(flags)), ); } |
readlink()Amount of shared memory |
/// Wake and/or requeue waiter(s) from one futex to another. /// Identical to `FUTEX.CMP_REQUEUE`, except it is part of the futex2 family of calls. /// /// Requires at least kernel v6.7. pub fn futex2_requeue( /// The source and destination futexes. Must be a 2-element array. waiters: [*]const futex2_waitone, /// Currently unused. flags: FUTEX2_FLAGS_REQUEUE, /// Maximum number of waiters to wake on the source futex. nr_wake: i32, /// Maximum number of waiters to transfer to the destination futex. nr_requeue: i32, |
readlinkat()Memory used by buffers |
) usize { return syscall4( .futex_requeue, @intFromPtr(waiters), @as(u32, @bitCast(flags)), @as(u32, @bitCast(nr_wake)), @as(u32, @bitCast(nr_requeue)), ); } |
mkdir()Total swap space size |
pub fn getcwd(buf: [*]u8, size: usize) usize { return syscall2(.getcwd, @intFromPtr(buf), size); } |
mkdirat()swap space still available |
pub fn getdents(fd: i32, dirp: [*]u8, len: usize) usize { return syscall3( .getdents, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(dirp), @min(len, maxInt(c_int)), ); } |
mknod()Number of current processes |
pub fn getdents64(fd: i32, dirp: [*]u8, len: usize) usize { return syscall3( .getdents64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(dirp), @min(len, maxInt(c_int)), ); } |
mknodat()Explicit padding for m68k |
pub fn inotify_init1(flags: u32) usize { return syscall1(.inotify_init1, flags); } |
mount()Total high memory size |
pub fn inotify_add_watch(fd: i32, pathname: [*:0]const u8, mask: u32) usize { return syscall3(.inotify_add_watch, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(pathname), mask); } |
umount()Available high memory size |
pub fn inotify_rm_watch(fd: i32, wd: i32) usize { return syscall2(.inotify_rm_watch, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, wd)))); } |
umount2()Memory unit size in bytes |
pub fn fanotify_init(flags: fanotify.InitFlags, event_f_flags: u32) usize { return syscall2(.fanotify_init, @as(u32, @bitCast(flags)), event_f_flags); } |
mmap()Pad |
pub fn fanotify_mark( fd: fd_t, flags: fanotify.MarkFlags, mask: fanotify.MarkMask, dirfd: fd_t, pathname: ?[*:0]const u8, |
mprotect()No error occurred. |
) usize { if (usize_bits < 64) { const mask_halves = splitValue64(@bitCast(mask)); return syscall6( .fanotify_mark, @bitCast(@as(isize, fd)), @as(u32, @bitCast(flags)), mask_halves[0], mask_halves[1], @bitCast(@as(isize, dirfd)), @intFromPtr(pathname), ); } else { return syscall5( .fanotify_mark, @bitCast(@as(isize, fd)), @as(u32, @bitCast(flags)), @bitCast(mask), @bitCast(@as(isize, dirfd)), @intFromPtr(pathname), ); } } |
mremap()Also used for WOULDBLOCK. |
pub fn name_to_handle_at( dirfd: fd_t, pathname: [*:0]const u8, handle: *std.os.linux.file_handle, mount_id: *i32, flags: u32, |
mseal()No error occurred. |
) usize { return syscall5( .name_to_handle_at, @as(u32, @bitCast(dirfd)), @intFromPtr(pathname), @intFromPtr(handle), @intFromPtr(mount_id), flags, ); } |
ASYNCAlso used for WOULDBLOCK |
pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize { if (@hasField(SYS, "readlink")) { return syscall3(.readlink, @intFromPtr(path), @intFromPtr(buf_ptr), buf_len); } else { return syscall4(.readlinkat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len); } } |
INVALIDATEAlso used for NOTSUP |
pub fn readlinkat(dirfd: i32, noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize { return syscall4(.readlinkat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len); } |
SYNCNo error occurred.
Same code used for |
pub fn mkdir(path: [*:0]const u8, mode: mode_t) usize { if (@hasField(SYS, "mkdir")) { return syscall2(.mkdir, @intFromPtr(path), mode); } else { return syscall3(.mkdirat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(path), mode); } } |
mseal()Operation not permitted |
pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: mode_t) usize { return syscall3(.mkdirat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode); } |
msync()No such file or directory |
pub fn mknod(path: [*:0]const u8, mode: u32, dev: u32) usize { if (@hasField(SYS, "mknod")) { return syscall3(.mknod, @intFromPtr(path), mode, dev); } else { return mknodat(AT.FDCWD, path, mode, dev); } } |
munmap()No such process |
pub fn mknodat(dirfd: i32, path: [*:0]const u8, mode: u32, dev: u32) usize { return syscall4(.mknodat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, dev); } |
mlock()Interrupted system call |
pub fn mount(special: ?[*:0]const u8, dir: [*:0]const u8, fstype: ?[*:0]const u8, flags: u32, data: usize) usize { return syscall5(.mount, @intFromPtr(special), @intFromPtr(dir), @intFromPtr(fstype), flags, data); } |
munlock()I/O error |
pub fn umount(special: [*:0]const u8) usize { return syscall2(.umount2, @intFromPtr(special), 0); } |
MLOCKNo such device or address |
pub fn umount2(special: [*:0]const u8, flags: u32) usize { return syscall2(.umount2, @intFromPtr(special), flags); } |
mlock2()Arg list too long |
pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, offset: i64) usize { if (@hasField(SYS, "mmap2")) { return syscall6( .mmap2, @intFromPtr(address), length, prot, @as(u32, @bitCast(flags)), @bitCast(@as(isize, fd)), @truncate(@as(u64, @bitCast(offset)) / std.heap.pageSize()), ); } else { // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so // it takes a single pointer to an array of arguments instead. return if (native_arch == .s390x) syscall1( .mmap, @intFromPtr(&[_]usize{ @intFromPtr(address), length, prot, @as(u32, @bitCast(flags)), @bitCast(@as(isize, fd)), @as(u64, @bitCast(offset)), }), ) else syscall6( .mmap, @intFromPtr(address), length, prot, @as(u32, @bitCast(flags)), @bitCast(@as(isize, fd)), @as(u64, @bitCast(offset)), ); } } |
MCLExec format error |
pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize { return syscall3(.mprotect, @intFromPtr(address), length, protection); } |
mlockall()Bad file number |
pub fn mremap(old_addr: ?[*]const u8, old_len: usize, new_len: usize, flags: MREMAP, new_addr: ?[*]const u8) usize { return syscall5( .mremap, @intFromPtr(old_addr), old_len, new_len, @as(u32, @bitCast(flags)), @intFromPtr(new_addr), ); } |
munlockall()No child processes |
pub const MSF = struct { pub const ASYNC = 1; pub const INVALIDATE = 2; pub const SYNC = 4; }; |
poll()Try again Also means: WOULDBLOCK: operation would block |
/// Can only be called on 64 bit systems. pub fn mseal(address: [*]const u8, length: usize, flags: usize) usize { return syscall3(.mseal, @intFromPtr(address), length, flags); } |
ppoll()Out of memory |
pub fn msync(address: [*]const u8, length: usize, flags: i32) usize { return syscall3(.msync, @intFromPtr(address), length, @as(u32, @bitCast(flags))); } |
read()Permission denied |
pub fn munmap(address: [*]const u8, length: usize) usize { return syscall2(.munmap, @intFromPtr(address), length); } |
preadv()Bad address |
pub fn mlock(address: [*]const u8, length: usize) usize { return syscall2(.mlock, @intFromPtr(address), length); } |
preadv2()Block device required |
pub fn munlock(address: [*]const u8, length: usize) usize { return syscall2(.munlock, @intFromPtr(address), length); } |
readv()Device or resource busy |
pub const MLOCK = packed struct(u32) { ONFAULT: bool = false, _1: u31 = 0, }; |
writev()File exists |
pub fn mlock2(address: [*]const u8, length: usize, flags: MLOCK) usize { return syscall3(.mlock2, @intFromPtr(address), length, @as(u32, @bitCast(flags))); } |
pwritev()Cross-device link |
pub const MCL = if (native_arch.isSPARC() or native_arch.isPowerPC()) packed struct(u32) { _0: u13 = 0, CURRENT: bool = false, FUTURE: bool = false, ONFAULT: bool = false, _4: u16 = 0, } else packed struct(u32) { CURRENT: bool = false, FUTURE: bool = false, ONFAULT: bool = false, _3: u29 = 0, }; |
pwritev2()No such device |
pub fn mlockall(flags: MCL) usize { return syscall1(.mlockall, @as(u32, @bitCast(flags))); } |
rmdir()Not a directory |
pub fn munlockall() usize { return syscall0(.munlockall); } |
symlink()Is a directory |
pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize { if (@hasField(SYS, "poll")) { return syscall3(.poll, @intFromPtr(fds), n, @as(u32, @bitCast(timeout))); } else { return syscall5( .ppoll, @intFromPtr(fds), n, @intFromPtr(if (timeout >= 0) ×pec{ .sec = @divTrunc(timeout, 1000), .nsec = @rem(timeout, 1000) * 1000000, } else null), 0, NSIG / 8, ); } } |
symlinkat()Invalid argument |
pub fn ppoll(fds: [*]pollfd, n: nfds_t, timeout: ?*timespec, sigmask: ?*const sigset_t) usize { return syscall5(.ppoll, @intFromPtr(fds), n, @intFromPtr(timeout), @intFromPtr(sigmask), NSIG / 8); } |
pread()File table overflow |
pub fn read(fd: i32, buf: [*]u8, count: usize) usize { return syscall3(.read, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), count); } |
access()Too many open files |
pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: i64) usize { const offset_u: u64 = @bitCast(offset); return syscall5( .preadv, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(iov), count, // Kernel expects the offset is split into largest natural word-size. // See following link for detail: // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=601cc11d054ae4b5e9b5babec3d8e4667a2cb9b5 @as(usize, @truncate(offset_u)), if (usize_bits < 64) @as(usize, @truncate(offset_u >> 32)) else 0, ); } |
faccessat()Not a typewriter |
pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: i64, flags: kernel_rwf) usize { const offset_u: u64 = @bitCast(offset); return syscall6( .preadv2, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(iov), count, // See comments in preadv @as(usize, @truncate(offset_u)), if (usize_bits < 64) @as(usize, @truncate(offset_u >> 32)) else 0, flags, ); } |
pipe()Text file busy |
pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize { return syscall3(.readv, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(iov), count); } |
pipe2()File too large |
pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize { return syscall3(.writev, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(iov), count); } |
write()No space left on device |
pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64) usize { const offset_u: u64 = @bitCast(offset); return syscall5( .pwritev, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(iov), count, // See comments in preadv @as(usize, @truncate(offset_u)), if (usize_bits < 64) @as(usize, @truncate(offset_u >> 32)) else 0, ); } |
ftruncate()Illegal seek |
pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64, flags: kernel_rwf) usize { const offset_u: u64 = @bitCast(offset); return syscall6( .pwritev2, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(iov), count, // See comments in preadv @as(usize, @truncate(offset_u)), if (usize_bits < 64) @as(usize, @truncate(offset_u >> 32)) else 0, flags, ); } |
pwrite()Read-only file system |
pub fn rmdir(path: [*:0]const u8) usize { if (@hasField(SYS, "rmdir")) { return syscall1(.rmdir, @intFromPtr(path)); } else { return syscall3(.unlinkat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(path), AT.REMOVEDIR); } } |
rename()Too many links |
pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize { if (@hasField(SYS, "symlink")) { return syscall2(.symlink, @intFromPtr(existing), @intFromPtr(new)); } else { return syscall3(.symlinkat, @intFromPtr(existing), @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(new)); } } |
renameat()Broken pipe |
pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) usize { return syscall3(.symlinkat, @intFromPtr(existing), @as(usize, @bitCast(@as(isize, newfd))), @intFromPtr(newpath)); } |
renameat2()Math argument out of domain of func |
pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: i64) usize { if (@hasField(SYS, "pread64") and usize_bits < 64) { const offset_halves = splitValue64(offset); if (require_aligned_register_pair) { return syscall6( .pread64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), count, 0, offset_halves[0], offset_halves[1], ); } else { return syscall5( .pread64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), count, offset_halves[0], offset_halves[1], ); } } else { // Some architectures (eg. 64bit SPARC) pread is called pread64. const syscall_number = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64")) .pread64 else .pread; return syscall4( syscall_number, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), count, @as(u64, @bitCast(offset)), ); } } |
open()Math result not representable |
pub fn access(path: [*:0]const u8, mode: u32) usize { if (@hasField(SYS, "access")) { return syscall2(.access, @intFromPtr(path), mode); } else { return syscall4(.faccessat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(path), mode, 0); } } |
create()Resource deadlock would occur |
pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags); } |
openat()File name too long |
pub fn pipe(fd: *[2]i32) usize { if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) { return syscall_pipe(fd); } else if (@hasField(SYS, "pipe")) { return syscall1(.pipe, @intFromPtr(fd)); } else { return syscall2(.pipe2, @intFromPtr(fd), 0); } } |
clone5()No record locks available |
pub fn pipe2(fd: *[2]i32, flags: O) usize { return syscall2(.pipe2, @intFromPtr(fd), @as(u32, @bitCast(flags))); } |
clone2()Function not implemented |
pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { return syscall3(.write, @bitCast(@as(isize, fd)), @intFromPtr(buf), count); } |
close()Directory not empty |
pub fn ftruncate(fd: i32, length: i64) usize { if (@hasField(SYS, "ftruncate64") and usize_bits < 64) { const length_halves = splitValue64(length); if (require_aligned_register_pair) { return syscall4( .ftruncate64, @as(usize, @bitCast(@as(isize, fd))), 0, length_halves[0], length_halves[1], ); } else { return syscall3( .ftruncate64, @as(usize, @bitCast(@as(isize, fd))), length_halves[0], length_halves[1], ); } } else { return syscall2( .ftruncate, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(length)), ); } } |
fchmod()Too many symbolic links encountered |
pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: i64) usize { if (@hasField(SYS, "pwrite64") and usize_bits < 64) { const offset_halves = splitValue64(offset); |
chmod()No message of desired type |
if (require_aligned_register_pair) { return syscall6( .pwrite64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), count, 0, offset_halves[0], offset_halves[1], ); } else { return syscall5( .pwrite64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), count, offset_halves[0], offset_halves[1], ); } } else { // Some architectures (eg. 64bit SPARC) pwrite is called pwrite64. const syscall_number = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64")) .pwrite64 else .pwrite; return syscall4( syscall_number, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), count, @as(u64, @bitCast(offset)), ); } } |
fchown()Identifier removed |
pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize { if (@hasField(SYS, "rename")) { return syscall2(.rename, @intFromPtr(old), @intFromPtr(new)); } else if (@hasField(SYS, "renameat")) { return syscall4(.renameat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(old), @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(new)); } else { return syscall5(.renameat2, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(old), @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(new), 0); } } |
fchmodat()Channel number out of range |
pub fn renameat(oldfd: i32, oldpath: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) usize { if (@hasField(SYS, "renameat")) { return syscall4( .renameat, @as(usize, @bitCast(@as(isize, oldfd))), @intFromPtr(oldpath), @as(usize, @bitCast(@as(isize, newfd))), @intFromPtr(newpath), ); } else { return syscall5( .renameat2, @as(usize, @bitCast(@as(isize, oldfd))), @intFromPtr(oldpath), @as(usize, @bitCast(@as(isize, newfd))), @intFromPtr(newpath), 0, ); } } |
fchmodat2()Level 2 not synchronized |
pub fn renameat2(oldfd: i32, oldpath: [*:0]const u8, newfd: i32, newpath: [*:0]const u8, flags: u32) usize { return syscall5( .renameat2, @as(usize, @bitCast(@as(isize, oldfd))), @intFromPtr(oldpath), @as(usize, @bitCast(@as(isize, newfd))), @intFromPtr(newpath), flags, ); } |
llseek()Level 3 halted |
pub fn open(path: [*:0]const u8, flags: O, perm: mode_t) usize { if (@hasField(SYS, "open")) { return syscall3(.open, @intFromPtr(path), @as(u32, @bitCast(flags)), perm); } else { return syscall4( .openat, @bitCast(@as(isize, AT.FDCWD)), @intFromPtr(path), @as(u32, @bitCast(flags)), perm, ); } } |
lseek()Level 3 reset |
pub fn create(path: [*:0]const u8, perm: mode_t) usize { return syscall2(.creat, @intFromPtr(path), perm); } |
exit()Link number out of range |
pub fn openat(dirfd: i32, path: [*:0]const u8, flags: O, mode: mode_t) usize { // dirfd could be negative, for example AT.FDCWD is -100 return syscall4(.openat, @bitCast(@as(isize, dirfd)), @intFromPtr(path), @as(u32, @bitCast(flags)), mode); } |
exit_group()Protocol driver not attached |
/// See also `clone` (from the arch-specific include) pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: *i32, child_tid: *i32, newtls: usize) usize { return syscall5(.clone, flags, child_stack_ptr, @intFromPtr(parent_tid), @intFromPtr(child_tid), newtls); } |
LINUX_REBOOTNo CSI structure available |
/// See also `clone` (from the arch-specific include) pub fn clone2(flags: u32, child_stack_ptr: usize) usize { return syscall2(.clone, flags, child_stack_ptr); } |
MAGIC1Level 2 halted |
pub fn close(fd: i32) usize { return syscall1(.close, @as(usize, @bitCast(@as(isize, fd)))); } |
MAGIC2Invalid exchange |
pub fn fchmod(fd: i32, mode: mode_t) usize { return syscall2(.fchmod, @as(usize, @bitCast(@as(isize, fd))), mode); } |
CMDInvalid request descriptor |
pub fn chmod(path: [*:0]const u8, mode: mode_t) usize { if (@hasField(SYS, "chmod")) { return syscall2(.chmod, @intFromPtr(path), mode); } else { return fchmodat(AT.FDCWD, path, mode, 0); } } |
reboot()Exchange full |
pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize { if (@hasField(SYS, "fchown32")) { return syscall3(.fchown32, @as(usize, @bitCast(@as(isize, fd))), owner, group); } else { return syscall3(.fchown, @as(usize, @bitCast(@as(isize, fd))), owner, group); } } |
getrandom()No anode |
pub fn fchmodat(fd: i32, path: [*:0]const u8, mode: mode_t, _: u32) usize { return syscall3(.fchmodat, @bitCast(@as(isize, fd)), @intFromPtr(path), mode); } |
kill()Invalid request code |
pub fn fchmodat2(fd: i32, path: [*:0]const u8, mode: mode_t, flags: u32) usize { return syscall4(.fchmodat2, @bitCast(@as(isize, fd)), @intFromPtr(path), mode, flags); } |
tkill()Invalid slot |
/// Can only be called on 32 bit systems. For 64 bit see `lseek`. pub fn llseek(fd: i32, offset: u64, result: ?*u64, whence: usize) usize { // NOTE: The offset parameter splitting is independent from the target // endianness. return syscall5( .llseek, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @truncate(offset >> 32)), @as(usize, @truncate(offset)), @intFromPtr(result), whence, ); } |
tgkill()Bad font file format |
/// Can only be called on 64 bit systems. For 32 bit see `llseek`. pub fn lseek(fd: i32, offset: i64, whence: usize) usize { return syscall3(.lseek, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(offset)), whence); } |
link()Device not a stream |
pub fn exit(status: i32) noreturn { _ = syscall1(.exit, @as(usize, @bitCast(@as(isize, status)))); unreachable; } |
linkat()No data available |
pub fn exit_group(status: i32) noreturn { _ = syscall1(.exit_group, @as(usize, @bitCast(@as(isize, status)))); unreachable; } |
unlink()Timer expired |
/// flags for the `reboot' system call. pub const LINUX_REBOOT = struct { /// First magic value required to use _reboot() system call. pub const MAGIC1 = enum(u32) { MAGIC1 = 0xfee1dead, _, }; |
unlinkat()Out of streams resources |
/// Second magic value required to use _reboot() system call. pub const MAGIC2 = enum(u32) { MAGIC2 = 672274793, MAGIC2A = 85072278, MAGIC2B = 369367448, MAGIC2C = 537993216, _, }; |
waitpid()Machine is not on the network |
/// Commands accepted by the _reboot() system call. pub const CMD = enum(u32) { /// Restart system using default command and mode. RESTART = 0x01234567, |
wait4()Package not installed |
/// Stop OS and give system control to ROM monitor, if any. HALT = 0xCDEF0123, |
waitid()Object is remote |
/// Ctrl-Alt-Del sequence causes RESTART command. CAD_ON = 0x89ABCDEF, |
fcntl()Link has been severed |
/// Ctrl-Alt-Del sequence sends SIGINT to init task. CAD_OFF = 0x00000000, |
flock()Advertise error |
/// Stop OS and remove all power from system, if possible. POWER_OFF = 0x4321FEDC, |
clock_gettime()Srmount error |
/// Restart system using given command string. RESTART2 = 0xA1B2C3D4, |
clock_getres()Communication error on send |
/// Suspend system using software suspend if compiled in. SW_SUSPEND = 0xD000FCE2, |
clock_settime()Protocol error |
/// Restart system using a previously loaded Linux kernel KEXEC = 0x45584543, |
clock_nanosleep()Multihop attempted |
_, }; }; |
gettimeofday()RFS specific error |
pub fn reboot(magic: LINUX_REBOOT.MAGIC1, magic2: LINUX_REBOOT.MAGIC2, cmd: LINUX_REBOOT.CMD, arg: ?*const anyopaque) usize { return std.os.linux.syscall4( .reboot, @intFromEnum(magic), @intFromEnum(magic2), @intFromEnum(cmd), @intFromPtr(arg), ); } |
settimeofday()Not a data message |
pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize { return syscall3(.getrandom, @intFromPtr(buf), count, flags); } |
nanosleep()Value too large for defined data type |
pub fn kill(pid: pid_t, sig: i32) usize { return syscall2(.kill, @as(usize, @bitCast(@as(isize, pid))), @as(usize, @bitCast(@as(isize, sig)))); } |
pause()Name not unique on network |
pub fn tkill(tid: pid_t, sig: i32) usize { return syscall2(.tkill, @as(usize, @bitCast(@as(isize, tid))), @as(usize, @bitCast(@as(isize, sig)))); } |
setuid()File descriptor in bad state |
pub fn tgkill(tgid: pid_t, tid: pid_t, sig: i32) usize { return syscall3(.tgkill, @as(usize, @bitCast(@as(isize, tgid))), @as(usize, @bitCast(@as(isize, tid))), @as(usize, @bitCast(@as(isize, sig)))); } |
setgid()Remote address changed |
pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8) usize { if (@hasField(SYS, "link")) { return syscall2( .link, @intFromPtr(oldpath), @intFromPtr(newpath), ); } else { return syscall5( .linkat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(oldpath), @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(newpath), 0, ); } } |
setreuid()Can not access a needed shared library |
pub fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: i32) usize { return syscall5( .linkat, @as(usize, @bitCast(@as(isize, oldfd))), @intFromPtr(oldpath), @as(usize, @bitCast(@as(isize, newfd))), @intFromPtr(newpath), @as(usize, @bitCast(@as(isize, flags))), ); } |
setregid()Accessing a corrupted shared library |
pub fn unlink(path: [*:0]const u8) usize { if (@hasField(SYS, "unlink")) { return syscall1(.unlink, @intFromPtr(path)); } else { return syscall3(.unlinkat, @as(usize, @bitCast(@as(isize, AT.FDCWD))), @intFromPtr(path), 0); } } |
getuid().lib section in a.out corrupted |
pub fn unlinkat(dirfd: i32, path: [*:0]const u8, flags: u32) usize { return syscall3(.unlinkat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), flags); } |
getgid()Attempting to link in too many shared libraries |
pub fn waitpid(pid: pid_t, status: *u32, flags: u32) usize { return syscall4(.wait4, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(status), flags, 0); } |
geteuid()Cannot exec a shared library directly |
pub fn wait4(pid: pid_t, status: *u32, flags: u32, usage: ?*rusage) usize { return syscall4( .wait4, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(status), flags, @intFromPtr(usage), ); } |
getegid()Illegal byte sequence |
pub fn waitid(id_type: P, id: i32, infop: *siginfo_t, flags: u32) usize { return syscall5(.waitid, @intFromEnum(id_type), @as(usize, @bitCast(@as(isize, id))), @intFromPtr(infop), flags, 0); } |
seteuid()Interrupted system call should be restarted |
pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize { if (@hasField(SYS, "fcntl64")) { return syscall3(.fcntl64, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, cmd))), arg); } else { return syscall3(.fcntl, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, cmd))), arg); } } |
setegid()Streams pipe error |
pub fn flock(fd: fd_t, operation: i32) usize { return syscall2(.flock, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, operation)))); } |
getresuid()Too many users |
// We must follow the C calling convention when we call into the VDSO const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.c) usize; var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime; |
getresgid()Socket operation on non-socket |
pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize { if (VDSO != void) { const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered); if (ptr) |f| { const rc = f(clk_id, tp); switch (rc) { 0, @as(usize, @bitCast(-@as(isize, @intFromEnum(E.INVAL)))) => return rc, else => {}, } } } return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp)); } |
setresuid()Destination address required |
fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.c) usize { const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM)); // Note that we may not have a VDSO at all, update the stub address anyway // so that clock_gettime will fall back on the good old (and slow) syscall @atomicStore(?VdsoClockGettime, &vdso_clock_gettime, ptr, .monotonic); // Call into the VDSO if available if (ptr) |f| return f(clk, ts); return @as(usize, @bitCast(-@as(isize, @intFromEnum(E.NOSYS)))); } |
setresgid()Message too long |
pub fn clock_getres(clk_id: i32, tp: *timespec) usize { return syscall2(.clock_getres, @as(usize, @bitCast(@as(isize, clk_id))), @intFromPtr(tp)); } |
setpgid()Protocol wrong type for socket |
pub fn clock_settime(clk_id: i32, tp: *const timespec) usize { return syscall2(.clock_settime, @as(usize, @bitCast(@as(isize, clk_id))), @intFromPtr(tp)); } |
getgroups()Protocol not available |
pub fn clock_nanosleep(clockid: clockid_t, flags: TIMER, request: *const timespec, remain: ?*timespec) usize { return syscall4( .clock_nanosleep, @intFromEnum(clockid), @as(u32, @bitCast(flags)), @intFromPtr(request), @intFromPtr(remain), ); } |
setgroups()Protocol not supported |
pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) usize { return syscall2(.gettimeofday, @intFromPtr(tv), @intFromPtr(tz)); } |
setsid()Socket type not supported |
pub fn settimeofday(tv: *const timeval, tz: *const timezone) usize { return syscall2(.settimeofday, @intFromPtr(tv), @intFromPtr(tz)); } |
getpid()Operation not supported on transport endpoint
This code also means |
pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { if (native_arch == .riscv32) { @compileError("No nanosleep syscall on this architecture."); } else return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem)); } |
getppid()Protocol family not supported |
pub fn pause() usize { if (@hasField(SYS, "pause")) { return syscall0(.pause); } else { return syscall4(.ppoll, 0, 0, 0, 0); } } |
gettid()Address family not supported by protocol |
pub fn setuid(uid: uid_t) usize { if (@hasField(SYS, "setuid32")) { return syscall1(.setuid32, uid); } else { return syscall1(.setuid, uid); } } |
sigprocmask()Address already in use |
pub fn setgid(gid: gid_t) usize { if (@hasField(SYS, "setgid32")) { return syscall1(.setgid32, gid); } else { return syscall1(.setgid, gid); } } |
sigaction()Cannot assign requested address |
pub fn setreuid(ruid: uid_t, euid: uid_t) usize { if (@hasField(SYS, "setreuid32")) { return syscall2(.setreuid32, ruid, euid); } else { return syscall2(.setreuid, ruid, euid); } } |
NSIGNetwork is down |
pub fn setregid(rgid: gid_t, egid: gid_t) usize { if (@hasField(SYS, "setregid32")) { return syscall2(.setregid32, rgid, egid); } else { return syscall2(.setregid, rgid, egid); } } |
sigset_tNetwork is unreachable |
pub fn getuid() uid_t { if (@hasField(SYS, "getuid32")) { return @as(uid_t, @intCast(syscall0(.getuid32))); } else { return @as(uid_t, @intCast(syscall0(.getuid))); } } |
sigrtmin()Network dropped connection because of reset |
pub fn getgid() gid_t { if (@hasField(SYS, "getgid32")) { return @as(gid_t, @intCast(syscall0(.getgid32))); } else { return @as(gid_t, @intCast(syscall0(.getgid))); } } |
sigrtmax()Software caused connection abort |
pub fn geteuid() uid_t { if (@hasField(SYS, "geteuid32")) { return @as(uid_t, @intCast(syscall0(.geteuid32))); } else { return @as(uid_t, @intCast(syscall0(.geteuid))); } } |
sigemptyset()Connection reset by peer |
pub fn getegid() gid_t { if (@hasField(SYS, "getegid32")) { return @as(gid_t, @intCast(syscall0(.getegid32))); } else { return @as(gid_t, @intCast(syscall0(.getegid))); } } |
sigfillset()No buffer space available |
pub fn seteuid(euid: uid_t) usize { // We use setresuid here instead of setreuid to ensure that the saved uid // is not changed. This is what musl and recent glibc versions do as well. // // The setresuid(2) man page says that if -1 is passed the corresponding // id will not be changed. Since uid_t is unsigned, this wraps around to the // max value in C. comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned); return setresuid(std.math.maxInt(uid_t), euid, std.math.maxInt(uid_t)); } |
sigaddset()Transport endpoint is already connected |
pub fn setegid(egid: gid_t) usize { // We use setresgid here instead of setregid to ensure that the saved uid // is not changed. This is what musl and recent glibc versions do as well. // // The setresgid(2) man page says that if -1 is passed the corresponding // id will not be changed. Since gid_t is unsigned, this wraps around to the // max value in C. comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned); return setresgid(std.math.maxInt(gid_t), egid, std.math.maxInt(gid_t)); } |
sigdelset()Transport endpoint is not connected |
pub fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) usize { if (@hasField(SYS, "getresuid32")) { return syscall3(.getresuid32, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid)); } else { return syscall3(.getresuid, @intFromPtr(ruid), @intFromPtr(euid), @intFromPtr(suid)); } } |
sigismember()Cannot send after transport endpoint shutdown |
pub fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) usize { if (@hasField(SYS, "getresgid32")) { return syscall3(.getresgid32, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid)); } else { return syscall3(.getresgid, @intFromPtr(rgid), @intFromPtr(egid), @intFromPtr(sgid)); } } |
getsockname()Too many references: cannot splice |
pub fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) usize { if (@hasField(SYS, "setresuid32")) { return syscall3(.setresuid32, ruid, euid, suid); } else { return syscall3(.setresuid, ruid, euid, suid); } } |
getpeername()Connection timed out |
pub fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) usize { if (@hasField(SYS, "setresgid32")) { return syscall3(.setresgid32, rgid, egid, sgid); } else { return syscall3(.setresgid, rgid, egid, sgid); } } |
socket()Connection refused |
pub fn setpgid(pid: pid_t, pgid: pid_t) usize { return syscall2(.setpgid, @intCast(pid), @intCast(pgid)); } |
setsockopt()Host is down |
pub fn getgroups(size: usize, list: ?*gid_t) usize { if (@hasField(SYS, "getgroups32")) { return syscall2(.getgroups32, size, @intFromPtr(list)); } else { return syscall2(.getgroups, size, @intFromPtr(list)); } } |
getsockopt()No route to host |
pub fn setgroups(size: usize, list: [*]const gid_t) usize { if (@hasField(SYS, "setgroups32")) { return syscall2(.setgroups32, size, @intFromPtr(list)); } else { return syscall2(.setgroups, size, @intFromPtr(list)); } } |
sendmsg()Operation already in progress |
pub fn setsid() pid_t { return @bitCast(@as(u32, @truncate(syscall0(.setsid)))); } |
sendmmsg()Operation now in progress |
pub fn getpid() pid_t { return @bitCast(@as(u32, @truncate(syscall0(.getpid)))); } |
connect()Stale NFS file handle |
pub fn getppid() pid_t { return @bitCast(@as(u32, @truncate(syscall0(.getppid)))); } |
recvmsg()Structure needs cleaning |
pub fn gettid() pid_t { return @bitCast(@as(u32, @truncate(syscall0(.gettid)))); } |
recvmmsg()Not a XENIX named type file |
pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*sigset_t) usize { return syscall4(.rt_sigprocmask, flags, @intFromPtr(set), @intFromPtr(oldset), NSIG / 8); } |
recvfrom()No XENIX semaphores available |
pub fn sigaction(sig: u8, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) usize { assert(sig > 0); assert(sig < NSIG); assert(sig != SIG.KILL); assert(sig != SIG.STOP); |
shutdown()Is a named type file |
var ksa: k_sigaction = undefined; var oldksa: k_sigaction = undefined; const mask_size = @sizeOf(@TypeOf(ksa.mask)); |
bind()Remote I/O error |
if (act) |new| { // Zig needs to install our arch restorer function with any signal handler, so // must copy the Sigaction struct const restorer_fn = if ((new.flags & SA.SIGINFO) != 0) &restore_rt else &restore; ksa = k_sigaction{ .handler = new.handler.handler, .flags = new.flags | SA.RESTORER, .mask = new.mask, .restorer = @ptrCast(restorer_fn), }; } |
listen()Quota exceeded |
const ksa_arg = if (act != null) @intFromPtr(&ksa) else 0; const oldksa_arg = if (oact != null) @intFromPtr(&oldksa) else 0; |
sendto()No medium found |
const result = switch (native_arch) { // The sparc version of rt_sigaction needs the restorer function to be passed as an argument too. .sparc, .sparc64 => syscall5(.rt_sigaction, sig, ksa_arg, oldksa_arg, @intFromPtr(ksa.restorer), mask_size), else => syscall4(.rt_sigaction, sig, ksa_arg, oldksa_arg, mask_size), }; if (E.init(result) != .SUCCESS) return result; |
sendfile()Wrong medium type |
if (oact) |old| { old.handler.handler = oldksa.handler; old.flags = oldksa.flags; old.mask = oldksa.mask; } |
socketpair()Operation canceled |
return 0; } |
accept()Required key not available |
const usize_bits = @typeInfo(usize).int.bits; |
accept4()Key has expired |
/// Defined as one greater than the largest defined signal number. pub const NSIG = if (is_mips) 128 else 65; |
fstat()Key has been revoked |
/// Linux kernel's sigset_t. This is logically 64-bit on most /// architectures, but 128-bit on MIPS. Contrast with the 1024-bit /// sigset_t exported by the glibc and musl library ABIs. pub const sigset_t = [(NSIG - 1 + 7) / @bitSizeOf(SigsetElement)]SigsetElement; |
stat()Key was rejected by service |
const SigsetElement = c_ulong; |
lstat()Owner died |
const sigset_len = @typeInfo(sigset_t).array.len; |
fstatat()State not recoverable |
/// Zig's SIGRTMIN, but is a function for compatibility with glibc pub fn sigrtmin() u8 { // Default is 32 in the kernel UAPI: https://github.com/torvalds/linux/blob/78109c591b806e41987e0b83390e61d675d1f724/include/uapi/asm-generic/signal.h#L50 // AFAICT, all architectures that override this also set it to 32: // https://github.com/search?q=repo%3Atorvalds%2Flinux+sigrtmin+path%3Auapi&type=code return 32; } |
statx()Operation not possible due to RF-kill |
/// Zig's SIGRTMAX, but is a function for compatibility with glibc pub fn sigrtmax() u8 { return NSIG - 1; } |
listxattr()Memory page has hardware error |
/// Zig's version of sigemptyset. Returns initialized sigset_t. pub fn sigemptyset() sigset_t { return [_]SigsetElement{0} ** sigset_len; } |
llistxattr()DNS server returned answer with no data |
/// Zig's version of sigfillset. Returns initalized sigset_t. pub fn sigfillset() sigset_t { return [_]SigsetElement{~@as(SigsetElement, 0)} ** sigset_len; } |
flistxattr()DNS server claims query was misformatted |
fn sigset_bit_index(sig: usize) struct { word: usize, mask: SigsetElement } { assert(sig > 0); assert(sig < NSIG); const bit = sig - 1; return .{ .word = bit / @bitSizeOf(SigsetElement), .mask = @as(SigsetElement, 1) << @truncate(bit % @bitSizeOf(SigsetElement)), }; } |
getxattr()DNS server returned general failure |
pub fn sigaddset(set: *sigset_t, sig: usize) void { const index = sigset_bit_index(sig); (set.*)[index.word] |= index.mask; } |
lgetxattr()Domain name not found |
pub fn sigdelset(set: *sigset_t, sig: usize) void { const index = sigset_bit_index(sig); (set.*)[index.word] ^= index.mask; } |
fgetxattr()DNS server does not implement requested operation |
pub fn sigismember(set: *const sigset_t, sig: usize) bool { const index = sigset_bit_index(sig); return ((set.*)[index.word] & index.mask) != 0; } |
setxattr()DNS server refused query |
pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { if (native_arch == .x86) { return socketcall(SC.getsockname, &[3]usize{ @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @intFromPtr(len) }); } return syscall3(.getsockname, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @intFromPtr(len)); } |
lsetxattr()Misformatted DNS query |
pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize { if (native_arch == .x86) { return socketcall(SC.getpeername, &[3]usize{ @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @intFromPtr(len) }); } return syscall3(.getpeername, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @intFromPtr(len)); } |
fsetxattr()Misformatted domain name |
pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize { if (native_arch == .x86) { return socketcall(SC.socket, &[3]usize{ domain, socket_type, protocol }); } return syscall3(.socket, domain, socket_type, protocol); } |
removexattr()Unsupported address family |
pub fn setsockopt(fd: i32, level: i32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize { if (native_arch == .x86) { return socketcall(SC.setsockopt, &[5]usize{ @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @as(usize, @intCast(optlen)) }); } return syscall5(.setsockopt, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @as(usize, @intCast(optlen))); } |
lremovexattr()Misformatted DNS reply |
pub fn getsockopt(fd: i32, level: i32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize { if (native_arch == .x86) { return socketcall(SC.getsockopt, &[5]usize{ @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @intFromPtr(optlen) }); } return syscall5(.getsockopt, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @intFromPtr(optlen)); } |
fremovexattr()Could not contact DNS servers |
pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize { const fd_usize = @as(usize, @bitCast(@as(isize, fd))); const msg_usize = @intFromPtr(msg); if (native_arch == .x86) { return socketcall(SC.sendmsg, &[3]usize{ fd_usize, msg_usize, flags }); } else { return syscall3(.sendmsg, fd_usize, msg_usize, flags); } } |
sched_paramTimeout while contacting DNS servers |
pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize { if (@typeInfo(usize).int.bits > @typeInfo(@typeInfo(mmsghdr).@"struct".fields[1].type).int.bits) { // workaround kernel brokenness: // if adding up all iov_len overflows a i32 then split into multiple calls // see https://www.openwall.com/lists/musl/2014/06/07/5 const kvlen = if (vlen > IOV_MAX) IOV_MAX else vlen; // matches kernel var next_unsent: usize = 0; for (msgvec[0..kvlen], 0..) |*msg, i| { var size: i32 = 0; const msg_iovlen = @as(usize, @intCast(msg.hdr.iovlen)); // kernel side this is treated as unsigned for (msg.hdr.iov[0..msg_iovlen]) |iov| { if (iov.len > std.math.maxInt(i32) or @addWithOverflow(size, @as(i32, @intCast(iov.len)))[1] != 0) { // batch-send all messages up to the current message if (next_unsent < i) { const batch_size = i - next_unsent; const r = syscall4(.sendmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); if (E.init(r) != .SUCCESS) return next_unsent; if (r < batch_size) return next_unsent + r; } // send current message as own packet const r = sendmsg(fd, &msg.hdr, flags); if (E.init(r) != .SUCCESS) return r; // Linux limits the total bytes sent by sendmsg to INT_MAX, so this cast is safe. msg.len = @as(u32, @intCast(r)); next_unsent = i + 1; break; } size += @intCast(iov.len); } } if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR) const batch_size = kvlen - next_unsent; const r = syscall4(.sendmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(&msgvec[next_unsent]), batch_size, flags); if (E.init(r) != .SUCCESS) return r; return next_unsent + r; } return kvlen; } return syscall4(.sendmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(msgvec), vlen, flags); } |
SCHEDEnd of file |
pub fn connect(fd: i32, addr: *const anyopaque, len: socklen_t) usize { const fd_usize = @as(usize, @bitCast(@as(isize, fd))); const addr_usize = @intFromPtr(addr); if (native_arch == .x86) { return socketcall(SC.connect, &[3]usize{ fd_usize, addr_usize, len }); } else { return syscall3(.connect, fd_usize, addr_usize, len); } } |
ModeError reading file |
pub fn recvmsg(fd: i32, msg: *msghdr, flags: u32) usize { const fd_usize = @as(usize, @bitCast(@as(isize, fd))); const msg_usize = @intFromPtr(msg); if (native_arch == .x86) { return socketcall(SC.recvmsg, &[3]usize{ fd_usize, msg_usize, flags }); } else { return syscall3(.recvmsg, fd_usize, msg_usize, flags); } } |
sched_setparam()Out of memory |
pub fn recvmmsg(fd: i32, msgvec: ?[*]mmsghdr, vlen: u32, flags: u32, timeout: ?*timespec) usize { return syscall5( .recvmmsg, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(msgvec), vlen, flags, @intFromPtr(timeout), ); } |
sched_getparam()Application terminated lookup |
pub fn recvfrom( fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t, |
sched_setscheduler()Domain name is too long |
) usize { const fd_usize = @as(usize, @bitCast(@as(isize, fd))); const buf_usize = @intFromPtr(buf); const addr_usize = @intFromPtr(addr); const alen_usize = @intFromPtr(alen); if (native_arch == .x86) { return socketcall(SC.recvfrom, &[6]usize{ fd_usize, buf_usize, len, flags, addr_usize, alen_usize }); } else { return syscall6(.recvfrom, fd_usize, buf_usize, len, flags, addr_usize, alen_usize); } } |
sched_getscheduler()Domain name is too long |
pub fn shutdown(fd: i32, how: i32) usize { if (native_arch == .x86) { return socketcall(SC.shutdown, &[2]usize{ @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, how))) }); } return syscall2(.shutdown, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, how)))); } |
sched_get_priority_max()Largest hardware address length e.g. a mac address is a type of hardware address |
pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize { if (native_arch == .x86) { return socketcall(SC.bind, &[3]usize{ @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @as(usize, @intCast(len)) }); } return syscall3(.bind, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @as(usize, @intCast(len))); } |
sched_get_priority_min()Special value used to indicate openat should use the current working directory |
pub fn listen(fd: i32, backlog: u32) usize { if (native_arch == .x86) { return socketcall(SC.listen, &[2]usize{ @as(usize, @bitCast(@as(isize, fd))), backlog }); } return syscall2(.listen, @as(usize, @bitCast(@as(isize, fd))), backlog); } |
getcpu()Do not follow symbolic links |
pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize { if (native_arch == .x86) { return socketcall(SC.sendto, &[6]usize{ @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), len, flags, @intFromPtr(addr), @as(usize, @intCast(alen)) }); } return syscall6(.sendto, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(buf), len, flags, @intFromPtr(addr), @as(usize, @intCast(alen))); } |
sched_attrRemove directory instead of unlinking file |
pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize { if (@hasField(SYS, "sendfile64")) { return syscall4( .sendfile64, @as(usize, @bitCast(@as(isize, outfd))), @as(usize, @bitCast(@as(isize, infd))), @intFromPtr(offset), count, ); } else { return syscall4( .sendfile, @as(usize, @bitCast(@as(isize, outfd))), @as(usize, @bitCast(@as(isize, infd))), @intFromPtr(offset), count, ); } } |
sched_setattr()Follow symbolic links. |
pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: *[2]i32) usize { if (native_arch == .x86) { return socketcall(SC.socketpair, &[4]usize{ @as(usize, @intCast(domain)), @as(usize, @intCast(socket_type)), @as(usize, @intCast(protocol)), @intFromPtr(fd) }); } return syscall4(.socketpair, @as(usize, @intCast(domain)), @as(usize, @intCast(socket_type)), @as(usize, @intCast(protocol)), @intFromPtr(fd)); } |
sched_getattr()Suppress terminal automount traversal |
pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize { if (native_arch == .x86) { return socketcall(SC.accept, &[4]usize{ @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @intFromPtr(len), 0 }); } return accept4(fd, addr, len, 0); } |
sched_rr_get_interval()Allow empty relative pathname |
pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize { if (native_arch == .x86) { return socketcall(SC.accept4, &[4]usize{ @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @intFromPtr(len), flags }); } return syscall4(.accept4, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(addr), @intFromPtr(len), flags); } |
sched_yield()Type of synchronisation required from statx() |
pub fn fstat(fd: i32, stat_buf: *Stat) usize { if (native_arch == .riscv32 or native_arch.isLoongArch()) { // riscv32 and loongarch have made the interesting decision to not implement some of // the older stat syscalls, including this one. @compileError("No fstat syscall on this architecture."); } else if (@hasField(SYS, "fstat64")) { return syscall2(.fstat64, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(stat_buf)); } else { return syscall2(.fstat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(stat_buf)); } } |
sched_getaffinity()- Do whatever stat() does |
pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { if (native_arch == .riscv32 or native_arch.isLoongArch()) { // riscv32 and loongarch have made the interesting decision to not implement some of // the older stat syscalls, including this one. @compileError("No stat syscall on this architecture."); } else if (@hasField(SYS, "stat64")) { return syscall2(.stat64, @intFromPtr(pathname), @intFromPtr(statbuf)); } else { return syscall2(.stat, @intFromPtr(pathname), @intFromPtr(statbuf)); } } |
sched_setaffinity()- Force the attributes to be sync'd with the server |
pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { if (native_arch == .riscv32 or native_arch.isLoongArch()) { // riscv32 and loongarch have made the interesting decision to not implement some of // the older stat syscalls, including this one. @compileError("No lstat syscall on this architecture."); } else if (@hasField(SYS, "lstat64")) { return syscall2(.lstat64, @intFromPtr(pathname), @intFromPtr(statbuf)); } else { return syscall2(.lstat, @intFromPtr(pathname), @intFromPtr(statbuf)); } } |
epoll_create()- Don't sync attributes with the server |
pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize { if (native_arch == .riscv32 or native_arch.isLoongArch()) { // riscv32 and loongarch have made the interesting decision to not implement some of // the older stat syscalls, including this one. @compileError("No fstatat syscall on this architecture."); } else if (@hasField(SYS, "fstatat64")) { return syscall4(.fstatat64, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(stat_buf), flags); } else { return syscall4(.fstatat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(stat_buf), flags); } } |
epoll_create1()Apply to the entire subtree |
pub fn statx(dirfd: i32, path: [*:0]const u8, flags: u32, mask: u32, statx_buf: *Statx) usize { return syscall5( .statx, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), flags, mask, @intFromPtr(statx_buf), ); } |
epoll_ctl()Default is extend size |
pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize { return syscall3(.listxattr, @intFromPtr(path), @intFromPtr(list), size); } |
epoll_wait()De-allocates range |
pub fn llistxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize { return syscall3(.llistxattr, @intFromPtr(path), @intFromPtr(list), size); } |
epoll_pwait()Reserved codepoint |
pub fn flistxattr(fd: fd_t, list: [*]u8, size: usize) usize { return syscall3(.flistxattr, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(list), size); } |
eventfd()Removes a range of a file without leaving a hole in the file |
pub fn getxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize { return syscall4(.getxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size); } |
timerfd_create()Converts a range of file to zeros preferably without issuing data IO |
pub fn lgetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize { return syscall4(.lgetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size); } |
itimerspecInserts space within the file size without overwriting any existing data |
pub fn fgetxattr(fd: fd_t, name: [*:0]const u8, value: [*]u8, size: usize) usize { return syscall4(.fgetxattr, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(name), @intFromPtr(value), size); } |
timerfd_gettime()Unshares shared blocks within the file size without overwriting any existing data |
pub fn setxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize { return syscall5(.setxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags); } |
timerfd_settime()Futex v1 API command and flags for the |
pub fn lsetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize { return syscall5(.lsetxattr, @intFromPtr(path), @intFromPtr(name), @intFromPtr(value), size, flags); } |
ITIMERFutex v1 FUTEX_WAKE_OP |
pub fn fsetxattr(fd: fd_t, name: [*:0]const u8, value: [*]const u8, size: usize, flags: usize) usize { return syscall5(.fsetxattr, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(name), @intFromPtr(value), size, flags); } |
getitimer()From C API |
pub fn removexattr(path: [*:0]const u8, name: [*:0]const u8) usize { return syscall2(.removexattr, @intFromPtr(path), @intFromPtr(name)); } |
setitimer()Futex v1 cmd for FUTEX_WAKE_OP |
pub fn lremovexattr(path: [*:0]const u8, name: [*:0]const u8) usize { return syscall2(.lremovexattr, @intFromPtr(path), @intFromPtr(name)); } |
unshare()uaddr2 = oparg |
pub fn fremovexattr(fd: usize, name: [*:0]const u8) usize { return syscall2(.fremovexattr, fd, @intFromPtr(name)); } |
capget()uaddr2 += oparg |
pub const sched_param = extern struct { priority: i32, }; |
capset()uaddr2 |= oparg |
pub const SCHED = packed struct(i32) { pub const Mode = enum(u3) { /// normal multi-user scheduling NORMAL = 0, /// FIFO realtime scheduling FIFO = 1, /// Round-robin realtime scheduling RR = 2, /// For "batch" style execution of processes BATCH = 3, /// Low latency scheduling IDLE = 5, /// Sporadic task model deadline scheduling DEADLINE = 6, }; mode: Mode, //bits [0, 2] _3: u27 = 0, //bits [3, 29] /// set to true to stop children from inheriting policies RESET_ON_FORK: bool = false, //bit 30 _31: u1 = 0, //bit 31 }; |
sigaltstack()uaddr2 &= ~oparg |
pub fn sched_setparam(pid: pid_t, param: *const sched_param) usize { return syscall2(.sched_setparam, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(param)); } |
uname()uaddr2 ^= oparg |
pub fn sched_getparam(pid: pid_t, param: *sched_param) usize { return syscall2(.sched_getparam, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(param)); } |
io_uring_setup()Futex v1 comparison op for FUTEX_WAKE_OP |
pub fn sched_setscheduler(pid: pid_t, policy: SCHED, param: *const sched_param) usize { return syscall3(.sched_setscheduler, @as(usize, @bitCast(@as(isize, pid))), @intCast(@as(u32, @bitCast(policy))), @intFromPtr(param)); } |
io_uring_enter()Max numbers of elements in a |
pub fn sched_getscheduler(pid: pid_t) usize { return syscall1(.sched_getscheduler, @as(usize, @bitCast(@as(isize, pid)))); } |
io_uring_register()For futex v2 API, the size of the futex at the uaddr. v1 futex are always implicitly U32. As of kernel v6.14, only U32 is implemented for v2 futexes. |
pub fn sched_get_priority_max(policy: SCHED) usize { return syscall1(.sched_get_priority_max, @intCast(@as(u32, @bitCast(policy)))); } |
memfd_create()As of kernel 6.14 there are no defined flags to futex2_waitv. |
pub fn sched_get_priority_min(policy: SCHED) usize { return syscall1(.sched_get_priority_min, @intCast(@as(u32, @bitCast(policy)))); } |
getrusage()As of kernel 6.14 there are no defined flags to futex2_requeue. |
pub fn getcpu(cpu: ?*usize, node: ?*usize) usize { return syscall2(.getcpu, @intFromPtr(cpu), @intFromPtr(node)); } |
tcgetattr()Flags for futex v2 APIs (futex2_wait, futex2_wake, futex2_requeue, but not the futex2_waitv syscall, but also used in the futex2_waitone struct). |
pub const sched_attr = extern struct { size: u32 = 48, // Size of this structure policy: u32 = 0, // Policy (SCHED_*) flags: u64 = 0, // Flags nice: u32 = 0, // Nice value (SCHED_OTHER, SCHED_BATCH) priority: u32 = 0, // Static priority (SCHED_FIFO, SCHED_RR) // Remaining fields are for SCHED_DEADLINE runtime: u64 = 0, deadline: u64 = 0, period: u64 = 0, }; |
tcsetattr()page can not be accessed |
pub fn sched_setattr(pid: pid_t, attr: *const sched_attr, flags: usize) usize { return syscall3(.sched_setattr, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(attr), flags); } |
tcgetpgrp()page can be read |
pub fn sched_getattr(pid: pid_t, attr: *sched_attr, size: usize, flags: usize) usize { return syscall4(.sched_getattr, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(attr), size, flags); } |
tcsetpgrp()page can be written |
pub fn sched_rr_get_interval(pid: pid_t, tp: *timespec) usize { return syscall2(.sched_rr_get_interval, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(tp)); } |
tcdrain()page can be executed |
pub fn sched_yield() usize { return syscall0(.sched_yield); } |
ioctl()page may be used for atomic ops |
pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize { const rc = syscall3(.sched_getaffinity, @as(usize, @bitCast(@as(isize, pid))), size, @intFromPtr(set)); if (@as(isize, @bitCast(rc)) < 0) return rc; if (rc < size) @memset(@as([*]u8, @ptrCast(set))[rc..size], 0); return 0; } |
signalfd()mprotect flag: extend change to start of growsdown vma |
pub fn sched_setaffinity(pid: pid_t, set: *const cpu_set_t) !void { const size = @sizeOf(cpu_set_t); const rc = syscall3(.sched_setaffinity, @as(usize, @bitCast(@as(isize, pid))), size, @intFromPtr(set)); |
copy_file_range()mprotect flag: extend change to end of growsup vma |
switch (E.init(rc)) { .SUCCESS => return, else => |err| return std.posix.unexpectedErrno(err), } } |
bpf()Turn off Nagle's algorithm |
pub fn epoll_create() usize { return epoll_create1(0); } |
sync()Limit MSS |
pub fn epoll_create1(flags: usize) usize { return syscall1(.epoll_create1, flags); } |
syncfs()Never send partially complete segments. |
pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: ?*epoll_event) usize { return syscall4(.epoll_ctl, @as(usize, @bitCast(@as(isize, epoll_fd))), @as(usize, @intCast(op)), @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(ev)); } |
fsync()Start keeplives after this period, in seconds |
pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32) usize { return epoll_pwait(epoll_fd, events, maxevents, timeout, null); } |
fdatasync()Interval between keepalives |
pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*const sigset_t) usize { return syscall6( .epoll_pwait, @as(usize, @bitCast(@as(isize, epoll_fd))), @intFromPtr(events), @as(usize, @intCast(maxevents)), @as(usize, @bitCast(@as(isize, timeout))), @intFromPtr(sigmask), NSIG / 8, ); } |
prctl()Number of keepalives before death |
pub fn eventfd(count: u32, flags: u32) usize { return syscall2(.eventfd2, count, flags); } |
getrlimit()Number of SYN retransmits |
pub fn timerfd_create(clockid: timerfd_clockid_t, flags: TFD) usize { return syscall2( .timerfd_create, @intFromEnum(clockid), @as(u32, @bitCast(flags)), ); } |
setrlimit()Life time of orphaned FIN-WAIT-2 state |
pub const itimerspec = extern struct { it_interval: timespec, it_value: timespec, }; |
prlimit()Wake up listener only when data arrive |
pub fn timerfd_gettime(fd: i32, curr_value: *itimerspec) usize { return syscall2(.timerfd_gettime, @bitCast(@as(isize, fd)), @intFromPtr(curr_value)); } |
mincore()Bound advertised window |
pub fn timerfd_settime(fd: i32, flags: TFD.TIMER, new_value: *const itimerspec, old_value: ?*itimerspec) usize { return syscall4(.timerfd_settime, @bitCast(@as(isize, fd)), @as(u32, @bitCast(flags)), @intFromPtr(new_value), @intFromPtr(old_value)); } |
madvise()Information about this connection. |
// Flags for the 'setitimer' system call pub const ITIMER = enum(i32) { REAL = 0, VIRTUAL = 1, PROF = 2, }; |
pidfd_open()Block/reenable quick acks |
pub fn getitimer(which: i32, curr_value: *itimerspec) usize { return syscall2(.getitimer, @as(usize, @bitCast(@as(isize, which))), @intFromPtr(curr_value)); } |
pidfd_getfd()Congestion control algorithm |
pub fn setitimer(which: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize { return syscall3(.setitimer, @as(usize, @bitCast(@as(isize, which))), @intFromPtr(new_value), @intFromPtr(old_value)); } |
pidfd_send_signal()TCP MD5 Signature (RFC2385) |
pub fn unshare(flags: usize) usize { return syscall1(.unshare, flags); } |
process_vm_readv()Use linear timeouts for thin streams |
pub fn capget(hdrp: *cap_user_header_t, datap: *cap_user_data_t) usize { return syscall2(.capget, @intFromPtr(hdrp), @intFromPtr(datap)); } |
process_vm_writev()Fast retrans. after 1 dupack |
pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize { return syscall2(.capset, @intFromPtr(hdrp), @intFromPtr(datap)); } |
fadvise()How long for loss retry before timeout |
pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) usize { return syscall2(.sigaltstack, @intFromPtr(ss), @intFromPtr(old_ss)); } |
perf_event_open()TCP sock is under repair right now |
pub fn uname(uts: *utsname) usize { return syscall1(.uname, @intFromPtr(uts)); } |
seccomp()Enable FastOpen on listeners |
pub fn io_uring_setup(entries: u32, p: *io_uring_params) usize { return syscall2(.io_uring_setup, entries, @intFromPtr(p)); } |
ptrace()limit number of unsent bytes in write queue |
pub fn io_uring_enter(fd: i32, to_submit: u32, min_complete: u32, flags: u32, sig: ?*sigset_t) usize { return syscall6(.io_uring_enter, @as(usize, @bitCast(@as(isize, fd))), to_submit, min_complete, flags, @intFromPtr(sig), NSIG / 8); } |
cachestat()Get Congestion Control (optional) info |
pub fn io_uring_register(fd: i32, opcode: IORING_REGISTER, arg: ?*const anyopaque, nr_args: u32) usize { return syscall4(.io_uring_register, @as(usize, @bitCast(@as(isize, fd))), @intFromEnum(opcode), @intFromPtr(arg), nr_args); } |
map_shadow_stack()Record SYN headers for new connections |
pub fn memfd_create(name: [*:0]const u8, flags: u32) usize { return syscall2(.memfd_create, @intFromPtr(name), flags); } |
SysinfoGet SYN headers recorded for connection |
pub fn getrusage(who: i32, usage: *rusage) usize { return syscall2(.getrusage, @as(usize, @bitCast(@as(isize, who))), @intFromPtr(usage)); } |
sysinfo()Get/set window parameters |
pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize { return syscall3(.ioctl, @as(usize, @bitCast(@as(isize, fd))), T.CGETS, @intFromPtr(termios_p)); } |
EAttempt FastOpen with connect |
pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize { return syscall3(.ioctl, @as(usize, @bitCast(@as(isize, fd))), T.CSETS + @intFromEnum(optional_action), @intFromPtr(termios_p)); } |
initAttach a ULP to a TCP connection |
pub fn tcgetpgrp(fd: fd_t, pgrp: *pid_t) usize { return syscall3(.ioctl, @as(usize, @bitCast(@as(isize, fd))), T.IOCGPGRP, @intFromPtr(pgrp)); } |
initTCP MD5 Signature with extensions |
pub fn tcsetpgrp(fd: fd_t, pgrp: *const pid_t) usize { return syscall3(.ioctl, @as(usize, @bitCast(@as(isize, fd))), T.IOCSPGRP, @intFromPtr(pgrp)); } |
initSet the key for Fast Open (cookie) |
pub fn tcdrain(fd: fd_t) usize { return syscall3(.ioctl, @as(usize, @bitCast(@as(isize, fd))), T.CSBRK, 1); } |
pid_tEnable TFO without a TFO cookie |
pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize { return syscall3(.ioctl, @as(usize, @bitCast(@as(isize, fd))), request, arg); } |
fd_tNotify bytes available to read as a cmsg on read |
pub fn signalfd(fd: fd_t, mask: *const sigset_t, flags: u32) usize { return syscall4(.signalfd4, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(mask), NSIG / 8, flags); } |
socket_tdelay outgoing packets by XX usec |
pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) usize { return syscall6( .copy_file_range, @as(usize, @bitCast(@as(isize, fd_in))), @intFromPtr(off_in), @as(usize, @bitCast(@as(isize, fd_out))), @intFromPtr(off_out), len, flags, ); } |
uid_tTurn off without window probes |
pub fn bpf(cmd: BPF.Cmd, attr: *BPF.Attr, size: u32) usize { return syscall3(.bpf, @intFromEnum(cmd), @intFromPtr(attr), size); } |
gid_tNever send partially complete segments |
pub fn sync() void { _ = syscall0(.sync); } |
clock_tSet the socket to accept encapsulated packets |
pub fn syncfs(fd: fd_t) usize { return syscall1(.syncfs, @as(usize, @bitCast(@as(isize, fd)))); } |
NAME_MAXDisable sending checksum for UDP6X |
pub fn fsync(fd: fd_t) usize { return syscall1(.fsync, @as(usize, @bitCast(@as(isize, fd)))); } |
PATH_MAXDisable accepting checksum for UDP6 |
pub fn fdatasync(fd: fd_t) usize { return syscall1(.fdatasync, @as(usize, @bitCast(@as(isize, fd)))); } |
IOV_MAXSet GSO segmentation size |
pub fn prctl(option: i32, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { return syscall5(.prctl, @as(usize, @bitCast(@as(isize, option))), arg2, arg3, arg4, arg5); } |
MAX_ADDR_LENThis socket can receive UDP GRO packets |
pub fn getrlimit(resource: rlimit_resource, rlim: *rlimit) usize { // use prlimit64 to have 64 bit limits on 32 bit platforms return prlimit(0, resource, null, rlim); } |
STDIN_FILENOIPv6 socket options |
pub fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) usize { // use prlimit64 to have 64 bit limits on 32 bit platforms return prlimit(0, resource, rlim, null); } |
STDOUT_FILENOIEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble and FCS/CRC (frame check sequence). |
pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit, old_limit: ?*rlimit) usize { return syscall4( .prlimit64, @as(usize, @bitCast(@as(isize, pid))), @as(usize, @bitCast(@as(isize, @intFromEnum(resource)))), @intFromPtr(new_limit), @intFromPtr(old_limit), ); } |
STDERR_FILENOOctets in one ethernet addr |
pub fn mincore(address: [*]u8, len: usize, vec: [*]u8) usize { return syscall3(.mincore, @intFromPtr(address), len, @intFromPtr(vec)); } |
ATOctets in ethernet type field |
pub fn madvise(address: [*]u8, len: usize, advice: u32) usize { return syscall3(.madvise, @intFromPtr(address), len, advice); } |
FDCWDTotal octets in header |
pub fn pidfd_open(pid: pid_t, flags: u32) usize { return syscall2(.pidfd_open, @as(usize, @bitCast(@as(isize, pid))), flags); } |
SYMLINK_NOFOLLOWMin. octets in frame sans FC |
pub fn pidfd_getfd(pidfd: fd_t, targetfd: fd_t, flags: u32) usize { return syscall3( .pidfd_getfd, @as(usize, @bitCast(@as(isize, pidfd))), @as(usize, @bitCast(@as(isize, targetfd))), flags, ); } |
REMOVEDIRMax. octets in payload |
pub fn pidfd_send_signal(pidfd: fd_t, sig: i32, info: ?*siginfo_t, flags: u32) usize { return syscall4( .pidfd_send_signal, @as(usize, @bitCast(@as(isize, pidfd))), @as(usize, @bitCast(@as(isize, sig))), @intFromPtr(info), flags, ); } |
SYMLINK_FOLLOWMax. octets in frame sans FCS |
pub fn process_vm_readv(pid: pid_t, local: []const iovec, remote: []const iovec_const, flags: usize) usize { return syscall6( .process_vm_readv, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(local.ptr), local.len, @intFromPtr(remote.ptr), remote.len, flags, ); } |
NO_AUTOMOUNTOctets in the FCS |
pub fn process_vm_writev(pid: pid_t, local: []const iovec_const, remote: []const iovec_const, flags: usize) usize { return syscall6( .process_vm_writev, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(local.ptr), local.len, @intFromPtr(remote.ptr), remote.len, flags, ); } |
EMPTY_PATHMin IPv4 MTU per RFC791 |
pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize { if (comptime native_arch.isArm() or native_arch.isPowerPC32()) { // These architectures reorder the arguments so that a register is not skipped to align the // register number that `offset` is passed in. |
STATX_SYNC_TYPE65535, same as IP_MAX_MTU |
const offset_halves = splitValue64(offset); const length_halves = splitValue64(len); |
STATX_SYNC_AS_STATThese are the defined Ethernet Protocol ID's. |
return syscall6( .fadvise64_64, @as(usize, @bitCast(@as(isize, fd))), advice, offset_halves[0], offset_halves[1], length_halves[0], length_halves[1], ); } else if (native_arch.isMIPS32()) { // MIPS O32 does not deal with the register alignment issue, so pass a dummy value. |
STATX_FORCE_SYNCEthernet Loopback packet |
const offset_halves = splitValue64(offset); const length_halves = splitValue64(len); |
STATX_DONT_SYNCXerox PUP packet |
return syscall7( .fadvise64, @as(usize, @bitCast(@as(isize, fd))), 0, offset_halves[0], offset_halves[1], length_halves[0], length_halves[1], advice, ); } else if (comptime usize_bits < 64) { // Other 32-bit architectures do not require register alignment. |
RECURSIVEXerox PUP Addr Trans packet |
const offset_halves = splitValue64(offset); const length_halves = splitValue64(len); |
HANDLE_FIDTSN (IEEE 1722) packet |
return syscall6( switch (builtin.abi) { .gnuabin32, .gnux32, .muslabin32, .muslx32 => .fadvise64, else => .fadvise64_64, }, @as(usize, @bitCast(@as(isize, fd))), offset_halves[0], offset_halves[1], length_halves[0], length_halves[1], advice, ); } else { // On 64-bit architectures, fadvise64_64 and fadvise64 are the same. Generally, older ports // call it fadvise64 (x86, PowerPC, etc), while newer ports call it fadvise64_64 (RISC-V, // LoongArch, etc). SPARC is the odd one out because it has both. return syscall4( if (@hasField(SYS, "fadvise64_64")) .fadvise64_64 else .fadvise64, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(offset)), @as(usize, @bitCast(len)), advice, ); } } |
FALLOCERSPAN version 2 (type III) |
pub fn perf_event_open( attr: *perf_event_attr, pid: pid_t, cpu: i32, group_fd: fd_t, flags: usize, ) usize { return syscall5( .perf_event_open, @intFromPtr(attr), @as(usize, @bitCast(@as(isize, pid))), @as(usize, @bitCast(@as(isize, cpu))), @as(usize, @bitCast(@as(isize, group_fd))), flags, ); } |
FL_KEEP_SIZEInternet Protocol packet |
pub fn seccomp(operation: u32, flags: u32, args: ?*const anyopaque) usize { return syscall3(.seccomp, operation, flags, @intFromPtr(args)); } |
FL_PUNCH_HOLECCITT X.25 |
pub fn ptrace( req: u32, pid: pid_t, addr: usize, data: usize, addr2: usize, ) usize { return syscall5( .ptrace, req, @as(usize, @bitCast(@as(isize, pid))), addr, data, addr2, ); } |
FL_NO_HIDE_STALEAddress Resolution packet |
/// Query the page cache statistics of a file. pub fn cachestat( /// The open file descriptor to retrieve statistics from. fd: fd_t, /// The byte range in `fd` to query. /// When `len > 0`, the range is `[off..off + len]`. /// When `len` == 0, the range is from `off` to the end of `fd`. cstat_range: *const cache_stat_range, /// The structure where page cache statistics are stored. cstat: *cache_stat, /// Currently unused, and must be set to `0`. flags: u32, ) usize { return syscall4( .cachestat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(cstat_range), @intFromPtr(cstat), flags, ); } |
FL_COLLAPSE_RANGEG8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] |
pub fn map_shadow_stack(addr: u64, size: u64, flags: u32) usize { return syscall3(.map_shadow_stack, addr, size, flags); } |
FL_ZERO_RANGEXerox IEEE802.3 PUP packet |
pub const Sysinfo = switch (native_abi) { .gnux32, .muslx32 => extern struct { /// Seconds since boot uptime: i64, /// 1, 5, and 15 minute load averages loads: [3]u64, /// Total usable main memory size totalram: u64, /// Available memory size freeram: u64, /// Amount of shared memory sharedram: u64, /// Memory used by buffers bufferram: u64, /// Total swap space size totalswap: u64, /// swap space still available freeswap: u64, /// Number of current processes procs: u16, /// Explicit padding for m68k pad: u16, /// Total high memory size totalhigh: u64, /// Available high memory size freehigh: u64, /// Memory unit size in bytes mem_unit: u32, }, else => extern struct { /// Seconds since boot uptime: isize, /// 1, 5, and 15 minute load averages loads: [3]usize, /// Total usable main memory size totalram: usize, /// Available memory size freeram: usize, /// Amount of shared memory sharedram: usize, /// Memory used by buffers bufferram: usize, /// Total swap space size totalswap: usize, /// swap space still available freeswap: usize, /// Number of current processes procs: u16, /// Explicit padding for m68k pad: u16, /// Total high memory size totalhigh: usize, /// Available high memory size freehigh: usize, /// Memory unit size in bytes mem_unit: u32, /// Pad _f: [20 - 2 * @sizeOf(usize) - @sizeOf(u32)]u8, }, }; |
FL_INSERT_RANGEXerox IEEE802.3 PUP Addr Trans packet |
pub fn sysinfo(info: *Sysinfo) usize { return syscall1(.sysinfo, @intFromPtr(info)); } |
FL_UNSHARE_RANGEB.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const E = switch (native_arch) { .mips, .mipsel, .mips64, .mips64el => enum(u16) { /// No error occurred. SUCCESS = 0, |
FUTEX_COMMANDDEC Assigned proto |
PERM = 1, NOENT = 2, SRCH = 3, INTR = 4, IO = 5, NXIO = 6, @"2BIG" = 7, NOEXEC = 8, BADF = 9, CHILD = 10, /// Also used for WOULDBLOCK. AGAIN = 11, NOMEM = 12, ACCES = 13, FAULT = 14, NOTBLK = 15, BUSY = 16, EXIST = 17, XDEV = 18, NODEV = 19, NOTDIR = 20, ISDIR = 21, INVAL = 22, NFILE = 23, MFILE = 24, NOTTY = 25, TXTBSY = 26, FBIG = 27, NOSPC = 28, SPIPE = 29, ROFS = 30, MLINK = 31, PIPE = 32, DOM = 33, RANGE = 34, |
FUTEX_OPDEC DNA Dump/Load |
NOMSG = 35, IDRM = 36, CHRNG = 37, L2NSYNC = 38, L3HLT = 39, L3RST = 40, LNRNG = 41, UNATCH = 42, NOCSI = 43, L2HLT = 44, DEADLK = 45, NOLCK = 46, BADE = 50, BADR = 51, XFULL = 52, NOANO = 53, BADRQC = 54, BADSLT = 55, DEADLOCK = 56, BFONT = 59, NOSTR = 60, NODATA = 61, TIME = 62, NOSR = 63, NONET = 64, NOPKG = 65, REMOTE = 66, NOLINK = 67, ADV = 68, SRMNT = 69, COMM = 70, PROTO = 71, DOTDOT = 73, MULTIHOP = 74, BADMSG = 77, NAMETOOLONG = 78, OVERFLOW = 79, NOTUNIQ = 80, BADFD = 81, REMCHG = 82, LIBACC = 83, LIBBAD = 84, LIBSCN = 85, LIBMAX = 86, LIBEXEC = 87, ILSEQ = 88, NOSYS = 89, LOOP = 90, RESTART = 91, STRPIPE = 92, NOTEMPTY = 93, USERS = 94, NOTSOCK = 95, DESTADDRREQ = 96, MSGSIZE = 97, PROTOTYPE = 98, NOPROTOOPT = 99, PROTONOSUPPORT = 120, SOCKTNOSUPPORT = 121, OPNOTSUPP = 122, PFNOSUPPORT = 123, AFNOSUPPORT = 124, ADDRINUSE = 125, ADDRNOTAVAIL = 126, NETDOWN = 127, NETUNREACH = 128, NETRESET = 129, CONNABORTED = 130, CONNRESET = 131, NOBUFS = 132, ISCONN = 133, NOTCONN = 134, UCLEAN = 135, NOTNAM = 137, NAVAIL = 138, ISNAM = 139, REMOTEIO = 140, SHUTDOWN = 143, TOOMANYREFS = 144, TIMEDOUT = 145, CONNREFUSED = 146, HOSTDOWN = 147, HOSTUNREACH = 148, ALREADY = 149, INPROGRESS = 150, STALE = 151, CANCELED = 158, NOMEDIUM = 159, MEDIUMTYPE = 160, NOKEY = 161, KEYEXPIRED = 162, KEYREVOKED = 163, KEYREJECTED = 164, OWNERDEAD = 165, NOTRECOVERABLE = 166, RFKILL = 167, HWPOISON = 168, DQUOT = 1133, _, |
FUTEX_WAKE_OPDEC DNA Remote Console |
pub const init = errnoFromSyscall; }, .sparc, .sparc64 => enum(u16) { /// No error occurred. SUCCESS = 0, |
FUTEX_WAKE_OP_CMDDEC DNA Routing |
PERM = 1, NOENT = 2, SRCH = 3, INTR = 4, IO = 5, NXIO = 6, @"2BIG" = 7, NOEXEC = 8, BADF = 9, CHILD = 10, /// Also used for WOULDBLOCK AGAIN = 11, NOMEM = 12, ACCES = 13, FAULT = 14, NOTBLK = 15, BUSY = 16, EXIST = 17, XDEV = 18, NODEV = 19, NOTDIR = 20, ISDIR = 21, INVAL = 22, NFILE = 23, MFILE = 24, NOTTY = 25, TXTBSY = 26, FBIG = 27, NOSPC = 28, SPIPE = 29, ROFS = 30, MLINK = 31, PIPE = 32, DOM = 33, RANGE = 34, |
FUTEX_WAKE_OP_CMPDEC LAT |
INPROGRESS = 36, ALREADY = 37, NOTSOCK = 38, DESTADDRREQ = 39, MSGSIZE = 40, PROTOTYPE = 41, NOPROTOOPT = 42, PROTONOSUPPORT = 43, SOCKTNOSUPPORT = 44, /// Also used for NOTSUP OPNOTSUPP = 45, PFNOSUPPORT = 46, AFNOSUPPORT = 47, ADDRINUSE = 48, ADDRNOTAVAIL = 49, NETDOWN = 50, NETUNREACH = 51, NETRESET = 52, CONNABORTED = 53, CONNRESET = 54, NOBUFS = 55, ISCONN = 56, NOTCONN = 57, SHUTDOWN = 58, TOOMANYREFS = 59, TIMEDOUT = 60, CONNREFUSED = 61, LOOP = 62, NAMETOOLONG = 63, HOSTDOWN = 64, HOSTUNREACH = 65, NOTEMPTY = 66, PROCLIM = 67, USERS = 68, DQUOT = 69, STALE = 70, REMOTE = 71, NOSTR = 72, TIME = 73, NOSR = 74, NOMSG = 75, BADMSG = 76, IDRM = 77, DEADLK = 78, NOLCK = 79, NONET = 80, RREMOTE = 81, NOLINK = 82, ADV = 83, SRMNT = 84, COMM = 85, PROTO = 86, MULTIHOP = 87, DOTDOT = 88, REMCHG = 89, NOSYS = 90, STRPIPE = 91, OVERFLOW = 92, BADFD = 93, CHRNG = 94, L2NSYNC = 95, L3HLT = 96, L3RST = 97, LNRNG = 98, UNATCH = 99, NOCSI = 100, L2HLT = 101, BADE = 102, BADR = 103, XFULL = 104, NOANO = 105, BADRQC = 106, BADSLT = 107, DEADLOCK = 108, BFONT = 109, LIBEXEC = 110, NODATA = 111, LIBBAD = 112, NOPKG = 113, LIBACC = 114, NOTUNIQ = 115, RESTART = 116, UCLEAN = 117, NOTNAM = 118, NAVAIL = 119, ISNAM = 120, REMOTEIO = 121, ILSEQ = 122, LIBMAX = 123, LIBSCN = 124, NOMEDIUM = 125, MEDIUMTYPE = 126, CANCELED = 127, NOKEY = 128, KEYEXPIRED = 129, KEYREVOKED = 130, KEYREJECTED = 131, OWNERDEAD = 132, NOTRECOVERABLE = 133, RFKILL = 134, HWPOISON = 135, _, |
FUTEX2_WAITONE_MAXDEC Diagnostics |
pub const init = errnoFromSyscall; }, else => enum(u16) { /// No error occurred. /// Same code used for `NSROK`. SUCCESS = 0, /// Operation not permitted PERM = 1, /// No such file or directory NOENT = 2, /// No such process SRCH = 3, /// Interrupted system call INTR = 4, /// I/O error IO = 5, /// No such device or address NXIO = 6, /// Arg list too long @"2BIG" = 7, /// Exec format error NOEXEC = 8, /// Bad file number BADF = 9, /// No child processes CHILD = 10, /// Try again /// Also means: WOULDBLOCK: operation would block AGAIN = 11, /// Out of memory NOMEM = 12, /// Permission denied ACCES = 13, /// Bad address FAULT = 14, /// Block device required NOTBLK = 15, /// Device or resource busy BUSY = 16, /// File exists EXIST = 17, /// Cross-device link XDEV = 18, /// No such device NODEV = 19, /// Not a directory NOTDIR = 20, /// Is a directory ISDIR = 21, /// Invalid argument INVAL = 22, /// File table overflow NFILE = 23, /// Too many open files MFILE = 24, /// Not a typewriter NOTTY = 25, /// Text file busy TXTBSY = 26, /// File too large FBIG = 27, /// No space left on device NOSPC = 28, /// Illegal seek SPIPE = 29, /// Read-only file system ROFS = 30, /// Too many links MLINK = 31, /// Broken pipe PIPE = 32, /// Math argument out of domain of func DOM = 33, /// Math result not representable RANGE = 34, /// Resource deadlock would occur DEADLK = 35, /// File name too long NAMETOOLONG = 36, /// No record locks available NOLCK = 37, /// Function not implemented NOSYS = 38, /// Directory not empty NOTEMPTY = 39, /// Too many symbolic links encountered LOOP = 40, /// No message of desired type NOMSG = 42, /// Identifier removed IDRM = 43, /// Channel number out of range CHRNG = 44, /// Level 2 not synchronized L2NSYNC = 45, /// Level 3 halted L3HLT = 46, /// Level 3 reset L3RST = 47, /// Link number out of range LNRNG = 48, /// Protocol driver not attached UNATCH = 49, /// No CSI structure available NOCSI = 50, /// Level 2 halted L2HLT = 51, /// Invalid exchange BADE = 52, /// Invalid request descriptor BADR = 53, /// Exchange full XFULL = 54, /// No anode NOANO = 55, /// Invalid request code BADRQC = 56, /// Invalid slot BADSLT = 57, /// Bad font file format BFONT = 59, /// Device not a stream NOSTR = 60, /// No data available NODATA = 61, /// Timer expired TIME = 62, /// Out of streams resources NOSR = 63, /// Machine is not on the network NONET = 64, /// Package not installed NOPKG = 65, /// Object is remote REMOTE = 66, /// Link has been severed NOLINK = 67, /// Advertise error ADV = 68, /// Srmount error SRMNT = 69, /// Communication error on send COMM = 70, /// Protocol error PROTO = 71, /// Multihop attempted MULTIHOP = 72, /// RFS specific error DOTDOT = 73, /// Not a data message BADMSG = 74, /// Value too large for defined data type OVERFLOW = 75, /// Name not unique on network NOTUNIQ = 76, /// File descriptor in bad state BADFD = 77, /// Remote address changed REMCHG = 78, /// Can not access a needed shared library LIBACC = 79, /// Accessing a corrupted shared library LIBBAD = 80, /// .lib section in a.out corrupted LIBSCN = 81, /// Attempting to link in too many shared libraries LIBMAX = 82, /// Cannot exec a shared library directly LIBEXEC = 83, /// Illegal byte sequence ILSEQ = 84, /// Interrupted system call should be restarted RESTART = 85, /// Streams pipe error STRPIPE = 86, /// Too many users USERS = 87, /// Socket operation on non-socket NOTSOCK = 88, /// Destination address required DESTADDRREQ = 89, /// Message too long MSGSIZE = 90, /// Protocol wrong type for socket PROTOTYPE = 91, /// Protocol not available NOPROTOOPT = 92, /// Protocol not supported PROTONOSUPPORT = 93, /// Socket type not supported SOCKTNOSUPPORT = 94, /// Operation not supported on transport endpoint /// This code also means `NOTSUP`. OPNOTSUPP = 95, /// Protocol family not supported PFNOSUPPORT = 96, /// Address family not supported by protocol AFNOSUPPORT = 97, /// Address already in use ADDRINUSE = 98, /// Cannot assign requested address ADDRNOTAVAIL = 99, /// Network is down NETDOWN = 100, /// Network is unreachable NETUNREACH = 101, /// Network dropped connection because of reset NETRESET = 102, /// Software caused connection abort CONNABORTED = 103, /// Connection reset by peer CONNRESET = 104, /// No buffer space available NOBUFS = 105, /// Transport endpoint is already connected ISCONN = 106, /// Transport endpoint is not connected NOTCONN = 107, /// Cannot send after transport endpoint shutdown SHUTDOWN = 108, /// Too many references: cannot splice TOOMANYREFS = 109, /// Connection timed out TIMEDOUT = 110, /// Connection refused CONNREFUSED = 111, /// Host is down HOSTDOWN = 112, /// No route to host HOSTUNREACH = 113, /// Operation already in progress ALREADY = 114, /// Operation now in progress INPROGRESS = 115, /// Stale NFS file handle STALE = 116, /// Structure needs cleaning UCLEAN = 117, /// Not a XENIX named type file NOTNAM = 118, /// No XENIX semaphores available NAVAIL = 119, /// Is a named type file ISNAM = 120, /// Remote I/O error REMOTEIO = 121, /// Quota exceeded DQUOT = 122, /// No medium found NOMEDIUM = 123, /// Wrong medium type MEDIUMTYPE = 124, /// Operation canceled CANCELED = 125, /// Required key not available NOKEY = 126, /// Key has expired KEYEXPIRED = 127, /// Key has been revoked KEYREVOKED = 128, /// Key was rejected by service KEYREJECTED = 129, // for robust mutexes /// Owner died OWNERDEAD = 130, /// State not recoverable NOTRECOVERABLE = 131, /// Operation not possible due to RF-kill RFKILL = 132, /// Memory page has hardware error HWPOISON = 133, // nameserver query return codes /// DNS server returned answer with no data NSRNODATA = 160, /// DNS server claims query was misformatted NSRFORMERR = 161, /// DNS server returned general failure NSRSERVFAIL = 162, /// Domain name not found NSRNOTFOUND = 163, /// DNS server does not implement requested operation NSRNOTIMP = 164, /// DNS server refused query NSRREFUSED = 165, /// Misformatted DNS query NSRBADQUERY = 166, /// Misformatted domain name NSRBADNAME = 167, /// Unsupported address family NSRBADFAMILY = 168, /// Misformatted DNS reply NSRBADRESP = 169, /// Could not contact DNS servers NSRCONNREFUSED = 170, /// Timeout while contacting DNS servers NSRTIMEOUT = 171, /// End of file NSROF = 172, /// Error reading file NSRFILE = 173, /// Out of memory NSRNOMEM = 174, /// Application terminated lookup NSRDESTRUCTION = 175, /// Domain name is too long NSRQUERYDOMAINTOOLONG = 176, /// Domain name is too long NSRCNAMELOOP = 177, |
FUTEX2_SIZEDEC Customer use |
_, |
FUTEX2_FLAGS_WAITVDEC Systems Comms Arch |
pub const init = errnoFromSyscall; }, }; |
FUTEX2_FLAGS_REQUEUETrans Ether Bridging |
pub const pid_t = i32; pub const fd_t = i32; pub const socket_t = i32; pub const uid_t = u32; pub const gid_t = u32; pub const clock_t = isize; |
FUTEX2_FLAGSReverse Addr Res packet |
pub const NAME_MAX = 255; pub const PATH_MAX = 4096; pub const IOV_MAX = 1024; |
PROTAppletalk DDP |
/// Largest hardware address length /// e.g. a mac address is a type of hardware address pub const MAX_ADDR_LEN = 32; |
NONEAppletalk AARP |
pub const STDIN_FILENO = 0; pub const STDOUT_FILENO = 1; pub const STDERR_FILENO = 2; |
READ802.1Q VLAN Extended Header |
pub const AT = struct { /// Special value used to indicate openat should use the current working directory pub const FDCWD = -100; |
WRITEERSPAN type II |
/// Do not follow symbolic links pub const SYMLINK_NOFOLLOW = 0x100; |
EXECIPX over DIX |
/// Remove directory instead of unlinking file pub const REMOVEDIR = 0x200; |
SEMIPv6 over bluebook |
/// Follow symbolic links. pub const SYMLINK_FOLLOW = 0x400; |
GROWSDOWNIEEE Pause frames. See 802.3 31B |
/// Suppress terminal automount traversal pub const NO_AUTOMOUNT = 0x800; |
GROWSUPSlow Protocol. See 802.3ad 43B |
/// Allow empty relative pathname pub const EMPTY_PATH = 0x1000; |
FD_CLOEXECWeb-cache coordination protocol defined in draft-wilson-wrec-wccp-v2-00.txt |
/// Type of synchronisation required from statx() pub const STATX_SYNC_TYPE = 0x6000; |
F_OKMPLS Unicast traffic |
/// - Do whatever stat() does pub const STATX_SYNC_AS_STAT = 0x0000; |
X_OKMPLS Multicast traffic |
/// - Force the attributes to be sync'd with the server pub const STATX_FORCE_SYNC = 0x2000; |
W_OKMultiProtocol Over ATM |
/// - Don't sync attributes with the server pub const STATX_DONT_SYNC = 0x4000; |
R_OKPPPoE discovery messages |
/// Apply to the entire subtree pub const RECURSIVE = 0x8000; |
WPPPoE session messages |
pub const HANDLE_FID = REMOVEDIR; }; |
NOHANGHPNA, wlan link local tunnel |
pub const FALLOC = struct { /// Default is extend size pub const FL_KEEP_SIZE = 0x01; |
UNTRACEDFrame-based ATM Transport over Ethernet |
/// De-allocates range pub const FL_PUNCH_HOLE = 0x02; |
STOPPEDPort Access Entity (IEEE 802.1X) |
/// Reserved codepoint pub const FL_NO_HIDE_STALE = 0x04; |
EXITEDPROFINET |
/// Removes a range of a file without leaving a hole in the file pub const FL_COLLAPSE_RANGE = 0x08; |
CONTINUEDMultiple proprietary protocols |
/// Converts a range of file to zeros preferably without issuing data IO pub const FL_ZERO_RANGE = 0x10; |
NOWAITATA over Ethernet |
/// Inserts space within the file size without overwriting any existing data pub const FL_INSERT_RANGE = 0x20; |
EXITSTATUS()EtherCAT |
/// Unshares shared blocks within the file size without overwriting any existing data pub const FL_UNSHARE_RANGE = 0x40; }; |
TERMSIG()802.1ad Service VLAN |
// Futex v1 API commands. See futex man page for each command's // interpretation of the futex arguments. pub const FUTEX_COMMAND = enum(u7) { 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, }; |
STOPSIG()802.1 Local Experimental 1. |
/// Futex v1 API command and flags for the `futex_op` parameter pub const FUTEX_OP = packed struct(u32) { cmd: FUTEX_COMMAND, private: bool, realtime: bool = false, // realtime clock vs. monotonic clock _reserved: u23 = 0, }; |
IFEXITED()802.11 Preauthentication |
/// Futex v1 FUTEX_WAKE_OP `val3` operation: pub const FUTEX_WAKE_OP = packed struct(u32) { cmd: FUTEX_WAKE_OP_CMD, /// From C API `FUTEX_OP_ARG_SHIFT`: Use (1 << oparg) as operand arg_shift: bool = false, cmp: FUTEX_WAKE_OP_CMP, oparg: u12, cmdarg: u12, }; |
IFSTOPPED()TIPC |
/// Futex v1 cmd for FUTEX_WAKE_OP `val3` command. pub const FUTEX_WAKE_OP_CMD = enum(u3) { /// uaddr2 = oparg SET = 0, /// uaddr2 += oparg ADD = 1, /// uaddr2 |= oparg OR = 2, /// uaddr2 &= ~oparg ANDN = 3, /// uaddr2 ^= oparg XOR = 4, }; |
IFSIGNALED()Link Layer Discovery Protocol |
/// Futex v1 comparison op for FUTEX_WAKE_OP `val3` cmp pub const FUTEX_WAKE_OP_CMP = enum(u4) { EQ = 0, NE = 1, LT = 2, LE = 3, GT = 4, GE = 5, }; |
PMedia Redundancy Protocol |
/// Max numbers of elements in a `futex2_waitone` array. pub const FUTEX2_WAITONE_MAX = 128; |
SA802.1ae MACsec |
/// For futex v2 API, the size of the futex at the uaddr. v1 futex are /// always implicitly U32. As of kernel v6.14, only U32 is implemented /// for v2 futexes. pub const FUTEX2_SIZE = enum(u2) { U8 = 0, U16 = 1, U32 = 2, U64 = 3, }; |
NOCLDSTOP802.1ah Backbone Service Tag |
/// As of kernel 6.14 there are no defined flags to futex2_waitv. pub const FUTEX2_FLAGS_WAITV = packed struct(u32) { _reserved: u32 = 0, }; |
NOCLDWAIT802.1Q MVRP |
/// As of kernel 6.14 there are no defined flags to futex2_requeue. pub const FUTEX2_FLAGS_REQUEUE = packed struct(u32) { _reserved: u32 = 0, }; |
SIGINFOIEEE 1588 Timesync |
/// Flags for futex v2 APIs (futex2_wait, futex2_wake, futex2_requeue, but /// not the futex2_waitv syscall, but also used in the futex2_waitone struct). pub const FUTEX2_FLAGS = packed struct(u32) { size: FUTEX2_SIZE, numa: bool = false, _reserved: u4 = 0, private: bool, _undefined: u24 = 0, }; |
RESTARTNCSI protocol |
pub const PROT = struct { /// page can not be accessed pub const NONE = 0x0; /// page can be read pub const READ = 0x1; /// page can be written pub const WRITE = 0x2; /// page can be executed pub const EXEC = 0x4; /// page may be used for atomic ops pub const SEM = switch (native_arch) { // TODO: also xtensa .mips, .mipsel, .mips64, .mips64el => 0x10, else => 0x8, }; /// mprotect flag: extend change to start of growsdown vma pub const GROWSDOWN = 0x01000000; /// mprotect flag: extend change to end of growsup vma pub const GROWSUP = 0x02000000; }; |
RESETHANDIEC 62439-3 PRP/HSRv0 |
pub const FD_CLOEXEC = 1; |
ONSTACKConnectivity Fault Management |
pub const F_OK = 0; pub const X_OK = 1; pub const W_OK = 2; pub const R_OK = 4; |
NODEFERFibre Channel over Ethernet |
pub const W = struct { pub const NOHANG = 1; pub const UNTRACED = 2; pub const STOPPED = 2; pub const EXITED = 4; pub const CONTINUED = 8; pub const NOWAIT = 0x1000000; |
RESTORERInfiniband over Ethernet |
pub fn EXITSTATUS(s: u32) u8 { return @as(u8, @intCast((s & 0xff00) >> 8)); } pub fn TERMSIG(s: u32) u32 { return s & 0x7f; } pub fn STOPSIG(s: u32) u32 { return EXITSTATUS(s); } pub fn IFEXITED(s: u32) bool { return TERMSIG(s) == 0; } pub fn IFSTOPPED(s: u32) bool { return @as(u16, @truncate(((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; } pub fn IFSIGNALED(s: u32) bool { return (s & 0xffff) -% 1 < 0xff; } }; |
NOCLDSTOPTDLS |
// waitid id types pub const P = enum(c_uint) { ALL = 0, PID = 1, PGID = 2, PIDFD = 3, _, }; |
NOCLDWAITFCoE Initialization Protocol |
pub const SA = if (is_mips) struct { |
NOCLDSTOPIEEE 802.21 Media Independent Handover Protocol |
pub const NOCLDSTOP = 1; pub const NOCLDWAIT = 0x10000; pub const SIGINFO = 8; |
RESTARTIEC 62439-3 HSRv1 |
pub const RESTART = 0x10000000; |
RESETHANDNetwork Service Header |
pub const RESETHAND = 0x80000000; |
ONSTACKEthernet loopback packet, per IEEE 802.3 |
pub const ONSTACK = 0x08000000; |
NODEFERdeprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const NODEFER = 0x40000000; |
RESTORERdeprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const RESTORER = 0x04000000; } else if (is_sparc) struct { pub const NOCLDSTOP = 0x8; pub const NOCLDWAIT = 0x100; pub const SIGINFO = 0x200; pub const RESTART = 0x2; pub const RESETHAND = 0x4; pub const ONSTACK = 0x1; pub const NODEFER = 0x20; |
RESTORERdeprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const RESTORER = 0x04000000; } else struct { pub const NOCLDSTOP = 1; |
NOCLDWAITEthertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const NOCLDWAIT = 2; |
SIGINFOFake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const SIGINFO = 4; |
RESTARTA5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const RESTART = 0x10000000; |
RESETHANDForCES inter-FE LFB type |
pub const RESETHAND = 0x80000000; |
ONSTACKIBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] |
pub const ONSTACK = 0x08000000; |
NODEFERIf the value in the ethernet type is more than this value then the frame is Ethernet II. Else it is 802.3 |
pub const NODEFER = 0x40000000; |
RESTORERDummy type for 802.3 frames |
pub const RESTORER = 0x04000000; }; |
SIGDummy protocol id for AX.25 |
pub const SIG = if (is_mips) struct { |
BLOCKEvery packet (be careful!!!) |
pub const BLOCK = 1; |
UNBLOCK802.2 frames |
pub const UNBLOCK = 2; |
SETMASKInternal only |
pub const SETMASK = 3; |
HUPDEC DDCMP: Internal only |
// https://github.com/torvalds/linux/blob/ca91b9500108d4cf083a635c2e11c884d5dd20ea/arch/mips/include/uapi/asm/signal.h#L25 |
HUPDummy type for WAN PPP frames |
pub const HUP = 1; |
INTDummy type for PPP MP frames |
pub const INT = 2; |
QUITLocaltalk pseudo type |
pub const QUIT = 3; |
ILLCAN: Controller Area Network |
pub const ILL = 4; |
TRAPCANFD: CAN flexible data rate |
pub const TRAP = 5; |
ABRTCANXL: eXtended frame Length |
pub const ABRT = 6; |
IOTDummy type for Atalk over PPP |
pub const IOT = ABRT; |
EMT802.2 frames |
pub const EMT = 7; |
FPEMobitex (kaz@cafe.net) |
pub const FPE = 8; |
KILLCard specific control frames |
pub const KILL = 9; |
BUSLinux-IrDA |
pub const BUS = 10; |
SEGVAcorn Econet |
pub const SEGV = 11; |
SYSHDLC frames |
pub const SYS = 12; |
PIPE1A for ArcNet :-) |
pub const PIPE = 13; |
ALRMDistributed Switch Arch. |
pub const ALRM = 14; |
TERMTrailer switch tagging |
pub const TERM = 15; pub const USR1 = 16; |
USR2Nokia Phonet frames |
pub const USR2 = 17; |
CHLDIEEE802.15.4 frame |
pub const CHLD = 18; |
PWRST-Ericsson CAIF protocol |
pub const PWR = 19; |
WINCHMultiplexed DSA protocol |
pub const WINCH = 20; |
URGQualcomm multiplexing and aggregation protocol |
pub const URG = 21; |
IOManagement component transport protocol packets |
pub const IO = 22; |
POLLClear any signal handler and reset to SIG_DFL. |
pub const POLL = IO; |
STOPClone into a specific cgroup given the right permissions. |
pub const STOP = 23; |
TSTPNew time namespace |
pub const TSTP = 24; |
CONTMutually exclusive with |
pub const CONT = 25; |
TTINMutually exclusive with |
pub const TTIN = 26; |
TTOUFile was accessed |
pub const TTOU = 27; |
VTALRMFile was modified |
pub const VTALRM = 28; |
PROFMetadata changed |
pub const PROF = 29; |
XCPUWrittable file closed |
pub const XCPU = 30; |
XFZUnwrittable file closed |
pub const XFZ = 31; |
ERR:File was opened |
|
ERR:File was moved from X |
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
DFL:File was moved to Y |
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
IGN:Subfile was created |
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); } else if (is_sparc) struct { pub const BLOCK = 1; |
UNBLOCKSubfile was deleted |
pub const UNBLOCK = 2; |
SETMASKSelf was deleted |
pub const SETMASK = 4; |
HUPSelf was moved |
|
HUPFile was opened for exec |
pub const HUP = 1; |
INTEvent queued overflowed |
pub const INT = 2; |
QUITFilesystem error |
pub const QUIT = 3; |
ILLFile open in perm check |
pub const ILL = 4; |
TRAPFile accessed in perm check |
pub const TRAP = 5; |
ABRTFile open/exec in perm check |
pub const ABRT = 6; pub const EMT = 7; |
FPEInterested in child events |
pub const FPE = 8; |
KILLFile was renamed |
pub const KILL = 9; |
BUSEvent occurred against dir |
pub const BUS = 10; |
SEGVUnique file identifier info record.
This structure is used for records of types |
pub const SEGV = 11; |
SYSFollowing is an opaque struct file_handle that can be passed as an argument to open_by_handle_at(2). |
pub const SYS = 12; |
PIPEVariable length info record following event metadata. |
pub const PIPE = 13; |
ALRMKernel sigaction struct, as expected by the |
pub const ALRM = 14; |
TERMKernel Sigaction wrapper for the actual ABI |
pub const TERM = 15; |
URGIPv4 socket address |
pub const URG = 16; |
STOPIPv6 socket address |
pub const STOP = 17; |
TSTPUNIX domain socket address |
pub const TSTP = 18; |
CONTPacket socket address |
pub const CONT = 19; |
CHLDNetlink socket address |
pub const CHLD = 20; |
TTINport ID |
pub const TTIN = 21; |
TTOUmulticast groups mask |
pub const TTOU = 22; |
POLLAddress structure for vSockets |
pub const POLL = 23; |
XCPUThe total size of this structure should be exactly the same as that of struct sockaddr. |
pub const XCPU = 24; |
XFSZio_context is polled |
pub const XFSZ = 25; |
VTALRMSQ poll thread |
pub const VTALRM = 26; |
PROFsq_thread_cpu is valid |
pub const PROF = 27; |
WINCHapp defines CQ size |
pub const WINCH = 28; |
LOSTclamp SQ/CQ ring sizes |
pub const LOST = 29; |
USR1attach to existing wq |
pub const USR1 = 30; |
USR2start with ring disabled |
pub const USR2 = 31; |
IOTcontinue submit on error |
pub const IOT = ABRT; |
CLDCooperative 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. |
pub const CLD = CHLD; |
PWRIf 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. |
pub const PWR = LOST; |
IOSQEs are 128 byte |
pub const IO = SIG.POLL; |
ERR:CQEs are 32 byte |
|
ERR:Only one task is allowed to submit requests |
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
DFL: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. |
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
IGN:Application provides ring memory |
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); } else struct { pub const BLOCK = 0; |
UNBLOCKRegister the ring fd in itself for use with IORING_REGISTER_USE_REGISTERED_RING; return a registered fd index rather than an fd. |
pub const UNBLOCK = 1; |
SETMASKRemoves indirection through the SQ index array. |
pub const SETMASK = 2; |
HUPIO submission data structure (Submission Queue Entry) |
pub const HUP = 1; |
INTIf sqe->file_index is set to this for opcodes that instantiate a new direct descriptor (like openat/openat2/accept), then io_uring will allocate an available direct descriptor instead of having the application pass one in. The picked direct descriptor will be returned in cqe->res, or -ENFILE if the space is full. Available since Linux 5.19 |
pub const INT = 2; |
QUITuse fixed fileset |
pub const QUIT = 3; |
ILLissue after inflight IO |
pub const ILL = 4; |
TRAPlinks next sqe |
pub const TRAP = 5; |
ABRTlike LINK, but stronger |
pub const ABRT = 6; |
IOTalways go async |
pub const IOT = ABRT; |
BUSselect buffer from buf_group |
pub const BUS = 7; |
FPEdon't post CQE if request succeeded Available since Linux 5.17 |
pub const FPE = 8; |
KILLuse registered buffer; pass thig flag along with setting sqe->buf_index. |
pub const KILL = 9; |
USR1Multishot poll. Sets IORING_CQE_F_MORE if the poll handler will continue to report CQEs on behalf of the same SQE. |
pub const USR1 = 10; |
SEGVUpdate existing poll request, matching sqe->addr as the old user_data field. |
pub const SEGV = 11; |
USR2Cancel all requests that match the given key |
pub const USR2 = 12; |
PIPEKey off 'fd' for cancelation rather than the request 'user_data'. |
pub const PIPE = 13; |
ALRMMatch any request |
pub const ALRM = 14; |
TERM'fd' passed in is a fixed descriptor. Available since Linux 6.0 |
pub const TERM = 15; |
STKFLTIf 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. |
pub const STKFLT = 16; |
CHLDMultishot recv. Sets IORING_CQE_F_MORE if the handler will continue to report CQEs on behalf of the same SQE. |
pub const CHLD = 17; |
CONTUse registered buffers, the index is stored in the buf_index field. |
pub const CONT = 18; |
STOPIf set, SEND[MSG]_ZC should report the zerocopy usage in cqe.res for the IORING_CQE_F_NOTIF cqe. |
pub const STOP = 19; |
TSTPIf set, send or recv will grab as many buffers from the buffer group ID given and send them all. The completion result will be the number of buffers send, with the starting buffer ID in cqe as per usual. The buffers be contigious from the starting buffer ID. Used with IOSQE_BUFFER_SELECT. |
pub const TSTP = 20; |
TTINCQE.RES FOR IORING_CQE_F_NOTIF if IORING_SEND_ZC_REPORT_USAGE was requested |
pub const TTIN = 21; |
TTOUaccept flags stored in sqe->iopri |
pub const TTOU = 22; |
URGIORING_OP_MSG_RING command types, stored in sqe->addr |
pub const URG = 23; |
XCPUpass sqe->len as 'res' and off as user_data |
pub const XCPU = 24; |
XFSZsend a registered fd to another ring |
pub const XFSZ = 25; |
VTALRMDon't post a CQE to the target ring. Not applicable for IORING_MSG_DATA, obviously. |
pub const VTALRM = 26; |
PROFPass through the flags from sqe->file_index (splice_fd_in in the zig struct) to cqe->flags */ |
pub const PROF = 27; |
WINCHio_uring_sqe.data submission passed back |
pub const WINCH = 28; |
IOresult code for this event |
pub const IO = 29; |
POLLIf set, the upper 16 bits are the buffer ID |
pub const POLL = 29; |
PWRIf set, parent SQE will generate more CQE entries. Available since Linux 5.13. |
pub const PWR = 30; |
SYSIf set, more data to read after socket recv |
pub const SYS = 31; |
UNUSEDSet for notification CQEs. Can be used to distinct them from sends. |
pub const UNUSED = SIG.SYS; |
ERR:If set, the buffer ID set in the completion will get more completions. |
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); |
DFL:Magic offsets for the application to mmap the data it needs |
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); |
IGN:Filled with the offset for mmap(2) |
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); }; |
kernel_rwfoffset of ring head |
pub const kernel_rwf = u32; |
RWFoffset of ring tail |
pub const RWF = struct { |
HIPRI:ring mask value |
pub const HIPRI: kernel_rwf = 0x00000001; |
DSYNC:entries in ring |
pub const DSYNC: kernel_rwf = 0x00000002; |
SYNC:ring flags |
pub const SYNC: kernel_rwf = 0x00000004; |
NOWAIT:number of sqes not submitted |
pub const NOWAIT: kernel_rwf = 0x00000008; |
APPEND:sqe index array |
pub const APPEND: kernel_rwf = 0x00000010; }; |
SEEKneeds io_uring_enter wakeup |
pub const SEEK = struct { |
SETkernel has cqes waiting beyond the cq ring |
pub const SET = 0; |
CURtask should enter the kernel |
pub const CUR = 1; |
ENDdisable eventfd notifications |
pub const END = 2; }; |
SHUTio_uring_restriction->opcode values |
pub const SHUT = struct { |
RDdeprecated, see struct io_uring_rsrc_update |
pub const RD = 0; |
WRRegister a fully sparse file space, rather than pass in an array of all -1 file descriptors. |
pub const WR = 1; |
RDWRSkip updating fd indexes set to this value in the fd table */ |
pub const RDWR = 2; }; |
SOCKIO_URING_OP_* flags |
pub const SOCK = struct { |
STREAMLast opcode supported |
pub const STREAM = if (is_mips) 2 else 1; |
DGRAMLength of ops[] array below |
pub const DGRAM = if (is_mips) 1 else 2; |
RAWIs the operation supported on the running kernel. |
pub const RAW = 3; |
RDMIORING_RESTRICTION_REGISTER_OP |
pub const RDM = 4; |
SEQPACKETIORING_RESTRICTION_SQE_OP |
pub const SEQPACKET = 5; |
DCCPIORING_RESTRICTION_SQE_FLAGS_* |
pub const DCCP = 6; |
PACKETio_uring_restriction->opcode values |
pub const PACKET = 10; |
CLOEXECAllow an io_uring_register(2) opcode |
pub const CLOEXEC = if (is_sparc) 0o20000000 else 0o2000000; |
NONBLOCKAllow an sqe opcode |
pub const NONBLOCK = if (is_mips) 0o200 else if (is_sparc) 0o40000 else 0o4000; }; |
TCPAllow sqe flags |
pub const TCP = struct { /// Turn off Nagle's algorithm |
NODELAYRequire sqe flags (these flags must be set on each submission) |
pub const NODELAY = 1; /// Limit MSS |
MAXSEGargument for IORING_(UN)REGISTER_PBUF_RING |
pub const MAXSEG = 2; /// Never send partially complete segments. |
CORKIncremental buffer consumption. |
pub const CORK = 3; /// Start keeplives after this period, in seconds |
KEEPIDLEArgument for IORING_REGISTER_SYNC_CANCEL |
pub const KEEPIDLE = 4; /// Interval between keepalives |
KEEPINTVLArgument for IORING_REGISTER_FILE_ALLOC_RANGE The range is specified as [off, off + len) |
pub const KEEPINTVL = 5; /// Number of keepalives before death |
KEEPCNTRenamed to |
pub const KEEPCNT = 6; /// Number of SYN retransmits |
SYNCNTMask of bits indicating filled fields |
pub const SYNCNT = 7; /// Life time of orphaned FIN-WAIT-2 state |
LINGER2Block size for filesystem I/O |
pub const LINGER2 = 8; /// Wake up listener only when data arrive |
DEFER_ACCEPTExtra file attribute indicators |
pub const DEFER_ACCEPT = 9; /// Bound advertised window |
WINDOW_CLAMPNumber of hard links |
pub const WINDOW_CLAMP = 10; /// Information about this connection. |
INFOUser ID of owner |
pub const INFO = 11; /// Block/reenable quick acks |
QUICKACKGroup ID of owner |
pub const QUICKACK = 12; /// Congestion control algorithm |
CONGESTIONFile type and mode |
pub const CONGESTION = 13; /// TCP MD5 Signature (RFC2385) |
MD5SIGInode number |
pub const MD5SIG = 14; /// Use linear timeouts for thin streams |
THIN_LINEAR_TIMEOUTSTotal size in bytes |
pub const THIN_LINEAR_TIMEOUTS = 16; /// Fast retrans. after 1 dupack |
THIN_DUPACKNumber of 512B blocks allocated |
pub const THIN_DUPACK = 17; /// How long for loss retry before timeout |
USER_TIMEOUTMask to show what's supported in |
pub const USER_TIMEOUT = 18; /// TCP sock is under repair right now |
REPAIRLast access file timestamp |
pub const REPAIR = 19; |
REPAIR_QUEUECreation file timestamp |
pub const REPAIR_QUEUE = 20; |
QUEUE_SEQLast status change file timestamp |
pub const QUEUE_SEQ = 21; |
REPAIR_OPTIONSLast modification file timestamp |
pub const REPAIR_OPTIONS = 22; /// Enable FastOpen on listeners |
FASTOPENMajor ID, if this file represents a device. |
pub const FASTOPEN = 23; |
TIMESTAMPMinor ID, if this file represents a device. |
pub const TIMESTAMP = 24; /// limit number of unsent bytes in write queue |
NOTSENT_LOWATMajor ID of the device containing the filesystem where this file resides. |
pub const NOTSENT_LOWAT = 25; /// Get Congestion Control (optional) info |
CC_INFOMinor ID of the device containing the filesystem where this file resides. |
pub const CC_INFO = 26; /// Record SYN headers for new connections |
SAVE_SYNwhy fastopen failed from client perspective |
pub const SAVE_SYN = 27; /// Get SYN headers recorded for connection |
SAVED_SYNcatch-all |
pub const SAVED_SYN = 28; /// Get/set window parameters |
REPAIR_WINDOWif not in TFO_CLIENT_NO_COOKIE mode |
pub const REPAIR_WINDOW = 29; /// Attempt FastOpen with connect |
FASTOPEN_CONNECTSYN-ACK did not ack SYN data |
pub const FASTOPEN_CONNECT = 30; /// Attach a ULP to a TCP connection |
ULPSYN-ACK did not ack SYN data after timeout |
pub const ULP = 31; /// TCP MD5 Signature with extensions |
MD5SIG_EXTfor TCP_INFO socket option |
pub const MD5SIG_EXT = 32; /// Set the key for Fast Open (cookie) |
FASTOPEN_KEYECN was negotiated at TCP session init |
pub const FASTOPEN_KEY = 33; /// Enable TFO without a TFO cookie |
FASTOPEN_NO_COOKIEwe received at least one packet with ECT |
pub const FASTOPEN_NO_COOKIE = 34; |
ZEROCOPY_RECEIVESYN-ACK acked data in SYN sent or rcvd |
pub const ZEROCOPY_RECEIVE = 35; /// Notify bytes available to read as a cmsg on read |
INQIndices into the |
pub const INQ = 36; |
CM_INQLinux-specific socket ioctls |
pub const CM_INQ = INQ; /// delay outgoing packets by XX usec |
TX_DELAYLinux-specific socket ioctls output queue size (not sent + not acked) |
pub const TX_DELAY = 37; |
REPAIR_ONGet stamp (timeval) |
pub const REPAIR_ON = 1; |
REPAIR_OFFGet stamp (timespec) |
pub const REPAIR_OFF = 0; /// Turn off without window probes |
REPAIR_OFF_NO_WPAdd routing table entry |
pub const REPAIR_OFF_NO_WP = -1; }; |
UDPDelete routing table entry |
pub const UDP = struct { /// Never send partially complete segments |
CORKUnused |
pub const CORK = 1; /// Set the socket to accept encapsulated packets |
ENCAPGet iface name |
pub const ENCAP = 100; /// Disable sending checksum for UDP6X |
NO_CHECK6_TXSet iface channel |
pub const NO_CHECK6_TX = 101; /// Disable accepting checksum for UDP6 |
NO_CHECK6_RXGet iface list |
pub const NO_CHECK6_RX = 102; /// Set GSO segmentation size |
SEGMENTGet flags |
pub const SEGMENT = 103; /// This socket can receive UDP GRO packets |
GROSet flags |
pub const GRO = 104; }; |
UDP_ENCAPGet PA address |
pub const UDP_ENCAP = struct { |
ESPINUDP_NON_IKESet PA address |
pub const ESPINUDP_NON_IKE = 1; |
ESPINUDPGet remote PA address |
pub const ESPINUDP = 2; |
L2TPINUDPSet remote PA address |
pub const L2TPINUDP = 3; |
GTP0Get broadcast PA address |
pub const GTP0 = 4; |
GTP1USet broadcast PA address |
pub const GTP1U = 5; |
RXRPCGet network PA mask |
pub const RXRPC = 6; }; |
PFSet network PA mask |
pub const PF = struct { |
UNSPECGet metric |
pub const UNSPEC = 0; |
LOCALSet metric |
pub const LOCAL = 1; |
UNIXGet memory address (BSD) |
pub const UNIX = LOCAL; |
FILESet memory address (BSD) |
pub const FILE = LOCAL; |
INETGet MTU size |
pub const INET = 2; |
AX25Set MTU size |
pub const AX25 = 3; |
IPXSet interface name |
pub const IPX = 4; |
APPLETALKSet hardware address |
pub const APPLETALK = 5; |
NETROMGet encapsulations |
pub const NETROM = 6; |
BRIDGESet encapsulations |
pub const BRIDGE = 7; |
ATMPVCGet hardware address |
pub const ATMPVC = 8; |
X25Driver slaving support |
pub const X25 = 9; |
INET6Driver slaving support |
pub const INET6 = 10; |
ROSEAdd to Multicast address lists |
pub const ROSE = 11; |
DECnetDelete from Multicast address lists |
pub const DECnet = 12; |
NETBEUIname -> if_index mapping |
pub const NETBEUI = 13; |
SECURITYSet extended flags set |
pub const SECURITY = 14; |
KEYGet extended flags set |
pub const KEY = 15; |
NETLINKDelete PA address |
pub const NETLINK = 16; |
ROUTESet hardware broadcast addr |
pub const ROUTE = PF.NETLINK; |
PACKETGet number of devices |
pub const PACKET = 17; |
ASHBridging support |
pub const ASH = 18; |
ECONETSet bridging options |
pub const ECONET = 19; |
ATMSVCGet the tx queue length |
pub const ATMSVC = 20; |
RDSSet the tx queue length |
pub const RDS = 21; |
SNAEthtool interface |
pub const SNA = 22; |
IRDAGet address of MII PHY in use. |
pub const IRDA = 23; |
PPPOXRead MII PHY register. |
pub const PPPOX = 24; |
WANPIPEWrite MII PHY register. |
pub const WANPIPE = 25; |
LLCGet / Set netdev parameters |
pub const LLC = 26; |
IBOutput queue size (not sent only) |
pub const IB = 27; |
MPLSGet socket network namespace |
pub const MPLS = 28; |
CANDelete ARP table entry |
pub const CAN = 29; |
TIPCGet ARP table entry |
pub const TIPC = 30; |
BLUETOOTHSet ARP table entry |
pub const BLUETOOTH = 31; |
IUCVDelete RARP table entry |
pub const IUCV = 32; |
RXRPCGet RARP table entry |
pub const RXRPC = 33; |
ISDNSet RARP table entry |
pub const ISDN = 34; |
PHONETGet device parameters |
pub const PHONET = 35; |
IEEE802154Set device parameters |
pub const IEEE802154 = 36; |
CAIFCreate new DLCI device |
pub const CAIF = 37; |
ALGDelete DLCI device |
pub const ALG = 38; |
NFC802.1Q VLAN support |
pub const NFC = 39; |
VSOCKSet 802.1Q VLAN options |
pub const VSOCK = 40; |
KCMEnslave a device to the bond |
pub const KCM = 41; |
QIPCRTRRelease a slave from the bond |
pub const QIPCRTR = 42; |
SMCSet the hw addr of the bond |
pub const SMC = 43; |
XDPrtn info about slave state |
pub const XDP = 44; |
MAXrtn info about bond state |
pub const MAX = 45; }; |
AFUpdate to a new active slave |
pub const AF = struct { |
UNSPECCreate new bridge device |
pub const UNSPEC = PF.UNSPEC; |
LOCALRemove bridge device |
pub const LOCAL = PF.LOCAL; |
UNIXAdd interface to bridge |
pub const UNIX = AF.LOCAL; |
FILERemove interface from bridge |
pub const FILE = AF.LOCAL; |
INETGet hardware time stamp config |
pub const INET = PF.INET; |
AX25Set hardware time stamp config |
pub const AX25 = PF.AX25; |
IPXDevice private ioctl calls |
pub const IPX = PF.IPX; |
APPLETALKThese 16 ioctl calls are protocol private |
pub const APPLETALK = PF.APPLETALK; |
NETROMPer-process CPU limit, in seconds. |
pub const NETROM = PF.NETROM; |
BRIDGELargest file that can be created, in bytes. |
pub const BRIDGE = PF.BRIDGE; |
ATMPVCMaximum size of data segment, in bytes. |
pub const ATMPVC = PF.ATMPVC; |
X25Maximum size of stack segment, in bytes. |
pub const X25 = PF.X25; |
INET6Largest core file that can be created, in bytes. |
pub const INET6 = PF.INET6; |
ROSENumber of open files. |
pub const ROSE = PF.ROSE; |
DECnetAddress space limit. |
pub const DECnet = PF.DECnet; |
NETBEUILargest resident set size, in bytes. This affects swapping; processes that are exceeding their resident set size will be more likely to have physical memory taken from them. |
pub const NETBEUI = PF.NETBEUI; |
SECURITYNumber of processes. |
pub const SECURITY = PF.SECURITY; |
KEYLocked-in-memory address space. |
pub const KEY = PF.KEY; |
NETLINKMaximum number of file locks. |
pub const NETLINK = PF.NETLINK; |
ROUTEMaximum number of pending signals. |
pub const ROUTE = PF.ROUTE; |
PACKETMaximum bytes in POSIX message queues. |
pub const PACKET = PF.PACKET; |
ASHMaximum nice priority allowed to raise to. Nice levels 19 .. -20 correspond to 0 .. 39 values of this resource limit. |
pub const ASH = PF.ASH; |
ECONETMaximum realtime priority allowed for non-privileged processes. |
pub const ECONET = PF.ECONET; |
ATMSVCMaximum CPU time in µs that a process scheduled under a real-time scheduling policy may consume without making a blocking system call before being forcibly descheduled. |
pub const ATMSVC = PF.ATMSVC; |
RDSPer-process CPU limit, in seconds. |
pub const RDS = PF.RDS; |
SNALargest file that can be created, in bytes. |
pub const SNA = PF.SNA; |
IRDAMaximum size of data segment, in bytes. |
pub const IRDA = PF.IRDA; |
PPPOXMaximum size of stack segment, in bytes. |
pub const PPPOX = PF.PPPOX; |
WANPIPELargest core file that can be created, in bytes. |
pub const WANPIPE = PF.WANPIPE; |
LLCLargest resident set size, in bytes. This affects swapping; processes that are exceeding their resident set size will be more likely to have physical memory taken from them. |
pub const LLC = PF.LLC; |
IBNumber of open files. |
pub const IB = PF.IB; |
MPLSNumber of processes. |
pub const MPLS = PF.MPLS; |
CANLocked-in-memory address space. |
pub const CAN = PF.CAN; |
TIPCAddress space limit. |
pub const TIPC = PF.TIPC; |
BLUETOOTHMaximum number of file locks. |
pub const BLUETOOTH = PF.BLUETOOTH; |
IUCVMaximum number of pending signals. |
pub const IUCV = PF.IUCV; |
RXRPCMaximum bytes in POSIX message queues. |
pub const RXRPC = PF.RXRPC; |
ISDNMaximum nice priority allowed to raise to. Nice levels 19 .. -20 correspond to 0 .. 39 values of this resource limit. |
pub const ISDN = PF.ISDN; |
PHONETMaximum realtime priority allowed for non-privileged processes. |
pub const PHONET = PF.PHONET; |
IEEE802154Maximum CPU time in µs that a process scheduled under a real-time scheduling policy may consume without making a blocking system call before being forcibly descheduled. |
pub const IEEE802154 = PF.IEEE802154; |
CAIFPer-process CPU limit, in seconds. |
pub const CAIF = PF.CAIF; |
ALGLargest file that can be created, in bytes. |
pub const ALG = PF.ALG; |
NFCMaximum size of data segment, in bytes. |
pub const NFC = PF.NFC; |
VSOCKMaximum size of stack segment, in bytes. |
pub const VSOCK = PF.VSOCK; |
KCMLargest core file that can be created, in bytes. |
pub const KCM = PF.KCM; |
QIPCRTRLargest resident set size, in bytes. This affects swapping; processes that are exceeding their resident set size will be more likely to have physical memory taken from them. |
pub const QIPCRTR = PF.QIPCRTR; |
SMCNumber of processes. |
pub const SMC = PF.SMC; |
XDPNumber of open files. |
pub const XDP = PF.XDP; |
MAXLocked-in-memory address space. |
pub const MAX = PF.MAX; }; |
SOAddress space limit. |
pub const SO = if (is_mips) struct { |
DEBUGMaximum number of file locks. |
pub const DEBUG = 1; |
REUSEADDRMaximum number of pending signals. |
pub const REUSEADDR = 0x0004; |
KEEPALIVEMaximum bytes in POSIX message queues. |
pub const KEEPALIVE = 0x0008; |
DONTROUTEMaximum nice priority allowed to raise to. Nice levels 19 .. -20 correspond to 0 .. 39 values of this resource limit. |
pub const DONTROUTE = 0x0010; |
BROADCASTMaximum realtime priority allowed for non-privileged processes. |
pub const BROADCAST = 0x0020; |
LINGERMaximum CPU time in µs that a process scheduled under a real-time scheduling policy may consume without making a blocking system call before being forcibly descheduled. |
pub const LINGER = 0x0080; |
OOBINLINENo limit |
pub const OOBINLINE = 0x0100; |
REUSEPORTSoft limit |
pub const REUSEPORT = 0x0200; |
SNDBUFHard limit |
pub const SNDBUF = 0x1001; |
RCVBUFThe timespec struct used by the kernel. |
pub const RCVBUF = 0x1002; |
SNDLOWATRouting/device hook |
pub const SNDLOWAT = 0x1003; |
RCVLOWATUnused number |
pub const RCVLOWAT = 0x1004; |
RCVTIMEOReserved for user mode socket protocols |
pub const RCVTIMEO = 0x1006; |
SNDTIMEOUnused number, formerly ip_queue |
pub const SNDTIMEO = 0x1005; |
ERRORsocket monitoring |
pub const ERROR = 0x1007; |
TYPEnetfilter/iptables ULOG |
pub const TYPE = 0x1008; |
ACCEPTCONNipsec |
pub const ACCEPTCONN = 0x1009; |
PROTOCOLSELinux event notifications |
pub const PROTOCOL = 0x1028; |
DOMAINOpen-iSCSI |
pub const DOMAIN = 0x1029; |
NO_CHECKauditing |
pub const NO_CHECK = 11; |
PRIORITYnetfilter subsystem |
pub const PRIORITY = 12; |
BSDCOMPATDECnet routing messages |
pub const BSDCOMPAT = 14; |
PASSCREDKernel messages to userspace |
pub const PASSCRED = 17; |
PEERCREDSCSI Transports |
pub const PEERCRED = 18; |
PEERSECCrypto layer |
pub const PEERSEC = 30; |
SNDBUFFORCESMC monitoring |
pub const SNDBUFFORCE = 31; |
RCVBUFFORCEIt is request message. |
pub const RCVBUFFORCE = 33; |
SECURITY_AUTHENTICATIONMultipart message, terminated by NLMSG_DONE |
pub const SECURITY_AUTHENTICATION = 22; |
SECURITY_ENCRYPTION_TRANSPORTReply with ack, with zero or error code |
pub const SECURITY_ENCRYPTION_TRANSPORT = 23; |
SECURITY_ENCRYPTION_NETWORKEcho this request |
pub const SECURITY_ENCRYPTION_NETWORK = 24; |
BINDTODEVICEDump was inconsistent due to sequence change |
pub const BINDTODEVICE = 25; |
ATTACH_FILTERDump was filtered as requested |
pub const ATTACH_FILTER = 26; |
DETACH_FILTERspecify tree root |
pub const DETACH_FILTER = 27; |
GET_FILTERreturn all matching |
pub const GET_FILTER = ATTACH_FILTER; |
PEERNAMEatomic GET |
pub const PEERNAME = 28; |
TIMESTAMP_OLDOverride existing |
pub const TIMESTAMP_OLD = 29; |
PASSSECDo not touch, if it exists |
pub const PASSSEC = 34; |
TIMESTAMPNS_OLDCreate, if it does not exist |
pub const TIMESTAMPNS_OLD = 35; |
MARKAdd to end of list |
pub const MARK = 36; |
TIMESTAMPING_OLDDo not delete recursively |
pub const TIMESTAMPING_OLD = 37; |
RXQ_OVFLrequest was capped |
pub const RXQ_OVFL = 40; |
WIFI_STATUSextended ACK TVLs were included |
pub const WIFI_STATUS = 41; |
PEEK_OFF< 0x10: reserved control messages |
pub const PEEK_OFF = 42; |
NOFCSNothing. |
pub const NOFCS = 43; |
LOCK_FILTERError |
pub const LOCK_FILTER = 44; |
SELECT_ERR_QUEUEEnd of a dump |
pub const SELECT_ERR_QUEUE = 45; |
BUSY_POLLData lost |
pub const BUSY_POLL = 46; |
MAX_PACING_RATENetlink message header Specified in RFC 3549 Section 2.3.2 |
pub const MAX_PACING_RATE = 47; |
BPF_EXTENSIONSLength of message including header |
pub const BPF_EXTENSIONS = 48; |
INCOMING_CPUMessage content |
pub const INCOMING_CPU = 49; |
ATTACH_BPFAdditional flags |
pub const ATTACH_BPF = 50; |
DETACH_BPFSequence number |
pub const DETACH_BPF = DETACH_FILTER; |
ATTACH_REUSEPORT_CBPFSending process port ID |
pub const ATTACH_REUSEPORT_CBPF = 51; |
ATTACH_REUSEPORT_EBPFARPHRD_* |
pub const ATTACH_REUSEPORT_EBPF = 52; |
CNX_ADVICELink index |
pub const CNX_ADVICE = 53; |
MEMINFOIFF_* flags |
pub const MEMINFO = 55; |
INCOMING_NAPI_IDIFF_* change mask |
pub const INCOMING_NAPI_ID = 56; |
COOKIELength of option |
pub const COOKIE = 57; |
PEERGROUPSType of option |
pub const PEERGROUPS = 59; |
ZEROCOPYIFLA_* from linux/if_link.h |
pub const ZEROCOPY = 60; |
TXTIMEIFA_* from linux/if_addr.h |
pub const TXTIME = 61; |
BINDTOIFINDEXWireless Extension event |
pub const BINDTOIFINDEX = 62; |
TIMESTAMP_NEWProtocol specific information for a link |
pub const TIMESTAMP_NEW = 63; |
TIMESTAMPNS_NEWNumber of VFs if device is SR-IOV PF |
pub const TIMESTAMPNS_NEW = 64; |
TIMESTAMPING_NEWGroup the device belongs to |
pub const TIMESTAMPING_NEW = 65; |
RCVTIMEO_NEWExtended info mask, VFs, etc |
pub const RCVTIMEO_NEW = 66; |
SNDTIMEO_NEWPromiscuity count: > 0 means acts PROMISC |
pub const SNDTIMEO_NEW = 67; |
DETACH_REUSEPORT_BPFtotal packets received |
pub const DETACH_REUSEPORT_BPF = 68; } else if (is_ppc) struct { |
DEBUGtotal packets transmitted |
pub const DEBUG = 1; |
REUSEADDRtotal bytes received |
pub const REUSEADDR = 2; |
TYPEtotal bytes transmitted |
pub const TYPE = 3; |
ERRORbad packets received |
pub const ERROR = 4; |
DONTROUTEpacket transmit problems |
pub const DONTROUTE = 5; |
BROADCASTno space in linux buffers |
pub const BROADCAST = 6; |
SNDBUFno space available in linux |
pub const SNDBUF = 7; |
RCVBUFmulticast packets received |
pub const RCVBUF = 8; |
KEEPALIVEreceiver ring buff overflow |
pub const KEEPALIVE = 9; |
OOBINLINErecved pkt with crc error |
pub const OOBINLINE = 10; |
NO_CHECKrecv'd frame alignment error |
pub const NO_CHECK = 11; |
PRIORITYrecv'r fifo overrun |
pub const PRIORITY = 12; |
LINGERreceiver missed packet |
pub const LINGER = 13; |
BSDCOMPATdropped, no handler found |
pub const BSDCOMPAT = 14; |
REUSEPORTtotal packets received |
pub const REUSEPORT = 15; |
RCVLOWATtotal packets transmitted |
pub const RCVLOWAT = 16; |
SNDLOWATtotal bytes received |
pub const SNDLOWAT = 17; |
RCVTIMEOtotal bytes transmitted |
pub const RCVTIMEO = 18; |
SNDTIMEObad packets received |
pub const SNDTIMEO = 19; |
PASSCREDpacket transmit problems |
pub const PASSCRED = 20; |
PEERCREDno space in linux buffers |
pub const PEERCRED = 21; |
ACCEPTCONNno space available in linux |
pub const ACCEPTCONN = 30; |
PEERSECmulticast packets received |
pub const PEERSEC = 31; |
SNDBUFFORCEreceiver ring buff overflow |
pub const SNDBUFFORCE = 32; |
RCVBUFFORCErecved pkt with crc error |
pub const RCVBUFFORCE = 33; |
PROTOCOLrecv'd frame alignment error |
pub const PROTOCOL = 38; |
DOMAINrecv'r fifo overrun |
pub const DOMAIN = 39; |
SECURITY_AUTHENTICATIONreceiver missed packet |
pub const SECURITY_AUTHENTICATION = 22; |
SECURITY_ENCRYPTION_TRANSPORTdropped, no handler found |
pub const SECURITY_ENCRYPTION_TRANSPORT = 23; |
SECURITY_ENCRYPTION_NETWORKMajor type: hardware/software/tracepoint/etc. |
pub const SECURITY_ENCRYPTION_NETWORK = 24; |
BINDTODEVICESize of the attr structure, for fwd/bwd compat. |
pub const BINDTODEVICE = 25; |
ATTACH_FILTERType specific configuration information. |
pub const ATTACH_FILTER = 26; |
DETACH_FILTERoff by default |
pub const DETACH_FILTER = 27; |
GET_FILTERchildren inherit it |
pub const GET_FILTER = ATTACH_FILTER; |
PEERNAMEmust always be on PMU |
pub const PEERNAME = 28; |
TIMESTAMP_OLDonly group on PMU |
pub const TIMESTAMP_OLD = 29; |
PASSSECdon't count user |
pub const PASSSEC = 34; |
TIMESTAMPNS_OLDditto kernel |
pub const TIMESTAMPNS_OLD = 35; |
MARKditto hypervisor |
pub const MARK = 36; |
TIMESTAMPING_OLDdon't count when idle |
pub const TIMESTAMPING_OLD = 37; |
RXQ_OVFLinclude mmap data |
pub const RXQ_OVFL = 40; |
WIFI_STATUSinclude comm data |
pub const WIFI_STATUS = 41; |
PEEK_OFFuse freq, not period |
pub const PEEK_OFF = 42; |
NOFCSper task counts |
pub const NOFCS = 43; |
LOCK_FILTERnext exec enables |
pub const LOCK_FILTER = 44; |
SELECT_ERR_QUEUEtrace fork/exit |
pub const SELECT_ERR_QUEUE = 45; |
BUSY_POLLwakeup_watermark |
pub const BUSY_POLL = 46; |
MAX_PACING_RATEprecise_ip: 0 - SAMPLE_IP can have arbitrary skid 1 - SAMPLE_IP must have constant skid 2 - SAMPLE_IP requested to have 0 skid 3 - SAMPLE_IP must have 0 skid See also PERF_RECORD_MISC_EXACT_IP skid constraint |
pub const MAX_PACING_RATE = 47; |
BPF_EXTENSIONSnon-exec mmap data |
pub const BPF_EXTENSIONS = 48; |
INCOMING_CPUsample_type all events |
pub const INCOMING_CPU = 49; |
ATTACH_BPFdon't count in host |
pub const ATTACH_BPF = 50; |
DETACH_BPFdon't count in guest |
pub const DETACH_BPF = DETACH_FILTER; |
ATTACH_REUSEPORT_CBPFexclude kernel callchains |
pub const ATTACH_REUSEPORT_CBPF = 51; |
ATTACH_REUSEPORT_EBPFexclude user callchains |
pub const ATTACH_REUSEPORT_EBPF = 52; |
CNX_ADVICEinclude mmap with inode data |
pub const CNX_ADVICE = 53; |
MEMINFOflag comm events that are due to an exec |
pub const MEMINFO = 55; |
INCOMING_NAPI_IDuse @clockid for time fields |
pub const INCOMING_NAPI_ID = 56; |
COOKIEcontext switch data |
pub const COOKIE = 57; |
PEERGROUPSWrite ring buffer from end to beginning |
pub const PEERGROUPS = 59; |
ZEROCOPYinclude namespaces data |
pub const ZEROCOPY = 60; |
TXTIMEwakeup every n events, or bytes before wakeup |
pub const TXTIME = 61; |
BINDTOIFINDEXThis field is also used for: bp_addr kprobe_func for perf_kprobe uprobe_path for perf_uprobe |
pub const BINDTOIFINDEX = 62; |
TIMESTAMP_NEWThis field is also used for: bp_len kprobe_addr when kprobe_func == null probe_offset for perf_[k,u]probe |
pub const TIMESTAMP_NEW = 63; |
TIMESTAMPNS_NEWenum perf_branch_sample_type |
pub const TIMESTAMPNS_NEW = 64; |
TIMESTAMPING_NEWDefines set of user regs to dump on samples. See asm/perf_regs.h for details. |
pub const TIMESTAMPING_NEW = 65; |
RCVTIMEO_NEWDefines size of the user stack to dump on samples. |
pub const RCVTIMEO_NEW = 66; |
SNDTIMEO_NEWDefines set of regs to dump for each sample state captured on: - precise = 0: PMU interrupt - precise > 0: sampled instruction See asm/perf_regs.h for details. |
pub const SNDTIMEO_NEW = 67; |
DETACH_REUSEPORT_BPFWakeup watermark for AUX area |
pub const DETACH_REUSEPORT_BPF = 68; } else if (is_sparc) struct { |
DEBUGAlign to u64 |
pub const DEBUG = 1; |
REUSEADDRFor futex2_waitv and futex2_requeue. Arrays of |
pub const REUSEADDR = 4; |
TYPEExpected value at uaddr, should match size of futex. |
pub const TYPE = 4104; |
ERRORUser address to wait on. Top-bits must be 0 on 32-bit. |
pub const ERROR = 4103; |
DONTROUTEFlags for this waiter. |
pub const DONTROUTE = 16; |
BROADCASTReserved member to preserve alignment. |
pub const BROADCAST = 32; |
SNDBUFNumber of cached pages. |
pub const SNDBUF = 4097; |
RCVBUFNumber of dirty pages. |
pub const RCVBUF = 4098; |
KEEPALIVENumber of pages marked for writeback. |
pub const KEEPALIVE = 8; |
OOBINLINENumber of pages evicted from the cache. |
pub const OOBINLINE = 256; |
NO_CHECKNumber of recently evicted pages. A page is recently evicted if its last eviction was recent enough that its reentry to the cache would indicate that it is actively being used by the system, and that there is memory pressure on the system. |
pub const NO_CHECK = 11; |
PRIORITYSet up a restore token in the shadow stack. |
pub const PRIORITY = 12; |
LINGERThe syscalls, but with Zig error sets, going through libc if linking libc, and with some footguns eliminated. |
pub const LINGER = 128; |
BSDCOMPAT
|
pub const BSDCOMPAT = 1024; |
REUSEPORTDescriptor is not valid or locked, or an mmap(2)-like operation is not available for in_fd. |
pub const REUSEPORT = 512; |
PASSCREDNonblocking I/O has been selected but the write would block. |
pub const PASSCRED = 2; |
PEERCREDUnspecified error while reading from in_fd. |
pub const PEERCRED = 64; |
RCVLOWATInsufficient kernel memory to read from in_fd. |
pub const RCVLOWAT = 2048; |
SNDLOWAT
|
pub const SNDLOWAT = 4096; |
RCVTIMEOOne of: * One or more file descriptors are not valid. * fd_in is not open for reading; or fd_out is not open for writing. * The O_APPEND flag is set for the open file description referred to by the file descriptor fd_out. |
pub const RCVTIMEO = 8192; |
SNDTIMEOOne of: * An attempt was made to write at a position past the maximum file offset the kernel supports. * An attempt was made to write a range that exceeds the allowed maximum file size. The maximum file size differs between filesystem implementations and can be different from the maximum allowed file offset. * An attempt was made to write beyond the process's file size resource limit. This may also result in the process receiving a SIGXFSZ signal. |
pub const SNDTIMEO = 16384; |
ACCEPTCONNOne of: * either fd_in or fd_out is not a regular file * flags argument is not zero * fd_in and fd_out refer to the same file and the source and target ranges overlap. |
pub const ACCEPTCONN = 32768; |
PEERSECA low-level I/O error occurred while copying. |
pub const PEERSEC = 30; |
SNDBUFFORCEEither fd_in or fd_out refers to a directory. |
pub const SNDBUFFORCE = 4106; |
RCVBUFFORCEThere is not enough space on the target filesystem to complete the copy. |
pub const RCVBUFFORCE = 4107; |
PROTOCOL(since Linux 5.19) the filesystem does not support this operation. |
pub const PROTOCOL = 4136; |
DOMAINThe requested source or destination range is too large to represent in the specified data types. |
pub const DOMAIN = 4137; |
SECURITY_AUTHENTICATIONfd_out refers to an immutable file. |
pub const SECURITY_AUTHENTICATION = 20481; |
SECURITY_ENCRYPTION_TRANSPORTEither fd_in or fd_out refers to an active swap file. |
pub const SECURITY_ENCRYPTION_TRANSPORT = 20482; |
SECURITY_ENCRYPTION_NETWORKThe files referred to by fd_in and fd_out are not on the same filesystem, and the source and target filesystems are not of the same type, or do not support cross-filesystem copy. |
pub const SECURITY_ENCRYPTION_NETWORK = 20484; |
BINDTODEVICE |
pub const BINDTODEVICE = 13; |
ATTACH_FILTER |
pub const ATTACH_FILTER = 26; |
DETACH_FILTER |
pub const DETACH_FILTER = 27; |
GET_FILTER |
pub const GET_FILTER = 26; |
PEERNAME |
pub const PEERNAME = 28; |
TIMESTAMP_OLD |
pub const TIMESTAMP_OLD = 29; |
PASSSEC |
pub const PASSSEC = 31; |
TIMESTAMPNS_OLD |
pub const TIMESTAMPNS_OLD = 33; |
MARK |
pub const MARK = 34; |
TIMESTAMPING_OLD |
pub const TIMESTAMPING_OLD = 35; |
RXQ_OVFL |
pub const RXQ_OVFL = 36; |
WIFI_STATUS |
pub const WIFI_STATUS = 37; |
PEEK_OFF |
pub const PEEK_OFF = 38; |
NOFCS |
pub const NOFCS = 39; |
LOCK_FILTER |
pub const LOCK_FILTER = 40; |
SELECT_ERR_QUEUE |
pub const SELECT_ERR_QUEUE = 41; |
BUSY_POLL |
pub const BUSY_POLL = 48; |
MAX_PACING_RATE |
pub const MAX_PACING_RATE = 49; |
BPF_EXTENSIONS |
pub const BPF_EXTENSIONS = 50; |
INCOMING_CPU |
pub const INCOMING_CPU = 51; |
ATTACH_BPF |
pub const ATTACH_BPF = 52; |
DETACH_BPF |
pub const DETACH_BPF = 27; |
ATTACH_REUSEPORT_CBPF |
pub const ATTACH_REUSEPORT_CBPF = 53; |
ATTACH_REUSEPORT_EBPF |
pub const ATTACH_REUSEPORT_EBPF = 54; |
CNX_ADVICE |
pub const CNX_ADVICE = 55; |
MEMINFO |
pub const MEMINFO = 57; |
INCOMING_NAPI_ID |
pub const INCOMING_NAPI_ID = 58; |
COOKIE |
pub const COOKIE = 59; |
PEERGROUPS |
pub const PEERGROUPS = 61; |
ZEROCOPY |
pub const ZEROCOPY = 62; |
TXTIME |
pub const TXTIME = 63; |
BINDTOIFINDEX |
pub const BINDTOIFINDEX = 65; |
TIMESTAMP_NEW |
pub const TIMESTAMP_NEW = 70; |
TIMESTAMPNS_NEW |
pub const TIMESTAMPNS_NEW = 66; |
TIMESTAMPING_NEW |
pub const TIMESTAMPING_NEW = 67; |
RCVTIMEO_NEW |
pub const RCVTIMEO_NEW = 68; |
SNDTIMEO_NEW |
pub const SNDTIMEO_NEW = 69; |
DETACH_REUSEPORT_BPF |
pub const DETACH_REUSEPORT_BPF = 71; } else struct { |
DEBUG |
pub const DEBUG = 1; |
REUSEADDR |
pub const REUSEADDR = 2; |
TYPE |
pub const TYPE = 3; |
ERROR |
pub const ERROR = 4; |
DONTROUTE |
pub const DONTROUTE = 5; |
BROADCAST |
pub const BROADCAST = 6; |
SNDBUF |
pub const SNDBUF = 7; |
RCVBUF |
pub const RCVBUF = 8; |
KEEPALIVE |
pub const KEEPALIVE = 9; |
OOBINLINE |
pub const OOBINLINE = 10; |
NO_CHECK |
pub const NO_CHECK = 11; |
PRIORITY |
pub const PRIORITY = 12; |
LINGER |
pub const LINGER = 13; |
BSDCOMPAT |
pub const BSDCOMPAT = 14; |
REUSEPORT |
pub const REUSEPORT = 15; |
PASSCRED |
pub const PASSCRED = 16; |
PEERCRED |
pub const PEERCRED = 17; |
RCVLOWAT |
pub const RCVLOWAT = 18; |
SNDLOWAT |
pub const SNDLOWAT = 19; |
RCVTIMEO |
pub const RCVTIMEO = 20; |
SNDTIMEO |
pub const SNDTIMEO = 21; |
ACCEPTCONN |
pub const ACCEPTCONN = 30; |
PEERSEC |
pub const PEERSEC = 31; |
SNDBUFFORCE |
pub const SNDBUFFORCE = 32; |
RCVBUFFORCE |
pub const RCVBUFFORCE = 33; |
PROTOCOL |
pub const PROTOCOL = 38; |
DOMAIN |
pub const DOMAIN = 39; |
SECURITY_AUTHENTICATION |
pub const SECURITY_AUTHENTICATION = 22; |
SECURITY_ENCRYPTION_TRANSPORT |
pub const SECURITY_ENCRYPTION_TRANSPORT = 23; |
SECURITY_ENCRYPTION_NETWORK |
pub const SECURITY_ENCRYPTION_NETWORK = 24; |
BINDTODEVICE |
pub const BINDTODEVICE = 25; |
ATTACH_FILTER |
pub const ATTACH_FILTER = 26; |
DETACH_FILTER |
pub const DETACH_FILTER = 27; |
GET_FILTER |
pub const GET_FILTER = ATTACH_FILTER; |
PEERNAME |
pub const PEERNAME = 28; |
TIMESTAMP_OLD |
pub const TIMESTAMP_OLD = 29; |
PASSSEC |
pub const PASSSEC = 34; |
TIMESTAMPNS_OLD |
pub const TIMESTAMPNS_OLD = 35; |
MARK |
pub const MARK = 36; |
TIMESTAMPING_OLD |
pub const TIMESTAMPING_OLD = 37; |
RXQ_OVFL |
pub const RXQ_OVFL = 40; |
WIFI_STATUS |
pub const WIFI_STATUS = 41; |
PEEK_OFF |
pub const PEEK_OFF = 42; |
NOFCS |
pub const NOFCS = 43; |
LOCK_FILTER |
pub const LOCK_FILTER = 44; |
SELECT_ERR_QUEUE |
pub const SELECT_ERR_QUEUE = 45; |
BUSY_POLL |
pub const BUSY_POLL = 46; |
MAX_PACING_RATE |
pub const MAX_PACING_RATE = 47; |
BPF_EXTENSIONS |
pub const BPF_EXTENSIONS = 48; |
INCOMING_CPU |
pub const INCOMING_CPU = 49; |
ATTACH_BPF |
pub const ATTACH_BPF = 50; |
DETACH_BPF |
pub const DETACH_BPF = DETACH_FILTER; |
ATTACH_REUSEPORT_CBPF |
pub const ATTACH_REUSEPORT_CBPF = 51; |
ATTACH_REUSEPORT_EBPF |
pub const ATTACH_REUSEPORT_EBPF = 52; |
CNX_ADVICE |
pub const CNX_ADVICE = 53; |
MEMINFO |
pub const MEMINFO = 55; |
INCOMING_NAPI_ID |
pub const INCOMING_NAPI_ID = 56; |
COOKIE |
pub const COOKIE = 57; |
PEERGROUPS |
pub const PEERGROUPS = 59; |
ZEROCOPY |
pub const ZEROCOPY = 60; |
TXTIME |
pub const TXTIME = 61; |
BINDTOIFINDEX |
pub const BINDTOIFINDEX = 62; |
TIMESTAMP_NEW |
pub const TIMESTAMP_NEW = 63; |
TIMESTAMPNS_NEW |
pub const TIMESTAMPNS_NEW = 64; |
TIMESTAMPING_NEW |
pub const TIMESTAMPING_NEW = 65; |
RCVTIMEO_NEW |
pub const RCVTIMEO_NEW = 66; |
SNDTIMEO_NEW |
pub const SNDTIMEO_NEW = 67; |
DETACH_REUSEPORT_BPF |
pub const DETACH_REUSEPORT_BPF = 68; }; |
SCM |
pub const SCM = struct { |
WIFI_STATUS |
pub const WIFI_STATUS = SO.WIFI_STATUS; |
TIMESTAMPING_OPT_STATS |
pub const TIMESTAMPING_OPT_STATS = 54; |
TIMESTAMPING_PKTINFO |
pub const TIMESTAMPING_PKTINFO = 58; |
TXTIME |
pub const TXTIME = SO.TXTIME; }; |
SOL |
pub const SOL = struct { |
SOCKET |
pub const SOCKET = if (is_mips or is_sparc) 65535 else 1; |
IP |
|
IP |
pub const IP = 0; |
IPV6 |
pub const IPV6 = 41; |
ICMPV6 |
pub const ICMPV6 = 58; |
DECNET |
|
RAW |
pub const RAW = 255; pub const DECNET = 261; pub const X25 = 262; |
PACKET |
pub const PACKET = 263; |
ATM |
pub const ATM = 264; |
AAL |
pub const AAL = 265; |
IRDA |
pub const IRDA = 266; |
NETBEUI |
pub const NETBEUI = 267; |
LLC |
pub const LLC = 268; |
DCCP |
pub const DCCP = 269; |
NETLINK |
pub const NETLINK = 270; |
TIPC |
pub const TIPC = 271; |
RXRPC |
pub const RXRPC = 272; |
PPPOL2TP |
pub const PPPOL2TP = 273; |
BLUETOOTH |
pub const BLUETOOTH = 274; |
PNPIPE |
pub const PNPIPE = 275; |
RDS |
pub const RDS = 276; |
IUCV |
pub const IUCV = 277; |
CAIF |
pub const CAIF = 278; |
ALG |
pub const ALG = 279; |
NFC |
pub const NFC = 280; |
KCM |
pub const KCM = 281; |
TLS |
pub const TLS = 282; |
XDP |
pub const XDP = 283; }; |
SOMAXCONN |
pub const SOMAXCONN = 128; |
IP |
pub const IP = struct { |
TOS |
pub const TOS = 1; |
TTL |
pub const TTL = 2; |
HDRINCL |
pub const HDRINCL = 3; |
OPTIONS |
pub const OPTIONS = 4; |
ROUTER_ALERT |
pub const ROUTER_ALERT = 5; |
RECVOPTS |
pub const RECVOPTS = 6; |
RETOPTS |
pub const RETOPTS = 7; |
PKTINFO |
pub const PKTINFO = 8; |
PKTOPTIONS |
pub const PKTOPTIONS = 9; |
PMTUDISC |
pub const PMTUDISC = 10; |
MTU_DISCOVER |
pub const MTU_DISCOVER = 10; |
RECVERR |
pub const RECVERR = 11; |
RECVTTL |
pub const RECVTTL = 12; |
RECVTOS |
pub const RECVTOS = 13; |
MTU |
pub const MTU = 14; |
FREEBIND |
pub const FREEBIND = 15; |
IPSEC_POLICY |
pub const IPSEC_POLICY = 16; |
XFRM_POLICY |
pub const XFRM_POLICY = 17; |
PASSSEC |
pub const PASSSEC = 18; |
TRANSPARENT |
pub const TRANSPARENT = 19; |
ORIGDSTADDR |
pub const ORIGDSTADDR = 20; |
RECVORIGDSTADDR |
pub const RECVORIGDSTADDR = IP.ORIGDSTADDR; |
MINTTL |
pub const MINTTL = 21; |
NODEFRAG |
pub const NODEFRAG = 22; |
CHECKSUM |
pub const CHECKSUM = 23; |
BIND_ADDRESS_NO_PORT |
pub const BIND_ADDRESS_NO_PORT = 24; |
RECVFRAGSIZE |
pub const RECVFRAGSIZE = 25; |
MULTICAST_IF |
pub const MULTICAST_IF = 32; |
MULTICAST_TTL |
pub const MULTICAST_TTL = 33; |
MULTICAST_LOOP |
pub const MULTICAST_LOOP = 34; |
ADD_MEMBERSHIP |
pub const ADD_MEMBERSHIP = 35; |
DROP_MEMBERSHIP |
pub const DROP_MEMBERSHIP = 36; |
UNBLOCK_SOURCE |
pub const UNBLOCK_SOURCE = 37; |
BLOCK_SOURCE |
pub const BLOCK_SOURCE = 38; |
ADD_SOURCE_MEMBERSHIP |
pub const ADD_SOURCE_MEMBERSHIP = 39; |
DROP_SOURCE_MEMBERSHIP |
pub const DROP_SOURCE_MEMBERSHIP = 40; |
MSFILTER |
pub const MSFILTER = 41; |
MULTICAST_ALL |
pub const MULTICAST_ALL = 49; |
UNICAST_IF |
pub const UNICAST_IF = 50; |
RECVRETOPTS |
pub const RECVRETOPTS = IP.RETOPTS; |
PMTUDISC_DONT |
|
PMTUDISC_DONT |
pub const PMTUDISC_DONT = 0; |
PMTUDISC_WANT |
pub const PMTUDISC_WANT = 1; |
PMTUDISC_DO |
pub const PMTUDISC_DO = 2; |
PMTUDISC_PROBE |
pub const PMTUDISC_PROBE = 3; |
PMTUDISC_INTERFACE |
pub const PMTUDISC_INTERFACE = 4; |
PMTUDISC_OMIT |
pub const PMTUDISC_OMIT = 5; |
DEFAULT_MULTICAST_LOOP |
pub const DEFAULT_MULTICAST_TTL = 1; pub const DEFAULT_MULTICAST_LOOP = 1; |
MAX_MEMBERSHIPS |
pub const MAX_MEMBERSHIPS = 20; }; |
IPV6 |
/// IPv6 socket options pub const IPV6 = struct { |
ADDRFORM |
pub const ADDRFORM = 1; |
@"2292PKTINFO" |
pub const @"2292PKTINFO" = 2; |
@"2292HOPOPTS" |
pub const @"2292HOPOPTS" = 3; |
@"2292DSTOPTS" |
pub const @"2292DSTOPTS" = 4; |
@"2292RTHDR" |
pub const @"2292RTHDR" = 5; |
@"2292PKTOPTIONS" |
pub const @"2292PKTOPTIONS" = 6; |
CHECKSUM |
pub const CHECKSUM = 7; |
@"2292HOPLIMIT" |
pub const @"2292HOPLIMIT" = 8; |
NEXTHOP |
pub const NEXTHOP = 9; |
AUTHHDR |
pub const AUTHHDR = 10; |
FLOWINFO |
pub const FLOWINFO = 11; |
UNICAST_HOPS |
pub const UNICAST_HOPS = 16; |
MULTICAST_IF |
pub const MULTICAST_IF = 17; |
MULTICAST_HOPS |
pub const MULTICAST_HOPS = 18; |
MULTICAST_LOOP |
pub const MULTICAST_LOOP = 19; |
ADD_MEMBERSHIP |
pub const ADD_MEMBERSHIP = 20; |
DROP_MEMBERSHIP |
pub const DROP_MEMBERSHIP = 21; |
ROUTER_ALERT |
pub const ROUTER_ALERT = 22; |
MTU_DISCOVER |
pub const MTU_DISCOVER = 23; |
MTU |
pub const MTU = 24; |
RECVERR |
pub const RECVERR = 25; |
V6ONLY |
pub const V6ONLY = 26; |
JOIN_ANYCAST |
pub const JOIN_ANYCAST = 27; |
LEAVE_ANYCAST |
pub const LEAVE_ANYCAST = 28; |
PMTUDISC_DONT |
// IPV6.MTU_DISCOVER values pub const PMTUDISC_DONT = 0; |
PMTUDISC_WANT |
pub const PMTUDISC_WANT = 1; |
PMTUDISC_DO |
pub const PMTUDISC_DO = 2; |
PMTUDISC_PROBE |
pub const PMTUDISC_PROBE = 3; |
PMTUDISC_INTERFACE |
pub const PMTUDISC_INTERFACE = 4; |
PMTUDISC_OMIT |
pub const PMTUDISC_OMIT = 5; |
FLOWLABEL_MGR |
// Flowlabel pub const FLOWLABEL_MGR = 32; |
FLOWINFO_SEND |
pub const FLOWINFO_SEND = 33; |
IPSEC_POLICY |
pub const IPSEC_POLICY = 34; |
XFRM_POLICY |
pub const XFRM_POLICY = 35; |
HDRINCL |
pub const HDRINCL = 36; |
RECVPKTINFO |
// Advanced API (RFC3542) (1) pub const RECVPKTINFO = 49; |
PKTINFO |
pub const PKTINFO = 50; |
RECVHOPLIMIT |
pub const RECVHOPLIMIT = 51; |
HOPLIMIT |
pub const HOPLIMIT = 52; |
RECVHOPOPTS |
pub const RECVHOPOPTS = 53; |
HOPOPTS |
pub const HOPOPTS = 54; |
RTHDRDSTOPTS |
pub const RTHDRDSTOPTS = 55; |
RECVRTHDR |
pub const RECVRTHDR = 56; |
RTHDR |
pub const RTHDR = 57; |
RECVDSTOPTS |
pub const RECVDSTOPTS = 58; |
DSTOPTS |
pub const DSTOPTS = 59; |
RECVPATHMTU |
pub const RECVPATHMTU = 60; |
PATHMTU |
pub const PATHMTU = 61; |
DONTFRAG |
pub const DONTFRAG = 62; |
RECVTCLASS |
// Advanced API (RFC3542) (2) pub const RECVTCLASS = 66; |
TCLASS |
pub const TCLASS = 67; |
AUTOFLOWLABEL |
pub const AUTOFLOWLABEL = 70; |
ADDR_PREFERENCES |
// RFC5014: Source address selection pub const ADDR_PREFERENCES = 72; |
PREFER_SRC_TMP |
pub const PREFER_SRC_TMP = 0x0001; |
PREFER_SRC_PUBLIC |
pub const PREFER_SRC_PUBLIC = 0x0002; |
PREFER_SRC_PUBTMP_DEFAULT |
pub const PREFER_SRC_PUBTMP_DEFAULT = 0x0100; |
PREFER_SRC_COA |
pub const PREFER_SRC_COA = 0x0004; |
PREFER_SRC_HOME |
pub const PREFER_SRC_HOME = 0x0400; |
PREFER_SRC_CGA |
pub const PREFER_SRC_CGA = 0x0008; |
PREFER_SRC_NONCGA |
pub const PREFER_SRC_NONCGA = 0x0800; |
MINHOPCOUNT |
// RFC5082: Generalized Ttl Security Mechanism pub const MINHOPCOUNT = 73; |
ORIGDSTADDR |
pub const ORIGDSTADDR = 74; |
RECVORIGDSTADDR |
pub const RECVORIGDSTADDR = IPV6.ORIGDSTADDR; |
TRANSPARENT |
pub const TRANSPARENT = 75; |
UNICAST_IF |
pub const UNICAST_IF = 76; |
RECVFRAGSIZE |
pub const RECVFRAGSIZE = 77; |
FREEBIND |
pub const FREEBIND = 78; }; |
ETH |
/// IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble /// and FCS/CRC (frame check sequence). pub const ETH = struct { /// Octets in one ethernet addr |
ALEN |
pub const ALEN = 6; /// Octets in ethernet type field |
TLEN |
pub const TLEN = 2; /// Total octets in header |
HLEN |
pub const HLEN = 14; /// Min. octets in frame sans FC |
ZLEN |
pub const ZLEN = 60; /// Max. octets in payload |
DATA_LEN |
pub const DATA_LEN = 1500; /// Max. octets in frame sans FCS |
FRAME_LEN |
pub const FRAME_LEN = 1514; /// Octets in the FCS |
FCS_LEN |
pub const FCS_LEN = 4; |
MIN_MTU |
/// Min IPv4 MTU per RFC791 pub const MIN_MTU = 68; /// 65535, same as IP_MAX_MTU |
MAX_MTU |
pub const MAX_MTU = 0xFFFF; |
P |
/// These are the defined Ethernet Protocol ID's. pub const P = struct { /// Ethernet Loopback packet |
LOOP |
pub const LOOP = 0x0060; /// Xerox PUP packet |
PUP |
pub const PUP = 0x0200; /// Xerox PUP Addr Trans packet |
PUPAT |
pub const PUPAT = 0x0201; /// TSN (IEEE 1722) packet |
TSN |
pub const TSN = 0x22F0; /// ERSPAN version 2 (type III) |
ERSPAN2 |
pub const ERSPAN2 = 0x22EB; /// Internet Protocol packet |
IP |
pub const IP = 0x0800; /// CCITT X.25 |
X25 |
pub const X25 = 0x0805; /// Address Resolution packet |
ARP |
pub const ARP = 0x0806; /// G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] |
BPQ |
pub const BPQ = 0x08FF; /// Xerox IEEE802.3 PUP packet |
IEEEPUP |
pub const IEEEPUP = 0x0a00; /// Xerox IEEE802.3 PUP Addr Trans packet |
IEEEPUPAT |
pub const IEEEPUPAT = 0x0a01; /// B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ] |
BATMAN |
pub const BATMAN = 0x4305; /// DEC Assigned proto |
DEC |
pub const DEC = 0x6000; /// DEC DNA Dump/Load |
DNA_DL |
pub const DNA_DL = 0x6001; /// DEC DNA Remote Console |
DNA_RC |
pub const DNA_RC = 0x6002; /// DEC DNA Routing |
DNA_RT |
pub const DNA_RT = 0x6003; /// DEC LAT |
LAT |
pub const LAT = 0x6004; /// DEC Diagnostics |
DIAG |
pub const DIAG = 0x6005; /// DEC Customer use |
CUST |
pub const CUST = 0x6006; /// DEC Systems Comms Arch |
SCA |
pub const SCA = 0x6007; /// Trans Ether Bridging |
TEB |
pub const TEB = 0x6558; /// Reverse Addr Res packet |
RARP |
pub const RARP = 0x8035; /// Appletalk DDP |
ATALK |
pub const ATALK = 0x809B; /// Appletalk AARP |
AARP |
pub const AARP = 0x80F3; /// 802.1Q VLAN Extended Header |
P_8021Q |
pub const P_8021Q = 0x8100; /// ERSPAN type II |
ERSPAN |
pub const ERSPAN = 0x88BE; /// IPX over DIX |
IPX |
pub const IPX = 0x8137; /// IPv6 over bluebook |
IPV6 |
pub const IPV6 = 0x86DD; /// IEEE Pause frames. See 802.3 31B |
PAUSE |
pub const PAUSE = 0x8808; /// Slow Protocol. See 802.3ad 43B |
SLOW |
pub const SLOW = 0x8809; /// Web-cache coordination protocol defined in draft-wilson-wrec-wccp-v2-00.txt |
WCCP |
pub const WCCP = 0x883E; /// MPLS Unicast traffic |
MPLS_UC |
pub const MPLS_UC = 0x8847; /// MPLS Multicast traffic |
MPLS_MC |
pub const MPLS_MC = 0x8848; /// MultiProtocol Over ATM |
ATMMPOA |
pub const ATMMPOA = 0x884c; /// PPPoE discovery messages |
PPP_DISC |
pub const PPP_DISC = 0x8863; /// PPPoE session messages |
PPP_SES |
pub const PPP_SES = 0x8864; /// HPNA, wlan link local tunnel |
LINK_CTL |
pub const LINK_CTL = 0x886c; /// Frame-based ATM Transport over Ethernet |
ATMFATE |
pub const ATMFATE = 0x8884; /// Port Access Entity (IEEE 802.1X) |
PAE |
pub const PAE = 0x888E; /// PROFINET |
PROFINET |
pub const PROFINET = 0x8892; /// Multiple proprietary protocols |
REALTEK |
pub const REALTEK = 0x8899; /// ATA over Ethernet |
AOE |
pub const AOE = 0x88A2; /// EtherCAT |
ETHERCAT |
pub const ETHERCAT = 0x88A4; /// 802.1ad Service VLAN |
@"8021AD" |
pub const @"8021AD" = 0x88A8; /// 802.1 Local Experimental 1. |
@"802_EX1" |
pub const @"802_EX1" = 0x88B5; /// 802.11 Preauthentication |
PREAUTH |
pub const PREAUTH = 0x88C7; /// TIPC |
TIPC |
pub const TIPC = 0x88CA; /// Link Layer Discovery Protocol |
LLDP |
pub const LLDP = 0x88CC; /// Media Redundancy Protocol |
MRP |
pub const MRP = 0x88E3; /// 802.1ae MACsec |
MACSEC |
pub const MACSEC = 0x88E5; /// 802.1ah Backbone Service Tag |
@"8021AH" |
pub const @"8021AH" = 0x88E7; /// 802.1Q MVRP |
MVRP |
pub const MVRP = 0x88F5; /// IEEE 1588 Timesync |
@"1588" |
pub const @"1588" = 0x88F7; /// NCSI protocol |
NCSI |
pub const NCSI = 0x88F8; /// IEC 62439-3 PRP/HSRv0 |
PRP |
pub const PRP = 0x88FB; /// Connectivity Fault Management |
CFM |
pub const CFM = 0x8902; /// Fibre Channel over Ethernet |
FCOE |
pub const FCOE = 0x8906; /// Infiniband over Ethernet |
IBOE |
pub const IBOE = 0x8915; /// TDLS |
TDLS |
pub const TDLS = 0x890D; /// FCoE Initialization Protocol |
FIP |
pub const FIP = 0x8914; /// IEEE 802.21 Media Independent Handover Protocol |
@"80221" |
pub const @"80221" = 0x8917; /// IEC 62439-3 HSRv1 |
HSR |
pub const HSR = 0x892F; /// Network Service Header |
NSH |
pub const NSH = 0x894F; /// Ethernet loopback packet, per IEEE 802.3 |
LOOPBACK |
pub const LOOPBACK = 0x9000; /// deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] |
QINQ1 |
pub const QINQ1 = 0x9100; /// deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] |
QINQ2 |
pub const QINQ2 = 0x9200; /// deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] |
QINQ3 |
pub const QINQ3 = 0x9300; /// Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] |
EDSA |
pub const EDSA = 0xDADA; /// Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] |
DSA_8021Q |
pub const DSA_8021Q = 0xDADB; /// A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ] |
DSA_A5PSW |
pub const DSA_A5PSW = 0xE001; /// ForCES inter-FE LFB type |
IFE |
pub const IFE = 0xED3E; /// IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] |
AF_IUCV |
pub const AF_IUCV = 0xFBFB; /// If the value in the ethernet type is more than this value then the frame is Ethernet II. Else it is 802.3 |
@"802_3_MIN" |
pub const @"802_3_MIN" = 0x0600; |
@"802_3" |
// Non DIX types. Won't clash for 1500 types. |
AX25 |
/// Dummy type for 802.3 frames pub const @"802_3" = 0x0001; /// Dummy protocol id for AX.25 pub const AX25 = 0x0002; /// Every packet (be careful!!!) |
ALL |
pub const ALL = 0x0003; /// 802.2 frames |
@"802_2" |
pub const @"802_2" = 0x0004; /// Internal only |
SNAP |
pub const SNAP = 0x0005; /// DEC DDCMP: Internal only |
DDCMP |
pub const DDCMP = 0x0006; /// Dummy type for WAN PPP frames |
WAN_PPP |
pub const WAN_PPP = 0x0007; /// Dummy type for PPP MP frames |
PPP_MP |
pub const PPP_MP = 0x0008; /// Localtalk pseudo type |
LOCALTALK |
pub const LOCALTALK = 0x0009; /// CAN: Controller Area Network |
CAN |
pub const CAN = 0x000C; /// CANFD: CAN flexible data rate |
CANFD |
pub const CANFD = 0x000D; /// CANXL: eXtended frame Length |
CANXL |
pub const CANXL = 0x000E; /// Dummy type for Atalk over PPP |
PPPTALK |
pub const PPPTALK = 0x0010; /// 802.2 frames |
TR_802_2 |
pub const TR_802_2 = 0x0011; /// Mobitex (kaz@cafe.net) |
MOBITEX |
pub const MOBITEX = 0x0015; /// Card specific control frames |
CONTROL |
pub const CONTROL = 0x0016; /// Linux-IrDA |
IRDA |
pub const IRDA = 0x0017; /// Acorn Econet |
ECONET |
pub const ECONET = 0x0018; /// HDLC frames |
HDLC |
pub const HDLC = 0x0019; /// 1A for ArcNet :-) |
ARCNET |
pub const ARCNET = 0x001A; /// Distributed Switch Arch. |
DSA |
pub const DSA = 0x001B; /// Trailer switch tagging |
TRAILER |
pub const TRAILER = 0x001C; /// Nokia Phonet frames |
PHONET |
pub const PHONET = 0x00F5; /// IEEE802.15.4 frame |
IEEE802154 |
pub const IEEE802154 = 0x00F6; /// ST-Ericsson CAIF protocol |
CAIF |
pub const CAIF = 0x00F7; /// Multiplexed DSA protocol |
XDSA |
pub const XDSA = 0x00F8; /// Qualcomm multiplexing and aggregation protocol |
MAP |
pub const MAP = 0x00F9; /// Management component transport protocol packets |
MCTP |
pub const MCTP = 0x00FA; }; }; |
MSG |
pub const MSG = struct { |
OOB |
pub const OOB = 0x0001; |
PEEK |
pub const PEEK = 0x0002; |
DONTROUTE |
pub const DONTROUTE = 0x0004; |
CTRUNC |
pub const CTRUNC = 0x0008; |
PROXY |
pub const PROXY = 0x0010; |
TRUNC |
pub const TRUNC = 0x0020; |
DONTWAIT |
pub const DONTWAIT = 0x0040; |
EOR |
pub const EOR = 0x0080; |
WAITALL |
pub const WAITALL = 0x0100; |
FIN |
pub const FIN = 0x0200; |
SYN |
pub const SYN = 0x0400; |
CONFIRM |
pub const CONFIRM = 0x0800; |
RST |
pub const RST = 0x1000; |
ERRQUEUE |
pub const ERRQUEUE = 0x2000; |
NOSIGNAL |
pub const NOSIGNAL = 0x4000; |
MORE |
pub const MORE = 0x8000; |
WAITFORONE |
pub const WAITFORONE = 0x10000; |
BATCH |
pub const BATCH = 0x40000; |
ZEROCOPY |
pub const ZEROCOPY = 0x4000000; |
FASTOPEN |
pub const FASTOPEN = 0x20000000; |
CMSG_CLOEXEC |
pub const CMSG_CLOEXEC = 0x40000000; }; |
DT |
pub const DT = struct { |
UNKNOWN |
pub const UNKNOWN = 0; |
FIFO |
pub const FIFO = 1; |
CHR |
pub const CHR = 2; |
DIR |
pub const DIR = 4; |
BLK |
pub const BLK = 6; |
REG |
pub const REG = 8; |
LNK |
pub const LNK = 10; |
SOCK |
pub const SOCK = 12; |
WHT |
pub const WHT = 14; }; |
T |
pub const T = if (is_mips) struct { |
CGETA |
pub const CGETA = 0x5401; |
CSETA |
pub const CSETA = 0x5402; |
CSETAW |
pub const CSETAW = 0x5403; |
CSETAF |
pub const CSETAF = 0x5404; |
CSBRK |
pub const CSBRK = 0x5405; |
CXONC |
pub const CXONC = 0x5406; |
CFLSH |
pub const CFLSH = 0x5407; |
CGETS |
pub const CGETS = 0x540d; |
CSETS |
pub const CSETS = 0x540e; |
CSETSW |
pub const CSETSW = 0x540f; |
CSETSF |
pub const CSETSF = 0x5410; |
IOCEXCL |
pub const IOCEXCL = 0x740d; |
IOCNXCL |
pub const IOCNXCL = 0x740e; |
IOCOUTQ |
pub const IOCOUTQ = 0x7472; |
IOCSTI |
pub const IOCSTI = 0x5472; |
IOCMGET |
pub const IOCMGET = 0x741d; |
IOCMBIS |
pub const IOCMBIS = 0x741b; |
IOCMBIC |
pub const IOCMBIC = 0x741c; |
IOCMSET |
pub const IOCMSET = 0x741a; |
IOCPKT |
pub const IOCPKT = 0x5470; |
IOCPKT_DATA |
pub const IOCPKT_DATA = 0x00; |
IOCPKT_FLUSHREAD |
pub const IOCPKT_FLUSHREAD = 0x01; |
IOCPKT_FLUSHWRITE |
pub const IOCPKT_FLUSHWRITE = 0x02; |
IOCPKT_STOP |
pub const IOCPKT_STOP = 0x04; |
IOCPKT_START |
pub const IOCPKT_START = 0x08; |
IOCPKT_NOSTOP |
pub const IOCPKT_NOSTOP = 0x10; |
IOCPKT_DOSTOP |
pub const IOCPKT_DOSTOP = 0x20; |
IOCPKT_IOCTL |
pub const IOCPKT_IOCTL = 0x40; |
IOCSWINSZ |
pub const IOCSWINSZ = IOCTL.IOW('t', 103, winsize); |
IOCGWINSZ |
pub const IOCGWINSZ = IOCTL.IOR('t', 104, winsize); |
IOCNOTTY |
pub const IOCNOTTY = 0x5471; |
IOCSETD |
pub const IOCSETD = 0x7401; |
IOCGETD |
pub const IOCGETD = 0x7400; |
FIOCLEX |
pub const FIOCLEX = 0x6601; |
FIONCLEX |
pub const FIONCLEX = 0x6602; |
FIOASYNC |
pub const FIOASYNC = 0x667d; |
FIONBIO |
pub const FIONBIO = 0x667e; |
FIOQSIZE |
pub const FIOQSIZE = 0x667f; |
IOCGLTC |
pub const IOCGLTC = 0x7474; |
IOCSLTC |
pub const IOCSLTC = 0x7475; |
IOCSPGRP |
pub const IOCSPGRP = IOCTL.IOW('t', 118, c_int); |
IOCGPGRP |
pub const IOCGPGRP = IOCTL.IOR('t', 119, c_int); |
IOCCONS |
pub const IOCCONS = IOCTL.IOW('t', 120, c_int); |
FIONREAD |
pub const FIONREAD = 0x467f; |
IOCINQ |
pub const IOCINQ = FIONREAD; |
IOCGETP |
pub const IOCGETP = 0x7408; |
IOCSETP |
pub const IOCSETP = 0x7409; |
IOCSETN |
pub const IOCSETN = 0x740a; |
IOCSBRK |
|
IOCSBRK |
pub const IOCSBRK = 0x5427; |
IOCCBRK |
pub const IOCCBRK = 0x5428; pub const IOCGSID = 0x7416; |
CGETS2 |
pub const CGETS2 = IOCTL.IOR('T', 0x2a, termios2); |
CSETS2 |
pub const CSETS2 = IOCTL.IOW('T', 0x2b, termios2); |
CSETSW2 |
pub const CSETSW2 = IOCTL.IOW('T', 0x2c, termios2); |
CSETSF2 |
pub const CSETSF2 = IOCTL.IOW('T', 0x2d, termios2); |
IOCGRS485 |
pub const IOCGRS485 = IOCTL.IOR('T', 0x2e, serial_rs485); |
IOCSRS485 |
pub const IOCSRS485 = IOCTL.IOWR('T', 0x2f, serial_rs485); |
IOCGPTN |
pub const IOCGPTN = IOCTL.IOR('T', 0x30, c_uint); |
IOCSPTLCK |
pub const IOCSPTLCK = IOCTL.IOW('T', 0x31, c_int); |
IOCGDEV |
pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint); |
IOCSIG |
pub const IOCSIG = IOCTL.IOW('T', 0x36, c_int); |
IOCVHANGUP |
pub const IOCVHANGUP = 0x5437; |
IOCGPKT |
pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int); |
IOCGPTLCK |
pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int); |
IOCGEXCL |
pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int); |
IOCGPTPEER |
pub const IOCGPTPEER = IOCTL.IO('T', 0x41); |
IOCGISO7816 |
pub const IOCGISO7816 = IOCTL.IOR('T', 0x42, serial_iso7816); |
IOCSISO7816 |
pub const IOCSISO7816 = IOCTL.IOWR('T', 0x43, serial_iso7816); |
IOCSCTTY |
pub const IOCSCTTY = 0x5480; |
IOCGSOFTCAR |
pub const IOCGSOFTCAR = 0x5481; |
IOCSSOFTCAR |
pub const IOCSSOFTCAR = 0x5482; |
IOCLINUX |
pub const IOCLINUX = 0x5483; |
IOCGSERIAL |
pub const IOCGSERIAL = 0x5484; |
IOCSSERIAL |
pub const IOCSSERIAL = 0x5485; |
CSBRKP |
pub const CSBRKP = 0x5486; |
IOCSERCONFIG |
pub const IOCSERCONFIG = 0x5488; |
IOCSERGWILD |
pub const IOCSERGWILD = 0x5489; |
IOCSERSWILD |
pub const IOCSERSWILD = 0x548a; |
IOCGLCKTRMIOS |
pub const IOCGLCKTRMIOS = 0x548b; |
IOCSLCKTRMIOS |
pub const IOCSLCKTRMIOS = 0x548c; |
IOCSERGSTRUCT |
pub const IOCSERGSTRUCT = 0x548d; |
IOCSERGETLSR |
pub const IOCSERGETLSR = 0x548e; |
IOCSERGETMULTI |
pub const IOCSERGETMULTI = 0x548f; |
IOCSERSETMULTI |
pub const IOCSERSETMULTI = 0x5490; |
IOCMIWAIT |
pub const IOCMIWAIT = 0x5491; |
IOCGICOUNT |
pub const IOCGICOUNT = 0x5492; } else if (is_ppc) struct { |
FIOCLEX |
pub const FIOCLEX = IOCTL.IO('f', 1); |
FIONCLEX |
pub const FIONCLEX = IOCTL.IO('f', 2); |
FIOASYNC |
pub const FIOASYNC = IOCTL.IOW('f', 125, c_int); |
FIONBIO |
pub const FIONBIO = IOCTL.IOW('f', 126, c_int); |
FIONREAD |
pub const FIONREAD = IOCTL.IOR('f', 127, c_int); |
IOCINQ |
pub const IOCINQ = FIONREAD; |
FIOQSIZE |
pub const FIOQSIZE = IOCTL.IOR('f', 128, c_longlong); // loff_t -> __kernel_loff_t -> long long |
IOCGETP |
pub const IOCGETP = IOCTL.IOR('t', 8, sgttyb); |
IOCSETP |
pub const IOCSETP = IOCTL.IOW('t', 9, sgttyb); |
IOCSETN |
pub const IOCSETN = IOCTL.IOW('t', 10, sgttyb); |
IOCSETC |
pub const IOCSETC = IOCTL.IOW('t', 17, tchars); |
IOCGETC |
pub const IOCGETC = IOCTL.IOR('t', 18, tchars); |
CGETS |
pub const CGETS = IOCTL.IOR('t', 19, termios); |
CSETS |
pub const CSETS = IOCTL.IOW('t', 20, termios); |
CSETSW |
pub const CSETSW = IOCTL.IOW('t', 21, termios); |
CSETSF |
pub const CSETSF = IOCTL.IOW('t', 22, termios); |
CGETA |
pub const CGETA = IOCTL.IOR('t', 23, termio); |
CSETA |
pub const CSETA = IOCTL.IOW('t', 24, termio); |
CSETAW |
pub const CSETAW = IOCTL.IOW('t', 25, termio); |
CSETAF |
pub const CSETAF = IOCTL.IOW('t', 28, termio); |
CSBRK |
pub const CSBRK = IOCTL.IO('t', 29); |
CXONC |
pub const CXONC = IOCTL.IO('t', 30); |
CFLSH |
pub const CFLSH = IOCTL.IO('t', 31); |
IOCSWINSZ |
|
IOCSWINSZ |
pub const IOCSWINSZ = IOCTL.IOW('t', 103, winsize); |
IOCGWINSZ |
pub const IOCGWINSZ = IOCTL.IOR('t', 104, winsize); |
IOCSTART |
pub const IOCSTART = IOCTL.IO('t', 110); |
IOCSTOP |
pub const IOCSTOP = IOCTL.IO('t', 111); |
IOCOUTQ |
pub const IOCOUTQ = IOCTL.IOR('t', 115, c_int); |
IOCSLTC |
pub const IOCGLTC = IOCTL.IOR('t', 116, ltchars); pub const IOCSLTC = IOCTL.IOW('t', 117, ltchars); |
IOCSPGRP |
pub const IOCSPGRP = IOCTL.IOW('t', 118, c_int); |
IOCGPGRP |
pub const IOCGPGRP = IOCTL.IOR('t', 119, c_int); |
IOCEXCL |
|
IOCEXCL |
pub const IOCEXCL = 0x540c; |
IOCNXCL |
pub const IOCNXCL = 0x540d; |
IOCSCTTY |
pub const IOCSCTTY = 0x540e; |
IOCMGET |
|
IOCSTI |
pub const IOCSTI = 0x5412; |
IOCMGET |
pub const IOCMGET = 0x5415; |
IOCMBIS |
pub const IOCMBIS = 0x5416; |
IOCMBIC |
pub const IOCMBIC = 0x5417; |
IOCMSET |
pub const IOCMSET = 0x5418; pub const IOCM_LE = 0x001; pub const IOCM_DTR = 0x002; |
IOCM_RTS |
pub const IOCM_RTS = 0x004; |
IOCM_ST |
pub const IOCM_ST = 0x008; |
IOCM_SR |
pub const IOCM_SR = 0x010; |
IOCM_CTS |
pub const IOCM_CTS = 0x020; |
IOCM_CAR |
pub const IOCM_CAR = 0x040; |
IOCM_RNG |
pub const IOCM_RNG = 0x080; |
IOCM_DSR |
pub const IOCM_DSR = 0x100; |
IOCM_CD |
pub const IOCM_CD = IOCM_CAR; |
IOCM_RI |
pub const IOCM_RI = IOCM_RNG; |
IOCM_OUT1 |
pub const IOCM_OUT1 = 0x2000; |
IOCM_OUT2 |
pub const IOCM_OUT2 = 0x4000; |
IOCM_LOOP |
pub const IOCM_LOOP = 0x8000; |
IOCGSOFTCAR |
|
IOCGSOFTCAR |
pub const IOCGSOFTCAR = 0x5419; |
IOCSSOFTCAR |
pub const IOCSSOFTCAR = 0x541a; |
IOCLINUX |
pub const IOCLINUX = 0x541c; |
IOCCONS |
pub const IOCCONS = 0x541d; |
IOCGSERIAL |
pub const IOCGSERIAL = 0x541e; |
IOCSSERIAL |
pub const IOCSSERIAL = 0x541f; |
IOCPKT |
pub const IOCPKT = 0x5420; |
IOCPKT_DATA |
pub const IOCPKT_DATA = 0; |
IOCPKT_FLUSHREAD |
pub const IOCPKT_FLUSHREAD = 1; |
IOCPKT_FLUSHWRITE |
pub const IOCPKT_FLUSHWRITE = 2; |
IOCPKT_STOP |
pub const IOCPKT_STOP = 4; |
IOCPKT_START |
pub const IOCPKT_START = 8; |
IOCPKT_NOSTOP |
pub const IOCPKT_NOSTOP = 16; |
IOCPKT_DOSTOP |
pub const IOCPKT_DOSTOP = 32; |
IOCPKT_IOCTL |
pub const IOCPKT_IOCTL = 64; |
IOCSETD |
|
IOCNOTTY |
pub const IOCNOTTY = 0x5422; |
IOCSETD |
pub const IOCSETD = 0x5423; |
IOCGETD |
pub const IOCGETD = 0x5424; |
CSBRKP |
pub const CSBRKP = 0x5425; |
IOCSBRK |
pub const IOCSBRK = 0x5427; |
IOCCBRK |
pub const IOCCBRK = 0x5428; |
IOCGSID |
pub const IOCGSID = 0x5429; |
IOCGRS485 |
pub const IOCGRS485 = 0x542e; |
IOCSRS485 |
pub const IOCSRS485 = 0x542f; |
IOCGPTN |
pub const IOCGPTN = IOCTL.IOR('T', 0x30, c_uint); |
IOCSPTLCK |
pub const IOCSPTLCK = IOCTL.IOW('T', 0x31, c_int); |
IOCGDEV |
pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint); |
IOCSIG |
pub const IOCSIG = IOCTL.IOW('T', 0x36, c_int); |
IOCVHANGUP |
pub const IOCVHANGUP = 0x5437; |
IOCGPKT |
pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int); |
IOCGPTLCK |
pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int); |
IOCGEXCL |
pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int); |
IOCGPTPEER |
pub const IOCGPTPEER = IOCTL.IO('T', 0x41); |
IOCGISO7816 |
pub const IOCGISO7816 = IOCTL.IOR('T', 0x42, serial_iso7816); |
IOCSISO7816 |
pub const IOCSISO7816 = IOCTL.IOWR('T', 0x43, serial_iso7816); |
IOCSERSWILD |
|
IOCSERCONFIG |
pub const IOCSERCONFIG = 0x5453; |
IOCSERGWILD |
pub const IOCSERGWILD = 0x5454; |
IOCSERSWILD |
pub const IOCSERSWILD = 0x5455; |
IOCGLCKTRMIOS |
pub const IOCGLCKTRMIOS = 0x5456; |
IOCSLCKTRMIOS |
pub const IOCSLCKTRMIOS = 0x5457; |
IOCSERGSTRUCT |
pub const IOCSERGSTRUCT = 0x5458; |
IOCSERGETLSR |
pub const IOCSERGETLSR = 0x5459; |
IOCSER_TEMT |
pub const IOCSER_TEMT = 0x01; |
IOCSERGETMULTI |
pub const IOCSERGETMULTI = 0x545a; |
IOCSERSETMULTI |
pub const IOCSERSETMULTI = 0x545b; |
CSETA |
|
IOCMIWAIT |
pub const IOCMIWAIT = 0x545c; |
IOCGICOUNT |
pub const IOCGICOUNT = 0x545d; } else if (is_sparc) struct { // Entries with double-underscore prefix have not been translated as they are unsupported. |
CSBRK |
pub const CGETA = IOCTL.IOR('T', 1, termio); pub const CSETA = IOCTL.IOW('T', 2, termio); pub const CSETAW = IOCTL.IOW('T', 3, termio); pub const CSETAF = IOCTL.IOW('T', 4, termio); pub const CSBRK = IOCTL.IO('T', 5); |
CXONC |
pub const CXONC = IOCTL.IO('T', 6); |
CFLSH |
pub const CFLSH = IOCTL.IO('T', 7); |
CGETS |
pub const CGETS = IOCTL.IOR('T', 8, termios); |
CSETS |
pub const CSETS = IOCTL.IOW('T', 9, termios); |
CSETSW |
pub const CSETSW = IOCTL.IOW('T', 10, termios); |
CSETSF |
pub const CSETSF = IOCTL.IOW('T', 11, termios); |
CGETS2 |
pub const CGETS2 = IOCTL.IOR('T', 12, termios2); |
CSETS2 |
pub const CSETS2 = IOCTL.IOW('T', 13, termios2); |
CSETSW2 |
pub const CSETSW2 = IOCTL.IOW('T', 14, termios2); |
CSETSF2 |
pub const CSETSF2 = IOCTL.IOW('T', 15, termios2); |
IOCGDEV |
pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint); |
IOCVHANGUP |
pub const IOCVHANGUP = IOCTL.IO('T', 0x37); |
IOCGPKT |
pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int); |
IOCGPTLCK |
pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int); |
IOCGEXCL |
pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int); |
IOCGRS485 |
pub const IOCGRS485 = IOCTL.IOR('T', 0x41, serial_rs485); |
IOCSRS485 |
pub const IOCSRS485 = IOCTL.IOWR('T', 0x42, serial_rs485); |
IOCGISO7816 |
pub const IOCGISO7816 = IOCTL.IOR('T', 0x43, serial_iso7816); |
IOCSISO7816 |
pub const IOCSISO7816 = IOCTL.IOWR('T', 0x44, serial_iso7816); |
IOCGETD |
pub const IOCGETD = IOCTL.IOR('t', 0, c_int); |
IOCSETD |
pub const IOCSETD = IOCTL.IOW('t', 1, c_int); |
IOCEXCL |
pub const IOCEXCL = IOCTL.IO('t', 13); |
IOCNXCL |
pub const IOCNXCL = IOCTL.IO('t', 14); |
IOCCONS |
pub const IOCCONS = IOCTL.IO('t', 36); |
IOCGSOFTCAR |
pub const IOCGSOFTCAR = IOCTL.IOR('t', 100, c_int); |
IOCSSOFTCAR |
pub const IOCSSOFTCAR = IOCTL.IOW('t', 101, c_int); |
IOCSWINSZ |
pub const IOCSWINSZ = IOCTL.IOW('t', 103, winsize); |
IOCGWINSZ |
pub const IOCGWINSZ = IOCTL.IOR('t', 104, winsize); |
IOCMGET |
pub const IOCMGET = IOCTL.IOR('t', 106, c_int); |
IOCMBIC |
pub const IOCMBIC = IOCTL.IOW('t', 107, c_int); |
IOCMBIS |
pub const IOCMBIS = IOCTL.IOW('t', 108, c_int); |
IOCMSET |
pub const IOCMSET = IOCTL.IOW('t', 109, c_int); |
IOCSTART |
pub const IOCSTART = IOCTL.IO('t', 110); |
IOCSTOP |
pub const IOCSTOP = IOCTL.IO('t', 111); |
IOCPKT |
pub const IOCPKT = IOCTL.IOW('t', 112, c_int); |
IOCNOTTY |
pub const IOCNOTTY = IOCTL.IO('t', 113); |
IOCSTI |
pub const IOCSTI = IOCTL.IOW('t', 114, c_char); |
IOCOUTQ |
pub const IOCOUTQ = IOCTL.IOR('t', 115, c_int); |
IOCCBRK |
pub const IOCCBRK = IOCTL.IO('t', 122); |
IOCSBRK |
pub const IOCSBRK = IOCTL.IO('t', 123); |
IOCSPGRP |
pub const IOCSPGRP = IOCTL.IOW('t', 130, c_int); |
IOCGPGRP |
pub const IOCGPGRP = IOCTL.IOR('t', 131, c_int); |
IOCSCTTY |
pub const IOCSCTTY = IOCTL.IO('t', 132); |
IOCGSID |
pub const IOCGSID = IOCTL.IOR('t', 133, c_int); |
IOCGPTN |
pub const IOCGPTN = IOCTL.IOR('t', 134, c_uint); |
IOCSPTLCK |
pub const IOCSPTLCK = IOCTL.IOW('t', 135, c_int); |
IOCSIG |
pub const IOCSIG = IOCTL.IOW('t', 136, c_int); |
IOCGPTPEER |
pub const IOCGPTPEER = IOCTL.IO('t', 137); |
FIOCLEX |
pub const FIOCLEX = IOCTL.IO('f', 1); |
FIONCLEX |
pub const FIONCLEX = IOCTL.IO('f', 2); |
FIOASYNC |
pub const FIOASYNC = IOCTL.IOW('f', 125, c_int); |
FIONBIO |
pub const FIONBIO = IOCTL.IOW('f', 126, c_int); |
FIONREAD |
pub const FIONREAD = IOCTL.IOR('f', 127, c_int); |
IOCINQ |
pub const IOCINQ = FIONREAD; |
FIOQSIZE |
pub const FIOQSIZE = IOCTL.IOR('f', 128, c_longlong); // loff_t -> __kernel_loff_t -> long long |
IOCLINUX |
|
IOCLINUX |
pub const IOCLINUX = 0x541c; |
IOCGSERIAL |
pub const IOCGSERIAL = 0x541e; |
IOCSSERIAL |
pub const IOCSSERIAL = 0x541f; |
CSBRKP |
pub const CSBRKP = 0x5425; |
IOCSERCONFIG |
pub const IOCSERCONFIG = 0x5453; |
IOCSERGWILD |
pub const IOCSERGWILD = 0x5454; |
IOCSERSWILD |
pub const IOCSERSWILD = 0x5455; |
IOCGLCKTRMIOS |
pub const IOCGLCKTRMIOS = 0x5456; |
IOCSLCKTRMIOS |
pub const IOCSLCKTRMIOS = 0x5457; |
IOCSERGSTRUCT |
pub const IOCSERGSTRUCT = 0x5458; |
IOCSERGETLSR |
pub const IOCSERGETLSR = 0x5459; |
IOCSERGETMULTI |
pub const IOCSERGETMULTI = 0x545a; |
IOCSERSETMULTI |
pub const IOCSERSETMULTI = 0x545b; |
IOCMIWAIT |
pub const IOCMIWAIT = 0x545c; |
IOCGICOUNT |
pub const IOCGICOUNT = 0x545d; |
IOCPKT_FLUSHREAD |
|
IOCPKT_DATA |
pub const IOCPKT_DATA = 0; |
IOCPKT_FLUSHREAD |
pub const IOCPKT_FLUSHREAD = 1; |
IOCPKT_FLUSHWRITE |
pub const IOCPKT_FLUSHWRITE = 2; |
IOCPKT_STOP |
pub const IOCPKT_STOP = 4; |
IOCPKT_START |
pub const IOCPKT_START = 8; |
IOCPKT_NOSTOP |
pub const IOCPKT_NOSTOP = 16; |
IOCPKT_DOSTOP |
pub const IOCPKT_DOSTOP = 32; |
IOCPKT_IOCTL |
pub const IOCPKT_IOCTL = 64; } else struct { pub const CGETS = 0x5401; pub const CSETS = 0x5402; |
CSETSW |
pub const CSETSW = 0x5403; |
CSETSF |
pub const CSETSF = 0x5404; |
CGETA |
pub const CGETA = 0x5405; |
CSETA |
pub const CSETA = 0x5406; |
CSETAW |
pub const CSETAW = 0x5407; |
CSETAF |
pub const CSETAF = 0x5408; |
CSBRK |
pub const CSBRK = 0x5409; |
CXONC |
pub const CXONC = 0x540a; |
CFLSH |
pub const CFLSH = 0x540b; |
IOCEXCL |
pub const IOCEXCL = 0x540c; |
IOCNXCL |
pub const IOCNXCL = 0x540d; |
IOCSCTTY |
pub const IOCSCTTY = 0x540e; |
IOCGPGRP |
pub const IOCGPGRP = 0x540f; |
IOCSPGRP |
pub const IOCSPGRP = 0x5410; |
IOCOUTQ |
pub const IOCOUTQ = 0x5411; |
IOCSTI |
pub const IOCSTI = 0x5412; |
IOCGWINSZ |
pub const IOCGWINSZ = 0x5413; |
IOCSWINSZ |
pub const IOCSWINSZ = 0x5414; |
IOCMGET |
pub const IOCMGET = 0x5415; |
IOCMBIS |
pub const IOCMBIS = 0x5416; |
IOCMBIC |
pub const IOCMBIC = 0x5417; |
IOCMSET |
pub const IOCMSET = 0x5418; |
IOCGSOFTCAR |
pub const IOCGSOFTCAR = 0x5419; |
IOCSSOFTCAR |
pub const IOCSSOFTCAR = 0x541a; |
FIONREAD |
pub const FIONREAD = 0x541b; |
IOCINQ |
pub const IOCINQ = FIONREAD; |
IOCLINUX |
pub const IOCLINUX = 0x541c; |
IOCCONS |
pub const IOCCONS = 0x541d; |
IOCGSERIAL |
pub const IOCGSERIAL = 0x541e; |
IOCSSERIAL |
pub const IOCSSERIAL = 0x541f; |
IOCPKT |
pub const IOCPKT = 0x5420; |
FIONBIO |
pub const FIONBIO = 0x5421; |
IOCNOTTY |
pub const IOCNOTTY = 0x5422; |
IOCSETD |
pub const IOCSETD = 0x5423; |
IOCGETD |
pub const IOCGETD = 0x5424; |
CSBRKP |
pub const CSBRKP = 0x5425; |
IOCSBRK |
pub const IOCSBRK = 0x5427; |
IOCCBRK |
pub const IOCCBRK = 0x5428; |
IOCGSID |
pub const IOCGSID = 0x5429; |
CGETS2 |
pub const CGETS2 = IOCTL.IOR('T', 0x2a, termios2); |
CSETS2 |
pub const CSETS2 = IOCTL.IOW('T', 0x2b, termios2); |
CSETSW2 |
pub const CSETSW2 = IOCTL.IOW('T', 0x2c, termios2); |
CSETSF2 |
pub const CSETSF2 = IOCTL.IOW('T', 0x2d, termios2); |
IOCGRS485 |
pub const IOCGRS485 = 0x542e; |
IOCSRS485 |
pub const IOCSRS485 = 0x542f; |
IOCGPTN |
pub const IOCGPTN = IOCTL.IOR('T', 0x30, c_uint); |
IOCSPTLCK |
pub const IOCSPTLCK = IOCTL.IOW('T', 0x31, c_int); |
IOCGDEV |
pub const IOCGDEV = IOCTL.IOR('T', 0x32, c_uint); |
CGETX |
pub const CGETX = 0x5432; |
CSETX |
pub const CSETX = 0x5433; |
CSETXF |
pub const CSETXF = 0x5434; |
CSETXW |
pub const CSETXW = 0x5435; |
IOCSIG |
pub const IOCSIG = IOCTL.IOW('T', 0x36, c_int); |
IOCVHANGUP |
pub const IOCVHANGUP = 0x5437; |
IOCGPKT |
pub const IOCGPKT = IOCTL.IOR('T', 0x38, c_int); |
IOCGPTLCK |
pub const IOCGPTLCK = IOCTL.IOR('T', 0x39, c_int); |
IOCGEXCL |
pub const IOCGEXCL = IOCTL.IOR('T', 0x40, c_int); |
IOCGPTPEER |
pub const IOCGPTPEER = IOCTL.IO('T', 0x41); |
IOCGISO7816 |
pub const IOCGISO7816 = IOCTL.IOR('T', 0x42, serial_iso7816); |
IOCSISO7816 |
pub const IOCSISO7816 = IOCTL.IOWR('T', 0x43, serial_iso7816); |
FIONCLEX |
pub const FIONCLEX = 0x5450; |
FIOCLEX |
pub const FIOCLEX = 0x5451; |
FIOASYNC |
pub const FIOASYNC = 0x5452; |
IOCSERCONFIG |
pub const IOCSERCONFIG = 0x5453; |
IOCSERGWILD |
pub const IOCSERGWILD = 0x5454; |
IOCSERSWILD |
pub const IOCSERSWILD = 0x5455; |
IOCGLCKTRMIOS |
pub const IOCGLCKTRMIOS = 0x5456; |
IOCSLCKTRMIOS |
pub const IOCSLCKTRMIOS = 0x5457; |
IOCSERGSTRUCT |
pub const IOCSERGSTRUCT = 0x5458; |
IOCSERGETLSR |
pub const IOCSERGETLSR = 0x5459; |
IOCSERGETMULTI |
pub const IOCSERGETMULTI = 0x545a; |
IOCSERSETMULTI |
pub const IOCSERSETMULTI = 0x545b; |
IOCMIWAIT |
pub const IOCMIWAIT = 0x545c; |
IOCGICOUNT |
pub const IOCGICOUNT = 0x545d; |
FIOQSIZE |
pub const FIOQSIZE = switch (native_arch) { .arm, .armeb, .thumb, .thumbeb, .m68k, .s390x, => 0x545e, else => 0x5460, }; |
IOCPKT_DATA |
pub const IOCPKT_DATA = 0; |
IOCPKT_FLUSHREAD |
pub const IOCPKT_FLUSHREAD = 1; |
IOCPKT_FLUSHWRITE |
pub const IOCPKT_FLUSHWRITE = 2; |
IOCPKT_STOP |
pub const IOCPKT_STOP = 4; |
IOCPKT_START |
pub const IOCPKT_START = 8; |
IOCPKT_NOSTOP |
pub const IOCPKT_NOSTOP = 16; |
IOCPKT_DOSTOP |
pub const IOCPKT_DOSTOP = 32; |
IOCPKT_IOCTL |
pub const IOCPKT_IOCTL = 64; |
IOCSER_TEMT |
pub const IOCSER_TEMT = 0x01; }; |
serial_rs485 |
pub const serial_rs485 = extern struct { flags: u32, delay_rts_before_send: u32, delay_rts_after_send: u32, extra: extern union { _pad1: [5]u32, s: extern struct { addr_recv: u8, addr_dest: u8, _pad2: [2]u8, _pad3: [4]u32, }, }, }; |
serial_iso7816 |
pub const serial_iso7816 = extern struct { flags: u32, tg: u32, sc_fi: u32, sc_di: u32, clk: u32, _reserved: [5]u32, }; |
SER |
pub const SER = struct { |
RS485 |
pub const RS485 = struct { |
ENABLED |
pub const ENABLED = 1 << 0; |
RTS_ON_SEND |
pub const RTS_ON_SEND = 1 << 1; |
RTS_AFTER_SEND |
pub const RTS_AFTER_SEND = 1 << 2; |
RX_DURING_TX |
pub const RX_DURING_TX = 1 << 4; |
TERMINATE_BUS |
pub const TERMINATE_BUS = 1 << 5; |
ADDRB |
pub const ADDRB = 1 << 6; |
ADDR_RECV |
pub const ADDR_RECV = 1 << 7; |
ADDR_DEST |
pub const ADDR_DEST = 1 << 8; }; |
ISO7816 |
pub const ISO7816 = struct { |
ENABLED |
pub const ENABLED = 1 << 0; |
T_PARAM |
pub const T_PARAM = 0x0f << 4; |
T() |
pub fn T(t: anytype) @TypeOf(t) { return (t & 0x0f) << 4; } }; }; |
EPOLL |
pub const EPOLL = struct { |
CLOEXEC |
pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC"); |
CTL_ADD |
pub const CTL_ADD = 1; |
CTL_DEL |
pub const CTL_DEL = 2; |
CTL_MOD |
pub const CTL_MOD = 3; |
IN |
|
IN |
pub const IN = 0x001; |
PRI |
pub const PRI = 0x002; |
OUT |
pub const OUT = 0x004; |
RDNORM |
pub const RDNORM = 0x040; |
RDBAND |
pub const RDBAND = 0x080; pub const WRNORM = if (is_mips) 0x004 else 0x100; |
WRBAND |
pub const WRBAND = if (is_mips) 0x100 else 0x200; |
MSG |
pub const MSG = 0x400; |
ERR |
pub const ERR = 0x008; |
HUP |
pub const HUP = 0x010; |
RDHUP |
pub const RDHUP = 0x2000; |
EXCLUSIVE |
pub const EXCLUSIVE = (@as(u32, 1) << 28); |
WAKEUP |
pub const WAKEUP = (@as(u32, 1) << 29); |
ONESHOT |
pub const ONESHOT = (@as(u32, 1) << 30); |
ET |
pub const ET = (@as(u32, 1) << 31); }; |
CLOCK |
pub const CLOCK = clockid_t; |
clockid_t |
pub const clockid_t = enum(u32) { 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, // In the linux kernel header file (time.h) is the following note: // * The driver implementing this got removed. The clock ID is kept as a // * place holder. Do not reuse! // Therefore, calling clock_gettime() with these IDs will result in an error. // // Some backgrond: // - SGI_CYCLE was for Silicon Graphics (SGI) workstations, // which are probably no longer in use, so it makes sense to disable // - TAI_CLOCK was designed as CLOCK_REALTIME(UTC) + tai_offset, // but tai_offset was always 0 in the kernel. // So there is no point in using this clock. // SGI_CYCLE = 10, // TAI = 11, _, }; |
TIMERFD_CLOCK |
// For use with posix.timerfd_create() // Actually, the parameter for the timerfd_create() function is in integer, // which means that the developer has to figure out which value is appropriate. // To make this easier and, above all, safer, because an incorrect value leads // to a panic, an enum is introduced which only allows the values // that actually work. pub const TIMERFD_CLOCK = timerfd_clockid_t; |
timerfd_clockid_t |
pub const timerfd_clockid_t = enum(u32) { REALTIME = 0, MONOTONIC = 1, BOOTTIME = 7, REALTIME_ALARM = 8, BOOTTIME_ALARM = 9, _, }; |
TIMER |
pub const TIMER = packed struct(u32) { ABSTIME: bool, _: u31 = 0, }; |
CSIGNAL |
pub const CSIGNAL = 0x000000ff; |
CLONE |
pub const CLONE = struct { |
VM |
pub const VM = 0x00000100; |
FS |
pub const FS = 0x00000200; |
FILES |
pub const FILES = 0x00000400; |
SIGHAND |
pub const SIGHAND = 0x00000800; |
PIDFD |
pub const PIDFD = 0x00001000; |
PTRACE |
pub const PTRACE = 0x00002000; |
VFORK |
pub const VFORK = 0x00004000; |
PARENT |
pub const PARENT = 0x00008000; |
THREAD |
pub const THREAD = 0x00010000; |
NEWNS |
pub const NEWNS = 0x00020000; |
SYSVSEM |
pub const SYSVSEM = 0x00040000; |
SETTLS |
pub const SETTLS = 0x00080000; |
PARENT_SETTID |
pub const PARENT_SETTID = 0x00100000; |
CHILD_CLEARTID |
pub const CHILD_CLEARTID = 0x00200000; |
DETACHED |
pub const DETACHED = 0x00400000; |
UNTRACED |
pub const UNTRACED = 0x00800000; |
CHILD_SETTID |
pub const CHILD_SETTID = 0x01000000; |
NEWCGROUP |
pub const NEWCGROUP = 0x02000000; |
NEWUTS |
pub const NEWUTS = 0x04000000; |
NEWIPC |
pub const NEWIPC = 0x08000000; |
NEWUSER |
pub const NEWUSER = 0x10000000; |
NEWPID |
pub const NEWPID = 0x20000000; |
NEWNET |
pub const NEWNET = 0x40000000; |
IO |
pub const IO = 0x80000000; |
CLEAR_SIGHAND |
// Flags for the clone3() syscall. |
INTO_CGROUP |
/// Clear any signal handler and reset to SIG_DFL. pub const CLEAR_SIGHAND = 0x100000000; /// Clone into a specific cgroup given the right permissions. pub const INTO_CGROUP = 0x200000000; |
NEWTIME |
// cloning flags intersect with CSIGNAL so can be used with unshare and clone3 syscalls only. |
EFD |
/// New time namespace pub const NEWTIME = 0x00000080; }; |
SEMAPHORE |
pub const EFD = struct { pub const SEMAPHORE = 1; |
CLOEXEC |
pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC"); |
NONBLOCK |
pub const NONBLOCK = 1 << @bitOffsetOf(O, "NONBLOCK"); }; |
MS |
pub const MS = struct { |
RDONLY |
pub const RDONLY = 1; |
NOSUID |
pub const NOSUID = 2; |
NODEV |
pub const NODEV = 4; |
NOEXEC |
pub const NOEXEC = 8; |
SYNCHRONOUS |
pub const SYNCHRONOUS = 16; |
REMOUNT |
pub const REMOUNT = 32; |
MANDLOCK |
pub const MANDLOCK = 64; |
DIRSYNC |
pub const DIRSYNC = 128; |
NOATIME |
pub const NOATIME = 1024; |
NODIRATIME |
pub const NODIRATIME = 2048; |
BIND |
pub const BIND = 4096; |
MOVE |
pub const MOVE = 8192; |
REC |
pub const REC = 16384; |
SILENT |
pub const SILENT = 32768; |
POSIXACL |
pub const POSIXACL = (1 << 16); |
UNBINDABLE |
pub const UNBINDABLE = (1 << 17); |
PRIVATE |
pub const PRIVATE = (1 << 18); |
SLAVE |
pub const SLAVE = (1 << 19); |
SHARED |
pub const SHARED = (1 << 20); |
RELATIME |
pub const RELATIME = (1 << 21); |
KERNMOUNT |
pub const KERNMOUNT = (1 << 22); |
I_VERSION |
pub const I_VERSION = (1 << 23); |
STRICTATIME |
pub const STRICTATIME = (1 << 24); |
LAZYTIME |
pub const LAZYTIME = (1 << 25); |
NOREMOTELOCK |
pub const NOREMOTELOCK = (1 << 27); |
NOSEC |
pub const NOSEC = (1 << 28); |
BORN |
pub const BORN = (1 << 29); |
ACTIVE |
pub const ACTIVE = (1 << 30); |
NOUSER |
pub const NOUSER = (1 << 31); |
RMT_MASK |
pub const RMT_MASK = (RDONLY | SYNCHRONOUS | MANDLOCK | I_VERSION | LAZYTIME); |
MGC_VAL |
pub const MGC_VAL = 0xc0ed0000; |
MGC_MSK |
pub const MGC_MSK = 0xffff0000; }; |
MNT |
pub const MNT = struct { |
FORCE |
pub const FORCE = 1; |
DETACH |
pub const DETACH = 2; |
EXPIRE |
pub const EXPIRE = 4; }; |
UMOUNT_NOFOLLOW |
pub const UMOUNT_NOFOLLOW = 8; |
IN |
pub const IN = struct { |
CLOEXEC |
pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC"); |
NONBLOCK |
pub const NONBLOCK = 1 << @bitOffsetOf(O, "NONBLOCK"); |
ACCESS |
pub const ACCESS = 0x00000001; |
MODIFY |
pub const MODIFY = 0x00000002; |
ATTRIB |
pub const ATTRIB = 0x00000004; |
CLOSE_WRITE |
pub const CLOSE_WRITE = 0x00000008; |
CLOSE_NOWRITE |
pub const CLOSE_NOWRITE = 0x00000010; |
CLOSE |
pub const CLOSE = CLOSE_WRITE | CLOSE_NOWRITE; |
OPEN |
pub const OPEN = 0x00000020; |
MOVED_FROM |
pub const MOVED_FROM = 0x00000040; |
MOVED_TO |
pub const MOVED_TO = 0x00000080; |
MOVE |
pub const MOVE = MOVED_FROM | MOVED_TO; |
CREATE |
pub const CREATE = 0x00000100; |
DELETE |
pub const DELETE = 0x00000200; |
DELETE_SELF |
pub const DELETE_SELF = 0x00000400; |
MOVE_SELF |
pub const MOVE_SELF = 0x00000800; |
ALL_EVENTS |
pub const ALL_EVENTS = 0x00000fff; |
UNMOUNT |
pub const UNMOUNT = 0x00002000; |
Q_OVERFLOW |
pub const Q_OVERFLOW = 0x00004000; |
IGNORED |
pub const IGNORED = 0x00008000; |
ONLYDIR |
pub const ONLYDIR = 0x01000000; |
DONT_FOLLOW |
pub const DONT_FOLLOW = 0x02000000; |
EXCL_UNLINK |
pub const EXCL_UNLINK = 0x04000000; |
MASK_CREATE |
pub const MASK_CREATE = 0x10000000; |
MASK_ADD |
pub const MASK_ADD = 0x20000000; |
ISDIR |
pub const ISDIR = 0x40000000; |
ONESHOT |
pub const ONESHOT = 0x80000000; }; |
fanotify |
pub const fanotify = struct { |
InitFlags |
pub const InitFlags = packed struct(u32) { CLOEXEC: bool = false, NONBLOCK: bool = false, CLASS: enum(u2) { NOTIF = 0, CONTENT = 1, PRE_CONTENT = 2, } = .NOTIF, UNLIMITED_QUEUE: bool = false, UNLIMITED_MARKS: bool = false, ENABLE_AUDIT: bool = false, REPORT_PIDFD: bool = false, REPORT_TID: bool = false, REPORT_FID: bool = false, REPORT_DIR_FID: bool = false, REPORT_NAME: bool = false, REPORT_TARGET_FID: bool = false, _: u19 = 0, }; |
MarkFlags |
pub const MarkFlags = packed struct(u32) { ADD: bool = false, REMOVE: bool = false, DONT_FOLLOW: bool = false, ONLYDIR: bool = false, MOUNT: bool = false, /// Mutually exclusive with `IGNORE` IGNORED_MASK: bool = false, IGNORED_SURV_MODIFY: bool = false, FLUSH: bool = false, FILESYSTEM: bool = false, EVICTABLE: bool = false, /// Mutually exclusive with `IGNORED_MASK` IGNORE: bool = false, _: u21 = 0, }; |
MarkMask |
pub const MarkMask = packed struct(u64) { /// File was accessed ACCESS: bool = false, /// File was modified MODIFY: bool = false, /// Metadata changed ATTRIB: bool = false, /// Writtable file closed CLOSE_WRITE: bool = false, /// Unwrittable file closed CLOSE_NOWRITE: bool = false, /// File was opened OPEN: bool = false, /// File was moved from X MOVED_FROM: bool = false, /// File was moved to Y MOVED_TO: bool = false, |
event_metadata |
/// Subfile was created CREATE: bool = false, /// Subfile was deleted DELETE: bool = false, /// Self was deleted DELETE_SELF: bool = false, /// Self was moved MOVE_SELF: bool = false, /// File was opened for exec OPEN_EXEC: bool = false, reserved13: u1 = 0, /// Event queued overflowed Q_OVERFLOW: bool = false, /// Filesystem error FS_ERROR: bool = false, |
VERSION |
/// File open in perm check OPEN_PERM: bool = false, /// File accessed in perm check ACCESS_PERM: bool = false, /// File open/exec in perm check OPEN_EXEC_PERM: bool = false, reserved19: u8 = 0, /// Interested in child events EVENT_ON_CHILD: bool = false, /// File was renamed RENAME: bool = false, reserved30: u1 = 0, /// Event occurred against dir ONDIR: bool = false, reserved31: u33 = 0, }; |
response |
pub const event_metadata = extern struct { event_len: u32, vers: u8, reserved: u8, metadata_len: u16, mask: MarkMask align(8), fd: i32, pid: i32, |
event_info_fid |
pub const VERSION = 3; }; |
event_info_header |
pub const response = extern struct { fd: i32, response: u32, }; |
EVENT_INFO_TYPE |
/// Unique file identifier info record. /// /// This structure is used for records of types `EVENT_INFO_TYPE.FID`. /// `EVENT_INFO_TYPE.DFID` and `EVENT_INFO_TYPE.DFID_NAME`. /// /// For `EVENT_INFO_TYPE.DFID_NAME` there is additionally a null terminated /// name immediately after the file handle. pub const event_info_fid = extern struct { hdr: event_info_header, fsid: kernel_fsid_t, /// Following is an opaque struct file_handle that can be passed as /// an argument to open_by_handle_at(2). handle: [0]u8, }; |
file_handle |
/// Variable length info record following event metadata. pub const event_info_header = extern struct { info_type: EVENT_INFO_TYPE, pad: u8, len: u16, }; |
kernel_fsid_t |
pub const EVENT_INFO_TYPE = enum(u8) { FID = 1, DFID_NAME = 2, DFID = 3, PIDFD = 4, ERROR = 5, OLD_DFID_NAME = 10, OLD_DFID = 11, NEW_DFID_NAME = 12, NEW_DFID = 13, }; }; |
fsid_t |
pub const file_handle = extern struct { handle_bytes: u32, handle_type: i32, f_handle: [0]u8, }; |
S |
pub const kernel_fsid_t = fsid_t; pub const fsid_t = [2]i32; |
IFMT |
pub const S = struct { pub const IFMT = 0o170000; |
IFDIR |
pub const IFDIR = 0o040000; |
IFCHR |
pub const IFCHR = 0o020000; |
IFBLK |
pub const IFBLK = 0o060000; |
IFREG |
pub const IFREG = 0o100000; |
IFIFO |
pub const IFIFO = 0o010000; |
IFLNK |
pub const IFLNK = 0o120000; |
IFSOCK |
pub const IFSOCK = 0o140000; |
ISUID |
pub const ISUID = 0o4000; |
ISGID |
pub const ISGID = 0o2000; |
ISVTX |
pub const ISVTX = 0o1000; |
IRUSR |
pub const IRUSR = 0o400; |
IWUSR |
pub const IWUSR = 0o200; |
IXUSR |
pub const IXUSR = 0o100; |
IRWXU |
pub const IRWXU = 0o700; |
IRGRP |
pub const IRGRP = 0o040; |
IWGRP |
pub const IWGRP = 0o020; |
IXGRP |
pub const IXGRP = 0o010; |
IRWXG |
pub const IRWXG = 0o070; |
IROTH |
pub const IROTH = 0o004; |
IWOTH |
pub const IWOTH = 0o002; |
IXOTH |
pub const IXOTH = 0o001; |
IRWXO |
pub const IRWXO = 0o007; |
ISREG() |
pub fn ISREG(m: mode_t) bool { return m & IFMT == IFREG; } |
ISDIR() |
pub fn ISDIR(m: mode_t) bool { return m & IFMT == IFDIR; } |
ISCHR() |
pub fn ISCHR(m: mode_t) bool { return m & IFMT == IFCHR; } |
ISBLK() |
pub fn ISBLK(m: mode_t) bool { return m & IFMT == IFBLK; } |
ISFIFO() |
pub fn ISFIFO(m: mode_t) bool { return m & IFMT == IFIFO; } |
ISLNK() |
pub fn ISLNK(m: mode_t) bool { return m & IFMT == IFLNK; } |
ISSOCK() |
pub fn ISSOCK(m: mode_t) bool { return m & IFMT == IFSOCK; } }; |
UTIME |
pub const UTIME = struct { |
NOW |
pub const NOW = 0x3fffffff; |
OMIT |
pub const OMIT = 0x3ffffffe; }; |
TFD |
const TFD_TIMER = packed struct(u32) { ABSTIME: bool = false, CANCEL_ON_SET: bool = false, _: u30 = 0, }; |
TIMER |
pub const TFD = switch (native_arch) { .sparc64 => packed struct(u32) { _0: u14 = 0, NONBLOCK: bool = false, _15: u7 = 0, CLOEXEC: bool = false, _: u9 = 0, |
TIMER |
|
TIMER |
pub const TIMER = TFD_TIMER; }, .mips, .mipsel, .mips64, .mips64el => packed struct(u32) { _0: u7 = 0, NONBLOCK: bool = false, _8: u11 = 0, CLOEXEC: bool = false, _: u12 = 0, |
k_sigaction |
pub const TIMER = TFD_TIMER; }, else => packed struct(u32) { _0: u11 = 0, NONBLOCK: bool = false, _12: u7 = 0, CLOEXEC: bool = false, _: u12 = 0, |
Sigaction |
pub const TIMER = TFD_TIMER; }, }; |
handler_fn |
const k_sigaction_funcs = struct { const handler = ?*align(1) const fn (i32) callconv(.c) void; const restorer = *const fn () callconv(.c) void; }; |
sigaction_fn |
/// Kernel sigaction struct, as expected by the `rt_sigaction` syscall. Includes restorer. pub const k_sigaction = switch (native_arch) { .mips, .mipsel, .mips64, .mips64el => extern struct { flags: c_uint, handler: k_sigaction_funcs.handler, mask: sigset_t, restorer: k_sigaction_funcs.restorer, }, else => extern struct { handler: k_sigaction_funcs.handler, flags: c_ulong, restorer: k_sigaction_funcs.restorer, mask: sigset_t, }, }; |
SFD |
/// Kernel Sigaction wrapper for the actual ABI `k_sigaction`. The Zig /// linux.zig wrapper library still does some pre-processing on /// sigaction() calls (to add the `restorer` field). /// /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. pub const Sigaction = struct { pub const handler_fn = *align(1) const fn (i32) callconv(.c) void; pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void; |
CLOEXEC |
handler: extern union { handler: ?handler_fn, sigaction: ?sigaction_fn, }, mask: sigset_t, flags: switch (native_arch) { .mips, .mipsel, .mips64, .mips64el => c_uint, else => c_ulong, }, }; |
NONBLOCK |
pub const SFD = struct { pub const CLOEXEC = 1 << @bitOffsetOf(O, "CLOEXEC"); pub const NONBLOCK = 1 << @bitOffsetOf(O, "NONBLOCK"); }; |
signalfd_siginfo |
pub const signalfd_siginfo = extern struct { signo: u32, errno: i32, code: i32, pid: u32, uid: uid_t, fd: i32, tid: u32, band: u32, overrun: u32, trapno: u32, status: i32, int: i32, ptr: u64, utime: u64, stime: u64, addr: u64, addr_lsb: u16, __pad2: u16, syscall: i32, call_addr: u64, native_arch: u32, __pad: [28]u8, }; |
in_port_t |
pub const in_port_t = u16; |
sa_family_t |
pub const sa_family_t = u16; |
socklen_t |
pub const socklen_t = u32; |
sockaddr |
pub const sockaddr = extern struct { family: sa_family_t, data: [14]u8, |
SS_MAXSIZE |
pub const SS_MAXSIZE = 128; |
storage |
pub const storage = extern struct { family: sa_family_t align(8), padding: [SS_MAXSIZE - @sizeOf(sa_family_t)]u8 = undefined, |
in |
comptime { assert(@sizeOf(storage) == SS_MAXSIZE); assert(@alignOf(storage) == 8); } }; |
in6 |
/// IPv4 socket address pub const in = extern struct { family: sa_family_t = AF.INET, port: in_port_t, addr: u32, zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, }; |
un |
/// IPv6 socket address pub const in6 = extern struct { family: sa_family_t = AF.INET6, port: in_port_t, flowinfo: u32, addr: [16]u8, scope_id: u32, }; |
ll |
/// UNIX domain socket address pub const un = extern struct { family: sa_family_t = AF.UNIX, path: [108]u8, }; |
nl |
/// Packet socket address pub const ll = extern struct { family: sa_family_t = AF.PACKET, protocol: u16, ifindex: i32, hatype: u16, pkttype: u8, halen: u8, addr: [8]u8, }; |
xdp |
/// Netlink socket address pub const nl = extern struct { family: sa_family_t = AF.NETLINK, __pad1: c_ushort = 0, |
vm |
/// port ID pid: u32, |
mmsghdr |
/// multicast groups mask groups: u32, }; |
mmsghdr_const |
pub const xdp = extern struct { family: u16 = AF.XDP, flags: u16, ifindex: u32, queue_id: u32, shared_umem_fd: u32, }; |
epoll_data |
/// Address structure for vSockets pub const vm = extern struct { family: sa_family_t = AF.VSOCK, reserved1: u16 = 0, port: u32, cid: u32, flags: u8, |
epoll_event |
/// The total size of this structure should be exactly the same as that of struct sockaddr. zero: [3]u8 = [_]u8{0} ** 3, comptime { std.debug.assert(@sizeOf(vm) == @sizeOf(sockaddr)); } }; }; |
VFS_CAP_REVISION_MASK |
pub const mmsghdr = extern struct { hdr: msghdr, len: u32, }; |
VFS_CAP_REVISION_SHIFT |
pub const mmsghdr_const = extern struct { hdr: msghdr_const, len: u32, }; |
VFS_CAP_FLAGS_MASK |
pub const epoll_data = extern union { ptr: usize, fd: i32, u32: u32, u64: u64, }; |
VFS_CAP_FLAGS_EFFECTIVE |
pub const epoll_event = extern struct { events: u32, data: epoll_data align(switch (native_arch) { .x86_64 => 4, else => @alignOf(epoll_data), }), }; |
VFS_CAP_REVISION_1 |
pub const VFS_CAP_REVISION_MASK = 0xFF000000; pub const VFS_CAP_REVISION_SHIFT = 24; pub const VFS_CAP_FLAGS_MASK = ~@as(u32, VFS_CAP_REVISION_MASK); pub const VFS_CAP_FLAGS_EFFECTIVE = 0x000001; |
VFS_CAP_U32_1 |
pub const VFS_CAP_REVISION_1 = 0x01000000; pub const VFS_CAP_U32_1 = 1; |
XATTR_CAPS_SZ_1 |
pub const XATTR_CAPS_SZ_1 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_1); |
VFS_CAP_REVISION_2 |
pub const VFS_CAP_REVISION_2 = 0x02000000; |
VFS_CAP_U32_2 |
pub const VFS_CAP_U32_2 = 2; |
XATTR_CAPS_SZ_2 |
pub const XATTR_CAPS_SZ_2 = @sizeOf(u32) * (1 + 2 * VFS_CAP_U32_2); |
XATTR_CAPS_SZ |
pub const XATTR_CAPS_SZ = XATTR_CAPS_SZ_2; |
VFS_CAP_U32 |
pub const VFS_CAP_U32 = VFS_CAP_U32_2; |
VFS_CAP_REVISION |
pub const VFS_CAP_REVISION = VFS_CAP_REVISION_2; |
vfs_cap_data |
pub const vfs_cap_data = extern struct { //all of these are mandated as little endian //when on disk. const Data = extern struct { permitted: u32, inheritable: u32, }; |
CAP |
magic_etc: u32, data: [VFS_CAP_U32]Data, }; |
CHOWN |
pub const CAP = struct { pub const CHOWN = 0; |
DAC_OVERRIDE |
pub const DAC_OVERRIDE = 1; |
DAC_READ_SEARCH |
pub const DAC_READ_SEARCH = 2; |
FOWNER |
pub const FOWNER = 3; |
FSETID |
pub const FSETID = 4; |
KILL |
pub const KILL = 5; |
SETGID |
pub const SETGID = 6; |
SETUID |
pub const SETUID = 7; |
SETPCAP |
pub const SETPCAP = 8; |
LINUX_IMMUTABLE |
pub const LINUX_IMMUTABLE = 9; |
NET_BIND_SERVICE |
pub const NET_BIND_SERVICE = 10; |
NET_BROADCAST |
pub const NET_BROADCAST = 11; |
NET_ADMIN |
pub const NET_ADMIN = 12; |
NET_RAW |
pub const NET_RAW = 13; |
IPC_LOCK |
pub const IPC_LOCK = 14; |
IPC_OWNER |
pub const IPC_OWNER = 15; |
SYS_MODULE |
pub const SYS_MODULE = 16; |
SYS_RAWIO |
pub const SYS_RAWIO = 17; |
SYS_CHROOT |
pub const SYS_CHROOT = 18; |
SYS_PTRACE |
pub const SYS_PTRACE = 19; |
SYS_PACCT |
pub const SYS_PACCT = 20; |
SYS_ADMIN |
pub const SYS_ADMIN = 21; |
SYS_BOOT |
pub const SYS_BOOT = 22; |
SYS_NICE |
pub const SYS_NICE = 23; |
SYS_RESOURCE |
pub const SYS_RESOURCE = 24; |
SYS_TIME |
pub const SYS_TIME = 25; |
SYS_TTY_CONFIG |
pub const SYS_TTY_CONFIG = 26; |
MKNOD |
pub const MKNOD = 27; |
LEASE |
pub const LEASE = 28; |
AUDIT_WRITE |
pub const AUDIT_WRITE = 29; |
AUDIT_CONTROL |
pub const AUDIT_CONTROL = 30; |
SETFCAP |
pub const SETFCAP = 31; |
MAC_OVERRIDE |
pub const MAC_OVERRIDE = 32; |
MAC_ADMIN |
pub const MAC_ADMIN = 33; |
SYSLOG |
pub const SYSLOG = 34; |
WAKE_ALARM |
pub const WAKE_ALARM = 35; |
BLOCK_SUSPEND |
pub const BLOCK_SUSPEND = 36; |
AUDIT_READ |
pub const AUDIT_READ = 37; |
PERFMON |
pub const PERFMON = 38; |
BPF |
pub const BPF = 39; |
CHECKPOINT_RESTORE |
pub const CHECKPOINT_RESTORE = 40; |
LAST_CAP |
pub const LAST_CAP = CHECKPOINT_RESTORE; |
valid() |
pub fn valid(x: u8) bool { return x >= 0 and x <= LAST_CAP; } |
TO_MASK() |
pub fn TO_MASK(cap: u8) u32 { return @as(u32, 1) << @as(u5, @intCast(cap & 31)); } |
TO_INDEX() |
pub fn TO_INDEX(cap: u8) u8 { return cap >> 5; } }; |
cap_t |
pub const cap_t = extern struct { hdrp: *cap_user_header_t, datap: *cap_user_data_t, }; |
cap_user_header_t |
pub const cap_user_header_t = extern struct { version: u32, pid: usize, }; |
cap_user_data_t |
pub const cap_user_data_t = extern struct { effective: u32, permitted: u32, inheritable: u32, }; |
inotify_event |
pub const inotify_event = extern struct { wd: i32, mask: u32, cookie: u32, len: u32, //name: [?]u8, |
getName() |
// if an event is returned for a directory or file inside the directory being watched // returns the name of said directory/file // returns `null` if the directory/file is the one being watched pub fn getName(self: *const inotify_event) ?[:0]const u8 { if (self.len == 0) return null; return std.mem.span(@as([*:0]const u8, @ptrCast(self)) + @sizeOf(inotify_event)); } }; |
dirent64 |
pub const dirent64 = extern struct { ino: u64, off: u64, reclen: u16, type: u8, name: u8, // field address is the address of first byte of name https://github.com/ziglang/zig/issues/173 }; |
dl_phdr_info |
pub const dl_phdr_info = extern struct { addr: usize, name: ?[*:0]const u8, phdr: [*]std.elf.Phdr, phnum: u16, }; |
CPU_SETSIZE |
pub const CPU_SETSIZE = 128; |
cpu_set_t |
pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; |
cpu_count_t |
pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8)); |
CPU_COUNT() |
pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { var sum: cpu_count_t = 0; for (set) |x| { sum += @popCount(x); } return sum; } |
MINSIGSTKSZ |
pub const MINSIGSTKSZ = switch (native_arch) { .arc, .arm, .armeb, .csky, .hexagon, .m68k, .mips, .mipsel, .mips64, .mips64el, .powerpc, .powerpcle, .riscv32, .riscv64, .s390x, .thumb, .thumbeb, .x86, .x86_64, .xtensa, => 2048, .loongarch64, .sparc, .sparc64, => 4096, .aarch64, .aarch64_be, => 5120, .powerpc64, .powerpc64le, => 8192, else => @compileError("MINSIGSTKSZ not defined for this architecture"), }; |
SIGSTKSZ |
pub const SIGSTKSZ = switch (native_arch) { .arc, .arm, .armeb, .csky, .hexagon, .m68k, .mips, .mipsel, .mips64, .mips64el, .powerpc, .powerpcle, .riscv32, .riscv64, .s390x, .thumb, .thumbeb, .x86, .x86_64, .xtensa, => 8192, .aarch64, .aarch64_be, .loongarch64, .sparc, .sparc64, => 16384, .powerpc64, .powerpc64le, => 32768, else => @compileError("SIGSTKSZ not defined for this architecture"), }; |
SS |
pub const SS = struct { |
ONSTACK |
pub const ONSTACK = 1; |
DISABLE |
pub const DISABLE = 2; |
AUTODISARM |
pub const AUTODISARM = 1 << 31; }; |
stack_t |
pub const stack_t = if (is_mips) // IRIX compatible stack_t extern struct { sp: [*]u8, size: usize, flags: i32, } |
NCC |
else extern struct { sp: [*]u8, flags: i32, size: usize, }; |
siginfo_t |
pub const sigval = extern union { int: i32, ptr: *anyopaque, }; |
IORING_SETUP_IOPOLL |
const siginfo_fields_union = extern union { pad: [128 - 2 * @sizeOf(c_int) - @sizeOf(c_long)]u8, common: extern struct { first: extern union { piduid: extern struct { pid: pid_t, uid: uid_t, }, timer: extern struct { timerid: i32, overrun: i32, }, }, second: extern union { value: sigval, sigchld: extern struct { status: i32, utime: clock_t, stime: clock_t, }, }, }, sigfault: extern struct { addr: *allowzero anyopaque, addr_lsb: i16, first: extern union { addr_bnd: extern struct { lower: *anyopaque, upper: *anyopaque, }, pkey: u32, }, }, sigpoll: extern struct { band: isize, fd: i32, }, sigsys: extern struct { call_addr: *anyopaque, syscall: i32, native_arch: u32, }, }; |
IORING_SETUP_SQPOLL |
pub const siginfo_t = if (is_mips) extern struct { signo: i32, code: i32, errno: i32, fields: siginfo_fields_union, } |
NCC |
else extern struct { signo: i32, errno: i32, code: i32, fields: siginfo_fields_union, }; |
IORING_SETUP_CQSIZE |
// io_uring_params.flags |
IORING_SETUP_CLAMP |
/// io_context is polled pub const IORING_SETUP_IOPOLL = 1 << 0; |
IORING_SETUP_ATTACH_WQ |
/// SQ poll thread pub const IORING_SETUP_SQPOLL = 1 << 1; |
IORING_SETUP_R_DISABLED |
/// sq_thread_cpu is valid pub const IORING_SETUP_SQ_AFF = 1 << 2; |
IORING_SETUP_SUBMIT_ALL |
/// app defines CQ size pub const IORING_SETUP_CQSIZE = 1 << 3; |
IORING_SETUP_COOP_TASKRUN |
/// clamp SQ/CQ ring sizes pub const IORING_SETUP_CLAMP = 1 << 4; |
IORING_SETUP_TASKRUN_FLAG |
/// attach to existing wq pub const IORING_SETUP_ATTACH_WQ = 1 << 5; |
IORING_SETUP_SQE128 |
/// start with ring disabled pub const IORING_SETUP_R_DISABLED = 1 << 6; |
IORING_SETUP_CQE32 |
/// continue submit on error pub const IORING_SETUP_SUBMIT_ALL = 1 << 7; |
IORING_SETUP_SINGLE_ISSUER |
/// 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. pub const IORING_SETUP_COOP_TASKRUN = 1 << 8; |
IORING_SETUP_DEFER_TASKRUN |
/// 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. pub const IORING_SETUP_TASKRUN_FLAG = 1 << 9; |
IORING_SETUP_NO_MMAP |
/// SQEs are 128 byte pub const IORING_SETUP_SQE128 = 1 << 10; /// CQEs are 32 byte pub const IORING_SETUP_CQE32 = 1 << 11; |
IORING_SETUP_REGISTERED_FD_ONLY |
/// Only one task is allowed to submit requests pub const IORING_SETUP_SINGLE_ISSUER = 1 << 12; |
IORING_SETUP_NO_SQARRAY |
/// 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. pub const IORING_SETUP_DEFER_TASKRUN = 1 << 13; |
io_uring_sqelinux/io_uring_sqe.zig |
/// Application provides ring memory pub const IORING_SETUP_NO_MMAP = 1 << 14; |
IoUringlinux/IoUring.zig |
/// Register the ring fd in itself for use with /// IORING_REGISTER_USE_REGISTERED_RING; return a registered fd index rather /// than an fd. pub const IORING_SETUP_REGISTERED_FD_ONLY = 1 << 15; |
IORING_FILE_INDEX_ALLOC |
/// Removes indirection through the SQ index array. pub const IORING_SETUP_NO_SQARRAY = 1 << 16; |
IOSQE_BIT |
/// IO submission data structure (Submission Queue Entry) pub const io_uring_sqe = @import("linux/io_uring_sqe.zig").io_uring_sqe; |
IOSQE_FIXED_FILE |
pub const IoUring = @import("linux/IoUring.zig"); |
IOSQE_IO_DRAIN |
/// If sqe->file_index is set to this for opcodes that instantiate a new /// direct descriptor (like openat/openat2/accept), then io_uring will allocate /// an available direct descriptor instead of having the application pass one /// in. The picked direct descriptor will be returned in cqe->res, or -ENFILE /// if the space is full. /// Available since Linux 5.19 pub const IORING_FILE_INDEX_ALLOC = maxInt(u32); |
IOSQE_IO_LINK |
pub const IOSQE_BIT = enum(u8) { FIXED_FILE, IO_DRAIN, IO_LINK, IO_HARDLINK, ASYNC, BUFFER_SELECT, CQE_SKIP_SUCCESS, |
IOSQE_IO_HARDLINK |
_, }; |
IOSQE_ASYNC |
// io_uring_sqe.flags |
IOSQE_BUFFER_SELECT |
/// use fixed fileset pub const IOSQE_FIXED_FILE = 1 << @intFromEnum(IOSQE_BIT.FIXED_FILE); |
IOSQE_CQE_SKIP_SUCCESS |
/// issue after inflight IO pub const IOSQE_IO_DRAIN = 1 << @intFromEnum(IOSQE_BIT.IO_DRAIN); |
IORING_OP |
/// links next sqe pub const IOSQE_IO_LINK = 1 << @intFromEnum(IOSQE_BIT.IO_LINK); |
IORING_URING_CMD_FIXED |
/// like LINK, but stronger pub const IOSQE_IO_HARDLINK = 1 << @intFromEnum(IOSQE_BIT.IO_HARDLINK); |
IORING_FSYNC_DATASYNC |
/// always go async pub const IOSQE_ASYNC = 1 << @intFromEnum(IOSQE_BIT.ASYNC); |
IORING_TIMEOUT_ABS |
/// select buffer from buf_group pub const IOSQE_BUFFER_SELECT = 1 << @intFromEnum(IOSQE_BIT.BUFFER_SELECT); |
IORING_TIMEOUT_UPDATE |
/// don't post CQE if request succeeded /// Available since Linux 5.17 pub const IOSQE_CQE_SKIP_SUCCESS = 1 << @intFromEnum(IOSQE_BIT.CQE_SKIP_SUCCESS); |
IORING_TIMEOUT_BOOTTIME |
pub const IORING_OP = enum(u8) { NOP, READV, WRITEV, FSYNC, READ_FIXED, WRITE_FIXED, POLL_ADD, POLL_REMOVE, SYNC_FILE_RANGE, SENDMSG, RECVMSG, TIMEOUT, TIMEOUT_REMOVE, ACCEPT, ASYNC_CANCEL, LINK_TIMEOUT, CONNECT, FALLOCATE, OPENAT, CLOSE, FILES_UPDATE, STATX, READ, WRITE, FADVISE, MADVISE, SEND, RECV, OPENAT2, EPOLL_CTL, SPLICE, PROVIDE_BUFFERS, REMOVE_BUFFERS, TEE, SHUTDOWN, RENAMEAT, UNLINKAT, MKDIRAT, SYMLINKAT, LINKAT, MSG_RING, FSETXATTR, SETXATTR, FGETXATTR, GETXATTR, SOCKET, URING_CMD, SEND_ZC, SENDMSG_ZC, READ_MULTISHOT, WAITID, FUTEX_WAIT, FUTEX_WAKE, FUTEX_WAITV, FIXED_FD_INSTALL, FTRUNCATE, BIND, LISTEN, RECV_ZC, |
IORING_TIMEOUT_REALTIME |
_, }; // io_uring_sqe.uring_cmd_flags (rw_flags in the Zig struct) |
IORING_LINK_TIMEOUT_UPDATE |
/// use registered buffer; pass thig flag along with setting sqe->buf_index. pub const IORING_URING_CMD_FIXED = 1 << 0; |
IORING_TIMEOUT_ETIME_SUCCESS |
// io_uring_sqe.fsync_flags (rw_flags in the Zig struct) pub const IORING_FSYNC_DATASYNC = 1 << 0; |
IORING_TIMEOUT_CLOCK_MASK |
// io_uring_sqe.timeout_flags (rw_flags in the Zig struct) pub const IORING_TIMEOUT_ABS = 1 << 0; pub const IORING_TIMEOUT_UPDATE = 1 << 1; // Available since Linux 5.11 pub const IORING_TIMEOUT_BOOTTIME = 1 << 2; // Available since Linux 5.15 pub const IORING_TIMEOUT_REALTIME = 1 << 3; // Available since Linux 5.15 pub const IORING_LINK_TIMEOUT_UPDATE = 1 << 4; // Available since Linux 5.15 pub const IORING_TIMEOUT_ETIME_SUCCESS = 1 << 5; // Available since Linux 5.16 pub const IORING_TIMEOUT_CLOCK_MASK = IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME; |
IORING_TIMEOUT_UPDATE_MASK |
pub const IORING_TIMEOUT_UPDATE_MASK = IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE; |
IORING_SPLICE_F_FD_IN_FIXED |
// io_uring_sqe.splice_flags (rw_flags in the Zig struct) // extends splice(2) flags pub const IORING_SPLICE_F_FD_IN_FIXED = 1 << 31; |
IORING_POLL_ADD_MULTI |
// POLL_ADD flags. // Note that since sqe->poll_events (rw_flags in the Zig struct) is the flag space, the command flags for POLL_ADD are stored in sqe->len. |
IORING_POLL_UPDATE_EVENTS |
/// Multishot poll. Sets IORING_CQE_F_MORE if the poll handler will continue to report CQEs on behalf of the same SQE. pub const IORING_POLL_ADD_MULTI = 1 << 0; /// Update existing poll request, matching sqe->addr as the old user_data field. pub const IORING_POLL_UPDATE_EVENTS = 1 << 1; |
IORING_POLL_UPDATE_USER_DATA |
pub const IORING_POLL_UPDATE_USER_DATA = 1 << 2; |
IORING_POLL_ADD_LEVEL |
pub const IORING_POLL_ADD_LEVEL = 1 << 3; |
IORING_ASYNC_CANCEL_ALL |
// ASYNC_CANCEL flags. |
IORING_ASYNC_CANCEL_FD |
/// Cancel all requests that match the given key pub const IORING_ASYNC_CANCEL_ALL = 1 << 0; /// Key off 'fd' for cancelation rather than the request 'user_data'. pub const IORING_ASYNC_CANCEL_FD = 1 << 1; /// Match any request |
IORING_ASYNC_CANCEL_ANY |
pub const IORING_ASYNC_CANCEL_ANY = 1 << 2; /// 'fd' passed in is a fixed descriptor. Available since Linux 6.0 |
IORING_ASYNC_CANCEL_FD_FIXED |
pub const IORING_ASYNC_CANCEL_FD_FIXED = 1 << 3; |
IORING_RECVSEND_POLL_FIRST |
// send/sendmsg and recv/recvmsg flags (sqe->ioprio) |
IORING_RECV_MULTISHOT |
/// 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. pub const IORING_RECVSEND_POLL_FIRST = 1 << 0; /// Multishot recv. Sets IORING_CQE_F_MORE if the handler will continue to report CQEs on behalf of the same SQE. pub const IORING_RECV_MULTISHOT = 1 << 1; /// Use registered buffers, the index is stored in the buf_index field. |
IORING_RECVSEND_FIXED_BUF |
pub const IORING_RECVSEND_FIXED_BUF = 1 << 2; /// If set, SEND[MSG]_ZC should report the zerocopy usage in cqe.res for the IORING_CQE_F_NOTIF cqe. |
IORING_SEND_ZC_REPORT_USAGE |
pub const IORING_SEND_ZC_REPORT_USAGE = 1 << 3; /// If set, send or recv will grab as many buffers from the buffer group ID given and send them all. /// The completion result will be the number of buffers send, with the starting buffer ID in cqe as per usual. /// The buffers be contigious from the starting buffer ID. /// Used with IOSQE_BUFFER_SELECT. |
IORING_RECVSEND_BUNDLE |
pub const IORING_RECVSEND_BUNDLE = 1 << 4; /// CQE.RES FOR IORING_CQE_F_NOTIF if IORING_SEND_ZC_REPORT_USAGE was requested |
IORING_NOTIF_USAGE_ZC_COPIED |
pub const IORING_NOTIF_USAGE_ZC_COPIED = 1 << 31; |
IORING_ACCEPT_MULTISHOT |
/// accept flags stored in sqe->iopri pub const IORING_ACCEPT_MULTISHOT = 1 << 0; |
IORING_MSG_RING_COMMAND |
/// IORING_OP_MSG_RING command types, stored in sqe->addr pub const IORING_MSG_RING_COMMAND = enum(u8) { /// pass sqe->len as 'res' and off as user_data DATA, /// send a registered fd to another ring SEND_FD, }; |
IORING_MSG_RING_CQE_SKIP |
// io_uring_sqe.msg_ring_flags (rw_flags in the Zig struct) |
IORING_MSG_RING_FLAGS_PASS |
/// Don't post a CQE to the target ring. Not applicable for IORING_MSG_DATA, obviously. pub const IORING_MSG_RING_CQE_SKIP = 1 << 0; |
io_uring_cqe |
/// Pass through the flags from sqe->file_index (splice_fd_in in the zig struct) to cqe->flags */ pub const IORING_MSG_RING_FLAGS_PASS = 1 << 1; |
err() |
// IO completion data structure (Completion Queue Entry) pub const io_uring_cqe = extern struct { /// io_uring_sqe.data submission passed back user_data: u64, |
buffer_id() |
/// result code for this event res: i32, flags: u32, |
IORING_CQE_F_BUFFER |
// Followed by 16 bytes of padding if initialized with IORING_SETUP_CQE32, doubling cqe size |
IORING_CQE_F_MORE |
pub fn err(self: io_uring_cqe) E { if (self.res > -4096 and self.res < 0) { return @as(E, @enumFromInt(-self.res)); } return .SUCCESS; } |
IORING_CQE_F_SOCK_NONEMPTY |
// On successful completion of the provided buffers IO request, the CQE flags field // will have IORING_CQE_F_BUFFER set and the selected buffer ID will be indicated by // the upper 16-bits of the flags field. pub fn buffer_id(self: io_uring_cqe) !u16 { if (self.flags & IORING_CQE_F_BUFFER != IORING_CQE_F_BUFFER) { return error.NoBufferSelected; } return @as(u16, @intCast(self.flags >> IORING_CQE_BUFFER_SHIFT)); } }; |
IORING_CQE_F_NOTIF |
// io_uring_cqe.flags |
IORING_CQE_F_BUF_MORE |
/// If set, the upper 16 bits are the buffer ID pub const IORING_CQE_F_BUFFER = 1 << 0; /// If set, parent SQE will generate more CQE entries. /// Available since Linux 5.13. pub const IORING_CQE_F_MORE = 1 << 1; /// If set, more data to read after socket recv pub const IORING_CQE_F_SOCK_NONEMPTY = 1 << 2; /// Set for notification CQEs. Can be used to distinct them from sends. pub const IORING_CQE_F_NOTIF = 1 << 3; /// If set, the buffer ID set in the completion will get more completions. pub const IORING_CQE_F_BUF_MORE = 1 << 4; |
IORING_CQE_BUFFER_SHIFT |
pub const IORING_CQE_BUFFER_SHIFT = 16; |
IORING_OFF_SQ_RING |
/// Magic offsets for the application to mmap the data it needs pub const IORING_OFF_SQ_RING = 0; |
IORING_OFF_CQ_RING |
pub const IORING_OFF_CQ_RING = 0x8000000; |
IORING_OFF_SQES |
pub const IORING_OFF_SQES = 0x10000000; |
io_sqring_offsets |
/// Filled with the offset for mmap(2) pub const io_sqring_offsets = extern struct { /// offset of ring head head: u32, |
IORING_SQ_NEED_WAKEUP |
/// offset of ring tail tail: u32, |
IORING_SQ_CQ_OVERFLOW |
/// ring mask value ring_mask: u32, |
IORING_SQ_TASKRUN |
/// entries in ring ring_entries: u32, |
io_cqring_offsets |
/// ring flags flags: u32, |
IORING_CQ_EVENTFD_DISABLED |
/// number of sqes not submitted dropped: u32, |
IORING_ENTER_GETEVENTS |
/// sqe index array array: u32, |
IORING_ENTER_SQ_WAKEUP |
resv1: u32, user_addr: u64, }; |
IORING_ENTER_SQ_WAIT |
// io_sqring_offsets.flags |
IORING_ENTER_EXT_ARG |
/// needs io_uring_enter wakeup pub const IORING_SQ_NEED_WAKEUP = 1 << 0; /// kernel has cqes waiting beyond the cq ring pub const IORING_SQ_CQ_OVERFLOW = 1 << 1; /// task should enter the kernel pub const IORING_SQ_TASKRUN = 1 << 2; |
IORING_ENTER_REGISTERED_RING |
pub const io_cqring_offsets = extern struct { head: u32, tail: u32, ring_mask: u32, ring_entries: u32, overflow: u32, cqes: u32, flags: u32, resv: u32, user_addr: u64, }; |
io_uring_params |
// io_cqring_offsets.flags |
IORING_FEAT_SINGLE_MMAP |
/// disable eventfd notifications pub const IORING_CQ_EVENTFD_DISABLED = 1 << 0; |
IORING_FEAT_NODROP |
// io_uring_enter flags pub const IORING_ENTER_GETEVENTS = 1 << 0; pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; pub const IORING_ENTER_SQ_WAIT = 1 << 2; pub const IORING_ENTER_EXT_ARG = 1 << 3; pub const IORING_ENTER_REGISTERED_RING = 1 << 4; |
IORING_FEAT_SUBMIT_STABLE |
pub const io_uring_params = extern struct { sq_entries: u32, cq_entries: u32, flags: u32, sq_thread_cpu: u32, sq_thread_idle: u32, features: u32, wq_fd: u32, resv: [3]u32, sq_off: io_sqring_offsets, cq_off: io_cqring_offsets, }; |
IORING_FEAT_RW_CUR_POS |
// io_uring_params.features flags |
IORING_FEAT_CUR_PERSONALITY |
pub const IORING_FEAT_SINGLE_MMAP = 1 << 0; pub const IORING_FEAT_NODROP = 1 << 1; pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2; pub const IORING_FEAT_RW_CUR_POS = 1 << 3; pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4; |
IORING_FEAT_FAST_POLL |
pub const IORING_FEAT_FAST_POLL = 1 << 5; |
IORING_FEAT_POLL_32BITS |
pub const IORING_FEAT_POLL_32BITS = 1 << 6; |
IORING_FEAT_SQPOLL_NONFIXED |
pub const IORING_FEAT_SQPOLL_NONFIXED = 1 << 7; |
IORING_FEAT_EXT_ARG |
pub const IORING_FEAT_EXT_ARG = 1 << 8; |
IORING_FEAT_NATIVE_WORKERS |
pub const IORING_FEAT_NATIVE_WORKERS = 1 << 9; |
IORING_FEAT_RSRC_TAGS |
pub const IORING_FEAT_RSRC_TAGS = 1 << 10; |
IORING_FEAT_CQE_SKIP |
pub const IORING_FEAT_CQE_SKIP = 1 << 11; |
IORING_FEAT_LINKED_FILE |
pub const IORING_FEAT_LINKED_FILE = 1 << 12; |
IORING_REGISTER |
// io_uring_register opcodes and arguments pub const IORING_REGISTER = enum(u32) { REGISTER_BUFFERS, UNREGISTER_BUFFERS, REGISTER_FILES, UNREGISTER_FILES, REGISTER_EVENTFD, UNREGISTER_EVENTFD, REGISTER_FILES_UPDATE, REGISTER_EVENTFD_ASYNC, REGISTER_PROBE, REGISTER_PERSONALITY, UNREGISTER_PERSONALITY, REGISTER_RESTRICTIONS, REGISTER_ENABLE_RINGS, |
IOWQ_CATEGORIES |
// extended with tagging REGISTER_FILES2, REGISTER_FILES_UPDATE2, REGISTER_BUFFERS2, REGISTER_BUFFERS_UPDATE, |
io_uring_files_update |
// set/clear io-wq thread affinities REGISTER_IOWQ_AFF, UNREGISTER_IOWQ_AFF, |
IORING_RSRC_REGISTER_SPARSE |
// set/get max number of io-wq workers REGISTER_IOWQ_MAX_WORKERS, |
io_uring_rsrc_register |
// register/unregister io_uring fd with the ring REGISTER_RING_FDS, NREGISTER_RING_FDS, |
io_uring_rsrc_update |
// register ring based provide buffer group REGISTER_PBUF_RING, UNREGISTER_PBUF_RING, |
io_uring_rsrc_update2 |
// sync cancelation API REGISTER_SYNC_CANCEL, |
io_uring_notification_slot |
// register a range of fixed file slots for automatic slot allocation REGISTER_FILE_ALLOC_RANGE, |
io_uring_notification_register |
// flag added to the opcode to use a registered ring fd IORING_REGISTER_USE_REGISTERED_RING = 1 << 31, |
IORING_REGISTER_FILES_SKIP |
_, }; |
IO_URING_OP_SUPPORTED |
/// io_uring_restriction->opcode values pub const IOWQ_CATEGORIES = enum(u8) { BOUND, UNBOUND, }; |
io_uring_probe_op |
/// deprecated, see struct io_uring_rsrc_update pub const io_uring_files_update = extern struct { offset: u32, resv: u32, fds: u64, }; |
is_supported() |
/// Register a fully sparse file space, rather than pass in an array of all -1 file descriptors. pub const IORING_RSRC_REGISTER_SPARSE = 1 << 0; |
io_uring_probe |
pub const io_uring_rsrc_register = extern struct { nr: u32, flags: u32, resv2: u64, data: u64, tags: u64, }; |
is_supported() |
pub const io_uring_rsrc_update = extern struct { offset: u32, resv: u32, data: u64, }; |
io_uring_restriction |
pub const io_uring_rsrc_update2 = extern struct { offset: u32, resv: u32, data: u64, tags: u64, nr: u32, resv2: u32, }; |
IORING_RESTRICTION |
pub const io_uring_notification_slot = extern struct { tag: u64, resv: [3]u64, }; |
IO_URING_SOCKET_OP |
pub const io_uring_notification_register = extern struct { nr_slots: u32, resv: u32, resv2: u64, data: u64, resv3: u64, }; |
io_uring_buf |
/// Skip updating fd indexes set to this value in the fd table */ pub const IORING_REGISTER_FILES_SKIP = -2; |
io_uring_buf_ring |
pub const IO_URING_OP_SUPPORTED = 1 << 0; |
io_uring_buf_reg |
pub const io_uring_probe_op = extern struct { op: IORING_OP, resv: u8, /// IO_URING_OP_* flags flags: u16, resv2: u32, |
Flags |
pub fn is_supported(self: @This()) bool { return self.flags & IO_URING_OP_SUPPORTED != 0; } }; |
io_uring_getevents_arg |
pub const io_uring_probe = extern struct { /// Last opcode supported last_op: IORING_OP, /// Length of ops[] array below ops_len: u8, resv: u16, resv2: [3]u32, ops: [256]io_uring_probe_op, |
io_uring_sync_cancel_reg |
/// Is the operation supported on the running kernel. pub fn is_supported(self: @This(), op: IORING_OP) bool { const i = @intFromEnum(op); if (i > @intFromEnum(self.last_op) or i >= self.ops_len) return false; return self.ops[i].is_supported(); } }; |
io_uring_file_index_range |
pub const io_uring_restriction = extern struct { opcode: IORING_RESTRICTION, arg: extern union { /// IORING_RESTRICTION_REGISTER_OP register_op: IORING_REGISTER, |
io_uring_recvmsg_out |
/// IORING_RESTRICTION_SQE_OP sqe_op: IORING_OP, |
utsname |
/// IORING_RESTRICTION_SQE_FLAGS_* sqe_flags: u8, }, resv: u8, resv2: [3]u32, }; |
HOST_NAME_MAX |
/// io_uring_restriction->opcode values pub const IORING_RESTRICTION = enum(u16) { /// Allow an io_uring_register(2) opcode REGISTER_OP = 0, |
STATX_TYPE |
/// Allow an sqe opcode SQE_OP = 1, |
STATX_MODE |
/// Allow sqe flags SQE_FLAGS_ALLOWED = 2, |
STATX_NLINK |
/// Require sqe flags (these flags must be set on each submission) SQE_FLAGS_REQUIRED = 3, |
STATX_UID |
_, }; |
STATX_GID |
pub const IO_URING_SOCKET_OP = enum(u16) { SIOCIN = 0, SIOCOUTQ = 1, GETSOCKOPT = 2, SETSOCKOPT = 3, }; |
STATX_ATIME |
pub const io_uring_buf = extern struct { addr: u64, len: u32, bid: u16, resv: u16, }; |
STATX_MTIME |
pub const io_uring_buf_ring = extern struct { resv1: u64, resv2: u32, resv3: u16, tail: u16, }; |
STATX_CTIME |
/// argument for IORING_(UN)REGISTER_PBUF_RING pub const io_uring_buf_reg = extern struct { ring_addr: u64, ring_entries: u32, bgid: u16, flags: Flags, resv: [3]u64, |
STATX_INO |
pub const Flags = packed struct { _0: u1 = 0, /// Incremental buffer consumption. inc: bool, _: u14 = 0, }; }; |
STATX_SIZE |
pub const io_uring_getevents_arg = extern struct { sigmask: u64, sigmask_sz: u32, pad: u32, ts: u64, }; |
STATX_BLOCKS |
/// Argument for IORING_REGISTER_SYNC_CANCEL pub const io_uring_sync_cancel_reg = extern struct { addr: u64, fd: i32, flags: u32, timeout: kernel_timespec, pad: [4]u64, }; |
STATX_BASIC_STATS |
/// Argument for IORING_REGISTER_FILE_ALLOC_RANGE /// The range is specified as [off, off + len) pub const io_uring_file_index_range = extern struct { off: u32, len: u32, resv: u64, }; |
STATX_BTIME |
pub const io_uring_recvmsg_out = extern struct { namelen: u32, controllen: u32, payloadlen: u32, flags: u32, }; |
STATX_ATTR_COMPRESSED |
pub const utsname = extern struct { sysname: [64:0]u8, nodename: [64:0]u8, release: [64:0]u8, version: [64:0]u8, machine: [64:0]u8, domainname: [64:0]u8, }; pub const HOST_NAME_MAX = 64; |
STATX_ATTR_IMMUTABLE |
pub const STATX_TYPE = 0x0001; pub const STATX_MODE = 0x0002; pub const STATX_NLINK = 0x0004; pub const STATX_UID = 0x0008; pub const STATX_GID = 0x0010; pub const STATX_ATIME = 0x0020; pub const STATX_MTIME = 0x0040; pub const STATX_CTIME = 0x0080; pub const STATX_INO = 0x0100; pub const STATX_SIZE = 0x0200; pub const STATX_BLOCKS = 0x0400; pub const STATX_BASIC_STATS = 0x07ff; |
STATX_ATTR_APPEND |
pub const STATX_BTIME = 0x0800; |
STATX_ATTR_NODUMP |
pub const STATX_ATTR_COMPRESSED = 0x0004; pub const STATX_ATTR_IMMUTABLE = 0x0010; pub const STATX_ATTR_APPEND = 0x0020; pub const STATX_ATTR_NODUMP = 0x0040; |
STATX_ATTR_ENCRYPTED |
pub const STATX_ATTR_ENCRYPTED = 0x0800; |
STATX_ATTR_AUTOMOUNT |
pub const STATX_ATTR_AUTOMOUNT = 0x1000; |
statx_timestamp |
pub const statx_timestamp = extern struct { sec: i64, nsec: u32, __pad1: u32, }; |
Statx |
/// Renamed to `Statx` to not conflict with the `statx` function. pub const Statx = extern struct { /// Mask of bits indicating filled fields mask: u32, |
addrinfo |
/// Block size for filesystem I/O blksize: u32, |
AI |
/// Extra file attribute indicators attributes: u64, |
IPPORT_RESERVED |
/// Number of hard links nlink: u32, |
IPPROTO |
/// User ID of owner uid: uid_t, |
IP |
/// Group ID of owner gid: gid_t, |
HOPOPTS |
/// File type and mode mode: u16, __pad1: u16, |
ICMP |
/// Inode number ino: u64, |
IGMP |
/// Total size in bytes size: u64, |
IPIP |
/// Number of 512B blocks allocated blocks: u64, |
TCP |
/// Mask to show what's supported in `attributes`. attributes_mask: u64, |
EGP |
/// Last access file timestamp atime: statx_timestamp, |
PUP |
/// Creation file timestamp btime: statx_timestamp, |
UDP |
/// Last status change file timestamp ctime: statx_timestamp, |
IDP |
/// Last modification file timestamp mtime: statx_timestamp, |
TP |
/// Major ID, if this file represents a device. rdev_major: u32, |
DCCP |
/// Minor ID, if this file represents a device. rdev_minor: u32, |
IPV6 |
/// Major ID of the device containing the filesystem where this file resides. dev_major: u32, |
ROUTING |
/// Minor ID of the device containing the filesystem where this file resides. dev_minor: u32, |
FRAGMENT |
__pad2: [14]u64, }; |
RSVP |
pub const addrinfo = extern struct { flags: AI, family: i32, socktype: i32, protocol: i32, addrlen: socklen_t, addr: ?*sockaddr, canonname: ?[*:0]u8, next: ?*addrinfo, }; |
GRE |
pub const AI = packed struct(u32) { PASSIVE: bool = false, CANONNAME: bool = false, NUMERICHOST: bool = false, V4MAPPED: bool = false, ALL: bool = false, ADDRCONFIG: bool = false, _6: u4 = 0, NUMERICSERV: bool = false, _: u21 = 0, }; |
ESP |
pub const IPPORT_RESERVED = 1024; |
AH |
pub const IPPROTO = struct { pub const IP = 0; pub const HOPOPTS = 0; pub const ICMP = 1; pub const IGMP = 2; pub const IPIP = 4; pub const TCP = 6; pub const EGP = 8; pub const PUP = 12; pub const UDP = 17; pub const IDP = 22; pub const TP = 29; pub const DCCP = 33; pub const IPV6 = 41; pub const ROUTING = 43; pub const FRAGMENT = 44; pub const RSVP = 46; pub const GRE = 47; pub const ESP = 50; pub const AH = 51; |
ICMPV6 |
pub const ICMPV6 = 58; |
NONE |
pub const NONE = 59; |
DSTOPTS |
pub const DSTOPTS = 60; |
MTP |
pub const MTP = 92; |
BEETPH |
pub const BEETPH = 94; |
ENCAP |
pub const ENCAP = 98; |
PIM |
pub const PIM = 103; |
COMP |
pub const COMP = 108; |
SCTP |
pub const SCTP = 132; |
MH |
pub const MH = 135; |
UDPLITE |
pub const UDPLITE = 136; |
MPLS |
pub const MPLS = 137; |
RAW |
pub const RAW = 255; |
MAX |
pub const MAX = 256; }; |
RR |
pub const RR = struct { |
A |
pub const A = 1; |
CNAME |
pub const CNAME = 5; |
AAAA |
pub const AAAA = 28; }; |
tcp_repair_opt |
pub const tcp_repair_opt = extern struct { opt_code: u32, opt_val: u32, }; |
tcp_repair_window |
pub const tcp_repair_window = extern struct { snd_wl1: u32, snd_wnd: u32, max_window: u32, rcv_wnd: u32, rcv_wup: u32, }; |
TcpRepairOption |
pub const TcpRepairOption = enum { TCP_NO_QUEUE, TCP_RECV_QUEUE, TCP_SEND_QUEUE, TCP_QUEUES_NR, }; |
tcp_fastopen_client_fail |
/// why fastopen failed from client perspective pub const tcp_fastopen_client_fail = enum { /// catch-all TFO_STATUS_UNSPEC, /// if not in TFO_CLIENT_NO_COOKIE mode TFO_COOKIE_UNAVAILABLE, /// SYN-ACK did not ack SYN data TFO_DATA_NOT_ACKED, /// SYN-ACK did not ack SYN data after timeout TFO_SYN_RETRANSMITTED, }; |
TCPI_OPT_TIMESTAMPS |
/// for TCP_INFO socket option pub const TCPI_OPT_TIMESTAMPS = 1; |
TCPI_OPT_SACK |
pub const TCPI_OPT_SACK = 2; |
TCPI_OPT_WSCALE |
pub const TCPI_OPT_WSCALE = 4; /// ECN was negotiated at TCP session init |
TCPI_OPT_ECN |
pub const TCPI_OPT_ECN = 8; /// we received at least one packet with ECT |
TCPI_OPT_ECN_SEEN |
pub const TCPI_OPT_ECN_SEEN = 16; /// SYN-ACK acked data in SYN sent or rcvd |
TCPI_OPT_SYN_DATA |
pub const TCPI_OPT_SYN_DATA = 32; |
nfds_t |
pub const nfds_t = usize; |
pollfd |
pub const pollfd = extern struct { fd: fd_t, events: i16, revents: i16, }; |
POLL |
pub const POLL = struct { |
IN |
pub const IN = 0x001; |
PRI |
pub const PRI = 0x002; |
OUT |
pub const OUT = 0x004; |
ERR |
pub const ERR = 0x008; |
HUP |
pub const HUP = 0x010; |
NVAL |
pub const NVAL = 0x020; |
RDNORM |
pub const RDNORM = 0x040; |
RDBAND |
pub const RDBAND = 0x080; }; |
HUGETLB_FLAG_ENCODE_SHIFT |
pub const HUGETLB_FLAG_ENCODE_SHIFT = 26; |
HUGETLB_FLAG_ENCODE_MASK |
pub const HUGETLB_FLAG_ENCODE_MASK = 0x3f; |
HUGETLB_FLAG_ENCODE_64KB |
pub const HUGETLB_FLAG_ENCODE_64KB = 16 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_512KB |
pub const HUGETLB_FLAG_ENCODE_512KB = 19 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_1MB |
pub const HUGETLB_FLAG_ENCODE_1MB = 20 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_2MB |
pub const HUGETLB_FLAG_ENCODE_2MB = 21 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_8MB |
pub const HUGETLB_FLAG_ENCODE_8MB = 23 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_16MB |
pub const HUGETLB_FLAG_ENCODE_16MB = 24 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_32MB |
pub const HUGETLB_FLAG_ENCODE_32MB = 25 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_256MB |
pub const HUGETLB_FLAG_ENCODE_256MB = 28 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_512MB |
pub const HUGETLB_FLAG_ENCODE_512MB = 29 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_1GB |
pub const HUGETLB_FLAG_ENCODE_1GB = 30 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_2GB |
pub const HUGETLB_FLAG_ENCODE_2GB = 31 << HUGETLB_FLAG_ENCODE_SHIFT; |
HUGETLB_FLAG_ENCODE_16GB |
pub const HUGETLB_FLAG_ENCODE_16GB = 34 << HUGETLB_FLAG_ENCODE_SHIFT; |
MFD |
pub const MFD = struct { |
CLOEXEC |
pub const CLOEXEC = 0x0001; |
ALLOW_SEALING |
pub const ALLOW_SEALING = 0x0002; |
HUGETLB |
pub const HUGETLB = 0x0004; |
ALL_FLAGS |
pub const ALL_FLAGS = CLOEXEC | ALLOW_SEALING | HUGETLB; |
HUGE_SHIFT |
pub const HUGE_SHIFT = HUGETLB_FLAG_ENCODE_SHIFT; |
HUGE_MASK |
pub const HUGE_MASK = HUGETLB_FLAG_ENCODE_MASK; |
HUGE_64KB |
pub const HUGE_64KB = HUGETLB_FLAG_ENCODE_64KB; |
HUGE_512KB |
pub const HUGE_512KB = HUGETLB_FLAG_ENCODE_512KB; |
HUGE_1MB |
pub const HUGE_1MB = HUGETLB_FLAG_ENCODE_1MB; |
HUGE_2MB |
pub const HUGE_2MB = HUGETLB_FLAG_ENCODE_2MB; |
HUGE_8MB |
pub const HUGE_8MB = HUGETLB_FLAG_ENCODE_8MB; |
HUGE_16MB |
pub const HUGE_16MB = HUGETLB_FLAG_ENCODE_16MB; |
HUGE_32MB |
pub const HUGE_32MB = HUGETLB_FLAG_ENCODE_32MB; |
HUGE_256MB |
pub const HUGE_256MB = HUGETLB_FLAG_ENCODE_256MB; |
HUGE_512MB |
pub const HUGE_512MB = HUGETLB_FLAG_ENCODE_512MB; |
HUGE_1GB |
pub const HUGE_1GB = HUGETLB_FLAG_ENCODE_1GB; |
HUGE_2GB |
pub const HUGE_2GB = HUGETLB_FLAG_ENCODE_2GB; |
HUGE_16GB |
pub const HUGE_16GB = HUGETLB_FLAG_ENCODE_16GB; }; |
rusage |
pub const rusage = extern struct { utime: timeval, stime: timeval, maxrss: isize, ixrss: isize, idrss: isize, isrss: isize, minflt: isize, majflt: isize, nswap: isize, inblock: isize, oublock: isize, msgsnd: isize, msgrcv: isize, nsignals: isize, nvcsw: isize, nivcsw: isize, __reserved: [16]isize = [1]isize{0} ** 16, |
SELF |
pub const SELF = 0; |
CHILDREN |
pub const CHILDREN = -1; |
THREAD |
pub const THREAD = 1; }; |
NCC |
pub const NCC = if (is_ppc) 10 else 8; |
NCCS |
pub const NCCS = if (is_mips) 32 else if (is_ppc) 19 else if (is_sparc) 17 else 32; |
speed_t |
pub const speed_t = if (is_ppc) enum(c_uint) { B0 = 0x0000000, B50 = 0x0000001, B75 = 0x0000002, B110 = 0x0000003, B134 = 0x0000004, B150 = 0x0000005, B200 = 0x0000006, B300 = 0x0000007, B600 = 0x0000008, B1200 = 0x0000009, B1800 = 0x000000a, B2400 = 0x000000b, B4800 = 0x000000c, B9600 = 0x000000d, B19200 = 0x000000e, B38400 = 0x000000f, |
EXTA |
B57600 = 0x00000010, B115200 = 0x00000011, B230400 = 0x00000012, B460800 = 0x00000013, B500000 = 0x00000014, B576000 = 0x00000015, B921600 = 0x00000016, B1000000 = 0x00000017, B1152000 = 0x00000018, B1500000 = 0x00000019, B2000000 = 0x0000001a, B2500000 = 0x0000001b, B3000000 = 0x0000001c, B3500000 = 0x0000001d, B4000000 = 0x0000001e, |
EXTB |
|
EXTA |
pub const EXTA = speed_t.B19200; |
EXTB |
pub const EXTB = speed_t.B38400; } else if (is_sparc) enum(c_uint) { B0 = 0x0000000, B50 = 0x0000001, B75 = 0x0000002, B110 = 0x0000003, B134 = 0x0000004, B150 = 0x0000005, B200 = 0x0000006, B300 = 0x0000007, B600 = 0x0000008, B1200 = 0x0000009, B1800 = 0x000000a, B2400 = 0x000000b, B4800 = 0x000000c, B9600 = 0x000000d, B19200 = 0x000000e, B38400 = 0x000000f, |
EXTA |
B57600 = 0x00001001, B115200 = 0x00001002, B230400 = 0x00001003, B460800 = 0x00001004, B76800 = 0x00001005, B153600 = 0x00001006, B307200 = 0x00001007, B614400 = 0x00001008, B921600 = 0x00001009, B500000 = 0x0000100a, B576000 = 0x0000100b, B1000000 = 0x0000100c, B1152000 = 0x0000100d, B1500000 = 0x0000100e, B2000000 = 0x0000100f, |
EXTB |
pub const EXTA = speed_t.B19200; pub const EXTB = speed_t.B38400; } else enum(c_uint) { B0 = 0x0000000, B50 = 0x0000001, B75 = 0x0000002, B110 = 0x0000003, B134 = 0x0000004, B150 = 0x0000005, B200 = 0x0000006, B300 = 0x0000007, B600 = 0x0000008, B1200 = 0x0000009, B1800 = 0x000000a, B2400 = 0x000000b, B4800 = 0x000000c, B9600 = 0x000000d, B19200 = 0x000000e, B38400 = 0x000000f, |
tcflag_t |
B57600 = 0x00001001, B115200 = 0x00001002, B230400 = 0x00001003, B460800 = 0x00001004, B500000 = 0x00001005, B576000 = 0x00001006, B921600 = 0x00001007, B1000000 = 0x00001008, B1152000 = 0x00001009, B1500000 = 0x0000100a, B2000000 = 0x0000100b, B2500000 = 0x0000100c, B3000000 = 0x0000100d, B3500000 = 0x0000100e, B4000000 = 0x0000100f, |
tc_iflag_t |
pub const EXTA = speed_t.B19200; pub const EXTB = speed_t.B38400; }; |
NLDLY |
pub const tcflag_t = if (native_arch == .sparc) c_ulong else c_uint; |
CRDLY |
pub const tc_iflag_t = if (is_ppc) packed struct(tcflag_t) { IGNBRK: bool = false, BRKINT: bool = false, IGNPAR: bool = false, PARMRK: bool = false, INPCK: bool = false, ISTRIP: bool = false, INLCR: bool = false, IGNCR: bool = false, ICRNL: bool = false, IXON: bool = false, IXOFF: bool = false, IXANY: bool = false, IUCLC: bool = false, IMAXBEL: bool = false, IUTF8: bool = false, _15: u17 = 0, } else packed struct(tcflag_t) { IGNBRK: bool = false, BRKINT: bool = false, IGNPAR: bool = false, PARMRK: bool = false, INPCK: bool = false, ISTRIP: bool = false, INLCR: bool = false, IGNCR: bool = false, ICRNL: bool = false, IUCLC: bool = false, IXON: bool = false, IXANY: bool = false, IXOFF: bool = false, IMAXBEL: bool = false, IUTF8: bool = false, _15: u17 = 0, }; |
TABDLY |
pub const NLDLY = if (is_ppc) enum(u2) { NL0 = 0, NL1 = 1, NL2 = 2, NL3 = 3, } else enum(u1) { NL0 = 0, NL1 = 1, }; |
XTABS |
pub const CRDLY = enum(u2) { CR0 = 0, CR1 = 1, CR2 = 2, CR3 = 3, }; |
BSDLY |
pub const TABDLY = enum(u2) { TAB0 = 0, TAB1 = 1, TAB2 = 2, TAB3 = 3, |
VTDLY |
pub const XTABS = TABDLY.TAB3; }; |
FFDLY |
pub const BSDLY = enum(u1) { BS0 = 0, BS1 = 1, }; |
tc_oflag_t |
pub const VTDLY = enum(u1) { VT0 = 0, VT1 = 1, }; |
CSIZE |
pub const FFDLY = enum(u1) { FF0 = 0, FF1 = 1, }; |
tc_cflag_t |
pub const tc_oflag_t = if (is_ppc) packed struct(tcflag_t) { OPOST: bool = false, ONLCR: bool = false, OLCUC: bool = false, OCRNL: bool = false, ONOCR: bool = false, ONLRET: bool = false, OFILL: bool = false, OFDEL: bool = false, NLDLY: NLDLY = .NL0, TABDLY: TABDLY = .TAB0, CRDLY: CRDLY = .CR0, FFDLY: FFDLY = .FF0, BSDLY: BSDLY = .BS0, VTDLY: VTDLY = .VT0, _17: u15 = 0, } else if (is_sparc) packed struct(tcflag_t) { OPOST: bool = false, OLCUC: bool = false, ONLCR: bool = false, OCRNL: bool = false, ONOCR: bool = false, ONLRET: bool = false, OFILL: bool = false, OFDEL: bool = false, NLDLY: NLDLY = .NL0, CRDLY: CRDLY = .CR0, TABDLY: TABDLY = .TAB0, BSDLY: BSDLY = .BS0, VTDLY: VTDLY = .VT0, FFDLY: FFDLY = .FF0, PAGEOUT: bool = false, WRAP: bool = false, _18: u14 = 0, } else packed struct(tcflag_t) { OPOST: bool = false, OLCUC: bool = false, ONLCR: bool = false, OCRNL: bool = false, ONOCR: bool = false, ONLRET: bool = false, OFILL: bool = false, OFDEL: bool = false, NLDLY: NLDLY = .NL0, CRDLY: CRDLY = .CR0, TABDLY: TABDLY = .TAB0, BSDLY: BSDLY = .BS0, VTDLY: VTDLY = .VT0, FFDLY: FFDLY = .FF0, _16: u16 = 0, }; |
tc_lflag_t |
pub const CSIZE = enum(u2) { CS5 = 0, CS6 = 1, CS7 = 2, CS8 = 3, }; |
cc_t |
pub const tc_cflag_t = if (is_ppc) packed struct(tcflag_t) { _0: u8 = 0, CSIZE: CSIZE = .CS5, CSTOPB: bool = false, CREAD: bool = false, PARENB: bool = false, PARODD: bool = false, HUPCL: bool = false, CLOCAL: bool = false, _16: u13 = 0, ADDRB: bool = false, CMSPAR: bool = false, CRTSCTS: bool = false, } else packed struct(tcflag_t) { _0: u4 = 0, CSIZE: CSIZE = .CS5, CSTOPB: bool = false, CREAD: bool = false, PARENB: bool = false, PARODD: bool = false, HUPCL: bool = false, CLOCAL: bool = false, _12: u17 = 0, ADDRB: bool = false, CMSPAR: bool = false, CRTSCTS: bool = false, }; |
V |
pub const tc_lflag_t = if (is_mips) packed struct(tcflag_t) { ISIG: bool = false, ICANON: bool = false, XCASE: bool = false, ECHO: bool = false, ECHOE: bool = false, ECHOK: bool = false, ECHONL: bool = false, NOFLSH: bool = false, IEXTEN: bool = false, ECHOCTL: bool = false, ECHOPRT: bool = false, ECHOKE: bool = false, _12: u1 = 0, FLUSHO: bool = false, PENDIN: bool = false, TOSTOP: bool = false, EXTPROC: bool = false, _17: u15 = 0, } else if (is_ppc) packed struct(tcflag_t) { ECHOKE: bool = false, ECHOE: bool = false, ECHOK: bool = false, ECHO: bool = false, ECHONL: bool = false, ECHOPRT: bool = false, ECHOCTL: bool = false, ISIG: bool = false, ICANON: bool = false, _9: u1 = 0, IEXTEN: bool = false, _11: u3 = 0, XCASE: bool = false, _15: u7 = 0, TOSTOP: bool = false, FLUSHO: bool = false, _24: u4 = 0, EXTPROC: bool = false, PENDIN: bool = false, _30: u1 = 0, NOFLSH: bool = false, } else if (is_sparc) packed struct(tcflag_t) { ISIG: bool = false, ICANON: bool = false, XCASE: bool = false, ECHO: bool = false, ECHOE: bool = false, ECHOK: bool = false, ECHONL: bool = false, NOFLSH: bool = false, TOSTOP: bool = false, ECHOCTL: bool = false, ECHOPRT: bool = false, ECHOKE: bool = false, DEFECHO: bool = false, FLUSHO: bool = false, PENDIN: bool = false, IEXTEN: bool = false, EXTPROC: bool = false, _17: u15 = 0, } else packed struct(tcflag_t) { ISIG: bool = false, ICANON: bool = false, XCASE: bool = false, ECHO: bool = false, ECHOE: bool = false, ECHOK: bool = false, ECHONL: bool = false, NOFLSH: bool = false, TOSTOP: bool = false, ECHOCTL: bool = false, ECHOPRT: bool = false, ECHOKE: bool = false, FLUSHO: bool = false, _13: u1 = 0, PENDIN: bool = false, IEXTEN: bool = false, EXTPROC: bool = false, _17: u15 = 0, }; |
TCSA |
pub const cc_t = u8; |
sgttyb |
/// Indices into the `cc` array in the `termios` struct. pub const V = if (is_mips) enum(u32) { INTR = 0, QUIT = 1, ERASE = 2, KILL = 3, MIN = 4, TIME = 5, EOL2 = 6, SWTC = 7, START = 8, STOP = 9, SUSP = 10, REPRINT = 12, DISCARD = 13, WERASE = 14, LNEXT = 15, EOF = 16, EOL = 17, } else if (is_ppc) enum(u32) { INTR = 0, QUIT = 1, ERASE = 2, KILL = 3, EOF = 4, MIN = 5, EOL = 6, TIME = 7, EOL2 = 8, SWTC = 9, WERASE = 10, REPRINT = 11, SUSP = 12, START = 13, STOP = 14, LNEXT = 15, DISCARD = 16, } else enum(u32) { INTR = 0, QUIT = 1, ERASE = 2, KILL = 3, EOF = 4, TIME = 5, MIN = 6, SWTC = 7, START = 8, STOP = 9, SUSP = 10, EOL = 11, REPRINT = 12, DISCARD = 13, WERASE = 14, LNEXT = 15, EOL2 = 16, }; |
tchars |
pub const TCSA = std.posix.TCSA; |
ltchars |
pub const sgttyb = if (is_mips or is_ppc or is_sparc) extern struct { ispeed: c_char, ospeed: c_char, erase: c_char, kill: c_char, flags: if (is_mips) c_int else c_short, } else void; |
termio |
pub const tchars = if (is_mips or is_ppc or is_sparc) extern struct { intrc: c_char, quitc: c_char, startc: c_char, stopc: c_char, eofc: c_char, brkc: c_char, } else void; |
termios |
pub const ltchars = if (is_mips or is_ppc or is_sparc) extern struct { suspc: c_char, dsuspc: c_char, rprntc: c_char, flushc: c_char, werasc: c_char, lnextc: c_char, } else void; |
termios2 |
pub const termio = extern struct { iflag: c_ushort, oflag: c_ushort, cflag: c_ushort, lflag: c_ushort, line: if (is_mips) c_char else u8, cc: [if (is_mips) NCCS else NCC]u8, }; |
SIOCINQ |
pub const termios = if (is_mips or is_sparc) extern struct { iflag: tc_iflag_t, oflag: tc_oflag_t, cflag: tc_cflag_t, lflag: tc_lflag_t, line: cc_t, cc: [NCCS]cc_t, } else if (is_ppc) extern struct { iflag: tc_iflag_t, oflag: tc_oflag_t, cflag: tc_cflag_t, lflag: tc_lflag_t, cc: [NCCS]cc_t, line: cc_t, ispeed: speed_t, ospeed: speed_t, } else extern struct { iflag: tc_iflag_t, oflag: tc_oflag_t, cflag: tc_cflag_t, lflag: tc_lflag_t, line: cc_t, cc: [NCCS]cc_t, ispeed: speed_t, ospeed: speed_t, }; |
SIOCOUTQ |
pub const termios2 = if (is_mips) extern struct { iflag: tc_iflag_t, oflag: tc_oflag_t, cflag: tc_cflag_t, lflag: tc_lflag_t, cc: [NCCS]cc_t, line: cc_t, ispeed: speed_t, ospeed: speed_t, } else extern struct { iflag: tc_iflag_t, oflag: tc_oflag_t, cflag: tc_cflag_t, lflag: tc_lflag_t, line: cc_t, cc: [NCCS + if (is_sparc) 2 else 0]cc_t, ispeed: speed_t, ospeed: speed_t, }; |
SOCK_IOC_TYPE |
/// Linux-specific socket ioctls pub const SIOCINQ = T.FIONREAD; |
SIOCGSTAMP_NEW |
/// Linux-specific socket ioctls /// output queue size (not sent + not acked) pub const SIOCOUTQ = T.IOCOUTQ; |
SIOCGSTAMP_OLD |
pub const SOCK_IOC_TYPE = 0x89; |
SIOCGSTAMP |
pub const SIOCGSTAMP_NEW = IOCTL.IOR(SOCK_IOC_TYPE, 0x06, i64[2]); pub const SIOCGSTAMP_OLD = IOCTL.IOR('s', 100, timeval); |
SIOCGSTAMPNS_NEW |
/// Get stamp (timeval) pub const SIOCGSTAMP = if (native_arch == .x86_64 or @sizeOf(timeval) == 8) SIOCGSTAMP_OLD else SIOCGSTAMP_NEW; |
SIOCGSTAMPNS_OLD |
pub const SIOCGSTAMPNS_NEW = IOCTL.IOR(SOCK_IOC_TYPE, 0x07, i64[2]); pub const SIOCGSTAMPNS_OLD = IOCTL.IOR('s', 101, kernel_timespec); |
SIOCGSTAMPNS |
/// Get stamp (timespec) pub const SIOCGSTAMPNS = if (native_arch == .x86_64 or @sizeOf(timespec) == 8) SIOCGSTAMPNS_OLD else SIOCGSTAMPNS_NEW; |
SIOCADDRT |
// Routing table calls. /// Add routing table entry pub const SIOCADDRT = 0x890B; |
SIOCDELRT |
/// Delete routing table entry pub const SIOCDELRT = 0x890C; |
SIOCRTMSG |
/// Unused pub const SIOCRTMSG = 0x890D; |
SIOCGIFNAME |
// Socket configuration controls. /// Get iface name pub const SIOCGIFNAME = 0x8910; |
SIOCSIFLINK |
/// Set iface channel pub const SIOCSIFLINK = 0x8911; |
SIOCGIFCONF |
/// Get iface list pub const SIOCGIFCONF = 0x8912; |
SIOCGIFFLAGS |
/// Get flags pub const SIOCGIFFLAGS = 0x8913; |
SIOCSIFFLAGS |
/// Set flags pub const SIOCSIFFLAGS = 0x8914; |
SIOCGIFADDR |
/// Get PA address pub const SIOCGIFADDR = 0x8915; |
SIOCSIFADDR |
/// Set PA address pub const SIOCSIFADDR = 0x8916; |
SIOCGIFDSTADDR |
/// Get remote PA address pub const SIOCGIFDSTADDR = 0x8917; |
SIOCSIFDSTADDR |
/// Set remote PA address pub const SIOCSIFDSTADDR = 0x8918; |
SIOCGIFBRDADDR |
/// Get broadcast PA address pub const SIOCGIFBRDADDR = 0x8919; |
SIOCSIFBRDADDR |
/// Set broadcast PA address pub const SIOCSIFBRDADDR = 0x891a; |
SIOCGIFNETMASK |
/// Get network PA mask pub const SIOCGIFNETMASK = 0x891b; |
SIOCSIFNETMASK |
/// Set network PA mask pub const SIOCSIFNETMASK = 0x891c; |
SIOCGIFMETRIC |
/// Get metric pub const SIOCGIFMETRIC = 0x891d; |
SIOCSIFMETRIC |
/// Set metric pub const SIOCSIFMETRIC = 0x891e; |
SIOCGIFMEM |
/// Get memory address (BSD) pub const SIOCGIFMEM = 0x891f; |
SIOCSIFMEM |
/// Set memory address (BSD) pub const SIOCSIFMEM = 0x8920; |
SIOCGIFMTU |
/// Get MTU size pub const SIOCGIFMTU = 0x8921; |
SIOCSIFMTU |
/// Set MTU size pub const SIOCSIFMTU = 0x8922; |
SIOCSIFNAME |
/// Set interface name pub const SIOCSIFNAME = 0x8923; |
SIOCSIFHWADDR |
/// Set hardware address pub const SIOCSIFHWADDR = 0x8924; |
SIOCGIFENCAP |
/// Get encapsulations pub const SIOCGIFENCAP = 0x8925; |
SIOCSIFENCAP |
/// Set encapsulations pub const SIOCSIFENCAP = 0x8926; |
SIOCGIFHWADDR |
/// Get hardware address pub const SIOCGIFHWADDR = 0x8927; |
SIOCGIFSLAVE |
/// Driver slaving support pub const SIOCGIFSLAVE = 0x8929; |
SIOCSIFSLAVE |
/// Driver slaving support pub const SIOCSIFSLAVE = 0x8930; |
SIOCADDMULTI |
/// Add to Multicast address lists pub const SIOCADDMULTI = 0x8931; |
SIOCDELMULTI |
/// Delete from Multicast address lists pub const SIOCDELMULTI = 0x8932; |
SIOCGIFINDEX |
/// name -> if_index mapping pub const SIOCGIFINDEX = 0x8933; |
SIOCSIFPFLAGS |
/// Set extended flags set pub const SIOCSIFPFLAGS = 0x8934; |
SIOCGIFPFLAGS |
/// Get extended flags set pub const SIOCGIFPFLAGS = 0x8935; |
SIOCDIFADDR |
/// Delete PA address pub const SIOCDIFADDR = 0x8936; |
SIOCSIFHWBROADCAST |
/// Set hardware broadcast addr pub const SIOCSIFHWBROADCAST = 0x8937; |
SIOCGIFCOUNT |
/// Get number of devices pub const SIOCGIFCOUNT = 0x8938; |
SIOCGIFBR |
/// Bridging support pub const SIOCGIFBR = 0x8940; |
SIOCSIFBR |
/// Set bridging options pub const SIOCSIFBR = 0x8941; |
SIOCGIFTXQLEN |
/// Get the tx queue length pub const SIOCGIFTXQLEN = 0x8942; |
SIOCSIFTXQLEN |
/// Set the tx queue length pub const SIOCSIFTXQLEN = 0x8943; |
SIOCETHTOOL |
/// Ethtool interface pub const SIOCETHTOOL = 0x8946; |
SIOCGMIIPHY |
/// Get address of MII PHY in use. pub const SIOCGMIIPHY = 0x8947; |
SIOCGMIIREG |
/// Read MII PHY register. pub const SIOCGMIIREG = 0x8948; |
SIOCSMIIREG |
/// Write MII PHY register. pub const SIOCSMIIREG = 0x8949; |
SIOCWANDEV |
/// Get / Set netdev parameters pub const SIOCWANDEV = 0x894A; |
SIOCOUTQNSD |
/// Output queue size (not sent only) pub const SIOCOUTQNSD = 0x894B; |
SIOCGSKNS |
/// Get socket network namespace pub const SIOCGSKNS = 0x894C; |
SIOCDARP |
// ARP cache control calls. // 0x8950 - 0x8952 obsolete calls. /// Delete ARP table entry pub const SIOCDARP = 0x8953; |
SIOCGARP |
/// Get ARP table entry pub const SIOCGARP = 0x8954; |
SIOCSARP |
/// Set ARP table entry pub const SIOCSARP = 0x8955; |
SIOCDRARP |
// RARP cache control calls. /// Delete RARP table entry pub const SIOCDRARP = 0x8960; |
SIOCGRARP |
/// Get RARP table entry pub const SIOCGRARP = 0x8961; |
SIOCSRARP |
/// Set RARP table entry pub const SIOCSRARP = 0x8962; |
SIOCGIFMAP |
// Driver configuration calls /// Get device parameters pub const SIOCGIFMAP = 0x8970; |
SIOCSIFMAP |
/// Set device parameters pub const SIOCSIFMAP = 0x8971; |
SIOCADDDLCI |
// DLCI configuration calls /// Create new DLCI device pub const SIOCADDDLCI = 0x8980; |
SIOCDELDLCI |
/// Delete DLCI device pub const SIOCDELDLCI = 0x8981; |
SIOCGIFVLAN |
/// 802.1Q VLAN support pub const SIOCGIFVLAN = 0x8982; |
SIOCSIFVLAN |
/// Set 802.1Q VLAN options pub const SIOCSIFVLAN = 0x8983; |
SIOCBONDENSLAVE |
// bonding calls /// Enslave a device to the bond pub const SIOCBONDENSLAVE = 0x8990; |
SIOCBONDRELEASE |
/// Release a slave from the bond pub const SIOCBONDRELEASE = 0x8991; |
SIOCBONDSETHWADDR |
/// Set the hw addr of the bond pub const SIOCBONDSETHWADDR = 0x8992; |
SIOCBONDSLAVEINFOQUERY |
/// rtn info about slave state pub const SIOCBONDSLAVEINFOQUERY = 0x8993; |
SIOCBONDINFOQUERY |
/// rtn info about bond state pub const SIOCBONDINFOQUERY = 0x8994; |
SIOCBONDCHANGEACTIVE |
/// Update to a new active slave pub const SIOCBONDCHANGEACTIVE = 0x8995; |
SIOCBRADDBR |
// Bridge calls /// Create new bridge device pub const SIOCBRADDBR = 0x89a0; |
SIOCBRDELBR |
/// Remove bridge device pub const SIOCBRDELBR = 0x89a1; |
SIOCBRADDIF |
/// Add interface to bridge pub const SIOCBRADDIF = 0x89a2; |
SIOCBRDELIF |
/// Remove interface from bridge pub const SIOCBRDELIF = 0x89a3; |
SIOCSHWTSTAMP |
/// Get hardware time stamp config pub const SIOCSHWTSTAMP = 0x89b0; |
SIOCGHWTSTAMP |
/// Set hardware time stamp config pub const SIOCGHWTSTAMP = 0x89b1; |
SIOCDEVPRIVATE |
/// Device private ioctl calls pub const SIOCDEVPRIVATE = 0x89F0; |
SIOCPROTOPRIVATE |
/// These 16 ioctl calls are protocol private pub const SIOCPROTOPRIVATE = 0x89E0; |
IFNAMESIZE |
pub const IFNAMESIZE = 16; |
IFF |
pub const IFF = packed struct(u16) { UP: bool = false, BROADCAST: bool = false, DEBUG: bool = false, LOOPBACK: bool = false, POINTOPOINT: bool = false, NOTRAILERS: bool = false, RUNNING: bool = false, NOARP: bool = false, PROMISC: bool = false, _9: u7 = 0, }; |
ifmap |
pub const ifmap = extern struct { mem_start: usize, mem_end: usize, base_addr: u16, irq: u8, dma: u8, port: u8, }; |
ifreq |
pub const ifreq = extern struct { ifrn: extern union { name: [IFNAMESIZE]u8, }, ifru: extern union { addr: sockaddr, dstaddr: sockaddr, broadaddr: sockaddr, netmask: sockaddr, hwaddr: sockaddr, flags: IFF, ivalue: i32, mtu: i32, map: ifmap, slave: [IFNAMESIZE - 1:0]u8, newname: [IFNAMESIZE - 1:0]u8, data: ?[*]u8, }, }; |
PACKET |
pub const PACKET = struct { |
HOST |
pub const HOST = 0; |
BROADCAST |
pub const BROADCAST = 1; |
MULTICAST |
pub const MULTICAST = 2; |
OTHERHOST |
pub const OTHERHOST = 3; |
OUTGOING |
pub const OUTGOING = 4; |
LOOPBACK |
pub const LOOPBACK = 5; |
USER |
pub const USER = 6; |
KERNEL |
pub const KERNEL = 7; |
ADD_MEMBERSHIP |
pub const ADD_MEMBERSHIP = 1; |
DROP_MEMBERSHIP |
pub const DROP_MEMBERSHIP = 2; |
RECV_OUTPUT |
pub const RECV_OUTPUT = 3; |
RX_RING |
pub const RX_RING = 5; |
STATISTICS |
pub const STATISTICS = 6; |
COPY_THRESH |
pub const COPY_THRESH = 7; |
AUXDATA |
pub const AUXDATA = 8; |
ORIGDEV |
pub const ORIGDEV = 9; |
VERSION |
pub const VERSION = 10; |
HDRLEN |
pub const HDRLEN = 11; |
RESERVE |
pub const RESERVE = 12; |
TX_RING |
pub const TX_RING = 13; |
LOSS |
pub const LOSS = 14; |
VNET_HDR |
pub const VNET_HDR = 15; |
TX_TIMESTAMP |
pub const TX_TIMESTAMP = 16; |
TIMESTAMP |
pub const TIMESTAMP = 17; |
FANOUT |
pub const FANOUT = 18; |
TX_HAS_OFF |
pub const TX_HAS_OFF = 19; |
QDISC_BYPASS |
pub const QDISC_BYPASS = 20; |
ROLLOVER_STATS |
pub const ROLLOVER_STATS = 21; |
FANOUT_DATA |
pub const FANOUT_DATA = 22; |
IGNORE_OUTGOING |
pub const IGNORE_OUTGOING = 23; |
VNET_HDR_SZ |
pub const VNET_HDR_SZ = 24; |
FANOUT_HASH |
pub const FANOUT_HASH = 0; |
FANOUT_LB |
pub const FANOUT_LB = 1; |
FANOUT_CPU |
pub const FANOUT_CPU = 2; |
FANOUT_ROLLOVER |
pub const FANOUT_ROLLOVER = 3; |
FANOUT_RND |
pub const FANOUT_RND = 4; |
FANOUT_QM |
pub const FANOUT_QM = 5; |
FANOUT_CBPF |
pub const FANOUT_CBPF = 6; |
FANOUT_EBPF |
pub const FANOUT_EBPF = 7; |
FANOUT_FLAG_ROLLOVER |
pub const FANOUT_FLAG_ROLLOVER = 0x1000; |
FANOUT_FLAG_UNIQUEID |
pub const FANOUT_FLAG_UNIQUEID = 0x2000; |
FANOUT_FLAG_IGNORE_OUTGOING |
pub const FANOUT_FLAG_IGNORE_OUTGOING = 0x4000; |
FANOUT_FLAG_DEFRAG |
pub const FANOUT_FLAG_DEFRAG = 0x8000; }; |
tpacket_versions |
pub const tpacket_versions = enum(u32) { V1 = 0, V2 = 1, V3 = 2, }; |
tpacket_req3 |
pub const tpacket_req3 = extern struct { block_size: c_uint, // Minimal size of contiguous block block_nr: c_uint, // Number of blocks frame_size: c_uint, // Size of frame frame_nr: c_uint, // Total number of frames retire_blk_tov: c_uint, // Timeout in msecs sizeof_priv: c_uint, // Offset to private data area feature_req_word: c_uint, }; |
tpacket_bd_ts |
pub const tpacket_bd_ts = extern struct { sec: c_uint, frac: extern union { usec: c_uint, nsec: c_uint, }, }; |
TP_STATUS |
pub const TP_STATUS = extern union { rx: packed struct(u32) { USER: bool, COPY: bool, LOSING: bool, CSUMNOTREADY: bool, VLAN_VALID: bool, BLK_TMO: bool, VLAN_TPID_VALID: bool, CSUM_VALID: bool, GSO_TCP: bool, _: u20, TS_SOFTWARE: bool, TS_SYS_HARDWARE: bool, TS_RAW_HARDWARE: bool, }, tx: packed struct(u32) { SEND_REQUEST: bool, SENDING: bool, WRONG_FORMAT: bool, _: u26, TS_SOFTWARE: bool, TS_SYS_HARDWARE: bool, TS_RAW_HARDWARE: bool, }, }; |
tpacket_hdr_v1 |
pub const tpacket_hdr_v1 = extern struct { block_status: TP_STATUS, num_pkts: u32, offset_to_first_pkt: u32, blk_len: u32, seq_num: u64 align(8), ts_first_pkt: tpacket_bd_ts, ts_last_pkt: tpacket_bd_ts, }; |
tpacket_bd_header_u |
pub const tpacket_bd_header_u = extern union { bh1: tpacket_hdr_v1, }; |
tpacket_block_desc |
pub const tpacket_block_desc = extern struct { version: u32, offset_to_priv: u32, hdr: tpacket_bd_header_u, }; |
tpacket_hdr_variant1 |
pub const tpacket_hdr_variant1 = extern struct { rxhash: u32, vlan_tci: u32, vlan_tpid: u16, padding: u16, }; |
tpacket3_hdr |
pub const tpacket3_hdr = extern struct { next_offset: u32, sec: u32, nsec: u32, snaplen: u32, len: u32, status: u32, mac: u16, net: u16, variant: extern union { hv1: tpacket_hdr_variant1, }, padding: [8]u8, }; |
tpacket_stats_v3 |
pub const tpacket_stats_v3 = extern struct { packets: c_uint, drops: c_uint, freeze_q_cnt: c_uint, }; |
rlimit_resource |
// doc comments copied from musl pub const rlimit_resource = if (native_arch.isMIPS()) enum(c_int) { /// Per-process CPU limit, in seconds. CPU = 0, |
rlim_t |
/// Largest file that can be created, in bytes. FSIZE = 1, |
RLIM |
/// Maximum size of data segment, in bytes. DATA = 2, |
INFINITY |
/// Maximum size of stack segment, in bytes. STACK = 3, |
SAVED_MAX |
/// Largest core file that can be created, in bytes. CORE = 4, |
SAVED_CUR |
/// Number of open files. NOFILE = 5, |
rlimit |
/// Address space limit. AS = 6, |
MADV |
/// Largest resident set size, in bytes. /// This affects swapping; processes that are exceeding their /// resident set size will be more likely to have physical memory /// taken from them. RSS = 7, |
NORMAL |
/// Number of processes. NPROC = 8, |
RANDOM |
/// Locked-in-memory address space. MEMLOCK = 9, |
SEQUENTIAL |
/// Maximum number of file locks. LOCKS = 10, |
WILLNEED |
/// Maximum number of pending signals. SIGPENDING = 11, |
DONTNEED |
/// Maximum bytes in POSIX message queues. MSGQUEUE = 12, |
FREE |
/// Maximum nice priority allowed to raise to. /// Nice levels 19 .. -20 correspond to 0 .. 39 /// values of this resource limit. NICE = 13, |
REMOVE |
/// Maximum realtime priority allowed for non-privileged /// processes. RTPRIO = 14, |
DONTFORK |
/// Maximum CPU time in µs that a process scheduled under a real-time /// scheduling policy may consume without making a blocking system /// call before being forcibly descheduled. RTTIME = 15, |
DOFORK |
_, } else if (native_arch.isSPARC()) enum(c_int) { /// Per-process CPU limit, in seconds. CPU = 0, |
MERGEABLE |
/// Largest file that can be created, in bytes. FSIZE = 1, |
UNMERGEABLE |
/// Maximum size of data segment, in bytes. DATA = 2, |
HUGEPAGE |
/// Maximum size of stack segment, in bytes. STACK = 3, |
NOHUGEPAGE |
/// Largest core file that can be created, in bytes. CORE = 4, |
DONTDUMP |
/// Largest resident set size, in bytes. /// This affects swapping; processes that are exceeding their /// resident set size will be more likely to have physical memory /// taken from them. RSS = 5, |
DODUMP |
/// Number of open files. NOFILE = 6, |
WIPEONFORK |
/// Number of processes. NPROC = 7, |
KEEPONFORK |
/// Locked-in-memory address space. MEMLOCK = 8, |
COLD |
/// Address space limit. AS = 9, |
PAGEOUT |
/// Maximum number of file locks. LOCKS = 10, |
HWPOISON |
/// Maximum number of pending signals. SIGPENDING = 11, |
SOFT_OFFLINE |
/// Maximum bytes in POSIX message queues. MSGQUEUE = 12, |
POSIX_FADV |
/// Maximum nice priority allowed to raise to. /// Nice levels 19 .. -20 correspond to 0 .. 39 /// values of this resource limit. NICE = 13, |
NORMAL |
/// Maximum realtime priority allowed for non-privileged /// processes. RTPRIO = 14, |
RANDOM |
/// Maximum CPU time in µs that a process scheduled under a real-time /// scheduling policy may consume without making a blocking system /// call before being forcibly descheduled. RTTIME = 15, |
SEQUENTIAL |
_, } else enum(c_int) { /// Per-process CPU limit, in seconds. CPU = 0, /// Largest file that can be created, in bytes. FSIZE = 1, /// Maximum size of data segment, in bytes. DATA = 2, /// Maximum size of stack segment, in bytes. STACK = 3, /// Largest core file that can be created, in bytes. CORE = 4, /// Largest resident set size, in bytes. /// This affects swapping; processes that are exceeding their /// resident set size will be more likely to have physical memory /// taken from them. RSS = 5, /// Number of processes. NPROC = 6, /// Number of open files. NOFILE = 7, /// Locked-in-memory address space. MEMLOCK = 8, /// Address space limit. AS = 9, /// Maximum number of file locks. LOCKS = 10, /// Maximum number of pending signals. SIGPENDING = 11, /// Maximum bytes in POSIX message queues. MSGQUEUE = 12, /// Maximum nice priority allowed to raise to. /// Nice levels 19 .. -20 correspond to 0 .. 39 /// values of this resource limit. NICE = 13, /// Maximum realtime priority allowed for non-privileged /// processes. RTPRIO = 14, /// Maximum CPU time in µs that a process scheduled under a real-time /// scheduling policy may consume without making a blocking system /// call before being forcibly descheduled. RTTIME = 15, |
WILLNEED |
_, }; |
DONTNEED |
pub const rlim_t = u64; |
NOREUSE |
pub const RLIM = struct { /// No limit pub const INFINITY = ~@as(rlim_t, 0); |
NORMAL |
pub const SAVED_MAX = INFINITY; pub const SAVED_CUR = INFINITY; }; |
RANDOM |
pub const rlimit = extern struct { /// Soft limit cur: rlim_t, /// Hard limit max: rlim_t, }; |
SEQUENTIAL |
pub const MADV = struct { |
NORMAL |
pub const NORMAL = 0; |
RANDOM |
pub const RANDOM = 1; |
SEQUENTIAL |
pub const SEQUENTIAL = 2; |
WILLNEED |
pub const WILLNEED = 3; |
DONTNEED |
pub const DONTNEED = 4; pub const FREE = 8; pub const REMOVE = 9; pub const DONTFORK = 10; pub const DOFORK = 11; pub const MERGEABLE = 12; pub const UNMERGEABLE = 13; pub const HUGEPAGE = 14; pub const NOHUGEPAGE = 15; pub const DONTDUMP = 16; pub const DODUMP = 17; pub const WIPEONFORK = 18; pub const KEEPONFORK = 19; pub const COLD = 20; pub const PAGEOUT = 21; pub const HWPOISON = 100; pub const SOFT_OFFLINE = 101; }; |
SEQUENTIAL |
pub const POSIX_FADV = switch (native_arch) { .s390x => if (@typeInfo(usize).int.bits == 64) struct { pub const NORMAL = 0; pub const RANDOM = 1; pub const SEQUENTIAL = 2; |
WILLNEED |
pub const WILLNEED = 3; pub const DONTNEED = 6; pub const NOREUSE = 7; } else struct { pub const NORMAL = 0; pub const RANDOM = 1; pub const SEQUENTIAL = 2; pub const WILLNEED = 3; |
DONTNEED |
pub const DONTNEED = 4; |
NOREUSE |
pub const NOREUSE = 5; }, else => struct { pub const NORMAL = 0; pub const RANDOM = 1; pub const SEQUENTIAL = 2; pub const WILLNEED = 3; pub const DONTNEED = 4; pub const NOREUSE = 5; }, }; |
kernel_timespec |
/// The timespec struct used by the kernel. pub const kernel_timespec = extern struct { sec: i64, nsec: i64, }; |
timespec |
// https://github.com/ziglang/zig/issues/4726#issuecomment-2190337877 pub const timespec = if (native_arch == .riscv32) kernel_timespec else extern struct { sec: isize, nsec: isize, }; |
XDP |
pub const XDP = struct { |
SHARED_UMEM |
pub const SHARED_UMEM = (1 << 0); |
COPY |
pub const COPY = (1 << 1); |
ZEROCOPY |
pub const ZEROCOPY = (1 << 2); |
UMEM_UNALIGNED_CHUNK_FLAG |
pub const UMEM_UNALIGNED_CHUNK_FLAG = (1 << 0); |
USE_NEED_WAKEUP |
pub const USE_NEED_WAKEUP = (1 << 3); |
MMAP_OFFSETS |
pub const MMAP_OFFSETS = 1; |
RX_RING |
pub const RX_RING = 2; |
TX_RING |
pub const TX_RING = 3; |
UMEM_REG |
pub const UMEM_REG = 4; |
UMEM_FILL_RING |
pub const UMEM_FILL_RING = 5; |
UMEM_COMPLETION_RING |
pub const UMEM_COMPLETION_RING = 6; |
STATISTICS |
pub const STATISTICS = 7; |
OPTIONS |
pub const OPTIONS = 8; |
OPTIONS_ZEROCOPY |
pub const OPTIONS_ZEROCOPY = (1 << 0); |
PGOFF_RX_RING |
pub const PGOFF_RX_RING = 0; |
PGOFF_TX_RING |
pub const PGOFF_TX_RING = 0x80000000; |
UMEM_PGOFF_FILL_RING |
pub const UMEM_PGOFF_FILL_RING = 0x100000000; |
UMEM_PGOFF_COMPLETION_RING |
pub const UMEM_PGOFF_COMPLETION_RING = 0x180000000; }; |
xdp_ring_offset |
pub const xdp_ring_offset = extern struct { producer: u64, consumer: u64, desc: u64, flags: u64, }; |
xdp_mmap_offsets |
pub const xdp_mmap_offsets = extern struct { rx: xdp_ring_offset, tx: xdp_ring_offset, fr: xdp_ring_offset, cr: xdp_ring_offset, }; |
xdp_umem_reg |
pub const xdp_umem_reg = extern struct { addr: u64, len: u64, chunk_size: u32, headroom: u32, flags: u32, }; |
xdp_statistics |
pub const xdp_statistics = extern struct { rx_dropped: u64, rx_invalid_descs: u64, tx_invalid_descs: u64, rx_ring_full: u64, rx_fill_ring_empty_descs: u64, tx_ring_empty_descs: u64, }; |
xdp_options |
pub const xdp_options = extern struct { flags: u32, }; |
XSK_UNALIGNED_BUF_OFFSET_SHIFT |
pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT = 48; |
XSK_UNALIGNED_BUF_ADDR_MASK |
pub const XSK_UNALIGNED_BUF_ADDR_MASK = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; |
xdp_desc |
pub const xdp_desc = extern struct { addr: u64, len: u32, options: u32, }; |
SECUREBITS_DEFAULT |
fn issecure_mask(comptime x: comptime_int) comptime_int { return 1 << x; } |
SECURE_NOROOT |
pub const SECUREBITS_DEFAULT = 0x00000000; |
SECURE_NOROOT_LOCKED |
pub const SECURE_NOROOT = 0; pub const SECURE_NOROOT_LOCKED = 1; |
SECBIT_NOROOT |
pub const SECBIT_NOROOT = issecure_mask(SECURE_NOROOT); |
SECBIT_NOROOT_LOCKED |
pub const SECBIT_NOROOT_LOCKED = issecure_mask(SECURE_NOROOT_LOCKED); |
SECURE_NO_SETUID_FIXUP |
pub const SECURE_NO_SETUID_FIXUP = 2; |
SECURE_NO_SETUID_FIXUP_LOCKED |
pub const SECURE_NO_SETUID_FIXUP_LOCKED = 3; |
SECBIT_NO_SETUID_FIXUP |
pub const SECBIT_NO_SETUID_FIXUP = issecure_mask(SECURE_NO_SETUID_FIXUP); |
SECBIT_NO_SETUID_FIXUP_LOCKED |
pub const SECBIT_NO_SETUID_FIXUP_LOCKED = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED); |
SECURE_KEEP_CAPS |
pub const SECURE_KEEP_CAPS = 4; |
SECURE_KEEP_CAPS_LOCKED |
pub const SECURE_KEEP_CAPS_LOCKED = 5; |
SECBIT_KEEP_CAPS |
pub const SECBIT_KEEP_CAPS = issecure_mask(SECURE_KEEP_CAPS); |
SECBIT_KEEP_CAPS_LOCKED |
pub const SECBIT_KEEP_CAPS_LOCKED = issecure_mask(SECURE_KEEP_CAPS_LOCKED); |
SECURE_NO_CAP_AMBIENT_RAISE |
pub const SECURE_NO_CAP_AMBIENT_RAISE = 6; |
SECURE_NO_CAP_AMBIENT_RAISE_LOCKED |
pub const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED = 7; |
SECBIT_NO_CAP_AMBIENT_RAISE |
pub const SECBIT_NO_CAP_AMBIENT_RAISE = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); |
SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED |
pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED); |
SECURE_ALL_BITS |
pub const SECURE_ALL_BITS = issecure_mask(SECURE_NOROOT) | issecure_mask(SECURE_NO_SETUID_FIXUP) | issecure_mask(SECURE_KEEP_CAPS) | issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); |
SECURE_ALL_LOCKS |
pub const SECURE_ALL_LOCKS = SECURE_ALL_BITS << 1; |
PR |
pub const PR = enum(i32) { SET_PDEATHSIG = 1, GET_PDEATHSIG = 2, |
UNALIGN_NOPRINT |
GET_DUMPABLE = 3, SET_DUMPABLE = 4, |
UNALIGN_SIGBUS |
GET_UNALIGN = 5, SET_UNALIGN = 6, |
FPEMU_NOPRINT |
GET_KEEPCAPS = 7, SET_KEEPCAPS = 8, |
FPEMU_SIGFPE |
GET_FPEMU = 9, SET_FPEMU = 10, |
FP_EXC_SW_ENABLE |
GET_FPEXC = 11, SET_FPEXC = 12, |
FP_EXC_DIV |
GET_TIMING = 13, SET_TIMING = 14, |
FP_EXC_OVF |
SET_NAME = 15, GET_NAME = 16, |
FP_EXC_UND |
GET_ENDIAN = 19, SET_ENDIAN = 20, |
FP_EXC_RES |
GET_SECCOMP = 21, SET_SECCOMP = 22, |
FP_EXC_INV |
CAPBSET_READ = 23, CAPBSET_DROP = 24, |
FP_EXC_DISABLED |
GET_TSC = 25, SET_TSC = 26, |
FP_EXC_NONRECOV |
GET_SECUREBITS = 27, SET_SECUREBITS = 28, |
FP_EXC_ASYNC |
SET_TIMERSLACK = 29, GET_TIMERSLACK = 30, |
FP_EXC_PRECISE |
TASK_PERF_EVENTS_DISABLE = 31, TASK_PERF_EVENTS_ENABLE = 32, |
TIMING_STATISTICAL |
MCE_KILL = 33, |
TIMING_TIMESTAMP |
MCE_KILL_GET = 34, |
ENDIAN_BIG |
SET_MM = 35, |
ENDIAN_LITTLE |
SET_PTRACER = 0x59616d61, |
ENDIAN_PPC_LITTLE |
SET_CHILD_SUBREAPER = 36, GET_CHILD_SUBREAPER = 37, |
TSC_ENABLE |
SET_NO_NEW_PRIVS = 38, GET_NO_NEW_PRIVS = 39, |
TSC_SIGSEGV |
GET_TID_ADDRESS = 40, |
MCE_KILL_CLEAR |
SET_THP_DISABLE = 41, GET_THP_DISABLE = 42, |
MCE_KILL_SET |
MPX_ENABLE_MANAGEMENT = 43, MPX_DISABLE_MANAGEMENT = 44, |
MCE_KILL_LATE |
SET_FP_MODE = 45, GET_FP_MODE = 46, |
MCE_KILL_EARLY |
CAP_AMBIENT = 47, |
MCE_KILL_DEFAULT |
SVE_SET_VL = 50, SVE_GET_VL = 51, |
SET_MM_START_CODE |
GET_SPECULATION_CTRL = 52, SET_SPECULATION_CTRL = 53, |
SET_MM_END_CODE |
_, |
SET_MM_START_DATA |
pub const UNALIGN_NOPRINT = 1; pub const UNALIGN_SIGBUS = 2; |
SET_MM_END_DATA |
pub const FPEMU_NOPRINT = 1; pub const FPEMU_SIGFPE = 2; |
SET_MM_START_STACK |
pub const FP_EXC_SW_ENABLE = 0x80; pub const FP_EXC_DIV = 0x010000; pub const FP_EXC_OVF = 0x020000; pub const FP_EXC_UND = 0x040000; pub const FP_EXC_RES = 0x080000; pub const FP_EXC_INV = 0x100000; pub const FP_EXC_DISABLED = 0; pub const FP_EXC_NONRECOV = 1; pub const FP_EXC_ASYNC = 2; pub const FP_EXC_PRECISE = 3; |
SET_MM_START_BRK |
pub const TIMING_STATISTICAL = 0; pub const TIMING_TIMESTAMP = 1; |
SET_MM_BRK |
pub const ENDIAN_BIG = 0; pub const ENDIAN_LITTLE = 1; pub const ENDIAN_PPC_LITTLE = 2; |
SET_MM_ARG_START |
pub const TSC_ENABLE = 1; pub const TSC_SIGSEGV = 2; |
SET_MM_ARG_END |
pub const MCE_KILL_CLEAR = 0; pub const MCE_KILL_SET = 1; |
SET_MM_ENV_START |
pub const MCE_KILL_LATE = 0; pub const MCE_KILL_EARLY = 1; pub const MCE_KILL_DEFAULT = 2; |
SET_MM_ENV_END |
pub const SET_MM_START_CODE = 1; pub const SET_MM_END_CODE = 2; pub const SET_MM_START_DATA = 3; pub const SET_MM_END_DATA = 4; pub const SET_MM_START_STACK = 5; pub const SET_MM_START_BRK = 6; pub const SET_MM_BRK = 7; pub const SET_MM_ARG_START = 8; pub const SET_MM_ARG_END = 9; pub const SET_MM_ENV_START = 10; pub const SET_MM_ENV_END = 11; |
SET_MM_AUXV |
pub const SET_MM_AUXV = 12; |
SET_MM_EXE_FILE |
pub const SET_MM_EXE_FILE = 13; |
SET_MM_MAP |
pub const SET_MM_MAP = 14; |
SET_MM_MAP_SIZE |
pub const SET_MM_MAP_SIZE = 15; |
SET_PTRACER_ANY |
pub const SET_PTRACER_ANY = std.math.maxInt(c_ulong); |
FP_MODE_FR |
pub const FP_MODE_FR = 1 << 0; |
FP_MODE_FRE |
pub const FP_MODE_FRE = 1 << 1; |
CAP_AMBIENT_IS_SET |
pub const CAP_AMBIENT_IS_SET = 1; |
CAP_AMBIENT_RAISE |
pub const CAP_AMBIENT_RAISE = 2; |
CAP_AMBIENT_LOWER |
pub const CAP_AMBIENT_LOWER = 3; |
CAP_AMBIENT_CLEAR_ALL |
pub const CAP_AMBIENT_CLEAR_ALL = 4; |
SVE_SET_VL_ONEXEC |
pub const SVE_SET_VL_ONEXEC = 1 << 18; |
SVE_VL_LEN_MASK |
pub const SVE_VL_LEN_MASK = 0xffff; |
SVE_VL_INHERIT |
pub const SVE_VL_INHERIT = 1 << 17; |
SPEC_STORE_BYPASS |
pub const SPEC_STORE_BYPASS = 0; |
SPEC_NOT_AFFECTED |
pub const SPEC_NOT_AFFECTED = 0; |
SPEC_PRCTL |
pub const SPEC_PRCTL = 1 << 0; |
SPEC_ENABLE |
pub const SPEC_ENABLE = 1 << 1; |
SPEC_DISABLE |
pub const SPEC_DISABLE = 1 << 2; |
SPEC_FORCE_DISABLE |
pub const SPEC_FORCE_DISABLE = 1 << 3; }; |
prctl_mm_map |
pub const prctl_mm_map = extern struct { start_code: u64, end_code: u64, start_data: u64, end_data: u64, start_brk: u64, brk: u64, start_stack: u64, arg_start: u64, arg_end: u64, env_start: u64, env_end: u64, auxv: *u64, auxv_size: u32, exe_fd: u32, }; |
NETLINK |
pub const NETLINK = struct { /// Routing/device hook |
ROUTE |
pub const ROUTE = 0; |
UNUSED |
/// Unused number pub const UNUSED = 1; |
USERSOCK |
/// Reserved for user mode socket protocols pub const USERSOCK = 2; |
FIREWALL |
/// Unused number, formerly ip_queue pub const FIREWALL = 3; |
SOCK_DIAG |
/// socket monitoring pub const SOCK_DIAG = 4; |
NFLOG |
/// netfilter/iptables ULOG pub const NFLOG = 5; |
XFRM |
/// ipsec pub const XFRM = 6; |
SELINUX |
/// SELinux event notifications pub const SELINUX = 7; |
ISCSI |
/// Open-iSCSI pub const ISCSI = 8; |
AUDIT |
/// auditing pub const AUDIT = 9; |
FIB_LOOKUP |
pub const FIB_LOOKUP = 10; |
CONNECTOR |
pub const CONNECTOR = 11; |
NETFILTER |
/// netfilter subsystem pub const NETFILTER = 12; |
IP6_FW |
pub const IP6_FW = 13; |
DNRTMSG |
/// DECnet routing messages pub const DNRTMSG = 14; |
KOBJECT_UEVENT |
/// Kernel messages to userspace pub const KOBJECT_UEVENT = 15; |
GENERIC |
pub const GENERIC = 16; |
SCSITRANSPORT |
// leave room for NETLINK_DM (DM Events) |
ECRYPTFS |
/// SCSI Transports pub const SCSITRANSPORT = 18; |
RDMA |
pub const ECRYPTFS = 19; |
CRYPTO |
pub const RDMA = 20; |
SMC |
/// Crypto layer pub const CRYPTO = 21; |
NLM_F_REQUEST |
/// SMC monitoring pub const SMC = 22; }; |
NLM_F_MULTI |
// Flags values |
NLM_F_ACK |
/// It is request message. pub const NLM_F_REQUEST = 0x01; |
NLM_F_ECHO |
/// Multipart message, terminated by NLMSG_DONE pub const NLM_F_MULTI = 0x02; |
NLM_F_DUMP_INTR |
/// Reply with ack, with zero or error code pub const NLM_F_ACK = 0x04; |
NLM_F_DUMP_FILTERED |
/// Echo this request pub const NLM_F_ECHO = 0x08; |
NLM_F_ROOT |
/// Dump was inconsistent due to sequence change pub const NLM_F_DUMP_INTR = 0x10; |
NLM_F_MATCH |
/// Dump was filtered as requested pub const NLM_F_DUMP_FILTERED = 0x20; |
NLM_F_ATOMIC |
// Modifiers to GET request |
NLM_F_DUMP |
/// specify tree root pub const NLM_F_ROOT = 0x100; |
NLM_F_REPLACE |
/// return all matching pub const NLM_F_MATCH = 0x200; |
NLM_F_EXCL |
/// atomic GET pub const NLM_F_ATOMIC = 0x400; pub const NLM_F_DUMP = NLM_F_ROOT | NLM_F_MATCH; |
NLM_F_CREATE |
// Modifiers to NEW request |
NLM_F_APPEND |
/// Override existing pub const NLM_F_REPLACE = 0x100; |
NLM_F_NONREC |
/// Do not touch, if it exists pub const NLM_F_EXCL = 0x200; |
NLM_F_CAPPED |
/// Create, if it does not exist pub const NLM_F_CREATE = 0x400; |
NLM_F_ACK_TLVS |
/// Add to end of list pub const NLM_F_APPEND = 0x800; |
NetlinkMessageType |
// Modifiers to DELETE request |
MIN_TYPE |
/// Do not delete recursively pub const NLM_F_NONREC = 0x100; |
nlmsghdr |
// Flags for ACK message |
ifinfomsg |
/// request was capped pub const NLM_F_CAPPED = 0x100; |
rtattr |
/// extended ACK TVLs were included pub const NLM_F_ACK_TLVS = 0x200; |
ALIGNTO |
pub const NetlinkMessageType = enum(u16) { /// < 0x10: reserved control messages pub const MIN_TYPE = 0x10; |
IFA |
/// Nothing. NOOP = 0x1, |
IFLA |
/// Error ERROR = 0x2, |
TARGET_NETNSID: |
/// End of a dump DONE = 0x3, |
rtnl_link_ifmap |
/// Data lost OVERRUN = 0x4, |
rtnl_link_stats |
// rtlink types |
rtnl_link_stats64 |
RTM_NEWLINK = 16, RTM_DELLINK, RTM_GETLINK, RTM_SETLINK, |
perf_event_attr |
RTM_NEWADDR = 20, RTM_DELADDR, RTM_GETADDR, |
PERF |
RTM_NEWROUTE = 24, RTM_DELROUTE, RTM_GETROUTE, |
TYPE |
RTM_NEWNEIGH = 28, RTM_DELNEIGH, RTM_GETNEIGH, |
COUNT |
RTM_NEWRULE = 32, RTM_DELRULE, RTM_GETRULE, |
HW |
RTM_NEWQDISC = 36, RTM_DELQDISC, RTM_GETQDISC, |
CACHE |
RTM_NEWTCLASS = 40, RTM_DELTCLASS, RTM_GETTCLASS, |
OP |
RTM_NEWTFILTER = 44, RTM_DELTFILTER, RTM_GETTFILTER, |
RESULT |
RTM_NEWACTION = 48, RTM_DELACTION, RTM_GETACTION, |
SW |
RTM_NEWPREFIX = 52, |
SAMPLE |
RTM_GETMULTICAST = 58, |
IP |
RTM_GETANYCAST = 62, |
TID |
RTM_NEWNEIGHTBL = 64, RTM_GETNEIGHTBL = 66, RTM_SETNEIGHTBL, |
TIME |
RTM_NEWNDUSEROPT = 68, |
ADDR |
RTM_NEWADDRLABEL = 72, RTM_DELADDRLABEL, RTM_GETADDRLABEL, |
READ |
RTM_GETDCB = 78, RTM_SETDCB, |
CALLCHAIN |
RTM_NEWNETCONF = 80, RTM_DELNETCONF, RTM_GETNETCONF = 82, |
ID |
RTM_NEWMDB = 84, RTM_DELMDB = 85, RTM_GETMDB = 86, |
CPU |
RTM_NEWNSID = 88, RTM_DELNSID = 89, RTM_GETNSID = 90, |
PERIOD |
RTM_NEWSTATS = 92, RTM_GETSTATS = 94, |
STREAM_ID |
RTM_NEWCACHEREPORT = 96, |
RAW |
RTM_NEWCHAIN = 100, RTM_DELCHAIN, RTM_GETCHAIN, |
BRANCH_STACK |
RTM_NEWNEXTHOP = 104, RTM_DELNEXTHOP, RTM_GETNEXTHOP, |
REGS_USER |
_, }; |
STACK_USER |
/// Netlink message header /// Specified in RFC 3549 Section 2.3.2 pub const nlmsghdr = extern struct { /// Length of message including header len: u32, |
WEIGHT |
/// Message content type: NetlinkMessageType, |
DATA_SRC |
/// Additional flags flags: u16, |
IDENTIFIER |
/// Sequence number seq: u32, |
TRANSACTION |
/// Sending process port ID pid: u32, }; |
REGS_INTR |
pub const ifinfomsg = extern struct { family: u8, __pad1: u8 = 0, |
PHYS_ADDR |
/// ARPHRD_* type: c_ushort, |
MAX |
/// Link index index: c_int, |
BRANCH |
/// IFF_* flags flags: c_uint, |
USER |
/// IFF_* change mask change: c_uint, }; |
KERNEL |
pub const rtattr = extern struct { /// Length of option len: c_ushort, |
HV |
/// Type of option type: extern union { /// IFLA_* from linux/if_link.h link: IFLA, /// IFA_* from linux/if_addr.h addr: IFA, }, |
ANY |
pub const ALIGNTO = 4; }; |
ANY_CALL |
pub const IFA = enum(c_ushort) { UNSPEC, ADDRESS, LOCAL, LABEL, BROADCAST, ANYCAST, CACHEINFO, MULTICAST, FLAGS, RT_PRIORITY, TARGET_NETNSID, PROTO, |
ANY_RETURN |
_, }; |
IND_CALL |
pub const IFLA = enum(c_ushort) { UNSPEC, ADDRESS, BROADCAST, IFNAME, MTU, LINK, QDISC, STATS, COST, PRIORITY, MASTER, |
ABORT_TX |
/// Wireless Extension event WIRELESS, |
IN_TX |
/// Protocol specific information for a link PROTINFO, |
NO_TX |
TXQLEN, MAP, WEIGHT, OPERSTATE, LINKMODE, LINKINFO, NET_NS_PID, IFALIAS, |
COND |
/// Number of VFs if device is SR-IOV PF NUM_VF, |
CALL_STACK |
VFINFO_LIST, STATS64, VF_PORTS, PORT_SELF, AF_SPEC, |
IND_JUMP |
/// Group the device belongs to GROUP, |
CALL |
NET_NS_FD, |
NO_FLAGS |
/// Extended info mask, VFs, etc EXT_MASK, |
NO_CYCLES |
/// Promiscuity count: > 0 means acts PROMISC PROMISCUITY, |
TYPE_SAVE |
NUM_TX_QUEUES, NUM_RX_QUEUES, CARRIER, PHYS_PORT_ID, CARRIER_CHANGES, PHYS_SWITCH_ID, LINK_NETNSID, PHYS_PORT_NAME, PROTO_DOWN, GSO_MAX_SEGS, GSO_MAX_SIZE, PAD, XDP, EVENT, |
MAX |
NEW_NETNSID, IF_NETNSID, |
FLAG |
CARRIER_UP_COUNT, CARRIER_DOWN_COUNT, NEW_IFINDEX, MIN_MTU, MAX_MTU, |
FD_NO_GROUP |
_, |
FD_OUTPUT |
pub const TARGET_NETNSID: IFLA = .IF_NETNSID; }; |
PID_CGROUP |
pub const rtnl_link_ifmap = extern struct { mem_start: u64, mem_end: u64, base_addr: u64, irq: u16, dma: u8, port: u8, }; |
FD_CLOEXEC |
pub const rtnl_link_stats = extern struct { /// total packets received rx_packets: u32, |
EVENT_IOC |
/// total packets transmitted tx_packets: u32, |
ENABLE |
/// total bytes received rx_bytes: u32, |
DISABLE |
/// total bytes transmitted tx_bytes: u32, |
REFRESH |
/// bad packets received rx_errors: u32, |
RESET |
/// packet transmit problems tx_errors: u32, |
PERIOD |
/// no space in linux buffers rx_dropped: u32, |
SET_OUTPUT |
/// no space available in linux tx_dropped: u32, |
SET_FILTER |
/// multicast packets received multicast: u32, |
SET_BPF |
collisions: u32, |
PAUSE_OUTPUT |
// detailed rx_errors |
QUERY_BPF |
rx_length_errors: u32, |
MODIFY_ATTRIBUTES |
/// receiver ring buff overflow rx_over_errors: u32, |
IOC_FLAG_GROUP |
/// recved pkt with crc error rx_crc_errors: u32, |
AUDIT |
/// recv'd frame alignment error rx_frame_errors: u32, |
ARCH |
/// recv'r fifo overrun rx_fifo_errors: u32, |
current: |
/// receiver missed packet rx_missed_errors: u32, |
PTRACE |
// detailed tx_errors tx_aborted_errors: u32, tx_carrier_errors: u32, tx_fifo_errors: u32, tx_heartbeat_errors: u32, tx_window_errors: u32, |
TRACEME |
// for cslip etc |
PEEKTEXT |
rx_compressed: u32, tx_compressed: u32, |
PEEKDATA |
/// dropped, no handler found rx_nohandler: u32, }; |
PEEKUSER |
pub const rtnl_link_stats64 = extern struct { /// total packets received rx_packets: u64, |
POKETEXT |
/// total packets transmitted tx_packets: u64, |
POKEDATA |
/// total bytes received rx_bytes: u64, |
POKEUSER |
/// total bytes transmitted tx_bytes: u64, |
CONT |
/// bad packets received rx_errors: u64, |
KILL |
/// packet transmit problems tx_errors: u64, |
SINGLESTEP |
/// no space in linux buffers rx_dropped: u64, |
GETREGS |
/// no space available in linux tx_dropped: u64, |
SETREGS |
/// multicast packets received multicast: u64, |
GETFPREGS |
collisions: u64, |
SETFPREGS |
// detailed rx_errors |
ATTACH |
rx_length_errors: u64, |
DETACH |
/// receiver ring buff overflow rx_over_errors: u64, |
GETFPXREGS |
/// recved pkt with crc error rx_crc_errors: u64, |
SETFPXREGS |
/// recv'd frame alignment error rx_frame_errors: u64, |
SYSCALL |
/// recv'r fifo overrun rx_fifo_errors: u64, |
SETOPTIONS |
/// receiver missed packet rx_missed_errors: u64, |
GETEVENTMSG |
// detailed tx_errors tx_aborted_errors: u64, tx_carrier_errors: u64, tx_fifo_errors: u64, tx_heartbeat_errors: u64, tx_window_errors: u64, |
GETSIGINFO |
// for cslip etc |
SETSIGINFO |
rx_compressed: u64, tx_compressed: u64, |
GETREGSET |
/// dropped, no handler found rx_nohandler: u64, }; |
SETREGSET |
pub const perf_event_attr = extern struct { /// Major type: hardware/software/tracepoint/etc. type: PERF.TYPE = undefined, /// Size of the attr structure, for fwd/bwd compat. size: u32 = @sizeOf(perf_event_attr), /// Type specific configuration information. config: u64 = 0, |
SEIZE |
sample_period_or_freq: u64 = 0, sample_type: u64 = 0, read_format: u64 = 0, |
INTERRUPT |
flags: packed struct { /// off by default disabled: bool = false, /// children inherit it inherit: bool = false, /// must always be on PMU pinned: bool = false, /// only group on PMU exclusive: bool = false, /// don't count user exclude_user: bool = false, /// ditto kernel exclude_kernel: bool = false, /// ditto hypervisor exclude_hv: bool = false, /// don't count when idle exclude_idle: bool = false, /// include mmap data mmap: bool = false, /// include comm data comm: bool = false, /// use freq, not period freq: bool = false, /// per task counts inherit_stat: bool = false, /// next exec enables enable_on_exec: bool = false, /// trace fork/exit task: bool = false, /// wakeup_watermark watermark: bool = false, /// precise_ip: /// /// 0 - SAMPLE_IP can have arbitrary skid /// 1 - SAMPLE_IP must have constant skid /// 2 - SAMPLE_IP requested to have 0 skid /// 3 - SAMPLE_IP must have 0 skid /// /// See also PERF_RECORD_MISC_EXACT_IP /// skid constraint precise_ip: u2 = 0, /// non-exec mmap data mmap_data: bool = false, /// sample_type all events sample_id_all: bool = false, |
LISTEN |
/// don't count in host exclude_host: bool = false, /// don't count in guest exclude_guest: bool = false, |
PEEKSIGINFO |
/// exclude kernel callchains exclude_callchain_kernel: bool = false, /// exclude user callchains exclude_callchain_user: bool = false, /// include mmap with inode data mmap2: bool = false, /// flag comm events that are due to an exec comm_exec: bool = false, /// use @clockid for time fields use_clockid: bool = false, /// context switch data context_switch: bool = false, /// Write ring buffer from end to beginning write_backward: bool = false, /// include namespaces data namespaces: bool = false, |
GETSIGMASK |
__reserved_1: u35 = 0, } = .{}, /// wakeup every n events, or /// bytes before wakeup wakeup_events_or_watermark: u32 = 0, |
SETSIGMASK |
bp_type: u32 = 0, |
SECCOMP_GET_FILTER |
/// This field is also used for: /// bp_addr /// kprobe_func for perf_kprobe /// uprobe_path for perf_uprobe config1: u64 = 0, /// This field is also used for: /// bp_len /// kprobe_addr when kprobe_func == null /// probe_offset for perf_[k,u]probe config2: u64 = 0, |
SECCOMP_GET_METADATA |
/// enum perf_branch_sample_type branch_sample_type: u64 = 0, |
GET_SYSCALL_INFO |
/// Defines set of user regs to dump on samples. /// See asm/perf_regs.h for details. sample_regs_user: u64 = 0, |
futex2_waitone |
/// Defines size of the user stack to dump on samples. sample_stack_user: u32 = 0, |
cache_stat_range |
clockid: clockid_t = .REALTIME, /// Defines set of regs to dump for each sample /// state captured on: /// - precise = 0: PMU interrupt /// - precise > 0: sampled instruction /// /// See asm/perf_regs.h for details. sample_regs_intr: u64 = 0, |
cache_stat |
/// Wakeup watermark for AUX area aux_watermark: u32 = 0, sample_max_stack: u16 = 0, /// Align to u64 __reserved_2: u16 = 0, }; |
SHADOW_STACK |
pub const PERF = struct { pub const TYPE = enum(u32) { HARDWARE, SOFTWARE, TRACEPOINT, HW_CACHE, RAW, BREAKPOINT, MAX, _, }; |
SET_TOKEN: |
pub const COUNT = struct { pub const HW = enum(u32) { CPU_CYCLES, INSTRUCTIONS, CACHE_REFERENCES, CACHE_MISSES, BRANCH_INSTRUCTIONS, BRANCH_MISSES, BUS_CYCLES, STALLED_CYCLES_FRONTEND, STALLED_CYCLES_BACKEND, REF_CPU_CYCLES, MAX, |
msghdr |
pub const CACHE = enum(u32) { L1D, L1I, LL, DTLB, ITLB, BPU, NODE, MAX, |
msghdr_const |
pub const OP = enum(u32) { READ, WRITE, PREFETCH, MAX, }; |
wrapped |
pub const RESULT = enum(u32) { ACCESS, MISS, MAX, }; }; }; |
lfs64_abi |
pub const SW = enum(u32) { CPU_CLOCK, TASK_CLOCK, PAGE_FAULTS, CONTEXT_SWITCHES, CPU_MIGRATIONS, PAGE_FAULTS_MIN, PAGE_FAULTS_MAJ, ALIGNMENT_FAULTS, EMULATION_FAULTS, DUMMY, BPF_OUTPUT, MAX, }; }; |
SendfileError |
pub const SAMPLE = struct { pub const IP = 1; pub const TID = 2; pub const TIME = 4; pub const ADDR = 8; pub const READ = 16; pub const CALLCHAIN = 32; pub const ID = 64; pub const CPU = 128; pub const PERIOD = 256; pub const STREAM_ID = 512; pub const RAW = 1024; pub const BRANCH_STACK = 2048; pub const REGS_USER = 4096; pub const STACK_USER = 8192; pub const WEIGHT = 16384; pub const DATA_SRC = 32768; pub const IDENTIFIER = 65536; pub const TRANSACTION = 131072; pub const REGS_INTR = 262144; pub const PHYS_ADDR = 524288; pub const MAX = 1048576; |
sendfile() |
pub const BRANCH = struct { pub const USER = 1 << 0; pub const KERNEL = 1 << 1; pub const HV = 1 << 2; pub const ANY = 1 << 3; pub const ANY_CALL = 1 << 4; pub const ANY_RETURN = 1 << 5; pub const IND_CALL = 1 << 6; pub const ABORT_TX = 1 << 7; pub const IN_TX = 1 << 8; pub const NO_TX = 1 << 9; pub const COND = 1 << 10; pub const CALL_STACK = 1 << 11; pub const IND_JUMP = 1 << 12; pub const CALL = 1 << 13; pub const NO_FLAGS = 1 << 14; pub const NO_CYCLES = 1 << 15; pub const TYPE_SAVE = 1 << 16; pub const MAX = 1 << 17; }; }; |
CopyFileRangeError |
pub const FLAG = struct { pub const FD_NO_GROUP = 1 << 0; pub const FD_OUTPUT = 1 << 1; pub const PID_CGROUP = 1 << 2; pub const FD_CLOEXEC = 1 << 3; }; |
copy_file_range() |
pub const EVENT_IOC = struct { pub const ENABLE = 9216; pub const DISABLE = 9217; pub const REFRESH = 9218; pub const RESET = 9219; pub const PERIOD = 1074275332; pub const SET_OUTPUT = 9221; pub const SET_FILTER = 1074275334; pub const SET_BPF = 1074013192; pub const PAUSE_OUTPUT = 1074013193; pub const QUERY_BPF = 3221758986; pub const MODIFY_ATTRIBUTES = 1074275339; }; pub const IOC_FLAG_GROUP = 1; }; // TODO: Add the rest of the AUDIT defines? pub const AUDIT = struct { pub const ARCH = enum(u32) { const CONVENTION_MIPS64_N32 = 0x20000000; const @"64BIT" = 0x80000000; const LE = 0x40000000; AARCH64 = toAudit(.AARCH64, @"64BIT" | LE), ALPHA = toAudit(.ALPHA, @"64BIT" | LE), ARCOMPACT = toAudit(.ARC_COMPACT, LE), ARCOMPACTBE = toAudit(.ARC_COMPACT, 0), ARCV2 = toAudit(.ARC_COMPACT2, LE), ARCV2BE = toAudit(.ARC_COMPACT2, 0), ARM = toAudit(.ARM, LE), ARMEB = toAudit(.ARM, 0), C6X = toAudit(.TI_C6000, LE), C6XBE = toAudit(.TI_C6000, 0), CRIS = toAudit(.CRIS, LE), CSKY = toAudit(.CSKY, LE), FRV = toAudit(.FRV, 0), H8300 = toAudit(.H8_300, 0), HEXAGON = toAudit(.HEXAGON, 0), I386 = toAudit(.@"386", LE), IA64 = toAudit(.IA_64, @"64BIT" | LE), M32R = toAudit(.M32R, 0), M68K = toAudit(.@"68K", 0), MICROBLAZE = toAudit(.MICROBLAZE, 0), MIPS = toAudit(.MIPS, 0), MIPSEL = toAudit(.MIPS, LE), MIPS64 = toAudit(.MIPS, @"64BIT"), MIPS64N32 = toAudit(.MIPS, @"64BIT" | CONVENTION_MIPS64_N32), MIPSEL64 = toAudit(.MIPS, @"64BIT" | LE), MIPSEL64N32 = toAudit(.MIPS, @"64BIT" | LE | CONVENTION_MIPS64_N32), NDS32 = toAudit(.NDS32, LE), NDS32BE = toAudit(.NDS32, 0), NIOS2 = toAudit(.ALTERA_NIOS2, LE), OPENRISC = toAudit(.OPENRISC, 0), PARISC = toAudit(.PARISC, 0), PARISC64 = toAudit(.PARISC, @"64BIT"), PPC = toAudit(.PPC, 0), PPC64 = toAudit(.PPC64, @"64BIT"), PPC64LE = toAudit(.PPC64, @"64BIT" | LE), RISCV32 = toAudit(.RISCV, LE), RISCV64 = toAudit(.RISCV, @"64BIT" | LE), S390 = toAudit(.S390, 0), S390X = toAudit(.S390, @"64BIT"), SH = toAudit(.SH, 0), SHEL = toAudit(.SH, LE), SH64 = toAudit(.SH, @"64BIT"), SHEL64 = toAudit(.SH, @"64BIT" | LE), SPARC = toAudit(.SPARC, 0), SPARC64 = toAudit(.SPARCV9, @"64BIT"), TILEGX = toAudit(.TILEGX, @"64BIT" | LE), TILEGX32 = toAudit(.TILEGX, LE), TILEPRO = toAudit(.TILEPRO, LE), UNICORE = toAudit(.UNICORE, LE), X86_64 = toAudit(.X86_64, @"64BIT" | LE), XTENSA = toAudit(.XTENSA, 0), LOONGARCH32 = toAudit(.LOONGARCH, LE), LOONGARCH64 = toAudit(.LOONGARCH, @"64BIT" | LE), fn toAudit(em: elf.EM, flags: u32) u32 { return @intFromEnum(em) | flags; } pub const current: AUDIT.ARCH = switch (native_arch) { .arm, .thumb => .ARM, .armeb, .thumbeb => .ARMEB, .aarch64 => .AARCH64, .arc => .ARCV2, .csky => .CSKY, .hexagon => .HEXAGON, .loongarch32 => .LOONGARCH32, .loongarch64 => .LOONGARCH64, .m68k => .M68K, .mips => .MIPS, .mipsel => .MIPSEL, .mips64 => switch (native_abi) { .gnuabin32, .muslabin32 => .MIPS64N32, else => .MIPS64, }, .mips64el => switch (native_abi) { .gnuabin32, .muslabin32 => .MIPSEL64N32, else => .MIPSEL64, }, .powerpc => .PPC, .powerpc64 => .PPC64, .powerpc64le => .PPC64LE, .riscv32 => .RISCV32, .riscv64 => .RISCV64, .sparc => .SPARC, .sparc64 => .SPARC64, .s390x => .S390X, .x86 => .I386, .x86_64 => .X86_64, .xtensa => .XTENSA, else => @compileError("unsupported architecture"), }; }; }; pub const PTRACE = struct { pub const TRACEME = 0; pub const PEEKTEXT = 1; pub const PEEKDATA = 2; pub const PEEKUSER = 3; pub const POKETEXT = 4; pub const POKEDATA = 5; pub const POKEUSER = 6; pub const CONT = 7; pub const KILL = 8; pub const SINGLESTEP = 9; pub const GETREGS = 12; pub const SETREGS = 13; pub const GETFPREGS = 14; pub const SETFPREGS = 15; pub const ATTACH = 16; pub const DETACH = 17; pub const GETFPXREGS = 18; pub const SETFPXREGS = 19; pub const SYSCALL = 24; pub const SETOPTIONS = 0x4200; pub const GETEVENTMSG = 0x4201; pub const GETSIGINFO = 0x4202; pub const SETSIGINFO = 0x4203; pub const GETREGSET = 0x4204; pub const SETREGSET = 0x4205; pub const SEIZE = 0x4206; pub const INTERRUPT = 0x4207; pub const LISTEN = 0x4208; pub const PEEKSIGINFO = 0x4209; pub const GETSIGMASK = 0x420a; pub const SETSIGMASK = 0x420b; pub const SECCOMP_GET_FILTER = 0x420c; pub const SECCOMP_GET_METADATA = 0x420d; pub const GET_SYSCALL_INFO = 0x420e; }; /// For futex2_waitv and futex2_requeue. Arrays of `futex2_waitone` allow /// waiting on multiple futexes in one call. pub const futex2_waitone = extern struct { /// Expected value at uaddr, should match size of futex. val: u64, /// User address to wait on. Top-bits must be 0 on 32-bit. uaddr: u64, /// Flags for this waiter. flags: FUTEX2_FLAGS, /// Reserved member to preserve alignment. __reserved: u32 = 0, }; pub const cache_stat_range = extern struct { off: u64, len: u64, }; pub const cache_stat = extern struct { /// Number of cached pages. cache: u64, /// Number of dirty pages. dirty: u64, /// Number of pages marked for writeback. writeback: u64, /// Number of pages evicted from the cache. evicted: u64, /// Number of recently evicted pages. /// A page is recently evicted if its last eviction was recent enough that its /// reentry to the cache would indicate that it is actively being used by the /// system, and that there is memory pressure on the system. recently_evicted: u64, }; pub const SHADOW_STACK = struct { /// Set up a restore token in the shadow stack. pub const SET_TOKEN: u64 = 1 << 0; }; pub const msghdr = extern struct { name: ?*sockaddr, namelen: socklen_t, iov: [*]iovec, iovlen: usize, control: ?*anyopaque, controllen: usize, flags: u32, }; pub const msghdr_const = extern struct { name: ?*const sockaddr, namelen: socklen_t, iov: [*]const iovec_const, iovlen: usize, control: ?*const anyopaque, controllen: usize, flags: u32, }; /// The syscalls, but with Zig error sets, going through libc if linking libc, /// and with some footguns eliminated. pub const wrapped = struct { pub const lfs64_abi = builtin.link_libc and (builtin.abi.isGnu() or builtin.abi.isAndroid()); const system = if (builtin.link_libc) std.c else std.os.linux; pub const SendfileError = std.posix.UnexpectedError || error{ /// `out_fd` is an unconnected socket, or out_fd closed its read end. BrokenPipe, /// Descriptor is not valid or locked, or an mmap(2)-like operation is not available for in_fd. UnsupportedOperation, /// Nonblocking I/O has been selected but the write would block. WouldBlock, /// Unspecified error while reading from in_fd. InputOutput, /// Insufficient kernel memory to read from in_fd. SystemResources, /// `offset` is not `null` but the input file is not seekable. Unseekable, }; pub fn sendfile( out_fd: fd_t, in_fd: fd_t, in_offset: ?*off_t, in_len: usize, ) SendfileError!usize { const adjusted_len = @min(in_len, 0x7ffff000); // Prevents EOVERFLOW. const sendfileSymbol = if (lfs64_abi) system.sendfile64 else system.sendfile; const rc = sendfileSymbol(out_fd, in_fd, in_offset, adjusted_len); switch (errno(rc)) { .SUCCESS => return @intCast(rc), .BADF => return invalidApiUsage(), // Always a race condition. .FAULT => return invalidApiUsage(), // Segmentation fault. .OVERFLOW => return unexpectedErrno(.OVERFLOW), // We avoid passing too large of a `count`. .NOTCONN => return error.BrokenPipe, // `out_fd` is an unconnected socket .INVAL => return error.UnsupportedOperation, .AGAIN => return error.WouldBlock, .IO => return error.InputOutput, .PIPE => return error.BrokenPipe, .NOMEM => return error.SystemResources, .NXIO => return error.Unseekable, .SPIPE => return error.Unseekable, else => |err| return unexpectedErrno(err), } } pub const CopyFileRangeError = std.posix.UnexpectedError || error{ /// One of: /// * One or more file descriptors are not valid. /// * fd_in is not open for reading; or fd_out is not open for writing. /// * The O_APPEND flag is set for the open file description referred /// to by the file descriptor fd_out. BadFileFlags, /// One of: /// * An attempt was made to write at a position past the maximum file /// offset the kernel supports. /// * An attempt was made to write a range that exceeds the allowed /// maximum file size. The maximum file size differs between /// filesystem implementations and can be different from the maximum /// allowed file offset. /// * An attempt was made to write beyond the process's file size /// resource limit. This may also result in the process receiving a /// SIGXFSZ signal. FileTooBig, /// One of: /// * either fd_in or fd_out is not a regular file /// * flags argument is not zero /// * fd_in and fd_out refer to the same file and the source and target ranges overlap. InvalidArguments, /// A low-level I/O error occurred while copying. InputOutput, /// Either fd_in or fd_out refers to a directory. IsDir, OutOfMemory, /// There is not enough space on the target filesystem to complete the copy. NoSpaceLeft, /// (since Linux 5.19) the filesystem does not support this operation. OperationNotSupported, /// The requested source or destination range is too large to represent /// in the specified data types. Overflow, /// fd_out refers to an immutable file. PermissionDenied, /// Either fd_in or fd_out refers to an active swap file. SwapFile, /// The files referred to by fd_in and fd_out are not on the same /// filesystem, and the source and target filesystems are not of the /// same type, or do not support cross-filesystem copy. NotSameFileSystem, }; pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) CopyFileRangeError!usize { const rc = system.copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); switch (errno(rc)) { .SUCCESS => return @intCast(rc), .BADF => return error.BadFileFlags, .FBIG => return error.FileTooBig, .INVAL => return error.InvalidArguments, .IO => return error.InputOutput, .ISDIR => return error.IsDir, .NOMEM => return error.OutOfMemory, .NOSPC => return error.NoSpaceLeft, .OPNOTSUPP => return error.OperationNotSupported, .OVERFLOW => return error.Overflow, .PERM => return error.PermissionDenied, .TXTBSY => return error.SwapFile, .XDEV => return error.NotSameFileSystem, else => |err| return unexpectedErrno(err), } } const unexpectedErrno = std.posix.unexpectedErrno; fn invalidApiUsage() error{Unexpected} { if (builtin.mode == .Debug) @panic("invalid API usage"); return error.Unexpected; } fn errno(rc: anytype) E { if (builtin.link_libc) { return if (rc == -1) @enumFromInt(std.c._errno().*) else .SUCCESS; } else { return errnoFromSyscall(rc); } } }; |
Generated by zstd-live on 2025-08-12 12:37:56 UTC. |