mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-01 12:20:02 +00:00
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
This commit is contained in:
@ -4422,8 +4422,14 @@ def dbg_files(lfs, paths, *,
|
||||
# parse all paths first, error if anything is malformed
|
||||
dirs = []
|
||||
# default paths to the root dir
|
||||
for path in (paths or ['/']):
|
||||
for path in (paths or ['%']):
|
||||
try:
|
||||
# skip leading %
|
||||
if path == '%':
|
||||
path = '/'
|
||||
if path.startswith('%/'):
|
||||
path = path[1:]
|
||||
# lookup path
|
||||
dir = lfs.pathlookup(path,
|
||||
all=args.get('all'))
|
||||
except Lfs3.PathError as e:
|
||||
@ -4952,16 +4958,17 @@ if __name__ == "__main__":
|
||||
parser.add_argument(
|
||||
'mroots',
|
||||
nargs='*',
|
||||
type=lambda x: rbydaddr(x) if not x.startswith('/') else x,
|
||||
type=lambda x: rbydaddr(x) if not x.startswith('%') else x,
|
||||
action=AppendMrootOrPath,
|
||||
help="Block address of the mroots. Defaults to 0x{0,1}.")
|
||||
parser.add_argument(
|
||||
'paths',
|
||||
nargs='*',
|
||||
type=lambda x: rbydaddr(x) if not x.startswith('/') else x,
|
||||
type=lambda x: rbydaddr(x) if not x.startswith('%') else x,
|
||||
action=AppendMrootOrPath,
|
||||
help="Paths to show, must start with a leading slash. Defaults "
|
||||
"to the root directory.")
|
||||
help="Paths to show, must start with %% where %% indicates the "
|
||||
"root littlefs directory. Defaults to the root littlefs "
|
||||
"directory.")
|
||||
parser.add_argument(
|
||||
'--trunk',
|
||||
type=lambda x: int(x, 0),
|
||||
|
||||
Reference in New Issue
Block a user