diff options
author | Doug Zongker <dougz@android.com> | 2010-09-14 18:10:18 -0700 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2010-09-14 21:27:37 -0700 |
commit | 867f8b454d754ff496b66527407753c451f54277 (patch) | |
tree | 63c2cade2edfc0dac4b0a22b9cd59d4627c7e4ee | |
parent | dc0f94be051feef01f0cd62bf9facdef052178ad (diff) | |
download | common-867f8b454d754ff496b66527407753c451f54277.tar.gz |
unmount cache before paving it over with the radio/hboot imageandroid-sdk-2.3.4_r1android-cts-2.3_r5android-cts-2.3_r4android-cts-2.3_r3android-cts-2.3_r2android-cts-2.3_r12android-cts-2.3_r11android-cts-2.3_r10android-cts-2.3_r1android-2.3_r1android-2.3.7_r1android-2.3.6_r1android-2.3.6_r0.9android-2.3.5_r1android-2.3.4_r1android-2.3.4_r0.9android-2.3.3_r1aandroid-2.3.3_r1.1android-2.3.3_r1android-2.3.2_r1android-2.3.1_r1gingerbread-releasegingerbread-mr4-releasegingerbread
Try to unmount the cache. If that fails, try to remount it read-only
and sync (which isn't as safe but is better than leaving it r/w). If
we can't even do that, abort the firmware installation.
Change-Id: I2ebb1ebf3d1f58270133c58b0e9337fb33d78dfa
-rw-r--r-- | updater/recovery_updater.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/updater/recovery_updater.c b/updater/recovery_updater.c index d382f96..b7df23a 100644 --- a/updater/recovery_updater.c +++ b/updater/recovery_updater.c @@ -14,16 +14,20 @@ * limitations under the License. */ -#include <stdio.h> #include <errno.h> #include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <unistd.h> -#include "mincrypt/sha.h" #include "edify/expr.h" #include "firmware.h" +#include "mincrypt/sha.h" +#include "minzip/Zip.h" +#include "mtdutils/mounts.h" +#include "updater/updater.h" Value* UpdateFn(const char* name, State* state, int argc, Expr* argv[]) { if (argc != 7) { @@ -50,6 +54,35 @@ Value* UpdateFn(const char* name, State* state, int argc, Expr* argv[]) { return NULL; } + // close the package + ZipArchive* za = ((UpdaterInfo*)(state->cookie))->package_zip; + mzCloseZipArchive(za); + ((UpdaterInfo*)(state->cookie))->package_zip = NULL; + + // Try to unmount /cache. If we fail (because we're running in an + // older recovery that still has the package file open), try to + // remount it read-only. If that fails, abort. + sync(); + scan_mounted_volumes(); + MountedVolume* vol = find_mounted_volume_by_mount_point("/cache"); + int result = unmount_mounted_volume(vol); + if (result != 0) { + printf("%s(): failed to unmount cache (%d: %s)\n", + name, result, strerror(errno)); + + result = remount_read_only(vol); + if (result != 0) { + printf("%s(): failed to remount cache (%d: %s)\n", + name, result, strerror(errno)); + return StringValue(strdup("")); + } else { + printf("%s(): remounted cache\n", name); + } + sync(); + } else { + printf("%s(): unmounted cache\n", name); + } + int width = 0, height = 0, bpp = 0; if (width_string->type != VAL_STRING || |