I am working on recover, currently pset, and only my last photo is not processing properly.

I am calling fread(buffer, 1, 512, inptr) to read 512 bytes of data at a time. The video says fread returns the amount of data read, but I seem to only be getting 512 or 0 (for the last block). I suspect that the last block has something less than 512 bytes, and I was under the impression that fread() should return how many bytes were grabbed. I can't really tell if I am getting the last partial block twice or if it just returns nothing since it hits the end of the file.

IF there were 200 bytes in the last block of the file pointed to by inptr and I call fread(buffer, 1, 512, inptr), will fread return 200 and read 200 bytes of data? Or does it behave differently when it sees EoF?

Thanks for any help

  • can you post your code? – stensal Jun 12 '20 at 16:51
  • This "getting the last partial block twice" makes me speculate the problem is tied to how program is detecting end-of-file. Perhaps this video, starting around 8:20 will explain/clarify what is going on. The card.raw in the distro does not have any "partial blocks", it contains 10,255 512-byte blocks. with the posted syntax, fread will return 200 if it reads 200 bytes of data. – DinoCoderSaurus Jun 14 '20 at 20:49

You must log in to answer this question.

Browse other questions tagged .