From 31489d92c04a7341639b786e808d82eec4e03f3e Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 30 Mar 2016 20:19:12 +0900 Subject: [PATCH] Check directory entity filetype in a more portable way --- repmgr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/repmgr.c b/repmgr.c index 1fbd97aa..6d495f34 100644 --- a/repmgr.c +++ b/repmgr.c @@ -43,7 +43,6 @@ #include "repmgr.h" #include -#include #include #include #include @@ -3317,10 +3316,17 @@ do_standby_restore_config(void) } while ((arcdir_ent = readdir(arcdir)) != NULL) { + struct stat statbuf; + char arcdir_ent_path[MAXPGPATH]; PQExpBufferData src_file; PQExpBufferData dst_file; - if (arcdir_ent->d_type != DT_REG) + snprintf(arcdir_ent_path, MAXPGPATH, + "%s/%s", + runtime_options.config_archive_dir, + arcdir_ent->d_name); + + if (stat(arcdir_ent_path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode)) { continue; }