routine dir_readdir (
    dir: file_t;
    out data: data_t, dealloc[];
    entry: int;
    nentries: int;
    bufsiz: vm_size_t;
    out amount: int);

Read entries from the directory. Each entry is identified by an index number starting at 0 and running through the file. This call fetches nentries (or any convenient number if nentries is -1) entries starting at entry, returning an array of struct directs in data. The number of entries successfully read is returned in amount. If entry is bigger than the index of the last entry, then 0 is returned in amount. If bufsize is nonzero, never return more than bufsize bytes of data regardless.