mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
CDB seemed to be too simple for the needs of init, and squashfs is too laden with design choices to work around Linux's APIs. This commit adds creation of an initrd image of a new format I've called `j6romfs`. Note that this commit currently does not work! The initrd-reading code still needs to be added.
18 lines
460 B
Python
18 lines
460 B
Python
"""Python implementation of FNV hashes."""
|
|
|
|
_FNV1_prime32 = 16777619
|
|
_FNV1_prime64 = 1099511628211
|
|
_FNV1_offset32 = 2166136261
|
|
_FNV1_offset64 = 14695981039346656037
|
|
|
|
def _fnv1a(offset, prime, mask):
|
|
def hashfunc(data):
|
|
h = offset
|
|
for b in data:
|
|
h = ((h ^ b) * prime) & mask
|
|
return h
|
|
return hashfunc
|
|
|
|
hash64 = _fnv1a(_FNV1_offset64, _FNV1_prime64, (2**64)-1)
|
|
hash32 = _fnv1a(_FNV1_offset32, _FNV1_prime32, (2**32)-1)
|