Support non-sequential partition index
Add support for the storage with non-sequential partition index
Ex: if using extended partition, the index of the partition will be greater than 5
[toddpoynor@google.com: fixup mPendingPartCount data type]
Change-Id: I5dbc870fbaac24045f5b994fcb899d5df73c6a55
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index 67f89ea..62c0560 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -38,7 +38,7 @@
mPaths = new PathCollection();
for (int i = 0; i < MAX_PARTITIONS; i++)
mPartMinors[i] = -1;
- mPendingPartMap = 0;
+ mPendingPartCount = 0;
mDiskMajor = -1;
mDiskMinor = -1;
mDiskNumParts = 0;
@@ -164,12 +164,9 @@
mDiskNumParts = 1;
}
- int partmask = 0;
- int i;
- for (i = 1; i <= mDiskNumParts; i++) {
- partmask |= (1 << i);
- }
- mPendingPartMap = partmask;
+ mPendingPartCount = mDiskNumParts;
+ for (int i = 0; i < MAX_PARTITIONS; i++)
+ mPartMinors[i] = -1;
if (mDiskNumParts == 0) {
#ifdef PARTITION_DEBUG
@@ -178,8 +175,7 @@
setState(Volume::State_Idle);
} else {
#ifdef PARTITION_DEBUG
- SLOGD("Dv::diskIns - waiting for %d partitions (mask 0x%x)",
- mDiskNumParts, mPendingPartMap);
+ SLOGD("Dv::diskIns - waiting for %d pending partitions", mPendingPartCount);
#endif
setState(Volume::State_Pending);
}
@@ -219,11 +215,12 @@
if (part_num >= MAX_PARTITIONS) {
SLOGE("Dv:partAdd: ignoring part_num = %d (max: %d)\n", part_num, MAX_PARTITIONS-1);
} else {
+ if ((mPartMinors[part_num - 1] == -1) && mPendingPartCount)
+ mPendingPartCount--;
mPartMinors[part_num -1] = minor;
}
- mPendingPartMap &= ~(1 << part_num);
- if (!mPendingPartMap) {
+ if (!mPendingPartCount) {
#ifdef PARTITION_DEBUG
SLOGD("Dv:partAdd: Got all partitions - ready to rock!");
#endif
@@ -236,7 +233,7 @@
}
} else {
#ifdef PARTITION_DEBUG
- SLOGD("Dv:partAdd: pending mask now = 0x%x", mPendingPartMap);
+ SLOGD("Dv:partAdd: pending %d disk", mPendingPartCount);
#endif
}
}
@@ -259,12 +256,9 @@
mDiskNumParts = 1;
}
- int partmask = 0;
- int i;
- for (i = 1; i <= mDiskNumParts; i++) {
- partmask |= (1 << i);
- }
- mPendingPartMap = partmask;
+ mPendingPartCount = mDiskNumParts;
+ for (int i = 0; i < MAX_PARTITIONS; i++)
+ mPartMinors[i] = -1;
if (getState() != Volume::State_Formatting) {
if (mDiskNumParts == 0) {
diff --git a/DirectVolume.h b/DirectVolume.h
index beda7c3..4495256 100644
--- a/DirectVolume.h
+++ b/DirectVolume.h
@@ -38,7 +38,7 @@
int mOrigDiskMinor;
int mOrigPartMinors[MAX_PARTITIONS];
int mDiskNumParts;
- unsigned int mPendingPartMap;
+ int mPendingPartCount;
int mIsDecrypted;
public: