2 * Copyright (C) 2017 - Julien Desfossez <jdesfossez@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
18 #ifndef LTTNG_ROTATE_H
19 #define LTTNG_ROTATE_H
26 * Return codes for lttng_rotate_session_get_output_path.
28 enum lttng_rotate_status
{
30 * After starting a rotation.
32 LTTNG_ROTATE_STARTED
= 0,
34 * When the rotation is complete.
36 LTTNG_ROTATE_COMPLETED
= 1,
38 * If the handle does not match the last rotate command, we cannot
39 * retrieve the path for the chunk.
41 LTTNG_ROTATE_EXPIRED
= 2,
43 * Nothing to rotate, it happens on the first rotation when tracing
44 * only in user-space and no app was started.
46 LTTNG_ROTATE_EMPTY
= 3,
50 LTTNG_ROTATE_ERROR
= 4,
54 * Input parameter to the lttng_rotate_session command.
55 * The lttng_rotate_session_attr object is opaque to the user. Use the helper
56 * functions below to use it.
58 struct lttng_rotate_session_attr
;
61 * Handle used to check the progress of a rotation.
62 * This object is opaque to the user. Use the helper functions below to use it.
64 struct lttng_rotate_session_handle
;
67 * lttng rotate session command inputs.
70 * Return a newly allocated rotate session attribute object or NULL on error.
72 struct lttng_rotate_session_attr
*lttng_rotate_session_attr_create(void);
75 * Free a given rotate ssession attribute object.
77 void lttng_rotate_session_attr_destroy(struct lttng_rotate_session_attr
*attr
);
80 * Set the name of the session to rotate.
82 int lttng_rotate_session_attr_set_session_name(
83 struct lttng_rotate_session_attr
*attr
, const char *session_name
);
86 * lttng rotate session handle functions.
89 * Get the status from a handle.
91 enum lttng_rotate_status
lttng_rotate_session_get_status(
92 struct lttng_rotate_session_handle
*rotate_handle
);
95 * If the rotation is complete, returns 0, allocate path and set
96 * it to the path of the readable chunk, the caller is responsible to free it.
97 * Otherwise return a negative value.
99 int lttng_rotate_session_get_output_path(
100 struct lttng_rotate_session_handle
*rotate_handle
,
104 * Destroy a lttng_rotate_session handle allocated by lttng_rotate_session()
106 void lttng_rotate_session_handle_destroy(
107 struct lttng_rotate_session_handle
*rotate_handle
);
110 * Rotate the output folder of the session
112 * On success, handle is allocated and can be used to monitor the progress
113 * of the rotation with lttng_rotate_session_pending(). The handle must be freed
114 * by the caller with lttng_rotate_session_handle_destroy().
116 * Return 0 if the rotate action was successfully launched or a negative
117 * LTTng error code on error.
119 extern int lttng_rotate_session(struct lttng_rotate_session_attr
*attr
,
120 struct lttng_rotate_session_handle
**rotate_handle
);
123 * For a given session name, this call checks if a session rotation is still in
124 * progress or has completed.
126 * Return 0 if the rotation is complete, in this case, the output path can be
127 * fetched with lttng_rotate_session_get_output_path().
128 * Return 1 if the rotate is still pending.
129 * Return a negative LTTng error code on error (readable with lttng_strerror).
131 extern int lttng_rotate_session_pending(
132 struct lttng_rotate_session_handle
*rotate_handle
);
138 #endif /* LTTNG_ROTATE_H */