Skip to content

Commit c0c3f01

Browse files
authored
Add GNU/Hurd support (#852)
1 parent f416b6b commit c0c3f01

File tree

9 files changed

+183
-31
lines changed

9 files changed

+183
-31
lines changed

src/backend/libc/fs/dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::io;
2020
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
2121
use crate::process::fchdir;
2222
use alloc::borrow::ToOwned;
23-
#[cfg(not(linux_like))]
23+
#[cfg(not(any(linux_like, target_os = "hurd")))]
2424
use c::readdir as libc_readdir;
25-
#[cfg(linux_like)]
25+
#[cfg(any(linux_like, target_os = "hurd"))]
2626
use c::readdir64 as libc_readdir;
2727
use core::fmt;
2828
use core::ptr::NonNull;

src/backend/libc/fs/syscalls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ weak!(fn __futimens64(c::c_int, *const LibcTimespec) -> c::c_int);
122122
/// Use a direct syscall (via libc) for `openat`.
123123
///
124124
/// This is only currently necessary as a workaround for old glibc; see below.
125-
#[cfg(all(unix, target_env = "gnu"))]
125+
#[cfg(all(unix, target_env = "gnu", not(target_os = "hurd")))]
126126
fn openat_via_syscall(
127127
dirfd: BorrowedFd<'_>,
128128
path: &CStr,
@@ -153,7 +153,7 @@ pub(crate) fn openat(
153153
) -> io::Result<OwnedFd> {
154154
// Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>.
155155
// glibc versions before 2.25 don't handle `O_TMPFILE` correctly.
156-
#[cfg(all(unix, target_env = "gnu"))]
156+
#[cfg(all(unix, target_env = "gnu", not(target_os = "hurd")))]
157157
if oflags.contains(OFlags::TMPFILE) && crate::backend::if_glibc_is_less_than_2_25() {
158158
return openat_via_syscall(dirfd, path, oflags, mode);
159159
}

src/backend/libc/fs/types.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ bitflags! {
274274
target_os = "android",
275275
target_os = "emscripten",
276276
target_os = "fuchsia",
277+
target_os = "hurd",
277278
target_os = "linux",
278279
))]
279280
const TMPFILE = c::O_TMPFILE;
@@ -717,6 +718,7 @@ bitflags! {
717718
bsd,
718719
target_os = "aix",
719720
target_os = "haiku",
721+
target_os = "hurd",
720722
target_os = "wasi",
721723
)))]
722724
const KEEP_SIZE = c::FALLOC_FL_KEEP_SIZE;
@@ -725,6 +727,7 @@ bitflags! {
725727
bsd,
726728
target_os = "aix",
727729
target_os = "haiku",
730+
target_os = "hurd",
728731
target_os = "wasi",
729732
)))]
730733
const PUNCH_HOLE = c::FALLOC_FL_PUNCH_HOLE;
@@ -733,6 +736,7 @@ bitflags! {
733736
bsd,
734737
target_os = "aix",
735738
target_os = "haiku",
739+
target_os = "hurd",
736740
target_os = "linux",
737741
target_os = "emscripten",
738742
target_os = "fuchsia",
@@ -744,6 +748,7 @@ bitflags! {
744748
bsd,
745749
target_os = "aix",
746750
target_os = "haiku",
751+
target_os = "hurd",
747752
target_os = "emscripten",
748753
target_os = "wasi",
749754
)))]
@@ -753,6 +758,7 @@ bitflags! {
753758
bsd,
754759
target_os = "aix",
755760
target_os = "haiku",
761+
target_os = "hurd",
756762
target_os = "emscripten",
757763
target_os = "wasi",
758764
)))]
@@ -762,6 +768,7 @@ bitflags! {
762768
bsd,
763769
target_os = "aix",
764770
target_os = "haiku",
771+
target_os = "hurd",
765772
target_os = "emscripten",
766773
target_os = "wasi",
767774
)))]
@@ -771,6 +778,7 @@ bitflags! {
771778
bsd,
772779
target_os = "aix",
773780
target_os = "haiku",
781+
target_os = "hurd",
774782
target_os = "emscripten",
775783
target_os = "wasi",
776784
)))]
@@ -844,7 +852,7 @@ pub enum FlockOperation {
844852
///
845853
/// [`statat`]: crate::fs::statat
846854
/// [`fstat`]: crate::fs::fstat
847-
#[cfg(not(linux_like))]
855+
#[cfg(not(any(linux_like, target_os = "hurd")))]
848856
pub type Stat = c::stat;
849857

850858
/// `struct stat` for use with [`statat`] and [`fstat`].
@@ -853,6 +861,7 @@ pub type Stat = c::stat;
853861
/// [`fstat`]: crate::fs::fstat
854862
#[cfg(any(
855863
all(linux_kernel, target_pointer_width = "64"),
864+
target_os = "hurd",
856865
target_os = "emscripten",
857866
target_os = "l4re",
858867
))]

0 commit comments

Comments
 (0)