readdir: marked 'ld' as static to avoid returning stack garbage