From: Mateusz Moscicki Date: Fri, 31 Aug 2018 10:44:13 +0000 (+0200) Subject: Merge move_dump_dir() and move_info_file() X-Git-Tag: accepted/tizen/unified/20180917.041311~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=403dcf7bfaf147d74c62c23a6a0726aee65c44fe;p=platform%2Fcore%2Fsystem%2Fcrash-worker.git Merge move_dump_dir() and move_info_file() Change-Id: I246bf743eefb199577bd00d6b3fd0defa6948eff --- diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index cf6525e..3aa16d6 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -1133,43 +1133,23 @@ static void compress(struct crash_info *cinfo) _E("Failed to delete temp directory"); } -static void move_dump_dir(const struct crash_info *cinfo) +static void move_dump_data(const char *from_path, const struct crash_info *cinfo) { int lock_fd; if ((lock_fd = lock_dumpdir()) < 0) return; - if (!rename(cinfo->pfx, cinfo->result_path)) + if (!rename(from_path, cinfo->result_path)) clean_dump(); else _E("Failed to move %s to %s", - cinfo->pfx, cinfo->result_path); + from_path, cinfo->result_path); unlock_dumpdir(lock_fd); if (remove_dir(cinfo->temp_dir, 1) < 0) _E("Failed to delete temp directory"); } -static void move_info_file(struct crash_info *cinfo) -{ - int lock_fd; - - if ((lock_fd = lock_dumpdir()) < 0) - return; - - snprintf(cinfo->result_path, sizeof(cinfo->result_path), "%s/%s.info", - crash_crash_path, cinfo->name); - if (!rename(cinfo->info_path, cinfo->result_path)) - clean_dump(); - else - _E("Failed to move %s to %s", - cinfo->info_path, cinfo->result_path); - - unlock_dumpdir(lock_fd); - if (remove_dir(cinfo->temp_dir, 1) < 0) - _E("Failed to delete temp directory"); -} - static int wait_for_opt(unsigned int timeout) { unsigned int count = 0; @@ -1262,9 +1242,11 @@ int main(int argc, char *argv[]) if (allow_zip) compress(&cinfo); else - move_dump_dir(&cinfo); + move_dump_data(cinfo.pfx, &cinfo); } else { - move_info_file(&cinfo); + snprintf(cinfo.result_path, sizeof(cinfo.result_path), "%s/%s.info", + crash_crash_path, cinfo.name); + move_dump_data(cinfo.info_path, &cinfo); } /* launch crash-popup only if the .debugmode file is exist*/ if (debug_mode)