* Add a ltt_session structure to the global list.
*
* The caller MUST acquire the session list lock before.
+ * Returns the unique identifier for the session.
*/
-static void add_session_list(struct ltt_session *ls)
+static int add_session_list(struct ltt_session *ls)
{
cds_list_add(&ls->list, <t_session_list.head);
- ltt_session_list.count++;
+ return ++ltt_session_list.count;
}
/*
/*
* Create a brand new session and add it to the session list.
*/
-int session_create(char *name, char *path)
+int session_create(char *name, char *path, uid_t uid, gid_t gid)
{
int ret;
struct ltt_session *new_session;
}
/* Allocate session data structure */
- new_session = malloc(sizeof(struct ltt_session));
+ new_session = zmalloc(sizeof(struct ltt_session));
if (new_session == NULL) {
- perror("malloc");
+ perror("zmalloc");
ret = LTTCOMM_FATAL;
goto error_malloc;
}
/* Init lock */
pthread_mutex_init(&new_session->lock, NULL);
+ new_session->uid = uid;
+ new_session->gid = gid;
+
/* Add new session to the session list */
session_lock_list();
- add_session_list(new_session);
+ new_session->id = add_session_list(new_session);
session_unlock_list();
- DBG("Tracing session %s created in %s", name, path);
+ DBG("Tracing session %s created in %s with ID %d by UID %d GID %d",
+ name, path, new_session->id,
+ new_session->uid, new_session->gid);
return LTTCOMM_OK;