Here follows the new kernel dumping infrastructure.

Caveats:

The new savecore program is not complete in the sense that it emulates
enough of the old savecores features to do the job, but implements none
of the options yet.

I would appreciate if a userland hacker could help me out getting savecore
to do what we want it to do from a users point of view, compression,
email-notification, space reservation etc etc.  (send me email if
you are interested).

Currently, savecore will scan all devices marked as "swap" or "dump" in
/etc/fstab _or_ any devices specified on the command-line.

All architectures but i386 lack an implementation of dumpsys(), but
looking at the i386 version it should be trivial for anybody familiar
with the platform(s) to provide this function.

Documentation is quite sparse at this time, more to come.

Sponsored by:   DARPA, NAI Labs

Details:

Dumpon now opens the device and uses ioctl(DIOCGKERNELDUMP) to set it
to be the dumpdevice.  When "off" is set, /dev/null is used.
This commit is contained in:
Poul-Henning Kamp 2002-03-31 22:24:24 +00:00
parent 1fbee2b785
commit 9e9c1cad4c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=93491
2 changed files with 25 additions and 37 deletions

View File

@ -1,7 +1,7 @@
# $FreeBSD$
PROG= dumpon
WARNS= 0
WARNS= 4
MAN= dumpon.8
.include <bsd.prog.mk>

View File

@ -48,11 +48,11 @@ static const char rcsid[] =
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <paths.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
#include <sys/disklabel.h>
#include <sysexits.h>
void usage(void) __dead2;
@ -61,8 +61,8 @@ int
main(int argc, char *argv[])
{
int ch, verbose, rv;
struct stat stab;
int mib[2];
int i, fd;
u_int u;
verbose = rv = 0;
while ((ch = getopt(argc, argv, "v")) != -1)
@ -80,41 +80,29 @@ main(int argc, char *argv[])
usage();
if (strcmp(argv[0], "off")) {
rv = stat(argv[0], &stab);
if (rv) {
fd = open(argv[0], O_RDONLY);
if (fd < 0)
err(EX_OSFILE, "%s", argv[0]);
}
if (!S_ISCHR(stab.st_mode)) {
errx(EX_USAGE,
"%s: must specify a character disk device",
argv[0]);
}
u = 0;
i = ioctl(fd, DIOCGKERNELDUMP, &u);
u = 1;
i = ioctl(fd, DIOCGKERNELDUMP, &u);
if (i == 0 && verbose)
printf("kernel dumps on %s\n", argv[0]);
} else {
stab.st_rdev = NODEV;
fd = open(_PATH_DEVNULL, O_RDONLY);
if (fd < 0)
err(EX_OSFILE, "%s", _PATH_DEVNULL);
u = 0;
i = ioctl(fd, DIOCGKERNELDUMP, &u);
if (i == 0 && verbose)
printf("kernel dumps disabled\n");
}
if (i < 0)
err(EX_OSERR, "ioctl(DIOCGKERNELDUMP)");
mib[0] = CTL_KERN;
mib[1] = KERN_DUMPDEV;
rv = sysctl(mib, 2, (void *)0, (size_t *)0, &stab.st_rdev,
sizeof stab.st_rdev);
if (rv) {
err(EX_OSERR, "sysctl: kern.dumpdev");
}
if (verbose) {
if (stab.st_rdev == NODEV) {
printf("dumpon: crash dumps disabled\n");
} else {
printf("dumpon: crash dumps to %s (%lu, %lu)\n",
argv[0],
(unsigned long)major(stab.st_rdev),
(unsigned long)minor(stab.st_rdev));
}
}
return (0);
exit (0);
}
void