BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / file_systems / nfs4 / ReplyInterpreter.h
blob819cce4955b75389bc19edebd96ce62764a00dd0
1 /*
2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Paweł Dziepak, pdziepak@quarnos.org
7 */
8 #ifndef REPLYINTERPRETER_H
9 #define REPLYINTERPRETER_H
12 #include <SupportDefs.h>
14 #include "FileInfo.h"
15 #include "NFS4Defs.h"
16 #include "RPCReply.h"
19 struct FSLocation {
20 const char** fRootPath;
22 const char** fLocations;
23 uint32 fCount;
25 ~FSLocation();
28 struct FSLocations {
29 const char** fRootPath;
31 FSLocation* fLocations;
32 uint32 fCount;
34 ~FSLocations();
37 struct AttrValue {
38 AttrValue();
39 ~AttrValue();
41 uint8 fAttribute;
42 bool fFreePointer;
43 union {
44 uint32 fValue32;
45 uint64 fValue64;
46 void* fPointer;
47 FSLocations* fLocations;
48 } fData;
51 struct DirEntry {
52 const char* fName;
53 AttrValue* fAttrs;
54 uint32 fAttrCount;
56 DirEntry();
57 ~DirEntry();
60 class LockInfo;
62 class ReplyInterpreter {
63 public:
64 ReplyInterpreter(RPC::Reply* reply = NULL);
65 ~ReplyInterpreter();
67 inline status_t SetTo(RPC::Reply* reply);
68 inline void Reset();
70 inline uint32 NFS4Error();
72 status_t Access(uint32* supported, uint32* allowed);
73 status_t Close();
74 status_t Commit();
75 status_t Create(uint64* before, uint64* after, bool& atomic);
76 inline status_t DelegReturn();
77 status_t GetAttr(AttrValue** attrs, uint32* count);
78 status_t GetFH(FileHandle* fh);
79 status_t Link(uint64* before, uint64* after, bool& atomic);
80 status_t Lock(LockInfo* linfo);
81 status_t LockT(uint64* pos, uint64* len, LockType* type);
82 status_t LockU(LockInfo* linfo);
83 inline status_t LookUp();
84 inline status_t LookUpUp();
85 inline status_t Nverify();
86 status_t Open(uint32* id, uint32* seq, bool* confirm,
87 OpenDelegationData* delegData,
88 ChangeInfo* changeInfo = NULL);
89 inline status_t OpenAttrDir();
90 status_t OpenConfirm(uint32* stateSeq);
91 inline status_t PutFH();
92 inline status_t PutRootFH();
93 status_t Read(void* buffer, uint32* size, bool* eof);
94 status_t ReadDir(uint64* cookie, uint64* cookieVerf,
95 DirEntry** dirents, uint32* count, bool* eof);
96 status_t ReadLink(void* buffer, uint32* size, uint32 maxSize);
97 status_t Remove(uint64* before, uint64* after, bool& atomic);
98 status_t Rename(uint64* fromBefore, uint64* fromAfter,
99 bool& fromAtomic, uint64* toBefore, uint64* toAfter,
100 bool& toAtomic);
101 inline status_t Renew();
102 inline status_t SaveFH();
103 status_t SetAttr();
104 status_t SetClientID(uint64* clientid, uint64* verifier);
105 inline status_t SetClientIDConfirm();
106 inline status_t Verify();
107 status_t Write(uint32* size);
108 inline status_t ReleaseLockOwner();
110 private:
111 void _ParseHeader();
113 static const char** _GetPath(XDR::ReadStream& stream);
115 status_t _DecodeAttrs(XDR::ReadStream& stream, AttrValue** attrs,
116 uint32* count);
117 status_t _OperationError(Opcode op);
119 static status_t _NFS4ErrorToHaiku(uint32 x);
121 uint32 fNFS4Error;
122 bool fDecodeError;
123 RPC::Reply* fReply;
127 inline status_t
128 ReplyInterpreter::SetTo(RPC::Reply* _reply)
130 if (fReply != NULL)
131 return B_DONT_DO_THAT;
133 fDecodeError = false;
134 fReply = _reply;
136 if (fReply != NULL)
137 _ParseHeader();
139 return B_OK;
143 inline void
144 ReplyInterpreter::Reset()
146 delete fReply;
147 fReply = NULL;
148 fDecodeError = false;
152 inline uint32
153 ReplyInterpreter::NFS4Error()
155 return fNFS4Error;
159 inline status_t
160 ReplyInterpreter::DelegReturn()
162 return _OperationError(OpDelegReturn);
166 inline status_t
167 ReplyInterpreter::LookUp()
169 return _OperationError(OpLookUp);
173 inline status_t
174 ReplyInterpreter::LookUpUp()
176 return _OperationError(OpLookUpUp);
180 inline status_t
181 ReplyInterpreter::OpenAttrDir()
183 return _OperationError(OpOpenAttrDir);
187 inline status_t
188 ReplyInterpreter::Nverify()
190 return _OperationError(OpNverify);
194 inline status_t
195 ReplyInterpreter::PutFH()
197 return _OperationError(OpPutFH);
201 inline status_t
202 ReplyInterpreter::PutRootFH()
204 return _OperationError(OpPutRootFH);
208 inline status_t
209 ReplyInterpreter::Renew()
211 return _OperationError(OpRenew);
215 inline status_t
216 ReplyInterpreter::SaveFH()
218 return _OperationError(OpSaveFH);
222 inline status_t
223 ReplyInterpreter::SetClientIDConfirm()
225 return _OperationError(OpSetClientIDConfirm);
229 inline status_t
230 ReplyInterpreter::Verify()
232 return _OperationError(OpVerify);
236 inline status_t
237 ReplyInterpreter::ReleaseLockOwner()
239 return _OperationError(OpReleaseLockOwner);
243 #endif // REPLYINTERPRETER_H