From aaadf3e907980a28910bf780b3c4852e73d6a78a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 23 Feb 2026 04:11:30 +0900 Subject: [PATCH] udev/dump: also dump current tags The "TAG" token in udev rules handles the current tags. Let's also show the current tags. --- src/udev/udev-dump.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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; -- 2.47.3