1999-08-29 13:28:55 +00:00
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
|
* <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
|
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-03-11 08:08:02 +00:00
|
|
|
#include "opt_geom.h"
|
|
|
|
#ifndef GEOM
|
|
|
|
|
1999-08-29 13:28:55 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
1999-09-09 19:08:44 +00:00
|
|
|
#include <sys/sysctl.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1999-08-29 13:28:55 +00:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/disk.h>
|
|
|
|
#include <sys/malloc.h>
|
2000-06-22 11:44:43 +00:00
|
|
|
#include <sys/sysctl.h>
|
1999-09-01 05:38:09 +00:00
|
|
|
#include <machine/md_var.h>
|
2000-08-20 21:34:39 +00:00
|
|
|
#include <sys/ctype.h>
|
|
|
|
|
2000-12-08 20:09:00 +00:00
|
|
|
static MALLOC_DEFINE(M_DISK, "disk", "disk data");
|
1999-08-29 13:28:55 +00:00
|
|
|
|
|
|
|
static d_strategy_t diskstrategy;
|
|
|
|
static d_open_t diskopen;
|
|
|
|
static d_close_t diskclose;
|
|
|
|
static d_ioctl_t diskioctl;
|
|
|
|
static d_psize_t diskpsize;
|
2000-06-15 20:30:53 +00:00
|
|
|
|
|
|
|
static LIST_HEAD(, disk) disklist = LIST_HEAD_INITIALIZER(&disklist);
|
2000-08-20 21:34:39 +00:00
|
|
|
|
2001-10-27 17:44:21 +00:00
|
|
|
void disk_dev_synth(dev_t dev);
|
|
|
|
|
|
|
|
void
|
|
|
|
disk_dev_synth(dev_t dev)
|
|
|
|
{
|
|
|
|
struct disk *dp;
|
|
|
|
int u, s, p;
|
|
|
|
dev_t pdev;
|
|
|
|
|
2001-11-04 09:01:07 +00:00
|
|
|
if (dksparebits(dev))
|
2001-11-03 23:21:00 +00:00
|
|
|
return;
|
2001-10-27 17:44:21 +00:00
|
|
|
LIST_FOREACH(dp, &disklist, d_list) {
|
|
|
|
if (major(dev) != dp->d_devsw->d_maj)
|
|
|
|
continue;
|
|
|
|
u = dkunit(dev);
|
|
|
|
p = RAW_PART;
|
|
|
|
s = WHOLE_DISK_SLICE;
|
|
|
|
pdev = makedev(dp->d_devsw->d_maj, dkmakeminor(u, s, p));
|
2001-10-28 09:39:28 +00:00
|
|
|
if (pdev->si_devsw == NULL)
|
|
|
|
return; /* Probably a unit we don't have */
|
2001-10-27 17:44:21 +00:00
|
|
|
s = dkslice(dev);
|
|
|
|
p = dkpart(dev);
|
|
|
|
if (s == WHOLE_DISK_SLICE && p == RAW_PART) {
|
|
|
|
/* XXX: actually should not happen */
|
|
|
|
dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%d",
|
|
|
|
dp->d_devsw->d_name, u);
|
|
|
|
dev_depends(pdev, dev);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (s == COMPATIBILITY_SLICE) {
|
|
|
|
dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%d%c",
|
|
|
|
dp->d_devsw->d_name, u, 'a' + p);
|
|
|
|
dev_depends(pdev, dev);
|
|
|
|
return;
|
|
|
|
}
|
2001-11-02 09:16:25 +00:00
|
|
|
if (p != RAW_PART) {
|
|
|
|
dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%ds%d%c",
|
|
|
|
dp->d_devsw->d_name, u, s - BASE_SLICE + 1,
|
|
|
|
'a' + p);
|
|
|
|
} else {
|
|
|
|
dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%ds%d",
|
|
|
|
dp->d_devsw->d_name, u, s - BASE_SLICE + 1);
|
|
|
|
make_dev_alias(dev, "%s%ds%dc",
|
2001-10-27 17:44:21 +00:00
|
|
|
dp->d_devsw->d_name, u, s - BASE_SLICE + 1);
|
2001-11-02 09:16:25 +00:00
|
|
|
}
|
|
|
|
dev_depends(pdev, dev);
|
2001-10-27 17:44:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-20 21:34:39 +00:00
|
|
|
static void
|
|
|
|
disk_clone(void *arg, char *name, int namelen, dev_t *dev)
|
|
|
|
{
|
|
|
|
struct disk *dp;
|
|
|
|
char const *d;
|
2002-03-11 08:08:02 +00:00
|
|
|
char *e;
|
|
|
|
int j, u, s, p;
|
2000-08-20 21:34:39 +00:00
|
|
|
dev_t pdev;
|
|
|
|
|
|
|
|
if (*dev != NODEV)
|
|
|
|
return;
|
|
|
|
|
|
|
|
LIST_FOREACH(dp, &disklist, d_list) {
|
|
|
|
d = dp->d_devsw->d_name;
|
2002-03-11 08:08:02 +00:00
|
|
|
j = dev_stdclone(name, &e, d, &u);
|
|
|
|
if (j == 0)
|
2000-08-20 21:34:39 +00:00
|
|
|
continue;
|
2000-12-15 17:55:24 +00:00
|
|
|
if (u > DKMAXUNIT)
|
|
|
|
continue;
|
2000-08-20 21:34:39 +00:00
|
|
|
p = RAW_PART;
|
|
|
|
s = WHOLE_DISK_SLICE;
|
|
|
|
pdev = makedev(dp->d_devsw->d_maj, dkmakeminor(u, s, p));
|
|
|
|
if (pdev->si_disk == NULL)
|
|
|
|
continue;
|
2002-03-11 08:08:02 +00:00
|
|
|
if (*e != '\0') {
|
|
|
|
j = dev_stdclone(e, &e, "s", &s);
|
|
|
|
if (j == 0)
|
2000-08-20 21:34:39 +00:00
|
|
|
s = COMPATIBILITY_SLICE;
|
2002-03-11 08:08:02 +00:00
|
|
|
else if (j == 1 || j == 2)
|
|
|
|
s += BASE_SLICE - 1;
|
|
|
|
if (!*e)
|
|
|
|
; /* ad0s1 case */
|
|
|
|
else if (e[1] != '\0')
|
|
|
|
return; /* can never be a disk name */
|
|
|
|
else if (*e < 'a' || *e > 'h')
|
|
|
|
return; /* can never be a disk name */
|
2000-08-20 21:34:39 +00:00
|
|
|
else
|
2002-03-11 08:08:02 +00:00
|
|
|
p = *e - 'a';
|
2000-08-20 21:34:39 +00:00
|
|
|
}
|
2002-03-11 08:08:02 +00:00
|
|
|
if (s == WHOLE_DISK_SLICE && p == RAW_PART) {
|
|
|
|
return;
|
|
|
|
} else if (s >= BASE_SLICE && p != RAW_PART) {
|
2001-10-27 17:44:21 +00:00
|
|
|
*dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p),
|
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%ds%d%c",
|
2001-11-02 09:16:25 +00:00
|
|
|
pdev->si_devsw->d_name, u, s - BASE_SLICE + 1,
|
|
|
|
p + 'a');
|
|
|
|
} else if (s >= BASE_SLICE) {
|
2001-10-27 17:44:21 +00:00
|
|
|
*dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p),
|
2001-11-02 09:16:25 +00:00
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%ds%d",
|
|
|
|
pdev->si_devsw->d_name, u, s - BASE_SLICE + 1);
|
|
|
|
make_dev_alias(*dev, "%s%ds%dc",
|
2001-10-27 17:44:21 +00:00
|
|
|
pdev->si_devsw->d_name, u, s - BASE_SLICE + 1);
|
2001-11-02 09:16:25 +00:00
|
|
|
} else {
|
|
|
|
*dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p),
|
2002-03-11 08:08:02 +00:00
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%d%c",
|
|
|
|
pdev->si_devsw->d_name, u, p + 'a');
|
2001-10-27 17:44:21 +00:00
|
|
|
}
|
2001-11-02 09:16:25 +00:00
|
|
|
dev_depends(pdev, *dev);
|
2000-08-20 21:34:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
static void
|
|
|
|
inherit_raw(dev_t pdev, dev_t dev)
|
|
|
|
{
|
|
|
|
dev->si_disk = pdev->si_disk;
|
|
|
|
dev->si_drv1 = pdev->si_drv1;
|
|
|
|
dev->si_drv2 = pdev->si_drv2;
|
|
|
|
dev->si_iosize_max = pdev->si_iosize_max;
|
|
|
|
dev->si_bsize_phys = pdev->si_bsize_phys;
|
|
|
|
dev->si_bsize_best = pdev->si_bsize_best;
|
|
|
|
}
|
|
|
|
|
1999-08-29 13:28:55 +00:00
|
|
|
dev_t
|
1999-09-12 20:40:29 +00:00
|
|
|
disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct cdevsw *proto)
|
1999-08-29 13:28:55 +00:00
|
|
|
{
|
2000-08-20 21:34:39 +00:00
|
|
|
static int once;
|
2001-05-29 18:19:57 +00:00
|
|
|
dev_t dev;
|
2001-05-26 08:27:58 +00:00
|
|
|
|
|
|
|
if (!once) {
|
|
|
|
EVENTHANDLER_REGISTER(dev_clone, disk_clone, 0, 1000);
|
|
|
|
once++;
|
|
|
|
}
|
1999-09-12 09:16:00 +00:00
|
|
|
|
|
|
|
bzero(dp, sizeof(*dp));
|
|
|
|
|
2001-05-24 20:27:16 +00:00
|
|
|
if (proto->d_open != diskopen) {
|
1999-09-12 20:40:29 +00:00
|
|
|
*proto = *cdevsw;
|
|
|
|
proto->d_open = diskopen;
|
|
|
|
proto->d_close = diskclose;
|
|
|
|
proto->d_ioctl = diskioctl;
|
|
|
|
proto->d_strategy = diskstrategy;
|
|
|
|
proto->d_psize = diskpsize;
|
1999-08-29 13:28:55 +00:00
|
|
|
}
|
|
|
|
|
1999-11-19 23:34:01 +00:00
|
|
|
if (bootverbose)
|
|
|
|
printf("Creating DISK %s%d\n", cdevsw->d_name, unit);
|
1999-09-13 18:20:21 +00:00
|
|
|
dev = make_dev(proto, dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART),
|
2000-08-20 21:34:39 +00:00
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "%s%d", cdevsw->d_name, unit);
|
1999-08-29 13:28:55 +00:00
|
|
|
|
|
|
|
dev->si_disk = dp;
|
|
|
|
dp->d_dev = dev;
|
1999-11-06 10:25:58 +00:00
|
|
|
dp->d_dsflags = flags;
|
1999-09-12 20:40:29 +00:00
|
|
|
dp->d_devsw = cdevsw;
|
2000-06-15 20:30:53 +00:00
|
|
|
LIST_INSERT_HEAD(&disklist, dp, d_list);
|
2001-05-26 08:27:58 +00:00
|
|
|
|
1999-08-29 13:28:55 +00:00
|
|
|
return (dev);
|
|
|
|
}
|
|
|
|
|
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
2002-03-31 22:37:00 +00:00
|
|
|
static int
|
|
|
|
diskdumpconf(u_int onoff, dev_t dev, struct disk *dp)
|
1999-09-01 05:38:09 +00:00
|
|
|
{
|
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
2002-03-31 22:37:00 +00:00
|
|
|
struct dumperinfo di;
|
1999-09-01 05:38:09 +00:00
|
|
|
struct disklabel *dl;
|
|
|
|
|
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
2002-03-31 22:37:00 +00:00
|
|
|
if (!onoff)
|
|
|
|
return(set_dumper(NULL));
|
1999-09-01 05:38:09 +00:00
|
|
|
dl = dsgetlabel(dev, dp->d_slice);
|
|
|
|
if (!dl)
|
|
|
|
return (ENXIO);
|
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
2002-03-31 22:37:00 +00:00
|
|
|
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));
|
1999-09-01 05:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
disk_invalidate (struct disk *disk)
|
|
|
|
{
|
2000-02-18 20:57:33 +00:00
|
|
|
if (disk->d_slice)
|
|
|
|
dsgone(&disk->d_slice);
|
1999-09-01 05:38:09 +00:00
|
|
|
}
|
|
|
|
|
1999-08-29 13:28:55 +00:00
|
|
|
void
|
2000-01-28 20:49:43 +00:00
|
|
|
disk_destroy(dev_t dev)
|
1999-08-29 13:28:55 +00:00
|
|
|
{
|
2000-06-15 20:30:53 +00:00
|
|
|
LIST_REMOVE(dev->si_disk, d_list);
|
|
|
|
bzero(dev->si_disk, sizeof(*dev->si_disk));
|
2000-02-18 20:57:33 +00:00
|
|
|
dev->si_disk = NULL;
|
|
|
|
destroy_dev(dev);
|
1999-08-29 13:28:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-15 20:30:53 +00:00
|
|
|
struct disk *
|
|
|
|
disk_enumerate(struct disk *disk)
|
|
|
|
{
|
|
|
|
if (!disk)
|
|
|
|
return (LIST_FIRST(&disklist));
|
|
|
|
else
|
|
|
|
return (LIST_NEXT(disk, d_list));
|
|
|
|
}
|
|
|
|
|
2000-06-22 11:44:43 +00:00
|
|
|
static int
|
2000-07-04 11:25:35 +00:00
|
|
|
sysctl_disks(SYSCTL_HANDLER_ARGS)
|
2000-06-22 11:44:43 +00:00
|
|
|
{
|
|
|
|
struct disk *disk;
|
|
|
|
int error, first;
|
|
|
|
|
|
|
|
disk = NULL;
|
|
|
|
first = 1;
|
|
|
|
|
|
|
|
while ((disk = disk_enumerate(disk))) {
|
|
|
|
if (!first) {
|
|
|
|
error = SYSCTL_OUT(req, " ", 1);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
} else {
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
error = SYSCTL_OUT(req, disk->d_dev->si_name, strlen(disk->d_dev->si_name));
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
error = SYSCTL_OUT(req, "", 1);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCTL_PROC(_kern, OID_AUTO, disks, CTLTYPE_STRING | CTLFLAG_RD, 0, NULL,
|
|
|
|
sysctl_disks, "A", "names of available disks");
|
|
|
|
|
1999-09-01 05:38:09 +00:00
|
|
|
/*
|
|
|
|
* The cdevsw functions
|
|
|
|
*/
|
|
|
|
|
1999-08-29 13:28:55 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
diskopen(dev_t dev, int oflags, int devtype, struct thread *td)
|
1999-08-29 13:28:55 +00:00
|
|
|
{
|
|
|
|
dev_t pdev;
|
|
|
|
struct disk *dp;
|
|
|
|
int error;
|
|
|
|
|
1999-09-01 05:38:09 +00:00
|
|
|
error = 0;
|
1999-08-29 13:28:55 +00:00
|
|
|
pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
|
1999-09-01 05:38:09 +00:00
|
|
|
|
1999-08-29 13:28:55 +00:00
|
|
|
dp = pdev->si_disk;
|
|
|
|
if (!dp)
|
|
|
|
return (ENXIO);
|
1999-09-01 05:38:09 +00:00
|
|
|
|
1999-11-06 10:25:58 +00:00
|
|
|
while (dp->d_flags & DISKFLAG_LOCK) {
|
|
|
|
dp->d_flags |= DISKFLAG_WANTED;
|
1999-12-19 12:36:41 +00:00
|
|
|
error = tsleep(dp, PRIBIO | PCATCH, "diskopen", hz);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1999-11-06 10:25:58 +00:00
|
|
|
}
|
|
|
|
dp->d_flags |= DISKFLAG_LOCK;
|
|
|
|
|
1999-10-02 11:17:54 +00:00
|
|
|
if (!dsisopen(dp->d_slice)) {
|
1999-10-02 20:21:49 +00:00
|
|
|
if (!pdev->si_iosize_max)
|
|
|
|
pdev->si_iosize_max = dev->si_iosize_max;
|
2001-09-12 08:38:13 +00:00
|
|
|
error = dp->d_devsw->d_open(pdev, oflags, devtype, td);
|
1999-10-02 11:17:54 +00:00
|
|
|
}
|
1999-09-30 21:14:28 +00:00
|
|
|
|
|
|
|
/* Inherit properties from the whole/raw dev_t */
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
inherit_raw(pdev, dev);
|
1999-08-29 13:28:55 +00:00
|
|
|
|
1999-09-01 05:38:09 +00:00
|
|
|
if (error)
|
1999-11-06 10:25:58 +00:00
|
|
|
goto out;
|
1999-09-01 05:38:09 +00:00
|
|
|
|
1999-11-06 10:25:58 +00:00
|
|
|
error = dsopen(dev, devtype, dp->d_dsflags, &dp->d_slice, &dp->d_label);
|
1999-08-29 13:28:55 +00:00
|
|
|
|
1999-09-01 05:38:09 +00:00
|
|
|
if (!dsisopen(dp->d_slice))
|
2001-09-12 08:38:13 +00:00
|
|
|
dp->d_devsw->d_close(pdev, oflags, devtype, td);
|
1999-11-06 10:25:58 +00:00
|
|
|
out:
|
|
|
|
dp->d_flags &= ~DISKFLAG_LOCK;
|
|
|
|
if (dp->d_flags & DISKFLAG_WANTED) {
|
|
|
|
dp->d_flags &= ~DISKFLAG_WANTED;
|
|
|
|
wakeup(dp);
|
|
|
|
}
|
1999-09-01 05:38:09 +00:00
|
|
|
|
1999-08-29 13:28:55 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
diskclose(dev_t dev, int fflag, int devtype, struct thread *td)
|
1999-08-29 13:28:55 +00:00
|
|
|
{
|
|
|
|
struct disk *dp;
|
|
|
|
int error;
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
dev_t pdev;
|
1999-08-29 13:28:55 +00:00
|
|
|
|
|
|
|
error = 0;
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
|
|
|
|
dp = pdev->si_disk;
|
2001-03-13 08:45:05 +00:00
|
|
|
if (!dp)
|
|
|
|
return (ENXIO);
|
1999-09-30 05:29:59 +00:00
|
|
|
dsclose(dev, devtype, dp->d_slice);
|
2001-03-13 08:45:05 +00:00
|
|
|
if (!dsisopen(dp->d_slice))
|
2001-09-12 08:38:13 +00:00
|
|
|
error = dp->d_devsw->d_close(dp->d_dev, fflag, devtype, td);
|
1999-08-29 13:28:55 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-04-15 05:54:02 +00:00
|
|
|
diskstrategy(struct bio *bp)
|
1999-08-29 13:28:55 +00:00
|
|
|
{
|
|
|
|
dev_t pdev;
|
|
|
|
struct disk *dp;
|
|
|
|
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
pdev = dkmodpart(dkmodslice(bp->bio_dev, WHOLE_DISK_SLICE), RAW_PART);
|
|
|
|
dp = pdev->si_disk;
|
2001-05-08 08:24:54 +00:00
|
|
|
bp->bio_resid = bp->bio_bcount;
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
if (dp != bp->bio_dev->si_disk)
|
|
|
|
inherit_raw(pdev, bp->bio_dev);
|
1999-08-29 13:28:55 +00:00
|
|
|
|
|
|
|
if (!dp) {
|
2001-05-06 20:00:03 +00:00
|
|
|
biofinish(bp, NULL, ENXIO);
|
1999-08-29 13:28:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-01-10 12:21:39 +00:00
|
|
|
if (dscheck(bp, dp->d_slice) <= 0) {
|
1999-08-29 13:28:55 +00:00
|
|
|
biodone(bp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-05-06 21:55:22 +00:00
|
|
|
if (bp->bio_bcount == 0) {
|
|
|
|
biodone(bp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-04-25 10:51:18 +00:00
|
|
|
KASSERT(dp->d_devsw != NULL, ("NULL devsw"));
|
|
|
|
KASSERT(dp->d_devsw->d_strategy != NULL, ("NULL d_strategy"));
|
1999-09-12 20:40:29 +00:00
|
|
|
dp->d_devsw->d_strategy(bp);
|
1999-08-29 13:28:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
diskioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
|
1999-08-29 13:28:55 +00:00
|
|
|
{
|
|
|
|
struct disk *dp;
|
|
|
|
int error;
|
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
2002-03-31 22:37:00 +00:00
|
|
|
u_int u;
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
dev_t pdev;
|
1999-08-29 13:28:55 +00:00
|
|
|
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
|
|
|
|
dp = pdev->si_disk;
|
2001-03-13 08:45:05 +00:00
|
|
|
if (!dp)
|
|
|
|
return (ENXIO);
|
2002-04-09 10:04:09 +00:00
|
|
|
if (cmd == DIOCSKERNELDUMP) {
|
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
2002-03-31 22:37:00 +00:00
|
|
|
u = *(u_int *)data;
|
|
|
|
return (diskdumpconf(u, dev, dp));
|
|
|
|
}
|
2002-04-09 15:43:32 +00:00
|
|
|
if (cmd == DIOCGFRONTSTUFF) {
|
|
|
|
*(off_t *)data = 8192; /* XXX: crude but enough) */
|
|
|
|
return (0);
|
|
|
|
}
|
1999-08-29 13:28:55 +00:00
|
|
|
error = dsioctl(dev, cmd, data, fflag, &dp->d_slice);
|
|
|
|
if (error == ENOIOCTL)
|
2001-09-12 08:38:13 +00:00
|
|
|
error = dp->d_devsw->d_ioctl(dev, cmd, data, fflag, td);
|
1999-08-29 13:28:55 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
diskpsize(dev_t dev)
|
|
|
|
{
|
|
|
|
struct disk *dp;
|
1999-09-01 05:38:09 +00:00
|
|
|
dev_t pdev;
|
1999-08-29 13:28:55 +00:00
|
|
|
|
End two weeks of on and off debugging. Fix the crash on the Nth
insertion of a CF card, for random values of N > 1. With these fixes,
I've been able to do 100 insert/remove of the cards w/o a crash with
lots of system activity going on that in the past would help trigger
the crash.
The problem:
FreeBSD creates dev_t's on the fly as they are needed and never
destroys them. These dev_t's point to a struct disk that is used for
housekeeping on the disk. When a device goes away, the struct disk
pointer becomes a dangling pointer. Sometimes when the device comes
back, the pointer will point to the new struct disk (in which case the
insertion will work). Other times it won't (especially if any length
of time has passed, since it is dependent on memory returned from
malloc).
The Fix:
There is one of these dev_t's that is always correct. The
device for the WHOLE_DISK_SLICE is always right. It gets set at
create_disk() time. So, the fix is to spend a little CPU time and
lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in
preference to the one that's in the device asking to do the I/O. In
addition, we change the test of si_disk == NULL meaning that the dev
needed to inherit properties from the pdev to dev->si_disk !=
pdev->si_disk. This test is a little stronger than the previous test,
but can sometimes be fooled into not inheriting. However, the results
of this fooling are that the old values will be used, which will
generally always be the same as before. si_drv[12] are the only
values that are copied that might pose a problem. They tend to change
as the si_disk field would change, so it is a hole, but it is a small
hole.
One could correctly argue that one should replace much of this code
with something much much better. I would be on the pro side of that
argument.
Reviewed by: phk (who also ported the original patch to current)
Sponsored by: Timing Solutions
2000-07-05 06:01:33 +00:00
|
|
|
pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
|
|
|
|
dp = pdev->si_disk;
|
|
|
|
if (!dp)
|
|
|
|
return (-1);
|
|
|
|
if (dp != dev->si_disk) {
|
1999-09-01 05:38:09 +00:00
|
|
|
dev->si_drv1 = pdev->si_drv1;
|
|
|
|
dev->si_drv2 = pdev->si_drv2;
|
|
|
|
/* XXX: don't set bp->b_dev->si_disk (?) */
|
|
|
|
}
|
1999-08-29 13:28:55 +00:00
|
|
|
return (dssize(dev, &dp->d_slice));
|
|
|
|
}
|
1999-09-09 19:08:44 +00:00
|
|
|
|
|
|
|
SYSCTL_INT(_debug_sizeof, OID_AUTO, disklabel, CTLFLAG_RD,
|
|
|
|
0, sizeof(struct disklabel), "sizeof(struct disklabel)");
|
|
|
|
|
|
|
|
SYSCTL_INT(_debug_sizeof, OID_AUTO, diskslices, CTLFLAG_RD,
|
|
|
|
0, sizeof(struct diskslices), "sizeof(struct diskslices)");
|
|
|
|
|
|
|
|
SYSCTL_INT(_debug_sizeof, OID_AUTO, disk, CTLFLAG_RD,
|
|
|
|
0, sizeof(struct disk), "sizeof(struct disk)");
|
2002-03-11 08:08:02 +00:00
|
|
|
|
|
|
|
#endif
|