From: Thomas Weißschuh Date: Wed, 12 Jun 2024 21:30:28 +0000 (+0200) Subject: lib/sysfs: abort device hierarchy walk at root of sysfs X-Git-Tag: v2.42-start~298 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=84e33a138dc9faf2b1b154df5eaed910aa236eeb;p=thirdparty%2Futil-linux.git lib/sysfs: abort device hierarchy walk at root of sysfs It does not make sense to leave the sysfs hierarchy during the walk of the parent directories. Signed-off-by: Thomas Weißschuh --- diff --git a/lib/sysfs.c b/lib/sysfs.c index dfacf4a4a..e7294e6b1 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -467,6 +467,10 @@ static int sysfs_devchain_is_removable(char *chain) /* append "/removable" to the path */ memcpy(chain + len, REMOVABLE_FILENAME, sizeof(REMOVABLE_FILENAME)); + /* root of device hierarchy */ + if (strcmp(chain, "/sys/dev/block" REMOVABLE_FILENAME) == 0) + break; + /* try to read it */ fd = open(chain, O_RDONLY); if (fd != -1) {