]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/dirent.h
xnu-792.6.56.tar.gz
[apple/xnu.git] / bsd / sys / dirent.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
ff6e181a
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
1c79356b 12 *
ff6e181a
A
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
ff6e181a
A
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
1c79356b
A
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
24/*-
25 * Copyright (c) 1989, 1993
26 * The Regents of the University of California. All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * This product includes software developed by the University of
39 * California, Berkeley and its contributors.
40 * 4. Neither the name of the University nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 *
56 * @(#)dirent.h 8.3 (Berkeley) 8/10/94
57 */
58
59/*
60 * The dirent structure defines the format of directory entries returned by
61 * the getdirentries(2) system call.
62 *
63 * A directory entry has a struct dirent at the front of it, containing its
64 * inode number, the length of the entry, and the length of the name
65 * contained in the entry. These are followed by the name padded to a 4
66 * byte boundary with null bytes. All names are guaranteed null terminated.
67 * The maximum length of a name in a directory is MAXNAMLEN.
68 */
69
70#ifndef _SYS_DIRENT_H
71#define _SYS_DIRENT_H
72
91447636
A
73#include <sys/_types.h>
74#include <sys/cdefs.h>
75
76#ifndef _INO_T
77typedef __darwin_ino_t ino_t; /* inode number */
78#define _INO_T
79#endif
80
81#define __DARWIN_MAXNAMLEN 255
82
83#if __DARWIN_ALIGN_POWER
84#pragma options align=power
85#endif
86
1c79356b 87struct dirent {
91447636
A
88 ino_t d_ino; /* file number of entry */
89 __uint16_t d_reclen; /* length of this record */
90 __uint8_t d_type; /* file type, see below */
91 __uint8_t d_namlen; /* length of string in d_name */
92 char d_name[__DARWIN_MAXNAMLEN + 1]; /* name must be no longer than this */
93};
94
95#if __DARWIN_ALIGN_POWER
96#pragma options align=reset
1c79356b 97#endif
91447636
A
98
99#ifdef KERNEL
100#include <sys/kernel_types.h>
101
102/* Extended directory entry */
103struct direntry{
104 ino64_t d_ino; /* file number of entry */
105 __uint64_t d_seekoff; /* seek offset (optional, used by servers) */
106 __uint16_t d_reclen; /* length of this record */
107 __uint16_t d_namlen; /* length of string in d_name */
108 __uint8_t d_type; /* file type, see below */
109 u_char d_name[MAXPATHLEN - 1]; /* entry name (up to MAXPATHLEN - 1 bytes) */
1c79356b 110};
91447636
A
111#endif
112
1c79356b 113
91447636
A
114#ifndef _POSIX_C_SOURCE
115#define d_fileno d_ino /* backward compatibility */
116#define MAXNAMLEN __DARWIN_MAXNAMLEN
1c79356b
A
117/*
118 * File types
119 */
120#define DT_UNKNOWN 0
121#define DT_FIFO 1
122#define DT_CHR 2
123#define DT_DIR 4
124#define DT_BLK 6
125#define DT_REG 8
126#define DT_LNK 10
127#define DT_SOCK 12
128#define DT_WHT 14
129
130/*
131 * Convert between stat structure types and directory types.
132 */
133#define IFTODT(mode) (((mode) & 0170000) >> 12)
134#define DTTOIF(dirtype) ((dirtype) << 12)
91447636 135#endif
1c79356b
A
136
137#endif /* _SYS_DIRENT_H */