Replace CreateDirectory with SHCreateDirectoryEx, so that
intermediate directories in the database path are created.

This fixes an issue where opensm fails to start unless the
path has been created beforehand.

Signed-off-by: Sean Hefty <[email protected]>
---
This will sync the opensm.git tree with the windows svn repository
for this patch.  This is simply to make future updates easier.
I do not see that the other files that changed are part of git.
If no one objects, I'll commit to svn once pulled into git.

 opensm/osm_db_files.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/opensm/osm_db_files.c b/opensm/osm_db_files.c
index 18ac830..6e9a676
--- a/opensm/osm_db_files.c
+++ b/opensm/osm_db_files.c
@@ -169,8 +169,19 @@ int osm_db_init(IN osm_db_t * p_db, IN osm_log_t * p_log)
        /* Create the directory if it doesn't exist */
        /* 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);
+       {
+               int ret;
+
+               ret = SHCreateDirectoryEx(NULL, p_db_imp->db_dir_name, NULL);
+               if (ret != ERROR_SUCCESS && ret != ERROR_ALREADY_EXISTS &&
+                       ret != ERROR_FILE_EXISTS) {
+                       OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0x%x: "
+                               "Failed to create the db directory:%s\n",
+                               ret, 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)) {


_______________________________________________
ofw mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw

Reply via email to