Linux-kernel mailing list archive 1997-48,: Adding tcgetsid to Linux 2.1.70+ (Patch)

# Adding tcgetsid to Linux 2.1.70+ (Patch)

Andreas Jaeger (aj@arthur.rhein-neckar.de)
Thu, 4 Dec 1997 16:35:13 +0100 (CET)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Michael Harnois: "Re: fix for ppp under 2.1.69/2.1.70"
- Previous message: Richard B. Johnson: "PPP and Proxy-Arp"

Hi Linus,

For implementing the tcgetsid() function from the Single Unix V2
specification in glibc we need just a little help from the kernel.
The obvious way to do this, is adding a new ioctl, TIOCGSID, to the
tty driver.

Mark Kettenis <kettenis@phys.uva.nl> has made the following kernel
patch - I just added the ioctl defines (please tell me if they're not
ok).

The patch is against 2.1.69 but should apply cleanly to 2.1.70. Could
you please apply it for 2.1.71?

Thanks,
Andreas

diff -ur linux-2.1.69/drivers/char/tty_io.c linux-2.1.69-aj/drivers/char/tty_io.c
--- linux-2.1.69/drivers/char/tty_io.c Mon Dec 1 23:26:30 1997
+++ linux-2.1.69-aj/drivers/char/tty_io.c Tue Dec 2 17:00:32 1997
@@ -1466,6 +1466,19 @@
return 0;
}
+static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t *arg)
+{
+ /*
+ * (tty == real_tty) is a cheap way of
+ * testing if the tty is NOT a master pty.
+ */
+ if (tty == real_tty && current->tty != real_tty)
+ return -ENOTTY;
+ if (real_tty->session <= 0)
+ return -ENOTTY;
+ return put_user(real_tty->session, arg);
+}
+
static int tiocttygstruct(struct tty_struct *tty, struct tty_struct *arg)
{
if (copy_to_user(arg, tty, sizeof(*arg)))
@@ -1585,6 +1598,8 @@
return tiocgpgrp(tty, real_tty, (pid_t *) arg);
case TIOCSPGRP:
return tiocspgrp(tty, real_tty, (pid_t *) arg);
+ case TIOCGSID:
+ return tiocgsid(tty, real_tty, (pid_t *) arg);
case TIOCGETD:
return put_user(tty->ldisc.num, (int *) arg);
case TIOCSETD:
diff -ur linux-2.1.69/include/asm/ioctls.h linux-2.1.69-aj/include/asm/ioctls.h
--- linux-2.1.69/include/asm/ioctls.h Thu Jun 26 21:33:39 1997
+++ linux-2.1.69-aj/include/asm/ioctls.h Tue Dec 2 17:06:27 1997
@@ -46,6 +46,7 @@
#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
#define TIOCSBRK 0x5427 /* BSD compatibility */
#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -ur linux-2.1.69/include/asm-alpha/ioctls.h linux-2.1.69-aj/include/asm-alpha/ioctls.h
--- linux-2.1.69/include/asm-alpha/ioctls.h Thu Jun 26 21:33:39 1997
+++ linux-2.1.69-aj/include/asm-alpha/ioctls.h Tue Dec 2 17:07:31 1997
@@ -85,6 +85,7 @@
#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
#define TIOCSBRK 0x5427 /* BSD compatibility */
#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCSERCONFIG 0x5453
#define TIOCSERGWILD 0x5454
diff -ur linux-2.1.69/include/asm-i386/ioctls.h linux-2.1.69-aj/include/asm-i386/ioctls.h
--- linux-2.1.69/include/asm-i386/ioctls.h Thu Jun 26 21:33:39 1997
+++ linux-2.1.69-aj/include/asm-i386/ioctls.h Tue Dec 2 17:06:27 1997
@@ -46,6 +46,7 @@
#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
#define TIOCSBRK 0x5427 /* BSD compatibility */
#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -ur linux-2.1.69/include/asm-m68k/ioctls.h linux-2.1.69-aj/include/asm-m68k/ioctls.h
--- linux-2.1.69/include/asm-m68k/ioctls.h Thu Jun 26 21:33:39 1997
+++ linux-2.1.69-aj/include/asm-m68k/ioctls.h Tue Dec 2 17:08:08 1997
@@ -46,6 +46,7 @@
#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
#define TIOCSBRK 0x5427 /* BSD compatibility */
#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
#define FIOCLEX 0x5451
diff -ur linux-2.1.69/include/asm-mips/ioctls.h linux-2.1.69-aj/include/asm-mips/ioctls.h
--- linux-2.1.69/include/asm-mips/ioctls.h Thu Jul 31 22:09:18 1997
+++ linux-2.1.69-aj/include/asm-mips/ioctls.h Tue Dec 2 17:08:52 1997
@@ -98,6 +98,7 @@
#define TIOCTTYGSTRUCT 0x5487 /* For debugging only */
#define TIOCSBRK 0x5427 /* BSD compatibility */
#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCSERCONFIG 0x5488
#define TIOCSERGWILD 0x5489
diff -ur linux-2.1.69/include/asm-ppc/ioctls.h linux-2.1.69-aj/include/asm-ppc/ioctls.h
--- linux-2.1.69/include/asm-ppc/ioctls.h Sat Aug 16 18:51:09 1997
+++ linux-2.1.69-aj/include/asm-ppc/ioctls.h Tue Dec 2 17:09:15 1997
@@ -85,6 +85,7 @@
#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
#define TIOCSBRK 0x5427 /* BSD compatibility */
#define TIOCCBRK 0x5428 /* BSD compatibility */
+#define TIOCGSID 0x5429 /* Return the session ID of FD */
#define TIOCSERCONFIG 0x5453
#define TIOCSERGWILD 0x5454
diff -ur linux-2.1.69/include/asm-sparc/ioctls.h linux-2.1.69-aj/include/asm-sparc/ioctls.h
--- linux-2.1.69/include/asm-sparc/ioctls.h Mon Jul 7 17:18:55 1997
+++ linux-2.1.69-aj/include/asm-sparc/ioctls.h Tue Dec 2 17:22:22 1997
@@ -74,6 +74,7 @@
#define TIOCSPGRP _IOW('t', 130, int)
#define TIOCGPGRP _IOR('t', 131, int)
#define TIOCSCTTY _IO('t', 132)
+#define TIOCGSID _IOR('t', 133, int)
/* Little f */
#define FIOCLEX _IO('f', 1)
diff -ur linux-2.1.69/include/asm-sparc64/ioctls.h linux-2.1.69-aj/include/asm-sparc64/ioctls.h
--- linux-2.1.69/include/asm-sparc64/ioctls.h Sat Aug 16 18:51:10 1997
+++ linux-2.1.69-aj/include/asm-sparc64/ioctls.h Tue Dec 2 17:21:32 1997
@@ -75,6 +75,7 @@
#define TIOCSPGRP _IOW('t', 130, int)
#define TIOCGPGRP _IOR('t', 131, int)
#define TIOCSCTTY _IO('t', 132)
+#define TIOCGSID _IOR('t', 133, int)
/* Little f */
#define FIOCLEX _IO('f', 1)

    --
     Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
      for pgp-key finger ajaeger@alma.student.uni-kl.de
        http://www.student.uni-kl.de/~ajaeger/

- Next message: Michael Harnois: "Re: fix for ppp under 2.1.69/2.1.70"
- Previous message: Richard B. Johnson: "PPP and Proxy-Arp"