mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-05 13:38:38 +00:00
console: struct lxc_terminal_state
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
0e4be3cf03
commit
5b55021fa9
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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,51 +48,14 @@ struct lxc_terminal_info {
|
||||
int busy;
|
||||
};
|
||||
|
||||
struct lxc_terminal {
|
||||
int slave;
|
||||
int master;
|
||||
int peer;
|
||||
struct lxc_terminal_info peerpty;
|
||||
struct lxc_epoll_descr *descr;
|
||||
char *path;
|
||||
char name[MAXPATHLEN];
|
||||
struct termios *tios;
|
||||
struct lxc_tty_state *tty_state;
|
||||
|
||||
struct /* lxc_console_log */ {
|
||||
/* size of the log file */
|
||||
uint64_t log_size;
|
||||
|
||||
/* path to the log file */
|
||||
char *log_path;
|
||||
|
||||
/* fd to the log file */
|
||||
int log_fd;
|
||||
|
||||
/* whether the log file will be rotated */
|
||||
unsigned int log_rotate;
|
||||
};
|
||||
|
||||
struct /* lxc_pty_ringbuf */ {
|
||||
/* size of the ringbuffer */
|
||||
uint64_t buffer_size;
|
||||
|
||||
/* the in-memory ringbuffer */
|
||||
struct lxc_ringbuf ringbuf;
|
||||
};
|
||||
};
|
||||
|
||||
struct lxc_epoll_descr; /* defined in mainloop.h */
|
||||
struct lxc_container; /* defined in lxccontainer.h */
|
||||
struct lxc_tty_state
|
||||
{
|
||||
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
|
||||
* 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;
|
||||
@ -110,6 +75,40 @@ struct lxc_tty_state
|
||||
sigset_t oldmask;
|
||||
};
|
||||
|
||||
struct lxc_terminal {
|
||||
int slave;
|
||||
int master;
|
||||
int peer;
|
||||
struct lxc_terminal_info peerpty;
|
||||
struct lxc_epoll_descr *descr;
|
||||
char *path;
|
||||
char name[MAXPATHLEN];
|
||||
struct termios *tios;
|
||||
struct lxc_terminal_state *tty_state;
|
||||
|
||||
struct /* lxc_console_log */ {
|
||||
/* size of the log file */
|
||||
uint64_t log_size;
|
||||
|
||||
/* path to the log file */
|
||||
char *log_path;
|
||||
|
||||
/* fd to the log file */
|
||||
int log_fd;
|
||||
|
||||
/* whether the log file will be rotated */
|
||||
unsigned int log_rotate;
|
||||
};
|
||||
|
||||
struct /* lxc_terminal_ringbuf */ {
|
||||
/* size of the ringbuffer */
|
||||
uint64_t buffer_size;
|
||||
|
||||
/* the in-memory ringbuffer */
|
||||
struct lxc_ringbuf ringbuf;
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
Loading…
Reference in New Issue
Block a user