criu/include/tty.h
Cyrill Gorcunov bec5a023d1 tty: Fix mistyping of /dev/tty
/dev/tty stands for current terminal which we don't yet
implemented a support for.

This is a bugfix for upcoming stable version, the proper
support of /dev/tty is gonna be implemented separately.

Reported-by: Saied Kazemi <saied@google.com>
CC: Andrew Vagin <avagin@parallels.com>
CC: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-02-20 00:11:38 +03:00

78 lines
1.6 KiB
C

#ifndef __CR_TTY_H__
#define __CR_TTY_H__
#include <linux/major.h>
#include <linux/vt.h>
#include "files.h"
/* Kernel's limit */
#define TERMIOS_NCC 19
enum {
TTY_TYPE_UNKNOWN = 0,
TTY_TYPE_PTM = 1,
TTY_TYPE_PTS = 2,
TTY_TYPE_CONSOLE = 3,
TTY_TYPE_VT = 4,
TTY_TYPE_MAX
};
#define PTMX_PATH "/dev/ptmx"
#ifndef PTMX_MINOR
# define PTMX_MINOR 2
#endif
#define PTS_FMT "/dev/pts/%d"
extern const struct fdtype_ops tty_dump_ops;
static inline int tty_type(int major, int minor)
{
switch (major) {
case TTYAUX_MAJOR:
if (minor == 2)
return TTY_TYPE_PTM;
else if (minor == 1)
return TTY_TYPE_CONSOLE;
break;
case TTY_MAJOR:
if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
/*
* Minors [MIN_NR_CONSOLES; MAX_NR_CONSOLES] stand
* for consoles (virtual terminals, VT in terms
* of kernel).
*/
return TTY_TYPE_VT;
case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
return TTY_TYPE_PTM;
case UNIX98_PTY_SLAVE_MAJOR:
return TTY_TYPE_PTS;
}
return TTY_TYPE_UNKNOWN;
}
static inline int is_tty(int major, int minor)
{
return tty_type(major, minor) != TTY_TYPE_UNKNOWN;
}
static inline int is_pty(int type)
{
return (type == TTY_TYPE_PTM || type == TTY_TYPE_PTS);
}
extern int dump_verify_tty_sids(void);
extern struct collect_image_info tty_info_cinfo;
extern struct collect_image_info tty_cinfo;
extern int prepare_shared_tty(void);
extern int tty_setup_slavery(void);
extern int tty_verify_active_pairs(void);
extern int tty_prep_fds(void);
extern void tty_fini_fds(void);
#define OPT_SHELL_JOB "shell-job"
#endif /* __CR_TTY_H__ */