Skip to content

Personality Components

The Zig personality layer: identifiers, binary-format detection, dispatch, and per-OS syscall translation.

personality/src/personality.zig

personality.zig — Personality identifiers and binary-format detection.

A "personality" defines which OS ABI a userspace process expects. Every Context in the kernel carries a personality, set during exec() based on the binary format and its metadata (ELF OS/ABI, PE subsystem, Mach-O filetype, etc.).

The personality determines:

  1. Which syscall number table to use for dispatch.
  2. How to translate arguments and data structures between the foreign ABI and the kernel's internal representation.
  3. How to encode return values and errors for the foreign ABI.
  4. Signal delivery semantics and signal number mapping.
  5. Process startup convention (register state, stack layout, aux vectors).

Adding a new personality

  1. Add a variant to Personality enum below.
  2. Add a detection clause in from_elf_osabi() and/or from_pe().
  3. Create src/<name>/tables.zig with the syscall number table.
  4. Create src/<name>/shim.zig with argument/structure translators.
  5. Wire the dispatch in main.zig's syscall() function.
  6. Add binary format loading support in the Rust side's ELF/PE/Mach-O loader (see src/elf.rs and the new src/pe.rs, src/macho.rs).

Personality decl

zig
pub const Personality = enum(u32)

Identifies the OS personality of a process.

The numeric values match the C enum in include/personality.h and are the on-wire representation stored in the Context struct.

native decl

zig
pub fn native() Personality

Convenience: return the personality for a native/unknown binary.

name decl

zig
pub fn name(self: Personality) []const u8

Return a human-readable name for logging / debugging.

fromElfOsAbi decl

zig
pub fn fromElfOsAbi(osabi: u8, machine: u16) Personality

Map an ELF e_ident[EI_OSABI] byte to a Personality.

Reference: https://www.sco.com/developers/gabi/latest/ch4.eheader.html

Many ELF binaries have ELFOSABI_NONE (0) or ELFOSABI_LINUX (3). For ELFOSABI_NONE we also inspect the ELF flags and machine type to disambiguate — this is especially important because modern Linux toolchains emit ELFOSABI_NONE with a ELFOSABI_LINUX-compatible ABI.

fromPe decl

zig
pub fn fromPe(machine: u16, _: u16) Personality

Map a PE Machine + Subsystem to a Personality.

Reference: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format

PE (Portable Executable) is the format for Windows executables, DLLs, and object files. It can also be used by UEFI applications.

fromMachO decl

zig
pub fn fromMachO(cputype: u32, _: u32) Personality

Map a Mach-O cputype + filetype to a Personality.

Reference: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/MachRuntime/Reference/reference.html

personality/src/kernel/tables.zig

kernel/tables.zig — Native kernel syscall number definitions and dispatch.

This table mirrors the native kernel syscall ABI defined in syscall/src/number.rs. The dispatch function is a direct passthrough: no argument or structure translation is needed because the kernel's internals use the same ABI.

ABI summary (native kernel)

  • Syscall number in a (register depends on arch: RAX, X8, A7, EAX).
  • Arguments: b through f in arch-specific registers.
  • Return value: usize in arch return register.
  • Error: Error::mux(result)-errno as usize (same as Linux convention).
  • Signals: currently a subset of POSIX; signal numbers are compatible with Linux for the common set.

Stability

The kernel personality MUST remain stable for all existing native userspace programs that ship with this kernel tree (initfs, drivers, etc.).

SYS_OPENAT decl

zig
pub const SYS_OPENAT: usize = SYS_CLASS_PATH | SYS_RET_FILE | 7;

SYS_OPENAT_WITH_FILTER decl

zig
pub const SYS_OPENAT_WITH_FILTER: usize = SYS_CLASS_PATH | SYS_RET_FILE | 985;

SYS_UNLINKAT decl

zig
pub const SYS_UNLINKAT: usize = SYS_CLASS_PATH | 263;

SYS_UNLINKAT_WITH_FILTER decl

zig
pub const SYS_UNLINKAT_WITH_FILTER: usize = SYS_CLASS_PATH | 986;

SYS_CLOSE decl

zig
pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6;

SYS_DUP decl

zig
pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41;

SYS_DUP2 decl

zig
pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63;

SYS_READ decl

zig
pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3;

SYS_READ2 decl

zig
pub const SYS_READ2: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 35;

SYS_WRITE decl

zig
pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4;

SYS_WRITE2 decl

zig
pub const SYS_WRITE2: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 45;

SYS_LSEEK decl

zig
pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19;

SYS_FCHMOD decl

zig
pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94;

SYS_FCHOWN decl

zig
pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207;

SYS_FCNTL decl

zig
pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55;

SYS_FEVENT decl

zig
pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927;

SYS_CALL decl

