This repository was archived by the owner on Mar 7, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -238,13 +238,30 @@ impl FileOperationsVtable {
238238 }
239239}
240240
241+ /// `FileOperations` corresponds to the kernel's `struct file_operations`. You
242+ /// implement this trait whenever you'd create a `struct file_operations`. File
243+ /// descriptors may be used from multiple threads (or processes) concurrently,
244+ /// so your type must be `Sync`.
241245pub trait FileOperations : Sync + Sized {
246+ /// A container for the actual `file_operations` value. This will always be:
247+ /// ```
248+ /// const VTABLE: linux_kernel_module::chrdev::FileOperationsVtable =
249+ /// linux_kernel_module::chrdev::FileOperationsVtable::new::<Self>();
250+ /// ```
242251 const VTABLE : FileOperationsVtable ;
243252
253+ /// Creates a new instance of this file. Corresponds to the `open` function
254+ /// pointer in `struct file_operations`.
244255 fn open ( ) -> KernelResult < Self > ;
256+
257+ /// Reads data from this file to userspace. Corresponds to the `read`
258+ /// function pointer in `struct file_operations`.
245259 fn read ( & self , _buf : & mut UserSlicePtrWriter , _offset : u64 ) -> KernelResult < ( ) > {
246260 Err ( Error :: EINVAL )
247261 }
262+
263+ /// Changes the position of the file. Corresponds to the `llseek` function
264+ /// pointer in `struct file_operations`.
248265 fn seek ( & self , _file : & File , _offset : SeekFrom ) -> KernelResult < u64 > {
249266 Err ( Error :: ESPIPE )
250267 }
You can’t perform that action at this time.
0 commit comments