diff mbox

opensm/osm_sa.c: enhance opensm_dump_to_file() to accept full path file name

Message ID 4BBDD6AA.5050504@dev.mellanox.co.il (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Yevgeny Kliteynik April 8, 2010, 1:14 p.m. UTC
None
diff mbox

Patch

diff --git a/opensm/opensm/osm_sa.c b/opensm/opensm/osm_sa.c
index 3473e4c..8aab548 100644
--- a/opensm/opensm/osm_sa.c
+++ b/opensm/opensm/osm_sa.c
@@ -510,8 +510,13 @@  opensm_dump_to_file(osm_opensm_t * p_osm, const char *file_name,
 	char path[1024];
 	FILE *file;

-	snprintf(path, sizeof(path), "%s/%s",
-		 p_osm->subn.opt.dump_files_dir, file_name);
+	if (*file_name == '/')
+		/* file name was provided as an absolute path */
+		snprintf(path, sizeof(path), "%s", file_name);
+	else
+		/* file name is relative to dump_files_dir */
+		snprintf(path, sizeof(path), "%s/%s",
+			 p_osm->subn.opt.dump_files_dir, file_name);

 	file = fopen(path, "w");
 	if (!file) {