zig
pub const SYS_CALL: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | SYS_ARG_MSLICE | 0xCA11;

SYS_SENDFD decl

zig
pub const SYS_SENDFD: usize = SYS_CLASS_FILE | 34;

SYS_GETDENTS decl

zig
pub const SYS_GETDENTS: usize = SYS_CLASS_FILE | 43;

SYS_FMAP decl

zig
pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900;

SYS_FUNMAP decl

zig
pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 92;

SYS_MREMAP decl

zig
pub const SYS_MREMAP: usize = 155;
zig
pub const SYS_FLINK: usize = SYS_CLASS_FILE | SYS_ARG_PATH | 9;

SYS_FPATH decl

zig
pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928;

SYS_FRENAME decl

zig
pub const SYS_FRENAME: usize = SYS_CLASS_FILE | SYS_ARG_PATH | 38;

SYS_FSTAT decl

zig
pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28;

SYS_FSTATVFS decl

zig
pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100;

SYS_FSYNC decl

zig
pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118;

SYS_FTRUNCATE decl

zig
pub const SYS_FTRUNCATE: usize = SYS_CLASS_FILE | 93;

SYS_FUTIMENS decl

zig
pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320;

SYS_CLOCK_GETTIME decl

zig
pub const SYS_CLOCK_GETTIME: usize = 265;

SYS_FUTEX decl

zig
pub const SYS_FUTEX: usize = 240;

SYS_MPROTECT decl

zig
pub const SYS_MPROTECT: usize = 125;

SYS_MKNS decl

zig
pub const SYS_MKNS: usize = 984;

SYS_NANOSLEEP decl

zig
pub const SYS_NANOSLEEP: usize = 162;

SYS_YIELD decl

zig
pub const SYS_YIELD: usize = 158;

KERNEL_O_RDONLY decl

zig
pub const KERNEL_O_RDONLY: usize = 0x0001_0000;

Native kernel open flags (bit positions differ from canonical POSIX).

KERNEL_O_WRONLY decl

zig
pub const KERNEL_O_WRONLY: usize = 0x0002_0000;

KERNEL_O_RDWR decl

zig
pub const KERNEL_O_RDWR: usize = 0x0003_0000;

KERNEL_O_NONBLOCK decl

zig
pub const KERNEL_O_NONBLOCK: usize = 0x0004_0000;

KERNEL_O_APPEND decl

zig
pub const KERNEL_O_APPEND: usize = 0x0008_0000;

KERNEL_O_SHLOCK decl

zig
pub const KERNEL_O_SHLOCK: usize = 0x0010_0000;

KERNEL_O_EXLOCK decl

zig
pub const KERNEL_O_EXLOCK: usize = 0x0020_0000;

KERNEL_O_ASYNC decl

zig
pub const KERNEL_O_ASYNC: usize = 0x0040_0000;

KERNEL_O_FSYNC decl

zig
pub const KERNEL_O_FSYNC: usize = 0x0080_0000;

KERNEL_O_CLOEXEC decl

zig
pub const KERNEL_O_CLOEXEC: usize = 0x0100_0000;

KERNEL_O_CREAT decl

zig
pub const KERNEL_O_CREAT: usize = 0x0200_0000;

KERNEL_O_TRUNC decl

zig
pub const KERNEL_O_TRUNC: usize = 0x0400_0000;

KERNEL_O_EXCL decl

zig
pub const KERNEL_O_EXCL: usize = 0x0800_0000;

KERNEL_O_DIRECTORY decl

zig
pub const KERNEL_O_DIRECTORY: usize = 0x1000_0000;

KERNEL_O_STAT decl

zig
pub const KERNEL_O_STAT: usize = 0x2000_0000;
zig
pub const KERNEL_O_SYMLINK: usize = 0x4000_0000;

KERNEL_O_NOFOLLOW decl

zig
pub const KERNEL_O_NOFOLLOW: usize = 0x8000_0000;

KERNEL_O_ACCMODE decl

zig
pub const KERNEL_O_ACCMODE: usize = 0x0003_0000;

KERNEL_PROT_NONE decl

zig
pub const KERNEL_PROT_NONE: usize = 0x0000_0000;

Native kernel mmap flags.

KERNEL_PROT_EXEC decl

zig
pub const KERNEL_PROT_EXEC: usize = 0x0001_0000;

KERNEL_PROT_WRITE decl

zig
pub const KERNEL_PROT_WRITE: usize = 0x0002_0000;

KERNEL_PROT_READ decl

zig
pub const KERNEL_PROT_READ: usize = 0x0004_0000;

KERNEL_MAP_SHARED decl

zig
pub const KERNEL_MAP_SHARED: usize = 0x0001;

KERNEL_MAP_PRIVATE decl

zig
pub const KERNEL_MAP_PRIVATE: usize = 0x0002;

