From 0a600ee647490c993753478ef557c46e8601bab0 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 19 Sep 2009 13:13:26 -0700 Subject: [PATCH] --- yaml --- r: 163841 b: refs/heads/master c: d3b5cffcf84a8bdc7073dce4745d67c72629af85 h: refs/heads/master i: 163839: 820908f85d8f79136026e16e4e366ec7895ebcf6 v: v3 --- [refs] | 2 +- trunk/drivers/char/vt_ioctl.c | 38 ++++++++++++++++++++++++++++++++++- trunk/include/linux/vt.h | 7 +++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 17a97858dc64..b1a6b2707823 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a5eb56242d1e2d82938a066219ac1cdf0d68adc8 +refs/heads/master: d3b5cffcf84a8bdc7073dce4745d67c72629af85 diff --git a/trunk/drivers/char/vt_ioctl.c b/trunk/drivers/char/vt_ioctl.c index d29fbd44bdca..0fceb8f4d6f2 100644 --- a/trunk/drivers/char/vt_ioctl.c +++ b/trunk/drivers/char/vt_ioctl.c @@ -972,6 +972,41 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, } break; + case VT_SETACTIVATE: + { + struct vt_setactivate vsa; + + if (!perm) + goto eperm; + + if (copy_from_user(&vsa, (struct vt_setactivate __user *)arg, + sizeof(struct vt_setactivate))) + return -EFAULT; + if (vsa.console == 0 || vsa.console > MAX_NR_CONSOLES) + ret = -ENXIO; + else { + vsa.console--; + acquire_console_sem(); + ret = vc_allocate(vsa.console); + if (ret == 0) { + struct vc_data *nvc; + /* This is safe providing we don't drop the + console sem between vc_allocate and + finishing referencing nvc */ + nvc = vc_cons[vsa.console].d; + nvc->vt_mode = vsa.mode; + nvc->vt_mode.frsig = 0; + put_pid(nvc->vt_pid); + nvc->vt_pid = get_pid(task_pid(current)); + } + release_console_sem(); + if (ret) + break; + /* Commence switch and lock */ + set_console(arg); + } + } + /* * wait until the specified VT has been activated */ @@ -1342,7 +1377,8 @@ void vc_SAK(struct work_struct *work) } /* - * Performs the back end of a vt switch + * Performs the back end of a vt switch. Called under the console + * semaphore. */ static void complete_change_console(struct vc_data *vc) { diff --git a/trunk/include/linux/vt.h b/trunk/include/linux/vt.h index 831daf64b90c..7afca0d72139 100644 --- a/trunk/include/linux/vt.h +++ b/trunk/include/linux/vt.h @@ -77,4 +77,11 @@ struct vt_event { #define VT_WAITEVENT 0x560E /* Wait for an event */ +struct vt_setactivate { + unsigned int console; + struct vt_mode mode; +}; + +#define VT_SETACTIVATE 0x560F /* Activate and set the mode of a console */ + #endif /* _LINUX_VT_H */