summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-08-31 12:44:13 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-09-05 09:31:34 +0200
commit403dcf7bfaf147d74c62c23a6a0726aee65c44fe (patch)
treedb6af21d598a02d3e5277d3d72fd023a72ea9222
parent35ef82f3738efc9872f5b6f926d47256a7fe38b2 (diff)
downloadcrash-worker-403dcf7bfaf147d74c62c23a6a0726aee65c44fe.tar.gz
crash-worker-403dcf7bfaf147d74c62c23a6a0726aee65c44fe.tar.bz2
crash-worker-403dcf7bfaf147d74c62c23a6a0726aee65c44fe.zip
Merge move_dump_dir() and move_info_file()
Change-Id: I246bf743eefb199577bd00d6b3fd0defa6948eff
-rw-r--r--src/crash-manager/crash-manager.c32
1 files changed, 7 insertions, 25 deletions
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)