nfs4: Let FileSystem::Mount() use FileInfo::ParsePath()

This commit is contained in:
Pawel Dziepak
2012-07-04 16:58:45 +02:00
parent dd86fd8f4c
commit 209c46eec4
3 changed files with 12 additions and 26 deletions
@@ -13,8 +13,10 @@
#include "Request.h"
static status_t
ParsePath(RequestBuilder& req, uint32& count, const char* _path)
// TODO: This function probably needs more strict checking against incorrect
// paths. Correct handling of '..' and '.' also may be useful.
status_t
FileInfo::ParsePath(RequestBuilder& req, uint32& count, const char* _path)
{
char* path = strdup(_path);
if (path == NULL)
@@ -28,6 +28,7 @@ struct Filehandle {
class Filesystem;
class RequestBuilder;
// Complete information needed to identify a file in any situation.
// Unfortunately just a filehandle is not enough even when they are persistent
@@ -46,6 +47,9 @@ struct FileInfo {
inline FileInfo& operator=(const FileInfo& fi);
status_t UpdateFileHandles(Filesystem* fs);
static status_t ParsePath(RequestBuilder& req, uint32& count,
const char* _path);
};
struct FilesystemId {
@@ -73,30 +73,10 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
req.PutRootFH();
// Better way of doing this will be needed
uint32 lookupCount = 0;
char* path = strdup(fsPath);
char* pathStart = path;
char* pathEnd;
while (pathStart != NULL && pathStart[0] != '\0') {
pathEnd = strpbrk(pathStart, "/");
if (pathEnd != NULL)
*pathEnd = '\0';
if (pathEnd == pathStart) {
pathStart++;
continue;
}
req.LookUp(pathStart);
if (pathEnd != NULL && pathEnd[1] != '\0')
pathStart = pathEnd + 1;
else
pathStart = NULL;
lookupCount++;
}
free(path);
status_t result = FileInfo::ParsePath(req, lookupCount, fsPath);
if (result != B_OK)
return result;
req.GetFH();
req.Access();
@@ -105,7 +85,7 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
FATTR4_FSID, FATTR4_FS_LOCATIONS };
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
status_t result = request.Send();
result = request.Send();
if (result != B_OK)
return result;