From patchwork Wed Oct 19 22:14:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 59102 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 672083857BB6 for ; Wed, 19 Oct 2022 22:18:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 672083857BB6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666217880; bh=eLXLMjIK8DsAGanH2FNH0SCS4eVC7hSznTdMLudL3GY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QLJXW/SduSetuSKCFaVQc5on9RsoMsflNiYERmbDUARu6SukHPise88gFZ4G91W7D NdcL7yN4ciX6K3ihsfPjrFKykUdvTmweuKcUU3ucuojeL7pZLkaRLIlS7e2sLAmIF+ TgLBTZAotV1hcVJtZEvRHZFTvVkftC/12cIlge/A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 021CE38582B8 for ; Wed, 19 Oct 2022 22:14:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 021CE38582B8 Received: by mail-oi1-x231.google.com with SMTP id u15so20879119oie.2 for ; Wed, 19 Oct 2022 15:14:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eLXLMjIK8DsAGanH2FNH0SCS4eVC7hSznTdMLudL3GY=; b=1Yzo3RmR77ItE7/DuqiFEL7N9mGWhskeZXEneP7266sQzHyz+BH86cN9y/O28Rli5h TiTQJnau1YuERwLtflRKNNGfTHAT4jtY2fJ8oiyIR2FW7cnpnRjE+LAbMAI0QNCPCjHs qP3UM/9HywlH+BpvAKtfB1Ry+DIIqfvoBaIfd4oFojQo/0HLEFaCpyT5i6cvYSr1vkGd ru9nx0I7VOOYOnaAxe7LJA8LLje9W1WqcgLrz8IXNPszn76sfMF8e4LHn/KFwWi2eLxe 0R050dY+18Jeg/U97WxhIridpvg1zFackuRMi8MH78RQfgj43zYtIEe8/JfJ5mb16a7I b71g== X-Gm-Message-State: ACrzQf16WOW8XXyVICz2+2GEwb4qbvjNGU0XeY5cJdrFEt8s30h6drlz +5+PeqKGwDZ5HJns77PqHQmoFDm4UCKdT2Rh X-Google-Smtp-Source: AMsMyM5tpcP4j0Xfy3mQAWkgtDwDHUCQ/cQFBncxa4TaIHj01nbn4WY/lJQ0AA0G6+pL6+lhY6NLjQ== X-Received: by 2002:a05:6808:2223:b0:354:d41e:5318 with SMTP id bd35-20020a056808222300b00354d41e5318mr5420162oib.80.1666217688355; Wed, 19 Oct 2022 15:14:48 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:7d19:f1c1:9fb4:472a:ab68]) by smtp.gmail.com with ESMTPSA id m9-20020aca5809000000b00353fe4fb4casm7137927oib.48.2022.10.19.15.14.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 15:14:48 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 08/30] Linux: consolidate lchown implementation Date: Wed, 19 Oct 2022 19:14:11 -0300 Message-Id: <20221019221433.1082017-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019221433.1082017-1-adhemerval.zanella@linaro.org> References: <20221019221433.1082017-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Use lchown syscall if defined, otherwise use fchownat. Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- sysdeps/unix/sysv/linux/{generic => }/lchown.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) rename sysdeps/unix/sysv/linux/{generic => }/lchown.c (75%) 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)