}
/* Create UST channel */
- uchan = trace_ust_create_channel(attr, usess->pathname);
+ uchan = trace_ust_create_channel(attr);
if (uchan == NULL) {
ret = LTTNG_ERR_FATAL;
goto error;
size_t nb_uri, lttng_sock_cred *creds)
{
int ret;
- char *path = NULL;
struct ltt_session *session;
assert(name);
}
/* Create tracing session in the registry */
- ret = session_create(name, path, LTTNG_SOCK_GET_UID_CRED(creds),
+ ret = session_create(name, LTTNG_SOCK_GET_UID_CRED(creds),
LTTNG_SOCK_GET_GID_CRED(creds));
if (ret != LTTNG_OK) {
goto session_error;
(ksess && ksess->consumer->type == CONSUMER_DST_NET) ||
(usess && usess->consumer->type == CONSUMER_DST_NET)) {
ret = build_network_session_path(sessions[i].path,
- sizeof(session[i].path), session);
+ sizeof(sessions[i].path), session);
} else {
- ret = snprintf(sessions[i].path, sizeof(session[i].path), "%s",
+ ret = snprintf(sessions[i].path, sizeof(sessions[i].path), "%s",
session->consumer->dst.trace_path);
}
if (ret < 0) {
/* Get the right path name destination */
if (consumer->type == CONSUMER_DST_LOCAL) {
/* Set application path to the destination path */
- ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s",
+ ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s",
consumer->dst.trace_path, consumer->subdir);
if (ret < 0) {
PERROR("snprintf metadata path");
/* Get the right path name destination */
if (consumer->type == CONSUMER_DST_LOCAL) {
/* Set application path to the destination path */
- ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s",
+ ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s",
consumer->dst.trace_path, consumer->subdir);
if (ret < 0) {
PERROR("snprintf metadata path");
assert(session);
/* Allocate data structure */
- lks = trace_kernel_create_session(session->path);
+ lks = trace_kernel_create_session();
if (lks == NULL) {
ret = -1;
goto error;
DBG("Creating UST session");
- lus = trace_ust_create_session(session->path, session->id);
+ lus = trace_ust_create_session(session->id);
if (lus == NULL) {
ret = LTTNG_ERR_UST_SESS_FAIL;
goto error;
/*
* Create a brand new session and add it to the session list.
*/
-int session_create(char *name, char *path, uid_t uid, gid_t gid)
+int session_create(char *name, uid_t uid, gid_t gid)
{
int ret;
struct ltt_session *new_session;
goto error;
}
- /* Define session system path */
- if (path != NULL) {
- if (snprintf(new_session->path, PATH_MAX, "%s", path) < 0) {
- ret = LTTNG_ERR_FATAL;
- goto error_asprintf;
- }
- }
-
/* Init kernel session */
new_session->kernel_session = NULL;
new_session->ust_session = NULL;
new_session->uid = uid;
new_session->gid = gid;
- /* Mkdir if we have a valid path and length */
- if (strlen(new_session->path) > 0) {
- ret = run_as_mkdir_recursive(new_session->path, S_IRWXU | S_IRWXG,
- new_session->uid, new_session->gid);
- if (ret < 0) {
- if (ret != -EEXIST) {
- ERR("Trace directory creation error");
- ret = LTTNG_ERR_CREATE_DIR_FAIL;
- goto error;
- }
- }
- }
-
/* Add new session to the session list */
session_lock_list();
new_session->id = add_session_list(new_session);
* up and, if valid, assign it to the session.
*/
- DBG("Tracing session %s created in %s with ID %u by UID %d GID %d", name,
- path, new_session->id, new_session->uid, new_session->gid);
+ DBG("Tracing session %s created with ID %u by UID %d GID %d", name,
+ new_session->id, new_session->uid, new_session->gid);
return LTTNG_OK;
*/
struct ltt_session {
char name[NAME_MAX];
- char path[PATH_MAX];
struct ltt_kernel_session *kernel_session;
struct ltt_ust_session *ust_session;
/*
};
/* Prototypes */
-int session_create(char *name, char *path, uid_t uid, gid_t gid);
+int session_create(char *name, uid_t uid, gid_t gid);
int session_destroy(struct ltt_session *session);
void session_lock(struct ltt_session *session);
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_session *trace_kernel_create_session(char *path)
+struct ltt_kernel_session *trace_kernel_create_session(void)
{
struct ltt_kernel_session *lks = NULL;
*/
lks->tmp_consumer = NULL;
- if (*path != '\0') {
- int ret;
-
- /* Use the default consumer output which is the tracing session path. */
- ret = snprintf(lks->consumer->dst.trace_path, PATH_MAX,
- "%s" DEFAULT_KERNEL_TRACE_DIR, path);
- if (ret < 0) {
- PERROR("snprintf consumer trace path");
- goto error;
- }
-
- /* Set session path */
- ret = asprintf(&lks->trace_path, "%s" DEFAULT_KERNEL_TRACE_DIR, path);
- if (ret < 0) {
- PERROR("asprintf kernel traces path");
- goto error;
- }
- }
-
return lks;
error:
consumer_destroy_output(session->consumer);
consumer_destroy_output(session->tmp_consumer);
- free(session->trace_path);
free(session);
}
int consumer_fds_sent;
unsigned int channel_count;
unsigned int stream_count_global;
- char *trace_path;
struct ltt_kernel_metadata *metadata;
struct ltt_kernel_channel_list channel_list;
/* UID/GID of the user owning the session */
/*
* Create functions malloc() the data structure.
*/
-struct ltt_kernel_session *trace_kernel_create_session(char *path);
+struct ltt_kernel_session *trace_kernel_create_session(void);
struct ltt_kernel_channel *trace_kernel_create_channel(
struct lttng_channel *chan);
struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev);
*
* Return pointer to structure or NULL.
*/
-struct ltt_ust_session *trace_ust_create_session(char *path,
- unsigned int session_id)
+struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
{
struct ltt_ust_session *lus;
*/
lus->tmp_consumer = NULL;
- /* Use the default consumer output which is the tracing session path. */
- if (*path != '\0') {
- int ret;
-
- ret = snprintf(lus->consumer->dst.trace_path, PATH_MAX,
- "%s" DEFAULT_UST_TRACE_DIR, path);
- if (ret < 0) {
- PERROR("snprintf UST consumer trace path");
- goto error_path;
- }
- }
-
DBG2("UST trace session create successful");
return lus;
-error_path:
- consumer_destroy_output(lus->consumer);
error_consumer:
lttng_ht_destroy(lus->domain_global.channels);
free(lus);
*
* Return pointer to structure or NULL.
*/
-struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan,
- char *path)
+struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan)
{
struct ltt_ust_channel *luc;
assert(chan);
- assert(path);
luc = zmalloc(sizeof(struct ltt_ust_channel));
if (luc == NULL) {
uint64_t id; /* unique id per session. */
unsigned int enabled;
char name[LTTNG_UST_SYM_NAME_LEN];
- char pathname[PATH_MAX];
struct lttng_ust_channel_attr attr;
struct lttng_ht *ctx;
struct lttng_ht *events;
struct ltt_ust_session {
int id; /* Unique identifier of session */
int start_trace;
- char pathname[PATH_MAX];
struct ltt_ust_domain_global domain_global;
/* UID/GID of the user owning the session */
uid_t uid;
/*
* Create functions malloc() the data structure.
*/
-struct ltt_ust_session *trace_ust_create_session(char *path,
- unsigned int session_id);
-struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
- char *path);
+struct ltt_ust_session *trace_ust_create_session(unsigned int session_id);
+struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr);
struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
struct lttng_filter_bytecode *filter);
struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
}
static inline
-struct ltt_ust_session *trace_ust_create_session(char *path,
- unsigned int session_id)
+struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
{
return NULL;
}
static inline
-struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
- char *path)
+struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr)
{
return NULL;
}
switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
ret = snprintf(ua_sess->path, sizeof(ua_sess->path),
- DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s/", app->name, app->pid,
+ DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s", app->name, app->pid,
datetime);
break;
case LTTNG_BUFFER_PER_UID:
/* Get correct path name destination */
if (consumer->type == CONSUMER_DST_LOCAL) {
/* Set application path to the destination path */
- ret = snprintf(pathname, PATH_MAX, "%s/%s/%s",
+ ret = snprintf(pathname, PATH_MAX, "%s%s%s",
consumer->dst.trace_path, consumer->subdir, ua_sess->path);
if (ret < 0) {
PERROR("snprintf channel path");
}
}
} else {
- ret = snprintf(pathname, PATH_MAX, "%s/%s", consumer->subdir,
+ ret = snprintf(pathname, PATH_MAX, "%s%s", consumer->subdir,
ua_sess->path);
if (ret < 0) {
PERROR("snprintf channel path");
#include <tap/tap.h>
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
#define RANDOM_STRING_LEN 11
/* Number of TAP tests in this file */
static void test_create_one_kernel_session(void)
{
- kern = trace_kernel_create_session(PATH1);
+ kern = trace_kernel_create_session();
ok(kern != NULL, "Create kernel session");
ok(kern->fd == -1 &&
#define SESSION1 "test1"
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
#define MAX_SESSIONS 10000
#define RANDOM_STRING_LEN 11
/* Number of TAP tests in this file */
-#define NUM_TESTS 12
+#define NUM_TESTS 11
static struct ltt_session_list *session_list;
/*
* Test creation of 1 session
*/
-static int create_one_session(char *name, char *path)
+static int create_one_session(char *name)
{
int ret;
- ret = session_create(name, path, geteuid(), getegid());
+ ret = session_create(name, geteuid(), getegid());
if (ret == LTTNG_OK) {
/* Validate */
ret = find_session_name(name);
int ret;
struct ltt_session *sess;
- ret = create_one_session(SESSION1, PATH1);
+ ret = create_one_session(SESSION1);
if (ret < 0) {
/* Fail */
return -1;
void test_create_one_session(void)
{
- ok(create_one_session(SESSION1, PATH1) == 0,
+ ok(create_one_session(SESSION1) == 0,
"Create session: %s",
SESSION1);
}
"Validating session: session found");
ok(tmp->kernel_session == NULL &&
- strlen(tmp->path) &&
strlen(tmp->name),
"Validating session: basic sanity check");
void test_bogus_session_param(void)
{
- ok(create_one_session(NULL, NULL) < 0,
- "Create session with bogus param: NULL, NULL should fail");
-
- ok(create_one_session(NULL, PATH1) < 0,
- "Create session with bogus param: NULL, %s should fail",
- PATH1);
+ ok(create_one_session(NULL) < 0,
+ "Create session with bogus param: NULL should fail");
ok(session_list_count() == 0,
"Create session with bogus param: session list empty");
for (i = 0; i < MAX_SESSIONS; i++) {
char *tmp_name = get_random_string();
- ret = create_one_session(tmp_name, PATH1);
+ ret = create_one_session(tmp_name);
if (ret < 0) {
diag("session %d (name: %s) creation failed", i, tmp_name);
++failed;
{
dom.type = LTTNG_DOMAIN_UST;
- usess = trace_ust_create_session(PATH1, 42);
+ usess = trace_ust_create_session(42);
ok(usess != NULL, "Create UST session");
ok(usess->id == 42 &&
strncpy(attr.name, "channel0", 8);
- uchan = trace_ust_create_channel(&attr, PATH1);
+ uchan = trace_ust_create_channel(&attr);
ok(uchan != NULL, "Create UST channel");
ok(uchan->enabled == 0 &&