From e65232440111b8f6654218033431e5bdd20525c2 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 1 Dec 2014 22:04:49 +0100 Subject: [PATCH] mount: fix sysupgrade handling for mainline overlayfs Signed-off-by: Felix Fietkau --- libfstools/mount.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libfstools/mount.c b/libfstools/mount.c index 970b9cf..e095455 100644 --- a/libfstools/mount.c +++ b/libfstools/mount.c @@ -98,10 +98,13 @@ fopivot(char *rw_root, char *ro_root) */ snprintf(lowerdir, sizeof(lowerdir), "lowerdir=/,upperdir=%s", rw_root); if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, lowerdir)) { - char upperdir[64], workdir[64]; + 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(lowerdir, sizeof(lowerdir), "lowerdir=/,upperdir=%s,workdir=%s", upperdir, workdir); @@ -115,6 +118,9 @@ fopivot(char *rw_root, char *ro_root) 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, lowerdir)) { if (mount(overlay, "/mnt", "overlayfs", MS_NOATIME, lowerdir)) { -- 2.25.1