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 <mishra.abhishek2808@gmail.com>
This commit is contained in:
Abhishek Mishra 2026-06-06 16:47:24 +00:00 committed by Alan C. Assis
parent d7f168061b
commit ce01327a45

View file

@ -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();