diff options
author | Zheng Da <zhengda1936@gmail.com> | 2010-06-17 11:12:47 +0200 |
---|---|---|
committer | Zheng Da <zhengda1936@gmail.com> | 2010-06-17 11:12:47 +0200 |
commit | e9762c27cfc0b614ca09b4812351c83167501447 (patch) | |
tree | 5f247b36a8ddf65d321c3d12c83e2018135e79b9 /libmachdev | |
parent | 70d6d54fe949a7743bd5091e74aab2477336b5d3 (diff) |
fix a bug in device_open in libmachdev.
check the negative error value.
Diffstat (limited to 'libmachdev')
-rw-r--r-- | libmachdev/block.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libmachdev/block.c b/libmachdev/block.c index 080338d8..3dddd74a 100644 --- a/libmachdev/block.c +++ b/libmachdev/block.c @@ -115,6 +115,7 @@ device_open (mach_port_t reply_port, mach_msg_type_name_t reply_port_type, struct block_data *bd = NULL; int slice, part; char *dev_name = NULL; + int dev_err; dev_name = translate_name (name, &slice, &part); @@ -126,10 +127,11 @@ device_open (mach_port_t reply_port, mach_msg_type_name_t reply_port_type, goto out; } bd->dev = open_block_dev (dev_name, slice, mode); - if (bd->dev < 0) + dev_err = (int) bd->dev; + if (dev_err < 0) { - ddekit_printf ("open_block_dev fails with %d\n", bd->dev); - err = linux_to_mach_error (err); + ddekit_printf ("open_block_dev %s fails with %d\n", dev_name, bd->dev); + err = linux_to_mach_error (dev_err); goto out; } bd->device.emul_data = bd; |