pub trait Operations {
    type Data: PointerWrapper + Send + Sync = ();
    type OpenData: Sync = ();
Show 11 associated constants and 10 methods const USE_VTABLE_ATTR: (); const HAS_OPEN: bool = false; const HAS_RELEASE: bool = false; const HAS_READ: bool = false; const HAS_WRITE: bool = false; const HAS_SEEK: bool = false; const HAS_IOCTL: bool = false; const HAS_COMPAT_IOCTL: bool = false; const HAS_FSYNC: bool = false; const HAS_MMAP: bool = false; const HAS_POLL: bool = false; fn open(context: &Self::OpenData, file: &File) -> Result<Self::Data>; fn release(_data: Self::Data, _file: &File) { ... } fn read(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _writer: &mut impl IoBufferWriter,
        _offset: u64
    ) -> Result<usize> { ... } fn write(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _reader: &mut impl IoBufferReader,
        _offset: u64
    ) -> Result<usize> { ... } fn seek(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _offset: SeekFrom
    ) -> Result<u64> { ... } fn ioctl(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _cmd: &mut IoctlCommand
    ) -> Result<i32> { ... } fn compat_ioctl(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _cmd: &mut IoctlCommand
    ) -> Result<i32> { ... } fn fsync(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _start: u64,
        _end: u64,
        _datasync: bool
    ) -> Result<u32> { ... } fn mmap(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _vma: &mut Area
    ) -> Result { ... } fn poll(
        _data: <Self::Data as PointerWrapper>::Borrowed<'_>,
        _file: &File,
        _table: &PollTable
    ) -> Result<u32> { ... }
}
Expand description

Corresponds to the kernel’s struct file_operations.

You implement this trait whenever you would create a struct file_operations.

File descriptors may be used from multiple threads/processes concurrently, so your type must be Sync. It must also be Send because Operations::release will be called from the thread that decrements that associated file’s refcount to zero.

Provided Associated Types

The type of the context data returned by Operations::open and made available to other methods.

The type of the context data passed to Operations::open.

Required Associated Constants

A marker to prevent implementors from forgetting to use #[vtable] attribute when implementing this trait.

Provided Associated Constants

Indicates if the open method is overridden by the implementor.

Indicates if the release method is overridden by the implementor.

Indicates if the read method is overridden by the implementor.

Indicates if the write method is overridden by the implementor.

Indicates if the seek method is overridden by the implementor.

Indicates if the ioctl method is overridden by the implementor.

Indicates if the compat_ioctl method is overridden by the implementor.

Indicates if the fsync method is overridden by the implementor.

Indicates if the mmap method is overridden by the implementor.

Indicates if the poll method is overridden by the implementor.

Required Methods

Creates a new instance of this file.

Corresponds to the open function pointer in struct file_operations.

Provided Methods

Cleans up after the last reference to the file goes away.

Note that context data is moved, so it will be freed automatically unless the implementation moves it elsewhere.

Corresponds to the release function pointer in struct file_operations.

Reads data from this file to the caller’s buffer.

Corresponds to the read and read_iter function pointers in struct file_operations.

Writes data from the caller’s buffer to this file.

Corresponds to the write and write_iter function pointers in struct file_operations.

Changes the position of the file.

Corresponds to the llseek function pointer in struct file_operations.

Performs IO control operations that are specific to the file.

Corresponds to the unlocked_ioctl function pointer in struct file_operations.

Performs 32-bit IO control operations on that are specific to the file on 64-bit kernels.

Corresponds to the compat_ioctl function pointer in struct file_operations.

Syncs pending changes to this file.

Corresponds to the fsync function pointer in struct file_operations.

Maps areas of the caller’s virtual memory with device/file memory.

Corresponds to the mmap function pointer in struct file_operations.

Checks the state of the file and optionally registers for notification when the state changes.

Corresponds to the poll function pointer in struct file_operations.

Implementors