xref: /titanic_52/usr/src/lib/libbc/inc/include/sys/dirent.h (revision 148434217c040ea38dc844384f6ba68d9b325906)
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 /*
23  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*      Copyright (c) 1984 AT&T */
28 /*        All Rights Reserved   */
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Filesystem-independent directory information.
34  * Directory entry structures are of variable length.
35  * Each directory entry is a struct dirent containing its file number, the
36  * offset of the next entry (a cookie interpretable only the filesystem
37  * type that generated it), the length of the entry, and the length of the
38  * name contained in the entry.  These are followed by the name. The
39  * entire entry is padded with null bytes to a 4 byte boundary. All names
40  * are guaranteed null terminated. The maximum length of a name in a
41  * directory is MAXNAMLEN, plus a null byte.
42  */
43 
44 #ifndef	__sys_dirent_h
45 #define	__sys_dirent_h
46 
47 struct	dirent {
48 	off_t		d_off;		/* offset of next disk dir entry */
49 	unsigned long	d_fileno;	/* file number of entry */
50 	unsigned short	d_reclen;	/* length of this record */
51 	unsigned short	d_namlen;	/* length of string in d_name */
52 	char		d_name[255+1];	/* name (up to MAXNAMLEN + 1) */
53 };
54 
55 #ifndef	_POSIX_SOURCE
56 /*
57  * It's unlikely to change, but make sure that sizeof d_name above is
58  * at least MAXNAMLEN + 1 (more may be added for padding).
59  */
60 #define	MAXNAMLEN	255
61 /*
62  * The macro DIRSIZ(dp) gives the minimum amount of space required to represent
63  * a directory entry.  For any directory entry dp->d_reclen >= DIRSIZ(dp).
64  * Specific filesystem types may use this macro to construct the value
65  * for d_reclen.
66  */
67 #undef	DIRSIZ
68 #define	DIRSIZ(dp) \
69 	(((sizeof(struct dirent) - (MAXNAMLEN+1) + ((dp)->d_namlen+1)) +3) & ~3)
70 
71 #endif	/* !_POSIX_SOURCE */
72 #endif	/* !__sys_dirent_h */
73