mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 06:39:01 +08:00
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:
+9
-4
@@ -159,11 +159,16 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
|
||||
|
||||
{
|
||||
int oflags = va_arg(ap, int);
|
||||
int nonblock = !!(oflags & O_NONBLOCK);
|
||||
|
||||
oflags &= FFCNTL;
|
||||
filep->f_oflags &= ~FFCNTL;
|
||||
filep->f_oflags |= oflags;
|
||||
ret = OK;
|
||||
ret = file_ioctl(filep, FIONBIO, &nonblock);
|
||||
if (ret == OK)
|
||||
{
|
||||
oflags &= (FFCNTL & ~O_NONBLOCK);
|
||||
filep->f_oflags &= ~(FFCNTL & ~O_NONBLOCK);
|
||||
filep->f_oflags |= oflags;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+4
-4
@@ -83,14 +83,14 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap)
|
||||
FAR int *nonblock = (FAR int *)(uintptr_t)arg;
|
||||
if (nonblock && *nonblock)
|
||||
{
|
||||
ret = file_fcntl(filep, F_SETFL,
|
||||
file_fcntl(filep, F_GETFL) | O_NONBLOCK);
|
||||
filep->f_oflags |= O_NONBLOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = file_fcntl(filep, F_SETFL,
|
||||
file_fcntl(filep, F_GETFL) & ~O_NONBLOCK);
|
||||
filep->f_oflags &= ~O_NONBLOCK;
|
||||
}
|
||||
|
||||
ret = OK;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user