From: Jean Delvare <jdelvare@suse.de>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Mario_Limonciello@Dell.com, Allen_Hung@Dell.com,
rmk+kernel@arm.linux.org.uk, somlo@cmu.edu,
bjorn.andersson@sonymobile.com, jens.wiklander@linaro.org,
agross@codeaurora.org, arnd@arndb.de, sudeep.holla@arm.com,
eric@anholt.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem strings to sysfs
Date: Wed, 31 Aug 2016 17:47:33 +0200 [thread overview]
Message-ID: <20160831174733.3dfde375@endymion> (raw)
In-Reply-To: <20160831144326.GA24945@kroah.com>
Hi all,
On Wed, 31 Aug 2016 16:43:26 +0200, Greg KH wrote:
> On Wed, Aug 31, 2016 at 02:01:23PM +0000, Mario_Limonciello@Dell.com wrote:
> > Jean Delvare would rather see this implemented in userspace dmidecode.
> > Jean raised a concern in an earlier submission that this runs on every
> > machine (https://lkml.org/lkml/2016/8/2/799).
>
> Ah, yeah, just use dmidecode, much simpler, keeps the kernel smaller, I
> like it.
I wrote a proof of concept patch for dmidecode before my vacation, I
can't remember if I sent it out or not, so I guess it did not happen.
Here it is:
From: Jean Delvare <jdelvare@suse.de>
Subject: dmidecode: New option --oem-string
Add a new option to extract OEM strings, like we already have for
many other strings.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 7 +++++++
dmiopt.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
--- dmidecode.orig/dmiopt.c 2015-10-01 08:41:43.533806256 +0200
+++ dmidecode/dmiopt.c 2016-08-05 10:32:44.907196966 +0200
@@ -171,6 +171,10 @@ static const struct string_keyword opt_s
{ "processor-frequency", 4, 0x16 }, /* dmi_processor_frequency() */
};
+/* This is a template, 3rd field is set at runtime. */
+static struct string_keyword opt_oem_string_keyword =
+ { NULL, 11, 0x00 };
+
static void print_opt_string_list(void)
{
unsigned int i;
@@ -206,6 +210,29 @@ static int parse_opt_string(const char *
return -1;
}
+static int parse_opt_oem_string(const char *arg)
+{
+ unsigned long val;
+ char *next;
+
+ if (opt.string)
+ {
+ fprintf(stderr, "Only one string can be specified\n");
+ return -1;
+ }
+
+ val = strtoul(arg, &next, 10);
+ if (next == arg || val <= 0x00 || val > 0xff)
+ {
+ fprintf(stderr, "Invalid OEM string number: %s\n", arg);
+ return -1;
+ }
+
+ opt_oem_string_keyword.offset = val;
+ opt.string = &opt_oem_string_keyword;
+ return 0;
+}
+
/*
* Command line options handling
@@ -225,6 +252,7 @@ int parse_command_line(int argc, char *
{ "dump", no_argument, NULL, 'u' },
{ "dump-bin", required_argument, NULL, 'B' },
{ "from-dump", required_argument, NULL, 'F' },
+ { "oem-string", required_argument, NULL, 'O' },
{ "no-sysfs", no_argument, NULL, 'S' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
@@ -255,6 +283,11 @@ int parse_command_line(int argc, char *
return -1;
opt.flags |= FLAG_QUIET;
break;
+ case 'O':
+ if (parse_opt_oem_string(optarg) < 0)
+ return -1;
+ opt.flags |= FLAG_QUIET;
+ break;
case 't':
opt.type = parse_opt_type(opt.type, optarg);
if (opt.type == NULL)
--- dmidecode.orig/dmidecode.c 2016-07-22 10:26:50.190119889 +0200
+++ dmidecode/dmidecode.c 2016-08-05 10:41:53.746645533 +0200
@@ -4370,6 +4370,13 @@ static void dmi_table_string(const struc
int key;
u8 offset = opt.string->offset;
+ if (opt.string->type == 11) /* OEM strings */
+ {
+ if (h->length >= 5 && offset <= data[4])
+ printf("%s\n", dmi_string(h, offset));
+ return;
+ }
+
if (offset >= h->length)
return;
I know it's not a universal way to decide where to put the code, but
note how it's half the side of your kernel-side implementation proposal.
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2016-08-31 15:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-15 9:22 [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem strings to sysfs Allen Hung
2016-08-31 12:40 ` Greg Kroah-Hartman
2016-08-31 14:01 ` Mario_Limonciello
2016-08-31 14:43 ` Greg KH
2016-08-31 15:47 ` Jean Delvare [this message]
2016-08-31 21:51 ` Mario_Limonciello
2016-09-01 18:01 ` Jean Delvare
2016-09-01 19:14 ` Mario_Limonciello
2017-05-01 11:39 ` Jean Delvare
2017-05-01 20:58 ` Mario.Limonciello
2017-05-22 7:47 ` Jean Delvare
2017-05-22 19:53 ` Mario.Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160831174733.3dfde375@endymion \
--to=jdelvare@suse.de \
--cc=Allen_Hung@Dell.com \
--cc=Mario_Limonciello@Dell.com \
--cc=agross@codeaurora.org \
--cc=arnd@arndb.de \
--cc=bjorn.andersson@sonymobile.com \
--cc=eric@anholt.net \
--cc=gregkh@linuxfoundation.org \
--cc=jens.wiklander@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=somlo@cmu.edu \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).