|
19 | 19 |
|
20 | 20 |
|
21 | 21 | def _fs_from_args(args: argparse.Namespace, block_count=None, mount=True, context: UserContext = None) -> LittleFS: |
| 22 | + """Build LittleFS from CLI args. Options name_max, attr_max, file_max are stored in the |
| 23 | + superblock and must match when mounting an existing image. inline_max is format-relevant |
| 24 | + (limiting it may improve flash usage).""" |
22 | 25 | block_count = block_count if block_count is not None else getattr(args, "block_count", 0) |
23 | | - return LittleFS( |
24 | | - context=context, |
25 | | - block_size=args.block_size, |
26 | | - block_count=block_count, |
27 | | - name_max=args.name_max, |
28 | | - mount=mount, |
29 | | - ) |
| 26 | + kwargs = { |
| 27 | + "block_size": args.block_size, |
| 28 | + "block_count": block_count, |
| 29 | + "name_max": args.name_max, |
| 30 | + "inline_max": args.inline_max, |
| 31 | + "attr_max": args.attr_max, |
| 32 | + "file_max": args.file_max, |
| 33 | + } |
| 34 | + return LittleFS(context=context, mount=mount, **kwargs) |
30 | 35 |
|
31 | 36 |
|
32 | 37 | def size_parser(size_str): |
@@ -81,6 +86,12 @@ def create(parser: argparse.ArgumentParser, args: argparse.Namespace) -> int: |
81 | 86 | print(f" Image Size: {args.fs_size:9d} / 0x{args.fs_size:X}") |
82 | 87 | print(f" Block Count: {args.block_count:9d}") |
83 | 88 | print(f" Name Max: {args.name_max:9d}") |
| 89 | + if args.inline_max: |
| 90 | + print(f" Inline Max: {args.inline_max:9d} / 0x{args.inline_max:X}") |
| 91 | + if args.attr_max: |
| 92 | + print(f" Attr Max: {args.attr_max:9d}") |
| 93 | + if args.file_max: |
| 94 | + print(f" File Max: {args.file_max:9d}") |
84 | 95 | print(f" Image: {args.destination}") |
85 | 96 |
|
86 | 97 | source = Path(args.source).absolute() |
@@ -144,6 +155,12 @@ def _mount_from_context(parser: argparse.ArgumentParser, args: argparse.Namespac |
144 | 155 | print(f" Image Size: {input_image_size:9d} / 0x{input_image_size:X}") |
145 | 156 | print(f" Block Count: {fs.block_count:9d}") |
146 | 157 | print(f" Name Max: {args.name_max:9d}") |
| 158 | + if args.inline_max: |
| 159 | + print(f" Inline Max: {args.inline_max:9d} / 0x{args.inline_max:X}") |
| 160 | + if args.attr_max: |
| 161 | + print(f" Attr Max: {args.attr_max:9d}") |
| 162 | + if args.file_max: |
| 163 | + print(f" File Max: {args.file_max:9d}") |
147 | 164 | print(f" Image: {args.source}") |
148 | 165 |
|
149 | 166 | return fs |
@@ -251,12 +268,32 @@ def get_parser(): |
251 | 268 |
|
252 | 269 | common_parser = argparse.ArgumentParser(add_help=False) |
253 | 270 | common_parser.add_argument("-v", "--verbose", action="count", default=0) |
| 271 | + # Stored in superblock; must match when mounting an existing image: |
254 | 272 | common_parser.add_argument( |
255 | 273 | "--name-max", |
256 | 274 | type=size_parser, |
257 | 275 | default=255, |
258 | 276 | help="LittleFS max file path length. Defaults to LittleFS's default (255).", |
259 | 277 | ) |
| 278 | + common_parser.add_argument( |
| 279 | + "--attr-max", |
| 280 | + type=int, |
| 281 | + default=0, |
| 282 | + help="Max custom attribute size per file. Defaults to LittleFS's default (0 = use library default).", |
| 283 | + ) |
| 284 | + common_parser.add_argument( |
| 285 | + "--file-max", |
| 286 | + type=int, |
| 287 | + default=0, |
| 288 | + help="Max number of open files. Defaults to LittleFS's default (0 = use library default).", |
| 289 | + ) |
| 290 | + # Format option: limiting inline_max may improve flash usage. |
| 291 | + common_parser.add_argument( |
| 292 | + "--inline-max", |
| 293 | + type=size_parser, |
| 294 | + default=0, |
| 295 | + help="Max inline file size; 0 = use library default. Limiting can improve flash usage.", |
| 296 | + ) |
260 | 297 |
|
261 | 298 | subparsers = parser.add_subparsers(required=True, title="Available Commands", dest="command") |
262 | 299 |
|
|
0 commit comments