[ofw] [PATCH] opensm: create all directories in database path
Smith, Stan
stan.smith at intel.com
Wed Apr 20 17:06:09 PDT 2011
Looks good; I'm sure Uri will appreciate the update.
Thanks.
>-----Original Message-----
>From: Hefty, Sean
>Sent: Wednesday, April 20, 2011 2:58 PM
>To: Smith, Stan; ofw at lists.openfabrics.org
>Subject: [PATCH] opensm: create all directories in database path
>
>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 <sean.hefty at intel.com>
>---
> .../ulp/opensm/user/include/vendor/winosm_common.h | 1 +
> trunk/ulp/opensm/user/opensm/SOURCES | 1 +
> trunk/ulp/opensm/user/opensm/osm_db_files.c | 13 ++++++++-----
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
>diff --git a/trunk/ulp/opensm/user/include/vendor/winosm_common.h
>b/trunk/ulp/opensm/user/include/vendor/winosm_common.h
>index 91fdc13..0d9e291 100644
>--- a/trunk/ulp/opensm/user/include/vendor/winosm_common.h
>+++ b/trunk/ulp/opensm/user/include/vendor/winosm_common.h
>@@ -12,6 +12,7 @@
> #include <linux\arpa\inet.h>
> #include <stdarg.h>
> #include <ctype.h>
>+#include <shlobj.h>
>
> #include <complib\cl_debug.h>
> #define cl_is_debug osm_is_debug
>diff --git a/trunk/ulp/opensm/user/opensm/SOURCES b/trunk/ulp/opensm/user/opensm/SOURCES
>index 32302d4..622ac7d 100644
>--- a/trunk/ulp/opensm/user/opensm/SOURCES
>+++ b/trunk/ulp/opensm/user/opensm/SOURCES
>@@ -34,6 +34,7 @@ OSM_HOME=..
> TARGETLIBS= \
> $(SDK_LIB_PATH)\kernel32.lib \
> $(SDK_LIB_PATH)\ws2_32.lib \
>+ $(SDK_LIB_PATH)\shell32.lib \
> !if $(FREEBUILD)
> $(VENDOR_LIBS) \
> $(LIBPATH)\*\complib.lib \
>diff --git a/trunk/ulp/opensm/user/opensm/osm_db_files.c b/trunk/ulp/opensm/user/opensm/osm_db_files.c
>index 2fc8c53..3b7394e 100644
>--- a/trunk/ulp/opensm/user/opensm/osm_db_files.c
>+++ b/trunk/ulp/opensm/user/opensm/osm_db_files.c
>@@ -166,13 +166,16 @@ 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. */
>- if (!CreateDirectory(p_db_imp->db_dir_name, NULL)) {
>- DWORD gle = GetLastError();
>- if (gle != ERROR_ALREADY_EXISTS) {
>+ {
>+ int ret;
>+
>+ /* Check if the directory exists. If not - create it. */
>+ 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",
>- gle, p_db_imp->db_dir_name);
>+ ret, p_db_imp->db_dir_name);
> OSM_LOG_EXIT(p_log);
> return 1;
> }
More information about the ofw
mailing list