From eadc6f84fd1f0165c5625b0de8aae18f5505c507 Mon Sep 17 00:00:00 2001 From: Ning Yu Date: Tue, 23 Jul 2019 13:32:30 +0800 Subject: [PATCH v1 3/4] Fix callers of pg_mkdir_p() Some callers of pg_mkdir_p() consider EEXIST as a non-error case, this is incorrect. When pg_mkdir_p() sets errno to EEXIST it means that the target path already exists but is not a directory. So as long as pg_mkdir_p() returns -1 we should consider it as a failure. Co-authored-by: Paul Guo Co-authored-by: Ning Yu --- src/bin/pg_basebackup/pg_basebackup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 15f43f9432..d02200b3ff 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -610,7 +610,7 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier) PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal"); - if (pg_mkdir_p(statusdir, pg_dir_create_mode) != 0 && errno != EEXIST) + if (pg_mkdir_p(statusdir, pg_dir_create_mode) != 0) { pg_log_error("could not create directory \"%s\": %m", statusdir); exit(1); -- 2.20.1