1 /* dirent.h - Declarations for directory reading routines.
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.
15 #include <sys/types.h>
20 /* _fl_direct is a flexible directory entry. Actually it's a union of 8
21 * characters and the 3 fields defined below.
24 /* Flexible directory entry: */
25 struct _fl_direct
{ /* First slot in an entry */
27 unsigned char d_extent
;
28 char d_name
[3]; /* two characters for the shortest name */
31 /* Name of length len needs _EXTENT(len) extra slots. */
32 #define _EXTENT(len) (((len) + 5) >> 3)
34 /* Version 7 directory entry: */
40 /* The block size must be at least 1024 bytes, because otherwise
41 * the superblock (at 1024 bytes) overlaps with other filesystem data.
43 #define _MIN_BLOCK_SIZE 1024
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.
50 #define _MAX_BLOCK_SIZE 4096
52 /* This is the block size for the fixed versions of the filesystem (V1/V2) */
53 #define _STATIC_BLOCK_SIZE 1024
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))
59 /* Definitions for the directory(3) routines: */
61 char _fd
; /* Filedescriptor of open directory */
62 unsigned _count
; /* This many bytes in _buf */
63 unsigned _pos
; /* Position in _buf */
64 char _buf
[_MAX_BLOCK_SIZE
]; /* The size does not really
65 * matter as long as the
66 * buffer is big enough
67 * to contain at least one
72 #define _DIRENT_NAME_LEN 61
74 struct dirent
{ /* Largest entry (8 slots) */
75 ino_t d_ino
; /* I-node number */
76 off_t d_off
; /* Offset in directory */
77 unsigned short d_reclen
; /* Length of this record */
78 char d_name
[1]; /* Null terminated name */
81 /* Function Prototypes. */
82 _PROTOTYPE( int closedir
, (DIR *_dirp
) );
83 _PROTOTYPE( DIR *opendir
, (const char *_dirname
) );
84 _PROTOTYPE( struct dirent
*readdir
, (DIR *_dirp
) );
85 _PROTOTYPE( void rewinddir
, (DIR *_dirp
) );
88 _PROTOTYPE( int seekdir
, (DIR *_dirp
, off_t _loc
) );
89 _PROTOTYPE( off_t telldir
, (DIR *_dirp
) );
91 #define dirfd(dirp) ((dirp)->_fd)
93 _PROTOTYPE( int getdents
, (int _fildes
, struct dirent
*_buf
,
98 #endif /* _DIRENT_H */