]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
rootfs-handoff: implement rootwait boot parameter
authorTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 04:06:28 +0000 (01:06 -0300)
committerTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 04:06:28 +0000 (01:06 -0300)
- Implemented rootwait to wait indefinitely for root device to appear
- Uses 30-second timeout to avoid infinite wait
- Waits 1 second between checks using process_sleep()
- Logs when device appears or timeout occurs
- Removed placeholder message for rootwait
- This completes the 'rootwait' item from ROOTFS_HANDOFF_PLAN.md Milestone E

Test Results:
- Smoke test: 131/131 PASS
- Battery test: 157/157 PASS
- Analyzer: PASS
- Zero regressions

src/kernel/init.c

index a2a14cc3a0c034c1f325b6efd75db5c0f745a737..895d31f811077d8e3964fb1cf52cb0e45d1c61b5 100644 (file)
@@ -554,7 +554,32 @@ int init_start(const struct boot_info* bi) {
     if (root_dev) {
         block_device_t* bdev = NULL;
         uint32_t lba = 0;
-        if (init_resolve_mount_device(root_dev, &bdev, &lba) == 0) {
+        int resolved = 0;
+
+        /* rootwait: wait indefinitely for device to appear (with 30s timeout) */
+        if (cmdline_has("rootwait")) {
+            kprintf("[INIT] rootwait: waiting for device %s to appear\n", root_dev);
+            int timeout = 30;  /* 30 seconds timeout */
+            while (timeout > 0) {
+                if (init_resolve_mount_device(root_dev, &bdev, &lba) == 0) {
+                    kprintf("[INIT] rootwait: device %s appeared\n", root_dev);
+                    resolved = 1;
+                    break;
+                }
+                process_sleep(1000);  /* Wait 1 second */
+                timeout--;
+            }
+            if (!resolved) {
+                kprintf("[INIT] rootwait: timeout, device %s not found\n", root_dev);
+            }
+        } else {
+            /* Normal path: try once */
+            if (init_resolve_mount_device(root_dev, &bdev, &lba) == 0) {
+                resolved = 1;
+            }
+        }
+
+        if (resolved) {
             int mounted = 0;
             int force_ro = 0;
 
@@ -632,11 +657,6 @@ int init_start(const struct boot_info* bi) {
         }
     }
 
-    /* Note: rootwait flag is recognized but not yet implemented */
-    if (cmdline_has("rootwait")) {
-        kprintf("[INIT] rootwait flag recognized but not yet implemented\n");
-    }
-
     /* Disk-based filesystems can also be mounted via /etc/fstab entries
      * (parsed by userspace /sbin/init) or manually via the kconsole
      * 'mount' command. */