[Ocfs2-tools-devel] [PATCH 01/39] o2cb: Ignore files in cluster directory.

Joel Becker joel.becker at oracle.com
Fri Mar 14 16:52:24 PDT 2008


The cluster directory usually only contains subdirectories.  However,
if it were to contain an attribute file, libo2cb and o2cb.init will see it
as a cluster name.  Teach libo2cb to only look at S_ISDIR().  Teach
o2cb.init to only look at test -d.

Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
 libo2cb/o2cb_abi.c      |   13 +++++++++++++
 vendor/common/o2cb.init |    8 ++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index 7ac89e6..678b838 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -1124,6 +1124,8 @@ static errcode_t o2cb_list_dir(char *path, char ***objs)
 {
 	errcode_t ret;
 	int count;
+	char statpath[PATH_MAX];
+	struct stat stat_buf;
 	DIR *dir;
 	struct dirent *dirent;
 	struct dlist {
@@ -1162,6 +1164,17 @@ static errcode_t o2cb_list_dir(char *path, char ***objs)
 		if (is_dots(dirent->d_name))
 			continue;
 
+		snprintf(statpath, sizeof(statpath), "%s/%s", path,
+			 dirent->d_name);
+
+		/* Silently ignore, we can't access it anyway */
+		if (lstat(statpath, &stat_buf))
+			continue;
+
+		/* Non-directories are attributes */
+		if (!S_ISDIR(stat_buf.st_mode))
+			continue;
+
 		tmp = malloc(sizeof(struct dlist));
 		if (!tmp)
 			goto out_free_list;
diff --git a/vendor/common/o2cb.init b/vendor/common/o2cb.init
index 9296c44..0f08447 100755
--- a/vendor/common/o2cb.init
+++ b/vendor/common/o2cb.init
@@ -865,8 +865,12 @@ unload()
     then
         ls -1 $(configfs_path)/cluster/ | while read CLUSTER
         do
-            echo "Unable to unload modules as O2CB cluster ${CLUSTER} is still online" >&2
-            exit 1
+            if [ ! -L "$(configfs_path)/cluster/${CLUSTER}" -a \
+                 -d "$(configfs_path)/cluster/${CLUSTER}" ]
+            then
+                echo "Unable to unload modules as O2CB cluster ${CLUSTER} is still online" >&2
+                exit 1
+            fi
         done
         if [ $? = 1 ]
         then
-- 
1.5.3.8




More information about the Ocfs2-tools-devel mailing list