]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
Add -e flag to main in order to enable starting a new log file,
authoreitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 12 Oct 2005 06:25:26 +0000 (06:25 +0000)
committereitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 12 Oct 2005 06:25:26 +0000 (06:25 +0000)
instead of accumulating it.

git-svn-id: svn://openib.tc.cornell.edu/gen1@111 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/opensm/user/ibtrapgen/ibtrapgen.c
trunk/ulp/opensm/user/include/opensm/osm_log.h
trunk/ulp/opensm/user/include/opensm/osm_subnet.h
trunk/ulp/opensm/user/opensm/cl_event_wheel.c
trunk/ulp/opensm/user/opensm/main.c
trunk/ulp/opensm/user/opensm/osm_opensm.c
trunk/ulp/opensm/user/opensm/osm_subnet.c
trunk/ulp/opensm/user/osmtest/osmtest.c

index c6bd3a24a7c4dbdcb395d417d50343416b6e4626..f5663a54d49f99189d07f4a91380a8ced86f38ae 100644 (file)
@@ -113,7 +113,7 @@ ibtrapgen_init( IN ibtrapgen_t * const p_ibtrapgen,
   p_ibtrapgen->p_log = (osm_log_t *)cl_malloc(sizeof(osm_log_t));
   osm_log_construct( p_ibtrapgen->p_log );
   status = osm_log_init( p_ibtrapgen->p_log, p_opt->force_log_flush,
-                         0x0001, p_opt->log_file );
+                         0x0001, p_opt->log_file, TRUE );
   if( status != IB_SUCCESS )
     return ( status );
 
index c84355f80c874948b6614d1cd08e7097063b9fc3..3337794a7bdfdfb59be0c9e1b2da6bc29007a001 100644 (file)
@@ -230,7 +230,8 @@ osm_log_init(
   IN osm_log_t* const p_log,
   IN const boolean_t flush,
   IN const uint8_t log_flags,
-  IN const char *log_file)
+  IN const char *log_file,
+  IN const boolean_t accum_log_file )
 {
   p_log->level = log_flags;
   p_log->flush = flush;
@@ -241,10 +242,18 @@ osm_log_init(
   }
   else
   {
+    if (accum_log_file)
     p_log->out_port = fopen(log_file,"a+");
+    else
+      p_log->out_port = fopen(log_file,"w+");
+    
     if (!p_log->out_port)
     {
+      if (accum_log_file)
       printf("Cannot open %s for appending. Permission denied\n", log_file);
+      else
+        printf("Cannot open %s for writing. Permission denied\n", log_file);
+
       return(IB_UNKNOWN_ERROR);
     }
   }
index 4e0793d8fe8ff1bf45303d972fa29b8b7663f7bd..2ec5a2abdd0c4f92047badfdfcaeb3a89e7f87fa 100644 (file)
@@ -217,6 +217,7 @@ typedef struct _osm_subn_opt
   uint8_t                  log_flags;
   char *                   dump_files_dir;
   char *                   log_file;
+  boolean_t                accum_log_file;
   cl_map_t                 port_pro_ignore_guids;
   boolean_t                port_profile_switch_nodes;
   uint32_t                 max_port_profile;
@@ -316,6 +317,10 @@ typedef struct _osm_subn_opt
 *  log_file
 *     Name of the log file (or NULL) for stdout.
 *
+*  accum_log_file
+*     If TRUE (default) - the log file will be accumulated.
+*     If FALSE - the log file will be erased before starting current opensm run.
+*
 *  port_pro_ignore_guids
 *     A map of guids to be ignored by port profiling.
 *
index e23d51c2ee67b4b9631586b9d55ce86aa2fc4f3d..97cceb2b65ddbd703359e0229c781df6475740b6 100644 (file)
@@ -604,7 +604,7 @@ main ()
   cl_event_wheel_construct( &event_wheel );
 
   /* init */
-  osm_log_init( &log, TRUE, 0xff, NULL);
+  osm_log_init( &log, TRUE, 0xff, NULL, FALSE);
   cl_event_wheel_init( &event_wheel, &log );
 
   /* Start Playing */
index a5b46512c5df04ef71855ed927ce4a29ad200e8d..8059ec503b3ce1a1898cec38041cc0cd5eabefd3 100644 (file)
@@ -160,6 +160,11 @@ show_usage(void)
           "          This option defines the log to be the given file.\n"
           "          By default the log goes to /var/log/osm.log.\n"
           "          For the log to go to standard output use -f stdout.\n\n");
