--- linux/kernel/chr_drv/vt.c 2018/04/24 18:08:17 1.1 +++ linux/kernel/chr_drv/vt.c 2018/04/24 18:15:42 1.1.1.4 @@ -1,21 +1,20 @@ /* * kernel/chr_drv/vt.c * - * (C) 1992 obz under the linux copyright + * Copyright (C) 1992 obz under the linux copyright */ -#include - -#include -#include -#include - -#include -#include - +#include +#include #include #include +#include #include +#include +#include + +#include +#include #include "vt_kern.h" @@ -23,9 +22,8 @@ * console (vt and kd) routines, as defined by usl svr4 manual */ -struct vt_cons vt_cons[MAX_CONSOLES]; +struct vt_cons vt_cons[NR_CONSOLES]; -extern int NR_CONSOLES; extern unsigned char kleds; extern unsigned char kraw; extern unsigned char ke0; @@ -65,16 +63,18 @@ kiocsound(unsigned int freq) } /* - * all the vt ioctls affect only consoles, so we reject all other ttys. - * we also have the capability to modify any console, not just the fg_console. + * We handle the console-specific ioctl's here. We allow the + * capability to modify any console, not just the fg_console. */ -int -vt_ioctl(struct tty_struct *tty, int dev, int cmd, int arg) +int vt_ioctl(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned int arg) { - int console = dev ? dev - 1 : fg_console; + int console; unsigned char ucval; - if (!IS_A_CONSOLE(dev) || console < 0 || console >= NR_CONSOLES) + console = tty->line - 1; + + if (console < 0 || console >= NR_CONSOLES) return -EINVAL; switch (cmd) { @@ -121,7 +121,17 @@ vt_ioctl(struct tty_struct *tty, int dev default: return -EINVAL; } - vt_cons[console].vt_mode = arg; + if (vt_cons[console].vt_mode == (unsigned char) arg) + return 0; + vt_cons[console].vt_mode = (unsigned char) arg; + if (console != fg_console) + return 0; + if (arg == KD_TEXT) + unblank_screen(); + else { + timer_active &= 1<read_q); - flush(tty->secondary); + flush_input(tty); return 0; case KDGKBMODE: verify_area((void *) arg, sizeof(unsigned long));