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 2021/07/12 03:42:57 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

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


   ## Summary
   
   ## Impact
   
   ## Testing
   
   


-- 
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] davids5 commented on a change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
davids5 commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668732778



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       @gustavonihei I think I would agree with @xiaoxiang781216 that the ENOSYS is appropriate here. Do you have a better solution in mind?




-- 
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] patacongo commented on a change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668835377



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       > But one thing that was bugging me was that `-ENOSYS` is intended for **optional** features that are not implemented, which is not the the case for `stat`.
   
   Then perhaps you might consider -ENOTSUP.  “Not supported.” A function returns this error when certain parameter values are valid, but the functionality they request is not available. This can mean that the function does not implement a particular command or option value or flag bit at all.




-- 
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] gustavonihei commented on a change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668207133



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       According to the standard, `stat` should not return `ENOSYS` as an error code:
   https://pubs.opengroup.org/onlinepubs/007904875/functions/stat.html
   
   What's the purpose for returning `ENOSYS` here?




-- 
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 change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668408982



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       If the file system doesn't provide stat implementation, it is wrong to return OK but with the bad/unitial value in the stat buf. How to interpret the error code not mention in standard? I think the error code is the implementation detail, OS can return other suitable error code, unless the standared specially note the error case and code(e.g. EAGAIN, EINTR...).




-- 
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] gustavonihei commented on a change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668823474



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       > from https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html:
   > 
   > Implementations may support additional errors not included in this list, may generate errors included in this list under circumstances other than those described here, or may contain extensions or limitations that prevent some errors from occurring.
   
   Yeah, I checked that list. But one thing that was bugging me was that  `-ENOSYS` is intended for **optional** features that are not implemented, which is not the the case for `stat`.
   
   > All FS should implement it, but this check ensure if implementer forget it, the user(even the implementer self) can catch it immediately, instead wasting the time to the unnecessary debug.
   
   I completely agree with the motivation. The point that I am not so sure is whether we shouldn't really enforce the implementation by the FS via assertions.
   
   But okay, I'll merge it. `-ENOSYS` is already being returned in several functions for similar reasons.




-- 
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] gustavonihei merged pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
gustavonihei merged pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121


   


-- 
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 change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668804207



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       > > How to interpret the error code not mention in standard?
   > 
   > The application is not expecting to receive `-ENOSYS`, since this is non-compliant to the standard.
   > 
   
   from https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html:
   
   Implementations may support additional errors not included in this list, may generate errors included in this list under circumstances other than those described here, or may contain extensions or limitations that prevent some errors from occurring.
   
   It's valid to return the additional error code. Actually, I don't believe anyone write the code to only hande the error value mentioned by the standard, it's totally unportable.
   
   > > @gustavonihei I think I would agree with @xiaoxiang781216 that the ENOSYS is appropriate here. Do you have a better solution in mind?
   > 
   > I'd like to understand what is the error scenario that the `-ENOSYS` value may be useful:
   > 
   > 1. Is it when `stat` should be implemented by the FS implementation, but it is not?  (missing implementation)
   
   All FS should implement it, but this check ensure if implementer forget it, the user(even the implementer self) can catch it immediately, instead wasting the time to the unnecessary debug.
   
   > 2. Is it when the application erroneously calls `stat` for an invalid FS node? (usage error)
   > 
   
   This case is covered by the code before this point.
   
   > Please, correct me if I am understanding it wrong, but what I am worried about is that we may be trying to postpone to runtime the handling of a "static" error.
   
   




-- 
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] gustavonihei commented on a change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668741243



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       > How to interpret the error code not mention in standard?
   
   The application is not expecting to receive `-ENOSYS`, since this is non-compliant to the standard.
   
   > @gustavonihei I think I would agree with @xiaoxiang781216 that the ENOSYS is appropriate here. Do you have a better solution in mind?
   
   I'd like to understand what is the error scenario that the `-ENOSYS` value may be useful:
   1) Is it when `stat` should be implemented by the FS implementation, but it is not?  (missing implementation)
   2) Is it when the application erroneously calls `stat` for an invalid FS node? (usage error)
   
   Please, correct me if I am understanding it wrong, but what I am worried about is that we may be trying to postpone to runtime the handling of a "static" error.




-- 
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 change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668804207



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       from https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html:
   
   Implementations may support additional errors not included in this list, may generate errors included in this list under circumstances other than those described here, or may contain extensions or limitations that prevent some errors from occurring.
   
   It's valid to return the additional error code. Actually, I don't believe anyone write the code to only hande the error value mentioned by the standard, it's totally unportable.




-- 
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 change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668804207



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       from https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html:
   ```
   Implementations may support additional errors not included in this list, may generate errors included in this list under circumstances other than those described here, or may contain extensions or limitations that prevent some errors from occurring.
   ```
   It's valid to return the additional error code. Actually, I don't believe anyone write the code to only hande the error value mentioned by the standard, it's totally unportable.




-- 
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] patacongo commented on a change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
patacongo commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668835377



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       > But one thing that was bugging me was that `-ENOSYS` is intended for **optional** features that are not implemented, which is not the the case for `stat`.
   
   Then perhaps you might consider -ENOTSUP.  “Not supported.  A function returns this error when certain parameter values are valid, but the functionality they request is not available. This can mean that the function does not implement a particular command or option value or flag bit at all. ..."
   
   BUT:  "If the entire function is not available at all in the implementation,  it returns ENOSYS instead."
   




-- 
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] gustavonihei commented on a change in pull request #4121: vfs: stat_recursive should return -ENOSYS if stat callback is NULL

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #4121:
URL: https://github.com/apache/incubator-nuttx/pull/4121#discussion_r668741243



##########
File path: fs/vfs/fs_stat.c
##########
@@ -120,6 +120,10 @@ static int stat_recursive(FAR const char *path,
 
           ret = inode->u.i_mops->stat(inode, desc.relpath, buf);
         }
+      else
+        {
+          ret = -ENOSYS;

Review comment:
       > How to interpret the error code not mention in standard?
   
   The application is not expecting to receive `-ENOSYS`, since this is non-compliant to the standard.
   
   > @gustavonihei I think I would agree with @xiaoxiang781216 that the ENOSYS is appropriate here. Do you have a better solution in mind?
   
   I'd like to understand what is the error scenario that the `-ENOSYS` value may be useful:
   1) Is it when `stat` should be implemented by the FS implementation, but it is not?  (missing implementation)
   2) Is it when the application erroneously called `stat` for a invalid FS node? (usage error)
   
   Please, correct me if I am understanding it wrong, but what I am worried about is that we may be trying to postpone to runtime the handling of a "static" error.




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