mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	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
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user