return 0;
}
+static int setup_console(const char *name, const char *tty)
+{
+ if (access("/dev/console", R_OK|W_OK))
+ return 0;
+
+ if (mount(tty, "/dev/console", "none", MS_BIND, 0)) {
+ lxc_log_error("failed to mount the console");
+ return -1;
+ }
+
+ return 0;
+}
+
static int setup_cgroup_cb(void* buffer, void *data)
{
char *key = buffer, *value;
int conf_destroy_network(const char *name)
{
+#ifdef NETWORK_DESTROY
if (delete_netdev(name)) {
lxc_log_error("failed to remove the network devices");
return -1;
}
-
+#endif
return 0;
}
-int lxc_setup(const char *name)
+int lxc_setup(const char *name, const char *tty)
{
if (conf_has_utsname(name) && setup_utsname(name)) {
lxc_log_error("failed to setup the utsname for '%s'", name);
}
if (conf_has_fstab(name) && setup_mount(name)) {
- lxc_log_error("failed to setup the mount points for '%s'", name);
+ lxc_log_error("failed to setup the mounts for '%s'", name);
return -LXC_ERROR_SETUP_MOUNT;
}
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;
+ }
+
return 0;
}
/*
* Configure the container from inside
*/
-extern int lxc_setup(const char *name);
+extern int lxc_setup(const char *name, const char *tty);
extern int conf_has(const char *name, const char *info);
#define conf_has_rootfs(__name) conf_has(__name, "rootfs")
#define conf_has_utsname(__name) conf_has(__name, "utsname")
#define conf_has_network(__name) conf_has(__name, "network")
+#define conf_has_console(__name) conf_has(__name, "console")
#define conf_has_cgroup(__name) conf_has(__name, "cgroup")
#endif