am 37ad1f12: Merge "Force write to disk while doing uncrypt" into lmp-mr1-dev
* commit '37ad1f1273dd579b84317be6d1a9a27ad32af88c': Force write to disk while doing uncrypt
This commit is contained in:
+10
-5
@@ -164,7 +164,8 @@ char* parse_recovery_command_file()
|
|||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
FILE* fo = fopen(RECOVERY_COMMAND_FILE_TMP, "w");
|
int fd = open(RECOVERY_COMMAND_FILE_TMP, O_WRONLY | O_SYNC);
|
||||||
|
FILE* fo = fdopen(fd, "w");
|
||||||
|
|
||||||
while (fgets(temp, sizeof(temp), f)) {
|
while (fgets(temp, sizeof(temp), f)) {
|
||||||
printf("read: %s", temp);
|
printf("read: %s", temp);
|
||||||
@@ -175,6 +176,7 @@ char* parse_recovery_command_file()
|
|||||||
fputs(temp, fo);
|
fputs(temp, fo);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
fsync(fd);
|
||||||
fclose(fo);
|
fclose(fo);
|
||||||
|
|
||||||
if (fn) {
|
if (fn) {
|
||||||
@@ -190,7 +192,8 @@ int produce_block_map(const char* path, const char* map_file, const char* blk_de
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
FILE* mapf = fopen(map_file, "w");
|
int mapfd = open(map_file, O_WRONLY | O_SYNC);
|
||||||
|
FILE* mapf = fdopen(mapfd, "w");
|
||||||
|
|
||||||
ret = stat(path, &sb);
|
ret = stat(path, &sb);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
@@ -232,7 +235,7 @@ int produce_block_map(const char* path, const char* map_file, const char* blk_de
|
|||||||
|
|
||||||
int wfd = -1;
|
int wfd = -1;
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
wfd = open(blk_dev, O_WRONLY);
|
wfd = open(blk_dev, O_WRONLY | O_SYNC);
|
||||||
if (wfd < 0) {
|
if (wfd < 0) {
|
||||||
ALOGE("failed to open fd for writing: %s\n", strerror(errno));
|
ALOGE("failed to open fd for writing: %s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
@@ -302,9 +305,11 @@ int produce_block_map(const char* path, const char* map_file, const char* blk_de
|
|||||||
fprintf(mapf, "%d %d\n", ranges[i*2], ranges[i*2+1]);
|
fprintf(mapf, "%d %d\n", ranges[i*2], ranges[i*2+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fsync(mapfd);
|
||||||
fclose(mapf);
|
fclose(mapf);
|
||||||
close(fd);
|
close(fd);
|
||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
|
fsync(wfd);
|
||||||
close(wfd);
|
close(wfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +323,7 @@ void wipe_misc() {
|
|||||||
struct fstab_rec* v = &fstab->recs[i];
|
struct fstab_rec* v = &fstab->recs[i];
|
||||||
if (!v->mount_point) continue;
|
if (!v->mount_point) continue;
|
||||||
if (strcmp(v->mount_point, "/misc") == 0) {
|
if (strcmp(v->mount_point, "/misc") == 0) {
|
||||||
int fd = open(v->blk_device, O_WRONLY);
|
int fd = open(v->blk_device, O_WRONLY | O_SYNC);
|
||||||
uint8_t zeroes[1088]; // sizeof(bootloader_message) from recovery
|
uint8_t zeroes[1088]; // sizeof(bootloader_message) from recovery
|
||||||
memset(zeroes, 0, sizeof(zeroes));
|
memset(zeroes, 0, sizeof(zeroes));
|
||||||
|
|
||||||
@@ -333,7 +338,7 @@ void wipe_misc() {
|
|||||||
written += w;
|
written += w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fsync(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user