From: Jérémie Galarneau Date: Wed, 15 Jun 2016 20:58:54 +0000 (-0400) Subject: Implement create command --default-name option X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=e51a4200dade67836a99a2ca32a51b8267f12da5 Implement create command --default-name option Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index caa12d93e..62607a038 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -52,11 +52,13 @@ static int opt_no_consumer; static int opt_no_output; static int opt_snapshot; static unsigned int opt_live_timer; +static bool opt_default_name; enum { OPT_HELP = 1, OPT_LIST_OPTIONS, OPT_LIVE_TIMER, + OPT_DEFAULT_NAME, }; enum output_type { @@ -89,6 +91,7 @@ static struct poptOption long_options[] = { {"live", 0, POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL, 0, OPT_LIVE_TIMER, 0, 0}, {"shm-path", 0, POPT_ARG_STRING, &opt_shm_path, 0, 0, 0}, {"template-path", 0, POPT_ARG_STRING, &opt_template_path, 0, 0, 0}, + {"default-name", 0, POPT_ARG_NONE, NULL, OPT_DEFAULT_NAME, 0, 0}, {0, 0, 0, 0, 0, 0, 0} }; @@ -256,6 +259,11 @@ static int validate_command_options(enum session_type type) } } + if (opt_session_name && opt_default_name) { + ERR("A session name must not be provided if the --default-name option is used"); + ret = CMD_ERROR; + goto error; + } error: return ret; } @@ -1053,7 +1061,7 @@ static int create_session(void) goto error; } DBG("Session name from command option set to %s", base_session_name); - } else if (base_session_name) { + } else if (base_session_name && !opt_default_name) { printed_bytes = asprintf(&session_name_date, "%s-%s", base_session_name, datetime); if (printed_bytes < 0) { PERROR("Asprintf session name"); @@ -1470,6 +1478,9 @@ int cmd_create(int argc, const char **argv) DBG("Session live timer interval set to %d", opt_live_timer); break; } + case OPT_DEFAULT_NAME: + opt_default_name = true; + break; default: ret = CMD_UNDEFINED; goto end;