+  printf( "-e\n"
+          "--erase_log_file\n"
+          "          This option will cause deletion of the log file \n"
+          "          (if it previously exists). By default, the log file \n"
+          "          is accumulative.\n\n");
   printf( "-v\n"
           "--verbose\n"
           "          This option increases the log verbosity level.\n"
@@ -449,7 +454,7 @@ main(
   boolean_t             cache_options = FALSE;
   char                 *ignore_guids_file_name = NULL;
   uint32_t              val;
-  const char * const    short_option = "i:f:d:g:l:s:t:vVhorc";
+  const char * const    short_option = "i:f:ed:g:l:s:t:vVhorc";
 
   /*
     In the array below, the 2nd parameter specified the number
@@ -469,6 +474,7 @@ main(
       {  "verbose",       0, NULL, 'v'},
       {  "D",             1, NULL, 'D'},
       {  "log_file",      1, NULL, 'f'},
+      {  "erase_log_file",0, NULL, 'e'},
       {  "maxsmps",       1, NULL, 'n'},
       {  "V",             0, NULL, 'V'},
       {  "help",          0, NULL, 'h'},
@@ -618,6 +624,11 @@ main(
         opt.log_file = optarg;
       break;
 
+    case 'e':
+      opt.accum_log_file = FALSE;
+      printf(" Erasing existing(old) log file\n");
+      break;
+
     case 'v':
       log_flags = (log_flags <<1 )|1;
       printf(" Verbose option -v (log flags = 0x%X)\n", log_flags );
index 2e800d18d9741a3721be6b5ed60f34eb0003c878..925d227ec8f6ab32cb3cc4d06101b6b8b1c8403b 100644 (file)
@@ -202,7 +202,7 @@ osm_opensm_init(
    osm_opensm_construct( p_osm );
 
    status = osm_log_init( &p_osm->log, p_opt->force_log_flush,
-                          p_opt->log_flags, p_opt->log_file );
+                          p_opt->log_flags, p_opt->log_file, p_opt->accum_log_file );
    if( status != IB_SUCCESS )
       return ( status );
 
index 9ab35f79f702be0736a76017066ede0a840d2b5e..beec964a564e56d5f8aae1bcd80356a6eb99c845 100644 (file)
@@ -424,6 +424,7 @@ osm_subn_set_default_opt(
     p_opt->dump_files_dir = OSM_DEFAULT_TMP_DIR;
 
   p_opt->log_file = OSM_DEFAULT_LOG_FILE;
+  p_opt->accum_log_file = TRUE;
   p_opt->port_profile_switch_nodes = FALSE;
   p_opt->max_port_profile = 0xffffffff;
   p_opt->pfn_ui_pre_lid_assign = NULL;
@@ -751,6 +752,10 @@ osm_subn_parse_conf_file(
       __osm_subn_opts_unpack_charp(
         "log_file" , p_key, p_val, &p_opts->log_file);
 
+      __osm_subn_opts_unpack_boolean(
+        "accum_log_file",
+        p_key, p_val, &p_opts->accum_log_file);
+
       __osm_subn_opts_unpack_charp(
         "dump_files_dir" ,
         p_key, p_val, &p_opts->dump_files_dir);
@@ -917,6 +922,7 @@ osm_subn_write_conf_file(
     "force_log_flush %s\n\n"
     "# Log file to be used\n"
     "log_file %s\n\n" 
+    "accum_log_file %s\n\n"
     "# The directory to hold the file OpenSM dumps\n"
     "dump_files_dir %s\n\n"
     "# If TRUE if OpenSM should disable multicast support\n"
@@ -926,6 +932,7 @@ osm_subn_write_conf_file(
     p_opts->log_flags,
     p_opts->force_log_flush ? "TRUE" : "FALSE",
     p_opts->log_file,
+    p_opts->accum_log_file,
     p_opts->dump_files_dir,
     p_opts->no_multicast_option ? "TRUE" : "FALSE",
     p_opts->disable_multicast ? "TRUE" : "FALSE"
index b88cf79ba74ec2722dd1b4a50e7100e3934733c5..ef8ee085495c4b47463d39443c60420ab14f3da3 100644 (file)
@@ -518,7 +518,7 @@ osmtest_init( IN osmtest_t * const p_osmt,
   osmtest_construct( p_osmt );
 
   status = osm_log_init( &p_osmt->log, p_opt->force_log_flush,
-                         0x0001, p_opt->log_file );
+                         0x0001, p_opt->log_file, TRUE );
   if( status != IB_SUCCESS )
     return ( status );
   /* but we do not want any extra staff here */