projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Support creds passing between lttng and sessiond
[lttng-tools.git]
/
liblttngctl
/
lttngctl.c
diff --git
a/liblttngctl/lttngctl.c
b/liblttngctl/lttngctl.c
index fc6ff3cc1ac92b41e28184dd04dc03944ba054ce..c65760155347d4ca7e576ea7b24132b580d47e7f 100644
(file)
--- a/
liblttngctl/lttngctl.c
+++ b/
liblttngctl/lttngctl.c
@@
-93,7
+93,7
@@
static int send_session_msg(struct lttcomm_session_msg *lsm)
goto end;
}
goto end;
}
- ret = lttcomm_send_unix_sock(sessiond_socket, lsm,
+ ret = lttcomm_send_
creds_
unix_sock(sessiond_socket, lsm,
sizeof(struct lttcomm_session_msg));
end:
sizeof(struct lttcomm_session_msg));
end:
@@
-425,17
+425,17
@@
int lttng_register_consumer(struct lttng_handle *handle,
/*
* Start tracing for all trace of the session.
*/
/*
* Start tracing for all trace of the session.
*/
-int lttng_start_tracing(
struct lttng_handle *handl
e)
+int lttng_start_tracing(
const char *session_nam
e)
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (
!handle
) {
+ if (
session_name == NULL
) {
return -1;
}
lsm.cmd_type = LTTNG_START_TRACE;
return -1;
}
lsm.cmd_type = LTTNG_START_TRACE;
- copy_string(lsm.session.name, handle->session_name,
-
sizeof(lsm.session.name));
+
+
copy_string(lsm.session.name, session_name,
sizeof(lsm.session.name));
return ask_sessiond(&lsm, NULL);
}
return ask_sessiond(&lsm, NULL);
}
@@
-443,13
+443,17
@@
int lttng_start_tracing(struct lttng_handle *handle)
/*
* Stop tracing for all trace of the session.
*/
/*
* Stop tracing for all trace of the session.
*/
-int lttng_stop_tracing(
struct lttng_handle *handl
e)
+int lttng_stop_tracing(
const char *session_nam
e)
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
+ if (session_name == NULL) {
+ return -1;
+ }
+
lsm.cmd_type = LTTNG_STOP_TRACE;
lsm.cmd_type = LTTNG_STOP_TRACE;
- copy_string(lsm.session.name, handle->session_name,
-
sizeof(lsm.session.name));
+
+
copy_string(lsm.session.name, session_name,
sizeof(lsm.session.name));
return ask_sessiond(&lsm, NULL);
}
return ask_sessiond(&lsm, NULL);
}
@@
-463,7
+467,8
@@
int lttng_add_context(struct lttng_handle *handle,
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (!handle) {
+ /* Safety check. Both are mandatory */
+ if (handle == NULL || ctx == NULL) {
return -1;
}
return -1;
}
@@
-478,9
+483,7
@@
int lttng_add_context(struct lttng_handle *handle,
copy_lttng_domain(&lsm.domain, &handle->domain);
copy_lttng_domain(&lsm.domain, &handle->domain);
- if (ctx) {
- memcpy(&lsm.u.context.ctx, ctx, sizeof(struct lttng_event_context));
- }
+ memcpy(&lsm.u.context.ctx, ctx, sizeof(struct lttng_event_context));
copy_string(lsm.session.name, handle->session_name,
sizeof(lsm.session.name));
copy_string(lsm.session.name, handle->session_name,
sizeof(lsm.session.name));
@@
-496,10
+499,11
@@
int lttng_enable_event(struct lttng_handle *handle,
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (
!handle
|| ev == NULL) {
+ if (
handle == NULL
|| ev == NULL) {
return -1;
}
return -1;
}
+ /* If no channel name, we put the default name */
if (channel_name == NULL) {
copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME,
sizeof(lsm.u.enable.channel_name));
if (channel_name == NULL) {
copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME,
sizeof(lsm.u.enable.channel_name));
@@
-531,7
+535,7
@@
int lttng_disable_event(struct lttng_handle *handle, const char *name,
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (
!handle
) {
+ if (
handle == NULL
) {
return -1;
}
return -1;
}
@@
-566,13
+570,14
@@
int lttng_enable_channel(struct lttng_handle *handle,
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (!handle) {
+ /*
+ * NULL arguments are forbidden. No default values.
+ */
+ if (handle == NULL || chan == NULL) {
return -1;
}
return -1;
}
- if (chan) {
- memcpy(&lsm.u.channel.chan, chan, sizeof(lsm.u.channel.chan));
- }
+ memcpy(&lsm.u.channel.chan, chan, sizeof(lsm.u.channel.chan));
lsm.cmd_type = LTTNG_ENABLE_CHANNEL;
lsm.cmd_type = LTTNG_ENABLE_CHANNEL;
@@
-591,17
+596,16
@@
int lttng_disable_channel(struct lttng_handle *handle, const char *name)
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (!handle) {
+ /* Safety check. Both are mandatory */
+ if (handle == NULL || name == NULL) {
return -1;
}
return -1;
}
- if (name) {
- copy_string(lsm.u.disable.channel_name, name,
- sizeof(lsm.u.disable.channel_name));
- }
-
lsm.cmd_type = LTTNG_DISABLE_CHANNEL;
lsm.cmd_type = LTTNG_DISABLE_CHANNEL;
+ copy_string(lsm.u.disable.channel_name, name,
+ sizeof(lsm.u.disable.channel_name));
+
copy_lttng_domain(&lsm.domain, &handle->domain);
copy_string(lsm.session.name, handle->session_name,
copy_lttng_domain(&lsm.domain, &handle->domain);
copy_string(lsm.session.name, handle->session_name,
@@
-622,7
+626,7
@@
int lttng_list_tracepoints(struct lttng_handle *handle,
int ret;
struct lttcomm_session_msg lsm;
int ret;
struct lttcomm_session_msg lsm;
- if (
!handle
) {
+ if (
handle == NULL
) {
return -1;
}
return -1;
}
@@
-666,17
+670,17
@@
int lttng_create_session(const char *name, const char *path)
/*
* Destroy session using name.
*/
/*
* Destroy session using name.
*/
-int lttng_destroy_session(
struct lttng_handle *handl
e)
+int lttng_destroy_session(
const char *session_nam
e)
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (
!handle
) {
+ if (
session_name == NULL
) {
return -1;
}
lsm.cmd_type = LTTNG_DESTROY_SESSION;
return -1;
}
lsm.cmd_type = LTTNG_DESTROY_SESSION;
- copy_string(lsm.session.name, handle->session_name,
-
sizeof(lsm.session.name));
+
+
copy_string(lsm.session.name, session_name,
sizeof(lsm.session.name));
return ask_sessiond(&lsm, NULL);
}
return ask_sessiond(&lsm, NULL);
}
@@
-704,20
+708,19
@@
int lttng_list_sessions(struct lttng_session **sessions)
/*
* List domain of a session.
*/
/*
* List domain of a session.
*/
-int lttng_list_domains(
struct lttng_handle *handl
e,
+int lttng_list_domains(
const char *session_nam
e,
struct lttng_domain **domains)
{
int ret;
struct lttcomm_session_msg lsm;
struct lttng_domain **domains)
{
int ret;
struct lttcomm_session_msg lsm;
- if (
!handle
) {
+ if (
session_name == NULL
) {
return -1;
}
lsm.cmd_type = LTTNG_LIST_DOMAINS;
return -1;
}
lsm.cmd_type = LTTNG_LIST_DOMAINS;
- copy_string(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ copy_string(lsm.session.name, session_name, sizeof(lsm.session.name));
ret = ask_sessiond(&lsm, (void**) domains);
if (ret < 0) {
ret = ask_sessiond(&lsm, (void**) domains);
if (ret < 0) {
@@
-736,7
+739,7
@@
int lttng_list_channels(struct lttng_handle *handle,
int ret;
struct lttcomm_session_msg lsm;
int ret;
struct lttcomm_session_msg lsm;
- if (
!handle
) {
+ if (
handle == NULL
) {
return -1;
}
return -1;
}
@@
-763,7
+766,8
@@
int lttng_list_events(struct lttng_handle *handle,
int ret;
struct lttcomm_session_msg lsm;
int ret;
struct lttcomm_session_msg lsm;
- if (!handle) {
+ /* Safety check. An handle and channel name are mandatory */
+ if (handle == NULL || channel_name == NULL) {
return -1;
}
return -1;
}
@@
-789,6
+793,10
@@
int lttng_list_events(struct lttng_handle *handle,
*/
int lttng_set_tracing_group(const char *name)
{
*/
int lttng_set_tracing_group(const char *name)
{
+ if (name == NULL) {
+ return -1;
+ }
+
if (asprintf(&tracing_group, "%s", name) < 0) {
return -ENOMEM;
}
if (asprintf(&tracing_group, "%s", name) < 0) {
return -ENOMEM;
}
@@
-804,7
+812,8
@@
int lttng_calibrate(struct lttng_handle *handle,
{
struct lttcomm_session_msg lsm;
{
struct lttcomm_session_msg lsm;
- if (!handle) {
+ /* Safety check. NULL pointer are forbidden */
+ if (handle == NULL || calibrate == NULL) {
return -1;
}
return -1;
}
This page took
0.027439 seconds
and
4
git commands to generate.