Index: /trunk/src/corelib/io/qfsfileengine.cpp
===================================================================
--- /trunk/src/corelib/io/qfsfileengine.cpp	(revision 374)
+++ /trunk/src/corelib/io/qfsfileengine.cpp	(revision 375)
@@ -106,7 +106,10 @@
     is_sequential = 0;
     tried_stat = 0;
-#ifdef Q_OS_UNIX
+#if defined(Q_OS_UNIX) || defined(Q_OS_OS2)
     need_lstat = 1;
     is_link = 0;
+#endif
+#if defined(Q_OS_OS2)
+    not_ready = 0;
 #endif
     openMode = QIODevice::NotOpen;
Index: /trunk/src/corelib/io/qfsfileengine_os2.cpp
===================================================================
--- /trunk/src/corelib/io/qfsfileengine_os2.cpp	(revision 374)
+++ /trunk/src/corelib/io/qfsfileengine_os2.cpp	(revision 375)
@@ -166,4 +166,12 @@
 }
 
+static bool isDriveRootPath(const QString &path)
+{
+    return (path.length() >= 2 && path.at(0).isLetter() &&
+            path.at(1) == QLatin1Char(':') &&
+            (path.length() == 2 ||
+             (path.length() == 3 && path.at(2) == QLatin1Char('/'))));
+}
+
 /*!
     \internal
@@ -617,15 +625,39 @@
 {
     if (tried_stat == 0) {
-        QFSFileEnginePrivate *that = const_cast<QFSFileEnginePrivate*>(this);
         if (fh && nativeFilePath.isEmpty()) {
             // ### actually covers two cases: d->fh and when the file is not open
-            that->could_stat = (QT_FSTAT(fileno(fh), &st) == 0);
+            could_stat = (QT_FSTAT(fileno(fh), &st) == 0);
         } else if (fd == -1) {
             // ### actually covers two cases: d->fh and when the file is not open
-            that->could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
+            if (isDriveRootPath(filePath)) {
+                // it's a root directory of the drive. Check that the drive is
+                // ready: an attempt to stat() on a removable drive with no
+                // media inserted will cause an unnecessary delay and noise.
+                not_ready = 0;
+                BYTE drv[3] = { filePath.at(0).cell(), ':', '\0' };
+                BYTE buf[sizeof(FSQBUFFER2) + (3 * CCHMAXPATH)] = {0};
+                ULONG bufSize = sizeof(buf);
+                PFSQBUFFER2 pfsq = (PFSQBUFFER2) buf;
+                APIRET arc = DosQueryFSAttach(drv, 0, FSAIL_QUERYNAME, pfsq,
+                                              &bufSize);
+                if (arc == ERROR_NOT_READY) {
+                    // it must be a removable drive with no media in it
+                    memset(&st, 0, sizeof(st));
+                    st.st_mode = S_IFDIR | 0777;
+                    not_ready = 1;
+                    could_stat = true;
+                } else if (arc != NO_ERROR) {
+                    Q_ASSERT(arc == ERROR_INVALID_DRIVE);
+                    could_stat = false;
+                } else {
+                    could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
+                }
+            } else {
+                could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
+            }
         } else {
-            that->could_stat = (QT_FSTAT(fd, &st) == 0);
-        }
-	that->tried_stat = 1;
+            could_stat = (QT_FSTAT(fd, &st) == 0);
+        }
+        tried_stat = 1;
     }
     return could_stat;
@@ -700,7 +732,7 @@
         if (exists)
             ret |= ExistsFlag;
-        if (fileName(BaseName)[0] == QLatin1Char('.'))
+        if (d->st.st_attr & FILE_HIDDEN)
             ret |= HiddenFlag;
-        if (d->filePath == QLatin1String("/"))
+        if (isDriveRootPath(d->filePath))
             ret |= RootFlag;
     }
@@ -963,5 +995,5 @@
     Q_D(const QFSFileEngine);
     QDateTime ret;
-    if (d->doStat()) {
+    if (d->doStat() && !d->not_ready) {
         if (time == CreationTime)
             ret.setTime_t(d->st.st_ctime ? d->st.st_ctime : d->st.st_mtime);
Index: /trunk/src/corelib/io/qfsfileengine_p.h
===================================================================
--- /trunk/src/corelib/io/qfsfileengine_p.h	(revision 374)
+++ /trunk/src/corelib/io/qfsfileengine_p.h	(revision 375)
@@ -143,4 +143,7 @@
     mutable uint is_link : 1;
 #endif
+#if defined(Q_OS_OS2)
+    mutable uint not_ready : 1;
+#endif
     bool doStat() const;
     bool isSymlink() const;
