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>
(cherry picked from commit
84e33a138dc9faf2b1b154df5eaed910aa236eeb)
/* 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) {