getdirentries.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 154 行

2
154
字号
.\" SCCSID: @(#)getdirentries.2	8.1	9/11/90.TH getdirentries 2 .SH Name getdirentries \- gets directory entries in a generic directory format.SH Syntax.nf.ft B#include <sys/dir.h>.PP.ft Bcc = getdirentries(fd, buf, nbytes, basep)int cc, fd;char *buf;int nbytes;long *basep;.ft R.fi.SH Description.NXB "getdirentries system call".NXB "directory" "getting entries".PPThe .PN getdirentries system call puts directory entries from the directory referenced by the file descriptor.I fdinto the buffer pointed to by.I buf,in a generic directory format.  Up to.I nbytesof data are transferred.  The.I nbytesof data must be greater than or equal to the block sizeassociated with the file.  For further information, see .MS stat 2 .Sizes less than .I nbytescan cause errors on certain file systems..PPThe data returned in the buffer is a series of.I directstructures, each containing the following entries:.EXunsigned long   d_ino;unsigned short  d_reclen;unsigned short  d_namlen;char            d_name[MAXNAMLEN + 1]; .EE.PPThe.I d_inoentry is a number that is unique for eachdistinct file in the file system.Files that are linked by hard links have the same.I d_ino .For further information, see .MS link 2 .The.I d_reclenentry is the length, in bytes, of the directory record.The.I d_namlenentry specifies the length of the file name.The.I d_nameentry contains a null-terminated file name.Thus, the actual size of.I d_namecan vary from 2 to MAXNAMLEN + 1..PPThe generic directory structures are not necessarily tightly packed.The.I d_reclenentry may be used as an offset from the beginning of a.I directstructure to the next structure, if any..PPUpon return, the actual number of bytes transferred is returned.The current position pointer associated with.I fdis set to point to the next block of entries.The pointer is not necessarily incrementedby the number of bytes returned by .PN getdirentries .If the value returned is zero, the end of thedirectory has been reached.The current position pointer may be set and retrieved by.PN lseek .The.PN getdirentriessystem callwrites the position of the block read into the location pointed to by.IR basep .It is not safe to set the current position pointerto any value other thana value previously returned by .PN lseek or a value previously returned in the location pointed to by.I basepor zero..SH Return Values.NXR "getdirentries system call" "return value"If successful, the number of bytes actually transferred is returned.Otherwise, a \-1 is returned and the global variable.I errnois set to indicate the error..SH Diagnostics.NXR "getdirentries system call" "diagnostics"The.PN getdirentriessystem callfails under the following conditions: .TP 15EBADFThe\fIfd\fP is not a valid file descriptor open for reading..TP 15ENOTDIRThe \fIfd\fP is not a directory..TP 15EFAULTEither \fIbuf\fP or \fIbasep\fP pointsoutside the allocated address space..TP 15EIOWhile reading from or writing to the file system,an I/O error occurred..TP 15EINTRA read from a slow device was interrupted by the delivery of a signal before any data arrived..TP 15EPERMThe user does not have read permission in the directory..NTThe .PN getdirentries system callis not the suggested interface for readingdirectories.  The .PN opendir ,.PN readdir ,and.PN telldir routines offer a standard interface. See the.MS directory 3reference page for information on these routines..NE.SH See Alsoclose(2), link(2), lseek(2), open(2), stat(2), directory(3).NXE "getdirentries system call".NXE "directory" "getting entries"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?