#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <urcu/list.h>
#include "lttngerr.h"
}
}
-/*
- * find_session_by_uuid
- *
- * Return a ltt_session structure ptr that matches the uuid.
- */
-struct ltt_session *find_session_by_uuid(uuid_t session_id)
-{
- int found = 0;
- struct ltt_session *iter;
-
- /* Sanity check for NULL session_id */
- if (uuid_is_null(session_id)) {
- goto end;
- }
-
- cds_list_for_each_entry(iter, <t_session_list.head, list) {
- if (uuid_compare(iter->uuid, session_id) == 0) {
- found = 1;
- break;
- }
- }
-
-end:
- if (!found) {
- iter = NULL;
- }
- return iter;
-}
-
/*
* find_session_by_name
*
int create_session(char *name, char *path)
{
int ret;
+ char date_time[NAME_MAX];
struct ltt_session *new_session;
-
- DBG("Creating session %s at %s", name, path);
+ time_t rawtime;
+ struct tm *timeinfo;
new_session = find_session_by_name(name);
if (new_session != NULL) {
/* Define session system path */
if (path != NULL) {
- if (asprintf(&new_session->path, "%s", path) < 0) {
+ if (strstr(name, "auto-") == NULL) {
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+ strftime(date_time, sizeof(date_time), "-%Y%m%d-%H%M%S", timeinfo);
+ } else {
+ date_time[0] = '\0';
+ }
+
+ if (asprintf(&new_session->path, "%s/%s%s", path, name, date_time) < 0) {
ret = -ENOMEM;
goto error_asprintf;
}
goto error;
}
- /* UUID generation */
- uuid_generate(new_session->uuid);
-
/*
* Set consumer (identifier) to 0. This means that there is
* NO consumer attach to that session yet.
/* Init kernel session */
new_session->kernel_session = NULL;
- new_session->kern_session_count = 0;
/* Init list */
CDS_INIT_LIST_HEAD(&new_session->ust_traces);
/* Add new session to the global session list */
add_session_list(new_session);
+ DBG("Tracing session %s created in %s", name, new_session->path);
+
return 0;
error: