diff options
author | Colin Walters <walters@verbum.org> | 2018-03-22 10:14:22 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-22 19:02:29 +0000 |
commit | 38cf31f6a72a946a469a8fa649ade2193e041e9e (patch) | |
tree | cfd7f0feef39beb4427003c5cc5ebab8c654a65a /src/switchroot/ostree-mount-util.h | |
parent | 246a7a5cc21cefa57a908f4374a7e19766fb89cc (diff) | |
download | ostree-38cf31f6a72a946a469a8fa649ade2193e041e9e.tar.gz |
switchroot: Ensure /run/ostree-booted is created even without initramfs
See https://mail.gnome.org/archives/ostree-list/2018-March/msg00012.html
If ostree-prepare-root is run as pid 1 (i.e we're not using an initramfs), then
anything we write outside the target sysroot (such as `/run/ostree-booted`) will
be lost.
Since `ostree-remount.service` runs fairly early in boot, and is triggered via
`ConditionKernelCommandLine=ostree`, we can just touch the file there in
addition.
Closes: #1508
Approved by: akiernan
Diffstat (limited to 'src/switchroot/ostree-mount-util.h')
-rw-r--r-- | src/switchroot/ostree-mount-util.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/switchroot/ostree-mount-util.h b/src/switchroot/ostree-mount-util.h index 7cf7e09e..08e10f97 100644 --- a/src/switchroot/ostree-mount-util.h +++ b/src/switchroot/ostree-mount-util.h @@ -104,4 +104,19 @@ read_proc_cmdline_ostree (void) return ret; } +/* This is an API for other projects to determine whether or not the + * currently running system is ostree-controlled. + */ +static inline void +touch_run_ostree (void) +{ + int fd = open ("/run/ostree-booted", O_CREAT | O_WRONLY | O_NOCTTY | O_CLOEXEC, 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); +} + #endif /* __OSTREE_MOUNT_UTIL_H_ */ |