nfs4: Add create_dir() hook
This commit is contained in:
@@ -336,7 +336,7 @@ Inode::CreateLink(const char* name, const char* path, int mode)
|
|||||||
attr.fAttribute = FATTR4_MODE;
|
attr.fAttribute = FATTR4_MODE;
|
||||||
attr.fFreePointer = false;
|
attr.fFreePointer = false;
|
||||||
attr.fData.fValue32 = mode;
|
attr.fData.fValue32 = mode;
|
||||||
req.Create(NF4LNK, name, path, &attr, 1);
|
req.Create(NF4LNK, name, &attr, 1, path);
|
||||||
|
|
||||||
status_t result = request.Send();
|
status_t result = request.Send();
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
@@ -919,6 +919,38 @@ Inode::Write(OpenFileCookie* cookie, off_t pos, const void* _buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Inode::CreateDir(const char* name, int mode)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
RPC::Server* serv = fFilesystem->Server();
|
||||||
|
Request request(serv);
|
||||||
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
|
req.PutFH(fHandle);
|
||||||
|
|
||||||
|
AttrValue attr;
|
||||||
|
attr.fAttribute = FATTR4_MODE;
|
||||||
|
attr.fFreePointer = false;
|
||||||
|
attr.fData.fValue32 = mode;
|
||||||
|
req.Create(NF4DIR, name, &attr, 1);
|
||||||
|
|
||||||
|
status_t result = request.Send();
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
ReplyInterpreter& reply = request.Reply();
|
||||||
|
|
||||||
|
if (_HandleErrors(reply.NFS4Error(), serv))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
reply.PutFH();
|
||||||
|
|
||||||
|
return reply.Create();
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Inode::OpenDir(OpenDirCookie* cookie)
|
Inode::OpenDir(OpenDirCookie* cookie)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
status_t Write(OpenFileCookie* cookie, off_t pos,
|
status_t Write(OpenFileCookie* cookie, off_t pos,
|
||||||
const void* buffer, size_t *_length);
|
const void* buffer, size_t *_length);
|
||||||
|
|
||||||
|
status_t CreateDir(const char* name, int mode);
|
||||||
status_t OpenDir(OpenDirCookie* cookie);
|
status_t OpenDir(OpenDirCookie* cookie);
|
||||||
status_t ReadDir(void* buffer, uint32 size,
|
status_t ReadDir(void* buffer, uint32 size,
|
||||||
uint32* count, OpenDirCookie* cookie);
|
uint32* count, OpenDirCookie* cookie);
|
||||||
|
|||||||
@@ -87,23 +87,24 @@ RequestBuilder::Close(uint32 seq, const uint32* id, uint32 stateSeq)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
RequestBuilder::Create(FileType type, const char* name, const char* path,
|
RequestBuilder::Create(FileType type, const char* name, AttrValue* attr,
|
||||||
AttrValue* attr, uint32 count)
|
uint32 count, const char* path)
|
||||||
{
|
{
|
||||||
if (fProcedure != ProcCompound)
|
if (fProcedure != ProcCompound)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
if (fRequest == NULL)
|
if (fRequest == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
if (path == NULL)
|
if (type == NF4LNK && path == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
if (type != NF4LNK)
|
if (type == NF4BLK || type == NF4CHR)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
fRequest->Stream().AddUInt(OpCreate);
|
fRequest->Stream().AddUInt(OpCreate);
|
||||||
fRequest->Stream().AddUInt(type);
|
fRequest->Stream().AddUInt(type);
|
||||||
fRequest->Stream().AddString(path);
|
if (type == NF4LNK)
|
||||||
|
fRequest->Stream().AddString(path);
|
||||||
fRequest->Stream().AddString(name);
|
fRequest->Stream().AddString(name);
|
||||||
_EncodeAttrs(fRequest->Stream(), attr, count);
|
_EncodeAttrs(fRequest->Stream(), attr, count);
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ public:
|
|||||||
status_t Close(uint32 seq, const uint32* id,
|
status_t Close(uint32 seq, const uint32* id,
|
||||||
uint32 stateSeq);
|
uint32 stateSeq);
|
||||||
status_t Create(FileType type, const char* name,
|
status_t Create(FileType type, const char* name,
|
||||||
const char* path, AttrValue* attr,
|
AttrValue* attr, uint32 count,
|
||||||
uint32 count);
|
const char* path = NULL);
|
||||||
status_t GetAttr(Attribute* attrs, uint32 count);
|
status_t GetAttr(Attribute* attrs, uint32 count);
|
||||||
status_t GetFH();
|
status_t GetFH();
|
||||||
status_t Link(const char* name);
|
status_t Link(const char* name);
|
||||||
|
|||||||
@@ -376,6 +376,15 @@ nfs4_write(fs_volume* volume, fs_vnode* vnode, void* _cookie, off_t pos,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static status_t
|
||||||
|
nfs4_create_dir(fs_volume* volume, fs_vnode* parent, const char* name,
|
||||||
|
int mode)
|
||||||
|
{
|
||||||
|
Inode* inode = reinterpret_cast<Inode*>(parent->private_node);
|
||||||
|
return inode->CreateDir(name, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
nfs4_remove_dir(fs_volume* volume, fs_vnode* parent, const char* name)
|
nfs4_remove_dir(fs_volume* volume, fs_vnode* parent, const char* name)
|
||||||
{
|
{
|
||||||
@@ -526,7 +535,7 @@ fs_vnode_ops gNFSv4VnodeOps = {
|
|||||||
nfs4_write,
|
nfs4_write,
|
||||||
|
|
||||||
/* directory operations */
|
/* directory operations */
|
||||||
NULL, // create_dir()
|
nfs4_create_dir,
|
||||||
nfs4_remove_dir,
|
nfs4_remove_dir,
|
||||||
nfs4_open_dir,
|
nfs4_open_dir,
|
||||||
nfs4_close_dir,
|
nfs4_close_dir,
|
||||||
|
|||||||
Reference in New Issue
Block a user