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§
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 Associated Types§
Sourcetype Ptr: ForeignOwnable + Send + Sync
type Ptr: ForeignOwnable + Send + Sync
What kind of pointer should Self
be wrapped in.
Required Methods§
Provided Methods§
Sourcefn mmap(
_device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
_file: &File,
_vma: &VmaNew,
) -> Result
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
.
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.
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.