e7c3caeefb2e6dce8de041c7bf4e9c73e6888628
2 * Copyright (C) 2013 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "../command.h"
27 #include <lttng/save.h>
29 static char *opt_output_path
;
31 static int opt_save_all
;
39 static struct poptOption save_opts
[] = {
40 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
41 {"help", 'h', POPT_ARG_NONE
, 0, OPT_HELP
, 0, 0},
42 {"all", 'a', POPT_ARG_NONE
, 0, OPT_ALL
, 0, 0},
43 {"output-path", 'o', POPT_ARG_STRING
, &opt_output_path
, 0, 0, 0},
44 {"force", 'f', POPT_ARG_NONE
, 0, OPT_FORCE
, 0, 0},
51 static void usage(FILE *ofp
)
53 fprintf(ofp
, "usage: lttng save [OPTIONS] [SESSION]\n");
55 fprintf(ofp
, "Options:\n");
56 fprintf(ofp
, " -h, --help Show this help\n");
57 fprintf(ofp
, " -a, --all Save all sessions (default)\n");
58 fprintf(ofp
, " -o, --output-path Output path of the session configuration(s)\n");
59 fprintf(ofp
, " -f, --force Overwrite existing session configuration(s)\n");
63 * The 'save <options>' first level command
65 int cmd_save(int argc
, const char **argv
)
67 int ret
= CMD_SUCCESS
;
69 const char *session_name
= NULL
;
71 struct lttng_save_session_attr
*attr
;
73 pc
= poptGetContext(NULL
, argc
, argv
, save_opts
, 0);
74 poptReadDefaultConfig(pc
, 0);
76 while ((opt
= poptGetNextOpt(pc
)) != -1) {
95 session_name
= poptGetArg(pc
);
97 ERR("A session name must be provided if the \"all\" option is not used.");
101 DBG2("Session name: %s", session_name
);
104 attr
= lttng_save_session_attr_create();
110 if (lttng_save_session_attr_set_session_name(attr
, session_name
)) {
115 if (lttng_save_session_attr_set_overwrite(attr
, opt_force
)) {
120 if (lttng_save_session_attr_set_output_url(attr
,
126 ret
= lttng_save_session(attr
);
128 if (ret
== -LTTNG_ERR_SESS_NOT_FOUND
) {
129 ERR("Session '%s' not found", session_name
);
134 lttng_save_session_attr_destroy(attr
);
This page took 0.033053 seconds and 4 git commands to generate.