Repository navigation
nshlib: Keep the execute permission of the source in cp. - #3866
Merged
Merged
Conversation
cp created the new file with mode 0666. On a file system that keeps the mode, a copied program lost its execute permission. Create the new file with 0666 plus the execute bits of the source. The mode of an existing destination file does not change. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
xiaoxiang781216
approved these changes
Oct 18, 2026
acassis
approved these changes
Oct 18, 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
cpcreated the new file with mode0666. On a file system that keeps the mode, a copied program lost its execute permission.This PR creates the new file with
0666plus the execute bits of the source. The mode of an existing destination file does not change. Only the execute bits are copied, so a copy of a read-only file is still writable, as before.The NSH command page is updated in apache/nuttx#20763.
Impact
A copy of a file with execute bits now has execute bits too.
Testing
On
qemu-armv8a:knsh(QEMU 11 with HVF on an Apple M4) withCONFIG_SCHED_USER_IDENTITY,CONFIG_FS_PERMISSIONand tmpfs (which keeps the mode):cpof a program with mode0755gives-rwxrwxrwx;cpof a file with mode0644gives-rw-rw-rw-. (apps master creates every new file with0666.)tools/checkpatch.sh -c -u -m -gpasses.