[LEDE-DEV] [LEDE-DEV, 3/3] fstools: fix lost mount point when first boot

rosysong at rosinson.com rosysong at rosinson.com
Thu Mar 29 01:25:52 PDT 2018


When firmware is new flashed and reboot with a storage device plug in its usb
interface. Though the filesystem is not ready (FS_STATE_UNKNOWN), the
/dev/sda1 still mount on /mnt/sda1 by block-mount, then the system switching jffs...

root at OpenWrt:~# dmesg
......
[   32.224522] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[   32.270514] jffs2_build_filesystem(): unlocking the mtd device...
[   32.278711] jffs2_build_filesystem(): erasing all blocks after the end marker...

root at OpenWrt:~# mount
......
/dev/sda1 on /mnt/sda1 type exfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,iocharset=utf8,namecase=0,errors=remount-ro)
mountd(pid1314) on /tmp/run/blockd type autofs (rw,relatime,fd=7,pgrp=1,timeout=30,minproto=5,maxproto=5,indirect)

After few miniutes, when filesystem is ready (FS_STATE_READY, /overlay/.fs_state -> 2)
the /dev/sda1 lost its mount point

root at OpenWrt:~# dmesg

...

[  207.439407] jffs2: notice: (1336) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.

root at OpenWrt:~# mount
......
**no /mnt/sda1 found**
......

Signed-off-by: Rosy Song <rosysong at rosinson.com>
---
 mount_root.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/mount_root.c b/mount_root.c
index dffb0a6..110e4fd 100644
--- a/mount_root.c
+++ b/mount_root.c
@@ -101,6 +101,7 @@ stop(int argc, char *argv[1])
 static int
 done(int argc, char *argv[1])
 {
+	int ret;
 	struct volume *v = volume_find("rootfs_data");
 
 	if (!v)
@@ -109,7 +110,15 @@ done(int argc, char *argv[1])
 	switch (volume_identify(v)) {
 	case FS_NONE:
 	case FS_DEADCODE:
-		return jffs2_switch(v);
+		ret = jffs2_switch(v);
+		/*
+		* Devices mounted under /mnt will lost their mount point(see switch2jffs())
+		* if the filesystem's(/overlay) state is not FS_STATE_READY,
+		* this action can fix it.
+		*/
+		if (!access("/sbin/block", X_OK))
+			system("/sbin/block mount");
+		return ret;
 
 	case FS_EXT4:
 	case FS_F2FS:
-- 
2.13.3



Lede-dev mailing list
Lede-dev at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


More information about the Lede-dev mailing list