diff options
author | Zheng Da <zhengda1936@gmail.com> | 2010-08-08 08:05:16 +0200 |
---|---|---|
committer | Zheng Da <zhengda1936@gmail.com> | 2010-08-08 08:05:16 +0200 |
commit | 3de13f2a911c402fc1275582d30b2f934cf433e5 (patch) | |
tree | 2a7428d7fe6a6486908b6add366359f0b6bf5cf1 | |
parent | 38b75c82d5555d1c2248fc98fb47d6fa2265059b (diff) |
check if the device exists.
-rw-r--r-- | libmachdev/block.c | 7 |
1 files changed, 6 insertions, 1 deletions
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) { |