[lxc-devel] [lxc/master] tree-wide: update terminal terminology once more

brauner on Github lxc-bot at linuxcontainers.org
Sun Jul 5 20:03:02 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200705/c737cd86/attachment-0001.bin>
-------------- next part --------------
From 36a94ce8e32abc77a453e04023fb50cd72b5648e Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 5 Jul 2020 21:54:32 +0200
Subject: [PATCH 1/2] tree-wide: s/ptmx/ptx/g

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/include/openpty.c  | 20 ++++-----
 src/include/openpty.h  |  6 +--
 src/lxc/attach.c       |  6 +--
 src/lxc/commands.c     | 18 ++++----
 src/lxc/commands.h     |  2 +-
 src/lxc/conf.c         | 26 +++++------
 src/lxc/lxccontainer.c |  4 +-
 src/lxc/lxccontainer.h |  4 +-
 src/lxc/start.c        |  4 +-
 src/lxc/terminal.c     | 98 +++++++++++++++++++++---------------------
 src/lxc/terminal.h     | 22 +++++-----
 src/tests/console.c    | 24 +++++------
 12 files changed, 117 insertions(+), 117 deletions(-)

diff --git a/src/include/openpty.c b/src/include/openpty.c
index 7804d4c983..3a7e80a750 100644
--- a/src/include/openpty.c
+++ b/src/include/openpty.c
@@ -32,25 +32,25 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
-#define _PATH_DEVPTMX "/dev/ptmx"
+#define _PATH_DEVPTMX "/dev/ptx"
 
