diff --git a/Cargo.toml b/Cargo.toml index d976558a0..a3cab2776 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ all = [ "tac", "tail", "tee", - "test", + "test_uu", "timeout", "touch", "tr", @@ -139,7 +139,7 @@ sync = { optional=true, path="src/sync" } tac = { optional=true, path="src/tac" } tail = { optional=true, path="src/tail" } tee = { optional=true, path="src/tee" } -test = { optional=true, path="src/test" } +test_uu = { optional=true, path="src/test" } timeout = { optional=true, path="src/timeout" } touch = { optional=true, path="src/touch" } tr = { optional=true, path="src/tr" } diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 61629734e..4ee5cf56c 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -18,9 +18,8 @@ use getopts::Options; use std::fs::File; use std::intrinsics::{copy_nonoverlapping}; use std::io::{stdout, stdin, stderr, Write, Read, Result}; -use libc::consts::os::posix88::STDIN_FILENO; -use libc::funcs::posix88::unistd::isatty; -use libc::types::os::arch::c95::c_int; +use libc::STDIN_FILENO; +use libc::{c_int, isatty}; #[path = "../common/util.rs"] #[macro_use] diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index 6ea2699df..35646212e 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -14,7 +14,7 @@ extern crate libc; use c_types::{get_pw_from_args, get_group}; use getopts::Options; -use libc::funcs::posix88::unistd::{setgid, setuid}; +use libc::{setgid, setuid}; use std::ffi::CString; use std::io::{Error, Write}; use std::iter::FromIterator; diff --git a/src/common/c_types.rs b/src/common/c_types.rs index d41871257..0f0dbdb46 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -13,7 +13,7 @@ use self::libc::time_t; #[cfg(target_os = "macos")] use self::libc::int32_t; -use self::libc::funcs::posix88::unistd::getgroups; +use self::libc::getgroups; use std::ffi::{CStr, CString}; use std::io::{Error, Write}; diff --git a/src/common/process.rs b/src/common/process.rs index 7f098a722..d5ac317ea 100644 --- a/src/common/process.rs +++ b/src/common/process.rs @@ -8,7 +8,6 @@ */ extern crate libc; -extern crate time; use libc::{c_int, pid_t}; use std::fmt; @@ -17,6 +16,7 @@ use std::process::Child; use std::sync::{Arc, Condvar, Mutex}; use std::thread; use time::{Duration, get_time}; +use std::time::Duration as StdDuration; // This is basically sys::unix::process::ExitStatus #[derive(PartialEq, Eq, Clone, Copy, Debug)] @@ -76,8 +76,8 @@ pub trait ChildExt { impl ChildExt for Child { fn send_signal(&mut self, signal: usize) -> io::Result<()> { - if unsafe { libc::funcs::posix88::signal::kill(self.id() as pid_t, - signal as i32) } != 0 { + if unsafe { libc::kill(self.id() as pid_t, + signal as i32) } != 0 { Err(io::Error::last_os_error()) } else { Ok(()) @@ -125,7 +125,7 @@ impl ChildExt for Child { return Ok(None) } let ms = (target - get_time()).num_milliseconds() as u32; - exitstatus = cvar.wait_timeout_ms(exitstatus, ms).unwrap().0; + exitstatus = cvar.wait_timeout(exitstatus, StdDuration::new(0, ms*1000)).unwrap().0; } // Turn Option> into Result> diff --git a/src/id/id.rs b/src/id/id.rs index ca3f07e83..03e8afa9c 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -17,8 +17,7 @@ extern crate getopts; extern crate libc; -use libc::{getgid, getuid, uid_t}; -use libc::funcs::posix88::unistd::{getegid, geteuid, getlogin}; +use libc::{getgid, getuid, uid_t, getegid, geteuid, getlogin}; use std::ffi::CStr; use std::io::Write; use std::ptr::read; diff --git a/src/kill/kill.rs b/src/kill/kill.rs index 1556a2807..2195e0e7d 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -182,7 +182,7 @@ fn kill(signalname: &str, pids: std::vec::Vec) -> i32 { for pid in pids.iter() { match pid.parse::() { Ok(x) => { - if unsafe { libc::funcs::posix88::signal::kill(x as pid_t, signal_value as c_int) } != 0 { + if unsafe { libc::kill(x as pid_t, signal_value as c_int) } != 0 { show_error!("{}", Error::last_os_error()); status = 1; } diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 9b496c416..99965231c 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -12,7 +12,7 @@ extern crate getopts; extern crate libc; -use libc::funcs::posix88::stat_::mkfifo; +use libc::mkfifo; use std::ffi::CString; use std::io::{Error, Write}; diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index 304776d5a..f0fb64712 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -12,11 +12,8 @@ extern crate getopts; extern crate libc; -use libc::c_char; -use libc::funcs::posix01::signal::signal; -use libc::funcs::posix88::unistd::{dup2, execvp, isatty}; -use libc::consts::os::posix01::SIG_IGN; -use libc::consts::os::posix88::SIGHUP; +use libc::{c_char, signal, dup2, execvp, isatty}; +use libc::{SIG_IGN, SIGHUP}; use std::env; use std::ffi::CString; use std::fs::{File, OpenOptions}; diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index 70abc233e..91d0d7999 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -13,7 +13,8 @@ extern crate getopts; extern crate libc; use std::io::Write; -use std::thread::sleep_ms; +use std::thread::{self}; +use std::time::Duration; use std::u32::MAX as U32_MAX; #[path = "../common/util.rs"] @@ -75,7 +76,7 @@ fn sleep(args: Vec) { let sleep_dur = if sleep_time > (U32_MAX as f64) { U32_MAX } else { - (1000.0 * sleep_time) as u32 + (1000000.0 * sleep_time) as u32 }; - sleep_ms(sleep_dur); + thread::sleep(Duration::new(0, sleep_dur)); } diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 03b830593..bbed394ec 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -14,9 +14,8 @@ extern crate getopts; extern crate libc; -use libc::consts::os::posix88::STDIN_FILENO; -use libc::funcs::posix88::unistd::isatty; -use libc::types::os::arch::c95::c_int; +use libc::STDIN_FILENO; +use libc::{c_int, isatty}; use std::cmp::Ordering; use std::fs::File; use std::io::{BufRead, BufReader, Read, stdin, Write}; diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 8b64760a5..f49519f1a 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -17,7 +17,8 @@ use std::fs::File; use std::io::{BufRead, BufReader, Read, stdin, stdout, Write}; use std::path::Path; use std::str::from_utf8; -use std::thread::sleep_ms; +use std::thread::sleep; +use std::time::Duration; #[path = "../common/util.rs"] #[macro_use] @@ -273,7 +274,7 @@ fn tail(reader: &mut BufReader, mut line_count: usize, mut byte_coun // if we follow the file, sleep a bit and print the rest if the file has grown. while follow { - sleep_ms(sleep_msec); + sleep(Duration::new(0, sleep_msec*1000)); for io_line in reader.lines() { match io_line { Ok(line) => print!("{}", line), diff --git a/src/test/Cargo.toml b/src/test/Cargo.toml index 38acc688a..bebada638 100644 --- a/src/test/Cargo.toml +++ b/src/test/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "test" +name = "test_uu" version = "0.0.1" authors = [] [lib] -name = "test" +name = "test_uu" path = "test.rs" [dependencies] diff --git a/src/test/test.rs b/src/test/test.rs index 7cd446e69..f0e6b1e7c 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -1,4 +1,4 @@ -#![crate_name = "test"] +#![crate_name = "test_uu"] /* * This file is part of the uutils coreutils package. diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index 1c9a5e02d..15817b334 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -15,11 +15,8 @@ extern crate getopts; extern crate libc; use getopts::Options; -use libc::consts::os::posix88::{S_IFMT, S_IFLNK, S_IFREG}; -use libc::funcs::posix01::stat_::lstat; -use libc::funcs::posix88::unistd::unlink; -use libc::types::os::arch::c95::c_char; -use libc::types::os::arch::posix01::stat; +use libc::{S_IFMT, S_IFLNK, S_IFREG}; +use libc::{lstat, unlink, c_char, stat}; use std::io::{Error, ErrorKind, Write}; use std::mem::uninitialized; diff --git a/src/uutils/uutils_cargo.rs b/src/uutils/uutils_cargo.rs index 275459147..627c62c43 100644 --- a/src/uutils/uutils_cargo.rs +++ b/src/uutils/uutils_cargo.rs @@ -20,13 +20,21 @@ static VERSION: &'static str = "0.0.1"; include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); +fn name_sub(util_name: &str) -> &str { + match util_name { + "test" => "test_uu", + "test_uu" => "test", + x @ _ => x + } +} + fn usage(cmap: &UtilityMap) { println!("{} {}", NAME, VERSION); println!(""); println!("Usage:"); println!(" {} [util [arguments...]]\n", NAME); println!("Currently defined functions:"); - let mut utils: Vec<&str> = cmap.keys().map(|&s| s).collect(); + let mut utils: Vec<&str> = cmap.keys().map(|&s| name_sub(s)).collect(); utils.sort(); for util in utils.iter() { println!("\t{}", util); @@ -64,7 +72,7 @@ fn main() { args.remove(0); let util = &args[0][..]; - match umap.get(util) { + match umap.get(name_sub(util)) { Some(&uumain) => { std::process::exit(uumain(args.clone())); } @@ -73,7 +81,7 @@ fn main() { // see if they want help on a specific util if args.len() >= 2 { let util = &args[1][..]; - match umap.get(util) { + match umap.get(name_sub(util)) { Some(&uumain) => { std::process::exit(uumain(vec![util.to_string(), "--help".to_string()])); }