resyfer opened a new pull request, #14533:
URL: https://github.com/apache/nuttx/pull/14533
## Summary
- Fix bug which prevents mkdir for depth > 3 (bug present in
`mfs_get_patharr`).
- Better logs for mnemofs
- Improve logging macro `MFS_LOG` and `MFS_EXTRA_LOG`
- Add logs for `mfs_get_patharr` and `next_child`.
The former change is necessary as `mkdir` worked for mnemofs only upto 3
items in the requested path, but failed for anything more.
The latter change is required to provide better logs for mnemofs.
## Impact
- `mkdir` for any number of items in the path.
- Better debugging using the improved logs.
- Build Impact: No.
- User Impact: Better logs to report in case of crashes and no errors while
creating directories with depth more than 3.
- Documentation: The code printing the logs also serve as section-wise docs.
## Testing
I confirm that changes are verified on local setup and works as intended:
- Build Host(s): OS (Linux), CPU(Intel), compiler(GCC 13).
- Target(s): arch(sim), sim:mnemofs.
Logs before:
```
nsh> mkdir /hi/bye/die/lie
binfs_stat: Entry
mnemofs_mkdir: Mnemofs mkdir at bye/die/lie.
mnemofs_mkdir: Lock acquired.
...
mnemofs_mkdir: File exists.
mfs_pitr_free: Pitr at depth 231216 with CTZ (21264, 231200) freed.
mnemofs_mkdir: Lock released.
mnemofs_mkdir: Mnemofs mkdir exited with ret -17.
nsh: /hi/bye/die/lie: mkdir failed: 17
```
Logs after:
```
nsh> mkdir /hi/bye/die/lie
binfs_stat: Entry
mnemofs_mkdir: [mnemofs | MKDIR] Entry.
mnemofs_mkdir: [mnemofs | MKDIR] New directory at "bye/die/lie".
mnemofs_mkdir: [mnemofs | MKDIR] Mode is 0x41ff.
mnemofs_mkdir: [mnemofs | MKDIR] Superblock is 0x512000000040.
mnemofs_mkdir: [mnemofs | MKDIR] Mutex lock acquired.
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Entry.
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Relpath is "bye/die/lie".
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Path is 0x5310000386c0.
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] There are 4 objects in path.
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Path array is allocated at
0x506000000320.
next_child: [mnemofs | NEXT_CHILD] Requested string is "bye/die/lie"
(0x502000000414),
next_child: [mnemofs | NEXT_CHILD] Length is 3
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Root Master Node.
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] CTZ is (0, 432)
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Size is 68
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Looking at depth 1
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Current String is "bye"
(0x502000000414)
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Name length is 3
mfs_get_patharr: [mnemofs | MFS_GET_PATHARR] Next String is "die/lie"
mfs_hash: Hash calculated for size 3 to be 22722
...
mnemofs_mkdir: [mnemofs | MKDIR] Direntry append successful.
mnemofs_mkdir: [mnemofs | MKDIR] Depth of parent 3.
mnemofs_mkdir: [mnemofs | MKDIR] Current iteration offset 0.
mnemofs_mkdir: [mnemofs | MKDIR] Parent's offset 0.
mnemofs_mkdir: [mnemofs | MKDIR] Parent's size 0.
mnemofs_mkdir: [mnemofs | MKDIR] Parent's CTZ (0, 0)
mfs_pitr_free: Pitr at depth 3 with CTZ (0, 0) freed.
mnemofs_mkdir: [mnemofs | MKDIR] Parent iterator freed.
mnemofs_mkdir: [mnemofs | MKDIR] Directory created at "bye/die/lie".
mnemofs_mkdir: [mnemofs | MKDIR] Path array freed.
mnemofs_mkdir: [mnemofs | MKDIR] Mutex released.
mnemofs_mkdir: [mnemofs | MKDIR] Exit | Return: 0.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]