@@ -45,6 +45,7 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <opensm/osm_file_ids.h>
@@ -480,8 +481,8 @@ int osm_db_store(IN osm_db_domain_t * p_domain)
p_file = fopen(p_tmp_file_name, "w");
if (!p_file) {
OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6107: "
- "Failed to open the db file:%s for writing\n",
- p_domain_imp->file_name);
+ "Failed to open the db file:%s for writing: err:%s\n",
+ p_domain_imp->file_name, strerror(errno));
status = 1;
goto Exit;
}
@@ -489,19 +490,11 @@ int osm_db_store(IN osm_db_domain_t * p_domain)
st_foreach(p_domain_imp->p_hash, dump_tbl_entry, (st_data_t) p_file);
fclose(p_file);
- /* move the domain file */
- status = remove(p_domain_imp->file_name);
- if (status) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6109: "
- "Failed to remove file:%s (err:%u)\n",
- p_domain_imp->file_name, status);
- }
-
status = rename(p_tmp_file_name, p_domain_imp->file_name);
if (status) {
OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6108: "
- "Failed to rename the db file to:%s (err:%u)\n",
- p_domain_imp->file_name, status);
+ "Failed to rename the db file to:%s (err:%s)\n",
+ p_domain_imp->file_name, strerror(errno));
}
Exit:
cl_spinlock_release(&p_domain_imp->lock);