[ostree] prepare-root: set up /boot bind-mount for single partition systems



commit 598530daf45a8bcb3be171732569b8aad0f4345d
Author: Daniel Drake <drake endlessm com>
Date:   Tue Jul 21 08:04:34 2015 -0600

    prepare-root: set up /boot bind-mount for single partition systems
    
    When booting from a system with /boot on the main partition, set up
    an appropriate bind mount during boot. The ostree runtime binary
    expects to be able to access the bootloader configs at /boot.
    
    See: https://mail.gnome.org/archives/ostree-list/2015-July/msg00015.html
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756267

 src/switchroot/ostree-prepare-root.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c
index bb9ba13..3de137b 100644
--- a/src/switchroot/ostree-prepare-root.c
+++ b/src/switchroot/ostree-prepare-root.c
@@ -194,6 +194,23 @@ main(int argc, char *argv[])
       exit (EXIT_FAILURE);
     }
 
+  /* If /boot is on the same partition, use a bind mount to make it visible
+   * at /boot inside the deployment. */
+  snprintf (srcpath, sizeof(srcpath), "%s/boot/loader", root_mountpoint);
+  if (lstat (srcpath, &stbuf) == 0 && S_ISLNK (stbuf.st_mode))
+    {
+      snprintf (destpath, sizeof(destpath), "%s/boot", newroot);
+      if (lstat (destpath, &stbuf) == 0 && S_ISDIR (stbuf.st_mode))
+        {
+          snprintf (srcpath, sizeof(srcpath), "%s/boot", root_mountpoint);
+          if (mount (srcpath, destpath, NULL, MS_BIND, NULL) < 0)
+            {
+              perrorv ("failed to bind mount %s to %s", srcpath, destpath);
+              exit (EXIT_FAILURE);
+            }
+        }
+    }
+
   /* Set up any read-only bind mounts (notably /usr) */
   for (i = 0; readonly_bind_mounts[i] != NULL; i++)
     {


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