@@ -12,12 +12,14 @@ use cap_primitives::fs::FileType;
12
12
use cap_std:: fs:: { Dir , File , Metadata } ;
13
13
use cap_tempfile:: cap_std;
14
14
use cap_tempfile:: cap_std:: fs:: DirEntry ;
15
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
15
16
use rustix:: path:: Arg ;
16
17
use std:: cmp:: Ordering ;
17
18
use std:: ffi:: OsStr ;
18
19
use std:: io:: Result ;
19
20
use std:: io:: { self , Write } ;
20
21
use std:: ops:: Deref ;
22
+ #[ cfg( unix) ]
21
23
use std:: os:: fd:: OwnedFd ;
22
24
use std:: path:: { Path , PathBuf } ;
23
25
@@ -447,6 +449,7 @@ fn subdir_of<'d, 'p>(d: &'d Dir, p: &'p Path) -> io::Result<(DirOwnedOrBorrowed<
447
449
Ok ( ( r, name) )
448
450
}
449
451
452
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
450
453
/// A thin wrapper for [`openat2`] but that retries on interruption.
451
454
fn openat2_with_retry (
452
455
dirfd : impl std:: os:: fd:: AsFd ,
@@ -474,6 +477,7 @@ fn openat2_with_retry(
474
477
} )
475
478
}
476
479
480
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
477
481
fn is_mountpoint_impl_statx ( root : & Dir , path : & Path ) -> Result < Option < bool > > {
478
482
// https://github.com/systemd/systemd/blob/8fbf0a214e2fe474655b17a4b663122943b55db0/src/basic/mountpoint-util.c#L176
479
483
use rustix:: fs:: StatxAttributes ;
@@ -577,6 +581,7 @@ where
577
581
debug_assert ! ( matches!( flow, std:: ops:: ControlFlow :: Continue ( ( ) ) ) ) ;
578
582
// Open the child directory, using the noxdev API if
579
583
// we're configured not to cross devices,
584
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
580
585
let d = {
581
586
if !config. noxdev {
582
587
entry. open_dir ( ) ?
@@ -587,6 +592,10 @@ where
587
592
continue ;
588
593
}
589
594
} ;
595
+
596
+ #[ cfg( not( any( target_os = "android" , target_os = "linux" ) ) ) ]
597
+ let d = entry. open_dir ( ) ?;
598
+
590
599
// Recurse into the target directory
591
600
walk_inner ( & d, path, callback, config) ?;
592
601
path. pop ( ) ;
@@ -784,6 +793,7 @@ impl CapStdExtDirExt for Dir {
784
793
. map_err ( Into :: into)
785
794
}
786
795
796
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
787
797
fn is_mountpoint ( & self , path : impl AsRef < Path > ) -> Result < Option < bool > > {
788
798
is_mountpoint_impl_statx ( self , path. as_ref ( ) ) . map_err ( Into :: into)
789
799
}
0 commit comments