Просмотр исходного кода

riscv64: the large-file fcntl lock commands are the plain ones

fcntl (fd, F_SETLKW, &fl) returned EINVAL on riscv64 whenever the caller was
built with _FILE_OFFSET_BITS=64, which is what UCLIBC_HAS_LFS gives every
program by default.

bits/fcntl.h maps F_GETLK/F_SETLK/F_SETLKW onto the *64 variants in that mode
and defined those as 12/13/14. Those numbers are the 32-bit compatibility
commands: fs/fcntl.c handles them under "#if BITS_PER_LONG == 32" only, so on
a 64-bit kernel they fall through to the default case and come back as EINVAL.
The riscv64 header was copied from the 32-bit one, where 12/13/14 are right.
aarch64 and x86_64 alias them to 5/6/7, alpha to its own F_GETLK -- riscv64
was the odd one out.

Six tests failed on riscv64 with NPTL against 4.19.56 headers: tst-flock2 said
"first fcntl failed" outright, and tst-cancel7 said "pthread_cancel failed",
which was a consequence -- its thread dies on the same fcntl before the
cancellation, so pthread_cancel then reports ESRCH.

Verified under qemu-system-riscv64: tst-flock2, tst-cancel7, tst-cancelx7 and
their -O2 twins pass.

riscv32 keeps its copy unchanged; there the 32-bit numbering is correct.

Signed-off-by: Ramin Moussavi <lordrasmus@gmail.com>
ramin 1 неделя назад
Родитель
Сommit
bd3d888960
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      libc/sysdeps/linux/riscv64/bits/fcntl.h

+ 5 - 3
libc/sysdeps/linux/riscv64/bits/fcntl.h

@@ -71,9 +71,11 @@
 # define F_SETLK	F_SETLK64  /* Set record locking info (non-blocking).*/
 # define F_SETLKW	F_SETLKW64 /* Set record locking info (blocking).  */
 #endif
-#define F_GETLK64	12	/* Get record locking info.  */
-#define F_SETLK64	13	/* Set record locking info (non-blocking).  */
-#define F_SETLKW64	14	/* Set record locking info (blocking).	*/
+/* 64-bit: the kernel implements 12/13/14 only for BITS_PER_LONG == 32
+   (fs/fcntl.c), so the large-file commands are the plain ones.  */
+#define F_GETLK64	5	/* Get record locking info.  */
+#define F_SETLK64	6	/* Set record locking info (non-blocking).  */
+#define F_SETLKW64	7	/* Set record locking info (blocking).	*/
 
 #if defined __USE_BSD || defined __USE_XOPEN2K
 # define F_SETOWN	8	/* Get owner of socket (receiver of SIGIO).  */