mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
Add netdev files associated with link to networkd JSON output (#37402)
`networkctl status LINK` gained support for showing the netdev
configuration files associated with a link in
c9837c17d5, but these netdev files were
never added to the JSON output too.
This pull-request fixes that by adding two new fields (`NetDevFile` and
`NetDevFileDropins`) to the `networkctl` (and `D-Bus`) JSON output.
This commit is contained in:
@@ -450,6 +450,18 @@ static int network_append_json(Network *network, sd_json_variant **v) {
|
||||
activation_policy_to_string(network->activation_policy)));
|
||||
}
|
||||
|
||||
static int netdev_append_json(NetDev *netdev, sd_json_variant **v) {
|
||||
assert(v);
|
||||
|
||||
if (!netdev)
|
||||
return 0;
|
||||
|
||||
return sd_json_variant_merge_objectbo(
|
||||
v,
|
||||
SD_JSON_BUILD_PAIR_STRING("NetDevFile", netdev->filename),
|
||||
SD_JSON_BUILD_PAIR_STRV("NetDevFileDropins", netdev->dropins));
|
||||
}
|
||||
|
||||
static int device_append_json(sd_device *device, sd_json_variant **v) {
|
||||
_cleanup_strv_free_ char **link_dropins = NULL;
|
||||
const char *link = NULL, *path = NULL, *vendor = NULL, *model = NULL, *joined;
|
||||
@@ -1448,6 +1460,10 @@ int link_build_json(Link *link, sd_json_variant **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = netdev_append_json(link->netdev, &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = device_append_json(link->dev, &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user