Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getdirentries(2) — SunOS 2.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

lseek(2)

GETDIRENTRIES(2)  —  SYSTEM CALLS

NAME

getdirentries − gets directory entries in a filesystem independent format

SYNOPSIS

#include <sys/dir.h>

cc = getdirentries(d, buf, nbytes, basep)
int cc, d;
char ∗buf;
int nbytes;
long ∗basep

DESCRIPTION

Getdirentries attempts to put directory entries from the directory referenced by the descriptor d into the buffer pointed to by buf, in a filesystem independent format. Up to nbytes of data will be transferred.  Nbytes must be greater than the block size associated with the file, see stat(2). Sizes less than this may cause errors on certain filesystems.

The data in the buffer is a series of direct structures.  The direct structure is defined as

struct direct {
unsigned longd_fileno;
unsigned shortd_reclen;
unsigned shortd_namlen;
char    d_name[MAXNAMELEN + 1];
};

The d_fileno entry is a number which is unique for each distinct file in the filesystem.  Files that are linked by hard links (see link(2)) have the same d_fileno. The d_reclen entry is the length, in bytes, of the directory record.  The d_name and d_namelen entries specify the actual file name and its length. 

Upon return, the actual number of bytes transferred is returned.  The current position pointer associated with d is set to point to the next block of entries.  The pointer is not necessarily incremented by the number of bytes returned by getdirentries. If the value returned is zero, the end of the directory has been reached. The current position pointer may be set and retrieved by lseek(2). The basep entry is a pointer to a location into which the current position of the buffer just transferred is placed.  It is not safe to set the current position pointer to any value other than a value previously returned by lseek(2) or a value previously returned in basep or zero. 

RETURN VALUE

If successful, the number of bytes actually transferred is returned.  Otherwise, a −1 is returned and the global variable errno is set to indicate the error. 

SEE ALSO

open(2), lseek(2)

Sun Release 2.0  —  Last change: 29 July 1984

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026