mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
commit
2739e414b3
3 changed files with 72 additions and 6 deletions
11
Makefile
11
Makefile
|
@ -43,17 +43,18 @@ PROGS := \
|
||||||
tail \
|
tail \
|
||||||
|
|
||||||
UNIX_PROGS := \
|
UNIX_PROGS := \
|
||||||
|
groups \
|
||||||
hostid \
|
hostid \
|
||||||
hostname \
|
hostname \
|
||||||
|
id \
|
||||||
kill \
|
kill \
|
||||||
logname \
|
logname \
|
||||||
users \
|
sync \
|
||||||
whoami \
|
|
||||||
tty \
|
tty \
|
||||||
groups \
|
uname \
|
||||||
id \
|
|
||||||
uptime \
|
uptime \
|
||||||
uname
|
users \
|
||||||
|
whoami
|
||||||
|
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
PROGS := $(PROGS) $(UNIX_PROGS)
|
PROGS := $(PROGS) $(UNIX_PROGS)
|
||||||
|
|
|
@ -171,7 +171,6 @@ To do
|
||||||
- stat
|
- stat
|
||||||
- stdbuf
|
- stdbuf
|
||||||
- stty (in progress)
|
- stty (in progress)
|
||||||
- sync
|
|
||||||
- tail (not all features implemented)
|
- tail (not all features implemented)
|
||||||
- test
|
- test
|
||||||
- timeout
|
- timeout
|
||||||
|
|
66
sync/sync.rs
Normal file
66
sync/sync.rs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#![crate_id(name="sync", vers="1.0.0", author="Alexander Fomin")]
|
||||||
|
/*
|
||||||
|
* This file is part of the uutils coreutils package.
|
||||||
|
*
|
||||||
|
* (c) Alexander Fomin <xander.fomin@ya.ru>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Last synced with: sync (GNU coreutils) 8.13 */
|
||||||
|
|
||||||
|
extern crate getopts;
|
||||||
|
extern crate libc;
|
||||||
|
|
||||||
|
use std::os;
|
||||||
|
use getopts::{optflag, getopts, usage};
|
||||||
|
|
||||||
|
extern {
|
||||||
|
fn sync() -> libc::c_void;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn main () { os::set_exit_status(uumain(os::args())); }
|
||||||
|
|
||||||
|
pub fn uumain(args: Vec<String>) -> int {
|
||||||
|
let program = args.get(0);
|
||||||
|
|
||||||
|
let options = [
|
||||||
|
optflag("h", "help", "display this help and exit"),
|
||||||
|
optflag("V", "version", "output version information and exit")
|
||||||
|
];
|
||||||
|
|
||||||
|
let matches = match getopts(args.tail(), options) {
|
||||||
|
Ok(m) => { m }
|
||||||
|
_ => { help(program.as_slice(), options); return 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
if matches.opt_present("h") {
|
||||||
|
help(program.as_slice(), options);
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if matches.opt_present("V") {
|
||||||
|
version();
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
sync()
|
||||||
|
};
|
||||||
|
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn version() {
|
||||||
|
println!("sync (uutils) 1.0.0");
|
||||||
|
println!("The MIT License");
|
||||||
|
println!("");
|
||||||
|
println!("Author -- Alexander Fomin.");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn help(program: &str, options: &[getopts::OptGroup]) {
|
||||||
|
println!("Usage: {:s} [OPTION]", program);
|
||||||
|
print!("{:s}", usage("Force changed blocks to disk, update the super block.", options));
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue