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_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 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 Types§

source

type Ptr: ForeignOwnable + Send + Sync

What kind of pointer should Self be wrapped in.

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_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 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 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.

Object Safety§

This trait is not object safe.

Implementors§