return;
}
-static void lxc_terminal_winch(struct lxc_tty_state *ts)
+static void lxc_terminal_winch(struct lxc_terminal_state *ts)
{
lxc_terminal_winsz(ts->stdinfd, ts->masterfd);
void lxc_terminal_sigwinch(int sig)
{
struct lxc_list *it;
- struct lxc_tty_state *ts;
+ struct lxc_terminal_state *ts;
lxc_list_for_each(it, &lxc_ttys) {
ts = it->elem;
{
ssize_t ret;
struct signalfd_siginfo siginfo;
- struct lxc_tty_state *ts = cbdata;
+ struct lxc_terminal_state *ts = cbdata;
ret = read(fd, &siginfo, sizeof(siginfo));
if (ret < 0 || (size_t)ret < sizeof(siginfo)) {
return 0;
}
-struct lxc_tty_state *lxc_terminal_signal_init(int srcfd, int dstfd)
+struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
{
int ret;
bool istty;
sigset_t mask;
- struct lxc_tty_state *ts;
+ struct lxc_terminal_state *ts;
ts = malloc(sizeof(*ts));
if (!ts)
return ts;
}
-void lxc_terminal_signal_fini(struct lxc_tty_state *ts)
+void lxc_terminal_signal_fini(struct lxc_terminal_state *ts)
{
if (ts->sigfd >= 0) {
close(ts->sigfd);
static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal, int sockfd)
{
struct termios oldtermio;
- struct lxc_tty_state *ts;
+ struct lxc_terminal_state *ts;
int ret;
if (terminal->master < 0) {
static int lxc_terminal_peer_default(struct lxc_terminal *terminal)
{
- struct lxc_tty_state *ts;
+ struct lxc_terminal_state *ts;
const char *path = terminal->path;
int fd;
int ret = 0;
int lxc_terminal_stdin_cb(int fd, uint32_t events, void *cbdata,
struct lxc_epoll_descr *descr)
{
- struct lxc_tty_state *ts = cbdata;
+ struct lxc_terminal_state *ts = cbdata;
char c;
if (fd != ts->stdinfd)
int lxc_terminal_master_cb(int fd, uint32_t events, void *cbdata,
struct lxc_epoll_descr *descr)
{
- struct lxc_tty_state *ts = cbdata;
+ struct lxc_terminal_state *ts = cbdata;
char buf[LXC_TERMINAL_BUFFER_SIZE];
int r, w;
int ret, ttyfd, masterfd;
struct lxc_epoll_descr descr;
struct termios oldtios;
- struct lxc_tty_state *ts;
+ struct lxc_terminal_state *ts;
int istty = 0;
ttyfd = lxc_cmd_console(c->name, &ttynum, &masterfd, c->config_path);
#include "list.h"
#include "ringbuf.h"
+struct lxc_container;
struct lxc_conf;
+struct lxc_epoll_descr;
/* Defines a structure containing a pty information for virtualizing a tty
* @name : the path name of the slave pty side
int busy;
};
+struct lxc_terminal_state {
+ struct lxc_list node;
+ int stdinfd;
+ int stdoutfd;
+ int masterfd;
+ /* Escape sequence to use for exiting the pty. A single char can be
+ * specified. The pty can then exited by doing: Ctrl + specified_char +
+ * q. This field is checked by lxc_terminal_stdin_cb(). Set to -1 to
+ * disable exiting the pty via a escape sequence.
+ */
+ int escape;
+ /* Used internally by lxc_terminal_stdin_cb() to check whether an
+ * escape sequence has been received.
+ */
+ int saw_escape;
+ /* Name of the container to forward the SIGWINCH event to. */
+ const char *winch_proxy;
+ /* Path of the container to forward the SIGWINCH event to. */
+ const char *winch_proxy_lxcpath;
+ /* File descriptor that accepts signals. If set to -1 no signal handler
+ * could be installed. This also means that the sigset_t oldmask member
+ * is meaningless.
+ */
+ int sigfd;
+ sigset_t oldmask;
+};
+
struct lxc_terminal {
int slave;
int master;
char *path;
char name[MAXPATHLEN];
struct termios *tios;
- struct lxc_tty_state *tty_state;
+ struct lxc_terminal_state *tty_state;
struct /* lxc_console_log */ {
/* size of the log file */
unsigned int log_rotate;
};
- struct /* lxc_pty_ringbuf */ {
+ struct /* lxc_terminal_ringbuf */ {
/* size of the ringbuffer */
uint64_t buffer_size;
};
};
-struct lxc_epoll_descr; /* defined in mainloop.h */
-struct lxc_container; /* defined in lxccontainer.h */
-struct lxc_tty_state
-{
- struct lxc_list node;
- int stdinfd;
- int stdoutfd;
- int masterfd;
- /* Escape sequence to use for exiting the pty. A single char can be
- * specified. The pty can then exited by doing: Ctrl + specified_char + q.
- * This field is checked by lxc_terminal_stdin_cb(). Set to -1 to
- * disable exiting the pty via a escape sequence.
- */
- int escape;
- /* Used internally by lxc_terminal_stdin_cb() to check whether an
- * escape sequence has been received.
- */
- int saw_escape;
- /* Name of the container to forward the SIGWINCH event to. */
- const char *winch_proxy;
- /* Path of the container to forward the SIGWINCH event to. */
- const char *winch_proxy_lxcpath;
- /* File descriptor that accepts signals. If set to -1 no signal handler
- * could be installed. This also means that the sigset_t oldmask member
- * is meaningless.
- */
- int sigfd;
- sigset_t oldmask;
-};
-
/*
* lxc_terminal_allocate: allocate the console or a tty
*
* @srcfd : src for winsz in SIGWINCH handler
* @dstfd : dst for winsz in SIGWINCH handler
*
- * Returns lxc_tty_state structure on success or NULL on failure. The sigfd
- * member of the returned lxc_tty_state can be select()/poll()ed/epoll()ed
+ * Returns lxc_terminal_state structure on success or NULL on failure. The sigfd
+ * member of the returned lxc_terminal_state can be select()/poll()ed/epoll()ed
* on (ie added to a mainloop) for signals.
*
* Must be called with process_lock held to protect the lxc_ttys list, or
*
* This function allocates memory. It is up to the caller to free it.
*/
-extern struct lxc_tty_state *lxc_terminal_signal_init(int srcfd, int dstfd);
+extern struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd);
/*
* Handler for signal events. To be registered via the corresponding functions
/*
* lxc_terminal_signal_fini: uninstall signal handler
*
- * @ts : the lxc_tty_state returned by lxc_terminal_signal_init
+ * @ts : the lxc_terminal_state returned by lxc_terminal_signal_init
*
* Restore the saved signal handler that was in effect at the time
* lxc_terminal_signal_init() was called.
* Must be called with process_lock held to protect the lxc_ttys list, or
* from a non-threaded context.
*/
-extern void lxc_terminal_signal_fini(struct lxc_tty_state *ts);
+extern void lxc_terminal_signal_fini(struct lxc_terminal_state *ts);
extern int lxc_terminal_write_ringbuffer(struct lxc_terminal *console);
extern int lxc_terminal_create_log_file(struct lxc_terminal *console);