From: Yu Watanabe Date: Sun, 22 Feb 2026 19:11:30 +0000 (+0900) Subject: udev/dump: also dump current tags X-Git-Tag: v260-rc1~37^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F40786%2Fhead;p=thirdparty%2Fsystemd.git udev/dump: also dump current tags The "TAG" token in udev rules handles the current tags. Let's also show the current tags. --- diff --git a/src/udev/udev-dump.c b/src/udev/udev-dump.c index e8d23377ff6..57e008c73de 100644 --- a/src/udev/udev-dump.c +++ b/src/udev/udev-dump.c @@ -270,6 +270,20 @@ static int dump_event_json(UdevEvent *event, sd_json_format_flags_t flags, FILE return r; } + tags = strv_free(tags); + + FOREACH_DEVICE_CURRENT_TAG(dev, tag) { + r = strv_extend(&tags, tag); + if (r < 0) + return r; + } + + if (!strv_isempty(tags)) { + r = sd_json_variant_set_field_strv(&v, "currentTags", strv_sort(tags)); + if (r < 0) + return r; + } + char **properties; if (device_get_properties_strv(dev, &properties) >= 0 && !strv_isempty(properties)) { r = sd_json_variant_set_field_strv(&v, "properties", strv_sort(properties)); @@ -417,6 +431,12 @@ int dump_event(UdevEvent *event, sd_json_format_flags_t flags, FILE *f) { fprintf(f, " %s\n", tag); } + if (sd_device_get_current_tag_first(dev)) { + fprintf(f, "%sCurrent Tags:%s\n", ansi_highlight(), ansi_normal()); + FOREACH_DEVICE_CURRENT_TAG(dev, tag) + fprintf(f, " %s\n", tag); + } + char **properties; if (device_get_properties_strv(dev, &properties) >= 0 && !strv_isempty(properties)) { bool space = true;