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

Function process_get

util/smmstoretool/main.c:282–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282static int process_get(int argc, char *argv[], const char store_file[])
283{
284 const char *name = NULL;
285 const char *type_str = NULL;
286 const char *guid_str = NULL;
287 int opt;
288 while ((opt = getopt(argc, argv, "n:g:t:")) != -1) {
289 switch (opt) {
290 case 'n':
291 name = optarg;
292 break;
293 case 'g':
294 guid_str = optarg;
295 break;
296 case 't':
297 type_str = optarg;
298 break;
299
300 case '?': /* parsing error */
301 print_sub_command_usage(argv[0]);
302 }
303 }
304
305 if (name == NULL || type_str == NULL || guid_str == NULL) {
306 fprintf(stderr, "All options are required\n");
307 print_sub_command_usage(argv[0]);
308 }
309
310 EFI_GUID guid;
311 if (!parse_guid(guid_str, &guid)) {
312 fprintf(stderr, "Failed to parse GUID: %s\n", guid_str);
313 return EXIT_FAILURE;
314 }
315
316 enum data_type type;
317 if (!parse_data_type(type_str, &type)) {
318 fprintf(stderr, "Failed to parse type: %s\n", type_str);
319 return EXIT_FAILURE;
320 }
321
322 struct storage_t storage;
323 if (!storage_open(store_file, &storage, /*rw=*/false))
324 return EXIT_FAILURE;
325
326 int result = EXIT_SUCCESS;
327
328 struct var_t *var = vs_find(&storage.vs, name, &guid);
329 if (var == NULL) {
330 result = EXIT_FAILURE;
331 fprintf(stderr, "Couldn't find variable \"%s:%s\"\n",
332 guid_str, name);
333 } else if (var->data_size == 0) {
334 fprintf(stderr, "There is no data to show.\n");
335 result = EXIT_FAILURE;
336 } else {
337 print_data(var->data, var->data_size, type);
338 }
339

Callers

nothing calls this directly

Calls 9

getoptFunction · 0.85
print_sub_command_usageFunction · 0.85
fprintfFunction · 0.85
parse_guidFunction · 0.85
parse_data_typeFunction · 0.85
storage_openFunction · 0.85
vs_findFunction · 0.85
print_dataFunction · 0.85
storage_dropFunction · 0.85

Tested by

no test coverage detected