xref: /titanic_52/usr/src/lib/libbc/inc/include/sys/dir.h (revision e4f5a11d4a234623168c1558fcdf4341e11769e1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 #pragma ident	"%Z%%M%	%I%	%E% SMI"
23 
24 /*
25  * Filesystem-independent directory information.
26  * Directory entry structures are of variable length.
27  * Each directory entry is a struct direct containing its file number, the
28  * offset of the next entry (a cookie interpretable only the filesystem
29  * type that generated it), the length of the entry, and the length of the
30  * name contained in the entry.  These are followed by the name. The
31  * entire entry is padded with null bytes to a 4 byte boundary. All names
32  * are guaranteed null terminated. The maximum length of a name in a
33  * directory is MAXNAMLEN, plus a null byte.
34  * Note: this file is present only for backwards compatibility. It is superseded
35  * by the files /usr/include/dirent.h and /usr/include/sys/dirent.h. It will
36  * disappear in a future major release.
37  */
38 
39 #ifndef _sys_dir_h
40 #define _sys_dir_h
41 
42 #define	MAXNAMLEN	255
43 
44 struct	direct {
45 	off_t   d_off;			/* offset of next disk directory entry */
46 	u_long	d_fileno;		/* file number of entry */
47 	u_short	d_reclen;		/* length of this record */
48 	u_short	d_namlen;		/* length of string in d_name */
49 	char	d_name[MAXNAMLEN + 1];	/* name (up to MAXNAMLEN + 1) */
50 };
51 
52 /*
53  * The macro DIRSIZ(dp) gives the minimum amount of space required to represent
54  * a directory entry.  For any directory entry dp->d_reclen >= DIRSIZ(dp).
55  * Specific filesystem typesm may use this macro to construct the value
56  * for d_reclen.
57  */
58 #undef DIRSIZ
59 #define DIRSIZ(dp)  \
60 	(((sizeof (struct direct) - (MAXNAMLEN+1) + ((dp)->d_namlen+1)) + 3) & ~3)
61 
62 #ifndef KERNEL
63 #define d_ino	d_fileno		/* compatability */
64 
65 
66 /*
67  * Definitions for library routines operating on directories.
68  */
69 
70 typedef struct _dirdesc {
71 	int	dd_fd;			/* file descriptor */
72 	long	dd_loc;             /* buf offset of entry from last readddir() */
73 	long	dd_size;		/* amount of valid data in buffer */
74 	long	dd_bsize;		/* amount of entries read at a time */
75 	long	dd_off;             	/* Current offset in dir (for telldir) */
76 	char	*dd_buf;		/* directory data buffer */
77 } DIR;
78 
79 #ifndef NULL
80 #define NULL 0
81 #endif
82 extern	DIR *opendir();
83 extern	struct direct *readdir();
84 extern	long telldir();
85 extern	void seekdir();
86 #define rewinddir(dirp)	seekdir((dirp), (long)0)
87 extern	int closedir();
88 #endif
89 
90 #endif /*!_sys_dir_h*/
91