1 /* This file is part of the KDE project
2 Copyright (C) 2000 Alexander Neundorf <neundorf@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library 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 GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
23 #include <kio/slavebase.h>
24 #include <kio/global.h>
26 #include <QtCore/QHash>
27 #include <QtCore/QMap>
28 #include <QtCore/QString>
29 #include <QtCore/QStringList>
30 #include <QtCore/QTimer>
32 #define PORTMAP //this seems to be required to compile on Solaris
34 #include <sys/socket.h>
35 #include <netinet/in.h>
42 NFSFileHandle(const NFSFileHandle
& handle
);
44 NFSFileHandle
& operator= (const NFSFileHandle
& src
);
45 NFSFileHandle
& operator= (const char* src
);
46 operator const char* () const {return m_handle
;}
47 bool isInvalid() const {return m_isInvalid
;}
48 void setInvalid() {m_isInvalid
=true;}
49 // time_t age() const;
51 char m_handle
[NFS_FHSIZE
+1];
53 // time_t m_detectTime;
56 //ostream& operator<<(ostream&, const NFSFileHandle&);
58 typedef QMap
<QString
,NFSFileHandle
> NFSFileHandleMap
;
61 class NFSProtocol
: public KIO::SlaveBase
64 NFSProtocol (const QByteArray
&pool
, const QByteArray
&app
);
65 virtual ~NFSProtocol();
67 virtual void openConnection();
68 virtual void closeConnection();
70 virtual void setHost( const QString
& host
, quint16 port
, const QString
& user
, const QString
& pass
);
72 virtual void put( const KUrl
& url
, int _mode
, KIO::JobFlags _flags
);
73 virtual void get( const KUrl
& url
);
74 virtual void listDir( const KUrl
& url
);
75 virtual void symlink( const QString
&target
, const KUrl
&dest
, KIO::JobFlags
);
76 virtual void stat( const KUrl
& url
);
77 virtual void mkdir( const KUrl
& url
, int permissions
);
78 virtual void del( const KUrl
& url
, bool isfile
);
79 virtual void chmod(const KUrl
& url
, int permissions
);
80 virtual void rename(const KUrl
&src
, const KUrl
&dest
, KIO::JobFlags flags
);
81 virtual void copy( const KUrl
& src
, const KUrl
&dest
, int mode
, KIO::JobFlags flags
);
83 // void createVirtualDirEntry(KIO::UDSEntry & entry);
84 bool checkForError(int clientStat
, int nfsStat
, const QString
& text
);
85 bool isExportedDir(const QString
& path
);
86 void completeUDSEntry(KIO::UDSEntry
& entry
, fattr
& attributes
);
87 void completeBadLinkUDSEntry(KIO::UDSEntry
& entry
, fattr
& attributes
);
88 void completeAbsoluteLinkUDSEntry(KIO::UDSEntry
& entry
, const QByteArray
& path
);
89 bool isValidLink(const QString
& parentDir
, const QString
& linkDest
);
90 // bool isAbsoluteLink(const QString& path);
92 NFSFileHandle
getFileHandle(QString path
);
94 NFSFileHandleMap m_handleCache
;
95 QHash
<long, QString
> m_usercache
; // maps long ==> QString *
96 QHash
<long, QString
> m_groupcache
;
98 QStringList m_exportedDirs
;
99 QString m_currentHost
;
102 timeval total_timeout
;
103 timeval pertry_timeout
;
106 void checkForOldFHs();