nfs4: Add close() and free_cookie() hooks
This commit is contained in:
parent
2f2e57d035
commit
60a8140ded
@ -249,6 +249,30 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Inode::Close(OpenFileCookie* cookie)
|
||||
{
|
||||
RequestBuilder req(ProcCompound);
|
||||
req.PutFH(fHandle);
|
||||
req.Close(cookie->fSeq, cookie->fStateId, cookie->fStateSeq);
|
||||
|
||||
RPC::Reply *rpl;
|
||||
fFilesystem->Server()->SendCall(req.Request(), &rpl);
|
||||
ReplyInterpreter reply(rpl);
|
||||
|
||||
status_t result;
|
||||
result = reply.PutFH();
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
result = reply.Close();
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Inode::Read(OpenFileCookie* cookie, off_t pos, void* buffer, size_t* _length)
|
||||
{
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
status_t Stat(struct stat* st);
|
||||
|
||||
status_t Open(int mode, OpenFileCookie* cookie);
|
||||
status_t Close(OpenFileCookie* cookie);
|
||||
status_t Read(OpenFileCookie* cookie, off_t pos,
|
||||
void* buffer, size_t* length);
|
||||
|
||||
|
@ -22,6 +22,7 @@ enum Procedure {
|
||||
|
||||
enum Opcode {
|
||||
OpAccess = 3,
|
||||
OpClose = 4,
|
||||
OpGetAttr = 9,
|
||||
OpGetFH = 10,
|
||||
OpLookUp = 15,
|
||||
|
@ -65,6 +65,22 @@ ReplyInterpreter::Access(uint32* supported, uint32* allowed)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ReplyInterpreter::Close()
|
||||
{
|
||||
status_t res = _OperationError(OpClose);
|
||||
if (res != B_OK)
|
||||
return res;
|
||||
|
||||
fReply->Stream().GetUInt();
|
||||
fReply->Stream().GetUInt();
|
||||
fReply->Stream().GetUInt();
|
||||
fReply->Stream().GetUInt();
|
||||
|
||||
return fReply->Stream().IsEOF() ? B_BAD_VALUE : B_OK;
|
||||
}
|
||||
|
||||
|
||||
// Bit Twiddling Hacks
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html
|
||||
static inline uint32 sCountBits(uint32 v)
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
~ReplyInterpreter();
|
||||
|
||||
status_t Access(uint32* supported, uint32* allowed);
|
||||
status_t Close();
|
||||
status_t GetAttr(AttrValue** attrs, uint32* count);
|
||||
status_t GetFH(Filehandle* fh);
|
||||
inline status_t LookUp();
|
||||
|
@ -53,6 +53,27 @@ RequestBuilder::Access()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RequestBuilder::Close(uint32 seq, const uint32* id, uint32 stateSeq)
|
||||
{
|
||||
if (fProcedure != ProcCompound)
|
||||
return B_BAD_VALUE;
|
||||
if (fRequest == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
fRequest->Stream().AddUInt(OpClose);
|
||||
fRequest->Stream().AddUInt(seq);
|
||||
fRequest->Stream().AddUInt(stateSeq);
|
||||
fRequest->Stream().AddUInt(id[0]);
|
||||
fRequest->Stream().AddUInt(id[1]);
|
||||
fRequest->Stream().AddUInt(id[2]);
|
||||
|
||||
fOpCount++;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RequestBuilder::GetAttr(Attribute* attrs, uint32 count)
|
||||
{
|
||||
|
@ -23,6 +23,8 @@ public:
|
||||
~RequestBuilder();
|
||||
|
||||
status_t Access();
|
||||
status_t Close(uint32 seq, const uint32* id,
|
||||
uint32 stateSeq);
|
||||
status_t GetAttr(Attribute* attrs, uint32 count);
|
||||
status_t GetFH();
|
||||
status_t LookUp(const char* name);
|
||||
|
@ -156,7 +156,26 @@ nfs4_open(fs_volume* volume, fs_vnode* vnode, int openMode, void** _cookie)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
static status_t
|
||||
nfs4_close(fs_volume* volume, fs_vnode* vnode, void* cookie)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
nfs4_free_cookie(fs_volume* volume, fs_vnode* vnode, void* _cookie)
|
||||
{
|
||||
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
||||
OpenFileCookie* cookie = reinterpret_cast<OpenFileCookie*>(_cookie);
|
||||
inode->Close(cookie);
|
||||
delete cookie;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
nfs4_read(fs_volume* volume, fs_vnode* vnode, void* _cookie, off_t pos,
|
||||
void* buffer, size_t* length)
|
||||
{
|
||||
@ -308,8 +327,8 @@ fs_vnode_ops gNFSv4VnodeOps = {
|
||||
/* file operations */
|
||||
NULL, // create()
|
||||
nfs4_open,
|
||||
NULL, // close()
|
||||
NULL, // free_cookie()
|
||||
nfs4_close,
|
||||
nfs4_free_cookie,
|
||||
nfs4_read,
|
||||
NULL, // write,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user