1: /*	ndir.h	4.4	82/07/25	*/
   2: 
   3: /*
   4:  * Change notice (rti!trt):  To be compatible with non-bsd systems:
   5:  * #defines for u_short, u_long, and void added.
   6:  */
   7: 
   8: #define u_short unsigned short
   9: #define u_long  long
  10: #define void
  11: 
  12: /*
  13:  * A directory consists of some number of blocks of DIRBLKSIZ
  14:  * bytes, where DIRBLKSIZ is chosen such that it can be transferred
  15:  * to disk in a single atomic operation (e.g. 512 bytes on most machines).
  16:  *
  17:  * Each DIRBLKSIZ byte block contains some number of directory entry
  18:  * structures, which are of variable length.  Each directory entry has
  19:  * a struct direct at the front of it, containing its inode number,
  20:  * the length of the entry, and the length of the name contained in
  21:  * the entry.  These are followed by the name padded to a 4 byte boundary
  22:  * with null bytes.  All names are guaranteed null terminated.
  23:  * The maximum length of a name in a directory is MAXNAMLEN.
  24:  *
  25:  * The macro DIRSIZ(dp) gives the amount of space required to represent
  26:  * a directory entry.  Free space in a directory is represented by
  27:  * entries which have dp->d_reclen >= DIRSIZ(dp).  All DIRBLKSIZ bytes
  28:  * in a directory block are claimed by the directory entries.  This
  29:  * usually results in the last entry in a directory having a large
  30:  * dp->d_reclen.  When entries are deleted from a directory, the
  31:  * space is returned to the previous entry in the same directory
  32:  * block by increasing its dp->d_reclen.  If the first entry of
  33:  * a directory block is free, then its dp->d_ino is set to 0.
  34:  * Entries other than the first in a directory do not normally have
  35:  * dp->d_ino set to 0.
  36:  */
  37: #define DIRBLKSIZ   512
  38: #define MAXNAMLEN   255
  39: 
  40: struct  direct {
  41:     u_long  d_ino;          /* inode number of entry */
  42:     u_short d_reclen;       /* length of this record */
  43:     u_short d_namlen;       /* length of string in d_name */
  44:     char    d_name[MAXNAMLEN + 1];  /* name must be no longer than this */
  45: };
  46: 
  47: /*
  48:  * The DIRSIZ macro gives the minimum record length which will hold
  49:  * the directory entry.  This requires the amount of space in struct direct
  50:  * without the d_name field, plus enough space for the name with a terminating
  51:  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  52:  */
  53: #undef DIRSIZ
  54: #define DIRSIZ(dp) \
  55:     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  56: 
  57: #ifndef KERNEL
  58: /*
  59:  * Definitions for library routines operating on directories.
  60:  */
  61: typedef struct _dirdesc {
  62:     int dd_fd;
  63:     long    dd_loc;
  64:     long    dd_size;
  65:     char    dd_buf[DIRBLKSIZ];
  66: } DIR;
  67: #ifndef NULL
  68: #define NULL 0
  69: #endif
  70: extern  DIR *opendir();
  71: extern  struct direct *readdir();
  72: extern  long telldir();
  73: extern  void seekdir();
  74: #define rewinddir(dirp) seekdir((dirp), (long)0)
  75: extern  void closedir();
  76: #endif KERNEL

Defined struct's

_dirdesc defined in line 61; never used
direct defined in line 40; used 2 times
  • in line 71(2)

Defined typedef's

DIR defined in line 66; used 1 times
  • in line 70

Defined macros

DIRBLKSIZ defined in line 37; used 1 times
  • in line 65
DIRSIZ defined in line 54; used 1 times
  • in line 53
MAXNAMLEN defined in line 38; used 2 times
NULL defined in line 68; used 1 times
  • in line 67
rewinddir defined in line 74; never used
u_long defined in line 9; used 1 times
  • in line 41
u_short defined in line 8; used 2 times
void defined in line 10; never used
Last modified: 1986-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 959
Valid CSS Valid XHTML 1.0 Strict