libc/fopen: support fopen with mode 'm'

refs:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html
This is a fake implementation, in order for fopen to succeed,
Because the complete mmap mapping the entire file will waste a lot of
memory.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1 2023-08-21 21:49:05 +08:00 committed by Xiang Xiao
parent 3a0e713f2e
commit 5e3c1985e7

View file

@ -165,7 +165,7 @@ int lib_mode2oflags(FAR const char *mode)
{
switch (*mode)
{
/* Open for read access ("r{b|x|+}") */
/* Open for read access ("r{m|b|x|+}") */
case 'r' :
if (state == MODE_NONE)
@ -264,6 +264,15 @@ int lib_mode2oflags(FAR const char *mode)
}
break;
/* Attempt to access the file using mmap. */
case 'm' :
if (state != MODE_R)
{
goto errout;
}
break;
/* Open for binary access ("{r|w|a|x|+}b") */
case 'b' :