SHA256
1
0
forked from pool/biosdevname
biosdevname/more-cmdline-args

123 lines
3.4 KiB
Plaintext
Raw Normal View History

From: Jordan Hargrave <Jordan_Hargrave@dell.com>
Date: Thu, 31 Mar 2011 17:48:00 +0000 (-0500)
Subject: Add command line arguments for checking SMBIOS version and ignore $PIRQ.
X-Git-Url: http://linux.dell.com/cgi-bin/gitweb/gitweb.cgi?p=biosdevname.git;a=commitdiff_plain;h=8dde4129ab403f4df5f013209e5dd21d25b43f05
Add command line arguments for checking SMBIOS version and ignore $PIRQ.
---
diff --git a/src/bios_dev_name.c b/src/bios_dev_name.c
index 81e7620..e2f8454 100644
--- a/src/bios_dev_name.c
+++ b/src/bios_dev_name.c
@@ -14,6 +14,9 @@
#include "bios_dev_name.h"
static struct bios_dev_name_opts opts;
+int nopirq;
+int smver_mjr;
+int smver_mnr;
static void usage(void)
{
@@ -23,6 +26,8 @@ static void usage(void)
fprintf(stderr, " -d or --debug enable debugging\n");
fprintf(stderr, " --policy [physical | all_ethN ]\n");
fprintf(stderr, " --prefix [string] string use for embedded NICs (default='em')\n");
+ fprintf(stderr, " --smbios [x.y] Require SMBIOS x.y or greater\n");
+ fprintf(stderr, " --nopirq Don't use $PIR table for slot numbers\n");
fprintf(stderr, " Example: biosdevname -i eth0\n");
fprintf(stderr, " returns: em1\n");
fprintf(stderr, " when eth0 is an embedded NIC with label '1' on the chassis.\n");
@@ -55,6 +60,8 @@ parse_opts(int argc, char **argv)
{"interface", no_argument, 0, 'i'},
{"policy", required_argument, 0, 'p'},
{"prefix", required_argument, 0, 'P'},
+ {"nopirq", no_argument, 0, 'x'},
+ {"smbios", required_argument, 0, 's'},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv,
@@ -75,6 +82,12 @@ parse_opts(int argc, char **argv)
case 'P':
opts.prefix = optarg;
break;
+ case 's':
+ sscanf(optarg, "%u.%u", &smver_mjr, &smver_mnr);
+ break;
+ case 'x':
+ nopirq = 1;
+ break;
default:
usage();
exit(1);
diff --git a/src/dmidecode/dmidecode.c b/src/dmidecode/dmidecode.c
index ec91305..7bedc3a 100644
--- a/src/dmidecode/dmidecode.c
+++ b/src/dmidecode/dmidecode.c
@@ -40,6 +40,8 @@
#include "../pci.h"
#include "../naming_policy.h"
+extern int smver_mjr, smver_mnr;
+
static const char *bad_index = "<BAD INDEX>";
/*
@@ -176,12 +178,27 @@ static void to_dmi_header(struct dmi_header *h, u8 *data)
h->data=data;
}
+static int isvalidsmbios(int mjr, int mnr)
+{
+ if (!smver_mjr && !smver_mnr)
+ return 1;
+ if (mjr > smver_mjr)
+ return 1;
+ if ((mjr == smver_mjr) && (mnr >= smver_mnr))
+ return 1;
+ return 0;
+}
+
static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, const struct libbiosdevname_state *state)
{
u8 *buf;
u8 *data;
int i=0;
+ /* Verify SMBIOS version */
+ if (!isvalidsmbios(ver >> 8, ver & 0xFF)) {
+ return;
+ }
if((buf=mem_chunk(base, len, devmem))==NULL)
{
#ifndef USE_MMAP
diff --git a/src/pirq.c b/src/pirq.c
index 14685bb..8eb4c97 100644
--- a/src/pirq.c
+++ b/src/pirq.c
@@ -18,6 +18,8 @@
#include <sys/mman.h>
#include "pirq.h"
+extern int nopirq;
+
/* If unknown, use INT_MAX so they get sorted last */
int pirq_pci_dev_to_slot(struct routing_table *table, int domain, int bus, int dev)
{
@@ -49,8 +51,13 @@ struct routing_table * pirq_alloc_read_table()
int i;
void *mem;
off_t offset=0L;
- int fd=open("/dev/mem", O_RDONLY);
+ int fd;
+ /* Skip PIRQ table parsing */
+ if (nopirq) {
+ return NULL;
+ }
+ fd = open("/dev/mem", O_RDONLY);
if(fd==-1)
return NULL;