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.40.2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff1909c7b92163a9b48ae6d20be741002d4a02d2;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 (cherry picked from commit 84e33a138dc9faf2b1b154df5eaed910aa236eeb) --- 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) {