<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 31, 2019 at 4:44 PM Jinhui huang <<a href="mailto:huangjh.jy@cn.fujitsu.com">huangjh.jy@cn.fujitsu.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On new kernels, copy_file_range() returned EISDIR when copyed contents<br>
to directory, but on old kernels, it returned EBADF, we should accept<br>
EBADF to be compatible with new and old kernels.<br>
<br>
The patch as follows:<br>
commit 11cbfb10775a ("vfs: deny copy_file_range() for non regular files")<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Patch makes sense.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>></div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Signed-off-by: Jinhui huang <<a href="mailto:huangjh.jy@cn.fujitsu.com" target="_blank">huangjh.jy@cn.fujitsu.com</a>><br>
---<br>
 .../syscalls/copy_file_range/copy_file_range02.c   | 33 +++++++++++++++-------<br>
 1 file changed, 23 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c<br>
index 07c0207..9e6356c 100644<br>
--- a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c<br>
+++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c<br>
@@ -54,19 +54,32 @@ static void verify_copy_file_range(unsigned int n)<br>
        TEST(sys_copy_file_range(fd_src, 0, *tc->copy_to_fd,<br>
                                0, CONTSIZE, tc->flags));<br>
<br>
-       if (TST_RET == -1) {<br>
-               if (tc->exp_err == TST_ERR) {<br>
+       if (TST_RET != -1) {<br>
+               tst_res(TFAIL,<br>
+                       "copy_file_range returned wrong value: %ld", TST_RET);<br>
+               return;<br>
+       }<br>
+<br>
+       if (tc->exp_err == TST_ERR) {<br>
+               tst_res(TPASS | TTERRNO,<br>
+                       "copy_file_range failed as expected");<br>
+       } else {<br>
+               /* copy_file_range() returned EISDIR when copyed contents to<br>
+                * directory on new kernels, but on old kernels, it returned<br>
+                * EBADF.<br>
+                *<br>
+                * the patch as follws:<br>
+                * commit 11cbfb10775a ("vfs: deny copy_file_range() for non regular files")<br>
+                */<br>
+               if (tc->exp_err == EISDIR && TST_ERR == EBADF) {<br>
                        tst_res(TPASS | TTERRNO,<br>
-                                       "copy_file_range failed as expected");<br>
-               } else {<br>
-                       tst_res(TFAIL | TTERRNO,<br>
-                               "copy_file_range failed unexpectedly; expected %s, but got",<br>
-                               tst_strerrno(tc->exp_err));<br>
+                               "copy_file_range failed as expected");<br>
                        return;<br>
                }<br>
-       } else {<br>
-               tst_res(TFAIL,<br>
-                       "copy_file_range returned wrong value: %ld", TST_RET);<br>
+<br>
+               tst_res(TFAIL | TTERRNO,<br>
+                       "copy_file_range failed unexpectedly; expected %s, but got",<br>
+                       tst_strerrno(tc->exp_err));<br>
        }<br>
 }<br>
<br>
-- <br>
1.8.3.1<br>
<br>
<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>