Re: struct dirent in Linux 2.0

Ulrich Windl (ulrich.windl@rz.uni-regensburg.de)
Wed, 19 Feb 1997 08:09:56 +0100


On 18 Feb 97 at 16:58, Swen Thuemmler wrote:

> On Tue, 18 Feb 1997, Ulrich Windl wrote:
>
> > > The first is definitely not POSIX. *All* POSIX specifies about struct
> > > dirent is that it contain d_name.
> >
> > At least they should specify the zero-termination property of
> > d_name, too. Despite of that the HP-UX manual page on dirent(5)
> > claims that the above structure conforms to AES, SVID2, SVID3, XPG2,
> > XPG3, XPG4, FIPS 151-2, POSIX.1 -- Now what about Linux?
>
> Well, my copy of POSIX.1 (1003.1 from 1988) says:
>
> "The readdir() function returns a pointer to an object of type struct
> dirent that includes the member:
> Member Type Member Name Description
> ----------- ----------- -----------
> char[] d_name Null-terminated filename
> The character array d_name is of unspecified size, but the number of bytes
> preceding the terminating null character shall not exceed {NAME_MAX}."
>
> So it explicitely states, that d_name is zero-terminated. It mentions no
> other members of the dirent structure, so any other member is nonstandard
> (but not explicitly forbidden, you may use it, but then your program does
> not conform to POSIX.1, I think).
>

OK, convinced. Unfortunately the description I had did not
distinguish what was POSIX, and what was an extension to POSIX.

Thanks to everybody who put some light into that!

Ulrich