Skip to main content

FileDescriptorTable

Struct FileDescriptorTable 

Source
pub struct FileDescriptorTable { /* private fields */ }
Expand description

Per-process file descriptor table.

Implementations§

Source§

impl FileDescriptorTable

Source

pub fn new() -> Self

Create a new empty FD table.

Source

pub fn insert(&mut self, file: Arc<OpenFile>) -> u32

Insert an open file and return its FD number.

Source

pub fn insert_at(&mut self, fd: u32, file: Arc<OpenFile>)

Insert a file at a specific FD (for stdin/stdout/stderr).

Source

pub fn insert_with_flags(&mut self, file: Arc<OpenFile>, cloexec: bool) -> u32

Insert a file with explicit CLOEXEC flag.

Source

pub fn get(&self, fd: u32) -> Result<Arc<OpenFile>, SyscallError>

Get an open file by FD.

Source

pub fn get_cloexec(&self, fd: u32) -> Result<bool, SyscallError>

Get the CLOEXEC flag for a file descriptor.

Source

pub fn set_cloexec( &mut self, fd: u32, cloexec: bool, ) -> Result<(), SyscallError>

Set the CLOEXEC flag for a file descriptor.

Source

pub fn remove(&mut self, fd: u32) -> Result<Arc<OpenFile>, SyscallError>

Remove an FD and return the file.

Source

pub fn contains(&self, fd: u32) -> bool

Check if an FD exists.

Source

pub fn duplicate(&mut self, old_fd: u32) -> Result<u32, SyscallError>

Duplicate an FD (fork/dup semantics).

Source

pub fn duplicate_from( &mut self, old_fd: u32, min_fd: u32, ) -> Result<u32, SyscallError>

Duplicate an FD with a minimum target FD number (F_DUPFD semantics).

Source

pub fn duplicate_to( &mut self, old_fd: u32, new_fd: u32, ) -> Result<u32, SyscallError>

Duplicate old_fd onto new_fd (dup2 semantics).

Source

pub fn close_all(&mut self)

Close all file descriptors (process exit).

Source

pub fn close_cloexec(&mut self)

Close all file descriptors with CLOEXEC flag (execve cleanup).

Source

pub fn clone_for_fork(&self) -> Self

Clone this FD table (fork semantics).

All descriptors are copied, including those with CLOEXEC. CLOEXEC only takes effect at exec-time via close_cloexec().

Trait Implementations§

Source§

impl Default for FileDescriptorTable

Source§

fn default() -> Self

Builds a default instance.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.