From patchwork Wed Jan 22 20:03:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 37469 Received: (qmail 101199 invoked by alias); 22 Jan 2020 20:03:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 101191 invoked by uid 89); 22 Jan 2020 20:03:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2500 X-HELO: us-smtp-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579723416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7mM09eG+CDZxkVXMMXxYJUvNOXLZ0bqMj2NfG0K63co=; b=P91ncpGR6m4RN4OpmTscJCRgerZ7Et+lJQf1ZxLKjeRR0eRleURpQklIAuFH1tWE0gA/Eh yvtM8egX0cmI1ptMLXtHMVy7nu7tHMyLdByxwKCrqDQIlRU3ZYPdpOJl3bfJ3cMRHHEEBi jH+YMiVSNB3EkzNnUSnOnjvfTLF36Qs= From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 2/5] io: Implement lchmod using fchmodat [BZ #14578] In-Reply-To: References: Message-Id: <4a98ad5dfb77ce47553e7a331cec3b6b5782ed1c.1579723048.git.fweimer@redhat.com> Date: Wed, 22 Jan 2020 21:03:25 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com --- include/sys/stat.h | 1 + io/fchmodat.c | 1 + io/lchmod.c | 10 ++++------ sysdeps/mach/hurd/fchmodat.c | 1 + sysdeps/unix/sysv/linux/fchmodat.c | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/sys/stat.h b/include/sys/stat.h index b82d452780..92284ca48b 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -9,6 +9,7 @@ extern int __lstat (const char *__file, struct stat *__buf); extern int __chmod (const char *__file, __mode_t __mode); libc_hidden_proto (__chmod) extern int __fchmod (int __fd, __mode_t __mode); +libc_hidden_proto (fchmodat) extern __mode_t __umask (__mode_t __mask); extern int __mkdir (const char *__path, __mode_t __mode); libc_hidden_proto (__mkdir) diff --git a/io/fchmodat.c b/io/fchmodat.c index 7f3a07aaa2..78895ac187 100644 --- a/io/fchmodat.c +++ b/io/fchmodat.c @@ -42,3 +42,4 @@ fchmodat (int fd, const char *file, mode_t mode, int flag) return -1; } stub_warning (fchmodat) +libc_hidden_def (fchmodat) diff --git a/io/lchmod.c b/io/lchmod.c index 90b33a49f9..8b788034ee 100644 --- a/io/lchmod.c +++ b/io/lchmod.c @@ -1,4 +1,4 @@ -/* lchmod -- Change the protections of a file or symbolic link. Stub version. +/* lchmod -- Change the protections of a file or symbolic link. Generic version. Copyright (C) 2002-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -17,15 +17,13 @@ . */ #include -#include +#include #include +#include /* Change the protections of FILE to MODE. */ int lchmod (const char *file, mode_t mode) { - __set_errno (ENOSYS); - return -1; + return fchmodat (AT_FDCWD, file, mode, AT_SYMLINK_NOFOLLOW); } - -stub_warning (lchmod) diff --git a/sysdeps/mach/hurd/fchmodat.c b/sysdeps/mach/hurd/fchmodat.c index cd227d5c83..d42f9520e9 100644 --- a/sysdeps/mach/hurd/fchmodat.c +++ b/sysdeps/mach/hurd/fchmodat.c @@ -37,3 +37,4 @@ fchmodat (int fd, const char *file, mode_t mode, int flag) return __hurd_fail (err); return 0; } +libc_hidden_def (fchmodat) diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c index 224439ffba..c41ebb290d 100644 --- a/sysdeps/unix/sysv/linux/fchmodat.c +++ b/sysdeps/unix/sysv/linux/fchmodat.c @@ -38,3 +38,4 @@ fchmodat (int fd, const char *file, mode_t mode, int flag) return INLINE_SYSCALL (fchmodat, 3, fd, file, mode); } +libc_hidden_def (fchmodat)