Skip to main content

canonicalize

Function canonicalize 

Source
pub fn canonicalize(path: &Path) -> Result<PathBuf>
Expand description

path with every symbolic link followed and every . and .. resolved, as glibc’s realpath (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 (ELOOP after 40, Linux’s MAXSYMLINKS).

Walked with raw getcwd, readlinkat and newfstatat into buffers from Rust’s allocator, never with std::fs::canonicalize: that calls glibc’s realpath, whose result comes from the C library’s malloc. Where Detcore runs in the guest’s process (SaBRe, in-guest LiteInst), that heap is the guest’s, and the allocation moves the guest’s own malloc results and can grow its program break (see find_in_directory).