Command flags for fcntl(2).
pub const F = switch (native_os)
pub const F = switch (native_os) {
.linux => linux.F,
.emscripten => emscripten.F,
.wasi => struct {
// Match `F_*` constants from lib/libc/include/wasm-wasi-musl/__header_fcntl.h
pub const GETFD = 1;
pub const SETFD = 2;
pub const GETFL = 3;
pub const SETFL = 4;
},
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct {
/// duplicate file descriptor
pub const DUPFD = 0;
/// get file descriptor flags
pub const GETFD = 1;
/// set file descriptor flags
pub const SETFD = 2;
/// get file status flags
pub const GETFL = 3;
/// set file status flags
pub const SETFL = 4;
/// get SIGIO/SIGURG proc/pgrp
pub const GETOWN = 5;
/// set SIGIO/SIGURG proc/pgrp
pub const SETOWN = 6;
/// get record locking information
pub const GETLK = 7;
/// set record locking information
pub const SETLK = 8;
/// F.SETLK; wait if blocked
pub const SETLKW = 9;
/// F.SETLK; wait if blocked, return on timeout
pub const SETLKWTIMEOUT = 10;
pub const FLUSH_DATA = 40;
/// Used for regression test
pub const CHKCLEAN = 41;
/// Preallocate storage
pub const PREALLOCATE = 42;
/// Truncate a file without zeroing space
pub const SETSIZE = 43;
/// Issue an advisory read async with no copy to user
pub const RDADVISE = 44;
/// turn read ahead off/on for this fd
pub const RDAHEAD = 45;
/// turn data caching off/on for this fd
pub const NOCACHE = 48;
/// file offset to device offset
pub const LOG2PHYS = 49;
/// return the full path of the fd
pub const GETPATH = 50;
/// fsync + ask the drive to flush to the media
pub const FULLFSYNC = 51;
/// find which component (if any) is a package
pub const PATHPKG_CHECK = 52;
/// "freeze" all fs operations
pub const FREEZE_FS = 53;
/// "thaw" all fs operations
pub const THAW_FS = 54;
/// turn data caching off/on (globally) for this file
pub const GLOBAL_NOCACHE = 55;
/// add detached signatures
pub const ADDSIGS = 59;
/// add signature from same file (used by dyld for shared libs)
pub const ADDFILESIGS = 61;
/// used in conjunction with F.NOCACHE to indicate that DIRECT, synchronous writes
/// should not be used (i.e. its ok to temporarily create cached pages)
pub const NODIRECT = 62;
/// Get the protection class of a file from the EA, returns int
pub const GETPROTECTIONCLASS = 63;
/// Set the protection class of a file for the EA, requires int
pub const SETPROTECTIONCLASS = 64;
/// file offset to device offset, extended
pub const LOG2PHYS_EXT = 65;
/// get record locking information, per-process
pub const GETLKPID = 66;
/// Mark the file as being the backing store for another filesystem
pub const SETBACKINGSTORE = 70;
/// return the full path of the FD, but error in specific mtmd circumstances
pub const GETPATH_MTMINFO = 71;
/// Returns the code directory, with associated hashes, to the caller
pub const GETCODEDIR = 72;
/// No SIGPIPE generated on EPIPE
pub const SETNOSIGPIPE = 73;
/// Status of SIGPIPE for this fd
pub const GETNOSIGPIPE = 74;
/// For some cases, we need to rewrap the key for AKS/MKB
pub const TRANSCODEKEY = 75;
/// file being written to a by single writer... if throttling enabled, writes
/// may be broken into smaller chunks with throttling in between
pub const SINGLE_WRITER = 76;
/// Get the protection version number for this filesystem
pub const GETPROTECTIONLEVEL = 77;
/// Add detached code signatures (used by dyld for shared libs)
pub const FINDSIGS = 78;
/// Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
/// fsync + issue barrier to drive
pub const BARRIERFSYNC = 85;
/// Add signature from same file, return end offset in structure on success
pub const ADDFILESIGS_RETURN = 97;
/// Check if Library Validation allows this Mach-O file to be mapped into the calling process
pub const CHECK_LV = 98;
/// Deallocate a range of the file
pub const PUNCHHOLE = 99;
/// Trim an active file
pub const TRIM_ACTIVE_FILE = 100;
/// mark the dup with FD_CLOEXEC
pub const DUPFD_CLOEXEC = 67;
/// shared or read lock
pub const RDLCK = 1;
/// unlock
pub const UNLCK = 2;
/// exclusive or write lock
pub const WRLCK = 3;
},
.freebsd => struct {
/// Duplicate file descriptor.
pub const DUPFD = 0;
/// Get file descriptor flags.
pub const GETFD = 1;
/// Set file descriptor flags.
pub const SETFD = 2;
/// Get file status flags.
pub const GETFL = 3;
/// Set file status flags.
pub const SETFL = 4;
/// Get SIGIO/SIGURG proc/pgrrp.
pub const GETOWN = 5;
/// Set SIGIO/SIGURG proc/pgrrp.
pub const SETOWN = 6;
/// Get record locking information.
pub const GETLK = 11;
/// Set record locking information.
pub const SETLK = 12;
/// Set record locking information and wait if blocked.
pub const SETLKW = 13;
/// Debugging support for remote locks.
pub const SETLK_REMOTE = 14;
/// Read ahead.
pub const READAHEAD = 15;
/// DUPFD with FD_CLOEXEC set.
pub const DUPFD_CLOEXEC = 17;
/// DUP2FD with FD_CLOEXEC set.
pub const DUP2FD_CLOEXEC = 18;
pub const ADD_SEALS = 19;
pub const GET_SEALS = 20;
/// Return `kinfo_file` for a file descriptor.
pub const KINFO = 22;
// Seals (ADD_SEALS, GET_SEALS)
/// Prevent adding sealings.
pub const SEAL_SEAL = 0x0001;
/// May not shrink
pub const SEAL_SHRINK = 0x0002;
/// May not grow.
pub const SEAL_GROW = 0x0004;
/// May not write.
pub const SEAL_WRITE = 0x0008;
// Record locking flags (GETLK, SETLK, SETLKW).
/// Shared or read lock.
pub const RDLCK = 1;
/// Unlock.
pub const UNLCK = 2;
/// Exclusive or write lock.
pub const WRLCK = 3;
/// Purge locks for a given system ID.
pub const UNLCKSYS = 4;
/// Cancel an async lock request.
pub const CANCEL = 5;
pub const SETOWN_EX = 15;
pub const GETOWN_EX = 16;
pub const GETOWNER_UIDS = 17;
},
.illumos => struct {
/// Unlock a previously locked region
pub const ULOCK = 0;
/// Lock a region for exclusive use
pub const LOCK = 1;
/// Test and lock a region for exclusive use
pub const TLOCK = 2;
/// Test a region for other processes locks
pub const TEST = 3;
/// Duplicate fildes
pub const DUPFD = 0;
/// Get fildes flags
pub const GETFD = 1;
/// Set fildes flags
pub const SETFD = 2;
/// Get file flags
pub const GETFL = 3;
/// Get file flags including open-only flags
pub const GETXFL = 45;
/// Set file flags
pub const SETFL = 4;
/// Unused
pub const CHKFL = 8;
/// Duplicate fildes at third arg
pub const DUP2FD = 9;
/// Like DUP2FD with O_CLOEXEC set EINVAL is fildes matches arg1
pub const DUP2FD_CLOEXEC = 36;
/// Like DUPFD with O_CLOEXEC set
pub const DUPFD_CLOEXEC = 37;
/// Is the file desc. a stream ?
pub const ISSTREAM = 13;
/// Turn on private access to file
pub const PRIV = 15;
/// Turn off private access to file
pub const NPRIV = 16;
/// UFS quota call
pub const QUOTACTL = 17;
/// Get number of BLKSIZE blocks allocated
pub const BLOCKS = 18;
/// Get optimal I/O block size
pub const BLKSIZE = 19;
/// Get owner (socket emulation)
pub const GETOWN = 23;
/// Set owner (socket emulation)
pub const SETOWN = 24;
/// Object reuse revoke access to file desc.
pub const REVOKE = 25;
/// Does vp have NFS locks private to lock manager
pub const HASREMOTELOCKS = 26;
/// Set file lock
pub const SETLK = 6;
/// Set file lock and wait
pub const SETLKW = 7;
/// Allocate file space
pub const ALLOCSP = 10;
/// Free file space
pub const FREESP = 11;
/// Get file lock
pub const GETLK = 14;
/// Get file lock owned by file
pub const OFD_GETLK = 47;
/// Set file lock owned by file
pub const OFD_SETLK = 48;
/// Set file lock owned by file and wait
pub const OFD_SETLKW = 49;
/// Set a file share reservation
pub const SHARE = 40;
/// Remove a file share reservation
pub const UNSHARE = 41;
/// Create Poison FD
pub const BADFD = 46;
/// Read lock
pub const RDLCK = 1;
/// Write lock
pub const WRLCK = 2;
/// Remove lock(s)
pub const UNLCK = 3;
/// remove remote locks for a given system
pub const UNLKSYS = 4;
// f_access values
/// Read-only share access
pub const RDACC = 0x1;
/// Write-only share access
pub const WRACC = 0x2;
/// Read-Write share access
pub const RWACC = 0x3;
// f_deny values
/// Don't deny others access
pub const NODNY = 0x0;
/// Deny others read share access
pub const RDDNY = 0x1;
/// Deny others write share access
pub const WRDNY = 0x2;
/// Deny others read or write share access
pub const RWDNY = 0x3;
/// private flag: Deny delete share access
pub const RMDNY = 0x4;
},
.netbsd => struct {
pub const DUPFD = 0;
pub const GETFD = 1;
pub const SETFD = 2;
pub const GETFL = 3;
pub const SETFL = 4;
pub const GETOWN = 5;
pub const SETOWN = 6;
pub const GETLK = 7;
pub const SETLK = 8;
pub const SETLKW = 9;
pub const CLOSEM = 10;
pub const MAXFD = 11;
pub const DUPFD_CLOEXEC = 12;
pub const GETNOSIGPIPE = 13;
pub const SETNOSIGPIPE = 14;
pub const GETPATH = 15;
pub const RDLCK = 1;
pub const WRLCK = 3;
pub const UNLCK = 2;
},
.dragonfly => struct {
pub const ULOCK = 0;
pub const LOCK = 1;
pub const TLOCK = 2;
pub const TEST = 3;
pub const DUPFD = 0;
pub const GETFD = 1;
pub const RDLCK = 1;
pub const SETFD = 2;
pub const UNLCK = 2;
pub const WRLCK = 3;
pub const GETFL = 3;
pub const SETFL = 4;
pub const GETOWN = 5;
pub const SETOWN = 6;
pub const GETLK = 7;
pub const SETLK = 8;
pub const SETLKW = 9;
pub const DUP2FD = 10;
pub const DUPFD_CLOEXEC = 17;
pub const DUP2FD_CLOEXEC = 18;
pub const GETPATH = 19;
},
.haiku => struct {
pub const DUPFD = 0x0001;
pub const GETFD = 0x0002;
pub const SETFD = 0x0004;
pub const GETFL = 0x0008;
pub const SETFL = 0x0010;
pub const GETLK = 0x0020;
pub const SETLK = 0x0080;
pub const SETLKW = 0x0100;
pub const DUPFD_CLOEXEC = 0x0200;
pub const RDLCK = 0x0040;
pub const UNLCK = 0x0200;
pub const WRLCK = 0x0400;
},
.openbsd => struct {
pub const DUPFD = 0;
pub const GETFD = 1;
pub const SETFD = 2;
pub const GETFL = 3;
pub const SETFL = 4;
pub const GETOWN = 5;
pub const SETOWN = 6;
pub const GETLK = 7;
pub const SETLK = 8;
pub const SETLKW = 9;
pub const RDLCK = 1;
pub const UNLCK = 2;
pub const WRLCK = 3;
},
.serenity => struct {
// https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L15-L24
pub const DUPFD = 0;
pub const GETFD = 1;
pub const SETFD = 2;
pub const GETFL = 3;
pub const SETFL = 4;
pub const ISTTY = 5;
pub const GETLK = 6;
pub const SETLK = 7;
pub const SETLKW = 8;
pub const DUPFD_CLOEXEC = 9;
// https://github.com/SerenityOS/serenity/blob/2808b0376406a40e31293bb3bcb9170374e90506/Kernel/API/POSIX/fcntl.h#L45-L47
pub const RDLCK = 0;
pub const WRLCK = 1;
pub const UNLCK = 2;
},
else => void,
}