build_romfs can't handle input with more than 1018 subdirectories
Phelerox opened this issue · comments
I noticed that using build_romfs to convert a RomFS folder containing 1521 directories into a romfs.bin fails with the following output:
$ ./build_romfs /romfs romfs.bin
Visiting directories...
Failed to open directory /romfs/<subdirectory_x>/<subdirectory 1019 subdirectories in>
I tested shuffling around the alphabetical order of the subdirectories and consistently got it to fail 1019 subdirectories deep, so there's no permission issue with a specific folder. The number of files also do not seem to be a problem either.
To verify, it worked fine with 1018 subdirectories, but failed with 1019.
This is probably hitting a file descriptor limit caused by leaking directory handles.
@misson20000 Correct! Thanks for figuring it out. I made a pull request that fixes it, but it was really you and Stary (who found where the issue was in the code) that solved this.