dir(5)


NAME
     dir, dirent - directory layout

SYNOPSIS
     #include <sys/types.h>
     #include <dirent.h>

DESCRIPTION
     The directories of the standard V1 and V2 file systems are arrays of  the
     following structure defined in <dirent.h>:

     struct _v7_direct {
          ino_t          d_ino;         /* I-node number */
          char           d_name[14];    /* Name of up to 14 characters */
     };

     The d_ino field is the inode number of the file named by  d_name.   D_ino
     is  zero  if the directory slot isn't allocated.  This number is the same
     as st_ino returned by stat(2) unless the entry is mounted on.  D_name  is
     the  name of up to 14 characters, null-terminated only if less then 14 in
     length.  Any character other than null or '/' is allowed.

     The flex versions of the V1 and V2 file systems have the directory layout
     defined by these two structures:

     struct _fl_direct { /* First slot in an entry */
          ino_t          d_ino;
          unsigned char  d_extent;
          char           d_name[5];     /* The shortest name has length 4 */
     };

          /* Name of length len needs _EXTENT(len) extra slots. */
     #define _EXTENT(len) (((len) + 3) >> 3)

     struct dirent {     /* Largest entry (8 slots) */
          ino_t          d_ino;         /* I-node number */
          unsigned char  d_extent;      /* Extended with this many slots */
          char           d_name[61];    /* Null terminated name */
     };

     The d_ino and d_name fields are  like  before,  except  that  d_name  may
     contain  a  null-terminated  name  of  up to 60 characters.  The d_extent
     field tells how many 8 byte slots follow the first slot  to  contain  the
     whole entry.  An entry is always fully contained within a directory block
     of Minix native block size.

     If you have to access directories at the low level then the way  to  find
     out  if  the  directory  is  flex or the old Version 7 type is to look at
     d_extent of the first slot.  This slot always contains the "." entry,  so
     d_extent is zero for flex, '.' for V7.
     See directory(3) for a portable way to access directories, _v7_direct and
     _fl_direct are not even in the user's namespace.

SEE ALSO
     directory(3).

AUTHOR
     Kees J. Bot (kjb@cs.vu.nl)