am 8e5e4dad
: close update package before installing; allow remount
Merge commit '8e5e4dada713609c9b2c45ea9cf4572bb89ef761' into gingerbread-plus-aosp * commit '8e5e4dada713609c9b2c45ea9cf4572bb89ef761': close update package before installing; allow remount
This commit is contained in:
commit
858f0a763d
5 changed files with 17 additions and 3 deletions
|
@ -42,6 +42,7 @@ try_update_binary(const char *path, ZipArchive *zip) {
|
||||||
const ZipEntry* binary_entry =
|
const ZipEntry* binary_entry =
|
||||||
mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME);
|
mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME);
|
||||||
if (binary_entry == NULL) {
|
if (binary_entry == NULL) {
|
||||||
|
mzCloseZipArchive(zip);
|
||||||
return INSTALL_CORRUPT;
|
return INSTALL_CORRUPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +50,13 @@ try_update_binary(const char *path, ZipArchive *zip) {
|
||||||
unlink(binary);
|
unlink(binary);
|
||||||
int fd = creat(binary, 0755);
|
int fd = creat(binary, 0755);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
mzCloseZipArchive(zip);
|
||||||
LOGE("Can't make %s\n", binary);
|
LOGE("Can't make %s\n", binary);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd);
|
bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
mzCloseZipArchive(zip);
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGE("Can't copy %s\n", ASSUMED_UPDATE_BINARY_NAME);
|
LOGE("Can't copy %s\n", ASSUMED_UPDATE_BINARY_NAME);
|
||||||
|
@ -298,6 +301,5 @@ install_package(const char *root_path)
|
||||||
/* Verify and install the contents of the package.
|
/* Verify and install the contents of the package.
|
||||||
*/
|
*/
|
||||||
int status = handle_update_package(path, &zip);
|
int status = handle_update_package(path, &zip);
|
||||||
mzCloseZipArchive(&zip);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,3 +212,11 @@ unmount_mounted_volume(const MountedVolume *volume)
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
remount_read_only(const MountedVolume* volume)
|
||||||
|
{
|
||||||
|
return mount(volume->device, volume->mount_point, volume->filesystem,
|
||||||
|
MS_NOATIME | MS_NODEV | MS_NODIRATIME |
|
||||||
|
MS_RDONLY | MS_REMOUNT, 0);
|
||||||
|
}
|
||||||
|
|
|
@ -28,4 +28,6 @@ find_mounted_volume_by_mount_point(const char *mount_point);
|
||||||
|
|
||||||
int unmount_mounted_volume(const MountedVolume *volume);
|
int unmount_mounted_volume(const MountedVolume *volume);
|
||||||
|
|
||||||
|
int remount_read_only(const MountedVolume* volume);
|
||||||
|
|
||||||
#endif // MTDUTILS_MOUNTS_H_
|
#endif // MTDUTILS_MOUNTS_H_
|
||||||
|
|
|
@ -455,7 +455,7 @@ static int write_block(MtdWriteContext *ctx, const char *data)
|
||||||
if (retry > 0) {
|
if (retry > 0) {
|
||||||
fprintf(stderr, "mtd: wrote block after %d retries\n", retry);
|
fprintf(stderr, "mtd: wrote block after %d retries\n", retry);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "mtd: successfully wrote block at %x\n", pos);
|
fprintf(stderr, "mtd: successfully wrote block at %llx\n", pos);
|
||||||
return 0; // Success!
|
return 0; // Success!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,9 @@ int main(int argc, char** argv) {
|
||||||
free(result);
|
free(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
mzCloseZipArchive(&za);
|
if (updater_info.package_zip) {
|
||||||
|
mzCloseZipArchive(updater_info.package_zip);
|
||||||
|
}
|
||||||
free(script);
|
free(script);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue