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
This commit is contained in:
parent
89ec37fcdd
commit
b31f33b5e4
2 changed files with 13 additions and 19 deletions
|
@ -38,7 +38,7 @@ DirectVolume::DirectVolume(VolumeManager *vm, const fstab_rec* rec, int flags) :
|
|||
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 @@ void DirectVolume::handleDiskAdded(const char * /*devpath*/,
|
|||
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 @@ void DirectVolume::handleDiskAdded(const char * /*devpath*/,
|
|||
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 @@ void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt)
|
|||
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 @@ void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt)
|
|||
}
|
||||
} 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 @@ void DirectVolume::handleDiskChanged(const char * /*devpath*/,
|
|||
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) {
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
int mOrigDiskMinor;
|
||||
int mOrigPartMinors[MAX_PARTITIONS];
|
||||
int mDiskNumParts;
|
||||
unsigned int mPendingPartMap;
|
||||
int mPendingPartCount;
|
||||
int mIsDecrypted;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue