* added support to packagefs for picking up its volume name from the

mount parameters - there doesn't seem to be a way for a filesystem
  to access the path to which it was mounted, is there?


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40225 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2011-01-12 20:11:13 +00:00
parent b16710b814
commit 4ca2f6909f
2 changed files with 20 additions and 12 deletions
@@ -343,25 +343,30 @@ Volume::Mount(const char* parameterString)
if (error != B_OK) if (error != B_OK)
RETURN_ERROR(error); RETURN_ERROR(error);
// create the root node const char* packages = NULL;
fRootDirectory = new(std::nothrow) Directory(kRootDirectoryID); const char* volumeName = "Package FS";
if (fRootDirectory == NULL)
RETURN_ERROR(B_NO_MEMORY);
fNodes.Insert(fRootDirectory);
const char* domain = NULL;
void* parameterHandle = parse_driver_settings_string(parameterString); void* parameterHandle = parse_driver_settings_string(parameterString);
if (parameterHandle != NULL) { if (parameterHandle != NULL) {
domain = get_driver_parameter(parameterHandle, "packages", NULL, NULL); packages
= get_driver_parameter(parameterHandle, "packages", NULL, NULL);
volumeName
= get_driver_parameter(parameterHandle, "volume-name", NULL, NULL);
delete_driver_settings(parameterHandle); delete_driver_settings(parameterHandle);
} }
if (domain == NULL || domain[0] == '\0') { if (packages == NULL || packages[0] == '\0') {
ERROR("need package folder ('packages' parameter)!\n"); ERROR("need package folder ('packages' parameter)!\n");
RETURN_ERROR(B_BAD_VALUE); RETURN_ERROR(B_BAD_VALUE);
} }
// create the root node
fRootDirectory = new(std::nothrow) Directory(kRootDirectoryID);
if (fRootDirectory == NULL)
RETURN_ERROR(B_NO_MEMORY);
fRootDirectory->Init(NULL, volumeName);
fNodes.Insert(fRootDirectory);
// create default package domain // create default package domain
error = _AddInitialPackageDomain(domain); error = _AddInitialPackageDomain(packages);
if (error != B_OK) if (error != B_OK)
RETURN_ERROR(error); RETURN_ERROR(error);
@@ -143,13 +143,16 @@ packagefs_unmount(fs_volume* fsVolume)
static status_t static status_t
packagefs_read_fs_info(fs_volume* fsVolume, struct fs_info* info) packagefs_read_fs_info(fs_volume* fsVolume, struct fs_info* info)
{ {
FUNCTION("volume: %p, info: %p\n", fsVolume->private_volume, info); Volume* volume = (Volume*)fsVolume->private_volume;
FUNCTION("volume: %p, info: %p\n", volume, info);
info->flags = B_FS_IS_READONLY; info->flags = B_FS_IS_READONLY;
info->block_size = 4096; info->block_size = 4096;
info->io_size = kOptimalIOSize; info->io_size = kOptimalIOSize;
info->total_blocks = info->free_blocks = 1; info->total_blocks = info->free_blocks = 1;
strlcpy(info->volume_name, "Package FS", sizeof(info->volume_name)); strlcpy(info->volume_name, volume->RootDirectory()->Name(),
sizeof(info->volume_name));
return B_OK; return B_OK;
} }