diff mbox series

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

Message ID 20230606224254.16380-1-matt@traverse.com.au
State New
Headers show
Series [fstools] block: autofs: do not generate events for the root partition | expand

Commit Message

Mathew McBride June 6, 2023, 10:42 p.m. UTC
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@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 mbox series

Patch

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)