summaryrefslogtreecommitdiff
path: root/debian/patches/device_close_forced.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/device_close_forced.patch')
-rw-r--r--debian/patches/device_close_forced.patch102
1 files changed, 102 insertions, 0 deletions
diff --git a/debian/patches/device_close_forced.patch b/debian/patches/device_close_forced.patch
new file mode 100644
index 0000000..34c34cf
--- /dev/null
+++ b/debian/patches/device_close_forced.patch
@@ -0,0 +1,102 @@
+--- gnumach-20040229.orig/linux/dev/glue/block.c
++++ gnumach-20040229/linux/dev/glue/block.c
+@@ -797,6 +797,7 @@
+ extern struct device_emulation_ops linux_block_emulation_ops;
+
+ static io_return_t device_close (void *);
++static io_return_t device_close_forced (void *, int);
+
+ /* Return a send right for block device BD. */
+ static ipc_port_t
+@@ -1172,6 +1173,7 @@
+ {
+ ipc_kobject_set (bd->port, IKO_NULL, IKOT_NONE);
+ ipc_port_dealloc_kernel (bd->port);
++ *devp = IP_NULL;
+ }
+ kfree ((vm_offset_t) bd, sizeof (struct block_data));
+ bd = NULL;
+@@ -1182,18 +1184,16 @@
+ bd->open_count = 1;
+ bd->next = open_list;
+ open_list = bd;
++ *devp = &bd -> device;
+ }
+
+- if (IP_VALID (reply_port))
+- ds_device_open_reply (reply_port, reply_port_type, err, dev_to_port (bd));
+- else if (! err)
++ if (!IP_VALID (reply_port) && ! err)
+ device_close (bd);
+-
+- return MIG_NO_REPLY;
++ return err;
+ }
+
+ static io_return_t
+-device_close (void *d)
++device_close_forced (void *d, int force)
+ {
+ struct block_data *bd = d, *bdp, **prev;
+ struct device_struct *ds = bd->ds;
+@@ -1210,7 +1210,7 @@
+ }
+ ds->busy = 1;
+
+- if (--bd->open_count == 0)
++ if (force || --bd->open_count == 0)
+ {
+ /* Wait for pending I/O to complete. */
+ while (bd->iocount > 0)
+@@ -1253,6 +1253,13 @@
+ return D_SUCCESS;
+ }
+
++static io_return_t
++device_close (void *d)
++{
++ return device_close_forced (d, 0);
++}
++
++
+ #define MAX_COPY (VM_MAP_COPY_PAGE_LIST_MAX << PAGE_SHIFT)
+
+ /* Check block BN and size COUNT for I/O validity
+@@ -1712,6 +1719,16 @@
+ return D_SUCCESS;
+ }
+
++
++static void
++device_no_senders (mach_no_senders_notification_t *ns)
++{
++ device_t dev;
++
++ dev = (device_t) ((ipc_port_t) ns->not_header.msgh_remote_port) -> ip_kobject;
++ device_close_forced (dev->emul_data, 1);
++}
++
+ struct device_emulation_ops linux_block_emulation_ops =
+ {
+ NULL,
+@@ -1727,7 +1744,7 @@
+ device_get_status,
+ NULL,
+ NULL,
+- NULL,
++ device_no_senders,
+ NULL,
+ NULL
+ };
+--- gnumach-20040229.orig/i386/i386at/i386at_ds_routines.c
++++ gnumach-20040229/i386/i386at/i386at_ds_routines.c
+@@ -229,7 +229,8 @@
+ mach_no_senders_notification_t *ns;
+
+ ns = (mach_no_senders_notification_t *) msg;
+- dev = (device_t) ns->not_header.msgh_remote_port;
++ dev = (device_t) ((ipc_port_t) ns->not_header.msgh_remote_port)
++ -> ip_kobject;
+ if (dev->emul_ops->no_senders)
+ (*dev->emul_ops->no_senders) (ns);
+ return TRUE;