nuttx-apps/nshlib
Junbo Zheng 101b713be6 nshlib: add du command support
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>
2026-07-26 07:39:39 -03:00
..
CMakeLists.txt netutils/dropbear: add Dropbear SSH server port for NuttX 2026-06-27 08:42:00 -03:00
Kconfig nshlib: add du command support 2026-07-26 07:39:39 -03:00
Make.defs nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
Makefile netutils/dropbear: add Dropbear SSH server port for NuttX 2026-06-27 08:42:00 -03:00
nsh.h nshlib: add du command support 2026-07-26 07:39:39 -03:00
nsh_alias.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_altconsole.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_builtin.c sched/signal: Add support to disable partial or all signals 2026-01-15 15:48:54 +08:00
nsh_codeccmd.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_command.c nshlib: add du command support 2026-07-26 07:39:39 -03:00
nsh_console.c nshlib: fix infinite loop on broken stdout in nsh_catfile 2026-05-26 16:06:28 -03:00
nsh_console.h nshlib: Add stderr redirection support 2026-01-27 03:14:00 +08:00
nsh_consolemain.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_dbgcmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_dropbear.c netutils/dropbear: add Dropbear SSH server port for NuttX 2026-06-27 08:42:00 -03:00
nsh_envcmds.c nsh/echo: Fix echo previous behavior, single write with '\n' 2026-06-27 13:44:14 +02:00
nsh_fileapps.c nshlib: Add stderr redirection support 2026-01-27 03:14:00 +08:00
nsh_fscmds.c nshlib: add du command support 2026-07-26 07:39:39 -03:00
nsh_fsutils.c nshlib: fix infinite loop on broken stdout in nsh_catfile 2026-05-26 16:06:28 -03:00
nsh_identity.c !nshlib: Remove fixed login; require FSUTILS_PASSWD 2026-07-22 17:21:22 +08:00
nsh_init.c netutils/dropbear: add Dropbear SSH server port for NuttX 2026-06-27 08:42:00 -03:00
nsh_login.c !nshlib: Remove fixed login; require FSUTILS_PASSWD 2026-07-22 17:21:22 +08:00
nsh_mmcmds.c apps/nshlib: Reuse local variable for cmd_memdump 2025-01-17 23:27:43 +08:00
nsh_mntcmds.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_modcmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_netcmds.c apps: Fix unchecked strdup()/asprintf() as requested in #1727 2026-05-23 16:30:52 -04:00
nsh_parse.c nshlib: Add su, id, and whoami identity commands 2026-06-20 15:38:45 -03:00
nsh_passwdcmds.c !nshlib: Remove fixed login; require FSUTILS_PASSWD 2026-07-22 17:21:22 +08:00
nsh_printf.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_proccmds.c nshlib: top: add Linux-like summary and flicker-free refresh 2026-07-12 10:00:40 +08:00
nsh_prompt.c nshlib: Add su, id, and whoami identity commands 2026-06-20 15:38:45 -03:00
nsh_routecmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_script.c apps: Replace O_RDOK with O_RDONLY after alias removal 2026-06-28 13:00:52 +02:00
nsh_session.c readline: Make prompt-caching available 2026-07-24 14:12:38 -03:00
nsh_syscmds.c nsh_syscmds/rpmsg: add rpmsg test command support 2026-01-08 22:50:11 +08:00
nsh_system.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_telnetd.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_telnetlogin.c !nshlib: Remove fixed login; require FSUTILS_PASSWD 2026-07-22 17:21:22 +08:00
nsh_test.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_timcmds.c !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
nsh_usbconsole.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_usbtrace.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_vars.c fix: V-001 security vulnerability 2026-07-10 13:01:42 +08:00
nsh_wait.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
rc.sysinit.template nsh/script: support rc.sysinit script 2022-04-21 12:54:24 +03:00
rcS.template nsh/script: support rc.sysinit script 2022-04-21 12:54:24 +03:00