summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lipka <clipka@jp.adit-jv.com>2015-11-26 11:12:56 +0900
committerLutz Helwing <lutz_helwing@mentor.com>2015-12-07 10:07:26 +0100
commit86fa115e9e49541b9e15813c33e9940065e2d6e1 (patch)
tree1cd2a56b9b57289b926b74ec927c9a0583f6a19f
parentf817bdaf8b45c8fb11280b572565475eeee5ed73 (diff)
downloadDLT-daemon-86fa115e9e49541b9e15813c33e9940065e2d6e1.tar.gz
Logstorage: Check if given path is writable in logstorage control application
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
-rw-r--r--src/console/logstorage/dlt-logstorage-common.c23
-rw-r--r--src/console/logstorage/dlt-logstorage-common.h8
-rw-r--r--src/console/logstorage/dlt-logstorage-ctrl.c6
3 files changed, 37 insertions, 0 deletions
diff --git a/src/console/logstorage/dlt-logstorage-common.c b/src/console/logstorage/dlt-logstorage-common.c
index a2f60a0..592da25 100644
--- a/src/console/logstorage/dlt-logstorage-common.c
+++ b/src/console/logstorage/dlt-logstorage-common.c
@@ -58,6 +58,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -234,6 +235,28 @@ int dlt_logstorage_check_config_file(char *mnt_point)
return ret;
}
+/** @brief Check if given mount point is writable
+ *
+ * @param mnt_point The mount point to check
+ *
+ * @return 1 if the file is writable, 0 otherwise.
+ */
+int dlt_logstorage_check_directory_permission(char *mnt_point)
+{
+ if (mnt_point == NULL)
+ {
+ pr_error("Given mount point is NULL\n");
+ return 0;
+ }
+
+ if (access(mnt_point, W_OK) == 0)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
/** @brief Prepares the body of the message to be send to DLT
*
* @param body A pointer to the MsgBody structure pointer
diff --git a/src/console/logstorage/dlt-logstorage-common.h b/src/console/logstorage/dlt-logstorage-common.h
index 712f2e3..a1c0994 100644
--- a/src/console/logstorage/dlt-logstorage-common.h
+++ b/src/console/logstorage/dlt-logstorage-common.h
@@ -80,4 +80,12 @@ int dlt_logstorage_send_event(int, char *);
*/
int dlt_logstorage_check_config_file(char *);
+/** @brief Check if given mount point is writable
+ *
+ * @param mnt_point The mount point to check
+ *
+ * @return 1 if the file is writable, 0 otherwise.
+ */
+int dlt_logstorage_check_directory_permission(char *mnt_point);
+
#endif
diff --git a/src/console/logstorage/dlt-logstorage-ctrl.c b/src/console/logstorage/dlt-logstorage-ctrl.c
index b4d2b92..b213501 100644
--- a/src/console/logstorage/dlt-logstorage-ctrl.c
+++ b/src/console/logstorage/dlt-logstorage-ctrl.c
@@ -374,6 +374,12 @@ static int dlt_logstorage_ctrl_single_request()
return -1;
}
+ if (!dlt_logstorage_check_directory_permission(get_default_path()))
+ {
+ pr_error("'%s' is not writable\n", get_default_path());
+ return -1;
+ }
+
/* Initializing the communication with the daemon */
while (dlt_control_init(analyze_response, get_ecuid(), get_verbosity()) &&
!dlt_logstorage_must_exit())