From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [PATCH] dmidecode: update to version 3.1 Date: Sat, 20 Jan 2018 14:36:51 +0000 Message-ID: <1516459011.3647.167.camel@ipfire.org> In-Reply-To: <20180119175746.874-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5204773130044377163==" List-Id: --===============5204773130044377163== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Thanks, merged! On Fri, 2018-01-19 at 18:57 +0100, Jonatan Schlag wrote: > The removed patches are included in this version so there is no need > that we apply them. >=20 > Signed-off-by: Jonatan Schlag > --- > lfs/dmidecode | 8 +-- > ...d-no-sysfs-option-description-to-h-output.patch | 15 ---- > ...BIOS-nor-DMI-entry-point-found-on-SMBIOS3.patch | 26 ------- > ...Let-read_file-return-the-actual-data-size.patch | 84 ------------------- > --- > ...se-read_file-to-read-the-DMI-table-from-s.patch | 72 ------------------- > 5 files changed, 2 insertions(+), 203 deletions(-) > delete mode 100644 src/patches/dmidecode/0001-Add-no-sysfs-option- > description-to-h-output.patch > delete mode 100644 src/patches/dmidecode/0002-Fix-No-SMBIOS-nor-DMI-entry- > point-found-on-SMBIOS3.patch > delete mode 100644 src/patches/dmidecode/0003-Let-read_file-return-the- > actual-data-size.patch > delete mode 100644 src/patches/dmidecode/0004-dmidecode-Use-read_file-to- > read-the-DMI-table-from-s.patch >=20 > diff --git a/lfs/dmidecode b/lfs/dmidecode > index a2dcc2357..8f8a2491c 100644 > --- a/lfs/dmidecode > +++ b/lfs/dmidecode > @@ -24,7 +24,7 @@ > =20 > include Config > =20 > -VER =3D 3.0 > +VER =3D 3.1 > =20 > THISAPP =3D dmidecode-$(VER) > DL_FILE =3D $(THISAPP).tar.gz > @@ -41,7 +41,7 @@ objects =3D $(DL_FILE) > =20 > $(DL_FILE) =3D $(DL_FROM)/$(DL_FILE) > =20 > -$(DL_FILE)_MD5 =3D be7501ad0f844e875976b96106afaa3c > +$(DL_FILE)_MD5 =3D 7798f68a02b82358c44af913da3b6b42 > =20 > install : $(TARGET) > check : $(patsubst %,$(DIR_CHK)/%,$(objects)) > @@ -70,10 +70,6 @@ $(subst %,%_MD5,$(objects)) : > $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) > @$(PREBUILD) > @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) > - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dmidecode/0001- > Add-no-sysfs-option-description-to-h-output.patch > - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dmidecode/0002- > Fix-No-SMBIOS-nor-DMI-entry-point-found-on-SMBIOS3.patch > - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dmidecode/0003- > Let-read_file-return-the-actual-data-size.patch > - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dmidecode/0004- > dmidecode-Use-read_file-to-read-the-DMI-table-from-s.patch > cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dmidecode/0005- > nothing-should-go-into-usr-local.patch > cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) > cd $(DIR_APP) && make install > diff --git a/src/patches/dmidecode/0001-Add-no-sysfs-option-description-to-= h- > output.patch b/src/patches/dmidecode/0001-Add-no-sysfs-option-description-t= o- > h-output.patch > deleted file mode 100644 > index 4b6c1177c..000000000 > --- a/src/patches/dmidecode/0001-Add-no-sysfs-option-description-to-h- > output.patch > +++ /dev/null > @@ -1,15 +0,0 @@ > -diff --git a/dmiopt.c b/dmiopt.c > -index 0d142d2..de607f4 100644 > ---- a/dmiopt.c > -+++ b/dmiopt.c > -@@ -314,6 +314,7 @@ void print_help(void) > - " -u, --dump Do not decode the entries\n" > - " --dump-bin FILE Dump the DMI data to a binary > file\n" > - " --from-dump FILE Read the DMI data from a binary > file\n" > -+ " --no-sysfs Do not attempt to read DMI data > from sysfs files\n" > - " -V, --version Display the version and exit\n"; > -=20 > - printf("%s", help); > ---=20 > -2.1.4 > - > diff --git a/src/patches/dmidecode/0002-Fix-No-SMBIOS-nor-DMI-entry-point- > found-on-SMBIOS3.patch b/src/patches/dmidecode/0002-Fix-No-SMBIOS-nor-DMI- > entry-point-found-on-SMBIOS3.patch > deleted file mode 100644 > index 9f7db9cb4..000000000 > --- a/src/patches/dmidecode/0002-Fix-No-SMBIOS-nor-DMI-entry-point-found-on- > SMBIOS3.patch > +++ /dev/null > @@ -1,26 +0,0 @@ > -diff --git a/dmidecode.c b/dmidecode.c > -index ce0511b..cfcade4 100644 > ---- a/dmidecode.c > -+++ b/dmidecode.c > -@@ -4866,8 +4866,16 @@ int main(int argc, char * const argv[]) > - goto exit_free; > - } > -=20 > -- if (smbios_decode(buf, opt.devmem, 0)) > -- found++; > -+ if (memcmp(buf, "_SM3_", 5) =3D=3D 0) > -+ { > -+ if (smbios3_decode(buf, opt.devmem, 0)) > -+ found++; > -+ } > -+ else if (memcmp(buf, "_SM_", 4) =3D=3D 0) > -+ { > -+ if (smbios_decode(buf, opt.devmem, 0)) > -+ found++; > -+ } > - goto done; > -=20 > - memory_scan: > ---=20 > -2.1.4 > - > diff --git a/src/patches/dmidecode/0003-Let-read_file-return-the-actual-dat= a- > size.patch b/src/patches/dmidecode/0003-Let-read_file-return-the-actual-dat= a- > size.patch > deleted file mode 100644 > index 3fea6bc79..000000000 > --- a/src/patches/dmidecode/0003-Let-read_file-return-the-actual-data- > size.patch > +++ /dev/null > @@ -1,84 +0,0 @@ > -diff --git a/dmidecode.c b/dmidecode.c > -index 183ced4..a43cfd1 100644 > ---- a/dmidecode.c > -+++ b/dmidecode.c > -@@ -4751,6 +4751,7 @@ int main(int argc, char * const argv[]) > - int ret =3D 0; /* Returned value */ > - int found =3D 0; > - off_t fp; > -+ size_t size; > - int efi; > - u8 *buf; > -=20 > -@@ -4820,8 +4821,9 @@ int main(int argc, char * const argv[]) > - * contain one of several types of entry points, so read enough for > - * the largest one, then determine what type it contains. > - */ > -+ size =3D 0x20; > - if (!(opt.flags & FLAG_NO_SYSFS) > -- && (buf =3D read_file(0x20, SYS_ENTRY_FILE)) !=3D NULL) > -+ && (buf =3D read_file(&size, SYS_ENTRY_FILE)) !=3D NULL) > - { > - if (!(opt.flags & FLAG_QUIET)) > - printf("Getting SMBIOS data from sysfs.\n"); > -diff --git a/util.c b/util.c > -index f97ac0d..52ed413 100644 > ---- a/util.c > -+++ b/util.c > -@@ -94,10 +94,11 @@ int checksum(const u8 *buf, size_t len) > - * needs to be freed by the caller. > - * This provides a similar usage model to mem_chunk() > - * > -- * Returns pointer to buffer of max_len bytes, or NULL on error > -+ * Returns pointer to buffer of max_len bytes, or NULL on error, and > -+ * sets max_len to the length actually read. > - * > - */ > --void *read_file(size_t max_len, const char *filename) > -+void *read_file(size_t *max_len, const char *filename) > - { > - int fd; > - size_t r2 =3D 0; > -@@ -115,7 +116,7 @@ void *read_file(size_t max_len, const char *filename) > - return(NULL); > - } > -=20 > -- if ((p =3D malloc(max_len)) =3D=3D NULL) > -+ if ((p =3D malloc(*max_len)) =3D=3D NULL) > - { > - perror("malloc"); > - return NULL; > -@@ -123,7 +124,7 @@ void *read_file(size_t max_len, const char *filename) > -=20 > - do > - { > -- r =3D read(fd, p + r2, max_len - r2); > -+ r =3D read(fd, p + r2, *max_len - r2); > - if (r =3D=3D -1) > - { > - if (errno !=3D EINTR) > -@@ -140,6 +141,8 @@ void *read_file(size_t max_len, const char *filename) > - while (r !=3D 0); > -=20 > - close(fd); > -+ *max_len =3D r2; > -+ > - return p; > - } > -=20 > -diff --git a/util.h b/util.h > -index 9d409cd..b8748f1 100644 > ---- a/util.h > -+++ b/util.h > -@@ -25,7 +25,7 @@ > - #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) > -=20 > - int checksum(const u8 *buf, size_t len); > --void *read_file(size_t len, const char *filename); > -+void *read_file(size_t *len, const char *filename); > - void *mem_chunk(off_t base, size_t len, const char *devmem); > - int write_dump(size_t base, size_t len, const void *data, const char > *dumpfile, int add); > - u64 u64_range(u64 start, u64 end); > ---=20 > -2.1.4 > - > diff --git a/src/patches/dmidecode/0004-dmidecode-Use-read_file-to-read-the- > DMI-table-from-s.patch b/src/patches/dmidecode/0004-dmidecode-Use-read_file- > to-read-the-DMI-table-from-s.patch > deleted file mode 100644 > index 45584b72b..000000000 > --- a/src/patches/dmidecode/0004-dmidecode-Use-read_file-to-read-the-DMI- > table-from-s.patch > +++ /dev/null > @@ -1,72 +0,0 @@ > -From 364055211b1956539c6a6268e111e244e1292c8c Mon Sep 17 00:00:00 2001 > -From: Jean Delvare > -Date: Mon, 2 Nov 2015 09:45:31 +0100 > -Subject: [PATCH] dmidecode: Use read_file() to read the DMI table from sys= fs > - > -We shouldn't use mem_chunk() to read the DMI table from sysfs. This > -will fail for SMBIOS v3 implementations which specify a maximum length > -for the table rather than its exact length. The kernel will trim the > -table to the actual length, so the DMI file will be shorter than the > -length announced in entry point. > - > -read_file() fits the bill in this case, as it deals with end of file > -nicely. > - > -This also helps with corrupted DMI tables, as the kernel will not > -export the part of the table that it wasn't able to parse, effectively > -trimming it. > - > -This fixes bug #46176: > -https://savannah.nongnu.org/bugs/?46176 > -Unexpected end of file error > ---- > - CHANGELOG | 3 +++ > - dmidecode.c | 29 +++++++++++++++++++++-------- > - 2 files changed, 24 insertions(+), 8 deletions(-) > - > - > -diff --git a/dmidecode.c b/dmidecode.c > -index a43cfd1..16d1823 100644 > ---- a/dmidecode.c > -+++ b/dmidecode.c > -@@ -4524,16 +4524,29 @@ static void dmi_table(off_t base, u32 len, u16 num, > u16 ver, const char *devmem, > - printf("\n"); > - } > -=20 > -- /* > -- * When we are reading the DMI table from sysfs, we want to print > -- * the address of the table (done above), but the offset of the > -- * data in the file is 0. When reading from /dev/mem, the offset > -- * in the file is the address. > -- */ > - if (flags & FLAG_NO_FILE_OFFSET) > -- base =3D 0; > -+ { > -+ /* > -+ * When reading from sysfs, the file may be shorter than > -+ * announced. For SMBIOS v3 this is expcted, as we only know > -+ * the maximum table size, not the actual table size. For > older > -+ * implementations (and for SMBIOS v3 too), this would be > the > -+ * result of the kernel truncating the table on parse error. > -+ */ > -+ size_t size =3D len; > -+ buf =3D read_file(&size, devmem); > -+ if (!(opt.flags & FLAG_QUIET) && num && size !=3D (size_t)len) > -+ { > -+ printf("Wrong DMI structures length: %u bytes " > -+ "announced, only %lu bytes available.\n", > -+ len, (unsigned long)size); > -+ } > -+ len =3D size; > -+ } > -+ else > -+ buf =3D mem_chunk(base, len, devmem); > -=20 > -- if ((buf =3D mem_chunk(base, len, devmem)) =3D=3D NULL) > -+ if (buf =3D=3D NULL) > - { > - fprintf(stderr, "Table is unreachable, sorry." > - #ifndef USE_MMAP > ---=20 > -2.1.4 > - --===============5204773130044377163== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUFCQ2dBZEZpRUU1L3JXNWwzR0dl Mnlwa3R4Z0hudy8yK1FDUWNGQWxwalZBTUFDZ2tRZ0hudy8yK1EKQ1FlaGdBLy9SS3F6ZnNxbnRn UVJWSklGMjB3S1gyeEU5TGQ2OFBPeGQvbEF6TVBzQXh4UDZQQWNDeWxic1ZFdgp0S21hblppU1RL ekxzWnR1V3dnOEpPbGdQWTRwVVFQTWpzZE42RGZvTkRVeXJHQ1NGSjV3RzBGNC9TL2IrQUs1CmEz bmVLTFlqbk5jYmptNVduc0ttSVNwNnpqVmMxQzI0NFBHRGNWck5DRW8xMm11T2lzaHlBR0dicUlP Qy9DeEgKd0c3NEZrd0pRQ0hKMnNRcWhyN25ocjNadTI4dE9KRkk4bThnUE01d1ZWWEdyY1k0Q3RL WUhEVDVJWi9HNFNqOQplRFNubzQ1Nm5INjZtS3dlSE1adjR3N0tjaVlOS3Qra0NtWVI1QjBEOHg5 MzRXT3kzd1Vua3FpZ20wRmZtK3ZMCkV2SzN6ZXA4TE1FY0drM3h5enF0ano5dFA0WFVmVVJOcVZS V1RKZU1iUE54TTVuMzhBRmpFajM4cnR5ZmZKbncKNkpyUjJXdWpCRDFTOVhOcFdjMFVBU0RzTjIy OW5ibXhHc1FRLzNCdmNYb2c1eE5FOWtZeS9DU0I1WFZxUmN2Twprdm1pMTBXc1VyTzNZUE9xTEha QitPbXJOc2hsNURUT1AwNmkvdE80UDh0MmluYXhPSHdsVWpZekFMekVBMTJsCjA4cHJ0dXNwelho OTdZUytqa3VjTnZLZFZXOHBQejVETGdCdWFSZEhuRHlKcnVyeXpJLzU3YU9kODlrNVFvTGkKclgx STJGUmpPNmFyQ1FJU3M4NUJnaDF6SDFBQ2FzQ0dYOXZvd1FOLzdLMEdBSHpqMUE3NVRmL2NvVllP RkVwMApGbFJOMnBiektXdm9JSE0wVDRsaEFxR3BEUXNDb1FvT085ZWZ5RktnN2ZSMU5EcjlrWlE9 Cj15azFNCi0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQo= --===============5204773130044377163==--