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
@@ -45,6 +45,7 @@ public:
virtual status_t PublishDevice();
virtual status_t UnpublishDevice();
virtual status_t RepublishDevice();
void SetDeviceFlags(uint32 flags); // comprises the ones below
uint32 DeviceFlags() const;
@@ -63,6 +64,7 @@ public:
// TODO: Remove this method or make it private. Once initialized the
// path must not be changed.
const char *Path() const;
virtual status_t GetFileName(char* buffer, size_t size) const;
virtual status_t GetPath(KPath *path) const;
// File descriptor: Set only from a kernel thread, valid only for
@@ -48,6 +48,7 @@ public:
virtual status_t Open(int flags, int *fd);
virtual status_t PublishDevice();
virtual status_t UnpublishDevice();
virtual status_t RepublishDevice();
bool IsPublished() const;
void SetBusy(bool busy);
@@ -106,6 +107,7 @@ public:
virtual void SetID(partition_id id);
partition_id ID() const;
virtual status_t GetFileName(char* buffer, size_t size) const;
virtual status_t GetPath(KPath *path) const;
// no setter (see BDiskDevice) -- built on the fly
@@ -207,7 +209,7 @@ protected:
void FireContentCookieChanged(void *cookie);
private:
void _UpdateChildIndices(int32 index);
void _UpdateChildIndices(int32 start, int32 end);
static int32 _NextID();
protected:
@@ -226,7 +228,7 @@ protected:
uint32 fAlgorithmData;
int32 fReferenceCount;
bool fObsolete;
bool fPublished;
char *fPublishedName;
static int32 fNextID;
};