Skip to content

Commit

Permalink
Merge pull request #3477 from brauner/2020-07-05/fixes
Browse files Browse the repository at this point in the history
tree-wide: update terminal terminology once more
  • Loading branch information
stgraber committed Jul 5, 2020
2 parents 3e51985 + 41808e2 commit 184de6b
Show file tree
Hide file tree
Showing 16 changed files with 192 additions and 192 deletions.
4 changes: 2 additions & 2 deletions doc/ja/lxc.container.conf.sgml.in
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion doc/ko/lxc.container.conf.sgml.in
Expand Up @@ -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의 최대 개수를 지정한다. (이 제한은 아직 구현되지 않았다)
Expand Down
2 changes: 1 addition & 1 deletion doc/lxc.container.conf.sgml.in
Expand Up @@ -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>
Expand Down
30 changes: 15 additions & 15 deletions src/include/openpty.c
Expand Up @@ -32,45 +32,45 @@
#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, pty;

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 (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);

*aptmx = ptmx;
*apts = pts;
*aptx = ptx;
*apts = pty;
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 pty 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
10 changes: 5 additions & 5 deletions src/lxc/attach.c
Expand Up @@ -932,14 +932,14 @@ 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)
{
close_prot_errno_disarm(terminal->pts);
close_prot_errno_disarm(terminal->pty);
}

static inline void lxc_attach_terminal_close_peer(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 Expand Up @@ -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;

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

0 comments on commit 184de6b

Please sign in to comment.