Centralize dumpdev handling.

This commit is contained in:
Poul-Henning Kamp 1999-07-17 20:47:52 +00:00
parent 68f7448fd7
commit f06a54f0a0
5 changed files with 61 additions and 183 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: autoconf.c,v 1.27 1999/05/29 19:23:20 gallatin Exp $
* $Id: autoconf.c,v 1.28 1999/05/31 20:44:11 dt Exp $
*/
#include "opt_bootp.h"
@ -62,7 +62,6 @@ SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL)
static void configure_finish __P((void));
static void configure_start __P((void));
static int setdumpdev __P((dev_t dev));
device_t isa_bus_device = 0;
struct cam_sim *boot_sim = 0;
@ -261,58 +260,3 @@ cpu_rootconf()
}
#endif
}
void
cpu_dumpconf()
{
if (setdumpdev(dumpdev) != 0)
dumpdev = NODEV;
}
static int
setdumpdev(dev)
dev_t dev;
{
int maj, psize;
long newdumplo;
if (dev == NODEV) {
dumpdev = dev;
return (0);
}
maj = major(dev);
if (bdevsw(dev) == NULL)
return (ENXIO); /* XXX is this right? */
if (bdevsw(dev)->d_psize == NULL)
return (ENXIO); /* XXX should be ENODEV ? */
psize = bdevsw(dev)->d_psize(dev);
if (psize == -1)
return (ENXIO); /* XXX should be ENODEV ? */
/*
* XXX should clean up checking in dumpsys() to be more like this,
* and nuke dodump sysctl (too many knobs), and move this to
* kern_shutdown.c...
*/
newdumplo = psize - Maxmem * PAGE_SIZE / DEV_BSIZE;
if (newdumplo < 0)
return (ENOSPC);
dumpdev = dev;
dumplo = newdumplo;
return (0);
}
static int
sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
{
int error;
udev_t ndumpdev;
ndumpdev = dev2udev(dumpdev);
error = sysctl_handle_opaque(oidp, &ndumpdev, sizeof ndumpdev, req);
if (error == 0 && req->newptr != NULL)
error = setdumpdev(udev2dev(ndumpdev, 1));
return (error);
}
SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.127 1999/07/03 17:40:29 peter Exp $
* $Id: autoconf.c,v 1.128 1999/07/03 21:03:56 peter Exp $
*/
/*
@ -101,7 +101,6 @@ static void configure_final __P((void *));
static void configure_finish __P((void));
static void configure_start __P((void));
static int setdumpdev __P((dev_t dev));
#if defined(FFS) || defined(FFS_ROOT)
static void setroot __P((void));
#endif
@ -362,47 +361,6 @@ cpu_rootconf()
}
}
void
cpu_dumpconf()
{
if (setdumpdev(dumpdev) != 0)
dumpdev = NODEV;
}
static int
setdumpdev(dev)
dev_t dev;
{
int maj, psize;
long newdumplo;
if (dev == NODEV) {
dumpdev = dev;
return (0);
}
maj = major(dev);
if (bdevsw(dev) == NULL)
return (ENXIO); /* XXX is this right? */
if (bdevsw(dev)->d_psize == NULL)
return (ENXIO); /* XXX should be ENODEV ? */
psize = bdevsw(dev)->d_psize(dev);
if (psize == -1)
return (ENXIO); /* XXX should be ENODEV ? */
/*
* XXX should clean up checking in dumpsys() to be more like this,
* and nuke dodump sysctl (too many knobs), and move this to
* kern_shutdown.c...
*/
newdumplo = psize - Maxmem * PAGE_SIZE / DEV_BSIZE;
if (newdumplo < 0)
return (ENOSPC);
dumpdev = dev;
dumplo = newdumplo;
return (0);
}
u_long bootdev = 0; /* not a dev_t - encoding is different */
#define FDMAJOR 2
@ -493,23 +451,6 @@ setroot()
#endif
static int
sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
{
int error;
udev_t ndumpdev;
ndumpdev = dev2udev(dumpdev);
error = sysctl_handle_opaque(oidp, &ndumpdev, sizeof ndumpdev, req);
if (error == 0 && req->newptr != NULL)
error = setdumpdev(udev2dev(ndumpdev, 1));
return (error);
}
SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");
static int
setrootbyname(char *name)

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.127 1999/07/03 17:40:29 peter Exp $
* $Id: autoconf.c,v 1.128 1999/07/03 21:03:56 peter Exp $
*/
/*
@ -101,7 +101,6 @@ static void configure_final __P((void *));
static void configure_finish __P((void));
static void configure_start __P((void));
static int setdumpdev __P((dev_t dev));
#if defined(FFS) || defined(FFS_ROOT)
static void setroot __P((void));
#endif
@ -362,47 +361,6 @@ cpu_rootconf()
}
}
void
cpu_dumpconf()
{
if (setdumpdev(dumpdev) != 0)
dumpdev = NODEV;
}
static int
setdumpdev(dev)
dev_t dev;
{
int maj, psize;
long newdumplo;
if (dev == NODEV) {
dumpdev = dev;
return (0);
}
maj = major(dev);
if (bdevsw(dev) == NULL)
return (ENXIO); /* XXX is this right? */
if (bdevsw(dev)->d_psize == NULL)
return (ENXIO); /* XXX should be ENODEV ? */
psize = bdevsw(dev)->d_psize(dev);
if (psize == -1)
return (ENXIO); /* XXX should be ENODEV ? */
/*
* XXX should clean up checking in dumpsys() to be more like this,
* and nuke dodump sysctl (too many knobs), and move this to
* kern_shutdown.c...
*/
newdumplo = psize - Maxmem * PAGE_SIZE / DEV_BSIZE;
if (newdumplo < 0)
return (ENOSPC);
dumpdev = dev;
dumplo = newdumplo;
return (0);
}
u_long bootdev = 0; /* not a dev_t - encoding is different */
#define FDMAJOR 2
@ -493,23 +451,6 @@ setroot()
#endif
static int
sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
{
int error;
udev_t ndumpdev;
ndumpdev = dev2udev(dumpdev);
error = sysctl_handle_opaque(oidp, &ndumpdev, sizeof ndumpdev, req);
if (error == 0 && req->newptr != NULL)
error = setdumpdev(udev2dev(ndumpdev, 1));
return (error);
}
SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");
static int
setrootbyname(char *name)

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
* $Id: kern_shutdown.c,v 1.53 1999/06/26 02:46:02 mckusick Exp $
* $Id: kern_shutdown.c,v 1.54 1999/07/01 22:54:55 peter Exp $
*/
#include "opt_ddb.h"
@ -127,6 +127,8 @@ static struct shutdown_list shutdown_lists[SHUTDOWN_FINAL + 1];
static void boot __P((int)) __dead2;
static void dumpsys __P((void));
static int setdumpdev __P((dev_t dev));
#ifndef _SYS_SYSPROTO_H_
struct reboot_args {
@ -352,8 +354,41 @@ static u_long const dumpmag = 0x8fca0101UL;
static int dumpsize = 0; /* also for savecore */
static int dodump = 1;
SYSCTL_INT(_machdep, OID_AUTO, do_dump, CTLFLAG_RW,
&dodump, 0, "Do coredump on kernel panic");
SYSCTL_INT(_machdep, OID_AUTO, do_dump, CTLFLAG_RW, &dodump, 0,
"Try to perform coredump on kernel panic");
static int
setdumpdev(dev)
dev_t dev;
{
int maj, psize;
long newdumplo;
if (dev == NODEV) {
dumpdev = dev;
return (0);
}
maj = major(dev);
if (bdevsw(dev) == NULL)
return (ENXIO); /* XXX is this right? */
if (bdevsw(dev)->d_psize == NULL)
return (ENXIO); /* XXX should be ENODEV ? */
psize = bdevsw(dev)->d_psize(dev);
if (psize == -1)
return (ENXIO); /* XXX should be ENODEV ? */
/*
* XXX should clean up checking in dumpsys() to be more like this,
* and nuke dodump sysctl (too many knobs).
*/
newdumplo = psize - Maxmem * PAGE_SIZE / DEV_BSIZE;
if (newdumplo < 0)
return (ENOSPC);
dumpdev = dev;
dumplo = newdumplo;
return (0);
}
/* ARGSUSED */
static void dump_conf __P((void *dummy));
@ -361,10 +396,28 @@ static void
dump_conf(dummy)
void *dummy;
{
cpu_dumpconf();
if (setdumpdev(dumpdev) != 0)
dumpdev = NODEV;
}
SYSINIT(dump_conf, SI_SUB_DUMP_CONF, SI_ORDER_FIRST, dump_conf, NULL)
static int
sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
{
int error;
udev_t ndumpdev;
ndumpdev = dev2udev(dumpdev);
error = sysctl_handle_opaque(oidp, &ndumpdev, sizeof ndumpdev, req);
if (error == 0 && req->newptr != NULL)
error = setdumpdev(udev2dev(ndumpdev, 1));
return (error);
}
SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");
/*
* Doadump comes here after turning off memory management and
* getting on the dump stack, either when called above, or by

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)systm.h 8.7 (Berkeley) 3/29/95
* $Id: systm.h,v 1.90 1999/05/31 20:42:41 dt Exp $
* $Id: systm.h,v 1.91 1999/07/17 18:43:48 phk Exp $
*/
#ifndef _SYS_SYSTM_H_
@ -103,7 +103,6 @@ void *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
void panic __P((const char *, ...)) __dead2 __printflike(1, 2);
void cpu_boot __P((int));
void cpu_rootconf __P((void));
void cpu_dumpconf __P((void));
void tablefull __P((const char *));
int addlog __P((const char *, ...)) __printflike(1, 2);
int kvprintf __P((char const *, void (*)(int, void*), void *, int,