nfs4: Rename Filehandle to FileHandle and Filesystem to FileSystem
This commit is contained in:
@@ -124,7 +124,7 @@ Cookie::CancelAll()
|
|||||||
MutexLocker _(fRequestLock);
|
MutexLocker _(fRequestLock);
|
||||||
RequestEntry* ent = fRequests;
|
RequestEntry* ent = fRequests;
|
||||||
while (ent != NULL) {
|
while (ent != NULL) {
|
||||||
fFilesystem->Server()->WakeCall(ent->fRequest);
|
fFileSystem->Server()->WakeCall(ent->fRequest);
|
||||||
ent = ent->fNext;
|
ent = ent->fNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ OpenFileCookie::DeleteLock(LockInfo* lock)
|
|||||||
status_t
|
status_t
|
||||||
OpenFileCookie::_ReleaseLockOwner(LockOwner* owner)
|
OpenFileCookie::_ReleaseLockOwner(LockOwner* owner)
|
||||||
{
|
{
|
||||||
Request request(fFilesystem->Server());
|
Request request(fFileSystem->Server());
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
req.ReleaseLockOwner(this, owner);
|
req.ReleaseLockOwner(this, owner);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include "Filesystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
|
|
||||||
struct LockOwner {
|
struct LockOwner {
|
||||||
@@ -55,7 +55,7 @@ struct Cookie {
|
|||||||
RequestEntry* fNext;
|
RequestEntry* fNext;
|
||||||
};
|
};
|
||||||
|
|
||||||
Filesystem* fFilesystem;
|
FileSystem* fFileSystem;
|
||||||
RequestEntry* fRequests;
|
RequestEntry* fRequests;
|
||||||
mutex fRequestLock;
|
mutex fRequestLock;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "FileInfo.h"
|
#include "FileInfo.h"
|
||||||
|
|
||||||
#include "Filesystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ FileInfo::ParsePath(RequestBuilder& req, uint32& count, const char* _path)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
FileInfo::UpdateFileHandles(Filesystem* fs)
|
FileInfo::UpdateFileHandles(FileSystem* fs)
|
||||||
{
|
{
|
||||||
Request request(fs->Server());
|
Request request(fs->Server());
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|||||||
@@ -17,27 +17,27 @@
|
|||||||
|
|
||||||
#define NFS4_FHSIZE 128
|
#define NFS4_FHSIZE 128
|
||||||
|
|
||||||
struct Filehandle {
|
struct FileHandle {
|
||||||
uint8 fSize;
|
uint8 fSize;
|
||||||
uint8 fFH[NFS4_FHSIZE];
|
uint8 fData[NFS4_FHSIZE];
|
||||||
|
|
||||||
inline Filehandle();
|
inline FileHandle();
|
||||||
inline Filehandle(const Filehandle& fh);
|
inline FileHandle(const FileHandle& fh);
|
||||||
inline Filehandle& operator=(const Filehandle& fh);
|
inline FileHandle& operator=(const FileHandle& fh);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Filesystem;
|
class FileSystem;
|
||||||
class RequestBuilder;
|
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
|
||||||
// since OPEN requires both parent filehandle and file name (just like LOOKUP).
|
// since OPEN requires both parent FileHandle and file name (just like LOOKUP).
|
||||||
struct FileInfo {
|
struct FileInfo {
|
||||||
uint64 fFileId;
|
uint64 fFileId;
|
||||||
Filehandle fHandle;
|
FileHandle fHandle;
|
||||||
|
|
||||||
Filehandle fParent;
|
FileHandle fParent;
|
||||||
const char* fName;
|
const char* fName;
|
||||||
const char* fPath;
|
const char* fPath;
|
||||||
|
|
||||||
@@ -46,23 +46,23 @@ struct FileInfo {
|
|||||||
inline FileInfo(const FileInfo& fi);
|
inline FileInfo(const FileInfo& fi);
|
||||||
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,
|
static status_t ParsePath(RequestBuilder& req, uint32& count,
|
||||||
const char* _path);
|
const char* _path);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FilesystemId {
|
struct FileSystemId {
|
||||||
uint64 fMajor;
|
uint64 fMajor;
|
||||||
uint64 fMinor;
|
uint64 fMinor;
|
||||||
|
|
||||||
inline bool operator==(const FilesystemId& fsid) const;
|
inline bool operator==(const FileSystemId& fsid) const;
|
||||||
inline bool operator!=(const FilesystemId& fsid) const;
|
inline bool operator!=(const FileSystemId& fsid) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
Filehandle::Filehandle()
|
FileHandle::FileHandle()
|
||||||
:
|
:
|
||||||
fSize(0)
|
fSize(0)
|
||||||
{
|
{
|
||||||
@@ -70,19 +70,19 @@ Filehandle::Filehandle()
|
|||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
Filehandle::Filehandle(const Filehandle& fh)
|
FileHandle::FileHandle(const FileHandle& fh)
|
||||||
:
|
:
|
||||||
fSize(fh.fSize)
|
fSize(fh.fSize)
|
||||||
{
|
{
|
||||||
memcpy(fFH, fh.fFH, fSize);
|
memcpy(fData, fh.fData, fSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Filehandle&
|
inline FileHandle&
|
||||||
Filehandle::operator=(const Filehandle& fh)
|
FileHandle::operator=(const FileHandle& fh)
|
||||||
{
|
{
|
||||||
fSize = fh.fSize;
|
fSize = fh.fSize;
|
||||||
memcpy(fFH, fh.fFH, fSize);
|
memcpy(fData, fh.fData, fSize);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,14 +135,14 @@ FileInfo::operator=(const FileInfo& fi)
|
|||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
FilesystemId::operator==(const FilesystemId& fsid) const
|
FileSystemId::operator==(const FileSystemId& fsid) const
|
||||||
{
|
{
|
||||||
return fMajor == fsid.fMajor && fMinor == fsid.fMinor;
|
return fMajor == fsid.fMajor && fMinor == fsid.fMinor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
FilesystemId::operator!=(const FilesystemId& fsid) const
|
FileSystemId::operator!=(const FileSystemId& fsid) const
|
||||||
{
|
{
|
||||||
return !operator==(fsid);
|
return !operator==(fsid);
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-18
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Filesystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ extern RPC::ServerManager* gRPCServerManager;
|
|||||||
extern RPC::ProgramData* CreateNFS4Server(RPC::Server* serv);
|
extern RPC::ProgramData* CreateNFS4Server(RPC::Server* serv);
|
||||||
|
|
||||||
|
|
||||||
Filesystem::Filesystem()
|
FileSystem::FileSystem()
|
||||||
:
|
:
|
||||||
fNext(NULL),
|
fNext(NULL),
|
||||||
fPrev(NULL),
|
fPrev(NULL),
|
||||||
@@ -35,9 +35,9 @@ Filesystem::Filesystem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Filesystem::~Filesystem()
|
FileSystem::~FileSystem()
|
||||||
{
|
{
|
||||||
NFSServer()->RemoveFilesystem(this);
|
NFSServer()->RemoveFileSystem(this);
|
||||||
|
|
||||||
mutex_destroy(&fOpenLock);
|
mutex_destroy(&fOpenLock);
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ sGetPath(const char* root, const char* path)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
FileSystem::Mount(FileSystem** pfs, RPC::Server* serv, const char* fsPath,
|
||||||
dev_t id)
|
dev_t id)
|
||||||
{
|
{
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
@@ -94,7 +94,7 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
|||||||
for (uint32 i = 0; i < lookupCount; i++)
|
for (uint32 i = 0; i < lookupCount; i++)
|
||||||
reply.LookUp();
|
reply.LookUp();
|
||||||
|
|
||||||
Filehandle fh;
|
FileHandle fh;
|
||||||
reply.GetFH(&fh);
|
reply.GetFH(&fh);
|
||||||
|
|
||||||
uint32 allowed;
|
uint32 allowed;
|
||||||
@@ -111,7 +111,7 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
|||||||
if (result != B_OK || count < 2)
|
if (result != B_OK || count < 2)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Filesystem* fs = new(std::nothrow) Filesystem;
|
FileSystem* fs = new(std::nothrow) FileSystem;
|
||||||
if (fs == NULL)
|
if (fs == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
@@ -122,8 +122,8 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
|||||||
fs->fExpireType = values[1].fData.fValue32;
|
fs->fExpireType = values[1].fData.fValue32;
|
||||||
|
|
||||||
// FATTR4_FSID is mandatory
|
// FATTR4_FSID is mandatory
|
||||||
FilesystemId* fsid =
|
FileSystemId* fsid =
|
||||||
reinterpret_cast<FilesystemId*>(values[2].fData.fPointer);
|
reinterpret_cast<FileSystemId*>(values[2].fData.fPointer);
|
||||||
|
|
||||||
if (count == 4 && values[3].fAttribute == FATTR4_FS_LOCATIONS) {
|
if (count == 4 && values[3].fAttribute == FATTR4_FS_LOCATIONS) {
|
||||||
FSLocations* locs =
|
FSLocations* locs =
|
||||||
@@ -168,7 +168,7 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
|||||||
|
|
||||||
fs->fRoot = reinterpret_cast<RootInode*>(inode);
|
fs->fRoot = reinterpret_cast<RootInode*>(inode);
|
||||||
|
|
||||||
fs->NFSServer()->AddFilesystem(fs);
|
fs->NFSServer()->AddFileSystem(fs);
|
||||||
*pfs = fs;
|
*pfs = fs;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -176,7 +176,7 @@ Filesystem::Mount(Filesystem** pfs, RPC::Server* serv, const char* fsPath,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Filesystem::GetInode(ino_t id, Inode** _inode)
|
FileSystem::GetInode(ino_t id, Inode** _inode)
|
||||||
{
|
{
|
||||||
FileInfo fi;
|
FileInfo fi;
|
||||||
status_t result = fInoIdMap.GetFileInfo(&fi, id);
|
status_t result = fInoIdMap.GetFileInfo(&fi, id);
|
||||||
@@ -197,7 +197,7 @@ Filesystem::GetInode(ino_t id, Inode** _inode)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Filesystem::Migrate(const RPC::Server* serv)
|
FileSystem::Migrate(const RPC::Server* serv)
|
||||||
{
|
{
|
||||||
MutexLocker _(fOpenLock);
|
MutexLocker _(fOpenLock);
|
||||||
if (serv != fServer)
|
if (serv != fServer)
|
||||||
@@ -250,8 +250,8 @@ Filesystem::Migrate(const RPC::Server* serv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NFS4Server* old = reinterpret_cast<NFS4Server*>(server->PrivateData());
|
NFS4Server* old = reinterpret_cast<NFS4Server*>(server->PrivateData());
|
||||||
old->RemoveFilesystem(this);
|
old->RemoveFileSystem(this);
|
||||||
NFSServer()->AddFilesystem(this);
|
NFSServer()->AddFileSystem(this);
|
||||||
|
|
||||||
gRPCServerManager->Release(server);
|
gRPCServerManager->Release(server);
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ Filesystem::Migrate(const RPC::Server* serv)
|
|||||||
|
|
||||||
|
|
||||||
OpenFileCookie*
|
OpenFileCookie*
|
||||||
Filesystem::OpenFilesLock()
|
FileSystem::OpenFilesLock()
|
||||||
{
|
{
|
||||||
mutex_lock(&fOpenLock);
|
mutex_lock(&fOpenLock);
|
||||||
return fOpenFiles;
|
return fOpenFiles;
|
||||||
@@ -268,14 +268,14 @@ Filesystem::OpenFilesLock()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filesystem::OpenFilesUnlock()
|
FileSystem::OpenFilesUnlock()
|
||||||
{
|
{
|
||||||
mutex_unlock(&fOpenLock);
|
mutex_unlock(&fOpenLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filesystem::AddOpenFile(OpenFileCookie* cookie)
|
FileSystem::AddOpenFile(OpenFileCookie* cookie)
|
||||||
{
|
{
|
||||||
MutexLocker _(fOpenLock);
|
MutexLocker _(fOpenLock);
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ Filesystem::AddOpenFile(OpenFileCookie* cookie)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filesystem::RemoveOpenFile(OpenFileCookie* cookie)
|
FileSystem::RemoveOpenFile(OpenFileCookie* cookie)
|
||||||
{
|
{
|
||||||
MutexLocker _(fOpenLock);
|
MutexLocker _(fOpenLock);
|
||||||
if (cookie == fOpenFiles)
|
if (cookie == fOpenFiles)
|
||||||
+20
-20
@@ -17,11 +17,11 @@
|
|||||||
class Inode;
|
class Inode;
|
||||||
class RootInode;
|
class RootInode;
|
||||||
|
|
||||||
class Filesystem {
|
class FileSystem {
|
||||||
public:
|
public:
|
||||||
static status_t Mount(Filesystem** pfs, RPC::Server* serv,
|
static status_t Mount(FileSystem** pfs, RPC::Server* serv,
|
||||||
const char* path, dev_t id);
|
const char* path, dev_t id);
|
||||||
~Filesystem();
|
~FileSystem();
|
||||||
|
|
||||||
status_t GetInode(ino_t id, Inode** inode);
|
status_t GetInode(ino_t id, Inode** inode);
|
||||||
inline Inode* Root();
|
inline Inode* Root();
|
||||||
@@ -41,17 +41,17 @@ public:
|
|||||||
inline NFS4Server* NFSServer();
|
inline NFS4Server* NFSServer();
|
||||||
|
|
||||||
inline const char* Path() const;
|
inline const char* Path() const;
|
||||||
inline const FilesystemId& FsId() const;
|
inline const FileSystemId& FsId() const;
|
||||||
|
|
||||||
inline uint64 AllocFileId();
|
inline uint64 AllocFileId();
|
||||||
|
|
||||||
inline dev_t DevId() const;
|
inline dev_t DevId() const;
|
||||||
inline InodeIdMap* InoIdMap();
|
inline InodeIdMap* InoIdMap();
|
||||||
|
|
||||||
Filesystem* fNext;
|
FileSystem* fNext;
|
||||||
Filesystem* fPrev;
|
FileSystem* fPrev;
|
||||||
private:
|
private:
|
||||||
Filesystem();
|
FileSystem();
|
||||||
|
|
||||||
OpenFileCookie* fOpenFiles;
|
OpenFileCookie* fOpenFiles;
|
||||||
uint32 fOpenCount;
|
uint32 fOpenCount;
|
||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
uint32 fExpireType;
|
uint32 fExpireType;
|
||||||
uint32 fSupAttrs[2];
|
uint32 fSupAttrs[2];
|
||||||
|
|
||||||
FilesystemId fFsId;
|
FileSystemId fFsId;
|
||||||
const char* fPath;
|
const char* fPath;
|
||||||
|
|
||||||
RootInode* fRoot;
|
RootInode* fRoot;
|
||||||
@@ -75,77 +75,77 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
inline Inode*
|
inline Inode*
|
||||||
Filesystem::Root()
|
FileSystem::Root()
|
||||||
{
|
{
|
||||||
return reinterpret_cast<Inode*>(fRoot);
|
return reinterpret_cast<Inode*>(fRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint32
|
inline uint32
|
||||||
Filesystem::OpenFilesCount()
|
FileSystem::OpenFilesCount()
|
||||||
{
|
{
|
||||||
return fOpenCount;
|
return fOpenCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Filesystem::IsAttrSupported(Attribute attr) const
|
FileSystem::IsAttrSupported(Attribute attr) const
|
||||||
{
|
{
|
||||||
return sIsAttrSet(attr, fSupAttrs, 2);
|
return sIsAttrSet(attr, fSupAttrs, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint32
|
inline uint32
|
||||||
Filesystem::ExpireType() const
|
FileSystem::ExpireType() const
|
||||||
{
|
{
|
||||||
return fExpireType;
|
return fExpireType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline RPC::Server*
|
inline RPC::Server*
|
||||||
Filesystem::Server()
|
FileSystem::Server()
|
||||||
{
|
{
|
||||||
return fServer;
|
return fServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline NFS4Server*
|
inline NFS4Server*
|
||||||
Filesystem::NFSServer()
|
FileSystem::NFSServer()
|
||||||
{
|
{
|
||||||
return reinterpret_cast<NFS4Server*>(fServer->PrivateData());
|
return reinterpret_cast<NFS4Server*>(fServer->PrivateData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const char*
|
inline const char*
|
||||||
Filesystem::Path() const
|
FileSystem::Path() const
|
||||||
{
|
{
|
||||||
return fPath;
|
return fPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const FilesystemId&
|
inline const FileSystemId&
|
||||||
Filesystem::FsId() const
|
FileSystem::FsId() const
|
||||||
{
|
{
|
||||||
return fFsId;
|
return fFsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint64
|
inline uint64
|
||||||
Filesystem::AllocFileId()
|
FileSystem::AllocFileId()
|
||||||
{
|
{
|
||||||
return atomic_add64(&fId, 1);
|
return atomic_add64(&fId, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline dev_t
|
inline dev_t
|
||||||
Filesystem::DevId() const
|
FileSystem::DevId() const
|
||||||
{
|
{
|
||||||
return fDevId;
|
return fDevId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline InodeIdMap*
|
inline InodeIdMap*
|
||||||
Filesystem::InoIdMap()
|
FileSystem::InoIdMap()
|
||||||
{
|
{
|
||||||
return &fInoIdMap;
|
return &fInoIdMap;
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ Inode::Inode()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Inode::CreateInode(Filesystem* fs, const FileInfo &fi, Inode** _inode)
|
Inode::CreateInode(FileSystem* fs, const FileInfo &fi, Inode** _inode)
|
||||||
{
|
{
|
||||||
Inode* inode = NULL;
|
Inode* inode = NULL;
|
||||||
if (fs->Root() == NULL)
|
if (fs->Root() == NULL)
|
||||||
@@ -37,7 +37,7 @@ Inode::CreateInode(Filesystem* fs, const FileInfo &fi, Inode** _inode)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
inode->fInfo = fi;
|
inode->fInfo = fi;
|
||||||
inode->fFilesystem = fs;
|
inode->fFileSystem = fs;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fs->Server();
|
RPC::Server* serv = fs->Server();
|
||||||
@@ -78,8 +78,8 @@ Inode::CreateInode(Filesystem* fs, const FileInfo &fi, Inode** _inode)
|
|||||||
inode->fType = values[0].fData.fValue32;
|
inode->fType = values[0].fData.fValue32;
|
||||||
|
|
||||||
// FATTR4_FSID is mandatory
|
// FATTR4_FSID is mandatory
|
||||||
FilesystemId* fsid =
|
FileSystemId* fsid =
|
||||||
reinterpret_cast<FilesystemId*>(values[1].fData.fPointer);
|
reinterpret_cast<FileSystemId*>(values[1].fData.fPointer);
|
||||||
if (*fsid != fs->FsId()) {
|
if (*fsid != fs->FsId()) {
|
||||||
delete[] values;
|
delete[] values;
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
@@ -111,7 +111,7 @@ Inode::LookUp(const char* name, ino_t* id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ Inode::LookUp(const char* name, ino_t* id)
|
|||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Filehandle fh;
|
FileHandle fh;
|
||||||
reply.GetFH(&fh);
|
reply.GetFH(&fh);
|
||||||
|
|
||||||
AttrValue* values;
|
AttrValue* values;
|
||||||
@@ -154,16 +154,16 @@ Inode::LookUp(const char* name, ino_t* id)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
// FATTR4_FSID is mandatory
|
// FATTR4_FSID is mandatory
|
||||||
FilesystemId* fsid =
|
FileSystemId* fsid =
|
||||||
reinterpret_cast<FilesystemId*>(values[0].fData.fPointer);
|
reinterpret_cast<FileSystemId*>(values[0].fData.fPointer);
|
||||||
if (*fsid != fFilesystem->FsId()) {
|
if (*fsid != fFileSystem->FsId()) {
|
||||||
delete[] values;
|
delete[] values;
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 fileId;
|
uint64 fileId;
|
||||||
if (count < 2 || values[1].fAttribute != FATTR4_FILEID)
|
if (count < 2 || values[1].fAttribute != FATTR4_FILEID)
|
||||||
fileId = fFilesystem->AllocFileId();
|
fileId = fFileSystem->AllocFileId();
|
||||||
else
|
else
|
||||||
fileId = values[1].fData.fValue64;
|
fileId = values[1].fData.fValue64;
|
||||||
delete[] values;
|
delete[] values;
|
||||||
@@ -188,7 +188,7 @@ Inode::LookUp(const char* name, ino_t* id)
|
|||||||
strcat(path, name);
|
strcat(path, name);
|
||||||
fi.fPath = path;
|
fi.fPath = path;
|
||||||
|
|
||||||
fFilesystem->InoIdMap()->AddEntry(fi, *id);
|
fFileSystem->InoIdMap()->AddEntry(fi, *id);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -199,7 +199,7 @@ status_t
|
|||||||
Inode::Link(Inode* dir, const char* name)
|
Inode::Link(Inode* dir, const char* name)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -214,16 +214,16 @@ Inode::Link(Inode* dir, const char* name)
|
|||||||
|
|
||||||
ReplyInterpreter& reply = request.Reply();
|
ReplyInterpreter& reply = request.Reply();
|
||||||
|
|
||||||
// filehandle has expired
|
// FileHandle has expired
|
||||||
if (reply.NFS4Error() == NFS4ERR_FHEXPIRED) {
|
if (reply.NFS4Error() == NFS4ERR_FHEXPIRED) {
|
||||||
fInfo.UpdateFileHandles(fFilesystem);
|
fInfo.UpdateFileHandles(fFileSystem);
|
||||||
dir->fInfo.UpdateFileHandles(dir->fFilesystem);
|
dir->fInfo.UpdateFileHandles(dir->fFileSystem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// filesystem has been moved
|
// filesystem has been moved
|
||||||
if (reply.NFS4Error() == NFS4ERR_MOVED) {
|
if (reply.NFS4Error() == NFS4ERR_MOVED) {
|
||||||
fFilesystem->Migrate(serv);
|
fFileSystem->Migrate(serv);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,13 +237,13 @@ Inode::Link(Inode* dir, const char* name)
|
|||||||
|
|
||||||
|
|
||||||
// May cause problem similar to Rename (described below). When node's is has
|
// May cause problem similar to Rename (described below). When node's is has
|
||||||
// more than one hard link and we delete the name it stores for filehandle
|
// more than one hard link and we delete the name it stores for FileHandle
|
||||||
// restoration node will inocorectly become unavailable.
|
// restoration node will inocorectly become unavailable.
|
||||||
status_t
|
status_t
|
||||||
Inode::Remove(const char* name, FileType type)
|
Inode::Remove(const char* name, FileType type)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -293,18 +293,18 @@ Inode::Remove(const char* name, FileType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Rename may cause some problems if filehandles are volatile and local Inode
|
// Rename may cause some problems if FileHandles are volatile and local Inode
|
||||||
// object exists for renamed node. It's stored filename will become invalid
|
// object exists for renamed node. It's stored filename will become invalid
|
||||||
// and, consequnetly, filehandle restoration will fail. Probably, it will
|
// and, consequnetly, FileHandle restoration will fail. Probably, it will
|
||||||
// be much easier to solve this problem if more metadata is cached.
|
// be much easier to solve this problem if more metadata is cached.
|
||||||
status_t
|
status_t
|
||||||
Inode::Rename(Inode* from, Inode* to, const char* fromName, const char* toName)
|
Inode::Rename(Inode* from, Inode* to, const char* fromName, const char* toName)
|
||||||
{
|
{
|
||||||
if (from->fFilesystem != to->fFilesystem)
|
if (from->fFileSystem != to->fFileSystem)
|
||||||
return B_DONT_DO_THAT;
|
return B_DONT_DO_THAT;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = from->fFilesystem->Server();
|
RPC::Server* serv = from->fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -319,16 +319,16 @@ Inode::Rename(Inode* from, Inode* to, const char* fromName, const char* toName)
|
|||||||
|
|
||||||
ReplyInterpreter& reply = request.Reply();
|
ReplyInterpreter& reply = request.Reply();
|
||||||
|
|
||||||
// filehandle has expired
|
// FileHandle has expired
|
||||||
if (reply.NFS4Error() == NFS4ERR_FHEXPIRED) {
|
if (reply.NFS4Error() == NFS4ERR_FHEXPIRED) {
|
||||||
from->fInfo.UpdateFileHandles(from->fFilesystem);
|
from->fInfo.UpdateFileHandles(from->fFileSystem);
|
||||||
to->fInfo.UpdateFileHandles(to->fFilesystem);
|
to->fInfo.UpdateFileHandles(to->fFileSystem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// filesystem has been moved
|
// filesystem has been moved
|
||||||
if (reply.NFS4Error() == NFS4ERR_MOVED) {
|
if (reply.NFS4Error() == NFS4ERR_MOVED) {
|
||||||
from->fFilesystem->Migrate(serv);
|
from->fFileSystem->Migrate(serv);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ Inode::CreateLink(const char* name, const char* path, int mode)
|
|||||||
bool badOwner = false;
|
bool badOwner = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -360,14 +360,14 @@ Inode::CreateLink(const char* name, const char* path, int mode)
|
|||||||
cattr[i].fData.fValue32 = mode;
|
cattr[i].fData.fValue32 = mode;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER)) {
|
if (!badOwner && fFileSystem->IsAttrSupported(FATTR4_OWNER)) {
|
||||||
cattr[i].fAttribute = FATTR4_OWNER;
|
cattr[i].fAttribute = FATTR4_OWNER;
|
||||||
cattr[i].fFreePointer = true;
|
cattr[i].fFreePointer = true;
|
||||||
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
|
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
|
if (!badOwner && fFileSystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
|
||||||
cattr[i].fAttribute = FATTR4_OWNER_GROUP;
|
cattr[i].fAttribute = FATTR4_OWNER_GROUP;
|
||||||
cattr[i].fFreePointer = true;
|
cattr[i].fFreePointer = true;
|
||||||
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
|
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
|
||||||
@@ -403,7 +403,7 @@ Inode::ReadLink(void* buffer, size_t* length)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ status_t
|
|||||||
Inode::Access(int mode)
|
Inode::Access(int mode)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ status_t
|
|||||||
Inode::Stat(struct stat* st)
|
Inode::Stat(struct stat* st)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -671,7 +671,7 @@ Inode::WriteStat(const struct stat* st, uint32 mask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -742,7 +742,7 @@ Inode::TestLock(OpenFileCookie* cookie, struct flock* lock)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -812,7 +812,7 @@ Inode::AcquireLock(OpenFileCookie* cookie, const struct flock* lock,
|
|||||||
do {
|
do {
|
||||||
MutexLocker ownerLocker(linfo->fOwner->fLock);
|
MutexLocker ownerLocker(linfo->fOwner->fLock);
|
||||||
|
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -881,7 +881,7 @@ Inode::ReleaseLock(OpenFileCookie* cookie, const struct flock* lock)
|
|||||||
do {
|
do {
|
||||||
MutexLocker ownerLocker(linfo->fOwner->fLock);
|
MutexLocker ownerLocker(linfo->fOwner->fLock);
|
||||||
|
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -926,7 +926,7 @@ Inode::ReleaseAllLocks(OpenFileCookie* cookie)
|
|||||||
do {
|
do {
|
||||||
MutexLocker ownerLocker(linfo->fOwner->fLock);
|
MutexLocker ownerLocker(linfo->fOwner->fLock);
|
||||||
|
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -989,7 +989,7 @@ Inode::_HandleErrors(uint32 nfs4Error, RPC::Server* serv,
|
|||||||
|
|
||||||
// server is in grace period, we need to wait
|
// server is in grace period, we need to wait
|
||||||
case NFS4ERR_GRACE:
|
case NFS4ERR_GRACE:
|
||||||
leaseTime = fFilesystem->NFSServer()->LeaseTime();
|
leaseTime = fFileSystem->NFSServer()->LeaseTime();
|
||||||
if (cookie == NULL) {
|
if (cookie == NULL) {
|
||||||
snooze_etc(sSecToBigTime(leaseTime) / 3, B_SYSTEM_TIMEBASE,
|
snooze_etc(sSecToBigTime(leaseTime) / 3, B_SYSTEM_TIMEBASE,
|
||||||
B_RELATIVE_TIMEOUT);
|
B_RELATIVE_TIMEOUT);
|
||||||
@@ -1008,25 +1008,25 @@ Inode::_HandleErrors(uint32 nfs4Error, RPC::Server* serv,
|
|||||||
// server has rebooted, reclaim share and try again
|
// server has rebooted, reclaim share and try again
|
||||||
case NFS4ERR_STALE_CLIENTID:
|
case NFS4ERR_STALE_CLIENTID:
|
||||||
case NFS4ERR_STALE_STATEID:
|
case NFS4ERR_STALE_STATEID:
|
||||||
fFilesystem->NFSServer()->ServerRebooted(cookie->fClientId);
|
fFileSystem->NFSServer()->ServerRebooted(cookie->fClientId);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// filehandle has expired
|
// FileHandle has expired
|
||||||
case NFS4ERR_FHEXPIRED:
|
case NFS4ERR_FHEXPIRED:
|
||||||
if (fInfo.UpdateFileHandles(fFilesystem) == B_OK)
|
if (fInfo.UpdateFileHandles(fFileSystem) == B_OK)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// filesystem has been moved
|
// filesystem has been moved
|
||||||
case NFS4ERR_LEASE_MOVED:
|
case NFS4ERR_LEASE_MOVED:
|
||||||
case NFS4ERR_MOVED:
|
case NFS4ERR_MOVED:
|
||||||
fFilesystem->Migrate(serv);
|
fFileSystem->Migrate(serv);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// lease has expired
|
// lease has expired
|
||||||
case NFS4ERR_EXPIRED:
|
case NFS4ERR_EXPIRED:
|
||||||
if (cookie != NULL) {
|
if (cookie != NULL) {
|
||||||
fFilesystem->NFSServer()->ClientId(cookie->fClientId, true);
|
fFileSystem->NFSServer()->ClientId(cookie->fClientId, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -14,21 +14,21 @@
|
|||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include "Cookie.h"
|
#include "Cookie.h"
|
||||||
#include "Filesystem.h"
|
#include "FileSystem.h"
|
||||||
#include "NFS4Defs.h"
|
#include "NFS4Defs.h"
|
||||||
#include "ReplyInterpreter.h"
|
#include "ReplyInterpreter.h"
|
||||||
|
|
||||||
|
|
||||||
class Inode {
|
class Inode {
|
||||||
public:
|
public:
|
||||||
static status_t CreateInode(Filesystem* fs, const FileInfo& fi,
|
static status_t CreateInode(FileSystem* fs, const FileInfo& fi,
|
||||||
Inode** inode);
|
Inode** inode);
|
||||||
~Inode();
|
~Inode();
|
||||||
|
|
||||||
inline ino_t ID() const;
|
inline ino_t ID() const;
|
||||||
inline mode_t Type() const;
|
inline mode_t Type() const;
|
||||||
inline const char* Name() const;
|
inline const char* Name() const;
|
||||||
inline Filesystem* FileSystem() const;
|
inline FileSystem* GetFileSystem() const;
|
||||||
|
|
||||||
status_t LookUp(const char* name, ino_t* id);
|
status_t LookUp(const char* name, ino_t* id);
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ protected:
|
|||||||
RPC::Server* serv,
|
RPC::Server* serv,
|
||||||
OpenFileCookie* cookie = NULL);
|
OpenFileCookie* cookie = NULL);
|
||||||
|
|
||||||
status_t _ConfirmOpen(const Filehandle& fh,
|
status_t _ConfirmOpen(const FileHandle& fh,
|
||||||
OpenFileCookie* cookie);
|
OpenFileCookie* cookie);
|
||||||
|
|
||||||
status_t _ReadDirOnce(DirEntry** dirents, uint32* count,
|
status_t _ReadDirOnce(DirEntry** dirents, uint32* count,
|
||||||
@@ -92,7 +92,7 @@ protected:
|
|||||||
uint32 fType;
|
uint32 fType;
|
||||||
|
|
||||||
FileInfo fInfo;
|
FileInfo fInfo;
|
||||||
Filesystem* fFilesystem;
|
FileSystem* fFileSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -128,10 +128,10 @@ Inode::Name() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Filesystem*
|
inline FileSystem*
|
||||||
Inode::FileSystem() const
|
Inode::GetFileSystem() const
|
||||||
{
|
{
|
||||||
return fFilesystem;
|
return fFileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Inode::CreateDir(const char* name, int mode)
|
|||||||
bool badOwner = false;
|
bool badOwner = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -36,14 +36,14 @@ Inode::CreateDir(const char* name, int mode)
|
|||||||
cattr[i].fData.fValue32 = mode;
|
cattr[i].fData.fValue32 = mode;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER)) {
|
if (!badOwner && fFileSystem->IsAttrSupported(FATTR4_OWNER)) {
|
||||||
cattr[i].fAttribute = FATTR4_OWNER;
|
cattr[i].fAttribute = FATTR4_OWNER;
|
||||||
cattr[i].fFreePointer = true;
|
cattr[i].fFreePointer = true;
|
||||||
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
|
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
|
if (!badOwner && fFileSystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
|
||||||
cattr[i].fAttribute = FATTR4_OWNER_GROUP;
|
cattr[i].fAttribute = FATTR4_OWNER_GROUP;
|
||||||
cattr[i].fFreePointer = true;
|
cattr[i].fFreePointer = true;
|
||||||
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
|
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
|
||||||
@@ -79,7 +79,7 @@ Inode::OpenDir(OpenDirCookie* cookie)
|
|||||||
return B_NOT_A_DIRECTORY;
|
return B_NOT_A_DIRECTORY;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ Inode::OpenDir(OpenDirCookie* cookie)
|
|||||||
if (allowed & ACCESS4_READ != ACCESS4_READ)
|
if (allowed & ACCESS4_READ != ACCESS4_READ)
|
||||||
return B_PERMISSION_DENIED;
|
return B_PERMISSION_DENIED;
|
||||||
|
|
||||||
cookie->fFilesystem = fFilesystem;
|
cookie->fFileSystem = fFileSystem;
|
||||||
cookie->fCookie = 0;
|
cookie->fCookie = 0;
|
||||||
cookie->fCookieVerf = 2;
|
cookie->fCookieVerf = 2;
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ Inode::_ReadDirOnce(DirEntry** dirents, uint32* count, OpenDirCookie* cookie,
|
|||||||
bool* eof)
|
bool* eof)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ Inode::_FillDirEntry(struct dirent* de, ino_t id, const char* name, uint32 pos,
|
|||||||
if (pos + entSize + nameSize > size)
|
if (pos + entSize + nameSize > size)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
de->d_dev = fFilesystem->DevId();
|
de->d_dev = fFileSystem->DevId();
|
||||||
de->d_ino = id;
|
de->d_ino = id;
|
||||||
de->d_reclen = entSize + nameSize;
|
de->d_reclen = entSize + nameSize;
|
||||||
if (de->d_reclen % 8 != 0)
|
if (de->d_reclen % 8 != 0)
|
||||||
@@ -171,7 +171,7 @@ status_t
|
|||||||
Inode::_ReadDirUp(struct dirent* de, uint32 pos, uint32 size)
|
Inode::_ReadDirUp(struct dirent* de, uint32 pos, uint32 size)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ Inode::_ReadDirUp(struct dirent* de, uint32 pos, uint32 size)
|
|||||||
req.LookUpUp();
|
req.LookUpUp();
|
||||||
req.GetFH();
|
req.GetFH();
|
||||||
|
|
||||||
if (fFilesystem->IsAttrSupported(FATTR4_FILEID)) {
|
if (fFileSystem->IsAttrSupported(FATTR4_FILEID)) {
|
||||||
Attribute attr[] = { FATTR4_FILEID };
|
Attribute attr[] = { FATTR4_FILEID };
|
||||||
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
||||||
}
|
}
|
||||||
@@ -198,11 +198,11 @@ Inode::_ReadDirUp(struct dirent* de, uint32 pos, uint32 size)
|
|||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Filehandle fh;
|
FileHandle fh;
|
||||||
reply.GetFH(&fh);
|
reply.GetFH(&fh);
|
||||||
|
|
||||||
uint64 fileId;
|
uint64 fileId;
|
||||||
if (fFilesystem->IsAttrSupported(FATTR4_FILEID)) {
|
if (fFileSystem->IsAttrSupported(FATTR4_FILEID)) {
|
||||||
AttrValue* values;
|
AttrValue* values;
|
||||||
uint32 count;
|
uint32 count;
|
||||||
reply.GetAttr(&values, &count);
|
reply.GetAttr(&values, &count);
|
||||||
@@ -212,7 +212,7 @@ Inode::_ReadDirUp(struct dirent* de, uint32 pos, uint32 size)
|
|||||||
fileId = values[0].fData.fValue64;
|
fileId = values[0].fData.fValue64;
|
||||||
delete[] values;
|
delete[] values;
|
||||||
} else
|
} else
|
||||||
fileId = fFilesystem->AllocFileId();
|
fileId = fFileSystem->AllocFileId();
|
||||||
|
|
||||||
return _FillDirEntry(de, _FileIdToInoT(fileId), "..", pos, size);
|
return _FillDirEntry(de, _FileIdToInoT(fileId), "..", pos, size);
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -273,15 +273,15 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count,
|
|||||||
|
|
||||||
// FATTR4_FSID is mandatory
|
// FATTR4_FSID is mandatory
|
||||||
void* data = dirents[i].fAttrs[0].fData.fPointer;
|
void* data = dirents[i].fAttrs[0].fData.fPointer;
|
||||||
FilesystemId* fsid = reinterpret_cast<FilesystemId*>(data);
|
FileSystemId* fsid = reinterpret_cast<FileSystemId*>(data);
|
||||||
if (*fsid != fFilesystem->FsId())
|
if (*fsid != fFileSystem->FsId())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ino_t id;
|
ino_t id;
|
||||||
if (dirents[i].fAttrCount == 2)
|
if (dirents[i].fAttrCount == 2)
|
||||||
id = _FileIdToInoT(dirents[i].fAttrs[1].fData.fValue64);
|
id = _FileIdToInoT(dirents[i].fAttrs[1].fData.fValue64);
|
||||||
else
|
else
|
||||||
id = _FileIdToInoT(fFilesystem->AllocFileId());
|
id = _FileIdToInoT(fFileSystem->AllocFileId());
|
||||||
|
|
||||||
const char* name = dirents[i].fName;
|
const char* name = dirents[i].fName;
|
||||||
if (_FillDirEntry(de, id, name, pos, size) == B_BUFFER_OVERFLOW) {
|
if (_FillDirEntry(de, id, name, pos, size) == B_BUFFER_OVERFLOW) {
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Inode::_ConfirmOpen(const Filehandle& fh, OpenFileCookie* cookie)
|
Inode::_ConfirmOpen(const FileHandle& fh, OpenFileCookie* cookie)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
|
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
@@ -32,7 +32,7 @@ Inode::_ConfirmOpen(const Filehandle& fh, OpenFileCookie* cookie)
|
|||||||
|
|
||||||
status_t result = request.Send();
|
status_t result = request.Send();
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
fFilesystem->RemoveOpenFile(cookie);
|
fFileSystem->RemoveOpenFile(cookie);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ Inode::_ConfirmOpen(const Filehandle& fh, OpenFileCookie* cookie)
|
|||||||
reply.PutFH();
|
reply.PutFH();
|
||||||
result = reply.OpenConfirm(&cookie->fStateSeq);
|
result = reply.OpenConfirm(&cookie->fStateSeq);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
fFilesystem->RemoveOpenFile(cookie);
|
fFileSystem->RemoveOpenFile(cookie);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,11 +67,11 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
|
|||||||
cookie->fLocks = NULL;
|
cookie->fLocks = NULL;
|
||||||
|
|
||||||
bool badOwner = false;
|
bool badOwner = false;
|
||||||
Filehandle fh;
|
FileHandle fh;
|
||||||
do {
|
do {
|
||||||
cookie->fClientId = fFilesystem->NFSServer()->ClientId();
|
cookie->fClientId = fFileSystem->NFSServer()->ClientId();
|
||||||
|
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -92,14 +92,14 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
|
|||||||
cattr[i].fData.fValue32 = perms;
|
cattr[i].fData.fValue32 = perms;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER)) {
|
if (!badOwner && fFileSystem->IsAttrSupported(FATTR4_OWNER)) {
|
||||||
cattr[i].fAttribute = FATTR4_OWNER;
|
cattr[i].fAttribute = FATTR4_OWNER;
|
||||||
cattr[i].fFreePointer = true;
|
cattr[i].fFreePointer = true;
|
||||||
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
|
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
|
if (!badOwner && fFileSystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
|
||||||
cattr[i].fAttribute = FATTR4_OWNER_GROUP;
|
cattr[i].fAttribute = FATTR4_OWNER_GROUP;
|
||||||
cattr[i].fFreePointer = true;
|
cattr[i].fFreePointer = true;
|
||||||
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
|
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
|
||||||
@@ -112,7 +112,7 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
|
|||||||
|
|
||||||
req.GetFH();
|
req.GetFH();
|
||||||
|
|
||||||
if (fFilesystem->IsAttrSupported(FATTR4_FILEID)) {
|
if (fFileSystem->IsAttrSupported(FATTR4_FILEID)) {
|
||||||
Attribute attr[] = { FATTR4_FILEID };
|
Attribute attr[] = { FATTR4_FILEID };
|
||||||
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
|
|||||||
reply.GetFH(&fh);
|
reply.GetFH(&fh);
|
||||||
|
|
||||||
uint64 fileId;
|
uint64 fileId;
|
||||||
if (fFilesystem->IsAttrSupported(FATTR4_FILEID)) {
|
if (fFileSystem->IsAttrSupported(FATTR4_FILEID)) {
|
||||||
AttrValue* values;
|
AttrValue* values;
|
||||||
uint32 count;
|
uint32 count;
|
||||||
result = reply.GetAttr(&values, &count);
|
result = reply.GetAttr(&values, &count);
|
||||||
@@ -146,7 +146,7 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
|
|||||||
|
|
||||||
delete[] values;
|
delete[] values;
|
||||||
} else
|
} else
|
||||||
fileId = fFilesystem->AllocFileId();
|
fileId = fFileSystem->AllocFileId();
|
||||||
|
|
||||||
*id = _FileIdToInoT(fileId);
|
*id = _FileIdToInoT(fileId);
|
||||||
|
|
||||||
@@ -163,15 +163,15 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
|
|||||||
strcat(path, name);
|
strcat(path, name);
|
||||||
fi.fPath = path;
|
fi.fPath = path;
|
||||||
|
|
||||||
fFilesystem->InoIdMap()->AddEntry(fi, *id);
|
fFileSystem->InoIdMap()->AddEntry(fi, *id);
|
||||||
|
|
||||||
cookie->fFilesystem = fFilesystem;
|
cookie->fFileSystem = fFileSystem;
|
||||||
cookie->fInfo = fi;
|
cookie->fInfo = fi;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
fFilesystem->AddOpenFile(cookie);
|
fFileSystem->AddOpenFile(cookie);
|
||||||
|
|
||||||
if (confirm)
|
if (confirm)
|
||||||
return _ConfirmOpen(fh, cookie);
|
return _ConfirmOpen(fh, cookie);
|
||||||
@@ -186,16 +186,16 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
bool confirm;
|
bool confirm;
|
||||||
status_t result;
|
status_t result;
|
||||||
|
|
||||||
cookie->fFilesystem = fFilesystem;
|
cookie->fFileSystem = fFileSystem;
|
||||||
cookie->fInfo = fInfo;
|
cookie->fInfo = fInfo;
|
||||||
cookie->fMode = mode;
|
cookie->fMode = mode;
|
||||||
cookie->fSequence = 0;
|
cookie->fSequence = 0;
|
||||||
cookie->fLocks = NULL;
|
cookie->fLocks = NULL;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
cookie->fClientId = fFilesystem->NFSServer()->ClientId();
|
cookie->fClientId = fFileSystem->NFSServer()->ClientId();
|
||||||
|
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
|
|
||||||
// Since we are opening the file using a pair (parentFH, name) we
|
// Since we are opening the file using a pair (parentFH, name) we
|
||||||
// need to check for race conditions.
|
// need to check for race conditions.
|
||||||
if (fFilesystem->IsAttrSupported(FATTR4_FILEID)) {
|
if (fFileSystem->IsAttrSupported(FATTR4_FILEID)) {
|
||||||
req.PutFH(fInfo.fParent);
|
req.PutFH(fInfo.fParent);
|
||||||
req.LookUp(fInfo.fName);
|
req.LookUp(fInfo.fName);
|
||||||
AttrValue attr;
|
AttrValue attr;
|
||||||
@@ -211,7 +211,7 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
attr.fFreePointer = false;
|
attr.fFreePointer = false;
|
||||||
attr.fData.fValue64 = fInfo.fFileId;
|
attr.fData.fValue64 = fInfo.fFileId;
|
||||||
req.Verify(&attr, 1);
|
req.Verify(&attr, 1);
|
||||||
} else if (fFilesystem->ExpireType() == FH4_PERSISTENT) {
|
} else if (fFileSystem->ExpireType() == FH4_PERSISTENT) {
|
||||||
req.PutFH(fInfo.fParent);
|
req.PutFH(fInfo.fParent);
|
||||||
req.LookUp(fInfo.fName);
|
req.LookUp(fInfo.fName);
|
||||||
AttrValue attr;
|
AttrValue attr;
|
||||||
@@ -246,8 +246,8 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
|
|
||||||
// Verify if the file we want to open is the file this Inode
|
// Verify if the file we want to open is the file this Inode
|
||||||
// represents.
|
// represents.
|
||||||
if (fFilesystem->IsAttrSupported(FATTR4_FILEID) ||
|
if (fFileSystem->IsAttrSupported(FATTR4_FILEID) ||
|
||||||
fFilesystem->ExpireType() == FH4_PERSISTENT) {
|
fFileSystem->ExpireType() == FH4_PERSISTENT) {
|
||||||
reply.PutFH();
|
reply.PutFH();
|
||||||
result = reply.LookUp();
|
result = reply.LookUp();
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
@@ -267,7 +267,7 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
fFilesystem->AddOpenFile(cookie);
|
fFileSystem->AddOpenFile(cookie);
|
||||||
|
|
||||||
if (confirm)
|
if (confirm)
|
||||||
return _ConfirmOpen(fInfo.fHandle, cookie);
|
return _ConfirmOpen(fInfo.fHandle, cookie);
|
||||||
@@ -279,10 +279,10 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
status_t
|
status_t
|
||||||
Inode::Close(OpenFileCookie* cookie)
|
Inode::Close(OpenFileCookie* cookie)
|
||||||
{
|
{
|
||||||
fFilesystem->RemoveOpenFile(cookie);
|
fFileSystem->RemoveOpenFile(cookie);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ Inode::Read(OpenFileCookie* cookie, off_t pos, void* buffer, size_t* _length)
|
|||||||
|
|
||||||
while (size < *_length && !eof) {
|
while (size < *_length && !eof) {
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ Inode::Write(OpenFileCookie* cookie, off_t pos, const void* _buffer,
|
|||||||
|
|
||||||
while (size < *_length) {
|
while (size < *_length) {
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ KernelAddon nfs4 :
|
|||||||
Cookie.cpp
|
Cookie.cpp
|
||||||
Connection.cpp
|
Connection.cpp
|
||||||
FileInfo.cpp
|
FileInfo.cpp
|
||||||
Filesystem.cpp
|
FileSystem.cpp
|
||||||
IdMap.cpp
|
IdMap.cpp
|
||||||
Inode.cpp
|
Inode.cpp
|
||||||
InodeDir.cpp
|
InodeDir.cpp
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Filesystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Inode.h"
|
#include "Inode.h"
|
||||||
#include "NFS4Server.h"
|
#include "NFS4Server.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
@@ -20,7 +20,7 @@ NFS4Server::NFS4Server(RPC::Server* serv)
|
|||||||
fLeaseTime(0),
|
fLeaseTime(0),
|
||||||
fClientIdLastUse(0),
|
fClientIdLastUse(0),
|
||||||
fUseCount(0),
|
fUseCount(0),
|
||||||
fFilesystems(NULL),
|
fFileSystems(NULL),
|
||||||
fServer(serv)
|
fServer(serv)
|
||||||
{
|
{
|
||||||
mutex_init(&fClientIdLock, NULL);
|
mutex_init(&fClientIdLock, NULL);
|
||||||
@@ -52,7 +52,7 @@ NFS4Server::ServerRebooted(uint64 clientId)
|
|||||||
|
|
||||||
// reclaim all opened files and held locks from all filesystems
|
// reclaim all opened files and held locks from all filesystems
|
||||||
MutexLocker _(fFSLock);
|
MutexLocker _(fFSLock);
|
||||||
Filesystem* fs = fFilesystems;
|
FileSystem* fs = fFileSystems;
|
||||||
while (fs != NULL) {
|
while (fs != NULL) {
|
||||||
OpenFileCookie* current = fs->OpenFilesLock();
|
OpenFileCookie* current = fs->OpenFilesLock();
|
||||||
while (current != NULL) {
|
while (current != NULL) {
|
||||||
@@ -157,14 +157,14 @@ NFS4Server::_ReclaimLocks(OpenFileCookie* cookie)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NFS4Server::AddFilesystem(Filesystem* fs)
|
NFS4Server::AddFileSystem(FileSystem* fs)
|
||||||
{
|
{
|
||||||
MutexLocker _(fFSLock);
|
MutexLocker _(fFSLock);
|
||||||
fs->fPrev = NULL;
|
fs->fPrev = NULL;
|
||||||
fs->fNext = fFilesystems;
|
fs->fNext = fFileSystems;
|
||||||
if (fFilesystems != NULL)
|
if (fFileSystems != NULL)
|
||||||
fFilesystems->fPrev = fs;
|
fFileSystems->fPrev = fs;
|
||||||
fFilesystems = fs;
|
fFileSystems = fs;
|
||||||
fUseCount += fs->OpenFilesCount();
|
fUseCount += fs->OpenFilesCount();
|
||||||
if (fs->OpenFilesCount() > 0 && fThreadCancel)
|
if (fs->OpenFilesCount() > 0 && fThreadCancel)
|
||||||
_StartRenewing();
|
_StartRenewing();
|
||||||
@@ -172,11 +172,11 @@ NFS4Server::AddFilesystem(Filesystem* fs)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NFS4Server::RemoveFilesystem(Filesystem* fs)
|
NFS4Server::RemoveFileSystem(FileSystem* fs)
|
||||||
{
|
{
|
||||||
MutexLocker _(fFSLock);
|
MutexLocker _(fFSLock);
|
||||||
if (fs == fFilesystems)
|
if (fs == fFileSystems)
|
||||||
fFilesystems = fs->fNext;
|
fFileSystems = fs->fNext;
|
||||||
|
|
||||||
if (fs->fNext)
|
if (fs->fNext)
|
||||||
fs->fNext->fPrev = fs->fPrev;
|
fs->fNext->fPrev = fs->fPrev;
|
||||||
@@ -223,11 +223,11 @@ NFS4Server::ClientId(uint64 prevId, bool forceNew)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
NFS4Server::FilesystemMigrated()
|
NFS4Server::FileSystemMigrated()
|
||||||
{
|
{
|
||||||
// reclaim all opened files and held locks from all filesystems
|
// reclaim all opened files and held locks from all filesystems
|
||||||
MutexLocker _(fFSLock);
|
MutexLocker _(fFSLock);
|
||||||
Filesystem* fs = fFilesystems;
|
FileSystem* fs = fFileSystems;
|
||||||
while (fs != NULL) {
|
while (fs != NULL) {
|
||||||
fs->Migrate(fServer);
|
fs->Migrate(fServer);
|
||||||
fs = fs->fNext;
|
fs = fs->fNext;
|
||||||
@@ -330,7 +330,7 @@ NFS4Server::_Renewal()
|
|||||||
ServerRebooted(clientId);
|
ServerRebooted(clientId);
|
||||||
break;
|
break;
|
||||||
case NFS4ERR_LEASE_MOVED:
|
case NFS4ERR_LEASE_MOVED:
|
||||||
FilesystemMigrated();
|
FileSystemMigrated();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include "RPCServer.h"
|
#include "RPCServer.h"
|
||||||
|
|
||||||
|
|
||||||
class Filesystem;
|
class FileSystem;
|
||||||
class OpenFileCookie;
|
class OpenFileCookie;
|
||||||
|
|
||||||
class NFS4Server : public RPC::ProgramData {
|
class NFS4Server : public RPC::ProgramData {
|
||||||
@@ -23,10 +23,10 @@ public:
|
|||||||
virtual ~NFS4Server();
|
virtual ~NFS4Server();
|
||||||
|
|
||||||
uint64 ServerRebooted(uint64 clientId);
|
uint64 ServerRebooted(uint64 clientId);
|
||||||
status_t FilesystemMigrated();
|
status_t FileSystemMigrated();
|
||||||
|
|
||||||
void AddFilesystem(Filesystem* fs);
|
void AddFileSystem(FileSystem* fs);
|
||||||
void RemoveFilesystem(Filesystem* fs);
|
void RemoveFileSystem(FileSystem* fs);
|
||||||
|
|
||||||
inline void IncUsage();
|
inline void IncUsage();
|
||||||
inline void DecUsage();
|
inline void DecUsage();
|
||||||
@@ -55,7 +55,7 @@ private:
|
|||||||
mutex fClientIdLock;
|
mutex fClientIdLock;
|
||||||
|
|
||||||
uint32 fUseCount;
|
uint32 fUseCount;
|
||||||
Filesystem* fFilesystems;
|
FileSystem* fFileSystems;
|
||||||
mutex fFSLock;
|
mutex fFSLock;
|
||||||
|
|
||||||
RPC::Server* fServer;
|
RPC::Server* fServer;
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ ReplyInterpreter::GetAttr(AttrValue** attrs, uint32* count)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ReplyInterpreter::GetFH(Filehandle* fh)
|
ReplyInterpreter::GetFH(FileHandle* fh)
|
||||||
{
|
{
|
||||||
status_t res = _OperationError(OpGetFH);
|
status_t res = _OperationError(OpGetFH);
|
||||||
if (res != B_OK)
|
if (res != B_OK)
|
||||||
@@ -179,7 +179,7 @@ ReplyInterpreter::GetFH(Filehandle* fh)
|
|||||||
|
|
||||||
if (fh != NULL) {
|
if (fh != NULL) {
|
||||||
fh->fSize = size;
|
fh->fSize = size;
|
||||||
memcpy(fh->fFH, ptr, size);
|
memcpy(fh->fData, ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fReply->Stream().IsEOF() ? B_BAD_VALUE : B_OK;
|
return fReply->Stream().IsEOF() ? B_BAD_VALUE : B_OK;
|
||||||
@@ -538,7 +538,7 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
|
|||||||
values[current].fAttribute = FATTR4_FSID;
|
values[current].fAttribute = FATTR4_FSID;
|
||||||
values[current].fFreePointer = true;
|
values[current].fFreePointer = true;
|
||||||
|
|
||||||
FilesystemId fsid;
|
FileSystemId fsid;
|
||||||
fsid.fMajor = stream.GetUHyper();
|
fsid.fMajor = stream.GetUHyper();
|
||||||
fsid.fMinor = stream.GetUHyper();
|
fsid.fMinor = stream.GetUHyper();
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
status_t Close();
|
status_t Close();
|
||||||
status_t Create();
|
status_t Create();
|
||||||
status_t GetAttr(AttrValue** attrs, uint32* count);
|
status_t GetAttr(AttrValue** attrs, uint32* count);
|
||||||
status_t GetFH(Filehandle* fh);
|
status_t GetFH(FileHandle* fh);
|
||||||
status_t Link();
|
status_t Link();
|
||||||
status_t Lock(LockInfo* linfo);
|
status_t Lock(LockInfo* linfo);
|
||||||
status_t LockT(uint64* pos, uint64* len, LockType* type);
|
status_t LockT(uint64* pos, uint64* len, LockType* type);
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ RequestBuilder::OpenConfirm(uint32 seq, const uint32* id, uint32 stateSeq)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
RequestBuilder::PutFH(const Filehandle& fh)
|
RequestBuilder::PutFH(const FileHandle& fh)
|
||||||
{
|
{
|
||||||
if (fProcedure != ProcCompound)
|
if (fProcedure != ProcCompound)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -410,7 +410,7 @@ RequestBuilder::PutFH(const Filehandle& fh)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
fRequest->Stream().AddUInt(OpPutFH);
|
fRequest->Stream().AddUInt(OpPutFH);
|
||||||
fRequest->Stream().AddOpaque(fh.fFH, fh.fSize);
|
fRequest->Stream().AddOpaque(fh.fData, fh.fSize);
|
||||||
fOpCount++;
|
fOpCount++;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -761,8 +761,8 @@ RequestBuilder::_EncodeAttrs(XDR::WriteStream& stream, AttrValue* attr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i < count && attr[i].fAttribute == FATTR4_FILEHANDLE) {
|
if (i < count && attr[i].fAttribute == FATTR4_FILEHANDLE) {
|
||||||
Filehandle* fh = reinterpret_cast<Filehandle*>(attr[i].fData.fPointer);
|
FileHandle* fh = reinterpret_cast<FileHandle*>(attr[i].fData.fPointer);
|
||||||
str.AddOpaque(fh->fFH, fh->fSize);
|
str.AddOpaque(fh->fData, fh->fSize);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
uint32 count = 0, bool excl = false);
|
uint32 count = 0, bool excl = false);
|
||||||
status_t OpenConfirm(uint32 seq, const uint32* id,
|
status_t OpenConfirm(uint32 seq, const uint32* id,
|
||||||
uint32 stateSeq);
|
uint32 stateSeq);
|
||||||
status_t PutFH(const Filehandle& fh);
|
status_t PutFH(const FileHandle& fh);
|
||||||
status_t PutRootFH();
|
status_t PutRootFH();
|
||||||
status_t Read(const uint32* id, uint32 stateSeq,
|
status_t Read(const uint32* id, uint32 stateSeq,
|
||||||
uint64 pos, uint32 len);
|
uint64 pos, uint32 len);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ status_t
|
|||||||
RootInode::ReadInfo(struct fs_info* info)
|
RootInode::ReadInfo(struct fs_info* info)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ bool
|
|||||||
RootInode::ProbeMigration()
|
RootInode::ProbeMigration()
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ status_t
|
|||||||
RootInode::GetLocations(AttrValue** attrv)
|
RootInode::GetLocations(AttrValue** attrv)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
RPC::Server* serv = fFilesystem->Server();
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
Request request(serv);
|
Request request(serv);
|
||||||
RequestBuilder& req = request.Builder();
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <fs_interface.h>
|
#include <fs_interface.h>
|
||||||
|
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
#include "Filesystem.h"
|
#include "FileSystem.h"
|
||||||
#include "IdMap.h"
|
#include "IdMap.h"
|
||||||
#include "Inode.h"
|
#include "Inode.h"
|
||||||
#include "NFS4Defs.h"
|
#include "NFS4Defs.h"
|
||||||
@@ -86,8 +86,8 @@ nfs4_mount(fs_volume* volume, const char* device, uint32 flags,
|
|||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Filesystem* fs;
|
FileSystem* fs;
|
||||||
result = Filesystem::Mount(&fs, server, path, volume->id);
|
result = FileSystem::Mount(&fs, server, path, volume->id);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
gRPCServerManager->Release(server);
|
gRPCServerManager->Release(server);
|
||||||
return result;
|
return result;
|
||||||
@@ -119,7 +119,7 @@ static status_t
|
|||||||
nfs4_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode, int* _type,
|
nfs4_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode, int* _type,
|
||||||
uint32* _flags, bool reenter)
|
uint32* _flags, bool reenter)
|
||||||
{
|
{
|
||||||
Filesystem* fs = reinterpret_cast<Filesystem*>(volume->private_volume);
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
Inode* inode;
|
Inode* inode;
|
||||||
status_t result = fs->GetInode(id, &inode);
|
status_t result = fs->GetInode(id, &inode);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
@@ -138,7 +138,7 @@ nfs4_get_vnode(fs_volume* volume, ino_t id, fs_vnode* vnode, int* _type,
|
|||||||
static status_t
|
static status_t
|
||||||
nfs4_unmount(fs_volume* volume)
|
nfs4_unmount(fs_volume* volume)
|
||||||
{
|
{
|
||||||
Filesystem* fs = reinterpret_cast<Filesystem*>(volume->private_volume);
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
RPC::Server* server = fs->Server();
|
RPC::Server* server = fs->Server();
|
||||||
|
|
||||||
delete fs;
|
delete fs;
|
||||||
@@ -151,7 +151,7 @@ nfs4_unmount(fs_volume* volume)
|
|||||||
static status_t
|
static status_t
|
||||||
nfs4_read_fs_info(fs_volume* volume, struct fs_info* info)
|
nfs4_read_fs_info(fs_volume* volume, struct fs_info* info)
|
||||||
{
|
{
|
||||||
Filesystem* fs = reinterpret_cast<Filesystem*>(volume->private_volume);
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
RootInode* inode = reinterpret_cast<RootInode*>(fs->Root());
|
RootInode* inode = reinterpret_cast<RootInode*>(fs->Root());
|
||||||
return inode->ReadInfo(info);
|
return inode->ReadInfo(info);
|
||||||
}
|
}
|
||||||
@@ -183,12 +183,12 @@ nfs4_get_vnode_name(fs_volume* volume, fs_vnode* vnode, char* buffer,
|
|||||||
static status_t
|
static status_t
|
||||||
nfs4_put_vnode(fs_volume* volume, fs_vnode* vnode, bool reenter)
|
nfs4_put_vnode(fs_volume* volume, fs_vnode* vnode, bool reenter)
|
||||||
{
|
{
|
||||||
Filesystem* fs = reinterpret_cast<Filesystem*>(volume->private_volume);
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
||||||
if (fs->Root() == inode)
|
if (fs->Root() == inode)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
inode->FileSystem()->InoIdMap()->RemoveEntry(inode->ID());
|
inode->GetFileSystem()->InoIdMap()->RemoveEntry(inode->ID());
|
||||||
delete inode;
|
delete inode;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -202,12 +202,12 @@ nfs4_remove_vnode(fs_volume* volume, fs_vnode* vnode, bool reenter)
|
|||||||
// side are only an attempt to simulate local filesystem. Hence,
|
// side are only an attempt to simulate local filesystem. Hence,
|
||||||
// this hook is the same as put_vnode().
|
// this hook is the same as put_vnode().
|
||||||
|
|
||||||
Filesystem* fs = reinterpret_cast<Filesystem*>(volume->private_volume);
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
||||||
if (fs->Root() == inode)
|
if (fs->Root() == inode)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
inode->FileSystem()->InoIdMap()->RemoveEntry(inode->ID());
|
inode->GetFileSystem()->InoIdMap()->RemoveEntry(inode->ID());
|
||||||
delete inode;
|
delete inode;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user