hostfs: mask bit fields of not support

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
wanggang26 2023-09-22 21:20:39 +08:00 committed by Masayuki Ishikawa
parent 52096aeb80
commit 7f5e6bd383
3 changed files with 9 additions and 3 deletions

View File

@ -76,6 +76,8 @@ static ssize_t host_flen(long fd)
static int host_flags_to_mode(int flags)
{
static const int modemasks = O_RDONLY | O_WRONLY | O_TEXT | O_RDWR |
O_CREAT | O_TRUNC | O_APPEND;
static const int modeflags[] =
{
O_RDONLY | O_TEXT,
@ -96,7 +98,7 @@ static int host_flags_to_mode(int flags)
int i;
for (i = 0; modeflags[i] != 0; i++)
{
if (modeflags[i] == flags)
if ((modemasks & flags) == modeflags[i])
{
return i;
}

View File

@ -76,6 +76,8 @@ static ssize_t host_flen(long fd)
static int host_flags_to_mode(int flags)
{
static const int modemasks = O_RDONLY | O_WRONLY | O_TEXT | O_RDWR |
O_CREAT | O_TRUNC | O_APPEND;
static const int modeflags[] =
{
O_RDONLY | O_TEXT,
@ -96,7 +98,7 @@ static int host_flags_to_mode(int flags)
int i;
for (i = 0; modeflags[i] != 0; i++)
{
if (modeflags[i] == flags)
if ((modemasks & flags) == modeflags[i])
{
return i;
}

View File

@ -76,6 +76,8 @@ static ssize_t host_flen(long fd)
static int host_flags_to_mode(int flags)
{
static const int modemasks = O_RDONLY | O_WRONLY | O_TEXT | O_RDWR |
O_CREAT | O_TRUNC | O_APPEND;
static const int modeflags[] =
{
O_RDONLY | O_TEXT,
@ -96,7 +98,7 @@ static int host_flags_to_mode(int flags)
int i;
for (i = 0; modeflags[i] != 0; i++)
{
if (modeflags[i] == flags)
if ((modemasks & flags) == modeflags[i])
{
return i;
}