summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorrpokala <rpokala@FreeBSD.org>2016-01-14 21:52:21 +0000
committerrpokala <rpokala@FreeBSD.org>2016-01-14 21:52:21 +0000
commitb44c9b27614b4dd0f17257fca26ff654d074a0b9 (patch)
tree118ac12d56dc5896989cb740607d4796fc0783b1 /sys/geom
parent456702a99280b5064d45a9b2ecdadfc5d95659f9 (diff)
downloadFreeBSD-src-b44c9b27614b4dd0f17257fca26ff654d074a0b9.zip
FreeBSD-src-b44c9b27614b4dd0f17257fca26ff654d074a0b9.tar.gz
Add rotationrate to geom disk dumpconf
Parse and report the nominal rotation rate reported by the drive. Reviewed by: sbruno, jhb Approved by: jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D4483 Requested by: Kevin Bowling < kevin.bowling @ kev009.com >
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom_disk.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 1943430..afd1fde 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -549,6 +549,23 @@ g_disk_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g
indent, dp->d_fwheads);
sbuf_printf(sb, "%s<fwsectors>%u</fwsectors>\n",
indent, dp->d_fwsectors);
+
+ /*
+ * "rotationrate" is a little complicated, because the value
+ * returned by the drive might not be the RPM; 0 and 1 are
+ * special cases, and there's also a valid range.
+ */
+ sbuf_printf(sb, "%s<rotationrate>", indent);
+ if (dp->d_rotation_rate == 0) /* Old drives don't */
+ sbuf_printf(sb, "unknown"); /* report RPM. */
+ else if (dp->d_rotation_rate == 1) /* Since 0 is used */
+ sbuf_printf(sb, "0"); /* above, SSDs use 1. */
+ else if ((dp->d_rotation_rate >= 0x041) &&
+ (dp->d_rotation_rate <= 0xfffe))
+ sbuf_printf(sb, "%u", dp->d_rotation_rate);
+ else
+ sbuf_printf(sb, "invalid");
+ sbuf_printf(sb, "</rotationrate>\n");
if (dp->d_getattr != NULL) {
buf = g_malloc(DISK_IDENT_SIZE, M_WAITOK);
bp = g_alloc_bio();
OpenPOWER on IntegriCloud