public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [infiniband-diags] [1/2] support libibnetdisc caching overwrite flag
@ 2010-04-15 23:52 Al Chu
       [not found] ` <1271375547.17987.178.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Al Chu @ 2010-04-15 23:52 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

[-- Attachment #1: Type: text/plain, Size: 249 bytes --]

Hi Sasha,

This patch supports a flag in the libibnetdisc caching code to overwrite
a previous cache.

Al

-- 
Albert Chu
chu11-i2BcT+NCU+M@public.gmane.org
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory

[-- Attachment #2: 0001-support-libibnetdisc-caching-overwrite-flag.patch --]
[-- Type: message/rfc822, Size: 2109 bytes --]

From: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
Subject: [PATCH] support libibnetdisc caching overwrite flag
Date: Thu, 15 Apr 2010 09:37:44 -0700
Message-ID: <1271375429.17987.176.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>


Signed-off-by: Albert Chu <chu11-i2BcT+NCU+M@public.gmane.org>
---
 .../libibnetdisc/include/infiniband/ibnetdisc.h    |    3 +++
 .../libibnetdisc/src/ibnetdisc_cache.c             |   17 ++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
index 136282c..c83bd0b 100644
--- a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
+++ b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
@@ -181,6 +181,9 @@ MAD_EXPORT void ibnd_destroy_fabric(ibnd_fabric_t * fabric);
 MAD_EXPORT ibnd_fabric_t *ibnd_load_fabric(const char *file,
 					   unsigned int flags);
 
+#define IBND_CACHE_FABRIC_FLAG_DEFAULT   0x0000
+#define IBND_CACHE_FABRIC_FLAG_OVERWRITE 0x0001
+
 MAD_EXPORT int ibnd_cache_fabric(ibnd_fabric_t * fabric, const char *file,
 				 unsigned int flags);
 
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
index 480a0a2..6cf7d4d 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
@@ -876,9 +876,20 @@ int ibnd_cache_fabric(ibnd_fabric_t * fabric, const char *file,
 		return -1;
 	}
 
-	if (!stat(file, &statbuf)) {
-		IBND_DEBUG("file '%s' already exists\n", file);
-		return -1;
+	if (flags & IBND_CACHE_FABRIC_FLAG_OVERWRITE) {
+		if (!stat(file, &statbuf)) {
+			if (unlink(file) < 0) {
+				IBND_DEBUG("error removing '%s': %s\n",
+					   file, strerror(errno));
+				return -1;
+			}
+		}
+	}
+	else {
+		if (!stat(file, &statbuf)) {
+			IBND_DEBUG("file '%s' already exists\n", file);
+			return -1;
+		}
 	}
 
 	if ((fd = open(file, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) {
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-19 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-15 23:52 [infiniband-diags] [1/2] support libibnetdisc caching overwrite flag Al Chu
     [not found] ` <1271375547.17987.178.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
2010-04-19 15:04   ` Sasha Khapyorsky
2010-04-19 16:40     ` Al Chu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox