[haiku-commits] r38987 - in haiku/trunk/src: add-ons/kernel/partitioning_systems/intel apps/drivesetup

  • From: bgroff@xxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 17 Oct 2010 11:41:36 +0200 (CEST)

Author: bgroff
Date: 2010-10-17 11:41:36 +0200 (Sun, 17 Oct 2010)
New Revision: 38987
Changeset: http://dev.haiku-os.org/changeset/38987
Ticket: http://dev.haiku-os.org/ticket/4417

Modified:
   haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp
   haiku/trunk/src/apps/drivesetup/PartitionList.cpp
Log:
- Adds parameters column to DriveSetup.
- Parse and display "active" parameter. Fixes ticket: #4417
- Removes const declaration in PartitionMap::Check.


Modified: 
haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp  
2010-10-16 19:56:34 UTC (rev 38986)
+++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp  
2010-10-17 09:41:36 UTC (rev 38987)
@@ -805,15 +805,15 @@
 
        // 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 @@
                }
 
                // 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 @@
                                                "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;

Modified: haiku/trunk/src/apps/drivesetup/PartitionList.cpp
===================================================================
--- haiku/trunk/src/apps/drivesetup/PartitionList.cpp   2010-10-16 19:56:34 UTC 
(rev 38986)
+++ haiku/trunk/src/apps/drivesetup/PartitionList.cpp   2010-10-17 09:41:36 UTC 
(rev 38987)
@@ -15,6 +15,8 @@
 #include <Locale.h>
 #include <Path.h>
 
+#include <driver_settings.h>
+
 #include "Support.h"
 
 
@@ -184,7 +186,8 @@
        kFilesystemColumn,
        kVolumeNameColumn,
        kMountedAtColumn,
-       kSizeColumn
+       kSizeColumn,
+       kParametersColumn
 };
 
 
@@ -223,7 +226,7 @@
        }
 
        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 @@
        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 @@
                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);
 }


Other related posts:

  • » [haiku-commits] r38987 - in haiku/trunk/src: add-ons/kernel/partitioning_systems/intel apps/drivesetup - bgroff