From: Karel Zak Date: Tue, 24 Jan 2023 16:38:49 +0000 (+0100) Subject: lsblk: use sysfs_blkdev_is_removable() X-Git-Tag: v2.39-rc1~117 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=60c3686b816505b6b891fda7b140d5ec52f4d18d;p=thirdparty%2Futil-linux.git lsblk: use sysfs_blkdev_is_removable() Signed-off-by: Karel Zak --- diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index cbe307a74b..fae918bd3f 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -703,21 +703,20 @@ static int is_removable_device(struct lsblk_device *dev, struct lsblk_device *pa if (dev->removable != -1) goto done; - if (ul_path_scanf(dev->sysfs, "removable", "%d", &dev->removable) == 1) - goto done; - if (parent) { + dev->removable = sysfs_blkdev_is_removable(dev->sysfs); + + if (!dev->removable && parent) { pc = sysfs_blkdev_get_parent(dev->sysfs); if (!pc) goto done; - /* dev is partition and parent is whole-disk */ if (pc == parent->sysfs) + /* dev is partition and parent is whole-disk */ dev->removable = is_removable_device(parent, NULL); - - /* parent is something else, use sysfs parent */ - else if (ul_path_scanf(pc, "removable", "%d", &dev->removable) != 1) - dev->removable = 0; + else + /* parent is something else, use sysfs parent */ + dev->removable = sysfs_blkdev_is_removable(pc); } done: if (dev->removable == -1)