jlaitine commented on code in PR #8000:
URL: https://github.com/apache/nuttx/pull/8000#discussion_r1059331367
##########
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);
+ int (*munmap)(FAR struct task_group_s *group, FAR struct inode *inode,
Review Comment:
We've been using the mmap returned address and length as the identifier and
stored those, together with a reference to the inode in the group-specific list
of mappings. If there is really an inode-backed mapping, the inode is the
reference. It doesn't really then matter whether the fd is open or close when
it is being unmapped, the inode can be preserved with the reference counter it
already has.
In all normal cases there is no need to pass the "group" as an argument for
mmap or munmap; it is always the current group. The only reason why group is
passed in munmap is that during process exit, the current group is something
else. Doing actual MMU unmapping cannot be done in that case (an doesn't need
to be done, since the whole address environment is destroyed anyways), but
there may still be kernel-allocated resources (such as the inode), which need
to be freed. So what we have done is that we pass "NULL" as group at task
deletion and the current group when we enter munmap normally from "munmap" user
call.
Then the driver can do MMU mapping deletion for example by checking "if
(group) { }, or such.
We could also pass just some flag, e.g. "bool on_exit", or such, but were
thinking that passing the group is more generic.
If you have some clear vision on different interface, please give a
suggestion, these are easy to change.
--
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]