diff mbox series

[v3] io: Fix F_GETLK, F_SETLK, and F_SETLKW for powerpc64

Message ID 20230531125025.4047485-1-adhemerval.zanella@linaro.org
State New
Headers show
Series [v3] io: Fix F_GETLK, F_SETLK, and F_SETLKW for powerpc64 | expand

Commit Message

Adhemerval Zanella Netto May 31, 2023, 12:50 p.m. UTC
Different than other 64 bit architectures, powerpc64 defines the
LFS POSIX lock constants  with values similar to 32 ABI, which
are meant to be used with fcntl64 syscall.  Since powerpc64 kABI
does not have fcntl, the constants are adjusted with the
FCNTL_ADJUST_CMD macro.

The 4d0fe291aed3a476a changed the logic of generic constants
LFS value are equal to the default values; which is now wrong
for powerpc64.

Fix the value by explicit define the previous glibc constants
(powerpc64 does not need to use the 32 kABI value, but it simplifies
the FCNTL_ADJUST_CMD which should be kept as compatibility).

Checked on powerpc64-linux-gnu and powerpc-linux-gnu.
---
 sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Andreas Schwab May 31, 2023, 5:44 p.m. UTC | #1
On Mai 31 2023, Adhemerval Zanella wrote:

> Different than other 64 bit architectures, powerpc64 defines the
> LFS POSIX lock constants  with values similar to 32 ABI, which
> are meant to be used with fcntl64 syscall.  Since powerpc64 kABI
> does not have fcntl, the constants are adjusted with the
> FCNTL_ADJUST_CMD macro.
>
> The 4d0fe291aed3a476a changed the logic of generic constants
> LFS value are equal to the default values; which is now wrong
> for powerpc64.
>
> Fix the value by explicit define the previous glibc constants
> (powerpc64 does not need to use the 32 kABI value, but it simplifies
> the FCNTL_ADJUST_CMD which should be kept as compatibility).

Ok.
Carlos O'Donell June 1, 2023, 12:17 p.m. UTC | #2
On 5/31/23 08:50, Adhemerval Zanella via Libc-alpha wrote:
> Different than other 64 bit architectures, powerpc64 defines the
> LFS POSIX lock constants  with values similar to 32 ABI, which
> are meant to be used with fcntl64 syscall.  Since powerpc64 kABI
> does not have fcntl, the constants are adjusted with the
> FCNTL_ADJUST_CMD macro.
> 
> The 4d0fe291aed3a476a changed the logic of generic constants
> LFS value are equal to the default values; which is now wrong
> for powerpc64.
> 
> Fix the value by explicit define the previous glibc constants
> (powerpc64 does not need to use the 32 kABI value, but it simplifies
> the FCNTL_ADJUST_CMD which should be kept as compatibility).
> 
> Checked on powerpc64-linux-gnu and powerpc-linux-gnu.

Thanks for fixing this.

We just hit this in the Fedora Rawhide CI/CD for ppc64le:
https://kojipkgs.fedoraproject.org//work/tasks/9393/101689393/build.log
~~~
Adding ru_UA
Adding ru_UA.utf8
cannot lock new archive: Invalid argument
error: Bad exit status from /var/tmp/rpm-tmp.RkU0cx (%install)
    Bad exit status from /var/tmp/rpm-tmp.RkU0cx (%install)
~~~
Which is because lockf64() is not using the right constant.

I've asked Patsy to respin the Fedora CI/CD sync and try again.

> ---
>  sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h
> index 0905cd833c..f7615a447e 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h
> @@ -33,6 +33,12 @@
>  # define __O_LARGEFILE	0200000
>  #endif
>  
> +#if __WORDSIZE == 64
> +# define F_GETLK	5
> +# define F_SETLK	6
> +# define F_SETLKW	7
> +#endif
> +
>  struct flock
>    {
>      short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h
index 0905cd833c..f7615a447e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h
@@ -33,6 +33,12 @@ 
 # define __O_LARGEFILE	0200000
 #endif
 
+#if __WORDSIZE == 64
+# define F_GETLK	5
+# define F_SETLK	6
+# define F_SETLKW	7
+#endif
+
 struct flock
   {
     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/