Subject: 'mount /dev/ram /tmp' panics the system (#305) Index: sys/ufs_mount.c 2.11BSD Description: Doing a "mount /dev/ram /tmp" causes a "panic: dup biodone" crash. Repeat-By: Build a kernel with the ram(4) driver. Make a filesystem on /dev/ram (this will work fine). Then attempt to mount /dev/ram. *thud*. Fix: The problem is that the ram(4) driver is a 'BLOCK' (IFBLK) device only, there is no corresponding 'CHARACTER' (IFCHR) device. Thus referring to 'cdevsw[]' with ram(4)'s major device number is a serious bug that causes a wild jump when calling cdevsw[].d_ioctl (to the tmscpstrategy() routine in my case). The fix is to check for the NODEV return from the call to 'blktochr()' in ufs_mount.c. Arguably the 'cdevsw' table should have been expanded to include a 'ram' entry point. But since ram(4) is the only "disk" device which does not have a 'raw' (character) device it was felt that fixing ufs_mount.c was a better (data space saving) solution. Cut where indicated saving to a file (/tmp/305). Then: patch -p0 < /tmp/305 It is not strictly necessary to rebuild the kernel at this time (but probably a good idea) if you do not have the ram(4) driver included. =============================cut here==================== *** /sys/sys/ufs_mount.c.old Tue Dec 26 20:09:53 1995 --- /sys/sys/ufs_mount.c Fri Mar 1 21:03:35 1996 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_mount.c 1.6 (2.11BSD GTE) 1995/12/24 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_mount.c 1.7 (2.11BSD GTE) 1996/3/1 */ #include "param.h" *************** *** 118,124 **** register int error; int ronly = flags & MNT_RDONLY; int needclose = 0; ! int (*ioctl)(); struct partinfo dpart; error = --- 118,124 ---- register int error; int ronly = flags & MNT_RDONLY; int needclose = 0; ! int chrdev, (*ioctl)(); struct partinfo dpart; error = *************** *** 129,136 **** * Now make a check that the partition is really a filesystem if the * underlying driver supports disklabels (there is an ioctl entry point * and calling it does not return an error). */ ! ioctl = cdevsw[blktochr(dev)].d_ioctl; if (ioctl && !(*ioctl)(dev, DIOCGPART, &dpart, FREAD)) { if (dpart.part->p_fstype != FS_V71K) --- 129,144 ---- * Now make a check that the partition is really a filesystem if the * underlying driver supports disklabels (there is an ioctl entry point * and calling it does not return an error). + * + * XXX - Check for NODEV because BLK only devices (i.e. the 'ram' driver) do not + * XXX - have a CHR counterpart. Such drivers can not support labels due to + * XXX - the lack of an ioctl entry point. */ ! chrdev = blktochr(dev); ! if (chrdev == NODEV) ! ioctl = NULL; ! else ! ioctl = cdevsw[chrdev].d_ioctl; if (ioctl && !(*ioctl)(dev, DIOCGPART, &dpart, FREAD)) { if (dpart.part->p_fstype != FS_V71K) *** /VERSION.old Fri Feb 23 20:34:10 1996 --- /VERSION Fri Mar 1 23:19:40 1996 *************** *** 1,4 **** ! Current Patch Level: 304 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 305 2.11 BSD ============