summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2002-07-23 14:30:27 +0000
committerkan <kan@FreeBSD.org>2002-07-23 14:30:27 +0000
commit2eb7466905b2273cd96297ab464c37de31d5ba90 (patch)
tree15dbd878349d206939b994c68bae134399ca9206
parentaf83e99c432bb650b3f7b79ae80695fb414a2def (diff)
downloadFreeBSD-src-2eb7466905b2273cd96297ab464c37de31d5ba90.zip
FreeBSD-src-2eb7466905b2273cd96297ab464c37de31d5ba90.tar.gz
Fix DIOCGMEDIASIZE and DIOCGSECTORSIZE ioctls to work for all
disk devices. This fixes the problem with these ioctls returning EINVAL for plain slice devices with no disklabel on them. The patch incorporates improvements and style fixes from BDE. Reviewed by: bde Approved by: obrien (mentor)
-rw-r--r--sys/kern/subr_diskslice.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index ec6099e..06c207b 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -365,6 +365,12 @@ dsioctl(dev, cmd, data, flags, sspp)
lp = sp->ds_label;
switch (cmd) {
+ case DIOCGDINFO:
+ if (lp == NULL)
+ return (EINVAL);
+ *(struct disklabel *)data = *lp;
+ return (0);
+
case DIOCGDVIRGIN:
lp = (struct disklabel *)data;
if (ssp->dss_slices[WHOLE_DISK_SLICE].ds_label) {
@@ -398,23 +404,17 @@ dsioctl(dev, cmd, data, flags, sspp)
lp->d_checksum = dkcksum(lp);
return (0);
- case DIOCGDINFO:
+ case DIOCGMEDIASIZE:
if (lp == NULL)
- return (EINVAL);
- *(struct disklabel *)data = *lp;
+ *(off_t *)data = (off_t)sp->ds_size * ssp->dss_secsize;
+ else
+ *(off_t *)data =
+ (off_t)lp->d_partitions[dkpart(dev)].p_size *
+ lp->d_secsize;
return (0);
case DIOCGSECTORSIZE:
- if (lp == NULL)
- return (EINVAL);
- *(u_int *)data = lp->d_secsize;
- return (0);
-
- case DIOCGMEDIASIZE:
- if (lp == NULL)
- return (EINVAL);
- *(off_t *)data = (off_t)lp->d_partitions[dkpart(dev)].p_size *
- lp->d_secsize;
+ *(u_int *)data = ssp->dss_secsize;
return (0);
case DIOCGSLICEINFO:
OpenPOWER on IntegriCloud