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/03/16 11:12:21 UTC

[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3070: fs/mmap: Return EACCES for incompatible file descriptors

gustavonihei commented on a change in pull request #3070:
URL: https://github.com/apache/incubator-nuttx/pull/3070#discussion_r595071043



##########
File path: fs/mmap/fs_mmap.c
##########
@@ -142,6 +148,30 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
     }
 #endif
 
+  if (fs_getfilep(fd, &filep) < 0)

Review comment:
       `fs_getfilep` either returns **-EBADF** or **-EAGAIN**.
   According to the `mmap` specification, although EAGAIN is a possible return value, it is useful for indicating that a file is currently locked and the API user should try `mmap` again later.
   But, `fs_getfilep` returns **-EAGAIN** for a unrecoverable error scenario:
   
   ![image](https://user-images.githubusercontent.com/38959758/111299708-07f4ca00-862f-11eb-8765-3fe71e92c48d.png)
   
   So, I think it does not make sense to simply make `mmap` propagate the error from `fs_getfilep`. Instead, I chose to handle the error and raise a new one that fits to `mmap` API.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org