diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 15:52:39 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 15:52:39 +0100 |
| commit | ef2d8e354a91ef30e34e2ddb61381131a989591c (patch) | |
| tree | 6a5e46da58f3371e430354d5352b6675d6076c39 /bins/mkdir/src | |
| parent | build: default profile is release (debug too slow for dev loop) (diff) | |
| download | rs-dos-ef2d8e354a91ef30e34e2ddb61381131a989591c.tar.gz rs-dos-ef2d8e354a91ef30e34e2ddb61381131a989591c.zip | |
bins: read user args from argv[1..]; fix date year digit
exec::spawn passes C-style argv with argv[0] = the command name, but
ls, cat, mkdir, touch and rm treated argv[0] as their first user
argument. Every path they were given resolved to the literal command
name ("ls", "mkdir", ...), so they failed silently: `mkdir .../sub`
never created the directory, `cat` printed nothing.
date formatted its last year digit as `y as u8 % 10`, which truncates
before the modulo (2026 -> 234 -> '4'), printing "2024".
Only visible now that the system image actually stages /bin — before,
/bin was empty and every command fell back to a built-in.
Diffstat (limited to '')
| -rw-r--r-- | bins/mkdir/src/main.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/bins/mkdir/src/main.rs b/bins/mkdir/src/main.rs index f6f7e66..82302df 100644 --- a/bins/mkdir/src/main.rs +++ b/bins/mkdir/src/main.rs | |||
| @@ -10,7 +10,8 @@ fn panic(_info: &core::panic::PanicInfo) -> ! { | |||
| 10 | 10 | ||
| 11 | #[unsafe(no_mangle)] | 11 | #[unsafe(no_mangle)] |
| 12 | pub extern "C" fn efi_main(exports: &'static rsapi::Exports, argc: usize, argv: *const rsapi::Arg) -> i32 { | 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) }; | 13 | // C-style argv: argv[0] is the program name, user args start at 1. |
| 14 | let args = unsafe { core::slice::from_raw_parts(argv.add(1), argc.saturating_sub(1)) }; | ||
| 14 | if args.is_empty() { return 1; } | 15 | 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 | let path = unsafe { core::str::from_utf8_unchecked(core::slice::from_raw_parts(args[0].ptr, args[0].len)) }; |
| 16 | let rc = (exports.fs_create)(rsapi::Line { ptr: path.as_ptr(), len: path.len() }, true); | 17 | let rc = (exports.fs_create)(rsapi::Line { ptr: path.as_ptr(), len: path.len() }, true); |
