linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/3] ttys flags, updated
@ 2012-09-27 21:10 Cyrill Gorcunov
  2012-09-27 21:10 ` [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c Cyrill Gorcunov
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-09-27 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: alan, hpa, gregkh, xemul, jslaby

Hi guys, here is updated series which should address all concerns.
Please review, thanks!

	Cyrill

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c
  2012-09-27 21:10 [patch 0/3] ttys flags, updated Cyrill Gorcunov
@ 2012-09-27 21:10 ` Cyrill Gorcunov
  2012-10-16  8:33   ` Cyrill Gorcunov
  2012-10-24 18:27   ` Greg KH
  2012-09-27 21:10 ` [patch 2/3] tty, ioctls -- Add new ioctl definitions for tty flags fetching Cyrill Gorcunov
  2012-09-27 21:10 ` [patch 3/3] tty: Add get- ioctls to fetch tty status v3 Cyrill Gorcunov
  2 siblings, 2 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-09-27 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: alan, hpa, gregkh, xemul, jslaby, Cyrill Gorcunov

[-- Attachment #1: tty-move-pktmode-set-2 --]
[-- Type: text/plain, Size: 3045 bytes --]

Since this ioctl is for pty devices only move it to pty.c.

v2:
 - drop PTY_TYPE_MASTER test since it's master peer
   ioctl anyway (by jslaby@)

Suggested-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/pty.c       |   26 ++++++++++++++++++++++++++
 drivers/tty/tty_ioctl.c |   20 --------------------
 2 files changed, 26 insertions(+), 20 deletions(-)

Index: tty.git/drivers/tty/pty.c
===================================================================
--- tty.git.orig/drivers/tty/pty.c
+++ tty.git/drivers/tty/pty.c
@@ -174,6 +174,28 @@ static int pty_set_lock(struct tty_struc
 	return 0;
 }
 
+/* Set the packet mode on a pty */
+static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
+{
+	unsigned long flags;
+	int pktmode;
+
+	if (get_user(pktmode, arg))
+		return -EFAULT;
+
+	spin_lock_irqsave(&tty->ctrl_lock, flags);
+	if (pktmode) {
+		if (!tty->packet) {
+			tty->packet = 1;
+			tty->link->ctrl_status = 0;
+		}
+	} else
+		tty->packet = 0;
+	spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+
+	return 0;
+}
+
 /* Send a signal to the slave */
 static int pty_signal(struct tty_struct *tty, int sig)
 {
@@ -393,6 +415,8 @@ static int pty_bsd_ioctl(struct tty_stru
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *) arg);
+	case TIOCPKT: /* Set PT packet mode */
+		return pty_set_pktmode(tty, (int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
 		return pty_signal(tty, (int) arg);
 	}
@@ -507,6 +531,8 @@ static int pty_unix98_ioctl(struct tty_s
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *)arg);
+	case TIOCPKT: /* Set PT packet mode */
+		return pty_set_pktmode(tty, (int __user *)arg);
 	case TIOCGPTN: /* Get PT Number */
 		return put_user(tty->index, (unsigned int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
Index: tty.git/drivers/tty/tty_ioctl.c
===================================================================
--- tty.git.orig/drivers/tty/tty_ioctl.c
+++ tty.git/drivers/tty/tty_ioctl.c
@@ -1153,26 +1153,6 @@ int n_tty_ioctl_helper(struct tty_struct
 		return 0;
 	case TCFLSH:
 		return tty_perform_flush(tty, arg);
-	case TIOCPKT:
-	{
-		int pktmode;
-
-		if (tty->driver->type != TTY_DRIVER_TYPE_PTY ||
-		    tty->driver->subtype != PTY_TYPE_MASTER)
-			return -ENOTTY;
-		if (get_user(pktmode, (int __user *) arg))
-			return -EFAULT;
-		spin_lock_irqsave(&tty->ctrl_lock, flags);
-		if (pktmode) {
-			if (!tty->packet) {
-				tty->packet = 1;
-				tty->link->ctrl_status = 0;
-			}
-		} else
-			tty->packet = 0;
-		spin_unlock_irqrestore(&tty->ctrl_lock, flags);
-		return 0;
-	}
 	default:
 		/* Try the mode commands */
 		return tty_mode_ioctl(tty, file, cmd, arg);


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [patch 2/3] tty, ioctls -- Add new ioctl definitions for tty flags fetching
  2012-09-27 21:10 [patch 0/3] ttys flags, updated Cyrill Gorcunov
  2012-09-27 21:10 ` [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c Cyrill Gorcunov
@ 2012-09-27 21:10 ` Cyrill Gorcunov
  2012-10-24 18:28   ` Greg KH
  2012-09-27 21:10 ` [patch 3/3] tty: Add get- ioctls to fetch tty status v3 Cyrill Gorcunov
  2 siblings, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-09-27 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: alan, hpa, gregkh, xemul, jslaby, Cyrill Gorcunov

[-- Attachment #1: tty-add-new-ioctls --]
[-- Type: text/plain, Size: 7049 bytes --]

This patch defines new ioctl codes TIOCGPKT, TIOCGPTLCK,
TIOCGEXCL for fetching pty's packet mode and locking state,
and exclusive mode of tty.

[ No real handlers for the codes though, this will be
  addressed in another patch for easier review and
  bisectability ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Jiri Slaby <jslaby@suse.cz>
---
 arch/alpha/include/asm/ioctls.h   |    3 +++
 arch/mips/include/asm/ioctls.h    |    3 +++
 arch/parisc/include/asm/ioctls.h  |    3 +++
 arch/powerpc/include/asm/ioctls.h |    3 +++
 arch/sh/include/asm/ioctls.h      |    3 +++
 arch/sparc/include/asm/ioctls.h   |    3 +++
 arch/xtensa/include/asm/ioctls.h  |    3 +++
 fs/compat_ioctl.c                 |    3 +++
 include/asm-generic/ioctls.h      |    3 +++
 9 files changed, 27 insertions(+)

Index: tty.git/arch/alpha/include/asm/ioctls.h
===================================================================
--- tty.git.orig/arch/alpha/include/asm/ioctls.h
+++ tty.git/arch/alpha/include/asm/ioctls.h
@@ -95,6 +95,9 @@
 #define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
 #define TIOCSIG		_IOW('T',0x36, int)  /* Generate signal on Pty slave */
 #define TIOCVHANGUP	0x5437
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 #define TIOCSERCONFIG	0x5453
 #define TIOCSERGWILD	0x5454
Index: tty.git/arch/mips/include/asm/ioctls.h
===================================================================
--- tty.git.orig/arch/mips/include/asm/ioctls.h
+++ tty.git/arch/mips/include/asm/ioctls.h
@@ -86,6 +86,9 @@
 #define TIOCGDEV	_IOR('T', 0x32, unsigned int) /* Get primary device node of /dev/console */
 #define TIOCSIG		_IOW('T', 0x36, int)  /* Generate signal on Pty slave */
 #define TIOCVHANGUP	0x5437
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 /* I hope the range from 0x5480 on is free ... */
 #define TIOCSCTTY	0x5480		/* become controlling tty */
Index: tty.git/arch/parisc/include/asm/ioctls.h
===================================================================
--- tty.git.orig/arch/parisc/include/asm/ioctls.h
+++ tty.git/arch/parisc/include/asm/ioctls.h
@@ -55,6 +55,9 @@
 #define TIOCGDEV	_IOR('T',0x32, int)  /* Get primary device node of /dev/console */
 #define TIOCSIG		_IOW('T',0x36, int)  /* Generate signal on Pty slave */
 #define TIOCVHANGUP	0x5437
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 #define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX		0x5451
Index: tty.git/arch/powerpc/include/asm/ioctls.h
===================================================================
--- tty.git.orig/arch/powerpc/include/asm/ioctls.h
+++ tty.git/arch/powerpc/include/asm/ioctls.h
@@ -97,6 +97,9 @@
 #define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
 #define TIOCSIG		_IOW('T',0x36, int)  /* Generate signal on Pty slave */
 #define TIOCVHANGUP	0x5437
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 #define TIOCSERCONFIG	0x5453
 #define TIOCSERGWILD	0x5454
Index: tty.git/arch/sh/include/asm/ioctls.h
===================================================================
--- tty.git.orig/arch/sh/include/asm/ioctls.h
+++ tty.git/arch/sh/include/asm/ioctls.h
@@ -88,6 +88,9 @@
 #define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
 #define TIOCSIG		_IOW('T',0x36, int)  /* Generate signal on Pty slave */
 #define TIOCVHANGUP	_IO('T', 0x37)
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 #define TIOCSERCONFIG	_IO('T', 83) /* 0x5453 */
 #define TIOCSERGWILD	_IOR('T', 84,  int) /* 0x5454 */
Index: tty.git/arch/sparc/include/asm/ioctls.h
===================================================================
--- tty.git.orig/arch/sparc/include/asm/ioctls.h
+++ tty.git/arch/sparc/include/asm/ioctls.h
@@ -21,6 +21,9 @@
 #define TCSETSF2	_IOW('T', 15, struct termios2)
 #define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
 #define TIOCVHANGUP	_IO('T', 0x37)
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 /* Note that all the ioctls that are not available in Linux have a 
  * double underscore on the front to: a) avoid some programs to
Index: tty.git/arch/xtensa/include/asm/ioctls.h
===================================================================
--- tty.git.orig/arch/xtensa/include/asm/ioctls.h
+++ tty.git/arch/xtensa/include/asm/ioctls.h
@@ -101,6 +101,9 @@
 #define TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
 #define TIOCSIG		_IOW('T',0x36, int)  /* Generate signal on Pty slave */
 #define TIOCVHANGUP	_IO('T', 0x37)
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 #define TIOCSERCONFIG	_IO('T', 83)
 #define TIOCSERGWILD	_IOR('T', 84,  int)
Index: tty.git/fs/compat_ioctl.c
===================================================================
--- tty.git.orig/fs/compat_ioctl.c
+++ tty.git/fs/compat_ioctl.c
@@ -842,6 +842,9 @@ COMPATIBLE_IOCTL(TIOCGDEV)
 COMPATIBLE_IOCTL(TIOCCBRK)
 COMPATIBLE_IOCTL(TIOCGSID)
 COMPATIBLE_IOCTL(TIOCGICOUNT)
+COMPATIBLE_IOCTL(TIOCGPKT)
+COMPATIBLE_IOCTL(TIOCGPTLCK)
+COMPATIBLE_IOCTL(TIOCGEXCL)
 /* Little t */
 COMPATIBLE_IOCTL(TIOCGETD)
 COMPATIBLE_IOCTL(TIOCSETD)
Index: tty.git/include/asm-generic/ioctls.h
===================================================================
--- tty.git.orig/include/asm-generic/ioctls.h
+++ tty.git/include/asm-generic/ioctls.h
@@ -74,6 +74,9 @@
 #define TCSETXW		0x5435
 #define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
 #define TIOCVHANGUP	0x5437
+#define TIOCGPKT	_IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK	_IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL	_IOR('T', 0x40, int) /* Get exclusive mode state */
 
 #define FIONCLEX	0x5450
 #define FIOCLEX		0x5451


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [patch 3/3] tty: Add get- ioctls to fetch tty status v3
  2012-09-27 21:10 [patch 0/3] ttys flags, updated Cyrill Gorcunov
  2012-09-27 21:10 ` [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c Cyrill Gorcunov
  2012-09-27 21:10 ` [patch 2/3] tty, ioctls -- Add new ioctl definitions for tty flags fetching Cyrill Gorcunov
@ 2012-09-27 21:10 ` Cyrill Gorcunov
  2 siblings, 0 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-09-27 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: alan, hpa, gregkh, xemul, jslaby, Cyrill Gorcunov

[-- Attachment #1: tty-fetch-flags-8 --]
[-- Type: text/plain, Size: 3513 bytes --]

For checkpoint/restore we need to know if tty has
exclusive or packet mode set, as well as if pty
is currently locked. Just to be able to restore
this characteristics.

For this sake the following ioctl codes are introduced

 - TIOCGPKT to get packet mode state
 - TIOCGPTLCK to get Pty locked state
 - TIOCGEXCL to get Exclusive mode state

Note this ioctls are a bit unsafe in terms of data
obtained consistency. The tty characteristics might
be changed right after ioctl complete. Keep it in
mind and use this ioctl carefully.

v2:
 - Use TIOC prefix for ioctl codes (by jslaby@)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/pty.c    |   21 +++++++++++++++++++++
 drivers/tty/tty_io.c |    5 +++++
 2 files changed, 26 insertions(+)

Index: tty.git/drivers/tty/pty.c
===================================================================
--- tty.git.orig/drivers/tty/pty.c
+++ tty.git/drivers/tty/pty.c
@@ -174,6 +174,12 @@ static int pty_set_lock(struct tty_struc
 	return 0;
 }
 
+static int pty_get_lock(struct tty_struct *tty, int __user *arg)
+{
+	int locked = test_bit(TTY_PTY_LOCK, &tty->flags);
+	return put_user(locked, arg);
+}
+
 /* Set the packet mode on a pty */
 static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
 {
@@ -196,6 +202,13 @@ static int pty_set_pktmode(struct tty_st
 	return 0;
 }
 
+/* Get the packet mode of a pty */
+static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
+{
+	int pktmode = tty->packet;
+	return put_user(pktmode, arg);
+}
+
 /* Send a signal to the slave */
 static int pty_signal(struct tty_struct *tty, int sig)
 {
@@ -415,8 +428,12 @@ static int pty_bsd_ioctl(struct tty_stru
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *) arg);
+	case TIOCGPTLCK: /* Get PT Lock status */
+		return pty_get_lock(tty, (int __user *)arg);
 	case TIOCPKT: /* Set PT packet mode */
 		return pty_set_pktmode(tty, (int __user *)arg);
+	case TIOCGPKT: /* Get PT packet mode */
+		return pty_get_pktmode(tty, (int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
 		return pty_signal(tty, (int) arg);
 	}
@@ -531,8 +548,12 @@ static int pty_unix98_ioctl(struct tty_s
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *)arg);
+	case TIOCGPTLCK: /* Get PT Lock status */
+		return pty_get_lock(tty, (int __user *)arg);
 	case TIOCPKT: /* Set PT packet mode */
 		return pty_set_pktmode(tty, (int __user *)arg);
+	case TIOCGPKT: /* Get PT packet mode */
+		return pty_get_pktmode(tty, (int __user *)arg);
 	case TIOCGPTN: /* Get PT Number */
 		return put_user(tty->index, (unsigned int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
Index: tty.git/drivers/tty/tty_io.c
===================================================================
--- tty.git.orig/drivers/tty/tty_io.c
+++ tty.git/drivers/tty/tty_io.c
@@ -2693,6 +2693,11 @@ long tty_ioctl(struct file *file, unsign
 	case TIOCNXCL:
 		clear_bit(TTY_EXCLUSIVE, &tty->flags);
 		return 0;
+	case TIOCGEXCL:
+	{
+		int excl = test_bit(TTY_EXCLUSIVE, &tty->flags);
+		return put_user(excl, (int __user *)p);
+	}
 	case TIOCNOTTY:
 		if (current->signal->tty != tty)
 			return -ENOTTY;


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c
  2012-09-27 21:10 ` [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c Cyrill Gorcunov
@ 2012-10-16  8:33   ` Cyrill Gorcunov
  2012-10-16  8:58     ` Alan Cox
  2012-10-24 18:27   ` Greg KH
  1 sibling, 1 reply; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-10-16  8:33 UTC (permalink / raw)
  To: gregkh, alan; +Cc: linux-kernel, hpa, xemul, jslaby

On Fri, Sep 28, 2012 at 01:10:33AM +0400, Cyrill Gorcunov wrote:
> Since this ioctl is for pty devices only move it to pty.c.
> 
> v2:
>  - drop PTY_TYPE_MASTER test since it's master peer
>    ioctl anyway (by jslaby@)
> 
> Suggested-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> CC: "H. Peter Anvin" <hpa@zytor.com>
> CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> CC: Pavel Emelyanov <xemul@parallels.com>
> CC: Jiri Slaby <jslaby@suse.cz>

Greg, Alan, what about this series? Is there anything else I should do?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c
  2012-10-16  8:58     ` Alan Cox
@ 2012-10-16  8:57       ` Cyrill Gorcunov
  0 siblings, 0 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-10-16  8:57 UTC (permalink / raw)
  To: Alan Cox; +Cc: gregkh, linux-kernel, hpa, xemul, jslaby

On Tue, Oct 16, 2012 at 09:58:22AM +0100, Alan Cox wrote:
> > Greg, Alan, what about this series? Is there anything else I should do?
> 
> Other than resending it now the merge window is closed - I can't think of
> anything.

OK, thanks, I'll resend.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c
  2012-10-16  8:33   ` Cyrill Gorcunov
@ 2012-10-16  8:58     ` Alan Cox
  2012-10-16  8:57       ` Cyrill Gorcunov
  0 siblings, 1 reply; 12+ messages in thread
From: Alan Cox @ 2012-10-16  8:58 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: gregkh, linux-kernel, hpa, xemul, jslaby

> Greg, Alan, what about this series? Is there anything else I should do?

Other than resending it now the merge window is closed - I can't think of
anything.

Alan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c
  2012-09-27 21:10 ` [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c Cyrill Gorcunov
  2012-10-16  8:33   ` Cyrill Gorcunov
@ 2012-10-24 18:27   ` Greg KH
  1 sibling, 0 replies; 12+ messages in thread
From: Greg KH @ 2012-10-24 18:27 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: linux-kernel, alan, hpa, xemul, jslaby

On Fri, Sep 28, 2012 at 01:10:33AM +0400, Cyrill Gorcunov wrote:
> Since this ioctl is for pty devices only move it to pty.c.
> 
> v2:
>  - drop PTY_TYPE_MASTER test since it's master peer
>    ioctl anyway (by jslaby@)

This patch adds the compiler warning:
drivers/tty/tty_ioctl.c: In function ‘n_tty_ioctl_helper’:
drivers/tty/tty_ioctl.c:1121:16: warning: unused variable ‘flags’ [-Wunused-variable]

Care to fix it up and resend?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch 2/3] tty, ioctls -- Add new ioctl definitions for tty flags fetching
  2012-09-27 21:10 ` [patch 2/3] tty, ioctls -- Add new ioctl definitions for tty flags fetching Cyrill Gorcunov
@ 2012-10-24 18:28   ` Greg KH
  2012-10-24 18:35     ` Cyrill Gorcunov
  0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2012-10-24 18:28 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: linux-kernel, alan, hpa, xemul, jslaby

On Fri, Sep 28, 2012 at 01:10:34AM +0400, Cyrill Gorcunov wrote:
> This patch defines new ioctl codes TIOCGPKT, TIOCGPTLCK,
> TIOCGEXCL for fetching pty's packet mode and locking state,
> and exclusive mode of tty.
> 
> [ No real handlers for the codes though, this will be
>   addressed in another patch for easier review and
>   bisectability ]
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
> CC: "H. Peter Anvin" <hpa@zytor.com>
> CC: Pavel Emelyanov <xemul@parallels.com>
> CC: Jiri Slaby <jslaby@suse.cz>
> ---
>  arch/alpha/include/asm/ioctls.h   |    3 +++
>  arch/mips/include/asm/ioctls.h    |    3 +++
>  arch/parisc/include/asm/ioctls.h  |    3 +++
>  arch/powerpc/include/asm/ioctls.h |    3 +++
>  arch/sh/include/asm/ioctls.h      |    3 +++
>  arch/sparc/include/asm/ioctls.h   |    3 +++
>  arch/xtensa/include/asm/ioctls.h  |    3 +++
>  fs/compat_ioctl.c                 |    3 +++
>  include/asm-generic/ioctls.h      |    3 +++
>  9 files changed, 27 insertions(+)

Most of these files are no longer in the tree.  Can you redo this
against the latest linux-next release and resend the whole series?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch 2/3] tty, ioctls -- Add new ioctl definitions for tty flags fetching
  2012-10-24 18:28   ` Greg KH
@ 2012-10-24 18:35     ` Cyrill Gorcunov
  0 siblings, 0 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-10-24 18:35 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, alan, hpa, xemul, jslaby

On Wed, Oct 24, 2012 at 11:28:16AM -0700, Greg KH wrote:
> 
> Most of these files are no longer in the tree.  Can you redo this
> against the latest linux-next release and resend the whole series?

Sure, thanks!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/3] tty: Add get- ioctls to fetch tty status v3
  2012-10-24 19:43 [PATCH 0/3] TTY -- " Cyrill Gorcunov
@ 2012-10-24 19:43 ` Cyrill Gorcunov
  0 siblings, 0 replies; 12+ messages in thread
From: Cyrill Gorcunov @ 2012-10-24 19:43 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, alan, hpa, xemul, jslaby, Cyrill Gorcunov

From: Cyrill Gorcunov <gorcunov@openvz.org>

For checkpoint/restore we need to know if tty has
exclusive or packet mode set, as well as if pty
is currently locked. Just to be able to restore
this characteristics.

For this sake the following ioctl codes are introduced

 - TIOCGPKT to get packet mode state
 - TIOCGPTLCK to get Pty locked state
 - TIOCGEXCL to get Exclusive mode state

Note this ioctls are a bit unsafe in terms of data
obtained consistency. The tty characteristics might
be changed right after ioctl complete. Keep it in
mind and use this ioctl carefully.

v2:
 - Use TIOC prefix for ioctl codes (by jslaby@)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/pty.c    |   21 +++++++++++++++++++++
 drivers/tty/tty_io.c |    5 +++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index df3c642..0ce0b3e 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -171,6 +171,12 @@ static int pty_set_lock(struct tty_struct *tty, int __user *arg)
 	return 0;
 }
 
+static int pty_get_lock(struct tty_struct *tty, int __user *arg)
+{
+	int locked = test_bit(TTY_PTY_LOCK, &tty->flags);
+	return put_user(locked, arg);
+}
+
 /* Set the packet mode on a pty */
 static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
 {
@@ -193,6 +199,13 @@ static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
 	return 0;
 }
 
+/* Get the packet mode of a pty */
+static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
+{
+	int pktmode = tty->packet;
+	return put_user(pktmode, arg);
+}
+
 /* Send a signal to the slave */
 static int pty_signal(struct tty_struct *tty, int sig)
 {
@@ -420,8 +433,12 @@ static int pty_bsd_ioctl(struct tty_struct *tty,
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *) arg);
+	case TIOCGPTLCK: /* Get PT Lock status */
+		return pty_get_lock(tty, (int __user *)arg);
 	case TIOCPKT: /* Set PT packet mode */
 		return pty_set_pktmode(tty, (int __user *)arg);
+	case TIOCGPKT: /* Get PT packet mode */
+		return pty_get_pktmode(tty, (int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
 		return pty_signal(tty, (int) arg);
 	}
@@ -536,8 +553,12 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *)arg);
+	case TIOCGPTLCK: /* Get PT Lock status */
+		return pty_get_lock(tty, (int __user *)arg);
 	case TIOCPKT: /* Set PT packet mode */
 		return pty_set_pktmode(tty, (int __user *)arg);
+	case TIOCGPKT: /* Get PT packet mode */
+		return pty_get_pktmode(tty, (int __user *)arg);
 	case TIOCGPTN: /* Get PT Number */
 		return put_user(tty->index, (unsigned int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index a3eba7f..739ea86 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2687,6 +2687,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	case TIOCNXCL:
 		clear_bit(TTY_EXCLUSIVE, &tty->flags);
 		return 0;
+	case TIOCGEXCL:
+	{
+		int excl = test_bit(TTY_EXCLUSIVE, &tty->flags);
+		return put_user(excl, (int __user *)p);
+	}
 	case TIOCNOTTY:
 		if (current->signal->tty != tty)
 			return -ENOTTY;
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [patch 3/3] tty: Add get- ioctls to fetch tty status v3
  2012-10-16  9:46 [patch 0/3] TTY flags fetching gorcunov
@ 2012-10-16  9:46 ` gorcunov
  0 siblings, 0 replies; 12+ messages in thread
From: gorcunov @ 2012-10-16  9:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: alan, gregkh, hpa, xemul, jslaby, Cyrill Gorcunov

[-- Attachment #1: tty-fetch-flags-8 --]
[-- Type: text/plain, Size: 3513 bytes --]

For checkpoint/restore we need to know if tty has
exclusive or packet mode set, as well as if pty
is currently locked. Just to be able to restore
this characteristics.

For this sake the following ioctl codes are introduced

 - TIOCGPKT to get packet mode state
 - TIOCGPTLCK to get Pty locked state
 - TIOCGEXCL to get Exclusive mode state

Note this ioctls are a bit unsafe in terms of data
obtained consistency. The tty characteristics might
be changed right after ioctl complete. Keep it in
mind and use this ioctl carefully.

v2:
 - Use TIOC prefix for ioctl codes (by jslaby@)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/pty.c    |   21 +++++++++++++++++++++
 drivers/tty/tty_io.c |    5 +++++
 2 files changed, 26 insertions(+)

Index: tty.git/drivers/tty/pty.c
===================================================================
--- tty.git.orig/drivers/tty/pty.c
+++ tty.git/drivers/tty/pty.c
@@ -174,6 +174,12 @@ static int pty_set_lock(struct tty_struc
 	return 0;
 }
 
+static int pty_get_lock(struct tty_struct *tty, int __user *arg)
+{
+	int locked = test_bit(TTY_PTY_LOCK, &tty->flags);
+	return put_user(locked, arg);
+}
+
 /* Set the packet mode on a pty */
 static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
 {
@@ -196,6 +202,13 @@ static int pty_set_pktmode(struct tty_st
 	return 0;
 }
 
+/* Get the packet mode of a pty */
+static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
+{
+	int pktmode = tty->packet;
+	return put_user(pktmode, arg);
+}
+
 /* Send a signal to the slave */
 static int pty_signal(struct tty_struct *tty, int sig)
 {
@@ -415,8 +428,12 @@ static int pty_bsd_ioctl(struct tty_stru
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *) arg);
+	case TIOCGPTLCK: /* Get PT Lock status */
+		return pty_get_lock(tty, (int __user *)arg);
 	case TIOCPKT: /* Set PT packet mode */
 		return pty_set_pktmode(tty, (int __user *)arg);
+	case TIOCGPKT: /* Get PT packet mode */
+		return pty_get_pktmode(tty, (int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
 		return pty_signal(tty, (int) arg);
 	}
@@ -531,8 +548,12 @@ static int pty_unix98_ioctl(struct tty_s
 	switch (cmd) {
 	case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
 		return pty_set_lock(tty, (int __user *)arg);
+	case TIOCGPTLCK: /* Get PT Lock status */
+		return pty_get_lock(tty, (int __user *)arg);
 	case TIOCPKT: /* Set PT packet mode */
 		return pty_set_pktmode(tty, (int __user *)arg);
+	case TIOCGPKT: /* Get PT packet mode */
+		return pty_get_pktmode(tty, (int __user *)arg);
 	case TIOCGPTN: /* Get PT Number */
 		return put_user(tty->index, (unsigned int __user *)arg);
 	case TIOCSIG:    /* Send signal to other side of pty */
Index: tty.git/drivers/tty/tty_io.c
===================================================================
--- tty.git.orig/drivers/tty/tty_io.c
+++ tty.git/drivers/tty/tty_io.c
@@ -2690,6 +2690,11 @@ long tty_ioctl(struct file *file, unsign
 	case TIOCNXCL:
 		clear_bit(TTY_EXCLUSIVE, &tty->flags);
 		return 0;
+	case TIOCGEXCL:
+	{
+		int excl = test_bit(TTY_EXCLUSIVE, &tty->flags);
+		return put_user(excl, (int __user *)p);
+	}
 	case TIOCNOTTY:
 		if (current->signal->tty != tty)
 			return -ENOTTY;


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-10-24 19:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-27 21:10 [patch 0/3] ttys flags, updated Cyrill Gorcunov
2012-09-27 21:10 ` [patch 1/3] tty: pty - Move TIOCPKT handling into pty.c Cyrill Gorcunov
2012-10-16  8:33   ` Cyrill Gorcunov
2012-10-16  8:58     ` Alan Cox
2012-10-16  8:57       ` Cyrill Gorcunov
2012-10-24 18:27   ` Greg KH
2012-09-27 21:10 ` [patch 2/3] tty, ioctls -- Add new ioctl definitions for tty flags fetching Cyrill Gorcunov
2012-10-24 18:28   ` Greg KH
2012-10-24 18:35     ` Cyrill Gorcunov
2012-09-27 21:10 ` [patch 3/3] tty: Add get- ioctls to fetch tty status v3 Cyrill Gorcunov
2012-10-16  9:46 [patch 0/3] TTY flags fetching gorcunov
2012-10-16  9:46 ` [patch 3/3] tty: Add get- ioctls to fetch tty status v3 gorcunov
2012-10-24 19:43 [PATCH 0/3] TTY -- " Cyrill Gorcunov
2012-10-24 19:43 ` [PATCH 3/3] tty: " Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).