| Updated: October 28, 2024 |
Data structure for a directory entry
#include <dirent.h>
struct dirent {
#if __OFF_BITS__ == 64
ino_t d_ino;
off_t d_offset;
#elif __OFF_BITS__ == 32
# if defined(__LITTLEENDIAN__)
ino_t d_ino;
ino_t d_ino_hi;
off_t d_offset;
off_t d_offset_hi;
# elif defined(__BIGENDIAN__)
ino_t d_ino_hi;
ino_t d_ino;
off_t d_offset_hi;
off_t d_offset;
# else
# error endian not configured for system
# endif
#else
# error __OFF_BITS__ value is unsupported
#endif
int16_t d_reclen;
int16_t d_namelen;
char d_name[1]);
};
#ifdef __EXT_LF64SRC
struct dirent64 {
ino64_t d_ino;
off64_t d_offset;
int16_t d_reclen;
int16_t d_namelen;
char d_name[1]);
};
#endif
The dirent structure describes an entry in a directory. The dirent64 structure is for large-file support.
The members include:
These structures provide d_name as a place-holder for the start of the name, but do not supply storage for more than the leading bytes in the name.
If using readdir(), the dirent structures returned by this function supply enough space to hold the entire name.
offsetof(struct dirent, d_name) + PATH_MAX
dirent is POSIX 1003.1; dirent64 is Large-file support