aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/dbsize.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-31 01:31:43 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-31 01:31:43 +0000
commitc5f11f9d19964b8dc568bc4b9bfff7d31ee26db0 (patch)
treeeb3cc210ce10eaf6a583750b6d980f8f51d244b3 /src/backend/utils/adt/dbsize.c
parentb65a5097463d6dc5d75661f5236a742c4023f989 (diff)
downloadpostgresql-c5f11f9d19964b8dc568bc4b9bfff7d31ee26db0.tar.gz
postgresql-c5f11f9d19964b8dc568bc4b9bfff7d31ee26db0.zip
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.)
Diffstat (limited to 'src/backend/utils/adt/dbsize.c')
-rw-r--r--src/backend/utils/adt/dbsize.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 72807321ae3..7b8aa6b9e67 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -5,7 +5,7 @@
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.17 2008/03/25 22:42:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.18 2008/03/31 01:31:43 tgl Exp $
*
*/
@@ -209,7 +209,7 @@ calculate_tablespace_size(Oid tblspcOid)
errmsg("could not stat file \"%s\": %m", pathname)));
}
- if (fst.st_mode & S_IFDIR)
+ if (S_ISDIR(fst.st_mode))
totalsize += db_dir_size(pathname);
totalsize += fst.st_size;