dir File

Purpose

Describes the format of a directory.

Syntax

#include <sys/dir.h>

Description

A directory is a file that contains information and structures necessary to define a file hierarchy. A file is interpreted as a directory by the system if it has the S_IFDIR file mode. All modifications to the structure of a directory must be performed under the control of the operating system.

The directory file format accommodates component names of up to 256 characters. This is accomplished through the use of a variable-length structure to describe individual directory entries. The structure of a directory entry follows.

Note: This structure is a file system-specific data structure. It is recommended that file system-independent application programs use the file system-independent direct structure and its associated library support routines.
struct direct {
         ino_t      d_ino;
         ushort     d_reclen;
         ushort     d_namelen;
         char       d_name[256];
  };

By convention, the first two entries in each directory are . (dot) and .. (dot dot). The . (dot) is an entry for the directory itself. The .. (dot dot) entry is for the parent directory. Within the root ( / ) directory the meaning of .. (dot dot) is modified; because there is no parent directory, the .. (dot dot) entry has the same meaning as the . (dot) entry.

The DIRSIZ (dp) macro gives the amount of space required to represent a directory entry. The dp argument is a pointer to a direct structure.