summaryrefslogtreecommitdiff
path: root/src/daemon/dlt_daemon_offline_logstorage.c
diff options
context:
space:
mode:
authorChristoph Lipka <clipka@jp.adit-jv.com>2016-03-16 16:05:53 +0900
committerGernot Wirschal <gernot.wirschal@bmw.de>2016-04-25 14:34:34 +0200
commitbc09757d465d4ee5728157dce4fed0f71841daa7 (patch)
treec65dbe20fe43dc36e480ca85b74b41aa812e5de2 /src/daemon/dlt_daemon_offline_logstorage.c
parentab443bc109f1d6a957fc5a85cd0efc566299bd4d (diff)
downloadDLT-daemon-bc09757d465d4ee5728157dce4fed0f71841daa7.tar.gz
Offline logstorage: On Demand triggering for syncing Logstorage cache and support long options
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com> Change-Id: I2bac5e48a5d210b544a96fe96dc322f28ac472fe
Diffstat (limited to 'src/daemon/dlt_daemon_offline_logstorage.c')
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage.c95
1 files changed, 93 insertions, 2 deletions
diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c
index a6d799e..6e245eb 100644
--- a/src/daemon/dlt_daemon_offline_logstorage.c
+++ b/src/daemon/dlt_daemon_offline_logstorage.c
@@ -521,7 +521,9 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
"Disable storage device\n");
/* DLT_OFFLINE_LOGSTORAGE_MAX_WRITE_ERRORS happened,
* therefore remove logstorage device */
- dlt_logstorage_device_disconnected(&(daemon->storage_handle[i]));
+ dlt_logstorage_device_disconnected(
+ &(daemon->storage_handle[i]),
+ DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
}
}
}
@@ -593,9 +595,98 @@ int dlt_daemon_logstorage_cleanup(DltDaemon *daemon,
if (daemon->storage_handle[i].connection_type ==
DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
{
- dlt_logstorage_device_disconnected(&daemon->storage_handle[i]);
+ dlt_logstorage_device_disconnected(
+ &daemon->storage_handle[i],
+ DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT);
}
}
return 0;
}
+
+int dlt_daemon_logstorage_sync_cache(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ char *mnt_point,
+ int verbose)
+{
+ int i = 0;
+ DltLogStorage *handle = NULL;
+
+ PRINT_FUNCTION_VERBOSE(verbose);
+
+ if (daemon == NULL || mnt_point == NULL)
+ {
+ return -1;
+ }
+
+ if (strlen(mnt_point) > 0) /* mount point is given */
+ {
+ handle = dlt_daemon_logstorage_get_device(daemon,
+ daemon_local,
+ mnt_point,
+ verbose);
+ if (handle == NULL)
+ {
+ return -1;
+ }
+ else
+ {
+ if (dlt_logstorage_sync_caches(handle) != 0)
+ {
+ return -1;
+ }
+ }
+ }
+ else /* sync caches for all connected logstorage devices */
+ {
+ for(i=0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
+ {
+ if (daemon->storage_handle[i].connection_type ==
+ DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+ {
+ if (dlt_logstorage_sync_caches(&daemon->storage_handle[i]) != 0)
+ {
+ return -1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+DltLogStorage *dlt_daemon_logstorage_get_device(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ char *mnt_point,
+ int verbose)
+{
+ int i = 0;
+ int len1 = 0;
+ int len2 = 0;
+
+ PRINT_FUNCTION_VERBOSE(verbose);
+
+ if (daemon == NULL || daemon_local == NULL || mnt_point == NULL)
+ {
+ return NULL;
+ }
+
+ len1 = strlen(mnt_point);
+
+ for(i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
+ {
+ len2 = strlen(daemon->storage_handle[i].device_mount_point);
+
+ /* Check if the requested device path is already used as log storage
+ * device. Check for strlen first, to avoid comparison errors when
+ * final '/' is given or not */
+ if (strncmp(daemon->storage_handle[i].device_mount_point,
+ mnt_point,
+ len1 > len2 ? len2 : len1) == 0)
+ {
+ return &daemon->storage_handle[i];
+ }
+ }
+
+ return NULL;
+}