This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: struct dirent.d_reclen


On Tue, Sep 01, 2009 at 05:39:02PM +0000, Eric Blake wrote:
>Wish list (probably post 7.1): As long as we are making struct dirent more like 
>Linux with the recent addition of d_type, we should probably also burn two of 
>the remaining 3 __d_unused1 bytes to declare unsigned short d_reclen, whose 
>value is always strlen(d_name), so that applications could get by with fewer 
>strlen calls.  Coreutils ls would certainly benefit from this optimization.

Defining d_*rec*len as strlen(d_name) would not be correct since that is
supposed to be the length of the record not the name.  That's why linux
has macros that look like this:

#  define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0])

Maybe you mean d_namlen?

It is not a given that adding d_reclen would speed anything up since it
cause every single program that uses dirent to effectively perform a
strlen on every record returned by readdir whether it needed that field
or not.  Making sure that field was filled out would also complicate
Cygwin's internal logic.

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]