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
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.
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]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
34 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 11.11 */
36 #include <sys/feature_tests.h>
43 * File-system independent directory entry.
45 typedef struct dirent
{
46 ino_t d_ino
; /* "inode number" of entry */
47 off_t d_off
; /* offset of disk directory entry */
48 unsigned short d_reclen
; /* length of this record */
49 char d_name
[1]; /* name of file */
52 #if defined(_SYSCALL32)
54 /* kernel's view of user ILP32 dirent */
56 typedef struct dirent32
{
57 ino32_t d_ino
; /* "inode number" of entry */
58 off32_t d_off
; /* offset of disk directory entry */
59 uint16_t d_reclen
; /* length of this record */
60 char d_name
[1]; /* name of file */
63 #endif /* _SYSCALL32 */
65 #ifdef _LARGEFILE64_SOURCE
68 * transitional large file interface version AND kernel internal version
70 typedef struct dirent64
{
71 ino64_t d_ino
; /* "inode number" of entry */
72 off64_t d_off
; /* offset of disk directory entry */
73 unsigned short d_reclen
; /* length of this record */
74 char d_name
[1]; /* name of file */
77 #endif /* _LARGEFILE64_SOURCE */
79 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
81 #define DIRENT64_RECLEN(namelen) \
82 ((offsetof(dirent64_t, d_name[0]) + 1 + (namelen) + 7) & ~ 7)
83 #define DIRENT64_NAMELEN(reclen) \
84 ((reclen) - (offsetof(dirent64_t, d_name[0])))
85 #define DIRENT32_RECLEN(namelen) \
86 ((offsetof(dirent32_t, d_name[0]) + 1 + (namelen) + 3) & ~ 3)
87 #define DIRENT32_NAMELEN(reclen) \
88 ((reclen) - (offsetof(dirent32_t, d_name[0])))
94 * large file compilation environment setup
96 * In the LP64 compilation environment, map large file interfaces
97 * back to native versions where possible. (This only works because
98 * a 'struct dirent' == 'struct dirent64').
101 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
102 #ifdef __PRAGMA_REDEFINE_EXTNAME
103 #pragma redefine_extname getdents getdents64
105 #define getdents getdents64
107 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
109 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
110 #ifdef __PRAGMA_REDEFINE_EXTNAME
111 #pragma redefine_extname getdents64 getdents
113 #define getdents64 getdents
114 #define dirent64 dirent
115 #define dirent64_t dirent_t
117 #endif /* _LP64 && _LARGEFILE64_SOURCE */
119 #if defined(__STDC__)
120 extern int getdents(int, struct dirent
*, size_t);
122 extern int getdents();
125 /* N.B.: transitional large file interface version deliberately not provided */
127 #endif /* !defined(_KERNEL) */
128 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
134 #endif /* _SYS_DIRENT_H */