minix/nbsd_include/sys/dirent.h
Gianluca Guida f19a4bf1c4 Various fixes for NBSD include.
This patch include various fixes to NBSD includes.

- unistd.h: Avoid different linkages on non-_NETBSD_SOURCE 
 compilation;
- stdlib.h: remove devname declaration.
- sys/select.h: Add _MINIX specific flags.
- limits.h: Add SYMLOOP_MAX and SYMLINK_MAX
- time.h: Fix CLOCKS_PER_SEC and remove BSD's timer_t, as it
  confuses minix own specific timers.
- utmp.h: Set Minix-specific paths and use Minix utmp format.
- param.h: Do not set BSD4_4, as this mostly means sa_len in
  struct sock_addr.
- arch/i386/include/param.h: include <machine/vmparam.h> to 
  add PAGE_SIZE and related macros, defined round_page() and
  trunc_page() for minix compatibility.

- dirent.h: remove DIRBLKSIZ and fix d_ino/d_fileno.
- sys/dir.h: ADD from existing includes and edit include
  conditions.
- sys/dirent.h: include <minix/dirent.h>, fix d_ino/d_fileno.

- sys/fd_set.h: set default FD_SETSIZE at __MINIX_OPENMAX, as 
  the default NetBSD value is too big and cause vfs to return
  an error.
- sys/cdefs.h: Always include <minix/ansi.h>

- minix/paths.h: Add Minix-specific paths.
- minix/dirent.h: ADD, keep only "direct" and "flex"definitions.
- minix/types.h: include <minix/ansi.h>

- sys/Makefile: add sys/dirent.h and statfs.h (forgot!)
- minix/Makefile: add minix/dirent.h

   nbsd_include/minix-port.patch updated accordingly.
2011-03-04 23:15:48 +00:00

69 lines
2.1 KiB
C

#ifndef _SYS_DIRENT_H_
#define _SYS_DIRENT_H_
#include <sys/cdefs.h>
#include <sys/featuretest.h>
#include <minix/dirent.h>
/*
* The dirent structure defines the format of directory entries returned by
* the getdents(2) system call.
*/
struct dirent { /* Largest entry (8 slots) */
ino_t d_ino; /* I-node number */
off_t d_off; /* Offset in directory */
unsigned short d_reclen; /* Length of this record */
char d_name[1]; /* Null terminated name */
};
#if defined(_NETBSD_SOURCE)
#define d_fileno d_ino
#endif
#define _DIRENT_NAME_LEN 61 /* Backward compatibility with Minix. */
#if defined(_NETBSD_SOURCE)
#define MAXNAMLEN _DIRENT_NAME_LEN
#endif
/*
* The _DIRENT_ALIGN macro returns the alignment of struct dirent. It
* is used to check for bogus pointers and to calculate in advance the
* memory required to store a dirent.
* Unfortunately Minix doesn't use any standard alignment in dirents
* at the moment, so, in order to calculate a safe dirent size, we add
* an arbitrary number of bytes to the structure (_DIRENT_PAD), and we
* set _DIRENT_ALIGN to zero to pass the pointers checks.
* Please, FIXME.
*/
#define _DIRENT_ALIGN(dp) 0
#define _DIRENT_PAD 64
/*
* The _DIRENT_NAMEOFF macro returns the offset of the d_name field in
* struct dirent
*/
#define _DIRENT_NAMEOFF(dp) \
((char *)(void *)&(dp)->d_name - (char *)(void *)dp)
/*
* The _DIRENT_RECLEN macro gives the minimum record length which will hold
* a name of size "namlen".
*/
#define _DIRENT_RECLEN(dp, namlen) \
((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_PAD + _DIRENT_ALIGN(dp)) & \
~_DIRENT_ALIGN(dp))
/*
* The _DIRENT_SIZE macro returns the minimum record length required for
* name name stored in the current record.
*/
#define _DIRENT_SIZE(dp) _DIRENT_RECLEN(dp, strlen(dp->d_name))
/*
* The _DIRENT_NEXT macro advances to the next dirent record.
*/
#define _DIRENT_NEXT(dp) ((void *)((char *)(void *)(dp) + (dp)->d_reclen))
/*
* The _DIRENT_MINSIZE returns the size of an empty (invalid) record.
*/
#define _DIRENT_MINSIZE(dp) _DIRENT_RECLEN(dp, 0)
#endif /* !_SYS_DIRENT_H_ */