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:
parent
3a0e713f2e
commit
5e3c1985e7
1 changed files with 10 additions and 1 deletions
|
@ -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' :
|
||||
|
|
Loading…
Reference in a new issue