diff --git a/fs/inode/fs_inode.c b/fs/inode/fs_inode.c index 654b8f7a340..e89eb337489 100644 --- a/fs/inode/fs_inode.c +++ b/fs/inode/fs_inode.c @@ -275,7 +275,16 @@ int inode_checkopenperm(FAR struct inode *inode, int oflags) { FAR const struct file_operations *ops; - if (INODE_IS_PSEUDODIR(inode)) + if (INODE_IS_NAMEDSEM(inode)) + { +#ifdef CONFIG_FS_PERMISSION + return inode_checkperm(inode, R_OK | W_OK); +#else + return OK; +#endif + } + + if (INODE_IS_MQUEUE(inode) || INODE_IS_PSEUDODIR(inode)) { #ifdef CONFIG_FS_PERMISSION return inode_checkperm(inode, fs_open_amode(oflags)); diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c index 514f053997e..feeeea66761 100644 --- a/fs/mqueue/mq_open.c +++ b/fs/mqueue/mq_open.c @@ -262,6 +262,26 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name, goto errout_with_inode; } +#ifdef CONFIG_FS_PERMISSION + ret = inode_checkopenperm(inode, oflags); + if (ret < 0) + { + goto errout_with_inode; + } +#endif + + if (inode->i_private == NULL) + { + ret = nxmq_alloc_msgq(NULL, &msgq); + if (ret < 0) + { + goto errout_with_inode; + } + + inode->i_private = msgq; + msgq->inode = inode; + } + /* Associate the inode with a file structure */ mq->f_oflags = oflags; diff --git a/fs/semaphore/sem_open.c b/fs/semaphore/sem_open.c index 0fdac9dd2c9..e89e0de7461 100644 --- a/fs/semaphore/sem_open.c +++ b/fs/semaphore/sem_open.c @@ -138,6 +138,14 @@ int nxsem_open(FAR sem_t **sem, FAR const char *name, int oflags, ...) goto errout_with_inode; } +#ifdef CONFIG_FS_PERMISSION + ret = inode_checkopenperm(inode, O_RDWR); + if (ret < 0) + { + goto errout_with_inode; + } +#endif + /* Return a reference to the semaphore, retaining the reference * count on the inode. */ diff --git a/fs/shm/shm_open.c b/fs/shm/shm_open.c index dd609fc79c7..27279c39867 100644 --- a/fs/shm/shm_open.c +++ b/fs/shm/shm_open.c @@ -112,11 +112,10 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name, goto errout_with_sem; } -#ifdef CONFIG_PSEUDOFS_ATTRIBUTES - if (((oflags & O_ACCMODE) != O_RDONLY && !(inode->i_mode & S_IWUSR)) || - ((oflags & O_ACCMODE) != O_WRONLY && !(inode->i_mode & S_IRUSR))) +#ifdef CONFIG_FS_PERMISSION + ret = inode_checkopenperm(inode, oflags); + if (ret < 0) { - ret = -EACCES; inode_release(inode); goto errout_with_sem; }