Skip to content

nshlib: Pass the generic mount options as mount flags. - #3865

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

acassis merged 1 commit into
apache:masterfrom
casaroli:nsh-mount-flags

Conversation

@casaroli

@casaroli casaroli commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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.

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, noatime and atime. A later option wins (ro,rw gives 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 -o with 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: after mount -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 -o runs.

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 -g passes.

Comment thread nshlib/nsh_mntcmds.c Resolved
Comment thread nshlib/nsh_mntcmds.c Resolved
Comment thread nshlib/nsh_mntcmds.c Resolved
Comment thread nshlib/nsh_mntcmds.c Resolved
"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]>
@acassis
acassis merged commit 71dfd54 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