session->kernel_session->consumer_fd = kconsumerd_cmd_sock;
}
- ret = asprintf(&session->kernel_session->trace_path, "%s/kernel",
- session->path);
- if (ret < 0) {
- perror("asprintf kernel traces path");
- goto error;
- }
-
ret = mkdir_recursive(session->kernel_session->trace_path,
S_IRWXU | S_IRWXG, geteuid(), allowed_group());
if (ret < 0) {
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_session *trace_kernel_create_session(void)
+struct ltt_kernel_session *trace_kernel_create_session(char *path)
{
+ int ret;
struct ltt_kernel_session *lks;
/* Allocate a new ltt kernel session */
lks->consumer_fd = 0;
CDS_INIT_LIST_HEAD(&lks->channel_list.head);
+ /* Set session path */
+ ret = asprintf(&lks->trace_path, "%s/kernel", path);
+ if (ret < 0) {
+ perror("asprintf kernel traces path");
+ goto error;
+ }
+
return lks;
error:
DBG("[trace] Closing stream fd %d", stream->fd);
/* Close kernel fd */
close(stream->fd);
- free(stream->pathname);
-
/* Remove from stream list */
cds_list_del(&stream->list);
+
+ free(stream->pathname);
free(stream);
}
DBG("[trace] Closing event fd %d", event->fd);
/* Close kernel fd */
close(event->fd);
- /* Free attributes */
- free(event->event);
/* Remove from event list */
cds_list_del(&event->list);
+
+ free(event->event);
+ free(event->ctx);
free(event);
}
DBG("[trace] Closing channel fd %d", channel->fd);
/* Close kernel fd */
close(channel->fd);
- free(channel->pathname);
- /* Free attributes structure */
- free(channel->channel);
/* For each stream in the channel list */
cds_list_for_each_entry_safe(stream, stmp, &channel->stream_list.head, list) {
/* Remove from channel list */
cds_list_del(&channel->list);
+
+ free(channel->pathname);
+ free(channel->channel);
+ free(channel->ctx);
free(channel);
}
DBG("[trace] Closing metadata fd %d", metadata->fd);
/* Close kernel fd */
close(metadata->fd);
- /* Free attributes */
- free(metadata->conf);
+ free(metadata->conf);
+ free(metadata->pathname);
free(metadata);
}
DBG("[trace] Closing session fd %d", session->fd);
/* Close kernel fds */
close(session->fd);
+
if (session->metadata_stream_fd != 0) {
DBG("[trace] Closing metadata stream fd %d", session->metadata_stream_fd);
close(session->metadata_stream_fd);
trace_kernel_destroy_channel(channel);
}
+ free(session->trace_path);
free(session);
}
/*
* Create functions malloc() the data structure.
*/
-struct ltt_kernel_session *trace_kernel_create_session(void);
+struct ltt_kernel_session *trace_kernel_create_session(char *path);
struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *chan, char *path);
struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev);
struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path);