⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

ThreadFs

Struct ThreadFs 

Source
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: AtomicU32

File creation mask (umask). Atomic because it can be read/written from concurrent syscall paths without holding a lock.

Implementations§

Source§

impl ThreadFs

Source

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.

Source

pub fn clone_shared(src: &Arc<Self>) -> Arc<Self>

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ThreadFs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for ThreadFs

§

impl !RefUnwindSafe for ThreadFs

§

impl Send for ThreadFs

§

impl Sync for ThreadFs

§

impl Unpin for ThreadFs

§

impl UnwindSafe for ThreadFs

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.