[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kio
From:       David Faure <faure () kde ! org>
Date:       2007-04-30 19:02:28
Message-ID: 1177959748.143878.620.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 659759 by dfaure:

Port KDirLister to KMountPoint, kill KIO::manually_mounted.


 M  +8 -74     kio/global.cpp  
 M  +0 -8      kio/global.h  
 M  +30 -12    kio/kdirlister.cpp  
 M  +0 -1      tests/speed.cpp  


--- trunk/KDE/kdelibs/kio/kio/global.cpp #659758:659759
@@ -1595,9 +1595,8 @@
 }
 
 // returns the mount point, checks the mount state.
-// if ismanual == Wrong this function does not check the manual mount state
 static QString get_mount_info(const QString& filename,
-    MountState& isautofs, MountState& isslow, MountState& ismanual,
+    MountState& isautofs, MountState& isslow,
     QString& fstype)
 {
     static bool gotRoot = false;
@@ -1609,7 +1608,6 @@
        QString mountPoint;
        MountState isautofs;
        MountState isslow;
-       MountState ismanual;
        QString fstype;
     };
     static struct cachedDevice_t *cachedDevice = 0;
@@ -1632,20 +1630,15 @@
           static const QString &root = KGlobal::staticQString("/");
           isautofs = Wrong;
           isslow = Wrong;
-          ismanual = Wrong;
           fstype.clear(); // ### do we need it?
           return root;
        }
        if (cachedDevice && (stat_buf.st_dev == cachedDevice->device))
        {
-          bool interestedInIsManual = ismanual != Wrong;
           isautofs = cachedDevice->isautofs;
           isslow = cachedDevice->isslow;
-          ismanual = cachedDevice->ismanual;
           fstype = cachedDevice->fstype;
-          // Don't use the cache if it doesn't have the information we're looking \
                for
-          if ( !interestedInIsManual || ismanual != Unseen )
-              return cachedDevice->mountPoint;
+          return cachedDevice->mountPoint;
        }
     }
 
@@ -1704,13 +1697,6 @@
             check_mount_point( mounttype, mounted[i].f_mntfromname,
                                isautofs, isslow );
             // keep going, looking for a potentially better one
-
-            if (ismanual == Unseen)
-            {
-                struct fstab *ft = getfsfile(mounted[i].f_mntonname);
-                if (!ft || strstr(ft->fs_mntops, "noauto"))
-                  ismanual = Right;
-            }
         }
     }
 
@@ -1769,13 +1755,6 @@
                 mountPoint = QFile::decodeName(mountedto);
                 fstype = QLatin1String(ent->vfsent_name);
                 check_mount_point(ent->vfsent_name, device_name, isautofs, isslow);
-
-                if (ismanual == Unseen)
-                {
-                    // TODO: add check for ismanual, I couldn't find any way
-                    // how to get the mount attribute from /etc/filesystems
-                    ismanual == Wrong;
-                }
             }
 
             free(mountedfrom);
@@ -1811,38 +1790,6 @@
             mountPoint = QFile::decodeName( MOUNTPOINT(me) );
             fstype = MOUNTTYPE(me);
             check_mount_point(MOUNTTYPE(me), FSNAME(me), isautofs, isslow);
-            // we don't check if ismanual is Right, if /a/b is manually
-            // mounted /a/b/c can't be automounted. At least IMO.
-            if (ismanual == Unseen)
-            {
-                // The next GETMNTENT call may destroy 'me'
-                // Copy out the info that we need
-                QByteArray fsname_me = FSNAME(me);
-                QByteArray mounttype_me = MOUNTTYPE(me);
-
-                STRUCT_SETMNTENT fstab;
-                if ((fstab = SETMNTENT(FSTAB, "r")) == 0) {
-                    continue;
-                }
-
-                bool found = false;
-                STRUCT_MNTENT fe;
-                while (GETMNTENT(fstab, fe))
-                {
-                    if (fsname_me == FSNAME(fe))
-                    {
-                        found = true;
-                        if (HASMNTOPT(fe, "noauto") ||
-                            !strcmp(MOUNTTYPE(fe), "supermount"))
-                            ismanual = Right;
-                        break;
-                    }
-                }
-                if (!found || (mounttype_me == "supermount"))
-                  ismanual = Right;
-
-                ENDMNTENT(fstab);
-            }
         }
     }
 
@@ -1862,7 +1809,6 @@
        cachedDevice->mountPoint = mountPoint;
        cachedDevice->isautofs = isautofs;
        cachedDevice->isslow = isslow;
-       cachedDevice->ismanual = ismanual;
        cachedDevice->fstype = fstype;
     }
 
@@ -1880,32 +1826,20 @@
 QString KIO::findPathMountPoint(const QString& filename)
 {
 #ifdef Q_OS_UNIX
-  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
+  MountState isautofs = Unseen, isslow = Unseen;
   QString fstype;
-  return get_mount_info(filename, isautofs, isslow, ismanual, fstype);
+  return get_mount_info(filename, isautofs, isslow, fstype);
 #else //!Q_OS_UNIX
   return QString();
 #endif
 }
 
-bool KIO::manually_mounted(const QString& filename)
-{
-#ifdef Q_OS_UNIX
-  MountState isautofs = Unseen, isslow = Unseen, ismanual = Unseen;
-  QString fstype;
-  QString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual, fstype);
-  return !mountPoint.isNull() && (ismanual == Right);
-#else //!Q_OS_UNIX
-  return false;
-#endif
-}
-
 bool KIO::probably_slow_mounted(const QString& filename)
 {
 #ifdef Q_OS_UNIX
-  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
+  MountState isautofs = Unseen, isslow = Unseen;
   QString fstype;
-  QString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual, fstype);
+  QString mountPoint = get_mount_info(filename, isautofs, isslow, fstype);
   return !mountPoint.isNull() && (isslow == Right);
 #else //!Q_OS_UNIX
   return false;
