aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/null/null.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2002-03-31 22:37:00 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2002-03-31 22:37:00 +0000
commit81661c94b6a5a0b3b13048741a7e219300df81a9 (patch)
tree0962f06e2a2c422d89af486eb66e8e726fea13b7 /sys/dev/null/null.c
parent67cd130e592c3937634403d105c7c72ed20bd7f9 (diff)
downloadsrc-81661c94b6a5a0b3b13048741a7e219300df81a9.tar.gz
src-81661c94b6a5a0b3b13048741a7e219300df81a9.zip
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. Details: ATA and SCSI drivers should work as the dump formatting code has been removed. The IDA, TWE and AAC have not yet been converted. Dumpon now opens the device and uses ioctl(DIOCGKERNELDUMP) to set the device as dumpdev. To implement the "off" argument, /dev/null is used as the device. Savecore will fail if handed any options since they are not (yet) implemented. All devices marked "dump" or "swap" in /etc/fstab will be scanned and dumps found will be saved to diskfiles named from the MD5 hash of the header record. The header record is dumped in readable format in the .info file. The kernel is not saved. Only complete dumps will be saved. All maintainer rights for this code are disclaimed: feel free to improve and extend. Sponsored by: DARPA, NAI Labs
Notes
Notes: svn path=/head/; revision=93496
Diffstat (limited to 'sys/dev/null/null.c')
-rw-r--r--sys/dev/null/null.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c
index f7eaa77081f6..ec0d521270e8 100644
--- a/sys/dev/null/null.c
+++ b/sys/dev/null/null.c
@@ -33,6 +33,7 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
+#include <sys/disklabel.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <machine/resource.h>
@@ -43,6 +44,7 @@ static dev_t null_dev;
static dev_t zero_dev;
static d_write_t null_write;
+static d_ioctl_t null_ioctl;
static d_read_t zero_read;
#define CDEV_MAJOR 2
@@ -54,7 +56,7 @@ static struct cdevsw null_cdevsw = {
/* close */ (d_close_t *)nullop,
/* read */ (d_read_t *)nullop,
/* write */ null_write,
- /* ioctl */ noioctl,
+ /* ioctl */ null_ioctl,
/* poll */ nopoll,
/* mmap */ nommap,
/* strategy */ nostrategy,
@@ -91,6 +93,20 @@ null_write(dev_t dev, struct uio *uio, int flag)
}
static int
+null_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
+{
+ int error;
+
+ if (cmd != DIOCGKERNELDUMP)
+ return (noioctl(dev, cmd, data, fflag, td));
+ error = suser_td(td);
+ if (error)
+ return (error);
+ return (set_dumper(NULL));
+}
+
+
+static int
zero_read(dev_t dev, struct uio *uio, int flag)
{
u_int c;