Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a file checksum directly from the filesystem instead of calculating it explicitly

I'm guessing that a typical filesystem tends to keep some kind of checksum/CRC/hash of every file it manages, so it can detect file corruption.

Is that guess correct? And if yes, is there a way to access it?

I'm primarily interested in Windows and NTFS, but comments on other platforms would be welcome as well... Language is unimportant at this point, but I'd like to avoid assembler if possible.

like image 351
Branko Dimitrijevic Avatar asked Oct 10 '22 17:10

Branko Dimitrijevic


2 Answers

OK, it appears that what I'm asking is impossible.

BTW, this was also discussed here: There is in Windows file systems a pre computed hash for each file?

like image 100
Branko Dimitrijevic Avatar answered Oct 13 '22 12:10

Branko Dimitrijevic


In the majority of filesystems and the storage hardware they would keep checksums of allocation units, not full files.

The checksums in the hardware are probably not accessible at all in general, and the checksum of the filesystem clusters would not be very useful for the great majority of cases so would be difficult to get, if possible.

like image 36
Thymine Avatar answered Oct 13 '22 10:10

Thymine