Disk Device Manager: checks the raw content_name when editing a partition
also only provide a default name for partition containing a file system fix #17958 Change-Id: Ib5a8928dc5272a400a99aa05b792201f3a6a2c7d Reviewed-on: https://review.haiku-os.org/c/haiku/+/5705 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
5b51027ca5
commit
e065d697fb
@ -54,6 +54,7 @@ public:
|
||||
|
||||
const char* Name() const;
|
||||
BString ContentName() const;
|
||||
const char* RawContentName() const;
|
||||
const char* Type() const; // See DiskDeviceTypes.h
|
||||
const char* ContentType() const; // See DiskDeviceTypes.h
|
||||
partition_id ID() const;
|
||||
|
@ -56,7 +56,7 @@ InitializeBFSEditor::SetTo(BPartition* partition)
|
||||
{
|
||||
BString name = partition->Name();
|
||||
if (name.IsEmpty())
|
||||
name = partition->ContentName();
|
||||
name = partition->RawContentName();
|
||||
if (!name.IsEmpty())
|
||||
fNameControl->SetText(name.String());
|
||||
off_t size = partition->Size();
|
||||
|
@ -54,7 +54,7 @@ InitializeBTRFSEditor::SetTo(BPartition* partition)
|
||||
{
|
||||
BString name = partition->Name();
|
||||
if (name.IsEmpty())
|
||||
name = partition->ContentName();
|
||||
name = partition->RawContentName();
|
||||
if (!name.IsEmpty())
|
||||
fNameControl->SetText(name.String());
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ InitializeFATEditor::SetTo(BPartition* partition)
|
||||
{
|
||||
BString name = partition->Name();
|
||||
if (name.IsEmpty())
|
||||
name = partition->ContentName();
|
||||
name = partition->RawContentName();
|
||||
if (!name.IsEmpty())
|
||||
fNameControl->SetText(name.String());
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ InitializeNTFSEditor::SetTo(BPartition* partition)
|
||||
{
|
||||
BString name = partition->Name();
|
||||
if (name.IsEmpty())
|
||||
name = partition->ContentName();
|
||||
name = partition->RawContentName();
|
||||
if (!name.IsEmpty())
|
||||
fNameControl->SetText(name.String());
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ dump_partition_info(const BPartition* partition)
|
||||
printf("\tIsBusy(): %s\n\n", partition->IsBusy() ? "true" : "false");
|
||||
printf("\tFlags(): %" B_PRIx32 "\n\n", partition->Flags());
|
||||
printf("\tName(): %s\n", partition->Name());
|
||||
printf("\tContentName(): %s\n", partition->ContentName().String());
|
||||
printf("\tContentName(): %s\n", partition->RawContentName());
|
||||
printf("\tType(): %s\n", partition->Type());
|
||||
printf("\tContentType(): %s\n", partition->ContentType());
|
||||
printf("\tID(): %" B_PRIx32 "\n\n", partition->ID());
|
||||
|
@ -434,7 +434,7 @@ DiskDeviceJobGenerator::_GenerateRemainingJobs(BPartition* parent,
|
||||
|
||||
// content name
|
||||
if ((changeFlags & B_PARTITION_CHANGED_NAME)
|
||||
|| compare_string(partition->ContentName(),
|
||||
|| compare_string(partition->RawContentName(),
|
||||
partitionData->content_name)) {
|
||||
status_t error = _GenerateSetContentNameJob(partition);
|
||||
if (error != B_OK)
|
||||
@ -506,7 +506,7 @@ DiskDeviceJobGenerator::_GenerateInitializeJob(BPartition* partition)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = job->Init(partition->ContentType(),
|
||||
partition->ContentName(), partition->ContentParameters());
|
||||
partition->RawContentName(), partition->ContentParameters());
|
||||
if (error != B_OK) {
|
||||
delete job;
|
||||
return error;
|
||||
@ -550,7 +550,7 @@ DiskDeviceJobGenerator::_GenerateSetContentNameJob(BPartition* partition)
|
||||
if (!job)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = job->Init(partition->ContentName(),
|
||||
error = job->Init(partition->RawContentName(),
|
||||
B_DISK_DEVICE_JOB_SET_CONTENT_NAME);
|
||||
if (error != B_OK) {
|
||||
delete job;
|
||||
|
@ -218,25 +218,6 @@ BMutablePartition::SetName(const char* name)
|
||||
BString
|
||||
BMutablePartition::ContentName() const
|
||||
{
|
||||
if (fData->content_name == NULL) {
|
||||
// Give a default name to unnamed volumes
|
||||
off_t divisor = 1ULL << 40;
|
||||
off_t diskSize = fData->content_size;
|
||||
char unit = 'T';
|
||||
if (diskSize < divisor) {
|
||||
divisor = 1UL << 30;
|
||||
unit = 'G';
|
||||
if (diskSize < divisor) {
|
||||
divisor = 1UL << 20;
|
||||
unit = 'M';
|
||||
}
|
||||
}
|
||||
double size = double((10 * diskSize + divisor - 1) / divisor);
|
||||
BString name;
|
||||
name.SetToFormat("%g %ciB %s volume", size / 10, unit, fData->content_type);
|
||||
return name;
|
||||
}
|
||||
|
||||
return fData->content_name;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,8 @@ BPartition::Name() const
|
||||
BString
|
||||
BPartition::ContentName() const
|
||||
{
|
||||
if (_PartitionData()->content_name == NULL) {
|
||||
if ((_PartitionData()->content_name == NULL || strlen(_PartitionData()->content_name) == 0)
|
||||
&& ContainsFileSystem()) {
|
||||
// Give a default name to unnamed volumes
|
||||
off_t divisor = 1ULL << 40;
|
||||
off_t diskSize = _PartitionData()->content_size;
|
||||
@ -284,6 +285,13 @@ BPartition::ContentName() const
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
BPartition::RawContentName() const
|
||||
{
|
||||
return _PartitionData()->content_name;
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Returns a human readable string for the type of the partition.
|
||||
\return A human readable string for the type of the partition.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user