mountvolume: return type of ContentName() is now BString

fixes #18011

Change-Id: Ie8dda950005c191c843535b12f7cf8f9819bdcfb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5757
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
Jérôme Duval 2022-10-23 19:10:04 +02:00
parent 37f29a6f7a
commit 876ddc1adb

View File

@ -163,19 +163,19 @@ struct MountVisitor : public BDiskDeviceVisitor {
virtual bool Visit(BPartition* partition, int32 level) virtual bool Visit(BPartition* partition, int32 level)
{ {
// get name and type // get name and type
const char* name = partition->ContentName(); BString name = partition->ContentName();
if (!name) if (name.IsEmpty())
name = partition->Name(); name = partition->Name();
const char* type = partition->ContentType(); const char* type = partition->ContentType();
// check whether to mount // check whether to mount
bool mount = false; bool mount = false;
if (name && toMount.find(name) != toMount.end()) { if (name && toMount.find(name.String()) != toMount.end()) {
toMount.erase(name); toMount.erase(name.String());
if (!partition->IsMounted()) if (!partition->IsMounted())
mount = true; mount = true;
else if (!silent) else if (!silent)
fprintf(stderr, "Volume `%s' already mounted.\n", name); fprintf(stderr, "Volume `%s' already mounted.\n", name.String());
} else if (mountAll) { } else if (mountAll) {
mount = true; mount = true;
} else if (mountBFS && type != NULL } else if (mountBFS && type != NULL
@ -196,13 +196,13 @@ struct MountVisitor : public BDiskDeviceVisitor {
// check whether to unmount // check whether to unmount
bool unmount = false; bool unmount = false;
if (name && toUnmount.find(name) != toUnmount.end()) { if (name && toUnmount.find(name.String()) != toUnmount.end()) {
toUnmount.erase(name); toUnmount.erase(name.String());
if (partition->IsMounted()) { if (partition->IsMounted()) {
unmount = true; unmount = true;
mount = false; mount = false;
} else if (!silent) } else if (!silent)
fprintf(stderr, "Volume `%s' not mounted.\n", name); fprintf(stderr, "Volume `%s' not mounted.\n", name.String());
} }
// mount/unmount // mount/unmount
@ -213,11 +213,11 @@ struct MountVisitor : public BDiskDeviceVisitor {
if (error >= B_OK) { if (error >= B_OK) {
BPath mountPoint; BPath mountPoint;
partition->GetMountPoint(&mountPoint); partition->GetMountPoint(&mountPoint);
printf("Volume `%s' mounted successfully at '%s'.\n", name, printf("Volume `%s' mounted successfully at '%s'.\n", name.String(),
mountPoint.Path()); mountPoint.Path());
} else { } else {
fprintf(stderr, "Failed to mount volume `%s': %s\n", fprintf(stderr, "Failed to mount volume `%s': %s\n",
name, strerror(error)); name.String(), strerror(error));
} }
} }
if (openInTracker && error == B_OK) if (openInTracker && error == B_OK)
@ -226,10 +226,10 @@ struct MountVisitor : public BDiskDeviceVisitor {
status_t error = partition->Unmount(); status_t error = partition->Unmount();
if (!silent) { if (!silent) {
if (error == B_OK) { if (error == B_OK) {
printf("Volume `%s' unmounted successfully.\n", name); printf("Volume `%s' unmounted successfully.\n", name.String());
} else { } else {
fprintf(stderr, "Failed to unmount volume `%s': %s\n", fprintf(stderr, "Failed to unmount volume `%s': %s\n",
name, strerror(error)); name.String(), strerror(error));
} }
} }
} }
@ -269,10 +269,10 @@ struct PrintPartitionsVisitor : public BDiskDeviceVisitor {
virtual bool Visit(BPartition* partition, int32 level) virtual bool Visit(BPartition* partition, int32 level)
{ {
// get name and type // get name and type
const char* name = partition->ContentName(); BString name = partition->ContentName();
if (name == NULL || name[0] == '\0') { if (name.IsEmpty()) {
name = partition->Name(); name = partition->Name();
if (name == NULL || name[0] == '\0') { if (name.IsEmpty()) {
if (partition->ContainsFileSystem()) if (partition->ContainsFileSystem())
name = "<unnamed>"; name = "<unnamed>";
else else
@ -301,7 +301,7 @@ struct PrintPartitionsVisitor : public BDiskDeviceVisitor {
if (partition->IsMounted()) if (partition->IsMounted())
partition->GetMountPoint(&mountPoint); partition->GetMountPoint(&mountPoint);
printf("%-*s %-*s %8s %s%s(%s)\n", sVolumeNameWidth, name, printf("%-*s %-*s %8s %s%s(%s)\n", sVolumeNameWidth, name.String(),
sFSNameWidth, type, size_string(partition->Size()), sFSNameWidth, type, size_string(partition->Size()),
partition->IsMounted() ? mountPoint.Path() : "", partition->IsMounted() ? mountPoint.Path() : "",
partition->IsMounted() ? " " : "", partition->IsMounted() ? " " : "",