summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-02-24 02:39:00 +0000
committerbde <bde@FreeBSD.org>1998-02-24 02:39:00 +0000
commitfe00dbc3ff63d7a5982cc7aacca4344a8e781bde (patch)
tree24115a66dd5c124a3a5d1085da531f93fa085557 /share
parentb4cedfe9698269025044d4f6f3b19ab2a94e3a05 (diff)
downloadFreeBSD-src-fe00dbc3ff63d7a5982cc7aacca4344a8e781bde.zip
FreeBSD-src-fe00dbc3ff63d7a5982cc7aacca4344a8e781bde.tar.gz
Update to sort of match reality by literally including <sys/dirent.h>
instead of a pre-BSD4.4 version of <dirent.h>. The old version had library goop which is still in <dirent.h>. See reality if you want real details.
Diffstat (limited to 'share')
-rw-r--r--share/man/man5/dir.5104
1 files changed, 46 insertions, 58 deletions
diff --git a/share/man/man5/dir.5 b/share/man/man5/dir.5
index b50a3c4..3c038bd 100644
--- a/share/man/man5/dir.5
+++ b/share/man/man5/dir.5
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)dir.5 8.3 (Berkeley) 4/19/94
-.\" $Id: dir.5,v 1.7 1997/02/22 13:25:58 peter Exp $
+.\" $Id: dir.5,v 1.8 1997/03/19 03:48:12 bde Exp $
.\"
.Dd April 19, 1994
.Dt DIR 5
@@ -81,81 +81,69 @@ and
.Xr mount 8 . )
.Pp
The directory entry format is defined in the file
-.Aq dirent.h :
+.Aq sys/dirent.h
+(which should not be included directly by applications):
.Bd -literal
-#ifndef _DIRENT_H_
-#define _DIRENT_H_
+#ifndef _SYS_DIRENT_H_
+#define _SYS_DIRENT_H_
/*
-* A directory entry has a struct dirent at the front of it, containing its
-* inode number, the length of the entry, and the length of the name
-* contained in the entry. These are followed by the name padded to a 4
-* byte boundary with null bytes. All names are guaranteed null terminated.
-* The maximum length of a name in a directory is MAXNAMLEN.
-*/
+ * The dirent structure defines the format of directory entries returned by
+ * the getdirentries(2) system call.
+ *
+ * A directory entry has a struct dirent at the front of it, containing its
+ * inode number, the length of the entry, and the length of the name
+ * contained in the entry. These are followed by the name padded to a 4
+ * byte boundary with null bytes. All names are guaranteed null terminated.
+ * The maximum length of a name in a directory is MAXNAMLEN.
+ */
struct dirent {
- u_long d_fileno; /* file number of entry */
- u_short d_reclen; /* length of this record */
- u_char d_type; /* file type, see below */
- u_char d_namlen; /* length of string in d_name */
+ u_int32_t d_fileno; /* file number of entry */
+ u_int16_t d_reclen; /* length of this record */
+ u_int8_t d_type; /* file type, see below */
+ u_int8_t d_namlen; /* length of string in d_name */
#ifdef _POSIX_SOURCE
- char d_name[255 + 1]; /* maximum name length */
+ char d_name[255 + 1]; /* name must be no longer than this */
#else
-#define MAXNAMLEN 255
- char d_name[MAXNAMLEN + 1]; /* maximum name length */
+#define MAXNAMLEN 255
+ char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
#endif
-
};
/*
* File types
*/
-#define DT_UNKNOWN 0
-#define DT_FIFO 1
-#define DT_CHR 2
-#define DT_DIR 4
-#define DT_BLK 6
-#define DT_REG 8
-#define DT_LKN 10
-#define DT_SOCK 12
-#define DT_WHT 14
-
-#ifdef _POSIX_SOURCE
-typedef void * DIR;
-#else
-
-#define d_ino d_fileno /* backward compatibility */
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
-/* definitions for library routines operating on directories. */
-#define DIRBLKSIZ 1024
-
-/* structure describing an open directory. */
-typedef struct _dirdesc {
- int dd_fd; /* file descriptor associated with directory */
- long dd_loc; /* offset in current buffer */
- long dd_size; /* amount of data returned by getdirentries */
- char *dd_buf; /* data buffer */
- int dd_len; /* size of data buffer */
- long dd_seek; /* magic cookie returned by getdirentries */
- long dd_rewind;/* magic cookie for rewinding */
-} DIR;
+/*
+ * Convert between stat structure types and directory types.
+ */
+#define IFTODT(mode) (((mode) & 0170000) >> 12)
+#define DTTOIF(dirtype) ((dirtype) << 12)
-#define dirfd(dirp) ((dirp)->dd_fd)
+/*
+ * The _GENERIC_DIRSIZ macro gives the minimum record length which will hold
+ * the directory entry. This requires the amount of space in struct direct
+ * without the d_name field, plus enough space for the name with a terminating
+ * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
+ */
+#define _GENERIC_DIRSIZ(dp) \
+ ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
-#ifndef NULL
-#define NULL 0
+#ifdef KERNEL
+#define GENERIC_DIRSIZ(dp) _GENERIC_DIRSIZ(dp)
#endif
-#endif /* _POSIX_SOURCE */
-
-#ifndef KERNEL
-
-#include <sys/cdefs.h>
-
-#endif /* !KERNEL */
-
-#endif /* !_DIRENT_H_ */
+#endif /* !_SYS_DIRENT_H_ */
.Ed
.Sh SEE ALSO
.Xr fs 5 ,
OpenPOWER on IntegriCloud