[Sheepdog] [PATCH 2/3] check the return value of opendir

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Tue Dec 22 08:36:23 CET 2009


Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
 collie/store.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/collie/store.c b/collie/store.c
index 9f14d00..29d01b8 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -338,6 +338,8 @@ static int so_read_vdis(struct request *req)
 	snprintf(path, sizeof(path), "%s/vdi", obj_dir);
 
 	dir = opendir(path);
+	if (!dir)
+		return SD_RES_NO_SUPER_OBJ;
 
 	while ((dent = readdir(dir))) {
 		if (!strcmp(dent->d_name, ".") ||
@@ -367,6 +369,9 @@ static int so_read_vdis(struct request *req)
 		close(fd);
 
 		vdir = opendir(vpath);
+		if (!vdir)
+			return SD_RES_NO_VDI;
+
 		while ((vdent = readdir(vdir))) {
 			if (!strcmp(vdent->d_name, ".") ||
 			    !strcmp(vdent->d_name, ".."))
@@ -443,6 +448,8 @@ static int so_lookup_vdi(struct request *req)
 	}
 
 	dir = opendir(path);
+	if (!dir)
+		return SD_RES_NO_VDI;
 
 	while ((dent = readdir(dir))) {
 		if (!strcmp(dent->d_name, ".") ||
-- 
1.5.6.5




More information about the sheepdog mailing list