From: Adhemerval Zanella Date: Fri, 27 Jul 2018 13:07:14 +0000 (-0300) Subject: Fix Linux fcntl OFD locks on unsupported kernels X-Git-Tag: glibc-2.28~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c6da2f48769ca37b22088fe65bdcb4b0f319b80;p=thirdparty%2Fglibc.git Fix Linux fcntl OFD locks on unsupported kernels This patch make the OFD tests return unsupported if kernel does not support OFD locks (it was added on 3.15). Checked on a ia64-linux-gnu with Linux 3.14. * sysdeps/unix/sysv/linux/tst-ofdlocks.c: Return unsupported if kernel does not support OFD locks. * sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise. --- diff --git a/ChangeLog b/ChangeLog index 562ddc7a00d..50fc501865d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-07-27 Adhemerval Zanella + + * sysdeps/unix/sysv/linux/tst-ofdlocks.c: Return unsupported if + kernel does not support OFD locks. + * sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise. + 2018-07-27 Samuel Thibault * sysdeps/mach/hurd/Versions (libc): Make __access and diff --git a/sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c b/sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c index 03c4abfeffd..aaf65af0db4 100644 --- a/sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c +++ b/sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c @@ -62,7 +62,12 @@ do_test (void) .l_start = (off64_t)INT32_MAX + 1024, .l_len = 1024, }; - TEST_VERIFY_EXIT (fcntl (temp_fd, F_OFD_SETLKW, &lck64) == 0); + int ret = fcntl (temp_fd, F_OFD_SETLKW, &lck64); + if (ret == -1 && errno == EINVAL) + /* OFD locks are only available on Linux 3.15. */ + FAIL_UNSUPPORTED ("fcntl (F_OFD_SETLKW) not supported"); + + TEST_VERIFY_EXIT (ret == 0); /* Open file description locks placed through the same open file description (either by same file descriptor or a duplicated one created by fork, diff --git a/sysdeps/unix/sysv/linux/tst-ofdlocks.c b/sysdeps/unix/sysv/linux/tst-ofdlocks.c index bd345e9b649..a660bab6dd9 100644 --- a/sysdeps/unix/sysv/linux/tst-ofdlocks.c +++ b/sysdeps/unix/sysv/linux/tst-ofdlocks.c @@ -46,7 +46,12 @@ do_test (void) .l_start = (off64_t)INT32_MAX + 1024, .l_len = 1024, }; - TEST_VERIFY_EXIT (fcntl64 (temp_fd, F_OFD_SETLKW, &lck64) == 0); + int ret = fcntl64 (temp_fd, F_OFD_SETLKW, &lck64); + if (ret == -1 && errno == EINVAL) + /* OFD locks are only available on Linux 3.15. */ + FAIL_UNSUPPORTED ("fcntl (F_OFD_SETLKW) not supported"); + + TEST_VERIFY_EXIT (ret == 0); /* Open file description locks placed through the same open file description (either by same file descriptor or a duplicated one created by fork,