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,
45 LTTNG_ROTATE_ERROR
= 3,
49 * Input parameter to the lttng_rotate_session command.
50 * The lttng_rotate_session_attr object is opaque to the user. Use the helper
51 * functions below to use it.
53 struct lttng_rotate_session_attr
;
56 * Handle used to check the progress of a rotation.
57 * This object is opaque to the user. Use the helper functions below to use it.
59 struct lttng_rotate_session_handle
;
62 * lttng rotate session command inputs.
65 * Return a newly allocated rotate session attribute object or NULL on error.
67 struct lttng_rotate_session_attr
*lttng_rotate_session_attr_create(void);
70 * Free a given rotate ssession attribute object.
72 void lttng_rotate_session_attr_destroy(struct lttng_rotate_session_attr
*attr
);
75 * Set the name of the session to rotate.
77 int lttng_rotate_session_attr_set_session_name(
78 struct lttng_rotate_session_attr
*attr
, const char *session_name
);
81 * lttng rotate session handle functions.
84 * Get the status from a handle.
86 enum lttng_rotate_status
lttng_rotate_session_get_status(
87 struct lttng_rotate_session_handle
*rotate_handle
);
90 * If the rotation is complete, returns 0, allocate path and set
91 * it to the path of the readable chunk, the caller is responsible to free it.
92 * Otherwise return a negative value.
94 int lttng_rotate_session_get_output_path(
95 struct lttng_rotate_session_handle
*rotate_handle
,
99 * Destroy a lttng_rotate_session handle allocated by lttng_rotate_session()
101 void lttng_rotate_session_handle_destroy(
102 struct lttng_rotate_session_handle
*rotate_handle
);
105 * Rotate the output folder of the session
107 * On success, handle is allocated and can be used to monitor the progress
108 * of the rotation with lttng_rotate_session_pending(). The handle must be freed
109 * by the caller with lttng_rotate_session_handle_destroy().
111 * Return 0 if the rotate action was successfully launched or a negative
112 * LTTng error code on error.
114 extern int lttng_rotate_session(struct lttng_rotate_session_attr
*attr
,
115 struct lttng_rotate_session_handle
**rotate_handle
);
118 * For a given session name, this call checks if a session rotation is still in
119 * progress or has completed.
121 * Return 0 if the rotation is complete, in this case, the output path can be
122 * fetched with lttng_rotate_session_get_output_path().
123 * Return 1 if the rotate is still pending.
124 * Return a negative LTTng error code on error (readable with lttng_strerror).
126 extern int lttng_rotate_session_pending(
127 struct lttng_rotate_session_handle
*rotate_handle
);
133 #endif /* LTTNG_ROTATE_H */