switchroot: use shared constant for unlock --hotfix
authorColin Walters <walters@verbum.org>
Wed, 3 Jan 2024 18:05:15 +0000 (13:05 -0500)
committerColin Walters <walters@verbum.org>
Wed, 3 Jan 2024 19:33:55 +0000 (14:33 -0500)
So it's easier to link the two bits of code.

src/libotcore/otcore.h
src/switchroot/ostree-prepare-root.c

index 4d51398e6a686f2fa6d6ef8a33bf1f4e187dffac..1fe4be015e8e12f268e7fc19fd9ef6e1c3c25151 100644 (file)
@@ -60,6 +60,9 @@ GKeyFile *otcore_load_config (int rootfs, const char *filename, GError **error);
 // The directory holding the root overlayfs
 #define OSTREE_DEPLOYMENT_ROOT_TRANSIENT_DIR "root-transient"
 
+// Written by ostree admin unlock --hotfix, read by ostree-prepare-root
+#define OTCORE_HOTFIX_USR_OVL_WORK ".usr-ovl-work"
+
 // The name of the composefs metadata root
 #define OSTREE_COMPOSEFS_NAME ".ostree.cfs"
 // The temporary directory used for the EROFS mount; it's in the .private directory
index 1a0539e190d31fd13c6f3383512e41671a4dc70c..5f4d213286b31f6c31efacd87c4ae8e30614e545 100644 (file)
@@ -632,12 +632,17 @@ main (int argc, char *argv[])
     }
 
   /* Prepare /usr.
-   * It may be either just a read-only bind-mount, or a persistent overlayfs. */
-  if (lstat (".usr-ovl-work", &stbuf) == 0)
+   * It may be either just a read-only bind-mount, or a persistent overlayfs if set up
+   * with ostree admin unlock --hotfix.
+   * Note however that root.transient as handled above is effectively a generalization of unlock
+   * --hotfix.
+   */
+  if (lstat (OTCORE_HOTFIX_USR_OVL_WORK, &stbuf) == 0)
     {
       /* Do we have a persistent overlayfs for /usr?  If so, mount it now. */
       const char usr_ovl_options[]
-          = "lowerdir=" TMP_SYSROOT "/usr,upperdir=.usr-ovl-upper,workdir=.usr-ovl-work";
+          = "lowerdir=" TMP_SYSROOT
+            "/usr,upperdir=.usr-ovl-upper,workdir=" OTCORE_HOTFIX_USR_OVL_WORK;
 
       /* Except overlayfs barfs if we try to mount it on a read-only
        * filesystem.  For this use case I think admins are going to be