Struct magma_device::MagmaFile

source ·
pub struct MagmaFile { /* private fields */ }

Implementations§

source§

impl MagmaFile

source

pub fn init()

source

pub fn new_file( _current_task: &CurrentTask, _dev: DeviceType, _node: &FsNode, _flags: OpenFlags ) -> Result<Box<dyn FileOps>, Errno>

Trait Implementations§

source§

impl FileOps for MagmaFile

source§

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>

Adjust the current_offset if the file is seekable.
source§

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>

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>

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)

Called when the FileObject is closed.
§

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

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>

Syncs cached state associated with the file descriptor to persistent storage. Read more
§

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>

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>

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>

Respond to a getdents or getdents64 calls. Read more
§

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>

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>

Return a handle that allows access to this file descritor through the zxio protocols. Read more
§

fn as_pid(&self, _file: &FileObject) -> Result<i32, Errno>

Returns the associated pid_t. Read more
§

fn readahead( &self, _file: &FileObject, _current_task: &CurrentTask, _offset: usize, _length: usize ) -> Result<(), Errno>

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
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn type_name(&self) -> &'static str

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> Encode<Ambiguous1> for T

source§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> Encode<Ambiguous2> for T

source§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Cast the given object into a dyn std::any::Any.
source§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

source§

fn into_ext(self) -> U

Performs the conversion.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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.
source§

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

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

source§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<St> WithTag for St

source§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag
§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,

§

impl<B, A> LockEqualOrBefore<B> for A
where A: LockBefore<B>,