[87711] Resolve the issue of log loss after reboot device
Change-Id: I9690d2a2c5e844e67ffa825e9febbd0c22388756
diff --git a/mbtk/mbtk_logd/syslog_read.c b/mbtk/mbtk_logd/syslog_read.c
index 3bca900..db30d57 100755
--- a/mbtk/mbtk_logd/syslog_read.c
+++ b/mbtk/mbtk_logd/syslog_read.c
@@ -177,7 +177,11 @@
time_t t;
char *c, *m;
- sprintf(tmp_buf, "/tmp/log%s", strstr_tail(log_file, "/"));
+ //
+ //sprintf(tmp_buf, "/tmp/log%s", strstr_tail(log_file, "/"));
+
+
+ snprintf(tmp_buf,sizeof(tmp_buf), "%s", log_file);
if(access(tmp_buf, W_OK) != 0)
{
sender.fd = open(tmp_buf, O_CREAT | O_WRONLY | O_APPEND, 0600);
@@ -549,7 +553,11 @@
} else if (strlen(log_file) > 0) {
log_type = LOG_FILE;
// 先将文件保存到 /tmp/log/ 目录下,后面到达 rotate_file_size 后,转移到out_path
- sprintf(tmp_log, "/tmp/log%s", strstr_tail(log_file, "/"));
+
+ //sprintf(tmp_log, "/tmp/log%s", strstr_tail(log_file, "/"));
+
+ //直接将log文件存储在不会掉电丢失的路径
+ snprintf(tmp_log,sizeof(tmp_log), "%s",log_file);
sender.fd = open(tmp_log, O_CREAT | O_WRONLY| O_APPEND, 0600);
if (sender.fd < 0) {
fprintf(stderr, "failed to open %s: %s\n", tmp_log, strerror(errno));