@@ -240,6 +240,19 @@ static int parse_opt_oem_string(const char *arg)
240
240
return 0 ;
241
241
}
242
242
243
+ static u32 parse_opt_handle (const char * arg )
244
+ {
245
+ u32 val ;
246
+ char * next ;
247
+
248
+ val = strtoul (arg , & next , 0 );
249
+ if (next == arg || * next != '\0' || val > 0xffff )
250
+ {
251
+ fprintf (stderr , "Invalid handle number: %s\n" , arg );
252
+ return ~0 ;
253
+ }
254
+ return val ;
255
+ }
243
256
244
257
/*
245
258
* Command line options handling
@@ -249,7 +262,7 @@ static int parse_opt_oem_string(const char *arg)
249
262
int parse_command_line (int argc , char * const argv [])
250
263
{
251
264
int option ;
252
- const char * optstring = "d:hqs:t:uV " ;
265
+ const char * optstring = "d:hqs:t:uH:V " ;
253
266
struct option longopts [] = {
254
267
{ "dev-mem" , required_argument , NULL , 'd' },
255
268
{ "help" , no_argument , NULL , 'h' },
@@ -259,6 +272,7 @@ int parse_command_line(int argc, char * const argv[])
259
272
{ "dump" , no_argument , NULL , 'u' },
260
273
{ "dump-bin" , required_argument , NULL , 'B' },
261
274
{ "from-dump" , required_argument , NULL , 'F' },
275
+ { "handle" , required_argument , NULL , 'H' },
262
276
{ "oem-string" , required_argument , NULL , 'O' },
263
277
{ "no-sysfs" , no_argument , NULL , 'S' },
264
278
{ "version" , no_argument , NULL , 'V' },
@@ -300,6 +314,11 @@ int parse_command_line(int argc, char * const argv[])
300
314
if (opt .type == NULL )
301
315
return -1 ;
302
316
break ;
317
+ case 'H' :
318
+ opt .handle = parse_opt_handle (optarg );
319
+ if (opt .handle == ~0U )
320
+ return -1 ;
321
+ break ;
303
322
case 'u' :
304
323
opt .flags |= FLAG_DUMP ;
305
324
break ;
@@ -326,9 +345,9 @@ int parse_command_line(int argc, char * const argv[])
326
345
327
346
/* Check for mutually exclusive output format options */
328
347
if ((opt .string != NULL ) + (opt .type != NULL )
329
- + !!(opt .flags & FLAG_DUMP_BIN ) > 1 )
348
+ + !!(opt .flags & FLAG_DUMP_BIN ) + ( opt . handle != ~ 0U ) > 1 )
330
349
{
331
- fprintf (stderr , "Options --string, --type and --dump-bin are mutually exclusive\n" );
350
+ fprintf (stderr , "Options --string, --type, --handle and --dump-bin are mutually exclusive\n" );
332
351
return -1 ;
333
352
}
334
353
@@ -351,6 +370,7 @@ void print_help(void)
351
370
" -q, --quiet Less verbose output\n"
352
371
" -s, --string KEYWORD Only display the value of the given DMI string\n"
353
372
" -t, --type TYPE Only display the entries of given type\n"
373
+ " -H, --handle HANDLE Only display the entry of given handle\n"
354
374
" -u, --dump Do not decode the entries\n"
355
375
" --dump-bin FILE Dump the DMI data to a binary file\n"
356
376
" --from-dump FILE Read the DMI data from a binary file\n"
0 commit comments