From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Guthro Subject: [PATCH 3/4] Add error checking in blktapctrl Date: Tue, 19 Jun 2007 09:16:35 -0400 Message-ID: <4677D733.8090604@virtualiron.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020707030907080500050001" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------020707030907080500050001 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit [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 Signed-off-by: Ben Guthro --------------020707030907080500050001 Content-Type: text/x-patch; name="blktap-fixes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="blktap-fixes.patch" 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) { --------------020707030907080500050001 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------020707030907080500050001--