Cleaned up GetPath(). In the kernel we no longer prefix the partition path names with "obos_" or "haiku_".

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9561 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2004-10-28 15:13:08 +00:00
parent 0402530222
commit e5452be634

View File

@ -477,29 +477,27 @@ KPartition::GetPath(KPath *path) const
status_t error = Parent()->GetPath(path); status_t error = Parent()->GetPath(path);
if (error != B_OK) if (error != B_OK)
return error; return error;
// check length for safety
int32 len = path->Length();
if (len >= path->BufferSize() - 10)
return B_NAME_TOO_LONG;
char* buffer = path->LockBuffer();
if (!buffer)
return B_ERROR;
if (Parent()->IsDevice()) { if (Parent()->IsDevice()) {
// Our parent is a device, so we replace `raw' by our index. // Our parent is a device, so we replace `raw' by our index.
int32 leafLen = strlen("/raw"); const char *leaf = path->Leaf();
if (len <= leafLen || strcmp(path->Path() + len - leafLen, "/raw")) { if (!leaf || strcmp(leaf, "raw") != B_OK)
error = B_ERROR; return B_ERROR;
} else { #ifdef _KERNEL_MODE
// TODO: For the time being the name is "obos_*" to not interfere with R5's char indexBuffer[12];
// names. snprintf(indexBuffer, sizeof(indexBuffer), "%ld", Index());
// sprintf(path + len - leafLen + 1, "%ld", Index()); #else
sprintf(buffer + len - leafLen + 1, "obos_%ld", Index()); const char *prefix = "haiku_";
} char indexBuffer[strlen(prefix) + 12];
snprintf(indexBuffer, sizeof(indexBuffer), "%s%ld", prefix,
Index());
#endif
error = path->ReplaceLeaf(indexBuffer);
} else { } else {
// Our parent is a normal partition, no device: Append our index. // Our parent is a normal partition, no device: Append our index.
sprintf(buffer + len, "_%ld", Index()); char indexBuffer[13];
snprintf(indexBuffer, sizeof(indexBuffer), "_%ld", Index());
error = path->Append(indexBuffer, false);
} }
path->UnlockBuffer();
return error; return error;
} }