aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Barcroft <mike@FreeBSD.org>2002-09-10 18:12:16 +0000
committerMike Barcroft <mike@FreeBSD.org>2002-09-10 18:12:16 +0000
commit9ad8e31ee817854515bca6274ff960317dc479bb (patch)
treefe9a9607cb3e929fc652b2ff859bbcf59ff52334
parentb2c6ac5b2b568c2c1ef38bdf93b9e44874eed3da (diff)
Notes
-rw-r--r--include/dirent.h47
-rw-r--r--sys/sys/dirent.h12
2 files changed, 39 insertions, 20 deletions
diff --git a/include/dirent.h b/include/dirent.h
index b3de757a04274..f6e4ccd53c19b 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -41,13 +41,18 @@
* The kernel defines the format of directory entries returned by
* the getdirentries(2) system call.
*/
+#include <sys/cdefs.h>
#include <sys/dirent.h>
-#ifdef _POSIX_SOURCE
-typedef void * DIR;
-#else
+#if __BSD_VISIBLE || __XSI_VISIBLE
+/*
+ * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer
+ * to the specification.
+ */
+#define d_ino d_fileno /* backward and XSI compatibility */
+#endif
-#define d_ino d_fileno /* backward compatibility */
+#if __BSD_VISIBLE
/* definitions for library routines operating on directories. */
#define DIRBLKSIZ 1024
@@ -80,29 +85,37 @@ typedef struct _dirdesc {
#define NULL 0
#endif
-#endif /* _POSIX_SOURCE */
+#else /* !__BSD_VISIBLE */
-#ifndef _KERNEL
+typedef void * DIR;
-#include <sys/cdefs.h>
+#endif /* __BSD_VISIBLE */
+
+#ifndef _KERNEL
__BEGIN_DECLS
+#if __BSD_VISIBLE
+DIR *__opendir2(const char *, int);
+int alphasort(const void *, const void *);
+int getdents(int, char *, int);
+int getdirentries(int, char *, int, long *);
+#endif
DIR *opendir(const char *);
struct dirent *
readdir(DIR *);
+#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
+int readdir_r(DIR *, struct dirent *, struct dirent **);
+#endif
void rewinddir(DIR *);
-int closedir(DIR *);
-#ifndef _POSIX_SOURCE
-DIR *__opendir2(const char *, int);
-long telldir(DIR *);
-void seekdir(DIR *, long);
+#if __BSD_VISIBLE
int scandir(const char *, struct dirent ***,
int (*)(struct dirent *), int (*)(const void *, const void *));
-int alphasort(const void *, const void *);
-int getdents(int, char *, int);
-int getdirentries(int, char *, int, long *);
-int readdir_r(DIR *, struct dirent *, struct dirent **);
-#endif /* not POSIX */
+#endif
+#if __XSI_VISIBLE
+void seekdir(DIR *, long);
+long telldir(DIR *);
+#endif
+int closedir(DIR *);
__END_DECLS
#endif /* !_KERNEL */
diff --git a/sys/sys/dirent.h b/sys/sys/dirent.h
index 9f8cfadc202e7..951a8ef7bdfb7 100644
--- a/sys/sys/dirent.h
+++ b/sys/sys/dirent.h
@@ -37,6 +37,7 @@
#ifndef _SYS_DIRENT_H_
#define _SYS_DIRENT_H_
+#include <sys/cdefs.h>
#include <sys/_types.h>
/*
@@ -55,14 +56,15 @@ struct dirent {
__uint16_t d_reclen; /* length of this record */
__uint8_t d_type; /* file type, see below */
__uint8_t d_namlen; /* length of string in d_name */
-#ifdef _POSIX_SOURCE
- char d_name[255 + 1]; /* name must be no longer than this */
-#else
+#if __BSD_VISIBLE
#define MAXNAMLEN 255
char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
+#else
+ char d_name[255 + 1]; /* name must be no longer than this */
#endif
};
+#if __BSD_VISIBLE
/*
* File types
*/
@@ -87,9 +89,13 @@ struct dirent {
* 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.
+ *
+ * XXX although this macro is in the implementation namespace, it requires
+ * a manifest constant that is not.
*/
#define _GENERIC_DIRSIZ(dp) \
((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
+#endif /* __BSD_VISIBLE */
#ifdef _KERNEL
#define GENERIC_DIRSIZ(dp) _GENERIC_DIRSIZ(dp)