@@ -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 :: AsDirFd ;
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 : AsDirFd , 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_dir_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 : AsDirFd , P1 : ?Sized + NixPath , Fd2 : AsDirFd , 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_dir_fd ( ) ,
243
245
old_cstr. as_ptr( ) ,
244
- new_dirfd. as_fd ( ) . as_raw_fd ( ) ,
246
+ new_dirfd. as_dir_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 : AsDirFd , P1 : ?Sized + NixPath , Fd2 : AsDirFd , 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_dir_fd ( ) ,
278
280
old_cstr. as_ptr( ) ,
279
- new_dirfd. as_fd ( ) . as_raw_fd ( ) ,
281
+ new_dirfd. as_dir_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
@@ -623,9 +625,9 @@ feature! {
623
625
/// returned.
624
626
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
625
627
pub fn copy_file_range<Fd1 : AsFd , Fd2 : AsFd >(
626
- fd_in: & Fd1 ,
628
+ fd_in: Fd1 ,
627
629
off_in: Option <& mut libc:: loff_t>,
628
- fd_out: & Fd2 ,
630
+ fd_out: Fd2 ,
629
631
off_out: Option <& mut libc:: loff_t>,
630
632
len: usize ,
631
633
) -> Result <usize > {
@@ -652,9 +654,9 @@ pub fn copy_file_range<Fd1: AsFd, Fd2: AsFd>(
652
654
653
655
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
654
656
pub fn splice<Fd1 : AsFd , Fd2 : AsFd >(
655
- fd_in: & Fd1 ,
657
+ fd_in: Fd1 ,
656
658
off_in: Option <& mut libc:: loff_t>,
657
- fd_out: & Fd2 ,
659
+ fd_out: Fd2 ,
658
660
off_out: Option <& mut libc:: loff_t>,
659
661
len: usize ,
660
662
flags: SpliceFFlags ,
@@ -681,8 +683,8 @@ pub fn splice<Fd1: AsFd, Fd2: AsFd>(
681
683
682
684
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
683
685
pub fn tee<Fd1 : AsFd , Fd2 : AsFd >(
684
- fd_in: & Fd1 ,
685
- fd_out: & Fd2 ,
686
+ fd_in: Fd1 ,
687
+ fd_out: Fd2 ,
686
688
len: usize ,
687
689
flags: SpliceFFlags ,
688
690
) -> Result <usize > {
@@ -699,7 +701,7 @@ pub fn tee<Fd1: AsFd, Fd2: AsFd>(
699
701
700
702
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
701
703
pub fn vmsplice<Fd : AsFd >(
702
- fd: & Fd ,
704
+ fd: Fd ,
703
705
iov: & [ std:: io:: IoSlice <' _>] ,
704
706
flags: SpliceFFlags ,
705
707
) -> Result <usize > {
@@ -758,7 +760,7 @@ feature! {
758
760
#[ cfg( any( target_os = "linux" ) ) ]
759
761
#[ cfg( feature = "fs" ) ]
760
762
pub fn fallocate<Fd : AsFd >(
761
- fd: & Fd ,
763
+ fd: Fd ,
762
764
mode: FallocateFlags ,
763
765
offset: libc:: off_t,
764
766
len: libc:: off_t,
@@ -834,7 +836,7 @@ impl SpacectlRange {
834
836
/// ```
835
837
#[ cfg( target_os = "freebsd" ) ]
836
838
pub fn fspacectl<Fd : AsFd >(
837
- fd: & Fd ,
839
+ fd: Fd ,
838
840
range: SpacectlRange ,
839
841
) -> Result <SpacectlRange > {
840
842
let mut rqsr = libc:: spacectl_range {
@@ -885,7 +887,7 @@ pub fn fspacectl<Fd: AsFd>(
885
887
/// ```
886
888
#[ cfg( target_os = "freebsd" ) ]
887
889
pub fn fspacectl_all<Fd : AsFd >(
888
- fd: & Fd ,
890
+ fd: Fd ,
889
891
offset: libc:: off_t,
890
892
len: libc:: off_t,
891
893
) -> Result <( ) > {
@@ -941,7 +943,7 @@ mod posix_fadvise {
941
943
feature! {
942
944
#![ feature = "fs" ]
943
945
pub fn posix_fadvise<Fd : AsFd >(
944
- fd: & Fd ,
946
+ fd: Fd ,
945
947
offset: libc:: off_t,
946
948
len: libc:: off_t,
947
949
advice: PosixFadviseAdvice ,
@@ -974,7 +976,7 @@ mod posix_fadvise {
974
976
target_os = "freebsd"
975
977
) ) ]
976
978
pub fn posix_fallocate<Fd : AsFd >(
977
- fd: & Fd ,
979
+ fd: Fd ,
978
980
offset: libc:: off_t,
979
981
len: libc:: off_t,
980
982
) -> Result <( ) > {
0 commit comments