summaryrefslogtreecommitdiff
path: root/debian/patches/fix-devnode0001-devnode-fix-falling-back-to-the-kernel-driver.patch
blob: 48706c669ce7c160b4c9d58a2aceab97999f9173 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From ef4a4280e0f372c26f9c5fe2068312b443f82d24 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Sat, 2 Jan 2016 19:18:40 +0100
Subject: [PATCH hurd] 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.
---
 devnode/devnode.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/devnode/devnode.c b/devnode/devnode.c
index 2802471..a5120d7 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;
-- 
2.1.4