Messages in this thread |  | | Date | Wed, 19 Feb 1997 01:00:49 -0800 (PST) | From | Chad Page <> | Subject | Re: struct dirent in Linux 2.0 |
| |
On Wed, 19 Feb 1997, Ulrich Windl wrote:
> > 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. > One other question - is the address returned by readdir valid only until the next readdir for the directory in question, or just the next readdir. Basically, what I'm asking is if in the case of Linux/8086, where data segement space is tight, can the library code get away with allocating just one dirent structure, regardless of the number of directories open? If so, it could be implemented rather easily. (Or, in worst case, does *each* readdir have to have a different dirent?)
IMHO, the entire readdir() idea dosen't jive well with the core UNIX syscalls, since the library returns a pointer, instead of having one preinitialized... oh well. (It's impossible to do a pure in-kernel implementation of readdir() under ELKS because of this...) Thanks...
- Chad
|  |