Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS-6422 diskinfo should be able to list disk firmware revision #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 48 additions & 19 deletions usr/src/cmd/diskinfo/diskinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

/*
* Copyright (c) 2013 Joyent Inc., All rights reserved.
* Copyright (c) 2017, Joyent, Inc.
*/

#include <sys/types.h>
Expand All @@ -37,6 +37,28 @@
#include <sys/fm/protocol.h>
#include <modules/common/disk/disk.h>

/*
* The default output with no flags specified.
* TYPE, DISK, VID, PID, SIZE, RMV, SSD
*/
#define FMT_DEFAULT "%-7s %-22s %-8s %-20s %-13s %-3s %-3s\n"
#define FMT_DEFAULT_PARSABLE "%s\t%s\t%s\t%s\t%s\t%s\t%s\n"

/*
* Condensed (compact) output. Lines kept to 80 columns with newlines where
* they are necessary.
* TYPE, DISK, VID, PID, SERIAL, \n REV, SIZE, FLRS, LOCATION
*/
#define FMT_CONDENSED "%-7s %-22s %-8s %-20s %-16s\n\t%-8s %-13s %-4s %s\n"
#define FMT_CONDENSED_PARSABLE "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"

/*
* Physical output mode.
* DISK, VID, PID, SERIAL, REV, FLT, LOC, LOCATION
*/
#define FMT_PHYSICAL "%-22s %-8s %-20s %-16s %-8s %-3s %-3s %s\n"
#define FMT_PHYSICAL_PARSABLE "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"

typedef struct di_opts {
boolean_t di_scripted;
boolean_t di_parseable;
Expand All @@ -47,6 +69,7 @@ typedef struct di_opts {
typedef struct di_phys {
const char *dp_dev;
const char *dp_serial;
const char *dp_fwrev;
const char *dp_slotname;
int dp_chassis;
int dp_slot;
Expand Down Expand Up @@ -117,7 +140,7 @@ disk_walker(topo_hdl_t *hp, tnode_t *np, void *arg)
int err;
topo_led_state_t mode;
topo_led_type_t type;
char *name, *slotname, *serial;
char *name, *slotname, *serial, *fwrev;

if (strcmp(topo_node_name(np), DISK) != 0)
return (TOPO_WALK_NEXT);
Expand All @@ -135,6 +158,11 @@ disk_walker(topo_hdl_t *hp, tnode_t *np, void *arg)
pp->dp_serial = serial;
}

if (topo_prop_get_string(np, TOPO_PGROUP_STORAGE,
TOPO_STORAGE_FIRMWARE_REV, &fwrev, &err) == 0) {
pp->dp_fwrev = fwrev;
}

pnp = topo_node_parent(np);
ppnp = topo_node_parent(pnp);
if (strcmp(topo_node_name(pnp), BAY) == 0) {
Expand Down Expand Up @@ -345,41 +373,42 @@ enumerate_disks(di_opts_t *opts)

if (opts->di_physical) {
if (opts->di_scripted) {
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
printf(FMT_PHYSICAL_PARSABLE,
device, vid, pid,
display_string(phys.dp_serial),
display_string(phys.dp_fwrev),
display_tristate(phys.dp_faulty),
display_tristate(phys.dp_locate), slotname);
} else {
printf("%-22s %-8s %-16s "
"%-20s %-3s %-3s %s\n",
printf(FMT_PHYSICAL,
device, vid, pid,
display_string(phys.dp_serial),
display_string(phys.dp_fwrev),
display_tristate(phys.dp_faulty),
display_tristate(phys.dp_locate), slotname);
}
} else if (opts->di_condensed) {
if (opts->di_scripted) {
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
printf(FMT_CONDENSED_PARSABLE,
ctype, device, vid, pid,
display_string(phys.dp_serial),
display_string(phys.dp_fwrev),
sizestr, statestr, slotname);
} else {
printf("%-7s %-22s %-8s %-16s "
"%-20s\n\t%-13s %-4s %s\n",
printf(FMT_CONDENSED,
ctype, device, vid, pid,
display_string(phys.dp_serial),
display_string(phys.dp_fwrev),
sizestr, statestr, slotname);
}
} else {
if (opts->di_scripted) {
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
printf(FMT_DEFAULT_PARSABLE,
ctype, device, vid, pid, sizestr,
display_tristate(removable),
display_tristate(ssd));
} else {
printf("%-7s %-22s %-8s %-16s "
"%-13s %-3s %-3s\n", ctype, device,
printf(FMT_DEFAULT, ctype, device,
vid, pid, sizestr,
display_tristate(removable),
display_tristate(ssd));
Expand Down Expand Up @@ -442,16 +471,16 @@ main(int argc, char *argv[])

if (!opts.di_scripted) {
if (opts.di_physical) {
printf("DISK VID PID"
" SERIAL FLT LOC"
" LOCATION\n");
printf(FMT_PHYSICAL,
"DISK", "VID", "PID", "SERIAL", "REV",
"FLT", "LOC", "LOCATION");
} else if (opts.di_condensed) {
printf("TYPE DISK VID PID"
" SERIAL\n");
printf("\tSIZE FLRS LOCATION\n");
printf(FMT_CONDENSED,
"TYPE", "DISK", "VID", "PID", "SERIAL",
"REV", "SIZE", "FLRS", "LOCATION");
} else {
printf("TYPE DISK VID PID"
" SIZE RMV SSD\n");
printf(FMT_DEFAULT, "TYPE", "DISK", "VID", "PID",
"SIZE", "RMV", "SSD");
}
}

Expand Down
9 changes: 6 additions & 3 deletions usr/src/man/man1m/diskinfo.1m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
.\" source. A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\" Copyright 2014 Joyent, Inc.
.\" Copyright 2017 Joyent, Inc.
.\" Copyright 2016 Nexenta Systems, Inc.
.\"
.Dd July 20, 2016
.Dd November 22, 2017
.Dt DISKINFO 1M
.Os
.Sh NAME
Expand Down Expand Up @@ -48,7 +48,8 @@ In this mode, each line of output likewise describes one disk device; however,
the fields provided indicate the base name of the device in the
.Pa /dev/dsk
directory, the disk's vendor and product identification strings, the serial
number of the device, whether the device is faulty as diagnosed by
number of the device, its firmware revision, whether the device is faulty
as diagnosed by
.Xr fmd 1M ,
whether the locate or identification indicator is on for the device
.Pq if one is present ,
Expand Down Expand Up @@ -160,6 +161,8 @@ The serial number of the device.
The entire serial number is reported if the device and its drivers provide it.
.Pp
This field is available in compact and physical output modes.
.It Sy REV
The firmware revision of the device.
.It Sy SIZE
The device's storage capacity.
If the
Expand Down