@@ -9,6 +9,8 @@ use std::os::unix::io::FromRawFd;
9
9
use std:: os:: unix:: io:: OwnedFd ;
10
10
use std:: os:: unix:: io:: RawFd ;
11
11
12
+ #[ cfg( not( target_os = "redox" ) ) ]
13
+ use crate :: AsPathFd ;
12
14
#[ cfg( feature = "fs" ) ]
13
15
use crate :: { sys:: stat:: Mode , NixPath , Result } ;
14
16
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
@@ -211,15 +213,15 @@ pub fn open<P: ?Sized + NixPath>(
211
213
// The conversion is not identical on all operating systems.
212
214
#[ allow( clippy:: useless_conversion) ]
213
215
#[ cfg( not( target_os = "redox" ) ) ]
214
- pub fn openat<Fd : AsFd , P : ?Sized + NixPath >(
215
- dirfd: & Fd ,
216
+ pub fn openat<Fd : AsPathFd , P : ?Sized + NixPath >(
217
+ dirfd: Fd ,
216
218
path: & P ,
217
219
oflag: OFlag ,
218
220
mode: Mode ,
219
221
) -> Result <OwnedFd > {
220
222
let fd = path. with_nix_path( |cstr| unsafe {
221
223
libc:: openat(
222
- dirfd. as_fd ( ) . as_raw_fd ( ) ,
224
+ dirfd. as_path_fd ( ) ,
223
225
cstr. as_ptr( ) ,
224
226
oflag. bits( ) ,
225
227
mode. bits( ) as c_uint,
@@ -230,18 +232,18 @@ pub fn openat<Fd: AsFd, P: ?Sized + NixPath>(
230
232
}
231
233
232
234
#[ cfg( not( target_os = "redox" ) ) ]
233
- pub fn renameat<Fd1 : AsFd , P1 : ?Sized + NixPath , Fd2 : AsFd , P2 : ?Sized + NixPath >(
234
- old_dirfd: & Fd1 ,
235
+ pub fn renameat<Fd1 : AsPathFd , P1 : ?Sized + NixPath , Fd2 : AsPathFd , P2 : ?Sized + NixPath >(
236
+ old_dirfd: Fd1 ,
235
237
old_path: & P1 ,
236
- new_dirfd: & Fd2 ,
238
+ new_dirfd: Fd2 ,
237
239
new_path: & P2 ,
238
240
) -> Result <( ) > {
239
241
let res = old_path. with_nix_path( |old_cstr| {
240
242
new_path. with_nix_path( |new_cstr| unsafe {
241
243
libc:: renameat(
242
- old_dirfd. as_fd ( ) . as_raw_fd ( ) ,
244
+ old_dirfd. as_path_fd ( ) ,
243
245
old_cstr. as_ptr( ) ,
244
- new_dirfd. as_fd ( ) . as_raw_fd ( ) ,
246
+ new_dirfd. as_path_fd ( ) ,
245
247
new_cstr. as_ptr( ) ,
246
248
)
247
249
} )
@@ -264,19 +266,19 @@ libc_bitflags! {
264
266
feature ! {
265
267
#![ feature = "fs" ]
266
268
#[ cfg( all( target_os = "linux" , target_env = "gnu" ) ) ]
267
- pub fn renameat2<Fd1 : AsFd , P1 : ?Sized + NixPath , Fd2 : AsFd , P2 : ?Sized + NixPath >(
268
- old_dirfd: & Fd1 ,
269
+ pub fn renameat2<Fd1 : AsPathFd , P1 : ?Sized + NixPath , Fd2 : AsPathFd , P2 : ?Sized + NixPath >(
270
+ old_dirfd: Fd1 ,
269
271
old_path: & P1 ,
270
- new_dirfd: & Fd2 ,
272
+ new_dirfd: Fd2 ,
271
273
new_path: & P2 ,
272
274
flags: RenameFlags ,
273
275
) -> Result <( ) > {
274
276
let res = old_path. with_nix_path( |old_cstr| {
275
277
new_path. with_nix_path( |new_cstr| unsafe {
276
278
libc:: renameat2(
277
- old_dirfd. as_fd ( ) . as_raw_fd ( ) ,
279
+ old_dirfd. as_path_fd ( ) ,
278
280
old_cstr. as_ptr( ) ,
279
- new_dirfd. as_fd ( ) . as_raw_fd ( ) ,
281
+ new_dirfd. as_path_fd ( ) ,
280
282
new_cstr. as_ptr( ) ,
281
283
flags. bits( ) ,
282
284
)
@@ -404,10 +406,10 @@ pub fn readlink<P: ?Sized + NixPath>(path: &P) -> Result<OsString> {
404
406
405
407
#[ cfg( not( target_os = "redox" ) ) ]
406
408
pub fn readlinkat<Fd : AsFd , P : ?Sized + NixPath >(
407
- dirfd: & Fd ,
409
+ dirfd: Fd ,
408
410
path: & P ,
409
411
) -> Result <OsString > {
410
- inner_readlink( Some ( dirfd) , path)
412
+ inner_readlink( Some ( & dirfd) , path)
411
413
}
412
414
}
413
415
@@ -599,9 +601,9 @@ feature! {
599
601
/// returned.
600
602
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
601
603
pub fn copy_file_range<Fd1 : AsFd , Fd2 : AsFd >(
602
- fd_in: & Fd1 ,
604
+ fd_in: Fd1 ,
603
605
off_in: Option <& mut libc:: loff_t>,
604
- fd_out: & Fd2 ,
606
+ fd_out: Fd2 ,
605
607
off_out: Option <& mut libc:: loff_t>,
606
608
len: usize ,
607
609
) -> Result <usize > {
@@ -628,9 +630,9 @@ pub fn copy_file_range<Fd1: AsFd, Fd2: AsFd>(
628
630
629
631
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
630
632
pub fn splice<Fd1 : AsFd , Fd2 : AsFd >(
631
- fd_in: & Fd1 ,
633
+ fd_in: Fd1 ,
632
634
off_in: Option <& mut libc:: loff_t>,
633
- fd_out: & Fd2 ,
635
+ fd_out: Fd2 ,
634
636
off_out: Option <& mut libc:: loff_t>,
635
637
len: usize ,
636
638
flags: SpliceFFlags ,
@@ -657,8 +659,8 @@ pub fn splice<Fd1: AsFd, Fd2: AsFd>(
657
659
658
660
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
659
661
pub fn tee<Fd1 : AsFd , Fd2 : AsFd >(
660
- fd_in: & Fd1 ,
661
- fd_out: & Fd2 ,
662
+ fd_in: Fd1 ,
663
+ fd_out: Fd2 ,
662
664
len: usize ,
663
665
flags: SpliceFFlags ,
664
666
) -> Result <usize > {
@@ -675,7 +677,7 @@ pub fn tee<Fd1: AsFd, Fd2: AsFd>(
675
677
676
678
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
677
679
pub fn vmsplice<Fd : AsFd >(
678
- fd: & Fd ,
680
+ fd: Fd ,
679
681
iov: & [ std:: io:: IoSlice <' _>] ,
680
682
flags: SpliceFFlags ,
681
683
) -> Result <usize > {
@@ -734,7 +736,7 @@ feature! {
734
736
#[ cfg( any( target_os = "linux" ) ) ]
735
737
#[ cfg( feature = "fs" ) ]
736
738
pub fn fallocate<Fd : AsFd >(
737
- fd: & Fd ,
739
+ fd: Fd ,
738
740
mode: FallocateFlags ,
739
741
offset: libc:: off_t,
740
742
len: libc:: off_t,
@@ -810,7 +812,7 @@ impl SpacectlRange {
810
812
/// ```
811
813
#[ cfg( target_os = "freebsd" ) ]
812
814
pub fn fspacectl<Fd : AsFd >(
813
- fd: & Fd ,
815
+ fd: Fd ,
814
816
range: SpacectlRange ,
815
817
) -> Result <SpacectlRange > {
816
818
let mut rqsr = libc:: spacectl_range {
@@ -861,7 +863,7 @@ pub fn fspacectl<Fd: AsFd>(
861
863
/// ```
862
864
#[ cfg( target_os = "freebsd" ) ]
863
865
pub fn fspacectl_all<Fd : AsFd >(
864
- fd: & Fd ,
866
+ fd: Fd ,
865
867
offset: libc:: off_t,
866
868
len: libc:: off_t,
867
869
) -> Result <( ) > {
@@ -917,7 +919,7 @@ mod posix_fadvise {
917
919
feature! {
918
920
#![ feature = "fs" ]
919
921
pub fn posix_fadvise<Fd : AsFd >(
920
- fd: & Fd ,
922
+ fd: Fd ,
921
923
offset: libc:: off_t,
922
924
len: libc:: off_t,
923
925
advice: PosixFadviseAdvice ,
@@ -950,7 +952,7 @@ mod posix_fadvise {
950
952
target_os = "freebsd"
951
953
) ) ]
952
954
pub fn posix_fallocate<Fd : AsFd >(
953
- fd: & Fd ,
955
+ fd: Fd ,
954
956
offset: libc:: off_t,
955
957
len: libc:: off_t,
956
958
) -> Result <( ) > {
0 commit comments