2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Paweł Dziepak, pdziepak@quarnos.org
10 #include "ReplyBuilder.h"
13 #include "RPCCallbackReply.h"
16 ReplyBuilder::ReplyBuilder(uint32 xid
)
20 fReply(RPC::CallbackReply::Create(xid
))
26 ReplyBuilder::~ReplyBuilder()
33 ReplyBuilder::_InitHeader()
35 fStatusPosition
= fReply
->Stream().Current();
36 fReply
->Stream().AddUInt(0);
38 fReply
->Stream().AddOpaque(NULL
, 0);
40 fOpCountPosition
= fReply
->Stream().Current();
41 fReply
->Stream().AddUInt(0);
49 fReply
->Stream().InsertUInt(fStatusPosition
, _HaikuErrorToNFS4(fStatus
));
50 fReply
->Stream().InsertUInt(fOpCountPosition
, fOpCount
);
52 if (fReply
== NULL
|| fReply
->Stream().Error() == B_OK
)
60 ReplyBuilder::GetAttr(status_t status
, int mask
, uint64 size
, uint64 change
)
65 fReply
->Stream().AddUInt(OpCallbackGetAttr
);
66 fReply
->Stream().AddUInt(_HaikuErrorToNFS4(fStatus
));
71 if ((mask
& CallbackAttrChange
) != 0)
72 bitmap
|= 1 << FATTR4_CHANGE
;
73 if ((mask
& CallbackAttrSize
) != 0)
74 bitmap
|= 1 << FATTR4_SIZE
;
75 fReply
->Stream().AddUInt(1);
76 fReply
->Stream().AddUInt(bitmap
);
79 if ((mask
& CallbackAttrChange
) != 0)
80 str
.AddUHyper(change
);
82 if ((mask
& CallbackAttrSize
) != 0)
84 fReply
->Stream().AddOpaque(str
);
94 ReplyBuilder::Recall(status_t status
)
99 fReply
->Stream().AddUInt(OpCallbackRecall
);
100 fReply
->Stream().AddUInt(_HaikuErrorToNFS4(fStatus
));
110 ReplyBuilder::_HaikuErrorToNFS4(status_t error
)
113 case B_OK
: return NFS4_OK
;
114 case B_FILE_NOT_FOUND
: return NFS4ERR_BADHANDLE
;
115 case B_NOT_SUPPORTED
: return NFS4ERR_OP_ILLEGAL
;
116 default: return NFS4ERR_RESOURCE
;