]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Linux: consolidate lchown implementation
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Wed, 19 Oct 2022 22:14:11 +0000 (19:14 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 7 Dec 2022 14:27:01 +0000 (11:27 -0300)
Use lchown syscall if defined, otherwise use fchownat.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
sysdeps/unix/sysv/linux/lchown.c [moved from sysdeps/unix/sysv/linux/generic/lchown.c with 75% similarity]

similarity index 75%
rename from sysdeps/unix/sysv/linux/generic/lchown.c
rename to sysdeps/unix/sysv/linux/lchown.c
index 996925d7992d9b0508c0b292ed9fa2c551b8a41a..4888e5f194c116f4bb90d530851f302772c38dff 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 2011-2022 Free Software Foundation, Inc.
+/* Change ownership of a file.  Linux version.
+   Copyright (C) 2011-2022 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
 int
 __lchown (const char *file, uid_t owner, gid_t group)
 {
-  return INLINE_SYSCALL (fchownat, 5, AT_FDCWD, file, owner, group,
-                         AT_SYMLINK_NOFOLLOW);
+#ifdef __NR_lchown
+  return INLINE_SYSCALL_CALL (lchown, file, owner, group);
+#else
+  return INLINE_SYSCALL_CALL (fchownat, AT_FDCWD, file, owner, group,
+                             AT_SYMLINK_NOFOLLOW);
+#endif
 }
 weak_alias (__lchown, lchown)