]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev/dump: also dump current tags 40786/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 22 Feb 2026 19:11:30 +0000 (04:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 22 Feb 2026 20:52:49 +0000 (05:52 +0900)
The "TAG" token in udev rules handles the current tags.
Let's also show the current tags.

src/udev/udev-dump.c

index e8d23377ff6bcef79eb1e7102d07312b56d1bf4e..57e008c73de8fc578483e0a24ee06b7d9a85faf0 100644 (file)
@@ -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;