From a71278945fef227acf8f94d7eefc947ede6f439e Mon Sep 17 00:00:00 2001 From: Stan Smith Date: Thu, 16 Sep 2010 14:35:24 +0000 Subject: [PATCH] [OPENSM] When creating the opensm database file directory, return an error if the actual createDirectory operation fails. git-svn-id: svn://openib.tc.cornell.edu/gen1@2932 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- branches/WOF2-3/ulp/opensm/user/opensm/osm_db_files.c | 11 ++++++++++- trunk/ulp/opensm/user/opensm/osm_db_files.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/branches/WOF2-3/ulp/opensm/user/opensm/osm_db_files.c b/branches/WOF2-3/ulp/opensm/user/opensm/osm_db_files.c index 5b4dedd0..2fc8c53e 100644 --- a/branches/WOF2-3/ulp/opensm/user/opensm/osm_db_files.c +++ b/branches/WOF2-3/ulp/opensm/user/opensm/osm_db_files.c @@ -167,7 +167,16 @@ int osm_db_init(IN osm_db_t * p_db, IN osm_log_t * p_log) /* There is a difference in creating directory between windows and linux */ #ifdef __WIN__ /* Check if the directory exists. If not - create it. */ - CreateDirectory(p_db_imp->db_dir_name, NULL); + if (!CreateDirectory(p_db_imp->db_dir_name, NULL)) { + DWORD gle = GetLastError(); + if (gle != ERROR_ALREADY_EXISTS) { + OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0x%x: " + "Failed to create the db directory:%s\n", + gle, p_db_imp->db_dir_name); + OSM_LOG_EXIT(p_log); + return 1; + } + } #else /* __WIN__ */ /* make sure the directory exists */ if (lstat(p_db_imp->db_dir_name, &dstat)) { diff --git a/trunk/ulp/opensm/user/opensm/osm_db_files.c b/trunk/ulp/opensm/user/opensm/osm_db_files.c index 5b4dedd0..2fc8c53e 100644 --- a/trunk/ulp/opensm/user/opensm/osm_db_files.c +++ b/trunk/ulp/opensm/user/opensm/osm_db_files.c @@ -167,7 +167,16 @@ int osm_db_init(IN osm_db_t * p_db, IN osm_log_t * p_log) /* There is a difference in creating directory between windows and linux */ #ifdef __WIN__ /* Check if the directory exists. If not - create it. */ - CreateDirectory(p_db_imp->db_dir_name, NULL); + if (!CreateDirectory(p_db_imp->db_dir_name, NULL)) { + DWORD gle = GetLastError(); + if (gle != ERROR_ALREADY_EXISTS) { + OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0x%x: " + "Failed to create the db directory:%s\n", + gle, p_db_imp->db_dir_name); + OSM_LOG_EXIT(p_log); + return 1; + } + } #else /* __WIN__ */ /* make sure the directory exists */ if (lstat(p_db_imp->db_dir_name, &dstat)) { -- 2.46.0