mirror of
https://review.haiku-os.org/haiku
synced 2025-02-07 06:16:11 +01:00
nfs4: Add stub Filesystem class and Mount method
This commit is contained in:
parent
e552920f09
commit
45aa18ac4c
118
src/add-ons/kernel/file_systems/nfs4/Filesystem.cpp
Normal file
118
src/add-ons/kernel/file_systems/nfs4/Filesystem.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2012 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Paweł Dziepak, pdziepak@quarnos.org
|
||||
*/
|
||||
|
||||
|
||||
#include "Filesystem.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ReplyInterpreter.h"
|
||||
#include "RequestBuilder.h"
|
||||
|
||||
|
||||
Filesystem::Filesystem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Filesystem::~Filesystem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath)
|
||||
{
|
||||
RequestBuilder req(ProcCompound);
|
||||
req.PutRootFH();
|
||||
|
||||
// Better way of doing this will be needed
|
||||
uint32 lookupCount;
|
||||
char* path = strdup(fsPath);
|
||||
char* pathStart = path;
|
||||
char* pathEnd;
|
||||
while (pathStart != NULL) {
|
||||
pathEnd = strpbrk(pathStart, "/");
|
||||
if (pathEnd != NULL)
|
||||
*pathEnd = '\0';
|
||||
|
||||
req.LookUp(pathStart);
|
||||
|
||||
if (pathEnd != NULL && pathEnd[1] != '\0')
|
||||
pathStart = pathEnd + 1;
|
||||
else
|
||||
pathStart = NULL;
|
||||
|
||||
lookupCount++;
|
||||
}
|
||||
free(path);
|
||||
|
||||
req.GetFH();
|
||||
req.Access();
|
||||
Attribute attr[] = { FATTR4_FH_EXPIRE_TYPE };
|
||||
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
||||
|
||||
RPC::Reply *rpl;
|
||||
serv->SendCall(req.Request(), &rpl);
|
||||
ReplyInterpreter reply(rpl);
|
||||
|
||||
status_t result;
|
||||
|
||||
result = reply.PutRootFH();
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
for (uint32 i = 0; i < lookupCount; i++) {
|
||||
result = reply.LookUp();
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
}
|
||||
|
||||
Filehandle fh;
|
||||
result = reply.GetFH(&fh);
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
uint32 allowed;
|
||||
result = reply.Access(NULL, &allowed);
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
else if (allowed & (ACCESS4_READ | ACCESS4_LOOKUP)
|
||||
!= (ACCESS4_READ | ACCESS4_LOOKUP))
|
||||
return B_PERMISSION_DENIED;
|
||||
|
||||
AttrValue* values;
|
||||
uint32 count;
|
||||
result = reply.GetAttr(&values, &count);
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
if (count != 1 || values[0].fAttribute != FATTR4_FH_EXPIRE_TYPE) {
|
||||
delete values;
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
// Currently, only persistent filehandles are supported. That will be
|
||||
// changed soon.
|
||||
if (values[0].fData.fValue32 != FH4_PERSISTENT) {
|
||||
delete values;
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Filesystem* fs = new Filesystem;
|
||||
fs->fFHExpiryType = values[0].fData.fValue32;
|
||||
memcpy(&fs->fRootFH, &fh, sizeof(Filehandle));
|
||||
fs->fServer = serv;
|
||||
|
||||
delete values;
|
||||
|
||||
*pfs = fs;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
36
src/add-ons/kernel/file_systems/nfs4/Filesystem.h
Normal file
36
src/add-ons/kernel/file_systems/nfs4/Filesystem.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2012 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Paweł Dziepak, pdziepak@quarnos.org
|
||||
*/
|
||||
#ifndef FILESYSTEM_H
|
||||
#define FILESYSTEM_H
|
||||
|
||||
|
||||
#include "NFS4Defs.h"
|
||||
#include "RPCServer.h"
|
||||
|
||||
|
||||
class Filesystem {
|
||||
public:
|
||||
static status_t Mount(Filesystem** pfs, RPC::Server* serv,
|
||||
const char* path);
|
||||
~Filesystem();
|
||||
|
||||
inline uint32 FHExpiryType() const;
|
||||
|
||||
private:
|
||||
Filesystem();
|
||||
|
||||
uint32 fFHExpiryType;
|
||||
|
||||
Filehandle fRootFH;
|
||||
|
||||
RPC::Server* fServer;
|
||||
};
|
||||
|
||||
|
||||
#endif // FILESYSTEM_H
|
||||
|
@ -4,6 +4,7 @@ UsePrivateHeaders kernel ;
|
||||
|
||||
KernelAddon nfs4 :
|
||||
Connection.cpp
|
||||
Filesystem.cpp
|
||||
kernel_interface.cpp
|
||||
ReplyInterpreter.cpp
|
||||
RequestBuilder.cpp
|
||||
|
@ -9,6 +9,9 @@
|
||||
#define NFS4DEFS_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
#define NFS4_FHSIZE 128
|
||||
|
||||
struct Filehandle {
|
||||
|
Loading…
x
Reference in New Issue
Block a user