diff options
author | Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de> | 2010-08-08 21:56:52 +0000 |
---|---|---|
committer | Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de> | 2010-08-08 21:56:52 +0000 |
commit | d9f266d1fb83fb0f5bffe470633a7127c23cee91 (patch) | |
tree | 74229e8407b335d23ebe8098156551f84bacfc80 /dmi.c | |
parent | 243ec633057e64e2f2538df9bb3847b323ece6a7 (diff) | |
download | flashrom-d9f266d1fb83fb0f5bffe470633a7127c23cee91.tar.gz flashrom-d9f266d1fb83fb0f5bffe470633a7127c23cee91.tar.bz2 flashrom-d9f266d1fb83fb0f5bffe470633a7127c23cee91.zip |
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.
Corresponding to flashrom svn r1136.
Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Sean Nelson <audiohacked@gmail.com>
Diffstat (limited to 'dmi.c')
-rw-r--r-- | dmi.c | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -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)) |