$ man 2 intro
Syscall reference
One card per kernel interface Rod has actually written up: when it landed, whether glibc bothered to wrap it, the flags worth knowing, the errno you'll hit at 2 a.m., and what the BSDs did instead (usually first, usually smaller). Every version number is lifted from the man page cited on the card. If you want the war story, each card links to the full Tip.
Not sure what the box in front of you has? Paste its uname -sr into the kernel check and it'll tell you which of these you can call and what you're missing. Scripts can pull the whole table from /syscalls.json.
42 of 42
| Other side of the fence | |||
|---|---|---|---|
| cachestat(2)Query page cache status (resident, dirty, writeback, evicted) for a byte range of an open file. | 6.5 | Filesystem | FreeBSD: no equivalent. mincore(3) is available with the same mmap-first requirement as Linux mincore(2). |
| capset(2)Raw syscall to set a thread's permitted, effective and inheritable capability sets. | 2.2 | Security | FreeBSD: no POSIX.1e-style process capability sets; Capsicum (cap_enter(2), cap_rights_limit(2)) restricts per-fd rights instead. OpenBSD: none; pledge(2). |
| clone3(2)Fork a child process using a struct-based API; write a pidfd atomically with CLONE_PIDFD. | 5.3 | Processes | FreeBSD: pdfork(2) (FreeBSD 9.0) writes a process descriptor on fork in a single call; pdkill(2), pdwait4(2), and EVFILT_PROCDESC in kqueue(2) complete the API. OpenBSD: none. |
| close_range(2)Close, or mark close-on-exec, every file descriptor in a range in one call. | 5.9 | File descriptors | FreeBSD: close_range(2) with CLOSE_RANGE_CLOEXEC (FreeBSD 12.2) and closefrom(2) (FreeBSD 8.0). OpenBSD: closefrom(2) (OpenBSD 3.5). |
| copy_file_range(2)Copy a range of bytes between two file descriptors entirely inside the kernel, with server-side offload on NFS 4.2 and reflink on btrfs. | 4.5 | I/O | FreeBSD: copy_file_range(2) (FreeBSD 13.0), identical interface; uses ZFS reflink when both fds are on the same dataset. |
| eventfd(2)Create a kernel-backed 64-bit counter fd for wakeups between threads or processes. | 2.6.22 | Events | FreeBSD: eventfd(2) (FreeBSD 13.0). OpenBSD: closest is EVFILT_USER in kqueue(2). |
| fanotify_init(2)Create an fanotify group: VFS-level file access events with live fds and blockable opens. | 2.6.37 | Events | FreeBSD and OpenBSD: no equivalent. kqueue(2) EVFILT_VNODE gives after-the-fact vnode notifications only, with no permission decisions. |
| flock(2)Apply or remove an advisory whole-file lock tied to an open file description. | 4.2BSD; Linux 2.0 | File descriptors | FreeBSD: flock(2) (appeared in 4.2BSD). OpenBSD: flock(2) (first appeared in 4.1cBSD per its man page). On the modern BSDs flock and fcntl locks interact; on Linux they don't (except over NFS/SMB). |
| fsopen(2)Open a filesystem context: step one of the fd-based mount API (fsconfig, fsmount, move_mount). | 5.2 | Filesystem | FreeBSD: nmount(2) takes structured name/value option iovecs (FreeBSD 5.0), but it's still a one-shot call. OpenBSD: none; plain mount(2). |
| futex(2)Fast userspace locking: wait on or wake threads sleeping on a 32-bit word in memory. | 2.6.0 | IPC | FreeBSD: _umtx_op(2) (UMTX_OP_WAIT_UINT / UMTX_OP_WAKE), the undocumented-in-spirit substrate under libthr. OpenBSD: futex(2), added in OpenBSD 6.2. |
| getrandom(2)Fill a buffer with random bytes from the kernel CSPRNG, without opening /dev/urandom. | 3.17 | Security | FreeBSD: getrandom(2) since FreeBSD 12.0, plus arc4random(3). OpenBSD: getentropy(2) since OpenBSD 5.6; arc4random(3) for bulk use. |
| io_uring_setup(2)Create an io_uring instance: shared submission/completion rings for async I/O. | 5.1 | I/O | FreeBSD: aio(4) (kernel option since FreeBSD 3.0, in all kernels since FreeBSD 11.0), with completions deliverable through kqueue(2) EVFILT_AIO. OpenBSD: none. |
| ioprio_set(2)Set a thread's I/O scheduling class and priority (ionice is the CLI wrapper). | 2.6.13 | I/O | FreeBSD and OpenBSD: no per-process I/O priority syscall. |
| jail(2)Create a FreeBSD jail and lock the current process into it (jail_set/jail_attach for more). | FreeBSD 4.0 | Sandboxing | FreeBSD · Linux: no single equivalent; namespaces via clone(2)/unshare(2)/setns(2) plus chroot/pivot_root, assembled by container runtimes. |
| keyctl(2)Manipulate the kernel key retention service: read, revoke, time out and link keys and keyrings. | 2.6.10 | Security | FreeBSD and OpenBSD: no kernel keyring equivalent. |
| landlock_create_ruleset(2)Create a Landlock ruleset fd, step one of unprivileged filesystem/network sandboxing. | 5.13 | Sandboxing | OpenBSD: unveil(2) (OpenBSD 6.4). FreeBSD: Capsicum capability mode via cap_enter(2). |
| madvise(2)Advise the kernel how a memory range will be used: free it, page it out, exclude it from dumps. | 4.4BSD | Memory | FreeBSD: madvise(2) (4.4BSD) with MADV_FREE and MADV_NOCORE; minherit(2) INHERIT_ZERO for wipe-on-fork. OpenBSD: madvise(2) (since OpenBSD 2.7). |
| memfd_create(2)Create an anonymous RAM-backed file with no path, optionally sealable. | 3.17 | Memory | FreeBSD: memfd_create(2) (FreeBSD 13.0), an SHM_ANON shared memory object that supports MFD_ALLOW_SEALING. OpenBSD: none. |
| memfd_secret(2)Create memory removed from the kernel's direct map, mapped only by fd holders. | 5.14 | Memory | none |
| mlock(2)Lock pages into RAM so they can't be swapped out; mlockall() does the whole address space. | POSIX.1-1996 (SVr4) | Memory | FreeBSD: mlock(2)/mlockall(2) (mlock since 4.4BSD); madvise(2) MADV_NOCORE for core-dump exclusion. OpenBSD: mlock(2)/mlockall(2) (4.4BSD). |
| openat2(2)Open a file with kernel-enforced path-resolution constraints (RESOLVE_* flags). | 5.6 | Filesystem | FreeBSD: O_RESOLVE_BENEATH flag to openat(2) (FreeBSD 13), which fails with ENOTCAPABLE on escape. OpenBSD: none; closest is unveil(2). |
| pidfd_getfd(2)Duplicate a file descriptor out of another process, addressed by its pidfd. | 5.6 | File descriptors | none; on FreeBSD and OpenBSD the closest is passing the descriptor with SCM_RIGHTS over a unix(4) socket, which needs the owner's cooperation. |
| pidfd_open(2)Get a file descriptor that refers to a process, immune to PID reuse. | 5.3 | Processes | FreeBSD: process descriptors created at fork time with pdfork(2), plus pdgetpid(2) and EVFILT_PROCDESC in kqueue(2) (FreeBSD 9.0). OpenBSD: none. |
| pidfd_send_signal(2)Send a signal to the process a pidfd refers to, without PID-reuse races. | 5.1 | Processes | FreeBSD: pdkill(2) on a process descriptor from pdfork(2) (FreeBSD 9.0). OpenBSD: none. |
| pkey_alloc / pkey_mprotect(2)Allocate a memory protection key and use it to gate access to a memory region via a per-thread register, without a syscall per permission switch. | 4.8 | Memory | FreeBSD: no equivalent in base as of 14.2. ARM: MTE (Memory Tagging Extension, ARMv8.5-A) provides a related but incompatible mechanism. OpenBSD: none. |
| pledge(2)Restrict the process to named groups of system operations; violations kill it with SIGABRT. | OpenBSD 5.9 | Sandboxing | OpenBSD · Linux: no single equivalent; combine seccomp(2) filters, Landlock (landlock_create_ruleset(2)) and prctl(PR_SET_NO_NEW_PRIVS). FreeBSD: Capsicum, cap_enter(2) and cap_rights_limit(2). |
| prctl(2)Per-process/thread control knobs: no_new_privs, dumpable, parent-death signal, VMA names and more. | 2.1.57 | Processes | FreeBSD: procctl(2) (FreeBSD 9.3), including PROC_PDEATHSIG_CTL (FreeBSD 11.2, modeled on PR_SET_PDEATHSIG) and PROC_NO_NEW_PRIVS_CTL. OpenBSD: none; pledge(2) covers the sandboxing side. |
| process_madvise(2)madvise() for another process's address space, addressed by pidfd and an iovec of ranges. | 5.10 | Memory | FreeBSD and OpenBSD: none; madvise(2) only works on the caller's own address space. |
| rseq(2)Register a per-thread struct that the kernel keeps updated with the current CPU ID, enabling lock-free per-CPU data updates via restartable critical sections. | 4.18 | Scheduling | No equivalent on FreeBSD, OpenBSD, or NetBSD. Per-CPU userspace data structures at this layer are Linux-specific. Portable alternative: sched_getcpu(3) on Linux, thread-local storage everywhere else. |
| sched_setaffinity(2)Set the set of CPUs a thread may run on (taskset is the CLI wrapper). | 2.5.8 | Processes | FreeBSD: cpuset_setaffinity(2) (FreeBSD 7.1) and the cpuset(1) tool. OpenBSD: none. |
| SCM_RIGHTSPass open file descriptors to another process over a UNIX domain socket. | unknown | IPC | FreeBSD and OpenBSD: the same SCM_RIGHTS control message on unix(4) sockets. |
| seccomp(2)Set the thread's seccomp state: strict mode or a BPF filter on every syscall. | 3.17 | Sandboxing | OpenBSD: pledge(2) (OpenBSD 5.9), coarse promise strings rather than BPF. FreeBSD: Capsicum capability mode via cap_enter(2). |
| setns(2)Move the calling thread into an existing namespace, given an fd for it (or a pidfd). | 3.0 | Processes | FreeBSD: no namespaces; jail_attach(2) (FreeBSD 5.1) is the closest thing to joining an existing isolated environment. OpenBSD: none. |
| signalfd(2)Accept signals by reading a file descriptor instead of running a handler. | 2.6.22 | Events | FreeBSD and OpenBSD: EVFILT_SIGNAL in kqueue(2). |
| SO_REUSEPORTLet multiple sockets bind one address:port; the kernel spreads traffic across them. | 3.9 | I/O | FreeBSD: SO_REUSEPORT_LB load-balances TCP and UDP across up to 256 sockets per group. OpenBSD: SO_REUSEPORT allows duplicate bindings, documented for multicast/broadcast reception rather than load balancing. |
| splice(2)Move data between a pipe and another fd without copying through userspace. | 2.6.17 | I/O | FreeBSD: sendfile(2) for file-to-socket (FreeBSD 3.0), and the SO_SPLICE socket option for socket-to-socket (FreeBSD 14.3). OpenBSD: SO_SPLICE via setsockopt(2) (OpenBSD 4.9). |
| statx(2)Extended stat: request specific fields, get birth time, inode attribute flags and mount ID. | 4.11 | Filesystem | FreeBSD: no statx; stat(2) already carries st_birthtim (st_birthtime). OpenBSD: no statx; plain stat(2)/fstatat(2). |
| tee(2)Duplicate data from one pipe into another without consuming it from the source. | 2.6.17 | I/O | none |
| timerfd_create(2)Create a timer that reports expirations through a readable file descriptor. | 2.6.25 | Events | FreeBSD: native timerfd(2) (FreeBSD 14.0), or EVFILT_TIMER in kqueue(2). OpenBSD: EVFILT_TIMER in kqueue(2). |
| unshare(2)Create new namespaces and move the calling process into them without forking. | 2.6.16 | Processes | FreeBSD: jail(2) (FreeBSD 4.0) wraps filesystem, network, and PID visibility in one coarser-grained call. OpenBSD: none; isolation is pledge(2), unveil(2), and chroot(2). |
| unveil(2)Hide the whole filesystem except the paths you name, with per-path r/w/x/c permissions. | OpenBSD 6.4 | Sandboxing | OpenBSD · Linux: Landlock (landlock_create_ruleset(2)) is the closest path-based restriction, though denied paths aren't made invisible. FreeBSD: Capsicum cap_enter(2) with pre-opened directory fds. |
| userfaultfd(2)Create an fd that lets userspace resolve page faults on registered memory ranges. | 4.3 | Memory | none |
"Since" is the Linux kernel release unless the row says otherwise. For the full arguments behind each card, see Rod's Tips From the Console.