} location;
} LTTNG_PACKED;
-/* For the LTTNG_SESSION_GET_CURRENT_OUTPUT command. */
-struct lttng_session_get_current_output_return {
- char path[LTTNG_PATH_MAX];
-} LTTNG_PACKED;
-
/* For the LTTNG_SESSION_LIST_SCHEDULES command. */
struct lttng_session_list_schedules_return {
struct {
extern int lttng_list_tracker_pids(struct lttng_handle *handle,
int *enabled, int32_t **pids, size_t *nr_pids);
-/*
- * Ask the session daemon where the data for this session is currently being
- * written to. If rotations occured during a session, this call is useful to
- * know the location of the last chunk.
- *
- * Return 0 and allocate chunk_path if rotations occured for this session, the
- * caller needs to free chunk_path.
- * Return 1 if no rotation occured during the session, chunk_path is left
- * unallocated.
- *
- * Return a negative LTTng error code on error (readable with lttng_strerror).
- *
- * FIXME: Return an lttng_location object rather than a path.
- */
-extern int lttng_session_get_current_archive_location(const char *session_name,
- char **chunk_path);
-
#ifdef __cplusplus
}
#endif
return ret;
}
-/*
- * Command ROTATE_GET_CURRENT_PATH from the lttng-ctl library.
- *
- * Configure the automatic rotation parameters.
- * Set to -1ULL to disable them.
- *
- * Return LTTNG_OK on success or else a LTTNG_ERR code.
- */
-int cmd_session_get_current_output(struct ltt_session *session,
- struct lttng_session_get_current_output_return *output_return)
-{
- int ret;
- const char *path;
-
- if (!session->snapshot_mode) {
- if (session->current_archive_id == 0) {
- if (session->kernel_session) {
- path = session_get_base_path(session);
- } else if (session->ust_session) {
- path = session_get_base_path(session);
- } else {
- abort();
- }
- assert(path);
- } else {
- path = session->rotation_chunk.active_tracing_path;
- }
- } else {
- /*
- * A snapshot session does not have a "current" trace archive
- * location.
- */
- path = "";
- }
-
- DBG("Cmd get current output for session %s, returning %s",
- session->name, path);
-
- ret = lttng_strncpy(output_return->path,
- path,
- sizeof(output_return->path));
- if (ret) {
- ERR("Failed to copy trace output path to session get current output command reply");
- ret = -LTTNG_ERR_UNK;
- goto end;
- }
-
- ret = LTTNG_OK;
-end:
- return ret;
-}
-
/* Wait for a given path to be removed before continuing. */
static enum lttng_error_code wait_on_path(void *path_data)
{
int cmd_rotate_get_info(struct ltt_session *session,
struct lttng_rotation_get_info_return *info_return,
uint64_t rotate_id);
-int cmd_session_get_current_output(struct ltt_session *session,
- struct lttng_session_get_current_output_return *output_return);
int cmd_rotation_set_schedule(struct ltt_session *session,
bool activate, enum lttng_rotation_schedule_type schedule_type,
uint64_t value,
case LTTNG_UNREGISTER_TRIGGER:
case LTTNG_ROTATE_SESSION:
case LTTNG_ROTATION_GET_INFO:
- case LTTNG_SESSION_GET_CURRENT_OUTPUT:
case LTTNG_ROTATION_SET_SCHEDULE:
case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
need_domain = 0;
ret = LTTNG_OK;
break;
}
- case LTTNG_SESSION_GET_CURRENT_OUTPUT:
- {
- struct lttng_session_get_current_output_return output_return;
-
- memset(&output_return, 0, sizeof(output_return));
- ret = cmd_session_get_current_output(cmd_ctx->session,
- &output_return);
- if (ret < 0) {
- ret = -ret;
- goto error;
- }
-
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &output_return,
- sizeof(output_return));
- if (ret < 0) {
- ret = -ret;
- goto error;
- }
-
- ret = LTTNG_OK;
- break;
- }
case LTTNG_ROTATION_SET_SCHEDULE:
{
bool set_schedule;
LTTNG_ROTATE_SESSION = 45,
LTTNG_ROTATION_GET_INFO = 46,
LTTNG_ROTATION_SET_SCHEDULE = 47,
- LTTNG_SESSION_GET_CURRENT_OUTPUT = 48,
- LTTNG_SESSION_LIST_ROTATION_SCHEDULES = 49,
+ LTTNG_SESSION_LIST_ROTATION_SCHEDULES = 48,
};
enum lttcomm_relayd_command {
return ret;
}
-int lttng_session_get_current_archive_location(const char *session_name,
- char **chunk_path)
-{
- struct lttcomm_session_msg lsm;
- struct lttng_session_get_current_output_return *output_return = NULL;
- int ret;
- size_t path_len;
-
- memset(&lsm, 0, sizeof(lsm));
- lsm.cmd_type = LTTNG_SESSION_GET_CURRENT_OUTPUT;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
- if (ret) {
- ret = -LTTNG_ERR_INVALID;
- goto end;
- }
-
- ret = lttng_ctl_ask_sessiond(&lsm, (void **) &output_return);
- if (ret < 0) {
- ret = -1;
- goto end;
- }
-
- path_len = lttng_strnlen(output_return->path,
- sizeof(output_return->path));
- if (path_len == 0 || path_len == sizeof(output_return->path)) {
- ret = -LTTNG_ERR_NO_SESSION_OUTPUT;
- goto end;
- }
-
- *chunk_path = zmalloc(path_len + 1);
- if (!*chunk_path) {
- ret = -1;
- goto end;
- }
- memcpy(*chunk_path, output_return->path, path_len);
-
- ret = 0;
-
-end:
- free(output_return);
- return ret;
-}
-
/*
* lib constructor.
*/