Lines Matching full:file
16 fs::{File, Kiocb},
121 /// The returned pointer will be stored as the private data for the file.
122 fn open(_file: &File, _misc: &MiscDeviceRegistration<Self>) -> Result<Self::Ptr>;
125 fn release(device: Self::Ptr, _file: &File) {
132 /// `file`. The function is a callback that is part of the VMA initializer. The kernel will do
139 _file: &File,
162 _file: &File,
179 _file: &File,
190 _file: &File,
196 /// A vtable for the file operations of a Rust miscdevice.
202 /// `file` and `inode` must be the file and inode for a file that is undergoing initialization.
203 /// The file must be associated with a `MiscDeviceRegistration<T>`.
204 unsafe extern "C" fn open(inode: *mut bindings::inode, raw_file: *mut bindings::file) -> c_int {
205 // SAFETY: The pointers are valid and for a file being opened.
211 // SAFETY: The open call of a file can access the private data.
221 // * This underlying file is valid for (much longer than) the duration of `T::open`.
222 // * There is no active fdget_pos region on the file on this thread.
223 let file = unsafe { File::from_raw_file(raw_file) };
225 let ptr = match T::open(file, misc) {
231 // of this file's private data. All future accesses to the private data is performed by
232 // other fops_* methods in this file, which all correctly cast the private data to the new
235 // SAFETY: The open call of a file can access the private data.
243 /// `file` and `inode` must be the file and inode for a file that is being released. The file
245 unsafe extern "C" fn release(_inode: *mut bindings::inode, file: *mut bindings::file) -> c_int {
246 // SAFETY: The release call of a file owns the private data.
247 let private = unsafe { (*file).private_data };
248 // SAFETY: The release call of a file owns the private data.
252 // * The file is valid for the duration of this call.
253 // * There is no active fdget_pos region on the file on this thread.
254 T::release(ptr, unsafe { File::from_raw_file(file) });
261 /// `kiocb` must be correspond to a valid file that is associated with a
268 // `MiscDeviceRegistration<T>` file.
281 /// `kiocb` must be correspond to a valid file that is associated with a
288 // `MiscDeviceRegistration<T>` file.
301 /// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`.
302 /// `vma` must be a vma that is currently being mmap'ed with this file.
304 file: *mut bindings::file,
307 // SAFETY: The mmap call of a file can access the private data.
308 let private = unsafe { (*file).private_data };
316 // * The file is valid for the duration of this call.
317 // * There is no active fdget_pos region on the file on this thread.
318 let file = unsafe { File::from_raw_file(file) };
320 match T::mmap(device, file, area) {
328 /// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`.
329 unsafe extern "C" fn ioctl(file: *mut bindings::file, cmd: c_uint, arg: c_ulong) -> c_long {
330 // SAFETY: The ioctl call of a file can access the private data.
331 let private = unsafe { (*file).private_data };
332 // SAFETY: Ioctl calls can borrow the private data of the file.
336 // * The file is valid for the duration of this call.
337 // * There is no active fdget_pos region on the file on this thread.
338 let file = unsafe { File::from_raw_file(file) };
340 match T::ioctl(device, file, cmd, arg) {
348 /// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`.
351 file: *mut bindings::file,
355 // SAFETY: The compat ioctl call of a file can access the private data.
356 let private = unsafe { (*file).private_data };
357 // SAFETY: Ioctl calls can borrow the private data of the file.
361 // * The file is valid for the duration of this call.
362 // * There is no active fdget_pos region on the file on this thread.
363 let file = unsafe { File::from_raw_file(file) };
365 match T::compat_ioctl(device, file, cmd, arg) {
373 /// - `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`.
375 unsafe extern "C" fn show_fdinfo(seq_file: *mut bindings::seq_file, file: *mut bindings::file) {
376 // SAFETY: The release call of a file owns the private data.
377 let private = unsafe { (*file).private_data };
378 // SAFETY: Ioctl calls can borrow the private data of the file.
381 // * The file is valid for the duration of this call.
382 // * There is no active fdget_pos region on the file on this thread.
383 let file = unsafe { File::from_raw_file(file) };
388 T::show_fdinfo(device, m, file);