summaryrefslogtreecommitdiff
path: root/debian/patches/fix-console.patch
blob: 9872c5b0fc4c898729c28612fe8731c480a13817 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
diff --git a/console/display.c b/console/display.c
index 8d9e478..09add5c 100644
--- a/console/display.c
+++ b/console/display.c
@@ -42,6 +42,7 @@
 #include "display.h"
 #include "pager.h"
 
+#include "notify_S.h"
 
 struct changes
 {
@@ -318,7 +319,7 @@ free_modreqs (struct modreq *mr)
 /* A port deleted notification is generated when we deallocate the
    user's notify port before it is dead.  */
 error_t
-do_mach_notify_port_deleted (mach_port_t notify, mach_port_t name)
+do_mach_notify_port_deleted (struct port_info *pi, mach_port_t name)
 {
   /* As we cancel the dead-name notification before deallocating the
      port, this should not happen.  */
@@ -327,15 +328,16 @@ do_mach_notify_port_deleted (mach_port_t notify, mach_port_t name)
 
 /* We request dead name notifications for the user ports.  */
 error_t
-do_mach_notify_dead_name (mach_port_t notify, mach_port_t dead_name)
+do_mach_notify_dead_name (struct port_info *pi, mach_port_t dead_name)
 {
-  struct notify *notify_port = ports_lookup_port (notify_bucket,
-						  notify, notify_class);
+  struct notify *notify_port = (struct notify *) pi;
   struct display *display;
   struct modreq **preq;
   struct modreq *req;
 
-  if (!notify_port)
+  if (!notify_port
+      || notify_port->pi.bucket != notify_bucket
+      || notify_port->pi.class != notify_class)
     return EOPNOTSUPP;
 
   display = notify_port->display;
@@ -369,30 +371,35 @@ do_mach_notify_dead_name (mach_port_t notify, mach_port_t dead_name)
   return 0;
 }
 
-void do_mach_notify_port_destroyed (void) { assert (0); }
+error_t
+do_mach_notify_port_destroyed (struct port_info *pi, mach_port_t rights)
+{
+  assert (0);
+}
 
 error_t
-do_mach_notify_no_senders (mach_port_t port, mach_port_mscount_t count)
+do_mach_notify_no_senders (struct port_info *pi, mach_port_mscount_t count)
 {
-  return ports_do_mach_notify_no_senders (port, count);
+  return ports_do_mach_notify_no_senders (pi, count);
 }
 
 kern_return_t
-do_mach_notify_send_once (mach_port_t notify)
+do_mach_notify_send_once (struct port_info *pi)
 {
   return 0;
 }
 
 kern_return_t
-do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send)
+do_mach_notify_msg_accepted (struct port_info *pi, mach_port_t send)
 {
-  struct notify *notify_port = ports_lookup_port (notify_bucket,
-						  notify, notify_class);
+  struct notify *notify_port = (struct notify *) pi;
   struct display *display;
   struct modreq **preq;
   struct modreq *req;
 
-  if (!notify_port)
+  if (!notify_port
+      || notify_port->pi.bucket != notify_bucket
+      || notify_port->pi.class != notify_class)
     return EOPNOTSUPP;
 
   /* If we deallocated the send right in display_destroy before the
@@ -401,7 +408,6 @@ do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send)
   if (!send)
     {
       assert(0);
-      ports_port_deref (notify_port);
       return 0;
     }
 
@@ -418,7 +424,6 @@ do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send)
     {
       assert(0);
       pthread_mutex_unlock (&display->lock);
-      ports_port_deref (notify_port);
       return 0;
     }
   req = *preq;
@@ -430,7 +435,7 @@ do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send)
 	 and stay in pending queue.  */
       req->pending = 0;
       err = nowait_file_changed (req->port, 0, FILE_CHANGED_WRITE, -1, -1,
-				 notify);
+				 notify_port->pi.port_right);
       if (err && err != MACH_SEND_WILL_NOTIFY)
 	{
 	  mach_port_t old;
@@ -446,7 +451,6 @@ do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send)
 
 	  mach_port_deallocate (mach_task_self (), req->port);
 	  free (req);
-	  ports_port_deref (notify_port);
 	  return err;
 	}
       if (err == MACH_SEND_WILL_NOTIFY)
@@ -462,7 +466,6 @@ do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t send)
   req->next = display->filemod_reqs;
   display->filemod_reqs = req;
   pthread_mutex_unlock (&display->lock);
-  ports_port_deref (notify_port);
   return 0;
 }
 
diff --git a/console/mutations.h b/console/mutations.h
index 5f26672..c1867a0 100644
--- a/console/mutations.h
+++ b/console/mutations.h
@@ -24,3 +24,10 @@
 #define IO_DESTRUCTOR end_using_protid_port (protid_t)
 
 #define TIOCTL_IMPORTS import "priv.h";
+
+#define NOTIFY_INTRAN						\
+  port_info_t begin_using_port_info_port (mach_port_t)
+#define NOTIFY_DESTRUCTOR					\
+  end_using_port_info (port_info_t)
+#define NOTIFY_IMPORTS						\
+  import "libports/mig-decls.h";