KERNEL_MAP_FIXED decl

zig
pub const KERNEL_MAP_FIXED: usize = 0x0004;

KERNEL_MAP_FIXED_NOREPLACE decl

zig
pub const KERNEL_MAP_FIXED_NOREPLACE: usize = 0x000C;

KERNEL_MAP_LAZY decl

zig
pub const KERNEL_MAP_LAZY: usize = 0x0010;

posixToKernelOpenFlags decl

zig
pub fn posixToKernelOpenFlags(canonical: u32) usize

Convert canonical POSIX open flags to native kernel open flags.

posixToKernelProt decl

zig
pub fn posixToKernelProt(canonical: u32) usize

Convert canonical mmap prot flags to native kernel prot flags.

posixToKernelMapFlags decl

zig
pub fn posixToKernelMapFlags(canonical: u32) usize

Convert canonical mmap flags to native kernel mmap flags.

SyscallEntry decl

zig
pub const SyscallEntry = struct

Internal operation identifiers — these are indices into the kernel ops table (see KernelOps in main.zig).

For the kernel personality, we dispatch directly by syscall number since the numbers ARE the kernel's native ABI. This table maps the SYS_* constants to kernel operation indices.

UNIMPLEMENTED decl

zig
pub const UNIMPLEMENTED: SyscallEntry = .{ .op_index = -1, .returns_fd = false };

The default operation to return for unimplemented syscalls.

lookup decl

zig
pub fn lookup(syscall_num: usize) ?SyscallEntry

Translate a native kernel syscall number to a kernel operation table index. Returns null for ENOSYS.

personality/src/linux/tables.zig

linux/tables.zig — Linux syscall number definitions and dispatch table.

This file defines the Linux syscall ABI for x86_64, aarch64, and riscv64. Each architecture has its own syscall number assignment; the dispatch table maps from (arch, number) to a kernel operation index.

ABI summary (Linux)

x86_64 (syscall instruction):

  • Number in RAX, arguments in RDI, RSI, RDX, R10, R8, R9.
  • Return value in RAX (positive or zero on success).
  • Error: RAX = -errno (negative errno, 0..=4095 range).
  • RCX and R11 are clobbered (RCX = return RIP, R11 = saved RFLAGS).

aarch64 (svc #0):

  • Number in X8, arguments in X0..X5.
  • Return value in X0.
  • Error: X0 in range [-4095..-1] (negative errno).

riscv64 (ecall):

  • Number in A7, arguments in A0..A5.
  • Return value in A0.
  • Error: A0 in range [-4095..-1] (negative errno).

References

SyscallEntry decl

zig
pub const SyscallEntry = struct

Describes a syscall table entry.

UNIMPLEMENTED decl

zig
pub const UNIMPLEMENTED: SyscallEntry = .

x86_64_table decl

zig
pub const x86_64_table = init:

aarch64_table decl

zig
pub const aarch64_table = init:

riscv64_table decl

zig
pub const riscv64_table = aarch64_table;

Arch decl

zig
pub const Arch = enum(u32)

Arch identifier for per-arch table selection.

getTable decl

zig
pub fn getTable(arch: Arch) *const [512]SyscallEntry

Return the syscall table for the given architecture.

personality/src/linux/shim.zig

linux/shim.zig — Translates Linux ABI data structures and arguments into the kernel's canonical internal representation.

Each personality must provide shim functions for every syscall whose arguments include pointers to structures whose layout differs between the foreign OS and the kernel internals, OR whose flag/value constants have different numeric definitions.

The functions here are called from the Linux dispatch table handler in main.zig when the needs_translation flag is set.

linuxToCanonicalOpenFlags decl

zig
pub fn linuxToCanonicalOpenFlags(linux_flags: u32) u32

Linux open flags → canonical open flags. Flags not listed here are passed through unchanged.

linuxToCanonicalProt decl

zig
pub fn linuxToCanonicalProt(linux_prot: u32) u32

Linux mmap prot flags → canonical prot flags (values are identical).

linuxToCanonicalMapFlags decl

zig
pub fn linuxToCanonicalMapFlags(linux_flags: u32) u32

Linux mmap flags → canonical mmap flags.

LinuxStat decl

zig
pub const LinuxStat = extern struct

Linux struct stat layout (x86_64) → canonical FileStat.

Linux x86_64 struct stat (from <asm/stat.h>):

c
struct stat {
unsigned long  st_dev;     // 8 bytes (offset 0)
unsigned long  st_ino;     // 8 bytes (offset 8)
unsigned long  st_nlink;   // 8 bytes (offset 16)
unsigned int   st_mode;    // 4 bytes (offset 24)
unsigned int   st_uid;     // 4 bytes (offset 28)
unsigned int   st_gid;     // 4 bytes (offset 32)
unsigned int   __pad0;     // 4 bytes (offset 36)
unsigned long  st_rdev;    // 8 bytes (offset 40)
long           st_size;    // 8 bytes (offset 48)
long           st_blksize; // 8 bytes (offset 56)
long           st_blocks;  // 8 bytes (offset 64)
struct timespec st_atim;   // 16 bytes (offset 72)
struct timespec st_mtim;   // 16 bytes (offset 88)
struct timespec st_ctim;   // 16 bytes (offset 104)
long           __unused[3];// 24 bytes (offset 120)
}; // total size = 144 bytes

toCanonical decl

zig
pub fn toCanonical(self: *const LinuxStat) types.FileStat

Convert a Linux stat to the canonical internal FileStat.

LinuxStatAarch64 decl

zig
pub const LinuxStatAarch64 = extern struct

Linux struct stat layout (aarch64) — differs from x86_64 in field types.

ARM64 struct stat (from <asm/stat.h>):

c
struct stat {
unsigned long long st_dev;     // 8 (0)
unsigned long long st_ino;     // 8 (8)
unsigned int       st_mode;    // 4 (16)
unsigned int       st_nlink;   // 4 (20)
unsigned int       st_uid;     // 4 (24)
unsigned int       st_gid;     // 4 (28)
unsigned long long st_rdev;    // 8 (32)
unsigned long long __pad0;     // 8 (40)
long long          st_size;    // 8 (48)
int                st_blksize; // 4 (56)
int                __pad1;     // 4 (60)
long long          st_blocks;  // 8 (64)
struct timespec    st_atim;    // 16 (72)
struct timespec    st_mtim;    // 16 (88)
struct timespec    st_ctim;    // 16 (104)
long long          __unused[2];// 16 (120)
}; // total = 128 bytes (ARM64 has no padding for alignment)

toCanonical decl

zig
pub fn toCanonical(self: *const LinuxStatAarch64) types.FileStat

LinuxTimeSpec decl

zig
pub const LinuxTimeSpec = extern struct

Linux struct timespec (both x86_64 and aarch64):

c
struct timespec {
long   tv_sec;   // 8 bytes
long   tv_nsec;  // 8 bytes
};

Note: Linux long is always 8 bytes on x86_64 and aarch64. Our canonical TimeSpec uses i64, i32.

toCanonical decl

zig
pub fn toCanonical(self: *const LinuxTimeSpec) types.TimeSpec

fromCanonical decl

zig
pub fn fromCanonical(canon: *const types.TimeSpec) LinuxTimeSpec

LinuxCompatTimeSpec decl

zig
pub const LinuxCompatTimeSpec = packed struct

Linux struct timespec for 32-bit x86 (compat):

c
struct timespec {
long long tv_sec;   // 8 bytes
long      tv_nsec;  // 4 bytes on 32-bit
};

toCanonical decl

zig
pub fn toCanonical(self: *const LinuxCompatTimeSpec) types.TimeSpec

LinuxSigaction decl

zig
pub const LinuxSigaction = extern struct

Linux struct sigaction layout (x86_64):

c
struct sigaction {
void     (*sa_handler)(int);        // 8 bytes
unsigned long sa_flags;             // 8 bytes
void     (*sa_restorer)(void);      // 8 bytes
sigset_t sa_mask;                   // 8 bytes (on x86_64, sigset_t is unsigned long)
};

Note: This differs from our canonical sigaction (if any). We'll need this when implementing Linux signal delivery.

LinuxRLimit decl

zig
pub const LinuxRLimit = extern struct

Linux struct rlimit (x86_64):

c
struct rlimit {
unsigned long rlim_cur;  // 8 bytes
unsigned long rlim_max;  // 8 bytes
};

LinuxUtsName decl

zig
pub const LinuxUtsName = extern struct

Linux struct utsname (for uname syscall):

c
struct utsname {
char sysname[65];
char nodename[65];
char release[65];
char version[65];
char machine[65];
char domainname[65];
};

linuxErrnoToCanonical decl

zig
pub fn linuxErrnoToCanonical(linux_errno: i32) i32

Linux errno values are identical to our canonical errno values (Linux-compatible from the start). No translation is needed.

canonicalToLinuxResult decl

zig
pub fn canonicalToLinuxResult(result_code: i64, errno: i32) i64

Translate a canonical errno to the Linux return convention. Linux returns negative errno in the return register.

personality/src/main.zig

main.zig — Multi-personality syscall dispatch.

Convention

Kernel ops return i32: non-negative=success, negative=-errno. invokeOperation sign-extends i32→isize→usize so negative values survive as large usize. decodeResult reverses this: usize→isize→i32 to extract errno.

get decl

zig
pub fn get(self: *const @This(), index: usize) ?KernelOp

personality_init decl

zig
export fn personality_init(ops: *const KernelOps) void

personality_syscall decl

zig
export fn personality_syscall(

personality/src/types.zig

types.zig — Shared type definitions for the personality syscall layer.

This file defines the data structures that bridge foreign-OS ABIs and the kernel's internal representation. Each personality shim translates between foreign struct layouts (e.g., Linux struct stat) and these canonical internal types, which are then passed to the kernel operation callbacks.

Canonical internal types

FileStat decl

zig
pub const FileStat = extern struct

Canonical metadata about a file (bridge between all OS stat variants).

TimeSpec decl

zig
pub const TimeSpec = extern struct

Canonical time specification.

Map decl

zig
pub const Map = extern struct

Canonical memory map description.

S_IFMT decl

zig
pub const S_IFMT: u32 = 0o170000;

S_IFSOCK decl

zig
pub const S_IFSOCK: u32 = 0o140000;

S_IFLNK decl

zig
pub const S_IFLNK: u32 = 0o120000;

S_IFREG decl

zig
pub const S_IFREG: u32 = 0o100000;

S_IFBLK decl

zig
pub const S_IFBLK: u32 = 0o060000;

S_IFDIR decl

zig
pub const S_IFDIR: u32 = 0o040000;

S_IFCHR decl

zig
pub const S_IFCHR: u32 = 0o020000;

S_IFIFO decl

zig
pub const S_IFIFO: u32 = 0o010000;

S_ISUID decl

zig
pub const S_ISUID: u32 = 0o4000;

S_ISGID decl

zig
pub const S_ISGID: u32 = 0o2000;

S_ISVTX decl

zig
pub const S_ISVTX: u32 = 0o1000;

S_IRWXU decl

zig
pub const S_IRWXU: u32 = 0o0700;

S_IRUSR decl

zig
pub const S_IRUSR: u32 = 0o0400;

S_IWUSR decl

zig
pub const S_IWUSR: u32 = 0o0200;

S_IXUSR decl

zig
pub const S_IXUSR: u32 = 0o0100;

S_IRWXG decl

zig
pub const S_IRWXG: u32 = 0o0070;

S_IRGRP decl

zig
pub const S_IRGRP: u32 = 0o0040;

S_IWGRP decl

zig
pub const S_IWGRP: u32 = 0o0020;

S_IXGRP decl

zig
pub const S_IXGRP: u32 = 0o0010;

S_IRWXO decl

zig
pub const S_IRWXO: u32 = 0o0007;

S_IROTH decl

zig
pub const S_IROTH: u32 = 0o0004;

S_IWOTH decl

zig
pub const S_IWOTH: u32 = 0o0002;

S_IXOTH decl

zig
pub const S_IXOTH: u32 = 0o0001;

O_ACCMODE decl

zig
pub const O_ACCMODE: u32 = 0x0003;

Canonical open flags (common subset of O_RDONLY, O_WRONLY, O_RDWR etc.)

O_RDONLY decl

zig
pub const O_RDONLY: u32 = 0x0000;

O_WRONLY decl

zig
pub const O_WRONLY: u32 = 0x0001;

O_RDWR decl

zig
pub const O_RDWR: u32 = 0x0002;

O_CREAT decl

zig
pub const O_CREAT: u32 = 0x0040;

O_EXCL decl

zig
pub const O_EXCL: u32 = 0x0080;

O_NOCTTY decl

zig
pub const O_NOCTTY: u32 = 0x0100;

O_TRUNC decl

zig
pub const O_TRUNC: u32 = 0x0200;

O_APPEND decl

zig
pub const O_APPEND: u32 = 0x0400;

O_NONBLOCK decl

zig
pub const O_NONBLOCK: u32 = 0x0800;

O_DSYNC decl

zig
pub const O_DSYNC: u32 = 0x1000;

O_DIRECTORY decl

zig
pub const O_DIRECTORY: u32 = 0x2000;

O_NOFOLLOW decl

zig
pub const O_NOFOLLOW: u32 = 0x4000;

O_CLOEXEC decl

zig
pub const O_CLOEXEC: u32 = 0x8000;

O_SYNC decl

zig
pub const O_SYNC: u32 = 0x4010000; // __O_SYNC | O_DSYNC in Linux

SEEK_SET decl

zig
pub const SEEK_SET: u32 = 0;

Canonical seek whence.

SEEK_CUR decl

zig
pub const SEEK_CUR: u32 = 1;

SEEK_END decl

zig
pub const SEEK_END: u32 = 2;

PROT_NONE decl

zig
pub const PROT_NONE: u32 = 0;

Canonical mmap prot flags.

PROT_READ decl

zig
pub const PROT_READ: u32 = 1;

PROT_WRITE decl

zig
pub const PROT_WRITE: u32 = 2;

PROT_EXEC decl

zig
pub const PROT_EXEC: u32 = 4;

MAP_SHARED decl

zig
pub const MAP_SHARED: u32 = 0x01;

Canonical mmap flags.

MAP_PRIVATE decl

zig
pub const MAP_PRIVATE: u32 = 0x02;

MAP_FIXED decl

zig
pub const MAP_FIXED: u32 = 0x10;

MAP_ANONYMOUS decl

zig
pub const MAP_ANONYMOUS: u32 = 0x20;

MAP_GROWSDOWN decl

zig
pub const MAP_GROWSDOWN: u32 = 0x0100;

MAP_DENYWRITE decl

zig
pub const MAP_DENYWRITE: u32 = 0x0800;

MAP_EXECUTABLE decl

zig
pub const MAP_EXECUTABLE: u32 = 0x1000;

MAP_LOCKED decl

zig
pub const MAP_LOCKED: u32 = 0x2000;

MAP_NORESERVE decl

zig
pub const MAP_NORESERVE: u32 = 0x4000;

MAP_POPULATE decl

zig
pub const MAP_POPULATE: u32 = 0x8000;

SIG_HUP decl

zig
pub const SIG_HUP: u32 = 1;

Canonical signal numbers (Linux-compatible as the baseline). Each personality shim maps foreign signals to/from these.

SIG_INT decl

zig
pub const SIG_INT: u32 = 2;

SIG_QUIT decl

zig
pub const SIG_QUIT: u32 = 3;

SIG_ILL decl

zig
pub const SIG_ILL: u32 = 4;

SIG_TRAP decl

zig
pub const SIG_TRAP: u32 = 5;

SIG_ABRT decl

zig
pub const SIG_ABRT: u32 = 6;

SIG_EMT decl

zig
pub const SIG_EMT: u32 = 7;

SIG_FPE decl

zig
pub const SIG_FPE: u32 = 8;

SIG_KILL decl

zig
pub const SIG_KILL: u32 = 9;

SIG_BUS decl

zig
pub const SIG_BUS: u32 = 10;

SIG_SEGV decl

zig
pub const SIG_SEGV: u32 = 11;

SIG_SYS decl

zig
pub const SIG_SYS: u32 = 12;

SIG_PIPE decl

zig
pub const SIG_PIPE: u32 = 13;

SIG_ALRM decl

zig
pub const SIG_ALRM: u32 = 14;

SIG_TERM decl

zig
pub const SIG_TERM: u32 = 15;

SIG_URG decl

zig
pub const SIG_URG: u32 = 16;

SIG_STOP decl

zig
pub const SIG_STOP: u32 = 17;

SIG_TSTP decl

zig
pub const SIG_TSTP: u32 = 18;

SIG_CONT decl

zig
pub const SIG_CONT: u32 = 19;

SIG_CHLD decl

zig
pub const SIG_CHLD: u32 = 20;

SIG_TTIN decl

zig
pub const SIG_TTIN: u32 = 21;

SIG_TTOU decl

zig
pub const SIG_TTOU: u32 = 22;

SIG_IO decl

zig
pub const SIG_IO: u32 = 23;

SIG_XCPU decl

zig
pub const SIG_XCPU: u32 = 24;

SIG_XFSZ decl

zig
pub const SIG_XFSZ: u32 = 25;

SIG_VTALRM decl

zig
pub const SIG_VTALRM: u32 = 26;

SIG_PROF decl

zig
pub const SIG_PROF: u32 = 27;

SIG_WINCH decl

zig
pub const SIG_WINCH: u32 = 28;

SIG_INFO decl

zig
pub const SIG_INFO: u32 = 29;

SIG_USR1 decl

zig
pub const SIG_USR1: u32 = 30;

SIG_USR2 decl

zig
pub const SIG_USR2: u32 = 31;

SIG_MAX decl

zig
pub const SIG_MAX: u32 = 31;

Maximum canonical signal number.

EPERM decl

zig
pub const EPERM: i32 = 1;

Canonical errno constants (Linux-compatible; the kernel's internal error space already uses these values — see syscall/src/error.rs).

Each personality shim translates between foreign errno values and these internal ones. The kernel operation callbacks return these values.

ENOENT decl

zig
pub const ENOENT: i32 = 2;

ESRCH decl

zig
pub const ESRCH: i32 = 3;

EINTR decl

zig
pub const EINTR: i32 = 4;

EIO decl

zig
pub const EIO: i32 = 5;

ENXIO decl

zig
pub const ENXIO: i32 = 6;

E2BIG decl

zig
pub const E2BIG: i32 = 7;

ENOEXEC decl

zig
pub const ENOEXEC: i32 = 8;

EBADF decl

zig
pub const EBADF: i32 = 9;

ECHILD decl

zig
pub const ECHILD: i32 = 10;

EAGAIN decl

zig
pub const EAGAIN: i32 = 11;

ENOMEM decl

zig
pub const ENOMEM: i32 = 12;

EACCES decl

zig
pub const EACCES: i32 = 13;

EFAULT decl

zig
pub const EFAULT: i32 = 14;

ENOTBLK decl

zig
pub const ENOTBLK: i32 = 15;

EBUSY decl

zig
pub const EBUSY: i32 = 16;

EEXIST decl

zig
pub const EEXIST: i32 = 17;

EXDEV decl

zig
pub const EXDEV: i32 = 18;

ENODEV decl

zig
pub const ENODEV: i32 = 19;

ENOTDIR decl

zig
pub const ENOTDIR: i32 = 20;

EISDIR decl

zig
pub const EISDIR: i32 = 21;

EINVAL decl

zig
pub const EINVAL: i32 = 22;

ENFILE decl

zig
pub const ENFILE: i32 = 23;

EMFILE decl

zig
pub const EMFILE: i32 = 24;

ENOTTY decl

zig
pub const ENOTTY: i32 = 25;

ETXTBSY decl

zig
pub const ETXTBSY: i32 = 26;

EFBIG decl

zig
pub const EFBIG: i32 = 27;

ENOSPC decl

zig
pub const ENOSPC: i32 = 28;

ESPIPE decl

zig
pub const ESPIPE: i32 = 29;

EROFS decl

zig
pub const EROFS: i32 = 30;
zig
pub const EMLINK: i32 = 31;

EPIPE decl

zig
pub const EPIPE: i32 = 32;

EDOM decl

zig
pub const EDOM: i32 = 33;

ERANGE decl

zig
pub const ERANGE: i32 = 34;

EDEADLK decl

zig
pub const EDEADLK: i32 = 35;

ENAMETOOLONG decl

zig
pub const ENAMETOOLONG: i32 = 36;

ENOLCK decl

zig
pub const ENOLCK: i32 = 37;

ENOSYS decl

zig
pub const ENOSYS: i32 = 38;

ENOTEMPTY decl

zig
pub const ENOTEMPTY: i32 = 39;

ELOOP decl

zig
pub const ELOOP: i32 = 40;

EWOULDBLOCK decl

zig
pub const EWOULDBLOCK: i32 = 41;

ENOMSG decl

zig
pub const ENOMSG: i32 = 42;

EIDRM decl

zig
pub const EIDRM: i32 = 43;

ECHRNG decl

zig
pub const ECHRNG: i32 = 44;

EL2NSYNC decl

zig
pub const EL2NSYNC: i32 = 45;

EL3HLT decl

zig
pub const EL3HLT: i32 = 46;

EL3RST decl

zig
pub const EL3RST: i32 = 47;

ELNRNG decl

zig
pub const ELNRNG: i32 = 48;

EUNATCH decl

zig
pub const EUNATCH: i32 = 49;

ENOCSI decl

zig
pub const ENOCSI: i32 = 50;

EL2HLT decl

zig
pub const EL2HLT: i32 = 51;

EBADE decl

zig
pub const EBADE: i32 = 52;

EBADR decl

zig
pub const EBADR: i32 = 53;

EXFULL decl

zig
pub const EXFULL: i32 = 54;

ENOANO decl

zig
pub const ENOANO: i32 = 55;

EBADRQC decl

zig
pub const EBADRQC: i32 = 56;

EBADSLT decl

zig
pub const EBADSLT: i32 = 57;

EDEADLOCK decl

zig
pub const EDEADLOCK: i32 = 58;

EBFONT decl

zig
pub const EBFONT: i32 = 59;

ENOSTR decl

zig
pub const ENOSTR: i32 = 60;

ENODATA decl

zig
pub const ENODATA: i32 = 61;

ETIME decl

zig
pub const ETIME: i32 = 62;

ENOSR decl

zig
pub const ENOSR: i32 = 63;

ENONET decl

zig
pub const ENONET: i32 = 64;

ENOPKG decl

zig
pub const ENOPKG: i32 = 65;

EREMOTE decl

zig
pub const EREMOTE: i32 = 66;
zig
pub const ENOLINK: i32 = 67;

EADV decl

zig
pub const EADV: i32 = 68;

ESRMNT decl

zig
pub const ESRMNT: i32 = 69;

ECOMM decl

zig
pub const ECOMM: i32 = 70;

EPROTO decl

zig
pub const EPROTO: i32 = 71;

EMULTIHOP decl

zig
pub const EMULTIHOP: i32 = 72;

EDOTDOT decl

zig
pub const EDOTDOT: i32 = 73;

EBADMSG decl

zig
pub const EBADMSG: i32 = 74;

EOVERFLOW decl

zig
pub const EOVERFLOW: i32 = 75;

ENOTUNIQ decl

zig
pub const ENOTUNIQ: i32 = 76;

EBADFD decl

zig
pub const EBADFD: i32 = 77;

EREMCHG decl

zig
pub const EREMCHG: i32 = 78;

ELIBACC decl

zig
pub const ELIBACC: i32 = 79;

ELIBBAD decl

zig
pub const ELIBBAD: i32 = 80;

ELIBSCN decl

zig
pub const ELIBSCN: i32 = 81;

ELIBMAX decl

zig
pub const ELIBMAX: i32 = 82;

ELIBEXEC decl

zig
pub const ELIBEXEC: i32 = 83;

EILSEQ decl

zig
pub const EILSEQ: i32 = 84;

ERESTART decl

zig
pub const ERESTART: i32 = 85;

ESTRPIPE decl

zig
pub const ESTRPIPE: i32 = 86;

EUSERS decl

zig
pub const EUSERS: i32 = 87;

ENOTSOCK decl

zig
pub const ENOTSOCK: i32 = 88;

EDESTADDRREQ decl

zig
pub const EDESTADDRREQ: i32 = 89;

EMSGSIZE decl

zig
pub const EMSGSIZE: i32 = 90;

EPROTOTYPE decl

zig
pub const EPROTOTYPE: i32 = 91;

ENOPROTOOPT decl

zig
pub const ENOPROTOOPT: i32 = 92;

EPROTONOSUPPORT decl

zig
pub const EPROTONOSUPPORT: i32 = 93;

ESOCKTNOSUPPORT decl

zig
pub const ESOCKTNOSUPPORT: i32 = 94;

EOPNOTSUPP decl

zig
pub const EOPNOTSUPP: i32 = 95;

EPFNOSUPPORT decl

zig
pub const EPFNOSUPPORT: i32 = 96;

EAFNOSUPPORT decl

zig
pub const EAFNOSUPPORT: i32 = 97;

EADDRINUSE decl

zig
pub const EADDRINUSE: i32 = 98;

EADDRNOTAVAIL decl

zig
pub const EADDRNOTAVAIL: i32 = 99;

ENETDOWN decl

zig
pub const ENETDOWN: i32 = 100;

ENETUNREACH decl

zig
pub const ENETUNREACH: i32 = 101;

ENETRESET decl

zig
pub const ENETRESET: i32 = 102;

ECONNABORTED decl

zig
pub const ECONNABORTED: i32 = 103;

ECONNRESET decl

zig
pub const ECONNRESET: i32 = 104;

ENOBUFS decl

zig
pub const ENOBUFS: i32 = 105;

EISCONN decl

zig
pub const EISCONN: i32 = 106;

ENOTCONN decl

zig
pub const ENOTCONN: i32 = 107;

ESHUTDOWN decl

zig
pub const ESHUTDOWN: i32 = 108;

ETOOMANYREFS decl

zig
pub const ETOOMANYREFS: i32 = 109;

ETIMEDOUT decl

zig
pub const ETIMEDOUT: i32 = 110;

ECONNREFUSED decl

zig
pub const ECONNREFUSED: i32 = 111;

EHOSTDOWN decl

zig
pub const EHOSTDOWN: i32 = 112;

EHOSTUNREACH decl

zig
pub const EHOSTUNREACH: i32 = 113;

EALREADY decl

zig
pub const EALREADY: i32 = 114;

EINPROGRESS decl

zig
pub const EINPROGRESS: i32 = 115;

ESTALE decl

zig
pub const ESTALE: i32 = 116;

EUCLEAN decl

zig
pub const EUCLEAN: i32 = 117;

ENOTNAM decl

zig
pub const ENOTNAM: i32 = 118;

ENAVAIL decl

zig
pub const ENAVAIL: i32 = 119;

EISNAM decl

zig
pub const EISNAM: i32 = 120;

EREMOTEIO decl

zig
pub const EREMOTEIO: i32 = 121;

EDQUOT decl

zig
pub const EDQUOT: i32 = 122;

ENOMEDIUM decl

zig
pub const ENOMEDIUM: i32 = 123;

EMEDIUMTYPE decl

zig
pub const EMEDIUMTYPE: i32 = 124;

ECANCELED decl

zig
pub const ECANCELED: i32 = 125;

ENOKEY decl

zig
pub const ENOKEY: i32 = 126;

EKEYEXPIRED decl

zig
pub const EKEYEXPIRED: i32 = 127;

EKEYREVOKED decl

zig
pub const EKEYREVOKED: i32 = 128;

EKEYREJECTED decl

zig
pub const EKEYREJECTED: i32 = 129;

EOWNERDEAD decl

zig
pub const EOWNERDEAD: i32 = 130;

ENOTRECOVERABLE decl

zig
pub const ENOTRECOVERABLE: i32 = 131;

Released under the AWFixer Source Available License v0.4. #linuswasright