mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
shm: fix shm_open permission error
to pass PSE52 test suite Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
This commit is contained in:
parent
9ec50ceb0d
commit
9c381340c0
2 changed files with 12 additions and 1 deletions
|
|
@ -138,7 +138,7 @@ static int file_mmap_(FAR struct file *filep, FAR void *start,
|
|||
}
|
||||
|
||||
if ((flags & MAP_SHARED) &&
|
||||
(filep->f_oflags & O_WRONLY) == 0 && prot == PROT_WRITE)
|
||||
(filep->f_oflags & O_WRONLY) == 0 && (prot & PROT_WRITE))
|
||||
{
|
||||
ferr("ERROR: Unsupported options for read-only file descriptor,"
|
||||
"prot=%x flags=%04x\n", prot, flags);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "inode/inode.h"
|
||||
#include "vfs/vfs.h"
|
||||
|
|
@ -111,6 +112,16 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name,
|
|||
goto errout_with_sem;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
|
||||
if (((oflags & O_WRONLY) && !(inode->i_mode & S_IWUSR)) ||
|
||||
((oflags & O_RDONLY) && !(inode->i_mode & S_IRUSR))
|
||||
{
|
||||
ret = -EACCES;
|
||||
inode_release(inode);
|
||||
goto errout_with_sem;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the shared memory object already exists, truncate it to
|
||||
* zero bytes.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue