00001 /* dirent.h - Declarations for directory reading routines. 00002 * Author: Kees J. Bot 00003 * 24 Apr 1989 00004 * 00005 * Note: The V7 format directory entries used under Minix must be transformed 00006 * into a struct dirent with a d_name of at least 15 characters. Given that 00007 * we have to transform V7 entries anyhow it is little trouble to let the 00008 * routines understand the so-called "flex" directory format too. 00009 */ 00010 00011 #ifndef _DIRENT_H 00012 #define _DIRENT_H 00013 00014 #ifndef _TYPES_H 00015 #include <sys/types.h> 00016 #endif 00017 00018 #include <sys/dir.h> 00019 00020 /* _fl_direct is a flexible directory entry. Actually it's a union of 8 00021 * characters and the 3 fields defined below. 00022 */ 00023 00024 /* Flexible directory entry: */ 00025 struct _fl_direct { /* First slot in an entry */ 00026 ino_t d_ino; 00027 unsigned char d_extent; 00028 char d_name[3]; /* two characters for the shortest name */ 00029 }; 00030 00031 /* Name of length len needs _EXTENT(len) extra slots. */ 00032 #define _EXTENT(len) (((len) + 5) >> 3) 00033 00034 /* Version 7 directory entry: */ 00035 struct _v7_direct { 00036 ino_t d_ino; 00037 char d_name[DIRSIZ]; 00038 }; 00039 00040 /* The block size must be at least 1024 bytes, because otherwise 00041 * the superblock (at 1024 bytes) overlaps with other filesystem data. 00042 */ 00043 #define _MIN_BLOCK_SIZE 1024 00044 00045 /* The below is allocated in some parts of the system as the largest 00046 * a filesystem block can be. For instance, the boot monitor allocates 00047 * 3 of these blocks and has to fit within 64kB, so this can't be 00048 * increased without taking that into account. 00049 */ 00050 #define _MAX_BLOCK_SIZE 4096 00051 00052 /* This is the block size for the fixed versions of the filesystem (V1/V2) */ 00053 #define _STATIC_BLOCK_SIZE 1024 00054 00055 #define _STATIC_FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct)) 00056 #define _FLEX_PER_V7 (_EXTENT(DIRSIZ) + 1) 00057 #define _FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct)) 00058 00059 /* Definitions for the directory(3) routines: */ 00060 typedef struct { 00061 char _fd; /* Filedescriptor of open directory */ 00062 char _v7; /* Directory is Version 7 */ 00063 short _count; /* This many objects in buf */ 00064 off_t _pos; /* Position in directory file */ 00065 struct _fl_direct *_ptr; /* Next slot in buf */ 00066 struct _fl_direct _buf[_FLEX_PER_BLOCK]; /* One block of a directory file */ 00067 struct _fl_direct _v7f[_FLEX_PER_V7]; /* V7 entry transformed to flex */ 00068 } DIR; 00069 00070 #define _DIRENT_NAME_LEN 61 00071 00072 struct dirent { /* Largest entry (8 slots) */ 00073 ino_t d_ino; /* I-node number */ 00074 unsigned char d_extent; /* Extended with this many slots */ 00075 char d_name[_DIRENT_NAME_LEN]; /* Null terminated name */ 00076 }; 00077 00078 /* Function Prototypes. */ 00079 _PROTOTYPE( int closedir, (DIR *_dirp) ); 00080 _PROTOTYPE( DIR *opendir, (const char *_dirname) ); 00081 _PROTOTYPE( struct dirent *readdir, (DIR *_dirp) ); 00082 _PROTOTYPE( void rewinddir, (DIR *_dirp) ); 00083 00084 #ifdef _MINIX 00085 _PROTOTYPE( int seekdir, (DIR *_dirp, off_t _loc) ); 00086 _PROTOTYPE( off_t telldir, (DIR *_dirp) ); 00087 00088 #define dirfd(dirp) ((dirp)->_fd) 00089 00090 #endif 00091 00092 #endif /* _DIRENT_H */
1.4.6