summaryrefslogtreecommitdiffstats
path: root/applypatch/applypatch.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@google.com>2013-12-20 01:03:12 +0100
committerAndroid Git Automerger <android-git-automerger@android.com>2013-12-20 01:03:12 +0100
commite1bb2733f9261336f38a94dc9d93ed010a7cbc57 (patch)
tree3b45604e2661c722ec2adc8a64c5eb16e5c8d0f3 /applypatch/applypatch.c
parentam c87bab10: add the functions for multi-stage packages to updater (diff)
parentfix unnecessarily slow writing of EMMC partitions (diff)
downloadandroid_bootable_recovery-e1bb2733f9261336f38a94dc9d93ed010a7cbc57.tar
android_bootable_recovery-e1bb2733f9261336f38a94dc9d93ed010a7cbc57.tar.gz
android_bootable_recovery-e1bb2733f9261336f38a94dc9d93ed010a7cbc57.tar.bz2
android_bootable_recovery-e1bb2733f9261336f38a94dc9d93ed010a7cbc57.tar.lz
android_bootable_recovery-e1bb2733f9261336f38a94dc9d93ed010a7cbc57.tar.xz
android_bootable_recovery-e1bb2733f9261336f38a94dc9d93ed010a7cbc57.tar.zst
android_bootable_recovery-e1bb2733f9261336f38a94dc9d93ed010a7cbc57.zip
Diffstat (limited to 'applypatch/applypatch.c')
-rw-r--r--applypatch/applypatch.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c
index 6b8da2a8a..cb9bc2349 100644
--- a/applypatch/applypatch.c
+++ b/applypatch/applypatch.c
@@ -424,20 +424,18 @@ int WriteToPartition(unsigned char* data, size_t len,
{
size_t start = 0;
int success = 0;
- int fd = open(partition, O_RDWR | O_SYNC);
+ int fd = open(partition, O_RDWR);
if (fd < 0) {
printf("failed to open %s: %s\n", partition, strerror(errno));
return -1;
}
int attempt;
- for (attempt = 0; attempt < 10; ++attempt) {
- size_t next_sync = start + (1<<20);
- printf("raw O_SYNC write %s attempt %d start at %d\n", partition, attempt+1, start);
+ for (attempt = 0; attempt < 2; ++attempt) {
lseek(fd, start, SEEK_SET);
while (start < len) {
size_t to_write = len - start;
- if (to_write > 4096) to_write = 4096;
+ if (to_write > 1<<20) to_write = 1<<20;
ssize_t written = write(fd, data+start, to_write);
if (written < 0) {
@@ -450,10 +448,6 @@ int WriteToPartition(unsigned char* data, size_t len,
}
}
start += written;
- if (start >= next_sync) {
- fsync(fd);
- next_sync = start + (1<<20);
- }
}
fsync(fd);
@@ -506,8 +500,6 @@ int WriteToPartition(unsigned char* data, size_t len,
success = true;
break;
}
-
- sleep(2);
}
if (!success) {
@@ -519,11 +511,7 @@ int WriteToPartition(unsigned char* data, size_t len,
printf("error closing %s (%s)\n", partition, strerror(errno));
return -1;
}
- // hack: sync and sleep after closing in hopes of getting
- // the data actually onto flash.
- printf("sleeping after close\n");
sync();
- sleep(5);
break;
}
}