static int lxc_setup_ttys(struct lxc_conf *conf)
{
int i, ret;
- const struct lxc_tty_info *tty_info = &conf->tty_info;
+ const struct lxc_tty_info *ttys = &conf->ttys;
char *ttydir = conf->ttydir;
char path[MAXPATHLEN], lxcpath[MAXPATHLEN];
if (!conf->rootfs.path)
return 0;
- for (i = 0; i < tty_info->nbtty; i++) {
- struct lxc_terminal_info *tty = &tty_info->tty[i];
+ for (i = 0; i < ttys->nbtty; i++) {
+ struct lxc_terminal_info *tty = &ttys->tty[i];
ret = snprintf(path, sizeof(path), "/dev/tty%d", i + 1);
if (ret < 0 || (size_t)ret >= sizeof(path))
}
}
- INFO("Finished setting up %d /dev/tty<N> device(s)", tty_info->nbtty);
+ INFO("Finished setting up %d /dev/tty<N> device(s)", ttys->nbtty);
return 0;
}
int lxc_allocate_ttys(const char *name, struct lxc_conf *conf)
{
- struct lxc_tty_info *tty_info = &conf->tty_info;
+ struct lxc_tty_info *ttys = &conf->ttys;
int i, ret;
/* no tty in the configuration */
if (!conf->tty)
return 0;
- tty_info->tty = malloc(sizeof(*tty_info->tty) * conf->tty);
- if (!tty_info->tty)
+ ttys->tty = malloc(sizeof(*ttys->tty) * conf->tty);
+ if (!ttys->tty)
return -ENOMEM;
for (i = 0; i < conf->tty; i++) {
- struct lxc_terminal_info *tty = &tty_info->tty[i];
+ struct lxc_terminal_info *tty = &ttys->tty[i];
ret = openpty(&tty->master, &tty->slave,
tty->name, NULL, NULL);
if (ret) {
SYSERROR("failed to create pty device number %d", i);
- tty_info->nbtty = i;
- lxc_delete_tty(tty_info);
+ ttys->nbtty = i;
+ lxc_delete_tty(ttys);
return -ENOTTY;
}
tty->busy = 0;
}
- tty_info->nbtty = conf->tty;
+ ttys->nbtty = conf->tty;
INFO("finished allocating %d pts devices", conf->tty);
return 0;
}
-void lxc_delete_tty(struct lxc_tty_info *tty_info)
+void lxc_delete_tty(struct lxc_tty_info *ttys)
{
int i;
- for (i = 0; i < tty_info->nbtty; i++) {
- struct lxc_terminal_info *tty = &tty_info->tty[i];
+ for (i = 0; i < ttys->nbtty; i++) {
+ struct lxc_terminal_info *tty = &ttys->tty[i];
close(tty->master);
close(tty->slave);
}
- free(tty_info->tty);
- tty_info->tty = NULL;
- tty_info->nbtty = 0;
+ free(ttys->tty);
+ ttys->tty = NULL;
+ ttys->nbtty = 0;
}
static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
{
int i;
struct lxc_conf *conf = handler->conf;
- struct lxc_tty_info *tty_info = &conf->tty_info;
+ struct lxc_tty_info *ttys = &conf->ttys;
int sock = handler->data_sock[0];
int ret = -1;
for (i = 0; i < conf->tty; i++) {
int ttyfds[2];
- struct lxc_terminal_info *tty = &tty_info->tty[i];
+ struct lxc_terminal_info *tty = &ttys->tty[i];
ttyfds[0] = tty->master;
ttyfds[1] = tty->slave;
ret = 0;
on_error:
- lxc_delete_tty(&conf->tty_info);
+ lxc_delete_tty(&conf->ttys);
return ret;
}
unsigned long hostid, nsid, range;
};
-/*
- * Defines the number of tty configured and contains the
+/* Defines the number of tty configured and contains the
* instantiated ptys
* @nbtty = number of configured ttys
*/
* @fstab : path to a fstab file format
* @caps : list of the capabilities to drop
* @keepcaps : list of the capabilities to keep
- * @tty_info : tty data
+ * @ttys : tty data
* @console : console data
* @ttydir : directory (under /dev) in which to create console and ttys
* @lsm_aa_profile : apparmor profile to switch to or NULL
struct lxc_list mount_list;
struct lxc_list caps;
struct lxc_list keepcaps;
- struct lxc_tty_info tty_info;
+ struct lxc_tty_info ttys;
/* Comma-separated list of lxc.tty.max pty names. */
char *pty_names;
struct lxc_terminal console;
extern int pin_rootfs(const char *rootfs);
extern int lxc_map_ids(struct lxc_list *idmap, pid_t pid);
extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
-extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
+extern void lxc_delete_tty(struct lxc_tty_info *ttys);
extern int lxc_clear_config_caps(struct lxc_conf *c);
extern int lxc_clear_config_keepcaps(struct lxc_conf *c);
extern int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version);
int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
{
int masterfd = -1, ttynum;
- struct lxc_tty_info *tty_info = &conf->tty_info;
+ struct lxc_tty_info *ttys = &conf->ttys;
struct lxc_terminal *terminal = &conf->console;
if (*ttyreq == 0) {
}
if (*ttyreq > 0) {
- if (*ttyreq > tty_info->nbtty)
+ if (*ttyreq > ttys->nbtty)
goto out;
- if (tty_info->tty[*ttyreq - 1].busy)
+ if (ttys->tty[*ttyreq - 1].busy)
goto out;
/* the requested tty is available */
}
/* search for next available tty, fixup index tty1 => [0] */
- for (ttynum = 1; ttynum <= tty_info->nbtty && tty_info->tty[ttynum - 1].busy; ttynum++)
+ for (ttynum = 1; ttynum <= ttys->nbtty && ttys->tty[ttynum - 1].busy; ttynum++)
;
/* we didn't find any available slot for tty */
- if (ttynum > tty_info->nbtty)
+ if (ttynum > ttys->nbtty)
goto out;
*ttyreq = ttynum;
out_tty:
- tty_info->tty[ttynum - 1].busy = sockfd;
- masterfd = tty_info->tty[ttynum - 1].master;
+ ttys->tty[ttynum - 1].busy = sockfd;
+ masterfd = ttys->tty[ttynum - 1].master;
out:
return masterfd;
}
void lxc_terminal_free(struct lxc_conf *conf, int fd)
{
int i;
- struct lxc_tty_info *tty_info = &conf->tty_info;
+ struct lxc_tty_info *ttys = &conf->ttys;
struct lxc_terminal *terminal = &conf->console;
- for (i = 0; i < tty_info->nbtty; i++) {
- if (tty_info->tty[i].busy == fd)
- tty_info->tty[i].busy = 0;
+ for (i = 0; i < ttys->nbtty; i++) {
+ if (ttys->tty[i].busy == fd)
+ ttys->tty[i].busy = 0;
}
if (terminal->peerpty.busy == fd) {
FILE *mnts;
struct mntent mntent;
- char buf[4096], tty_info[32];
+ char buf[4096], ttys[32];
size_t pos;
/* If we are currently in a cgroup /foo/bar, and the container is in a
*/
static_args += 6;
- tty_info[0] = 0;
- if (load_tty_major_minor(opts->user->directory, tty_info, sizeof(tty_info)))
+ ttys[0] = 0;
+ if (load_tty_major_minor(opts->user->directory, ttys, sizeof(ttys)))
return;
/* --inherit-fd fd[%d]:tty[%s] */
- if (tty_info[0])
+ if (ttys[0])
static_args += 2;
} else {
return;
DECLARE_ARG("--restore-detached");
DECLARE_ARG("--restore-sibling");
- if (tty_info[0]) {
+ if (ttys[0]) {
if (opts->console_fd < 0) {
ERROR("lxc.console.path configured on source host but not target");
goto err;
}
- ret = snprintf(buf, sizeof(buf), "fd[%d]:%s", opts->console_fd, tty_info);
+ ret = snprintf(buf, sizeof(buf), "fd[%d]:%s", opts->console_fd, ttys);
if (ret < 0 || ret >= sizeof(buf))
goto err;
out_restore_sigmask:
sigprocmask(SIG_SETMASK, &handler->oldmask, NULL);
out_delete_tty:
- lxc_delete_tty(&conf->tty_info);
+ lxc_delete_tty(&conf->ttys);
out_aborting:
lxc_set_state(name, handler, ABORTING);
out_close_maincmd_fd:
WARN("%s - Failed to restore signal mask", strerror(errno));
lxc_terminal_delete(&handler->conf->console);
- lxc_delete_tty(&handler->conf->tty_info);
+ lxc_delete_tty(&handler->conf->ttys);
/* The command socket is now closed, no more state clients can register
* themselves from now on. So free the list of state clients.
int ret = -1;
int sock = handler->data_sock[1];
struct lxc_conf *conf = handler->conf;
- struct lxc_tty_info *tty_info = &conf->tty_info;
+ struct lxc_tty_info *ttys = &conf->ttys;
if (!conf->tty)
return 0;
- tty_info->tty = malloc(sizeof(*tty_info->tty) * conf->tty);
- if (!tty_info->tty)
+ ttys->tty = malloc(sizeof(*ttys->tty) * conf->tty);
+ if (!ttys->tty)
return -1;
for (i = 0; i < conf->tty; i++) {
if (ret < 0)
break;
- tty = &tty_info->tty[i];
+ tty = &ttys->tty[i];
tty->busy = 0;
tty->master = ttyfds[0];
tty->slave = ttyfds[1];
else
TRACE("Received %d ttys from child", conf->tty);
- tty_info->nbtty = conf->tty;
+ ttys->nbtty = conf->tty;
return ret;
}