nshlib: add du command support#3656
Open
Junbo-Zheng wants to merge 1 commit into
Open
Conversation
acassis
requested review from
cederom,
jerpelea,
linguini1,
simbit18 and
xiaoxiang781216
July 23, 2026 20:16
Contributor
|
@Junbo-Zheng please fix: |
acassis
previously approved these changes
Jul 24, 2026
Add a du command to NSH that recursively summarizes the size of each path argument in 1K-blocks, or human-readable form with -h. Supports -s (summary only), -a (all files), -d N (max-depth), and -h, matching GNU du semantics. Testing: Built and ran on sim:nsh with: ```bash cmake -B out/nuttx_sim_nsh -S nuttx -DBOARD_CONFIG=sim:nsh -GNinja ninja -C out/nuttx_sim_nsh ./out/nuttx_sim_nsh/nuttx nsh> du 397449 /data/test/elf 71993 /data/test/coredump 5 /data/test/log2 3251 /data/test/log1 472700 /data/test nsh> du -h 388.1M /data/test/elf 70.3M /data/test/coredump 4.1K /data/test/log2 3.1M /data/test/log1 461.6M /data/test ``` Host Ubuntu22.04 du on the same directory: ```bash $ du 397456 ./elf 72000 ./coredump 8 ./log2 3252 ./log1 472720 . $ du -h 389M ./elf 71M ./coredump 8.0K ./log2 3.2M ./log1 462M . ``` Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a
du(disk usage) command to NSH that recursively summarizes the size of each path argument in 1K-blocks, or in human-readable form with-h. Also supports-s(summary only),-a(all files),-d N(max-depth), and-h, matching GNUdusemantics.Impact
ducommand in NSH; no existing command or behaviorchanged.
CONFIG_NSH_DISABLE_DU(default followsDEFAULT_SMALL) to omit the command on small builds.Testing
Built and run on sim:nsh (host Ubuntu 22.04):
-hprints one decimal via integer arithmetic, float printf:Host Ubuntu 22.04
duon the same directory