Hi all,

the following avoids printing bad information on SEL usage based on the fact 
that the Get SEL Info Command bytes 5 and 6 returns: "Free Space in bytes, LS 
Byte first. FFFFh indicates 65535 or more bytes of free space are available."

Therefore is someone implements a SEL larger than 4095 entries, the percent 
used can be displayed at  > 100% ... which is wrong.

Whenever 'total space' if >= 65535, the percentage can't be safely determined.

I took the liberty to commit that patch. If anyone disagrees, I'll be glad to 
ear your point.

Thank you.


cvs diff -u ipmi_sel.c
[EMAIL PROTECTED]'s password:
Index: ipmi_sel.c
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/lib/ipmi_sel.c,v
retrieving revision 1.72
diff -u -r1.72 ipmi_sel.c
--- ipmi_sel.c  9 Jul 2008 05:55:55 -0000       1.72
+++ ipmi_sel.c  13 Aug 2008 19:22:58 -0000
@@ -666,7 +666,8 @@
 {
        struct ipmi_rs * rsp;
        struct ipmi_rq req;
-       uint16_t e, f, version;
+       uint16_t e, version;
+       uint32_t f;
        int pctfull = 0;
        uint32_t fs    = 0xffffffff;
        uint32_t zeros = 0;
@@ -699,13 +700,20 @@
        e = buf2short(rsp->data + 1);
        f = buf2short(rsp->data + 3);
        printf("Entries          : %d\n", e);
-       printf("Free Space       : %d bytes\n", f);
+       printf("Free Space       : %d bytes %s\n", f ,(f==65535 ? "or more" : 
"" ));
+
        if (e) {
-               e *= 16;
-               f += e;
+               e *= 16; /* each entry takes 16 bytes */
+               f += e; /* this is supposed to give the total size ... */
                pctfull = (int)(100 * ( (double)e / (double)f ));
        }
-       printf("Percent Used     : %d%%\n", pctfull);
+
+       if( f >= 65535 ) {
+               printf("Percent Used     : %s\n", "unknown" );
+       }
+       else {
+               printf("Percent Used     : %d%%\n", pctfull);
+       }


        if ((!memcmp(rsp->data + 5, &fs,    4)) ||

Francois Isabelle


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to