nfs4: Add open_dir, close_dir and free_dir_cookie hooks
This commit is contained in:
@@ -107,3 +107,34 @@ Inode::Stat(struct stat* st)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Inode::OpenDir(uint64* cookie)
|
||||
{
|
||||
if (fType != NF4DIR)
|
||||
return B_NOT_A_DIRECTORY;
|
||||
|
||||
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;
|
||||
|
||||
if (allowed & ACCESS4_READ != ACCESS4_READ)
|
||||
return B_PERMISSION_DENIED;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
inline mode_t Type() const;
|
||||
|
||||
status_t Stat(struct stat* st);
|
||||
status_t OpenDir(uint64* cookie);
|
||||
|
||||
private:
|
||||
uint64 fFileId;
|
||||
|
||||
@@ -95,6 +95,38 @@ nfs4_read_stat(fs_volume* volume, fs_vnode* vnode, struct stat* stat)
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
nfs4_open_dir(fs_volume* volume, fs_vnode* vnode, void** _cookie)
|
||||
{
|
||||
uint64* cookie = new(std::nothrow) uint64;
|
||||
if (cookie == NULL)
|
||||
return B_NO_MEMORY;
|
||||
*_cookie = cookie;
|
||||
|
||||
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
||||
status_t result = inode->OpenDir(cookie);
|
||||
if (result != B_OK)
|
||||
delete cookie;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
nfs4_close_dir(fs_volume* volume, fs_vnode* vnode, void* cookie)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
nfs4_free_dir_cookie(fs_volume* volume, fs_vnode* vnode, void* cookie)
|
||||
{
|
||||
delete reinterpret_cast<uint64*>(cookie);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
nfs4_init()
|
||||
{
|
||||
@@ -174,6 +206,25 @@ fs_vnode_ops gNFSv4VnodeOps = {
|
||||
|
||||
NULL, // access()
|
||||
&nfs4_read_stat,
|
||||
NULL, // write_stat()
|
||||
NULL, // fs_preallocate()
|
||||
|
||||
/* file operations */
|
||||
NULL, // create()
|
||||
NULL, // open()
|
||||
NULL, // close()
|
||||
NULL, // free_cookie()
|
||||
NULL, // read()
|
||||
NULL, // write,
|
||||
|
||||
/* directory operations */
|
||||
NULL, // create_dir()
|
||||
NULL, // remove_dir()
|
||||
nfs4_open_dir,
|
||||
nfs4_close_dir,
|
||||
nfs4_free_dir_cookie,
|
||||
NULL, // read_dir()
|
||||
NULL, // rewind_dir,
|
||||
};
|
||||
|
||||
static file_system_module_info sNFSv4ModuleInfo = {
|
||||
|
||||
Reference in New Issue
Block a user