From 6d9c0772615a573e2f01d0225ecb88b5675a7def Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 24 May 2025 21:29:06 -0500 Subject: [PATCH] Reordered LFSR_TAG_NAMELIMIT/FILELIMIT Not sure why, but this just seems more intuitive/correct. Maybe because LFSR_TAG_NAME is always the first tag in a file's attr set: LFSR_TAG_NAMELIMIT 0x0039 v--- ---- --11 1--1 LFSR_TAG_FILELIMIT 0x003a v--- ---- --11 1-1- Seeing as several parts of the codebase still use the previous order, it seems reasonable to switch back to that. No code changes. --- lfs.c | 60 +++++++++++++++++++++---------------------- scripts/dbgbmap.py | 6 ++--- scripts/dbgbmapsvg.py | 6 ++--- scripts/dbgbtree.py | 6 ++--- scripts/dbglfs.py | 6 ++--- scripts/dbgmtree.py | 6 ++--- scripts/dbgrbyd.py | 6 ++--- scripts/dbgtag.py | 6 ++--- 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/lfs.c b/lfs.c index 0460be87..e7001de4 100644 --- a/lfs.c +++ b/lfs.c @@ -1102,8 +1102,8 @@ enum lfsr_tag { LFSR_TAG_WCOMPAT = 0x0036, LFSR_TAG_OCOMPAT = 0x0037, LFSR_TAG_GEOMETRY = 0x0038, - LFSR_TAG_FILELIMIT = 0x0039, - LFSR_TAG_NAMELIMIT = 0x003a, + LFSR_TAG_NAMELIMIT = 0x0039, + LFSR_TAG_FILELIMIT = 0x003a, // in-device only, to help find unknown config tags LFSR_TAG_UNKNOWNCONFIG = 0x003b, @@ -3588,8 +3588,8 @@ static int lfsr_rbyd_appendrattr_(lfs_t *lfs, lfsr_rbyd_t *rbyd, // leb128? } else if (rattr.count >= 0 - && (rattr.tag == LFSR_TAG_FILELIMIT - || rattr.tag == LFSR_TAG_NAMELIMIT + && (rattr.tag == LFSR_TAG_NAMELIMIT + || rattr.tag == LFSR_TAG_FILELIMIT || rattr.tag == LFSR_TAG_DID)) { // leb128s should not exceed 31-bits LFS_ASSERT(rattr.u.leb128 <= 0x7fffffff); @@ -14362,32 +14362,6 @@ static int lfsr_mountmroot(lfs_t *lfs, const lfsr_mdir_t *mroot) { lfs->block_count = geometry.block_count; - // read the file limit - lfs_off_t file_limit = 0x7fffffff; - err = lfsr_mdir_lookup(lfs, mroot, LFSR_TAG_FILELIMIT, - NULL, &data); - if (err && err != LFS_ERR_NOENT) { - return err; - } - if (err != LFS_ERR_NOENT) { - err = lfsr_data_readleb128(lfs, &data, &file_limit); - if (err && err != LFS_ERR_CORRUPT) { - return err; - } - if (err == LFS_ERR_CORRUPT) { - file_limit = -1; - } - } - - if (file_limit > lfs->file_limit) { - LFS_ERROR("Incompatible file limit %"PRId32" (> %"PRId32")", - file_limit, - lfs->file_limit); - return LFS_ERR_NOTSUP; - } - - lfs->file_limit = file_limit; - // read the name limit lfs_size_t name_limit = 0xff; err = lfsr_mdir_lookup(lfs, mroot, LFSR_TAG_NAMELIMIT, @@ -14414,6 +14388,32 @@ static int lfsr_mountmroot(lfs_t *lfs, const lfsr_mdir_t *mroot) { lfs->name_limit = name_limit; + // read the file limit + lfs_off_t file_limit = 0x7fffffff; + err = lfsr_mdir_lookup(lfs, mroot, LFSR_TAG_FILELIMIT, + NULL, &data); + if (err && err != LFS_ERR_NOENT) { + return err; + } + if (err != LFS_ERR_NOENT) { + err = lfsr_data_readleb128(lfs, &data, &file_limit); + if (err && err != LFS_ERR_CORRUPT) { + return err; + } + if (err == LFS_ERR_CORRUPT) { + file_limit = -1; + } + } + + if (file_limit > lfs->file_limit) { + LFS_ERROR("Incompatible file limit %"PRId32" (> %"PRId32")", + file_limit, + lfs->file_limit); + return LFS_ERR_NOTSUP; + } + + lfs->file_limit = file_limit; + // check for unknown configs lfsr_tag_t tag; err = lfsr_mdir_lookupnext(lfs, mroot, LFSR_TAG_UNKNOWNCONFIG, diff --git a/scripts/dbgbmap.py b/scripts/dbgbmap.py index 465aecf5..45fc6ff9 100755 --- a/scripts/dbgbmap.py +++ b/scripts/dbgbmap.py @@ -37,8 +37,8 @@ TAG_RCOMPAT = 0x0035 # 0x0035 v--- ---- --11 -1-1 TAG_WCOMPAT = 0x0036 # 0x0036 v--- ---- --11 -11- TAG_OCOMPAT = 0x0037 # 0x0037 v--- ---- --11 -111 TAG_GEOMETRY = 0x0038 # 0x0038 v--- ---- --11 1--- -TAG_FILELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 -TAG_NAMELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- +TAG_NAMELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 +TAG_FILELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- TAG_GDELTA = 0x0100 ## 0x01tt v--- ---1 -ttt ttrr TAG_GRMDELTA = 0x0100 # 0x0100 v--- ---1 ---- ---- TAG_NAME = 0x0200 ## 0x02tt v--- --1- -ttt tttt @@ -292,8 +292,8 @@ def tagrepr(tag, weight=None, size=None, *, else 'wcompat' if (tag & 0xfff) == TAG_WCOMPAT else 'ocompat' if (tag & 0xfff) == TAG_OCOMPAT else 'geometry' if (tag & 0xfff) == TAG_GEOMETRY - else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT + else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'config 0x%02x' % (tag & 0xff), ' w%d' % weight if weight else '', ' %s' % size if size is not None else '') diff --git a/scripts/dbgbmapsvg.py b/scripts/dbgbmapsvg.py index d6b9a68a..304729d8 100755 --- a/scripts/dbgbmapsvg.py +++ b/scripts/dbgbmapsvg.py @@ -35,8 +35,8 @@ TAG_RCOMPAT = 0x0035 # 0x0035 v--- ---- --11 -1-1 TAG_WCOMPAT = 0x0036 # 0x0036 v--- ---- --11 -11- TAG_OCOMPAT = 0x0037 # 0x0037 v--- ---- --11 -111 TAG_GEOMETRY = 0x0038 # 0x0038 v--- ---- --11 1--- -TAG_FILELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 -TAG_NAMELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- +TAG_NAMELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 +TAG_FILELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- TAG_GDELTA = 0x0100 ## 0x01tt v--- ---1 -ttt ttrr TAG_GRMDELTA = 0x0100 # 0x0100 v--- ---1 ---- ---- TAG_NAME = 0x0200 ## 0x02tt v--- --1- -ttt tttt @@ -322,8 +322,8 @@ def tagrepr(tag, weight=None, size=None, *, else 'wcompat' if (tag & 0xfff) == TAG_WCOMPAT else 'ocompat' if (tag & 0xfff) == TAG_OCOMPAT else 'geometry' if (tag & 0xfff) == TAG_GEOMETRY - else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT + else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'config 0x%02x' % (tag & 0xff), ' w%d' % weight if weight else '', ' %s' % size if size is not None else '') diff --git a/scripts/dbgbtree.py b/scripts/dbgbtree.py index 80b0da5d..fb1bd4ad 100755 --- a/scripts/dbgbtree.py +++ b/scripts/dbgbtree.py @@ -26,8 +26,8 @@ TAG_RCOMPAT = 0x0035 # 0x0035 v--- ---- --11 -1-1 TAG_WCOMPAT = 0x0036 # 0x0036 v--- ---- --11 -11- TAG_OCOMPAT = 0x0037 # 0x0037 v--- ---- --11 -111 TAG_GEOMETRY = 0x0038 # 0x0038 v--- ---- --11 1--- -TAG_FILELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 -TAG_NAMELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- +TAG_NAMELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 +TAG_FILELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- TAG_GDELTA = 0x0100 ## 0x01tt v--- ---1 -ttt ttrr TAG_GRMDELTA = 0x0100 # 0x0100 v--- ---1 ---- ---- TAG_NAME = 0x0200 ## 0x02tt v--- --1- -ttt tttt @@ -200,8 +200,8 @@ def tagrepr(tag, weight=None, size=None, *, else 'wcompat' if (tag & 0xfff) == TAG_WCOMPAT else 'ocompat' if (tag & 0xfff) == TAG_OCOMPAT else 'geometry' if (tag & 0xfff) == TAG_GEOMETRY - else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT + else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'config 0x%02x' % (tag & 0xff), ' w%d' % weight if weight else '', ' %s' % size if size is not None else '') diff --git a/scripts/dbglfs.py b/scripts/dbglfs.py index 3cbd0513..acca4001 100755 --- a/scripts/dbglfs.py +++ b/scripts/dbglfs.py @@ -27,8 +27,8 @@ TAG_RCOMPAT = 0x0035 # 0x0035 v--- ---- --11 -1-1 TAG_WCOMPAT = 0x0036 # 0x0036 v--- ---- --11 -11- TAG_OCOMPAT = 0x0037 # 0x0037 v--- ---- --11 -111 TAG_GEOMETRY = 0x0038 # 0x0038 v--- ---- --11 1--- -TAG_FILELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 -TAG_NAMELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- +TAG_NAMELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 +TAG_FILELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- TAG_GDELTA = 0x0100 ## 0x01tt v--- ---1 -ttt ttrr TAG_GRMDELTA = 0x0100 # 0x0100 v--- ---1 ---- ---- TAG_NAME = 0x0200 ## 0x02tt v--- --1- -ttt tttt @@ -249,8 +249,8 @@ def tagrepr(tag, weight=None, size=None, *, else 'wcompat' if (tag & 0xfff) == TAG_WCOMPAT else 'ocompat' if (tag & 0xfff) == TAG_OCOMPAT else 'geometry' if (tag & 0xfff) == TAG_GEOMETRY - else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT + else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'config 0x%02x' % (tag & 0xff), ' w%d' % weight if weight else '', ' %s' % size if size is not None else '') diff --git a/scripts/dbgmtree.py b/scripts/dbgmtree.py index 248cc5d5..2843659d 100755 --- a/scripts/dbgmtree.py +++ b/scripts/dbgmtree.py @@ -26,8 +26,8 @@ TAG_RCOMPAT = 0x0035 # 0x0035 v--- ---- --11 -1-1 TAG_WCOMPAT = 0x0036 # 0x0036 v--- ---- --11 -11- TAG_OCOMPAT = 0x0037 # 0x0037 v--- ---- --11 -111 TAG_GEOMETRY = 0x0038 # 0x0038 v--- ---- --11 1--- -TAG_FILELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 -TAG_NAMELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- +TAG_NAMELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 +TAG_FILELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- TAG_GDELTA = 0x0100 ## 0x01tt v--- ---1 -ttt ttrr TAG_GRMDELTA = 0x0100 # 0x0100 v--- ---1 ---- ---- TAG_NAME = 0x0200 ## 0x02tt v--- --1- -ttt tttt @@ -215,8 +215,8 @@ def tagrepr(tag, weight=None, size=None, *, else 'wcompat' if (tag & 0xfff) == TAG_WCOMPAT else 'ocompat' if (tag & 0xfff) == TAG_OCOMPAT else 'geometry' if (tag & 0xfff) == TAG_GEOMETRY - else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT + else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'config 0x%02x' % (tag & 0xff), ' w%d' % weight if weight else '', ' %s' % size if size is not None else '') diff --git a/scripts/dbgrbyd.py b/scripts/dbgrbyd.py index 905b0eeb..05c70e83 100755 --- a/scripts/dbgrbyd.py +++ b/scripts/dbgrbyd.py @@ -36,8 +36,8 @@ TAG_RCOMPAT = 0x0035 # 0x0035 v--- ---- --11 -1-1 TAG_WCOMPAT = 0x0036 # 0x0036 v--- ---- --11 -11- TAG_OCOMPAT = 0x0037 # 0x0037 v--- ---- --11 -111 TAG_GEOMETRY = 0x0038 # 0x0038 v--- ---- --11 1--- -TAG_FILELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 -TAG_NAMELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- +TAG_NAMELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 +TAG_FILELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- TAG_GDELTA = 0x0100 ## 0x01tt v--- ---1 -ttt ttrr TAG_GRMDELTA = 0x0100 # 0x0100 v--- ---1 ---- ---- TAG_NAME = 0x0200 ## 0x02tt v--- --1- -ttt tttt @@ -203,8 +203,8 @@ def tagrepr(tag, weight=None, size=None, *, else 'wcompat' if (tag & 0xfff) == TAG_WCOMPAT else 'ocompat' if (tag & 0xfff) == TAG_OCOMPAT else 'geometry' if (tag & 0xfff) == TAG_GEOMETRY - else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT + else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'config 0x%02x' % (tag & 0xff), ' w%d' % weight if weight else '', ' %s' % size if size is not None else '') diff --git a/scripts/dbgtag.py b/scripts/dbgtag.py index cd8402e5..e0322359 100755 --- a/scripts/dbgtag.py +++ b/scripts/dbgtag.py @@ -19,8 +19,8 @@ TAG_RCOMPAT = 0x0035 # 0x0035 v--- ---- --11 -1-1 TAG_WCOMPAT = 0x0036 # 0x0036 v--- ---- --11 -11- TAG_OCOMPAT = 0x0037 # 0x0037 v--- ---- --11 -111 TAG_GEOMETRY = 0x0038 # 0x0038 v--- ---- --11 1--- -TAG_FILELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 -TAG_NAMELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- +TAG_NAMELIMIT = 0x0039 # 0x0039 v--- ---- --11 1--1 +TAG_FILELIMIT = 0x003a # 0x003a v--- ---- --11 1-1- TAG_GDELTA = 0x0100 ## 0x01tt v--- ---1 -ttt ttrr TAG_GRMDELTA = 0x0100 # 0x0100 v--- ---1 ---- ---- TAG_NAME = 0x0200 ## 0x02tt v--- --1- -ttt tttt @@ -107,8 +107,8 @@ def tagrepr(tag, weight=None, size=None, *, else 'wcompat' if (tag & 0xfff) == TAG_WCOMPAT else 'ocompat' if (tag & 0xfff) == TAG_OCOMPAT else 'geometry' if (tag & 0xfff) == TAG_GEOMETRY - else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'namelimit' if (tag & 0xfff) == TAG_NAMELIMIT + else 'filelimit' if (tag & 0xfff) == TAG_FILELIMIT else 'config 0x%02x' % (tag & 0xff), ' w%d' % weight if weight else '', ' %s' % size if size is not None else '')