[LTP] [PATCH] syscalls/copy_file_range02.c: Compatible with new and old kernels
Cyril Hrubis
chrubis@suse.cz
Fri May 31 14:26:30 CEST 2019
Hi!
> I have no objection on this. But, is there really make sense to test some
> more non regular files which not being mentioned by Linux Manual Page?
>
> The copy_file_range02 test errors are all extract from manual page, I
> commented that in Christian's first patch version. And I don't think it's
> necessary to test undefined behavior in syscall using, because how do we
> know what error return is the expected?
That's not undefined that's undocummented at best. The kernel code for
vfs_copy_file_range does:
if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
return -EISDIR;
if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
return -EINVAL;
Which means that directories are treated as special here and all other file
descriptors that are not regular files are supposed to fail with EINVAL.
So as far as I can tell it makes sense to pass a pipe fd for example and check
for EINVAL. And we should do that both for in_fd and out_fd as well.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list