DIR(5)
NAME
dir − format of directories
USAGE
#include <sys/dir.h>
DESCRIPTION
A directory behaves exactly like an ordinary file, except that no user may write into a directory. The fact that a file is a directory is indicated by a bit in the flag word of its inode entry The structure of a directory entry as given in the include file is:
#ifndef DEV_BSIZE
#defineDEV_BSIZE1024
#endif
#define DIRBLKSIZDEV_BSIZE
#defineMAXNAMLEN 32
structdirect {
unsigned longd_ino;
shortd_reclen;
shortd_namlen;
chard_name[MAXNAMLEN + 1];
};
/*
* The DIRSIZ macro gives the minimum record length which will hold
* the directory entry. This requires the amount of space in struct direct
* without the d_name field, plus enough space for the name with a terminating
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
*/
#undef DIRSIZ
#define DIRSIZ(dp) ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
/*
* Definitions for library routines operating on directories.
*/
typedef struct _dirdesc {
intdd_fd;
longdd_loc;
longdd_size;
chardd_buf[DIRBLKSIZ];
} DIR;
#ifndef NULL
#define NULL 0
#endif
externDIR *opendir();
externstruct direct *readdir();
externlong telldir();
externvoid seekdir();
#define rewinddir(dirp) seekdir((dirp), (long)0)
externvoid closedir();
By convention, the first two entries in each directory are for . and ... The first is an entry for the directory itself. The second is for the parent directory. The meaning of .. is modified for the root directory of the master file system; there is no parent, so .. has the same meaning as ..