From nobody@FreeBSD.ORG  Tue Aug 29 19:18:46 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 7B56D37B424; Tue, 29 Aug 2000 19:18:46 -0700 (PDT)
Message-Id: <20000830021846.7B56D37B424@hub.freebsd.org>
Date: Tue, 29 Aug 2000 19:18:46 -0700 (PDT)
From: dcschooley@ieee.org
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: ATAPI ZIP drive allows mounted disks to be ejected
X-Send-Pr-Version: www-1.0

>Number:         20933
>Category:       kern
>Synopsis:       ATAPI ZIP drive allows mounted disks to be ejected
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 29 19:20:02 PDT 2000
>Closed-Date:    Mon Apr 2 12:47:40 PDT 2001
>Last-Modified:  Mon Apr 02 12:49:54 PDT 2001
>Originator:     David Schooley
>Release:        4.1-STABLE, cvsup'ed on 8/28/2000
>Organization:
N/A
>Environment:
FreeBSD geek-machine 4.1-STABLE FreeBSD 4.1-STABLE #1: Tue Aug 29 06:57:52 CDT 2000     dcs@geek-machine:/usr/src/sys/compile/WHEEL  i386
>Description:
As implemented in the current atapi-fd driver code, an ATAPI ZIP drive allows mounted disks to be ejected. This can cause an unrecoverable I/O error if the disk is reinserted, which requires the machine to be rebooted.

The existing code uses the correct ATA calls to lock the drive, but the function is only called if count_dev() returns 1. During my testing, count_dev() only returned 0 for the ZIP drive, but it did return 1 for the CDROM.
>How-To-Repeat:
1. Mount a ufs formatted zip disk.
2. Eject the disk.
3. Reinsert the disk and attempt to unmount it.
>Fix:
The following patch to sys/dev/ata/atapi-fd.c fixes the problem by eliminating the call to count_dev(). The count_dev() function call appears to be unnecessary.

*** atapi-fd.c.orig	Tue Aug 29 06:55:26 2000
--- atapi-fd.c	Tue Aug 29 06:57:20 2000
***************
*** 224,231 ****
  
      atapi_test_ready(fdp->atp);
  
!     if (count_dev(dev) == 1)
! 	afd_prevent_allow(fdp, 1);
  
      if (afd_sense(fdp))
  	printf("afd%d: sense media type failed\n", fdp->lun);
--- 224,230 ----
  
      atapi_test_ready(fdp->atp);
  
!     afd_prevent_allow(fdp, 1);
  
      if (afd_sense(fdp))
  	printf("afd%d: sense media type failed\n", fdp->lun);
***************
*** 247,254 ****
  {
      struct afd_softc *fdp = dev->si_drv1;
  
!     if (count_dev(dev) == 1)
! 	afd_prevent_allow(fdp, 0); 
      return 0;
  }
  
--- 246,252 ----
  {
      struct afd_softc *fdp = dev->si_drv1;
  
!     afd_prevent_allow(fdp, 0); 
      return 0;
  }

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Wed Aug 30 00:55:37 PDT 2000 
Responsible-Changed-Why:  
Over to the ATA maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=20933 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Mon Apr 2 12:47:40 PDT 2001 
State-Changed-Why:  
This works on my -current system now... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=20933 
>Unformatted:
