2 * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <lttng/lttng-error.h>
24 #include <lttng/load.h>
25 #include <lttng/load-internal.h>
26 #include <common/sessiond-comm/sessiond-comm.h>
27 #include <common/config/config.h>
29 #include "lttng-ctl-helper.h"
31 struct lttng_load_session_attr
*lttng_load_session_attr_create(void)
33 return zmalloc(sizeof(struct lttng_load_session_attr
));
36 void lttng_load_session_attr_destroy(struct lttng_load_session_attr
*attr
)
43 const char *lttng_load_session_attr_get_session_name(
44 struct lttng_load_session_attr
*attr
)
46 const char *ret
= NULL
;
48 if (attr
&& attr
->session_name
[0]) {
49 ret
= attr
->session_name
;
55 const char *lttng_load_session_attr_get_input_url(
56 struct lttng_load_session_attr
*attr
)
58 const char *ret
= NULL
;
60 if (attr
&& attr
->input_url
[0]) {
61 ret
= attr
->input_url
;
67 int lttng_load_session_attr_get_overwrite(
68 struct lttng_load_session_attr
*attr
)
70 return attr
? attr
->overwrite
: -LTTNG_ERR_INVALID
;
73 int lttng_load_session_attr_set_session_name(
74 struct lttng_load_session_attr
*attr
, const char *session_name
)
79 ret
= -LTTNG_ERR_INVALID
;
86 len
= strlen(session_name
);
87 if (len
>= LTTNG_NAME_MAX
) {
88 ret
= -LTTNG_ERR_INVALID
;
92 strncpy(attr
->session_name
, session_name
, len
);
94 attr
->session_name
[0] = '\0';
100 int lttng_load_session_attr_set_input_url(
101 struct lttng_load_session_attr
*attr
, const char *url
)
105 struct lttng_uri
*uris
= NULL
;
108 ret
= -LTTNG_ERR_INVALID
;
113 attr
->input_url
[0] = '\0';
119 if (len
>= PATH_MAX
) {
120 ret
= -LTTNG_ERR_INVALID
;
124 size
= uri_parse_str_urls(url
, NULL
, &uris
);
125 if (size
<= 0 || uris
[0].dtype
!= LTTNG_DST_PATH
) {
126 ret
= -LTTNG_ERR_INVALID
;
130 /* Copy string plus the NULL terminated byte. */
131 lttng_ctl_copy_string(attr
->input_url
, uris
[0].dst
.path
,
132 sizeof(attr
->input_url
));
140 int lttng_load_session_attr_set_overwrite(
141 struct lttng_load_session_attr
*attr
, int overwrite
)
146 ret
= -LTTNG_ERR_INVALID
;
150 attr
->overwrite
= !!overwrite
;
156 * The lttng-ctl API does not expose all the information needed to load the
157 * session configurations. Thus, we must send a load command to the session
158 * daemon which will, in turn, load its current session configuration.
160 int lttng_load_session(struct lttng_load_session_attr
*attr
)
165 ret
= -LTTNG_ERR_INVALID
;
169 ret
= config_load_session(attr
->input_url
, attr
->session_name
,
This page took 0.039172 seconds and 4 git commands to generate.