dmidecode-devel
[Top][All Lists]
Advanced

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

[dmidecode] [PATCH] dmidecode: Add an -r option for rfc 4122


From: Navin P
Subject: [dmidecode] [PATCH] dmidecode: Add an -r option for rfc 4122
Date: Thu, 21 May 2015 18:53:30 +0530

Hi,
   This patch adds an option for displaying uuid in rfc 4122 format
but not the smbios format.
    RFC 4122 format is used by kernel and lshal. In case they need
this format they have the option  of getting from -r option.Also this
matches with kernel /sys/class/dmi/id/product_uuid

address@hidden:~/dmidecode/dmidecode$ sudo ./dmidecode -r |
grep -i uuid
        UUID: FF24355A-16B4-E411-91F9-1C545F06E0FF
address@hidden:~/dmidecode/dmidecode$ sudo ./dmidecode  | grep -i uuid
        UUID: 5A3524FF-B416-11E4-91F9-1C545F06E0FF
address@hidden:~/dmidecode/dmidecode$ sudo cat
/sys/class/dmi/id/product_uuid
FF24355A-16B4-E411-91F9-1C545F06E0FF
address@hidden:~/dmidecode/dmidecode$ sudo
./dmidecode.savannah.gnu | grep -i uuid
        UUID: 5A3524FF-B416-11E4-91F9-1C545F06E0FF



Attached the patch.
Posting it inline as well.

Thanks,
Navin

Index: dmidecode.c
===================================================================
RCS file: /sources/dmidecode/dmidecode/dmidecode.c,v
retrieving revision 1.200
diff -u -r1.200 dmidecode.c
--- dmidecode.c 13 May 2015 07:17:38 -0000      1.200
+++ dmidecode.c 21 May 2015 13:21:51 -0000
@@ -405,7 +405,7 @@
         * network byte order, so I am reluctant to apply the byte-swapping
         * for older versions.
         */
-       if (ver >= 0x0206)
+       if ((ver >= 0x0206) && (!(opt.flags&FLAG_RFC)))

printf("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
                        p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6],
                        p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
Index: dmiopt.c
===================================================================
RCS file: /sources/dmidecode/dmidecode/dmiopt.c,v
retrieving revision 1.29
diff -u -r1.29 dmiopt.c
--- dmiopt.c    28 Apr 2015 11:17:47 -0000      1.29
+++ dmiopt.c    21 May 2015 13:21:51 -0000
@@ -215,11 +215,12 @@
 int parse_command_line(int argc, char * const argv[])
 {
        int option;
-       const char *optstring = "d:hqs:t:uV";
+       const char *optstring = "d:hqrs:t:uV";
        struct option longopts[] = {
                { "dev-mem", required_argument, NULL, 'd' },
                { "help", no_argument, NULL, 'h' },
                { "quiet", no_argument, NULL, 'q' },
+               { "rfc4122",no_argument, NULL, 'r' },
                { "string", required_argument, NULL, 's' },
                { "type", required_argument, NULL, 't' },
                { "dump", no_argument, NULL, 'u' },
@@ -250,6 +251,9 @@
                        case 'q':
                                opt.flags |= FLAG_QUIET;
                                break;
+                        case 'r':
+                               opt.flags |= FLAG_RFC;
+                               break;
                        case 's':
                                if (parse_opt_string(optarg) < 0)
                                        return -1;
@@ -309,6 +313,7 @@
                " -d, --dev-mem FILE     Read memory from device FILE
(default: " DEFAULT_MEM_DEV ")\n"                " -h, --help
   Display this help text and exit\n"
                " -q, --quiet            Less verbose output\n"
+               " -r, --rfc              Output uuid according to
RFC4122 not SMBIOS format\n"
                " -s, --string KEYWORD   Only display the value of the
given DMI string\n"
                " -t, --type TYPE        Only display the entries of
given type\n"
                " -u, --dump             Do not decode the entries\n"
Index: dmiopt.h
===================================================================
RCS file: /sources/dmidecode/dmidecode/dmiopt.h,v
retrieving revision 1.15
diff -u -r1.15 dmiopt.h
--- dmiopt.h    28 Apr 2015 11:07:08 -0000      1.15
+++ dmiopt.h    21 May 2015 13:21:51 -0000
@@ -45,6 +45,7 @@
 #define FLAG_DUMP_BIN           (1 << 4)
 #define FLAG_FROM_DUMP          (1 << 5)
 #define FLAG_NO_SYSFS           (1 << 6)
+#define FLAG_RFC                (1 << 7)

 int parse_command_line(int argc, char * const argv[]);
 void print_help(void);
Index: man/dmidecode.8
===================================================================
RCS file: /sources/dmidecode/dmidecode/man/dmidecode.8,v
retrieving revision 1.28
diff -u -r1.28 dmidecode.8
--- man/dmidecode.8     21 Apr 2015 07:38:19 -0000      1.28
+++ man/dmidecode.8     21 May 2015 13:21:51 -0000
@@ -68,6 +68,9 @@
 Be less verbose. Unknown, inactive and \s-1OEM\s0-specific entries are not
 displayed. Meta-data and handle references are hidden.
 .TP
+.BR "-r" ", " "--rfc4122"
+Display  \fBUUID\fR in RFC4122 format intead of SMBIOS.
+.TP
 .BR "-s" ", " "--string KEYWORD"
 Only display the value of the \s-1DMI\s0 string identified by \fBKEYWORD\fR.
 \fBKEYWORD\fR must be a keyword from the following list: \fBbios-vendor\fR,

reply via email to

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