RustForge

foundry

Foundry OS: the operating system built on the Rustbelt kernel

authorTyler Fowler <tyler@localhost>2026-10-30 11:39:24 -0700
commit5ba29e2307d0368b527aa8b12cd702643d9dd196
parentf3ac93a5e66e1b828a642807220156affbf9d100
treebrowse files at this commit
WIP 15.1: version bump, selftest/headless/screenshot, README chapter
Mdemo.rs+12 -7
Mulib.rs+2 -0

2 files changed, 14 insertions, 7 deletions

@@ -59,18 +59,23 @@ fn main() -> i64 {     // --- list a directory with getdents64 -----------------------------------     let dir = open("bin", 0);     let mut dents = [0u8; 1024];-    let len = getdents64(dir, &mut dents);+    let mut len = getdents64(dir, &mut dents);     check(len > 0, "getdents64 bin");     let (mut saw_demo, mut saw_child) = (false, false);     print!("[demo] /mnt/disk0/bin:");-    for_each_dirent(&dents, len.max(0) as usize, |name, d_type| {-        print!(" {}{}", name, if d_type == 4 { "/" } else { "" });-        saw_demo |= name == "demo";-        saw_child |= name == "child";-    });+    // One call returns as many whole records as fit in the buffer; keep+    // calling until it returns 0 (the end of the directory).+    while len > 0 {+        for_each_dirent(&dents, len as usize, |name, d_type| {+            print!(" {}{}", name, if d_type == 4 { "/" } else { "" });+            saw_demo |= name == "demo";+            saw_child |= name == "child";+        });+        len = getdents64(dir, &mut dents);+    }     println!();     check(saw_demo && saw_child, "bin contains demo and child");-    check(getdents64(dir, &mut dents) == 0, "getdents64 at end returns 0");+    check(len == 0 && getdents64(dir, &mut dents) == 0, "getdents64 at end returns 0");     close(dir);      // --- relative paths, "..", errors ----------------------------------------
@@ -867,6 +867,7 @@ pub fn strerror(errno: i64) -> &'static str {         16 => "Device or resource busy",         19 => "No such device",         17 => "File exists",+        18 => "Invalid cross-device link",         20 => "Not a directory",         21 => "Is a directory",         22 => "Invalid argument",@@ -886,6 +887,7 @@ pub fn strerror(errno: i64) -> &'static str {         88 => "Socket operation on non-socket",         89 => "Destination address required",         90 => "Message too long",+        92 => "Protocol not available",         93 => "Protocol not supported",         97 => "Address family not supported",         98 => "Address already in use",