Fix minor buildworld issues, mainly #include file dependancies and fields
[dragonfly.git] / sys / i386 / boot / dosboot / dirent.h
1 /*-\r
2  * Copyright (c) 1989 The Regents of the University of California.\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  * 1. Redistributions of source code must retain the above copyright\r
9  *    notice, this list of conditions and the following disclaimer.\r
10  * 2. Redistributions in binary form must reproduce the above copyright\r
11  *    notice, this list of conditions and the following disclaimer in the\r
12  *    documentation and/or other materials provided with the distribution.\r
13  * 3. All advertising materials mentioning features or use of this software\r
14  *    must display the following acknowledgement:\r
15  *      This product includes software developed by the University of\r
16  *      California, Berkeley and its contributors.\r
17  * 4. Neither the name of the University nor the names of its contributors\r
18  *    may be used to endorse or promote products derived from this software\r
19  *    without specific prior written permission.\r
20  *\r
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
31  * SUCH DAMAGE.\r
32  *\r
33  *      @(#)dirent.h    5.18 (Berkeley) 2/23/91\r
34  *\r
35  * $FreeBSD: src/sys/i386/boot/dosboot/dirent.h,v 1.2 1999/12/29 04:32:50 peter Exp $\r
36  * $DragonFly: src/sys/i386/boot/dosboot/Attic/dirent.h,v 1.2 2003/06/17 04:28:34 dillon Exp $\r
37  */\r
38 \r
39 #ifndef _DIRENT_H_\r
40 #define _DIRENT_H_\r
41 \r
42 /*\r
43  * A directory entry has a struct dirent at the front of it, containing its\r
44  * inode number, the length of the entry, and the length of the name\r
45  * contained in the entry.  These are followed by the name padded to a 4\r
46  * byte boundary with null bytes.  All names are guaranteed null terminated.\r
47  * The maximum length of a name in a directory is MAXNAMLEN.\r
48  */\r
49 \r
50 struct dirent {\r
51         u_long  d_fileno;               /* file number of entry */\r
52         u_short d_reclen;               /* length of this record */\r
53         u_short d_namlen;               /* length of string in d_name */\r
54 #ifdef _POSIX_SOURCE\r
55         char    d_name[255 + 1];        /* name must be no longer than this */\r
56 #else\r
57 #define MAXNAMLEN       255\r
58         char    d_name[MAXNAMLEN + 1];  /* name must be no longer than this */\r
59 #endif\r
60 };\r
61 \r
62 #ifdef _POSIX_SOURCE\r
63 typedef void *  DIR;\r
64 #else\r
65 \r
66 #define d_ino           d_fileno        /* backward compatibility */\r
67 \r
68 /* definitions for library routines operating on directories. */\r
69 #define DIRBLKSIZ       1024\r
70 \r
71 /* structure describing an open directory. */\r
72 typedef struct _dirdesc {\r
73         long    dd_fd;          /* file descriptor associated with directory */\r
74         long    dd_loc;         /* offset in current buffer */\r
75         long    dd_size;        /* amount of data returned by getdirentries */\r
76         char    *dd_buf;        /* data buffer */\r
77         long    dd_len;         /* size of data buffer */\r
78         long    dd_seek;        /* magic cookie returned by getdirentries */\r
79         void    *dd_ddloc;      /* Linked list of ddloc structs for telldir/seekdir */\r
80 } DIR;\r
81 \r
82 #define dirfd(dirp)     ((dirp)->dd_fd)\r
83 \r
84 #ifndef NULL\r
85 #define NULL    0\r
86 #endif\r
87 \r
88 #endif /* _POSIX_SOURCE */\r
89 \r
90 #ifndef KERNEL\r
91 \r
92 #include "cdefs.h"\r
93 \r
94 __BEGIN_DECLS\r
95 DIR *opendir __P((const char *));\r
96 struct dirent *readdir __P((DIR *));\r
97 void rewinddir __P((DIR *));\r
98 int closedir __P((DIR *));\r
99 #ifndef _POSIX_SOURCE\r
100 long telldir __P((const DIR *));\r
101 void seekdir __P((DIR *, long));\r
102 int scandir __P((const char *, struct dirent ***,\r
103     int (*)(struct dirent *), int (*)(const void *, const void *)));\r
104 int alphasort __P((const void *, const void *));\r
105 int getdirentries __P((int, char *, int, long *));\r
106 #endif /* not POSIX */\r
107 __END_DECLS\r
108 \r
109 #endif /* !_KERNEL */\r
110 \r
111 #endif /* !_DIRENT_H_ */\r