diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2016-01-02 19:18:40 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2016-02-07 18:13:36 +0100 |
commit | 987084c1cc955c4368e216e27a3c21de1d524bbf (patch) | |
tree | 86673b1b64ba93f43dcd6127912b2c7e883bb206 | |
parent | d3c2b1c852424a820130f608d65b7720e6f87e0b (diff) |
devnode: fix falling back to the kernel driver
* devnode/devnode.c (ds_device_open): Do not exit if opening the
master device fails.
(parse_opt): Likewise.
-rw-r--r-- | devnode/devnode.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/devnode/devnode.c b/devnode/devnode.c index 2802471f..a5120d7e 100644 --- a/devnode/devnode.c +++ b/devnode/devnode.c @@ -153,12 +153,20 @@ ds_device_open (mach_port_t master_port, mach_port_t reply_port, if (master_file != NULL) { - if (master_device != MACH_PORT_NULL) + mach_port_t md; + if (MACH_PORT_VALID (master_device)) mach_port_deallocate (mach_task_self (), master_device); - - master_device = file_name_lookup (master_file, 0, 0); - if (master_device == MACH_PORT_NULL) - error (1, errno, "file_name_lookup"); + md = file_name_lookup (master_file, 0, 0); + if (MACH_PORT_VALID (md)) + master_device = md; + else + { + error (0, 0, "%s: %s.\nFalling back to kernel driver.", + master_file, strerror (errno)); + err = get_privileged_ports (0, &master_device); + if (err) + return err; + } } err = device_open (master_device, mode, device_name, device); @@ -298,7 +306,8 @@ parse_opt (int opt, char *arg, struct argp_state *state) master_file = arg; master_device = file_name_lookup (arg, 0, 0); if (master_device == MACH_PORT_NULL) - error (1, errno, "file_name_lookup"); + error (0, 0, "%s: %s.\nFalling back to kernel driver.", + arg, strerror (errno)); break; case 'n': user_device_name = arg; |