Hello,
Recently I need to create a filesystem related code.
I noticed lot of inconsistent documentation regarding
struct dirent:
-
'd_namlen' field
info libc in chapter ''File System Interface"
specifies 'd_namlen' field as length of 'd_name' string.
When compiling under Linux (and GNU libc obviously)
'd_namlen' is missing. -
'd_reclen'
this field is documented as "length of d_name" in readdir(2) whereas in '/usr/include/dirent.h' it is described as 'size of entire directory entry'. In 'info libc' 'd_reclen' is mentioned but not really described at all. -
'd_off' field
in readdir(2) this is offset to current dirent [from start of the directory], but again in '/usr/include/dirent.h' this is "offset of next directory entry".
I understand that only 'd_name' is really portable and it is enough for my purposes.
But could anybody explain above? In my opinion some of inconsistencies from 2. and 3. are due to readir(2)
possibly deals with kernel 'struct dirent' which can be independent of libc one.
Regards,
Miroslaw
Regards.