From 509fc0d252641108f8bfccc5098f05040df58ac2 Mon Sep 17 00:00:00 2001
From: kushalsingh007 <kushal.spiderman.singh@gmail.com>
Date: Mon, 26 Jan 2015 08:47:32 +0530
Subject: [PATCH] * Previously intel add-on allowed creation of partition with
size > 2TB, now it allows partition size and offset to be less than 2TB
limit. * Made some conditions more readable and easier to understand. * Fixes
#8990
---
src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp
index d9c1450..e34a03b 100644
a
|
b
|
PartitionMapAddOn::CreatePartitionHandle(BMutablePartition* partition,
|
90 | 90 | bool |
91 | 91 | PartitionMapAddOn::CanInitialize(const BMutablePartition* partition) |
92 | 92 | { |
| 93 | const off_t kMBRLimit = ((off_t)1 <<32) * 512; |
| 94 | // Limit on size is (max_sector_count)*(sector size)=(2^32)*(512)=2TB. |
| 95 | |
93 | 96 | // If it's big enough, but not too big (ie. larger than 2^32 blocks) we can |
94 | | // initialize it. |
| 97 | // initialize it. Also, the highest offset of a partition should be lesser |
| 98 | // than 2TB. |
95 | 99 | return partition->Size() >= 2 * partition->BlockSize() |
96 | | && partition->Size() / partition->BlockSize() < UINT32_MAX; |
| 100 | && partition->Size() <= kMBRLimit |
| 101 | && partition->Offset() < kMBRLimit; |
97 | 102 | } |
98 | 103 | |
99 | 104 | |
… |
… |
status_t
|
101 | 106 | PartitionMapAddOn::ValidateInitialize(const BMutablePartition* partition, |
102 | 107 | BString* name, const char* parameters) |
103 | 108 | { |
104 | | if (!CanInitialize(partition) |
105 | | || (parameters != NULL && parameters[0] != '\0')) { |
| 109 | if ((!CanInitialize(partition)) |
| 110 | || (parameters == NULL) || (parameters[0] == '\0')) { |
106 | 111 | return B_BAD_VALUE; |
107 | 112 | } |
108 | 113 | |
… |
… |
status_t
|
118 | 123 | PartitionMapAddOn::Initialize(BMutablePartition* partition, const char* name, |
119 | 124 | const char* parameters, BPartitionHandle** _handle) |
120 | 125 | { |
121 | | if (!CanInitialize(partition) |
122 | | || (name != NULL && name[0] != '\0') |
123 | | || (parameters != NULL && parameters[0] != '\0')) { |
| 126 | if ((!CanInitialize(partition)) |
| 127 | || (name == NULL) || (name[0] == '\0') |
| 128 | || (parameters == NULL) || (parameters[0] == '\0')) { |
124 | 129 | return B_BAD_VALUE; |
125 | 130 | } |
126 | 131 | |