diff options
Diffstat (limited to 'bins/rm')
| -rw-r--r-- | bins/rm/Cargo.toml | 8 | ||||
| -rw-r--r-- | bins/rm/src/main.rs | 17 |
2 files changed, 25 insertions, 0 deletions
diff --git a/bins/rm/Cargo.toml b/bins/rm/Cargo.toml new file mode 100644 index 0000000..b49abac --- /dev/null +++ b/bins/rm/Cargo.toml | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | [package] | ||
| 2 | name = "rm" | ||
| 3 | version.workspace = true | ||
| 4 | edition.workspace = true | ||
| 5 | [lints] | ||
| 6 | workspace = true | ||
| 7 | [dependencies] | ||
| 8 | rsapi = { path = "../../rsapi" } | ||
diff --git a/bins/rm/src/main.rs b/bins/rm/src/main.rs new file mode 100644 index 0000000..3407563 --- /dev/null +++ b/bins/rm/src/main.rs | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | //! rm — remove a file or empty directory via the exports table. | ||
| 2 | |||
| 3 | #![no_std] | ||
| 4 | #![no_main] | ||
| 5 | |||
| 6 | #[panic_handler] | ||
| 7 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 8 | loop { core::hint::spin_loop(); } | ||
| 9 | } | ||
| 10 | |||
| 11 | #[unsafe(no_mangle)] | ||
| 12 | pub extern "C" fn efi_main(exports: &'static rsapi::Exports, argc: usize, argv: *const rsapi::Arg) -> i32 { | ||
| 13 | let args = unsafe { core::slice::from_raw_parts(argv, argc) }; | ||
| 14 | if args.is_empty() { return 1; } | ||
| 15 | let path = unsafe { core::str::from_utf8_unchecked(core::slice::from_raw_parts(args[0].ptr, args[0].len)) }; | ||
| 16 | (exports.fs_remove)(rsapi::Line { ptr: path.as_ptr(), len: path.len() }) | ||
| 17 | } | ||
