[ofa-general] [PATCH][MINOR] OpenSM: Handle conf file open failures better

Hal Rosenstock halr at voltaire.com
Thu Mar 29 14:17:21 PDT 2007


OpenSM: Handle conf file open failures better

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

diff --git a/osm/include/opensm/osm_subnet.h b/osm/include/opensm/osm_subnet.h
index ade73ac..fc52b5e 100644
--- a/osm/include/opensm/osm_subnet.h
+++ b/osm/include/opensm/osm_subnet.h
@@ -1088,7 +1088,7 @@ osm_subn_set_default_opt(
 *
 * SYNOPSIS
 */
-void
+ib_api_status_t
 osm_subn_parse_conf_file(
   IN osm_subn_opt_t* const p_opt );
 /*
@@ -1098,7 +1098,7 @@ osm_subn_parse_conf_file(
 *		[in] Pointer to the subnet options structure.
 *
 * RETURN VALUES
-*	None
+*	IB_SUCCESS, IB_ERROR
 *
 * NOTES
 *  Assumes the conf file is part of the cache dir which defaults to
@@ -1118,7 +1118,7 @@ osm_subn_parse_conf_file(
 *
 * SYNOPSIS
 */
-void
+ib_api_status_t
 osm_subn_rescan_conf_file(
   IN osm_subn_opt_t* const p_opts );
 /*
@@ -1128,7 +1128,7 @@ osm_subn_rescan_conf_file(
 *		[in] Pointer to the subnet options structure.
 *
 * RETURN VALUES
-*	None
+*	IB_SUCCESS, IB_ERROR
 *
 * NOTES
 *  This uses the same file as osm_subn_parse_conf_file()
@@ -1144,7 +1144,7 @@ osm_subn_rescan_conf_file(
 *
 * SYNOPSIS
 */
-void
+ib_api_status_t
 osm_subn_write_conf_file(
   IN osm_subn_opt_t* const p_opt );
 /*
@@ -1154,7 +1154,7 @@ osm_subn_write_conf_file(
 *		[in] Pointer to the subnet options structure.
 *
 * RETURN VALUES
-*	None
+*	IB_SUCCESS, IB_ERROR
 *
 * NOTES
 *  Assumes the conf file is part of the cache dir which defaults to
diff --git a/osm/opensm/main.c b/osm/opensm/main.c
index a3f892b..5fb58eb 100644
--- a/osm/opensm/main.c
+++ b/osm/opensm/main.c
@@ -651,7 +651,8 @@ main(
   printf("%s\n", OSM_VERSION);
 
   osm_subn_set_default_opt(&opt);
-  osm_subn_parse_conf_file(&opt);
+  if (osm_subn_parse_conf_file(&opt) != IB_SUCCESS)
+    printf("\nosm_subn_parse_conf_file failed!\n");
 
   printf("Command Line Arguments:\n");
   do
@@ -969,7 +970,12 @@ main(
   }
 
   if ( cache_options == TRUE )
-    osm_subn_write_conf_file( &opt );
+  {
+    if (osm_subn_write_conf_file( &opt ) != IB_SUCCESS)
+    {
+      printf( "\nosm_subn_write_conf_file failed!\n" );
+    }
+  }
 
   status = osm_opensm_bind( &osm, opt.guid );
   if( status != IB_SUCCESS )
diff --git a/osm/opensm/osm_state_mgr.c b/osm/opensm/osm_state_mgr.c
index 8061231..196026e 100644
--- a/osm/opensm/osm_state_mgr.c
+++ b/osm/opensm/osm_state_mgr.c
@@ -1931,8 +1931,13 @@ osm_state_mgr_process(
                p_mgr->p_subn->subnet_initialization_error = FALSE;
 
                /* rescan configuration updates */
-               osm_subn_rescan_conf_file(&p_mgr->p_subn->opt);
-
+               status = osm_subn_rescan_conf_file(&p_mgr->p_subn->opt);
+               if( status != IB_SUCCESS )
+               {
+                 osm_log( p_mgr->p_log, OSM_LOG_ERROR,
+                         "osm_state_mgr_process: ERR 331A: "
+                         "osm_subn_rescan_conf_file failed\n" );
+               }
                status = __osm_state_mgr_sweep_hop_0( p_mgr );
                if( status == IB_SUCCESS )
                {
diff --git a/osm/opensm/osm_subnet.c b/osm/opensm/osm_subnet.c
index 46315a5..746fbd1 100644
--- a/osm/opensm/osm_subnet.c
+++ b/osm/opensm/osm_subnet.c
@@ -732,7 +732,7 @@ subn_dump_qos_options(
 
 /**********************************************************************
  **********************************************************************/
-void
+ib_api_status_t
 osm_subn_rescan_conf_file(
   IN osm_subn_opt_t* const p_opts )
 {
@@ -751,7 +751,7 @@ osm_subn_rescan_conf_file(
   
   opts_file = fopen(file_name, "r");
   if (!opts_file)
-    return;
+    return IB_ERROR;
 
   while (fgets(line, 1023, opts_file) != NULL)
   {
@@ -779,6 +779,8 @@ osm_subn_rescan_conf_file(
     }
   }
   fclose(opts_file);
+
+  return IB_SUCCESS;
 }
 
 /**********************************************************************
@@ -825,7 +827,7 @@ osm_subn_verify_conf_file(
 
 /**********************************************************************
  **********************************************************************/
-void
+ib_api_status_t
 osm_subn_parse_conf_file(
   IN osm_subn_opt_t* const p_opts )
 {
@@ -844,7 +846,7 @@ osm_subn_parse_conf_file(
   
   opts_file = fopen(file_name, "r");
   if (!opts_file)
-    return;
+    return IB_ERROR;
 
   while (fgets(line, 1023, opts_file) != NULL)
   {
@@ -1090,11 +1092,13 @@ osm_subn_parse_conf_file(
   fclose(opts_file);
 
   osm_subn_verify_conf_file(p_opts);
+
+  return IB_SUCCESS;
 }
 
 /**********************************************************************
  **********************************************************************/
-void
+ib_api_status_t
 osm_subn_write_conf_file(
   IN osm_subn_opt_t* const p_opts )
 {
@@ -1111,7 +1115,7 @@ osm_subn_write_conf_file(
   
   opts_file = fopen(file_name, "w");
   if (!opts_file)
-    return;
+    return IB_ERROR;
 
   fprintf( 
     opts_file,
@@ -1379,4 +1383,6 @@ osm_subn_write_conf_file(
   /* optional string attributes ... */
   
   fclose(opts_file);
+
+  return IB_SUCCESS;
 }






More information about the general mailing list