tag 701214 +patch
thanks

Hi,
after some time of debugging, I figured out, that the problem is the
usage of "readdir" in combination with "dirent.d_type", which is not
supported for some filesystems (including apparently XFS). When
searching for a solution, I discovered, that the problem was recently
fixed upstream. The fix affects only lib/warmux/tools/file_tools.cpp and
the latest version of the file is available here
http://svn.gna.org/viewcvs/*checkout*/warmux/trunk/lib/warmux/tools/file_tools.cpp

The fix does not contain more changes within this file. Since the bug
affects a significant amount of users (at least everyone using XFS) I
suggest to raise severity to RC and to propagate the fix to wheezy.

For convenience I've attached the patch.

Best regards

Ben

--- warmux-11.04.1+repack/lib/warmux/tools/file_tools.cpp	2013-04-10 21:02:16.000000000 +0200
+++ warmux-11.04.1+repack-fixed/lib/warmux/tools/file_tools.cpp	2011-04-28 21:03:13.000000000 +0200
@@ -33,8 +33,6 @@
 #  include <direct.h>
 #  undef DeleteFile  // windows.h defines it I think
 #else
-#  include <sys/types.h>
-#  include <sys/stat.h>
 #  include <stdlib.h> // getenv
 #  include <unistd.h> // not needed by mingw
 #endif
@@ -277,14 +275,18 @@
 {
   DIR           *dir;
   struct dirent *file;
+#ifdef __SYMBIAN32__
   std::string    dname;
+#endif
 };
 
 FolderSearch* OpenFolder(const std::string& dirname)
 {
   FolderSearch *f = new FolderSearch;
   f->dir = opendir(dirname.c_str());
+#ifdef __SYMBIAN32__
   f->dname = dirname;
+#endif
 
   if (!f->dir) {
     delete f;
@@ -298,11 +300,11 @@
 {
   while ((f->file = readdir(f->dir)) != NULL) {
 
-    if (
 #ifdef __SYMBIAN32__
-      f->file->d_namlen &&
+    if (f->file->d_namlen && DoesFolderExist(f->dname+"/"+std::string(f->file->d_name))) {
+#else
+    if (f->file->d_type == DT_DIR) {
 #endif
-      DoesFolderExist(f->dname+"/"+std::string(f->file->d_name))) {
       // If we are also looking for files, report it isn't one
       if (file)
         file = false;
@@ -314,11 +316,11 @@
       continue;
 
     // This is a file and we do search for file
-    if (
 #ifdef __SYMBIAN32__
-      f->file->d_namlen &&
+    if (f->file->d_namlen && DoesFileExist(f->dname+"/"+std::string(f->file->d_name))) {
+#else
+    if (f->file->d_type == DT_REG) {
 #endif
-      DoesFileExist(f->dname+"/"+std::string(f->file->d_name))) {
       file = true;
       return f->file->d_name;
     }
@@ -388,4 +390,4 @@
   }
 
   return formated_name;
-}
\ No newline at end of file
+}

Reply via email to