#include <libc.h>
long dirread(int fd, Dir **buf)
long dirreadall(int fd, Dir **buf)
#define STATMAX 65535U
#define DIRMAX (sizeof(Dir)+STATMAX)
Dirreadall is like dirread , but reads in the entire directory; by contrast, dirread steps through a directory one read (2) at a time.
Directory entries have variable length. A successful read of a directory always returns an integral number of complete directory entries; dirread always returns complete Dir structures. See read (5) for more information.
The constant STATMAX is the maximum size that a directory entry can occupy. The constant DIRMAX is an upper limit on the size necessary to hold a Dir structure and all the associated data.
Dirread and dirreadall return the number of Dir structures filled in buf . The file offset is advanced by the number of bytes actually read.
These functions set errstr .