summaryrefslogtreecommitdiffstats
path: root/x11-fm/krusader/files/patch-krusader::kmountman.cpp
blob: fdc2c1a1f5cab552adcd396368d941f637341d42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
*** krusader/MountMan/kmountman.cpp.orig	Sun Jul 28 22:36:55 2002
--- krusader/MountMan/kmountman.cpp	Thu Oct 24 12:01:13 2002
***************
*** 176,182 ****
    --i; fstab.close();  // finished with it
    for (j=0; j<=i; ++j) {
    	if (temp[0][j]=="" || temp[0][j]=="tmpfs" || temp[0][j]=="none" || temp[0][j]=="proc" ||
!         temp[0][j]=="swap" || temp[1][j]=="proc" || temp[1][j]=="/dev/pts" ||	
          temp[1][j]=="swap" || temp[4][j]=="supermount") continue;
    	++noOfFilesystems;
    }
--- 176,182 ----
    --i; fstab.close();  // finished with it
    for (j=0; j<=i; ++j) {
    	if (temp[0][j]=="" || temp[0][j]=="tmpfs" || temp[0][j]=="none" || temp[0][j]=="proc" ||
!         temp[0][j]=="swap" || temp[1][j]=="procfs" || temp[1][j]=="/dev/pts" || // FreeBSD: procfs instead of proc
          temp[1][j]=="swap" || temp[4][j]=="supermount") continue;
    	++noOfFilesystems;
    }
***************
*** 203,220 ****
      }
    }
  	kdDebug() << "Mt.Man: found the followning:\n" << forDebugOnly << "Trying DF..." << endl;
  	return true;
  }
  
  // run DF process and when it finishes, catch output with "parseDfData"
  ///////////////////////////////////////////////////////////////////////
  void KMountMan::updateFilesystems() {
!   // create the "df -P -T" process
    tempFile = new KTempFile();
    tempFile->setAutoDelete(true);
    dfProc.clearArguments();
    dfProc.setExecutable("df");
!   dfProc << "-T" << "-P" << ">" << tempFile->name();
    connect(&dfProc, SIGNAL(processExited(KProcess *)), this,
            SLOT(finishUpdateFilesystems()));
    dfProc.start(KProcess::NotifyOnExit);
--- 203,267 ----
      }
    }
  	kdDebug() << "Mt.Man: found the followning:\n" << forDebugOnly << "Trying DF..." << endl;
