summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lebon <jonathan@jlebon.com>2022-01-12 13:39:59 -0500
committerGitHub <noreply@github.com>2022-01-12 13:39:59 -0500
commit1af0150750fbedc780e8348c5927843824c65be0 (patch)
treef4383d2d2c9de0b71f36e8b1f76f7ad30cb252bb
parent8aeceb9b8837cbf67421fe78900c9e477733f7b6 (diff)
parent0ff4bee74348e6894795ba3a5ac2bfab8aab7f28 (diff)
downloadostree-1af0150750fbedc780e8348c5927843824c65be0.tar.gz
Merge pull request #2516 from cgwalters/define-ostree-booted
-rw-r--r--src/libostree/ostree-sysroot.c6
-rw-r--r--src/libostree/ostree-sysroot.h8
-rw-r--r--src/ostree/ot-admin-builtin-finalize-staged.c2
-rw-r--r--src/ostree/ot-main.c2
4 files changed, 13 insertions, 5 deletions
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
index eccf9375..9cb40e66 100644
--- a/src/libostree/ostree-sysroot.c
+++ b/src/libostree/ostree-sysroot.c
@@ -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);
}
}
diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h
index 41361716..c240aaa0 100644
--- a/src/libostree/ostree-sysroot.h
+++ b/src/libostree/ostree-sysroot.h
@@ -24,6 +24,14 @@
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))
diff --git a/src/ostree/ot-admin-builtin-finalize-staged.c b/src/ostree/ot-admin-builtin-finalize-staged.c
index 80d8a9b7..17b6a625 100644
--- a/src/ostree/ot-admin-builtin-finalize-staged.c
+++ b/src/ostree/ot-admin-builtin-finalize-staged.c
@@ -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 ("");
diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c
index 7a4c4707..b7b50d67 100644
--- a/src/ostree/ot-main.c
+++ b/src/ostree/ot-main.c
@@ -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;