grub4dos icon indicating copy to clipboard operation
grub4dos copied to clipboard

grub4dos dd bug

Open steve6375 opened this issue 4 years ago • 42 comments

F1 and F2 have same contents

image image

!BAT
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw dd if=(hd0,0)/f2 of=(md)0x3000+511
raw dd if=(md)0x3000+511 of=(md)0x3000+511 bs=1 skip=6 seek=12
raw dd if=(md)0x3000+511 of=(md)0x3000+511 bs=1 skip=12 seek=6
raw dd if=(md)0x3000+511 of=(hd0,0)/f2
raw cmp /f1 /f2 && echo F1 is SAME as F2

ddbug.zip

steve6375 avatar Sep 17 '21 22:09 steve6375

!BAT
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw dd if=(hd0,0)/f2 of=(md)0x3000+511 bs=1
raw dd if=(md)0x3000+511 of=(hd0,0)/f2 bs=1
raw cmp /f1 /f2 && echo F1 is SAME as F2

image

This works OK

steve6375 avatar Sep 17 '21 22:09 steve6375

image

!BAT
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw dd if=(hd0,0)/f2 of=(md)0x3000+511
raw dd if=(md)0x3000+511 of=(md)0x20000+511 bs=1 skip=6 seek=12
raw dd if=(md)0x20000+511 of=(md)0x3000+511 bs=1 skip=12 seek=6
raw dd if=(md)0x3000+511 of=(hd0,0)/f2
raw cmp /f1 /f2 && echo F1 is SAME as F2

Works if use 2nd buffer area

steve6375 avatar Sep 18 '21 08:09 steve6375

!BAT
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw dd if=(hd0,0)/f2 of=(md)0x3000+511 bs=1
raw dd if=(md)0x3000+511 of=(md)0x3000+511 bs=1 skip=0 seek=1
raw dd if=(md)0x3000+511 of=(md)0x3000+511 bs=1 skip=1 seek=0
raw dd if=(md)0x3000+511 of=(hd0,0)/f2 bs=1
raw cmp /f1 /f2 && echo F1 is SAME as F2

image image

steve6375 avatar Sep 18 '21 09:09 steve6375

!BAT
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw dd if=(hd0,0)/f2 of=(md)0x3000+511 bs=1
raw dd if=(md)0x3000+511 of=(md)0x3000+511 bs=1 skip=0 seek=16
raw dd if=(md)0x3000+511 of=(md)0x3000+511 bs=1 skip=16 seek=0
raw dd if=(md)0x3000+511 of=(hd0,0)/f2
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw cat --hex --skip=65520 --length=0x40 /f1
raw cat --hex --skip=65520 --length=0x40 /f2

image

steve6375 avatar Sep 18 '21 10:09 steve6375

Same issue in grub4efi image

steve6375 avatar Sep 19 '21 06:09 steve6375

使用dd移动数据,一般是从一个文件到另一个文件。在同一个文件内移动数据,如果缓存够大,超过文件尺寸,可以一次移动完毕。当缓存不够大,需要多次移动时,尤其是向后移动,dd函数不能使用。应当使用复制函数。

yaya2007 avatar Sep 19 '21 12:09 yaya2007

reading/writing to a different file is OK The following code using files works OK

!BAT
raw dd if=(bd)/f0 of=(bd)/f1
raw dd if=(bd)/f0 of=(bd)/f2
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw dd if=(bd)/f1 of=(bd)/f2 bs=1 skip=0 seek=16
raw dd if=(bd)/f2 of=(bd)/f1 bs=1 skip=16 seek=0
raw cmp /f1 /f0 && echo F1 is SAME as F0
raw cat --hex --skip=65520 --length=0x40 /f1
raw cat --hex --skip=65520 --length=0x40 /f0

Are you saying there is a 64k limit when moving memory backwards (including the skip/seek offset)? If so, shouldn't the dd code test for this case and report an error? 'Error: backwards memory move limit exceeded'

steve6375 avatar Sep 19 '21 13:09 steve6375

This code which uses the same file as if and of fails with same error at 64k boundary

!BAT
raw dd if=(bd)/f0 of=(bd)/f1
raw dd if=(bd)/f0 of=(bd)/f2
raw cmp /f1 /f2 && echo F1 is SAME as F2
raw dd if=(bd)/f1 of=(bd)/f1 bs=1 skip=0 seek=16
raw dd if=(bd)/f1 of=(bd)/f1 bs=1 skip=16 seek=0
raw cmp /f1 /f0 && echo F1 is SAME as F0
raw cat --hex --skip=65520 --length=0x40 /f1
raw cat --hex --skip=65520 --length=0x40 /f0

image

steve6375 avatar Sep 19 '21 13:09 steve6375

尝试修复,请测试. BOOTX64.rar.txt

