summaryrefslogtreecommitdiff
path: root/src/switchroot
diff options
context:
space:
mode:
authorJonathan Lebon <jonathan@jlebon.com>2018-07-03 17:41:45 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-04 16:06:38 +0000
commita13ea6497e91920e9d6297d14a132123a5e48b43 (patch)
tree75068099df40c7b0ebe3cb1213246cb22b4fd6b2 /src/switchroot
parent8af389b758970ce73929c84315505ac8410f355b (diff)
downloadostree-a13ea6497e91920e9d6297d14a132123a5e48b43.tar.gz
switchroot: Fix regression for separately mounted /var
I made a logical error in #1617 which resulted in the exact *opposite* behaviour we want when `/var` is a separate mount. Split this out and lower the number of negations to make it more obvious that it's correct. Closes: #1667 Closes: #1668 Approved by: cgwalters
Diffstat (limited to 'src/switchroot')
-rw-r--r--src/switchroot/ostree-prepare-root.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c
index 53df463c..0131d246 100644
--- a/src/switchroot/ostree-prepare-root.c
+++ b/src/switchroot/ostree-prepare-root.c
@@ -151,14 +151,17 @@ main(int argc, char *argv[])
if (chdir (deploy_path) < 0)
err (EXIT_FAILURE, "failed to chdir to deploy_path");
+ /* Default to true, but in the systemd case, default to false because it's handled by
+ * ostree-system-generator. */
bool mount_var = true;
- /* In the systemd case, this is handled by ostree-system-generator by default */
-#ifndef HAVE_SYSTEMD_AND_LIBMOUNT
- /* file in /run can override that behaviour */
- if (lstat (INITRAMFS_MOUNT_VAR, &stbuf) < 0)
- mount_var = false;
+#ifdef HAVE_SYSTEMD_AND_LIBMOUNT
+ mount_var = false;
#endif
+ /* file in /run can override the default behaviour so that we definitely mount /var */
+ if (lstat (INITRAMFS_MOUNT_VAR, &stbuf) == 0)
+ mount_var = true;
+
/* Link to the deployment's /var */
if (mount_var && mount ("../../var", "var", NULL, MS_MGC_VAL|MS_BIND, NULL) < 0)
err (EXIT_FAILURE, "failed to bind mount ../../var to var");