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

List:       kfm-devel
Subject:    Re: KDirLister keeps mounted devices in use
From:       Michael Brade <brade () kde ! org>
Date:       2003-01-15 12:30:02
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


On Wednesday 15 January 2003 11:24, Lubos Lunak wrote:
>  Where's the patch :) ?
Oh, on kde-cvs :)

> But I think it will require both mtab and fstab (do
> all systems have both of them?).
No idea, but I think so.

> IMHO it could work this way:
> - the dir is not in mtab -> ok, not mounted
This case should be basically impossible, no? Everything (except the new 
devfs) is mounted.

> - the dir is in mtab but not fstab -> not ok, manually mounted
> - the dir is in mtab and fstab and it has noauto option -> not ok
> - otherwise (mtab&fstab and doesn't have noauto) -> ok
Indeed, that should catch all cases then. Still, I can't finish the 
implementation as I don't know about AIX and BSD implementations of 
get[fs,mnt]ent.

Here's the patch to implement the above. I think it should be backported if 
someone does the AIX and BSD implementation. Also, this stuff still has to be 
#defined.

Untested, I have to go to university now.

-- 
Michael Brade;                 KDE Developer, Student of Computer Science
  |-mail: echo brade !#|tr -d "c oh"|s\e\d 's/e/\@/2;s/$/.org/;s/bra/k/2'
  °--web: http://www.kde.org/people/michaelb.html

KDE 3: The Next Generation in Desktop Experience
["patch" (text/x-diff)]

? WORK_FOR_KDE_4
? patch
Index: global.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/global.cpp,v
retrieving revision 1.104
diff -u -3 -p -r1.104 global.cpp
--- global.cpp	14 Jan 2003 21:23:22 -0000	1.104
+++ global.cpp	15 Jan 2003 12:24:21 -0000
@@ -1250,7 +1250,6 @@ extern "C" void endvfsent( );
 #define GETMNTENT(file, var) ((var = getmntent(file)) != 0)
 #define MOUNTPOINT(var) var->mnt_dir
 #define MOUNTTYPE(var) var->mnt_type
-#define MOUNTOPTS(var) var->mnt_opts
 #define FSNAME(var) var->mnt_fsname
 #elif defined(_AIX)
 /* we don't need this stuff */
@@ -1262,7 +1261,6 @@ extern "C" void endvfsent( );
 #define GETMNTENT(file, var) (getmntent(file, &var) == 0)
 #define MOUNTPOINT(var) var.mnt_mountp
 #define MOUNTTYPE(var) var.mnt_fstype
-#warning please add MOUNTOPTS(var) !!
 #define FSNAME(var) var.mnt_special
 #endif
 
@@ -1526,7 +1524,8 @@ static void check_mount_point(const char
     }
 }
 
-// returns the mount point, checks the mount state
+// 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)
 {
@@ -1580,8 +1579,9 @@ static QString get_mount_info(const QStr
             check_mount_point( mounttype, mounted[i].f_mntfromname,
                                isautofs, isslow );
             // keep going, looking for a potentially better one
-            if ( strstr(MOUNTOPTS(me), "user") )
-                ismanual = Right;
+
+            if (ismanual == Unseen)
+                ; // TODO: add check for ismanual!
         }
     }
 
@@ -1639,7 +1639,9 @@ static QString get_mount_info(const QStr
             {
                 mountPoint = QFile::decodeName(mountedto);
                 check_mount_point(ent->vfsent_name, device_name, isautofs, isslow);
-                // TODO: add check for ismanual!
+
+                if (ismanual == Unseen)
+                    ; // TODO: add check for ismanual!
             }
 
             free(mountedfrom);
@@ -1674,8 +1676,16 @@ static QString get_mount_info(const QStr
         {
             mountPoint = QFile::decodeName( MOUNTPOINT(me) );
             check_mount_point(MOUNTTYPE(me), FSNAME(me), isautofs, isslow);
-            if ( strstr(MOUNTOPTS(me), "user") )
-                ismanual = Right;
+
+            // 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)
+            {
+                // TODO: this has to be #defined!
+                struct fstab *ff = getfsfile(MOUNTPOINT(me));
+                if (!ff || strstr(ff->fs_mntops, "noauto"))
+                  ismanual = Right;
+            }
         }
     }
 
@@ -1691,7 +1701,7 @@ static QString get_mount_info(const QStr
 
 QString KIO::findPathMountPoint(const QString& filename)
 {
-  MountState isautofs = Unseen, isslow = Unseen, ismanual = Unseen;
+  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
   return get_mount_info(filename, isautofs, isslow, ismanual);
 }
 
@@ -1704,7 +1714,7 @@ bool KIO::manually_mounted(const QString
 
 bool KIO::probably_slow_mounted(const QString& filename)
 {
-  MountState isautofs = Unseen, isslow = Unseen, ismanual = Unseen;
+  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
   QString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual);
   return (mountPoint != QString::null) && (isslow == Right);
 }

[Attachment #6 (application/pgp-signature)]

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

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