[OpenWrt-Devel] [PATCH 2/2] mount_root: Also handle new overlay= option in done()

josua.mayer97 at gmail.com josua.mayer97 at gmail.com
Wed May 4 08:45:08 EDT 2016


From: Josua Mayer <privacy at not.given>

The done()-function is used both to initialize rootfs_data when there is
no filesystem yet, but also to set ready-state on fresh filesystems.

Make sure to also do that when a non-standard overlay device is specified.

Signed-off-by: Josua Mayer <josua.mayer97 at gmail.com>
---
 mount_root.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/mount_root.c b/mount_root.c
index 446e3cc..7084e3d 100644
--- a/mount_root.c
+++ b/mount_root.c
@@ -124,8 +124,39 @@ stop(int argc, char *argv[1])
 static int
 done(int argc, char *argv[1])
 {
-	struct volume *v = volume_find("rootfs_data");
+	struct volume *v = NULL;
+	FILE *fp;
+	char buffer[100] = {0};
 
+	/*
+	 * First check if there is an overlay device hint in cmdline
+	 */
+	fp = fopen("/proc/cmdline", "r");
+	while (!feof(fp)) {
+		if (fscanf(fp, "overlay=%s", buffer))
+			break;
+
+		fseek(fp, 1, SEEK_CUR);
+	}
+	fclose(fp);
+	if (buffer[0]) {
+		// strip /dev/ prefix if any
+		int offset = 0;
+		if(strstr(buffer, "/dev/"))
+			offset = 5;
+
+		v = volume_find(buffer + offset);
+	}
+
+	/*
+	 * Now look for standard overlay device name
+	 */
+	if (!v)
+		v = volume_find("rootfs_data");
+
+	/*
+	 * If no overlay device exists, then there is nothing to do here
+	 */
 	if (!v)
 		return -1;
 
-- 
2.6.6
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list