Skip to content

nshlib: add chmod and chown builtins#3480

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Abhishekmishra2808:nsh-chmod-chown
May 19, 2026
Merged

nshlib: add chmod and chown builtins#3480
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Abhishekmishra2808:nsh-chmod-chown

Conversation

@Abhishekmishra2808
Copy link
Copy Markdown
Contributor

Summary

This PR adds chmod and chown builtins to NSH by exposing the existing libc/VFS permission and ownership interfaces through the shell. The implementation supports numeric octal permission modes for chmod and numeric ownership forms for chown, including uid, uid:gid, uid:, and :gid, matching the semantics already handled by the underlying NuttX chown() implementation.
Documentation will be added shortly on Nuttx Repo

Impact

This makes filesystem permission and ownership management directly accessible from NSH and exposes the existing libc/VFS ownership semantics in NuttX, improving usability/debugging without requiring custom test applications.

Testing

image

Comment thread nshlib/nsh_fscmds.c Outdated
@xiaoxiang781216
Copy link
Copy Markdown
Contributor

out of flash:

  Building NuttX...
lto-wrapper: warning: using serial compilation of 4 LTRANS jobs
lto-wrapper: note: see the '-flto' option documentation for more information
/tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /github/workspace/sources/nuttx/nuttx section `.data' will not fit in region `flash'
/tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: region `flash' overflowed by 504 bytes
/tools/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: warning: /github/workspace/sources/nuttx/nuttx has a LOAD segment with RWX permissions
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:226: nuttx] Error 1
make: *** [tools/Unix.mk:568: nuttx] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 397: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize lm3s6432-s2e/nsh
On branch master

Comment thread nshlib/Kconfig
Comment thread nshlib/Kconfig
Comment thread nshlib/nsh_command.c Outdated
Add minimal chmod/chown support to NSH using the
existing libc/VFS syscall interfaces.

Supported forms:

  - chmod <octal-mode> <path>
  - chown <uid>[:gid] <path>

The chown implementation supports the numeric
ownership forms already handled by the underlying
NuttX chown() implementation, including unchanged
uid/gid semantics via omitted fields.

Only numeric permission modes and numeric uid/gid
forms are supported in this initial implementation.

This adds interactive filesystem permission and
ownership management support to NSH and aligns the
shell more closely with standard POSIX environments.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
@Abhishekmishra2808
Copy link
Copy Markdown
Contributor Author

Abhishekmishra2808 commented May 16, 2026

@acassis @xiaoxiang781216 @JianyuWang0623, thanks for the review. Implemented your suggestions/fixes in the latest commit
CI also turned green :-)

@xiaoxiang781216 xiaoxiang781216 merged commit ecfc1b5 into apache:master May 19, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants