]> git.proxmox.com Git - mirror_lxc.git/commitdiff
console: s/pty_info/tty/g
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 27 Feb 2018 17:20:00 +0000 (18:20 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 27 Feb 2018 21:42:36 +0000 (22:42 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/console.c
src/lxc/start.c

index 1aa5bb6216d6adbb5aa1d7676a9cd602aeff332b..4f87a7e6f16355bb1e27788fb414d00d9004ead7 100644 (file)
@@ -848,7 +848,7 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
                return 0;
 
        for (i = 0; i < tty_info->nbtty; i++) {
-               struct lxc_terminal_info *pty_info = &tty_info->pty_info[i];
+               struct lxc_terminal_info *tty = &tty_info->tty[i];
 
                ret = snprintf(path, sizeof(path), "/dev/tty%d", i + 1);
                if (ret < 0 || (size_t)ret >= sizeof(path))
@@ -875,13 +875,13 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
                                return -1;
                        }
 
-                       ret = mount(pty_info->name, lxcpath, "none", MS_BIND, 0);
+                       ret = mount(tty->name, lxcpath, "none", MS_BIND, 0);
                        if (ret < 0) {
                                WARN("Failed to bind mount \"%s\" onto \"%s\"",
-                                    pty_info->name, path);
+                                    tty->name, path);
                                continue;
                        }
-                       DEBUG("bind mounted \"%s\" onto \"%s\"", pty_info->name,
+                       DEBUG("bind mounted \"%s\" onto \"%s\"", tty->name,
                              path);
 
                        ret = snprintf(lxcpath, sizeof(lxcpath), "%s/tty%d",
@@ -910,17 +910,17 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
                                }
                        }
 
-                       ret = mount(pty_info->name, path, "none", MS_BIND, 0);
+                       ret = mount(tty->name, path, "none", MS_BIND, 0);
                        if (ret < 0) {
-                               SYSERROR("Failed to mount '%s'->'%s'", pty_info->name, path);
+                               SYSERROR("Failed to mount '%s'->'%s'", tty->name, path);
                                continue;
                        }
 
-                       DEBUG("Bind mounted \"%s\" onto \"%s\"", pty_info->name,
+                       DEBUG("Bind mounted \"%s\" onto \"%s\"", tty->name,
                              path);
                }
 
-               if (!append_ptyname(&conf->pty_names, pty_info->name)) {
+               if (!append_ptyname(&conf->pty_names, tty->name)) {
                        ERROR("Error setting up container_ttys string");
                        return -1;
                }
@@ -939,17 +939,15 @@ int lxc_allocate_ttys(const char *name, struct lxc_conf *conf)
        if (!conf->tty)
                return 0;
 
-       tty_info->pty_info = malloc(sizeof(*tty_info->pty_info) * conf->tty);
-       if (!tty_info->pty_info) {
-               SYSERROR("failed to allocate struct *pty_info");
+       tty_info->tty = malloc(sizeof(*tty_info->tty) * conf->tty);
+       if (!tty_info->tty)
                return -ENOMEM;
-       }
 
        for (i = 0; i < conf->tty; i++) {
-               struct lxc_terminal_info *pty_info = &tty_info->pty_info[i];
+               struct lxc_terminal_info *tty = &tty_info->tty[i];
 
-               ret = openpty(&pty_info->master, &pty_info->slave,
-                             pty_info->name, NULL, NULL);
+               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;
@@ -958,22 +956,22 @@ int lxc_allocate_ttys(const char *name, struct lxc_conf *conf)
                }
 
                DEBUG("allocated pty \"%s\" with master fd %d and slave fd %d",
-                     pty_info->name, pty_info->master, pty_info->slave);
+                     tty->name, tty->master, tty->slave);
 
                /* Prevent leaking the file descriptors to the container */
-               ret = fcntl(pty_info->master, F_SETFD, FD_CLOEXEC);
+               ret = fcntl(tty->master, F_SETFD, FD_CLOEXEC);
                if (ret < 0)
                        WARN("failed to set FD_CLOEXEC flag on master fd %d of "
                             "pty device \"%s\": %s",
-                            pty_info->master, pty_info->name, strerror(errno));
+                            tty->master, tty->name, strerror(errno));
 
-               ret = fcntl(pty_info->slave, F_SETFD, FD_CLOEXEC);
+               ret = fcntl(tty->slave, F_SETFD, FD_CLOEXEC);
                if (ret < 0)
                        WARN("failed to set FD_CLOEXEC flag on slave fd %d of "
                             "pty device \"%s\": %s",
-                            pty_info->slave, pty_info->name, strerror(errno));
+                            tty->slave, tty->name, strerror(errno));
 
-               pty_info->busy = 0;
+               tty->busy = 0;
        }
 
        tty_info->nbtty = conf->tty;
@@ -987,14 +985,14 @@ void lxc_delete_tty(struct lxc_tty_info *tty_info)
        int i;
 
        for (i = 0; i < tty_info->nbtty; i++) {
-               struct lxc_terminal_info *pty_info = &tty_info->pty_info[i];
+               struct lxc_terminal_info *tty = &tty_info->tty[i];
 
-               close(pty_info->master);
-               close(pty_info->slave);
+               close(tty->master);
+               close(tty->slave);
        }
 
-       free(tty_info->pty_info);
-       tty_info->pty_info = NULL;
+       free(tty_info->tty);
+       tty_info->tty = NULL;
        tty_info->nbtty = 0;
 }
 
@@ -1011,17 +1009,17 @@ 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 *pty_info = &tty_info->pty_info[i];
+               struct lxc_terminal_info *tty = &tty_info->tty[i];
 
-               ttyfds[0] = pty_info->master;
-               ttyfds[1] = pty_info->slave;
+               ttyfds[0] = tty->master;
+               ttyfds[1] = tty->slave;
 
                ret = lxc_abstract_unix_send_fds(sock, ttyfds, 2, NULL, 0);
                if (ret < 0)
                        break;
 
                TRACE("Send pty \"%s\" with master fd %d and slave fd %d to "
-                     "parent", pty_info->name, pty_info->master, pty_info->slave);
+                     "parent", tty->name, tty->master, tty->slave);
        }
 
        if (ret < 0)
index 1f7cd3807f46dbf8a2db7d6fa2ca431a8c56901f..c138c855a90e83432d001a0590ce7dcab7634d9d 100644 (file)
@@ -141,7 +141,7 @@ struct id_map {
  */
 struct lxc_tty_info {
        int nbtty;
-       struct lxc_terminal_info *pty_info;
+       struct lxc_terminal_info *tty;
 };
 
 struct lxc_tty_state;
index 6534162c4e5ceb4996830660f114d2326c65b441..8123f2a4fd0b1e743266730eb54fe9243ba47a2f 100644 (file)
@@ -592,7 +592,7 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
                if (*ttyreq > tty_info->nbtty)
                        goto out;
 
-               if (tty_info->pty_info[*ttyreq - 1].busy)
+               if (tty_info->tty[*ttyreq - 1].busy)
                        goto out;
 
                /* the requested tty is available */
@@ -601,7 +601,7 @@ 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->pty_info[ttynum - 1].busy; ttynum++)
+       for (ttynum = 1; ttynum <= tty_info->nbtty && tty_info->tty[ttynum - 1].busy; ttynum++)
                ;
 
        /* we didn't find any available slot for tty */
@@ -611,8 +611,8 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
        *ttyreq = ttynum;
 
 out_tty:
-       tty_info->pty_info[ttynum - 1].busy = sockfd;
-       masterfd = tty_info->pty_info[ttynum - 1].master;
+       tty_info->tty[ttynum - 1].busy = sockfd;
+       masterfd = tty_info->tty[ttynum - 1].master;
 out:
        return masterfd;
 }
@@ -624,8 +624,8 @@ void lxc_terminal_free(struct lxc_conf *conf, int fd)
        struct lxc_terminal *terminal = &conf->console;
 
        for (i = 0; i < tty_info->nbtty; i++) {
-               if (tty_info->pty_info[i].busy == fd)
-                       tty_info->pty_info[i].busy = 0;
+               if (tty_info->tty[i].busy == fd)
+                       tty_info->tty[i].busy = 0;
        }
 
        if (terminal->peerpty.busy == fd) {
index fbe50d3214ae74673e06c9f2f94f3d7116dbb398..d70e716443ab895b1f52fe7da04734a9426bab17 100644 (file)
@@ -1340,7 +1340,7 @@ out_error:
 static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
 {
        int i;
-       struct lxc_terminal_info *pty_info;
+       struct lxc_terminal_info *tty;
        int ret = -1;
        int sock = handler->data_sock[1];
        struct lxc_conf *conf = handler->conf;
@@ -1349,8 +1349,8 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
        if (!conf->tty)
                return 0;
 
-       tty_info->pty_info = malloc(sizeof(*tty_info->pty_info) * conf->tty);
-       if (!tty_info->pty_info)
+       tty_info->tty = malloc(sizeof(*tty_info->tty) * conf->tty);
+       if (!tty_info->tty)
                return -1;
 
        for (i = 0; i < conf->tty; i++) {
@@ -1360,12 +1360,12 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
                if (ret < 0)
                        break;
 
-               pty_info = &tty_info->pty_info[i];
-               pty_info->busy = 0;
-               pty_info->master = ttyfds[0];
-               pty_info->slave = ttyfds[1];
+               tty = &tty_info->tty[i];
+               tty->busy = 0;
+               tty->master = ttyfds[0];
+               tty->slave = ttyfds[1];
                TRACE("Received pty with master fd %d and slave fd %d from "
-                     "parent", pty_info->master, pty_info->slave);
+                     "parent", tty->master, tty->slave);
        }
        if (ret < 0)
                ERROR("Failed to receive %d ttys from child: %s", conf->tty,