bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CD-ROM lock


From: Alexey Dejneka
Subject: CD-ROM lock
Date: Wed, 08 Nov 2000 11:33:42 +0300

Gnumach doesn't close device when last send right is released. If you do 
  dd if=/dev/hd2 of=/dev/null bs=1k count=1
  kill /* pid of /hurd/storeio hd2 */
cdrom (hd2) door remains locked.
Patch:
-----------cut here-------
diff -r -C 2 --exclude configure
gnumach/i386/i386at/i386at_ds_routines.c
gnumach-new/i386/i386at/i386at_ds_routines.c
*** gnumach/i386/i386at/i386at_ds_routines.c    Mon Apr 26 09:30:00 1999
--- gnumach-new/i386/i386at/i386at_ds_routines.c        Wed Nov  8
09:08:04 2000
***************
*** 230,234 ****
  
        ns = (mach_no_senders_notification_t *) msg;
!       dev = (device_t) ns->not_header.msgh_remote_port;
        if (dev->emul_ops->no_senders)
        (*dev->emul_ops->no_senders) (ns);
--- 230,235 ----
  
        ns = (mach_no_senders_notification_t *) msg;
!       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);
diff -r -C 2 --exclude configure gnumach/linux/dev/glue/block.c
gnumach-new/linux/dev/glue/block.c
*** gnumach/linux/dev/glue/block.c      Sun Sep 24 11:51:12 2000
--- gnumach-new/linux/dev/glue/block.c  Wed Nov  8 12:20:47 2000
***************
*** 798,801 ****
--- 798,802 ----
  
  static io_return_t device_close (void *);
+ static io_return_t device_close_forced (void *, int);
  
  /* Return a send right for block device BD.  */
***************
*** 1173,1176 ****
--- 1174,1178 ----
              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));
***************
*** 1183,1198 ****
        bd->next = open_list;
        open_list = bd;
      }
  
!   if (IP_VALID (reply_port))
!     ds_device_open_reply (reply_port, reply_port_type, err,
dev_to_port (bd));
!   else if (! err)
      device_close (bd);
! 
!   return MIG_NO_REPLY;
  }
  
  static io_return_t
! device_close (void *d)
  {
    struct block_data *bd = d, *bdp, **prev;
--- 1185,1198 ----
        bd->next = open_list;
        open_list = bd;
+       *devp = &bd -> device;
      }
  
!   if (!IP_VALID (reply_port) && ! err)
      device_close (bd);
!   return err;
  }
  
  static io_return_t
! device_close_forced (void *d, int force)
  {
    struct block_data *bd = d, *bdp, **prev;
***************
*** 1211,1215 ****
    ds->busy = 1;
  
!   if (--bd->open_count == 0)
      {
        /* Wait for pending I/O to complete.  */
--- 1211,1215 ----
    ds->busy = 1;
  
!   if (force || --bd->open_count == 0)
      {
        /* Wait for pending I/O to complete.  */
***************
*** 1254,1257 ****
--- 1254,1264 ----
  }
  
+ 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)
  
***************
*** 1675,1678 ****
--- 1682,1695 ----
  }
  
+ 
+ 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 =
  {
***************
*** 1690,1694 ****
    NULL,
    NULL,
!   NULL,
    NULL,
    NULL
--- 1707,1711 ----
    NULL,
    NULL,
!   device_no_senders,
    NULL,
    NULL
--------------------cut here--------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]