Subject: Re: 64 bit inode changes
To: None <tech-kern@netbsd.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-kern
Date: 08/16/2005 20:48:02
On Tue, Aug 16, 2005 at 06:23:13PM +0000, Christos Zoulas wrote:
> 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?
Yeah, looks good. I'd consider _DIRENT_RECLEN, _DIRENT_SIZE and
_DIRENT_NEXT for public use and document them as such. I'm not sure if
_DIRENT_NAMEOFF and _DIRENT_MINSIZE should be used by anything, but
basic sanity checks.
Who submits a patch to use them in GNU make? :-)
Joerg