grub4dos icon indicating copy to clipboard operation
grub4dos copied to clipboard

cannot use fat copy on some files

Open steve6375 opened this issue 9 years ago • 21 comments

FATCOPY_ISS115.zip

I have noticed that 'fat copy' command does not copy some files but has no problem with many other similar files. A test case is attached

steve6375 avatar Apr 13 '16 10:04 steve6375

image

steve6375 avatar Apr 13 '16 10:04 steve6375

Please point me at latest version of fat executable? Seems to work OK if the same file is on the USB drive (not in ISO) (bd)/fat copy (bd)/ocmanage.dll (fd0)/ || pause copy ocmanage.dll failed! is OK. So problem with reading ISO???

steve6375 avatar Apr 13 '16 10:04 steve6375

I compiled latest version of fat and get the same problem.

steve6375 avatar Apr 13 '16 19:04 steve6375

Same issue with 20160413

steve6375 avatar Apr 16 '16 12:04 steve6375

Using this modified code in copyFF.g4b, it proves that the problem is nothing to do with the fat utility, because dd also fails on same fails that fat copy fails on (dummy.txt is just a large file). So the problem is reading certain files from inside the ISO. Some are OK but others are not!

::copy file
echo FILE=%FD%%%cd%/%1
debug 1
#dd if=(bd)/dummy.txt of=(bd)/dummy.txt || echo Error: dd failed on dummy test
dd if=()/%1 of=(bd)/dummy.txt > nul || echo **** ERROR dd failed on  %cd%/%1 - dd if=()/%1 of=(bd)/dummy.txt
fat copy ()/%1 %FD%%%cd%/ > nul || echo **** ERROR FAT %cd%/%1
echo -----------------------------
pause
shift
goto :copyfiles

image

steve6375 avatar Apr 16 '16 14:04 steve6375

Error using the "DD" command. "DD" is not possible to create a file.

2012yaya2007 avatar Apr 20 '16 13:04 2012yaya2007

dummy.txt already exists. You can see it works for ocmanager.dll and setup.exe, but not for some other files.

steve6375 avatar Apr 20 '16 13:04 steve6375

Any progress please? This seems to be a bug in grub4dos? Can you reproduce the issue using the test case I uploaded?

steve6375 avatar Apr 26 '16 08:04 steve6375

Fat may have problems. DD no problem.

::copy file echo dd if=()%%cd%/%1 of=()/1.txt dd if=()%%cd%/%1 of=()/dummy.txt > nul || pause ERROR - dd if=()%%cd%/%1 of=()/dummy.txt shift goto :copyfiles

2012yaya2007 avatar Apr 29 '16 02:04 2012yaya2007

Yes sorry bad code It is just fat problem

steve6375 avatar Apr 29 '16 09:04 steve6375

Yes sorry bad code It is just fat problem but if copy same file from (hd0,0)/ocmanage.dll then it works. So problem is when copying file from inside an ISO???

steve6375 avatar Apr 29 '16 09:04 steve6375

If I rename ocmanage.dll to rcmanage.dll then works. If I rename setup.exe to ocmanage.dll inside ISO then it fails. So it is the file name that has a problem.

steve6375 avatar Apr 29 '16 10:04 steve6375

FAT no problem.

::copy file echo fat copy ()%cd%/%1 %FD%%%cd%/ fat copy ()%cd%/%1 %FD%%%cd%/ > nul || pause Error: copy ()%cd%/%1 %FD%%%cd%/ shift goto :copyfiles

2012yaya2007 avatar Apr 29 '16 12:04 2012yaya2007

Fd0 to be large enough to accommodate the contents of TEST.iso

2012yaya2007 avatar Apr 29 '16 12:04 2012yaya2007

Try this code: it just copies the same file in two different ways why does it work for some files but not other flles??? I test for full path after copy and delete file before 2nd copy.

set C1=
set C2=
fat copy ()%cd%/%1 %FD%%%cd%/ > nul || set C1=1
if exist C1 echo ERROR1: copy ()%cd%/%1 %FD%%%cd%/ || echo OK1  : copy ()%cd%/%1 %FD%%%cd%/ 
if not exist %FD%%%cd%/%1 echo COPY1 FAILED

fat del %FD%%%cd%/%1 > nul

fat copy /%1 %FD%%%cd%/ || set C2=1
if exist C2 echo ERROR2: %cd%/%1 || echo OK2  : copy /%1 %FD%%%cd%/
if not exist %FD%%%cd%/%1 echo COPY2 FAILED

shift
goto :copyfiles

image

steve6375 avatar Apr 30 '16 17:04 steve6375

This example would like to explain what?

  1. fat copy ()%cd%/%1 %FD%%%cd%/ > nul || set C1=1 Copy oracle.cab success .
  2. You delete the oracle.cab.
  3. fat copy /%1 %FD%%%cd%/ || set C2=1 Copy oracle.cab fail. Tell you that oracle.cab does not exist.

Don't forget, the previous copy of the successful oracle.cab , has been deleted by you ,

2012yaya2007 avatar May 01 '16 13:05 2012yaya2007

If you look at the screenshot, you can see that many files are copied OK (preload.exe, etc. etc.). Only certain files fail to copy.

The root is set to the /add-ons/pws directory, so both forms of the 'fat copy' command should work (and do work for many files in same directory - but not all files!). You can see that both 'fat copy' commands work for many files, but not for some files e.g. ocmanage.dll and oracle.cab. I have proved that it is the file name that is the problem, if I rename ocmanage,dll to setup.exe inside the ISO, and rename setup.exe to ocmanage.dll, then ocmanage.dll still fails (which is really setup.exe). So it is the file name that is causing the problem.

If I rename ocmanage.dll to rcmanage.dll (inside the ISO and save new ISO) then works. So it is not the length of the file name. If I rename rcmanage.dll back to ocmanage.dll and re-save the ISO, then it fails again!

steve6375 avatar May 01 '16 13:05 steve6375

How FAT works, I don't know. however : fat copy ()%cd%/%1 %FD%%%cd%/ OK! fat copy /%1 %FD%%%cd%/ fail!

2012yaya2007 avatar May 01 '16 13:05 2012yaya2007

FAT has a parameter '/o' ,Problem by it . use:

  1. fat copy ()%cd%/%1 %FD%%%cd%/
  2. fat copy //%1 %FD%%%cd%/

2012yaya2007 avatar May 02 '16 02:05 2012yaya2007

Yes! I can't believe I didn't spot that only files beginning with o had a problem! So it is a bug in fat.c. if (memcmp(arg, "/o", 2) == 0) change to... if (memcmp(arg, " /o ", 4) == 0)

Then it will only fail if there is a file called o or is there a better fix?

steve6375 avatar May 02 '16 10:05 steve6375

Can you fix the fat.c code and recompile please?

steve6375 avatar Aug 09 '16 10:08 steve6375