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

FileTable

Struct FileTable 

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

File descriptor table for a process

Implementations§

Source§

impl FileTable

Source

pub fn new() -> Self

Create a new file table

Source§

impl FileTable

Source

pub fn open(&self, file: Arc<File>) -> Result<FileDescriptor, KernelError>

Open a file and return a file descriptor

Source

pub fn open_with_flags( &self, file: Arc<File>, cloexec: bool, ) -> Result<FileDescriptor, KernelError>

Open a file with close-on-exec flag and return a file descriptor

Source

pub fn get(&self, fd: FileDescriptor) -> Option<Arc<File>>

Get a file by descriptor

Source

pub fn get_entry(&self, fd: FileDescriptor) -> Option<(Arc<File>, bool)>

Get a file entry by descriptor (includes flags)

Source

pub fn close(&self, fd: FileDescriptor) -> Result<(), KernelError>

Close a file descriptor

Source

pub fn dup(&self, fd: FileDescriptor) -> Result<FileDescriptor, KernelError>

Duplicate a file descriptor

Source

pub fn dup_cloexec( &self, fd: FileDescriptor, ) -> Result<FileDescriptor, KernelError>

Duplicate a file descriptor with close-on-exec flag

Source

pub fn dup_at_least( &self, fd: FileDescriptor, min_fd: FileDescriptor, cloexec: bool, ) -> Result<FileDescriptor, KernelError>

Duplicate fd to the lowest available fd >= min_fd (for F_DUPFD)

Source

pub fn dup2( &self, old_fd: FileDescriptor, new_fd: FileDescriptor, ) -> Result<(), KernelError>

Replace a file descriptor with another

Source

pub fn dup3( &self, old_fd: FileDescriptor, new_fd: FileDescriptor, cloexec: bool, ) -> Result<(), KernelError>

Replace a file descriptor with another, setting close-on-exec flag

Source

pub fn set_cloexec( &self, fd: FileDescriptor, cloexec: bool, ) -> Result<(), KernelError>

Set close-on-exec flag for a file descriptor

Source

pub fn get_cloexec(&self, fd: FileDescriptor) -> Result<bool, KernelError>

Get close-on-exec flag for a file descriptor

Source

pub fn close_on_exec(&self)

Close all file descriptors marked with close-on-exec Called during exec() system call

Source

pub fn count_open(&self) -> usize

Get the number of open file descriptors

Source

pub fn clone_for_fork(&self) -> Self

Clone file table for fork() All file descriptors are duplicated with same flags

Source

pub fn close_all(&self)

Close all open file descriptors

Trait Implementations§

Source§

impl Default for FileTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for FileTable

§

impl !RefUnwindSafe for FileTable

§

impl Send for FileTable

§

impl Sync for FileTable

§

impl Unpin for FileTable

§

impl !UnwindSafe for FileTable

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.