]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
blockdevi-util: also check sysname when enumerating partitions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 8 Sep 2022 20:25:55 +0000 (05:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Sep 2022 13:30:19 +0000 (22:30 +0900)
src/shared/blockdev-util.c

index 66807c673d1f3c13bf54483895d354e72a6b0360..82893a05163ae770866374ce0841cbdb5b4f84cf 100644 (file)
@@ -543,6 +543,16 @@ static int partition_enumerator_new(sd_device *dev, sd_device_enumerator **ret)
         if (r < 0)
                 return r;
 
+        r = sd_device_get_sysname(dev, &s);
+        if (r < 0)
+                return r;
+
+        /* Also add sysname check for safety. Hopefully, this also improves performance. */
+        s = strjoina(s, "*");
+        r = sd_device_enumerator_add_match_sysname(e, s);
+        if (r < 0)
+                return r;
+
         r = sd_device_enumerator_add_match_subsystem(e, "block", /* match = */ true);
         if (r < 0)
                 return r;