From: CicadaTAK Date: Sat, 3 Oct 2026 00:00:00 +0000 Subject: [PATCH] libfstools: fall back to ramoverlay when the overlay will not mount CicadaTAK-Marker: CICADATAK-FSTOOLS-RAMOVERLAY mount_root's start() hands an f2fs/ext4/jffs2/ubifs rootfs_data volume to mount_overlay() and ignores its return value. mount_overlay() returns the error as soon as the mount fails, so a filesystem whose magic is present but which will not mount (corruption, or a stale superblock left at the overlay's offset) leaves the system on the read-only rootfs with no overlay at all: no writable /, so the boot partition is never mounted, no sysupgrade config restore runs, and nothing configures the network. Fall back to ramoverlay() there, exactly as mount_overlay() already does when the later move/pivot fails. No fsck, no reformat, no write to the volume: the broken filesystem is left as it is for repair. A missing filesystem (FS_NONE) already falls back to RAM in start(); this covers a broken one. The marker string is read back from the built image's libfstools.so. --- libfstools/overlay.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/libfstools/overlay.c +++ b/libfstools/overlay.c @@ -413,6 +413,9 @@ } +/* Read back from the built image by imagebuilder/tools/package-readback.py. */ +static const char cicadatak_marker[] __attribute__((used)) = "CICADATAK-FSTOOLS-RAMOVERLAY"; + int mount_overlay(struct volume *v) { const char *overlay_mp = "/tmp/overlay"; @@ -429,8 +432,16 @@ } err = overlay_mount_fs(v, overlay_mp); - if (err) - return err; + if (err) { + /* + * CicadaTAK: a filesystem whose magic is present but which will not mount (corruption, a + * fossil superblock) used to leave the system on the read-only rootfs with no overlay at + * all: no /boot mount, no config restore, no network. Fall back to RAM, as this function + * already does when the later move/pivot fails. The filesystem is left as it is. + */ + ULOG_ERR("overlay filesystem on %s will not mount - fallback to ramoverlay\n", v->blk); + return ramoverlay(); + } /* * Check for extroot config in overlay (rootfs_data) and if present then