File indexing completed on 2024-04-28 08:50:00
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2000 Alexander Neundorf <neundorf@kde.org> 0003 SPDX-FileCopyrightText: 2014 Mathias Tillman <master.homer@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KIO_NFSV3_H 0009 #define KIO_NFSV3_H 0010 0011 #include "kio_nfs.h" 0012 0013 #define PORTMAP // this seems to be required to compile on Solaris 0014 #include <netinet/in.h> 0015 #include <rpc/rpc.h> 0016 #include <sys/socket.h> 0017 #include <sys/time.h> 0018 0019 class NFSProtocolV3 : public NFSProtocol 0020 { 0021 public: 0022 explicit NFSProtocolV3(NFSSlave *slave); 0023 ~NFSProtocolV3() override; 0024 0025 bool isCompatible(bool &connectionError) override; 0026 bool isConnected() const override; 0027 0028 void openConnection() override; 0029 void closeConnection() override; 0030 0031 void put(const QUrl &url, int _mode, KIO::JobFlags _flags) override; 0032 void get(const QUrl &url) override; 0033 void listDir(const QUrl &url) override; 0034 void symlink(const QString &target, const QUrl &dest, KIO::JobFlags) override; 0035 void stat(const QUrl &url) override; 0036 void mkdir(const QUrl &url, int permissions) override; 0037 void del(const QUrl &url, bool isfile) override; 0038 void chmod(const QUrl &url, int permissions) override; 0039 void rename(const QUrl &src, const QUrl &dest, KIO::JobFlags flags) override; 0040 0041 protected: 0042 void copySame(const QUrl &src, const QUrl &dest, int mode, KIO::JobFlags flags) override; 0043 void copyFrom(const QUrl &src, const QUrl &dest, int mode, KIO::JobFlags flags) override; 0044 void copyTo(const QUrl &src, const QUrl &dest, int mode, KIO::JobFlags flags) override; 0045 0046 // For servers that don't support the READDIRPLUS command. 0047 void listDirCompat(const QUrl &url); 0048 0049 // Look up a file handle. 0050 NFSFileHandle lookupFileHandle(const QString &path) override; 0051 0052 private: 0053 NFSFileHandle create(const QString &path, int mode); 0054 0055 bool getAttr(const QString &path, int &rpcStatus, GETATTR3res &result); 0056 0057 bool lookupHandle(const QString &path, int &rpcStatus, LOOKUP3res &result); 0058 0059 bool symLinkTarget(const QString &path, int &rpcStatus, READLINK3res &result, char *dataBuffer); 0060 0061 // Calls @remove, but with dummy rpcStatus and result arguments 0062 bool remove(const QString &path); 0063 bool remove(const QString &path, int &rpcStatus, REMOVE3res &result); 0064 0065 // Calls @rename, but with dummy rpcStatus and result arguments 0066 bool rename(const QString &src, const QString &dest); 0067 bool rename(const QString &src, const QString &dest, int &rpcStatus, RENAME3res &result); 0068 0069 bool setAttr(const QString &path, const sattr3 &attributes, int &rpcStatus, SETATTR3res &result); 0070 0071 bool symLink(const QString &target, const QString &dest, int &rpcStatus, SYMLINK3res &result); 0072 0073 // Initialises the optimal read, write and read dir buffer sizes 0074 void initPreferredSizes(const NFSFileHandle &fh); 0075 0076 // UDS helper functions 0077 void completeUDSEntry(KIO::UDSEntry &entry, const fattr3 &attributes); 0078 void completeBadLinkUDSEntry(KIO::UDSEntry &entry, const fattr3 &attributes); 0079 0080 CLIENT *m_mountClient; 0081 int m_mountSock; 0082 CLIENT *m_nfsClient; 0083 int m_nfsSock; 0084 0085 timeval clnt_timeout; 0086 0087 // The optimal read and write buffer sizes and read dir size, cached values 0088 uint32 m_readBufferSize; 0089 uint32 m_writeBufferSize; 0090 uint32 m_readDirSize; 0091 }; 0092 0093 #endif