Skip to content

Commit 224daf0

Browse files
authored
Enable fstatvfs for Haiku (#1493)
* fstatvfs is available on Haiku It is available in Haiku since 2005. Not sure why it was disabled in Rustix. * Make tests pass on Haiku fionread on a file returns a "Not a tty" error.
1 parent 6f86d18 commit 224daf0

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

src/backend/libc/fs/dir.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ use crate::fs::{fstat, Stat};
2424
target_os = "wasi",
2525
)))]
2626
use crate::fs::{fstatfs, StatFs};
27-
#[cfg(not(any(
28-
solarish,
29-
target_os = "haiku",
30-
target_os = "redox",
31-
target_os = "vita",
32-
target_os = "wasi"
33-
)))]
27+
#[cfg(not(any(solarish, target_os = "redox", target_os = "vita", target_os = "wasi")))]
3428
use crate::fs::{fstatvfs, StatVfs};
3529
use crate::io;
3630
#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
@@ -243,7 +237,6 @@ impl Dir {
243237
/// `fstatvfs(self)`
244238
#[cfg(not(any(
245239
solarish,
246-
target_os = "haiku",
247240
target_os = "horizon",
248241
target_os = "redox",
249242
target_os = "vita",

src/backend/libc/fs/syscalls.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use crate::fs::Timestamps;
6060
)))]
6161
use crate::fs::{Dev, FileType};
6262
use crate::fs::{Mode, OFlags, SeekFrom, Stat};
63-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
63+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
6464
use crate::fs::{StatVfs, StatVfsMountFlags};
6565
use crate::io;
6666
#[cfg(all(target_env = "gnu", fix_y2038))]
@@ -271,7 +271,7 @@ pub(crate) fn statfs(filename: &CStr) -> io::Result<StatFs> {
271271
}
272272
}
273273

274-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
274+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
275275
#[inline]
276276
pub(crate) fn statvfs(filename: &CStr) -> io::Result<StatVfs> {
277277
unsafe {
@@ -1591,7 +1591,7 @@ pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
15911591
}
15921592
}
15931593

1594-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
1594+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
15951595
pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
15961596
let mut statvfs = MaybeUninit::<c::statvfs>::uninit();
15971597
unsafe {
@@ -1600,7 +1600,7 @@ pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
16001600
}
16011601
}
16021602

1603-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
1603+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
16041604
fn libc_statvfs_to_statvfs(from: c::statvfs) -> StatVfs {
16051605
StatVfs {
16061606
f_bsize: from.f_bsize as u64,

src/backend/libc/fs/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ bitflags! {
845845
}
846846
}
847847

848-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
848+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
849849
bitflags! {
850850
/// `ST_*` constants for use with [`StatVfs`].
851851
#[repr(transparent)]
@@ -877,11 +877,11 @@ bitflags! {
877877
const NOEXEC = c::ST_NOEXEC as u64;
878878

879879
/// `ST_NOSUID`
880-
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
880+
#[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "horizon", target_os = "vita")))]
881881
const NOSUID = c::ST_NOSUID as u64;
882882

883883
/// `ST_RDONLY`
884-
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
884+
#[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "horizon", target_os = "vita")))]
885885
const RDONLY = c::ST_RDONLY as u64;
886886

887887
/// `ST_RELATIME`
@@ -1077,7 +1077,7 @@ pub type Fsid = c::fsid_t;
10771077
///
10781078
/// [`statvfs`]: crate::fs::statvfs
10791079
/// [`fstatvfs`]: crate::fs::fstatvfs
1080-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
1080+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
10811081
#[allow(missing_docs)]
10821082
pub struct StatVfs {
10831083
pub f_bsize: u64,

src/fs/fd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use backend::fs::types::Stat;
4040
target_os = "wasi",
4141
)))]
4242
use backend::fs::types::StatFs;
43-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
43+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
4444
use backend::fs::types::StatVfs;
4545

4646
/// Timestamps used by [`utimensat`] and [`futimens`].
@@ -196,7 +196,7 @@ pub fn fstatfs<Fd: AsFd>(fd: Fd) -> io::Result<StatFs> {
196196
///
197197
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/fstatvfs.html
198198
/// [Linux]: https://man7.org/linux/man-pages/man2/fstatvfs.2.html
199-
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
199+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
200200
#[inline]
201201
pub fn fstatvfs<Fd: AsFd>(fd: Fd) -> io::Result<StatVfs> {
202202
backend::fs::syscalls::fstatvfs(fd.as_fd())

tests/io/ioctl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// `ioctl_fionread` on Windows doesn't work on files.
2-
#[cfg(not(any(windows, target_os = "cygwin")))]
2+
#[cfg(not(any(windows, target_os = "cygwin", target_os = "haiku")))]
33
#[test]
44
fn test_ioctls() {
55
let file = std::fs::File::open("Cargo.toml").unwrap();

0 commit comments

Comments
 (0)