You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/03/16 03:03:00 UTC
[incubator-nuttx] branch master updated (4cde8da -> ecb9e03)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.
from 4cde8da boards/esp32-wrover-kit: Mount tmpfs on bring up
new 00d9f81 fs/mmap: Clarify MAP_PRIVATE dependency on CONFIG_FS_RAMMAP
new ecb9e03 fs/mmap: Update mmap documentation of possible return values
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
fs/mmap/fs_mmap.c | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
[incubator-nuttx] 01/02: fs/mmap: Clarify MAP_PRIVATE dependency on
CONFIG_FS_RAMMAP
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 00d9f8191954c7e6f90a6c5ba5e20f575b44fe70
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Mon Mar 15 16:35:30 2021 -0300
fs/mmap: Clarify MAP_PRIVATE dependency on CONFIG_FS_RAMMAP
---
fs/mmap/fs_mmap.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c
index 259a06f..e7f4f40 100644
--- a/fs/mmap/fs_mmap.c
+++ b/fs/mmap/fs_mmap.c
@@ -112,7 +112,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
int fd, off_t offset)
{
FAR void *addr;
- int ret = -1;
+ int ret;
/* Since only a tiny subset of mmap() functionality, we have to verify many
* things.
@@ -132,6 +132,16 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
goto errout;
}
+#ifndef CONFIG_FS_RAMMAP
+ if ((flags & MAP_PRIVATE) != 0)
+ {
+ ferr("ERROR: MAP_PRIVATE is not supported without file mapping"
+ "emulation\n");
+ ret = -ENOSYS;
+ goto errout;
+ }
+#endif /* CONFIG_FS_RAMMAP */
+
/* A length of 0 is invalid. */
if (length == 0)
@@ -140,7 +150,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
ret = -EINVAL;
goto errout;
}
-#endif
+#endif /* CONFIG_DEBUG_FEATURES */
/* Check if we are just be asked to allocate memory, i.e., MAP_ANONYMOUS
* set meaning that the memory is not backed up from a file. The file
@@ -169,17 +179,24 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
return alloc;
}
+ if ((flags & MAP_PRIVATE) != 0)
+ {
+#ifdef CONFIG_FS_RAMMAP
+ /* Allocate memory and copy the file into memory. We would, of course,
+ * do much better in the KERNEL build using the MMU.
+ */
+
+ return rammap(fd, length, offset);
+#endif
+ }
+
/* Perform the ioctl to get the base address of the file in 'mapped'
* in memory. (casting to uintptr_t first eliminates complaints on some
* architectures where the sizeof long is different from the size of
* a pointer).
*/
- if ((flags & MAP_PRIVATE) == 0)
- {
- ret = nx_ioctl(fd, FIOC_MMAP, (unsigned long)((uintptr_t)&addr));
- }
-
+ ret = nx_ioctl(fd, FIOC_MMAP, (unsigned long)((uintptr_t)&addr));
if (ret < 0)
{
/* Not directly mappable, probably because the underlying media does
[incubator-nuttx] 02/02: fs/mmap: Update mmap documentation of
possible return values
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit ecb9e03a7f2a6d1de8327b98495711318b526a53
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Mon Mar 15 17:26:34 2021 -0300
fs/mmap: Update mmap documentation of possible return values
---
fs/mmap/fs_mmap.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/mmap/fs_mmap.c b/fs/mmap/fs_mmap.c
index e7f4f40..ede0084 100644
--- a/fs/mmap/fs_mmap.c
+++ b/fs/mmap/fs_mmap.c
@@ -98,13 +98,15 @@
* ENOSYS
* Returned if any of the unsupported mmap() features are attempted
* EBADF
- * 'fd' is not a valid file descriptor.
+ * 'fd' is not a valid file descriptor.
* EINVAL
- * Length is 0. flags contained neither MAP_PRIVATE or MAP_SHARED, or
- * contained both of these values.
+ * Length is 0. flags contained neither MAP_PRIVATE or MAP_SHARED, or
+ * contained both of these values.
* ENODEV
- * The underlying filesystem of the specified file does not support
- * memory mapping.
+ * The underlying filesystem of the specified file does not support
+ * memory mapping.
+ * ENOMEM
+ * Insufficient memory is available to map the file.
*
****************************************************************************/