Subject: RE: 64 bit inode changes
To: Christos Zoulas <tech-kern@netbsd.org>
From: Gordon Waidhofer <gww@traakan.com>
List: tech-kern
Date: 08/16/2005 16:40:30
> >
> >#define _DIRENT_RECLEN(dp, namlen) \
> > ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + 0xf) & ~0xf)
> >
> >Does this 0xF alignment hold for all variants of dirent?
>
> Unfortunately not. Our on-disk struct direct and struct dirent12 use 0x3.
> I thought about parameterizing this one, but did not. instead i do:
>
> #define _DIRENT12_RECLEN(dp, namlen) \
> ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + 0x3) & ~0x3)
>
> I thought about defining the # in another macro or using some
> ugliness like:
>
> #define _DIRENT_ALIGN(dp)
> (/*CONSTCOND*/sizeof(dp->d_namlen) == sizeof(uint8_t) ? 0x3 : 0xf)
>
> #define _DIRENT_RECLEN(dp, namlen) \
> ((_DIRENT_NAMEOFF(dp) + (namlen) + 1 + _DIRENT_ALIGN(dp)) & \
> ~_DIRENT_ALIGN(dp))
>
> but I decided to use a separate macro..
How does readdir(3) locate the next directory entry?
Using dp->d_reclen or DIRENT_RECLEN?