X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/9bccf70c0258c7cac2dcb80011b2a964d884c552..7e41aa883dd258f888d0470250eead40a53ef1f5:/bsd/man/man2/getdirentries.2?ds=inline diff --git a/bsd/man/man2/getdirentries.2 b/bsd/man/man2/getdirentries.2 index e6cc24a50..a513ea8e8 100644 --- a/bsd/man/man2/getdirentries.2 +++ b/bsd/man/man2/getdirentries.2 @@ -41,6 +41,8 @@ .Nd "get directory entries in a filesystem independent format" .Sh SYNOPSIS .Fd #include +.Fd #include +.Fd #include .Ft int .Fn getdirentries "int fd" "char *buf" "int nbytes" "long *basep" .Sh DESCRIPTION @@ -65,13 +67,8 @@ with buffers smaller than this size. .Pp The data in the buffer is a series of .Em dirent -structures each containing the following entries: -.Bd -literal -offset indent -unsigned long d_fileno; -unsigned short d_reclen; -unsigned short d_namlen; -char d_name[MAXNAMELEN + 1]; /* see below */ -.Ed +structures (see +.Xr dir 5 ) .Pp The .Fa d_fileno @@ -81,6 +78,12 @@ Files that are linked by hard links (see .Xr link 2 ) have the same .Fa d_fileno . +Users of +.Fn getdirentries +should skip +entries with +.Fa d_fileno += 0, as such entries represent files which have been deleted but not yet removed from the directory entry. The .Fa d_reclen entry is the length, in bytes, of the directory record. @@ -95,6 +98,20 @@ Thus the actual size of may vary from 1 to .Dv MAXNAMELEN \&+ 1. +.Fa d_type +is a integer representing the type of the directory entry. The following types are defined in +.Aq sys/dirent.h : +.Bd -literal -offset indent +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 +.Ed .Pp Entries may be separated by extra space. The @@ -122,6 +139,32 @@ The current position pointer should only be set to a value returned by a value returned in the location pointed to by .Fa basep , or zero. +.Sh NOTES +.Fn getdirentries +should rarely be used directly; instead, +.Xr opendir 3 +and +.Xr readdir 3 +should be used. +.Pp +As of Mac OS X 10.6, +.Fn getdirentries +is deprecated, and it is recommended that applications +use +.Xr readdir 3 +rather than using +.Fn getdirentries +directly. Due to limitations with the system call, +.Fn getdirentries +will not work +with 64-bit inodes; in order to use +.Fn getdirentries , +.Dv _DARWIN_NO_64_BIT_INODE +must be defined. See +.Xr stat 2 +for more information on +.Dv _DARWIN_NO_64_BIT_INODE +and its other effects. .Sh RETURN VALUES If successful, the number of bytes actually transferred is returned. Otherwise, -1 is returned and the global variable @@ -146,8 +189,12 @@ An error occurred while reading from or writing to the file system. .El .Sh SEE ALSO +.Xr lseek 2 , .Xr open 2 , -.Xr lseek 2 +.Xr stat 2 , +.Xr opendir 3 , +.Xr readdir 3 , +.Xr dir 5 .Sh HISTORY The .Fn getdirentries