Blob Blame History Raw
diff -up kdelibs-4.6.5/kdecore/CMakeLists.txt.kconfig_sync-1 kdelibs-4.6.5/kdecore/CMakeLists.txt
--- kdelibs-4.6.5/kdecore/CMakeLists.txt.kconfig_sync-1	2011-04-01 08:55:50.000000000 -0500
+++ kdelibs-4.6.5/kdecore/CMakeLists.txt	2011-10-11 11:04:00.141866936 -0500
@@ -208,6 +208,7 @@ set(kdecore_LIB_SRCS
    io/kdebug.cpp
    io/kdebugdbusiface.cpp
    io/kdirwatch.cpp
+   io/kfilesystemtype_p.cpp
    io/klimitediodevice.cpp
    io/kmessage.cpp
    io/kmountpoint.cpp
diff -up kdelibs-4.6.5/kdecore/io/kdirwatch.cpp.kconfig_sync-1 kdelibs-4.6.5/kdecore/io/kdirwatch.cpp
--- kdelibs-4.6.5/kdecore/io/kdirwatch.cpp.kconfig_sync-1	2011-04-01 08:56:18.000000000 -0500
+++ kdelibs-4.6.5/kdecore/io/kdirwatch.cpp	2011-10-11 11:16:03.054895138 -0500
@@ -43,6 +43,7 @@
 
 #include "kdirwatch.h"
 #include "kdirwatch_p.h"
+#include "kfilesystemtype_p.h"
 
 #include "io/config-kdirwatch.h"
 #include <config.h>
@@ -62,7 +63,6 @@
 #include <kglobal.h>
 #include <kde_file.h>
 #include <kconfiggroup.h>
-#include "kmountpoint.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -709,9 +709,7 @@ bool KDirWatchPrivate::useQFSWatch(Entry
 
 bool KDirWatchPrivate::useStat(Entry* e)
 {
-  KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByPath(e->path);
-  const bool slow = mp ? mp->probablySlow() : false;
-  if (slow)
+  if (KFileSystemType::fileSystemType(e->path) == KFileSystemType::Nfs) // TODO: or Smbfs?
     useFreq(e, m_nfsPollInterval);
   else
     useFreq(e, m_PollInterval);
@@ -904,8 +902,7 @@ void KDirWatchPrivate::addWatch(Entry* e
   // are made locally. #177892.
   KDirWatch::Method preferredMethod = m_preferredMethod;
   if (m_nfsPreferredMethod != m_preferredMethod) {
-    KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(e->path);
-    if (mountPoint && mountPoint->probablySlow()) {
+    if (KFileSystemType::fileSystemType(e->path) == KFileSystemType::Nfs) {
       preferredMethod = m_nfsPreferredMethod;
     }
   }
diff -up kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.cpp.kconfig_sync-1 kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.cpp
--- kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.cpp.kconfig_sync-1	2011-10-11 11:04:00.142866875 -0500
+++ kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.cpp	2011-10-11 11:04:00.142866875 -0500
@@ -0,0 +1,115 @@
+/*
+   This file is part of the KDE libraries
+   Copyright (c) 2011 David Faure <faure@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License version 2.1 as published by the Free Software Foundation.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#include "kfilesystemtype_p.h"
+#include <QFile>
+//#include <errno.h>
+
+#ifndef Q_OS_WIN
+inline KFileSystemType::Type kde_typeFromName(const char *name)
+{
+    if (qstrncmp(name, "nfs", 3) == 0
+        || qstrncmp(name, "autofs", 6) == 0
+        || qstrncmp(name, "cachefs", 7) == 0)
+        return KFileSystemType::Nfs;
+    if (qstrncmp(name, "fat", 3) == 0
+        || qstrncmp(name, "vfat", 4) == 0
+        || qstrncmp(name, "msdos", 5) == 0)
+        return KFileSystemType::Fat;
+    return KFileSystemType::Other;
+}
+
+#if defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)
+# include <sys/param.h>
+# include <sys/mount.h>
+
+KFileSystemType::Type determineFileSystemTypeImpl(const QByteArray& path)
+{
+    struct statfs buf;
+    if (statfs(path.constData(), &buf) != 0)
+        return Unknown;
+    return kde_typeFromName(buf.f_fstypename);
+}
+
+#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD)
+# include <sys/vfs.h>
+# ifdef QT_LINUXBASE
+   // LSB 3.2 has statfs in sys/statfs.h, sys/vfs.h is just an empty dummy header
+#  include <sys/statfs.h>
+# endif
+# ifndef NFS_SUPER_MAGIC
+#  define NFS_SUPER_MAGIC       0x00006969
+# endif
+# ifndef AUTOFS_SUPER_MAGIC
+#  define AUTOFS_SUPER_MAGIC    0x00000187
+# endif
+# ifndef AUTOFSNG_SUPER_MAGIC
+#  define AUTOFSNG_SUPER_MAGIC  0x7d92b1a0
+# endif
+# ifndef MSDOS_SUPER_MAGIC
+#  define MSDOS_SUPER_MAGIC     0x00004d44
+# endif
+
+KFileSystemType::Type determineFileSystemTypeImpl(const QByteArray& path)
+{
+    struct statfs buf;
+    if (statfs(path.constData(), &buf) != 0) {
+        //kDebug() << path << errno << strerror(errno);
+        return KFileSystemType::Unknown;
+    }
+    switch (buf.f_type) {
+    case NFS_SUPER_MAGIC:
+    case AUTOFS_SUPER_MAGIC:
+    case AUTOFSNG_SUPER_MAGIC:
+        return KFileSystemType::Nfs;
+    case MSDOS_SUPER_MAGIC:
+        return KFileSystemType::Fat;
+    default:
+        return KFileSystemType::Other;
+    }
+}
+
+#elif defined(Q_OS_SOLARIS) || defined(Q_OS_IRIX) || defined(Q_OS_AIX) || defined(Q_OS_HPUX) \
+      || defined(Q_OS_OSF) || defined(Q_OS_QNX) || defined(Q_OS_SCO) \
+      || defined(Q_OS_UNIXWARE) || defined(Q_OS_RELIANT) || defined(Q_OS_NETBSD)
+# include <sys/statvfs.h>
+
+KFileSystemType::Type determineFileSystemTypeImpl(const QByteArray& path)
+{
+    struct statvfs buf;
+    if (statvfs(path.constData(), &buf) != 0)
+        return KFileSystemType::Unknown;
+#if defined(Q_OS_NETBSD)
+    return kde_typeFromName(buf.f_fstypename);
+#else
+    return kde_typeFromName(buf.f_basetype);
+#endif
+}
+#else
+KFileSystemType::Type determineFileSystemTypeImpl(const QByteArray& path)
+{
+    return KFileSystemType::Unknown;
+}
+#endif
+#endif
+
+KFileSystemType::Type KFileSystemType::fileSystemType(const QString& path)
+{
+    return determineFileSystemTypeImpl(QFile::encodeName(path));
+}
diff -up kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.h.kconfig_sync-1 kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.h
--- kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.h.kconfig_sync-1	2011-10-11 11:04:00.142866875 -0500
+++ kdelibs-4.6.5/kdecore/io/kfilesystemtype_p.h	2011-10-11 11:04:00.142866875 -0500
@@ -0,0 +1,38 @@
+/*
+   This file is part of the KDE libraries
+   Copyright (c) 2011 David Faure <faure@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License version 2.1 as published by the Free Software Foundation.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KFILESYSTEMTYPE_P_H
+#define KFILESYSTEMTYPE_P_H
+
+#include <QtCore/QString>
+
+namespace KFileSystemType
+{
+   enum Type {
+       Unknown,
+       Nfs, // NFS or similar (autofs, subfs, cachefs)
+       Fat,  // FAT or similar (msdos, fat, vfat)
+       Other // ext, reiser, and so on. "Normal" filesystems.
+   };
+
+   Type fileSystemType(const QString& path);
+
+};
+
+#endif