@@ -1915,9 +1849,9 @@
 bool KIO::testFileSystemFlag(const QString& filename, FileSystemFlag flag)
 {
 #ifdef Q_OS_UNIX
-  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
+  MountState isautofs = Unseen, isslow = Unseen;
   QString fstype;
-  QString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual, fstype);
+  QString mountPoint = get_mount_info(filename, isautofs, isslow, fstype);
     kDebug() << "testFileSystemFlag: fstype=" << fstype << endl;
   if (mountPoint.isNull())
       return false;
--- trunk/KDE/kdelibs/kio/kio/global.h #659758:659759
@@ -376,14 +376,6 @@
    */
   KIO_EXPORT bool probably_slow_mounted(const QString& filename);
 
-  /**
-   * Checks if the path belongs to a filesystem that is manually
-   * mounted.
-   * @param filename the file name to check
-   * @return true if the filesystem is manually mounted
-   */
-  KIO_EXPORT bool manually_mounted(const QString& filename);
-
   enum FileSystemFlag { SupportsChmod, SupportsChown, SupportsUTime,
                         SupportsSymlinks, CaseInsensitive };
   /**
--- trunk/KDE/kdelibs/kio/kio/kdirlister.cpp #659758:659759
@@ -36,6 +36,7 @@
 #include <kglobal.h>
 #include <kglobalsettings.h>
 #include "kprotocolmanager.h"
+#include "kmountpoint.h"
 
 #include <assert.h>
 
@@ -450,6 +451,20 @@
   }
 }
 
+static bool manually_mounted(const QString& path, const KMountPoint::List& \
possibleMountPoints) +{
+    KMountPoint::Ptr mp = possibleMountPoints.findByPath(path);
+    if (!mp) // not listed in fstab -> yes, manually mounted
+        return true;
+    const bool supermount = mp->mountType() == "supermount";
+    if (supermount) {
+        return true;
+    }
+    // noauto -> manually mounted. Otherwise, mounted at boot time, won't be \
unmounted any time soon hopefully. +    return mp->mountOptions().contains("noauto");
+}
+
+
 void KDirListerCache::forgetDirs( KDirLister *lister, const KUrl& _url, bool notify \
)  {
   kDebug(7004) << k_funcinfo << lister << " _url: " << _url << endl;
@@ -499,23 +514,26 @@
         kDebug(7004) << k_funcinfo << lister << " item moved into cache: " << url << \
endl;  itemsCached.insert( urlStr, item ); // TODO: may return false!!
 
+        const KMountPoint::List possibleMountPoints = \
KMountPoint::possibleMountPoints(KMountPoint::NeedMountOptions); +
         // Should we forget the dir for good, or keep a watch on it?
         // Generally keep a watch, except when it would prevent
         // unmounting a removable device (#37780)
         const bool isLocal = item->url.isLocalFile();
-        const bool isManuallyMounted = isLocal && KIO::manually_mounted( \
item->url.path() ); +        bool isManuallyMounted = false;
         bool containsManuallyMounted = false;
-        if ( !isManuallyMounted && isLocal )
-        {
-          // Look for a manually-mounted directory inside
-          // If there's one, we can't keep a watch either, FAM would prevent \
                unmounting the CDROM
-          // I hope this isn't too slow (manually_mounted caches the last device so \
                most
-          // of the time this is just a stat per subdir)
-          KFileItemList::const_iterator kit = item->lstItems.begin();
-          const KFileItemList::const_iterator kend = item->lstItems.end();
-          for ( ; kit != kend && !containsManuallyMounted; ++kit )
-            if ( (*kit)->isDir() && KIO::manually_mounted( (*kit)->url().path() ) )
-              containsManuallyMounted = true;
+        if (isLocal) {
+            isManuallyMounted = manually_mounted( item->url.path(), \
possibleMountPoints ); +            if ( !isManuallyMounted ) {
+                // Look for a manually-mounted directory inside
+                // If there's one, we can't keep a watch either, FAM would prevent \
unmounting the CDROM +                // I hope this isn't too slow
+                KFileItemList::const_iterator kit = item->lstItems.begin();
+                const KFileItemList::const_iterator kend = item->lstItems.end();
+                for ( ; kit != kend && !containsManuallyMounted; ++kit )
+                    if ( (*kit)->isDir() && manually_mounted((*kit)->url().path(), \
possibleMountPoints) ) +                        containsManuallyMounted = true;
+            }
         }
 
         if ( isManuallyMounted || containsManuallyMounted )
--- trunk/KDE/kdelibs/kio/tests/speed.cpp #659758:659759
@@ -85,7 +85,6 @@
     const KMountPoint::List mountPoints = KMountPoint::currentMountPoints();
 
     kDebug() << url.url() << " is probably " << \
                (KIO::probably_slow_mounted(url.path()) ? "slow" : "normal") << " \
                mounted\n";
-    kDebug() << url.url() << " is " << (KIO::manually_mounted(url.path()) ? \
"manually" : "system") << " mounted\n";  KMountPoint::Ptr mp = \
mountPoints.findByDevice(url.path());  if (!mp) {
         kDebug() << "no mount point for device " << url << " found\n";


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic