getdirentries(2) getdirentries(2)NAME getdirentries - gets directory entries SYNOPSIS #include <sys/types.h> #include <sys/dir.h> int getdirentries(d, buf, nbytes, basep) int d; char *buf; int nbytes; long *basep; DESCRIPTION getdirentries attempts to put directory entries from the directory referenced by the descriptor d into the buffer pointed to by buf, in a file system independent format. Up to nbytes of data will be transferred. nbytes must be greater than or equal to the block size associated with the file (see stat(2)). Sizes less than this may cause errors on certain file systems. The data in the buffer is a series of direct structures. The direct structure is defined as struct direct { unsigned long d_fileno; unsigned short d_reclen; unsigned short d_namlen; char d_name[MAXNAMELEN + 1]; }; The d_fileno entry is a number which is unique for each distinct file in the file system. Files that are linked by hard links (see link(2)) have the same d_fileno. The d_reclen entry is the length, in bytes, of the directory record. The d_name and d_namelen entries specify the actual file name and its length. Upon return, the actual number of bytes transferred is returned. The current position pointer associated with d is set to point to the next block of entries. The pointer is not necessarily incremented by the number of bytes returned by getdirentries. If the value returned is zero, the end of the directory has been reached. The current position pointer may be set and retrieved by lseek(2). The basep entry is a pointer to a location into which the current position of the buffer just transferred is placed. It is not safe to set the current position pointer to any value other than a value previously returned by lseek(2) or a value previously returned in basep or zero. January 1992 1
getdirentries(2) getdirentries(2)STATUS MESSAGES AND VALUES If successful, the number of bytes actually transferred is returned. Otherwise, a -1 is returned and the global variable errno is set to indicate the error. SEE ALSO link(2), lseek(2), open(2), stat(2), directory(3) 2 January 1992