@@ -22,6 +22,8 @@ class Inode;
|
|||||||
class RootInode;
|
class RootInode;
|
||||||
|
|
||||||
struct MountConfiguration {
|
struct MountConfiguration {
|
||||||
|
bool fReadOnly;
|
||||||
|
|
||||||
bool fHard;
|
bool fHard;
|
||||||
int fRetryLimit;
|
int fRetryLimit;
|
||||||
bigtime_t fRequestTimeout;
|
bigtime_t fRequestTimeout;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
#include <fs_cache.h>
|
#include <fs_cache.h>
|
||||||
#include <fs_interface.h>
|
#include <fs_interface.h>
|
||||||
|
#include <fs_volume.h>
|
||||||
|
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
@@ -161,8 +162,10 @@ nfs4_mount(fs_volume* volume, const char* device, uint32 flags,
|
|||||||
}
|
}
|
||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
|
|
||||||
AddressResolver* resolver;
|
|
||||||
MountConfiguration config;
|
MountConfiguration config;
|
||||||
|
config.fReadOnly = (flags & B_MOUNT_READ_ONLY) != 0;
|
||||||
|
|
||||||
|
AddressResolver* resolver;
|
||||||
char* path;
|
char* path;
|
||||||
char* serverName;
|
char* serverName;
|
||||||
result = ParseArguments(args, &resolver, &serverName, &path, &config);
|
result = ParseArguments(args, &resolver, &serverName, &path, &config);
|
||||||
@@ -527,6 +530,10 @@ nfs4_create_symlink(fs_volume* volume, fs_vnode* dir, const char* name,
|
|||||||
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s, path = %s, mode = %d\n",
|
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s, path = %s, mode = %d\n",
|
||||||
volume, vti->ID(), name, path, mode);
|
volume, vti->ID(), name, path, mode);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
@@ -556,12 +563,15 @@ nfs4_link(fs_volume* volume, fs_vnode* dir, const char* name, fs_vnode* vnode)
|
|||||||
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s, vnode = %" B_PRIi64
|
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s, vnode = %" B_PRIi64
|
||||||
"\n", volume, dirVti->ID(), name, vti->ID());
|
"\n", volume, dirVti->ID(), name, vti->ID());
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _dir(dirVti);
|
VnodeToInodeLocker _dir(dirVti);
|
||||||
Inode* dirInode = dirVti->Get();
|
Inode* dirInode = dirVti->Get();
|
||||||
if (dirInode == NULL)
|
if (dirInode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
@@ -576,14 +586,18 @@ nfs4_unlink(fs_volume* volume, fs_vnode* dir, const char* name)
|
|||||||
{
|
{
|
||||||
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(dir->private_node);
|
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(dir->private_node);
|
||||||
|
|
||||||
|
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s\n", volume, vti->ID(),
|
||||||
|
name);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker locker(vti);
|
VnodeToInodeLocker locker(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s\n", volume, vti->ID(),
|
|
||||||
name);
|
|
||||||
|
|
||||||
ino_t id;
|
ino_t id;
|
||||||
status_t result = inode->Remove(name, NF4REG, &id);
|
status_t result = inode->Remove(name, NF4REG, &id);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
@@ -617,12 +631,15 @@ nfs4_rename(fs_volume* volume, fs_vnode* fromDir, const char* fromName,
|
|||||||
" fromName = %s, toName = %s\n", volume, fromVti->ID(), toVti->ID(),
|
" fromName = %s, toName = %s\n", volume, fromVti->ID(), toVti->ID(),
|
||||||
fromName, toName);
|
fromName, toName);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _from(fromVti);
|
VnodeToInodeLocker _from(fromVti);
|
||||||
Inode* fromInode = fromVti->Get();
|
Inode* fromInode = fromVti->Get();
|
||||||
if (fromInode == NULL)
|
if (fromInode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
|
||||||
VnodeToInodeLocker _to(toVti);
|
VnodeToInodeLocker _to(toVti);
|
||||||
Inode* toInode = toVti->Get();
|
Inode* toInode = toVti->Get();
|
||||||
if (toInode == NULL)
|
if (toInode == NULL)
|
||||||
@@ -711,6 +728,10 @@ nfs4_write_stat(fs_volume* volume, fs_vnode* vnode, const struct stat* stat,
|
|||||||
TRACE("volume = %p, vnode = %" B_PRIi64 ", statMask = %" B_PRIu32 "\n",
|
TRACE("volume = %p, vnode = %" B_PRIi64 ", statMask = %" B_PRIu32 "\n",
|
||||||
volume, vti->ID(), statMask);
|
volume, vti->ID(), statMask);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
@@ -768,6 +789,9 @@ nfs4_create(fs_volume* volume, fs_vnode* dir, const char* name, int openMode,
|
|||||||
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s, openMode = %d," \
|
TRACE("volume = %p, dir = %" B_PRIi64 ", name = %s, openMode = %d," \
|
||||||
" perms = %d\n", volume, vti->ID(), name, openMode, perms);
|
" perms = %d\n", volume, vti->ID(), name, openMode, perms);
|
||||||
|
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
@@ -828,6 +852,10 @@ nfs4_open(fs_volume* volume, fs_vnode* vnode, int openMode, void** _cookie)
|
|||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly && (openMode & O_RWMASK) != O_RDONLY)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
if (inode->Type() == S_IFDIR && (openMode & O_RWMASK) != O_RDONLY)
|
if (inode->Type() == S_IFDIR && (openMode & O_RWMASK) != O_RDONLY)
|
||||||
return B_IS_A_DIRECTORY;
|
return B_IS_A_DIRECTORY;
|
||||||
if ((openMode & O_DIRECTORY) != 0 && inode->Type() != S_IFDIR)
|
if ((openMode & O_DIRECTORY) != 0 && inode->Type() != S_IFDIR)
|
||||||
@@ -838,7 +866,6 @@ nfs4_open(fs_volume* volume, fs_vnode* vnode, int openMode, void** _cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
|
||||||
OpenFileCookie* cookie = new OpenFileCookie(fs);
|
OpenFileCookie* cookie = new OpenFileCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -867,7 +894,6 @@ nfs4_close(fs_volume* volume, fs_vnode* vnode, void* _cookie)
|
|||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
|
||||||
if (inode->Type() == S_IFDIR || inode->Type() == S_IFLNK)
|
if (inode->Type() == S_IFDIR || inode->Type() == S_IFLNK)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
@@ -959,6 +985,10 @@ nfs4_create_dir(fs_volume* volume, fs_vnode* parent, const char* name,
|
|||||||
TRACE("volume = %p, parent = %" B_PRIi64 ", mode = %d\n", volume, vti->ID(),
|
TRACE("volume = %p, parent = %" B_PRIi64 ", mode = %d\n", volume, vti->ID(),
|
||||||
mode);
|
mode);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
@@ -987,6 +1017,10 @@ nfs4_remove_dir(fs_volume* volume, fs_vnode* parent, const char* name)
|
|||||||
TRACE("volume = %p, parent = %" B_PRIi64 ", name = %s\n", volume, vti->ID(),
|
TRACE("volume = %p, parent = %" B_PRIi64 ", name = %s\n", volume, vti->ID(),
|
||||||
name);
|
name);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
@@ -1158,12 +1192,15 @@ nfs4_create_attr(fs_volume* volume, fs_vnode* vnode, const char* name,
|
|||||||
{
|
{
|
||||||
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(vnode->private_node);
|
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(vnode->private_node);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
|
||||||
OpenAttrCookie* cookie = new OpenAttrCookie(fs);
|
OpenAttrCookie* cookie = new OpenAttrCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -1189,6 +1226,9 @@ nfs4_open_attr(fs_volume* volume, fs_vnode* vnode, const char* name,
|
|||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly && (openMode & O_RWMASK) != O_RDONLY)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
OpenAttrCookie* cookie = new OpenAttrCookie(fs);
|
OpenAttrCookie* cookie = new OpenAttrCookie(fs);
|
||||||
if (cookie == NULL)
|
if (cookie == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -1298,6 +1338,11 @@ nfs4_rename_attr(fs_volume* volume, fs_vnode* fromVnode, const char* fromName,
|
|||||||
fs_vnode* toVnode, const char* toName)
|
fs_vnode* toVnode, const char* toName)
|
||||||
{
|
{
|
||||||
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(toVnode->private_node);
|
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(toVnode->private_node);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker to(vti);
|
VnodeToInodeLocker to(vti);
|
||||||
Inode* toInode = vti->Get();
|
Inode* toInode = vti->Get();
|
||||||
if (toInode == NULL)
|
if (toInode == NULL)
|
||||||
@@ -1318,6 +1363,10 @@ nfs4_remove_attr(fs_volume* volume, fs_vnode* vnode, const char* name)
|
|||||||
{
|
{
|
||||||
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(vnode->private_node);
|
VnodeToInode* vti = reinterpret_cast<VnodeToInode*>(vnode->private_node);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
@@ -1354,6 +1403,9 @@ nfs4_acquire_lock(fs_volume* volume, fs_vnode* vnode, void* _cookie,
|
|||||||
TRACE("volume = %p, vnode = %" B_PRIi64 ", cookie = %p, lock = %p\n",
|
TRACE("volume = %p, vnode = %" B_PRIi64 ", cookie = %p, lock = %p\n",
|
||||||
volume, vti->ID(), _cookie, lock);
|
volume, vti->ID(), _cookie, lock);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
@@ -1373,6 +1425,10 @@ nfs4_release_lock(fs_volume* volume, fs_vnode* vnode, void* _cookie,
|
|||||||
TRACE("volume = %p, vnode = %" B_PRIi64 ", cookie = %p, lock = %p\n",
|
TRACE("volume = %p, vnode = %" B_PRIi64 ", cookie = %p, lock = %p\n",
|
||||||
volume, vti->ID(), _cookie, lock);
|
volume, vti->ID(), _cookie, lock);
|
||||||
|
|
||||||
|
FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
|
||||||
|
if (fs->GetConfiguration().fReadOnly)
|
||||||
|
return B_READ_ONLY_DEVICE;
|
||||||
|
|
||||||
VnodeToInodeLocker _(vti);
|
VnodeToInodeLocker _(vti);
|
||||||
Inode* inode = vti->Get();
|
Inode* inode = vti->Get();
|
||||||
if (inode == NULL)
|
if (inode == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user