Fixed issue with creating files named "littlefs"

A rather humorous issue, we accidentally ended up mixing our file
namespace with our superblocks. This meant if we created a file named
"littlefs" it would reference the superblock and all sorts of things
would break.

Fixing this also highlighted another issue, the fact that the superblock
always needs to come before any file entries in the directory. I didn't
account for this in the initial B-tree design, but we need a higher
ordering for superblocks + children + files than just name. To fix this
I added ordering information in the 2 bits currently unused in the tag
type. Though note that the size of these fields are flexible.

9-bit type field:
[---      9      ---]
[1|- 3 -|- 2 -|- 3 -]
 ^   ^     ^     ^- type-specific info
 |   |     \------- ordering info
 |   \------------- subtype
 \----------------- user bit
This commit is contained in:
Christopher Haster
2018-10-04 16:25:19 -05:00
parent aeca7667b3
commit 97a7191814
4 changed files with 50 additions and 40 deletions

View File

@@ -4,8 +4,8 @@ import struct
import binascii
TYPES = {
(0x1ff, 0x002): 'reg',
(0x1ff, 0x003): 'dir',
(0x1ff, 0x011): 'create reg',
(0x1ff, 0x010): 'create dir',
(0x1ff, 0x001): 'superblock',
(0x1ff, 0x020): 'delete',
(0x1f0, 0x0e0): 'globals',
@@ -23,10 +23,10 @@ def typeof(type):
mask = 0x1ff & ~((1 << prefix)-1)
if (mask, type & mask) in TYPES:
return TYPES[mask, type & mask] + (
' [%0*x]' % (prefix/4, type & ((1 << prefix)-1))
' %0*x' % (prefix/4, type & ((1 << prefix)-1))
if prefix else '')
else:
return '[%02x]' % type
return '%02x' % type
def main(*blocks):
# find most recent block