#define INITRAMFS_MOUNT_VAR "/run/ostree/initramfs-mount-var"
#define _OSTREE_SYSROOT_READONLY_STAMP "/run/ostree-sysroot-ro.stamp"
+#define _OSTREE_COMPOSEFS_ROOT_STAMP "/run/ostree-composefs-root.stamp"
static inline int
path_is_on_readonly_fs (const char *path)
err (EXIT_FAILURE, "Failed to mount composefs");
}
else
- using_composefs = 1;
+ {
+ int fd = open (_OSTREE_COMPOSEFS_ROOT_STAMP, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
+ if (fd < 0)
+ err (EXIT_FAILURE, "failed to create %s", _OSTREE_COMPOSEFS_ROOT_STAMP);
+ (void)close (fd);
+
+ using_composefs = 1;
+ }
#else
err (EXIT_FAILURE, "Composefs not supported");
#endif
if (mount ("none", "/sysroot", NULL, MS_REC | MS_PRIVATE, NULL) < 0)
perror ("warning: While remounting /sysroot MS_PRIVATE");
- if (path_is_on_readonly_fs ("/"))
+ bool root_is_composefs = false;
+ struct stat stbuf;
+ if (fstatat (AT_FDCWD, _OSTREE_COMPOSEFS_ROOT_STAMP, &stbuf, 0) == 0)
+ root_is_composefs = true;
+
+ if (path_is_on_readonly_fs ("/") && !root_is_composefs)
{
/* If / isn't writable, don't do any remounts; we don't want
* to clear the readonly flag in that case.