Skip to content

Commit cd573b1

Browse files
redox: Unmask most of fs, some of time
Redox supports most of the *at functions as well as some of the `time` header.
1 parent 287214b commit cd573b1

26 files changed

Lines changed: 48 additions & 120 deletions

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ rustc-std-workspace-alloc = { version = "1.0.0", optional = true } # not aliased
3535
[target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", any(target_endian = "little", any(target_arch = "s390x", target_arch = "powerpc")), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc"), all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))'.dependencies]
3636
linux-raw-sys = { version = "0.12", default-features = false, features = ["auxvec", "general", "errno", "ioctl", "no_std", "elf"] }
3737
libc_errno = { package = "errno", version = "0.3.10", default-features = false, optional = true }
38-
libc = { version = "0.2.182", default-features = false, optional = true }
38+
libc = { version = "0.2.189", default-features = false, optional = true }
3939

4040
# Dependencies for platforms where only libc is supported:
4141
#
4242
# On all other Unix-family platforms, and under Miri, we always use the libc
4343
# backend, so enable its dependencies unconditionally.
4444
[target.'cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_endian = "little", any(target_arch = "s390x", target_arch = "powerpc")), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc"), all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies]
4545
libc_errno = { package = "errno", version = "0.3.10", default-features = false }
46-
libc = { version = "0.2.182", default-features = false }
46+
libc = { version = "0.2.189", default-features = false }
4747

4848
# Additional dependencies for Linux and Android with the libc backend:
4949
#
@@ -69,7 +69,7 @@ default-features = false
6969

7070
[dev-dependencies]
7171
tempfile = "3.5.0"
72-
libc = "0.2.171"
72+
libc = "0.2.189"
7373
libc_errno = { package = "errno", version = "0.3.10", default-features = false }
7474
serial_test = "2.0.0"
7575
memoffset = "0.9.0"

src/backend/libc/conv.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ pub(super) fn borrowed_fd(fd: BorrowedFd<'_>) -> LibcFd {
3838

3939
#[cfg(all(
4040
feature = "alloc",
41-
not(any(
42-
windows,
43-
target_os = "espidf",
44-
target_os = "horizon",
45-
target_os = "redox"
46-
))
41+
not(any(windows, target_os = "espidf", target_os = "horizon"))
4742
))]
4843
#[inline]
4944
pub(super) fn owned_fd(fd: OwnedFd) -> LibcFd {

src/backend/libc/event/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "illumos"))]
1+
#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "illumos",))]
22
use crate::backend::c;
33
#[cfg(any(
44
linux_kernel,
55
target_os = "freebsd",
66
target_os = "illumos",
7-
target_os = "espidf"
7+
target_os = "espidf",
88
))]
99
use bitflags::bitflags;
1010

1111
#[cfg(any(
1212
linux_kernel,
1313
target_os = "freebsd",
1414
target_os = "illumos",
15-
target_os = "espidf"
15+
target_os = "espidf",
1616
))]
1717
bitflags! {
1818
/// `EFD_*` flags for use with [`eventfd`].

src/backend/libc/fs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(all(
22
feature = "alloc",
3-
not(any(target_os = "espidf", target_os = "horizon", target_os = "redox"))
3+
not(any(target_os = "espidf", target_os = "horizon"))
44
))]
55
pub(crate) mod dir;
66
#[cfg(linux_kernel)]

src/backend/libc/fs/syscalls.rs

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! libc syscalls supporting `rustix::fs`.
22
33
use crate::backend::c;
4-
#[cfg(any(not(target_os = "redox"), feature = "alloc"))]
5-
use crate::backend::conv::ret_usize;
6-
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd};
4+
use crate::backend::conv::{
5+
borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd, ret_usize,
6+
};
77
use crate::fd::{BorrowedFd, OwnedFd};
88
#[allow(unused_imports)]
99
use crate::ffi;
@@ -12,7 +12,7 @@ use crate::ffi::CStr;
1212
use crate::ffi::CString;
1313
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
1414
use crate::fs::Access;
15-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
15+
#[cfg(not(target_os = "espidf"))]
1616
use crate::fs::AtFlags;
1717
#[cfg(not(any(
1818
netbsdlike,
@@ -55,7 +55,6 @@ use crate::fs::Timestamps;
5555
apple,
5656
target_os = "espidf",
5757
target_os = "horizon",
58-
target_os = "redox",
5958
target_os = "vita",
6059
target_os = "wasi"
6160
)))]
@@ -206,7 +205,6 @@ fn openat_via_syscall(
206205
}
207206
}
208207

