From f332e26062bf4ff4b83e0a3cd7a5ad8bdc8253e8 Mon Sep 17 00:00:00 2001
From: kushalsingh007 <kushal.spiderman.singh@gmail.com>
Date: Sun, 25 Jan 2015 18:51:44 +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. * Fixed minor overflow condition and operator precedence issue with
Logical NOT. * Fixes #8990
---
src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp
index d9c1450..1edaecd 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 <<41; //2TB is the limit on the max size. |
| 94 | |
93 | 95 | // If it's big enough, but not too big (ie. larger than 2^32 blocks) we can |
94 | | // initialize it. |
| 96 | // initialize it. Also, the highest offset of a partition should be lesser |
| 97 | // than 2TB. |
95 | 98 | return partition->Size() >= 2 * partition->BlockSize() |
96 | | && partition->Size() / partition->BlockSize() < UINT32_MAX; |
| 99 | && partition->Size() <= kMBRLimit |
| 100 | && partition->Offset() < kMBRLimit; |
97 | 101 | } |
98 | 102 | |
99 | 103 | |
… |
… |
status_t
|
101 | 105 | PartitionMapAddOn::ValidateInitialize(const BMutablePartition* partition, |
102 | 106 | BString* name, const char* parameters) |
103 | 107 | { |
104 | | if (!CanInitialize(partition) |
105 | | || (parameters != NULL && parameters[0] != '\0')) { |
| 108 | if (!(CanInitialize(partition) |
| 109 | || (parameters != NULL && parameters[0] != '\0'))) { |
106 | 110 | return B_BAD_VALUE; |
107 | 111 | } |
108 | 112 | |
… |
… |
status_t
|
118 | 122 | PartitionMapAddOn::Initialize(BMutablePartition* partition, const char* name, |
119 | 123 | const char* parameters, BPartitionHandle** _handle) |
120 | 124 | { |
121 | | if (!CanInitialize(partition) |
| 125 | if (!(CanInitialize(partition) |
122 | 126 | || (name != NULL && name[0] != '\0') |
123 | | || (parameters != NULL && parameters[0] != '\0')) { |
| 127 | || (parameters != NULL && parameters[0] != '\0'))) { |
124 | 128 | return B_BAD_VALUE; |
125 | 129 | } |
126 | 130 | |