@@ -152,7 +152,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
152152 type_ : u32:: from ( dirent64. d_ty ) ,
153153 name,
154154 } ,
155- data. get_handle_raw_fd ( ) ,
155+ data. borrow_fd ( ) . as_raw_fd ( ) ,
156156 )
157157 } ;
158158
@@ -663,7 +663,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
663663 // Manually implement File::try_clone() by borrowing fd of data.file instead of dup().
664664 // It's safe because the `data` variable's lifetime spans the whole function,
665665 // 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 ( ) ) } ;
667667
668668 self . check_fd_flags ( data, f. as_raw_fd ( ) , flags) ?;
669669
@@ -690,7 +690,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
690690 // Manually implement File::try_clone() by borrowing fd of data.file instead of dup().
691691 // It's safe because the `data` variable's lifetime spans the whole function,
692692 // 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 ( ) ) } ;
694694
695695 self . check_fd_flags ( data, f. as_raw_fd ( ) , flags) ?;
696696
@@ -732,7 +732,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
732732 let inode_data = self . inode_map . get ( inode) ?;
733733
734734 enum Data {
735- Handle ( Arc < HandleData > , RawFd ) ,
735+ Handle ( Arc < HandleData > ) ,
736736 ProcPath ( CString ) ,
737737 }
738738
@@ -745,8 +745,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
745745 // If we have a handle then use it otherwise get a new fd from the inode.
746746 if let Some ( handle) = handle {
747747 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)
750749 } else {
751750 let pathname = CString :: new ( format ! ( "{}" , file. as_raw_fd( ) ) )
752751 . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidData , e) ) ?;
@@ -762,7 +761,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
762761 // Safe because this doesn't modify any memory and we check the return value.
763762 let res = unsafe {
764763 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 ) ,
766765 Data :: ProcPath ( ref p) => {
767766 libc:: fchmodat ( self . proc_self_fd . as_raw_fd ( ) , p. as_ptr ( ) , attr. st_mode , 0 )
768767 }
@@ -817,7 +816,9 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
817816
818817 // Safe because this doesn't modify any memory and we check the return value.
819818 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+ } ,
821822 _ => {
822823 // There is no `ftruncateat` so we need to get a new fd and truncate it.
823824 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> {
857858
858859 // Safe because this doesn't modify any memory and we check the return value.
859860 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+ } ,
861864 Data :: ProcPath ( ref p) => unsafe {
862865 libc:: utimensat ( self . proc_self_fd . as_raw_fd ( ) , p. as_ptr ( ) , tvs. as_ptr ( ) , 0 )
863866 } ,
@@ -1043,7 +1046,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
10431046 // behavior by doing the same thing (dup-ing the fd and then immediately closing it). Safe
10441047 // because this doesn't modify any memory and we check the return values.
10451048 unsafe {
1046- let newfd = libc:: dup ( data. get_handle_raw_fd ( ) ) ;
1049+ let newfd = libc:: dup ( data. borrow_fd ( ) . as_raw_fd ( ) ) ;
10471050 if newfd < 0 {
10481051 return Err ( io:: Error :: last_os_error ( ) ) ;
10491052 }
@@ -1064,14 +1067,14 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
10641067 handle : Handle ,
10651068 ) -> io:: Result < ( ) > {
10661069 let data = self . get_data ( handle, inode, libc:: O_RDONLY ) ?;
1067- let fd = data. get_handle_raw_fd ( ) ;
1070+ let fd = data. borrow_fd ( ) ;
10681071
10691072 // Safe because this doesn't modify any memory and we check the return value.
10701073 let res = unsafe {
10711074 if datasync {
1072- libc:: fdatasync ( fd)
1075+ libc:: fdatasync ( fd. as_raw_fd ( ) )
10731076 } else {
1074- libc:: fsync ( fd)
1077+ libc:: fsync ( fd. as_raw_fd ( ) )
10751078 }
10761079 } ;
10771080 if res == 0 {
@@ -1276,7 +1279,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
12761279 ) -> io:: Result < ( ) > {
12771280 // Let the Arc<HandleData> in scope, otherwise fd may get invalid.
12781281 let data = self . get_data ( handle, inode, libc:: O_RDWR ) ?;
1279- let fd = data. get_handle_raw_fd ( ) ;
1282+ let fd = data. borrow_fd ( ) ;
12801283
12811284 if self . seal_size . load ( Ordering :: Relaxed ) {
12821285 let st = stat_fd ( & fd, None ) ?;
@@ -1292,7 +1295,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
12921295 // Safe because this doesn't modify any memory and we check the return value.
12931296 let res = unsafe {
12941297 libc:: fallocate64 (
1295- fd,
1298+ fd. as_raw_fd ( ) ,
12961299 mode as libc:: c_int ,
12971300 offset as libc:: off64_t ,
12981301 length as libc:: off64_t ,
0 commit comments