fs: Save umask to tls_task_s for non kernel mode only

since the kernel mode has the dedicated userspace

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-07-31 22:08:58 +08:00 committed by Gustavo Henrique Nihei
parent 1d3594ba07
commit ae7fe055fc
2 changed files with 19 additions and 2 deletions

View File

@ -85,13 +85,13 @@ typedef CODE void (*tls_dtor_t)(FAR void *);
struct task_info_s
{
sem_t ta_sem;
mode_t ta_umask; /* File mode creation mask */
#if CONFIG_TLS_NELEM > 0
tls_ndxset_t ta_tlsset; /* Set of TLS indexes allocated */
tls_dtor_t ta_tlsdtor[CONFIG_TLS_NELEM]; /* List of TLS destructors */
#endif
#ifndef CONFIG_BUILD_KERNEL
struct getopt_s ta_getopt; /* Globals used by getopt() */
mode_t ta_umask; /* File mode creation mask */
#endif
};

View File

@ -25,6 +25,14 @@
#include <sys/stat.h>
#include <nuttx/tls.h>
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
static mode_t g_umask;
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -45,12 +53,17 @@
mode_t umask(mode_t mask)
{
FAR struct task_info_s *info;
mode_t prev;
#ifndef CONFIG_BUILD_KERNEL
FAR struct task_info_s *info;
info = task_get_info();
prev = info->ta_umask;
info->ta_umask = mask;
#else
prev = g_umask;
g_umask = mask;
#endif
return prev;
}
@ -61,8 +74,12 @@ mode_t umask(mode_t mask)
mode_t getumask(void)
{
#ifndef CONFIG_BUILD_KERNEL
FAR struct task_info_s *info;
info = task_get_info();
return info->ta_umask;
#else
return g_umask;
#endif
}