]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: non-functional changes 1547/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 10 May 2017 11:32:23 +0000 (13:32 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 10 May 2017 11:35:54 +0000 (13:35 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 8372da68a6d56665771ffe9b417cbcf7414c7954..35bdb249ba6248a1467c0ff89a367c5c3a19a55e 100644 (file)
@@ -1287,23 +1287,23 @@ int prepare_ramfs_root(char *root)
        char *p2;
 
        if (realpath(root, nroot) == NULL)
-               return -1;
+               return -errno;
 
        if (chdir("/") == -1)
-               return -1;
+               return -errno;
 
        /*
         * We could use here MS_MOVE, but in userns this mount is
         * locked and can't be moved.
         */
-       if (mount(root, "/", NULL, MS_REC | MS_BIND, NULL)) {
+       if (mount(root, "/", NULL, MS_REC | MS_BIND, NULL) < 0) {
                SYSERROR("Failed to move %s into /", root);
-               return -1;
+               return -errno;
        }
 
-       if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) {
+       if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL) < 0) {
                SYSERROR("Failed to make . rprivate");
-               return -1;
+               return -errno;
        }
 
        /*
@@ -1369,17 +1369,28 @@ int prepare_ramfs_root(char *root)
 
 static int setup_pivot_root(const struct lxc_rootfs *rootfs)
 {
-       if (!rootfs->path)
+       if (!rootfs->path) {
+               DEBUG("container does not have a rootfs, so not doing pivot root");
                return 0;
+       }
 
        if (detect_ramfs_rootfs()) {
-               if (prepare_ramfs_root(rootfs->mount))
+               DEBUG("detected that container is on ramfs");
+               if (prepare_ramfs_root(rootfs->mount)) {
+                       ERROR("failed to prepare minimal ramfs root");
                        return -1;
-       } else if (setup_rootfs_pivot_root(rootfs->mount)) {
-               ERROR("failed to setup pivot root");
+               }
+
+               DEBUG("prepared ramfs root for container");
+               return 0;
+       }
+
+       if (setup_rootfs_pivot_root(rootfs->mount) < 0) {
+               ERROR("failed to pivot root");
                return -1;
        }
 
+       DEBUG("finished pivot root");
        return 0;
 }