The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/include/dirent.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      dirent.h - Declarations for directory reading routines.
    2  *                                                      Author: Kees J. Bot
    3  *                                                              24 Apr 1989
    4  * 
    5  * Note: The V7 format directory entries used under Minix must be transformed
    6  * into a struct dirent with a d_name of at least 15 characters.  Given that
    7  * we have to transform V7 entries anyhow it is little trouble to let the
    8  * routines understand the so-called "flex" directory format too.
    9  */
   10 
   11 #ifndef _DIRENT_H
   12 #define _DIRENT_H
   13 
   14 #ifndef _TYPES_H
   15 #include <sys/types.h>
   16 #endif
   17 
   18 #include <sys/dir.h>
   19 
   20 /* _fl_direct is a flexible directory entry.  Actually it's a union of 8
   21  * characters and the 3 fields defined below. 
   22  */
   23 
   24 /* Flexible directory entry: */
   25 struct _fl_direct {             /* First slot in an entry */
   26         ino_t           d_ino;
   27         unsigned char   d_extent;
   28         char            d_name[3];  /* two characters for the shortest name */
   29 };
   30 
   31         /* Name of length len needs _EXTENT(len) extra slots. */
   32 #define _EXTENT(len)    (((len) + 5) >> 3)
   33 
   34 /* Version 7 directory entry: */
   35 struct _v7_direct {             
   36         ino_t           d_ino;
   37         char            d_name[DIRSIZ];
   38 };
   39 
   40 /* The block size must be at least 1024 bytes, because otherwise
   41  * the superblock (at 1024 bytes) overlaps with other filesystem data.
   42  */
   43 #define MIN_BLOCK_SIZE           1024
   44 
   45 /* The below is allocated in some parts of the system as the largest
   46  * a filesystem block can be. For instance, the boot monitor allocates
   47  * 3 of these blocks and has to fit within 64kB, so this can't be
   48  * increased without taking that into account.
   49  */
   50 #define MAX_BLOCK_SIZE           4096
   51 
   52 /* This is the block size for the fixed versions of the filesystem (V1/V2) */
   53 #define STATIC_BLOCK_SIZE       1024
   54 
   55 #define STATIC_FLEX_PER_BLOCK (STATIC_BLOCK_SIZE/sizeof(struct _fl_direct))
   56 #define FLEX_PER_V7 (_EXTENT(DIRSIZ) + 1)
   57 #define FLEX_PER_BLOCK (STATIC_BLOCK_SIZE/sizeof(struct _fl_direct))
   58 
   59 /* Definitions for the directory(3) routines: */
   60 typedef struct {
   61         char            _fd;    /* Filedescriptor of open directory */
   62         char            _v7;    /* Directory is Version 7 */
   63         short           _count; /* This many objects in buf */
   64         off_t           _pos;   /* Position in directory file */
   65         struct _fl_direct  *_ptr;       /* Next slot in buf */
   66         struct _fl_direct  _buf[FLEX_PER_BLOCK]; /* One block of a directory file */
   67         struct _fl_direct  _v7f[FLEX_PER_V7];    /* V7 entry transformed to flex */
   68 } DIR;
   69 
   70 #define _DIRENT_NAME_LEN 61
   71 
   72 struct dirent {         /* Largest entry (8 slots) */
   73         ino_t           d_ino;          /* I-node number */
   74         unsigned char   d_extent;       /* Extended with this many slots */
   75         char            d_name[_DIRENT_NAME_LEN];       /* Null terminated name */
   76 };
   77 
   78 /* Function Prototypes. */
   79 _PROTOTYPE( int closedir, (DIR *_dirp)                                  );
   80 _PROTOTYPE( DIR *opendir, (const char *_dirname)                        );
   81 _PROTOTYPE( struct dirent *readdir, (DIR *_dirp)                        );
   82 _PROTOTYPE( void rewinddir, (DIR *_dirp)                                );
   83 
   84 #ifdef _MINIX
   85 _PROTOTYPE( int seekdir, (DIR *_dirp, off_t _loc)                       );
   86 _PROTOTYPE( off_t telldir, (DIR *_dirp)                                 );
   87 #endif
   88 
   89 #endif /* _DIRENT_H */

Cache object: 7fe10a26cc00e1b7015b2e2feb752254


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.