Skip to content

Commit

Permalink
Add O_CREAT option for open
Browse files Browse the repository at this point in the history
Factory reset fails if there is no file, for example, RECOVERY_COMMAND_FILE_TMP.
So create file as adding O_CREAT option if it does not exist.

error log:
--------- beginning of crash
12-10 02:35:17.190  3059  3059 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x30 in tid 3059 (uncrypt)
12-10 02:35:17.296   766  1528 W NativeCrashListener: Couldn't find ProcessRecord for pid 3059
12-10 02:35:17.296   191   191 I DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-10 02:35:17.296   191   191 E DEBUG   : AM write failure (32 / Broken pipe)
12-10 02:35:17.296   191   191 I DEBUG   : Build fingerprint: 'Android/aosp_hammerhead/hammerhead:5.1/LMP/hopemini12052127:userdebug/test-keys'
12-10 02:35:17.296   191   191 I DEBUG   : Revision: '10'
12-10 02:35:17.297   191   191 I DEBUG   : ABI: 'arm'
12-10 02:35:17.297   191   191 I DEBUG   : pid: 3059, tid: 3059, name: uncrypt  >>> /system/bin/uncrypt <<<
12-10 02:35:17.297   191   191 I DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x30
12-10 02:35:17.302   191   191 I DEBUG   :     r0 00000001  r1 be94b690  r2 fffffe90  r3 b6fdbf7c
12-10 02:35:17.302   191   191 I DEBUG   :     r4 00000000  r5 00000000  r6 b6fd8ca4  r7 be94b67c
12-10 02:35:17.302   191   191 I DEBUG   :     r8 00000000  r9 ffffffff  sl b6ff582b  fp be94b68d
12-10 02:35:17.302   191   191 I DEBUG   :     ip b6fcfd08  sp be94b648  lr b6f98fe5  pc b6f98fe4  cpsr 20070030
12-10 02:35:17.303   191   191 I DEBUG   :
12-10 02:35:17.303   191   191 I DEBUG   : backtrace:
12-10 02:35:17.303   191   191 I DEBUG   :     #00 pc 00032fe4  /system/lib/libc.so (fputs+29)
12-10 02:35:17.303   191   191 I DEBUG   :     #1 pc 000016a1  /system/bin/uncrypt
12-10 02:35:17.303   191   191 I DEBUG   :     Hashcode#2 pc 0000114b  /system/bin/uncrypt
12-10 02:35:17.303   191   191 I DEBUG   :     Hashcode#3 pc 00012df5  /system/lib/libc.so (__libc_init+44)
12-10 02:35:17.303   191   191 I DEBUG   :     CyanogenMod#4 pc 000013cc  /system/bin/uncrypt
12-10 02:35:17.325   191   191 I DEBUG   :
12-10 02:35:17.325   191   191 I DEBUG   : Tombstone written to: /data/tombstones/tombstone_00

Bug: 18709330
Change-Id: Ib5dccdd366e829049938a188ea5f98d9e4e282db
  • Loading branch information
hopemini authored and pattjin committed Dec 11, 2014
1 parent f59b994 commit a72512c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions uncrypt/uncrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ char* parse_recovery_command_file()
if (f == NULL) {
return NULL;
}
int fd = open(RECOVERY_COMMAND_FILE_TMP, O_WRONLY | O_SYNC);
int fd = open(RECOVERY_COMMAND_FILE_TMP, O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
ALOGE("failed to open %s\n", RECOVERY_COMMAND_FILE_TMP);
return NULL;
}
FILE* fo = fdopen(fd, "w");

while (fgets(temp, sizeof(temp), f)) {
Expand Down Expand Up @@ -192,7 +196,11 @@ int produce_block_map(const char* path, const char* map_file, const char* blk_de
struct stat sb;
int ret;

int mapfd = open(map_file, O_WRONLY | O_SYNC);
int mapfd = open(map_file, O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
if (mapfd < 0) {
ALOGE("failed to open %s\n", map_file);
return -1;
}
FILE* mapf = fdopen(mapfd, "w");

ret = stat(path, &sb);
Expand Down

0 comments on commit a72512c

Please sign in to comment.