mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
Build hashsum, join, ln, ls, mkdir, mktemp, nl, ptx, sort on Redox
This commit is contained in:
parent
bc9a0aae66
commit
6f4b91db93
3 changed files with 18 additions and 20 deletions
18
Cargo.toml
18
Cargo.toml
|
@ -65,19 +65,10 @@ fuchsia = [
|
||||||
]
|
]
|
||||||
generic = [
|
generic = [
|
||||||
"arch",
|
"arch",
|
||||||
"hashsum",
|
|
||||||
"hostname",
|
"hostname",
|
||||||
"join",
|
|
||||||
"more",
|
"more",
|
||||||
"ln",
|
|
||||||
"ls",
|
|
||||||
"mkdir",
|
|
||||||
"mktemp",
|
|
||||||
"nl",
|
|
||||||
"nproc",
|
"nproc",
|
||||||
"ptx",
|
|
||||||
"shred",
|
"shred",
|
||||||
"sort",
|
|
||||||
"sync",
|
"sync",
|
||||||
"tail",
|
"tail",
|
||||||
"test",
|
"test",
|
||||||
|
@ -111,13 +102,21 @@ redox_generic = [
|
||||||
"false",
|
"false",
|
||||||
"fmt",
|
"fmt",
|
||||||
"fold",
|
"fold",
|
||||||
|
"hashsum",
|
||||||
"head",
|
"head",
|
||||||
|
"join",
|
||||||
"link",
|
"link",
|
||||||
|
"ln",
|
||||||
|
"ls",
|
||||||
|
"mkdir",
|
||||||
|
"mktemp",
|
||||||
"mv",
|
"mv",
|
||||||
|
"nl",
|
||||||
"od",
|
"od",
|
||||||
"paste",
|
"paste",
|
||||||
"printenv",
|
"printenv",
|
||||||
"printf",
|
"printf",
|
||||||
|
"ptx",
|
||||||
"pwd",
|
"pwd",
|
||||||
"readlink",
|
"readlink",
|
||||||
"realpath",
|
"realpath",
|
||||||
|
@ -127,6 +126,7 @@ redox_generic = [
|
||||||
"seq",
|
"seq",
|
||||||
"shuf",
|
"shuf",
|
||||||
"sleep",
|
"sleep",
|
||||||
|
"sort",
|
||||||
"split",
|
"split",
|
||||||
"sum",
|
"sum",
|
||||||
"tac",
|
"tac",
|
||||||
|
|
|
@ -14,7 +14,7 @@ extern crate uucore;
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{stdin, BufRead, BufReader, Result};
|
use std::io::{stdin, BufRead, BufReader, Result};
|
||||||
#[cfg(unix)]
|
#[cfg(any(unix, target_os = "redox"))]
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::os::windows::fs::{symlink_dir, symlink_file};
|
use std::os::windows::fs::{symlink_dir, symlink_file};
|
||||||
|
|
|
@ -135,20 +135,18 @@ fn mkdir(path: &Path, mode: u16, verbose: bool) -> i32 {
|
||||||
show_info!("created directory '{}'", path.display());
|
show_info!("created directory '{}'", path.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(any(unix, target_os = "redox"))]
|
||||||
fn chmod(path: &Path, mode: u16) -> i32 {
|
fn chmod(path: &Path, mode: u16) -> i32 {
|
||||||
use std::ffi::CString;
|
use fs::{Permissions, set_permissions};
|
||||||
use std::io::Error;
|
use std::os::unix::fs::{PermissionsExt};
|
||||||
|
|
||||||
let directory =
|
let mode = Permissions::from_mode(mode as u32);
|
||||||
CString::new(path.as_os_str().to_str().unwrap()).unwrap_or_else(|e| crash!(1, "{}", e));
|
|
||||||
let mode = mode as libc::mode_t;
|
|
||||||
|
|
||||||
if unsafe { libc::chmod(directory.as_ptr(), mode) } != 0 {
|
if let Err(err) = set_permissions(path, mode) {
|
||||||
show_info!(
|
show_error!(
|
||||||
"{}: errno {}",
|
"{}: {}",
|
||||||
path.display(),
|
path.display(),
|
||||||
Error::last_os_error().raw_os_error().unwrap()
|
err
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue