diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c index e38eef6e83..aaccd4ddce 100644 --- a/fs/vfs/fs_fcntl.c +++ b/fs/vfs/fs_fcntl.c @@ -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; diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index 689a69cd4c..796cbcff02 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -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;