WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 3/4] (Refactored) Add error checking in blktapctrl

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 3/4] (Refactored) Add error checking in blktapctrl
From: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>
Date: Thu, 21 Jun 2007 13:27:55 -0400
Delivery-date: Thu, 21 Jun 2007 10:25:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.0 (X11/20070418)
[PATCH 3/4] (Refactored) Add error checking in blktapctrl
blktap-fixes.patch
Add some additional error checking to blktapctrl during mkfifo
Signed-off-by: Boris Ostrovsky <bostrovsky@xxxxxxxxxxxxxxx>
Signed-off-by: Ben Guthro <bguthro@xxxxxxxxxxxxxxx>

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) {


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 3/4] (Refactored) Add error checking in blktapctrl, Ben Guthro <=