pub struct ThreadFs {
pub cwd: Mutex<String>,
pub umask: AtomicU32,
}Expand description
Per-thread filesystem state for CLONE_FS support.
Each thread has a reference-counted ThreadFs that holds the thread’s
current working directory (cwd) and file creation mask (umask). When
CLONE_FS is set during clone(), the parent and child share the same
Arc<ThreadFs>, so changes to cwd or umask in one thread are visible
to the other. When CLONE_FS is not set, the child receives an
independent copy (via clone_copy).
This mirrors the Linux kernel’s struct fs_struct semantics.
Fields§
§cwd: Mutex<String>Current working directory path. Protected by a spinlock because it can be read from syscall paths (getcwd) and modified from others (chdir) concurrently.
umask: AtomicU32File creation mask (umask). Atomic because it can be read/written from concurrent syscall paths without holding a lock.
Implementations§
Source§impl ThreadFs
impl ThreadFs
Sourcepub fn new_root() -> Arc<Self>
pub fn new_root() -> Arc<Self>
Create a new root filesystem state with cwd=“/” and umask=0o022.
Used for the initial thread of a new process.
Share the filesystem state (CLONE_FS semantics).
Returns a clone of the Arc, so parent and child reference the
same underlying ThreadFs. Changes to cwd or umask in either
thread are visible to the other.
Sourcepub fn clone_copy(src: &Arc<Self>) -> Arc<Self>
pub fn clone_copy(src: &Arc<Self>) -> Arc<Self>
Copy the filesystem state (non-CLONE_FS semantics).
Creates a new independent ThreadFs with the same cwd and umask
values. Subsequent changes in either thread are isolated.