1 /*- 2 * Copyright (c) 1989 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)dirent.h 5.17 (Berkeley) 02/22/91 8 */ 9 10 #ifndef _DIRENT_H_ 11 #define _DIRENT_H_ 12 13 /* 14 * A directory entry has a struct dirent at the front of it, containing its 15 * inode number, the length of the entry, and the length of the name 16 * contained in the entry. These are followed by the name padded to a 4 17 * byte boundary with null bytes. All names are guaranteed null terminated. 18 * The maximum length of a name in a directory is MAXNAMLEN. 19 */ 20 21 struct dirent { 22 u_long d_fileno; /* file number of entry */ 23 u_short d_reclen; /* length of this record */ 24 u_short d_namlen; /* length of string in d_name */ 25 #ifdef _POSIX_SOURCE 26 char d_name[255 + 1]; /* name must be no longer than this */ 27 #else 28 #define MAXNAMLEN 255 29 char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ 30 #endif 31 }; 32 33 #ifdef _POSIX_SOURCE 34 typedef void * DIR; 35 #else 36 37 #define d_ino d_fileno /* backward compatibility */ 38 39 /* definitions for library routines operating on directories. */ 40 #define DIRBLKSIZ 1024 41 42 /* structure describing an open directory. */ 43 typedef struct _dirdesc { 44 int dd_fd; /* file descriptor associated with directory */ 45 long dd_loc; /* offset in current buffer */ 46 long dd_size; /* amount of data returned by getdirentries */ 47 char *dd_buf; /* data buffer */ 48 int dd_len; /* size of data buffer */ 49 long dd_seek; /* magic cookie returned by getdirentries */ 50 } DIR; 51 52 #define dirfd(dirp) ((dirp)->dd_fd) 53 54 #ifndef NULL 55 #define NULL 0 56 #endif 57 58 #endif /* _POSIX_SOURCE */ 59 60 #ifndef KERNEL 61 62 #include <sys/cdefs.h> 63 64 __BEGIN_DECLS 65 DIR *opendir __P((const char *)); 66 struct dirent *readdir __P((DIR *)); 67 void rewinddir __P((DIR *)); 68 int closedir __P((DIR *)); 69 #ifndef _POSIX_SOURCE 70 long telldir __P((const DIR *)); 71 void seekdir __P((DIR *, long)); 72 int scandir __P((const char *, struct dirent ***, 73 int (*)(struct dirent *), int (*)(void *, void *))); 74 int alphasort __P((const void *, const void *)); 75 int getdirentries __P((int, char *, int, long *)); 76 #endif /* not POSIX */ 77 __END_DECLS 78 79 #endif /* !KERNEL */ 80 81 #endif /* !_DIRENT_H_ */ 82