(vfs_clone_file): clarify errno in case of bad file descriptors.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2018-08-11 20:55:10 +03:00
parent 0493a5e90e
commit 23a2056a18

View File

@ -675,18 +675,28 @@ vfs_clone_file (int dest_vfs_fd, int src_vfs_fd)
struct vfs_class *src_class; struct vfs_class *src_class;
dest_class = vfs_class_find_by_handle (dest_vfs_fd, &dest_fd); dest_class = vfs_class_find_by_handle (dest_vfs_fd, &dest_fd);
if (dest_fd == NULL || (dest_class->flags & VFSF_LOCAL) == 0) if ((dest_class->flags & VFSF_LOCAL) == 0)
{ {
errno = EOPNOTSUPP; errno = EOPNOTSUPP;
return (-1); return (-1);
} }
if (dest_fd == NULL)
{
errno = EBADF;
return (-1);
}
src_class = vfs_class_find_by_handle (src_vfs_fd, &src_fd); src_class = vfs_class_find_by_handle (src_vfs_fd, &src_fd);
if (src_fd == NULL || (src_class->flags & VFSF_LOCAL) == 0) if ((src_class->flags & VFSF_LOCAL) == 0)
{ {
errno = EOPNOTSUPP; errno = EOPNOTSUPP;
return (-1); return (-1);
} }
if (src_fd == NULL)
{
errno = EBADF;
return (-1);
}
return ioctl (*(int *) dest_fd, FICLONE, *(int *) src_fd); return ioctl (*(int *) dest_fd, FICLONE, *(int *) src_fd);
#else #else