-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io.Copy error? #132
Comments
Interesting. I was able to reproduce it.
Based on the diff, it looks like the first 0x3c0000 bytes are identical, which is 3932160, or the exact 120 complete writes. That would mean that the last partial write is not going across correctly. Can you confirm those numbers? If they are, can you construct a simple file of just one whole and one partial, perhaps a 64000 byte file, and see what happens with that? |
I can confirm the input size is the same with mine. (FWIW my actual file was 48M, the file I'm reporting here was for demonstration purposes) I had wondered whether I should just do io.CopyBytes() over a loop. |
Indeed when I make /tmp/in only the first 64000 bytes of the original file, then it works. |
Hold on. 64000 bytes exactly works? But it isn't an exact multiple of 32768. |
Yeah, but it works! It gets worse. When I use mcopy to copy the file out of the fat32 file, the file is copied out correctly! At least I think. I might be doing something wrong. Will try again in the morning. |
Oh, well:
/mnt/EFI/BOOT/kernel.efi is the file on the mounted fat. Heck maybe it's a Linux kernel bug. Well, where does the 'Blocks: 126' come from? |
So this 3962026 byte file works except for the last <32768 (i.e. single cluster) chunk. But a 64000 byte file with exactly one cluster and another <32768 does not. That is odd.
You mean when you use mcopy with the 3962026 file that we used before? I need to see that. |
Luck of the draw. Try 63000 and 65000 and it still gives the error. Exactly 64000 works. This is significant, but I do not know why or how. |
And it isn't multiples of 32000 either, but exact multiples of 64000. 10000 also fails. How odd |
Could it be the underlying OS filesystem not flushing or something? That 64000 is not a multiple of 32768 or 512, so it is quite strange. I stepped through the code with a 10000 byte file, it clearly is the last cluster (272 bytes) that is not getting sent out. No, that isn't it. I tried your mcopy. The copied file has the same hash, but then I mount the disk and still have the issue:
This leads me to suspect that there is something going on with how Linux is mounting it. Given the age, I would suspect that there is something mcopy is comfortable with that diskfs is taking advantage of, but that Linux kernel (more correctly, the fat32 driver) is stricter about. I have no evidence at this time to prove it, though. |
Yeah I need to find some time to instrument a linux kernel's fat driver and run it in a vm, but I'm afraid it probably won't be today. |
I'm probably doing something wrong here, so apologies in advance. However, when I copy a large file into a newly created fat32, the copied size is correct, but the tail of the file is zeroed out.
Using the following as a fat32.go test file: https://gist.github.com/hallyn/24acd9c7cf407c0561629b5c032f2bb8
With the following go.mod:
I fetched
https://github.com/shadow-maint/shadow/releases/download/v4.9/shadow-4.9.tar.gz
and copied it to /tmp/in, and ran 'go run fat32.go'. The test places the output
in /tmp/fat, so
The text was updated successfully, but these errors were encountered: