Repository navigation
nshlib: Pass the generic mount options as mount flags. - #3865
Merged
Merged
Conversation
"mount -o" passed the whole option list to the file system as data, and the mount flags were always 0. So "mount -o ro" or "mount -o noexec" did not set MS_RDONLY or MS_NOEXEC. Take the generic options out of the list and pass them as mount flags: ro, rw, noexec, exec, nosuid, suid, nodev, dev, sync, async, noatime and atime. The other options go to the file system as before. If no option is left, the data is NULL, as without -o. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
casaroli
force-pushed
the
nsh-mount-flags
branch
from
October 18, 2026 12:30
f614118 to
19027d3
Compare
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
mount -opassed the whole option list to the file system as data, and the mount flags were always 0. Somount -o roormount -o noexecdid not setMS_RDONLYorMS_NOEXEC.This PR takes the generic options out of the list and passes them as mount flags:
ro,rw,noexec,exec,nosuid,suid,nodev,dev,sync,async,noatimeandatime. A later option wins (ro,rwgives no flag). The other options go to the file system as before, in the same order. If no option is left, the data is NULL, as without-o.The NSH command page is updated in apache/nuttx#20763.
Impact
Only commands that use
-owith a generic option change: the option now sets the flag instead of going to the file system.Testing
On
qemu-armv8a:knsh(QEMU 11 with HVF on an Apple M4), with apache/nuttx#20762: aftermount -t tmpfs -o noexec /nx3, a program copied there is listed without execute bits, and with the execute permission check it fails with "Permission denied". The same program on a tmpfs mount without-oruns.The option parsing compiled on the host with 14 cases: options before, between and after file system options (
noexec,trans=virtio,tag=system,trans=virtio,tag=system,ro), only generic options,ro,rw, empty items, names that only start like an option (noexecx), and names that are the start of an option (no,r).tools/checkpatch.sh -c -u -m -gpasses.