Группа :: Графические оболочки/KDE
Пакет: kdebase
Главная Изменения Спек Патчи Загрузить Bugs and FR
Патч: kdebase-3.1.2-frendly_automount.patch
--- kdebase-3.1.2/kioslave/devices/kdedmodule/disklist.cpp~ 2003-07-08 20:27:49 +0400
+++ kdebase-3.1.2/kioslave/devices/kdedmodule/disklist.cpp 2003-07-09 15:27:26 +0400
@@ -170,6 +170,53 @@
{
if (readingDFStdErrOut || dfProc->isRunning()) return -1;
+ QString automountDevices;
+ QString autotab, mntprefix;
+ QFile amf(AUTOMASTER);
+ //fprintf (stderr, "Automount is running: <%s>\n", (automount_is_running)?"true":"false");
+ if ( amf.open(IO_ReadOnly) && automount_is_running)
+ {
+
+ QTextStream amt (&amf);
+ QString ams;
+ while (! amt.eof())
+ {
+ ams=amt.readLine();
+ ams=ams.simplifyWhiteSpace();
+ if ( (!ams.isEmpty() ) && (ams.find(DELIMITER)!=0) )
+ {
+ //fprintf (stderr, "auto.master: <%s>\n", ams.latin1());
+ QStringList aml = QStringList::split(' ', ams);
+ mntprefix = *aml.at(0);
+ autotab = *aml.at(1);
+ //fprintf (stderr, "auto.tab: <%s> mntprefix: <%s>\n", autotab.latin1(), mntprefix.latin1() );
+ break;
+ }
+ }
+
+ QFile af(autotab);
+ if ( af.open(IO_ReadOnly) )
+ {
+ QTextStream at (&af);
+ QString as;
+ while (! at.eof())
+ {
+ as=at.readLine();
+ as=as.simplifyWhiteSpace();
+ if ( (!as.isEmpty() ) && (as.find(DELIMITER)!=0) )
+ {
+ int dpos=as.findRev(":");
+ if (dpos > 12) // < 12 not usable
+ {
+ automountDevices.append( as.mid(dpos+1, as.length()-dpos-1) + ':' + as.left(as.find(' ')) + ";" );
+ }
+ } //if not empty
+ } //while
+ af.close();
+ }
+ //fprintf (stderr, "Automount devices: <%s>\n", automountDevices.latin1());
+ }
+
#ifdef HAVE_SETMNTENT
#define SETMNTENT setmntent
@@ -203,7 +250,21 @@
disk->setMountOptions(QFile::decodeName(MOUNTOPTIONS(fe)));
//kdDebug() << " Mount-Options: [" << disk->mountOptions() << "]" << endl;
if (!ignoreDisk(disk))
+ {
+ if (automount_is_running) {
+ int dstart,nstart,nend;
+ dstart = automountDevices.find(disk->deviceName()+":");
+ if ( dstart >= 0 )
+ {
+ nstart = automountDevices.find(':', dstart) + 1;
+ nend = automountDevices.find(';', dstart);
+ disk->setMountPoint( mntprefix + '/' + automountDevices.mid(nstart,nend-nstart) );
+ dstart = -1;
+ //fprintf(stderr, "Automount device: <%s %s dstart=%d nstart=%d nend=%d>\n", disk->deviceName().latin1(), disk->mountPoint().latin1(), dstart,nstart,nend);
+ }
+ }
replaceDeviceEntry(disk);
+ }
else
delete disk;
}
--- kdebase-3.1.2/kioslave/devices/kdedmodule/disklist.h~ 2003-07-08 21:57:29 +0400
+++ kdebase-3.1.2/kioslave/devices/kdedmodule/disklist.h 2003-07-08 21:57:18 +0400
@@ -54,6 +54,7 @@
#else
+#define AUTOMASTER "/etc/auto.master"
#define FSTAB "/etc/fstab"
//#if defined(_OS_LINUX_)
#define MTAB "/etc/mtab"
--- kdebase-3.1.2/kioslave/devices/kdedmodule/mountwatcher.cpp~ 2003-07-08 18:32:01 +0400
+++ kdebase-3.1.2/kioslave/devices/kdedmodule/mountwatcher.cpp 2003-07-09 18:13:52 +0400
@@ -17,6 +17,8 @@
Boston, MA 02111-1307, USA.
*/
+#include <config.h>
+
#include <string.h>
#include <time.h>
@@ -40,9 +42,48 @@
#include "mountwatcher.h"
#include "kdirnotify_stub.h"
+#ifdef HAVE_MNTENT_H
+#include <mntent.h>
+#endif
+
+bool automount_is_running = false;
+
MountWatcherModule::MountWatcherModule(const QCString &obj)
: KDEDModule(obj),mDiskList(this),mtabsize(0)
{
+#ifdef MTAB
+#ifdef HAVE_SETMNTENT
+#define SETMNTENT setmntent
+#define ENDMNTENT endmntent
+#define STRUCT_MNTENT struct mntent *
+#define STRUCT_SETMNTENT FILE *
+#define GETMNTENT(file, var) ((var = getmntent(file)) != 0)
+#define MOUNTPOINT(var) var->mnt_dir
+#define MOUNTTYPE(var) var->mnt_type
+#define MOUNTOPTIONS(var) var->mnt_opts
+#define HASMNTOPT(var, opt) hasmntopt(var, opt)
+#define FSNAME(var) var->mnt_fsname
+ STRUCT_SETMNTENT mtab;
+ if ((mtab = SETMNTENT(MTAB, "r")) == 0)
+ {
+ automount_is_running = false;
+ }
+ else
+ {
+ STRUCT_MNTENT fe;
+ while (GETMNTENT(mtab, fe))
+ {
+ //fprintf (stderr, "Search automount in <%s>:\n", QFile::decodeName(FSNAME(fe)).latin1());
+ if ( QFile::decodeName(FSNAME(fe)).find("automount") >= 0 )
+ {
+ automount_is_running = true;
+ //fprintf (stderr, "Set automount is running.\n");
+ }
+ }
+ ENDMNTENT(mtab);
+ }
+#endif // HAVE_SETMNTENT
+#endif
firstTime=true;
mDiskList.readFSTAB();
mDiskList.readDF();