Conversation
|
I've decided to temporarily revert commit 5ce076c, while issue #204 is still present. I will rebase my changes as soon as a fix is pushed into efibootmgr tree or a new efivar release is pushed with rhboot/efivar#217 merged. |
Make read_u16 and read_order available to call outside efibootmgr.c. Make var_entry_t public to be used by other source files. Prepare efibootmgr for JSON output support by making required utility functions and types publicly available to other source files. Signed-off-by: Jose M. Guisado <jguisado@soleta.eu>
Enable JSON output for efibootmgr. This provides an interface for third party tools so they do not need to scrap the existing textual output. This feature is optional and is enabled by using JSON=1 when compiling: make ... JSON=1 Add parameter '-j'/--json' to use JSON output. If efibootmgr is not built with JSON output support it will print out this instead: "JSON support is not built-in" This feature adds a new optional dependency with libjansson. Signed-off-by: Jose M. Guisado <jguisado@soleta.eu>
|
Any update on this? Json output will be very useful to all of us who are building complicated regex parsing of the output at the moment. |
|
I've been using these changes in a production environment and it works great, would be nice to have it upstream. |
|
Bumping PR. I also need it. |
| void print_json(list_t __unused *entry_list, ebm_mode __unused mode, | ||
| char __unused **prefices, char __unused **order_name) | ||
| { | ||
| printf("JSON support is not built-in\n"); |
There was a problem hiding this comment.
exit with error would be better. Also, all warnings and messages that are not expected to be parsed should go to stderr instead of stdout
| printf("\t-g | --gpt Force disk with invalid PMBR to be treated as GPT.\n"); | ||
| printf("\t-i | --iface name Create a netboot entry for the named interface.\n"); | ||
| printf("\t-I | --index number When creating an entry, insert it in bootorder at specified position (default: 0).\n"); | ||
| printf("\t-j | --json Enable JSON output\n"); |
There was a problem hiding this comment.
I would prefer #ifdef here instead of stub function that does nothing in case of JSON compile option was not set.
| "Could not read variable 'BootNext'"); | ||
| if (num >= 0) { | ||
| snprintf(s, sizeof(s), "%04X", num); | ||
| value = json_string(s); |
There was a problem hiding this comment.
possibly dump here num as number, not as hex string ?
| if (num >= 0) { | ||
| snprintf(s, sizeof(s), "%04X", num); | ||
| value = json_string(s); | ||
| json_object_set_new(root, "BootNext", value); |
There was a problem hiding this comment.
I prefer (as opposed to golang style) JSON formats where keys in dicts always exists, but refer to null instead of value. It's easier to interpret, actually.
(JSON output support has been discussed in the past. #70)
Add
--jsonoption to enable JSON output support when compiling efibootmgr with it.This output is compact and intended to be fed to other programs that want to interface with efibootmgr.
To enable JSON support, simply compile with
make ... JSON=1compilation flag.Adds a new optional dependency with libjansson.
If the user runs
efibootmgr --jsonwithout json support being compiled, it will print the following message:JSON support is not built-inThe rationale behind this change is that I'd like to avoid parsing textual output from efibootmgr.
As additional context for these changes: I'm working on the development of a python program used for remote management of computers. This python program needs to retrieve BootOrder, BootNext and the boot entries of the machine it's running on. The program runs an efibootmgr subprocess for such tasks.
Example: