This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new ce01327a458 fs/vfs: inherit ownership in pseudofile_create
ce01327a458 is described below
commit ce01327a458c39803f791de6d37866c75c2f327d
Author: Abhishek Mishra <[email protected]>
AuthorDate: Sat Jun 6 16:47:24 2026 +0000
fs/vfs: inherit ownership in pseudofile_create
Initialize i_owner and i_group from the creating task's
effective uid/gid when a pseudo-file is created via O_CREAT.
This aligns pseudo-file ownership with the creator's
effective credentials instead of leaving new files
root-owned by default.
Signed-off-by: Abhishek Mishra <[email protected]>
---
fs/vfs/fs_pseudofile.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/fs/vfs/fs_pseudofile.c b/fs/vfs/fs_pseudofile.c
index 7b091bce740..e5376cfe97e 100644
--- a/fs/vfs/fs_pseudofile.c
+++ b/fs/vfs/fs_pseudofile.c
@@ -468,6 +468,10 @@ int pseudofile_create(FAR struct inode **node, FAR const
char *path,
mode_t mode)
{
FAR struct fs_pseudofile_s *pf;
+#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && \
+ defined(CONFIG_SCHED_USER_IDENTITY)
+ FAR struct tcb_s *rtcb;
+#endif
int ret;
if (node == NULL || path == NULL)
@@ -493,6 +497,18 @@ int pseudofile_create(FAR struct inode **node, FAR const
char *path,
(*node)->i_flags = 1;
(*node)->u.i_ops = &g_pseudofile_ops;
(*node)->i_private = pf;
+
+#if defined(CONFIG_PSEUDOFS_ATTRIBUTES) && \
+ defined(CONFIG_SCHED_USER_IDENTITY)
+
+ rtcb = nxsched_self();
+ if (rtcb != NULL && rtcb->group != NULL)
+ {
+ (*node)->i_owner = rtcb->group->tg_euid;
+ (*node)->i_group = rtcb->group->tg_egid;
+ }
+#endif
+
atomic_fetch_add(&(*node)->i_crefs, 1);
inode_unlock();