From 226b0a71ad473ec85f5b613509d78d0fe36cf5ea Mon Sep 17 00:00:00 2001 From: honggli Date: Mon, 15 Apr 2024 03:39:50 -0400 Subject: [PATCH 1/2] export slot id for more slot types --- dmidecode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dmidecode.c b/dmidecode.c index 54f59c1..1ad8c63 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -2161,6 +2161,10 @@ static void dmi_slot_id(u8 code1, u8 code2, u8 type) case 0x21: /* PCI Express Mini */ case 0x22: /* PCI Express Mini */ case 0x23: /* PCI Express Mini */ + case 0x24: /* PCI Express Gen 4 SFF-8639 (U.2) */ + case 0x25: /* PCI Express Gen 5 SFF-8639 (U.2) */ + case 0x26: /* OCP NIC 3.0 Small Form Factor (SFF) */ + case 0x27: /* OCP NIC 3.0 Large Form Factor (LFF) */ case 0xA5: /* PCI Express */ case 0xA6: /* PCI Express */ case 0xA7: /* PCI Express */ @@ -2192,6 +2196,8 @@ static void dmi_slot_id(u8 code1, u8 code2, u8 type) case 0xC2: /* PCI Express 5 */ case 0xC3: /* PCI Express 5 */ case 0xC4: /* PCI Express 6+ */ + case 0xC5: /* Enterprise and Datacenter 1U E1 Form Factor Slot (EDSFF E1.S, E1.L) */ + case 0xC6: /* Enterprise and Datacenter 3" E3 Form Factor Slot (EDSFF E3.S, E3.L) */ pr_attr("ID", "%u", code1); break; case 0x07: /* PCMCIA */ From caac5851b8267bcaaf53b334570edf887870327b Mon Sep 17 00:00:00 2001 From: honggli Date: Tue, 24 Sep 2024 06:38:02 +0000 Subject: [PATCH 2/2] remove the safety check for root user --- util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index 2770b1d..297bad9 100644 --- a/util.c +++ b/util.c @@ -186,10 +186,11 @@ void *mem_chunk(off_t base, size_t len, const char *devmem) /* * Safety check: if running as root, devmem is expected to be a * character device file. + * TODO: Remove this check */ if ((fd = open(devmem, O_RDONLY)) == -1 - || fstat(fd, &statbuf) == -1 - || (geteuid() == 0 && !S_ISCHR(statbuf.st_mode))) + || fstat(fd, &statbuf) == -1) + // || (geteuid() == 0 && !S_ISCHR(statbuf.st_mode))) { fprintf(stderr, "Can't read memory from %s\n", devmem); if (fd == -1)