Fix a number of places that were making file-type tests infelicitously.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 31 Mar 2008 01:32:48 +0000 (01:32 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 31 Mar 2008 01:32:48 +0000 (01:32 +0000)
commit580db4cf0b98736c66b021da578d6df372a3b01a
tree6ced3b8a0da9a3b673e086dbe6aedb1f995429a1
parent388bf0eaf4c0921f2ed2e05bf2e509febf8e3fbf
Fix a number of places that were making file-type tests infelicitously.
The places that did, eg,
(statbuf.st_mode & S_IFMT) == S_IFDIR
were correct, but there is no good reason not to use S_ISDIR() instead,
especially when that's what the other 90% of our code does.  The places
that did, eg,
(statbuf.st_mode & S_IFDIR)
were flat out *wrong* and would fail in various platform-specific ways,
eg a symlink could be mistaken for a regular file on most Unixen.

The actual impact of this is probably small, since the problem cases
seem to always involve symlinks or sockets, which are unlikely to be
found in the directories that PG code might be scanning.  But it's
clearly trouble waiting to happen, so patch all the way back anyway.
(There seem to be no occurrences of the mistake in 7.4.)
src/backend/utils/adt/dbsize.c
src/backend/utils/adt/genfile.c [new file with mode: 0644]
src/port/copydir.c
src/port/exec.c