patched up to commit df9ebd5ffbe

Signed-off-by: Anton Arapov <arapov@gmail.com>
This commit is contained in:
Anton Arapov 2016-10-18 13:38:39 +02:00
parent 95bebcfa35
commit 32682d39c9
7 changed files with 278 additions and 16 deletions

View File

@ -0,0 +1,38 @@
From dcbff064744f8b7c0d53d6932d25708b4bb13b4f Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Fri, 22 Jul 2016 10:26:41 +0200
Subject: [PATCH 13/17] dmidecode: Clarify error message on table read failure
Stop using the term "unreachable" when the DMI table can't be read. It
originates from the /dev/mem access method, but no longer makes sense
when reading from sysfs or from a binary dump file.
Also don't suggest building with -DUSE_MMAP if reading from sysfs, as
it wouldn't help anyway.
---
dmidecode.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index 48d9e66..ffd916c 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4550,11 +4550,12 @@ static void dmi_table(off_t base, u32 len, u16 num, u16 ver, const char *devmem,
if (buf == NULL)
{
- fprintf(stderr, "Table is unreachable, sorry."
+ fprintf(stderr, "Failed to read table, sorry.\n");
#ifndef USE_MMAP
- " Try compiling dmidecode with -DUSE_MMAP."
+ if (!(flags & FLAG_NO_FILE_OFFSET))
+ fprintf(stderr,
+ "Try compiling dmidecode with -DUSE_MMAP.\n");
#endif
- "\n");
return;
}
--
2.7.4

View File

@ -0,0 +1,112 @@
From 74614633b31a2ac01240c72890722a86a3f3fc97 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Fri, 22 Jul 2016 10:26:50 +0200
Subject: [PATCH 14/17] dmidecode: Move error messages to stderr
Consistently write error messages to stderr, to avoid messing up the
output of "dmidecode -s". Based on preliminary patches by
Kevin Bowling and Simon Rettberg.
Fixes bug #47274:
https://savannah.nongnu.org/bugs/?47274
Fixes bug #48158:
https://savannah.nongnu.org/bugs/?48158
Supersedes patch #8989:
https://savannah.nongnu.org/patch/?8989
---
dmidecode.c | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index ffd916c..f56d0c5 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2958,7 +2958,8 @@ static void dmi_fixup_type_34(struct dmi_header *h, int display)
&& is_printable(p + 0x0B, 0x10 - 0x0B))
{
if (!(opt.flags & FLAG_QUIET) && display)
- printf("Invalid entry length (%u). Fixed up to %u.\n",
+ fprintf(stderr,
+ "Invalid entry length (%u). Fixed up to %u.\n",
0x10, 0x0B);
h->length = 0x0B;
}
@@ -4427,9 +4428,14 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
*/
if (h.length < 4)
{
- printf("Invalid entry length (%u). DMI table is "
- "broken! Stop.\n\n", (unsigned int)h.length);
- opt.flags |= FLAG_QUIET;
+ if (!(opt.flags & FLAG_QUIET))
+ {
+ fprintf(stderr,
+ "Invalid entry length (%u). DMI table "
+ "is broken! Stop.\n\n",
+ (unsigned int)h.length);
+ opt.flags |= FLAG_QUIET;
+ }
break;
}
@@ -4490,11 +4496,11 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
if (!(opt.flags & FLAG_QUIET))
{
if (num && i != num)
- printf("Wrong DMI structures count: %d announced, "
+ fprintf(stderr, "Wrong DMI structures count: %d announced, "
"only %d decoded.\n", num, i);
if ((unsigned long)(data - buf) > len
|| (num && (unsigned long)(data - buf) < len))
- printf("Wrong DMI structures length: %u bytes "
+ fprintf(stderr, "Wrong DMI structures length: %u bytes "
"announced, structures occupy %lu bytes.\n",
len, (unsigned long)(data - buf));
}
@@ -4539,7 +4545,7 @@ static void dmi_table(off_t base, u32 len, u16 num, u16 ver, const char *devmem,
buf = read_file(&size, devmem);
if (!(opt.flags & FLAG_QUIET) && num && size != (size_t)len)
{
- printf("Wrong DMI structures length: %u bytes "
+ fprintf(stderr, "Wrong DMI structures length: %u bytes "
"announced, only %lu bytes available.\n",
len, (unsigned long)size);
}
@@ -4652,14 +4658,16 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
case 0x021F:
case 0x0221:
if (!(opt.flags & FLAG_QUIET))
- printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
- ver & 0xFF, 3);
+ fprintf(stderr,
+ "SMBIOS version fixup (2.%d -> 2.%d).\n",
+ ver & 0xFF, 3);
ver = 0x0203;
break;
case 0x0233:
if (!(opt.flags & FLAG_QUIET))
- printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
- 51, 6);
+ fprintf(stderr,
+ "SMBIOS version fixup (2.%d -> 2.%d).\n",
+ 51, 6);
ver = 0x0206;
break;
}
@@ -4771,6 +4779,13 @@ int main(int argc, char * const argv[])
int efi;
u8 *buf;
+ /*
+ * We don't want stdout and stderr to be mixed up if both are
+ * redirected to the same file.
+ */
+ setlinebuf(stdout);
+ setlinebuf(stderr);
+
if (sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4 || '\0' != 0)
{
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
--
2.7.4

View File

@ -0,0 +1,30 @@
From 5696fa33e5f9fce843fa3b5972b87a705fed2067 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 7 Sep 2016 22:16:16 +0200
Subject: [PATCH 15/17] Clarify a comment in dmi_memory_device_extended_size
Improve the comment to avoid the confusion as reported in bug #48723:
http://savannah.nongnu.org/bugs/?48723
---
dmidecode.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dmidecode.c b/dmidecode.c
index f56d0c5..f929b28 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2277,7 +2277,10 @@ static void dmi_memory_device_extended_size(u32 code)
{
code &= 0x7FFFFFFFUL;
- /* Use the most suitable unit depending on size */
+ /*
+ * Use the greatest unit for which the exact value can be displayed
+ * as an integer without rounding
+ */
if (code & 0x3FFUL)
printf(" %lu MB", (unsigned long)code);
else if (code & 0xFFFFFUL)
--
2.7.4

View File

@ -0,0 +1,31 @@
From 0b5c47c64b6fb3b626c5f75d9dc36bc864907fca Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 7 Sep 2016 22:16:20 +0200
Subject: [PATCH 16/17] Prevent static code analyzer confusion
As reported in bug #48723:
http://savannah.nongnu.org/bugs/?48723
This is a false positive and the static code analyzer output should
be made clearer. Nevertheless we can write the code differently so
that it doesn't trigger a warning.
---
dmidecode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmidecode.c b/dmidecode.c
index f929b28..3993592 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2283,7 +2283,7 @@ static void dmi_memory_device_extended_size(u32 code)
*/
if (code & 0x3FFUL)
printf(" %lu MB", (unsigned long)code);
- else if (code & 0xFFFFFUL)
+ else if (code & 0xFFC00UL)
printf(" %lu GB", (unsigned long)code >> 10);
else
printf(" %lu TB", (unsigned long)code >> 20);
--
2.7.4

View File

@ -0,0 +1,50 @@
From df9ebd5ffbe039550ca4f9d5075db09aa7dd2bfe Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Thu, 22 Sep 2016 17:59:09 +0200
Subject: [PATCH 17/17] Cygwin is no longer supported
---
CHANGELOG | 4 ++++
README | 7 +++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ebae4b3..ac748b0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2016-09-22 Jean Delvare <jdelvare@suse.de>
+
+ * README: Explain that we can no longer support Cygwin.
+
2016-06-30 Petr Oros <poros@redhat.com>
* dmidecode.c: Unmask LRDIMM in memory type detail (DMI type 17).
diff --git a/README b/README
index 391a5cb..f612b36 100644
--- a/README
+++ b/README
@@ -28,7 +28,7 @@ and other interesting material, such as a list of related projects and
articles.
This program was first written for Linux, and has since been reported to work
-on FreeBSD, NetBSD, OpenBSD, BeOS, Cygwin and Solaris as well.
+on FreeBSD, NetBSD, OpenBSD, BeOS and Solaris as well.
There's no configure script, so simply run "make" to build dmidecode, and
"make install" to install it. You also can use "make uninstall" to remove
@@ -83,9 +83,8 @@ successfully run.
CYGWIN
-Dmidecode was reported to work under Cygwin. It seems that /dev/mem doesn't
-work properly before version 1.5.10 though, so you will need to use at least
-this version.
+Dmidecode used to work under Cygwin. However the /dev/mem interface was
+removed at some point in time so it no longer works.
** MISCELLANEOUS TOOLS **
--
2.7.4

View File

@ -1,12 +0,0 @@
diff -up dmidecode-3.0/dmidecode.c.unmask_lrdimm dmidecode-3.0/dmidecode.c
--- dmidecode-3.0/dmidecode.c.unmask_lrdimm 2016-06-29 13:44:05.987255690 +0200
+++ dmidecode-3.0/dmidecode.c 2016-06-29 13:44:15.003150517 +0200
@@ -2392,7 +2392,7 @@ static void dmi_memory_device_type_detai
"LRDIMM" /* 15 */
};
- if ((code & 0x7FFE) == 0)
+ if ((code & 0xFFFE) == 0)
printf(" None");
else
{

View File

@ -1,7 +1,7 @@
Summary: Tool to analyse BIOS DMI data
Name: dmidecode
Version: 3.0
Release: 5%{?dist}
Release: 6%{?dist}
Epoch: 1
Group: System Environment/Base
License: GPLv2+
@ -16,9 +16,14 @@ Patch6: 0006-dmidecode-Introduce-SYS_FIRMWARE_DIR.patch
Patch7: 0007-Let-read_file-return-the-actual-data-size.patch
Patch8: 0008-dmidecode-Use-read_file-to-read-the-DMI-table-from-s.patch
Patch9: 0009-dmidecode-Check-sysfs-entry-point-length.patch
Patch10: 0010-Use-DWORD-for-Structure-table-maximum-size-in-SMBIOS.patch
Patch11: 0011-dmidecode-Hide-irrelevant-fixup-message.patch
Patch12: 0012-dmidecode-Unmask-LRDIMM-in-memory-type-detail.patch
Patch10: 0010-Use-DWORD-for-Structure-table-maximum-size-in-SMBIOS.patch
Patch11: 0011-dmidecode-Hide-irrelevant-fixup-message.patch
Patch12: 0012-dmidecode-Unmask-LRDIMM-in-memory-type-detail.patch
Patch13: 0013-dmidecode-Clarify-error-message-on-table-read-failur.patch
Patch14: 0014-dmidecode-Move-error-messages-to-stderr.patch
Patch15: 0015-Clarify-a-comment-in-dmi_memory_device_extended_size.patch
Patch16: 0016-Prevent-static-code-analyzer-confusion.patch
Patch17: 0017-Cygwin-is-no-longer-supported.patch
BuildRequires: automake autoconf
ExclusiveArch: %{ix86} x86_64 ia64 aarch64
@ -47,6 +52,11 @@ I/O ports (e.g. serial, parallel, USB).
%patch10 -p1 -b .dword
%patch11 -p1 -b .hide_fixup_msg
%patch12 -p1 -b .unmask_lrdimm
%patch13 -p1 -b .clarify_error
%patch14 -p1 -b .stderr
%patch15 -p1 -b .clarify_comment
%patch16 -p1 -b .no_confusion
%patch17 -p1 -b .no_cygwin
%build
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS"
@ -67,6 +77,9 @@ make %{?_smp_mflags} DESTDIR=%{buildroot} prefix=%{_prefix} install-bin install-
%{_mandir}/man8/*
%changelog
* Tue Oct 18 2016 Anton Arapov <aarapov@redhat.com> - 1:3.0-6
- patched up to commit df9ebd5ffbe
* Thu Jul 07 2016 Anton Arapov <arapov@gmail.com> - 1:3.0-5
- patched up to commit a50565a65c9