Subject: kern/5305: MTIOCRDSPOS, MTIOCSLOCATE, et al. fail on write-protected tapes
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@bga.com>
List: netbsd-bugs
Date: 04/17/1998 05:27:05
>Number:         5305
>Category:       kern
>Synopsis:       MTIOCRDSPOS, MTIOCSLOCATE, et al. fail on write-protected tapes
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 17 03:35:00 1998
>Last-Modified:
>Originator:     Dave Huang
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 22 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Release:        NetBSD-current as of April 16, 1998
>Environment:
	
System: NetBSD dahan.metonymy.com 1.3E NetBSD 1.3E (SPIFF) #210: Fri Apr 17 03:38:19 CDT 1998 khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386

SCSI controller and tape drive:
ncr1 at pci0 dev 11 function 0: ncr 53c810 fast10 scsi
ncr1: interrupting at irq 10
ncr1: minsync=25, maxsync=206, maxoffs=8, 16 dwords burst, normal dma fifo
ncr1: single-ended, open drain IRQ driver
ncr1: restart (scsi reset).
scsibus1 at ncr1: 8 targets
st0 at scsibus1 targ 6 lun 0: <ARCHIVE, Python 28849-XXX, 4.CM> SCSI2 1/sequential removable
st0: st0(ncr1:6:0): 5.0 MB/s (200 ns, offset 8)
drive empty
ch0 at scsibus1 targ 6 lun 1: <ARCHIVE, Python 28849-XXX, 4.CM> SCSI2 8/changer removable
ch0: 4 slots, 1 drive, 1 picker, 0 portals

>Description:
	The st device's MTIOCRDSPOS, MTIOCRDHPOS, MTIOCSLOCATE, and
MTIOCHLOCATE ioctls may fail with EROFS (Read-only filesystem) for
write-protected media.

>How-To-Repeat:
	Put a write-protected tape into the above Archive Python DAT
drive (I'm sure other drives would show the same problem though), then
try "mt rdspos" or "mt setspos 123"

>Fix:
	EROFS is the error returned for a write-protected tape, not
EACCES. Perhaps EACCES should be left in, but (from a quick skim of
the code) I didn't see any way for st_write_filemarks to return
EACCES.

--- /usr/src/sys/dev/scsipi/st.c	Fri Feb 13 06:30:18 1998
+++ st.c	Fri Apr 17 03:37:51 1998
@@ -1909,7 +1909,7 @@
 	 * which are too stupid to recognize a zero count
 	 * for writing filemarks as a no-op.
 	 */
-	if (error != 0 && error != EACCES)
+	if (error != 0 && error != EROFS)
 		return (error);
 
 	bzero(&cmd, sizeof(cmd));
@@ -1959,7 +1959,7 @@
 	 * which are too stupid to recognize a zero count
 	 * for writing filemarks as a no-op.
 	 */
-	if (error != 0 && error != EACCES)
+	if (error != 0 && error != EROFS)
 		return (error);
 
 	bzero(&cmd, sizeof(cmd));
>Audit-Trail:
>Unformatted: