Synopsis: Problem with SVR4_MAKEDEV on i386 platforms.
NetBSD versions: 1.3 and 1.3.1, 1.3.2, 1.3.3, -current to 19990419
Thanks to: Klaus Klein
Reported in NetBSD Advisory: NetBSD-SA1999-009
Notes: cd to /usr/src and run `patch -p < thisfile' to apply.


Index: share/examples/emul/svr4/etc/SVR4_MAKEDEV
===================================================================
RCS file: /cvsroot/src/share/examples/emul/svr4/etc/SVR4_MAKEDEV,v
retrieving revision 1.1.2.1
diff -c -r1.1.2.1 SVR4_MAKEDEV
*** SVR4_MAKEDEV	1998/11/10 05:47:54	1.1.2.1
--- SVR4_MAKEDEV	1999/04/19 15:16:59
***************
*** 1,5 ****
  #!/bin/sh -
! #	$NetBSD: SVR4_MAKEDEV,v 1.1.2.1 1998/11/10 05:47:54 cgd Exp $
  #
  # Copyright (c) 1995 Christos Zoulas
  # Copyright (c) 1997 Todd Vierling
--- 1,5 ----
  #!/bin/sh -
! #	$NetBSD: SVR4_MAKEDEV,v 1.5 1999/04/19 14:46:27 kleink Exp $
  #
  # Copyright (c) 1995 Christos Zoulas
  # Copyright (c) 1997 Todd Vierling
***************
*** 43,50 ****
--- 43,60 ----
  #	wabi		Windows emulation; /dev/null for now
  #
  PATH=/sbin:/bin/:/usr/bin:/usr/sbin:/usr/etc
+ MACHINE=${MACHINE:-`/usr/bin/uname -m`}
  umask 77
  
+ case $MACHINE in
+ i386)		major=43;;
+ sparc)		major=43;;
+ *)
+ 		echo $MACHINE: unsupported machine >&2
+ 		exit 1
+ 		;;
+ esac
+ 
  for i
  do
  
***************
*** 60,66 ****
  
  ptmx)
  	rm -f $i
! 	mknod $i		c 43 10
  	chown bin.bin $i
  	chmod 666 $i
  	;;
--- 70,76 ----
  
  ptmx)
  	rm -f $i
! 	mknod $i		c $major 10
  	chown bin.bin $i
  	chmod 666 $i
  	;;
***************
*** 89,95 ****
  
  tcp)
  	rm -f $i
! 	mknod $i		c 43 35
  	chown bin.bin $i
  	chmod 666 $i
  	;;
--- 99,105 ----
  
  tcp)
  	rm -f $i
! 	mknod $i		c $major 35
  	chown bin.bin $i
  	chmod 666 $i
  	;;
***************
*** 97,131 ****
  
  udp)
  	rm -f $i
! 	mknod $i		c 43 36
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  rawip)
  	rm -f $i
! 	mknod $i		c 43 37
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  ticlts)
  	rm -f $i
! 	mknod $i		c 43 38
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  ticotsord)
  	rm -f $i
! 	mknod $i		c 43 39
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  ticots)
  	rm -f $i
! 	mknod $i		c 43 40
  	chown bin.bin $i
  	chmod 666 $i
  	;;
--- 107,141 ----
  
  udp)
  	rm -f $i
! 	mknod $i		c $major 36
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  rawip)
  	rm -f $i
! 	mknod $i		c $major 37
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  ticlts)
  	rm -f $i
! 	mknod $i		c $major 38
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  ticotsord)
  	rm -f $i
! 	mknod $i		c $major 39
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  ticots)
  	rm -f $i
! 	mknod $i		c $major 40
  	chown bin.bin $i
  	chmod 666 $i
  	;;
***************
*** 133,145 ****
  
  wabi)
  	rm -f $i
! 	mknod $i		c 3 2	# /dev/null
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  *)
! 	echo $i: unknown device
  	;;
  esac
  done
--- 143,161 ----
  
  wabi)
  	rm -f $i
! 	case $MACHINE in
! 	sparc)
! 		mknod $i	c 3 2;;	# /dev/null
! 	i386)
! 		mknod $i	c 2 2;;	# /dev/null
! 	esac
  	chown bin.bin $i
  	chmod 666 $i
  	;;
  
  *)
! 	echo $i: unknown device 2>&1
! 	exit 1
  	;;
  esac
  done
Index: share/man/man8/compat_svr4.8
===================================================================
RCS file: /cvsroot/src/share/man/man8/compat_svr4.8,v
retrieving revision 1.6.2.2
diff -c -r1.6.2.2 compat_svr4.8
*** compat_svr4.8	1998/11/10 05:50:00	1.6.2.2
--- compat_svr4.8	1999/04/19 15:17:00
***************
*** 1,4 ****
! .\"	$NetBSD: compat_svr4.8,v 1.6.2.2 1998/11/10 05:50:00 cgd Exp $
  .\"
  .\" Copyright (c) 1996 Christos Zoulas
  .\" All rights reserved.
--- 1,4 ----
! .\"	$NetBSD: compat_svr4.8,v 1.14 1999/04/19 14:46:27 kleink Exp $
  .\"
  .\" Copyright (c) 1996 Christos Zoulas
  .\" All rights reserved.
***************
*** 31,37 ****
  .\"
  .\"	Stolen from compat_linux.8,v 1.2 1995/10/16 20:17:59 fvdl 
  .\"
! .Dd July 6, 1996
  .Dt COMPAT_SVR4 8
  .Os NetBSD
  .Sh NAME
--- 31,37 ----
  .\"
  .\"	Stolen from compat_linux.8,v 1.2 1995/10/16 20:17:59 fvdl 
  .\"
! .Dd April 19, 1999
  .Dt COMPAT_SVR4 8
  .Os NetBSD
  .Sh NAME
***************
*** 138,143 ****
--- 138,152 ----
  .br
  .It (me@netbsd) cd /emul/svr4/dev; sh SVR4_MAKEDEV all
  .El
+ .Pp
+ As the major number allocated for emulation of SVR4 devices may vary between
+ .Nx
+ platforms, the SVR4_MAKEDEV script utilizes the
+ .Xr uname 1
+ command to determine the architecture the devices nodes are being created for;
+ this can be overridden by setting the
+ .Ev MACHINE
+ environment variable accordingly.
  .El
  .Pp
  An alternative method is to mount a whole SVR4 partition in /emul/svr4