- Adds parameters column to DriveSetup.

- Parse and display "active" parameter. Fixes ticket: #4417
- Removes const declaration in PartitionMap::Check.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38987 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Bryce Groff 2010-10-17 09:41:36 +00:00
parent 5a695bce10
commit 9494bb5b15
2 changed files with 34 additions and 11 deletions

View File

@ -805,15 +805,15 @@ PartitionMap::Check(off_t sessionSize) const
// 2. check overlapping of partitions and location of partition tables
bool result = true;
const Partition** byOffset = new(nothrow) const Partition*[partitionCount];
Partition** byOffset = new(nothrow) Partition*[partitionCount];
off_t* tableOffsets = new(nothrow) off_t[partitionCount - 3];
if (byOffset && tableOffsets) {
// fill the arrays
int32 byOffsetCount = 0;
int32 tableOffsetCount = 1; // primary partition table
tableOffsets[0] = 0; //
tableOffsets[0] = 0;
for (int32 i = 0; i < partitionCount; i++) {
const Partition* partition = PartitionAt(i);
Partition* partition = (Partition*)PartitionAt(i);
if (!partition->IsExtended())
byOffset[byOffsetCount++] = partition;
@ -825,23 +825,23 @@ PartitionMap::Check(off_t sessionSize) const
}
// sort the arrays
qsort(byOffset, byOffsetCount, sizeof(const Partition*),
qsort(byOffset, byOffsetCount, sizeof(Partition*),
cmp_partition_offset);
qsort(tableOffsets, tableOffsetCount, sizeof(off_t), cmp_offset);
// check for overlappings
off_t nextOffset = 0;
for (int32 i = 0; i < byOffsetCount; i++) {
const Partition* partition = byOffset[i];
Partition* partition = byOffset[i];
if (partition->Offset() < nextOffset && i > 0) {
Partition* previousPartition = (Partition*)byOffset[i - 1];
Partition* previousPartition = byOffset[i - 1];
off_t previousSize = previousPartition->Size()
- (nextOffset - partition->Offset());
TRACE(("intel: PartitionMap::Check(): "));
if (previousSize == 0) {
previousPartition->Unset();
TRACE(("partition offset hides previous partition."
" Removing previous partition from disk layout.\n"));
" Removing previous partition from disk layout.\n"));
} else {
TRACE(("overlapping partitions! Setting partition %ld "
"size to %lld\n", i - 1, previousSize));
@ -860,8 +860,8 @@ PartitionMap::Check(off_t sessionSize) const
"for different extended partitions!\n"));
result = false;
break;
} else if (is_inside_partitions(tableOffsets[i], byOffset,
byOffsetCount)) {
} else if (is_inside_partitions(tableOffsets[i],
(const Partition**)byOffset, byOffsetCount)) {
TRACE(("intel: PartitionMap::Check(): a partition table "
"lies inside a non-extended partition!\n"));
result = false;

View File

@ -15,6 +15,8 @@
#include <Locale.h>
#include <Path.h>
#include <driver_settings.h>
#include "Support.h"
@ -184,7 +186,8 @@ enum {
kFilesystemColumn,
kVolumeNameColumn,
kMountedAtColumn,
kSizeColumn
kSizeColumn,
kParametersColumn
};
@ -223,7 +226,7 @@ PartitionListRow::PartitionListRow(BPartition* partition)
}
if (partition->IsMounted() && partition->GetMountPoint(&path) == B_OK) {
SetField(new BStringField(path.Path()), kMountedAtColumn);
SetField(new BStringField(path.Path()), kMountedAtColumn);
} else {
SetField(new BStringField(kUnavailableString), kMountedAtColumn);
}
@ -231,6 +234,24 @@ PartitionListRow::PartitionListRow(BPartition* partition)
char size[1024];
SetField(new BStringField(string_for_size(partition->Size(), size,
sizeof(size))), kSizeColumn);
if (partition->Parameters() != NULL) {
BString parameters;
// check parameters
void* handle = parse_driver_settings_string(partition->Parameters());
if (handle != NULL) {
bool active = get_driver_boolean_parameter(handle, "active", false, true);
if (active)
parameters += "Active";
delete_driver_settings(handle);
}
SetField(new BStringField(parameters), kParametersColumn);
} else {
SetField(new BStringField(kUnavailableString), kParametersColumn);
}
}
@ -273,6 +294,8 @@ PartitionListView::PartitionListView(const BRect& frame, uint32 resizeMode)
B_TRUNCATE_MIDDLE), kMountedAtColumn);
AddColumn(new PartitionColumn(B_TRANSLATE("Size"), 100, 50, 500,
B_TRUNCATE_END, B_ALIGN_RIGHT), kSizeColumn);
AddColumn(new PartitionColumn(B_TRANSLATE("Parameters"), 150, 50, 500,
B_TRUNCATE_MIDDLE), kParametersColumn);
SetSortingEnabled(false);
}