Fix resizeAsec to determine correct size
This fixes an eror where resizeAsec would attempt to read from the superblock struct before initializing it. Bug: 28292918 Change-Id: Ic6804e97e7c83bcedfb682a187b8d5e0e1bc51f9
This commit is contained in:
parent
e8167afe55
commit
e4c291a1ee
1 changed files with 16 additions and 18 deletions
|
@ -1007,24 +1007,6 @@ int VolumeManager::resizeAsec(const char *id, unsigned long numSectors, const ch
|
|||
|
||||
oldNumSec = info.st_size / 512;
|
||||
|
||||
unsigned long numImgSectors;
|
||||
if (sb.c_opts & ASEC_SB_C_OPTS_EXT4)
|
||||
numImgSectors = adjustSectorNumExt4(numSectors);
|
||||
else
|
||||
numImgSectors = adjustSectorNumFAT(numSectors);
|
||||
/*
|
||||
* add one block for the superblock
|
||||
*/
|
||||
SLOGD("Resizing from %lu sectors to %lu sectors", oldNumSec, numImgSectors + 1);
|
||||
if (oldNumSec == numImgSectors + 1) {
|
||||
SLOGW("Size unchanged; ignoring resize request");
|
||||
return 0;
|
||||
} else if (oldNumSec > numImgSectors + 1) {
|
||||
SLOGE("Only growing is currently supported.");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to read superblock.
|
||||
*/
|
||||
|
@ -1050,10 +1032,26 @@ int VolumeManager::resizeAsec(const char *id, unsigned long numSectors, const ch
|
|||
return -1;
|
||||
}
|
||||
|
||||
unsigned long numImgSectors;
|
||||
if (!(sb.c_opts & ASEC_SB_C_OPTS_EXT4)) {
|
||||
SLOGE("Only ext4 partitions are supported for resize");
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
} else {
|
||||
numImgSectors = adjustSectorNumExt4(numSectors);
|
||||
}
|
||||
|
||||
/*
|
||||
* add one block for the superblock
|
||||
*/
|
||||
SLOGD("Resizing from %lu sectors to %lu sectors", oldNumSec, numImgSectors + 1);
|
||||
if (oldNumSec == numImgSectors + 1) {
|
||||
SLOGW("Size unchanged; ignoring resize request");
|
||||
return 0;
|
||||
} else if (oldNumSec > numImgSectors + 1) {
|
||||
SLOGE("Only growing is currently supported.");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (Loop::resizeImageFile(asecFileName, numImgSectors + 1)) {
|
||||
|
|
Loading…
Reference in a new issue