Trait MiscDevice

Source
pub trait MiscDevice: Sized {
    type Ptr: ForeignOwnable + Send + Sync;

    const USE_VTABLE_ATTR: ();
    const HAS_OPEN: bool = false;
    const HAS_RELEASE: bool = false;
    const HAS_MMAP: bool = false;
    const HAS_IOCTL: bool = false;
    const HAS_COMPAT_IOCTL: bool = false;
    const HAS_SHOW_FDINFO: bool = false;

    // Required method
    fn open(
        _file: &File,
        _misc: &MiscDeviceRegistration<Self>,
    ) -> Result<Self::Ptr>;

    // Provided methods
    fn release(device: Self::Ptr, _file: &File) { ... }
    fn mmap(
        _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
        _file: &File,
        _vma: &VmaNew,
    ) -> Result { ... }
    fn ioctl(
        _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
        _file: &File,
        _cmd: u32,
        _arg: usize,
    ) -> Result<isize> { ... }
    fn compat_ioctl(
        _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
        _file: &File,
        _cmd: u32,
        _arg: usize,
    ) -> Result<isize> { ... }
    fn show_fdinfo(
        _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
        _m: &SeqFile,
        _file: &File,
    ) { ... }
}
Expand description

Trait implemented by the private data of an open misc device.

Required Associated Constants§

Source

const USE_VTABLE_ATTR: ()

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

Provided Associated Constants§

Source

const HAS_OPEN: bool = false

Indicates if the open method is overridden by the implementor.

Source

const HAS_RELEASE: bool = false

Indicates if the release method is overridden by the implementor.

Source

const HAS_MMAP: bool = false

Indicates if the mmap method is overridden by the implementor.

Source

const HAS_IOCTL: bool = false

Indicates if the ioctl method is overridden by the implementor.

Source

const HAS_COMPAT_IOCTL: bool = false

Indicates if the compat_ioctl method is overridden by the implementor.

Source

const HAS_SHOW_FDINFO: bool = false

Indicates if the show_fdinfo method is overridden by the implementor.

Required Associated Types§

Source

type Ptr: ForeignOwnable + Send + Sync

What kind of pointer should Self be wrapped in.

Required Methods§

Source

fn open(_file: &File, _misc: &MiscDeviceRegistration<Self>) -> Result<Self::Ptr>

Called when the misc device is opened.

The returned pointer will be stored as the private data for the file.

Provided Methods§

Source

fn release(device: Self::Ptr, _file: &File)

Called when the misc device is released.

Source

fn mmap( _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>, _file: &File, _vma: &VmaNew, ) -> Result

Handle for mmap.

This function is invoked when a user space process invokes the mmap system call on file. The function is a callback that is part of the VMA initializer. The kernel will do initial setup of the VMA before calling this function. The function can then interact with the VMA initialization by calling methods of vma. If the function does not return an error, the kernel will complete initialization of the VMA according to the properties of vma.

Source

fn ioctl( _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>, _file: &File, _cmd: u32, _arg: usize, ) -> Result<isize>

Handler for ioctls.

The cmd argument is usually manipulated using the utilties in kernel::ioctl.

Source

fn compat_ioctl( _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>, _file: &File, _cmd: u32, _arg: usize, ) -> Result<isize>

Handler for ioctls.

Used for 32-bit userspace on 64-bit platforms.

This method is optional and only needs to be provided if the ioctl relies on structures that have different layout on 32-bit and 64-bit userspace. If no implementation is provided, then compat_ptr_ioctl will be used instead.

Source

fn show_fdinfo( _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>, _m: &SeqFile, _file: &File, )

Show info for this fd.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§