X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=cc81906b6267ffc104ee357741d0b099af9fbc3c;hp=86c3c765c8dfb2173137894a4fceffb156515ce9;hb=7802bae326824ecb116cb0d782bb7472eaa6f6e4;hpb=62a0c2d4933fd52b78c896cf40a935e42ea94360 diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 86c3c765c..cc81906b6 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2748,64 +2748,6 @@ int cmd_destroy_session(struct ltt_session *session, int wpipe) return ret; } -/* - * Command LTTNG_CALIBRATE processed by the client thread. - */ -int cmd_calibrate(enum lttng_domain_type domain, - struct lttng_calibrate *calibrate) -{ - int ret; - - switch (domain) { - case LTTNG_DOMAIN_KERNEL: - { - struct lttng_kernel_calibrate kcalibrate; - - switch (calibrate->type) { - case LTTNG_CALIBRATE_FUNCTION: - default: - /* Default and only possible calibrate option. */ - kcalibrate.type = LTTNG_KERNEL_CALIBRATE_KRETPROBE; - break; - } - - ret = kernel_calibrate(kernel_tracer_fd, &kcalibrate); - if (ret < 0) { - ret = LTTNG_ERR_KERN_ENABLE_FAIL; - goto error; - } - break; - } - case LTTNG_DOMAIN_UST: - { - struct lttng_ust_calibrate ucalibrate; - - switch (calibrate->type) { - case LTTNG_CALIBRATE_FUNCTION: - default: - /* Default and only possible calibrate option. */ - ucalibrate.type = LTTNG_UST_CALIBRATE_TRACEPOINT; - break; - } - - ret = ust_app_calibrate_glb(&ucalibrate); - if (ret < 0) { - ret = LTTNG_ERR_UST_CALIBRATE_FAIL; - goto error; - } - break; - } - default: - ret = LTTNG_ERR_UND; - goto error; - } - - ret = LTTNG_OK; - -error: - return ret; -} - /* * Command LTTNG_REGISTER_CONSUMER processed by the client thread. */ @@ -3207,11 +3149,10 @@ int cmd_snapshot_add_output(struct ltt_session *session, DBG("Cmd snapshot add output for session %s", session->name); /* - * Permission denied to create an output if the session is not - * set in no output mode. + * Can't create an output if the session is not set in no-output mode. */ if (session->output_traces) { - ret = LTTNG_ERR_EPERM; + ret = LTTNG_ERR_NOT_SNAPSHOT_SESSION; goto error; } @@ -3275,7 +3216,7 @@ int cmd_snapshot_del_output(struct ltt_session *session, * set in no output mode. */ if (session->output_traces) { - ret = LTTNG_ERR_EPERM; + ret = LTTNG_ERR_NOT_SNAPSHOT_SESSION; goto error; } @@ -3327,19 +3268,19 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, * set in no output mode. */ if (session->output_traces) { - ret = -LTTNG_ERR_EPERM; - goto error; + ret = -LTTNG_ERR_NOT_SNAPSHOT_SESSION; + goto end; } if (session->snapshot.nb_output == 0) { ret = 0; - goto error; + goto end; } list = zmalloc(session->snapshot.nb_output * sizeof(*list)); if (!list) { ret = -LTTNG_ERR_NOMEM; - goto error; + goto end; } /* Copy list from session to the new list object. */ @@ -3352,14 +3293,14 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, if (lttng_strncpy(list[idx].name, output->name, sizeof(list[idx].name))) { ret = -LTTNG_ERR_INVALID; - goto error_unlock; + goto error; } if (output->consumer->type == CONSUMER_DST_LOCAL) { if (lttng_strncpy(list[idx].ctrl_url, output->consumer->dst.trace_path, sizeof(list[idx].ctrl_url))) { ret = -LTTNG_ERR_INVALID; - goto error_unlock; + goto error; } } else { /* Control URI. */ @@ -3367,7 +3308,7 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, list[idx].ctrl_url, sizeof(list[idx].ctrl_url)); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; - goto error_unlock; + goto error; } /* Data URI. */ @@ -3375,7 +3316,7 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, list[idx].data_url, sizeof(list[idx].data_url)); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; - goto error_unlock; + goto error; } } idx++; @@ -3384,10 +3325,10 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, *outputs = list; list = NULL; ret = session->snapshot.nb_output; -error_unlock: - rcu_read_unlock(); error: + rcu_read_unlock(); free(list); +end: return ret; } @@ -3436,6 +3377,27 @@ end: return ret; } +static +int clear_metadata_file(int fd) +{ + int ret; + + ret = lseek(fd, 0, SEEK_SET); + if (ret < 0) { + PERROR("lseek"); + goto end; + } + + ret = ftruncate(fd, 0); + if (ret < 0) { + PERROR("ftruncate"); + goto end; + } + +end: + return ret; +} + static int ust_regenerate_metadata(struct ltt_ust_session *usess) { @@ -3457,6 +3419,15 @@ int ust_regenerate_metadata(struct ltt_ust_session *usess) memset(registry->metadata, 0, registry->metadata_alloc_len); registry->metadata_len = 0; registry->metadata_version++; + if (registry->metadata_fd > 0) { + /* Clear the metadata file's content. */ + ret = clear_metadata_file(registry->metadata_fd); + if (ret) { + pthread_mutex_unlock(®istry->lock); + goto end; + } + } + ret = ust_metadata_session_statedump(registry, NULL, registry->major, registry->minor); if (ret) { @@ -3861,7 +3832,7 @@ int cmd_snapshot_record(struct ltt_session *session, * set in no output mode. */ if (session->output_traces) { - ret = LTTNG_ERR_EPERM; + ret = LTTNG_ERR_NOT_SNAPSHOT_SESSION; goto error; }