dmidecode-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [dmidecode] [PATCH 4/4] Add --no-sysfs option to disable use of sysf


From: Jean Delvare
Subject: Re: [dmidecode] [PATCH 4/4] Add --no-sysfs option to disable use of sysfs
Date: Fri, 17 Apr 2015 13:44:25 +0200

On Thu, 16 Apr 2015 21:14:01 -0700, Roy Franz wrote:
> 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(-)

You need to update man/dmidecode.8 as well. We'll have to update that
file to mention the sysfs interface too, BTW.

> 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";

I don't expect a wide use of this option so I don't think it deserves a
one-letter shortcut.

>       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' },

I'd rather use 'S', as there may be more "no-something" options later.

>               { 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);

Looks good otherwise.

-- 
Jean Delvare
SUSE L3 Support



reply via email to

[Prev in Thread] Current Thread [Next in Thread]