source: branches/minix3-book/include/dirent.h@ 9

Last change on this file since 9 was 4, checked in by Mattia Monga, 14 years ago

Importazione sorgenti libro

File size: 2.8 KB
Line 
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: */
25struct _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: */
35struct _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: */
60typedef 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
72struct 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 */
Note: See TracBrowser for help on using the repository browser.