Subject: /dev/zero is missing (#320) Index: sys/pdp/mem.c 2.11BSD Description: Support for the /dev/zero device is missing from the system. Repeat-By: dd if=/dev/zero of=file Note the no such file error. Look in /dev/MAKEDEV - there is no 'zero' mentioned. Fix: This was one of those things which somehow never quite made it into the system over the years. It is being added Due to "popular demand";) /dev/zero is implemented as another minor device in the 'mem' pseudo driver. This is the driver which provides /dev/mem, /dev/kmem and /dev/null. While it would have been somewhat more efficient to map the user buffer and clear it that would have meant quite a bit of additional code. It was simpler, cleaner, smaller and 'good enough' generalize /dev/mem handling to include the 'zero' device. Alas, even the modest growth (~80 bytes) of mem.c causes the object file to no longer fit in overlay 1 of the GENERIC kernel. It was therefore necessary to update once again the kernel Makefiles for the GENERIC kernel. There is a chance that your existing kernel overlay configuration will need to change. To apply this update cut where indicated, saving to a file (/tmp/320). Then: patch -p0 < /tmp/320 cd /dev mknod zero c 1 3 chmod 444 zero cd /sys/YOUR_KERNEL make If you get a link time error "too big for type 0431" then mem.o is too big and the overlay configuration needs to be tweeked. How to do this has been mentioned several times but send email if you need help. After installing the kernel it is necessary to reboot the system. This will also make sure that the device databases (/var/db/dev.{dir,pag} and /etc/psdatabase) are rebuilt. The GENERIC kernel should also be rebuilt and installed as /genunix: cd /sys/GENERIC make mv unix /genunix As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.IIPO.GTEGSC.COM or FTP.2BSD.COM in the directory /pub/2.11BSD. ==========================cut here==================== *** /sys/pdp/mem.c.old Tue Nov 29 21:54:53 1994 --- /sys/pdp/mem.c Wed May 15 20:49:35 1996 *************** *** 3,19 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)mem.c 1.2 (2.11BSD GTE) 11/29/94 */ #include "param.h" #include "../machine/seg.h" - #include "user.h" #include "conf.h" #include "uio.h" - #include "hk.h" - #include "xp.h" /* * This routine is callable only from the high --- 3,16 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)mem.c 1.3 (2.11BSD GTE) 1996/5/15 */ #include "param.h" #include "../machine/seg.h" #include "user.h" #include "conf.h" #include "uio.h" /* * This routine is callable only from the high *************** *** 30,36 **** --- 27,36 ---- int error = 0; register u_int c; u_int on; + char zero[1024]; + if (minor(dev) == 3) + bzero(zero, sizeof (zero)); while (uio->uio_resid && error == 0) { iov = uio->uio_iov; if (iov->iov_len == 0) { *************** *** 42,48 **** } switch (minor(dev)) { ! /* minor device 0 is physical memory */ case 0: mapseg5((memaddr)(uio->uio_offset>>6), ((btoc(8192)-1)<<8)|RW); --- 42,48 ---- } switch (minor(dev)) { ! /* minor device 0 is physical memory (/dev/mem) */ case 0: mapseg5((memaddr)(uio->uio_offset>>6), ((btoc(8192)-1)<<8)|RW); *************** *** 50,78 **** c = MIN(iov->iov_len, 8192 - on); error = uiomove(SEG5+on, c, uio); normalseg5(); ! continue; ! /* minor device 1 is kernel memory */ case 1: error = uiomove((caddr_t)uio->uio_offset, iov->iov_len, uio); ! continue; ! /* minor device 2 is EOF/RATHOLE */ case 2: if (uio->uio_rw == UIO_READ) return(0); c = iov->iov_len; break; ! } ! if (error) break; ! iov->iov_base += c; ! iov->iov_len -= c; ! uio->uio_offset += c; ! uio->uio_resid -= c; ! } return(error); } - #if NHK > 0 || NXPD > 0 /* * Internal versions of mmread(), mmwrite() * used by disk driver ecc routines. --- 50,84 ---- c = MIN(iov->iov_len, 8192 - on); error = uiomove(SEG5+on, c, uio); normalseg5(); ! break; ! /* minor device 1 is kernel memory (/dev/kmem) */ case 1: error = uiomove((caddr_t)uio->uio_offset, iov->iov_len, uio); ! break; ! /* minor device 2 is EOF/RATHOLE (/dev/null) */ case 2: if (uio->uio_rw == UIO_READ) return(0); c = iov->iov_len; + iov->iov_base += c; + iov->iov_len -= c; + uio->uio_offset += c; + uio->uio_resid -= c; break; ! /* minor device 3 is ZERO (/dev/zero) */ ! case 3: ! if (uio->uio_rw == UIO_WRITE) ! return(EIO); ! c = MIN(iov->iov_len, sizeof (zero)); ! error = uiomove(zero, c, uio); break; ! default: ! return(EINVAL); ! } /* switch */ ! } /* while */ return(error); } /* * Internal versions of mmread(), mmwrite() * used by disk driver ecc routines. *************** *** 114,117 **** UISA[0] = a; UISD[0] = d; } - #endif --- 120,122 ---- *** /sys/conf/Make.sunix.old Thu Jan 11 20:39:07 1996 --- /sys/conf/Make.sunix Wed May 15 21:18:27 1996 *************** *** 9,15 **** # software without specific prior written permission. This software # is provided ``as is'' without express or implied warranty. # ! # 2.5 (2.11BSD GTE) 1996/1/11 # ######################################################### # Non-network, but separate I/D kernel # --- 9,15 ---- # software without specific prior written permission. This software # is provided ``as is'' without express or implied warranty. # ! # 2.6 (2.11BSD GTE) 1996/5/15 # ######################################################### # Non-network, but separate I/D kernel # *************** *** 51,57 **** tty_conf.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o \ ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \ ufs_subr.o xp.o ! OV1= sys_generic.o ufs_syscalls.o mem.o OV2= kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resource.o OV3= clock.o cons.o kern_time.o \ machdep2.o quota_sys.o subr_prf.o sys_process.o \ --- 51,57 ---- tty_conf.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o \ ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \ ufs_subr.o xp.o ! OV1= sys_generic.o ufs_syscalls.o OV2= kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resource.o OV3= clock.o cons.o kern_time.o \ machdep2.o quota_sys.o subr_prf.o sys_process.o \ *************** *** 62,68 **** OV6= tmscp.o tmscpdump.o OV7= rl.o mch_fpsim.o ingreslock.o ufs_disksubr.o OV8= rx.o kern_sysctl.o vm_sched.o vm_text.o ! OV9= kern_pdp.o kern_xxx.o ufs_syscalls2.o KERNOBJ=${CONF} ${BASE} ${OV1} ${OV2} ${OV3} ${OV4} ${OV5} \ ${OV6} ${OV7} ${OV8} ${OV9} ${OV10} ${OV11} ${OV12} \ --- 62,68 ---- OV6= tmscp.o tmscpdump.o OV7= rl.o mch_fpsim.o ingreslock.o ufs_disksubr.o OV8= rx.o kern_sysctl.o vm_sched.o vm_text.o ! OV9= kern_pdp.o kern_xxx.o ufs_syscalls2.o mem.o KERNOBJ=${CONF} ${BASE} ${OV1} ${OV2} ${OV3} ${OV4} ${OV5} \ ${OV6} ${OV7} ${OV8} ${OV9} ${OV10} ${OV11} ${OV12} \ *** /sys/GENERIC/Makefile.old Wed May 15 21:17:17 1996 --- /sys/GENERIC/Makefile Wed May 15 21:10:22 1996 *************** *** 10,16 **** # software without specific prior written permission. This software # is provided ``as is'' without express or implied warranty. # ! # 2.5 (2.11BSD GTE) 1996/1/11 # ######################################################### # Non-network, but separate I/D kernel # --- 10,16 ---- # software without specific prior written permission. This software # is provided ``as is'' without express or implied warranty. # ! # 2.6 (2.11BSD GTE) 1996/5/15 # ######################################################### # Non-network, but separate I/D kernel # *************** *** 52,58 **** tty_conf.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o \ ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \ ufs_subr.o xp.o ! OV1= sys_generic.o ufs_syscalls.o mem.o OV2= kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resource.o OV3= clock.o cons.o kern_time.o \ machdep2.o quota_sys.o subr_prf.o sys_process.o \ --- 52,58 ---- tty_conf.o tty_subr.o tty_tb.o tty_tty.o ufs_alloc.o ufs_bio.o \ ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_namei.o \ ufs_subr.o xp.o ! OV1= sys_generic.o ufs_syscalls.o OV2= kern_acct.o kern_exec.o kern_exit.o kern_fork.o kern_resource.o OV3= clock.o cons.o kern_time.o \ machdep2.o quota_sys.o subr_prf.o sys_process.o \ *************** *** 63,69 **** OV6= tmscp.o tmscpdump.o OV7= rl.o mch_fpsim.o ingreslock.o ufs_disksubr.o OV8= rx.o kern_sysctl.o vm_sched.o vm_text.o ! OV9= kern_pdp.o kern_xxx.o ufs_syscalls2.o KERNOBJ=${CONF} ${BASE} ${OV1} ${OV2} ${OV3} ${OV4} ${OV5} \ ${OV6} ${OV7} ${OV8} ${OV9} ${OV10} ${OV11} ${OV12} \ --- 63,69 ---- OV6= tmscp.o tmscpdump.o OV7= rl.o mch_fpsim.o ingreslock.o ufs_disksubr.o OV8= rx.o kern_sysctl.o vm_sched.o vm_text.o ! OV9= kern_pdp.o kern_xxx.o ufs_syscalls2.o mem.o KERNOBJ=${CONF} ${BASE} ${OV1} ${OV2} ${OV3} ${OV4} ${OV5} \ ${OV6} ${OV7} ${OV8} ${OV9} ${OV10} ${OV11} ${OV12} \ *** /dev/MAKEDEV.old Sat Jun 17 23:47:20 1995 --- /dev/MAKEDEV Wed May 15 20:41:07 1996 *************** *** 4,10 **** # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)MAKEDEV 4.27.2 (2.11BSD GTE) 1995/06/17 # # Device "make" file. Valid arguments: # std standard devices --- 4,10 ---- # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)MAKEDEV 4.27.3 (2.11BSD GTE) 1996/05/15 # # Device "make" file. Valid arguments: # std standard devices *************** *** 55,60 **** --- 55,61 ---- /etc/mknod kmem c 1 1 ; chmod 640 kmem ; chgrp kmem kmem /etc/mknod mem c 1 0 ; chmod 640 mem ; chgrp kmem mem /etc/mknod null c 1 2 ; chmod 666 null + /etc/mknod zero c 1 3 ; chmod 444 zero /etc/mknod tty c 9 0 ; chmod 666 tty /etc/mknod klog c 22 0 ; chmod 600 klog ;; *** /VERSION.old Wed May 15 19:58:26 1996 --- /VERSION Thu May 16 20:00:42 1996 *************** *** 1,4 **** ! Current Patch Level: 319 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 320 2.11 BSD ============