aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-02-17 12:39:28 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-17 17:16:30 -0500
commit3c95c985fa91ecf6a0e29622bbdd13dcfc5ce9f1 (patch)
tree653ac54f667d5868712aef584ea7fea3b5542810
parentafaae08442d86402f9e0b63475c02a651c6f1387 (diff)
tty: add TIOCVHANGUP to allow clean tty shutdown of all ttys
This is useful for system management software so that it can kick off things like gettys and everything that's started from a tty, before we reuse it from/for something else or shut it down. Without this ioctl it would have to temporarily become the owner of the tty, then call vhangup() and then give it up again. Cc: Lennart Poettering <lennart@poettering.net> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--arch/alpha/include/asm/ioctls.h1
-rw-r--r--arch/mips/include/asm/ioctls.h1
-rw-r--r--arch/parisc/include/asm/ioctls.h1
-rw-r--r--arch/powerpc/include/asm/ioctls.h1
-rw-r--r--arch/sh/include/asm/ioctls.h1
-rw-r--r--arch/sparc/include/asm/ioctls.h1
-rw-r--r--arch/xtensa/include/asm/ioctls.h1
-rw-r--r--drivers/tty/tty_io.c5
-rw-r--r--include/asm-generic/ioctls.h1
9 files changed, 13 insertions, 0 deletions
diff --git a/arch/alpha/include/asm/ioctls.h b/arch/alpha/include/asm/ioctls.h
index 034b6cf5d9f3..80e1cee90f1f 100644
--- a/arch/alpha/include/asm/ioctls.h
+++ b/arch/alpha/include/asm/ioctls.h
@@ -94,6 +94,7 @@
94#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 94#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
95#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */ 95#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
96#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 96#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
97#define TIOCVHANGUP 0x5437
97 98
98#define TIOCSERCONFIG 0x5453 99#define TIOCSERCONFIG 0x5453
99#define TIOCSERGWILD 0x5454 100#define TIOCSERGWILD 0x5454
diff --git a/arch/mips/include/asm/ioctls.h b/arch/mips/include/asm/ioctls.h
index d967b8997626..92403c3d6007 100644
--- a/arch/mips/include/asm/ioctls.h
+++ b/arch/mips/include/asm/ioctls.h
@@ -85,6 +85,7 @@
85#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */ 85#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */
86#define TIOCGDEV _IOR('T', 0x32, unsigned int) /* Get primary device node of /dev/console */ 86#define TIOCGDEV _IOR('T', 0x32, unsigned int) /* Get primary device node of /dev/console */
87#define TIOCSIG _IOW('T', 0x36, int) /* Generate signal on Pty slave */ 87#define TIOCSIG _IOW('T', 0x36, int) /* Generate signal on Pty slave */
88#define TIOCVHANGUP 0x5437
88 89
89/* I hope the range from 0x5480 on is free ... */ 90/* I hope the range from 0x5480 on is free ... */
90#define TIOCSCTTY 0x5480 /* become controlling tty */ 91#define TIOCSCTTY 0x5480 /* become controlling tty */
diff --git a/arch/parisc/include/asm/ioctls.h b/arch/parisc/include/asm/ioctls.h
index 6ba80d03623a..054ec06f9e23 100644
--- a/arch/parisc/include/asm/ioctls.h
+++ b/arch/parisc/include/asm/ioctls.h
@@ -54,6 +54,7 @@
54#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 54#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
55#define TIOCGDEV _IOR('T',0x32, int) /* Get primary device node of /dev/console */ 55#define TIOCGDEV _IOR('T',0x32, int) /* Get primary device node of /dev/console */
56#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 56#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
57#define TIOCVHANGUP 0x5437
57 58
58#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 59#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
59#define FIOCLEX 0x5451 60#define FIOCLEX 0x5451
diff --git a/arch/powerpc/include/asm/ioctls.h b/arch/powerpc/include/asm/ioctls.h
index c7dc17cf84f1..e9b78870aaab 100644
--- a/arch/powerpc/include/asm/ioctls.h
+++ b/arch/powerpc/include/asm/ioctls.h
@@ -96,6 +96,7 @@
96#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 96#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
97#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */ 97#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
98#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 98#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
99#define TIOCVHANGUP 0x5437
99 100
100#define TIOCSERCONFIG 0x5453 101#define TIOCSERCONFIG 0x5453
101#define TIOCSERGWILD 0x5454 102#define TIOCSERGWILD 0x5454
diff --git a/arch/sh/include/asm/ioctls.h b/arch/sh/include/asm/ioctls.h
index 84e85a792638..a6769f352bf6 100644
--- a/arch/sh/include/asm/ioctls.h
+++ b/arch/sh/include/asm/ioctls.h
@@ -87,6 +87,7 @@
87#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 87#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
88#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */ 88#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
89#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 89#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
90#define TIOCVHANGUP _IO('T', 0x37)
90 91
91#define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */ 92#define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */
92#define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */ 93#define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */
diff --git a/arch/sparc/include/asm/ioctls.h b/arch/sparc/include/asm/ioctls.h
index ed3807b96bb5..28d0c8b02cc3 100644
--- a/arch/sparc/include/asm/ioctls.h
+++ b/arch/sparc/include/asm/ioctls.h
@@ -20,6 +20,7 @@
20#define TCSETSW2 _IOW('T', 14, struct termios2) 20#define TCSETSW2 _IOW('T', 14, struct termios2)
21#define TCSETSF2 _IOW('T', 15, struct termios2) 21#define TCSETSF2 _IOW('T', 15, struct termios2)
22#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */ 22#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
23#define TIOCVHANGUP _IO('T', 0x37)
23 24
24/* Note that all the ioctls that are not available in Linux have a 25/* Note that all the ioctls that are not available in Linux have a
25 * double underscore on the front to: a) avoid some programs to 26 * double underscore on the front to: a) avoid some programs to
diff --git a/arch/xtensa/include/asm/ioctls.h b/arch/xtensa/include/asm/ioctls.h
index ccf1800f0b0c..fd1d1369a407 100644
--- a/arch/xtensa/include/asm/ioctls.h
+++ b/arch/xtensa/include/asm/ioctls.h
@@ -100,6 +100,7 @@
100#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 100#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
101#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */ 101#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
102#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 102#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
103#define TIOCVHANGUP _IO('T', 0x37)
103 104
104#define TIOCSERCONFIG _IO('T', 83) 105#define TIOCSERCONFIG _IO('T', 83)
105#define TIOCSERGWILD _IOR('T', 84, int) 106#define TIOCSERGWILD _IOR('T', 84, int)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 20a862a2a0c2..8ef2d69470ec 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2626,6 +2626,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2626 return put_user(tty->ldisc->ops->num, (int __user *)p); 2626 return put_user(tty->ldisc->ops->num, (int __user *)p);
2627 case TIOCSETD: 2627 case TIOCSETD:
2628 return tiocsetd(tty, p); 2628 return tiocsetd(tty, p);
2629 case TIOCVHANGUP:
2630 if (!capable(CAP_SYS_ADMIN))
2631 return -EPERM;
2632 tty_vhangup(tty);
2633 return 0;
2629 case TIOCGDEV: 2634 case TIOCGDEV:
2630 { 2635 {
2631 unsigned int ret = new_encode_dev(tty_devnum(real_tty)); 2636 unsigned int ret = new_encode_dev(tty_devnum(real_tty));
diff --git a/include/asm-generic/ioctls.h b/include/asm-generic/ioctls.h
index 3f3f2d189fb8..199975fac395 100644
--- a/include/asm-generic/ioctls.h
+++ b/include/asm-generic/ioctls.h
@@ -73,6 +73,7 @@
73#define TCSETXF 0x5434 73#define TCSETXF 0x5434
74#define TCSETXW 0x5435 74#define TCSETXW 0x5435
75#define TIOCSIG _IOW('T', 0x36, int) /* pty: generate signal */ 75#define TIOCSIG _IOW('T', 0x36, int) /* pty: generate signal */
76#define TIOCVHANGUP 0x5437
76 77
77#define FIONCLEX 0x5450 78#define FIONCLEX 0x5450
78#define FIOCLEX 0x5451 79#define FIOCLEX 0x5451