You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/07/17 04:59:06 UTC

[incubator-nuttx] branch master updated: fs: should only apply umask to the userspace caller

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

masayuki 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 a44f62d  fs: should only apply umask to the userspace caller
a44f62d is described below

commit a44f62ddf7e0f5c84aec6227edcd64fa3e885bd2
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Jul 16 20:37:19 2021 +0800

    fs: should only apply umask to the userspace caller
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I608e3107aaf3d85045958163a742a1ef1107de91
---
 fs/mqueue/mq_open.c |  8 ++++----
 fs/vfs/fs_open.c    | 10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c
index bd6feee..2e15780 100644
--- a/fs/mqueue/mq_open.c
+++ b/fs/mqueue/mq_open.c
@@ -159,7 +159,7 @@ errout:
 }
 
 static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
-                         int oflags, va_list ap, int *created)
+                         int oflags, mode_t umask, va_list ap, int *created)
 {
   FAR struct inode *inode;
   FAR struct mqueue_inode_s *msgq;
@@ -189,7 +189,7 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
       attr = va_arg(ap, FAR struct mq_attr *);
     }
 
-  mode &= ~getumask();
+  mode &= ~umask;
 
   /* Skip over any leading '/'.  All message queue paths are relative to
    * CONFIG_FS_MQUEUE_MPATH.
@@ -339,7 +339,7 @@ static mqd_t nxmq_vopen(FAR const char *mq_name, int oflags, va_list ap)
   int created;
   int ret;
 
-  ret = file_mq_vopen(&mq, mq_name, oflags, ap, &created);
+  ret = file_mq_vopen(&mq, mq_name, oflags, getumask(), ap, &created);
   if (ret < 0)
     {
       return ret;
@@ -430,7 +430,7 @@ int file_mq_open(FAR struct file *mq,
   int ret;
 
   va_start(ap, oflags);
-  ret = file_mq_vopen(mq, mq_name, oflags, ap, NULL);
+  ret = file_mq_vopen(mq, mq_name, oflags, 0, ap, NULL);
   va_end(ap);
 
   return ret;
diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c
index 201875e..b7fd56b 100644
--- a/fs/vfs/fs_open.c
+++ b/fs/vfs/fs_open.c
@@ -47,8 +47,8 @@
  * Name: file_vopen
  ****************************************************************************/
 
-static int file_vopen(FAR struct file *filep,
-                      FAR const char *path, int oflags, va_list ap)
+static int file_vopen(FAR struct file *filep, FAR const char *path,
+                      int oflags, mode_t umask, va_list ap)
 {
   struct inode_search_s desc;
   FAR struct inode *inode;
@@ -71,7 +71,7 @@ static int file_vopen(FAR struct file *filep,
       mode = va_arg(ap, mode_t);
     }
 
-  mode &= ~getumask();
+  mode &= ~umask;
 #endif
 
   /* Get an inode for this file */
@@ -199,7 +199,7 @@ static int nx_vopen(FAR const char *path, int oflags, va_list ap)
 
   /* Let file_vopen() do all of the work */
 
-  ret = file_vopen(&filep, path, oflags, ap);
+  ret = file_vopen(&filep, path, oflags, getumask(), ap);
   if (ret < 0)
     {
       return ret;
@@ -270,7 +270,7 @@ int file_open(FAR struct file *filep, FAR const char *path, int oflags, ...)
   int ret;
 
   va_start(ap, oflags);
-  ret = file_vopen(filep, path, oflags, ap);
+  ret = file_vopen(filep, path, oflags, 0, ap);
   va_end(ap);
 
   return ret;