Skip to content

Commit a72512c

Browse files
hopeminipattjin
authored andcommitted
Add O_CREAT option for open
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
1 parent f59b994 commit a72512c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

uncrypt/uncrypt.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ char* parse_recovery_command_file()
164164
if (f == NULL) {
165165
return NULL;
166166
}
167-
int fd = open(RECOVERY_COMMAND_FILE_TMP, O_WRONLY | O_SYNC);
167+
int fd = open(RECOVERY_COMMAND_FILE_TMP, O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR);
168+
if (fd < 0) {
169+
ALOGE("failed to open %s\n", RECOVERY_COMMAND_FILE_TMP);
170+
return NULL;
171+
}
168172
FILE* fo = fdopen(fd, "w");
169173

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

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

198206
ret = stat(path, &sb);

0 commit comments

Comments
 (0)