[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dmidecode] [PATCH 4/4] Add --no-sysfs option to disable use of sysfs
From: |
Roy Franz |
Subject: |
[dmidecode] [PATCH 4/4] Add --no-sysfs option to disable use of sysfs |
Date: |
Thu, 16 Apr 2015 21:14:01 -0700 |
This option forces any SMBIOS information in sysfs to be ignored, resulting
in dmidecode using /dev/mem for SMBIOS access. This is likely most useful
for debugging.
Signed-off-by: Roy Franz <address@hidden>
---
dmidecode.c | 3 ++-
dmiopt.c | 6 +++++-
dmiopt.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index ef4259d..fb0ef70 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4681,7 +4681,8 @@ 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.
*/
- if ((buf = read_file(0x20, SYS_ENTRY_FILE)) != NULL)
+ if (!(opt.flags & FLAG_NO_SYSFS)
+ && (buf = read_file(0x20, SYS_ENTRY_FILE)) != NULL)
{
printf("Getting SMBIOS data from sysfs\n");
if (memcmp(buf, "_DMI_", 5) == 0)
diff --git a/dmiopt.c b/dmiopt.c
index 1c56a0e..e89ee8a 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -215,7 +215,7 @@ static int parse_opt_string(const char *arg)
int parse_command_line(int argc, char * const argv[])
{
int option;
- const char *optstring = "d:hqs:t:uV";
+ const char *optstring = "d:hqs:t:uVn";
struct option longopts[] = {
{ "dev-mem", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
@@ -226,6 +226,7 @@ int parse_command_line(int argc, char * const argv[])
{ "dump-bin", required_argument, NULL, 'B' },
{ "from-dump", required_argument, NULL, 'F' },
{ "version", no_argument, NULL, 'V' },
+ { "no-sysfs", no_argument, NULL, 'n' },
{ 0, 0, 0, 0 }
};
@@ -265,6 +266,9 @@ int parse_command_line(int argc, char * const argv[])
case 'V':
opt.flags |= FLAG_VERSION;
break;
+ case 'n':
+ opt.flags |= FLAG_NO_SYSFS;
+ break;
case '?':
switch (optopt)
{
diff --git a/dmiopt.h b/dmiopt.h
index b7f2533..5f3103c 100644
--- a/dmiopt.h
+++ b/dmiopt.h
@@ -42,6 +42,7 @@ extern struct opt opt;
#define FLAG_QUIET (1 << 3)
#define FLAG_DUMP_BIN (1 << 4)
#define FLAG_FROM_DUMP (1 << 5)
+#define FLAG_NO_SYSFS (1 << 6)
int parse_command_line(int argc, char * const argv[]);
void print_help(void);
--
1.9.1