summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sesutil/sesutil.c
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-12-11 20:45:39 +0000
committerbapt <bapt@FreeBSD.org>2015-12-11 20:45:39 +0000
commite149088043e6c1193382e2af3cf0609faf851310 (patch)
tree251519af3d649ea5dc2952367b4c474152f04457 /usr.sbin/sesutil/sesutil.c
parent8d8726ea868dc8e8e2dbaf693c2933d8aecd6e40 (diff)
downloadFreeBSD-src-e149088043e6c1193382e2af3cf0609faf851310.zip
FreeBSD-src-e149088043e6c1193382e2af3cf0609faf851310.tar.gz
sesutil: Add extra information specific to some SES devices to sesutil map
Rework stat2ascii preparing a buffer of what could be printed. This prevent the risk of overflowing a static buffer. Do not print those informations anymore in the "status" but into a new "extra status" only printed if there are actually extra things to print. Now add those extra informations: * Thermal sensor temperature * Cooling devices speed * Voltage sensors, current consumption Tested by: AllanJude Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D4520
Diffstat (limited to 'usr.sbin/sesutil/sesutil.c')
-rw-r--r--usr.sbin/sesutil/sesutil.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.sbin/sesutil/sesutil.c b/usr.sbin/sesutil/sesutil.c
index 2913f28..2f2b529 100644
--- a/usr.sbin/sesutil/sesutil.c
+++ b/usr.sbin/sesutil/sesutil.c
@@ -31,6 +31,8 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/sbuf.h>
#include <err.h>
#include <errno.h>
@@ -299,6 +301,7 @@ fault(int argc, char **argv)
static int
objmap(int argc, char **argv __unused)
{
+ struct sbuf *extra;
encioc_elm_devnames_t e_devname;
encioc_elm_status_t e_status;
encioc_elm_desc_t e_desc;
@@ -391,8 +394,10 @@ objmap(int argc, char **argv __unused)
}
printf("\tElement %u, Type: %s\n", e_ptr[j].elm_idx,
geteltnm(e_ptr[j].elm_type));
- printf("\t\tStatus: %s\n",
- stat2ascii(e_ptr[j].elm_type, e_status.cstat));
+ printf("\t\tStatus: %s (0x%02x 0x%02x 0x%02x 0x%02x)\n",
+ scode2ascii(e_status.cstat[0]), e_status.cstat[0],
+ e_status.cstat[1], e_status.cstat[2],
+ e_status.cstat[3]);
if (e_desc.elm_desc_len > 0) {
printf("\t\tDescription: %s\n",
e_desc.elm_desc_str);
@@ -401,6 +406,12 @@ objmap(int argc, char **argv __unused)
printf("\t\tDevice Names: %s\n",
e_devname.elm_devnames);
}
+ extra = stat2sbuf(e_ptr[j].elm_type, e_status.cstat);
+ if (sbuf_len(extra) > 0) {
+ printf("\t\tExtra status:\n%s",
+ sbuf_data(extra));
+ }
+ sbuf_delete(extra);
free(e_devname.elm_devnames);
}
close(fd);
OpenPOWER on IntegriCloud