nfs4: Fix removing nodes other than NF4DIR or NF4REG

This commit is contained in:
Pawel Dziepak 2012-06-26 21:20:57 +02:00
parent 69adfb6de2
commit 9737896827
5 changed files with 38 additions and 4 deletions

View File

@ -241,8 +241,11 @@ Inode::Remove(const char* name, FileType type)
AttrValue attr;
attr.fAttribute = FATTR4_TYPE;
attr.fFreePointer = false;
attr.fData.fValue32 = type;
req.Verify(&attr, 1);
attr.fData.fValue32 = NF4DIR;
if (type == NF4DIR)
req.Verify(&attr, 1);
else
req.Nverify(&attr, 1);
req.PutFH(fHandle);
req.Remove(name);
@ -259,8 +262,12 @@ Inode::Remove(const char* name, FileType type)
reply.PutFH();
reply.LookUp();
result = reply.Verify();
if (result == NFS4ERR_NOT_SAME && type == NF4REG)
if (type == NF4DIR)
result = reply.Verify();
else
result = reply.Nverify();
if (result == NFS4ERR_SAME && type != NF4DIR)
return B_IS_A_DIRECTORY;
if (result == NFS4ERR_NOT_SAME && type == NF4DIR)
return B_NOT_A_DIRECTORY;

View File

@ -29,6 +29,7 @@ enum Opcode {
OpLink = 11,
OpLookUp = 15,
OpLookUpUp = 16,
OpNverify = 17,
OpOpen = 18,
OpOpenConfirm = 20,
OpPutFH = 22,

View File

@ -72,6 +72,7 @@ public:
status_t Link();
inline status_t LookUp();
inline status_t LookUpUp();
inline status_t Nverify();
status_t Open(uint32* id, uint32* seq, bool* confirm);
status_t OpenConfirm(uint32* stateSeq);
inline status_t PutFH();
@ -150,6 +151,13 @@ ReplyInterpreter::LookUpUp()
}
inline status_t
ReplyInterpreter::Nverify()
{
return _OperationError(OpNverify);
}
inline status_t
ReplyInterpreter::PutFH()
{

View File

@ -197,6 +197,23 @@ RequestBuilder::LookUpUp()
}
status_t
RequestBuilder::Nverify(AttrValue* attr, uint32 count)
{
if (fProcedure != ProcCompound)
return B_BAD_VALUE;
if (fRequest == NULL)
return B_NO_MEMORY;
fRequest->Stream().AddUInt(OpNverify);
_EncodeAttrs(fRequest->Stream(), attr, count);
fOpCount++;
return B_OK;
}
status_t
RequestBuilder::Open(OpenClaim claim, uint32 seq, uint32 access, uint64 id,
OpenCreate oc, uint64 ownerId, const char* name, AttrValue* attr,

View File

@ -36,6 +36,7 @@ public:
status_t Link(const char* name);
status_t LookUp(const char* name);
status_t LookUpUp();
status_t Nverify(AttrValue* attr, uint32 count);
status_t Open(OpenClaim claim, uint32 seq,
uint32 access, uint64 id, OpenCreate oc,
uint64 ownerId, const char* name,