Messages in this thread | ![/](/images/icornerl.gif) | | Date | Thu, 28 Aug 2003 07:13:33 +0100 | From | Jamie Lokier <> | Subject | Re: Lockless file reading |
| |
Timo Sirainen wrote: > I'm sure someone has figured out a way to make a checksum of data that > can detect if there's even a single bit wrong, if the checksum is > allowed to take as much space as the data itself. I should read more > about algorithms..
You said that MD5 wasn't strong enough, and you would like a guarantee.
You won't find a guarantee unless you are prepared to use memory barriers in your code. _Any_ checksum is going to have a chance of false validation if you are doing out-of-order reads which can observe parts of the old and new data, and parts of the old and new checksum.
> How about checksum[n] = data[n-1] ^ data[n]? That looks like it would > work.
Consider when the data {1,0,1,0} is replaced by {2,0,2,0}.
-- Jamie
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| ![\](/images/icornerr.gif) |