Fix: typo in the create command help and man page
[lttng-tools.git] / src / bin / lttng / commands / create.c
index 6c7ab786e5d25fc90ca4b2606ee67a6bb9ff0f49..491ffd548ae6deb11c149f5819b572e98981052c 100644 (file)
@@ -52,9 +52,9 @@ static struct poptOption long_options[] = {
        {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
        {"output", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL},
        {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
-       {"set-uri",        'U', POPT_ARG_STRING, &opt_url, 0, 0, 0},
-       {"ctrl-uri",       'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
-       {"data-uri",       'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
+       {"set-url",        'U', POPT_ARG_STRING, &opt_url, 0, 0, 0},
+       {"ctrl-url",       'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
+       {"data-url",       'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
        {"no-consumer",      0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0},
        {"disable-consumer", 0, POPT_ARG_VAL, &opt_disable_consumer, 1, 0, 0},
        {0, 0, 0, 0, 0, 0, 0}
@@ -92,8 +92,10 @@ static void usage(FILE *ofp)
        fprintf(ofp, "  -C, --ctrl-url=URL   Set control path URL. (Must use -D also)\n");
        fprintf(ofp, "  -D, --data-url=URL   Set data path URL. (Must use -C also)\n");
        fprintf(ofp, "      --no-consumer    Don't activate a consumer for this session.\n");
+       fprintf(ofp, "                       OBSELETE\n");
        fprintf(ofp, "      --disable-consumer\n");
        fprintf(ofp, "                       Disable consumer for this session.\n");
+       fprintf(ofp, "                       OBSELETE\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Please refer to the man page (lttng(1)) for more information on network\n");
        fprintf(ofp, "streaming mechanisms and explanation of the control and data port\n");
@@ -170,79 +172,6 @@ error:
        return ret;
 }
 
-/*
- * For a session name, enable the consumer.
- */
-static int enable_consumer(const char *session_name)
-{
-       int ret;
-       struct lttng_handle *handle;
-       struct lttng_domain dom;
-
-       assert(session_name);
-
-       /*
-        * Set handle with the session name and the domain set to 0. This means to
-        * the session daemon that the next action applies on the tracing session
-        * rather then the domain specific session.
-        *
-        * XXX: This '0' value should be a domain enum value.
-        */
-       memset(&dom, 0, sizeof(dom));
-
-       handle = lttng_create_handle(session_name, 0);
-       if (handle == NULL) {
-               ret = CMD_FATAL;
-               goto error;
-       }
-
-       ret = lttng_enable_consumer(handle);
-       if (ret < 0) {
-               goto error;
-       }
-
-       MSG("Consumer enabled for session %s", session_name);
-
-error:
-       lttng_destroy_handle(handle);
-       return ret;
-}
-
-/*
- * For a session name, disable the consumer.
- */
-static int disable_consumer(const char *session_name)
-{
-       int ret;
-       struct lttng_handle *handle;
-
-       assert(session_name);
-
-       /*
-        * Set handle with the session name and the domain set to 0. This means to
-        * the session daemon that the next action applies on the tracing session
-        * rather then the domain specific session.
-        *
-        * XXX: This '0' value should be a domain enum value.
-        */
-       handle = lttng_create_handle(session_name, 0);
-       if (handle == NULL) {
-               ret = CMD_FATAL;
-               goto error;
-       }
-
-       ret = lttng_disable_consumer(handle);
-       if (ret < 0) {
-               goto error;
-       }
-       free(handle);
-
-       MSG("Consumer disabled for session %s", session_name);
-
-error:
-       return ret;
-}
-
 /*
  *  Create a tracing session.
  *  If no name is specified, a default name is generated.
@@ -254,7 +183,7 @@ static int create_session(void)
        int ret;
        char *session_name = NULL, *traces_path = NULL, *alloc_path = NULL;
        char *alloc_url = NULL, *url = NULL, datetime[16];
-       char session_name_date[NAME_MAX], *print_str_url = NULL;
+       char session_name_date[NAME_MAX + 17], *print_str_url = NULL;
        time_t rawtime;
        struct tm *timeinfo;
 
@@ -274,6 +203,12 @@ static int create_session(void)
                session_name = session_name_date;
                DBG("Auto session name set to %s", session_name_date);
        } else {
+               if (strlen(opt_session_name) > NAME_MAX) {
+                       ERR("Session name too long. Length must be lower or equal to %d",
+                                       NAME_MAX);
+                       ret = LTTNG_ERR_SESSION_FAIL;
+                       goto error;
+               }
                if (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
                                        strlen(DEFAULT_SESSION_NAME)) == 0 &&
                                strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME)) {
@@ -291,10 +226,7 @@ static int create_session(void)
                }
        }
 
-       if (opt_no_consumer) {
-               url = NULL;
-               print_str_url = "";
-       } else if (opt_output_path != NULL) {
+       if (opt_output_path != NULL) {
                traces_path = utils_expand_path(opt_output_path);
                if (traces_path == NULL) {
                        ret = CMD_ERROR;
@@ -338,6 +270,8 @@ static int create_session(void)
                print_str_url = alloc_url + strlen("file://");
        }
 
+       assert(url);
+
        ret = _lttng_create_session_ext(session_name, url, datetime);
        if (ret < 0) {
                /* Don't set ret so lttng can interpret the sessiond error. */
@@ -360,11 +294,6 @@ static int create_session(void)
                if (ret < 0) {
                        goto error;
                }
-
-               ret = enable_consumer(session_name);
-               if (ret < 0) {
-                       goto error;
-               }
        } else if ((!opt_ctrl_url && opt_data_url) ||
                        (opt_ctrl_url && !opt_data_url)) {
                ERR("You need both control and data URL.");
@@ -372,13 +301,6 @@ static int create_session(void)
                goto error;
        }
 
-       if (opt_disable_consumer && !opt_no_consumer) {
-               ret = disable_consumer(session_name);
-               if (ret < 0) {
-                       goto error;
-               }
-       }
-
        /* Init lttng session config */
        ret = config_init(session_name);
        if (ret < 0) {
@@ -428,6 +350,18 @@ int cmd_create(int argc, const char **argv)
                }
        }
 
+       if (opt_no_consumer) {
+               MSG("The option --no-consumer is obsolete.");
+               ret = CMD_WARNING;
+               goto end;
+       }
+
+       if (opt_disable_consumer) {
+               MSG("The option --disable-consumer is obsolete.");
+               ret = CMD_WARNING;
+               goto end;
+       }
+
        opt_session_name = (char*) poptGetArg(pc);
 
        ret = create_session();
This page took 0.026943 seconds and 5 git commands to generate.