nfs4: Add read_symlink() hook
This commit is contained in:
parent
27a291de54
commit
f2da914d39
@ -151,6 +151,36 @@ Inode::LookUp(const char* name, ino_t* id)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Inode::ReadLink(void* buffer, size_t* length)
|
||||
{
|
||||
if (fType != NF4LNK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
Request request(fFilesystem->Server());
|
||||
RequestBuilder& req = request.Builder();
|
||||
|
||||
req.PutFH(fHandle);
|
||||
req.ReadLink();
|
||||
|
||||
status_t result = request.Send();
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
ReplyInterpreter& reply = request.Reply();
|
||||
|
||||
result = reply.PutFH();
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
uint32 size;
|
||||
result = reply.ReadLink(buffer, &size, *length);
|
||||
*length = static_cast<size_t>(size);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Inode::Access(int mode)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
inline const char* Name() const;
|
||||
|
||||
status_t LookUp(const char* name, ino_t* id);
|
||||
status_t ReadLink(void* buffer, size_t* length);
|
||||
status_t Access(int mode);
|
||||
status_t Stat(struct stat* st);
|
||||
|
||||
|
@ -33,6 +33,7 @@ enum Opcode {
|
||||
OpPutRootFH = 24,
|
||||
OpRead = 25,
|
||||
OpReadDir = 26,
|
||||
OpReadLink = 27,
|
||||
OpRenew = 30,
|
||||
OpSetClientID = 35,
|
||||
OpSetClientIDConfirm = 36
|
||||
|
@ -257,6 +257,19 @@ ReplyInterpreter::ReadDir(uint64* cookie, DirEntry** dirents, uint32* _count,
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ReplyInterpreter::ReadLink(void* buffer, uint32* size, uint32 maxSize)
|
||||
{
|
||||
status_t res = _OperationError(OpReadLink);
|
||||
if (res != B_OK)
|
||||
return res;
|
||||
|
||||
const void* ptr = fReply->Stream().GetOpaque(size);
|
||||
memcpy(buffer, ptr, min_c(*size, maxSize));
|
||||
|
||||
return fReply->Stream().IsEOF() ? B_BAD_VALUE : B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
ReplyInterpreter::SetClientID(uint64* clientid, uint64* verifier)
|
||||
{
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
status_t Read(void* buffer, uint32* size, bool* eof);
|
||||
status_t ReadDir(uint64* cookie, DirEntry** dirents,
|
||||
uint32* count, bool* eof);
|
||||
status_t ReadLink(void* buffer, uint32* size, uint32 maxSize);
|
||||
inline status_t Renew();
|
||||
status_t SetClientID(uint64* clientid, uint64* verifier);
|
||||
inline status_t SetClientIDConfirm();
|
||||
|
@ -286,6 +286,22 @@ RequestBuilder::ReadDir(uint32 count, uint64* cookie, Attribute* attrs,
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RequestBuilder::ReadLink()
|
||||
{
|
||||
if (fProcedure != ProcCompound)
|
||||
return B_BAD_VALUE;
|
||||
if (fRequest == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
fRequest->Stream().AddUInt(OpReadLink);
|
||||
|
||||
fOpCount++;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RequestBuilder::Renew(uint64 clientId)
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
uint64 pos, uint32 len);
|
||||
status_t ReadDir(uint32 count, uint64* cookie,
|
||||
Attribute* attrs, uint32 attrCount);
|
||||
status_t ReadLink();
|
||||
status_t Renew(uint64 clientId);
|
||||
status_t SetClientID(const RPC::Server* serv);
|
||||
status_t SetClientIDConfirm(uint64 id, uint64 ver);
|
||||
|
@ -145,6 +145,15 @@ nfs4_put_vnode(fs_volume* volume, fs_vnode* vnode, bool reenter)
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
nfs4_read_symlink(fs_volume* volume, fs_vnode* link, char* buffer,
|
||||
size_t* _bufferSize)
|
||||
{
|
||||
Inode* inode = reinterpret_cast<Inode*>(link->private_node);
|
||||
return inode->ReadLink(buffer, _bufferSize);
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
nfs4_access(fs_volume* volume, fs_vnode* vnode, int mode)
|
||||
{
|
||||
@ -342,7 +351,7 @@ fs_vnode_ops gNFSv4VnodeOps = {
|
||||
NULL, // fs_deselect()
|
||||
NULL, // fsync()
|
||||
|
||||
NULL, // read_link()
|
||||
nfs4_read_symlink,
|
||||
NULL, // create_symlink()
|
||||
|
||||
NULL, // link()
|
||||
|
Loading…
Reference in New Issue
Block a user