Skip to content

Commit

Permalink
Run geodate in userspace
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Dec 13, 2023
1 parent 5a7798a commit 6ad0649
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Binary file added dsk/bin/geodate
Binary file not shown.
29 changes: 29 additions & 0 deletions src/bin/geodate.rs
Original file line number Diff line number Diff line change
@@ -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());
}
1 change: 1 addition & 0 deletions src/usr/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/usr/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 6ad0649

Please sign in to comment.