diff --git a/Cargo.toml b/Cargo.toml index ef5358f25..b8da013dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,19 +65,10 @@ fuchsia = [ ] generic = [ "arch", - "hashsum", "hostname", - "join", "more", - "ln", - "ls", - "mkdir", - "mktemp", - "nl", "nproc", - "ptx", "shred", - "sort", "sync", "tail", "test", @@ -111,13 +102,21 @@ redox_generic = [ "false", "fmt", "fold", + "hashsum", "head", + "join", "link", + "ln", + "ls", + "mkdir", + "mktemp", "mv", + "nl", "od", "paste", "printenv", "printf", + "ptx", "pwd", "readlink", "realpath", @@ -127,6 +126,7 @@ redox_generic = [ "seq", "shuf", "sleep", + "sort", "split", "sum", "tac", diff --git a/src/ln/ln.rs b/src/ln/ln.rs index 68e4d173b..5d0cccb92 100644 --- a/src/ln/ln.rs +++ b/src/ln/ln.rs @@ -14,7 +14,7 @@ extern crate uucore; use std::fs; use std::io::{stdin, BufRead, BufReader, Result}; -#[cfg(unix)] +#[cfg(any(unix, target_os = "redox"))] use std::os::unix::fs::symlink; #[cfg(windows)] use std::os::windows::fs::{symlink_dir, symlink_file}; diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index af8c3d2e9..ec07d36e8 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -135,20 +135,18 @@ fn mkdir(path: &Path, mode: u16, verbose: bool) -> i32 { show_info!("created directory '{}'", path.display()); } - #[cfg(unix)] + #[cfg(any(unix, target_os = "redox"))] fn chmod(path: &Path, mode: u16) -> i32 { - use std::ffi::CString; - use std::io::Error; + use fs::{Permissions, set_permissions}; + use std::os::unix::fs::{PermissionsExt}; - let directory = - CString::new(path.as_os_str().to_str().unwrap()).unwrap_or_else(|e| crash!(1, "{}", e)); - let mode = mode as libc::mode_t; + let mode = Permissions::from_mode(mode as u32); - if unsafe { libc::chmod(directory.as_ptr(), mode) } != 0 { - show_info!( - "{}: errno {}", + if let Err(err) = set_permissions(path, mode) { + show_error!( + "{}: {}", path.display(), - Error::last_os_error().raw_os_error().unwrap() + err ); return 1; }