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>
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 */
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;
}
[ 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"