summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2020-10-11 01:06:52 +0100
committerDaniel Golle <daniel@makrotopia.org>2020-10-16 01:48:40 +0100
commit8e0f29a0c6279172e6705c901a73a35ed9e9d9ea (patch)
tree5ce4b006208c9be2f24bb884b6b3cba91723ef1f
parent5345343828df944ae247d91cc77182f87559bc9a (diff)
downloadfstools-8e0f29a0c6279172e6705c901a73a35ed9e9d9ea.tar.gz
mount: remove support for legacy overlayfs before v2.3
overlayfs has been in mainline since Linux v3.18 (OpenWrt CC 15.05). Remove support for pre-mainline overlayfs. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--libfstools/mount.c58
1 files changed, 22 insertions, 36 deletions
diff --git a/libfstools/mount.c b/libfstools/mount.c
index c7f2789..d61a80f 100644
--- a/libfstools/mount.c
+++ b/libfstools/mount.c
@@ -94,7 +94,8 @@ pivot(char *new, char *old)
int
fopivot(char *rw_root, char *ro_root)
{
- char overlay[64], mount_options[64];
+ char overlay[64], mount_options[64], upperdir[64], workdir[64], upgrade[64], upgrade_dest[64];
+ struct stat st;
if (find_filesystem("overlay")) {
ULOG_ERR("BUG: no suitable fs found\n");
@@ -102,44 +103,29 @@ fopivot(char *rw_root, char *ro_root)
}
snprintf(overlay, sizeof(overlay), "overlayfs:%s", rw_root);
+ snprintf(upperdir, sizeof(upperdir), "%s/upper", rw_root);
+ snprintf(workdir, sizeof(workdir), "%s/work", rw_root);
+ snprintf(upgrade, sizeof(upgrade), "%s/sysupgrade.tgz", rw_root);
+ snprintf(upgrade_dest, sizeof(upgrade_dest), "%s/sysupgrade.tgz", upperdir);
+ snprintf(mount_options, sizeof(mount_options), "lowerdir=/,upperdir=%s,workdir=%s",
+ upperdir, workdir);
/*
- * 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
+ * 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.
*/
- snprintf(mount_options, sizeof(mount_options), "lowerdir=/,upperdir=%s", rw_root);
- if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, mount_options)) {
- char upperdir[64], workdir[64], upgrade[64], upgrade_dest[64];
- struct stat st;
-
- snprintf(upperdir, sizeof(upperdir), "%s/upper", rw_root);
- snprintf(workdir, sizeof(workdir), "%s/work", rw_root);
- snprintf(upgrade, sizeof(upgrade), "%s/sysupgrade.tgz", rw_root);
- snprintf(upgrade_dest, sizeof(upgrade_dest), "%s/sysupgrade.tgz", upperdir);
- snprintf(mount_options, sizeof(mount_options), "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 (stat(upgrade, &st) == 0)
- rename(upgrade, upgrade_dest);
-
- /* Mainlined overlayfs has been renamed to "overlay", try that first */
- if (mount(overlay, "/mnt", "overlay", MS_NOATIME, mount_options)) {
- if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, mount_options)) {
- ULOG_ERR("mount failed: %s, options %m\n", mount_options);
- return -1;
- }
- }
+ mkdir(upperdir, 0755);
+ mkdir(workdir, 0755);
+
+ if (stat(upgrade, &st) == 0)
+ rename(upgrade, upgrade_dest);
+
+ if (mount(overlay, "/mnt", "overlay", MS_NOATIME, mount_options)) {
+ ULOG_ERR("mount failed: %s, options %m\n", mount_options);
+ return -1;
}
return pivot("/mnt", ro_root);