nfs4: Rename Filehandle to FileHandle and Filesystem to FileSystem

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