]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: abort device hierarchy walk at root of sysfs
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 12 Jun 2024 21:30:28 +0000 (23:30 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 12 Jun 2024 21:30:28 +0000 (23:30 +0200)
It does not make sense to leave the sysfs hierarchy during the walk of
the parent directories.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
lib/sysfs.c

index dfacf4a4a77cc720bb5d4b9954d4df9d26ea290e..e7294e6b1aa457552ba82bb84251ed38b93a3bb2 100644 (file)
@@ -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) {