This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new ae7fe05  fs: Save umask to tls_task_s for non kernel mode only
ae7fe05 is described below

commit ae7fe055fc491f48ae4f24aa9168021ce8048ec0
Author: Xiang Xiao <[email protected]>
AuthorDate: Sat Jul 31 22:08:58 2021 +0800

    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 <[email protected]>
---
 include/nuttx/tls.h        |  2 +-
 libs/libc/misc/lib_umask.c | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/include/nuttx/tls.h b/include/nuttx/tls.h
index 5e655f7..0b342fa 100644
--- a/include/nuttx/tls.h
+++ b/include/nuttx/tls.h
@@ -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
 };
 
diff --git a/libs/libc/misc/lib_umask.c b/libs/libc/misc/lib_umask.c
index 995046c..aa8cb03 100644
--- a/libs/libc/misc/lib_umask.c
+++ b/libs/libc/misc/lib_umask.c
@@ -26,6 +26,14 @@
 #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
 }

Reply via email to