nfs4: Ignore superfluous slashes and get proper NFS4 share name
This commit is contained in:
@@ -125,8 +125,8 @@ GetInodeNames(const char** root, const char* _path)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
FileSystem::Mount(FileSystem** _fs, RPC::Server* serv, const char* fsPath,
|
FileSystem::Mount(FileSystem** _fs, RPC::Server* serv, const char* serverName,
|
||||||
dev_t id, const MountConfiguration& configuration)
|
const char* fsPath, dev_t id, const MountConfiguration& configuration)
|
||||||
{
|
{
|
||||||
ASSERT(_fs != NULL);
|
ASSERT(_fs != NULL);
|
||||||
ASSERT(serv != NULL);
|
ASSERT(serv != NULL);
|
||||||
@@ -222,23 +222,23 @@ FileSystem::Mount(FileSystem** _fs, RPC::Server* serv, const char* fsPath,
|
|||||||
result = Inode::CreateInode(fs, fi, &inode);
|
result = Inode::CreateInode(fs, fi, &inode);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
RootInode* rootInode = reinterpret_cast<RootInode*>(inode);
|
||||||
|
fs->fRoot = rootInode;
|
||||||
|
|
||||||
char* name = strrchr(fsPath, '/');
|
char* fsName = strdup(fsPath);
|
||||||
if (name != NULL) {
|
if (fsName == NULL)
|
||||||
name++;
|
return B_NO_MEMORY;
|
||||||
reinterpret_cast<RootInode*>(inode)->SetName(name);
|
for (int i = strlen(fsName) - 1; i >= 0 && fsName[i] == '/'; i--)
|
||||||
} else if (fsPath[0] != '\0')
|
fsName[i] = '\0';
|
||||||
reinterpret_cast<RootInode*>(inode)->SetName(fsPath);
|
|
||||||
else {
|
|
||||||
char* address = serv->ID().UniversalAddress();
|
|
||||||
if (address != NULL)
|
|
||||||
reinterpret_cast<RootInode*>(inode)->SetName(address);
|
|
||||||
else
|
|
||||||
reinterpret_cast<RootInode*>(inode)->SetName("NFS4 Share");
|
|
||||||
free(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
fs->fRoot = reinterpret_cast<RootInode*>(inode);
|
char* name = strrchr(fsName, '/');
|
||||||
|
if (name != NULL)
|
||||||
|
rootInode->SetName(name + 1);
|
||||||
|
else if (fsName[0] != '\0')
|
||||||
|
rootInode->SetName(fsName);
|
||||||
|
else
|
||||||
|
rootInode->SetName(serverName);
|
||||||
|
free(fsName);
|
||||||
|
|
||||||
fs->NFSServer()->AddFileSystem(fs);
|
fs->NFSServer()->AddFileSystem(fs);
|
||||||
*_fs = fs;
|
*_fs = fs;
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ struct MountConfiguration {
|
|||||||
class FileSystem : public DoublyLinkedListLinkImpl<FileSystem> {
|
class FileSystem : public DoublyLinkedListLinkImpl<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, const char* serverName,
|
||||||
|
dev_t id,
|
||||||
const MountConfiguration& configuration);
|
const MountConfiguration& configuration);
|
||||||
~FileSystem();
|
~FileSystem();
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ CreateNFS4Server(RPC::Server* serv)
|
|||||||
// dirtime=X - attempt revalidate directory cache not more often than each X
|
// dirtime=X - attempt revalidate directory cache not more often than each X
|
||||||
// seconds
|
// seconds
|
||||||
static status_t
|
static status_t
|
||||||
ParseArguments(const char* _args, AddressResolver** address, char** _path,
|
ParseArguments(const char* _args, AddressResolver** address, char** _server,
|
||||||
MountConfiguration* conf)
|
char** _path, MountConfiguration* conf)
|
||||||
{
|
{
|
||||||
if (_args == NULL)
|
if (_args == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -94,12 +94,18 @@ ParseArguments(const char* _args, AddressResolver** address, char** _path,
|
|||||||
return B_MISMATCHED_VALUES;
|
return B_MISMATCHED_VALUES;
|
||||||
*path++ = '\0';
|
*path++ = '\0';
|
||||||
|
|
||||||
*address = new AddressResolver(args);
|
*_server = strdup(args);
|
||||||
if (*address == NULL)
|
if (*_server == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
*address = new AddressResolver(args);
|
||||||
|
if (*address == NULL) {
|
||||||
|
delete *_server;
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
*_path = strdup(path);
|
*_path = strdup(path);
|
||||||
if (*_path == NULL) {
|
if (*_path == NULL) {
|
||||||
|
delete *_server;
|
||||||
delete *address;
|
delete *address;
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -176,7 +182,8 @@ nfs4_mount(fs_volume* volume, const char* device, uint32 flags,
|
|||||||
AddressResolver* resolver;
|
AddressResolver* resolver;
|
||||||
MountConfiguration config;
|
MountConfiguration config;
|
||||||
char* path;
|
char* path;
|
||||||
result = ParseArguments(args, &resolver, &path, &config);
|
char* serverName;
|
||||||
|
result = ParseArguments(args, &resolver, &serverName, &path, &config);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
MemoryDeleter pathDeleter(path);
|
MemoryDeleter pathDeleter(path);
|
||||||
@@ -188,7 +195,9 @@ nfs4_mount(fs_volume* volume, const char* device, uint32 flags,
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
FileSystem* fs;
|
FileSystem* fs;
|
||||||
result = FileSystem::Mount(&fs, server, path, volume->id, config);
|
result = FileSystem::Mount(&fs, server, serverName, path, volume->id,
|
||||||
|
config);
|
||||||
|
free(serverName);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
gRPCServerManager->Release(server);
|
gRPCServerManager->Release(server);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user