mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 07:28:38 +08:00
fs: Move umask to task_info_s
and implement the related semantic correctly Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I0587341e2c505e41b5e24e55dba039ed200d65f2
This commit is contained in:
parent
0148e1d501
commit
a0f2f6c362
7 changed files with 36 additions and 16 deletions
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
@ -188,6 +189,8 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
|
|||
attr = va_arg(ap, FAR struct mq_attr *);
|
||||
}
|
||||
|
||||
mode &= ~getumask();
|
||||
|
||||
/* Skip over any leading '/'. All message queue paths are relative to
|
||||
* CONFIG_FS_MQUEUE_MPATH.
|
||||
*/
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -86,7 +87,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR sem_t *sem_open (FAR const char *name, int oflags, ...)
|
||||
FAR sem_t *sem_open(FAR const char *name, int oflags, ...)
|
||||
{
|
||||
FAR struct inode *inode;
|
||||
FAR struct nsem_inode_s *nsem;
|
||||
|
@ -174,7 +175,7 @@ FAR sem_t *sem_open (FAR const char *name, int oflags, ...)
|
|||
*/
|
||||
|
||||
va_start(ap, oflags);
|
||||
mode = va_arg(ap, mode_t);
|
||||
mode = va_arg(ap, mode_t) & ~getumask();
|
||||
value = va_arg(ap, unsigned);
|
||||
va_end(ap);
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ int mkdir(const char *pathname, mode_t mode)
|
|||
int errcode;
|
||||
int ret;
|
||||
|
||||
mode &= ~getumask();
|
||||
|
||||
/* Find the inode that includes this path */
|
||||
|
||||
SETUP_SEARCH(&desc, pathname, false);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdbool.h>
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
|
@ -69,6 +70,8 @@ static int file_vopen(FAR struct file *filep,
|
|||
{
|
||||
mode = va_arg(ap, mode_t);
|
||||
}
|
||||
|
||||
mode &= ~getumask();
|
||||
#endif
|
||||
|
||||
/* Get an inode for this file */
|
||||
|
|
|
@ -63,15 +63,14 @@
|
|||
|
||||
struct task_info_s
|
||||
{
|
||||
sem_t ta_sem;
|
||||
|
||||
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 */
|
||||
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() */
|
||||
struct getopt_s ta_getopt; /* Globals used by getopt() */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ int fchmod(int fd, mode_t mode);
|
|||
int futimens(int fd, const struct timespec times[2]);
|
||||
|
||||
mode_t umask(mode_t mask);
|
||||
mode_t getumask(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
@ -23,12 +23,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static mode_t g_mask;
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
@ -50,8 +45,24 @@ static mode_t g_mask;
|
|||
|
||||
mode_t umask(mode_t mask)
|
||||
{
|
||||
mode_t prev = g_mask;
|
||||
FAR struct task_info_s *info;
|
||||
mode_t prev;
|
||||
|
||||
info = task_get_info();
|
||||
prev = info->ta_umask;
|
||||
info->ta_umask = mask;
|
||||
|
||||
g_mask = mask & 0777;
|
||||
return prev;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: getumask
|
||||
****************************************************************************/
|
||||
|
||||
mode_t getumask(void)
|
||||
{
|
||||
FAR struct task_info_s *info;
|
||||
|
||||
info = task_get_info();
|
||||
return info->ta_umask;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue