]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
console: struct lxc_terminal_state
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 27 Feb 2018 17:25:41 +0000 (18:25 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 27 Feb 2018 21:49:51 +0000 (22:49 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.h
src/lxc/console.c
src/lxc/console.h

index a425b09ce281254b7b1f2320756ece095d1bd7ee..6accce685e4b81ef575a303632ea1dc9e3d1e59d 100644 (file)
@@ -143,8 +143,6 @@ struct lxc_tty_info {
        struct lxc_terminal_info *tty;
 };
 
-struct lxc_tty_state;
-
 /* Defines a structure to store the rootfs location, the
  * optionals pivot_root, rootfs mount paths
  * @path       : the rootfs source (directory or device)
index 79df922ba88b6063772feddff2c597d5d7541c3f..672318545d6d8578c1aa9bf89365e3bcad00d369 100644 (file)
@@ -88,7 +88,7 @@ void lxc_terminal_winsz(int srcfd, int dstfd)
        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);
 
@@ -99,7 +99,7 @@ static void lxc_terminal_winch(struct lxc_tty_state *ts)
 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;
@@ -112,7 +112,7 @@ int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata,
 {
        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)) {
@@ -131,12 +131,12 @@ int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata,
        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)
@@ -189,7 +189,7 @@ on_error:
        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);
@@ -527,7 +527,7 @@ static void lxc_terminal_peer_proxy_free(struct lxc_terminal *terminal)
 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) {
@@ -636,7 +636,7 @@ void lxc_terminal_free(struct lxc_conf *conf, int fd)
 
 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;
@@ -930,7 +930,7 @@ int lxc_terminal_set_stdfds(int fd)
 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)
@@ -961,7 +961,7 @@ int lxc_terminal_stdin_cb(int fd, uint32_t events, void *cbdata,
 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;
 
@@ -995,7 +995,7 @@ int lxc_console(struct lxc_container *c, int ttynum,
        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);
index 3212171df64bf2ee56e0d964d56f63cdd6e96ae0..77b6f18bdc6eb30f3451f077f2f49c990a15546d 100644 (file)
@@ -32,7 +32,9 @@
 #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
@@ -46,6 +48,33 @@ struct lxc_terminal_info {
        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;
@@ -55,7 +84,7 @@ struct lxc_terminal {
        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 */
@@ -71,7 +100,7 @@ struct lxc_terminal {
                unsigned int log_rotate;
        };
 
-       struct /* lxc_pty_ringbuf */ {
+       struct /* lxc_terminal_ringbuf */ {
                /* size of the ringbuffer */
                uint64_t buffer_size;
 
@@ -80,36 +109,6 @@ struct lxc_terminal {
        };
 };
 
-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
  *
@@ -239,8 +238,8 @@ extern void lxc_terminal_winsz(int srcfd, int dstfd);
  * @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
@@ -255,7 +254,7 @@ extern void lxc_terminal_winsz(int srcfd, int dstfd);
  *
  * 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
@@ -267,7 +266,7 @@ extern int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata,
 /*
  * 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.
@@ -275,7 +274,7 @@ extern int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata,
  * 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);