nuttx/fcntl:pass O_NONBLOCK flag to ioctl

1. fix pty fcntl F_SETFL(O_NONBLOCK) fail issue

Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
This commit is contained in:
fangzhenwei 2021-11-25 13:43:10 +08:00 committed by Xiang Xiao
parent c7c91488d1
commit 37730a1fce
2 changed files with 13 additions and 8 deletions

View File

@ -159,12 +159,17 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
{ {
int oflags = va_arg(ap, int); int oflags = va_arg(ap, int);
int nonblock = !!(oflags & O_NONBLOCK);
oflags &= FFCNTL; ret = file_ioctl(filep, FIONBIO, &nonblock);
filep->f_oflags &= ~FFCNTL; if (ret == OK)
{
oflags &= (FFCNTL & ~O_NONBLOCK);
filep->f_oflags &= ~(FFCNTL & ~O_NONBLOCK);
filep->f_oflags |= oflags; filep->f_oflags |= oflags;
ret = OK; ret = OK;
} }
}
break; break;
case F_GETOWN: case F_GETOWN:

View File

@ -83,14 +83,14 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap)
FAR int *nonblock = (FAR int *)(uintptr_t)arg; FAR int *nonblock = (FAR int *)(uintptr_t)arg;
if (nonblock && *nonblock) if (nonblock && *nonblock)
{ {
ret = file_fcntl(filep, F_SETFL, filep->f_oflags |= O_NONBLOCK;
file_fcntl(filep, F_GETFL) | O_NONBLOCK);
} }
else else
{ {
ret = file_fcntl(filep, F_SETFL, filep->f_oflags &= ~O_NONBLOCK;
file_fcntl(filep, F_GETFL) & ~O_NONBLOCK);
} }
ret = OK;
} }
break; break;