From 7c17001c779bb21d532b7b58f5dc65e76f81d94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 26 May 2005 20:44:33 +0000 Subject: [PATCH] Implemented BPartition::GetPath() much like KPartition::GetPath(). The "mountvolume" command can now actually mount file systems :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12853 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/Partition.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/kits/storage/Partition.cpp b/src/kits/storage/Partition.cpp index 3cb59d43ad..0ace6b68d2 100644 --- a/src/kits/storage/Partition.cpp +++ b/src/kits/storage/Partition.cpp @@ -302,8 +302,34 @@ BPartition::GetDiskSystem(BDiskSystem *diskSystem) const status_t BPartition::GetPath(BPath *path) const { - // not implemented - return B_ERROR; + // The path is constructed on the fly using our parent + if (path == NULL || Parent() == NULL || Index() < 0) + return B_BAD_VALUE; + + // get the parent's path + status_t error = Parent()->GetPath(path); + if (error != B_OK) + return error; + + char indexBuffer[24]; + + if (Parent()->IsDevice()) { + // Our parent is a device, so we replace `raw' by our index. + const char *leaf = path->Leaf(); + if (!leaf || strcmp(leaf, "raw") != B_OK) + return B_ERROR; + + snprintf(indexBuffer, sizeof(indexBuffer), "%ld", Index()); + } else { + // Our parent is a normal partition, no device: Append our index. + snprintf(indexBuffer, sizeof(indexBuffer), "%s_%ld", path->Leaf(), Index()); + } + + error = path->GetParent(path); + if (error == B_OK) + error = path->Append(indexBuffer); + + return error; } // GetVolume