xref: /original-bsd/sys/ufs/ufs/dir.h (revision 9a96b58b)
1 /*	dir.h	4.3	82/04/19	*/
2 
3 /* @(#)ndir.h 4.4 3/30/82 */
4 
5 /*
6  * This sets the "page size" for directories.
7  * Requirements are DEV_BSIZE <= DIRBLKSIZ <= MINBSIZE with
8  * DIRBLKSIZ a power of two.
9  * Dennis Ritchie feels that directory pages should be atomic
10  * operations to the disk, so we use DEV_BSIZE.
11  */
12 #define DIRBLKSIZ DEV_BSIZE
13 
14 /*
15  * This limits the directory name length. Its main constraint
16  * is that it appears twice in the user structure. (u. area)
17  */
18 #define MAXNAMLEN 255
19 
20 struct	direct {
21 	u_long	d_ino;
22 	short	d_reclen;
23 	short	d_namlen;
24 	char	d_name[MAXNAMLEN + 1];
25 	/* typically shorter */
26 };
27 
28 struct _dirdesc {
29 	int	dd_fd;
30 	long	dd_loc;
31 	long	dd_size;
32 	char	dd_buf[DIRBLKSIZ];
33 };
34 
35 /*
36  * useful macros.
37  */
38 #undef DIRSIZ
39 #define DIRSIZ(dp) \
40     ((sizeof(struct direct) - MAXNAMLEN + (dp)->d_namlen + sizeof(ino_t) - 1) &\
41     ~(sizeof(ino_t) - 1))
42 typedef	struct _dirdesc DIR;
43 #ifndef	NULL
44 #define	NULL	0
45 #endif
46 
47 /*
48  * functions defined on directories
49  */
50 extern DIR *opendir();
51 extern struct direct *readdir();
52 extern long telldir();
53 extern void seekdir();
54 #define rewinddir(dirp)	seekdir((dirp), 0)
55 extern void closedir();
56