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