Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / platform / pc32 / 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  */\r
37 \r
38 #ifndef _DIRENT_H_\r
39 #define _DIRENT_H_\r
40 \r
41 /*\r
42  * A directory entry has a struct dirent at the front of it, containing its\r
43  * inode number, the length of the entry, and the length of the name\r
44  * contained in the entry.  These are followed by the name padded to a 4\r
45  * byte boundary with null bytes.  All names are guaranteed null terminated.\r
46  * The maximum length of a name in a directory is MAXNAMLEN.\r
47  */\r
48 \r
49 struct dirent {\r
50         u_long  d_fileno;               /* file number of entry */\r
51         u_short d_reclen;               /* length of this record */\r
52         u_short d_namlen;               /* length of string in d_name */\r
53 #ifdef _POSIX_SOURCE\r
54         char    d_name[255 + 1];        /* name must be no longer than this */\r
55 #else\r
56 #define MAXNAMLEN       255\r
57         char    d_name[MAXNAMLEN + 1];  /* name must be no longer than this */\r
58 #endif\r
59 };\r
60 \r
61 #ifdef _POSIX_SOURCE\r
62 typedef void *  DIR;\r
63 #else\r
64 \r
65 #define d_ino           d_fileno        /* backward compatibility */\r
66 \r
67 /* definitions for library routines operating on directories. */\r
68 #define DIRBLKSIZ       1024\r
69 \r
70 /* structure describing an open directory. */\r
71 typedef struct _dirdesc {\r
72         long    dd_fd;          /* file descriptor associated with directory */\r
73         long    dd_loc;         /* offset in current buffer */\r
74         long    dd_size;        /* amount of data returned by getdirentries */\r
75         char    *dd_buf;        /* data buffer */\r
76         long    dd_len;         /* size of data buffer */\r
77         long    dd_seek;        /* magic cookie returned by getdirentries */\r
78         void    *dd_ddloc;      /* Linked list of ddloc structs for telldir/seekdir */\r
79 } DIR;\r
80 \r
81 #define dirfd(dirp)     ((dirp)->dd_fd)\r
82 \r
83 #ifndef NULL\r
84 #define NULL    0\r
85 #endif\r
86 \r
87 #endif /* _POSIX_SOURCE */\r
88 \r
89 #ifndef KERNEL\r
90 \r
91 #include "cdefs.h"\r
92 \r
93 __BEGIN_DECLS\r
94 DIR *opendir __P((const char *));\r
95 struct dirent *readdir __P((DIR *));\r
96 void rewinddir __P((DIR *));\r
97 int closedir __P((DIR *));\r
98 #ifndef _POSIX_SOURCE\r
99 long telldir __P((const DIR *));\r
100 void seekdir __P((DIR *, long));\r
101 int scandir __P((const char *, struct dirent ***,\r
102     int (*)(struct dirent *), int (*)(const void *, const void *)));\r
103 int alphasort __P((const void *, const void *));\r
104 int getdirentries __P((int, char *, int, long *));\r
105 #endif /* not POSIX */\r
106 __END_DECLS\r
107 \r
108 #endif /* !_KERNEL */\r
109 \r
110 #endif /* !_DIRENT_H_ */\r