nfs4: Add access() hook
This commit is contained in:
@@ -132,6 +132,47 @@ Inode::LookUp(const char* name, ino_t* id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Inode::Access(int mode)
|
||||||
|
{
|
||||||
|
RequestBuilder req(ProcCompound);
|
||||||
|
req.PutFH(fHandle);
|
||||||
|
req.Access();
|
||||||
|
|
||||||
|
RPC::Reply *rpl;
|
||||||
|
fFilesystem->Server()->SendCall(req.Request(), &rpl);
|
||||||
|
ReplyInterpreter reply(rpl);
|
||||||
|
|
||||||
|
status_t result;
|
||||||
|
result = reply.PutFH();
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
uint32 allowed;
|
||||||
|
result = reply.Access(NULL, &allowed);
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
int acc = 0;
|
||||||
|
if ((allowed & ACCESS4_READ) != 0)
|
||||||
|
acc |= R_OK;
|
||||||
|
|
||||||
|
if (fType == NF4DIR && (allowed & ACCESS4_LOOKUP) != 0)
|
||||||
|
acc |= X_OK | R_OK;
|
||||||
|
|
||||||
|
if (fType != NF4DIR && (allowed & ACCESS4_EXECUTE) != 0)
|
||||||
|
acc |= X_OK;
|
||||||
|
|
||||||
|
if ((allowed & ACCESS4_MODIFY) != 0)
|
||||||
|
acc |= W_OK;
|
||||||
|
|
||||||
|
if ((mode & acc) != mode)
|
||||||
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Inode::Stat(struct stat* st)
|
Inode::Stat(struct stat* st)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public:
|
|||||||
inline const char* Name() const;
|
inline const char* Name() const;
|
||||||
|
|
||||||
status_t LookUp(const char* name, ino_t* id);
|
status_t LookUp(const char* name, ino_t* id);
|
||||||
|
status_t Access(int mode);
|
||||||
status_t Stat(struct stat* st);
|
status_t Stat(struct stat* st);
|
||||||
|
|
||||||
status_t Open(int mode, OpenFileCookie* cookie);
|
status_t Open(int mode, OpenFileCookie* cookie);
|
||||||
|
|||||||
@@ -131,6 +131,14 @@ nfs4_put_vnode(fs_volume* volume, fs_vnode* vnode, bool reenter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static status_t
|
||||||
|
nfs4_access(fs_volume* volume, fs_vnode* vnode, int mode)
|
||||||
|
{
|
||||||
|
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
||||||
|
return inode->Access(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
nfs4_read_stat(fs_volume* volume, fs_vnode* vnode, struct stat* stat)
|
nfs4_read_stat(fs_volume* volume, fs_vnode* vnode, struct stat* stat)
|
||||||
{
|
{
|
||||||
@@ -312,7 +320,7 @@ fs_vnode_ops gNFSv4VnodeOps = {
|
|||||||
NULL, // unlink()
|
NULL, // unlink()
|
||||||
NULL, // rename()
|
NULL, // rename()
|
||||||
|
|
||||||
NULL, // access()
|
nfs4_access,
|
||||||
nfs4_read_stat,
|
nfs4_read_stat,
|
||||||
NULL, // write_stat()
|
NULL, // write_stat()
|
||||||
NULL, // fs_preallocate()
|
NULL, // fs_preallocate()
|
||||||
|
|||||||
Reference in New Issue
Block a user