Expand description
Widely useful small utilities.
Structs§
- Dropping
Stderr RetryingStderrfor output whose loss must not change how a capped run ends: hermit’s own log when it goes to stderr, and the stack traces that--stacktrace-eventand--preemption-stacktraceprint there.- RawFd
- A descriptor opened with a raw syscall, closed with one when dropped.
- Retrying
Stderr - A
Writefor the supervisor’s own diagnostics on fd 2 that survives a NONBLOCKING description.
Constants§
- STDERR_
DIAGNOSTIC_ DEADLINE - Total wall-clock ALL diagnostic writes in ONE PROCESS may spend waiting for a reader that is not draining. Hermit forks, so read the fork note below before treating this as the whole exit path’s budget.
Functions§
- canonicalize
pathwith every symbolic link followed and every.and..resolved, as glibc’srealpath(std::fs::canonicalize) gives it: relative paths from the working directory, and the same errors for an empty path (ENOENT), a missing component (ENOENT), a component that is not a directory but is followed by more, by.,..or a trailing/(ENOTDIR), and links nested too deep (ELOOPafter 40, Linux’sMAXSYMLINKS).- describe_
io_ error - Describes
errorwithout asking the C library for an errno message. - descriptor_
names - The descriptor numbers the
linux_dirent64records inrecordsname: each entry whose name is a decimal number (a descriptor directory’s), in order, leaving out.and... - find_
in_ directory - Calls
visitwith each name in directorypath, without.and.., in the kernel’s order, until it returnsSome, and returns that value (Nonewhen every name was visited). - find_
in_ open_ directory find_in_directoryof a directory already open atdirectory, from its current offset.- init_
shared_ stderr_ deadline_ origin - Create the origin cell every hermit process of this invocation shares.
- punch_
out_ print - A simple debugging helper function that makes it easy to printf-debug through layers of stdout/stderr caputure, such as when running under buck test/tpx.
- raw_
lstat - The status of the file at
path, not following a link in its last component, by a rawnewfstatat. - raw_
read_ file - The whole contents of the file at
path, read with raw syscalls. Meant for small files such as procfs entries. - raw_
read_ link - The target of the link at
path, by a rawreadlinkat. - raw_
read_ listing - The whole contents of the procfs listing at
path, read with raw syscalls and without allocating between reads, so that where the tool shares the guest’s process its own allocator maps nothing while the kernel walks the address space: the buffer is allocated before the first read, and a listing that fills it is read again, from the start, into one twice the size. - raw_
result raw_syscall’s result as anio::Result.- raw_
stat - The status of the file at
path, following links, by a rawnewfstatat. - raw_
syscall ⚠ - Issues syscall
numberwithargsthrough the syscall instruction itself on x86-64, returning the kernel’s result (a negative errno on failure). Under in-guest LiteInst Detcore runs inside the guest, where libc’s wrappers (open,fstat,syscall, …) are dynamic symbols the program or a preloaded library may define, and allocate in. - raw_
zero_ result raw_syscall’s result for a syscall whose only success value is 0 (fstat,pipe2,socketpair, …): any other value is refused, a negative one as the error it names.raw_resultwould take a positive return as success, which for such a call the kernel never gives.- rcbs_
to_ duration - A helper function to convert a number of Retired Conditional Branches (RCBS) into
a
std::time::Durationvia theNANOS_PER_RCBdefined intypes.rs. - truncated
- A little better than the builtin string truncation in format strings, because it includes ellipses.