00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KIO_NFS_H
00021 #define KIO_NFS_H
00022
00023 #include <kio/slavebase.h>
00024 #include <kio/global.h>
00025
00026 #include <tqmap.h>
00027 #include <tqstring.h>
00028 #include <tqstringlist.h>
00029 #include <tqintdict.h>
00030 #include <tqtimer.h>
00031
00032 #define PORTMAP //this seems to be required to compile on Solaris
00033 #include <rpc/rpc.h>
00034 #include <sys/socket.h>
00035 #include <netinet/in.h>
00036 #include <sys/time.h>
00037
00038 class NFSFileHandle
00039 {
00040 public:
00041 NFSFileHandle();
00042 NFSFileHandle(const NFSFileHandle & handle);
00043 ~NFSFileHandle();
00044 NFSFileHandle& operator= (const NFSFileHandle& src);
00045 NFSFileHandle& operator= (const char* src);
00046 operator const char* () const {return m_handle;}
00047 bool isInvalid() const {return m_isInvalid;}
00048 void setInvalid() {m_isInvalid=TRUE;}
00049
00050 protected:
00051 char m_handle[NFS_FHSIZE+1];
00052 bool m_isInvalid;
00053
00054 };
00055
00056
00057
00058 typedef TQMap<TQString,NFSFileHandle> NFSFileHandleMap;
00059
00060
00061 class NFSProtocol : public KIO::SlaveBase
00062 {
00063 public:
00064 NFSProtocol (const TQCString &pool, const TQCString &app );
00065 virtual ~NFSProtocol();
00066
00067 virtual void openConnection();
00068 virtual void closeConnection();
00069
00070 virtual void setHost( const TQString& host, int port, const TQString& user, const TQString& pass );
00071
00072 virtual void put( const KURL& url, int _mode,bool _overwrite, bool _resume );
00073 virtual void get( const KURL& url );
00074 virtual void listDir( const KURL& url);
00075 virtual void symlink( const TQString &target, const KURL &dest, bool );
00076 virtual void stat( const KURL & url);
00077 virtual void mkdir( const KURL& url, int permissions );
00078 virtual void del( const KURL& url, bool isfile);
00079 virtual void chmod(const KURL& url, int permissions );
00080 virtual void rename(const KURL &src, const KURL &dest, bool overwrite);
00081 virtual void copy( const KURL& src, const KURL &dest, int mode, bool overwrite );
00082 protected:
00083
00084 bool checkForError(int clientStat, int nfsStat, const TQString& text);
00085 bool isExportedDir(const TQString& path);
00086 void completeUDSEntry(KIO::UDSEntry& entry, fattr& attributes);
00087 void completeBadLinkUDSEntry(KIO::UDSEntry& entry, fattr& attributes);
00088 void completeAbsoluteLinkUDSEntry(KIO::UDSEntry& entry, const TQCString& path);
00089 bool isValidLink(const TQString& parentDir, const TQString& linkDest);
00090
00091
00092 NFSFileHandle getFileHandle(TQString path);
00093
00094 NFSFileHandleMap m_handleCache;
00095 TQIntDict<TQString> m_usercache;
00096 TQIntDict<TQString> m_groupcache;
00097
00098 TQStringList m_exportedDirs;
00099 TQString m_currentHost;
00100 CLIENT *m_client;
00101 CLIENT *m_nfsClient;
00102 timeval total_timeout;
00103 timeval pertry_timeout;
00104 int m_sock;
00105 time_t m_lastCheck;
00106 void checkForOldFHs();
00107 };
00108
00109 #endif