projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bad strncmp length
[lttng-tools.git]
/
lttng
/
commands
/
create.c
diff --git
a/lttng/commands/create.c
b/lttng/commands/create.c
index 4a64d8a76f87bec5f0aea945602765d7b16d90b1..b8bbdb7e7ba453434279a320b538fddb36dd9f9d 100644
(file)
--- a/
lttng/commands/create.c
+++ b/
lttng/commands/create.c
@@
-3,8
+3,8
@@
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation;
either
version 2
- * of the License
, or (at your option) any later version
.
+ * as published by the Free Software Foundation;
only
version 2
+ * of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-26,9
+26,9
@@
#include <time.h>
#include <unistd.h>
#include <time.h>
#include <unistd.h>
-#include "cmd.h"
-#include "conf.h"
-#include "utils.h"
+#include "
../
cmd.h"
+#include "
../
conf.h"
+#include "
../
utils.h"
static char *opt_output_path;
static char *opt_session_name;
static char *opt_output_path;
static char *opt_session_name;
@@
-64,21
+64,28
@@
static void usage(FILE *ofp)
*/
static int create_session()
{
*/
static int create_session()
{
- int ret;
- char
name[NAME_MAX
];
+ int ret
, have_name = 0
;
+ char
datetime[16
];
char *session_name, *traces_path = NULL, *alloc_path = NULL;
time_t rawtime;
struct tm *timeinfo;
char *session_name, *traces_path = NULL, *alloc_path = NULL;
time_t rawtime;
struct tm *timeinfo;
+ /* Get date and time for automatic session name/path */
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+ strftime(datetime, sizeof(datetime), "%Y%m%d-%H%M%S", timeinfo);
+
/* Auto session name creation */
if (opt_session_name == NULL) {
/* Auto session name creation */
if (opt_session_name == NULL) {
- time(&rawtime);
- timeinfo = localtime(&rawtime);
- strftime(name, sizeof(name), "auto-%Y%m%d-%H%M%S", timeinfo);
- session_name = name;
+ ret = asprintf(&session_name, "auto-%s", datetime);
+ if (ret < 0) {
+ perror("asprintf session name");
+ goto error;
+ }
DBG("Auto session name set to %s", session_name);
} else {
session_name = opt_session_name;
DBG("Auto session name set to %s", session_name);
} else {
session_name = opt_session_name;
+ have_name = 1;
}
/* Auto output path */
}
/* Auto output path */
@@
-91,7
+98,8
@@
static int create_session()
goto error;
}
goto error;
}
- ret = asprintf(&traces_path, "%s/" LTTNG_DEFAULT_TRACE_DIR_NAME, alloc_path);
+ ret = asprintf(&traces_path, "%s/" LTTNG_DEFAULT_TRACE_DIR_NAME
+ "/%s-%s", alloc_path, session_name, datetime);
if (ret < 0) {
perror("asprintf trace dir name");
goto error;
if (ret < 0) {
perror("asprintf trace dir name");
goto error;
@@
-108,11
+116,18
@@
static int create_session()
/* Init lttng session config */
ret = config_init(session_name);
if (ret < 0) {
/* Init lttng session config */
ret = config_init(session_name);
if (ret < 0) {
+ if (ret == -1) {
+ ret = CMD_ERROR;
+ }
goto error;
}
MSG("Session %s created.", session_name);
goto error;
}
MSG("Session %s created.", session_name);
- MSG("Traces will be written in %s ", traces_path);
+ if (have_name) {
+ MSG("Traces will be written in %s" , traces_path);
+ } else {
+ MSG("Traces will be written in %s/%s", traces_path, session_name);
+ }
ret = CMD_SUCCESS;
ret = CMD_SUCCESS;
This page took
0.025096 seconds
and
4
git commands to generate.