Skip to content

nshlib: Keep the execute permission of the source in cp. - #3866

Merged
acassis merged 1 commit into
apache:masterfrom
casaroli:nsh-cp-xbits
Oct 18, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
casaroli:nsh-cp-xbits

Conversation

@casaroli

@casaroli casaroli commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

cp created the new file with mode 0666. On a file system that keeps the mode, a copied program lost its execute permission.

This PR creates the new file with 0666 plus 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) with CONFIG_SCHED_USER_IDENTITY, CONFIG_FS_PERMISSION and tmpfs (which keeps the mode): cp of a program with mode 0755 gives -rwxrwxrwx; cp of a file with mode 0644 gives -rw-rw-rw-. (apps master creates every new file with 0666.)

tools/checkpatch.sh -c -u -m -g passes.

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]>
@acassis
acassis merged commit 1946ca0 into apache:master Oct 18, 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.

3 participants