usched: Allow process to change self cpu affinity
[dragonfly.git] / sys / sys / dirent.h
blob4bd1ef7368d87159630f29fbaec5190358800ed1
1 /*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * @(#)dirent.h 8.3 (Berkeley) 8/10/94
30 * $FreeBSD: src/sys/sys/dirent.h,v 1.11 1999/12/29 04:24:39 peter Exp $
33 #ifndef _SYS_DIRENT_H_
34 #define _SYS_DIRENT_H_
37 * The dirent structure defines the format of directory entries returned by
38 * the getdirentries(2) system call.
40 * A directory entry has a struct dirent at the front of it, containing its
41 * inode number, the length of the entry, and the length of the name
42 * contained in the entry. These are followed by the name padded to a 8
43 * byte boundary with null bytes. All names are guaranteed null terminated.
47 * XXX Temporary bandaids to keep changes small:
48 * XXX - for userland programs which don't specify any C or POSIX options,
49 * XXX keep the old d_fileno and map d_ino via macro. Everything else gets
50 * XXX the POSIX d_ino and only that.
51 * XXX - d_name is declared with the current maximum directory entry length,
52 * XXX instead of being incomplete. Code must allocate space for the
53 * XXX directory itself.
56 #include <sys/cdefs.h>
57 #include <sys/types.h>
59 struct dirent {
60 #if defined(_KERNEL) || !__BSD_VISIBLE
61 ino_t d_ino; /* file number of entry */
62 #else
63 ino_t d_fileno; /* file number of entry */
64 #endif
65 uint16_t d_namlen; /* strlen(d_name) */
66 uint8_t d_type; /* file type, see blow */
67 uint8_t d_unused1; /* padding, reserved */
68 uint32_t d_unused2; /* reserved */
69 char d_name[255 + 1];
70 /* name, NUL-terminated */
74 * Linux compatibility, but its a good idea anyhow
76 #define _DIRENT_HAVE_D_NAMLEN
77 #define _DIRENT_HAVE_D_TYPE
79 #if !defined(_KERNEL) && __BSD_VISIBLE
80 #define d_ino d_fileno
81 #endif
84 * File types
86 #define DT_UNKNOWN 0
87 #define DT_FIFO 1
88 #define DT_CHR 2
89 #define DT_DIR 4
90 #define DT_BLK 6
91 #define DT_REG 8
92 #define DT_LNK 10
93 #define DT_SOCK 12
94 #define DT_WHT 14
95 #define DT_DBF 15 /* database record file */
98 * The _DIRENT_DIRSIZ macro gives the minimum record length which will hold
99 * the directory entry. This requires the amount of space in struct dirent
100 * without the d_name field, plus enough space for the name with a terminating
101 * null byte (dp->d_namlen+1), rounded up to an 8 byte boundary.
103 * The _DIRENT_MINSIZ macro gives space needed for the directory entry without
104 * the padding _DIRENT_DIRSIZ adds at the end.
106 #define _DIRENT_MINSIZ(dp) \
107 (__offsetof(struct dirent, d_name) + (dp)->d_namlen + 1)
108 #define _DIRENT_RECLEN(namelen) \
109 ((__offsetof(struct dirent, d_name) + (namelen) + 1 + 7) & ~7)
110 #define _DIRENT_DIRSIZ(dp) _DIRENT_RECLEN((dp)->d_namlen)
111 #define _DIRENT_NEXT(dp) \
112 ((struct dirent *)((uint8_t *)(dp) + _DIRENT_DIRSIZ(dp)))
114 #endif /* !_SYS_DIRENT_H_ */