@@ -13,7 +13,7 @@ use crate::{
1313 iov_iter:: IovIter ,
1414 mm,
1515 sync:: CondVar ,
16- types:: PointerWrapper ,
16+ types:: ForeignOwnable ,
1717 user_ptr:: { UserSlicePtr , UserSlicePtrReader , UserSlicePtrWriter } ,
1818 ARef , AlwaysRefCounted ,
1919} ;
@@ -309,7 +309,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
309309 let fileref = unsafe { File :: from_ptr( file) } ;
310310 // SAFETY: `arg` was previously returned by `A::convert` and must
311311 // be a valid non-null pointer.
312- let ptr = T :: open( unsafe { & * arg } , fileref) ?. into_pointer ( ) ;
312+ let ptr = T :: open( unsafe { & * arg } , fileref) ?. into_foreign ( ) ;
313313 // SAFETY: The C contract guarantees that `private_data` is available
314314 // for implementers of the file operations (no other C code accesses
315315 // it), so we know that there are no concurrent threads/CPUs accessing
@@ -329,7 +329,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
329329 let mut data =
330330 unsafe { UserSlicePtr :: new( buf as * mut core:: ffi:: c_void, len) . writer( ) } ;
331331 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
332- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
332+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
333333 // `release` callback, which the C API guarantees that will be called only when all
334334 // references to `file` have been released, so we know it can't be called while this
335335 // function is running.
@@ -356,7 +356,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
356356 let file = unsafe { ( * iocb) . ki_filp } ;
357357 let offset = unsafe { ( * iocb) . ki_pos } ;
358358 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
359- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
359+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
360360 // `release` callback, which the C API guarantees that will be called only when all
361361 // references to `file` have been released, so we know it can't be called while this
362362 // function is running.
@@ -382,7 +382,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
382382 let mut data =
383383 unsafe { UserSlicePtr :: new( buf as * mut core:: ffi:: c_void, len) . reader( ) } ;
384384 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
385- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
385+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
386386 // `release` callback, which the C API guarantees that will be called only when all
387387 // references to `file` have been released, so we know it can't be called while this
388388 // function is running.
@@ -409,7 +409,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
409409 let file = unsafe { ( * iocb) . ki_filp } ;
410410 let offset = unsafe { ( * iocb) . ki_pos } ;
411411 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
412- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
412+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
413413 // `release` callback, which the C API guarantees that will be called only when all
414414 // references to `file` have been released, so we know it can't be called while this
415415 // function is running.
@@ -430,7 +430,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
430430 file : * mut bindings:: file ,
431431 ) -> core:: ffi:: c_int {
432432 let ptr = mem:: replace ( unsafe { & mut ( * file) . private_data } , ptr:: null_mut ( ) ) ;
433- T :: release ( unsafe { T :: Data :: from_pointer ( ptr as _ ) } , unsafe {
433+ T :: release ( unsafe { T :: Data :: from_foreign ( ptr as _ ) } , unsafe {
434434 File :: from_ptr ( file)
435435 } ) ;
436436 0
@@ -449,7 +449,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
449449 _ => return Err ( EINVAL ) ,
450450 } ;
451451 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
452- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
452+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
453453 // `release` callback, which the C API guarantees that will be called only when all
454454 // references to `file` have been released, so we know it can't be called while this
455455 // function is running.
@@ -466,7 +466,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
466466 ) -> core:: ffi:: c_long {
467467 from_kernel_result ! {
468468 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
469- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
469+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
470470 // `release` callback, which the C API guarantees that will be called only when all
471471 // references to `file` have been released, so we know it can't be called while this
472472 // function is running.
@@ -484,7 +484,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
484484 ) -> core:: ffi:: c_long {
485485 from_kernel_result ! {
486486 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
487- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
487+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
488488 // `release` callback, which the C API guarantees that will be called only when all
489489 // references to `file` have been released, so we know it can't be called while this
490490 // function is running.
@@ -501,7 +501,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
501501 ) -> core:: ffi:: c_int {
502502 from_kernel_result ! {
503503 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
504- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
504+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
505505 // `release` callback, which the C API guarantees that will be called only when all
506506 // references to `file` have been released, so we know it can't be called while this
507507 // function is running.
@@ -529,7 +529,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
529529 let end = end. try_into( ) ?;
530530 let datasync = datasync != 0 ;
531531 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
532- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the
532+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the
533533 // `release` callback, which the C API guarantees that will be called only when all
534534 // references to `file` have been released, so we know it can't be called while this
535535 // function is running.
@@ -544,7 +544,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
544544 wait : * mut bindings:: poll_table_struct ,
545545 ) -> bindings:: __poll_t {
546546 // SAFETY: `private_data` was initialised by `open_callback` with a value returned by
547- // `T::Data::into_pointer `. `T::Data::from_pointer ` is only called by the `release`
547+ // `T::Data::into_foreign `. `T::Data::from_foreign ` is only called by the `release`
548548 // callback, which the C API guarantees that will be called only when all references to
549549 // `file` have been released, so we know it can't be called while this function is running.
550550 let f = unsafe { T :: Data :: borrow ( ( * file) . private_data ) } ;
@@ -775,7 +775,7 @@ pub trait OpenAdapter<T: Sync> {
775775pub trait Operations {
776776 /// The type of the context data returned by [`Operations::open`] and made available to
777777 /// other methods.
778- type Data : PointerWrapper + Send + Sync = ( ) ;
778+ type Data : ForeignOwnable + Send + Sync = ( ) ;
779779
780780 /// The type of the context data passed to [`Operations::open`].
781781 type OpenData : Sync = ( ) ;
@@ -797,7 +797,7 @@ pub trait Operations {
797797 ///
798798 /// Corresponds to the `read` and `read_iter` function pointers in `struct file_operations`.
799799 fn read (
800- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
800+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
801801 _file : & File ,
802802 _writer : & mut impl IoBufferWriter ,
803803 _offset : u64 ,
@@ -809,7 +809,7 @@ pub trait Operations {
809809 ///
810810 /// Corresponds to the `write` and `write_iter` function pointers in `struct file_operations`.
811811 fn write (
812- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
812+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
813813 _file : & File ,
814814 _reader : & mut impl IoBufferReader ,
815815 _offset : u64 ,
@@ -821,7 +821,7 @@ pub trait Operations {
821821 ///
822822 /// Corresponds to the `llseek` function pointer in `struct file_operations`.
823823 fn seek (
824- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
824+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
825825 _file : & File ,
826826 _offset : SeekFrom ,
827827 ) -> Result < u64 > {
@@ -832,7 +832,7 @@ pub trait Operations {
832832 ///
833833 /// Corresponds to the `unlocked_ioctl` function pointer in `struct file_operations`.
834834 fn ioctl (
835- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
835+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
836836 _file : & File ,
837837 _cmd : & mut IoctlCommand ,
838838 ) -> Result < i32 > {
@@ -843,7 +843,7 @@ pub trait Operations {
843843 ///
844844 /// Corresponds to the `compat_ioctl` function pointer in `struct file_operations`.
845845 fn compat_ioctl (
846- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
846+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
847847 _file : & File ,
848848 _cmd : & mut IoctlCommand ,
849849 ) -> Result < i32 > {
@@ -854,7 +854,7 @@ pub trait Operations {
854854 ///
855855 /// Corresponds to the `fsync` function pointer in `struct file_operations`.
856856 fn fsync (
857- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
857+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
858858 _file : & File ,
859859 _start : u64 ,
860860 _end : u64 ,
@@ -867,7 +867,7 @@ pub trait Operations {
867867 ///
868868 /// Corresponds to the `mmap` function pointer in `struct file_operations`.
869869 fn mmap (
870- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
870+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
871871 _file : & File ,
872872 _vma : & mut mm:: virt:: Area ,
873873 ) -> Result {
@@ -879,7 +879,7 @@ pub trait Operations {
879879 ///
880880 /// Corresponds to the `poll` function pointer in `struct file_operations`.
881881 fn poll (
882- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
882+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
883883 _file : & File ,
884884 _table : & PollTable ,
885885 ) -> Result < u32 > {
0 commit comments