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:
parent
c7c91488d1
commit
37730a1fce
|
@ -159,11 +159,16 @@ 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)
|
||||||
filep->f_oflags |= oflags;
|
{
|
||||||
ret = OK;
|
oflags &= (FFCNTL & ~O_NONBLOCK);
|
||||||
|
filep->f_oflags &= ~(FFCNTL & ~O_NONBLOCK);
|
||||||
|
filep->f_oflags |= oflags;
|
||||||
|
ret = OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue