nfs4: Let FileSystem::Mount() use FileInfo::ParsePath()
This commit is contained in:
@@ -13,8 +13,10 @@
|
|||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
// TODO: This function probably needs more strict checking against incorrect
|
||||||
ParsePath(RequestBuilder& req, uint32& count, const char* _path)
|
// paths. Correct handling of '..' and '.' also may be useful.
|
||||||
|
status_t
|
||||||
|
FileInfo::ParsePath(RequestBuilder& req, uint32& count, const char* _path)
|
||||||
{
|
{
|
||||||
char* path = strdup(_path);
|
char* path = strdup(_path);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ struct Filehandle {
|
|||||||
|
|
||||||
|
|
||||||
class Filesystem;
|
class Filesystem;
|
||||||
|
class RequestBuilder;
|
||||||
|
|
||||||
// Complete information needed to identify a file in any situation.
|
// Complete information needed to identify a file in any situation.
|
||||||
// Unfortunately just a filehandle is not enough even when they are persistent
|
// Unfortunately just a filehandle is not enough even when they are persistent
|
||||||
@@ -46,6 +47,9 @@ struct FileInfo {
|
|||||||
inline FileInfo& operator=(const FileInfo& fi);
|
inline FileInfo& operator=(const FileInfo& fi);
|
||||||
|
|
||||||
status_t UpdateFileHandles(Filesystem* fs);
|
status_t UpdateFileHandles(Filesystem* fs);
|
||||||
|
|
||||||
|
static status_t ParsePath(RequestBuilder& req, uint32& count,
|
||||||
|
const char* _path);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FilesystemId {
|
struct FilesystemId {
|
||||||
|
|||||||
@@ -73,30 +73,10 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
|||||||
|
|
||||||
req.PutRootFH();
|
req.PutRootFH();
|
||||||
|
|
||||||
// Better way of doing this will be needed
|
|
||||||
uint32 lookupCount = 0;
|
uint32 lookupCount = 0;
|
||||||
char* path = strdup(fsPath);
|
status_t result = FileInfo::ParsePath(req, lookupCount, fsPath);
|
||||||
char* pathStart = path;
|
if (result != B_OK)
|
||||||
char* pathEnd;
|
return result;
|
||||||
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);
|
|
||||||
|
|
||||||
req.GetFH();
|
req.GetFH();
|
||||||
req.Access();
|
req.Access();
|
||||||
@@ -105,7 +85,7 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
|||||||
FATTR4_FSID, FATTR4_FS_LOCATIONS };
|
FATTR4_FSID, FATTR4_FS_LOCATIONS };
|
||||||
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
||||||
|
|
||||||
status_t result = request.Send();
|
result = request.Send();
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user