[comp.bugs.4bsd] 4.3BSD-Reno /usr/include/{sys/dir.h,dirent.h} break namei.h, DIRBLKSIZ

jonathan@toru.isor.vuw.ac.nz (Jonathan Stone) (06/17/91)

Subject: 4.3BSD-Reno /usr/include/{sys/dir.h,dirent.h} break namei.h, DIRBLKSIZ
Index:  /usr/include/dirent.h /usr/include/sys/dir.h  /usr/include/sys/namei.h
      /usr/include/ufs/dir.h

Description:
	The 4.3BSD-Reno release includes a placebo /usr/include/sys/dir.h
	for "backward compatibility".   The sys/dir.h file simply includes
	/usr/include/dirent.h, and defines a backward-compatible
	DIRSIZ macro.  Unfortunately, it also  ``direct'' to
	be ``dirent'', which breaks the definition of a ``struct direct''
	in ufs/dir.h,  which is in turn included by sys/namei.h.
	
	The macro DIRBLKSIZ is defined to be 1024 within
	/usr/include/dirent.h, and also (inconsistently) defined to
	be DEV_BSIZE in ufs/dir.h.   While DEV_BSIZE is fortuitously
	1024 on a CCI tahoe, on a vax or hp300, DEV_BSIZE is 512,
	not 1024.

	Both these problems break programs that include both
	<sys/dir.h> and <sys/user.h> (for example, gdb,	the GNU	debugger).
	

Repeat-By:
	Try and compile the following six-line program on a vax:

		#include <sys/types.h>
		#include <sys/dir.h>
		#include <sys/user.h.h>
		main ()
		{
		}

	I get the following output:

		nikau> cc -c dir-include-foulup.c
		/usr/include/ufs/dir.h: 51: DIRBLKSIZ redefined
		"/usr/include/ufs/dir.h", line 54: redeclaration of dirent


Workaround:
	One obvious workaround is to include <dirent.h> instead of
	<sys/dir.h>,  which fixes the problem with the ``struct direct''
	in ufs/dir.h.  But that does not fix the DIRBLKSIZ inconsistency.