209-
#[cfg(not(target_os = "redox"))]
210208
pub(crate) fn openat(
211209
dirfd: BorrowedFd<'_>,
212210
path: &CStr,
@@ -288,7 +286,6 @@ pub(crate) fn readlink(path: &CStr, buf: &mut [u8]) -> io::Result<usize> {
288286
unsafe { ret_usize(c::readlink(c_str(path), buf.as_mut_ptr().cast(), buf.len()) as isize) }
289287
}
290288

291-
#[cfg(not(target_os = "redox"))]
292289
#[inline]
293290
pub(crate) unsafe fn readlinkat(
294291
dirfd: BorrowedFd<'_>,
@@ -302,7 +299,6 @@ pub(crate) fn mkdir(path: &CStr, mode: Mode) -> io::Result<()> {
302299
unsafe { ret(c::mkdir(c_str(path), mode.bits() as c::mode_t)) }
303300
}
304301

305-
#[cfg(not(target_os = "redox"))]
306302
pub(crate) fn mkdirat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Result<()> {
307303
unsafe {
308304
ret(c::mkdirat(
@@ -338,7 +334,7 @@ pub(crate) fn link(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
338334
unsafe { ret(c::link(c_str(old_path), c_str(new_path))) }
339335
}
340336

341-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
337+
#[cfg(not(target_os = "espidf"))]
342338
pub(crate) fn linkat(
343339
old_dirfd: BorrowedFd<'_>,
344340
old_path: &CStr,
@@ -401,7 +397,7 @@ pub(crate) fn unlink(path: &CStr) -> io::Result<()> {
401397
unsafe { ret(c::unlink(c_str(path))) }
402398
}
403399

404-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
400+
#[cfg(not(target_os = "espidf"))]
405401
pub(crate) fn unlinkat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<()> {
406402
// macOS ≤ 10.9 lacks `unlinkat`.
407403
#[cfg(target_os = "macos")]
@@ -628,7 +624,6 @@ pub(crate) fn symlink(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
628624
unsafe { ret(c::symlink(c_str(old_path), c_str(new_path))) }
629625
}
630626

631-
#[cfg(not(target_os = "redox"))]
632627
pub(crate) fn symlinkat(
633628
old_path: &CStr,
634629
new_dirfd: BorrowedFd<'_>,
@@ -730,7 +725,7 @@ pub(crate) fn lstat(path: &CStr) -> io::Result<Stat> {
730725
}
731726
}
732727

733-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
728+
#[cfg(not(target_os = "espidf"))]
734729
pub(crate) fn statat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<Stat> {
735730
// See the comments in `fstat` about using `crate::fs::statx` here.
736731
#[cfg(all(
@@ -812,7 +807,6 @@ pub(crate) fn access(path: &CStr, access: Access) -> io::Result<()> {
812807
target_os = "emscripten",
813808
target_os = "espidf",
814809
target_os = "horizon",
815-
target_os = "redox",
816810
target_os = "vita"
817811
)))]
818812
pub(crate) fn accessat(
@@ -880,12 +874,7 @@ pub(crate) fn accessat(
880874
Ok(())
881875
}
882876

883-
#[cfg(not(any(
884-
target_os = "espidf",
885-
target_os = "horizon",
886-
target_os = "redox",
887-
target_os = "vita"
888-
)))]
877+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
889878
pub(crate) fn utimensat(
890879
dirfd: BorrowedFd<'_>,
891880
path: &CStr,
@@ -1102,12 +1091,7 @@ pub(crate) fn chmod(path: &CStr, mode: Mode) -> io::Result<()> {
11021091
unsafe { ret(c::chmod(c_str(path), mode.bits() as c::mode_t)) }
11031092
}
11041093

1105-
#[cfg(not(any(
1106-
linux_kernel,
1107-
target_os = "espidf",
1108-
target_os = "redox",
1109-
target_os = "wasi"
1110-
)))]
1094+
#[cfg(not(any(linux_kernel, target_os = "espidf", target_os = "wasi")))]
11111095
pub(crate) fn chmodat(
11121096
dirfd: BorrowedFd<'_>,
11131097
path: &CStr,
@@ -1185,7 +1169,7 @@ pub(crate) fn fclonefileat(
11851169
}
11861170
}
11871171

1188-
#[cfg(not(any(target_os = "espidf", target_os = "redox", target_os = "wasi")))]
1172+
#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
11891173
pub(crate) fn chownat(
11901174
dirfd: BorrowedFd<'_>,
11911175
path: &CStr,
@@ -1209,7 +1193,6 @@ pub(crate) fn chownat(
12091193
apple,
12101194
target_os = "espidf",
12111195
target_os = "horizon",
1212-
target_os = "redox",
12131196
target_os = "vita",
12141197
target_os = "wasi"
12151198
)))]

src/backend/libc/fs/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bitflags! {
2828
}
2929
}
3030

31-
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "redox")))]
31+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
3232
bitflags! {
3333
/// `AT_*` constants for use with [`openat`], [`statat`], and other `*at`
3434
/// functions.
@@ -630,7 +630,6 @@ impl FileType {
630630
target_os = "haiku",
631631
target_os = "horizon",
632632
target_os = "nto",
633-
target_os = "redox",
634633
target_os = "vita"
635634
)))]
636635
#[inline]

