summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-03-31 22:37:00 +0000
committerphk <phk@FreeBSD.org>2002-03-31 22:37:00 +0000
commitef82a516346a59befd780764209cd79a53941758 (patch)
tree0962f06e2a2c422d89af486eb66e8e726fea13b7 /sys/dev
parentb19c49c220775864538a4c0608a821586b85eda2 (diff)
downloadFreeBSD-src-ef82a516346a59befd780764209cd79a53941758.zip
FreeBSD-src-ef82a516346a59befd780764209cd79a53941758.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. 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
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ata/ata-disk.c62
-rw-r--r--sys/dev/ida/ida_disk.c7
-rw-r--r--sys/dev/null/null.c18
-rw-r--r--sys/dev/twe/twe_freebsd.c7
4 files changed, 46 insertions, 48 deletions
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c
index 8a5ef87..8f21ea1 100644
--- a/sys/dev/ata/ata-disk.c
+++ b/sys/dev/ata/ata-disk.c
@@ -293,50 +293,29 @@ adstrategy(struct bio *bp)
ata_start(adp->device->channel);
}
-int
-addump(dev_t dev)
+static int
+addump(dev_t dev, void *virtual, vm_offset_t physical, off_t offset, size_t length)
{
struct ad_softc *adp = dev->si_drv1;
struct ad_request request;
- u_int count, blkno, secsize;
- vm_offset_t addr = 0;
- long blkcnt;
- int dumppages = MAXDUMPPGS;
- int error;
- int i;
-
- if ((error = disk_dumpcheck(dev, &count, &blkno, &secsize)))
- return error;
-
+ static int once;
+
if (!adp)
return ENXIO;
- /* force PIO mode for dumps */
- adp->device->mode = ATA_PIO;
- ata_reinit(adp->device->channel);
-
- blkcnt = howmany(PAGE_SIZE, secsize);
-
- while (count > 0) {
- caddr_t va = NULL;
- DELAY(1000);
-
- if ((count / blkcnt) < dumppages)
- dumppages = count / blkcnt;
-
- for (i = 0; i < dumppages; ++i) {
- vm_offset_t a = addr + (i * PAGE_SIZE);
- if (is_physical_memory(a))
- va = pmap_kenter_temporary(trunc_page(a), i);
- else
- va = pmap_kenter_temporary(trunc_page(0), i);
- }
+ if (!once) {
+ /* force PIO mode for dumps */
+ adp->device->mode = ATA_PIO;
+ ata_reinit(adp->device->channel);
+ once = 1;
+ }
+ if (length > 0) {
bzero(&request, sizeof(struct ad_request));
request.softc = adp;
- request.blockaddr = blkno;
- request.bytecount = PAGE_SIZE * dumppages;
- request.data = va;
+ request.blockaddr = offset / DEV_BSIZE;
+ request.bytecount = length;
+ request.data = virtual;
while (request.bytecount > 0) {
ad_transfer(&request);
@@ -346,17 +325,10 @@ addump(dev_t dev)
request.bytecount -= request.currentsize;
DELAY(20);
}
-
- if (dumpstatus(addr, (off_t)count * DEV_BSIZE) < 0)
- return EINTR;
-
- blkno += blkcnt * dumppages;
- count -= blkcnt * dumppages;
- addr += PAGE_SIZE * dumppages;
+ } else {
+ if (ata_wait(adp->device, ATA_S_READY | ATA_S_DSC) < 0)
+ ata_prtdev(adp->device, "timeout waiting for final ready\n");
}
-
- if (ata_wait(adp->device, ATA_S_READY | ATA_S_DSC) < 0)
- ata_prtdev(adp->device, "timeout waiting for final ready\n");
return 0;
}
diff --git a/sys/dev/ida/ida_disk.c b/sys/dev/ida/ida_disk.c
index 0a919d1..256b5aa 100644
--- a/sys/dev/ida/ida_disk.c
+++ b/sys/dev/ida/ida_disk.c
@@ -186,8 +186,12 @@ bad:
}
static int
-idad_dump(dev_t dev)
+idad_dump(dev_t dev, void *virtual, vm_offset_t physical, off_t offset, size_t length)
{
+
+ /* This needs modified to the new dump API */
+ return (ENXIO);
+#if 0
struct idad_softc *drv;
u_int count, blkno, secsize;
long blkcnt;
@@ -231,6 +235,7 @@ idad_dump(dev_t dev)
addr += PAGE_SIZE * dumppages;
}
return (0);
+#endif
}
void
diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c
index f7eaa77..ec0d521 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;
diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c
index 1fffe4e..403d9d8 100644
--- a/sys/dev/twe/twe_freebsd.c
+++ b/sys/dev/twe/twe_freebsd.c
@@ -701,8 +701,12 @@ twed_strategy(twe_bio *bp)
* System crashdump support
*/
int
-twed_dump(dev_t dev)
+twed_dump(dev_t dev, void *virtual, vm_offset_t physical, off_t offset, size_t length)
{
+
+ /* XXX: this needs modified to the new dump API */
+ return (ENXIO);
+#if 0
struct twed_softc *twed_sc = (struct twed_softc *)dev->si_drv1;
struct twe_softc *twe_sc = (struct twe_softc *)twed_sc->twed_controller;
u_int count, blkno, secsize;
@@ -747,6 +751,7 @@ twed_dump(dev_t dev)
addr += PAGE_SIZE * dumppages;
}
return(0);
+#endif
}
/********************************************************************************
OpenPOWER on IntegriCloud