summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2010-09-14 21:34:03 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-14 21:34:03 -0700
commit4d8a1179833237be6871f7663c77cc3c50b25ff6 (patch)
tree63c2cade2edfc0dac4b0a22b9cd59d4627c7e4ee
parent9ae050c8f7a38985a026f0c58b73addd034b739d (diff)
parent867f8b454d754ff496b66527407753c451f54277 (diff)
downloadcommon-main.tar.gz
am 867f8b45: unmount cache before paving it over with the radio/hboot imageHEADandroid-sdk-tools_r12android-sdk-adt_r12mastermain
Merge commit '867f8b454d754ff496b66527407753c451f54277' into gingerbread-plus-aosp * commit '867f8b454d754ff496b66527407753c451f54277': unmount cache before paving it over with the radio/hboot image
-rw-r--r--updater/recovery_updater.c37
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 ||