misc/85481: reading from fd0 when floppy disk is write-protected

Lev Levinson llevinson at inbox.ru
Tue Aug 30 14:40:24 GMT 2005


>Number:         85481
>Category:       misc
>Synopsis:       reading from fd0 when floppy disk is write-protected
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 30 14:40:18 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Lev Levinson
>Release:        5.4-RELEASE
>Organization:
>Environment:
FreeBSD  5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May  8 10:21:06 UTC 2005     root at harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
Reading n x 512 byte blocks from /dev/fd0 result in "Input/output error" when n IS NOT DIVISOR of 36 and floppy disk is write-protected. 
for example, 
dd if=/dev/fd0 of=/dev/null bs=512 
dd if=/dev/fd0 of=/dev/null bs=1024 # 2x512 
dd if=/dev/fd0 of=/dev/null bs=1536 # 3x512 
dd if=/dev/fd0 of=/dev/null bs=2048 # 4x512
dd if=/dev/fd0 of=/dev/null bs=3072 # 6x512
dd if=/dev/fd0 of=/dev/null bs=4608 # 9x512
works well, but
dd if=/dev/fd0 of=/dev/null bs=2560 # 5x512
dd if=/dev/fd0 of=/dev/null bs=3584 # 7x512
dd if=/dev/fd0 of=/dev/null bs=4096 # 8x512
dd if=/dev/fd0 of=/dev/null bs=5120 # 10x512
reports input-output error.

tar reads file with 20 x 512 byte blocks, and 
tar -xzf /dev/fd0 
no works if disk is write-protected.
but 
tar -xzf /dev/fd0 -b 36
works.



 





>How-To-Repeat:
1 Boot and login as root
2 Insert write protected floppy disk.
3 dd if=/dev/fd0 of=/dev/null bs=4096
  (or bs = n x 512, where n is not divisor of 36 - number of sectors per floppy track)
>Fix:
In function fdc_worker (src/sys/dev/fdc/fdc.c:746) i found this line:

if (bp != NULL &&
    (fdc->retry >= retries || (fd->flags & FDOPT_NORETRY))) {

In this line, option (BUT NOT FLAG!!!) FDOPT_NORETRY AND-ed against
field fd->flags (BUT NOT fd->options). 
Option FDOPT_NORETRY has same value as a flag FD_WP (write protected). Thus, instead "need more reads" we have "Disk is write-protected" in condition.
For fix this bug, code mast be like this:

if (bp != NULL &&
    (fdc->retry >= retries || (fd->options & FDOPT_NORETRY))) {





>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list