You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/09/03 11:51:10 UTC
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6976: fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path
xiaoxiang781216 commented on code in PR #6976:
URL: https://github.com/apache/incubator-nuttx/pull/6976#discussion_r962144412
##########
fs/vfs/fs_ioctl.c:
##########
@@ -67,53 +67,52 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap)
ret = inode->u.i_ops->ioctl(filep, req, arg);
}
- /* Check for File system IOCTL commands that can be implemented via
- * fcntl()
- */
-
- if (ret != -ENOTTY)
- {
- return ret;
- }
-
switch (req)
{
case FIONBIO:
- {
- FAR int *nonblock = (FAR int *)(uintptr_t)arg;
- if (nonblock && *nonblock)
- {
- filep->f_oflags |= O_NONBLOCK;
- }
- else
- {
- filep->f_oflags &= ~O_NONBLOCK;
- }
-
- ret = OK;
- }
+ if (ret == OK || ret == -ENOTTY)
+ {
+ FAR int *nonblock = (FAR int *)(uintptr_t)arg;
+ if (nonblock && *nonblock)
+ {
+ filep->f_oflags |= O_NONBLOCK;
+ }
+ else
+ {
+ filep->f_oflags &= ~O_NONBLOCK;
+ }
+
+ ret = OK;
+ }
break;
case FIOCLEX:
- filep->f_oflags |= O_CLOEXEC;
- ret = OK;
+ if (ret == OK || ret == -ENOTTY)
+ {
+ filep->f_oflags |= O_CLOEXEC;
+ ret = OK;
+ }
break;
case FIONCLEX:
- filep->f_oflags &= ~O_CLOEXEC;
- ret = OK;
+ if (ret == OK || ret == -ENOTTY)
+ {
+ filep->f_oflags &= ~O_CLOEXEC;
+ ret = OK;
+ }
break;
case FIOC_FILEPATH:
- if (!INODE_IS_MOUNTPT(inode))
+ if (ret == ENOTTY && !INODE_IS_MOUNTPT(inode))
{
ret = inode_getpath(inode, (FAR char *)(uintptr_t)arg);
}
break;
#ifndef CONFIG_DISABLE_MOUNTPOINT
case BIOC_BLKSSZGET:
- if (inode->u.i_ops != NULL && inode->u.i_ops->ioctl != NULL)
+ if (ret == ENOTTY && inode->u.i_ops != NULL &&
Review Comment:
Done.
##########
fs/vfs/fs_ioctl.c:
##########
@@ -67,53 +67,52 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap)
ret = inode->u.i_ops->ioctl(filep, req, arg);
}
- /* Check for File system IOCTL commands that can be implemented via
- * fcntl()
- */
-
- if (ret != -ENOTTY)
- {
- return ret;
- }
-
switch (req)
{
case FIONBIO:
- {
- FAR int *nonblock = (FAR int *)(uintptr_t)arg;
- if (nonblock && *nonblock)
- {
- filep->f_oflags |= O_NONBLOCK;
- }
- else
- {
- filep->f_oflags &= ~O_NONBLOCK;
- }
-
- ret = OK;
- }
+ if (ret == OK || ret == -ENOTTY)
+ {
+ FAR int *nonblock = (FAR int *)(uintptr_t)arg;
+ if (nonblock && *nonblock)
+ {
+ filep->f_oflags |= O_NONBLOCK;
+ }
+ else
+ {
+ filep->f_oflags &= ~O_NONBLOCK;
+ }
+
+ ret = OK;
+ }
break;
case FIOCLEX:
- filep->f_oflags |= O_CLOEXEC;
- ret = OK;
+ if (ret == OK || ret == -ENOTTY)
+ {
+ filep->f_oflags |= O_CLOEXEC;
+ ret = OK;
+ }
break;
case FIONCLEX:
- filep->f_oflags &= ~O_CLOEXEC;
- ret = OK;
+ if (ret == OK || ret == -ENOTTY)
+ {
+ filep->f_oflags &= ~O_CLOEXEC;
+ ret = OK;
+ }
break;
case FIOC_FILEPATH:
- if (!INODE_IS_MOUNTPT(inode))
+ if (ret == ENOTTY && !INODE_IS_MOUNTPT(inode))
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org