lkml.org 
[lkml]   [2008]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] firewire: fail open() quickly if the node doesn't exist anymore
Scenario:  Process A keeps the character device file of node N open.
N is being unplugged. File /dev/fwN won't be destroyed as long as A
doesn't close it. Now, process B opens /dev/fwN as well. Previously
it would succeed but be unable to do any IO on it of course. With this
patch, process B's open() will fail immediately with -ENODEV.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/firewire/fw-device.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Index: linux/drivers/firewire/fw-device.c
===================================================================
--- linux.orig/drivers/firewire/fw-device.c
+++ linux/drivers/firewire/fw-device.c
@@ -616,8 +616,12 @@ struct fw_device *fw_device_from_devt(de

down_read(&idr_rwsem);
device = idr_find(&fw_device_idr, MINOR(devt));
- if (device)
- fw_device_get(device);
+ if (device) {
+ if (fw_device_is_shutdown(device))
+ device = NULL;
+ else
+ fw_device_get(device);
+ }
up_read(&idr_rwsem);

return device;
--
Stefan Richter
-=====-==--- ---= ==-==
http://arcgraph.de/sr/


\
 
 \ /
  Last update: 2008-01-27 18:25    [W:0.113 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site