[sheepdog] [PATCH] farm: use access(2) to check file existence

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sun May 20 18:11:53 CEST 2012


This simplifies the code a bit.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/farm/farm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index d9c63a8..fdb237e 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -73,10 +73,9 @@ err:
 static int farm_exist(uint64_t oid)
 {
 	char path[PATH_MAX];
-	struct stat s;
 
 	sprintf(path, "%s%016"PRIx64, obj_path, oid);
-	if (stat(path, &s) < 0) {
+	if (access(path, R_OK | W_OK) < 0) {
 		if (errno != ENOENT)
 			eprintf("%m\n");
 		return 0;
-- 
1.7.2.5




More information about the sheepdog mailing list