[Ocfs2-tools-commits] zab commits r600 - in trunk/libocfs2: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Jan 26 17:17:32 CST 2005


Author: zab
Date: 2005-01-26 17:17:30 -0600 (Wed, 26 Jan 2005)
New Revision: 600

Modified:
   trunk/libocfs2/dir_iterate.c
   trunk/libocfs2/include/ocfs2.h
Log:
o add a flag to ocfs2_dir_iterate() so that callers don't see . and ..


Modified: trunk/libocfs2/dir_iterate.c
===================================================================
--- trunk/libocfs2/dir_iterate.c	2005-01-26 21:56:00 UTC (rev 599)
+++ trunk/libocfs2/dir_iterate.c	2005-01-26 23:17:30 UTC (rev 600)
@@ -137,7 +137,22 @@
 				  xlate_func, &xl);
 }
 
+/* make this a helper.. */
+static int is_dots(char *name, unsigned int len)
+{
+	if (len == 0)
+		return 0;
 
+	if (name[0] == '.') {
+		if (len == 1)
+			return 1;
+		if (len == 2 && name[1] == '.')
+			return 1;
+	}
+
+	return 0;
+}
+
 /*
  * Helper function which is private to this module.  Used by
  * ocfs2_dir_iterate() and ocfs2_dblist_dir_iterate()
@@ -178,6 +193,9 @@
 		if (!dirent->inode &&
 		    !(ctx->flags & OCFS2_DIRENT_FLAG_INCLUDE_EMPTY))
 			goto next;
+		if (is_dots(dirent->name, dirent->name_len) && 
+		    (ctx->flags & OCFS2_DIRENT_FLAG_EXCLUDE_DOTS))
+			goto next;
 
 		ret = (ctx->func)(ctx->dir,
 				  (next_real_entry > offset) ?

Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h	2005-01-26 21:56:00 UTC (rev 599)
+++ trunk/libocfs2/include/ocfs2.h	2005-01-26 23:17:30 UTC (rev 600)
@@ -127,6 +127,7 @@
 /* Directory iterator flags */
 #define OCFS2_DIRENT_FLAG_INCLUDE_EMPTY		0x01
 #define OCFS2_DIRENT_FLAG_INCLUDE_REMOVED	0x02
+#define OCFS2_DIRENT_FLAG_EXCLUDE_DOTS		0x04
 
 /* Return flags for the chain iterator functions */
 #define OCFS2_CHAIN_CHANGED	0x01



More information about the Ocfs2-tools-commits mailing list