Skip to content

Commit

Permalink
tree-wide: s/ptmx/ptx/g
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Jul 5, 2020
1 parent 3e51985 commit 36a94ce
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 117 deletions.
20 changes: 10 additions & 10 deletions src/include/openpty.c
Expand Up @@ -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);
Expand All @@ -63,14 +63,14 @@ 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);

return 0;

fail:
close(ptmx);
close(ptx);
return -1;
}
6 changes: 3 additions & 3 deletions src/include/openpty.h
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/lxc/attach.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions src/lxc/commands.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/lxc/commands.h
Expand Up @@ -61,7 +61,7 @@ struct lxc_cmd_rr {
};

struct lxc_cmd_console_rsp_data {
int ptmxfd;
int ptxfd;
int ttynum;
};

Expand Down
26 changes: 13 additions & 13 deletions src/lxc/conf.c
Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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);
}

Expand All @@ -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)
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/lxc/lxccontainer.c
Expand Up @@ -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 *)
Expand Down
4 changes: 2 additions & 2 deletions src/lxc/lxccontainer.h
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/lxc/start.c
Expand Up @@ -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)
Expand Down

0 comments on commit 36a94ce

Please sign in to comment.