[vhffs-dev] [1633] fixed recursion bug about d_type field of dirent struct when the filesystem does not handle d_type correctly , like ReiserFS

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1633
Author:   gradator
Date:     2010-10-26 21:55:55 +0200 (Tue, 26 Oct 2010)
Log Message:
-----------
fixed recursion bug about d_type field of dirent struct when the filesystem does not handle d_type correctly, like ReiserFS

Modified Paths:
--------------
    trunk/vhffs-fssync/vhffsfssync_master.c

Modified: trunk/vhffs-fssync/vhffsfssync_master.c
===================================================================
--- trunk/vhffs-fssync/vhffsfssync_master.c	2010-10-25 14:41:05 UTC (rev 1632)
+++ trunk/vhffs-fssync/vhffsfssync_master.c	2010-10-26 19:55:55 UTC (rev 1633)
@@ -22,10 +22,11 @@
 #endif
 
 #define _FILE_OFFSET_BITS 64
+#define _BSD_SOURCE
 
 #define DEBUG_NET 0
-#define DEBUG_INOTIFY 0
-#define DEBUG_EVENTS 0
+#define DEBUG_INOTIFY 1
+#define DEBUG_EVENTS 1
 //#define NDEBUG
 
 #include <assert.h>
@@ -1338,6 +1339,10 @@
 	if(d) {
 		struct dirent *dir;
 		while( (dir = readdir(d)) )  {
+			if(dir->d_type == DT_UNKNOWN) {
+				struct stat st;
+				if( !lstat(dir->d_name, &st) && S_ISDIR(st.st_mode) ) dir->d_type = DT_DIR;
+			}
 			if(dir->d_type == DT_DIR && strcmp(dir->d_name, ".") && strcmp(dir->d_name, "..") )  {
 				vhffsfssync_add_watch_recursively(inotifyfd, watch, dir->d_name, mask);
 			}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/