+ 
+ 
+   // FreeBSD problem: df does not retrive fs type.
+   // Workaround: execute mount -p and merge result.
+ 
+   KShellProcess proc;
+   proc << "mount -p";
+ 
+   // connect all outputs to collectOutput, to be displayed later
+   connect(&proc,SIGNAL(receivedStdout(KProcess*, char*, int)),
+           this,SLOT(collectOutput(KProcess*, char*,int)));
+   // launch
+   clearOutput();
+   if (!proc.start(KProcess::Block,KProcess::Stdout)) {
+     KMessageBox::error(0,
+       i18n("Unable to execute 'mount -p' !!!"));
+       return true;
+   }
+ 
+   QString str = getOutput();
+ 	QTextStream t2(str, IO_ReadOnly);
+   while (!t2.atEnd()) {
+     s = t2.readLine();
+     s = s.simplifyWhiteSpace(); // remove TABs
+     if (s==QString::null || s=="") continue;  // skip empty lines in fstab
+     // temp[0]==name, temp[1]==type, temp[2]==mount point, temp[3]==options
+     // temp[4] is reserved for special cases, right now, only for supermount
+     QString temp0=nextWord(s,' ');
+     QString temp2=nextWord(s,' ');
+     QString temp1=nextWord(s,' ');
+     QString temp3=nextWord(s,' ');
+ 		if (temp0=="" || temp2=="/proc" || temp2=="/dev/pts" ||
+   			temp2=="swap" || temp0=="none" || temp0=="procfs" ||
+         temp0=="swap" || location(temp0)) continue;
+     else {
+ 	    fsData* system=new fsData();
+ 	    system->setName(temp0);
+   	  system->setType(temp1);
+    	  system->setMntPoint(temp2);
+   	  system->supermount=false;
+   	  system->options=temp3;
+   	  filesystems.append(system);
+       ++noOfFilesystems;
+ 			kdWarning() << "Mt.Man: filesystem [" << temp0 << "] found by mount -p is unlisted in /etc/fstab." << endl;
+     }
+   }
+ 
  	return true;
  }
  
  // run DF process and when it finishes, catch output with "parseDfData"
  ///////////////////////////////////////////////////////////////////////
  void KMountMan::updateFilesystems() {
!   // create the "df" process // FreeBSD: df instead of df -T -P
    tempFile = new KTempFile();
    tempFile->setAutoDelete(true);
    dfProc.clearArguments();
    dfProc.setExecutable("df");
!   dfProc << ">" << tempFile->name(); // FreeBSD: df instead of df -T -P
    connect(&dfProc, SIGNAL(processExited(KProcess *)), this,
            SLOT(finishUpdateFilesystems()));
    dfProc.start(KProcess::NotifyOnExit);
***************
*** 244,250 ****
  fsData* KMountMan::location(QString name) {
    fsData* it;
    for (it=filesystems.first() ; (it!=0) ; it=filesystems.next())
!    if (followLink(it->name())==followLink(name)) break;
    return it;
  }
  
--- 291,300 ----
  fsData* KMountMan::location(QString name) {
    fsData* it;
    for (it=filesystems.first() ; (it!=0) ; it=filesystems.next())
!   {
!    if (followLink(it->name())==followLink(name)) break; 
!    if (name.left(2) == "//" && !strcasecmp(followLink(it->name()).latin1(), followLink(name).latin1())) break; // FreeBSD: ignore case due to smbfs mounts
!   }
    return it;
  }
  
***************
*** 336,341 ****
--- 386,392 ----
      temp=nextWord(s,' ');
      // avoid adding unwanted filesystems to the list
      if (temp=="tmpfs") continue;
+     if (temp == "procfs") continue;// FreeBSD: ignore procfs
      temp=followLink(temp);  // make sure DF gives us the true device and not a link
      fsData* loc=location(temp); // where is the filesystem located in our list?
      if (loc==0) {
***************
*** 347,361 ****
  			else loc->setName("/dev/"+temp);
  			newFS=true;
      }
!     temp=nextWord(s,' ');   // catch the TYPE
      // is it supermounted ?
!     if (temp=="supermount") loc->supermount=true;
!     loc->setType(temp);
!     if (loc->type()!=temp) {
!     	kdWarning() << "Mt.Man: according to DF, filesystem [" << loc->name() <<
!     				 "] has a different type from what's stated in /etc/fstab." << endl;
!       loc->setType(temp);  // DF knows best
!     }
      temp=nextWord(s,' ');
      loc->setTotalBlks(temp.toLong());
      temp=nextWord(s,' ');
--- 398,412 ----
  			else loc->setName("/dev/"+temp);
  			newFS=true;
      }
!     //    temp=nextWord(s,' ');   // catch the TYPE // FreeBSD: different df output
      // is it supermounted ?
!     //if (temp=="supermount") loc->supermount=true;
!     //loc->setType(temp);
!     //if (loc->type()!=temp) {
!     //	kdWarning() << "Mt.Man: according to DF, filesystem [" << loc->name() <<
!     //				 "] has a different type from what's stated in /etc/fstab." << endl;
!     //  loc->setType(temp);  // DF knows best
!     //}
      temp=nextWord(s,' ');
      loc->setTotalBlks(temp.toLong());
      temp=nextWord(s,' ');
***************
*** 389,395 ****
    	Operational=Ready=false;
  		return;										 // if something went wrong, bail out!
  	} else Operational=true;     // mountman is alive but not yet ready
! 	updateFilesystems();         // use the output of "DF -T -P" to update data
  }
  
  void KMountMan::collectOutput(KProcess *p, char *buffer,int buflen) {
--- 440,446 ----
    	Operational=Ready=false;
  		return;										 // if something went wrong, bail out!
  	} else Operational=true;     // mountman is alive but not yet ready
