[Pcsclite-cvs-commit] r6944 - trunk/PCSC/src

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Tue Jul 29 08:33:27 UTC 2014


Author: rousseau
Date: 2014-07-29 08:33:27 +0000 (Tue, 29 Jul 2014)
New Revision: 6944

Modified:
   trunk/PCSC/src/configfile.l
Log:
Add ReiserFS support (and maybe some other strange file systems)

"the attached patch fixes incorrect use of the dirent::d_type field. As
documented in readdir(3) d_type may be set to DT_UNKNOWN, which
applications must handle properly.

The effect of the bug is that config files are skipped in case the
config directory is located on a file system that doesn't support d_type
(e.g. ReiserFS)."

Thanks to Ingo Weinhold for the patch


Modified: trunk/PCSC/src/configfile.l
===================================================================
--- trunk/PCSC/src/configfile.l	2014-07-28 15:14:44 UTC (rev 6943)
+++ trunk/PCSC/src/configfile.l	2014-07-29 08:33:27 UTC (rev 6944)
@@ -41,6 +41,7 @@
 
 %{
 #include <dirent.h>
+#include <sys/stat.h>
 
 #include "wintypes.h"
 #include "pcscd.h"
@@ -290,13 +291,35 @@
 			char filename[FILENAME_MAX];
 			int r;
 
+			snprintf(filename, sizeof(filename), "%s/%s",
+				readerconf_dir, direntry->d_name);
+
 			/* skip non regular files */
-			if (direntry->d_type != DT_REG)
+			if (direntry->d_type == DT_UNKNOWN)
 			{
-				Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
-					direntry->d_name);
-				continue;
+				struct stat st;
+
+				if (lstat(filename, &st) != 0)
+				{
+					Log2(PCSC_LOG_DEBUG, "Skipping non statable file: %s",
+						direntry->d_name);
+					continue;
+				}
+
+				if (!S_ISREG(st.st_mode))
+				{
+					Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
+						direntry->d_name);
+					continue;
+				}
 			}
+			else
+				if (direntry->d_type != DT_REG)
+				{
+					Log2(PCSC_LOG_DEBUG, "Skipping non regular file: %s",
+						direntry->d_name);
+					continue;
+				}
 
 			/* skip files starting with . like ., .., .svn, etc */
 			if ('.' == direntry->d_name[0])
@@ -306,9 +329,6 @@
 				continue;
 			}
 
-			snprintf(filename, sizeof(filename), "%s/%s",
-				readerconf_dir, direntry->d_name);
-
 			/* each call to DBGetReaderList() will append to the list */
 			r = DBGetReaderList(filename, caller_reader_list);
 




More information about the Pcsclite-cvs-commit mailing list