[openib-general] [PATCH] Opensm - osm_db_file.c - windows fixes

Yael Kalka yael at mellanox.co.il
Mon Feb 6 01:03:10 PST 2006


Hi Hal,

The following patch adds some changes in osm_db_file.c to match the
windows stack.

Thanks,
Yael

Signed-off-by:  Yael Kalka <yael at mellanox.co.il>

Index: opensm/osm_db_files.c
===================================================================
--- opensm/osm_db_files.c       (revision 5307)
+++ opensm/osm_db_files.c       (working copy)
@@ -172,6 +172,12 @@ osm_db_init(
   if ( p_db_imp->db_dir_name == NULL )
     p_db_imp->db_dir_name = OSM_DEFAULT_CACHE_DIR;
 
+  /* create the directory if it doesn't exist */
+  /* There is difference between creating in windows and in linux */
+#ifdef __WIN__
+  /* Check if the directory exists. If not - create it. */
+  CreateDirectory(p_db_imp->db_dir_name, NULL);
+#else /* __WIN__ */  
   /* make sure the directory exists */
   if (lstat(p_db_imp->db_dir_name, &dstat))
   {
@@ -185,6 +191,7 @@ osm_db_init(
       return 1;
     }
   }
+#endif
 
   p_db->p_log = p_log;
   p_db->p_db_imp = (void*)p_db_imp;
@@ -466,6 +473,14 @@ osm_db_store(
   fclose(p_file);
 
   /* move the domain file */
+  status = remove(p_domain_imp->file_name);
+  if (status)
+  {
+    osm_log( p_log, OSM_LOG_ERROR,
+             "osm_db_store: ERR 6909: "
+             " Fail 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)
   {




More information about the general mailing list