This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2ac41195b8dce246ab9163daa52a6b6a99069e9d Author: Marco Casaroli <[email protected]> AuthorDate: Fri Nov 13 22:43:52 2026 +0100 fs/tmpfs: Give the root directory the sticky bit (01777). The root 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. Make the root 01777, as Linux tmpfs does by default (mm/shmem.c: ctx->mode = 0777 | S_ISVTX). This is 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. stat() of the root now reports S_ISVTX, and chmod() of the root still works. tmpfs keeps the mode only with CONFIG_FS_PERMISSION: without it, nothing changes. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- fs/tmpfs/fs_tmpfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c index c8409f343bc..181c56b382e 100644 --- a/fs/tmpfs/fs_tmpfs.c +++ b/fs/tmpfs/fs_tmpfs.c @@ -2718,10 +2718,11 @@ static int tmpfs_bind(FAR struct inode *blkdriver, FAR const void *data, } /* Create a root file system. This is like a single directory entry in - * the file system structure. + * the file system structure. Everybody can make files in it, so it has + * the sticky bit (01777), as the shmfs directory. */ - tdo = tmpfs_alloc_directory(NULL, 0777); + tdo = tmpfs_alloc_directory(NULL, S_ISVTX | 0777); if (tdo == NULL) { fs_heap_free(fs);
