* Added CreateChild().

* Added Publish/UnpublishDevice(). Not implemented yet.
* small fixes


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3479 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-06-11 22:03:26 +00:00
parent 13a452eaee
commit 1bf21e6a40
2 changed files with 47 additions and 1 deletions

View File

@ -31,12 +31,14 @@ public:
// Reference counting. As long as there's at least one referrer, the
// object won't be deleted.
// manager must be locked
// manager must be locked (Unregister() locks itself)
void Register();
void Unregister();
int32 CountReferences() const;
status_t Open(int flags, int *fd);
status_t PublishDevice();
status_t UnpublishDevice();
void SetBusy(bool busy);
bool IsBusy() const;
@ -118,6 +120,8 @@ public:
KPartition *Parent() const;
status_t AddChild(KPartition *partition, int32 index = -1);
status_t CreateChild(partition_id id, int32 index,
KPartition **child = NULL);
KPartition *RemoveChild(int32 index);
KPartition *ChildAt(int32 index) const;
int32 CountChildren() const;

View File

@ -70,6 +70,7 @@ KPartition::Register()
void
KPartition::Unregister()
{
ManagerLocker locker(KDiskDeviceManager::Default());
fReferenceCount--;
}
@ -98,6 +99,22 @@ KPartition::Open(int flags, int *fd)
return B_OK;
}
// PublishDevice
status_t
KPartition::PublishDevice()
{
// not implemented
return B_ERROR;
}
// UnpublishDevice
status_t
KPartition::UnpublishDevice()
{
// not implemented
return B_ERROR;
}
// SetBusy
void
KPartition::SetBusy(bool busy)
@ -339,6 +356,8 @@ KPartition::ID() const
int32
KPartition::ChangeCounter() const
{
// not implemented
return 0;
}
// GetPath
@ -486,6 +505,29 @@ KPartition::AddChild(KPartition *partition, int32 index)
return B_ERROR;
}
// CreateChild
status_t
KPartition::CreateChild(partition_id id, int32 index, KPartition **_child)
{
// check parameters
int32 count = fPartitionData.child_count;
if (index == -1)
index = count;
if (index < 0 || index > count)
return B_BAD_VALUE;
// create and add partition
KPartition *child = new(nothrow) KPartition(id);
if (!child)
return B_NO_MEMORY;
status_t error = AddChild(child, index);
// cleanup / set result
if (error != B_OK)
delete child;
else if (_child)
*_child = child;
return error;
}
// RemoveChild
KPartition *
KPartition::RemoveChild(int32 index)