summaryrefslogtreecommitdiffstats
path: root/sbin/dumpon
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-03-31 22:24:24 +0000
committerphk <phk@FreeBSD.org>2002-03-31 22:24:24 +0000
commite6623c74b801da420bb27c4261b67a6d07922419 (patch)
tree13aeb1f912c913e66edf201bb572e373bbe4844b /sbin/dumpon
parent6d90a200e5bbe8dd2349749eac015e3cb5f7a17a (diff)
downloadFreeBSD-src-e6623c74b801da420bb27c4261b67a6d07922419.zip
FreeBSD-src-e6623c74b801da420bb27c4261b67a6d07922419.tar.gz
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.
Diffstat (limited to 'sbin/dumpon')
-rw-r--r--sbin/dumpon/Makefile2
-rw-r--r--sbin/dumpon/dumpon.c60
2 files changed, 25 insertions, 37 deletions
diff --git a/sbin/dumpon/Makefile b/sbin/dumpon/Makefile
index 5a70382..12fced5 100644
--- a/sbin/dumpon/Makefile
+++ b/sbin/dumpon/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PROG= dumpon
-WARNS= 0
+WARNS= 4
MAN= dumpon.8
.include <bsd.prog.mk>
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index 8f93d52..2c4d4a4 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -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;
- }
-
- 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));
- }
+ 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)");
- return (0);
+ exit (0);
}
void
OpenPOWER on IntegriCloud