]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Change access mount and check on the console
authordlezcano <dlezcano>
Tue, 9 Dec 2008 17:38:18 +0000 (17:38 +0000)
committerdlezcano <dlezcano>
Tue, 9 Dec 2008 17:38:18 +0000 (17:38 +0000)
From: Daniel Lezcano <dlezcano@fr.ibm.com>

Changed to access the console to the rootfs directly.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_conf.c

index a6219ffe2ac585f4546948575b2bed8ca9d558bc..ab3586035576013a6432ff1f07fddc6be4a8e122 100644 (file)
@@ -668,10 +668,14 @@ static int setup_rootfs(const char *name)
 
 static int setup_console(const char *name, const char *tty)
 {
-       if (access("/dev/console", R_OK|W_OK))
+       char console[MAXPATHLEN];
+
+       snprintf(console, MAXPATHLEN, LXCPATH "/%s/rootfs/dev/console", name);
+
+       if (access(console, R_OK|W_OK))
                return 0;
        
-       if (mount(tty, "/dev/console", "none", MS_BIND, 0)) {
+       if (mount(tty, console, "none", MS_BIND, 0)) {
                lxc_log_error("failed to mount the console");
                return -1;
        }
@@ -1411,15 +1415,15 @@ int lxc_setup(const char *name, const char *tty)
                return -LXC_ERROR_SETUP_MOUNT;
        }
 
-       if (conf_has_rootfs(name) && setup_rootfs(name)) {
-               lxc_log_error("failed to set rootfs for '%s'", name);
-               return -LXC_ERROR_SETUP_ROOTFS;
-       }
-
        if (tty[0] && setup_console(name, tty)) {
                lxc_log_error("failed to setup the console for '%s'", name);
                return -LXC_ERROR_SETUP_CONSOLE;
        }
 
+       if (conf_has_rootfs(name) && setup_rootfs(name)) {
+               lxc_log_error("failed to set rootfs for '%s'", name);
+               return -LXC_ERROR_SETUP_ROOTFS;
+       }
+
        return 0;
 }