Commit d5dfab77 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

check: Add check_tty

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a365befa
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#include <sys/signalfd.h> #include <sys/signalfd.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <sys/ioctl.h>
#include <termios.h>
#include "proc_parse.h" #include "proc_parse.h"
#include "sockets.h" #include "sockets.h"
#include "crtools.h" #include "crtools.h"
...@@ -17,6 +20,53 @@ ...@@ -17,6 +20,53 @@
#include "sk-inet.h" #include "sk-inet.h"
#include "proc_parse.h" #include "proc_parse.h"
#include "mount.h" #include "mount.h"
#include "tty.h"
static int check_tty(void)
{
int master = -1, slave = -1;
const int lock = 1;
struct termios t;
char *slavename;
int ret = -1;
if (ARRAY_SIZE(t.c_cc) < TERMIOS_NCC) {
pr_msg("struct termios has %d @c_cc while "
"at least %d expected.\n",
(int)ARRAY_SIZE(t.c_cc),
TERMIOS_NCC);
goto out;
}
master = open("/dev/ptmx", O_RDWR);
if (master < 0) {
pr_msg("Can't open master pty.\n");
goto out;
}
if (ioctl(master, TIOCSPTLCK, &lock)) {
pr_msg("Unable to lock pty device.\n");
goto out;
}
slavename = ptsname(master);
slave = open(slavename, O_RDWR);
if (slave < 0) {
if (errno != EIO) {
pr_msg("Unexpected error code on locked pty.\n");
goto out;
}
} else {
pr_msg("Managed to open locked pty.\n");
goto out;
}
ret = 0;
out:
close_safe(&master);
close_safe(&slave);
return ret;
}
static int check_map_files(void) static int check_map_files(void)
{ {
...@@ -351,6 +401,7 @@ int cr_check(void) ...@@ -351,6 +401,7 @@ int cr_check(void)
ret |= check_tcp_repair(); ret |= check_tcp_repair();
ret |= check_fdinfo_ext(); ret |= check_fdinfo_ext();
ret |= check_unaligned_vmsplice(); ret |= check_unaligned_vmsplice();
ret |= check_tty();
if (!ret) if (!ret)
pr_msg("Looks good.\n"); pr_msg("Looks good.\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment