From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id A1AF9388B69A; Wed, 7 Dec 2022 19:15:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1AF9388B69A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670440509; bh=srbVTu7Vw7jBsWUSYODWd5Moy03u7geI/xeIUJtrkJM=; h=From:To:Subject:Date:From; b=bdjsnmA8zxndD2t+gWGMcIxLlfl3PTK7pYfa2c/yo2oZ9IUU5C0Fb7DTBz/LQqIuP sDSd0+BHe3arWNOCRl/6QrEeXDxzGG9gT4/52rQlU4BXUY/n8GL9Ol9mWpSU4fdStX ulvYDK95fx6C3oIiP4hfbMSPAfqB9+1DXy6SiP3E= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] Linux: consolidate lchown implementation X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella Netto X-Git-Refname: refs/heads/master X-Git-Oldrev: 842128f160a48e5545900ea3bc3ba2ce40539d11 X-Git-Newrev: 25ca6175bacb40b9704458e53ddee58865d8ab2b Message-Id: <20221207191509.A1AF9388B69A@sourceware.org> Date: Wed, 7 Dec 2022 19:15:09 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=25ca6175bacb40b9704458e53ddee58865d8ab2b commit 25ca6175bacb40b9704458e53ddee58865d8ab2b Author: Adhemerval Zanella Netto Date: Wed Oct 19 19:14:11 2022 -0300 Linux: consolidate lchown implementation Use lchown syscall if defined, otherwise use fchownat. Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell Diff: --- sysdeps/unix/sysv/linux/{generic => }/lchown.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sysdeps/unix/sysv/linux/generic/lchown.c b/sysdeps/unix/sysv/linux/lchown.c similarity index 75% rename from sysdeps/unix/sysv/linux/generic/lchown.c rename to sysdeps/unix/sysv/linux/lchown.c index 996925d799..4888e5f194 100644 --- a/sysdeps/unix/sysv/linux/generic/lchown.c +++ b/sysdeps/unix/sysv/linux/lchown.c @@ -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 @@ -23,7 +24,11 @@ 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)