@@ -13,7 +13,6 @@ use std::ffi::CStr;
13
13
use std:: ffi:: OsString ;
14
14
#[ cfg( not( any( target_os = "redox" , target_os = "solaris" ) ) ) ]
15
15
use std:: ops:: { Deref , DerefMut } ;
16
- use std:: os:: fd:: BorrowedFd ;
17
16
#[ cfg( not( target_os = "redox" ) ) ]
18
17
use std:: os:: raw;
19
18
use std:: os:: unix:: ffi:: OsStringExt ;
@@ -30,9 +29,6 @@ use std::path::PathBuf;
30
29
#[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
31
30
use std:: ptr;
32
31
33
- #[ cfg( feature = "fs" ) ]
34
- use std:: os:: fd:: FromRawFd ;
35
-
36
32
#[ cfg( feature = "fs" ) ]
37
33
use crate :: { sys:: stat:: Mode , NixPath , Result } ;
38
34
@@ -54,8 +50,8 @@ pub use self::posix_fadvise::{posix_fadvise, PosixFadviseAdvice};
54
50
// 2. It is not a valid file descriptor, but OS will handle it for us when passed
55
51
// to `xxat(2)` calls.
56
52
#[ cfg( not( target_os = "redox" ) ) ] // Redox does not have this
57
- pub const AT_FDCWD : BorrowedFd < ' static > =
58
- unsafe { BorrowedFd :: borrow_raw ( libc:: AT_FDCWD ) } ;
53
+ pub const AT_FDCWD : std :: os :: fd :: BorrowedFd < ' static > =
54
+ unsafe { std :: os :: fd :: BorrowedFd :: borrow_raw ( libc:: AT_FDCWD ) } ;
59
55
60
56
#[ cfg( not( target_os = "redox" ) ) ]
61
57
#[ cfg( any( feature = "fs" , feature = "process" , feature = "user" ) ) ]
@@ -235,7 +231,9 @@ pub fn open<P: ?Sized + NixPath>(
235
231
path: & P ,
236
232
oflag: OFlag ,
237
233
mode: Mode ,
238
- ) -> Result <OwnedFd > {
234
+ ) -> Result <std:: os:: fd:: OwnedFd > {
235
+ use std:: os:: fd:: FromRawFd ;
236
+
239
237
let fd = path. with_nix_path( |cstr| unsafe {
240
238
libc:: open( cstr. as_ptr( ) , oflag. bits( ) , mode. bits( ) as c_uint)
241
239
} ) ?;
@@ -244,7 +242,7 @@ pub fn open<P: ?Sized + NixPath>(
244
242
// SAFETY:
245
243
//
246
244
// `open(2)` should return a valid owned fd on success
247
- Ok ( unsafe { OwnedFd :: from_raw_fd( fd) } )
245
+ Ok ( unsafe { std :: os :: fd :: OwnedFd :: from_raw_fd( fd) } )
248
246
}
249
247
250
248
/// open or create a file for reading, writing or executing
@@ -265,6 +263,7 @@ pub fn openat<P: ?Sized + NixPath, Fd: std::os::fd::AsFd>(
265
263
mode: Mode ,
266
264
) -> Result <OwnedFd > {
267
265
use std:: os:: fd:: AsRawFd ;
266
+ use std:: os:: fd:: FromRawFd ;
268
267
269
268
let fd = path. with_nix_path( |cstr| unsafe {
270
269
libc:: openat( dirfd. as_fd( ) . as_raw_fd( ) , cstr. as_ptr( ) , oflag. bits( ) , mode. bits( ) as c_uint)
@@ -1350,7 +1349,7 @@ impl SpacectlRange {
1350
1349
/// f.write_all(INITIAL).unwrap();
1351
1350
/// let mut range = SpacectlRange(3, 6);
1352
1351
/// while (!range.is_empty()) {
1353
- /// range = fspacectl(f.as_raw_fd() , range).unwrap();
1352
+ /// range = fspacectl(&f , range).unwrap();
1354
1353
/// }
1355
1354
/// let mut buf = vec![0; INITIAL.len()];
1356
1355
/// f.read_exact_at(&mut buf, 0).unwrap();
@@ -1402,7 +1401,7 @@ pub fn fspacectl<Fd: std::os::fd::AsFd>(fd: Fd, range: SpacectlRange) -> Result<
1402
1401
/// const INITIAL: &[u8] = b"0123456789abcdef";
1403
1402
/// let mut f = tempfile().unwrap();
1404
1403
/// f.write_all(INITIAL).unwrap();
1405
- /// fspacectl_all(f.as_raw_fd() , 3, 6).unwrap();
1404
+ /// fspacectl_all(&f. , 3, 6).unwrap();
1406
1405
/// let mut buf = vec![0; INITIAL.len()];
1407
1406
/// f.read_exact_at(&mut buf, 0).unwrap();
1408
1407
/// assert_eq!(buf, b"012\0\0\0\0\0\09abcdef");
0 commit comments