[LXC_ERROR_CONF_NETWORK] = "Failed to configure the network",
[LXC_ERROR_CONF_TTY] = "Failed to configure the tty",
[LXC_ERROR_CONF_ROOTFS] = "Failed to configure the root fs",
+ [LXC_ERROR_CONF_PTS] = "Failed to configure the pts",
[LXC_ERROR_SETUP_CGROUP] = "Failed to setup the control group",
[LXC_ERROR_SETUP_MOUNT] = "Failed to setup the mount points",
[LXC_ERROR_SETUP_CONSOLE] = "Failed to setup the console",
[LXC_ERROR_SETUP_TTY] = "Failed to setup the tty",
[LXC_ERROR_SETUP_ROOTFS] = "Failed to setup the root fs",
+ [LXC_ERROR_SETUP_PTS] = "Failed to setup the new pts instance",
[LXC_ERROR_TTY_DENIED] = "tty service denied",
[LXC_ERROR_TTY_EAGAIN] = "tty service is not available",
LXC_ERROR_CONF_NETWORK,
LXC_ERROR_CONF_TTY,
LXC_ERROR_CONF_ROOTFS,
+ LXC_ERROR_CONF_PTS,
LXC_ERROR_SETUP_CGROUP,
LXC_ERROR_SETUP_MOUNT,
LXC_ERROR_SETUP_CONSOLE,
LXC_ERROR_SETUP_TTY,
LXC_ERROR_SETUP_ROOTFS,
+ LXC_ERROR_SETUP_PTS,
LXC_ERROR_TTY_DENIED,
LXC_ERROR_TTY_EAGAIN,
return symlink(absrootfs, path);
}
+static int configure_pts(const char *name, int pts)
+{
+ char path[MAXPATHLEN];
+ char *maxpts;
+ int ret;
+
+ if (asprintf(&maxpts, "%d", pts) < 0) {
+ lxc_log_error("failed to convert max pts number");
+ return -1;
+ }
+
+ snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
+
+ ret = write_info(path, "pts", maxpts);
+ if (ret)
+ lxc_log_error("failed to write the pts info");
+
+ free(maxpts);
+
+ return ret;
+}
+
static int configure_mount(const char *name, const char *fstab)
{
char path[MAXPATHLEN];
return 0;
}
+static int unconfigure_pts(const char *name)
+{
+ char path[MAXPATHLEN];
+
+ snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
+ delete_info(path, "pts");
+
+ return 0;
+}
+
static int unconfigure_tty(const char *name)
{
char path[MAXPATHLEN];
return -LXC_ERROR_CONF_MOUNT;
}
+ if (conf->pts && configure_pts(name, conf->pts)) {
+ lxc_log_error("failed to configure a new pts instance");
+ return -LXC_ERROR_CONF_PTS;
+ }
+
return 0;
}
lxc_log_error("failed to cleanup cgroup");
if (conf_has_tty(name) && unconfigure_tty(name))
- lxc_log_error("failed to cleanup mount");
+ lxc_log_error("failed to cleanup tty");
if (conf_has_rootfs(name) && unconfigure_rootfs(name))
lxc_log_error("failed to cleanup rootfs");
if (conf_has_fstab(name) && unconfigure_mount(name))
lxc_log_error("failed to cleanup mount");
+ if (conf_has_pts(name) && unconfigure_pts(name))
+ lxc_log_error("failed to cleanup pts");
+
return 0;
}
char *rootfs;
char *fstab;
int tty;
+ int pts;
struct utsname *utsname;
struct lxc_list cgroup;
struct lxc_list networks;
#define conf_has_console(__name) conf_has(__name, "console")
#define conf_has_cgroup(__name) conf_has(__name, "cgroup")
#define conf_has_tty(__name) conf_has(__name, "tty")
-
+#define conf_has_pts(__name) conf_has(__name, "pts")
#endif
typedef int (*file_cb)(char* buffer, void *data);
typedef int (*config_cb)(const char *, char *, struct lxc_conf *);
+static int config_pts(const char *, char *, struct lxc_conf *);
static int config_tty(const char *, char *, struct lxc_conf *);
static int config_cgroup(const char *, char *, struct lxc_conf *);
static int config_mount(const char *, char *, struct lxc_conf *);
static struct config config[] = {
+ { "lxc.pts", config_pts },
{ "lxc.tty", config_tty },
{ "lxc.cgroup", config_cgroup },
{ "lxc.mount", config_mount },
return 0;
}
+static int config_pts(const char *key, char *value, struct lxc_conf *lxc_conf)
+{
+ int maxpts = atoi(value);
+
+ lxc_conf->pts = maxpts;
+
+ return 0;
+}
+
static int config_tty(const char *key, char *value, struct lxc_conf *lxc_conf)
{
int nbtty = atoi(value);
conf->fstab = NULL;
conf->utsname = NULL;
conf->tty = 0;
+ conf->pts = 0;
lxc_list_init(&conf->cgroup);
lxc_list_init(&conf->networks);
return 0;