vfs: Forward fcntl(F_SETFD...) to ioctl(FIOCLEX|FIONCLEX...)

this is follow change to:
commit 37730a1fce
Author: fangzhenwei <fangzhenwei@xiaomi.com>
Date:   Thu Nov 25 13:43:10 2021 +0800

    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>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-04 11:53:57 +08:00 committed by Petro Karashchenko
parent 66c61d4ac3
commit 19e796305a
3 changed files with 7 additions and 10 deletions

View File

@ -121,14 +121,12 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
if (oflags & FD_CLOEXEC)
{
filep->f_oflags |= O_CLOEXEC;
ret = file_ioctl(filep, FIOCLEX, NULL);
}
else
{
filep->f_oflags &= ~O_CLOEXEC;
ret = file_ioctl(filep, FIONCLEX, NULL);
}
ret = OK;
}
break;
@ -167,7 +165,6 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
oflags &= (FFCNTL & ~O_NONBLOCK);
filep->f_oflags &= ~(FFCNTL & ~O_NONBLOCK);
filep->f_oflags |= oflags;
ret = OK;
}
}
break;

View File

@ -95,13 +95,13 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap)
break;
case FIOCLEX:
ret = file_fcntl(filep, F_SETFD,
file_fcntl(filep, F_GETFD) | FD_CLOEXEC);
filep->f_oflags |= O_CLOEXEC;
ret = OK;
break;
case FIONCLEX:
ret = file_fcntl(filep, F_SETFD,
file_fcntl(filep, F_GETFD) & ~FD_CLOEXEC);
filep->f_oflags &= ~O_CLOEXEC;
ret = OK;
break;
case FIOC_FILEPATH:

View File

@ -103,7 +103,7 @@
#define F_WRLCK 1 /* Take out a write lease */
#define F_UNLCK 2 /* Remove a lease */
/* close-on-exec flag for F_GETRL and F_SETFL */
/* close-on-exec flag for F_GETFD and F_SETFD */
#define FD_CLOEXEC 1