From 9d28c4f980502f3bc5b7c6347d1af7bd165336a0 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Mon, 31 Jul 2017 22:54:38 +0200 Subject: [PATCH] devpts: use max= option on mount This will only work with kernels >= 3.4 Signed-off-by: Christian Brauner --- src/lxc/conf.c | 8 +++++++- src/tests/console.c | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index ab038d36d..25d29c20a 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1332,7 +1332,8 @@ static int setup_pivot_root(const struct lxc_rootfs *rootfs) static int lxc_setup_devpts(int num_pts) { int ret; - const char *devpts_mntopts = "newinstance,ptmxmode=0666,mode=0620,gid=5"; + const char *default_devpts_mntopts = "newinstance,ptmxmode=0666,mode=0620,gid=5"; + char devpts_mntopts[256]; if (!num_pts) { DEBUG("no new devpts instance will be mounted since no pts " @@ -1340,6 +1341,11 @@ static int lxc_setup_devpts(int num_pts) return 0; } + ret = snprintf(devpts_mntopts, sizeof(devpts_mntopts), "%s,max=%d", + default_devpts_mntopts, num_pts); + if (ret < 0 || (size_t)ret >= sizeof(devpts_mntopts)) + return -1; + /* Unmount old devpts instance. */ ret = access("/dev/pts/ptmx", F_OK); if (!ret) { diff --git a/src/tests/console.c b/src/tests/console.c index c47f25344..9c32cf269 100644 --- a/src/tests/console.c +++ b/src/tests/console.c @@ -146,6 +146,7 @@ static int test_console(const char *lxcpath, } c->load_config(c, NULL); c->set_config_item(c, "lxc.tty.max", TTYCNT_STR); + c->set_config_item(c, "lxc.pty.max", "1024"); c->save_config(c, NULL); c->want_daemonize(c, true); if (!c->startl(c, 0, NULL)) { -- 2.47.2