File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ unsafe extern "C" fn release_callback<T: FileOperations>(
113113 file : * mut bindings:: file ,
114114) -> c_types:: c_int {
115115 let ptr = mem:: replace ( & mut ( * file) . private_data , ptr:: null_mut ( ) ) ;
116- drop ( T :: Wrapper :: from_pointer ( ptr as _ ) ) ;
116+ T :: release ( T :: Wrapper :: from_pointer ( ptr as _ ) , & File :: from_ptr ( file ) ) ;
117117 0
118118}
119119
@@ -223,6 +223,11 @@ pub trait FileOperations: Sync + Sized {
223223 /// pointer in `struct file_operations`.
224224 fn open ( ) -> KernelResult < Self :: Wrapper > ;
225225
226+ /// Cleans up after the last reference to the file goes away. Note that the object is moved, so
227+ /// it will be freed automatically unless the implemention moves it elsewhere. Corresponds to
228+ /// the `release` function pointer in `struct file_operations`.
229+ fn release ( _obj : Self :: Wrapper , _file : & File ) { }
230+
226231 /// Reads data from this file to userspace. Corresponds to the `read`
227232 /// function pointer in `struct file_operations`.
228233 const READ : ReadFn < Self > = None ;
You can’t perform that action at this time.
0 commit comments