Index: /trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp
===================================================================
--- /trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp	(revision 1046)
+++ /trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp	(revision 1047)
@@ -71,5 +71,6 @@
 public:
     inline QFSFileEngineIteratorPlatformSpecificData()
-        : dir(0), dirEntry(0), done(false)
+        : dir(0), dirEntry(0), root(false), seenDot(false), seenDotDot(false)
+        , done(false)
 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
           , mt_file(0)
@@ -79,5 +80,8 @@
     DIR *dir;
     dirent *dirEntry;
-    bool done;
+    bool root : 1;
+    bool seenDot : 1;
+    bool seenDotDot : 1;
+    bool done : 1;
 
 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
@@ -93,8 +97,11 @@
 public:
     inline QFSFileEngineIteratorPlatformSpecificData()
-        : done(false), hdir(HDIR_CREATE)
+        : root(false), seenDot(false), seenDotDot(false)
+        , done(false), hdir(HDIR_CREATE)
     {
         memset(&findBuf, 0, sizeof(findBuf));
     }
+
+    APIRET filterOutDots();
 
     static QDateTime convertFileDateTime(FDATE fdate, FTIME ftime);
@@ -102,5 +109,8 @@
     void resetFileInfo() { d_ptr->clear(); }
 
-    bool done;
+    bool root : 1;
+    bool seenDot : 1;
+    bool seenDotDot : 1;
+    bool done : 1;
     HDIR hdir;
     FILEFINDBUF3L findBuf;
@@ -120,8 +130,25 @@
 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
     if (::readdir_r(platform->dir, platform->mt_file, &platform->dirEntry) != 0)
-        platform->done = true;
+        platform->dirEntry = 0;
+    // filter out "." and ".." from root to have consistent behavior across
+    // different IFSes (some report them, some don't).
+    while (platform->root && platform->dirEntry &&
+           ((!platform->seenDot &&
+             (platform->seenDot = qstrcmp(platform->dirEntry->d_name, ".")) == 0) ||
+            (!platform->seenDotDot &&
+             (platform->seenDotDot = qstrcmp(platform->dirEntry->d_name, "..")) == 0)))
+        if (::readdir_r(platform->dir, platform->mt_file, &platform->dirEntry) != 0)
+            platform->dirEntry = 0;
 #else
     // ### add local lock to prevent breaking reentrancy
     platform->dirEntry = ::readdir(platform->dir);
+    // filter out "." and ".." from root to have consistent behavior across
+    // different IFSes (some report them, some don't).
+    while (platform->root && platform->dirEntry &&
+           ((!platform->seenDot &&
+             (platform->seenDot = qstrcmp(platform->dirEntry->d_name, ".")) == 0) ||
+            (!platform->seenDotDot &&
+             (platform->seenDotDot = qstrcmp(platform->dirEntry->d_name, "..")) == 0)))
+        platform->dirEntry = ::readdir(platform->dir);
 #endif // _POSIX_THREAD_SAFE_FUNCTIONS
     if (!platform->dirEntry) {
@@ -142,4 +169,7 @@
         return;
     }
+
+    if (platform->root && platform->filterOutDots() != NO_ERROR)
+        return;
 
     // set QFileInfo from find buffer
@@ -200,5 +230,6 @@
             path.append(QLatin1Char('/'));
         APIRET arc = NO_ERROR;
-        if (path.size() >= 2 && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')) {
+        if (path.length() >= 2 && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')) {
+            that->platform->root = path.length() == 3 && (path.at(2) == QLatin1Char('/'));
             // check that the drive is ready before trying to open it which reduces
             // delays and noise for drives with no media inserted
@@ -219,4 +250,6 @@
                 DosClose(hdrv);
             }
+        } else {
+            that->platform->root = path.length() == 1 && (path.at(0) == QLatin1Char('/'));
         }
 
@@ -244,5 +277,6 @@
                              FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED,
                              &that->platform->findBuf, sizeof(that->platform->findBuf),
-                             &count, FIL_STANDARDL) != NO_ERROR) {
+                             &count, FIL_STANDARDL) != NO_ERROR ||
+                (platform->root && platform->filterOutDots() != NO_ERROR)) {
                 that->platform->done = true;
             } else {
@@ -268,4 +302,23 @@
 
 #ifdef QT_OS2_USE_DOSFINDFIRST
+
+// Used to filter out "." and ".." from root to have consistent behavior across
+// different IFSes (some report them, some don't).
+APIRET QFSFileEngineIteratorPlatformSpecificData::filterOutDots()
+{
+    while ((!seenDot && (seenDot = qstrcmp(findBuf.achName, ".")) == 0) ||
+           (!seenDotDot && (seenDotDot = qstrcmp(findBuf.achName, "..") == 0))) {
+        APIRET arc;
+        ULONG count = 1;
+        if ((arc = DosFindNext(hdir, &findBuf,
+                               sizeof(findBuf), &count)) != NO_ERROR) {
+            DosFindClose(hdir);
+            hdir = HDIR_CREATE;
+            done = true;
+            return arc;
+        }
+    }
+    return NO_ERROR;
+}
 
 //static
