[OpenWrt-Devel] [PATCH] fstools: Deal with overlayfs v23+
Maxime Ripard
maxime.ripard at free-electrons.com
Thu Oct 9 10:48:48 EDT 2014
OverlayFS version 23 and later require an additional directory to be given at
mount time.
Add a patch to the fstools to first test wether it can mount it without (for
older versions), and if not, use the new mechanism.
Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
---
...s-mount-Support-latest-overlayfs-versions.patch | 63 ++++++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 package/system/fstools/patches/0001-libfstools-mount-Support-latest-overlayfs-versions.patch
diff --git a/package/system/fstools/patches/0001-libfstools-mount-Support-latest-overlayfs-versions.patch b/package/system/fstools/patches/0001-libfstools-mount-Support-latest-overlayfs-versions.patch
new file mode 100644
index 000000000000..0531f92c1a27
--- /dev/null
+++ b/package/system/fstools/patches/0001-libfstools-mount-Support-latest-overlayfs-versions.patch
@@ -0,0 +1,63 @@
+From abedad5d5d975022cbf6a5c6683c244bf79eadf6 Mon Sep 17 00:00:00 2001
+From: Maxime Ripard <maxime.ripard at free-electrons.com>
+Date: Thu, 9 Oct 2014 15:07:35 +0200
+Subject: [PATCH] libfstools/mount: Support latest overlayfs versions
+
+The latest overlayfs revisions (v23 and above) require an additional directory
+to be given in the options.
+
+Since we need to support both pre-v23 and post-v23 versions, take a lazy
+approach and try to first mount without a workdir, and if it fails, try with
+it.
+
+Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
+---
+ libfstools/mount.c | 30 +++++++++++++++++++++++++++---
+ 1 file changed, 27 insertions(+), 3 deletions(-)
+
+diff --git a/libfstools/mount.c b/libfstools/mount.c
+index efcfcd8bcf15..903043f940d5 100644
+--- a/libfstools/mount.c
++++ b/libfstools/mount.c
+@@ -90,11 +90,35 @@ fopivot(char *rw_root, char *ro_root)
+ }
+
+ snprintf(overlay, sizeof(overlay), "overlayfs:%s", rw_root);
+- snprintf(lowerdir, sizeof(lowerdir), "lowerdir=/,upperdir=%s", rw_root);
+
++ /*
++ * First, try to mount without a workdir, for overlayfs v22 and before.
++ * If it fails, it means that we are probably using a v23 and
++ * later versions that require a workdir
++ */
++ snprintf(lowerdir, sizeof(lowerdir), "lowerdir=/,upperdir=%s", rw_root);
+ if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, lowerdir)) {
+- fprintf(stderr, "mount failed: %s\n", strerror(errno));
+- return -1;
++ char upperdir[64], workdir[64];
++
++ snprintf(upperdir, sizeof(upperdir), "%s/upper", rw_root);
++ snprintf(workdir, sizeof(workdir), "%s/work", rw_root);
++ snprintf(lowerdir, sizeof(lowerdir), "lowerdir=/,upperdir=%s,workdir=%s",
++ upperdir, workdir);
++
++ /*
++ * Overlay FS v23 and later requires both a upper and
++ * a work directory, both on the same filesystem, but
++ * not part of the same subtree.
++ * We can't really deal with these constraints without
++ * creating two new subdirectories in /overlay.
++ */
++ mkdir(upperdir, 0755);
++ mkdir(workdir, 0755);
++
++ if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, lowerdir)) {
++ fprintf(stderr, "mount failed: %s, options %s\n", strerror(errno), lowerdir);
++ return -1;
++ }
+ }
+
+ return pivot("/mnt", ro_root);
+--
+2.1.1
+
--
2.1.1
_______________________________________________
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