kvm tools: Fix dirent handling on dirent non-friendly filesystems

Some filesystems don't return valid d_type field in dirent
structure (e.g XFS). So we must handle this case properly.

Signed-off-by: Milan Kocian <milon@wq.cz>
Cc: Sasha Levin <levinsasha928@gmail.com>
[ penberg@kernel.org: cleanups ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>