summaryrefslogtreecommitdiffstats
path: root/bins/rm/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bins/rm/src/main.rs')
-rw-r--r--bins/rm/src/main.rs17
1 files changed, 17 insertions, 0 deletions
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]
7fn panic(_info: &core::panic::PanicInfo) -> ! {
8 loop { core::hint::spin_loop(); }
9}
10
11#[unsafe(no_mangle)]
12pub 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}