fs/mmap: Clarify MAP_PRIVATE dependency on CONFIG_FS_RAMMAP
This commit is contained in:
parent
4cde8dab5a
commit
00d9f81919
@ -112,7 +112,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
|
|||||||
int fd, off_t offset)
|
int fd, off_t offset)
|
||||||
{
|
{
|
||||||
FAR void *addr;
|
FAR void *addr;
|
||||||
int ret = -1;
|
int ret;
|
||||||
|
|
||||||
/* Since only a tiny subset of mmap() functionality, we have to verify many
|
/* Since only a tiny subset of mmap() functionality, we have to verify many
|
||||||
* things.
|
* things.
|
||||||
@ -132,6 +132,16 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
|
|||||||
goto errout;
|
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. */
|
/* A length of 0 is invalid. */
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
@ -140,7 +150,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
|
|||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_DEBUG_FEATURES */
|
||||||
|
|
||||||
/* Check if we are just be asked to allocate memory, i.e., MAP_ANONYMOUS
|
/* 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
|
* 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;
|
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'
|
/* Perform the ioctl to get the base address of the file in 'mapped'
|
||||||
* in memory. (casting to uintptr_t first eliminates complaints on some
|
* in memory. (casting to uintptr_t first eliminates complaints on some
|
||||||
* architectures where the sizeof long is different from the size of
|
* architectures where the sizeof long is different from the size of
|
||||||
* a pointer).
|
* 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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* Not directly mappable, probably because the underlying media does
|
/* Not directly mappable, probably because the underlying media does
|
||||||
|
Loading…
x
Reference in New Issue
Block a user