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:
parent
df0e9da1ba
commit
f1236da21c
@ -78,18 +78,18 @@ static int host_flags_to_mode(int flags)
|
|||||||
{
|
{
|
||||||
static const int modeflags[] =
|
static const int modeflags[] =
|
||||||
{
|
{
|
||||||
|
O_RDONLY | O_TEXT,
|
||||||
O_RDONLY,
|
O_RDONLY,
|
||||||
O_RDONLY | O_BINARY,
|
O_RDWR | O_TEXT,
|
||||||
O_RDWR,
|
O_RDWR,
|
||||||
O_RDWR | O_BINARY,
|
O_WRONLY | O_CREAT | O_TRUNC | O_TEXT,
|
||||||
O_WRONLY | O_CREAT | O_TRUNC,
|
O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
O_RDWR | O_CREAT | O_TRUNC | O_TEXT,
|
||||||
O_RDWR | O_CREAT | O_TRUNC,
|
O_RDWR | O_CREAT | O_TRUNC,
|
||||||
O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
|
O_WRONLY | O_CREAT | O_APPEND | O_TEXT,
|
||||||
O_WRONLY | O_CREAT | O_APPEND,
|
O_WRONLY | O_CREAT | O_APPEND,
|
||||||
O_WRONLY | O_CREAT | O_APPEND | O_BINARY,
|
O_RDWR | O_CREAT | O_APPEND | O_TEXT,
|
||||||
O_RDWR | O_CREAT | O_APPEND,
|
O_RDWR | O_CREAT | O_APPEND,
|
||||||
O_RDWR | O_CREAT | O_APPEND | O_BINARY,
|
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ static int hci_open(struct file *filep)
|
|||||||
hci_dev_t *dev = inode->i_private;
|
hci_dev_t *dev = inode->i_private;
|
||||||
int ret;
|
int ret;
|
||||||
ret = file_open(&dev->filep,
|
ret = file_open(&dev->filep,
|
||||||
CONFIG_AMEBA_HCI_DEV_NAME, O_RDWR | O_BINARY);
|
CONFIG_AMEBA_HCI_DEV_NAME, O_RDWR);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -78,18 +78,18 @@ static int host_flags_to_mode(int flags)
|
|||||||
{
|
{
|
||||||
static const int modeflags[] =
|
static const int modeflags[] =
|
||||||
{
|
{
|
||||||
|
O_RDONLY | O_TEXT,
|
||||||
O_RDONLY,
|
O_RDONLY,
|
||||||
O_RDONLY | O_BINARY,
|
O_RDWR | O_TEXT,
|
||||||
O_RDWR,
|
O_RDWR,
|
||||||
O_RDWR | O_BINARY,
|
O_WRONLY | O_CREAT | O_TRUNC | O_TEXT,
|
||||||
O_WRONLY | O_CREAT | O_TRUNC,
|
O_WRONLY | O_CREAT | O_TRUNC,
|
||||||
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
O_RDWR | O_CREAT | O_TRUNC | O_TEXT,
|
||||||
O_RDWR | O_CREAT | O_TRUNC,
|
O_RDWR | O_CREAT | O_TRUNC,
|
||||||
O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
|
O_WRONLY | O_CREAT | O_APPEND | O_TEXT,
|
||||||
O_WRONLY | O_CREAT | O_APPEND,
|
O_WRONLY | O_CREAT | O_APPEND,
|
||||||
O_WRONLY | O_CREAT | O_APPEND | O_BINARY,
|
O_RDWR | O_CREAT | O_APPEND | O_TEXT,
|
||||||
O_RDWR | O_CREAT | O_APPEND,
|
O_RDWR | O_CREAT | O_APPEND,
|
||||||
O_RDWR | O_CREAT | O_APPEND | O_BINARY,
|
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ FAR struct btuart_lowerhalf_s *btuart_shim_getdevice(FAR const char *path)
|
|||||||
|
|
||||||
s = &n->state;
|
s = &n->state;
|
||||||
|
|
||||||
ret = file_open(&s->f, path, O_RDWR | O_BINARY);
|
ret = file_open(&s->f, path, O_RDWR);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
kmm_free(n);
|
kmm_free(n);
|
||||||
|
@ -248,7 +248,7 @@ int bcmf_upload_file(FAR struct bcmf_sdio_dev_s *sbus, uint32_t address,
|
|||||||
|
|
||||||
/* Open the file in the detached state */
|
/* Open the file in the detached state */
|
||||||
|
|
||||||
ret = file_open(&finfo, path, O_RDONLY | O_BINARY);
|
ret = file_open(&finfo, path, O_RDONLY);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
wlerr("ERROR: Failed to open the FILE MTD file %s: %d\n", path, ret);
|
wlerr("ERROR: Failed to open the FILE MTD file %s: %d\n", path, ret);
|
||||||
|
@ -259,7 +259,7 @@ int bcmf_driver_download_clm(FAR struct bcmf_dev_s *priv)
|
|||||||
wlinfo("Download %d bytes\n", datalen);
|
wlinfo("Download %d bytes\n", datalen);
|
||||||
|
|
||||||
ret = file_open(&finfo, CONFIG_IEEE80211_BROADCOM_FWCLMNAME,
|
ret = file_open(&finfo, CONFIG_IEEE80211_BROADCOM_FWCLMNAME,
|
||||||
O_RDONLY | O_BINARY);
|
O_RDONLY);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
wlerr("ERROR: Failed to open the FILE MTD file\n", ret);
|
wlerr("ERROR: Failed to open the FILE MTD file\n", ret);
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#define O_NDELAY O_NONBLOCK /* Synonym for O_NONBLOCK */
|
#define O_NDELAY O_NONBLOCK /* Synonym for O_NONBLOCK */
|
||||||
#define O_SYNC (1 << 7) /* Synchronize output on write */
|
#define O_SYNC (1 << 7) /* Synchronize output on write */
|
||||||
#define O_DSYNC O_SYNC /* Equivalent to OSYNC in NuttX */
|
#define O_DSYNC O_SYNC /* Equivalent to OSYNC in NuttX */
|
||||||
#define O_BINARY (1 << 8) /* Open the file in binary (untranslated) mode. */
|
#define O_TEXT (1 << 8) /* Open the file in text (translated) mode. */
|
||||||
#define O_DIRECT (1 << 9) /* Avoid caching, write directly to hardware */
|
#define O_DIRECT (1 << 9) /* Avoid caching, write directly to hardware */
|
||||||
#define O_CLOEXEC (1 << 10) /* Close on execute */
|
#define O_CLOEXEC (1 << 10) /* Close on execute */
|
||||||
|
|
||||||
@ -58,7 +58,7 @@
|
|||||||
#define O_RSYNC 0 /* Synchronize input on read */
|
#define O_RSYNC 0 /* Synchronize input on read */
|
||||||
#define O_ACCMODE O_RDWR /* Mask for access mode */
|
#define O_ACCMODE O_RDWR /* Mask for access mode */
|
||||||
#define O_NOCTTY 0 /* Required by POSIX */
|
#define O_NOCTTY 0 /* Required by POSIX */
|
||||||
#define O_TEXT 0 /* Open the file in text (translated) mode. */
|
#define O_BINARY 0 /* Open the file in binary (untranslated) mode. */
|
||||||
|
|
||||||
/* This is the highest bit number used in the open flags bitset. Bits above
|
/* This is the highest bit number used in the open flags bitset. Bits above
|
||||||
* this bit number may be used within NuttX for other, internal purposes.
|
* this bit number may be used within NuttX for other, internal purposes.
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define EFD_NONBLOCK O_NONBLOCK
|
#define EFD_NONBLOCK O_NONBLOCK
|
||||||
#define EFD_SEMAPHORE O_BINARY
|
#define EFD_SEMAPHORE O_SYNC
|
||||||
#define EFD_CLOEXEC O_CLOEXEC
|
#define EFD_CLOEXEC O_CLOEXEC
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -174,10 +174,6 @@
|
|||||||
# define NOALLIGN 1
|
# define NOALLIGN 1
|
||||||
#endif /* DOS */
|
#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 */
|
#ifdef M_XENIX /* Stupid compiler can't handle arrays with */
|
||||||
# if BITS == 16 /* more than 65535 bytes - so we fake it */
|
# if BITS == 16 /* more than 65535 bytes - so we fake it */
|
||||||
# define MAXSEG_64K
|
# define MAXSEG_64K
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#define MODE_NONE 0 /* No access mode determined */
|
#define MODE_NONE 0 /* No access mode determined */
|
||||||
#define MODE_MASK (MODE_R | MODE_W | MODE_A)
|
#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
|
* Public Functions
|
||||||
@ -156,7 +156,7 @@ int lib_mode2oflags(FAR const char *mode)
|
|||||||
{
|
{
|
||||||
/* Open for read access */
|
/* Open for read access */
|
||||||
|
|
||||||
oflags = O_RDOK;
|
oflags = O_RDOK | O_TEXT;
|
||||||
state = MODE_R;
|
state = MODE_R;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -172,7 +172,7 @@ int lib_mode2oflags(FAR const char *mode)
|
|||||||
{
|
{
|
||||||
/* Open for write access, truncating any existing file */
|
/* 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;
|
state = MODE_W;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -188,7 +188,7 @@ int lib_mode2oflags(FAR const char *mode)
|
|||||||
{
|
{
|
||||||
/* Write to the end of the file */
|
/* 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;
|
state = MODE_A;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -224,7 +224,7 @@ int lib_mode2oflags(FAR const char *mode)
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
oflags |= (O_RDWR | O_CREAT | O_TRUNC);
|
oflags |= O_RDWR | O_CREAT | O_TRUNC;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ int lib_mode2oflags(FAR const char *mode)
|
|||||||
* end,
|
* end,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
oflags |= (O_RDWR | O_CREAT | O_APPEND);
|
oflags |= O_RDWR | O_CREAT | O_APPEND;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ int lib_mode2oflags(FAR const char *mode)
|
|||||||
{
|
{
|
||||||
/* The file is opened in binary mode */
|
/* The file is opened in binary mode */
|
||||||
|
|
||||||
oflags |= O_BINARY;
|
oflags &= ~O_TEXT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ void lib_stdoutstream(FAR struct lib_stdoutstream_s *outstream,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
|
#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;
|
outstream->public.flush = stdoutstream_flush;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ void lib_stdsostream(FAR struct lib_stdsostream_s *outstream,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
|
#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;
|
outstream->public.flush = stdsostream_flush;
|
||||||
}
|
}
|
||||||
|
@ -625,7 +625,7 @@ static int tzload(FAR const char *name,
|
|||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
fid = _NX_OPEN(name, O_RDONLY | O_BINARY);
|
fid = _NX_OPEN(name, O_RDONLY);
|
||||||
if (fid < 0)
|
if (fid < 0)
|
||||||
{
|
{
|
||||||
goto oops;
|
goto oops;
|
||||||
|
Loading…
Reference in New Issue
Block a user