// dmesg — kernel-log dumper for /bin/dmesg. // // Reads the retained kernel boot log in a single snapshot and writes it to fd // 1, so the log can be inspected over the console without a serial adapter. The // buffer is a stack array sized to the ring, so one read captures the whole // retained log with no cursor and no tearing. // // The first Flash port to use control flow: an `if n > 0 { … }` guard around // the write, plus a fixed-size array declaration (`[flibc.KLOG_SIZE]u8`). Like // the other coreutils it pulls in the flibc _start shim and flibc_mem so a later // change that introduces a libcall cannot regress the link. use flibc link "flibc_start" link "flibc_mem" export fn main(_ usize, _ argv) noreturn { var buf [flibc.KLOG_SIZE]u8 = undefined n := flibc.sys.klog_read(&buf, buf.len) if n > 0 { _ = flibc.sys.write_fd(1, &buf, #intCast(n)) } flibc.exit() }