Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136861645
D4520.id11145.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D4520.id11145.diff
View Options
Index: head/usr.sbin/sesutil/Makefile
===================================================================
--- head/usr.sbin/sesutil/Makefile
+++ head/usr.sbin/sesutil/Makefile
@@ -4,4 +4,6 @@
SRCS= sesutil.c eltsub.c
MAN= sesutil.8
+LIBADD= sbuf
+
.include <bsd.prog.mk>
Index: head/usr.sbin/sesutil/eltsub.h
===================================================================
--- head/usr.sbin/sesutil/eltsub.h
+++ head/usr.sbin/sesutil/eltsub.h
@@ -32,5 +32,6 @@
* mjacob@feral.com
*/
-char * geteltnm(int);
-char * stat2ascii(int, u_char *);
+char *geteltnm(int);
+char *scode2ascii(u_char);
+struct sbuf *stat2sbuf(int, u_char *);
Index: head/usr.sbin/sesutil/eltsub.c
===================================================================
--- head/usr.sbin/sesutil/eltsub.c
+++ head/usr.sbin/sesutil/eltsub.c
@@ -32,6 +32,11 @@
* mjacob@feral.com
*/
+#include <sys/endian.h>
+#include <sys/types.h>
+#include <sys/sbuf.h>
+
+#include <err.h>
#include <unistd.h>
#include <stddef.h>
#include <stdint.h>
@@ -43,6 +48,13 @@
#include "eltsub.h"
+/*
+ * offset by +20 degrees.
+ * The range of the value expresses a temperature between -19 and +235 degrees
+ * Celsius. A value of 00h is reserved.
+ */
+#define TEMPERATURE_OFFSET 20
+
char *
geteltnm(int type)
{
@@ -134,7 +146,7 @@
return (rbuf);
}
-static char *
+char *
scode2ascii(u_char code)
{
static char rbuf[32];
@@ -173,22 +185,51 @@
return (rbuf);
}
-
-char *
-stat2ascii(int eletype, u_char *cstat)
+struct sbuf *
+stat2sbuf(int eletype, u_char *cstat)
{
- static char ebuf[256], *scode;
+ struct sbuf *buf;
- scode = scode2ascii(cstat[0]);
- sprintf(ebuf, "%s%s%s%s%s%s (0x%02x 0x%02x 0x%02x 0x%02x)",
- scode,
- (cstat[0] & 0x40) ? ", Prd.Fail" : "",
- (cstat[0] & 0x20) ? ", Disabled" : "",
- (cstat[0] & 0x10) ? ", Swapped" : "",
- ((eletype == ELMTYP_DEVICE || eletype == ELMTYP_ARRAY_DEV)
- && (cstat[2] & 0x02)) ? ", LED=Locate" : "",
- ((eletype == ELMTYP_DEVICE || eletype == ELMTYP_ARRAY_DEV)
- && (cstat[3] & 0x20)) ? ", LED=Fault" : "",
- cstat[0], cstat[1], cstat[2], cstat[3]);
- return (ebuf);
+ buf = sbuf_new_auto();
+ if (buf == NULL)
+ err(EXIT_FAILURE, "sbuf_new_auto()");
+
+ if (cstat[0] & 0x40)
+ sbuf_printf(buf, "\t\t- Predicted Failure\n");
+ if (cstat[0] & 0x20)
+ sbuf_printf(buf, "\t\t- Disabled\n");
+ if (cstat[0] & 0x10)
+ sbuf_printf(buf, "\t\t- Swapped\n");
+ switch (eletype) {
+ case ELMTYP_DEVICE:
+ if (cstat[2] & 0x02)
+ sbuf_printf(buf, "\t\t- LED=locate\n");
+ if (cstat[2] & 0x20)
+ sbuf_printf(buf, "\t\t- LED=fault\n");
+ break;
+ case ELMTYP_ARRAY_DEV:
+ if (cstat[2] & 0x02)
+ sbuf_printf(buf, "\t\t- LED=locate\n");
+ if (cstat[2] & 0x20)
+ sbuf_printf(buf, "\t\t- LED=fault\n");
+ break;
+ case ELMTYP_FAN:
+ sbuf_printf(buf, "\t\t- Speed: %d rpm\n",
+ (((0x7 & cstat[1]) << 8) + cstat[2]) * 10);
+ break;
+ case ELMTYP_THERM:
+ if (cstat[2]) {
+ sbuf_printf(buf, "\t\t- Temperature: %d C\n",
+ cstat[2] - TEMPERATURE_OFFSET);
+ } else {
+ sbuf_printf(buf, "\t\t- Temperature: -reserved-\n");
+ }
+ break;
+ case ELMTYP_VOM:
+ sbuf_printf(buf, "\t\t- Voltage: %.2f V\n",
+ be16dec(cstat + 2) / 100.0);
+ break;
+ }
+ sbuf_finish(buf);
+ return (buf);
}
Index: head/usr.sbin/sesutil/sesutil.c
===================================================================
--- head/usr.sbin/sesutil/sesutil.c
+++ head/usr.sbin/sesutil/sesutil.c
@@ -31,6 +31,8 @@
#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 @@
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 @@
}
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 @@
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);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 21, 4:57 AM (7 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25715843
Default Alt Text
D4520.id11145.diff (4 KB)
Attached To
Mode
D4520: sesutil: Add extra information specific to some SES devices
Attached
Detach File
Event Timeline
Log In to Comment