Fix: return error if not in overwrite mode and file exists
authorDavid Goulet <dgoulet@efficios.com>
Wed, 12 Mar 2014 20:41:43 +0000 (16:41 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 12 Mar 2014 20:50:31 +0000 (16:50 -0400)
For the save command, if the file is found and we are not in overwrite
mode, send back an new error indicating the client that the file already
exists.

Fixes #762

Signed-off-by: David Goulet <dgoulet@efficios.com>
include/lttng/lttng-error.h
src/bin/lttng-sessiond/save.c
src/common/error.c

index 87b6f84d6d0a380b7c33cad3914e45da4e40c925..d3f71880f136dac71e6cc554392fff362bc17d7a 100644 (file)
@@ -115,7 +115,7 @@ enum lttng_error_code {
        LTTNG_ERR_KERN_EVENT_ENOSYS      = 82,  /* Kernel event type not supported */
        LTTNG_ERR_NEED_CHANNEL_NAME      = 83,  /* Non-default channel exists within session: channel name needs to be specified with '-c name' */
        LTTNG_ERR_NO_UST                 = 84,  /* LTTng-UST tracer is not supported. Please rebuild lttng-tools with lttng-ust support enabled. */
-       /* 85 */
+       LTTNG_ERR_SAVE_FILE_EXIST        = 85,  /* Session file already exists. */
        /* 86 */
        /* 87 */
        /* 88 */
index fd6c5d894e6f9a7ef099ba3a01088bb114bd870b..fe5461cb1e34f30fbd43b9c3b3018e28c6adc783 100644 (file)
@@ -1478,7 +1478,8 @@ int save_session(struct ltt_session *session,
        config_file_path[len] = '\0';
 
        if (!access(config_file_path, F_OK) && !attr->overwrite) {
-               /* A file with the same name already exists, skip */
+               /* File exists, notify the user since the overwrite flag is off. */
+               ret = LTTNG_ERR_SAVE_FILE_EXIST;
                goto end;
        }
 
index 53b55b93f88385ebb74ec89ab70872bb1b8b30e2..b66c12d946e03dec8a66cd1e713e38344392ed01 100644 (file)
@@ -117,6 +117,7 @@ static const char *error_string_array[] = {
        [ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_NODATA) ] = "No data available in snapshot",
        [ ERROR_INDEX(LTTNG_ERR_NO_CHANNEL) ] = "No channel found in the session",
        [ ERROR_INDEX(LTTNG_ERR_SESSION_INVALID_CHAR) ] = "Invalid character found in session name",
+       [ ERROR_INDEX(LTTNG_ERR_SAVE_FILE_EXIST) ] = "Session file already exists",
 
        /* Last element */
        [ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"
This page took 0.027912 seconds and 5 git commands to generate.