nshlib: add chmod and chown builtins#3480
Open
Abhishekmishra2808 wants to merge 1 commit into
Open
Conversation
This was referenced May 13, 2026
|
|
||
| UNUSED(argc); | ||
|
|
||
| colon = strchr(spec, ':'); |
Contributor
There was a problem hiding this comment.
why need, let's check endptr after strtol
Author
There was a problem hiding this comment.
Thanks, good optimization!!
Contributor
|
out of flash: |
acassis
reviewed
May 14, 2026
| #endif | ||
|
|
||
| #ifndef CONFIG_NSH_DISABLE_CHOWN | ||
| CMD_MAP("chown", cmd_chown, 3, 3, "<uid>[:gid] <path>"), |
Contributor
There was a problem hiding this comment.
The implementation also accepts the []: form (e.g. chown :5 /path, where the uid is left unchanged), but the usage string only documents [:gid]. Users who run help chown will not learn that the uid side may be omitted.
Suggested change to keep the help text consistent with what the parser actually accepts:
- CMD_MAP("chown", cmd_chown, 3, 3, "<uid>[:gid] <path>"),
+ CMD_MAP("chown", cmd_chown, 3, 3, "[<uid>][:<gid>] <path>"),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>
5541471 to
d23106d
Compare
Author
|
@acassis @xiaoxiang781216 @JianyuWang0623, thanks for the review. Implemented your suggestions/fixes in the latest commit |
acassis
approved these changes
May 17, 2026
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
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