>> The getdents() call returns a structure which looks like:
>>
>> typedef struct dirent {
>>         ino_t           d_ino;          /* "inode number" of entry */
>>         off_t           d_off;          /* offset of disk directory entry */
>>         unsigned short  d_reclen;       /* length of this record */
>>         char            d_name[1];      /* name of file */
>> } dirent_t;
>>
>> It's easy to store the little bit of additional information by
>> bumping d_reclen and adding it add the end.
>>
>> This would not be noticable as the name is NUL terminated and we
>> control all the getdents return paths in the kernel.
>>
>> For the readdir() call it gets trickier but still not impossible.
>
>Du you like to use strlen in the access macro?

No, but it could easily be defined as something like:

#define FTYPE(dent)             (((char *)dent + dent->d_reclen - 1)[0])

(make it the last byte of the record)

There's one issue, though, readdir_r does not allow this bit of
trickery :-(  But then, nobody in his right mind uses it anyway.

Casper

Reply via email to