BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / file_systems / nfs4 / Delegation.cpp
blob086a2a46551d29f1c3d3170efbf0c1d79d2b6c7d
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 */
10 #include "Delegation.h"
12 #include "Inode.h"
13 #include "Request.h"
16 Delegation::Delegation(const OpenDelegationData& data, Inode* inode,
17 uint64 clientID, bool attribute)
19 fClientID(clientID),
20 fData(data),
21 fInode(inode),
22 fAttribute(attribute)
24 ASSERT(inode != NULL);
28 status_t
29 Delegation::GiveUp(bool truncate)
31 if (!fAttribute && !truncate)
32 fInode->SyncAndCommit(true);
34 ReturnDelegation();
36 return B_OK;
40 status_t
41 Delegation::ReturnDelegation()
43 uint32 attempt = 0;
44 do {
45 RPC::Server* serv = fFileSystem->Server();
46 Request request(serv, fFileSystem);
47 RequestBuilder& req = request.Builder();
49 req.PutFH(fInfo.fHandle);
50 req.DelegReturn(fData.fStateID, fData.fStateSeq);
52 status_t result = request.Send();
53 if (result != B_OK)
54 return result;
56 ReplyInterpreter& reply = request.Reply();
58 if (HandleErrors(attempt, reply.NFS4Error(), serv, NULL,
59 fInode->GetOpenState())) {
60 continue;
63 reply.PutFH();
65 return reply.DelegReturn();
66 } while (true);