[PATCH fstools] block: autofs: do not generate events for the root partition

Mathew McBride matt at traverse.com.au
Tue Jun 6 15:42:54 PDT 2023


This resolves an issue that occurs (mostly) when OpenWrt is booted
directly from a mass storage device (e.g x86 or ARM EFI, SATA, NVMe etc.)
and results in the system becoming unusable (everything but / is unmounted).

When "block autofs start" is called (e.g by LuCI when editing system mounts),
it was generating a "remove" hotplug event for the root device,
causing the system to try to unmount the root partition.

To resolve this issue, ensure no hotplug events are generated for
the "/", just as we don't for the extroot usecases.

Signed-off-by: Mathew McBride <matt at traverse.com.au>
Link: https://forum.traverse.com.au/t/no-proc-mounts/209
Fixes: https://github.com/openwrt/openwrt/issues/12791
---
 block.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index 9b7c49c..8aa31a4 100644
--- a/block.c
+++ b/block.c
@@ -1295,11 +1295,18 @@ static int main_autofs(int argc, char **argv)
 			if (m && m->extroot)
 				continue;
 
+			mp = find_mount_point(pr->dev);
+			if (mp && !strcmp(mp,"/")) {
+				free(mp);
+				continue;
+			}
+
 			blockd_notify("hotplug", pr->dev, m, pr);
-			if ((!m || !m->autofs) && (mp = find_mount_point(pr->dev))) {
+			if ((!m || !m->autofs) && mp) {
 				blockd_notify("mount", pr->dev, NULL, NULL);
-				free(mp);
 			}
+			if (mp)
+				free(mp);
 		}
 	} else {
 		if (argc < 4)
-- 
2.30.1




More information about the openwrt-devel mailing list