[ofw] [PATCH] opensm: create all directories in database path

Hal Rosenstock hal.rosenstock at gmail.com
Thu Apr 21 04:49:44 PDT 2011


On Wed, Apr 20, 2011 at 5:57 PM, Hefty, Sean <sean.hefty at intel.com> wrote:
> 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) {

Latest main/Linux version of this file shows:

        /* 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);
#else

so this hadn't been pushed for the previous change. Shouldn't these be
in sync to make Windows port easier next time around ?

-- Hal

> +       {
> +               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;
>                }
>
> _______________________________________________
> ofw mailing list
> ofw at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw
>



More information about the ofw mailing list