Struct magma_device::MagmaFile
source · pub struct MagmaFile { /* private fields */ }
Implementations§
Trait Implementations§
source§impl FileOps for MagmaFile
impl FileOps for MagmaFile
source§fn is_seekable(&self) -> bool
fn is_seekable(&self) -> bool
Returns whether the file is seekable.
source§fn seek(
&self,
_file: &FileObject,
_current_task: &CurrentTask,
_current_offset: off_t,
_target: SeekTarget
) -> Result<off_t, Errno>
fn seek( &self, _file: &FileObject, _current_task: &CurrentTask, _current_offset: off_t, _target: SeekTarget ) -> Result<off_t, Errno>
Adjust the
current_offset
if the file is seekable.fn ioctl( &self, _locked: &mut Locked<'_, Unlocked>, _file: &FileObject, current_task: &CurrentTask, _request: u32, arg: SyscallArg ) -> Result<SyscallResult, Errno>
source§fn read(
&self,
_locked: &mut Locked<'_, FileOpsCore>,
_file: &FileObject,
_current_task: &CurrentTask,
offset: usize,
_data: &mut dyn OutputBuffer
) -> Result<usize, Errno>
fn read( &self, _locked: &mut Locked<'_, FileOpsCore>, _file: &FileObject, _current_task: &CurrentTask, offset: usize, _data: &mut dyn OutputBuffer ) -> Result<usize, Errno>
Read from the file at an offset. If the file does not have persistent offsets (either
directly, or because it is not seekable), offset will be 0 and can be ignored.
Returns the number of bytes read.
source§fn write(
&self,
_locked: &mut Locked<'_, WriteOps>,
_file: &FileObject,
_current_task: &CurrentTask,
offset: usize,
_data: &mut dyn InputBuffer
) -> Result<usize, Errno>
fn write( &self, _locked: &mut Locked<'_, WriteOps>, _file: &FileObject, _current_task: &CurrentTask, offset: usize, _data: &mut dyn InputBuffer ) -> Result<usize, Errno>
Write to the file with an offset. If the file does not have persistent offsets (either
directly, or because it is not seekable), offset will be 0 and can be ignored.
Returns the number of bytes written.
§fn close(&self, _file: &FileObject, _current_task: &CurrentTask)
fn close(&self, _file: &FileObject, _current_task: &CurrentTask)
Called when the FileObject is closed.
§fn flush(&self, _file: &FileObject, _current_task: &CurrentTask)
fn flush(&self, _file: &FileObject, _current_task: &CurrentTask)
Called every time close() is called on this file, even if the file is not ready to be
released.
§fn has_persistent_offsets(&self) -> bool
fn has_persistent_offsets(&self) -> bool
Returns whether the file has meaningful seek offsets. Returning
false
is only
optimization and will makes FileObject
never hold the offset lock when calling read
and
write
.§fn sync(
&self,
file: &FileObject,
_current_task: &CurrentTask
) -> Result<(), Errno>
fn sync( &self, file: &FileObject, _current_task: &CurrentTask ) -> Result<(), Errno>
Syncs cached state associated with the file descriptor to persistent storage. Read more
§fn data_sync(
&self,
file: &FileObject,
current_task: &CurrentTask
) -> Result<(), Errno>
fn data_sync( &self, file: &FileObject, current_task: &CurrentTask ) -> Result<(), Errno>
Syncs cached data, and only enough metadata to retrieve said data, to persistent storage. Read more
§fn get_vmo(
&self,
_file: &FileObject,
_current_task: &CurrentTask,
_length: Option<usize>,
_prot: ProtectionFlags
) -> Result<Arc<Vmo>, Errno>
fn get_vmo( &self, _file: &FileObject, _current_task: &CurrentTask, _length: Option<usize>, _prot: ProtectionFlags ) -> Result<Arc<Vmo>, Errno>
Returns a VMO representing this file. At least the requested protection flags must
be set on the VMO. Reading or writing the VMO must read or write the file. If this is not
possible given the requested protection, an error must be returned.
The
length
is a hint for the desired size of the VMO. The returned VMO may be larger or
smaller than the requested length.
This method is typically called by [Self::mmap
].§fn mmap(
&self,
file: &FileObject,
current_task: &CurrentTask,
addr: DesiredAddress,
vmo_offset: u64,
length: usize,
prot_flags: ProtectionFlags,
options: MappingOptions,
filename: NamespaceNode
) -> Result<UserAddress, Errno>
fn mmap( &self, file: &FileObject, current_task: &CurrentTask, addr: DesiredAddress, vmo_offset: u64, length: usize, prot_flags: ProtectionFlags, options: MappingOptions, filename: NamespaceNode ) -> Result<UserAddress, Errno>
Responds to an mmap call. The default implementation calls [
Self::get_vmo
] to get a VMO
and then maps it with [crate::mm::MemoryManager::map
].
Only implement this trait method if your file needs to control mapping, or record where
a VMO gets mapped.§fn readdir(
&self,
_locked: &mut Locked<'_, FileOpsCore>,
_file: &FileObject,
_current_task: &CurrentTask,
_sink: &mut dyn DirentSink
) -> Result<(), Errno>
fn readdir( &self, _locked: &mut Locked<'_, FileOpsCore>, _file: &FileObject, _current_task: &CurrentTask, _sink: &mut dyn DirentSink ) -> Result<(), Errno>
§fn wait_async(
&self,
_file: &FileObject,
_current_task: &CurrentTask,
_waiter: &Waiter,
_events: FdEvents,
_handler: EventHandler
) -> Option<WaitCanceler>
fn wait_async( &self, _file: &FileObject, _current_task: &CurrentTask, _waiter: &Waiter, _events: FdEvents, _handler: EventHandler ) -> Option<WaitCanceler>
Establish a one-shot, edge-triggered, asynchronous wait for the given FdEvents for the
given file and task. Returns
None
if this file does not support blocking waits. Read more§fn query_events(
&self,
_file: &FileObject,
_current_task: &CurrentTask
) -> Result<FdEvents, Errno>
fn query_events( &self, _file: &FileObject, _current_task: &CurrentTask ) -> Result<FdEvents, Errno>
The events currently active on this file. Read more
fn fcntl( &self, _file: &FileObject, _current_task: &CurrentTask, cmd: u32, _arg: u64 ) -> Result<SyscallResult, Errno>
§fn to_handle(
&self,
locked: &mut Locked<'_, FileOpsToHandle>,
file: &FileObject,
current_task: &CurrentTask
) -> Result<Option<Handle>, Errno>
fn to_handle( &self, locked: &mut Locked<'_, FileOpsToHandle>, file: &FileObject, current_task: &CurrentTask ) -> Result<Option<Handle>, Errno>
Return a handle that allows access to this file descritor through the zxio protocols. Read more
fn readahead( &self, _file: &FileObject, _current_task: &CurrentTask, _offset: usize, _length: usize ) -> Result<(), Errno>
Auto Trait Implementations§
impl !Freeze for MagmaFile
impl !RefUnwindSafe for MagmaFile
impl Send for MagmaFile
impl Sync for MagmaFile
impl Unpin for MagmaFile
impl !UnwindSafe for MagmaFile
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
Mutably borrows from an owned value. Read more
source§impl<T> Encode<Ambiguous1> for T
impl<T> Encode<Ambiguous1> for T
source§impl<T> Encode<Ambiguous2> for T
impl<T> Encode<Ambiguous2> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoAny for T
impl<T> IntoAny for T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T, U> TryIntoExt<U> for Twhere
U: TryFromExt<T>,
impl<T, U> TryIntoExt<U> for Twhere
U: TryFromExt<T>,
type Error = <U as TryFromExt<T>>::Error
source§fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>
fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>
Tries to perform the conversion.