Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
DIRREAD(3)		   Library Functions Manual		    DIRREAD(3)

NAME
       dirread,	dirreadall - read directory

SYNOPSIS
       #include	<u.h>
       #include	<libc.h>

       long dirread(int	fd, Dir	**buf)

       long dirreadall(int fd, Dir **buf)

       #define	 STATMAX   65535U

       #define	 DIRMAX	   (sizeof(Dir)+STATMAX)

DESCRIPTION
       The  data  returned  by a on a directory	is a set of complete directory
       entries in a machine-independent	format,	exactly	equivalent to the  re-
       sult  of	 a on each file	or subdirectory	in the directory.  Dirread de-
       codes the directory entries into	a machine-dependent  form.   It	 reads
       from  fd	and unpacks the	data into an array of Dir structures whose ad-
       dress is	returned in *buf (see for the layout of	a Dir).	 The array  is
       allocated with each time	dirread	is called.

       Dirreadall  is like dirread, but	reads in the entire directory; by con-
       trast, dirread steps through a directory	one at a time.

       Directory entries have variable length.	A successful read of a	direc-
       tory  always  returns an	integral number	of complete directory entries;
       dirread always returns complete Dir structures.	See read(9p) for  more
       information.

       The constant STATMAX is the maximum size	that a directory entry can oc-
       cupy.  The constant DIRMAX is an	upper limit on the size	 necessary  to
       hold a Dir structure and	all the	associated data.

       Dirread	and  dirreadall	 return	the number of Dir structures filled in
       buf.  The file offset is	advanced by the	number of bytes	actually read.

SOURCE
       /src/lib9/dirread.c

SEE ALSO
DIAGNOSTICS
       Dirread and Dirreadall return zero for end of file and a	negative value
       for  error.   In	either case, *buf is set to nil	so the pointer can al-
       ways be freed with impunity.

       These functions set errstr.

								    DIRREAD(3)

NAME | SYNOPSIS | DESCRIPTION | SOURCE | SEE ALSO | DIAGNOSTICS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=dirread&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help