filelock:Move filelock call to ioctl

Forward the implementation originally placed in fcntl to ioctl. in order
to achieve cross-core.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1 2024-05-15 14:31:28 +08:00 committed by Xiang Xiao
parent a1e3444df0
commit d65f8bd4c1
3 changed files with 32 additions and 31 deletions

View file

@ -479,18 +479,8 @@ static int rpmsgfs_ioctl_handler(FAR struct rpmsg_endpoint *ept,
filep = rpmsgfs_get_file(priv, msg->fd);
if (filep != NULL)
{
unsigned long arg;
arg = msg->arglen > 0 ? (unsigned long)msg->buf : msg->arg;
switch (msg->request)
{
case FIOC_SETLK:
case FIOC_GETLK:
ret = file_fcntl(filep, msg->request, arg);
break;
default:
ret = file_ioctl(filep, msg->request, arg);
}
ret = file_ioctl(filep, msg->request, msg->arglen > 0 ?
(unsigned long)msg->buf : msg->arg);
}
msg->header.result = ret;

View file

@ -35,7 +35,6 @@
#include <nuttx/fs/fs.h>
#include "inode/inode.h"
#include "lock.h"
/****************************************************************************
* Private Functions
@ -197,12 +196,8 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
*/
{
FAR struct flock *flock = va_arg(ap, FAR struct flock *);
ret = file_ioctl(filep, FIOC_GETLK, flock);
if (ret < 0)
{
ret = file_getlk(filep, flock);
}
ret = file_ioctl(filep, FIOC_GETLK,
va_arg(ap, FAR struct flock *));
}
break;
@ -218,12 +213,8 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
*/
{
FAR struct flock *flock = va_arg(ap, FAR struct flock *);
ret = file_ioctl(filep, FIOC_SETLK, flock);
if (ret < 0)
{
ret = file_setlk(filep, flock, true);
}
ret = file_ioctl(filep, FIOC_SETLK,
va_arg(ap, FAR struct flock *));
}
break;
@ -238,12 +229,8 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
*/
{
FAR struct flock *flock = va_arg(ap, FAR struct flock *);
ret = file_ioctl(filep, FIOC_SETLKW, flock);
if (ret < 0)
{
ret = file_setlk(filep, flock, false);
}
ret = file_ioctl(filep, FIOC_SETLKW,
va_arg(ap, FAR struct flock *));
}
break;

View file

@ -31,6 +31,7 @@
#include <assert.h>
#include "inode/inode.h"
#include "lock.h"
/****************************************************************************
* Private Functions
@ -109,6 +110,29 @@ static int file_vioctl(FAR struct file *filep, int req, va_list ap)
}
break;
case FIOC_GETLK:
if (ret == -ENOTTY)
{
ret = file_getlk(filep, (FAR struct flock *)(uintptr_t)arg);
}
break;
case FIOC_SETLK:
if (ret == -ENOTTY)
{
ret = file_setlk(filep, (FAR struct flock *)(uintptr_t)arg,
true);
}
break;
case FIOC_SETLKW:
if (ret == -ENOTTY)
{
ret = file_setlk(filep, (FAR struct flock *)(uintptr_t)arg,
false);
}
break;
#ifdef CONFIG_FDSAN
case FIOC_SETTAG_FDSAN:
filep->f_tag_fdsan = *(FAR uint64_t *)arg;