>From 1394a162e681af58a81c8ec420ff526a9a1b3a24 Mon Sep 17 00:00:00 2001
From: Abhijit Menon-Sen <ams@2ndQuadrant.com>
Date: Fri, 29 May 2015 08:45:04 +0530
Subject: Silently accept EACCES on opendir/stat

---
 src/backend/storage/file/fd.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index b4f6590..af39744 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -2579,9 +2579,10 @@ walkdir(const char *path,
 	dir = AllocateDir(path);
 	if (dir == NULL)
 	{
-		ereport(elevel,
-				(errcode_for_file_access(),
-				 errmsg("could not open directory \"%s\": %m", path)));
+		if (errno != EACCES)
+			ereport(elevel,
+					(errcode_for_file_access(),
+					 errmsg("could not open directory \"%s\": %m", path)));
 		return;
 	}
 
@@ -2606,9 +2607,10 @@ walkdir(const char *path,
 
 		if (sret < 0)
 		{
-			ereport(elevel,
-					(errcode_for_file_access(),
-					 errmsg("could not stat file \"%s\": %m", subpath)));
+			if (errno != EACCES)
+				ereport(elevel,
+						(errcode_for_file_access(),
+						 errmsg("could not stat file \"%s\": %m", subpath)));
 			continue;
 		}
 
-- 
1.9.1

