From 92a86e3b45b494fe6cbb8bf0d1adbc0d9e5280d1 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 5 Aug 2020 14:52:26 +0900 Subject: [PATCH] Check RW mount Change-Id: Ie8fc9c7a7a4023d48c57b871d2a0366526388772 Signed-off-by: Jihoon Kim --- receiver/src/main.cpp | 7 +++++++ receiver/src/sticker_log.cpp | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index b874611..d8797dd 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -33,6 +33,8 @@ using namespace std; +static bool check_rw_mount(); + static bool app_create(void *data) { /* Hook to take necessary actions before main event loop starts @@ -40,6 +42,11 @@ static bool app_create(void *data) If this function returns true, the main loop of application starts If this function returns false, the application is terminated */ + if (!check_rw_mount()) { + service_app_exit(); + return true; + } + LOGD(""); char log_path[PATH_MAX]; diff --git a/receiver/src/sticker_log.cpp b/receiver/src/sticker_log.cpp index 1faffd5..8b9a3a7 100644 --- a/receiver/src/sticker_log.cpp +++ b/receiver/src/sticker_log.cpp @@ -42,10 +42,17 @@ void sticker_save_log(const char *fmt, ...) char *data_path = NULL; data_path = app_get_shared_data_path(); + if (!data_path) + return; + snprintf(log_path, sizeof(log_path), "%s/log", data_path); - if (data_path) + if (access(data_path, R_OK) != 0) { free(data_path); + return; + } + + free(data_path); int idx = 0; if (preference_get_int(LAST_LOG_FILE_INDEX, &idx) != PREFERENCE_ERROR_NONE) { -- 2.7.4