summaryrefslogtreecommitdiff
path: root/sbin/atactl/atactl.c
diff options
context:
space:
mode:
authorAlexander Yurchenko <grange@cvs.openbsd.org>2003-07-10 17:43:00 +0000
committerAlexander Yurchenko <grange@cvs.openbsd.org>2003-07-10 17:43:00 +0000
commit6c03ed6f224b82b80e36b3768494bc441b4906aa (patch)
tree105bf6db2104339761cea48d3c9a3559181d3d7a /sbin/atactl/atactl.c
parent88ae4dea2b26c6ff7f11321fd139b96b7638da55 (diff)
Properly determine the capacity for LBA48 drives and also remove
the check for obsoleted bits in the identify word 0 since some drives put garbage there. Tested by Peter Galbavy <peter.galbavy@knowtion.net> and avsm@.
Diffstat (limited to 'sbin/atactl/atactl.c')
-rw-r--r--sbin/atactl/atactl.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/sbin/atactl/atactl.c b/sbin/atactl/atactl.c
index 620a9e2f1f7..a22c1285193 100644
--- a/sbin/atactl/atactl.c
+++ b/sbin/atactl/atactl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atactl.c,v 1.28 2003/06/11 06:22:12 deraadt Exp $ */
+/* $OpenBSD: atactl.c,v 1.29 2003/07/10 17:42:59 grange Exp $ */
/* $NetBSD: atactl.c,v 1.4 1999/02/24 18:49:14 jwise Exp $ */
/*-
@@ -505,6 +505,7 @@ device_identify(int argc, char *argv[])
struct ataparams *inqbuf;
struct atareq req;
char inbuf[DEV_BSIZE], *s;
+ u_int64_t capacity;
if (argc != 1)
goto usage;
@@ -566,12 +567,17 @@ device_identify(int argc, char *argv[])
"ATAPI" : "ATA", inqbuf->atap_config & ATA_CFG_FIXED ? "fixed" :
"removable");
- if ((inqbuf->atap_config & WDC_CFG_ATAPI_MASK) == 0)
- printf("Cylinders: %d, heads: %d, sec/track: %d, total "
- "sectors: %d\n", inqbuf->atap_cylinders,
- inqbuf->atap_heads, inqbuf->atap_sectors,
- (inqbuf->atap_capacity[1] << 16) |
- inqbuf->atap_capacity[0]);
+ if (inqbuf->atap_cmd2_en & ATAPI_CMD2_48AD)
+ capacity = ((u_int64_t)inqbuf->atap_max_lba[3] << 48) |
+ ((u_int64_t)inqbuf->atap_max_lba[2] << 32) |
+ ((u_int64_t)inqbuf->atap_max_lba[1] << 16) |
+ (u_int64_t)inqbuf->atap_max_lba[0];
+ else
+ capacity = (inqbuf->atap_capacity[1] << 16) |
+ inqbuf->atap_capacity[0];
+ printf("Cylinders: %d, heads: %d, sec/track: %d, total "
+ "sectors: %llu\n", inqbuf->atap_cylinders,
+ inqbuf->atap_heads, inqbuf->atap_sectors, capacity);
if ((inqbuf->atap_cmd_set2 & ATA_CMD2_RWQ) &&
(inqbuf->atap_queuedepth & WDC_QUEUE_DEPTH_MASK))