@@ -13,7 +13,7 @@ use crate::{
13
13
iov_iter:: IovIter ,
14
14
mm,
15
15
sync:: CondVar ,
16
- types:: PointerWrapper ,
16
+ types:: ForeignOwnable ,
17
17
user_ptr:: { UserSlicePtr , UserSlicePtrReader , UserSlicePtrWriter } ,
18
18
ARef , AlwaysRefCounted ,
19
19
} ;
@@ -309,7 +309,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
309
309
let fileref = unsafe { File :: from_ptr( file) } ;
310
310
// SAFETY: `arg` was previously returned by `A::convert` and must
311
311
// 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 ( ) ;
313
313
// SAFETY: The C contract guarantees that `private_data` is available
314
314
// for implementers of the file operations (no other C code accesses
315
315
// 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> {
329
329
let mut data =
330
330
unsafe { UserSlicePtr :: new( buf as * mut core:: ffi:: c_void, len) . writer( ) } ;
331
331
// 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
333
333
// `release` callback, which the C API guarantees that will be called only when all
334
334
// references to `file` have been released, so we know it can't be called while this
335
335
// function is running.
@@ -356,7 +356,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
356
356
let file = unsafe { ( * iocb) . ki_filp } ;
357
357
let offset = unsafe { ( * iocb) . ki_pos } ;
358
358
// 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
360
360
// `release` callback, which the C API guarantees that will be called only when all
361
361
// references to `file` have been released, so we know it can't be called while this
362
362
// function is running.
@@ -382,7 +382,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
382
382
let mut data =
383
383
unsafe { UserSlicePtr :: new( buf as * mut core:: ffi:: c_void, len) . reader( ) } ;
384
384
// 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
386
386
// `release` callback, which the C API guarantees that will be called only when all
387
387
// references to `file` have been released, so we know it can't be called while this
388
388
// function is running.
@@ -409,7 +409,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
409
409
let file = unsafe { ( * iocb) . ki_filp } ;
410
410
let offset = unsafe { ( * iocb) . ki_pos } ;
411
411
// 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
413
413
// `release` callback, which the C API guarantees that will be called only when all
414
414
// references to `file` have been released, so we know it can't be called while this
415
415
// function is running.
@@ -430,7 +430,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
430
430
file : * mut bindings:: file ,
431
431
) -> core:: ffi:: c_int {
432
432
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 {
434
434
File :: from_ptr ( file)
435
435
} ) ;
436
436
0
@@ -449,7 +449,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
449
449
_ => return Err ( EINVAL ) ,
450
450
} ;
451
451
// 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
453
453
// `release` callback, which the C API guarantees that will be called only when all
454
454
// references to `file` have been released, so we know it can't be called while this
455
455
// function is running.
@@ -466,7 +466,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
466
466
) -> core:: ffi:: c_long {
467
467
from_kernel_result ! {
468
468
// 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
470
470
// `release` callback, which the C API guarantees that will be called only when all
471
471
// references to `file` have been released, so we know it can't be called while this
472
472
// function is running.
@@ -484,7 +484,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
484
484
) -> core:: ffi:: c_long {
485
485
from_kernel_result ! {
486
486
// 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
488
488
// `release` callback, which the C API guarantees that will be called only when all
489
489
// references to `file` have been released, so we know it can't be called while this
490
490
// function is running.
@@ -501,7 +501,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
501
501
) -> core:: ffi:: c_int {
502
502
from_kernel_result ! {
503
503
// 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
505
505
// `release` callback, which the C API guarantees that will be called only when all
506
506
// references to `file` have been released, so we know it can't be called while this
507
507
// function is running.
@@ -529,7 +529,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
529
529
let end = end. try_into( ) ?;
530
530
let datasync = datasync != 0 ;
531
531
// 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
533
533
// `release` callback, which the C API guarantees that will be called only when all
534
534
// references to `file` have been released, so we know it can't be called while this
535
535
// function is running.
@@ -544,7 +544,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
544
544
wait : * mut bindings:: poll_table_struct ,
545
545
) -> bindings:: __poll_t {
546
546
// 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`
548
548
// callback, which the C API guarantees that will be called only when all references to
549
549
// `file` have been released, so we know it can't be called while this function is running.
550
550
let f = unsafe { T :: Data :: borrow ( ( * file) . private_data ) } ;
@@ -775,7 +775,7 @@ pub trait OpenAdapter<T: Sync> {
775
775
pub trait Operations {
776
776
/// The type of the context data returned by [`Operations::open`] and made available to
777
777
/// other methods.
778
- type Data : PointerWrapper + Send + Sync = ( ) ;
778
+ type Data : ForeignOwnable + Send + Sync = ( ) ;
779
779
780
780
/// The type of the context data passed to [`Operations::open`].
781
781
type OpenData : Sync = ( ) ;
@@ -797,7 +797,7 @@ pub trait Operations {
797
797
///
798
798
/// Corresponds to the `read` and `read_iter` function pointers in `struct file_operations`.
799
799
fn read (
800
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
800
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
801
801
_file : & File ,
802
802
_writer : & mut impl IoBufferWriter ,
803
803
_offset : u64 ,
@@ -809,7 +809,7 @@ pub trait Operations {
809
809
///
810
810
/// Corresponds to the `write` and `write_iter` function pointers in `struct file_operations`.
811
811
fn write (
812
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
812
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
813
813
_file : & File ,
814
814
_reader : & mut impl IoBufferReader ,
815
815
_offset : u64 ,
@@ -821,7 +821,7 @@ pub trait Operations {
821
821
///
822
822
/// Corresponds to the `llseek` function pointer in `struct file_operations`.
823
823
fn seek (
824
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
824
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
825
825
_file : & File ,
826
826
_offset : SeekFrom ,
827
827
) -> Result < u64 > {
@@ -832,7 +832,7 @@ pub trait Operations {
832
832
///
833
833
/// Corresponds to the `unlocked_ioctl` function pointer in `struct file_operations`.
834
834
fn ioctl (
835
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
835
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
836
836
_file : & File ,
837
837
_cmd : & mut IoctlCommand ,
838
838
) -> Result < i32 > {
@@ -843,7 +843,7 @@ pub trait Operations {
843
843
///
844
844
/// Corresponds to the `compat_ioctl` function pointer in `struct file_operations`.
845
845
fn compat_ioctl (
846
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
846
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
847
847
_file : & File ,
848
848
_cmd : & mut IoctlCommand ,
849
849
) -> Result < i32 > {
@@ -854,7 +854,7 @@ pub trait Operations {
854
854
///
855
855
/// Corresponds to the `fsync` function pointer in `struct file_operations`.
856
856
fn fsync (
857
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
857
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
858
858
_file : & File ,
859
859
_start : u64 ,
860
860
_end : u64 ,
@@ -867,7 +867,7 @@ pub trait Operations {
867
867
///
868
868
/// Corresponds to the `mmap` function pointer in `struct file_operations`.
869
869
fn mmap (
870
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
870
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
871
871
_file : & File ,
872
872
_vma : & mut mm:: virt:: Area ,
873
873
) -> Result {
@@ -879,7 +879,7 @@ pub trait Operations {
879
879
///
880
880
/// Corresponds to the `poll` function pointer in `struct file_operations`.
881
881
fn poll (
882
- _data : <Self :: Data as PointerWrapper >:: Borrowed < ' _ > ,
882
+ _data : <Self :: Data as ForeignOwnable >:: Borrowed < ' _ > ,
883
883
_file : & File ,
884
884
_table : & PollTable ,
885
885
) -> Result < u32 > {
0 commit comments