projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: sessiond: fix -Wshadow error in save.c
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
save.c
diff --git
a/src/bin/lttng-sessiond/save.c
b/src/bin/lttng-sessiond/save.c
index 3c4c3b2bce527045f7c1c9d3c09f00773fd68a07..f53a527f5a0231a90af7094db972fb5bac41b3b2 100644
(file)
--- a/
src/bin/lttng-sessiond/save.c
+++ b/
src/bin/lttng-sessiond/save.c
@@
-1109,7
+1109,6
@@
int save_agent_events(struct config_writer *writer,
rcu_read_lock();
cds_lfht_for_each_entry(agent->events->ht, &iter.iter, node, node) {
rcu_read_lock();
cds_lfht_for_each_entry(agent->events->ht, &iter.iter, node, node) {
- int ret;
struct agent_event *agent_event;
struct ltt_ust_event fake_event;
struct agent_event *agent_event;
struct ltt_ust_event fake_event;
@@
-2290,6
+2289,7
@@
int save_session(struct ltt_session *session,
struct config_writer *writer = NULL;
size_t session_name_len;
const char *provided_path;
struct config_writer *writer = NULL;
size_t session_name_len;
const char *provided_path;
+ int file_open_flags = O_CREAT | O_WRONLY | O_TRUNC;
assert(session);
assert(attr);
assert(session);
assert(attr);
@@
-2363,18
+2363,26
@@
int save_session(struct ltt_session *session,
len += sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION);
config_file_path[len] = '\0';
len += sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION);
config_file_path[len] = '\0';
- if (!access(config_file_path, F_OK) && !attr->overwrite) {
- /* File exists, notify the user since the overwrite flag is off. */
- ret = LTTNG_ERR_SAVE_FILE_EXIST;
- goto end;
+ if (!attr->overwrite) {
+ file_open_flags |= O_EXCL;
}
}
- fd = run_as_open(config_file_path,
O_CREAT | O_WRONLY | O_TRUNC
,
+ fd = run_as_open(config_file_path,
file_open_flags
,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
LTTNG_SOCK_GET_UID_CRED(creds), LTTNG_SOCK_GET_GID_CRED(creds));
if (fd < 0) {
PERROR("Could not create configuration file");
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
LTTNG_SOCK_GET_UID_CRED(creds), LTTNG_SOCK_GET_GID_CRED(creds));
if (fd < 0) {
PERROR("Could not create configuration file");
- ret = LTTNG_ERR_SAVE_IO_FAIL;
+ switch (errno) {
+ case EEXIST:
+ ret = LTTNG_ERR_SAVE_FILE_EXIST;
+ break;
+ case EACCES:
+ ret = LTTNG_ERR_EPERM;
+ break;
+ default:
+ ret = LTTNG_ERR_SAVE_IO_FAIL;
+ break;
+ }
goto end;
}
goto end;
}
This page took
0.023661 seconds
and
4
git commands to generate.