Subject: bin/37422: file copy over USB works with dd, but not with cp: Invalid argument.
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <kuehro@gmx.de>
List: netbsd-bugs
Date: 11/23/2007 15:20:00
>Number:         37422
>Category:       bin
>Synopsis:       file copy over USB works with dd, but not with cp: Invalid argument.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 23 15:20:00 +0000 2007
>Originator:     Kai-Uwe Eckhardt
>Release:        NetBSD 4.99.34 GENERIC_LAPTOP
>Organization:
>Environment:
NetBSD toshp4.backusf2x.de 4.99.34 NetBSD 4.99.34 (GENERIC_LAPTOP) #0: Wed Oct 31 07:59:33 PDT 2007  builds@wb46:/home/builds/ab/HEAD/i386/200710310002Z-obj/home/builds/ab/HEAD/src/sys/arch/i386/compile/GENERIC_LAPTOP i386

>Description:
If I try to copy certain files from a fat or NTFS partition on an external USB harddisk, I get the following (with FFS1, no matter if
softdep is used or not):

# cp /mnt/dummy/fortran/blas.tgz /home/archive
cp: /home/archive/blas.tgz: Invalid argument

The same worked fine on NetBSD4_RC1 on the same machine. 
The file blas.tgz is not corrupt, since I built a working library from
it afterwards on several different OS. The problem happens with several other files but there is no pattern, except that it seems to
happen only with files > 64 KiB, but not with all of them. Using ktruss shows a problem related to mmap:

431      1 cp       NAMI  "/home/archive/blas.tgz"
   431      1 cp       RET   open 4
   431      1 cp       CALL  mmap(0,0x1828d,1,1,3,0,0,0)
   431      1 cp       RET   mmap -1147244544/0xbb9e7000
   431      1 cp       CALL  madvise(0xbb9e7000,0x1828d,2)
   431      1 cp       RET   madvise 0
   431      1 cp       CALL  write(4,0xbb9e7000,0x1828d)
   431      1 cp       RET   write -1 errno 22 Invalid argument
   431      1 cp       CALL  write(2,0xbfbfe304,4)
   431      1 cp       GIO   fd 2 wrote 4 bytes
       "cp: "

>How-To-Repeat:
copy http://www.netlib.org/blas/blas.tgz onto an external hardrive
onto a fat or ntfs partition. Then try to copy it on to the ufs
partition. 

I can send a dmesg output if needed, but the usb disk shows up as:

umass0 at uhub3 port 1 configuration 1 interface 0
umass0: Myson Century, Inc. USB Mass Storage Device, rev 2.00/b0.08, addr 2
umass0: using ATAPI over Bulk-Only
atapibus1 at umass0: 2 targets
sd0 at atapibus1 drive 0: <TOSHIBA, MK8032GAX, AD00> disk fixed
sd0: fabricating a geometry
sd0: 76319 MB, 76319 cyl, 64 head, 32 sec, 512 bytes/sect x 156301488 sectors
sd0: fabricating a geometry

>Fix:
The files can be copied correctly with dd.