readdir function returns inconsistent d_type
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gnome-terminal (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Due to lack of time, I can't investigate this, but I repeatedly observed it. Basically, when you call readdir, it returns a struct dirent. The d_type field is supposed to be DT_LNK for symbolic links when _DIRENT_HAVE_D_TYPE is known to the compiler (which it is). This is usually true, for example /usr/bin/X11 is a circularly-
By "circularly referential", I mean a symbolic link to "." (current folder).
"man readdir" also says:
Currently, only some filesystems (among them: Btrfs, ext2, ext3, and
ext4) have full support for returning the file type in d_type. All
applications must properly handle a return of DT_UNKNOWN.
You need to do an lstat in this case, as you said. This is the expected behavior.
This has absolutely nothing to do with gnome-terminal.