summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-06-24 23:39:19 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-06-24 23:39:19 +0000
commit7645d8719066da9c93c15efccca524202a95a8b4 (patch)
tree8fab41a6993214960cec155127577949db580f81 /sys/scsi
parent629efbaa10eb82b87a75346532c01ca6ca93321b (diff)
Fix botch introduced in r1.12. reduced_geometry.sectors is a 5 byte
field, with reduced_geometry.sectors[0] not being sectors/track. Add _5btol() to correctly parse entire field. From NetBSD.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsiconf.h17
-rw-r--r--sys/scsi/sd_scsi.c7
2 files changed, 19 insertions, 5 deletions
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index b593faaefe8..0a998bbc536 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.h,v 1.59 2005/06/23 00:31:44 krw Exp $ */
+/* $OpenBSD: scsiconf.h,v 1.60 2005/06/24 23:39:18 krw Exp $ */
/* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */
/*
@@ -367,6 +367,7 @@ static __inline void _lto8b(u_int64_t val, u_int8_t *bytes);
static __inline u_int32_t _2btol(u_int8_t *bytes);
static __inline u_int32_t _3btol(u_int8_t *bytes);
static __inline u_int32_t _4btol(u_int8_t *bytes);
+static __inline u_int64_t _5btol(u_int8_t *bytes);
static __inline u_int64_t _8btol(u_int8_t *bytes);
static __inline void _lto2l(u_int32_t val, u_int8_t *bytes);
@@ -457,6 +458,20 @@ _4btol(bytes)
}
static __inline u_int64_t
+_5btol(bytes)
+ u_int8_t *bytes;
+{
+ u_int64_t rv;
+
+ rv = ((u_int64_t)bytes[0] << 32) |
+ ((u_int64_t)bytes[1] << 24) |
+ ((u_int64_t)bytes[2] << 16) |
+ ((u_int64_t)bytes[3] << 8) |
+ (u_int64_t)bytes[4];
+ return (rv);
+}
+
+static __inline u_int64_t
_8btol(bytes)
u_int8_t *bytes;
{
diff --git a/sys/scsi/sd_scsi.c b/sys/scsi/sd_scsi.c
index 1ae01cb00c7..dfb86d6896e 100644
--- a/sys/scsi/sd_scsi.c
+++ b/sys/scsi/sd_scsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd_scsi.c,v 1.20 2005/06/24 21:03:36 krw Exp $ */
+/* $OpenBSD: sd_scsi.c,v 1.21 2005/06/24 23:39:18 krw Exp $ */
/* $NetBSD: sd_scsi.c,v 1.8 1998/10/08 20:21:13 thorpej Exp $ */
/*-
@@ -172,12 +172,11 @@ sd_scsibus_get_parms(sd, dp, flags)
dp->sectors = 32;
if (sense_pages) {
if (dp->disksize == 0)
- dp->disksize = _4btol(sense_pages->
- reduced_geometry.sectors+1);
+ dp->disksize = _5btol(sense_pages->
+ reduced_geometry.sectors);
if (blksize == 0)
blksize = _2btol(sense_pages->
reduced_geometry.bytes_s);
- dp->sectors = sense_pages->reduced_geometry.sectors[0];
}
dp->blksize = (blksize == 0) ? 512 : blksize;