From: Alexander Larsson Date: Fri, 26 May 2023 10:53:57 +0000 (+0200) Subject: ostree-remount: Don't skip remount if root is composefs X-Git-Tag: archive/raspbian/2023.7-3+rpi1~1^2~9^2~1^2~29^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f9bdc66649a90e8834d5fa9adb65ede9b2453b8b;p=ostree.git ostree-remount: Don't skip remount if root is composefs When using composefs the root fs will always be read-only, but in this case we should still continue remounting /sysroot. So, we record a /run/ostree-composefs-root.stamp file in ostree-prepare-root if composefs is used, and then react to it in ostree-remount. --- diff --git a/src/switchroot/ostree-mount-util.h b/src/switchroot/ostree-mount-util.h index e3b0037a..b6ee2f56 100644 --- a/src/switchroot/ostree-mount-util.h +++ b/src/switchroot/ostree-mount-util.h @@ -32,6 +32,7 @@ #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) diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 3dbca634..a65da45b 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -330,7 +330,14 @@ main (int argc, char *argv[]) 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 diff --git a/src/switchroot/ostree-remount.c b/src/switchroot/ostree-remount.c index ba5a16b2..80f8ad34 100644 --- a/src/switchroot/ostree-remount.c +++ b/src/switchroot/ostree-remount.c @@ -95,7 +95,12 @@ main (int argc, char *argv[]) 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.