Skip to content

Commit cd7dd37

Browse files
committed
scripts: dbglfs3.py: Adopted % as littlefs root dir character
The idea is this is similar to ~ for the home directory, hopefully simplifying littlefs path parsing in scripts: - /hi -> hi in root dir - ./hi -> hi in current dir - ../hi -> hi in parent dir - ~/hi -> hi in home dir - %/hi -> hi in littlefs root dir Note this only works when standalone: - ~hi != ~/hi - %hi != %/hi And files named % can still be referenced with a ./ prefix: - ./% -> % in current dir - %/% -> % in littlefs root dir --- This is probably overkill for dbglfs3.py, as the arg ordering was already enough to disambiguate disk path vs mroot address vs littlefs path, but eventually I think the idea will be useful for more powerful scripts. A hypothetical: $ mklfs3 cp disk -b4096 -r image_files %/image_files
1 parent 0d5cdea commit cd7dd37

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/dbglfs3.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4422,8 +4422,14 @@ def dbg_files(lfs, paths, *,
44224422
# parse all paths first, error if anything is malformed
44234423
dirs = []
44244424
# default paths to the root dir
4425-
for path in (paths or ['/']):
4425+
for path in (paths or ['%']):
44264426
try:
4427+
# skip leading %
4428+
if path == '%':
4429+
path = '/'
4430+
if path.startswith('%/'):
4431+
path = path[1:]
4432+
# lookup path
44274433
dir = lfs.pathlookup(path,
44284434
all=args.get('all'))
44294435
except Lfs3.PathError as e:
@@ -4952,16 +4958,17 @@ def __call__(self, parser, namespace, values, option):
49524958
parser.add_argument(
49534959
'mroots',
49544960
nargs='*',
4955-
type=lambda x: rbydaddr(x) if not x.startswith('/') else x,
4961+
type=lambda x: rbydaddr(x) if not x.startswith('%') else x,
49564962
action=AppendMrootOrPath,
49574963
help="Block address of the mroots. Defaults to 0x{0,1}.")
49584964
parser.add_argument(
49594965
'paths',
49604966
nargs='*',
4961-
type=lambda x: rbydaddr(x) if not x.startswith('/') else x,
4967+
type=lambda x: rbydaddr(x) if not x.startswith('%') else x,
49624968
action=AppendMrootOrPath,
4963-
help="Paths to show, must start with a leading slash. Defaults "
4964-
"to the root directory.")
4969+
help="Paths to show, must start with %% where %% indicates the "
4970+
"root littlefs directory. Defaults to the root littlefs "
4971+
"directory.")
49654972
parser.add_argument(
49664973
'--trunk',
49674974
type=lambda x: int(x, 0),

0 commit comments

Comments
 (0)