From owner-linux-ibcs2@vger.rutgers.edu  Wed Aug  9 06:23:10 1995
Return-Path: owner-linux-ibcs2@vger.rutgers.edu
Received: from coli-gate.coli.uni-sb.de (root@coli-gate.coli.uni-sb.de [134.96.68.11]) by jurix.jura.uni-sb.de (8.6.12/8.6.9) with ESMTP id GAA08353 for <florian@jurix.jura.uni-sb.de>; Wed, 9 Aug 1995 06:23:09 +0200
Received: from vger.rutgers.edu (majordomo@vger.rutgers.edu [128.6.190.2]) by coli-gate.coli.uni-sb.de (8.6.10/8.6.4) with ESMTP id GAA27831 for <flla@coli.uni-sb.de>; Wed, 9 Aug 1995 06:22:54 +0200
Received: (from majordomo@localhost) by vger.rutgers.edu (8.6.12/8.6.12) id RAA25614 for linux-ibcs2-outgoing; Tue, 8 Aug 1995 17:37:03 -0400
Date: Tue, 08 Aug 1995 22:15:57 GMT
From: jaggy@purplet.demon.co.uk (Mike Jagdis)
Message-Id: <8633@purplet.demon.co.uk>
To: linux-ibcs2@vger.rutgers.edu
Subject: Official patch for local X connections
X-Mailer: PCElm 1.10
Lines: 100
Sender: owner-linux-ibcs2@vger.rutgers.edu
Precedence: bulk
Status: RO

Sorry for the delay. My hard disk has started spewing out serious
errors all over the place and isn't much use for anything. Hence
this isn't tested *at all* so let me know if it works (or doesn't
work - but it will!)

  Anyway, not only do we need to add those missing three lines in
socksys.c but we also need to have getmsg/putmsg succeed silently
and unconditionally for /dev/null (since /dev/X0R is a link to
/dev/null remember?). I dislike having to recognise major/minor
of /dev/null in there but one day I will do this in a general
way for any spx type local transport. One day when I've saved
up for a new hard disk anyway :-(.

				Mike


Index: socksys.c
===================================================================
RCS file: /usr/CVS/ibcs/iBCSemul/socksys.c,v
retrieving revision 1.40
diff -u -r1.40 socksys.c
--- socksys.c	1995/07/31 12:28:22	1.40
+++ socksys.c	1995/08/04 13:04:03
@@ -699,9 +699,12 @@
 				current->pid, (unsigned long)filep);
 #endif
 	if (MINOR(ino->i_rdev) == 1) {
+		/* Special - minor 1 is fake spx for X. */
+		args[0] = AF_UNIX;
+		args[1] = SOCK_STREAM;
+		args[2] = 0;
 	} else switch ((args[0] = ((MINOR(ino->i_rdev) >> 4) & 0x0f))) {
-		case 0:
-			/* Special - minor 1 is fake spx for X. */
+		case AF_UNIX:
 			args[0] = AF_UNIX;
 			args[1] = SOCK_STREAM;
 			args[2] = 0;
Index: stream.c
===================================================================
RCS file: /usr/CVS/ibcs/iBCSemul/stream.c,v
retrieving revision 1.4
diff -u -r1.4 stream.c
--- stream.c	1995/07/03 12:51:54	1.4
+++ stream.c	1995/08/08 10:33:39
@@ -49,14 +49,19 @@
 	fd = (int)get_fs_long(((unsigned long *)regs->esp) + 1);
 
 	if (!current->FD[fd]
-	|| !(ino = current->FD[fd]->f_inode)
-	|| !ino->i_sock)
+	|| !(ino = current->FD[fd]->f_inode))
 		return -EBADF;
 
-	/* Ignore the /dev/spx device used for local X connections. */
-	if (MINOR(ino->i_rdev) == 1)
+	/* Ignore the /dev/spx device used for local X connections
+	 * and /dev/null (aka /dev/X0R).
+	 */
+	if (MINOR(ino->i_rdev) == 1
+	|| (MAJOR(ino->i_rdev) == 1 && MINOR(ino->i_rdev) == 3))
 		return 0;
 
+	if (!ino->i_sock)
+		return -EBADF;
+
 #ifdef EMU_XTI
 	return timod_getmsg(fd, ino, regs);
 #else
@@ -74,13 +79,18 @@
 	fd = (int)get_fs_long(((unsigned long *)regs->esp) + 1);
 
 	if (!current->FD[fd]
-	|| !(ino = current->FD[fd]->f_inode)
-	|| !ino->i_sock)
+	|| !(ino = current->FD[fd]->f_inode))
 		return -EBADF;
 
-	/* Ignore the /dev/spx device used for local X connections. */
-	if (MINOR(ino->i_rdev) == 1)
+	/* Ignore the /dev/spx device used for local X connections
+	 * and /dev/null (aka /dev/X0R).
+	 */
+	if (MINOR(ino->i_rdev) == 1
+	|| (MAJOR(ino->i_rdev) == 1 && MINOR(ino->i_rdev) == 3))
 		return 0;
+
+	if (!ino->i_sock)
+		return -EBADF;
 
 #ifdef EMU_XTI
 	return timod_putmsg(fd, ino, regs);


-- 
.----------------------------------------------------------------------.
| Mike Jagdis                   | Internet: jaggy@purplet.demon.co.uk  |
| 280, Silverdale Road, Earley, | Voice:    +44 1734 266996            |
| Reading RG6 7NU ENGLAND       | Work:     +44 1734 890403            |
`----------------------------------------------------------------------'

