From b06f6bdbb5bb759360a49d1a0d151859e26708d1 Mon Sep 17 00:00:00 2001 From: Dmitry Frolov Date: Tue, 28 Aug 2007 07:12:13 +0000 Subject: [PATCH] Fix chassis poh command: - The counter value was always interpreted as hours, the minutes-per-count value wasn't regarded. - No attention was paid to CPU endianness when reading the 32-bit counter value. Patch submitted by Ingo van Lil (inguin at users dot sourceforge dot net). Sourceforge patch ID: 1592950 --- ipmitool/lib/ipmi_chassis.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ipmitool/lib/ipmi_chassis.c b/ipmitool/lib/ipmi_chassis.c index 38c55c3..a8e6409 100644 --- a/ipmitool/lib/ipmi_chassis.c +++ b/ipmitool/lib/ipmi_chassis.c @@ -188,7 +188,10 @@ ipmi_chassis_poh(struct ipmi_intf * intf) { struct ipmi_rs * rsp; struct ipmi_rq req; + uint8_t mins_per_count; uint32_t count; + float minutes; + uint32_t days, hours; memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_CHASSIS; @@ -205,10 +208,24 @@ ipmi_chassis_poh(struct ipmi_intf * intf) return -1; } + mins_per_count = rsp->data[0]; memcpy(&count, rsp->data+1, 4); +#if WORDS_BIGENDIAN + count = BSWAP_32(count); +#endif - printf("POH Counter : %li hours total (%li days, %li hours)\n", - (long)count, (long)(count / 24), (long)(count % 24)); + minutes = (float)count * mins_per_count; + days = minutes / 1440; + minutes -= (float)days * 1440; + hours = minutes / 60; + minutes -= hours * 60; + + if (mins_per_count < 60) { + printf("POH Counter : %li days, %li hours, %li minutes\n", + days, hours, (long)minutes); + } else { + printf("POH Counter : %li days, %li hours\n", days, hours); + } return 0; }