All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] Add error checking in blktapctrl
@ 2007-06-19 13:16 Ben Guthro
  0 siblings, 0 replies; only message in thread
From: Ben Guthro @ 2007-06-19 13:16 UTC (permalink / raw)
  To: xen-devel

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

[PATCH 3/4] Add error checking in blktapctrl
blktap-fixes.patch
Add some additional error checking to blktapctrl during mkfifo
Signed-off-by: Boris Ostrovsky <bostrovsky@virtualiron.com>
Signed-off-by: Ben Guthro <bguthro@virtualiron.com>

[-- Attachment #2: blktap-fixes.patch --]
[-- Type: text/x-patch, Size: 1057 bytes --]

diff -r 46e334d40a68 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c	Mon Jun 04 14:24:51 2007 -0400
+++ b/tools/blktap/drivers/blktapctrl.c	Mon Jun 04 14:24:56 2007 -0400
@@ -604,11 +604,28 @@ int open_ctrl_socket(char *devname)
 	if (mkdir(BLKTAP_CTRL_DIR, 0755) == 0)
 		DPRINTF("Created %s directory\n", BLKTAP_CTRL_DIR);
 	ret = mkfifo(devname,S_IRWXU|S_IRWXG|S_IRWXO);
-	if ( (ret != 0) && (errno != EEXIST) ) {
-		DPRINTF("ERROR: pipe failed (%d)\n", errno);
-		exit(0);
-	}
-
+	if (ret) {
+		if (errno == EEXIST) {
+			/* 
+			 * Remove fifo since it may have data from
+			 * it's previous use --- earlier invocation 
+			 * of tapdisk may not have read all messages.
+			 */
+			ret = unlink(devname);
+			if (ret) {
+				DPRINTF("ERROR: unlink(%s) failed (%d)\n", 
+					devname, errno);
+				exit(0);
+			}
+
+			ret = mkfifo(devname,S_IRWXU|S_IRWXG|S_IRWXO);
+		}
+		if (ret) {
+			DPRINTF("ERROR: pipe failed (%d)\n", errno);
+			exit(0);
+		}
+	}
+	
 	ipc_fd = open(devname,O_RDWR|O_NONBLOCK);
 
 	if (ipc_fd < 0) {


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-19 13:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-19 13:16 [PATCH 3/4] Add error checking in blktapctrl Ben Guthro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.