Trait kernel::miscdevice::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_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§
sourcetype Ptr: ForeignOwnable + Send + Sync
type Ptr: ForeignOwnable + Send + Sync
What kind of pointer should Self
be wrapped in.
Required Associated Constants§
sourceconst USE_VTABLE_ATTR: ()
const USE_VTABLE_ATTR: ()
A marker to prevent implementors from forgetting to use #[vtable]
attribute when implementing this trait.
Provided Associated Constants§
sourceconst HAS_RELEASE: bool = false
const HAS_RELEASE: bool = false
Indicates if the release
method is overridden by the implementor.
sourceconst HAS_COMPAT_IOCTL: bool = false
const HAS_COMPAT_IOCTL: bool = false
Indicates if the compat_ioctl
method is overridden by the implementor.
sourceconst HAS_SHOW_FDINFO: bool = false
const HAS_SHOW_FDINFO: bool = false
Indicates if the show_fdinfo
method is overridden by the implementor.
Required Methods§
Provided Methods§
sourcefn ioctl(
_device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
_file: &File,
_cmd: u32,
_arg: usize
) -> Result<isize>
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
.
sourcefn compat_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>
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.
sourcefn show_fdinfo(
_device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
_m: &SeqFile,
_file: &File
)
fn show_fdinfo( _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>, _m: &SeqFile, _file: &File )
Show info for this fd.