@@ -152,7 +152,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
152
152
type_ : u32:: from ( dirent64. d_ty ) ,
153
153
name,
154
154
} ,
155
- data. get_handle_raw_fd ( ) ,
155
+ data. borrow_fd ( ) . as_raw_fd ( ) ,
156
156
)
157
157
} ;
158
158
@@ -663,7 +663,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
663
663
// Manually implement File::try_clone() by borrowing fd of data.file instead of dup().
664
664
// It's safe because the `data` variable's lifetime spans the whole function,
665
665
// so data.file won't be closed.
666
- let f = unsafe { File :: from_raw_fd ( data. get_handle_raw_fd ( ) ) } ;
666
+ let f = unsafe { File :: from_raw_fd ( data. borrow_fd ( ) . as_raw_fd ( ) ) } ;
667
667
668
668
self . check_fd_flags ( data, f. as_raw_fd ( ) , flags) ?;
669
669
@@ -690,7 +690,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
690
690
// Manually implement File::try_clone() by borrowing fd of data.file instead of dup().
691
691
// It's safe because the `data` variable's lifetime spans the whole function,
692
692
// so data.file won't be closed.
693
- let f = unsafe { File :: from_raw_fd ( data. get_handle_raw_fd ( ) ) } ;
693
+ let f = unsafe { File :: from_raw_fd ( data. borrow_fd ( ) . as_raw_fd ( ) ) } ;
694
694
695
695
self . check_fd_flags ( data, f. as_raw_fd ( ) , flags) ?;
696
696
@@ -732,7 +732,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
732
732
let inode_data = self . inode_map . get ( inode) ?;
733
733
734
734
enum Data {
735
- Handle ( Arc < HandleData > , RawFd ) ,
735
+ Handle ( Arc < HandleData > ) ,
736
736
ProcPath ( CString ) ,
737
737
}
738
738
@@ -745,8 +745,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
745
745
// If we have a handle then use it otherwise get a new fd from the inode.
746
746
if let Some ( handle) = handle {
747
747
let hd = self . handle_map . get ( handle, inode) ?;
748
- let fd = hd. get_handle_raw_fd ( ) ;
749
- Data :: Handle ( hd, fd)
748
+ Data :: Handle ( hd)
750
749
} else {
751
750
let pathname = CString :: new ( format ! ( "{}" , file. as_raw_fd( ) ) )
752
751
. map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidData , e) ) ?;
@@ -762,7 +761,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
762
761
// Safe because this doesn't modify any memory and we check the return value.
763
762
let res = unsafe {
764
763
match data {
765
- Data :: Handle ( _ , fd ) => libc:: fchmod ( fd , attr. st_mode ) ,
764
+ Data :: Handle ( ref h ) => libc:: fchmod ( h . borrow_fd ( ) . as_raw_fd ( ) , attr. st_mode ) ,
766
765
Data :: ProcPath ( ref p) => {
767
766
libc:: fchmodat ( self . proc_self_fd . as_raw_fd ( ) , p. as_ptr ( ) , attr. st_mode , 0 )
768
767
}
@@ -817,7 +816,9 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
817
816
818
817
// Safe because this doesn't modify any memory and we check the return value.
819
818
let res = match data {
820
- Data :: Handle ( _, fd) => unsafe { libc:: ftruncate ( fd, attr. st_size ) } ,
819
+ Data :: Handle ( ref h) => unsafe {
820
+ libc:: ftruncate ( h. borrow_fd ( ) . as_raw_fd ( ) , attr. st_size )
821
+ } ,
821
822
_ => {
822
823
// There is no `ftruncateat` so we need to get a new fd and truncate it.
823
824
let f = self . open_inode ( inode, libc:: O_NONBLOCK | libc:: O_RDWR ) ?;
@@ -857,7 +858,9 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
857
858
858
859
// Safe because this doesn't modify any memory and we check the return value.
859
860
let res = match data {
860
- Data :: Handle ( _, fd) => unsafe { libc:: futimens ( fd, tvs. as_ptr ( ) ) } ,
861
+ Data :: Handle ( ref h) => unsafe {
862
+ libc:: futimens ( h. borrow_fd ( ) . as_raw_fd ( ) , tvs. as_ptr ( ) )
863
+ } ,
861
864
Data :: ProcPath ( ref p) => unsafe {
862
865
libc:: utimensat ( self . proc_self_fd . as_raw_fd ( ) , p. as_ptr ( ) , tvs. as_ptr ( ) , 0 )
863
866
} ,
@@ -1043,7 +1046,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
1043
1046
// behavior by doing the same thing (dup-ing the fd and then immediately closing it). Safe
1044
1047
// because this doesn't modify any memory and we check the return values.
1045
1048
unsafe {
1046
- let newfd = libc:: dup ( data. get_handle_raw_fd ( ) ) ;
1049
+ let newfd = libc:: dup ( data. borrow_fd ( ) . as_raw_fd ( ) ) ;
1047
1050
if newfd < 0 {
1048
1051
return Err ( io:: Error :: last_os_error ( ) ) ;
1049
1052
}
@@ -1064,14 +1067,14 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
1064
1067
handle : Handle ,
1065
1068
) -> io:: Result < ( ) > {
1066
1069
let data = self . get_data ( handle, inode, libc:: O_RDONLY ) ?;
1067
- let fd = data. get_handle_raw_fd ( ) ;
1070
+ let fd = data. borrow_fd ( ) ;
1068
1071
1069
1072
// Safe because this doesn't modify any memory and we check the return value.
1070
1073
let res = unsafe {
1071
1074
if datasync {
1072
- libc:: fdatasync ( fd)
1075
+ libc:: fdatasync ( fd. as_raw_fd ( ) )
1073
1076
} else {
1074
- libc:: fsync ( fd)
1077
+ libc:: fsync ( fd. as_raw_fd ( ) )
1075
1078
}
1076
1079
} ;
1077
1080
if res == 0 {
@@ -1276,7 +1279,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
1276
1279
) -> io:: Result < ( ) > {
1277
1280
// Let the Arc<HandleData> in scope, otherwise fd may get invalid.
1278
1281
let data = self . get_data ( handle, inode, libc:: O_RDWR ) ?;
1279
- let fd = data. get_handle_raw_fd ( ) ;
1282
+ let fd = data. borrow_fd ( ) ;
1280
1283
1281
1284
if self . seal_size . load ( Ordering :: Relaxed ) {
1282
1285
let st = stat_fd ( & fd, None ) ?;
@@ -1292,7 +1295,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
1292
1295
// Safe because this doesn't modify any memory and we check the return value.
1293
1296
let res = unsafe {
1294
1297
libc:: fallocate64 (
1295
- fd,
1298
+ fd. as_raw_fd ( ) ,
1296
1299
mode as libc:: c_int ,
1297
1300
offset as libc:: off64_t ,
1298
1301
length as libc:: off64_t ,
0 commit comments