GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DIRREAD(3) FreeBSD Library Functions Manual DIRREAD(3)

dirread, dirreadall - read directory

#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)

The data returned by a on a directory is a set of complete directory entries in a machine-independent format, exactly equivalent to the result of a on each file or subdirectory in the directory. Dirread decodes the directory entries into a machine-dependent form. It reads from fd and unpacks the data into an array of Dir structures whose address 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 contrast, dirread steps through a directory one at a time.

Directory entries have variable length. A successful read of a directory 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 occupy. 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.

/src/lib9/dirread.c

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 always be freed with impunity.

These functions set errstr.


Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.