readdir function returns inconsistent d_type

Bug #1321091 reported by Veiokej
6
This bug affects 1 person
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-referential symbolic link with DT_LNK asserted. But when I install an Ubuntu 14.04 64-bit desktop image to a USB stick (using either Startup Disk Creator or the Disk utility, sorry I don't recall), I get a similar circularly-referential directory called "ubuntu". This symbolic link does not have DT_LNK set. lstat can get around this problem and see the link attribute, but the bug here is that d_type is not the expected value. I based all this on "man readdir", so it might be just a doc bug.

By "circularly referential", I mean a symbolic link to "." (current folder).

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

"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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.