[ostree] Add /run/ostree-booted



commit 79fa7ca692f8b720503c2a0c5fe272ff5db594a4
Author: Colin Walters <walters verbum org>
Date:   Fri Feb 28 03:48:23 2014 -0500

    Add /run/ostree-booted
    
    The idea with this is that things like yum should be able to look for
    it and determine whether or not they should assume that they can
    change things on the system.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725380

 src/switchroot/ostree-prepare-root.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c
index 7d6f8d7..b6b5f4a 100644
--- a/src/switchroot/ostree-prepare-root.c
+++ b/src/switchroot/ostree-prepare-root.c
@@ -93,6 +93,23 @@ parse_ostree_cmdline (void)
   return ret;
 }
 
+/* This is an API for other projects to determine whether or not the
+ * currently running system is ostree-controlled.
+ */
+static void
+touch_run_ostree (void)
+{
+  int fd;
+  
+  fd = open ("/run/ostree-booted", O_CREAT | O_WRONLY | O_NOCTTY, 0640);
+  /* We ignore failures here in case /run isn't mounted...not much we
+   * can do about that, but we don't want to fail.
+   */
+  if (fd == -1)
+    return;
+  (void) close (fd);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -189,6 +206,8 @@ main(int argc, char *argv[])
        }
     }
 
+  touch_run_ostree ();
+
   /* This is a bit hacky - move our deployment to /sysroot, since
    * systemd's initrd-switch-root target hardcodes looking for it
    * there.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]