Annotation of pkgsrc/sysutils/dmidecode/patches/patch-dmidecode.c, revision 1.3
1.3 ! tnn 1: $NetBSD: patch-dmidecode.c,v 1.2 2020/04/20 19:28:34 triaxx Exp $
1.1 jmcneill 2:
1.2 triaxx 3: * Find SMBIOS table address on NetBSD ARM64.
4: * Add missing header for FreeBSD.
1.3 ! tnn 5: * Subject: dmidecode: Fix the condition error in ascii_filter
! 6: https://git.savannah.gnu.org/cgit/dmidecode.git/patch/?id=1117390ccd9cea139638db6f460bb6de70e28f94
! 7: * Subject: dmidecode: Fix crash with -u option
! 8: https://git.savannah.gnu.org/cgit/dmidecode.git/patch/?id=11e134e54d15e67a64c39a623f492a28df922517
1.1 jmcneill 9:
1.3 ! tnn 10: --- dmidecode.c.orig 2020-10-14 12:51:11.000000000 +0000
1.1 jmcneill 11: +++ dmidecode.c
1.3 ! tnn 12: @@ -71,6 +71,13 @@
1.2 triaxx 13: #ifdef __FreeBSD__
14: #include <errno.h>
1.1 jmcneill 15: #include <kenv.h>
1.2 triaxx 16: +#include <sys/socket.h>
1.3 ! tnn 17: +#endif
! 18: +
1.1 jmcneill 19: +#ifdef __NetBSD__
20: +#include <sys/param.h>
21: +#include <sys/sysctl.h>
22: +#include <errno.h>
1.3 ! tnn 23: #endif
! 24:
1.1 jmcneill 25: #include "version.h"
1.3 ! tnn 26: @@ -116,7 +123,7 @@ static void ascii_filter(char *bp, size_
! 27: size_t i;
! 28:
! 29: for (i = 0; i < len; i++)
! 30: - if (bp[i] < 32 || bp[i] == 127)
! 31: + if (bp[i] < 32 || bp[i] >= 127)
! 32: bp[i] = '.';
! 33: }
! 34:
! 35: @@ -248,9 +255,9 @@ static void dmi_dump(const struct dmi_he
! 36: {
! 37: int j, l = strlen(s) + 1;
! 38:
! 39: - off = 0;
! 40: for (row = 0; row < ((l - 1) >> 4) + 1; row++)
! 41: {
! 42: + off = 0;
! 43: for (j = 0; j < 16 && j < l - (row << 4); j++)
! 44: off += sprintf(raw_data + off,
! 45: j ? " %02X" : "%02X",
! 46: @@ -5499,6 +5506,9 @@ static int address_from_efi(off_t *addre
1.1 jmcneill 47: char linebuf[64];
48: #elif defined(__FreeBSD__)
49: char addrstr[KENV_MVALLEN + 1];
50: +#elif defined(__NetBSD__)
51: + uint64_t addr;
52: + size_t addrlen;
53: #endif
54: const char *eptype;
55: int ret;
1.3 ! tnn 56: @@ -5552,6 +5562,23 @@ static int address_from_efi(off_t *addre
1.1 jmcneill 57: *address = strtoull(addrstr, NULL, 0);
1.3 ! tnn 58: eptype = "SMBIOS";
! 59: ret = 0;
1.1 jmcneill 60: +#elif defined(__NetBSD__)
61: + /*
62: + * On NetBSD, SMBIOS anchor base address on non-x86 is exposed
63: + * via sysctl.
64: + */
65: + addrlen = sizeof(addr);
66: + ret = sysctlbyname("machdep.smbios", &addr, &addrlen, NULL, 0);
67: + if (ret == -1)
68: + {
69: + if (errno != ENOENT)
70: + perror("sysctlbyname");
71: + return EFI_NOT_FOUND;
72: + }
73: +
74: + *address = (off_t)addr;
1.3 ! tnn 75: + eptype = "SMBIOS";
! 76: + ret = 0;
1.1 jmcneill 77: #else
1.3 ! tnn 78: ret = EFI_NOT_FOUND;
! 79: #endif
CVSweb <webmaster@jp.NetBSD.org>