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/08/31 15:35:08 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request, #6976: fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path

xiaoxiang781216 opened a new pull request, #6976:
URL: https://github.com/apache/incubator-nuttx/pull/6976

   ## Summary
   Avoid the FIONBIO/FIOCLEX/FIONCLEX handler in driver change the return value from OK to -NOTTY
   
   ## Impact
   
   ## Testing
   usrsock
   


-- 
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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #6976: fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #6976:
URL: https://github.com/apache/incubator-nuttx/pull/6976#issuecomment-1233653165

   > Does this depend on PR #6974 ?
   
   No, it's independent from PR #6974.


-- 
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


[GitHub] [incubator-nuttx] anchao merged pull request #6976: fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path

Posted by GitBox <gi...@apache.org>.
anchao merged PR #6976:
URL: https://github.com/apache/incubator-nuttx/pull/6976


-- 
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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6976: fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6976:
URL: https://github.com/apache/incubator-nuttx/pull/6976#discussion_r962144677


##########
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)

Review Comment:
   Can't since this will bypass FIOC_FILEPATH and BIOC_BLKSSZGET



-- 
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


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6976: fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6976:
URL: https://github.com/apache/incubator-nuttx/pull/6976#discussion_r961117930


##########
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:
   ```suggestion
           if (ret == -ENOTTY && !INODE_IS_MOUNTPT(inode))
   ```



##########
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)

Review Comment:
   Maybe just
   ```
   if (ret == -ENOTTY)
     {
       ret = OK;
     }
   ```
   before the `switch` and then check `if (ret == OK)` in case statements?



##########
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:
   ```suggestion
           if (ret == -ENOTTY && inode->u.i_ops != NULL &&
   ```



-- 
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


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6976: fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path

Posted by GitBox <gi...@apache.org>.
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