nfs4: Fix CID #991617: Set cookie file system at its creation
This commit is contained in:
parent
b92a3dcc61
commit
1192182c89
@ -67,8 +67,9 @@ LockInfo::operator==(const LockInfo& lock) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cookie::Cookie()
|
Cookie::Cookie(FileSystem* fileSystem)
|
||||||
:
|
:
|
||||||
|
fFileSystem(fileSystem),
|
||||||
fRequests(NULL),
|
fRequests(NULL),
|
||||||
fSnoozeCancel(create_sem(1, NULL))
|
fSnoozeCancel(create_sem(1, NULL))
|
||||||
{
|
{
|
||||||
@ -144,8 +145,16 @@ Cookie::CancelAll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OpenFileCookie::OpenFileCookie()
|
OpenStateCookie::OpenStateCookie(FileSystem* fileSystem)
|
||||||
:
|
:
|
||||||
|
Cookie(fileSystem)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OpenFileCookie::OpenFileCookie(FileSystem* fileSystem)
|
||||||
|
:
|
||||||
|
OpenStateCookie(fileSystem),
|
||||||
fLocks(NULL)
|
fLocks(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -173,9 +182,23 @@ OpenFileCookie::RemoveLock(LockInfo* lock, LockInfo* prev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OpenDirCookie::OpenDirCookie(FileSystem* fileSystem)
|
||||||
|
:
|
||||||
|
Cookie(fileSystem)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OpenDirCookie::~OpenDirCookie()
|
OpenDirCookie::~OpenDirCookie()
|
||||||
{
|
{
|
||||||
if (fSnapshot != NULL)
|
if (fSnapshot != NULL)
|
||||||
fSnapshot->ReleaseReference();
|
fSnapshot->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OpenAttrCookie::OpenAttrCookie(FileSystem* fileSystem)
|
||||||
|
:
|
||||||
|
OpenStateCookie(fileSystem)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ struct Cookie {
|
|||||||
|
|
||||||
sem_id fSnoozeCancel;
|
sem_id fSnoozeCancel;
|
||||||
|
|
||||||
Cookie();
|
Cookie(FileSystem* fileSystem);
|
||||||
virtual ~Cookie();
|
virtual ~Cookie();
|
||||||
|
|
||||||
status_t RegisterRequest(RPC::Request* req);
|
status_t RegisterRequest(RPC::Request* req);
|
||||||
@ -77,6 +77,8 @@ struct Cookie {
|
|||||||
struct OpenStateCookie : public Cookie {
|
struct OpenStateCookie : public Cookie {
|
||||||
OpenState* fOpenState;
|
OpenState* fOpenState;
|
||||||
uint32 fMode;
|
uint32 fMode;
|
||||||
|
|
||||||
|
OpenStateCookie(FileSystem* fileSystem);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OpenFileCookie : public OpenStateCookie {
|
struct OpenFileCookie : public OpenStateCookie {
|
||||||
@ -85,7 +87,7 @@ struct OpenFileCookie : public OpenStateCookie {
|
|||||||
void AddLock(LockInfo* lock);
|
void AddLock(LockInfo* lock);
|
||||||
void RemoveLock(LockInfo* lock, LockInfo* prev);
|
void RemoveLock(LockInfo* lock, LockInfo* prev);
|
||||||
|
|
||||||
OpenFileCookie();
|
OpenFileCookie(FileSystem* fileSystem);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OpenDirCookie : public Cookie {
|
struct OpenDirCookie : public Cookie {
|
||||||
@ -96,10 +98,13 @@ struct OpenDirCookie : public Cookie {
|
|||||||
|
|
||||||
bool fAttrDir;
|
bool fAttrDir;
|
||||||
|
|
||||||
|
OpenDirCookie(FileSystem* fileSystem);
|
||||||
~OpenDirCookie();
|
~OpenDirCookie();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OpenAttrCookie : public OpenStateCookie { };
|
struct OpenAttrCookie : public OpenStateCookie {
|
||||||
|
OpenAttrCookie(FileSystem* fileSystem);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // COOKIE_H
|
#endif // COOKIE_H
|
||||||
|
@ -36,7 +36,6 @@ Inode::OpenDir(OpenDirCookie* cookie)
|
|||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
cookie->fFileSystem = fFileSystem;
|
|
||||||
cookie->fSpecial = 0;
|
cookie->fSpecial = 0;
|
||||||
cookie->fSnapshot = NULL;
|
cookie->fSnapshot = NULL;
|
||||||
cookie->fCurrent = NULL;
|
cookie->fCurrent = NULL;
|
||||||
@ -52,7 +51,6 @@ Inode::OpenAttrDir(OpenDirCookie* cookie)
|
|||||||
{
|
{
|
||||||
ASSERT(cookie != NULL);
|
ASSERT(cookie != NULL);
|
||||||
|
|
||||||
cookie->fFileSystem = fFileSystem;
|
|
||||||
cookie->fSpecial = 0;
|
cookie->fSpecial = 0;
|
||||||
cookie->fSnapshot = NULL;
|
cookie->fSnapshot = NULL;
|
||||||
cookie->fCurrent = NULL;
|
cookie->fCurrent = NULL;
|
||||||
|
@ -84,7 +84,6 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cookie->fOpenState = state;
|
cookie->fOpenState = state;
|
||||||
cookie->fFileSystem = fFileSystem;
|
|
||||||
|
|
||||||
*id = FileIdToInoT(state->fInfo.fFileId);
|
*id = FileIdToInoT(state->fInfo.fFileId);
|
||||||
|
|
||||||
@ -168,7 +167,6 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
file_cache_set_size(fFileCache, 0);
|
file_cache_set_size(fFileCache, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie->fFileSystem = fFileSystem;
|
|
||||||
cookie->fMode = mode;
|
cookie->fMode = mode;
|
||||||
cookie->fLocks = NULL;
|
cookie->fLocks = NULL;
|
||||||
|
|
||||||
@ -262,7 +260,6 @@ Inode::OpenAttr(const char* _name, int mode, OpenAttrCookie* cookie,
|
|||||||
fFileSystem->AddOpenFile(state);
|
fFileSystem->AddOpenFile(state);
|
||||||
|
|
||||||
cookie->fOpenState = state;
|
cookie->fOpenState = state;
|
||||||
cookie->fFileSystem = fFileSystem;
|
|
||||||
cookie->fMode = mode;
|
cookie->fMode = mode;
|
||||||
|
|
||||||
if (data.fType != OPEN_DELEGATE_NONE) {
|
if (data.fType != OPEN_DELEGATE_NONE) {
|
||||||
|
@ -752,7 +752,9 @@ static status_t
|
|||||||
nfs4_create(fs_volume* volume, fs_vnode* dir, const char* name, int openMode,
|
nfs4_create(fs_volume* volume, fs_vnode* dir, const char* name, int openMode,
|
||||||
int perms, void** _cookie, ino_t* _newVnodeID)
|
int perms, void** _cookie, ino_t* _newVnodeID)
|
||||||
{
|
{
|
||||||
OpenFileCookie* cookie = new OpenFileCookie;
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
|
||||||
|
OpenFileCookie* cookie = new OpenFileCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
@ -766,7 +768,6 @@ nfs4_create(fs_volume* volume, fs_vnode* dir, const char* name, int openMode,
|
|||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
|
||||||
MutexLocker createLocker(fs->CreateFileLock());
|
MutexLocker createLocker(fs->CreateFileLock());
|
||||||
|
|
||||||
OpenDelegationData data;
|
OpenDelegationData data;
|
||||||
@ -826,7 +827,8 @@ nfs4_open(fs_volume* volume, fs_vnode* vnode, int openMode, void** _cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenFileCookie* cookie = new OpenFileCookie;
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
OpenFileCookie* cookie = new OpenFileCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
@ -1003,7 +1005,8 @@ nfs4_remove_dir(fs_volume* volume, fs_vnode* parent, const char* name)
|
|||||||
static status_t
|
static status_t
|
||||||
nfs4_open_dir(fs_volume* volume, fs_vnode* vnode, void** _cookie)
|
nfs4_open_dir(fs_volume* volume, fs_vnode* vnode, void** _cookie)
|
||||||
{
|
{
|
||||||
OpenDirCookie* cookie = new(std::nothrow) OpenDirCookie;
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
OpenDirCookie* cookie = new(std::nothrow) OpenDirCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
@ -1087,7 +1090,8 @@ nfs4_rewind_dir(fs_volume* volume, fs_vnode* vnode, void* _cookie)
|
|||||||
static status_t
|
static status_t
|
||||||
nfs4_open_attr_dir(fs_volume* volume, fs_vnode* vnode, void** _cookie)
|
nfs4_open_attr_dir(fs_volume* volume, fs_vnode* vnode, void** _cookie)
|
||||||
{
|
{
|
||||||
OpenDirCookie* cookie = new(std::nothrow) OpenDirCookie;
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
OpenDirCookie* cookie = new(std::nothrow) OpenDirCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
@ -1148,7 +1152,8 @@ nfs4_create_attr(fs_volume* volume, fs_vnode* vnode, const char* name,
|
|||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
OpenAttrCookie* cookie = new OpenAttrCookie;
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
OpenAttrCookie* cookie = new OpenAttrCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
@ -1172,7 +1177,8 @@ nfs4_open_attr(fs_volume* volume, fs_vnode* vnode, const char* name,
|
|||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
OpenAttrCookie* cookie = new OpenAttrCookie;
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
OpenAttrCookie* cookie = new OpenAttrCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
|
Loading…
Reference in New Issue
Block a user