casaroli opened a new pull request, #21901: URL: https://github.com/apache/nuttx/pull/21901
## Summary The root directory of a tmpfs volume had the mode 0777. Everybody can make files in it, as in `/tmp`. A shared directory of this type has the sticky bit by convention. This PR makes the tmpfs root 01777, as Linux tmpfs does by default (mm/shmem.c: `ctx->mode = 0777 | S_ISVTX`). `stat()` of the root reports `S_ISVTX` (`drwxrwxrwt`), and `chmod()` of the root still works. The second commit adds one sentence to `Documentation/os/filesystem/tmpfs.rst`. ## Impact tmpfs keeps the mode of an object only with `CONFIG_FS_PERMISSION`. Without it, `stat()` reports 0777 for every directory as before, and nothing changes. The change is in tmpfs only: the same in flat, protected and kernel builds and on every architecture. No API change. NuttX does not enforce the sticky bit today: this change gives the tmpfs root the same default as Linux tmpfs and the shmfs directory (`fs/shm/shmfs.c` registers it with 01777). 66 board files mount tmpfs at `CONFIG_LIBC_TMPDIR` in C, so the default is the place to set it. ## Testing A test program mounts a tmpfs volume, checks `stat()` of the root and then `chmod()` of the root to 0755. qemu-armv8a:knsh (kernel build, arm64, HVF) with `CONFIG_FS_TMPFS` and `CONFIG_FS_PERMISSION`: on master the mode is 0777 (FAIL), with this PR 01777 (PASS); `chmod()` to 0755 works on both. ostest passes (status 0) on qemu-armv8a:knsh and on qemu-armv8a:nsh (flat build, with the same options). The protected build was not built: the change has no build-mode code. checkpatch passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
