|
4 | 4 | use crate::fs::Mode; |
5 | 5 | #[cfg(not(target_os = "wasi"))] |
6 | 6 | use crate::fs::{Gid, Uid}; |
7 | | -use crate::fs::{OFlags, SeekFrom, Timespec}; |
| 7 | +use crate::fs::{SeekFrom, Timespec}; |
8 | 8 | use crate::{backend, io}; |
9 | | -use backend::fd::{AsFd, BorrowedFd}; |
| 9 | +use backend::fd::AsFd; |
10 | 10 | #[cfg(not(any( |
11 | 11 | netbsdlike, |
12 | 12 | target_os = "dragonfly", |
@@ -127,6 +127,7 @@ pub fn tell<Fd: AsFd>(fd: Fd) -> io::Result<u64> { |
127 | 127 | /// |
128 | 128 | /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/fchmod.html |
129 | 129 | /// [Linux]: https://man7.org/linux/man-pages/man2/fchmod.2.html |
| 130 | +/// [`OFlags::PATH`]: crate::fs::OFlags::PATH |
130 | 131 | #[cfg(not(target_os = "wasi"))] |
131 | 132 | #[inline] |
132 | 133 | pub fn fchmod<Fd: AsFd>(fd: Fd, mode: Mode) -> io::Result<()> { |
@@ -252,36 +253,6 @@ pub fn fallocate<Fd: AsFd>(fd: Fd, mode: FallocateFlags, offset: u64, len: u64) |
252 | 253 | backend::fs::syscalls::fallocate(fd.as_fd(), mode, offset, len) |
253 | 254 | } |
254 | 255 |
|
255 | | -/// `fcntl(fd, F_GETFL) & O_ACCMODE` |
256 | | -/// |
257 | | -/// Returns a pair of booleans indicating whether the file descriptor is |
258 | | -/// readable and/or writable, respectively. This is only reliable on files; for |
259 | | -/// example, it doesn't reflect whether sockets have been shut down; for |
260 | | -/// general I/O handle support, use [`io::is_read_write`]. |
261 | | -#[inline] |
262 | | -pub fn is_file_read_write<Fd: AsFd>(fd: Fd) -> io::Result<(bool, bool)> { |
263 | | - _is_file_read_write(fd.as_fd()) |
264 | | -} |
265 | | - |
266 | | -pub(crate) fn _is_file_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)> { |
267 | | - let mode = backend::fs::syscalls::fcntl_getfl(fd)?; |
268 | | - |
269 | | - // Check for `O_PATH`. |
270 | | - #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))] |
271 | | - if mode.contains(OFlags::PATH) { |
272 | | - return Ok((false, false)); |
273 | | - } |
274 | | - |
275 | | - // Use `RWMODE` rather than `ACCMODE` as `ACCMODE` may include `O_PATH`. |
276 | | - // We handled `O_PATH` above. |
277 | | - match mode & OFlags::RWMODE { |
278 | | - OFlags::RDONLY => Ok((true, false)), |
279 | | - OFlags::RDWR => Ok((true, true)), |
280 | | - OFlags::WRONLY => Ok((false, true)), |
281 | | - _ => unreachable!(), |
282 | | - } |
283 | | -} |
284 | | - |
285 | 256 | /// `fsync(fd)`—Ensures that file data and metadata is written to the |
286 | 257 | /// underlying storage device. |
287 | 258 | /// |
|
0 commit comments