hostfs:ioctl should return -ENOTTY when the instruction is incompatible

When sending FIOC_XXXLK to hostfs, hostfs will return -1 by default. For ioctl statements, incompatible instructions should be processed as -ENOTTY by default

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1 2024-05-15 15:34:32 +08:00 committed by Xiang Xiao
parent 6e9a43c504
commit def05ebabb

View File

@ -604,14 +604,21 @@ static int hostfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
/* Call our internal routine to perform the ioctl */
ret = host_ioctl(hf->fd, cmd, arg);
if (ret < 0 && cmd == FIOC_FILEPATH)
if (ret < 0)
{
FAR char *path = (FAR char *)(uintptr_t)arg;
ret = inode_getpath(filep->f_inode, path, PATH_MAX);
if (ret >= 0)
switch (cmd)
{
strlcat(path, hf->relpath, PATH_MAX);
case FIOC_FILEPATH:
FAR char *path = (FAR char *)(uintptr_t)arg;
ret = inode_getpath(filep->f_inode, path, PATH_MAX);
if (ret >= 0)
{
strlcat(path, hf->relpath, PATH_MAX);
}
break;
default:
ret = -ENOTTY;
}
}