-int openpty (int *aptmx, int *apts, char *name, struct termios *termp,
+int openpty (int *aptx, int *apts, char *name, struct termios *termp,
        struct winsize *winp)
 {
    char buf[PATH_MAX];
-   int ptmx, pts;
+   int ptx, pts;
 
-   ptmx = open(_PATH_DEVPTMX, O_RDWR);
-   if (ptmx == -1)
+   ptx = open(_PATH_DEVPTMX, O_RDWR);
+   if (ptx == -1)
        return -1;
 
-   if (grantpt(ptmx))
+   if (grantpt(ptx))
        goto fail;
 
-   if (unlockpt(ptmx))
+   if (unlockpt(ptx))
        goto fail;
 
-   if (ptsname_r(ptmx, buf, sizeof buf))
+   if (ptsname_r(ptx, buf, sizeof buf))
        goto fail;
 
    pts = open(buf, O_RDWR | O_NOCTTY);
@@ -63,7 +63,7 @@ int openpty (int *aptmx, int *apts, char *name, struct termios *termp,
    if (winp)
        ioctl(pts, TIOCSWINSZ, winp);
 
-   *aptmx = ptmx;
+   *aptx = ptx;
    *apts = pts;
    if (name != NULL)
        strcpy(name, buf);
@@ -71,6 +71,6 @@ int openpty (int *aptmx, int *apts, char *name, struct termios *termp,
    return 0;
 
 fail:
-   close(ptmx);
+   close(ptx);
    return -1;
 }
diff --git a/src/include/openpty.h b/src/include/openpty.h
index cb452e52a6..d686cb6190 100644
--- a/src/include/openpty.h
+++ b/src/include/openpty.h
@@ -28,11 +28,11 @@
 #include <sys/ioctl.h>
 
 /*
- * Create pseudo tty ptmx pts pair with @__name and set terminal
+ * Create pseudo tty ptx pts pair with @__name and set terminal
  * attributes according to @__termp and @__winp and return handles for both
- * ends in @__aptmx and @__apts.
+ * ends in @__aptx and @__apts.
  */
-extern int openpty (int *__aptmx, int *__apts, char *__name,
+extern int openpty (int *__aptx, int *__apts, char *__name,
 		    const struct termios *__termp,
 		    const struct winsize *__winp);
 
diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 4cd4f4175a..46da000ca4 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -932,9 +932,9 @@ static int lxc_attach_terminal_mainloop_init(struct lxc_terminal *terminal,
 	return 0;
 }
 
-static inline void lxc_attach_terminal_close_ptmx(struct lxc_terminal *terminal)
+static inline void lxc_attach_terminal_close_ptx(struct lxc_terminal *terminal)
 {
-	close_prot_errno_disarm(terminal->ptmx);
+	close_prot_errno_disarm(terminal->ptx);
 }
 
 static inline void lxc_attach_terminal_close_pts(struct lxc_terminal *terminal)
@@ -1332,7 +1332,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
 	close_prot_errno_disarm(ipc_sockets[0]);
 
 	if (options->attach_flags & LXC_ATTACH_TERMINAL) {
-		lxc_attach_terminal_close_ptmx(&terminal);
+		lxc_attach_terminal_close_ptx(&terminal);
 		lxc_attach_terminal_close_peer(&terminal);
 		lxc_attach_terminal_close_log(&terminal);
 	}
diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index d735b5ff6a..726d57ae0a 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -108,7 +108,7 @@ static const char *lxc_cmd_str(lxc_cmd_t cmd)
  * stored directly in data and datalen will be 0.
  *
  * As a special case, the response for LXC_CMD_CONSOLE is created
- * here as it contains an fd for the ptmx pty passed through the
+ * here as it contains an fd for the ptx pty passed through the
  * unix socket.
  */
 static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
@@ -139,7 +139,7 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
 					      ENOMEM, "Failed to receive response for command \"%s\"",
 					      lxc_cmd_str(cmd->req.cmd));
 
-		rspdata->ptmxfd = move_fd(fd_rsp);
+		rspdata->ptxfd = move_fd(fd_rsp);
 		rspdata->ttynum = PTR_TO_INT(rsp->data);
 		rsp->data = rspdata;
 	}
@@ -844,7 +844,7 @@ static int lxc_cmd_terminal_winch_callback(int fd, struct lxc_cmd_req *req,
  * @name           : name of container to connect to
  * @ttynum         : in:  the tty to open or -1 for next available
  *                 : out: the tty allocated
- * @fd             : out: file descriptor for ptmx side of pty
+ * @fd             : out: file descriptor for ptx side of pty
  * @lxcpath        : the lxcpath in which the container is running
  *
  * Returns fd holding tty allocated on success, < 0 on failure
@@ -871,11 +871,11 @@ int lxc_cmd_console(const char *name, int *ttynum, int *fd, const char *lxcpath)
 	if (ret == 0)
 		return log_error(-1, "tty number %d invalid, busy or all ttys busy", *ttynum);
 
-	if (rspdata->ptmxfd < 0)
+	if (rspdata->ptxfd < 0)
 		return log_error(-1, "Unable to allocate fd for tty %d", rspdata->ttynum);
 
 	ret = cmd.rsp.ret; /* socket fd */
-	*fd = rspdata->ptmxfd;
+	*fd = rspdata->ptxfd;
 	*ttynum = rspdata->ttynum;
 
 	return log_info(ret, "Alloced fd %d for tty %d via socket %d", *fd, rspdata->ttynum, ret);
@@ -885,17 +885,17 @@ static int lxc_cmd_console_callback(int fd, struct lxc_cmd_req *req,
 				    struct lxc_handler *handler,
 				    struct lxc_epoll_descr *descr)
 {
-	int ptmxfd, ret;
+	int ptxfd, ret;
 	struct lxc_cmd_rsp rsp;
 	int ttynum = PTR_TO_INT(req->data);
 
-	ptmxfd = lxc_terminal_allocate(handler->conf, fd, &ttynum);
-	if (ptmxfd < 0)
+	ptxfd = lxc_terminal_allocate(handler->conf, fd, &ttynum);
+	if (ptxfd < 0)
 		return LXC_CMD_REAP_CLIENT_FD;
 
 	memset(&rsp, 0, sizeof(rsp));
 	rsp.data = INT_TO_PTR(ttynum);
-	ret = lxc_abstract_unix_send_fds(fd, &ptmxfd, 1, &rsp, sizeof(rsp));
+	ret = lxc_abstract_unix_send_fds(fd, &ptxfd, 1, &rsp, sizeof(rsp));
 	if (ret < 0) {
 		lxc_terminal_free(handler->conf, fd);
 		return log_error_errno(LXC_CMD_REAP_CLIENT_FD, errno,
diff --git a/src/lxc/commands.h b/src/lxc/commands.h
index 3624a14975..a16c57db40 100644
--- a/src/lxc/commands.h
+++ b/src/lxc/commands.h
@@ -61,7 +61,7 @@ struct lxc_cmd_rr {
 };
 
 struct lxc_cmd_console_rsp_data {
-	int ptmxfd;
+	int ptxfd;
 	int ttynum;
 };
 
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 48cb74891f..4f75b14c14 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -921,9 +921,9 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
 	for (size_t i = 0; i < ttys->max; i++) {
 		struct lxc_terminal_info *tty = &ttys->tty[i];
 
-		tty->ptmx = -EBADF;
+		tty->ptx = -EBADF;
 		tty->pts = -EBADF;
-		ret = openpty(&tty->ptmx, &tty->pts, NULL, NULL, NULL);
+		ret = openpty(&tty->ptx, &tty->pts, NULL, NULL, NULL);
 		if (ret < 0) {
 			ttys->max = i;
 			return log_error_errno(-ENOTTY, ENOTTY, "Failed to create tty %zu", i);
@@ -935,14 +935,14 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
 			return log_error_errno(-ENOTTY, ENOTTY, "Failed to retrieve name of tty %zu pts", i);
 		}
 
-		DEBUG("Created tty \"%s\" with ptmx fd %d and pts fd %d",
-		      tty->name, tty->ptmx, tty->pts);
+		DEBUG("Created tty \"%s\" with ptx fd %d and pts fd %d",
+		      tty->name, tty->ptx, tty->pts);
 
 		/* Prevent leaking the file descriptors to the container */
-		ret = fd_cloexec(tty->ptmx, true);
+		ret = fd_cloexec(tty->ptx, true);
 		if (ret < 0)
-			SYSWARN("Failed to set FD_CLOEXEC flag on ptmx fd %d of tty device \"%s\"",
-				tty->ptmx, tty->name);
+			SYSWARN("Failed to set FD_CLOEXEC flag on ptx fd %d of tty device \"%s\"",
+				tty->ptx, tty->name);
 
 		ret = fd_cloexec(tty->pts, true);
 		if (ret < 0)
@@ -964,7 +964,7 @@ void lxc_delete_tty(struct lxc_tty_info *ttys)
 
 	for (int i = 0; i < ttys->max; i++) {
 		struct lxc_terminal_info *tty = &ttys->tty[i];
-		close_prot_errno_disarm(tty->ptmx);
+		close_prot_errno_disarm(tty->ptx);
 		close_prot_errno_disarm(tty->pts);
 	}
 
@@ -986,15 +986,15 @@ static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
 		int ttyfds[2];
 		struct lxc_terminal_info *tty = &ttys->tty[i];
 
-		ttyfds[0] = tty->ptmx;
+		ttyfds[0] = tty->ptx;
 		ttyfds[1] = tty->pts;
 
 		ret = lxc_abstract_unix_send_fds(sock, ttyfds, 2, NULL, 0);
 		if (ret < 0)
 			break;
 
-		TRACE("Sent tty \"%s\" with ptmx fd %d and pts fd %d to parent",
-		      tty->name, tty->ptmx, tty->pts);
+		TRACE("Sent tty \"%s\" with ptx fd %d and pts fd %d to parent",
+		      tty->name, tty->ptx, tty->pts);
 	}
 
 	if (ret < 0)
@@ -2546,9 +2546,9 @@ struct lxc_conf *lxc_conf_init(void)
 	new->console.path = NULL;
 	new->console.peer = -1;
 	new->console.proxy.busy = -1;
-	new->console.proxy.ptmx = -1;
+	new->console.proxy.ptx = -1;
 	new->console.proxy.pts = -1;
-	new->console.ptmx = -1;
+	new->console.ptx = -1;
 	new->console.pts = -1;
 	new->console.name[0] = '\0';
 	memset(&new->console.ringbuf, 0, sizeof(struct lxc_ringbuf));
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index aac6214825..21b1cb0715 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -537,12 +537,12 @@ static bool do_lxcapi_unfreeze(struct lxc_container *c)
 
 WRAP_API(bool, lxcapi_unfreeze)
 
-static int do_lxcapi_console_getfd(struct lxc_container *c, int *ttynum, int *ptmxfd)
+static int do_lxcapi_console_getfd(struct lxc_container *c, int *ttynum, int *ptxfd)
 {
 	if (!c)
 		return -1;
 
-	return lxc_terminal_getfd(c, ttynum, ptmxfd);
+	return lxc_terminal_getfd(c, ttynum, ptxfd);
 }
 
 WRAP_API_2(int, lxcapi_console_getfd, int *, int *)
diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h
index b4ec1d6d5f..71086f764d 100644
--- a/src/lxc/lxccontainer.h
+++ b/src/lxc/lxccontainer.h
@@ -563,7 +563,7 @@ struct lxc_container {
 	 * \param c Container.
 	 * \param[in,out] ttynum Terminal number to attempt to allocate,
 	 *  or \c -1 to allocate the first available tty.
-	 * \param[out] ptmxfd File descriptor referring to the ptmx side of the pty.
+	 * \param[out] ptxfd File descriptor referring to the ptx side of the pty.
 	 *
 	 * \return tty file descriptor number on success, or \c -1 on
 	 *  failure.
@@ -575,7 +575,7 @@ struct lxc_container {
 	 *  descriptor when no longer required so that it may be allocated
 	 *  by another caller.
 	 */
-	int (*console_getfd)(struct lxc_container *c, int *ttynum, int *ptmxfd);
+	int (*console_getfd)(struct lxc_container *c, int *ttynum, int *ptxfd);
 
 	/*!
 	 * \brief Allocate and run a console tty.
diff --git a/src/lxc/start.c b/src/lxc/start.c
index f014a8ffce..da2816d5ed 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1483,9 +1483,9 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
 
 		tty = &ttys->tty[i];
 		tty->busy = -1;
-		tty->ptmx = ttyfds[0];
+		tty->ptx = ttyfds[0];
 		tty->pts = ttyfds[1];
-		TRACE("Received pty with ptmx fd %d and pts fd %d from child", tty->ptmx, tty->pts);
+		TRACE("Received pty with ptx fd %d and pts fd %d from child", tty->ptx, tty->pts);
 	}
 
 	if (ret < 0)
diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c
index e58db5c466..701e1f9354 100644
--- a/src/lxc/terminal.c
+++ b/src/lxc/terminal.c
@@ -65,7 +65,7 @@ void lxc_terminal_winsz(int srcfd, int dstfd)
 
 static void lxc_terminal_winch(struct lxc_terminal_state *ts)
 {
-	lxc_terminal_winsz(ts->stdinfd, ts->ptmxfd);
+	lxc_terminal_winsz(ts->stdinfd, ts->ptxfd);
 }
 
 int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata,
@@ -105,7 +105,7 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
 
 	memset(ts, 0, sizeof(*ts));
 	ts->stdinfd = srcfd;
-	ts->ptmxfd = dstfd;
+	ts->ptxfd = dstfd;
 	ts->sigfd = -1;
 
 	ret = sigemptyset(&mask);
@@ -330,8 +330,8 @@ int lxc_terminal_io_cb(int fd, uint32_t events, void *data,
 		INFO("Terminal client on fd %d has exited", fd);
 		lxc_mainloop_del_handler(descr, fd);
 
-		if (fd == terminal->ptmx) {
-			terminal->ptmx = -EBADF;
+		if (fd == terminal->ptx) {
+			terminal->ptx = -EBADF;
 		} else if (fd == terminal->peer) {
 			lxc_terminal_signal_fini(terminal);
 			terminal->peer = -EBADF;
@@ -344,10 +344,10 @@ int lxc_terminal_io_cb(int fd, uint32_t events, void *data,
 	}
 
 	if (fd == terminal->peer)
-		w = lxc_write_nointr(terminal->ptmx, buf, r);
+		w = lxc_write_nointr(terminal->ptx, buf, r);
 
 	w_rbuf = w_log = 0;
-	if (fd == terminal->ptmx) {
+	if (fd == terminal->ptx) {
 		/* write to peer first */
 		if (terminal->peer >= 0)
 			w = lxc_write_nointr(terminal->peer, buf, r);
@@ -406,16 +406,16 @@ int lxc_terminal_mainloop_add(struct lxc_epoll_descr *descr,
 {
 	int ret;
 
-	if (terminal->ptmx < 0) {
+	if (terminal->ptx < 0) {
 		INFO("Terminal is not initialized");
 		return 0;
 	}
 
-	ret = lxc_mainloop_add_handler(descr, terminal->ptmx,
+	ret = lxc_mainloop_add_handler(descr, terminal->ptx,
 				       lxc_terminal_io_cb, terminal);
 	if (ret < 0) {
-		ERROR("Failed to add handler for terminal ptmx fd %d to "
-		      "mainloop", terminal->ptmx);
+		ERROR("Failed to add handler for terminal ptx fd %d to "
+		      "mainloop", terminal->ptx);
 		return -1;
 	}
 
@@ -483,8 +483,8 @@ static void lxc_terminal_peer_proxy_free(struct lxc_terminal *terminal)
 {
 	lxc_terminal_signal_fini(terminal);
 
-	close(terminal->proxy.ptmx);
-	terminal->proxy.ptmx = -1;
+	close(terminal->proxy.ptx);
+	terminal->proxy.ptx = -1;
 
 	close(terminal->proxy.pts);
 	terminal->proxy.pts = -1;
@@ -503,7 +503,7 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 	struct termios oldtermio;
 	struct lxc_terminal_state *ts;
 
-	if (terminal->ptmx < 0) {
+	if (terminal->ptx < 0) {
 		ERROR("Terminal not set up");
 		return -1;
 	}
@@ -519,9 +519,9 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 	}
 
 	/* This is the proxy terminal that will be given to the client, and
-	 * that the real terminal ptmx will send to / recv from.
+	 * that the real terminal ptx will send to / recv from.
 	 */
-	ret = openpty(&terminal->proxy.ptmx, &terminal->proxy.pts, NULL,
+	ret = openpty(&terminal->proxy.ptx, &terminal->proxy.pts, NULL,
 		      NULL, NULL);
 	if (ret < 0) {
 		SYSERROR("Failed to open proxy terminal");
@@ -535,9 +535,9 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 		goto on_error;
 	}
 
-	ret = fd_cloexec(terminal->proxy.ptmx, true);
+	ret = fd_cloexec(terminal->proxy.ptx, true);
 	if (ret < 0) {
-		SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal ptmx");
+		SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal ptx");
 		goto on_error;
 	}
 
@@ -551,7 +551,7 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 	if (ret < 0)
 		goto on_error;
 
-	ts = lxc_terminal_signal_init(terminal->proxy.ptmx, terminal->ptmx);
+	ts = lxc_terminal_signal_init(terminal->proxy.ptx, terminal->ptx);
 	if (!ts)
 		goto on_error;
 
@@ -562,8 +562,8 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 	if (ret < 0)
 		goto on_error;
 
-	NOTICE("Opened proxy terminal with ptmx fd %d and pts fd %d",
-	       terminal->proxy.ptmx, terminal->proxy.pts);
+	NOTICE("Opened proxy terminal with ptx fd %d and pts fd %d",
+	       terminal->proxy.ptx, terminal->proxy.pts);
 	return 0;
 
 on_error:
@@ -574,7 +574,7 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
 {
 	int ttynum;
-	int ptmxfd = -1;
+	int ptxfd = -1;
 	struct lxc_tty_info *ttys = &conf->ttys;
 	struct lxc_terminal *terminal = &conf->console;
 
@@ -585,7 +585,7 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
 		if (ret < 0)
 			goto out;
 
-		ptmxfd = terminal->proxy.ptmx;
+		ptxfd = terminal->proxy.ptx;
 		goto out;
 	}
 
@@ -614,10 +614,10 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
 
 out_tty:
 	ttys->tty[ttynum - 1].busy = sockfd;
-	ptmxfd = ttys->tty[ttynum - 1].ptmx;
+	ptxfd = ttys->tty[ttynum - 1].ptx;
 
 out:
-	return ptmxfd;
+	return ptxfd;
 }
 
 void lxc_terminal_free(struct lxc_conf *conf, int fd)
@@ -666,14 +666,14 @@ static int lxc_terminal_peer_default(struct lxc_terminal *terminal)
 		goto on_error_free_tios;
 	}
 
-	ts = lxc_terminal_signal_init(terminal->peer, terminal->ptmx);
+	ts = lxc_terminal_signal_init(terminal->peer, terminal->ptx);
 	terminal->tty_state = ts;
 	if (!ts) {
 		WARN("Failed to install signal handler");
 		goto on_error_free_tios;
 	}
 
-	lxc_terminal_winsz(terminal->peer, terminal->ptmx);
+	lxc_terminal_winsz(terminal->peer, terminal->ptx);
 
 	terminal->tios = malloc(sizeof(*terminal->tios));
 	if (!terminal->tios)
@@ -749,9 +749,9 @@ void lxc_terminal_delete(struct lxc_terminal *terminal)
 		close(terminal->peer);
 	terminal->peer = -1;
 
-	if (terminal->ptmx >= 0)
-		close(terminal->ptmx);
-	terminal->ptmx = -1;
+	if (terminal->ptx >= 0)
+		close(terminal->ptx);
+	terminal->ptx = -1;
 
 	if (terminal->pts >= 0)
 		close(terminal->pts);
@@ -764,7 +764,7 @@ void lxc_terminal_delete(struct lxc_terminal *terminal)
 
 /**
  * Note that this function needs to run before the mainloop starts. Since we
- * register a handler for the terminal's ptmxfd when we create the mainloop
+ * register a handler for the terminal's ptxfd when we create the mainloop
  * the terminal handler needs to see an allocated ringbuffer.
  */
 static int lxc_terminal_create_ringbuf(struct lxc_terminal *terminal)
@@ -832,7 +832,7 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
 {
 	int ret;
 
-	ret = openpty(&terminal->ptmx, &terminal->pts, NULL, NULL, NULL);
+	ret = openpty(&terminal->ptx, &terminal->pts, NULL, NULL, NULL);
 	if (ret < 0) {
 		SYSERROR("Failed to open terminal");
 		return -1;
@@ -844,9 +844,9 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
 		goto err;
 	}
 
-	ret = fd_cloexec(terminal->ptmx, true);
+	ret = fd_cloexec(terminal->ptx, true);
 	if (ret < 0) {
-		SYSERROR("Failed to set FD_CLOEXEC flag on terminal ptmx");
+		SYSERROR("Failed to set FD_CLOEXEC flag on terminal ptx");
 		goto err;
 	}
 
@@ -956,21 +956,21 @@ int lxc_terminal_stdin_cb(int fd, uint32_t events, void *cbdata,
 		ts->saw_escape = 0;
 	}
 
-	ret = lxc_write_nointr(ts->ptmxfd, &c, 1);
+	ret = lxc_write_nointr(ts->ptxfd, &c, 1);
 	if (ret <= 0)
 		return LXC_MAINLOOP_CLOSE;
 
 	return LXC_MAINLOOP_CONTINUE;
 }
 
-int lxc_terminal_ptmx_cb(int fd, uint32_t events, void *cbdata,
+int lxc_terminal_ptx_cb(int fd, uint32_t events, void *cbdata,
 			   struct lxc_epoll_descr *descr)
 {
 	int r, w;
 	char buf[LXC_TERMINAL_BUFFER_SIZE];
 	struct lxc_terminal_state *ts = cbdata;
 
-	if (fd != ts->ptmxfd)
+	if (fd != ts->ptxfd)
 		return LXC_MAINLOOP_CLOSE;
 
 	r = lxc_read_nointr(fd, buf, sizeof(buf));
@@ -984,16 +984,16 @@ int lxc_terminal_ptmx_cb(int fd, uint32_t events, void *cbdata,
 	return LXC_MAINLOOP_CONTINUE;
 }
 
-int lxc_terminal_getfd(struct lxc_container *c, int *ttynum, int *ptmxfd)
+int lxc_terminal_getfd(struct lxc_container *c, int *ttynum, int *ptxfd)
 {
-	return lxc_cmd_console(c->name, ttynum, ptmxfd, c->config_path);
+	return lxc_cmd_console(c->name, ttynum, ptxfd, c->config_path);
 }
 
 int lxc_console(struct lxc_container *c, int ttynum,
 		int stdinfd, int stdoutfd, int stderrfd,
 		int escape)
 {
-	int ptmxfd, ret, ttyfd;
+	int ptxfd, ret, ttyfd;
 	struct lxc_epoll_descr descr;
 	struct termios oldtios;
 	struct lxc_terminal_state *ts;
@@ -1002,7 +1002,7 @@ int lxc_console(struct lxc_container *c, int ttynum,
 	};
 	int istty = 0;
 
-	ttyfd = lxc_cmd_console(c->name, &ttynum, &ptmxfd, c->config_path);
+	ttyfd = lxc_cmd_console(c->name, &ttynum, &ptxfd, c->config_path);
 	if (ttyfd < 0)
 		return -1;
 
@@ -1010,7 +1010,7 @@ int lxc_console(struct lxc_container *c, int ttynum,
 	if (ret < 0)
 		TRACE("Process is already group leader");
 
-	ts = lxc_terminal_signal_init(stdinfd, ptmxfd);
+	ts = lxc_terminal_signal_init(stdinfd, ptxfd);
 	if (!ts) {
 		ret = -1;
 		goto close_fds;
@@ -1021,8 +1021,8 @@ int lxc_console(struct lxc_container *c, int ttynum,
 
 	istty = isatty(stdinfd);
 	if (istty) {
-		lxc_terminal_winsz(stdinfd, ptmxfd);
-		lxc_terminal_winsz(ts->stdinfd, ts->ptmxfd);
+		lxc_terminal_winsz(stdinfd, ptxfd);
+		lxc_terminal_winsz(ts->stdinfd, ts->ptxfd);
 	} else {
 		INFO("File descriptor %d does not refer to a terminal", stdinfd);
 	}
@@ -1049,10 +1049,10 @@ int lxc_console(struct lxc_container *c, int ttynum,
 		goto close_mainloop;
 	}
 
-	ret = lxc_mainloop_add_handler(&descr, ts->ptmxfd,
-				       lxc_terminal_ptmx_cb, ts);
+	ret = lxc_mainloop_add_handler(&descr, ts->ptxfd,
+				       lxc_terminal_ptx_cb, ts);
 	if (ret < 0) {
-		ERROR("Failed to add ptmx handler");
+		ERROR("Failed to add ptx handler");
 		goto close_mainloop;
 	}
 
@@ -1093,7 +1093,7 @@ int lxc_console(struct lxc_container *c, int ttynum,
 	lxc_terminal_signal_fini(&terminal);
 
 close_fds:
-	close(ptmxfd);
+	close(ptxfd);
 	close(ttyfd);
 
 	return ret;
@@ -1133,7 +1133,7 @@ int lxc_terminal_prepare_login(int fd)
 void lxc_terminal_info_init(struct lxc_terminal_info *terminal)
 {
 	terminal->name[0] = '\0';
-	terminal->ptmx = -EBADF;
+	terminal->ptx = -EBADF;
 	terminal->pts = -EBADF;
 	terminal->busy = -1;
 }
@@ -1142,7 +1142,7 @@ void lxc_terminal_init(struct lxc_terminal *terminal)
 {
 	memset(terminal, 0, sizeof(*terminal));
 	terminal->pts = -EBADF;
-	terminal->ptmx = -EBADF;
+	terminal->ptx = -EBADF;
 	terminal->peer = -EBADF;
 	terminal->log_fd = -EBADF;
 	lxc_terminal_info_init(&terminal->proxy);
diff --git a/src/lxc/terminal.h b/src/lxc/terminal.h
index 4d21f33d97..3322900c9d 100644
--- a/src/lxc/terminal.h
+++ b/src/lxc/terminal.h
@@ -18,8 +18,8 @@ struct lxc_terminal_info {
 	/* the path name of the pts side */
 	char name[PATH_MAX];
 
-	/* the file descriptor of the ptmx */
-	int ptmx;
+	/* the file descriptor of the ptx */
+	int ptx;
 
 	/* the file descriptor of the pts */
 	int pts;
@@ -32,7 +32,7 @@ struct lxc_terminal_state {
 	struct lxc_list node;
 	int stdinfd;
 	int stdoutfd;
-	int ptmxfd;
+	int ptxfd;
 
 	/* Escape sequence to use for exiting the terminal. A single char can
 	 * be specified. The terminal can then exited by doing: Ctrl +
@@ -58,7 +58,7 @@ struct lxc_terminal_state {
 
 struct lxc_terminal {
 	int pts;
-	int ptmx;
+	int ptx;
 	int peer;
 	struct lxc_terminal_info proxy;
 	struct lxc_epoll_descr *descr;
@@ -102,10 +102,10 @@ extern int  lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttynum
 
 /**
  * Create a new terminal:
- * - calls openpty() to allocate a ptmx/pts pair
- * - sets the FD_CLOEXEC flag on the ptmx/pts fds
+ * - calls openpty() to allocate a ptx/pts pair
+ * - sets the FD_CLOEXEC flag on the ptx/pts fds
  * - allocates either the current controlling terminal (default) or a user
- *   specified terminal as proxy for the newly created ptmx/pts pair
+ *   specified terminal as proxy for the newly created ptx/pts pair
  * - sets up SIGWINCH handler, winsz, and new terminal settings
  *   (Handlers for SIGWINCH and I/O are not registered in a mainloop.)
  */
@@ -164,7 +164,7 @@ extern int  lxc_console(struct lxc_container *c, int ttynum,
  * the range specified by lxc.tty.max to allocate a specific tty.
  */
 extern int lxc_terminal_getfd(struct lxc_container *c, int *ttynum,
-			      int *ptmxfd);
+			      int *ptxfd);
 
 /**
  * Make fd a duplicate of the standard file descriptors. The fd is made a
@@ -183,12 +183,12 @@ extern int lxc_terminal_stdin_cb(int fd, uint32_t events, void *cbdata,
 				 struct lxc_epoll_descr *descr);
 
 /**
- * Handler for events on the ptmx fd of the terminal. To be registered via
+ * Handler for events on the ptx fd of the terminal. To be registered via
  * the corresponding functions declared and defined in mainloop.{c,h} or
  * lxc_terminal_mainloop_add().
  * This function exits the loop cleanly when an EPOLLHUP event is received.
  */
-extern int lxc_terminal_ptmx_cb(int fd, uint32_t events, void *cbdata,
+extern int lxc_terminal_ptx_cb(int fd, uint32_t events, void *cbdata,
 				  struct lxc_epoll_descr *descr);
 
 /**
@@ -204,7 +204,7 @@ extern int lxc_setup_tios(int fd, struct termios *oldtios);
  * @srcfd
  * - terminal to get size from (typically a pts pty)
  * @dstfd
- * - terminal to set size on (typically a ptmx pty)
+ * - terminal to set size on (typically a ptx pty)
  */
 extern void lxc_terminal_winsz(int srcfd, int dstfd);
 
diff --git a/src/tests/console.c b/src/tests/console.c
index c88f4329bf..9acd694746 100644
--- a/src/tests/console.c
+++ b/src/tests/console.c
@@ -37,14 +37,14 @@
 } while (0)
 
 static void test_console_close_all(int ttyfd[MAXCONSOLES],
-				   int ptmxfd[MAXCONSOLES])
+				   int ptxfd[MAXCONSOLES])
 {
 	int i;
 
 	for (i = 0; i < MAXCONSOLES; i++) {
-		if (ptmxfd[i] != -1) {
-			close(ptmxfd[i]);
-			ptmxfd[i] = -1;
+		if (ptxfd[i] != -1) {
+			close(ptxfd[i]);
+			ptxfd[i] = -1;
 		}
 
 		if (ttyfd[i] != -1) {
@@ -59,14 +59,14 @@ static int test_console_running_container(struct lxc_container *c)
 	int nrconsoles, i, ret = -1;
 	int ttynum  [MAXCONSOLES];
 	int ttyfd   [MAXCONSOLES];
-	int ptmxfd[MAXCONSOLES];
+	int ptxfd[MAXCONSOLES];
 
 	for (i = 0; i < MAXCONSOLES; i++)
-		ttynum[i] = ttyfd[i] = ptmxfd[i] = -1;
+		ttynum[i] = ttyfd[i] = ptxfd[i] = -1;
 
 	ttynum[0] = 1;
 
-	ret = c->console_getfd(c, &ttynum[0], &ptmxfd[0]);
+	ret = c->console_getfd(c, &ttynum[0], &ptxfd[0]);
 	if (ret < 0) {
 		TSTERR("console allocate failed");
 		goto err1;
@@ -79,12 +79,12 @@ static int test_console_running_container(struct lxc_container *c)
 	}
 
 	/* attempt to alloc same ttynum */
-	ret = c->console_getfd(c, &ttynum[0], &ptmxfd[1]);
+	ret = c->console_getfd(c, &ttynum[0], &ptxfd[1]);
 	if (ret != -1) {
 		TSTERR("console allocate should fail for allocated ttynum %d", ttynum[0]);
 		goto err2;
 	}
-	close(ptmxfd[0]); ptmxfd[0] = -1;
+	close(ptxfd[0]); ptxfd[0] = -1;
 	close(ttyfd[0]); ttyfd[0] = -1;
 
 	/* ensure we can allocate all consoles, we do this a few times to
@@ -92,7 +92,7 @@ static int test_console_running_container(struct lxc_container *c)
 	 */
 	for (i = 0; i < 10; i++) {
 		for (nrconsoles = 0; nrconsoles < MAXCONSOLES; nrconsoles++) {
-			ret = c->console_getfd(c, &ttynum[nrconsoles], &ptmxfd[nrconsoles]);
+			ret = c->console_getfd(c, &ttynum[nrconsoles], &ptxfd[nrconsoles]);
 			if (ret < 0)
 				break;
 			ttyfd[nrconsoles] = ret;
@@ -103,13 +103,13 @@ static int test_console_running_container(struct lxc_container *c)
 			goto err2;
 		}
 
-		test_console_close_all(ttyfd, ptmxfd);
+		test_console_close_all(ttyfd, ptxfd);
 	}
 
 	ret = 0;
 
 err2:
-	test_console_close_all(ttyfd, ptmxfd);
+	test_console_close_all(ttyfd, ptxfd);
 
 err1:
 	return ret;

From 41808e20a1026446f3152beda6d95f6b48b5f0af Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 5 Jul 2020 22:00:11 +0200
Subject: [PATCH 2/2] tree-wide: s/pts/pty/g

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 doc/ja/lxc.container.conf.sgml.in |  4 +-
 doc/ko/lxc.container.conf.sgml.in |  2 +-
 doc/lxc.container.conf.sgml.in    |  2 +-
 src/include/openpty.c             | 14 +++----
 src/include/openpty.h             |  2 +-
 src/lxc/attach.c                  |  4 +-
 src/lxc/conf.c                    | 70 +++++++++++++++----------------
 src/lxc/criu.c                    |  4 +-
 src/lxc/start.c                   | 14 +++----
 src/lxc/terminal.c                | 50 +++++++++++-----------
 src/lxc/terminal.h                | 16 +++----
 11 files changed, 91 insertions(+), 91 deletions(-)

diff --git a/doc/ja/lxc.container.conf.sgml.in b/doc/ja/lxc.container.conf.sgml.in
index 3730399c6b..64218c4a67 100644
--- a/doc/ja/lxc.container.conf.sgml.in
+++ b/doc/ja/lxc.container.conf.sgml.in
@@ -1152,11 +1152,11 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
               <!--
               If set, the container will have a new pseudo tty
               instance, making this private to it. The value specifies
-              the maximum number of pseudo ttys allowed for a pts
+              the maximum number of pseudo ttys allowed for a pty
               instance (this limitation is not implemented yet).
               -->
               もし設定された場合、コンテナは新しい pseudo tty インスタンスを持ち、それを自身のプライベートとします。
-              この値は pts インスタンスに許可される pseudo tty の最大数を指定します (この制限はまだ実装されていません)。
+              この値は pty インスタンスに許可される pseudo tty の最大数を指定します (この制限はまだ実装されていません)。
             </para>
           </listitem>
         </varlistentry>
diff --git a/doc/ko/lxc.container.conf.sgml.in b/doc/ko/lxc.container.conf.sgml.in
index f87a293896..a8ff7afb7f 100644
--- a/doc/ko/lxc.container.conf.sgml.in
+++ b/doc/ko/lxc.container.conf.sgml.in
@@ -844,7 +844,7 @@ by Sungbae Yoo <sungbae.yoo at samsung.com>
               <!--
 	      If set, the container will have a new pseudo tty
 	      instance, making this private to it. The value specifies
-              the maximum number of pseudo ttys allowed for a pts
+              the maximum number of pseudo ttys allowed for a pty
               instance (this limitation is not implemented yet).
               -->
               만약 지정되었다면, 컨테이너는 새 pseudo tty 인스턴스를 갖는다. 그리고 이것을 자기자신 전용으로 만든다. 지정하는 값은 pseudo tty의 최대 개수를 지정한다. (이 제한은 아직 구현되지 않았다)
diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in
index 98177c2fdf..ba25b34130 100644
--- a/doc/lxc.container.conf.sgml.in
+++ b/doc/lxc.container.conf.sgml.in
@@ -873,7 +873,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
             <para>
               If set, the container will have a new pseudo tty
               instance, making this private to it. The value specifies
-              the maximum number of pseudo ttys allowed for a pts
+              the maximum number of pseudo ttys allowed for a pty
               instance (this limitation is not implemented yet).
             </para>
           </listitem>
diff --git a/src/include/openpty.c b/src/include/openpty.c
index 3a7e80a750..37aa0fbbeb 100644
--- a/src/include/openpty.c
+++ b/src/include/openpty.c
@@ -38,7 +38,7 @@ int openpty (int *aptx, int *apts, char *name, struct termios *termp,
        struct winsize *winp)
 {
    char buf[PATH_MAX];
-   int ptx, pts;
+   int ptx, pty;
 
    ptx = open(_PATH_DEVPTMX, O_RDWR);
    if (ptx == -1)
@@ -50,21 +50,21 @@ int openpty (int *aptx, int *apts, char *name, struct termios *termp,
    if (unlockpt(ptx))
        goto fail;
 
-   if (ptsname_r(ptx, buf, sizeof buf))
+   if (ptyname_r(ptx, buf, sizeof buf))
        goto fail;
 
-   pts = open(buf, O_RDWR | O_NOCTTY);
-   if (pts == -1)
+   pty = open(buf, O_RDWR | O_NOCTTY);
+   if (pty == -1)
        goto fail;
 
    /* XXX Should we ignore errors here?  */
    if (termp)
-       tcsetattr(pts, TCSAFLUSH, termp);
+       tcsetattr(pty, TCSAFLUSH, termp);
    if (winp)
-       ioctl(pts, TIOCSWINSZ, winp);
+       ioctl(pty, TIOCSWINSZ, winp);
 
    *aptx = ptx;
-   *apts = pts;
+   *apts = pty;
    if (name != NULL)
        strcpy(name, buf);
 
diff --git a/src/include/openpty.h b/src/include/openpty.h
index d686cb6190..3b67739ad7 100644
--- a/src/include/openpty.h
+++ b/src/include/openpty.h
@@ -28,7 +28,7 @@
 #include <sys/ioctl.h>
 
 /*
- * Create pseudo tty ptx pts pair with @__name and set terminal
+ * Create pseudo tty ptx pty pair with @__name and set terminal
  * attributes according to @__termp and @__winp and return handles for both
  * ends in @__aptx and @__apts.
  */
diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 46da000ca4..5443fee5f7 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -939,7 +939,7 @@ static inline void lxc_attach_terminal_close_ptx(struct lxc_terminal *terminal)
 
 static inline void lxc_attach_terminal_close_pts(struct lxc_terminal *terminal)
 {
-	close_prot_errno_disarm(terminal->pts);
+	close_prot_errno_disarm(terminal->pty);
 }
 
 static inline void lxc_attach_terminal_close_peer(struct lxc_terminal *terminal)
@@ -1377,7 +1377,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function,
 	payload.ipc_socket = ipc_sockets[1];
 	payload.options = options;
 	payload.init_ctx = init_ctx;
-	payload.terminal_pts_fd = terminal.pts;
+	payload.terminal_pts_fd = terminal.pty;
 	payload.exec_function = exec_function;
 	payload.exec_payload = exec_payload;
 
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 4f75b14c14..e009006429 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -922,21 +922,21 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
 		struct lxc_terminal_info *tty = &ttys->tty[i];
 
 		tty->ptx = -EBADF;
-		tty->pts = -EBADF;
-		ret = openpty(&tty->ptx, &tty->pts, NULL, NULL, NULL);
+		tty->pty = -EBADF;
+		ret = openpty(&tty->ptx, &tty->pty, NULL, NULL, NULL);
 		if (ret < 0) {
 			ttys->max = i;
 			return log_error_errno(-ENOTTY, ENOTTY, "Failed to create tty %zu", i);
 		}
 
-		ret = ttyname_r(tty->pts, tty->name, sizeof(tty->name));
+		ret = ttyname_r(tty->pty, tty->name, sizeof(tty->name));
 		if (ret < 0) {
 			ttys->max = i;
-			return log_error_errno(-ENOTTY, ENOTTY, "Failed to retrieve name of tty %zu pts", i);
+			return log_error_errno(-ENOTTY, ENOTTY, "Failed to retrieve name of tty %zu pty", i);
 		}
 
-		DEBUG("Created tty \"%s\" with ptx fd %d and pts fd %d",
-		      tty->name, tty->ptx, tty->pts);
+		DEBUG("Created tty \"%s\" with ptx fd %d and pty fd %d",
+		      tty->name, tty->ptx, tty->pty);
 
 		/* Prevent leaking the file descriptors to the container */
 		ret = fd_cloexec(tty->ptx, true);
@@ -944,10 +944,10 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
 			SYSWARN("Failed to set FD_CLOEXEC flag on ptx fd %d of tty device \"%s\"",
 				tty->ptx, tty->name);
 
-		ret = fd_cloexec(tty->pts, true);
+		ret = fd_cloexec(tty->pty, true);
 		if (ret < 0)
-			SYSWARN("Failed to set FD_CLOEXEC flag on pts fd %d of tty device \"%s\"",
-				tty->pts, tty->name);
+			SYSWARN("Failed to set FD_CLOEXEC flag on pty fd %d of tty device \"%s\"",
+				tty->pty, tty->name);
 
 		tty->busy = -1;
 	}
@@ -965,7 +965,7 @@ void lxc_delete_tty(struct lxc_tty_info *ttys)
 	for (int i = 0; i < ttys->max; i++) {
 		struct lxc_terminal_info *tty = &ttys->tty[i];
 		close_prot_errno_disarm(tty->ptx);
-		close_prot_errno_disarm(tty->pts);
+		close_prot_errno_disarm(tty->pty);
 	}
 
 	free_disarm(ttys->tty);
@@ -987,14 +987,14 @@ static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
 		struct lxc_terminal_info *tty = &ttys->tty[i];
 
 		ttyfds[0] = tty->ptx;
-		ttyfds[1] = tty->pts;
+		ttyfds[1] = tty->pty;
 
 		ret = lxc_abstract_unix_send_fds(sock, ttyfds, 2, NULL, 0);
 		if (ret < 0)
 			break;
 
-		TRACE("Sent tty \"%s\" with ptx fd %d and pts fd %d to parent",
-		      tty->name, tty->ptx, tty->pts);
+		TRACE("Sent tty \"%s\" with ptx fd %d and pty fd %d to parent",
+		      tty->name, tty->ptx, tty->pty);
 	}
 
 	if (ret < 0)
@@ -1582,7 +1582,7 @@ static inline bool wants_console(const struct lxc_terminal *terminal)
 
 static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
 				 const struct lxc_terminal *console,
-				 int pts_mnt_fd)
+				 int pty_mnt_fd)
 {
 	int ret;
 	char path[PATH_MAX];
@@ -1615,12 +1615,12 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
 	if (ret < 0 && errno != EEXIST)
 		return log_error_errno(-errno, errno, "Failed to create console");
 
-	ret = fchmod(console->pts, S_IXUSR | S_IXGRP);
+	ret = fchmod(console->pty, S_IXUSR | S_IXGRP);
 	if (ret < 0)
 		return log_error_errno(-errno, errno, "Failed to set mode \"0%o\" to \"%s\"", S_IXUSR | S_IXGRP, console->name);
 
-	if (pts_mnt_fd >= 0) {
-		ret = move_mount(pts_mnt_fd, "", -EBADF, path, MOVE_MOUNT_F_EMPTY_PATH);
+	if (pty_mnt_fd >= 0) {
+		ret = move_mount(pty_mnt_fd, "", -EBADF, path, MOVE_MOUNT_F_EMPTY_PATH);
 		if (!ret) {
 			DEBUG("Moved mount \"%s\" onto \"%s\"", console->name, path);
 			goto finish;
@@ -1629,21 +1629,21 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
 		if (ret && errno != ENOSYS)
 			return log_error_errno(-1, errno,
 					       "Failed to mount %d(%s) on \"%s\"",
-					       pts_mnt_fd, console->name, path);
+					       pty_mnt_fd, console->name, path);
 	}
 
 	ret = safe_mount(console->name, path, "none", MS_BIND, 0, rootfs_path);
 	if (ret < 0)
-		return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pts_mnt_fd, console->name, path);
+		return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pty_mnt_fd, console->name, path);
 
 finish:
-	DEBUG("Mounted pts device %d(%s) onto \"%s\"", pts_mnt_fd, console->name, path);
+	DEBUG("Mounted pty device %d(%s) onto \"%s\"", pty_mnt_fd, console->name, path);
 	return 0;
 }
 
 static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
 				    const struct lxc_terminal *console,
-				    char *ttydir, int pts_mnt_fd)
+				    char *ttydir, int pty_mnt_fd)
 {
 	int ret;
 	char path[PATH_MAX], lxcpath[PATH_MAX];
@@ -1686,13 +1686,13 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
 	if (ret < 0 && errno != EEXIST)
 		return log_error_errno(-errno, errno, "Failed to create console");
 
-	ret = fchmod(console->pts, S_IXUSR | S_IXGRP);
+	ret = fchmod(console->pty, S_IXUSR | S_IXGRP);
 	if (ret < 0)
 		return log_error_errno(-errno, errno, "Failed to set mode \"0%o\" to \"%s\"", S_IXUSR | S_IXGRP, console->name);
 
 	/* bind mount console->name to '/dev/<ttydir>/console' */
-	if (pts_mnt_fd >= 0) {
-		ret = move_mount(pts_mnt_fd, "", -EBADF, lxcpath, MOVE_MOUNT_F_EMPTY_PATH);
+	if (pty_mnt_fd >= 0) {
+		ret = move_mount(pty_mnt_fd, "", -EBADF, lxcpath, MOVE_MOUNT_F_EMPTY_PATH);
 		if (!ret) {
 			DEBUG("Moved mount \"%s\" onto \"%s\"", console->name, lxcpath);
 			goto finish;
@@ -1701,12 +1701,12 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
 		if (ret && errno != ENOSYS)
 			return log_error_errno(-1, errno,
 					       "Failed to mount %d(%s) on \"%s\"",
-					       pts_mnt_fd, console->name, lxcpath);
+					       pty_mnt_fd, console->name, lxcpath);
 	}
 
 	ret = safe_mount(console->name, lxcpath, "none", MS_BIND, 0, rootfs_path);
 	if (ret < 0)
-		return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pts_mnt_fd, console->name, lxcpath);
+		return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pty_mnt_fd, console->name, lxcpath);
 	DEBUG("Mounted \"%s\" onto \"%s\"", console->name, lxcpath);
 
 finish:
@@ -1722,13 +1722,13 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
 
 static int lxc_setup_console(const struct lxc_rootfs *rootfs,
 			     const struct lxc_terminal *console, char *ttydir,
-			     int pts_mnt_fd)
+			     int pty_mnt_fd)
 {
 
 	if (!ttydir)
-		return lxc_setup_dev_console(rootfs, console, pts_mnt_fd);
+		return lxc_setup_dev_console(rootfs, console, pty_mnt_fd);
 
-	return lxc_setup_ttydir_console(rootfs, console, ttydir, pts_mnt_fd);
+	return lxc_setup_ttydir_console(rootfs, console, ttydir, pty_mnt_fd);
 }
 
 static int parse_mntopt(char *opt, unsigned long *flags, char **data, size_t size)
@@ -2547,9 +2547,9 @@ struct lxc_conf *lxc_conf_init(void)
 	new->console.peer = -1;
 	new->console.proxy.busy = -1;
 	new->console.proxy.ptx = -1;
-	new->console.proxy.pts = -1;
+	new->console.proxy.pty = -1;
 	new->console.ptx = -1;
-	new->console.pts = -1;
+	new->console.pty = -1;
 	new->console.name[0] = '\0';
 	memset(&new->console.ringbuf, 0, sizeof(struct lxc_ringbuf));
 	new->maincmd_fd = -1;
@@ -3183,7 +3183,7 @@ static int lxc_setup_boot_id(void)
 
 int lxc_setup(struct lxc_handler *handler)
 {
-	__do_close int pts_mnt_fd = -EBADF;
+	__do_close int pty_mnt_fd = -EBADF;
 	int ret;
 	const char *lxcpath = handler->lxcpath, *name = handler->name;
 	struct lxc_conf *lxc_conf = handler->conf;
@@ -3223,9 +3223,9 @@ int lxc_setup(struct lxc_handler *handler)
 	}
 
 	if (wants_console(&lxc_conf->console)) {
-		pts_mnt_fd = open_tree(-EBADF, lxc_conf->console.name,
+		pty_mnt_fd = open_tree(-EBADF, lxc_conf->console.name,
 				       OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC | AT_EMPTY_PATH);
-		if (pts_mnt_fd < 0)
+		if (pty_mnt_fd < 0)
 			SYSTRACE("Failed to create detached mount for container's console \"%s\"",
 				 lxc_conf->console.name);
 		else
@@ -3310,7 +3310,7 @@ int lxc_setup(struct lxc_handler *handler)
 		return log_error(-1, "Failed to \"/proc\" LSMs");
 
 	ret = lxc_setup_console(&lxc_conf->rootfs, &lxc_conf->console,
-				lxc_conf->ttys.dir, pts_mnt_fd);
+				lxc_conf->ttys.dir, pty_mnt_fd);
 	if (ret < 0)
 		return log_error(-1, "Failed to setup console");
 
diff --git a/src/lxc/criu.c b/src/lxc/criu.c
index 19f2a173f7..c0caffa1b0 100644
--- a/src/lxc/criu.c
+++ b/src/lxc/criu.c
@@ -67,7 +67,7 @@ struct criu_opts {
 	struct lxc_handler *handler;
 	int console_fd;
 	/* The path that is bind mounted from /dev/console, if any. We don't
-	 * want to use `--ext-mount-map auto`'s result here because the pts
+	 * want to use `--ext-mount-map auto`'s result here because the pty
 	 * device may have a different path (e.g. if the pty number is
 	 * different) on the target host. NULL if lxc.console.path = "none".
 	 */
@@ -1020,7 +1020,7 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
 		os.action = "restore";
 		os.user = opts;
 		os.c = c;
-		os.console_fd = c->lxc_conf->console.pts;
+		os.console_fd = c->lxc_conf->console.pty;
 		os.criu_version = criu_version;
 		os.handler = handler;
 
diff --git a/src/lxc/start.c b/src/lxc/start.c
index da2816d5ed..11f452e78a 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1297,14 +1297,14 @@ static int do_start(void *data)
 	 * setup on its console ie. the pty allocated in lxc_terminal_setup() so
 	 * make sure that that pty is stdin,stdout,stderr.
 	 */
-	 if (handler->conf->console.pts >= 0) {
+	 if (handler->conf->console.pty >= 0) {
 		 if (handler->daemonize || !handler->conf->is_execute)
-			 ret = set_stdfds(handler->conf->console.pts);
+			 ret = set_stdfds(handler->conf->console.pty);
 		 else
-			 ret = lxc_terminal_set_stdfds(handler->conf->console.pts);
+			 ret = lxc_terminal_set_stdfds(handler->conf->console.pty);
 		 if (ret < 0) {
 			ERROR("Failed to redirect std{in,out,err} to pty file descriptor %d",
-			      handler->conf->console.pts);
+			      handler->conf->console.pty);
 			goto out_warn_father;
 		 }
 	 }
@@ -1331,7 +1331,7 @@ static int do_start(void *data)
 
 	close_prot_errno_disarm(handler->sigfd);
 
-	if (handler->conf->console.pts < 0 && handler->daemonize) {
+	if (handler->conf->console.pty < 0 && handler->daemonize) {
 		if (devnull_fd < 0) {
 			devnull_fd = open_devnull();
 			if (devnull_fd < 0)
@@ -1484,8 +1484,8 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
 		tty = &ttys->tty[i];
 		tty->busy = -1;
 		tty->ptx = ttyfds[0];
-		tty->pts = ttyfds[1];
-		TRACE("Received pty with ptx fd %d and pts fd %d from child", tty->ptx, tty->pts);
+		tty->pty = ttyfds[1];
+		TRACE("Received pty with ptx fd %d and pty fd %d from child", tty->ptx, tty->pty);
 	}
 
 	if (ret < 0)
diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c
index 701e1f9354..d76a313f5e 100644
--- a/src/lxc/terminal.c
+++ b/src/lxc/terminal.c
@@ -486,8 +486,8 @@ static void lxc_terminal_peer_proxy_free(struct lxc_terminal *terminal)
 	close(terminal->proxy.ptx);
 	terminal->proxy.ptx = -1;
 
-	close(terminal->proxy.pts);
-	terminal->proxy.pts = -1;
+	close(terminal->proxy.pty);
+	terminal->proxy.pty = -1;
 
 	terminal->proxy.busy = -1;
 
@@ -521,17 +521,17 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 	/* This is the proxy terminal that will be given to the client, and
 	 * that the real terminal ptx will send to / recv from.
 	 */
-	ret = openpty(&terminal->proxy.ptx, &terminal->proxy.pts, NULL,
+	ret = openpty(&terminal->proxy.ptx, &terminal->proxy.pty, NULL,
 		      NULL, NULL);
 	if (ret < 0) {
 		SYSERROR("Failed to open proxy terminal");
 		return -1;
 	}
 
-	ret = ttyname_r(terminal->proxy.pts, terminal->proxy.name,
+	ret = ttyname_r(terminal->proxy.pty, terminal->proxy.name,
 			sizeof(terminal->proxy.name));
 	if (ret < 0) {
-		SYSERROR("Failed to retrieve name of proxy terminal pts");
+		SYSERROR("Failed to retrieve name of proxy terminal pty");
 		goto on_error;
 	}
 
@@ -541,13 +541,13 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 		goto on_error;
 	}
 
-	ret = fd_cloexec(terminal->proxy.pts, true);
+	ret = fd_cloexec(terminal->proxy.pty, true);
 	if (ret < 0) {
-		SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal pts");
+		SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal pty");
 		goto on_error;
 	}
 
-	ret = lxc_setup_tios(terminal->proxy.pts, &oldtermio);
+	ret = lxc_setup_tios(terminal->proxy.pty, &oldtermio);
 	if (ret < 0)
 		goto on_error;
 
@@ -556,14 +556,14 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
 		goto on_error;
 
 	terminal->tty_state = ts;
-	terminal->peer = terminal->proxy.pts;
+	terminal->peer = terminal->proxy.pty;
 	terminal->proxy.busy = sockfd;
 	ret = lxc_terminal_mainloop_add_peer(terminal);
 	if (ret < 0)
 		goto on_error;
 
-	NOTICE("Opened proxy terminal with ptx fd %d and pts fd %d",
-	       terminal->proxy.ptx, terminal->proxy.pts);
+	NOTICE("Opened proxy terminal with ptx fd %d and pty fd %d",
+	       terminal->proxy.ptx, terminal->proxy.pty);
 	return 0;
 
 on_error:
@@ -633,7 +633,7 @@ void lxc_terminal_free(struct lxc_conf *conf, int fd)
 	if (terminal->proxy.busy != fd)
 		return;
 
-	lxc_mainloop_del_handler(terminal->descr, terminal->proxy.pts);
+	lxc_mainloop_del_handler(terminal->descr, terminal->proxy.pty);
 	lxc_terminal_peer_proxy_free(terminal);
 }
 
@@ -753,9 +753,9 @@ void lxc_terminal_delete(struct lxc_terminal *terminal)
 		close(terminal->ptx);
 	terminal->ptx = -1;
 
-	if (terminal->pts >= 0)
-		close(terminal->pts);
-	terminal->pts = -1;
+	if (terminal->pty >= 0)
+		close(terminal->pty);
+	terminal->pty = -1;
 
 	if (terminal->log_fd >= 0)
 		close(terminal->log_fd);
@@ -832,15 +832,15 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
 {
 	int ret;
 
-	ret = openpty(&terminal->ptx, &terminal->pts, NULL, NULL, NULL);
+	ret = openpty(&terminal->ptx, &terminal->pty, NULL, NULL, NULL);
 	if (ret < 0) {
 		SYSERROR("Failed to open terminal");
 		return -1;
 	}
 
-	ret = ttyname_r(terminal->pts, terminal->name, sizeof(terminal->name));
+	ret = ttyname_r(terminal->pty, terminal->name, sizeof(terminal->name));
 	if (ret < 0) {
-		SYSERROR("Failed to retrieve name of terminal pts");
+		SYSERROR("Failed to retrieve name of terminal pty");
 		goto err;
 	}
 
@@ -850,9 +850,9 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
 		goto err;
 	}
 
-	ret = fd_cloexec(terminal->pts, true);
+	ret = fd_cloexec(terminal->pty, true);
 	if (ret < 0) {
-		SYSERROR("Failed to set FD_CLOEXEC flag on terminal pts");
+		SYSERROR("Failed to set FD_CLOEXEC flag on terminal pty");
 		goto err;
 	}
 
@@ -1134,14 +1134,14 @@ void lxc_terminal_info_init(struct lxc_terminal_info *terminal)
 {
 	terminal->name[0] = '\0';
 	terminal->ptx = -EBADF;
-	terminal->pts = -EBADF;
+	terminal->pty = -EBADF;
 	terminal->busy = -1;
 }
 
 void lxc_terminal_init(struct lxc_terminal *terminal)
 {
 	memset(terminal, 0, sizeof(*terminal));
-	terminal->pts = -EBADF;
+	terminal->pty = -EBADF;
 	terminal->ptx = -EBADF;
 	terminal->peer = -EBADF;
 	terminal->log_fd = -EBADF;
@@ -1167,13 +1167,13 @@ int lxc_terminal_map_ids(struct lxc_conf *c, struct lxc_terminal *terminal)
 	if (strcmp(terminal->name, "") == 0)
 		return 0;
 
-	ret = userns_exec_mapped_root(terminal->name, terminal->pts, c);
+	ret = userns_exec_mapped_root(terminal->name, terminal->pty, c);
 	if (ret < 0) {
 		return log_error(-1, "Failed to chown terminal %d(%s)",
-				 terminal->pts, terminal->name);
+				 terminal->pty, terminal->name);
 	}
 
-	TRACE("Chowned terminal %d(%s)", terminal->pts, terminal->name);
+	TRACE("Chowned terminal %d(%s)", terminal->pty, terminal->name);
 
 	return 0;
 }
diff --git a/src/lxc/terminal.h b/src/lxc/terminal.h
index 3322900c9d..0b652001df 100644
--- a/src/lxc/terminal.h
+++ b/src/lxc/terminal.h
@@ -15,14 +15,14 @@ struct lxc_conf;
 struct lxc_epoll_descr;
 
 struct lxc_terminal_info {
-	/* the path name of the pts side */
+	/* the path name of the pty side */
 	char name[PATH_MAX];
 
 	/* the file descriptor of the ptx */
 	int ptx;
 
-	/* the file descriptor of the pts */
-	int pts;
+	/* the file descriptor of the pty */
+	int pty;
 
 	/* whether the terminal is currently used */
 	int busy;
@@ -57,7 +57,7 @@ struct lxc_terminal_state {
 };
 
 struct lxc_terminal {
-	int pts;
+	int pty;
 	int ptx;
 	int peer;
 	struct lxc_terminal_info proxy;
@@ -102,10 +102,10 @@ extern int  lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttynum
 
 /**
  * Create a new terminal:
- * - calls openpty() to allocate a ptx/pts pair
- * - sets the FD_CLOEXEC flag on the ptx/pts fds
+ * - calls openpty() to allocate a ptx/pty pair
+ * - sets the FD_CLOEXEC flag on the ptx/pty fds
  * - allocates either the current controlling terminal (default) or a user
- *   specified terminal as proxy for the newly created ptx/pts pair
+ *   specified terminal as proxy for the newly created ptx/pty pair
  * - sets up SIGWINCH handler, winsz, and new terminal settings
  *   (Handlers for SIGWINCH and I/O are not registered in a mainloop.)
  */
@@ -202,7 +202,7 @@ extern int lxc_setup_tios(int fd, struct termios *oldtios);
  * lxc_terminal_winsz: propagate winsz from one terminal to another
  *
  * @srcfd
- * - terminal to get size from (typically a pts pty)
+ * - terminal to get size from (typically a pty pty)
  * @dstfd
  * - terminal to set size on (typically a ptx pty)
  */


More information about the lxc-devel mailing list