fs: should only apply umask to the userspace caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I608e3107aaf3d85045958163a742a1ef1107de91
This commit is contained in:
Xiang Xiao 2021-07-16 20:37:19 +08:00 committed by Masayuki Ishikawa
parent af1fd49fb0
commit a44f62ddf7
2 changed files with 9 additions and 9 deletions

View File

@ -159,7 +159,7 @@ errout:
} }
static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name, 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 inode *inode;
FAR struct mqueue_inode_s *msgq; 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 *); attr = va_arg(ap, FAR struct mq_attr *);
} }
mode &= ~getumask(); mode &= ~umask;
/* Skip over any leading '/'. All message queue paths are relative to /* Skip over any leading '/'. All message queue paths are relative to
* CONFIG_FS_MQUEUE_MPATH. * 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 created;
int ret; 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) if (ret < 0)
{ {
return ret; return ret;
@ -430,7 +430,7 @@ int file_mq_open(FAR struct file *mq,
int ret; int ret;
va_start(ap, oflags); 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); va_end(ap);
return ret; return ret;

View File

@ -47,8 +47,8 @@
* Name: file_vopen * Name: file_vopen
****************************************************************************/ ****************************************************************************/
static int file_vopen(FAR struct file *filep, static int file_vopen(FAR struct file *filep, FAR const char *path,
FAR const char *path, int oflags, va_list ap) int oflags, mode_t umask, va_list ap)
{ {
struct inode_search_s desc; struct inode_search_s desc;
FAR struct inode *inode; FAR struct inode *inode;
@ -71,7 +71,7 @@ static int file_vopen(FAR struct file *filep,
mode = va_arg(ap, mode_t); mode = va_arg(ap, mode_t);
} }
mode &= ~getumask(); mode &= ~umask;
#endif #endif
/* Get an inode for this file */ /* 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 */ /* 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) if (ret < 0)
{ {
return ret; return ret;
@ -270,7 +270,7 @@ int file_open(FAR struct file *filep, FAR const char *path, int oflags, ...)
int ret; int ret;
va_start(ap, oflags); va_start(ap, oflags);
ret = file_vopen(filep, path, oflags, ap); ret = file_vopen(filep, path, oflags, 0, ap);
va_end(ap); va_end(ap);
return ret; return ret;