Added offset and size parameters to create_child_partition() and

KPartition::CreateChild(). CreateChild() calls AddChild(), which publishes
the new partition, though at that point offset and size were not set, so that
the published devices would not be usable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31463 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-07-08 20:26:43 +00:00
parent 967294dbd8
commit 1cc5e46925
12 changed files with 74 additions and 63 deletions
@@ -185,8 +185,11 @@ KPartition::PublishDevice()
// get the path
KPath path;
status_t error = GetPath(&path);
if (error != B_OK)
if (error != B_OK) {
dprintf("KPartition::PublishDevice(): Failed to get path for partition "
"%ld: %s\n", ID(), strerror(error));
return error;
}
// prepare a partition_info
partition_info info;
@@ -202,8 +205,11 @@ KPartition::PublishDevice()
error = devfs_publish_partition(path.Path() + 5, &info);
// we need to remove the "/dev/" part from the path
if (error != B_OK)
if (error != B_OK) {
dprintf("KPartition::PublishDevice(): Failed to publish partition "
"%ld: %s\n", ID(), strerror(error));
return error;
}
fPublished = true;
@@ -220,13 +226,21 @@ KPartition::UnpublishDevice()
// get the path
KPath path;
status_t error = GetPath(&path);
if (error != B_OK)
if (error != B_OK) {
dprintf("KPartition::UnpublishDevice(): Failed to get path for "
"partition %ld: %s\n", ID(), strerror(error));
return error;
}
fPublished = false;
return devfs_unpublish_partition(path.Path() + 5);
error = devfs_unpublish_partition(path.Path() + 5);
// we need to remove the "/dev/" part from the path
if (error != B_OK) {
dprintf("KPartition::UnpublishDevice(): Failed to unpublish "
"partition %ld: %s\n", ID(), strerror(error));
}
return error;
}
@@ -785,7 +799,8 @@ KPartition::AddChild(KPartition *partition, int32 index)
// CreateChild
status_t
KPartition::CreateChild(partition_id id, int32 index, KPartition **_child)
KPartition::CreateChild(partition_id id, int32 index, off_t offset, off_t size,
KPartition **_child)
{
// check parameters
int32 count = fPartitionData.child_count;
@@ -799,6 +814,9 @@ KPartition::CreateChild(partition_id id, int32 index, KPartition **_child)
if (!child)
return B_NO_MEMORY;
child->SetOffset(offset);
child->SetSize(size);
status_t error = AddChild(child, index);
// cleanup / set result