Skip to main content

Module fs

Module fs 

Source
Expand description

Filesystem-oriented low-level helpers.

This module contains lightweight Linux and Android file probes and helpers that are useful near the OS boundary, including path existence checks, page-cache read-ahead hints, and symlink-safe read/write primitives.

Structs§

PathFingerprint

Constants§

FADV_DONTNEED
FADV_NOREUSE
FADV_NORMAL
FADV_RANDOM
FADV_SEQUENTIAL
FADV_WILLNEED

Functions§

ensure_state_dir
Create dir if needed, then verify it is a real directory with no symlink component and that it is owned by the current effective uid. Returning the anchored fd lets callers refuse to operate inside an attacker-pre-created or attacker-redirected state directory.
fadvise
Advise the kernel on the expected access pattern for a file range.
mmap_madvise
Map a file range, advise the kernel that it will be needed, then unmap it.
open_append_nofollow
Open an existing-or-create append stream that refuses to follow symlinks.
path_exists
Probe whether a filesystem path is accessible and exists.
path_fingerprint
Return a fingerprint of the file metadata at the specified path.
path_lstat_exists
Probe whether a path exists without following symbolic links.
read_nofollow
Read a file to a string, refusing to follow a symlink at the final or any parent component.
read_to_string
Read a file into a string.
readahead
Advise the kernel to begin reading file data into the page cache.
remove_nofollow
Remove a directory entry without following a final symlink, anchored to its (symlink-free) parent. The entry itself is removed even if it is a symlink; its target is never touched.
write_atomic
Atomically replace path with content.