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

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

    const TO_USE: ToUse;
    fn release(_obj: Self::Wrapper, _file: &File) { ... }
fn read(
        &self,
        _file: &File,
        _data: &mut UserSlicePtrWriter,
        _offset: u64
    ) -> KernelResult<usize> { ... }
fn write(
        &self,
        _data: &mut UserSlicePtrReader,
        _offset: u64
    ) -> KernelResult<usize> { ... }
fn seek(&self, _file: &File, _offset: SeekFrom) -> KernelResult<u64> { ... }
fn ioctl(&self, _file: &File, _cmd: &mut IoctlCommand) -> KernelResult<i32> { ... }
fn compat_ioctl(
        &self,
        _file: &File,
        _cmd: &mut IoctlCommand
    ) -> KernelResult<i32> { ... }
fn fsync(
        &self,
        _file: &File,
        _start: u64,
        _end: u64,
        _datasync: bool
    ) -> KernelResult<u32> { ... }
fn mmap(&self, _file: &File, _vma: &mut vm_area_struct) -> KernelResult { ... }
fn poll(&self, _file: &File, _table: &PollTable) -> KernelResult<u32> { ... } }

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

type Wrapper: PointerWrapper<Self>[src]

The pointer type that will be used to hold ourselves.

Loading content...

Associated Constants

const TO_USE: ToUse[src]

The methods to use to populate [struct file_operations].

Loading content...

Provided methods

fn release(_obj: Self::Wrapper, _file: &File)[src]

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.

fn read(
    &self,
    _file: &File,
    _data: &mut UserSlicePtrWriter,
    _offset: u64
) -> KernelResult<usize>
[src]

Reads data from this file to userspace.

Corresponds to the read function pointer in struct file_operations.

fn write(
    &self,
    _data: &mut UserSlicePtrReader,
    _offset: u64
) -> KernelResult<usize>
[src]

Writes data from userspace to this file.

Corresponds to the write function pointer in struct file_operations.

fn seek(&self, _file: &File, _offset: SeekFrom) -> KernelResult<u64>[src]

Changes the position of the file.

Corresponds to the llseek function pointer in struct file_operations.

fn ioctl(&self, _file: &File, _cmd: &mut IoctlCommand) -> KernelResult<i32>[src]

Performs IO control operations that are specific to the file.

Corresponds to the unlocked_ioctl function pointer in struct file_operations.

fn compat_ioctl(
    &self,
    _file: &File,
    _cmd: &mut IoctlCommand
) -> KernelResult<i32>
[src]

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.

fn fsync(
    &self,
    _file: &File,
    _start: u64,
    _end: u64,
    _datasync: bool
) -> KernelResult<u32>
[src]

Syncs pending changes to this file.

Corresponds to the fsync function pointer in struct file_operations.

fn mmap(&self, _file: &File, _vma: &mut vm_area_struct) -> KernelResult[src]

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.

fn poll(&self, _file: &File, _table: &PollTable) -> KernelResult<u32>[src]

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.

Loading content...

Implementors

Loading content...