src/backend/libc/io/syscalls.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ pub(crate) fn writev(fd: BorrowedFd<'_>, bufs: &[IoSlice<'_>]) -> io::Result<usi
9999
target_os = "haiku",
100100
target_os = "horizon",
101101
target_os = "nto",
102-
target_os = "redox",
103102
target_os = "solaris",
104103
target_os = "vita",
105104
)))]
@@ -130,7 +129,6 @@ pub(crate) fn preadv(
130129
target_os = "haiku",
131130
target_os = "nto",
132131
target_os = "horizon",
133-
target_os = "redox",
134132
target_os = "solaris",
135133
target_os = "vita",
136134
)))]

src/backend/libc/thread/syscalls.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ use crate::pid::Pid;
1414
target_os = "espidf",
1515
target_os = "haiku",
1616
target_os = "horizon",
17-
target_os = "openbsd",
1817
target_os = "redox",
18+
target_os = "openbsd",
1919
target_os = "vita",
2020
target_os = "wasi",
2121
)))]
2222
use crate::thread::ClockId;
2323
#[cfg(linux_kernel)]
2424
use crate::thread::{Cpuid, MembarrierCommand, MembarrierQuery};
25-
#[cfg(not(target_os = "redox"))]
2625
use crate::thread::{NanosleepRelativeResult, Timespec};
2726
#[cfg(all(target_env = "gnu", fix_y2038))]
2827
use crate::timespec::LibcTimespec;
@@ -53,9 +52,9 @@ weak!(fn __nanosleep64(*const LibcTimespec, *mut LibcTimespec) -> c::c_int);
5352
target_os = "espidf",
5453
target_os = "freebsd", // FreeBSD 12 has clock_nanosleep, but libc targets FreeBSD 11.
5554
target_os = "haiku",
55+
target_os = "redox",
5656
target_os = "horizon",
5757
target_os = "openbsd",
58-
target_os = "redox",
5958
target_os = "vita",
6059
target_os = "wasi",
6160
)))]
@@ -244,7 +243,6 @@ fn clock_nanosleep_absolute_old(id: crate::clockid::ClockId, request: &Timespec)
244243
}
245244
}
246245

247-
#[cfg(not(target_os = "redox"))]
248246
#[inline]
249247
pub(crate) fn nanosleep(request: &Timespec) -> NanosleepRelativeResult {
250248
// Old 32-bit version: libc has `nanosleep` but it is not y2038 safe by

src/backend/libc/time/syscalls.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ use crate::io;
1717
#[cfg(not(fix_y2038))]
1818
use crate::timespec::as_libc_timespec_mut_ptr;
1919
#[cfg(not(fix_y2038))]
20-
#[cfg(not(any(
21-
target_os = "redox",
22-
target_os = "wasi",
23-
all(apple, not(target_os = "macos"))
24-
)))]
20+
#[cfg(not(any(target_os = "wasi", all(apple, not(target_os = "macos")))))]
2521
use crate::timespec::as_libc_timespec_ptr;
2622
#[cfg(all(target_env = "gnu", fix_y2038))]
2723
use crate::timespec::LibcTimespec;
@@ -53,7 +49,7 @@ weak!(fn __timerfd_gettime64(c::c_int, *mut LibcItimerspec) -> c::c_int);
5349
#[cfg(all(target_env = "gnu", fix_y2038))]
5450
weak!(fn __timerfd_settime64(c::c_int, c::c_int, *const LibcItimerspec, *mut LibcItimerspec) -> c::c_int);
5551

56-
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
52+
#[cfg(not(target_os = "wasi"))]
5753
#[inline]
5854
#[must_use]
5955
pub(crate) fn clock_getres(id: ClockId) -> Timespec {
@@ -292,11 +288,7 @@ pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
292288
}
293289
}
294290

295-
#[cfg(not(any(
296-
target_os = "redox",
297-
target_os = "wasi",
298-
all(apple, not(target_os = "macos"))
299-
)))]
291+
#[cfg(not(any(target_os = "wasi", all(apple, not(target_os = "macos")))))]
300292
#[cfg(fix_y2038)]
301293
fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
302294
let old_timespec = c::timespec {
@@ -315,7 +307,7 @@ fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
315307
target_os = "freebsd",
316308
target_os = "fuchsia",
317309
target_os = "illumos",
318-
target_os = "netbsd"
310+
target_os = "netbsd",
319311
))]
320312
pub(crate) fn timerfd_create(id: TimerfdClockId, flags: TimerfdFlags) -> io::Result<OwnedFd> {
321313
unsafe { ret_owned_fd(c::timerfd_create(id as c::clockid_t, bitflags_bits!(flags))) }
@@ -484,7 +476,8 @@ pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
484476
target_os = "freebsd",
485477
target_os = "fuchsia",
486478
target_os = "illumos",
487-
target_os = "netbsd"
479+
target_os = "netbsd",
480+
target_os = "redox"
488481
))]
489482
#[cfg(fix_y2038)]
490483
fn timerfd_gettime_old(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {

src/event/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub use crate::timespec::{Nsecs, Secs, Timespec};
2424
linux_kernel,
2525
target_os = "freebsd",
2626
target_os = "illumos",
27-
target_os = "espidf"
27+
target_os = "espidf",
2828
))]
2929
pub use eventfd::{eventfd, EventfdFlags};
3030
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]

0 commit comments

Comments
 (0)