pub struct SharedFdTable {
pub table: Arc<FdTable>,
}Expand description
A wrapper around FdTable that manages the table’s logical share count.
This type represents the primary reference to the file descriptor table held by a task. Cloning
and dropping SharedFdTable increment and decrement the share count of the FdTable,
respectively. When the last SharedFdTable for the table is dropped, the table is cleared.
Fields§
§table: Arc<FdTable>Implementations§
Methods from Deref<Target = FdTable>§
Sourcepub fn fork(&self) -> Arc<Self> ⓘ
pub fn fork(&self) -> Arc<Self> ⓘ
Returns new unshared FdTable that is a snapshot of the state of the FdTable.
Sourcepub fn insert(
&self,
current_task: &CurrentTask,
fd: FdNumber,
file: FileHandle,
) -> Result<(), Errno>
pub fn insert( &self, current_task: &CurrentTask, fd: FdNumber, file: FileHandle, ) -> Result<(), Errno>
Inserts a file descriptor into the table.
Sourcepub fn add(
&self,
current_task: &CurrentTask,
file: FileHandle,
flags: FdFlags,
) -> Result<FdNumber, Errno>
pub fn add( &self, current_task: &CurrentTask, file: FileHandle, flags: FdFlags, ) -> Result<FdNumber, Errno>
Adds a file descriptor to the table.
The file descriptor will be assigned the next available number.
Returns the assigned file descriptor number.
This function is the most common way to add a file descriptor to the table.
Sourcepub fn duplicate(
&self,
current_task: &CurrentTask,
oldfd: FdNumber,
target: TargetFdNumber,
flags: FdFlags,
) -> Result<FdNumber, Errno>
pub fn duplicate( &self, current_task: &CurrentTask, oldfd: FdNumber, target: TargetFdNumber, flags: FdFlags, ) -> Result<FdNumber, Errno>
Duplicates a file descriptor.
If target is TargetFdNumber::Minimum, a new FdNumber is allocated. Returns the new
FdNumber.
Sourcepub fn get_allowing_opath(&self, fd: FdNumber) -> Result<FileHandle, Errno>
pub fn get_allowing_opath(&self, fd: FdNumber) -> Result<FileHandle, Errno>
Returns the file handle associated with the given file descriptor.
Returns the file handle even if the file was opened with O_PATH.
This operation is uncommon. Most clients should use get instead, which fails if the file
was opened with O_PATH.
Sourcepub fn get_allowing_opath_with_flags(
&self,
fd: FdNumber,
) -> Result<(FileHandle, FdFlags), Errno>
pub fn get_allowing_opath_with_flags( &self, fd: FdNumber, ) -> Result<(FileHandle, FdFlags), Errno>
Returns the file handle and flags associated with the given file descriptor.
Returns the file handle even if the file was opened with O_PATH.
This operation is uncommon. Most clients should use get instead, which fails if the file
was opened with O_PATH.
Sourcepub fn get(&self, fd: FdNumber) -> Result<FileHandle, Errno>
pub fn get(&self, fd: FdNumber) -> Result<FileHandle, Errno>
Returns the file handle associated with the given file descriptor.
This operation fails if the file was opened with O_PATH.
Sourcepub fn close(&self, fd: FdNumber) -> Result<(), Errno>
pub fn close(&self, fd: FdNumber) -> Result<(), Errno>
Closes the file descriptor associated with the given file descriptor.
This operation fails if the file descriptor is not valid.
Sourcepub fn get_fd_flags_allowing_opath(
&self,
fd: FdNumber,
) -> Result<FdFlags, Errno>
pub fn get_fd_flags_allowing_opath( &self, fd: FdNumber, ) -> Result<FdFlags, Errno>
Returns the flags associated with the given file descriptor.
Returns the flags even if the file was opened with O_PATH.
Sourcepub fn ioctl_fd_flags(
&self,
current_task: &CurrentTask,
fd: FdNumber,
request: u32,
) -> Result<(), Errno>
pub fn ioctl_fd_flags( &self, current_task: &CurrentTask, fd: FdNumber, request: u32, ) -> Result<(), Errno>
Updates the flags of the specified FD with the requested change.
This operation fails if the file descriptor was opened with O_PATH or is not valid.
Sourcepub fn set_fd_flags_allowing_opath(
&self,
fd: FdNumber,
flags: FdFlags,
) -> Result<(), Errno>
pub fn set_fd_flags_allowing_opath( &self, fd: FdNumber, flags: FdFlags, ) -> Result<(), Errno>
Sets the flags associated with the given file descriptor.
This operation fails if the file descriptor is not valid.
Sourcepub fn retain<F>(&self, predicate: F)
pub fn retain<F>(&self, predicate: F)
Retains only the FDs matching the given predicate.
The predicate is called with the FdNumber and a mutable reference to the FdFlags for
each entry in the FdTable. If the predicate returns false, the entry is removed from
the FdTable. Otherwise, the FdFlags are updated to the value modified by the predicate.
Sourcepub fn get_all_fds(&self) -> Vec<FdNumber>
pub fn get_all_fds(&self) -> Vec<FdNumber>
Returns a vector of all current file descriptors in the table.
Sourcepub fn remap<F: Fn(&FileHandle) -> Option<FileHandle>>(
&self,
_current_task: &CurrentTask,
predicate: F,
)
pub fn remap<F: Fn(&FileHandle) -> Option<FileHandle>>( &self, _current_task: &CurrentTask, predicate: F, )
Executes predicate(file) => maybe_replacement on every non-empty table entry.
Replaces file with replacement_file in the table when
maybe_replacement == Some(replacement_file).
pub fn read<'a>(self: &'a FdTable) -> FdTableReadGuard<'a>
pub fn write<'a>(self: &'a FdTable) -> FdTableWriteGuard<'a>
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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