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
22 #include <lttng/lttng-error.h>
23 #include <lttng/load.h>
24 #include <lttng/load-internal.h>
25 #include <common/sessiond-comm/sessiond-comm.h>
26 #include <common/config/config.h>
28 #include "lttng-ctl-helper.h"
30 struct lttng_load_session_attr
*lttng_load_session_attr_create(void)
32 return zmalloc(sizeof(struct lttng_load_session_attr
));
35 void lttng_load_session_attr_destroy(struct lttng_load_session_attr
*attr
)
42 const char *lttng_load_session_attr_get_session_name(
43 struct lttng_load_session_attr
*attr
)
45 const char *ret
= NULL
;
47 if (attr
&& attr
->session_name
[0]) {
48 ret
= attr
->session_name
;
54 const char *lttng_load_session_attr_get_input_url(
55 struct lttng_load_session_attr
*attr
)
57 const char *ret
= NULL
;
59 if (attr
&& attr
->input_url
[0]) {
60 ret
= attr
->input_url
;
66 int lttng_load_session_attr_get_overwrite(
67 struct lttng_load_session_attr
*attr
)
69 return attr
? attr
->overwrite
: -LTTNG_ERR_INVALID
;
72 int lttng_load_session_attr_set_session_name(
73 struct lttng_load_session_attr
*attr
, const char *session_name
)
78 ret
= -LTTNG_ERR_INVALID
;
85 len
= strlen(session_name
);
86 if (len
>= NAME_MAX
) {
87 ret
= -LTTNG_ERR_INVALID
;
91 strncpy(attr
->session_name
, session_name
, len
);
93 attr
->session_name
[0] = '\0';
99 int lttng_load_session_attr_set_input_url(
100 struct lttng_load_session_attr
*attr
, const char *url
)
104 struct lttng_uri
*uris
= NULL
;
107 ret
= -LTTNG_ERR_INVALID
;
112 attr
->input_url
[0] = '\0';
118 if (len
>= PATH_MAX
) {
119 ret
= -LTTNG_ERR_INVALID
;
123 size
= uri_parse_str_urls(url
, NULL
, &uris
);
124 if (size
<= 0 || uris
[0].dtype
!= LTTNG_DST_PATH
) {
125 ret
= -LTTNG_ERR_INVALID
;
129 /* Copy string plus the NULL terminated byte. */
130 lttng_ctl_copy_string(attr
->input_url
, uris
[0].dst
.path
,
131 sizeof(attr
->input_url
));
139 int lttng_load_session_attr_set_overwrite(
140 struct lttng_load_session_attr
*attr
, int overwrite
)
145 ret
= -LTTNG_ERR_INVALID
;
149 attr
->overwrite
= !!overwrite
;
155 * The lttng-ctl API does not expose all the information needed to load the
156 * session configurations. Thus, we must send a load command to the session
157 * daemon which will, in turn, load its current session configuration.
159 int lttng_load_session(struct lttng_load_session_attr
*attr
)
164 ret
= -LTTNG_ERR_INVALID
;
168 ret
= config_load_session(attr
->input_url
, attr
->session_name
,
This page took 0.032304 seconds and 4 git commands to generate.