yaya2007 avatar Sep 24 '21 07:09 yaya2007

memory seems to work OK, but error when using a file. image FAIL!!

steve6375 avatar Sep 24 '21 07:09 steve6375

OK image image OK

steve6375 avatar Sep 24 '21 08:09 steve6375

我不明白你使用 dd 命令的目的是什么,但是 test3.g4d 的测试方法是错误的,结果永远是 FAIL! 比如 f1 的内容是: 11 11 11 11 11 11 11 11 - 11 11 11 11 11 11 11 11 22 22 22 22 22 22 22 22 - 22 22 22 22 22 22 22 22 33 33 33 33 33 33 33 33 - 33 33 33 33 33 33 33 33

执行 raw dd if=(bd)/f1 of=(bd)/f1 bs=1 skip=16 sddk=0 后,f1 的内容是: 11 11 11 11 11 11 11 11 - 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 - 11 11 11 11 11 11 11 11 22 22 22 22 22 22 22 22 - 22 22 22 22 22 22 22 22 注意: 33 33 33 33 33 33 33 33 - 33 33 33 33 33 33 33 33 这些数据被丢弃!

执行 raw dd if=(bd)/f1 of=(bd)/f1 bs=1 skip=0 sddk=16 后,f1 的内容是: 11 11 11 11 11 11 11 11 - 11 11 11 11 11 11 11 11 22 22 22 22 22 22 22 22 - 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 - 22 22 22 22 22 22 22 22 注意: 33 33 33 33 33 33 33 33 - 33 33 33 33 33 33 33 33 这些数据已经丢弃,不可能再复制到 f1 的第三行。

yaya2007 avatar Sep 24 '21 10:09 yaya2007

Yes, the last 16 bytes are expected to be different

but see actual result... image

However, the first bytes are different which is not correct - offset 0 is different!

e.g. If we use a small file, we get expected result... image

Note that error is at end of file, not at offset 0- so this is OK and expected.

steve6375 avatar Sep 24 '21 11:09 steve6375

如何重现test3.g4d? 方便的话,使用cat看看偏移0前后的变化。 也可能是cmp判断错误?

yaya2007 avatar Sep 24 '21 12:09 yaya2007

image

steve6375 avatar Sep 24 '21 13:09 steve6375

with debug image

steve6375 avatar Sep 24 '21 13:09 steve6375

问题无法重现。测试正常。 新建截图-20210925082941 新建截图-20210925082824

yaya2007 avatar Sep 25 '21 00:09 yaya2007

2021-09-25

??? where is this version ???

steve6375 avatar Sep 25 '21 07:09 steve6375

就是9月24日版本 这是我从楼上下载的版本。 新建截图-20210925152939 新建截图-20210925152837

yaya2007 avatar Sep 25 '21 07:09 yaya2007

Very strange! I test on USB drive. I tested NTFS and FAT32 and VBOX5 and real system and USB HDD and USB Flash - all same result - did not copy! The first dd command is not working? image

steve6375 avatar Sep 25 '21 08:09 steve6375

image

steve6375 avatar Sep 25 '21 09:09 steve6375

我使用U盘启动后测试,是实体机,正常。不清楚你那里是怎么回事。

yaya2007 avatar Sep 25 '21 10:09 yaya2007

I am first booting to grubfm and then loading bootx64.efi grub4efi - would that make a difference? Could you do a test version of grub4dos for me to test?

steve6375 avatar Sep 25 '21 11:09 steve6375

What filesystem? NTFS? FAT32? FAT16?

steve6375 avatar Sep 25 '21 11:09 steve6375

我的U盘是FAT12。按说从哪里启动都应当是一样的,只要进入g4e环境。我怀疑有一条命令没有执行,就执行下一条命令了。我在调试g4e时,遇到过2次。一次是jpg图像解码错误,在一行代码后插入几微妙延时,才解决。

yaya2007 avatar Sep 25 '21 12:09 yaya2007

我的虚拟机是QEMU。难道是选择性地限制写操作?

yaya2007 avatar Sep 25 '21 12:09 yaya2007

Why not try real system?

steve6375 avatar Sep 25 '21 12:09 steve6375

I use vbox 5 and VMUB This is specifically written for vbox 5 and usb drives. Qemu will snapshot filesystem, it is not the same as real system.

steve6375 avatar Sep 25 '21 13:09 steve6375

虚拟机测试是使用QEMU。虚拟机在windows7环境。

真实机是U盘,没有进入操作系统 ,直接启动到grub4efi,是fat32分区。

yaya2007 avatar Sep 25 '21 13:09 yaya2007

虚拟机测试是使用QEMU。虚拟机在windows7环境。

真实机是U盘,没有进入操作系统 ,直接启动到grub4efi,是fat32分区。

yaya2007 avatar Sep 25 '21 13:09 yaya2007