[lkml]   [1997]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: struct dirent in Linux 2.0
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).

Greetings, Swen

 \ /
  Last update: 2005-03-22 13:38    [W:0.050 / U:3.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site