diff --git a/Cargo.lock b/Cargo.lock index b2abe2e48..b954fffaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -719,7 +719,7 @@ checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.2.9", + "redox_syscall", "winapi 0.3.9", ] @@ -1238,7 +1238,7 @@ dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.2.9", + "redox_syscall", "smallvec 1.6.1", "winapi 0.3.9", ] @@ -1532,15 +1532,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] @@ -1551,7 +1545,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f" dependencies = [ - "redox_syscall 0.2.9", + "redox_syscall", ] [[package]] @@ -1810,7 +1804,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "rand 0.8.4", - "redox_syscall 0.2.9", + "redox_syscall", "remove_dir_all", "winapi 0.3.9", ] @@ -1851,7 +1845,7 @@ checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e" dependencies = [ "libc", "numtoa", - "redox_syscall 0.2.9", + "redox_syscall", "redox_termios", ] @@ -2499,7 +2493,7 @@ dependencies = [ "clap", "crossterm", "nix 0.13.1", - "redox_syscall 0.1.57", + "redox_syscall", "redox_termios", "unicode-segmentation", "unicode-width", @@ -2858,7 +2852,7 @@ dependencies = [ "clap", "libc", "nix 0.20.0", - "redox_syscall 0.1.57", + "redox_syscall", "uucore", "uucore_procs", "winapi 0.3.9", @@ -2881,7 +2875,7 @@ version = "0.0.7" dependencies = [ "clap", "libc", - "redox_syscall 0.1.57", + "redox_syscall", "uucore", "uucore_procs", ] diff --git a/Cargo.toml b/Cargo.toml index 42579b5d6..df60206ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -217,9 +217,8 @@ feat_os_unix_fuchsia = [ feat_os_unix_redox = [ "feat_common_core", # - "uname", "chmod", - "install", + "uname", ] # "feat_os_windows_legacy" == slightly restricted set of utilities which can be built/run on early windows platforms (eg, "WinXP") feat_os_windows_legacy = [ diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 0071b5e8c..042daa616 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -15,7 +15,7 @@ use chrono::{DateTime, FixedOffset, Local, Offset, Utc}; #[cfg(windows)] use chrono::{Datelike, Timelike}; use clap::{crate_version, App, Arg}; -#[cfg(all(unix, not(target_os = "macos")))] +#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))] use libc::{clock_settime, timespec, CLOCK_REALTIME}; use std::fs::File; use std::io::{BufRead, BufReader}; @@ -67,10 +67,12 @@ static RFC_3339_HELP_STRING: &str = "output date/time in RFC 3339 format. for date and time to the indicated precision. Example: 2006-08-14 02:34:56-06:00"; -#[cfg(not(target_os = "macos"))] +#[cfg(not(any(target_os = "macos", target_os = "redox")))] static OPT_SET_HELP_STRING: &str = "set time described by STRING"; #[cfg(target_os = "macos")] static OPT_SET_HELP_STRING: &str = "set time described by STRING (not available on mac yet)"; +#[cfg(target_os = "redox")] +static OPT_SET_HELP_STRING: &str = "set time described by STRING (not available on redox yet)"; /// Settings for this program, parsed from the command line struct Settings { @@ -357,7 +359,13 @@ fn set_system_datetime(_date: DateTime) -> i32 { 1 } -#[cfg(all(unix, not(target_os = "macos")))] +#[cfg(target_os = "redox")] +fn set_system_datetime(_date: DateTime) -> i32 { + eprintln!("date: setting the date is not supported by Redox"); + 1 +} + +#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))] /// System call to set date (unix). /// See here for more: /// https://doc.rust-lang.org/libc/i686-unknown-linux-gnu/libc/fn.clock_settime.html diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index da0165245..a0ed1ab91 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -19,13 +19,15 @@ byte-unit = "4.0" clap = { version = "2.33", features = [ "wrap_help" ] } gcd = "2.0" libc = "0.2" -signal-hook = "0.3.9" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [dev-dependencies] tempfile = "^3" +[target.'cfg(target_os = "linux")'.dependencies] +signal-hook = "0.3.9" + [[bin]] name = "dd" path = "src/main.rs" diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 8fcd34bed..ef314dfa8 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -1590,7 +1590,7 @@ fn display_uname(metadata: &Metadata, config: &Config) -> String { } } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "redox")))] fn cached_gid2grp(gid: u32) -> String { lazy_static! { static ref GID_CACHE: Mutex> = Mutex::new(HashMap::new()); @@ -1603,7 +1603,7 @@ fn cached_gid2grp(gid: u32) -> String { .clone() } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "redox")))] fn display_group(metadata: &Metadata, config: &Config) -> String { if config.long.numeric_uid_gid { metadata.gid().to_string() @@ -1612,6 +1612,11 @@ fn display_group(metadata: &Metadata, config: &Config) -> String { } } +#[cfg(target_os = "redox")] +fn display_group(metadata: &Metadata, config: &Config) -> String { + metadata.gid().to_string() +} + #[cfg(not(unix))] fn display_uname(_metadata: &Metadata, _config: &Config) -> String { "somebody".to_string() diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index 03866d187..2d66dc950 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -25,7 +25,7 @@ unicode-segmentation = "1.7.1" [target.'cfg(target_os = "redox")'.dependencies] redox_termios = "0.1" -redox_syscall = "0.1" +redox_syscall = "0.2" [target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] nix = "<=0.13" diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 3028e7f6a..d446e66a0 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -16,7 +16,7 @@ path = "src/pr.rs" [dependencies] clap = { version = "2.33", features = ["wrap_help"] } -uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["utmpx", "entries"] } +uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries"] } uucore_procs = { version=">=0.0.6", package="uucore_procs", path="../../uucore_procs" } getopts = "0.2.21" time = "0.1.41" diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index 710a1421f..6928330de 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -22,7 +22,7 @@ uucore_procs = { version=">=0.0.6", package="uucore_procs", path="../../uucore_p winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] } [target.'cfg(target_os = "redox")'.dependencies] -redox_syscall = "0.1" +redox_syscall = "0.2" [target.'cfg(unix)'.dependencies] nix = "0.20" diff --git a/src/uu/tail/src/platform/mod.rs b/src/uu/tail/src/platform/mod.rs index 4a8982713..7b7fd6fa3 100644 --- a/src/uu/tail/src/platform/mod.rs +++ b/src/uu/tail/src/platform/mod.rs @@ -14,14 +14,8 @@ pub use self::unix::{stdin_is_pipe_or_fifo, supports_pid_checks, Pid, ProcessChe #[cfg(windows)] pub use self::windows::{supports_pid_checks, Pid, ProcessChecker}; -#[cfg(target_os = "redox")] -pub use self::redox::{supports_pid_checks, Pid, ProcessChecker}; - #[cfg(unix)] mod unix; #[cfg(windows)] mod windows; - -#[cfg(target_os = "redox")] -mod redox; diff --git a/src/uu/tail/src/platform/redox.rs b/src/uu/tail/src/platform/redox.rs deleted file mode 100644 index bc6fb5220..000000000 --- a/src/uu/tail/src/platform/redox.rs +++ /dev/null @@ -1,25 +0,0 @@ -// spell-checker:ignore (ToDO) ENOSYS EPERM - -use self::syscall::{Error, ENOSYS, EPERM}; - -pub type Pid = usize; - -pub struct ProcessChecker { - pid: self::Pid, -} - -impl ProcessChecker { - pub fn new(process_id: self::Pid) -> ProcessChecker { - ProcessChecker { pid: process_id } - } - - // Borrowing mutably to be aligned with Windows implementation - pub fn is_dead(&mut self) -> bool { - let res = syscall::kill(self.pid, 0); - res != Ok(0) && res != Err(Error::new(EPERM)) - } -} - -pub fn supports_pid_checks(pid: self::Pid) -> bool { - true -} diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index f69918446..b9931185c 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -21,7 +21,7 @@ uucore = { version=">=0.0.9", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.6", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(target_os = "redox")'.dependencies] -redox_syscall = "0.1" +redox_syscall = "0.2" [[bin]] name = "test" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 4067aae52..60399b9be 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -16,7 +16,7 @@ edition = "2018" path="src/lib/lib.rs" [dependencies] -dns-lookup = "1.0.5" +dns-lookup = { version="1.0.5", optional=true } dunce = "1.0.0" getopts = "<= 0.2.21" wild = "2.0.4" @@ -55,6 +55,6 @@ process = ["libc"] ringbuffer = [] signals = [] utf8 = [] -utmpx = ["time", "libc"] +utmpx = ["time", "libc", "dns-lookup"] wide = [] zero-copy = ["nix", "libc", "lazy_static", "platform-info"] diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index c1e1ec31e..f90fc7b3d 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -29,6 +29,7 @@ pub mod signals; #[cfg(all( unix, not(target_os = "fuchsia"), + not(target_os = "redox"), not(target_env = "musl"), feature = "utmpx" ))] diff --git a/src/uucore/src/lib/features/entries.rs b/src/uucore/src/lib/features/entries.rs index 6b986e616..f139d6871 100644 --- a/src/uucore/src/lib/features/entries.rs +++ b/src/uucore/src/lib/features/entries.rs @@ -37,7 +37,9 @@ #[cfg(any(target_os = "freebsd", target_vendor = "apple"))] use libc::time_t; use libc::{c_char, c_int, gid_t, uid_t}; -use libc::{getgrgid, getgrnam, getgroups, getpwnam, getpwuid, group, passwd}; +#[cfg(not(target_os = "redox"))] +use libc::{getgrgid, getgrnam, getgroups}; +use libc::{getpwnam, getpwuid, group, passwd}; use std::borrow::Cow; use std::ffi::{CStr, CString}; @@ -65,6 +67,7 @@ extern "C" { /// > supplementary group IDs for the process is returned. This allows /// > the caller to determine the size of a dynamically allocated list /// > to be used in a further call to getgroups(). +#[cfg(not(target_os = "redox"))] pub fn get_groups() -> IOResult> { let ngroups = unsafe { getgroups(0, ptr::null_mut()) }; if ngroups == -1 { @@ -104,7 +107,7 @@ pub fn get_groups() -> IOResult> { /// > groups is the same (in the mathematical sense of ``set''). (The /// > history of a process and its parents could affect the details of /// > the result.) -#[cfg(all(unix, feature = "process"))] +#[cfg(all(unix, not(target_os = "redox"), feature = "process"))] pub fn get_groups_gnu(arg_id: Option) -> IOResult> { let groups = get_groups()?; let egid = arg_id.unwrap_or_else(crate::features::process::getegid); @@ -319,6 +322,7 @@ macro_rules! f { } f!(getpwnam, getpwuid, uid_t, Passwd); +#[cfg(not(target_os = "redox"))] f!(getgrnam, getgrgid, gid_t, Group); #[inline] @@ -326,6 +330,7 @@ pub fn uid2usr(id: uid_t) -> IOResult { Passwd::locate(id).map(|p| p.name().into_owned()) } +#[cfg(not(target_os = "redox"))] #[inline] pub fn gid2grp(id: gid_t) -> IOResult { Group::locate(id).map(|p| p.name().into_owned()) @@ -336,6 +341,7 @@ pub fn usr2uid(name: &str) -> IOResult { Passwd::locate(name).map(|p| p.uid()) } +#[cfg(not(target_os = "redox"))] #[inline] pub fn grp2gid(name: &str) -> IOResult { Group::locate(name).map(|p| p.gid()) diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index 36bdbfed0..9514b6842 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -15,8 +15,6 @@ use libc::{ use std::borrow::Cow; use std::env; use std::fs; -#[cfg(target_os = "redox")] -use std::io; use std::io::Result as IOResult; use std::io::{Error, ErrorKind}; #[cfg(any(unix, target_os = "redox"))] diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index d3eec468a..56e078c56 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -94,7 +94,8 @@ pub use libc::statfs as StatFs; target_os = "netbsd", target_os = "openbsd", target_os = "bitrig", - target_os = "dragonfly" + target_os = "dragonfly", + target_os = "redox" ))] pub use libc::statvfs as StatFs; @@ -110,7 +111,8 @@ pub use libc::statfs as statfs_fn; target_os = "netbsd", target_os = "openbsd", target_os = "bitrig", - target_os = "dragonfly" + target_os = "dragonfly", + target_os = "redox" ))] pub use libc::statvfs as statfs_fn; @@ -438,6 +440,11 @@ pub fn read_fs_list() -> Vec { } mounts } + #[cfg(target_os = "redox")] + { + // No method to read mounts, yet + Vec::new() + } } #[derive(Debug, Clone)] diff --git a/src/uucore/src/lib/features/mode.rs b/src/uucore/src/lib/features/mode.rs index fe109d73d..8e9f063ff 100644 --- a/src/uucore/src/lib/features/mode.rs +++ b/src/uucore/src/lib/features/mode.rs @@ -35,12 +35,6 @@ pub fn parse_symbolic( #[cfg(unix)] use libc::umask; - #[cfg(target_os = "redox")] - unsafe fn umask(_mask: u32) -> u32 { - // XXX Redox does not currently have umask - 0 - } - let (mask, pos) = parse_levels(mode); if pos == mode.len() { return Err(format!("invalid mode ({})", mode)); diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 1ac26b04e..aa96a1086 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -65,6 +65,7 @@ pub use crate::features::signals; #[cfg(all( unix, not(target_os = "fuchsia"), + not(target_os = "redox"), not(target_env = "musl"), feature = "utmpx" ))]