Skip to main content

Module host

Module host 

Source
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*).
MappedFile
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
accept with peer sockaddr written into addr_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. Returns new or None on failure.
dup_fd
Duplicate a host fd. Returns the new fd or None on failure.
execve_host⚠
Host execve with 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 guest ld can mark products executable.
fcntl_get
fcntl with no extra arg (F_GETFD / F_GETFL).
fcntl_set
fcntl with one integer arg (F_SETFD / F_SETFL / F_DUPFD).
fd_is_fifo
true when fd is a FIFO/pipe (S_IFIFO).
fixed_map_flag
Preferred fixed-map flag for this host.
fork_process
Host fork. Returns Ok(pid) where pid is 0 in the child, or Err(errno).
fstat_fd
fstat into a host stat buffer.
fstatat
fstatat(dirfd, path, …) — used by B1 bottle-relative stat/lstat.
fsync_fd
fsync(fd).
ftruncate_fd
ftruncate(fd, length).
getpeername
getpeername(fd, addr_out).
getsockname
getsockname(fd, addr_out).
getsockopt
getsockopt — writes into value, returns updated length.
gettimeofday
Host gettimeofday (timezone ignored).
link_path
link(existing, newpath) hard link.
listen
listen(fd, backlog).
lseek_fd
lseek on a host fd.
mkdirat
mkdirat(dirfd, path, mode) — returns Ok(()) on success or EEXIST.
mmap
Anonymous or file-backed mmap. Returns host base or None on failure.
mprotect
mprotect on a host mapping range.
msync
msync on a host mapping range.
munmap
munmap a mapping previously returned by mmap.
open_directory
Open a directory as O_RDONLY|O_DIRECTORY|O_CLOEXEC (bottle root dirfd, B1).
open_path
open(path, flags, mode) — prefers libc over std::fs::OpenOptions so directories open with O_RDONLY (archive walks) and we avoid extra syscalls.
openat
openat(dirfd, path, flags, mode).
page_size
Host page size in bytes, or None if sysconf fails.
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) or None on failure.
poll
poll(fds, timeout_ms) — empty slice sleeps / checks timeout only.
poll_fd_io
Block until fd is readable or writable (TLS may need both).
poll_fd_readable
Block until fd is readable, hung-up, or errored. timeout_ms as in poll(2) (-1 = forever). Returns true if any interesting revent.
poll_fd_writable
Block until fd is writable, hung-up, or errored.
posix_spawn_host⚠
Host posix_spawn without 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) into buf (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 or None.
socketpair
socketpair(domain, type, protocol, sv[2]).
symlink_path
symlink(target, linkpath).
u64_as_void_ptr
u64 address → void pointer (fixed mmap hints).
wait_pid
Host waitpid. Returns (pid, status) or Err(errno). pid == 0 with WNOHANG means no child ready.
write_fd
Write bytes to a host fd (write(2)).