Commit 9e432086 authored by Robert Schmidt's avatar Robert Schmidt

FlexRAN control delegation: write/remove depending if payload present

parent 6e2c8d84
......@@ -434,10 +434,11 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_
RC.flexran[mod_id]->cache_name,
control_delegation_msg->name);
if (len >= sizeof(target)) {
LOG_E(FLEXRAN_AGENT, "target has been truncated, cannot write file\n");
LOG_E(FLEXRAN_AGENT, "target has been truncated, cannot write file name\n");
return 0;
}
if (control_delegation_msg->has_payload) {
/* use low-level API: check whether exists while creating so we can abort if
* it exists to not overwrite anything */
int fd = open(target, O_CREAT | O_WRONLY | O_EXCL, S_IRUSR | S_IWUSR);
......@@ -469,6 +470,12 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_
return 0;
}
}
} else {
LOG_W(FLEXRAN_AGENT, "remove file %s\n", target);
int rc = remove(target);
if (rc < 0)
LOG_E(FLEXRAN_AGENT, "cannot remove file %s: %s\n", target, strerror(errno));
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment