<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 17, 2018 at 4:53 PM, Jan Stancek <span dir="ltr"><<a href="mailto:jstancek@redhat.com" target="_blank">jstancek@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">OFD commands require 64-bit argument (struct flock64). Until<br>
glibc commit 06ab719d30b0 ("Fix Linux fcntl OFD locks for<br>
non-LFS architectures (BZ#20251)") we relied on glibc passing<br>
arg directly to syscall.<br>
<br>
This creates problem for 32-bit version of the test, because old<br>
glibc is passing arg directly, while new one is casting it to<br>
struct flock.<br>
<br>
We could add a configure check for glibc version, but that may<br>
not help with other libc libraries.<br>
<br>
We could do a runtime check that exploits non-zero l_pid returning<br>
EINVAL. This however complicates SAFE_FCNTL macro substantially.<br>
<br>
This patch changes 32-bit version of test to use syscall directly.<br>
<br>
Signed-off-by: Jan Stancek <<a href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>><br>
---<br>
 testcases/kernel/syscalls/<wbr>fcntl/fcntl34.c      | 10 ++++++--<br>
 testcases/kernel/syscalls/<wbr>fcntl/fcntl36.c      | 19 +++++++++++----<br>
 testcases/kernel/syscalls/<wbr>fcntl/fcntl_common.h | 33 ++++++++++++++++++++++++++<br>
 3 files changed, 56 insertions(+), 6 deletions(-)<br>
 create mode 100644 testcases/kernel/syscalls/<wbr>fcntl/fcntl_common.h<br>
<br>
diff --git a/testcases/kernel/syscalls/<wbr>fcntl/fcntl34.c b/testcases/kernel/syscalls/<wbr>fcntl/fcntl34.c<br>
index aa29cf9ea0d8..90c40f9cf4c6 100644<br>
--- a/testcases/kernel/syscalls/<wbr>fcntl/fcntl34.c<br>
+++ b/testcases/kernel/syscalls/<wbr>fcntl/fcntl34.c<br>
@@ -28,6 +28,7 @@<br>
 #include "lapi/fcntl.h"<br>
 #include "tst_safe_pthread.h"<br>
 #include "tst_test.h"<br>
+#include "fcntl_common.h"<br>
<br>
 static int thread_cnt;<br>
 static const int max_thread_cnt = 32;<br>
@@ -68,7 +69,12 @@ void *thread_fn_01(void *arg)<br>
<br>
        memset(buf, (intptr_t)arg, write_size);<br>
<br>
+/* see explanation in fcntl_common.h */<br>
+#ifdef USE_STRUCT_FLOCK64<br>
        struct flock64 lck = {<br>
+#else<br>
+       struct flock lck = {<br>
+#endif<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">It seems the 'struct flock64' can satisfy both 64-bit and 32-bit platform, why here adding 'struct flock' here? Eventually, as the code comment says: On 32-bit, ..., recent one treats it as 'struct flock' and converts it to 'struct flock64'. Why not use <span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">'struct flock64'<span>  directly?</span></span></div></div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div>
</div></div></div></div></div>