]> Savannah Git Hosting - gnulib.git/commit
glob: resolve DT_UNKNOWN via is_dir
authorDJ Delorie <dj@redhat.com>
Wed, 23 Mar 2022 16:39:37 +0000 (09:39 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 23 Mar 2022 17:24:43 +0000 (10:24 -0700)
commit1bde7566b7262ed40462f038d6ac4995397d0c4a
treecbb0ac88572a29110ccfc0d7f3f1d272e998764b
parentbb220237d65b17845b4976166c46c9d7053f2e1a
glob: resolve DT_UNKNOWN via is_dir

The DT_* values returned by getdents (readdir) are only hints and
not required.  In fact, some Linux filesystems return DT_UNKNOWN
for most entries, regardless of actual type.  This causes make
to mis-match patterns with a trailing slash (via GLOB_ONLYDIR)
(see make's functions/wildcard test case).  Thus, this patch
detects that case and uses is_dir() to make the type known enough
for proper operation.

Performance in non-DT_UNKNOWN cases is not affected.

The lack of DT_* is a well known issue on older XFS installations
(for example, RHEL 7 and 8, Fedora 28) but can be recreated by
creating an XFS filesystem with flags that mimic older behavior:

$ fallocate -l 10G /xfs.fs
$ mkfs.xfs -n ftype=0 -m crc=0 -f /xfs.fs
$ mkdir /xfs
$ mount -o loop /xfs.fs /xfs
ChangeLog
lib/glob.c