rootdev: Prevent infinite recursion when parsing /sys/block.
The mmcblk driver of the 3.0.8 kernel adds mmcblk0boot0 and mmcblk0boot1
directories under /sys/block or /sys/block/mmcblk0. I have seen it both ways.
The device symlink in those directories points to "../../mmcblk0" which
points to the grandparent directory.
When rootdev scans /sys/block looking for a device that matches "/", it
can fall into this loop and recurse until failure.
While a proper fix would detect loops to prevent recursion, that adds
considerable complexity to the directory scan.
This relatively simple solution limits recursion depth to 5 to prevent
infinitely looping. It will fail to find device matches beyond 5 levels
of directories, but we are nowhere near that in today's systems. We find
matches at level 3 as best I can tell.
TEST=Run rootdev and check for failures.
Reviewed-by: Will Drewry <firstname.lastname@example.org>
Commit-Ready: Bryan Freed <email@example.com>
Tested-by: Bryan Freed <firstname.lastname@example.org>
1 file changed