Use readdir_r or fall back to readdir + lock