Subject: sys/dir.h vs. sys/dirent.h (and PR kern/2138)
To: None <developers@NetBSD.ORG>
From: Gordon W. Ross <gwr@mc.com>
List: netbsd-bugs
Date: 02/27/1996 17:36:30
Here is an issue somewhat related to PR kern/2138 that I'd
like some feedback about.  Is <sys/dir.h> really obsolete?
(Comments in that file suggest that it is.)  If so, I'd like
to eliminate its use from the kernel.  That's easy to do
(changes attached) but is it a good idea?  Should I do it?

Gordon

[ Changes to eliminate <sys/dir.h> from the kernel: ]

Change <sys/dir.h> to <sys/dirent.h> in:

M compat/sunos/sunos_misc.c
M isofs/cd9660/cd9660_util.c
M isofs/cd9660/cd9660_vnops.c

and apply the following change to <sys/dirent.h>

*** sys/dirent.h.~1~	Sat Feb  3 23:27:49 1996
--- sys/dirent.h	Tue Feb 27 17:10:32 1996
***************
*** 77,79 ****
--- 77,91 ----
   */
  #define	IFTODT(mode)	(((mode) & 0170000) >> 12)
  #define	DTTOIF(dirtype)	((dirtype) << 12)
+ 
+ #ifdef	_KERNEL
+ /*
+  * The DIRSIZ macro gives the minimum record length which will hold
+  * the directory entry.  This requires the amount of space in struct dirent
+  * 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	DIRSIZ(dp) \
+     ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
+ 
+ #endif	/* !_KERNEL */