[vhffs-dev] [1635] 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: 1635
Author:   gradator
Date:     2010-10-26 23:44:51 +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-autokill/autokill.c

Modified: trunk/vhffs-autokill/autokill.c
===================================================================
--- trunk/vhffs-autokill/autokill.c	2010-10-26 20:03:25 UTC (rev 1634)
+++ trunk/vhffs-autokill/autokill.c	2010-10-26 21:44:51 UTC (rev 1635)
@@ -23,6 +23,8 @@
 #error This software is only running on Linux-based OS, bye!
 #endif
 
+#define _BSD_SOURCE
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -34,6 +36,7 @@
 #include <sys/time.h>
 #include <pwd.h>
 #include <getopt.h>
+#include <sys/stat.h>
 
 #define FALSE 0
 #define TRUE !FALSE
@@ -194,6 +197,10 @@
 			char *signame;
 
 			// discard non directory and non numerical name
+			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 || dir->d_name[0] < '0' || dir->d_name[0] > '9')  continue;
 
 			pid = atoi(dir->d_name);


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