]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
blockdev-util: in blockdev_partscan_enabled() check if we are operating on block...
authorLennart Poettering <lennart@poettering.net>
Mon, 20 Oct 2025 10:35:05 +0000 (12:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 22 Oct 2025 20:56:01 +0000 (22:56 +0200)
The function makes no sense on any other type of fd, hence we better
check this explicitly.

src/shared/blockdev-util.c

index 7641f17aec97a82c6d93524315b4a1a6aa46cd42..4db38374beb0f18b63d4401ec8591b64069886b8 100644 (file)
@@ -414,6 +414,12 @@ int blockdev_partscan_enabled(sd_device *dev) {
 
         assert(dev);
 
+        r = device_in_subsystem(dev, "block");
+        if (r < 0)
+                return r;
+        if (r == 0)
+                return -ENOTBLK;
+
         /* For v6.10 or newer. */
         r = device_get_sysattr_bool(dev, "partscan");
         if (r != -ENOENT)