2
Copyright (c) 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
NFSHost::NFSHost(const QString & hostString)
28
QString s = hostString;
30
int l = s.indexOf('(');
31
int r = s.indexOf(')');
41
kDebug(5009) << "NFSHost: name='" << name << "'";
45
QString params = s.mid(l+1,r-l-1);
47
parseParamsString(params);
61
* Set the parameters to their default values
63
void NFSHost::initParams()
80
void NFSHost::parseParamsString(const QString & s)
93
i = rest.indexOf(",",0);
100
rest = rest.mid(i+1);
109
QString NFSHost::paramString() const
113
if (!readonly) s+="rw,";
114
if (!rootSquash) s+="no_root_squash,";
115
if (!secure) s+="insecure,";
116
if (!secureLocks) s+="insecure_locks,";
117
if (!subtreeCheck) s+="no_subtree_check,";
123
if (!wdelay) s+="wdelay,";
124
if (allSquash) s+="all_squash,";
125
if (!hide) s+="nohide,";
128
s+=QString("anongid=%1,").arg(anongid);
131
s+=QString("anonuid=%1,").arg(anonuid);
133
// get rid of the last ','
134
s.truncate(s.length()-1);
139
QString NFSHost::toString() const
151
NFSHost* NFSHost::copy() const {
152
NFSHost* result = new NFSHost();
156
result->readonly = readonly;
158
result->secure = secure;
159
result->wdelay = wdelay;
161
result->subtreeCheck = subtreeCheck;
162
result->secureLocks = secureLocks;
163
result->allSquash = allSquash;
164
result->rootSquash = rootSquash;
166
result->anonuid = anonuid;
167
result->anongid = anongid;
172
bool NFSHost::isPublic() const {
176
void NFSHost::setParam(const QString & s)
178
QString p = s.toLower();
208
if (p=="no_wdelay") {
220
if (p=="subtree_check") {
224
if (p=="no_subtree_check") {
225
subtreeCheck = false;
228
if (p=="secure_locks" ||
233
if (p=="insecure_locks" ||
238
if (p=="all_squash") {
242
if (p=="no_all_squash") {
246
if (p=="root_squash") {
250
if (p=="no_root_squash") {
254
int i = p.indexOf('=',0);
256
// get anongid or anonuid
259
QString name = p.left(i).toLower();
260
kDebug(5009) << name;
262
QString value = p.mid(i+1);
263
kDebug(5009) << value;
266
anongid = value.toInt();
269
anonuid = value.toInt();
274
NFSEntry::NFSEntry(const QString & path)
276
_hosts.setAutoDelete(true);
280
NFSEntry::~NFSEntry()
284
void NFSEntry::clear() {
288
NFSEntry* NFSEntry::copy() {
289
NFSEntry* result = new NFSEntry(path());
290
result->copyFrom(this);
294
void NFSEntry::copyFrom(NFSEntry* entry) {
296
HostIterator it = entry->getHosts();
299
while ( (host = it.current()) != 0 ) {
301
addHost(host->copy());
305
QString NFSEntry::toString() const
307
QString s = _path.trimmed();
309
if (_path.contains(' ')) {
315
HostIterator it = getHosts();
319
while ( (host = it.current()) != 0 )
322
s+= host->toString() ;
331
void NFSEntry::addHost(NFSHost * host)
336
void NFSEntry::removeHost(NFSHost * host)
341
NFSHost* NFSEntry::getHostByName(const QString & name) const
343
HostIterator it = getHosts();
346
while ( (host = it.current()) != 0 )
350
if (host->name==name)
357
NFSHost* NFSEntry::getPublicHost() const
359
NFSHost* result = getHostByName("*");
363
return getHostByName(QString::null); //krazy:exclude=nullstrassign for old broken gcc
367
HostIterator NFSEntry::getHosts() const
369
return HostIterator(_hosts);
372
QString NFSEntry::path() const
377
void NFSEntry::setPath(const QString & path)