replace library time handling functions
[minix3.git] / include / dirent.h
blob81c03181238e2e2a9b7852ff053049444449d1f7
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 */
11 #ifndef _DIRENT_H
12 #define _DIRENT_H
14 #ifndef _TYPES_H
15 #include <sys/types.h>
16 #endif
18 #include <sys/dir.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 */
26 ino_t d_ino;
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: */
35 struct _v7_direct {
36 ino_t d_ino;
37 char d_name[DIRSIZ];
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: */
60 typedef struct {
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
68 * entry.
70 } DIR;
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) );
87 #ifdef _MINIX
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,
94 size_t _nbyte) );
96 #endif
98 #endif /* _DIRENT_H */