Skip to content

Commit

Permalink
Add GNU/Hurd support
Browse files Browse the repository at this point in the history
  • Loading branch information
sthibaul committed Sep 29, 2023
1 parent f416b6b commit 8bd7f72
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/backend/libc/fs/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use crate::io;
#[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))]
use crate::process::fchdir;
use alloc::borrow::ToOwned;
#[cfg(not(linux_like))]
#[cfg(not(any(linux_like, target_os = "hurd")))]
use c::readdir as libc_readdir;
#[cfg(linux_like)]
#[cfg(any(linux_like, target_os = "hurd"))]
use c::readdir64 as libc_readdir;
use core::fmt;
use core::ptr::NonNull;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/libc/fs/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ weak!(fn __futimens64(c::c_int, *const LibcTimespec) -> c::c_int);
/// Use a direct syscall (via libc) for `openat`.
///
/// This is only currently necessary as a workaround for old glibc; see below.
#[cfg(all(unix, target_env = "gnu"))]
#[cfg(all(unix, target_env = "gnu", not(target_os = "hurd")))]
fn openat_via_syscall(
dirfd: BorrowedFd<'_>,
path: &CStr,
Expand Down Expand Up @@ -153,7 +153,7 @@ pub(crate) fn openat(
) -> io::Result<OwnedFd> {
// Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>.
// glibc versions before 2.25 don't handle `O_TMPFILE` correctly.
#[cfg(all(unix, target_env = "gnu"))]
#[cfg(all(unix, target_env = "gnu", not(target_os = "hurd")))]
if oflags.contains(OFlags::TMPFILE) && crate::backend::if_glibc_is_less_than_2_25() {
return openat_via_syscall(dirfd, path, oflags, mode);
}
Expand Down
11 changes: 10 additions & 1 deletion src/backend/libc/fs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ bitflags! {
target_os = "android",
target_os = "emscripten",
target_os = "fuchsia",
target_os = "hurd",
target_os = "linux",
))]
const TMPFILE = c::O_TMPFILE;
Expand Down Expand Up @@ -717,6 +718,7 @@ bitflags! {
bsd,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
target_os = "wasi",
)))]
const KEEP_SIZE = c::FALLOC_FL_KEEP_SIZE;
Expand All @@ -725,6 +727,7 @@ bitflags! {
bsd,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
target_os = "wasi",
)))]
const PUNCH_HOLE = c::FALLOC_FL_PUNCH_HOLE;
Expand All @@ -733,6 +736,7 @@ bitflags! {
bsd,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
target_os = "linux",
target_os = "emscripten",
target_os = "fuchsia",
Expand All @@ -744,6 +748,7 @@ bitflags! {
bsd,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
target_os = "emscripten",
target_os = "wasi",
)))]
Expand All @@ -753,6 +758,7 @@ bitflags! {
bsd,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
target_os = "emscripten",
target_os = "wasi",
)))]
Expand All @@ -762,6 +768,7 @@ bitflags! {
bsd,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
target_os = "emscripten",
target_os = "wasi",
)))]
Expand All @@ -771,6 +778,7 @@ bitflags! {
bsd,
target_os = "aix",
target_os = "haiku",
target_os = "hurd",
target_os = "emscripten",
target_os = "wasi",
)))]
Expand Down Expand Up @@ -844,7 +852,7 @@ pub enum FlockOperation {
///
/// [`statat`]: crate::fs::statat
/// [`fstat`]: crate::fs::fstat
#[cfg(not(linux_like))]
#[cfg(not(any(linux_like, target_os = "hurd")))]
pub type Stat = c::stat;

/// `struct stat` for use with [`statat`] and [`fstat`].
Expand All @@ -853,6 +861,7 @@ pub type Stat = c::stat;
/// [`fstat`]: crate::fs::fstat
#[cfg(any(
all(linux_kernel, target_pointer_width = "64"),
target_os = "hurd",
target_os = "emscripten",
target_os = "l4re",
))]
Expand Down
Loading

0 comments on commit 8bd7f72

Please sign in to comment.