Expand description
Host OS primitives: the only crate-level home for most libc I/O and memory syscalls used by the translator.
Call sites should prefer these wrappers so unsafe does not scatter across
BSD handlers. Each function documents the ownership / validity contract.
Structs§
- HostDir
- Opaque host directory stream (
DIR*). - Mapped
File - Read-only file-backed mapping of an entire file (lazy page faults).
Constants§
- MAP_
FIXED_ NOREPLACE - Linux
MAP_FIXED_NOREPLACE(do not clobber existing maps).
Functions§
- accept
accept(fd)— peer address discarded (curl client path rarely needs it).- accept_
addr acceptwith peer sockaddr written intoaddr_out(truncated to buffer len).- bind
bind(fd, sockaddr_bytes).- clear_
nonblock - Clear host
O_NONBLOCK(best-effort). Used for nested-helper stdio pipes. - clock_
gettime - Host
clock_gettime. - close_
fd - Close a host file descriptor. Errors are ignored (best-effort cleanup).
- connect
connect(fd, sockaddr_bytes).- dup2_fd
dup2(old, new)on the host. ReturnsneworNoneon failure.- dup_fd
- Duplicate a host fd. Returns the new fd or
Noneon failure. - execve_
host ⚠ - Host
execvewith owned C strings (never returns on success). - faccessat_
ok faccessat(dirfd, path, F_OK, 0)— existence check without full path build.- fchmod_
fd fchmod(fd, mode)— needed so guestldcan mark products executable.- fcntl_
get fcntlwith no extra arg (F_GETFD/F_GETFL).- fcntl_
set fcntlwith one integer arg (F_SETFD/F_SETFL/F_DUPFD).- fd_
is_ fifo truewhenfdis a FIFO/pipe (S_IFIFO).- fixed_
map_ flag - Preferred fixed-map flag for this host.
- fork_
process - Host
fork. ReturnsOk(pid)where pid is 0 in the child, orErr(errno). - fstat_
fd fstatinto a hoststatbuffer.- fstatat
fstatat(dirfd, path, …)— used by B1 bottle-relativestat/lstat.- fsync_
fd fsync(fd).- ftruncate_
fd ftruncate(fd, length).- getpeername
getpeername(fd, addr_out).- getsockname
getsockname(fd, addr_out).- getsockopt
getsockopt— writes intovalue, returns updated length.- gettimeofday
- Host
gettimeofday(timezone ignored). - link_
path link(existing, newpath)hard link.- listen
listen(fd, backlog).- lseek_
fd lseekon a host fd.- mkdirat
mkdirat(dirfd, path, mode)— returnsOk(())on success orEEXIST.- mmap
- Anonymous or file-backed
mmap. Returns host base orNoneon failure. - mprotect
mprotecton a host mapping range.- msync
msyncon a host mapping range.- munmap
munmapa mapping previously returned bymmap.- open_
directory - Open a directory as
O_RDONLY|O_DIRECTORY|O_CLOEXEC(bottle root dirfd, B1). - open_
path open(path, flags, mode)— prefers libc overstd::fs::OpenOptionsso directories open withO_RDONLY(archive walks) and we avoid extra syscalls.- openat
openat(dirfd, path, flags, mode).- page_
size - Host page size in bytes, or
Noneifsysconffails. - phys_
mem_ bytes - Best-effort host RAM size in bytes.
- phys_
pages - Physical page count from
sysconf(_SC_PHYS_PAGES), when available. - pipe_
fds pipe(2)— returns(read_fd, write_fd)orNoneon failure.- poll
poll(fds, timeout_ms)— empty slice sleeps / checks timeout only.- poll_
fd_ io - Block until
fdis readable or writable (TLS may need both). - poll_
fd_ readable - Block until
fdis readable, hung-up, or errored.timeout_msas inpoll(2)(-1= forever). Returnstrueif any interesting revent. - poll_
fd_ writable - Block until
fdis writable, hung-up, or errored. - posix_
spawn_ ⚠host - Host
posix_spawnwithout forking this process’s address space. - ptr_
addr_ u64 - Pointer address as
u64(identity guest/host model helpers). - read_fd
- Read bytes from a host fd (
read(2)). - readlink_
path readlink(path)intobuf(no trailing NUL). Returns bytes written or host errno.- recvfrom
recvfrom/recv— optional peer address out-buffer.- sendto
sendto/send— optional peer address bytes.- setsockopt
setsockopt(fd, level, optname, value_bytes).- shutdown
shutdown(fd, how).- socket
socket(domain, type, protocol)— host libc. Returns host fd orNone.- socketpair
socketpair(domain, type, protocol, sv[2]).- symlink_
path symlink(target, linkpath).- u64_
as_ void_ ptr u64address → void pointer (fixed mmap hints).- wait_
pid - Host
waitpid. Returns(pid, status)orErr(errno).pid == 0withWNOHANGmeans no child ready. - write_
fd - Write bytes to a host fd (
write(2)).