From patchwork Sat Nov 28 14:26:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 63481 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nASENwJ9012267 for ; Sat, 28 Nov 2009 14:23:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751096AbZK1OXu (ORCPT ); Sat, 28 Nov 2009 09:23:50 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751391AbZK1OXu (ORCPT ); Sat, 28 Nov 2009 09:23:50 -0500 Received: from ey-out-2122.google.com ([74.125.78.24]:36445 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbZK1OXu (ORCPT ); Sat, 28 Nov 2009 09:23:50 -0500 Received: by ey-out-2122.google.com with SMTP id 4so607945eyf.19 for ; Sat, 28 Nov 2009 06:23:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=2UTQpeL79k0fXR57vQqZGSPeWr8pGSjmMVRv2Lpuksk=; b=McoMD/oCeKRgWVlmNMH1MF1KXYgxcpjGc11JwDDghet12M1+Y5hQ+gnWeY99OG2mW8 Lphv7Mbqavuv5NmAAMutUFGm4ZaAaTFxDnR4NjX9LG9B4vRmY8YStesojkTO4C1ZmXUj ZErBNl2sJud1wrEMGQRR8SLjoqbk2F9UQlJeY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=Q+FPH6JRRgrjWzuYJHxBH325lrrzNLdfE6VCpAXiYWWLOvdzWW+4d6qh4eAFiixxhL uWRpWb5kXHZuVz0QrhgxlmQHnFtspS7SpUEb1hl6LcpEO8pgQmf1taSs21NKtVDNJBei 3+RTVi1IC4gQrdumSbuqX5tjQ5QUeJI8J30h0= Received: by 10.213.0.195 with SMTP id 3mr2510754ebc.81.1259418235575; Sat, 28 Nov 2009 06:23:55 -0800 (PST) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id 28sm3838410eyg.4.2009.11.28.06.23.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 28 Nov 2009 06:23:54 -0800 (PST) Received: by me.localdomain (Postfix, from userid 1000) id 561F111DF9; Sat, 28 Nov 2009 16:26:26 +0200 (IST) Date: Sat, 28 Nov 2009 16:26:26 +0200 From: Sasha Khapyorsky To: linux-rdma Cc: "Smith, Stan" Subject: [PATCH] opensm/osm_db_files.c: add '/' path delimited Message-ID: <20091128142626.GB16607@me> References: <784A3771E5D143179461A7D5151AE78C@amr.corp.intel.com> <20091012215455.GK13830@me> <3F6F638B8D880340AB536D29CD4C1E1912C896BBDA@orsmsx501.amr.corp.intel.com> <20091128142342.GA16607@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091128142342.GA16607@me> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/opensm/osm_db_files.c b/opensm/opensm/osm_db_files.c index ec7436e..5fd7c83 100644 --- a/opensm/opensm/osm_db_files.c +++ b/opensm/opensm/osm_db_files.c @@ -195,7 +195,7 @@ osm_db_domain_t *osm_db_domain_init(IN osm_db_t * p_db, IN char *domain_name) { osm_db_domain_t *p_domain; osm_db_domain_imp_t *p_domain_imp; - int dir_name_len; + size_t path_len; osm_log_t *p_log = p_db->p_log; FILE *p_file; @@ -209,16 +209,14 @@ osm_db_domain_t *osm_db_domain_init(IN osm_db_t * p_db, IN char *domain_name) (osm_db_domain_imp_t *) malloc(sizeof(osm_db_domain_imp_t)); CL_ASSERT(p_domain_imp != NULL); - dir_name_len = strlen(((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name); + path_len = strlen(((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name) + + strlen(domain_name) + 2; /* set the domain file name */ - p_domain_imp->file_name = - (char *)malloc(sizeof(char) * (dir_name_len) + strlen(domain_name) + - 2); + p_domain_imp->file_name = malloc(path_len); CL_ASSERT(p_domain_imp->file_name != NULL); - strcpy(p_domain_imp->file_name, - ((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name); - strcat(p_domain_imp->file_name, domain_name); + snprintf(p_domain_imp->file_name, path_len, "%s/%s", + ((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name, domain_name); /* make sure the file exists - or exit if not writable */ p_file = fopen(p_domain_imp->file_name, "a+");