This behaviour related with the XFS filesystem design.
Normally you have to make a
stat() call to get type of the entry which returns from
Stat system call gets information from inodes so an inode lookup (and another system call overhead) required here.
Most of the filesystems also duplicates type information in directory entry structure to speed up this process without need to inode lookup.
In default form, XFS filesystem doesn't store inode information in directory structure. You can change this behaviour while formatting the filesystem with
-ftype=1 option like below:
mkfs.xfs -n -ftype=1
But it is not possible to change after format. So, you need to catch the problem and create a fallback function to handle it.
If underlying filesystem doesn't store inode information,
entry->d_type will be equal to
DT_UNKNOWN and you will have to make a stat call for this case.