]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Only mount /proc if needed, even without a rootfs
authorDavid Ward <david.ward@ll.mit.edu>
Tue, 23 Jun 2015 14:57:19 +0000 (10:57 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 27 Aug 2015 21:47:46 +0000 (17:47 -0400)
Use the same code with and without a rootfs to check if mounting
/proc is necessary before doing so. If mounting it is unsuccessful
and there is no rootfs, continue as before.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c

index b9acc5d3738122c7fbf82b301684e91f2add77be..0d617ea8e43b746112dc5a4cc83dadc5ab240d32 100644 (file)
@@ -3484,17 +3484,12 @@ int tmp_proc_mount(struct lxc_conf *lxc_conf)
 {
        int mounted;
 
-       if (lxc_conf->rootfs.path == NULL || strlen(lxc_conf->rootfs.path) == 0) {
-               if (mount("proc", "/proc", "proc", 0, NULL)) {
-                       SYSERROR("Failed mounting /proc, proceeding");
-                       mounted = 0;
-               } else
-                       mounted = 1;
-       } else
-               mounted = mount_proc_if_needed(lxc_conf->rootfs.mount);
+       mounted = mount_proc_if_needed(lxc_conf->rootfs.path ? lxc_conf->rootfs.mount : "");
        if (mounted == -1) {
                SYSERROR("failed to mount /proc in the container.");
-               return -1;
+               /* continue only if there is no rootfs */
+               if (lxc_conf->rootfs.path)
+                       return -1;
        } else if (mounted == 1) {
                lxc_conf->tmp_umount_proc = 1;
        }