[ofw] RE: [PATCH] remove unnecessary leading '/' from filename

Smith, Stan stan.smith at intel.com
Mon Oct 12 15:18:29 PDT 2009


Sasha Khapyorsky wrote:
> On 16:46 Wed 07 Oct     , Stan C. Smith wrote:
>>
>> In osm_db_domain_init() the filename is appended to a path string
>> 'db_dir_name' which contains a trailing '/'. Remove extra '/'.
>>
>> Signed-off-by: stan smith <stan.smith at intel.com>
>>
>> diff --git a/opensm/opensm/osm_lid_mgr.c
>> b/opensm/opensm/osm_lid_mgr.c
>> index 947fe7a..1704054 100644
>> --- a/opensm/opensm/osm_lid_mgr.c
>> +++ b/opensm/opensm/osm_lid_mgr.c
>> @@ -239,7 +239,7 @@ ib_api_status_t osm_lid_mgr_init(IN
>> osm_lid_mgr_t * p_mgr, IN osm_sm_t * sm)     p_mgr->p_lock =
>> sm->p_lock;
>>
>>      /* we initialize and restore the db domain of guid to lid map */
>> -    p_mgr->p_g2l = osm_db_domain_init(p_mgr->p_db, "/guid2lid");
>> +    p_mgr->p_g2l = osm_db_domain_init(p_mgr->p_db, "guid2lid");
>
> I think that this can break when OSM_CACHE_DIR is supplied as
> environment variable and its value doesn't have '/' at the end. The
> patch below is from 2007 and it fixed this issue.
>
> Sasha

I believe removing the starting '/' from guid2lid filename is the correct fix for a couple of reasons:
1) prefixing a / to a filename seems strange when the path name is spec'ed as having a trailing / ?
2) / in a windows filename is a problem.

Due to comments in opensm/include/opensm/osm_base.h which explicitly speak to the requirement for a trailing directory delimiter, the missing functionality is the check for the trailing directory delimiter when using an environment var to build a path. One could be a 'good' guy and if the env is missing the trailing / then add one.

Do want me to resubmit with the env var check/fix or do you want to do it?

Stan.

>
>
> commit 907b95ec02d6a794ee8f6d6996cc6350a476bd15
> Author: Albert L. Chu <chu11 at llnl.gov>
> Date:   Wed Mar 14 07:08:58 2007 -0500
>
>     OpenSM: Fix cache filename corner case
>
>     Signed-off-by: Albert L. Chu <chu11 at llnl.gov>
>     Signed-off-by: Hal Rosenstock <halr at voltaire.com>
>
> diff --git a/osm/opensm/osm_lid_mgr.c b/osm/opensm/osm_lid_mgr.c
> index 89adc48..bd5945f 100644
> --- a/osm/opensm/osm_lid_mgr.c
> +++ b/osm/opensm/osm_lid_mgr.c
> @@ -282,7 +282,7 @@ osm_lid_mgr_init(
>    p_mgr->p_req = p_req;
>
>    /* we initialize and restore the db domain of guid to lid map */
> -  p_mgr->p_g2l = osm_db_domain_init(p_mgr->p_db, "guid2lid");
> +  p_mgr->p_g2l = osm_db_domain_init(p_mgr->p_db, "/guid2lid");
>    if (! p_mgr->p_g2l)
>    {
>      osm_log( p_mgr->p_log, OSM_LOG_ERROR,
> diff --git a/osm/opensm/osm_subnet.c b/osm/opensm/osm_subnet.c
> index 99e39aa..cbb3549 100644
> --- a/osm/opensm/osm_subnet.c
> +++ b/osm/opensm/osm_subnet.c
> @@ -745,7 +745,7 @@ osm_subn_rescan_conf_file(
>      p_cache_dir = OSM_DEFAULT_CACHE_DIR;
>
>    strcpy(file_name, p_cache_dir);
> -  strcat(file_name, "opensm.opts");
> +  strcat(file_name, "/opensm.opts");
>
>    opts_file = fopen(file_name, "r");
>    if (!opts_file)
> @@ -838,7 +838,7 @@ osm_subn_parse_conf_file(
>      p_cache_dir = OSM_DEFAULT_CACHE_DIR;
>
>    strcpy(file_name, p_cache_dir);
> -  strcat(file_name, "opensm.opts");
> +  strcat(file_name, "/opensm.opts");
>
>    opts_file = fopen(file_name, "r");
>    if (!opts_file) return;
> @@ -1096,7 +1096,7 @@ osm_subn_write_conf_file(
>      p_cache_dir = OSM_DEFAULT_CACHE_DIR;
>
>    strcpy(file_name, p_cache_dir);
> -  strcat(file_name, "opensm.opts");
> +  strcat(file_name, "/opensm.opts");
>
>    opts_file = fopen(file_name, "w");
>    if (!opts_file) return;
>
>>      if (!p_mgr->p_g2l) {
>>              OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0316: "
>>                      "Error initializing Guid-to-Lid persistent database\n");




More information about the ofw mailing list