Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1473625

Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem strings to sysfs

From Jean Delvare <jdelvare@suse.de>
Newsgroups linux.kernel
Subject Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem strings to sysfs
Date 2016-08-31 17:50 +0200
Message-ID <scfW2-4eb-25@gated-at.bofh.it> (permalink)
References <s6mnv-3MG-5@gated-at.bofh.it> <scd7P-2sm-1@gated-at.bofh.it> <sceng-3nc-29@gated-at.bofh.it> <sceZX-3Ew-19@gated-at.bofh.it>
Organization SUSE Linux

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem  strings to sysfs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-08-31 14:50 +0200
  RE: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem  strings to sysfs <Mario_Limonciello@Dell.com> - 2016-08-31 16:10 +0200
    Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem  strings to sysfs Greg KH <gregkh@linuxfoundation.org> - 2016-08-31 16:50 +0200
      Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem  strings to sysfs Jean Delvare <jdelvare@suse.de> - 2016-08-31 17:50 +0200
        RE: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem  strings to sysfs <Mario_Limonciello@Dell.com> - 2016-09-01 00:00 +0200
          Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem  strings to sysfs Jean Delvare <jdelvare@suse.de> - 2016-09-01 23:40 +0200
            RE: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem  strings to sysfs <Mario_Limonciello@Dell.com> - 2016-09-01 23:50 +0200

csiph-web