console: s/tty_info/ttys/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-02-27 18:23:07 +01:00
parent 2520facd01
commit 0e4be3cf03
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
5 changed files with 48 additions and 49 deletions

View File

@ -840,15 +840,15 @@ static bool append_ptyname(char **pp, char *name)
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))
@ -926,32 +926,32 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
}
}
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;
}
@ -974,33 +974,33 @@ int lxc_allocate_ttys(const char *name, struct lxc_conf *conf)
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;
@ -1009,7 +1009,7 @@ static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
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;
@ -1065,7 +1065,7 @@ static int lxc_create_ttys(struct lxc_handler *handler)
ret = 0;
on_error:
lxc_delete_tty(&conf->tty_info);
lxc_delete_tty(&conf->ttys);
return ret;
}

View File

@ -134,8 +134,7 @@ struct id_map {
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
*/
@ -203,7 +202,7 @@ enum {
* @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
@ -258,7 +257,7 @@ struct lxc_conf {
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;
@ -387,7 +386,7 @@ extern void lxc_conf_free(struct lxc_conf *conf);
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);

View File

@ -578,7 +578,7 @@ err1:
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) {
@ -589,10 +589,10 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
}
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 */
@ -601,18 +601,18 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
}
/* 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;
}
@ -620,12 +620,12 @@ out:
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) {

View File

@ -176,7 +176,7 @@ static void exec_criu(struct criu_opts *opts)
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
@ -233,12 +233,12 @@ static void exec_criu(struct criu_opts *opts)
*/
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;
@ -493,13 +493,13 @@ static void exec_criu(struct criu_opts *opts)
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;

View File

@ -824,7 +824,7 @@ int lxc_init(const char *name, struct lxc_handler *handler)
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:
@ -951,7 +951,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
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.
@ -1344,13 +1344,13 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
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++) {
@ -1360,7 +1360,7 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
if (ret < 0)
break;
tty = &tty_info->tty[i];
tty = &ttys->tty[i];
tty->busy = 0;
tty->master = ttyfds[0];
tty->slave = ttyfds[1];
@ -1373,7 +1373,7 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
else
TRACE("Received %d ttys from child", conf->tty);
tty_info->nbtty = conf->tty;
ttys->nbtty = conf->tty;
return ret;
}