diff options
author | Christopher Haster <chaster@utexas.edu> | 2018-09-15 10:40:53 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2018-10-18 18:00:49 +0300 |
commit | d7e4abad0bbbff05489a85a66302d5adb12cb789 (patch) | |
tree | cf3a8c57b168f95a167b89e5bf37ed327668b78c /tests | |
parent | cafe6ab46603244522916c7580385bfd04a3cff4 (diff) |
Edited tag structure to balance size vs id count
This is a minor tweak that resulted from looking at some other use cases
for the littlefs data-structure on disk. Consider an implementation that
does not need to buffer inline-files in RAM. In this case we should have
as large a tag size field as possible. Unfortunately, we don't have much
space to work with in the 32-bit tag struct, so we have to make some
compromises. These limitations could be removed with a 64-bit tag
struct, at the cost of code size.
32-bit tag structure:
[--- 32 ---]
[1|- 9 -|- 9 -|-- 13 --]
^ ^ ^ ^- entry length
| | \-------- file id
| \-------------- tag type
\------------------ valid bit
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/corrupt.py | 2 | ||||
-rwxr-xr-x | tests/debug.py | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/corrupt.py b/tests/corrupt.py index 4a49d42..d994389 100755 --- a/tests/corrupt.py +++ b/tests/corrupt.py @@ -19,7 +19,7 @@ def corrupt(block): break tag ^= ntag - size = (tag & 0xfff) if (tag & 0xfff) != 0xfff else 0 + size = (tag & 0x1fff) if (tag & 0x1fff) != 0x1fff else 0 file.seek(size, os.SEEK_CUR) # lob off last 3 bytes diff --git a/tests/debug.py b/tests/debug.py index 2fcc05a..0088442 100755 --- a/tests/debug.py +++ b/tests/debug.py @@ -76,11 +76,11 @@ def main(*blocks): off += 4 type = (tag & 0x7fc00000) >> 22 - id = (tag & 0x003ff000) >> 12 - size = (tag & 0x00000fff) >> 0 + id = (tag & 0x003fe000) >> 13 + size = (tag & 0x00001fff) >> 0 iscrc = (type & 0x1f0) == 0x0f0 - data = file.read(size if size != 0xfff else 0) + data = file.read(size if size != 0x1fff else 0) if iscrc: crc = binascii.crc32(data[:4], crc) else: @@ -89,12 +89,12 @@ def main(*blocks): print '%04x: %08x %-14s %3s %3s %-23s %-8s' % ( off, tag, typeof(type) + (' bad!' if iscrc and ~crc else ''), - id if id != 0x3ff else '.', - size if size != 0xfff else 'x', + id if id != 0x1ff else '.', + size if size != 0x1fff else 'x', ' '.join('%02x' % ord(c) for c in data[:8]), ''.join(c if c >= ' ' and c <= '~' else '.' for c in data[:8])) - off += size if size != 0xfff else 0 + off += size if size != 0x1fff else 0 if iscrc: crc = 0 tag ^= (type & 1) << 31 |