2 * Copyright (C) 2019 - Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
8 * This program 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 General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <common/defaults.h>
25 #include <common/error.h>
26 #include <common/utils.h>
34 int cmd_clear_session(struct ltt_session
*session
)
38 if (!session
->has_been_started
) {
39 /* Nothing to be cleared, do not warn */
44 if (session
->ust_session
) {
45 switch (session
->ust_session
->buffer_type
) {
46 case LTTNG_BUFFER_PER_PID
:
47 ERR("Clear command not supported for per-pid buffers.");
48 ret
= LTTNG_ERR_CLEAR_NOT_AVAILABLE
;
50 case LTTNG_BUFFER_PER_UID
:
51 case LTTNG_BUFFER_GLOBAL
:
57 * Clear kernel and UST session buffers and local files (if any).
59 if (session
->kernel_session
) {
60 ret
= kernel_clear_session(session
);
61 if (ret
!= LTTNG_OK
) {
65 if (session
->ust_session
) {
66 ret
= ust_app_clear_session(session
);
67 if (ret
!= LTTNG_OK
) {
73 * Clear remote (relayd) session files.
75 ret
= consumer_clear_session(session
);
77 ret
= LTTNG_ERR_CLEAR_FAIL_CONSUMER
;