Run geodate in userspace

This commit is contained in:
Vincent Ollivier 2023-12-14 00:54:29 +01:00
parent 5a7798aba1
commit 6ad0649281
4 changed files with 31 additions and 1 deletions

BIN
dsk/bin/geodate Normal file

Binary file not shown.

29
src/bin/geodate.rs Normal file
View File

@ -0,0 +1,29 @@
#![no_std]
#![no_main]
extern crate alloc;
use geodate::geodate;
use moros::entry_point;
use moros::api::clock;
use moros::api::syscall;
entry_point!(main);
fn main(args: &[&str]) {
if args.len() < 2 {
syscall::write(1, b"Usage: geodate <longitude> [<timestamp>]\n");
return;
}
let format = "%h:%y:%m:%d:%c:%b";
let longitude = args[1].parse().expect("Could not parse longitude");
let timestamp = if args.len() == 3 {
args[2].parse().expect("Could not parse timestamp")
} else {
clock::realtime()
};
let t = geodate::get_formatted_date(format, timestamp as i64, longitude);
syscall::write(1, t.as_bytes());
}

View File

@ -25,6 +25,7 @@ pub fn copy_files(verbose: bool) {
copy_file("/bin/halt", include_bytes!("../../dsk/bin/halt"), verbose);
//copy_file("/bin/hello", include_bytes!("../../dsk/bin/hello"), verbose);
copy_file("/bin/print", include_bytes!("../../dsk/bin/print"), verbose);
copy_file("/bin/geodate", include_bytes!("../../dsk/bin/geodate"), verbose);
copy_file("/bin/reboot", include_bytes!("../../dsk/bin/reboot"), verbose);
copy_file("/bin/sleep", include_bytes!("../../dsk/bin/sleep"), verbose);

View File

@ -457,7 +457,7 @@ fn exec_with_config(cmd: &str, config: &mut Config) -> Result<(), ExitCode> {
"elf" => usr::elf::main(&args),
"env" => usr::env::main(&args),
"find" => usr::find::main(&args),
"geodate" => usr::geodate::main(&args),
//"geodate" => usr::geodate::main(&args),
"goto" => cmd_change_dir(&args, config), // TODO: Remove this
"hash" => usr::hash::main(&args),
"help" => usr::help::main(&args),