sysroot: Add a public `#define OSTREE_PATH_BOOTED`
authorColin Walters <walters@verbum.org>
Wed, 12 Jan 2022 17:47:11 +0000 (12:47 -0500)
committerColin Walters <walters@verbum.org>
Wed, 12 Jan 2022 17:47:11 +0000 (12:47 -0500)
This is public API.  Motivated by
https://github.com/coreos/rpm-ostree/pull/3325/files#diff-56528694f6f3213d6fb88d872f77291412dceec263b57166519843b13eca9a4dR30

src/libostree/ostree-sysroot.c
src/libostree/ostree-sysroot.h
src/ostree/ot-admin-builtin-finalize-staged.c
src/ostree/ot-main.c

index eccf9375aec22db97ad9b60b2d9359e82a9360cd..9cb40e66997440092e8f115e811a29a84263c41a 100644 (file)
@@ -973,7 +973,7 @@ ostree_sysroot_initialize (OstreeSysroot  *self,
        * we'll use it to sanity check that we found a booted deployment for example.
        * Second, we also find out whether sysroot == /.
        */
-      if (!glnx_fstatat_allow_noent (AT_FDCWD, "/run/ostree-booted", NULL, 0, error))
+      if (!glnx_fstatat_allow_noent (AT_FDCWD, OSTREE_PATH_BOOTED, NULL, 0, error))
         return FALSE;
       const gboolean ostree_booted = (errno == 0);
 
@@ -1106,11 +1106,11 @@ sysroot_load_from_bootloader_configs (OstreeSysroot  *self,
         return FALSE;
       if (errno == ENOENT)
         {
-          return glnx_throw (error, "Unexpected state: /run/ostree-booted found, but no /boot/loader directory");
+          return glnx_throw (error, "Unexpected state: %s found, but no /boot/loader directory", OSTREE_PATH_BOOTED);
         }
       else
         {
-          return glnx_throw (error, "Unexpected state: /run/ostree-booted found and in / sysroot, but bootloader entry not found");
+          return glnx_throw (error, "Unexpected state: %s found and in / sysroot, but bootloader entry not found", OSTREE_PATH_BOOTED);
         }
      }
 
index 41361716db7c07f23531fa347c734c41460bca1f..c240aaa06b03285f32ac720f9c312989722bb33e 100644 (file)
 
 G_BEGIN_DECLS
 
+/**
+ * OSTREE_PATH_BOOTED:
+ * Filesystem path that is created on an ostree-booted system.
+ *
+ * Since: 2022.2
+ */
+#define OSTREE_PATH_BOOTED "/run/ostree-booted"
+
 #define OSTREE_TYPE_SYSROOT ostree_sysroot_get_type()
 #define OSTREE_SYSROOT(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSTREE_TYPE_SYSROOT, OstreeSysroot))
index 80d8a9b79948d7ea771a406cf8d3061db12ae760..17b6a6255a96380f05db87638a079052425e0ef0 100644 (file)
@@ -45,7 +45,7 @@ ot_admin_builtin_finalize_staged (int argc, char **argv, OstreeCommandInvocation
   /* Just a sanity check; we shouldn't be called outside of the service though.
    */
   struct stat stbuf;
-  if (fstatat (AT_FDCWD, "/run/ostree-booted", &stbuf, 0) < 0)
+  if (fstatat (AT_FDCWD, OSTREE_PATH_BOOTED, &stbuf, 0) < 0)
     return TRUE;
 
   g_autoptr(GOptionContext) context = g_option_context_new ("");
index 7a4c470787c3e5f49c7452c04e17032977296bf7..b7b50d67e34a7e9e0b2eae3787d47704c0d8aedb 100644 (file)
@@ -120,7 +120,7 @@ maybe_setup_mount_namespace (gboolean    *out_ns,
     return TRUE;
 
   /* If the system isn't booted via libostree, also nothing to do */
-  if (!glnx_fstatat_allow_noent (AT_FDCWD, "/run/ostree-booted", NULL, 0, error))
+  if (!glnx_fstatat_allow_noent (AT_FDCWD, OSTREE_PATH_BOOTED, NULL, 0, error))
     return FALSE;
   if (errno == ENOENT)
     return TRUE;