mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +08:00
fs: Make the binary(no process) mode as the default
POSIX require file system shouldn't enable the \r and \n conversion by default Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
df0e9da1ba
commit
f1236da21c
@@ -174,10 +174,6 @@
|
||||
# define NOALLIGN 1
|
||||
#endif /* DOS */
|
||||
|
||||
#ifndef O_BINARY
|
||||
# define O_BINARY 0 /* System has no binary mode */
|
||||
#endif
|
||||
|
||||
#ifdef M_XENIX /* Stupid compiler can't handle arrays with */
|
||||
# if BITS == 16 /* more than 65535 bytes - so we fake it */
|
||||
# define MAXSEG_64K
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#define MODE_NONE 0 /* No access mode determined */
|
||||
#define MODE_MASK (MODE_R | MODE_W | MODE_A)
|
||||
|
||||
#define FLAG_KEEP (O_BINARY | O_CLOEXEC | O_EXCL)
|
||||
#define FLAG_KEEP (O_TEXT | O_CLOEXEC | O_EXCL)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@@ -156,7 +156,7 @@ int lib_mode2oflags(FAR const char *mode)
|
||||
{
|
||||
/* Open for read access */
|
||||
|
||||
oflags = O_RDOK;
|
||||
oflags = O_RDOK | O_TEXT;
|
||||
state = MODE_R;
|
||||
}
|
||||
else
|
||||
@@ -172,7 +172,7 @@ int lib_mode2oflags(FAR const char *mode)
|
||||
{
|
||||
/* Open for write access, truncating any existing file */
|
||||
|
||||
oflags = (O_WROK | O_CREAT | O_TRUNC);
|
||||
oflags = O_WROK | O_CREAT | O_TRUNC | O_TEXT;
|
||||
state = MODE_W;
|
||||
}
|
||||
else
|
||||
@@ -188,7 +188,7 @@ int lib_mode2oflags(FAR const char *mode)
|
||||
{
|
||||
/* Write to the end of the file */
|
||||
|
||||
oflags = O_WROK | O_CREAT | O_APPEND;
|
||||
oflags = O_WROK | O_CREAT | O_APPEND | O_TEXT;
|
||||
state = MODE_A;
|
||||
}
|
||||
else
|
||||
@@ -224,7 +224,7 @@ int lib_mode2oflags(FAR const char *mode)
|
||||
* file.
|
||||
*/
|
||||
|
||||
oflags |= (O_RDWR | O_CREAT | O_TRUNC);
|
||||
oflags |= O_RDWR | O_CREAT | O_TRUNC;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -238,7 +238,7 @@ int lib_mode2oflags(FAR const char *mode)
|
||||
* end,
|
||||
*/
|
||||
|
||||
oflags |= (O_RDWR | O_CREAT | O_APPEND);
|
||||
oflags |= O_RDWR | O_CREAT | O_APPEND;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -255,7 +255,7 @@ int lib_mode2oflags(FAR const char *mode)
|
||||
{
|
||||
/* The file is opened in binary mode */
|
||||
|
||||
oflags |= O_BINARY;
|
||||
oflags &= ~O_TEXT;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@ void lib_stdoutstream(FAR struct lib_stdoutstream_s *outstream,
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
|
||||
if (stream->fs_bufstart != NULL && (stream->fs_oflags & O_BINARY) == 0)
|
||||
if (stream->fs_bufstart != NULL && (stream->fs_oflags & O_TEXT) != 0)
|
||||
{
|
||||
outstream->public.flush = stdoutstream_flush;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ void lib_stdsostream(FAR struct lib_stdsostream_s *outstream,
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
|
||||
if (stream->fs_bufstart != NULL && (stream->fs_oflags & O_BINARY) == 0)
|
||||
if (stream->fs_bufstart != NULL && (stream->fs_oflags & O_TEXT) != 0)
|
||||
{
|
||||
outstream->public.flush = stdsostream_flush;
|
||||
}
|
||||
|
||||
@@ -625,7 +625,7 @@ static int tzload(FAR const char *name,
|
||||
goto oops;
|
||||
}
|
||||
|
||||
fid = _NX_OPEN(name, O_RDONLY | O_BINARY);
|
||||
fid = _NX_OPEN(name, O_RDONLY);
|
||||
if (fid < 0)
|
||||
{
|
||||
goto oops;
|
||||
|
||||
Reference in New Issue
Block a user