Expand description
bun_sys — syscall wrappers (port of src/sys/sys.zig).
Re-exports§
pub use fd::ErrorCase;pub use fd::FdExt;pub use fd::FdOptionalExt;pub use fd::FdT;pub use fd::HashMapContext;pub use fd::MakeLibUvOwnedError;pub use fd::MovableIfWindowsFd;pub use fd::RawFd;pub use fd::UvFile;pub use signal_code::SignalCode;pub use tmp::Tmpfile;pub use file::File;pub use file::ReadToEndResult;pub use PlatformIoVec as PlatformIOVec;pub use PlatformIoVecConst as PlatformIOVecConst;pub use posix_stat::PosixStat;pub use posix_stat::stat_atime;pub use posix_stat::stat_birthtime;pub use posix_stat::stat_ctime;pub use posix_stat::stat_mtime;pub use make_path as MakePath;pub use dir::*;
Modules§
- O
- RTLD
std.c.RTLDflags fordlopen.- S
statmode-flag constants and predicates (Zig:std.posix.S). Values are POSIX-standard octal; identical across linux/darwin/freebsd. Constants are typedu32(==bun_core::Mode); on Darwin/FreeBSD the kernelmode_tis u16 so the upper 16 bits are always zero — every call site already casts (as i32/as u32/as _) so the wider type is harmless, and on Linuxmode_t==u32so it’s a drop-in re-export.statmode-flag constants and predicates (Zig:std.posix.S).- UV_E
- c
- copy_
file - coreutils_
error_ map - darwin
- dir
bun.sys.Dir— directory handle + helpers. Port of theDirhalf ofsrc/sys/sys.zig(Zig:bun.sys.Dir≈std.fs.Dir).- dir_
iterator - elf
std.elfconstants (just whatbun_exe_format/bun_crashneed).- fd
- file
bun.sys.File— high-level file handle. Port ofsrc/sys/File.zig.- freebsd
- fs
- High-level filesystem convenience functions (read_to_string, write, metadata, OpenOptions). High-level filesystem convenience functions built on top of bun_sys primitives.
- libuv_
error_ map - linux
- macho
- make_
path std.fs.Dir.makeOpenPathreachable as a module (Zig callers dobun.makePath/bun.makeOpenPath).- net
- posix
- posix_
stat bun.sys.PosixStat— uv-shaped stat struct (src/sys/PosixStat.zig). Re-exported here so dependents (node_fs.rs,Stat.rs) can spellbun_sys::PosixStatexactly as the Zig source spellsbun.sys.PosixStat.- signal_
code - sys_uv
- Zig:
pub const sys_uv = if (Environment.isWindows) @import("./sys_uv.zig") else sys;On non-Windows,sys_uvis just an alias for the regular syscall surface so callers (e.g.pack_command) can writebun_sys::sys_uv::fstat(fd)portably. - syscall
- time
std.timeshim — re-exported frombun_coreso callers that wrotebun_sys::time::timestamp()(matching Zig’sstd.timeimport via bun.sys) resolve without an extra dep.bun.Timer/std.time.Timer— minimal monotonic stopwatch. Mirrors Zig’sstd.time.Timer.{start,read}so callers ported verbatim (e.g.Lockfile::clean_with_logger,LifecycleScriptSubprocess) compile against the tier-0 surface without pulling inbun_perf.- tmp
- walker_
skippable
Macros§
- dlsym_
with_ handle bun.c.dlsymWithHandle— once-cached typed lookup. The Zig version monomorphises per(Type, name, handle_getter); in Rust this is a macro.- syslog
bun.sys.syslog— debug-scoped log underSYS(Zig:Output.scoped(.SYS)). PORT NOTE:bun_core::scoped_log!only accepts a bare$scope:ident, so we re-expand its body verbatim here with the qualified$crate::fd::SYSpath and::bun_core::helpers — keeping the[sys]tag prefix, trailing-\nappend, andpretty_fmt!ANSI rewrite (output.zig:893-933) thatScopedLogger::log()does not add on its own.
Structs§
- Close
OnDrop - RAII guard that closes a raw
Fdon drop. Most code should preferFile/Dir, which are owning RAII handles already; reach for this only when working with a bareFdin a context where a typed wrapper would be misleading (e.g. an fd that is sometimes a file, sometimes a directory, sometimes a pipe). - DynLib
- Error
- Fd
- FdOptional
- Niche-packed
Option<Fd>(enum(backing_int) { none = @bitCast(invalid), _ }). Use instead of encoding the invalid value directly. - File
Reader std::io::Readadapter forFd(used byFile::reader). Port ofFile.Reader = std.Io.GenericReader(File, anyerror, stdIoRead).- File
Writer std::io::Writeadapter forFd(used byFile::writer/buffered_writer). Port ofFile.Writer = std.Io.GenericWriter(File, anyerror, stdIoWrite).- Open
Flags std.fs.File.OpenFlags— convenience flagset foropen_file*helpers.- Platform
IoVec Const - Renameat2
Flags - Flags for
renameat2. Port ofbun.sys.RenameAt2Flags(sys.zig:2472). On Linux maps toRENAME_EXCHANGE/RENAME_NOREPLACE; on macOS maps toRENAME_SWAP/RENAME_EXCL/RENAME_NOFOLLOW_ANY. - Renameat
Concurrently Options - sys.zig:2461 — option struct for
renameat_concurrently. Zig used acomptimeanonymous struct param{ move_fallback: bool = false }; Rust surfaces it as a runtime options struct so callers can build it inline. - System
Error - Port of
SystemError(src/jsc/SystemError.zig) — the JS-facing rich error (path/dest/syscall asbun.String). The data side has no JSC dependency: the*JSGlobalObject-taking conversion methods (toErrorInstanceetc.) live inbun_jscas inherent extensions.#[repr(C)]and field order match the Zigextern structexactly so the C++SystemError__*externs (BunObject.cpp) read the same layout. - Tag
- Time
Like bun.jsc.Node.TimeLike—timespecshape, decoupled from JSC (T6). sys.zig takes this for futimens/utimens; the JSC binding constructs it from JS Date/number. T1 owns the data shape.- Timespec
bun.timespec— re-exported frombun_coresoPosixStat.rscan spellcrate::Timespec(matching the Zigbun.timespecnamespacing).- Windows
Symlink Options - Port of
WindowsSymlinkOptions(sys.zig:2653) — Windows-only flag struct plus a process-global “symlink creation has failed once” sticky bit. The flag is checked by the install linker to decide whether to fall back to junctions; on POSIX the flag is harmless dead state. Only the sticky bit is needed cross-platform (PackageManager::initsets it whenBUN_FEATURE_FLAG_FORCE_WINDOWS_JUNCTIONSis on). - Write
File Args - Args struct (Zig: anon-struct init at call sites).
Enums§
- Entry
Kind - Exists
AtType - sys.zig:3636
ExistsAtType. - FdKind
- Zig
Kind— tag in bit 63 on Windows,enum(u0)(zero-width) on POSIX. - File
Kind - Memfd
Flags bun.sys.MemfdFlags(Zig:enum(u32)).- Path
OrFile Descriptor - Target — path (relative to
dirfd) or an already-open fd. - Size
Hint bun.sys.File.SizeHint— pre-reserve hint forread_to_end_with_array_list. Mirrors Zig’senum { probably_small, unknown_size }(File.zig:298).- Stdio
- System
Errno - Write
File Data - Data payload for
write_file_with_path_buffer. - Write
File Encoding - Encoding tag (only
Bufferis honoured at T1).
Constants§
- MAX_
COUNT - Max single read/write count (sys.zig:1832): Linux caps at 0x7ffff000; Darwin/BSD use signed 32-bit byte counts.
- MSG_
DONTWAIT - SEND_
FLAGS_ NONBLOCK - STATX_
MASK_ FOR_ STATS STATX_*request mask covering every fieldnode:fs Statsconsumes (sys.zig:614StatxField— all variants OR’d, the only mask the Zig callers ever pass).- UTIME_
NOW - UTIME_
OMIT
Statics§
- SUPPORTS_
STATX_ ON_ LINUX - WINDOWS_
SYMLINK_ HAS_ FAILED - Zig:
pub var has_failed_to_create_symlink = false;(sys.zig:2669).
Traits§
- AsFd
- Anything that can hand out an
Fdwithout giving up ownership: a rawFd, or a reference to an owningFile/Dir. Mirrorsstd::os::fd::AsFd. Implemented for references only (not ownedFile/Dir) so syscall wrappers can’t accidentally consume and drop-close an owned handle. - GetErrno
- Zig’s
getErrno(rc: anytype)switches on@TypeOf(rc)to pick the errno extraction strategy. Rust has no type-switch, so we model it as a trait with per-type impls — call asrc.get_errno()orget_errno(rc). - Maybe
Ext - Zig
Maybe(T)static helpers —.success(),.errno(e, tag),.errnoSys(rc, tag). Ported as a trait overResult<T, Error>so call sites can keep writingbun_sys::Result::<()>::errno_sys(rc, tag)exactly as the Zig spells it. Windows-only paths inwindows/mod.rslean on these for the NTSTATUS →Emapping.
Functions§
- Bun__
errno Name - Exported for
headers-handwritten.hBun__errnoName. Returns a NUL-terminated upper-case errno name (e.g."ENOENT") or null for an unrecognised code. The pointer is thread-local and valid until the next call on the same thread; both C++ callers consume it immediately. - Bun__
unlink ⚠ - Small “fire and forget” wrapper around unlink for C usage that handles
EINTR, Windows path conversion, etc. Zig:
export fn Bun__unlink(ptr, len). - access
- can_
use_ memfd bun.sys.canUseMemfd()— false on non-Linux; on Linux, false oncememfd_createhas returned ENOSYS/EPERM/EACCES.- chdir
- chmod
- chown
- clonefile
clonefile— macOS-only CoW copy. On non-Darwin returns ENOTSUP so callers can fall back tocopy_file.- clonefileat
clonefileat— macOS-only CoW copy relative to directory fds. On non-Darwin returns ENOTSUP so callers can fall back to a manual copy.- close
- copy_
file bun.sys.copyFile— fd→fd full transfer using the best available kernel fast path (ioctl_ficlone / copy_file_range / sendfile / read-write loop).- copy_
file_ z_ slow_ with_ handle - sys.zig:4305 —
copyFileZSlowWithHandle(POSIX read/write fallback arm). - cwd
std.fs.cwd()— Zig callers dobun_sys::cwd()for the process cwdDir.- delete_
tree_ absolute std.fs.deleteTreeAbsolute— best-effort recursive delete of an absolute path. Routes throughDir::delete_treeon the parent directory.- directory_
exists_ at - sys.zig:3533 —
directoryExistsAt(dir, sub). ENOENT →Ok(false). - disable_
linger - sys.zig:3835
disableLinger— setSO_LINGER {1,0}so close sends RST. - dlopen
- sys.zig:4557 —
dlopen(filename, flags). Windows →LoadLibraryA. - dlsym_
impl - sys.zig:4565 —
dlsym(handle, name). - dup
- sys.zig:3897 —
fcntl(F_DUPFD_CLOEXEC, 0)so the dup’d fd doesn’t leak to children. NOTdup(2)(which lacks CLOEXEC). - dup2
- dup_
with_ flags - sys.zig:3873 —
fcntl(F_DUPFD_CLOEXEC)(POSIX) /DuplicateHandle(Win)._flagsis ignored (Zig signature parity). - e_
from_ negated - Zig:
SystemError.getErrno—@enumFromInt(this.errno * -1). - environ
std.os.environ— borrowed slice ofKEY=VALUE\0C strings. SAFETY note: the returned slice borrows the libcenvironglobal; do not mutate the environment concurrently.- environ_
ptr std.os.environ.ptr— raw NULL-terminated**c_charfor FFI envp args (e.g.posix_spawn). Unlikeenviron()this returns the raw libc global pointer (already NULL-terminated) rather than a length-bounded borrowed slice, so it is suitable to pass directly asenvp.- errno
std.c._errno()— pointer to thread-local errno. Preferlast_errno()for the value; this exists for callers that match the Zig*_errno()API shape (unsafe { *bun_sys::errno() }).- errno_
to_ zig_ err - Zig:
bun.errnoToZigErr(errno)(bun.zig) — re-exported here so callers that already depend onbun_sys(e.g.bun_installWindows paths) can writebun_sys::errno_to_zig_err(..)without also importingbun_core. - eventfd
eventfd(initval, flags)— kernel notification fd. Linux native (Android included since API 8); FreeBSD 13+ gained a Linux-compatibleeventfd(2)via thelibcshim.- exists
- sys.zig:3482 —
bun.sys.exists. Non-NUL-terminated convenience overexists_z: copies into a stackPathBuffer, NUL-terminates, thenaccess(path, F_OK)(POSIX) /GetFileAttributesW(Windows). - exists_
at - exists_
at_ type - sys.zig:3640 —
fstatatthenS_ISDIR. - exists_
os_ path - sys.zig:3447 —
access(path, F_OK) == 0.file_onlyignored on POSIX. - exists_
z - sys.zig:1748 — Windows uses
GetFileAttributesW; posix is plainaccess. - faccessat
- sys.zig:3504 — never returns
.err; any non-zero rc →Ok(false). - fchdir
- fchmod
- fchmodat
- fchown
- fchownat
- fcntl
- fdatasync
- fetch_
cache_ directory_ path bun.fetchCacheDirectoryPath— resolve$BUN_INSTALL_CACHE_DIR/$XDG_CACHE_HOME/.bun/install/cache/$HOME/.bun/install/cache. PORT NOTE: full env-override chain lives inbun_install; this is the fallback so the symbol resolves at T1. Returns an owned path (caller frees).- force_
link - Force the linker to include all
#[no_mangle]dispatch symbols. Called from dependent crate test harnesses to prevent link GC. - fstat
- fstatat
- fstatx
- fsync
- ftruncate
- futimens
- get_
errno - get_
fcntl_ flags - sys.zig:3599 —
fcntl(fd, F_GETFL, 0). - get_
fd_ path - sys.zig:2940 — fd → absolute path. Linux: readlink
/proc/self/fd/N; macOS:fcntl(F_GETPATH); Windows:GetFinalPathNameByHandle. - get_
fd_ path_ w - get_
fd_ path_ z - bun.zig:1303 —
bun.getFdPathZ(fd, buf). Wrapsget_fd_paththen NUL-terminates in-place so callers receive a&ZStr. - get_
file_ size - sys.zig:4152 —
fstatthen@max(st_size, 0)(clamp negative). - getcwd
- getcwd_
alloc bun.getcwdAlloc(allocator)(bun.zig:1256) — read cwd into a stackPathBuffer, then duplicate into a heap-owned NUL-terminatedZBox.- getcwd_
z bun.sys.getcwdZ(buf)(sys.zig:349) —getcwdreturning a NUL-terminated borrow intobuf. POSIXgetcwd(3)already NUL-terminates; on Windows the libuv path does too.- is_
executable_ file_ path - sys.zig:3767 — calls extern C
is_executable_file(c-bindings.cpp:72-89). We FFI to the same symbol so the behaviour is identical. - is_
regular_ file - Zig:
bun.isRegularFile(mode)(bun.zig) —S.ISREG(@intCast(mode)). - isatty
- iterate_
dir bun.iterateDir(dir)— convenience wrapper arounddir_iterator::iterate.- kind_
from_ mode - last_
errno - Read thread-local libc errno (set by the failing syscall).
Zig:
std.c._errno().*(sys.zig). On Windows this reads the CRT’s thread-local_errno(); libuv-backed paths that need Win32GetLastError()go throughbun_sys::windows::get_last_errnoinstead. - lchmod
lchmodis BSD/Darwin-only; Linux:fchmodat(.., AT_SYMLINK_NOFOLLOW)(sys.zig:434).- lchown
- link
- linkat
- linkat_
tmpfile linkatTmpfile(sys.zig:3973): materialize anO_TMPFILEfd. Fast path useslinkat(tmpfd, "", dirfd, name, AT_EMPTY_PATH)(requires CAP_DAC_READ_SEARCH); falls back to/proc/self/fd/N+ AT_SYMLINK_FOLLOW. Linux-only; on other unix this errors with EOPNOTSUPP (Zig same).- lseek
- lstat
- lstatat
- lstatx
- lutimens
- make_
path_ w - bun.zig:2319 — Windows-only
makePathover UTF-16. On POSIX, transcodes to UTF-8 and delegates tomkdir_recursive_at. - memfd_
create bun.sys.memfd_create(name, flags)— Linux only. Retries on EINTR; on EINVAL retries once with the pre-6.3 flag set (dropsMFD_EXEC/MFD_NOEXEC_SEAL); on ENOSYS/EPERM/EACCES latchescan_use_memfdto false.- mkdir
- mkdir_
recursive bun.mkdirRecursive—make_pathcwd-relative, taking a slice.- mkdir_
recursive_ at bun.makePath—mkdiratwalking up parents on ENOENT, likemkdir -p. Port of std.fs.Dir.makePath (Zig std/fs/Dir.zig).- mkdir_
recursive_ at_ mode mkdir_recursive_atwith an explicitmodefor created directories (matchesbun.api.node.fs.NodeFS.mkdirRecursive’smodearg).- mkdirat
- mkdirat_
z mkdiratZ—mkdiratwith already-NUL-terminated path. Same asmkdirat.- mmap
- mmap_
file bun.sys.mmapFile— openpathRDWR, fstat for size, mmap [offset, offset+len). Returns a process-lifetime mmap slice; caller is responsible formunmap. Mirrors ZigmmapFile(sys.zig).- move_
file_ z - sys.zig:4246 —
moveFileZ. Tries the rename first (no source open on the hot path); on EISDIR removes the dest dir and retries; on EXDEV falls back to the slow open+copy path. Only opens the source inside the EXDEV branch. - move_
file_ z_ slow - sys.zig:4291 —
moveFileZSlow: open source, unlink, copy to dest. - move_
file_ z_ slow_ maybe - sys.zig:4296 —
moveFileZSlowMaybe. Thin wrapper kept for source parity with Zig callers (renameatConcurrentlyfalls back through here). - move_
file_ z_ with_ handle renameat; on EISDIR removes the dest dir and retries; on EXDEV falls back to copy-then-unlink. Port ofbun.sys.moveFileZWithHandle.- munmap
- open
- open_a
openA— likeopenbut takes a non-NUL-terminated slice.- open_
dir_ absolute - bun.zig:890
openDirAbsolute. PORT NOTE: returnsFd, notstd.fs.Dir. - open_
dir_ absolute_ not_ for_ deleting_ or_ renaming - bun.zig:899 — Windows variant skips
DELETEaccess; on POSIX identical. - open_
dir_ at - bun.zig:879
openDirA— open a path as an iterable directory fd. - open_
dir_ for_ iteration - bun.zig:883 —
openDirForIteration(dir, sub). - open_
dir_ for_ iteration_ os_ path bun.openDirForIterationOSPath—openat(dir, path, O_DIRECTORY|O_RDONLY)on POSIX;CreateFileWwithFILE_FLAG_BACKUP_SEMANTICSon Windows.- open_
file std.fs.cwd().openFile— non-NUL-terminated convenience.- open_
file_ absolute_ z std.fs.openFileAbsoluteZ— open an absolute, NUL-terminated path.- open_
file_ read_ only openFileReadOnly—open(path, O_RDONLY|O_CLOEXEC).- openat
- openat2_
beneath - openat_
a openatA— likeopenatbut takes a non-NUL-terminated slice.- openat_
os_ path - sys.zig:1705
openatOSPath—openattaking a platform-native path (OSPathSliceZ=ZStron POSIX,WStron Windows). On POSIX this is identical toopenat; on Windows it routes through the NT openat path. - openat_
read_ only openatReadOnly—openat(dir, path, O_RDONLY|O_CLOEXEC).- page_
size - pidfd_
open pidfd_open(2)— Linux ≥ 5.3. Returns a pollable fd referring topid. Callers fall back to the waiter-thread onENOSYS/EPERM/EACCES.- pipe
- sys.zig:3839 — plain
pipe(&fds), NO CLOEXEC. Callers that want CLOEXEC set it themselves (matches Zig). - platform_
iovec_ const_ create - platform_
iovec_ create - pread
- preadv
bun.sys.preadv— scatter-read atposition. macOS usespreadv$NOCANCELwith no EINTR retry (sys.zig:2016-2048).- preallocate_
file - sys.zig:4536 —
fallocate(fd, 0, offset, len)on Linux, result discarded; no-op elsewhere. - pwrite
- pwritev
bun.sys.pwritev— gather-write atoffset. Returns bytes written (may be less than the sum ofvecslengths on a short write).- read
- read_
nonblocking - sys.zig:4046 — Linux:
preadv2(.., RWF_NOWAIT); else plainread. - readlink
- readlinkat
- readv
bun.sys.readv— scatter-read. macOS usesreadv$NOCANCELwith no EINTR retry (sys.zig:1982-2014); other POSIX retries on EINTR.- realpath
realpath—realpath$DARWIN_EXTSNon macOS for proper symlink resolution (Zig:bun.c.realpath). Writes intobufand returns the written slice.- recv
- recv_
non_ block - rename
- renameat
- renameat2
renameat2(2)(Linux) /renameatx_np(macOS). FreeBSD and any other unix without an atomic-exchange rename getENOSYSwhen flags are set, matchingbun.sys.renameat2(sys.zig:2503).- renameat_
concurrently - sys.zig:2461 —
renameatConcurrently. Tries an atomic NOREPLACE rename, then EXCHANGE, then a racy delete-tree + rename. Withmove_fallbackset, an EXDEV result falls through to a slow open/copy. - renameat_
concurrently_ a &[u8]-taking convenience overrenameat_concurrently— Z-terminates both paths into stack buffers (Zig signature is[:0]const u8).- renameat_
concurrently_ without_ fallback - sys.zig:2480 —
renameatConcurrentlyWithoutFallback. - renameat_
z renameatZalias (bun_install reaches for it as the NUL-terminated form).- rmdir
- Port of
sys.zig:2876 rmdir—rmdirat(FD.cwd(), to). Exposed on all platforms (POSIXunlinkat(.., AT_REMOVEDIR); WindowsDeleteFileBun). - self_
process_ memory_ usage bun.sys.selfProcessMemoryUsage()— returns the resident set size of the current process in bytes, orNoneon failure. Thin wrapper around the C++getRSSshim (lives insrc/jsc/bindings/memory.cpp).- send
- send_
non_ block - sys.zig:2205 —
MSG_DONTWAIT | MSG_NOSIGNALso a broken-pipe write returns EPIPE instead of raising SIGPIPE. - sendfile
- sys.zig:504 —
sendfile(src, dest, len). Clampslen(avoid EINVAL on - set_
close_ on_ exec - sys.zig:3054
setCloseOnExec—fcntl(F_GETFD)then OR inFD_CLOEXEC. - set_
file_ offset - sys.zig:3788 —
lseek(fd, offset, SEEK_SET); result discarded. - set_
nonblocking - sys.zig:3614.
- socketpair
- sys.zig:3103
socketpair—socketpairImpl(.., for_shell = false). Linux usesSOCK_CLOEXEC|SOCK_NONBLOCKtype flags; non-Linux sets CLOEXEC + nonblock + (Darwin)SO_NOSIGPIPEper-fd, closing both on any post-step error. - socketpair_
for_ shell - sys.zig:3125
socketpairForShell—socketpairImpl(.., for_shell = true). On macOS this skipsSO_NOSIGPIPE(so the child’s writes get SIGPIPE when the read end closes — required foryes | head-style pipelines) and bumpsSO_RCVBUF/SO_SNDBUFto 128 KB instead. On Linux/other POSIX it is identical tosocketpair. - stat
- statfs
bun.sys.statfs— query filesystem stats forpath. Retries on EINTR.- statx
- stderr_
writer bun.Output.stderrWriter()—std::io::Writeover stderr fd. Used by callers that want a borrowed writer without going throughbun_core::Output.- symlink
- symlink_
running_ executable - sys.zig:2615
symlinkRunningExecutable— same assymlink, except it handles ETXTBSY/EBUSY by unlinking the destination and retrying once. - symlinkat
- sys_
preadv2 ⚠ - Linux
preadv2(2)— real implementation (was a -1 stub in bao_native_stubs). - sys_
pwritev2 ⚠ - Linux
pwritev2(2)— real implementation (was undeclared; only declared via extern). - to_
posix_ path std.posix.toPosixPath— copypathinto a NUL-terminated buffer. ReturnsNameTooLongifpathcontains an interior NUL.- umask
- unlink
- unlinkat
- sys.zig:2912
unlinkat— 2-arg form (flags = 0). Zig’s surface is 2-arg; the 3-arg variant isunlinkatWithFlags. - unlinkat_
with_ flags - sys.zig:2884
unlinkatWithFlags— explicitflags(e.g.AT_REMOVEDIR). Zig builds the error viaerrnoSysFP(.., .unlink, dirfd, to)so the surfacedSystemErrorcarries BOTH the dirfd and the path. - update_
nonblocking - sys.zig:3618 — GETFL → toggle O_NONBLOCK → SETFL (only if changed).
- utimens
- write
- write_
file_ with_ path_ buffer NodeFS::writeFileWithPathBuffer— syncopenat(CREAT|TRUNC)+ write_all.path_bufis a scratch buffer for NUL-terminating the relative path.- write_
nonblocking - sys.zig:4099 — Linux:
pwritev2(.., RWF_NOWAIT); else plainwrite. - writev
bun.sys.writev— gather-write. macOS useswritev$NOCANCELwith no EINTR retry (sys.zig:1923-1934); other POSIX retries on EINTR.
Type Aliases§
- E
- Kernel errno enum. Zig’s
std.posix.Eand Bun’sSystemErrnoshare the exact same discriminant space on each POSIX target; alias rather than duplicate. Resolves to the per-OSSystemErrnovia the glob re-export above. TODO(port): Zig’sEuses unprefixed variant names (PERM,NOENT);SystemErrnousesEPERM,ENOENT. Callers matching onE::PERMmust migrate toE::EPERM(or this becomes a distinct enum). - EnvMap
std.process.EnvMap— ownedKEY → VALUEmap of environment variables. Minimal real def (no Zig hash-map semantics needed; Rust callers iterate).- Errno
std.posix.E— un-prefixed errno enum (.SUCCESS,.AGAIN, …). PORT NOTE: aliased tobun_errno::E(=SystemErrno); variants currently keep theEprefix (EAGAINnotAGAIN). Unprefixed associated consts live onSystemErrnodirectly (errno crate); callers comparing againstErrno::AGAIN/Errno::EXISTrely on those.- Error
Int bun.sys.Error.Int— backing integer forerrno.- Fcntl
Int - FdNative
std.posix.fd_t—c_inton POSIX,HANDLE(*anyopaque) on Windows.- Maybe
Maybe(T)— Zig’sunion(enum) { result: T, err: Error }. In Rust this is justResult<T, Error>; keep the alias so ported call sites type-check.- Mode
- Platform
IoVec - Rename
Options - Alias:
bun_installcall sites spell thisRenameOptions. - Result
- SocketT
std.posix.socket_t—c_inton POSIX,SOCKET(usize) on Windows.- Stat
- StatFS