summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c
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/kern/subr_disk.c
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/kern/subr_disk.c')
-rw-r--r--sys/kern/subr_disk.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index a4ef2d8..155cfc3 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -198,31 +198,26 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct
return (dev);
}
-int
-disk_dumpcheck(dev_t dev, u_int *count, u_int *blkno, u_int *secsize)
+static int
+diskdumpconf(u_int onoff, dev_t dev, struct disk *dp)
{
- struct disk *dp;
+ struct dumperinfo di;
struct disklabel *dl;
- u_int boff;
- dp = dev->si_disk;
- if (!dp)
- return (ENXIO);
- if (!dp->d_slice)
- return (ENXIO);
+ if (!onoff)
+ return(set_dumper(NULL));
dl = dsgetlabel(dev, dp->d_slice);
if (!dl)
return (ENXIO);
- *count = Maxmem * (PAGE_SIZE / dl->d_secsize);
- if (dumplo <= LABELSECTOR ||
- (dumplo + *count > dl->d_partitions[dkpart(dev)].p_size))
- return (EINVAL);
- boff = dl->d_partitions[dkpart(dev)].p_offset +
- dp->d_slice->dss_slices[dkslice(dev)].ds_offset;
- *blkno = boff + dumplo;
- *secsize = dl->d_secsize;
- return (0);
-
+ bzero(&di, sizeof di);
+ di.dumper = (dumper_t *)dp->d_devsw->d_dump;
+ di.priv = dp->d_dev;
+ di.blocksize = dl->d_secsize;
+ di.mediaoffset = (off_t)(dl->d_partitions[dkpart(dev)].p_offset +
+ dp->d_slice->dss_slices[dkslice(dev)].ds_offset) * DEV_BSIZE;
+ di.mediasize =
+ (off_t)(dl->d_partitions[dkpart(dev)].p_size) * DEV_BSIZE;
+ return(set_dumper(&di));
}
void
@@ -388,12 +383,17 @@ diskioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
{
struct disk *dp;
int error;
+ u_int u;
dev_t pdev;
pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
dp = pdev->si_disk;
if (!dp)
return (ENXIO);
+ if (cmd == DIOCGKERNELDUMP) {
+ u = *(u_int *)data;
+ return (diskdumpconf(u, dev, dp));
+ }
error = dsioctl(dev, cmd, data, fflag, &dp->d_slice);
if (error == ENOIOCTL)
error = dp->d_devsw->d_ioctl(dev, cmd, data, fflag, td);
OpenPOWER on IntegriCloud