diff mbox

[infiniband-diags,1/3] make libibnetdisc default behavior to overwrite a cache

Message ID 1271702587.17987.212.camel@auk31.llnl.gov (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Al Chu April 19, 2010, 6:43 p.m. UTC
None
diff mbox

Patch

diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
index 5acb8f6..e05ce99 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
@@ -889,8 +889,11 @@  int ibnd_cache_fabric(ibnd_fabric_t * fabric, const char *file,
 	}
 
 	if (!stat(file, &statbuf)) {
-		IBND_DEBUG("file '%s' already exists\n", file);
-		return -1;
+		if (unlink(file) < 0) {
+			IBND_DEBUG("error removing '%s': %s\n",
+				   file, strerror(errno));
+			return -1;
+		}
 	}
 
 	if ((fd = open(file, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) {