MCPcopy Create free account
hub / github.com/coreboot/coreboot / process_remove

Function process_remove

util/smmstoretool/main.c:393–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393static int process_remove(int argc, char *argv[], const char store_file[])
394{
395 const char *name = NULL;
396 const char *guid_str = NULL;
397 int opt;
398 while ((opt = getopt(argc, argv, "n:g:")) != -1) {
399 switch (opt) {
400 case 'n':
401 name = optarg;
402 break;
403 case 'g':
404 guid_str = optarg;
405 break;
406
407 case '?': /* parsing error */
408 print_sub_command_usage(argv[0]);
409 }
410 }
411
412 if (name == NULL || guid_str == NULL) {
413 fprintf(stderr, "All options are required\n");
414 print_sub_command_usage(argv[0]);
415 }
416
417 EFI_GUID guid;
418 if (!parse_guid(guid_str, &guid)) {
419 fprintf(stderr, "Failed to parse GUID: %s\n", guid_str);
420 return EXIT_FAILURE;
421 }
422
423 struct storage_t storage;
424 if (!storage_open(store_file, &storage, /*rw=*/true))
425 return EXIT_FAILURE;
426
427 int result = EXIT_SUCCESS;
428
429 struct var_t *var = vs_find(&storage.vs, name, &guid);
430 if (var == NULL) {
431 result = EXIT_FAILURE;
432 fprintf(stderr, "Couldn't find variable \"%s:%s\"\n",
433 guid_str, name);
434 } else {
435 vs_delete(&storage.vs, var);
436 }
437
438 storage_write_back(&storage);
439 return result;
440}
441
442static void help_guids(FILE *f, const struct subcommand_t *info)
443{

Callers

nothing calls this directly

Calls 8

getoptFunction · 0.85
print_sub_command_usageFunction · 0.85
fprintfFunction · 0.85
parse_guidFunction · 0.85
storage_openFunction · 0.85
vs_findFunction · 0.85
vs_deleteFunction · 0.85
storage_write_backFunction · 0.85

Tested by

no test coverage detected