|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] [PATCH 3/4] (Refactored) Add error checking in blktapctrl
[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 <=
|
|
|
|
|