To test behavior on read error the test file can be linked to something like /proc/self/mem that does not support read() but currently all symlinks are skipped. Use fstatat instead of the directory entry type to determine file type.