summaryrefslogtreecommitdiff
path: root/dmi.c
diff options
context:
space:
mode:
authormkarcher <mkarcher@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-08-08 21:56:52 +0000
committermkarcher <mkarcher@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-08-08 21:56:52 +0000
commitcfff09c022c501d0dbe6167bb2f72fd8307392b4 (patch)
tree74229e8407b335d23ebe8098156551f84bacfc80 /dmi.c
parentc32b60fea6f8e52a4f8c08e930be6ecc035f5a72 (diff)
downloadflashrom-cfff09c022c501d0dbe6167bb2f72fd8307392b4.tar.gz
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 <flashrom@mkarcher.dialup.fu-berlin.de> Acked-by: Sean Nelson <audiohacked@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1136 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'dmi.c')
-rw-r--r--dmi.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/dmi.c b/dmi.c
index cf459ec..f18907f 100644
--- a/dmi.c
+++ b/dmi.c
@@ -76,15 +76,24 @@ static char *get_dmi_string(const char *string_name)
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))