Skip to content

Commit

Permalink
Merge pull request #6787 from tea/unredox
Browse files Browse the repository at this point in the history
Get rid of redox-specific code
  • Loading branch information
cakebaker authored Oct 17, 2024
2 parents b19897f + b7819c0 commit e3b8191
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 48 deletions.
55 changes: 38 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ quick-error = "2.0.1"
rand = { version = "0.8.5", features = ["small_rng"] }
rand_core = "0.6.4"
rayon = "1.10"
redox_syscall = "0.5.1"
regex = "1.10.4"
rstest = "0.23.0"
rust-ini = "0.21.0"
Expand Down
3 changes: 0 additions & 3 deletions src/uu/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ clap = { workspace = true }
libc = { workspace = true }
uucore = { workspace = true, features = ["process"] }

[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = { workspace = true }

[[bin]]
name = "test"
path = "src/main.rs"
29 changes: 2 additions & 27 deletions src/uu/test/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::fs;
use std::os::unix::fs::MetadataExt;
use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError};
#[cfg(not(any(windows, target_os = "redox")))]
#[cfg(not(windows))]
use uucore::process::{getegid, geteuid};
use uucore::{format_usage, help_about, help_section};

Expand Down Expand Up @@ -234,14 +234,7 @@ fn isatty(fd: &OsStr) -> ParseResult<bool> {
fd.to_str()
.and_then(|s| s.parse().ok())
.ok_or_else(|| ParseError::InvalidInteger(fd.quote().to_string()))
.map(|i| {
#[cfg(not(target_os = "redox"))]
unsafe {
libc::isatty(i) == 1
}
#[cfg(target_os = "redox")]
syscall::dup(i, b"termios").map(syscall::close).is_ok()
})
.map(|i| unsafe { libc::isatty(i) == 1 })
}

#[derive(Eq, PartialEq)]
Expand Down Expand Up @@ -281,24 +274,6 @@ fn path(path: &OsStr, condition: &PathCondition) -> bool {
Execute = 0o1,
}

let geteuid = || {
#[cfg(not(target_os = "redox"))]
let euid = geteuid();
#[cfg(target_os = "redox")]
let euid = syscall::geteuid().unwrap() as u32;

euid
};

let getegid = || {
#[cfg(not(target_os = "redox"))]
let egid = getegid();
#[cfg(target_os = "redox")]
let egid = syscall::getegid().unwrap() as u32;

egid
};

let perm = |metadata: Metadata, p: Permission| {
if geteuid() == metadata.uid() {
metadata.mode() & ((p as u32) << 6) != 0
Expand Down

0 comments on commit e3b8191

Please sign in to comment.