Subject: kern/21503: empty SCSI tape drives cannot be queried or configured
To: None <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 05/08/2003 15:55:47
>Number:         21503
>Category:       kern
>Synopsis:       empty SCSI tape drives cannot be queried or configured
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 08 19:57:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Greg A. Woods
>Release:        2003/05/07
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
System: NetBSD-current
>Description:

	Empty SCSI tape drives cannot be interacted with using any of
	commands which open their raw character device files, but which
	do not need media to do their job (e.g. status queries,
	configuration controls, etc.)

>How-To-Repeat:

	Install a new tape drive in a machine and try checking it and
	then wonder yet again why "mt status" and even "scsictl
	identify" say "Operation not supported by device"

>Fix:

	This isn't a fix -- it's a quick hack to make the resulting
	error have a slightly more intuitive meaning.  ENODEV is a scary
	message, especially when you're simply testing to see if a drive
	is correctly identified.  ENOSPC is much more intuitive because
	obviously there's no space on a drive with no media.  ENODEV,
	and even the phrase "operation not supported" have entirely
	different and more serious meanings to anyone even vaguely
	familiar with UNIX devices.

	I don't know if a "real" fix is possible or not, though it
	should be possible since the drive will obviously respond
	properly to an IDENTIFY command as otherwise the kernel wouldn't
	be able to probe and attatch it at boot time if it were empty.
	If NetBSD had a CAM SCSI subsystem then maybe it would have a
	pass(4) device like that in FreeBSD, and maybe it would allow
	these operations to be performed even while the drive is empty,
	yet retain the existing special behaviour for st(4) (but with
	this more intuitively meaningful error, please!).

Index: scsipi_base.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/sys/dev/scsipi/scsipi_base.c,v
retrieving revision 1.88
diff -c -r1.88 scsipi_base.c
*** scsipi_base.c       19 Apr 2003 19:12:59 -0000      1.88
--- scsipi_base.c       8 May 2003 19:33:19 -0000
***************
*** 861,868 ****
                                periph->periph_flags &= ~PERIPH_MEDIA_LOADED;
                        if ((xs->xs_control & XS_CTL_IGNORE_NOT_READY) != 0)
                                return (0);
!                       if (sense->add_sense_code == 0x3A) {
!                               error = ENODEV; /* Medium not present */
                                if (xs->xs_control & XS_CTL_SILENT_NODEV)
                                        return (error);
                        } else
--- 861,868 ----
                                periph->periph_flags &= ~PERIPH_MEDIA_LOADED;
                        if ((xs->xs_control & XS_CTL_IGNORE_NOT_READY) != 0)
                                return (0);
!                       if (sense->add_sense_code == 0x3A) {            /* XXX MAGIC #!!! */
!                               error = ENOSPC; /* Medium not present */
                                if (xs->xs_control & XS_CTL_SILENT_NODEV)
                                        return (error);
                        } else
>Release-Note:
>Audit-Trail:
>Unformatted: