1: /*
   2:  * Copyright (c) 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)dir.h	1.2 (2.11BSD GTE) 11/4/94
   7:  */
   8: 
   9: #ifndef _DIR_
  10: #define _DIR_
  11: 
  12: #ifndef MAXNAMLEN
  13: #define MAXNAMLEN   63
  14: #endif
  15: 
  16: #define DIRBLKSIZ   512
  17: 
  18: /*
  19:  * inode numbers are ino_t rather than u_long now.  before, when v7direct
  20:  * was used for the kernel, inode numbers were u_short/ino_t anyways, and since
  21:  * everything had to be recompiled when the fs structure was changed it seemed
  22:  * like a good idea to change the "real direct structure".  SMS
  23: */
  24: 
  25: struct  direct {
  26:     ino_t   d_ino;          /* inode number of entry */
  27:     u_short d_reclen;       /* length of this record */
  28:     u_short d_namlen;       /* length of string in d_name */
  29:     char    d_name[MAXNAMLEN+1];    /* name must be no longer than this */
  30: };
  31: 
  32: /*
  33:  * A directory consists of some number of blocks of DIRBLKSIZ
  34:  * bytes, where DIRBLKSIZ is chosen such that it can be transferred
  35:  * to disk in a single atomic operation (e.g. 512 bytes on most machines).
  36:  *
  37:  * Each DIRBLKSIZ byte block contains some number of directory entry
  38:  * structures, which are of variable length.  Each directory entry has
  39:  * a struct direct at the front of it, containing its inode number,
  40:  * the length of the entry, and the length of the name contained in
  41:  * the entry.  These are followed by the name padded to a 4 byte boundary
  42:  * with null bytes.  All names are guaranteed null terminated.
  43:  * The maximum length of a name in a directory is MAXNAMLEN.
  44:  *
  45:  * The macro DIRSIZ(dp) gives the amount of space required to represent
  46:  * a directory entry.  Free space in a directory is represented by
  47:  * entries which have dp->d_reclen > DIRSIZ(dp).  All DIRBLKSIZ bytes
  48:  * in a directory block are claimed by the directory entries.  This
  49:  * usually results in the last entry in a directory having a large
  50:  * dp->d_reclen.  When entries are deleted from a directory, the
  51:  * space is returned to the previous entry in the same directory
  52:  * block by increasing its dp->d_reclen.  If the first entry of
  53:  * a directory block is free, then its dp->d_ino is set to 0.
  54:  * Entries other than the first in a directory do not normally have
  55:  * dp->d_ino set to 0.
  56:  */
  57: 
  58: #undef DIRSIZ
  59: #define DIRSIZ(dp) \
  60:     ((((sizeof (struct direct) - (MAXNAMLEN+1)) + (dp)->d_namlen+1) + 3) &~ 3)
  61: 
  62: /*
  63:  * Definitions for library routines operating on directories.
  64:  */
  65: typedef struct _dirdesc {
  66:     int dd_fd;
  67:     long    dd_loc;
  68:     long    dd_size;
  69:     char    dd_buf[DIRBLKSIZ];
  70:     struct direct   dd_cur;
  71: } DIR;
  72: 
  73: #ifndef NULL
  74: #define NULL 0
  75: #endif
  76: 
  77: #ifndef KERNEL
  78: 
  79: extern  DIR *opendir();
  80: extern  struct direct *readdir();
  81: extern  long telldir();
  82: extern  void seekdir();
  83: #define rewinddir(dirp) seekdir((dirp), (long)0)
  84: #define dirfd(dirp) ((dirp)->dd_fd)
  85: extern  void closedir();
  86: 
  87: #endif	KERNEL
  88: 
  89: /*
  90:  * Template for manipulating directories.
  91:  * Should use struct direct's, but the name field
  92:  * is MAXNAMLEN - 1, and this just won't do.
  93:  */
  94: #define dotdot_ino  dtdt_ino
  95: #define dotdot_reclen   dtdt_rec
  96: #define dotdot_name dtdt_name
  97: struct dirtemplate {
  98:     ino_t   dot_ino;
  99:     u_short dot_reclen;
 100:     u_short dot_namlen;
 101:     char    dot_name[2];        /* must be multiple of 4 */
 102:     ino_t   dotdot_ino;
 103:     u_short dotdot_reclen;
 104:     u_short dotdot_namlen;
 105:     char    dotdot_name[6];     /* ditto */
 106: };
 107: #endif	_DIR_

Defined struct's

_dirdesc defined in line 65; never used
direct defined in line 25; used 422 times
dirtemplate defined in line 97; used 20 times

Defined typedef's

DIR defined in line 71; used 127 times

Defined macros

MAXNAMLEN defined in line 13; used 91 times
NULL defined in line 74; used 1645 times
_DIR_ defined in line 10; used 1 times
  • in line 9
dotdot_name defined in line 96; used 5 times
dotdot_reclen defined in line 95; used 1 times

Usage of this include

dir.h used 127 times
Last modified: 1994-11-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4518
Valid CSS Valid XHTML 1.0 Strict