[readdir] introduce iterate_dir() and dir_context