Add --with-lttng-ust-prefix config option.
[lttng-tools.git] / src / bin / lttng / lttng.c
index be673f94f2d0ab552c4f9daa3f90bff70637b2d1..79a28ba82da1c94eb4028a874e03d1a2e654224c 100644 (file)
@@ -74,8 +74,8 @@ static struct cmd_struct commands[] =  {
        { "version", cmd_version},
        { "calibrate", cmd_calibrate},
        { "view", cmd_view},
-       { "enable-consumer", cmd_enable_consumer}, /* OBSELETE */
-       { "disable-consumer", cmd_disable_consumer}, /*OBSELETE */
+       { "enable-consumer", cmd_enable_consumer}, /* OBSOLETE */
+       { "disable-consumer", cmd_disable_consumer}, /* OBSOLETE */
        { NULL, NULL}   /* Array closure */
 };
 
@@ -272,7 +272,7 @@ static int handle_command(int argc, char **argv)
        }
 
        /* Command not found */
-       ret = -1;
+       ret = CMD_UNDEFINED;
 
 end:
        return ret;
@@ -346,39 +346,43 @@ end:
 static int check_sessiond(void)
 {
        int ret;
-       char *pathname = NULL, *alloc_pathname = NULL;
+       char *pathname = NULL;
 
        ret = lttng_session_daemon_alive();
        if (ret == 0) { /* not alive */
                /* Try command line option path */
-               if (opt_sessiond_path != NULL) {
-                       ret = access(opt_sessiond_path, F_OK | X_OK);
-                       if (ret < 0) {
-                               ERR("No such file or access denied: %s", opt_sessiond_path);
-                               goto end;
-                       }
-                       pathname = opt_sessiond_path;
-               } else {
-                       /* Try LTTNG_SESSIOND_PATH env variable */
+               pathname = opt_sessiond_path;
+
+               /* Try LTTNG_SESSIOND_PATH env variable */
+               if (pathname == NULL) {
                        pathname = getenv(DEFAULT_SESSIOND_PATH_ENV);
                }
 
-               /* Let's rock and roll */
+               /* Try with configured path */
                if (pathname == NULL) {
-                       ret = asprintf(&alloc_pathname, INSTALL_BIN_PATH "/lttng-sessiond");
-                       if (ret < 0) {
-                               perror("asprintf spawn sessiond");
-                               goto end;
+                       if (CONFIG_SESSIOND_BIN[0] != '\0') {
+                               pathname = CONFIG_SESSIOND_BIN;
                        }
-                       pathname = alloc_pathname;
+               }
+
+               /* Let's rock and roll while trying the default path */
+               if (pathname == NULL) {
+                       pathname = INSTALL_BIN_PATH "/lttng-sessiond";
+               }
+
+               DBG("Session daemon at: %s", pathname);
+
+               /* Check existence and permissions */
+               ret = access(pathname, F_OK | X_OK);
+               if (ret < 0) {
+                       ERR("No such file or access denied: %s", pathname);
+                       goto end;
                }
 
                ret = spawn_sessiond(pathname);
                if (ret < 0) {
                        ERR("Problem occurred when starting %s", pathname);
                }
-
-               free(alloc_pathname);
        }
 end:
        return ret;
@@ -495,6 +499,9 @@ static int parse_args(int argc, char **argv)
        case CMD_FATAL:
                ERR("Fatal error");
                break;
+       case CMD_UNSUPPORTED:
+               ERR("Unsupported command");
+               break;
        case -1:
                usage(stderr);
                ret = 1;
This page took 0.024873 seconds and 5 git commands to generate.