LTTNG_ERR_PER_PID_SESSION = 120, /* Per-PID sessions unsupported */
LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE = 121, /* Context unavailable on this kernel */
LTTNG_ERR_REGEN_STATEDUMP_FAIL = 122, /* Failed to regenerate the state dump */
- LTTNG_ERR_REGEN_STATEDUMP_NOMEM = 123, /* Failed to regenerate the state dump, not enough memory */
+ LTTNG_ERR_REGEN_STATEDUMP_NOMEM = 123, /* Failed to regenerate the state dump, not enough memory */
+ LTTNG_ERR_NOT_SNAPSHOT_SESSION = 124, /* Session is not in snapshot mode. */
/* MUST be last element */
LTTNG_ERR_NR, /* Last element */
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;
}
* set in no output mode.
*/
if (session->output_traces) {
- ret = LTTNG_ERR_EPERM;
+ ret = LTTNG_ERR_NOT_SNAPSHOT_SESSION;
goto error;
}
* 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. */
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. */
list[idx].ctrl_url, sizeof(list[idx].ctrl_url));
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
- goto error_unlock;
+ goto error;
}
/* Data URI. */
list[idx].data_url, sizeof(list[idx].data_url));
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
- goto error_unlock;
+ goto error;
}
}
idx++;
*outputs = list;
list = NULL;
ret = session->snapshot.nb_output;
-error_unlock:
- rcu_read_unlock();
error:
+ rcu_read_unlock();
free(list);
+end:
return ret;
}
* set in no output mode.
*/
if (session->output_traces) {
- ret = LTTNG_ERR_EPERM;
+ ret = LTTNG_ERR_NOT_SNAPSHOT_SESSION;
goto error;
}
[ ERROR_INDEX(LTTNG_ERR_KERN_CONTEXT_UNAVAILABLE) ] = "Context unavailable on this kernel",
[ ERROR_INDEX(LTTNG_ERR_REGEN_STATEDUMP_FAIL) ] = "Failed to regenerate the state dump",
[ ERROR_INDEX(LTTNG_ERR_REGEN_STATEDUMP_NOMEM) ] = "Failed to regenerate the state dump, not enough memory",
+ [ ERROR_INDEX(LTTNG_ERR_NOT_SNAPSHOT_SESSION) ] = "Snapshot command can't be applied to a non-snapshot session",
/* Last element */
[ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"