Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getdirentries(2) [osf1 man page]

getdirentries(2)						System Calls Manual						  getdirentries(2)

NAME
getdirentries - Gets directory entries in a file-system independent format. SYNOPSIS
#include <dirent.h> int getdirentries( int fd, char *buf, int nbytes, long *basep ); PARAMETERS
Specifies the file descriptor of a directory to be read. Points to a buffer containing the directory entries as dirent structures. Speci- fies the maximum amount of data to be transferred, in bytes. Points to the position of the block read. DESCRIPTION
The getdirentries() function reads directory entries from a directory into a buffer. The entries are returned as dirent structures, a file-system independent format. This call is not the POSIX-defined way to process directory entries. For POSIX interfaces, use the opendir(3),readdir(3), and closedir(3) library calls for reading and interpreting directory entries. The nbytes parameter should be greater than or equal to the block size associated with the file. (See stat(2).) Some file systems do not support the getdirentries() function with buffers smaller than this size. The entries returned by the getdirentries() function into the location pointed to by buf can be separated by extra space. The getdirentries() function writes the position of the block read into the location pointed to by the basep parameter. Alternatively, the current position pointer can be set and retrieved by lseek(). The current position pointer should only be set to a value returned by lseek(), a value returned in the location pointed to by basep, or 0 (zero). Upon successful completion, the actual number of bytes transferred is returned and the current position pointer associated with the fd parameter is set to point to the next block of entries. The file descriptor pointer might not advance by the same number of bytes returned by the getdirentries() function. A value of 0 (zero) is returned when the end of the directory has been reached. RETURN VALUES
Upon successful completion, the actual number of bytes transferred is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
If the getdirentries() function fails, errno is set to one of the following values: The fd parameter is not a valid file descriptor open for reading. Either the buf or basep parameter points outside the allocated address space. Either the fd parameter is not a valid file descriptor for a directory or the buffer is too small. An I/O error occurred while the operating system was reading from or writing to the file system. RELATED INFORMATION
Functions: open(2), lseek(2) delim off getdirentries(2)

Check Out this Related Man Page

getdirentries(2)						System Calls Manual						  getdirentries(2)

NAME
getdirentries() - get entries from a directory in a file-system-independent format SYNOPSIS
DESCRIPTION
The system call and the header file have been obsoleted starting from HP-UX 10.30 by the functions described in directory(3C). will not be supported for 64-bit applications. The system call places directory entries from the directory referenced by the file descriptor fildes into the buffer pointed to by buf, in a file-system-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 in stat(2). (Smaller block sizes can cause errors on certain file systems.) nbytes must be less than or equal to 65536(64K). The data in the buffer consists of a series of structures, each containing the following entries: ino32_t d_ino; unsigned short d_reclen; unsigned short d_namlen; char d_name[MAXNAMLEN + 1]; The entry is a number unique for each distinct file in the file system. Files linked by hard links (see link(2)) have the same The entry identifies the length, in bytes, of the directory record. The entry contains a null-terminated file name. The entry specifies the length of the file name. Thus the actual size of can vary from 2 to + 1. Note that the structures in the buffer are not necessarily tightly packed. The entry must be used as an offset from the beginning of a 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 If the value returned is zero, the end of the directory has been reached. The current position pointer is set and retrieved by see lseek(2). 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 to a value previously returned in the loca- tion pointed to by basep, or to zero. Any other manipulation of the position pointer causes undefined results. RETURN VALUE
returns the following values: Successful completion. n is the number of bytes actually transferred. Failure. is set to indicate the error. ERRORS
If fails, is set to one of the following values: [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. [EINVAL] nbytes is greater than the size of the structure pointed to by buf. [EINVAL] nbytes is greater than 65536 or is smaller than the size of a single directory entry. [EIO] An I/O error occurred while reading from or writing to the file system. WARNINGS
Obsolescent Interfaces is to be obsoleted at a future date. Note: The call can encounter truncated d_ino values when it is used with a 64-bit filesystem. AUTHOR
was developed by Sun Microsystems, Inc. SEE ALSO
lseek(2), open(2), directory(3C). TO BE OBSOLETED getdirentries(2)
Man Page