From 3de13f2a911c402fc1275582d30b2f934cf433e5 Mon Sep 17 00:00:00 2001 From: Zheng Da Date: Sun, 8 Aug 2010 08:05:16 +0200 Subject: check if the device exists. --- libmachdev/block.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libmachdev/block.c b/libmachdev/block.c index 4aa07672..b239ecff 100644 --- a/libmachdev/block.c +++ b/libmachdev/block.c @@ -118,9 +118,14 @@ device_open (mach_port_t reply_port, mach_msg_type_name_t reply_port_type, char *dev_name = NULL; int dev_err; + // TODO I need to check whether the device has been opened before. + // if it has been opened with the same `flag', return the same port, + // otherwise, return a different port. + // I need to have a reference to count the number of open. dev_name = translate_name (name, &slice, &part); + if (dev_name == NULL) + return D_NO_SUCH_DEVICE; - // TODO when the port isn't used by clients, it should be destroyed. err = create_device_port (sizeof (*bd), &bd); if (err) { -- cgit v1.2.3