! 	updateFilesystems();         // use the output of "DF" to update data // FreeBSD: df instead of df -T -P
  }
  
  void KMountMan::collectOutput(KProcess *p, char *buffer,int buflen) {
***************
*** 523,535 ****
      KMessageBox::information(0,i18n("Error ejecting device ! You need to have 'eject' in your path."),i18n("Error"),"CantExecuteEjectWarning");
  }
  
  // returns true if the path is an ejectable mount point (at the moment CDROM)
  bool KMountMan::ejectable(QString path) {
!   fsData* it;
!   for (it=filesystems.first() ; (it!=0) ; it=filesystems.next())
!     if (it->mntPoint()==path &&
!         (it->type()=="iso9660" || followLink(it->name()).left(2)=="cd"))
!       return true;
    return false;
  }
  
--- 574,587 ----
      KMessageBox::information(0,i18n("Error ejecting device ! You need to have 'eject' in your path."),i18n("Error"),"CantExecuteEjectWarning");
  }
  
+ 
  // returns true if the path is an ejectable mount point (at the moment CDROM)
  bool KMountMan::ejectable(QString path) {
!   //fsData* it;// FreeBSD: no eject command
!   //for (it=filesystems.first() ; (it!=0) ; it=filesystems.next())
!   //  if (it->mntPoint()==path &&
!   //      (it->type()=="iso9660" || followLink(it->name()).left(2)=="cd"))
!   //    return true;
    return false;
  }
  
***************
*** 537,544 ****
  statsCollector::statsCollector(QString path, QObject *caller): QObject() {
    QString stats;
    connect(this, SIGNAL(gotStats(QString)), caller, SLOT(gotStats(QString)));
!   if (path.left(5)=="/proc") { // /proc is a special case - no volume information
!     stats=i18n("No space information on a [proc]");
      emit gotStats(stats);
      return;
    }
--- 589,596 ----
  statsCollector::statsCollector(QString path, QObject *caller): QObject() {
    QString stats;
    connect(this, SIGNAL(gotStats(QString)), caller, SLOT(gotStats(QString)));
!   if (path.left(11)=="/dev/procfs") { // /dev/procfs is a special case - no volume information FreeBSD: procfs instead of proc
!     stats=i18n("No space information on a [procfs]"); // FreeBSD: procfs instead of proc
      emit gotStats(stats);
      return;
    }
***************
*** 571,577 ****
    QString s;
    s = t.readLine();  // read the 1st line - it's trash for us
    s = t.readLine();  // this is the important one!
!   data->setName(KMountMan::nextWord(s,' '));
    data->setType(KMountMan::nextWord(s,' '));
    data->setTotalBlks( KMountMan::nextWord(s,' ').toLong() );
    data->setUsedBlks( KMountMan::nextWord(s,' ').toLong() );
--- 623,629 ----
    QString s;
    s = t.readLine();  // read the 1st line - it's trash for us
    s = t.readLine();  // this is the important one!
! //  data->setName(KMountMan::nextWord(s,' ')); FreeBSD: different df output format
    data->setType(KMountMan::nextWord(s,' '));
    data->setTotalBlks( KMountMan::nextWord(s,' ').toLong() );
    data->setUsedBlks( KMountMan::nextWord(s,' ').toLong() );
***************
*** 587,593 ****
    KShellProcess dfProc;
    QString tmpFile = krApp->getTempFile();
  
!   dfProc << "df" << "-T" << "-P" << "\""+path+"\"" << ">" << tmpFile;
    dfProc.start(KProcess::Block);
    parseDf(tmpFile, data);
    QDir().remove(tmpFile);
--- 639,645 ----
    KShellProcess dfProc;
    QString tmpFile = krApp->getTempFile();
  
!   dfProc << "df" << "\""+path+"\"" << ">" << tmpFile; // FreeBSD: df instead of df -T -P
    dfProc.start(KProcess::Block);
    parseDf(tmpFile, data);
    QDir().remove(tmpFile);
OpenPOWER on IntegriCloud