summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Tolvanen <samitolvanen@google.com>2015-06-10 23:50:03 +0200
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-10 23:50:03 +0200
commitd7c9bf41daa865ca016dee12a68282ba457c31fb (patch)
treef445696802ff01a687af0ce8efc34e06dc47a927
parentSplit WipeData into PreWipeData and PostWipeData. (diff)
parentZero blocks before BLKDISCARD (diff)
downloadandroid_bootable_recovery-d7c9bf41daa865ca016dee12a68282ba457c31fb.tar
android_bootable_recovery-d7c9bf41daa865ca016dee12a68282ba457c31fb.tar.gz
android_bootable_recovery-d7c9bf41daa865ca016dee12a68282ba457c31fb.tar.bz2
android_bootable_recovery-d7c9bf41daa865ca016dee12a68282ba457c31fb.tar.lz
android_bootable_recovery-d7c9bf41daa865ca016dee12a68282ba457c31fb.tar.xz
android_bootable_recovery-d7c9bf41daa865ca016dee12a68282ba457c31fb.tar.zst
android_bootable_recovery-d7c9bf41daa865ca016dee12a68282ba457c31fb.zip
-rw-r--r--updater/blockimg.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/updater/blockimg.c b/updater/blockimg.c
index 7b8721dbf..e18480062 100644
--- a/updater/blockimg.c
+++ b/updater/blockimg.c
@@ -1404,6 +1404,7 @@ pcdout:
static int PerformCommandErase(CommandParameters* params) {
char* range = NULL;
int i;
+ int j;
int rc = -1;
RangeSet* tgt = NULL;
struct stat st;
@@ -1430,7 +1431,7 @@ static int PerformCommandErase(CommandParameters* params) {
range = strtok_r(NULL, " ", &params->cpos);
if (range == NULL) {
- fprintf(stderr, "missing target blocks for zero\n");
+ fprintf(stderr, "missing target blocks for erase\n");
goto pceout;
}
@@ -1439,7 +1440,22 @@ static int PerformCommandErase(CommandParameters* params) {
if (params->canwrite) {
fprintf(stderr, " erasing %d blocks\n", tgt->size);
+ allocate(BLOCKSIZE, &params->buffer, &params->bufsize);
+ memset(params->buffer, 0, BLOCKSIZE);
+
for (i = 0; i < tgt->count; ++i) {
+ // Always zero the blocks first to work around possibly flaky BLKDISCARD
+ // Bug: 20881595
+ if (!check_lseek(params->fd, (off64_t) tgt->pos[i * 2] * BLOCKSIZE, SEEK_SET)) {
+ goto pceout;
+ }
+
+ for (j = tgt->pos[i * 2]; j < tgt->pos[i * 2 + 1]; ++j) {
+ if (write_all(params->fd, params->buffer, BLOCKSIZE) == -1) {
+ goto pceout;
+ }
+ }
+
// offset in bytes
blocks[0] = tgt->pos[i * 2] * (uint64_t) BLOCKSIZE;
// length in bytes