Skip to content

Commit

Permalink
hostfs:ioctl should return -ENOTTY when the instruction is incompatible
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
crafcat7 authored and xiaoxiang781216 committed Aug 18, 2024
1 parent 6e9a43c commit def05eb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions fs/hostfs/hostfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit def05eb

Please sign in to comment.