File: nfsv2.h

package info (click to toggle)
kio-extras 4%3A16.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,720 kB
  • ctags: 3,303
  • sloc: cpp: 26,172; ansic: 5,034; perl: 1,056; xml: 460; python: 28; sh: 20; makefile: 6
file content (103 lines) | stat: -rw-r--r-- 3,887 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*  This file is part of the KDE project
    Copyright (C) 2000 Alexander Neundorf <neundorf@kde.org>,
        2014 Mathias Tillman <master.homer@gmail.com>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifndef KIO_NFSV2_H
#define KIO_NFSV2_H

#include "kio_nfs.h"

#define PORTMAP  //this seems to be required to compile on Solaris
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h>

class NFSProtocolV2 : public NFSProtocol
{
public:
    NFSProtocolV2(NFSSlave* slave);
    ~NFSProtocolV2();

    bool isCompatible(bool& connectionError) Q_DECL_OVERRIDE;
    bool isConnected() const Q_DECL_OVERRIDE;

    void openConnection() Q_DECL_OVERRIDE;
    void closeConnection() Q_DECL_OVERRIDE;

    void setHost(const QString& host) Q_DECL_OVERRIDE;

    void put(const QUrl& url, int _mode, KIO::JobFlags _flags) Q_DECL_OVERRIDE;
    void get(const QUrl& url) Q_DECL_OVERRIDE;
    void listDir(const QUrl& url) Q_DECL_OVERRIDE;
    void symlink(const QString& target, const QUrl& dest, KIO::JobFlags) Q_DECL_OVERRIDE;
    void stat(const QUrl& url) Q_DECL_OVERRIDE;
    void mkdir(const QUrl& url, int permissions) Q_DECL_OVERRIDE;
    void del(const QUrl& url, bool isfile) Q_DECL_OVERRIDE;
    void chmod(const QUrl& url, int permissions) Q_DECL_OVERRIDE;
    void rename(const QUrl& src, const QUrl& dest, KIO::JobFlags flags) Q_DECL_OVERRIDE;

protected:
    void copySame(const QUrl& src, const QUrl& dest, int mode, KIO::JobFlags flags) Q_DECL_OVERRIDE;
    void copyFrom(const QUrl& src, const QUrl& dest, int mode, KIO::JobFlags flags) Q_DECL_OVERRIDE;
    void copyTo(const QUrl& src, const QUrl& dest, int mode, KIO::JobFlags flags) Q_DECL_OVERRIDE;

    NFSFileHandle lookupFileHandle(const QString& path) Q_DECL_OVERRIDE;

private:
    bool create(const QString& path, int mode, int& rpcStatus, diropres& result);

    bool getAttr(const QString& path, int& rpcStatus, attrstat& result);

    bool lookupHandle(const QString& path, int& rpcStatus, diropres& result);

    bool readLink(const QString& path, int& rpcStatus, readlinkres& result, char* dataBuffer);

    // Calls @remove, but with dummy rpcStatus and result arguments
    bool remove(const QString& path);
    bool remove(const QString& path, int& rpcStatus, nfsstat& result);

    // Calls @rename, but with dummy rpcStatus and result arguments
    bool rename(const QString& src, const QString& dest);
    bool rename(const QString& src, const QString& dest, int& rpcStatus, nfsstat& result);

    bool setAttr(const QString& path, const sattr& attributes, int& rpcStatus, nfsstat& result);

    bool symLink(const QString& target, const QString& dest, int& rpcStatus, nfsstat& result);

    // UDS helper functions
    void completeUDSEntry(KIO::UDSEntry& entry, const fattr& attributes);
    void completeBadLinkUDSEntry(KIO::UDSEntry& entry, const fattr& attributes);

    NFSSlave* m_slave;

    QString m_currentHost;

    CLIENT* m_mountClient;
    int m_mountSock;
    CLIENT* m_nfsClient;
    int m_nfsSock;

    timeval clnt_timeout;

    QHash<long, QString> m_usercache;
    QHash<long, QString> m_groupcache;
};

#endif