[OpenWrt-Devel] [PATCH 1/2] mount_root: implement overlay= boot option
josua.mayer97 at gmail.com
josua.mayer97 at gmail.com
Thu Apr 28 13:39:19 EDT 2016
From: Josua Mayer <privacy at not.given>
This change adds code to handle a new option on cmdline: overlay=
This is used to find the rootfs_data partition / disk when it has a
non-standard name or location.
It takes either the device node name, or the full path to the device node:
i.e. /dev/mmcblk0p3 or mmcblk0p3
This option has precedence over the default name "rootfs_data", and extroot.
Signed-off-by: Josua Mayer <josua.mayer97 at gmail.com>.
---
mount_root.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/mount_root.c b/mount_root.c
index 47a3409..9d2c0de 100644
--- a/mount_root.c
+++ b/mount_root.c
@@ -33,6 +33,35 @@ start(int argc, char *argv[1])
if (!getenv("PREINIT"))
return -1;
+ /*
+ * Check cmdline for a hint about overlay device
+ */
+ if(!data) {
+ FILE *fp;
+ char buffer[100] = {0};
+
+ fp = fopen("/proc/cmdline", "r");
+ while(!feof(fp)) {
+ if(fscanf(fp, "overlay=%s", buffer))
+ break;
+
+ fseek(fp, 1, SEEK_CUR);
+ }
+ fclose(fp);
+
+ // overlay= argument was found
+ if(buffer[0]) {
+ // strip /dev/ prefix if any
+ int offset = 0;
+ if(strstr(buffer, "/dev/"))
+ offset = 5;
+
+ // try to find the volume
+ ULOG_NOTE("Looking for overlay device given on commandline\n");
+ data = volume_find(buffer + offset);
+ }
+ }
+
if (!data) {
root = volume_find("rootfs");
volume_init(root);
--
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