Patch by Bryce Groff, some changes by myself:

* devfs:
  - devfs_[un]publish_partition(): They no longer get the partition path as
    parameter, but rather the device path and the partition name.
  - Added devfs_rename_partition(), which renames an already published
    partition node.
* KPartition/KDiskDevice:
  - Replaced the fPublished flag by fPublishedName, the name under which the
    partition is published. This simplifies UnpublishDevice() and makes it
    practically infallible.
  - Added GetFileName(), which only returns the partition's file name.
    Simplified GetPath() by using it.
  - When a partition is added/removed the subsequent sibling partitions get a
    new index. Now we also rename their published device nodes (and those of
    their descendents). When something goes wrong we unpublish the concerned
    partition's device to be on the safe side. Would be a shame to accidentally
    format the wrong partition, eh? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31520 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-07-11 14:35:04 +00:00
parent 3db3c417f0
commit a365e1cfbb
6 changed files with 245 additions and 97 deletions
@@ -1,4 +1,8 @@
// KDiskDevice.cpp
/*
* Copyright 2003-2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include <errno.h>
#include <fcntl.h>
@@ -29,7 +33,7 @@ KDiskDevice::KDiskDevice(partition_id id)
{
Unset();
fDevice = this;
fPublished = true;
fPublishedName = (char*)"raw";
}
// destructor
@@ -160,8 +164,8 @@ KDiskDevice::SetID(partition_id id)
status_t
KDiskDevice::PublishDevice()
{
// PublishDevice() and UnpublishDevice() are no-ops for KDiskDevices,
// since they are always published.
// PublishDevice(), UnpublishDevice() and Republish are no-ops
// for KDiskDevices, since they are always published.
return B_OK;
}
@@ -169,11 +173,19 @@ KDiskDevice::PublishDevice()
status_t
KDiskDevice::UnpublishDevice()
{
// PublishDevice() and UnpublishDevice() are no-ops for KDiskDevices,
// since they are always published.
// PublishDevice(), UnpublishDevice() and Republish are no-ops
// for KDiskDevices, since they are always published.
return B_OK;
}
// RepublishDevice
status_t
KDiskDevice::RepublishDevice()
{
// PublishDevice(), UnpublishDevice() and Republish are no-ops
// for KDiskDevices, since they are always published.
return B_OK;
}
// SetDeviceFlags
void
@@ -269,6 +281,16 @@ KDiskDevice::Path() const
return fDeviceData.path;
}
status_t
KDiskDevice::GetFileName(char *buffer, size_t size) const
{
if (strlcpy(buffer, "raw", size) >= size)
return B_NAME_TOO_LONG;
return B_OK;
}
// GetPath
status_t
KDiskDevice::GetPath(KPath *path) const