File indexing completed on 2024-03-24 05:00:35
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_NFSV2_H 0009 #define KIO_NFSV2_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 NFSProtocolV2 : public NFSProtocol 0020 { 0021 public: 0022 explicit NFSProtocolV2(NFSSlave *slave); 0023 ~NFSProtocolV2() 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 NFSFileHandle lookupFileHandle(const QString &path) override; 0047 0048 private: 0049 bool create(const QString &path, int mode, int &rpcStatus, diropres &result); 0050 0051 bool getAttr(const QString &path, int &rpcStatus, attrstat &result); 0052 0053 bool lookupHandle(const QString &path, int &rpcStatus, diropres &result); 0054 0055 bool symLinkTarget(const QString &path, int &rpcStatus, readlinkres &result, char *dataBuffer); 0056 0057 // Calls @remove, but with dummy rpcStatus and result arguments 0058 bool remove(const QString &path); 0059 bool remove(const QString &path, int &rpcStatus, nfsstat &result); 0060 0061 // Calls @rename, but with dummy rpcStatus and result arguments 0062 bool rename(const QString &src, const QString &dest); 0063 bool rename(const QString &src, const QString &dest, int &rpcStatus, nfsstat &result); 0064 0065 bool setAttr(const QString &path, const sattr &attributes, int &rpcStatus, nfsstat &result); 0066 0067 bool symLink(const QString &target, const QString &dest, int &rpcStatus, nfsstat &result); 0068 0069 // UDS helper functions 0070 void completeUDSEntry(KIO::UDSEntry &entry, const fattr &attributes); 0071 void completeBadLinkUDSEntry(KIO::UDSEntry &entry, const fattr &attributes); 0072 0073 CLIENT *m_mountClient; 0074 int m_mountSock; 0075 CLIENT *m_nfsClient; 0076 int m_nfsSock; 0077 0078 timeval clnt_timeout; 0079 }; 0080 0081 #endif