- 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;