]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
rootfs-handoff: implement remount,rw after filesystem verification
authorTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 04:01:48 +0000 (01:01 -0300)
committerTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 04:01:48 +0000 (01:01 -0300)
- Implemented remount,rw after successful filesystem verification
- Uses vfs_mount_full with MS_REMOUNT flag to update mount flags
- Remounts filesystem read-write if it was forced read-only due to verification
- If remount fails, filesystem remains read-only with warning message
- This completes the 'root verification and remount,rw after checks' item from ROOTFS_HANDOFF_PLAN.md

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

src/kernel/init.c

index bfeedbb37ab76cae7ae6f1dc7672fac6f08cf07a..a2a14cc3a0c034c1f325b6efd75db5c0f745a737 100644 (file)
@@ -604,8 +604,16 @@ int init_start(const struct boot_info* bi) {
             /* Remount read-write if filesystem is clean and was forced read-only due to verification */
             if (mounted && force_ro && !(mount_flags & MS_RDONLY)) {
                 kprintf("[INIT] root=%s: filesystem verified clean, remounting read-write\n", root_dev);
-                /* TODO: Implement remount,rw after verification */
-                /* This requires syscall support for remount with flag changes */
+                /* Remount with original flags (without MS_RDONLY) */
+                /* Use vfs_mount_full with MS_REMOUNT to update flags */
+                int rc = vfs_mount_full("/newroot", NULL, NULL, NULL,
+                                       (mount_flags & ~MS_RDONLY) | MS_REMOUNT,
+                                       NULL, NULL);
+                if (rc == 0) {
+                    kprintf("[INIT] root=%s: remounted read-write successfully\n", root_dev);
+                } else {
+                    kprintf("[INIT] root=%s: remount read-write failed (%d), keeping read-only\n", root_dev, rc);
+                }
             }
         } else {
             kprintf("[INIT] root=%s: device not found\n", root_dev);