*BSD News Article 3179


Return to BSD News archive

Path: sserve!manuel!munnari.oz.au!news.hawaii.edu!ames!olivea!uunet!emba-news.uvm.edu!freehold.emba.uvm.edu!wollman
From: wollman@freehold.emba.uvm.edu (Garrett Wollman)
Newsgroups: comp.unix.bsd
Subject: [386BSD] How to get /dev/fd/nnn working.
Message-ID: <1992Aug6.020924.3446@uvm.edu>
Date: 6 Aug 92 02:09:24 GMT
Sender: news@uvm.edu
Organization: University of Vermont, EMBA Computer Facility
Lines: 74

Even wonder why `/dev/stderr' and `/dev/fd/63' don't work under
386BSD?  The answer is that they are created with major device number
53, which is way out of range for 386BSD.  Rather than change
/dev/MAKEDEV, I added this simple patch to spec_vnops.c, which seems
to do the trick.

I seem to remember some hackery in namei() at one point in time to do
this, but I think you'll agree that spec_vnops is the most appropriate
place to put this.  (The only problem is making sure that we never get
up to character major device 53...)  This has the added advantage of
enabling this functionality in Net/2-based operating systems for other
machines as well.

-GAWollman

------------------------------------
#!/bin/sh
#
# This is a hand-built shell archive, containing the file
# `devfd.patch'.  Extract this archive, and then say
#    patch -p <devfd.patch.
#
sed 's/^X//' >devfd.patch <<'EOF'
X*** /sys/kern/spec_vnops.c.orig	Wed Aug  5 16:54:51 1992
X--- /sys/kern/spec_vnops.c	Wed Aug  5 16:56:43 1992
X***************
X*** 50,55 ****
X--- 50,58 ----
X  #include "dkbad.h"	/* XXX */
X  #include "disklabel.h"
X  
X+ /* XXX */
X+ #define DEVFD_MAJOR 53
X+ 
X  /* symbolic sleep message strings for devices */
X  char	devopn[] = "devopn";
X  char	devio[] = "devio";
X***************
X*** 131,140 ****
X  	switch (vp->v_type) {
X  
X  	case VCHR:
X! 		if ((u_int)maj >= nchrdev)
X! 			return (ENXIO);
X! 		VOP_UNLOCK(vp);
X! 		error = (*cdevsw[maj].d_open)(dev, mode, S_IFCHR, p);
X  		VOP_LOCK(vp);
X  		return (error);
X  
X--- 134,149 ----
X  	switch (vp->v_type) {
X  
X  	case VCHR:
X! 	  /* XXX special case for /dev/fd added by GAW */
X! 	        if ((u_int)maj == DEVFD_MAJOR) {
X! 		  VOP_UNLOCK(vp);
X! 		  error = fdopen(dev, mode, S_IFCHR);
X! 		} else {
X! 		  if ((u_int)maj >= nchrdev)
X! 		    return (ENXIO);
X! 		  VOP_UNLOCK(vp);
X! 		  error = (*cdevsw[maj].d_open)(dev, mode, S_IFCHR, p);
X! 		}
X  		VOP_LOCK(vp);
X  		return (error);
X  
EOF

exit 0
-- 
   Garrett A. Wollman  = wollman@emba.uvm.edu = UVM is welcome to my opinions
                       =    uvm-gen!wollman   =
   That's what being alive is all about.  No deity, no higher goal
   exists, than to bring joy to another person.    - Elf Sternberg