Trait kernel::file_operations::FileOperations[][src]

pub trait FileOperations: Send + Sync + Sized {
    type Wrapper: PointerWrapper = Box<Self>;

    const TO_USE: ToUse;
    fn release(_obj: Self::Wrapper, _file: &File) { ... }
fn read<T: IoBufferWriter>(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _file: &File,
        _data: &mut T,
        _offset: u64
    ) -> Result<usize> { ... }
fn write<T: IoBufferReader>(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _file: &File,
        _data: &mut T,
        _offset: u64
    ) -> Result<usize> { ... }
fn seek(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _file: &File,
        _offset: SeekFrom
    ) -> Result<u64> { ... }
fn ioctl(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _file: &File,
        _cmd: &mut IoctlCommand
    ) -> Result<i32> { ... }
fn compat_ioctl(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _file: &File,
        _cmd: &mut IoctlCommand
    ) -> Result<i32> { ... }
fn fsync(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _file: &File,
        _start: u64,
        _end: u64,
        _datasync: bool
    ) -> Result<u32> { ... }
fn mmap(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _file: &File,
        _vma: &mut vm_area_struct
    ) -> Result { ... }
fn poll(
        _this: &<<Self::Wrapper as PointerWrapper>::Borrowed as Deref>::Target,
        _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 FileOperations::release will be called from the thread that decrements that associated file’s refcount to zero.

Associated Types

The pointer type that will be used to hold ourselves.

Associated Constants

The methods to use to populate [struct file_operations].

Provided methods

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

Note that the object 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. TODO: wrap vm_area_struct so that we don’t have to expose it.

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