add diagnosis module 75/182575/2
authorJeonghoon Park <jh1979.park@samsung.com>
Tue, 26 Jun 2018 07:46:42 +0000 (16:46 +0900)
committerJeonghoon Park <jh1979.park@samsung.com>
Tue, 26 Jun 2018 07:53:30 +0000 (16:53 +0900)
Change-Id: I331e53ade273f089aae8e4834b779fa3686484b2

daemon/include/ttd-diag.h [new file with mode: 0644]
daemon/src/ttd-diag.c [new file with mode: 0644]

diff --git a/daemon/include/ttd-diag.h b/daemon/include/ttd-diag.h
new file mode 100644 (file)
index 0000000..3400e16
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TT_DAEMON_DIAG_H__
+#define __TT_DAEMON_DIAG_H__
+
+char *ttd_diag_collect_log_to_zip(void);
+
+#endif /* __TT_DAEMON_DIAG_H__ */
diff --git a/daemon/src/ttd-diag.c b/daemon/src/ttd-diag.c
new file mode 100644 (file)
index 0000000..a97474a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <stdio.h>
+#include <tzplatform_config.h>
+#include "ttd-log.h"
+#include "common-util.h"
+#include "ttd-zip.h"
+#include "ttd-diag.h"
+
+struct _ttd_diag_info_s {
+       char *log_file;
+       char *file_hash;
+};
+
+char *ttd_diag_collect_log_to_zip(void)
+{
+       const char  *zip_name = NULL;
+       char *tmp_name = NULL;
+       ttd_zip *zip = NULL;
+
+       /* TODO : The ID should be changed to TZ_SYS_TMP, after tizen config is ready */
+       enum tzplatform_variable id = TZ_SYS_VAR;
+
+       tmp_name = g_strdup_printf("log-%lld.zip", common_get_epoch_coarse_time());
+       retv_if(!tmp_name, NULL);
+
+       zip_name = tzplatform_mkpath(id, tmp_name);
+       g_free(tmp_name);
+       tmp_name = NULL;
+       retv_if(!zip_name, NULL);
+
+       zip = ttd_zip_open(zip_name);
+       retv_if(!zip, NULL);
+
+       /* TODO : get list of log files */
+       ttd_zip_append_file(zip, "/opt/var/log/ttd.log", "ttd.log");
+       ttd_zip_append_file(zip, "/opt/var/log/dlog", "dlog");
+
+       ttd_zip_close(zip);
+
+       return g_strdup(zip_name);
+}