Members of Dirent structure

Naruto picture Naruto · Oct 20, 2012 · Viewed 88.6k times · Source

I have started working with dirent.h library and I came across a very useful member of "struct dirent" structer which struct dirent *p->d_name in my book. But unfortunatly it doesn't states any other members of this structure;

I was wondering what else are the members of this structure and what are they used for?

Regards

Answer

askmish picture askmish · Oct 20, 2012

The structure, struct dirent refers to directory entry.

http://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html

In linux it is defined as:

struct dirent {
    ino_t          d_ino;       /* inode number */
    off_t          d_off;       /* offset to the next dirent */
    unsigned short d_reclen;    /* length of this record */
    unsigned char  d_type;      /* type of file; not supported
                                   by all file system types */
    char           d_name[256]; /* filename */
};

refer: man readdir

Or just look for "dirent.h" in the include directory.