From b322fb5d76ace3b4fbaef7428ee1716b841645c2 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Tue, 12 May 1998 17:34:02 +0000 Subject: [PATCH] Backed out previous commit. It is invalid to call d_ioctl() on possibly non-open devices, and we don't want to restrict dumping to swap devices anwyay. It is especially invalid to call d_ioctl() in non-process context for panics. d_psize() can be called on non-open devices, at least on non-SLICED ones that support d_dump(), and setdumpdev() has depended on this for a long time although it is probably wrong, but even d_psize() can't be called in non-process context - that's why dumpsys() depends on previously computed values although these values may be stale. The historical restriction to devices with dkpart(dev) == SWAP_PART should go away. --- sys/amd64/amd64/autoconf.c | 7 ++----- sys/i386/i386/autoconf.c | 7 ++----- sys/kern/kern_shutdown.c | 11 +++-------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c index 90bee3c87f5b..f6177fbd0b8e 100644 --- a/sys/amd64/amd64/autoconf.c +++ b/sys/amd64/amd64/autoconf.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91 - * $Id: autoconf.c,v 1.95 1998/04/20 21:53:07 julian Exp $ + * $Id: autoconf.c,v 1.96 1998/05/06 22:14:40 julian Exp $ */ /* @@ -398,7 +398,6 @@ setdumpdev(dev) { int maj, psize; long newdumplo; - struct partinfo pi; if (dev == NODEV) { dumpdev = dev; @@ -419,9 +418,7 @@ setdumpdev(dev) * and nuke dodump sysctl (too many knobs), and move this to * kern_shutdown.c... */ - if (bdevsw[maj]->d_ioctl(dev, DIOCGPART, (caddr_t)&pi, 0, NULL) != 0) - return (ENODEV); - if (pi.part->p_fstype != FS_SWAP) + if (dkpart(dev) != SWAP_PART) return (ENODEV); newdumplo = psize - Maxmem * PAGE_SIZE / DEV_BSIZE; if (newdumplo < 0) diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c index 90bee3c87f5b..f6177fbd0b8e 100644 --- a/sys/i386/i386/autoconf.c +++ b/sys/i386/i386/autoconf.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91 - * $Id: autoconf.c,v 1.95 1998/04/20 21:53:07 julian Exp $ + * $Id: autoconf.c,v 1.96 1998/05/06 22:14:40 julian Exp $ */ /* @@ -398,7 +398,6 @@ setdumpdev(dev) { int maj, psize; long newdumplo; - struct partinfo pi; if (dev == NODEV) { dumpdev = dev; @@ -419,9 +418,7 @@ setdumpdev(dev) * and nuke dodump sysctl (too many knobs), and move this to * kern_shutdown.c... */ - if (bdevsw[maj]->d_ioctl(dev, DIOCGPART, (caddr_t)&pi, 0, NULL) != 0) - return (ENODEV); - if (pi.part->p_fstype != FS_SWAP) + if (dkpart(dev) != SWAP_PART) return (ENODEV); newdumplo = psize - Maxmem * PAGE_SIZE / DEV_BSIZE; if (newdumplo < 0) diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 40704d8821ba..448bcc0b5ec8 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 - * $Id: kern_shutdown.c,v 1.29 1998/03/08 09:56:54 julian Exp $ + * $Id: kern_shutdown.c,v 1.30 1998/05/06 22:14:48 julian Exp $ */ #include "opt_ddb.h" @@ -55,7 +55,6 @@ #include #include #include -#include #include #include @@ -359,21 +358,17 @@ SYSINIT(dump_conf, SI_SUB_DUMP_CONF, SI_ORDER_FIRST, dump_conf, NULL) static void dumpsys(void) { - struct partinfo pi; if (!dodump) return; if (dumpdev == NODEV) return; + if ((minor(dumpdev)&07) != 1) + return; if (!(bdevsw[major(dumpdev)])) return; if (!(bdevsw[major(dumpdev)]->d_dump)) return; - if ((*bdevsw[major(dumpdev)]->d_ioctl)(dumpdev, DIOCGPART, - (caddr_t)&pi, 0, NULL)) - return; - if (pi.part->p_fstype != FS_SWAP) - return; dumpsize = Maxmem; printf("\ndumping to dev %lx, offset %ld\n", dumpdev, dumplo); printf("dump ");