Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/backend/libc/fs/makedev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::fs::Dev;
target_os = "aix",
target_os = "android",
target_os = "emscripten",
target_os = "redox",
)))]
#[inline]
pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
Expand Down Expand Up @@ -44,6 +45,17 @@ pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
| (u64::from(min) & 0x0000_00ff_u64)
}

#[cfg(target_os = "redox")]
#[inline]
pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
// Redox's makedev is reportedly similar to 32-bit Android's but the return
// type is signed.
((i64::from(maj) & 0xffff_f000_i64) << 32)
| ((i64::from(maj) & 0x0000_0fff_i64) << 8)
| ((i64::from(min) & 0xffff_ff00_i64) << 12)
| (i64::from(min) & 0x0000_00ff_i64)
}

#[cfg(target_os = "emscripten")]
#[inline]
pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
Expand All @@ -70,7 +82,8 @@ pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
freebsdlike,
target_os = "android",
target_os = "emscripten",
target_os = "netbsd"
target_os = "netbsd",
target_os = "redox"
)))]
#[inline]
pub(crate) fn major(dev: Dev) -> u32 {
Expand All @@ -89,7 +102,10 @@ pub(crate) fn major(dev: Dev) -> u32 {
(unsafe { c::major(dev) }) as u32
}

#[cfg(all(target_os = "android", target_pointer_width = "32"))]
#[cfg(any(
all(target_os = "android", target_pointer_width = "32"),
target_os = "redox"
))]
#[inline]
pub(crate) fn major(dev: Dev) -> u32 {
// 32-bit Android's `dev_t` is 32-bit, but its `st_dev` is 64-bit, so we do
Expand All @@ -109,7 +125,8 @@ pub(crate) fn major(dev: Dev) -> u32 {
freebsdlike,
target_os = "android",
target_os = "emscripten",
target_os = "netbsd"
target_os = "netbsd",
target_os = "redox",
)))]
#[inline]
pub(crate) fn minor(dev: Dev) -> u32 {
Expand All @@ -128,7 +145,10 @@ pub(crate) fn minor(dev: Dev) -> u32 {
(unsafe { c::minor(dev) }) as u32
}

#[cfg(all(target_os = "android", target_pointer_width = "32"))]
#[cfg(any(
all(target_os = "android", target_pointer_width = "32"),
target_os = "redox"
))]
#[inline]
pub(crate) fn minor(dev: Dev) -> u32 {
// 32-bit Android's `dev_t` is 32-bit, but its `st_dev` is 64-bit, so we do
Expand Down
1 change: 0 additions & 1 deletion src/backend/libc/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub mod inotify;
target_os = "espidf",
target_os = "haiku",
target_os = "horizon",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
Expand Down
2 changes: 0 additions & 2 deletions src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ mod ioctl;
target_os = "espidf",
target_os = "haiku",
target_os = "horizon",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
Expand Down Expand Up @@ -103,7 +102,6 @@ pub use ioctl::*;
target_os = "espidf",
target_os = "haiku",
target_os = "horizon",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
Expand Down
8 changes: 4 additions & 4 deletions src/ioctl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ use crate::fd::{AsFd, BorrowedFd};
use crate::ffi as c;
use crate::io::Result;

#[cfg(any(linux_kernel, bsd))]
#[cfg(any(linux_kernel, bsd, target_os = "redox"))]
use core::mem;

pub use patterns::*;

mod patterns;

#[cfg(linux_kernel)]
#[cfg(any(linux_kernel, target_os = "redox"))]
mod linux;

#[cfg(bsd)]
mod bsd;

#[cfg(linux_kernel)]
#[cfg(any(linux_kernel, target_os = "redox"))]
use linux as platform;

#[cfg(bsd)]
Expand Down Expand Up @@ -198,7 +198,7 @@ pub unsafe trait Ioctl {
///
/// If you're writing a driver and defining your own ioctl numbers, it's
/// recommended to use these functions to compute them.
#[cfg(any(linux_kernel, bsd))]
#[cfg(any(linux_kernel, bsd, target_os = "redox"))]
pub mod opcode {
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/fs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod invalid_offset;
mod ioctl;
mod linkat;
mod long_paths;
#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
#[cfg(not(any(target_os = "haiku", target_os = "wasi")))]
mod makedev;
mod mkdirat;
mod mknodat;
Expand Down