xiaoxiang781216 commented on code in PR #8000:
URL: https://github.com/apache/nuttx/pull/8000#discussion_r1059356012
##########
include/nuttx/fs/fs.h:
##########
@@ -206,16 +207,21 @@ struct file_operations
* treated like unions.
*/
- int (*close)(FAR struct file *filep);
- ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t buflen);
- ssize_t (*write)(FAR struct file *filep, FAR const char *buffer,
- size_t buflen);
- off_t (*seek)(FAR struct file *filep, off_t offset, int whence);
- int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg);
+ int (*close)(FAR struct file *filep);
+ ssize_t (*read)(FAR struct file *filep, FAR char *buffer, size_t buflen);
+ ssize_t (*write)(FAR struct file *filep, FAR const char *buffer,
+ size_t buflen);
+ off_t (*seek)(FAR struct file *filep, off_t offset, int whence);
+ int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg);
+ int (*truncate)(FAR struct file *filep, off_t length);
+ FAR void *(*mmap)(FAR struct file *filep, off_t start, size_t length);
Review Comment:
> To the user side, it is in errno. Of course in this interface we can also
return differerent error numbers and pass the pointer in argument list. I was
thinking that there is no use for other return values and this approach was
simpler. Also user-side mmap only returns either address or MAP_FAILED.
>
but spec list the possible errno when when mmap return MAP_FAILD:
https://man7.org/linux/man-pages/man2/mmap.2.html
> Would you prefer an int type return and pointer in arguments list?
Yes, since only driver could know the real reason why mmap fail.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]