Reputation: 167
I'm having some difficulty understanding the meaning behind all this parameters in the dirent structure.
struct dirent{
ino_t d_ino; Inode number
off_t d_off; Not an offset; see below
unsigned short d_reclen; Length of this record
unsigned chart d_type; Type of file;
not supported by all filesystem types
char d_name[256]; Null-Terminated filename
}
I really need to understand this because I have to work on some files. Correct if I'm wrong, this struct is returned when you use opendir on a DIR* object right? This object is non-other than metadata of the file inside the directory, and every time I use it will return me the metadata of the next file, right?
The parameters that I don't understand are: d_off -> not an offset? What is it then? See below where? I checked the original page with all the info and I couldn't find where was I supposed to look. d_type -> what do they mean with "not supported by all filesystem types"? Which filesystem should I look out for? Okay, with this information how can I open the file on which I have to modify the data? Do I just use the d_name, or is there something way more comfortable I can rely on? Those are all my doubts, thank you in advance.
Upvotes: 2
Views: 579
Reputation: 409442
The POSIX standard only defines the structure to have d_ino
and d_name
. The remaining structure fields are Linux specific.
The Linux manual page says that d_off
is related to the telldir
function, and that it should be considered an opaque value.
In short, you should never need to read or otherwise use this member.
As for the d_type
member, its meaning and values is well-documented in the Linux manual page. On any normal filesystem it should be valid.
Upvotes: 1