Subject: Re: 64 bit inode changes
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 08/16/2005 18:23:13
In article <20050816135642.GJ987@britannica.bec.de>,
Joerg Sonnenberger  <joerg@britannica.bec.de> wrote:
>On Tue, Aug 16, 2005 at 03:28:03PM +0200, Joerg Sonnenberger wrote:
>> On Tue, Aug 16, 2005 at 12:32:41AM +0000, Christos Zoulas wrote:
>> > In article <20050815233221.GB1595@britannica.bec.de>,
>> > Joerg Sonnenberger  <joerg@britannica.bec.de> wrote:
>> > >> Sounds like fine names to me. I will change mine. Does your ALLOC take
>> > >> one or two arguments? What about NEXT?
>> > >
>> > >_DIRENT_ALLOC takes one argument, the length of the filename.
>> > 
>> > And returns a size, right? Then a better name would be _DIRENT_RECLEN(). I
>> > am passing the struct too, for symmetry with DIRENT_ADVANCE.
>> 
>> I intended to use it for allocation for dirents, e.g. by callers of
>> readdir_r. You don't have a struct dirent there.
>
>Actually, we want to have both. I've used _DIRENT_DIRSIZ for the version
>with struct dirent * as argument, but _DIRENT_RECLEN is better.

Here's what I have now:

/* 
 * The _DIRENT_NAMEOFF macro returns the offset of the d_name field in
 * struct dirent
 */
#define _DIRENT_NAMEOFF(dp) \
    ((char *)(void *)&(dp)->d_name - (char *)(void *)dp)
/* 
 * The _DIRENT_RECLEN macro gives the minimum record length which will hold
 * a name of size "namlen".  This requires the amount of space in struct dirent
 * without the d_name field, plus enough space for the name with a terminating
 * null byte (namlen+1), rounded up to a 16 byte boundary.
 */     
#define _DIRENT_RECLEN(dp, namlen) \     
    ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + 0xf) & ~0xf)
/*
 * The _DIRENT_SIZE macro returns the minimum record length required for
 * name name stored in the current record. 
 */  
#define _DIRENT_SIZE(dp) _DIRENT_RECLEN(dp, (dp)->d_namlen)
/*
 * The _DIRENT_NEXT macro advances to the next dirent record.
 */
#define _DIRENT_NEXT(dp) ((void *)((char *)(void *)(dp) + (dp)->d_reclen))
/* 
 * The _DIRENT_MINSIZE returns the size of an empty (invalid) record.
 */
#define _DIRENT_MINSIZE(dp) _DIRENT_RECLEN(dp, 0)

Is that a good set for you?

christos