Author: mkarcher
Date: Sun Aug  8 23:56:52 2010
New Revision: 1136
URL: http://flashrom.org/trac/coreboot/changeset/1136

Log:
Add dmidecode quirk workaround

dmidecode emits a warning message about unsupported SMBIOS versions
to stdout before the information asked for when using "-s". I consider
this behaviour broken, but we still need to workaround it as e.g. Fedora
currently distributes an dmidecode with this behaviour.

Signed-off-by: Michael Karcher <[email protected]>
Acked-by: Sean Nelson <[email protected]>

Modified:
   trunk/dmi.c

Modified: trunk/dmi.c
==============================================================================
--- trunk/dmi.c Sun Aug  8 19:04:21 2010        (r1135)
+++ trunk/dmi.c Sun Aug  8 23:56:52 2010        (r1136)
@@ -76,15 +76,24 @@
                msg_perr("DMI pipe open error\n");
                return NULL;
        }
-       if (!fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe)) {
-               if(ferror(dmidecode_pipe)) {
-                       msg_perr("DMI pipe read error\n");
-                       pclose(dmidecode_pipe);
-                       return NULL;
-               } else {
-                       answerbuf[0] = 0;       /* Hit EOF */
+
+       /* Kill lines starting with '#', as recent dmidecode versions
+          have the quirk to emit a "# SMBIOS implementations newer..."
+          message even on "-s" if the SMBIOS declares a
+          newer-than-supported version number, while it *should* only print
+          the requested string. */
+       do {
+               if (!fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe)) {
+                       if(ferror(dmidecode_pipe)) {
+                               msg_perr("DMI pipe read error\n");
+                               pclose(dmidecode_pipe);
+                               return NULL;
+                       } else {
+                               answerbuf[0] = 0;       /* Hit EOF */
+                       }
                }
-       }
+       } while(answerbuf[0] == '#');
+
        /* Toss all output above DMI_MAX_ANSWER_LEN away to prevent
           deadlock on pclose. */
        while (!feof(dmidecode_pipe))

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to