GETDIRENTRIES(2) — HP-UX
Series 300 Only
NAME
getdirentries − get entries from a directory in a filesystem-independent format
SYNOPSIS
#include <ndir.h>
int getdirentries(fildes, buf, nbytes, basep)
int fildes;
char *buf;
int nbytes;
long *basep;
DESCRIPTION
Getdirentries places directory entries from the directory referenced by the file descriptor fildes into the buffer pointed to by buf, in a filesystem-independent format. Up to nbytes of data are transferred. Nbytes must be greater than or equal to the block size associated with the file; see stat(2). Smaller block sizes can cause errors on certain file systems.
The data in the buffer consists of a series of direct structures, each containing the following entries:
unsigned longd_fileno;
unsigned shortd_reclen;
unsigned shortd_namlen;
char d_name[MAXNAMLEN + 1];
The d_fileno entry is a number unique for each distinct file in the file system. Files linked by hard links (see link(2)) have the same d_fileno. The d_reclen entry identifies the length, in bytes, of the directory record. The d_name entry contains a null-terminated file name. The d_namlen entry specifies the length of the file name. Thus the actual size of d_name can vary from 2 to MAXNAMLEN + 1. Note that the direct structures in the buffer are not necessarily tightly packed. The d_reclen entry must be used as an offset from the beginning of a direct structure to the next structure, if any.
The return value of the system call is the actual number of bytes transferred. The current position pointer associated with fildes 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 is set and retrieved by lseek(2). Getdirentries writes the position of the block read into the location pointed to by basep. The current position pointer can be set safely only to a value previously returned by lseek(2), to a value previously returned in the location pointed to by basep, or to zero. Any other manipulation of the position pointer causes undefined results.
RETURN VALUE
If successful, the number of bytes actually transferred is returned. Otherwise, −1 is returned and the global variable errno is set to indicate the error.
ERRORS
Getdirentries will fail if one or more of the following are true:
[EBADF] Fildes is not a valid file descriptor open for reading.
[EFAULT] Either buf or basep points outside the allocated address space.
[EINTR] A read from a slow device was interrupted by the delivery of a signal before any data arrived.
[EIO] An I/O error occurred while reading from or writing to the file system.
AUTHOR
Getdirentries was developed by Sun Microsystems, Inc.
SEE ALSO
Hewlett-Packard Company — Version B.1, May 11, 2021