From patchwork Fri Oct 14 13:06:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 58725 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 E1A3A3853546 for ; Fri, 14 Oct 2022 13:06:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1A3A3853546 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665752795; bh=reqlyrRNrBXZlAhlBen3DGOkuxk9aGB+dKFGgk8wUlU=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=p+/8TS1UZNr2mQOBl6QIl2Qdk1+DfPDqCv3h4geuoR+IAHMINXnElXwxeQ0S/hmtX skbGP2y2+vStM6LXtYCoAdEy7EHfyw4m9JPpizFC8im64j6e3IJbx72pz/sE2E/40X 4entd1zSG161v2iC4v8f1afXk/YQ/ZoJzJZRgtBs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 972C038582B6 for ; Fri, 14 Oct 2022 13:06:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 972C038582B6 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-311-1Lg6VG50MHm7Z7nbY4JRyw-1; Fri, 14 Oct 2022 09:06:12 -0400 X-MC-Unique: 1Lg6VG50MHm7Z7nbY4JRyw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F4872932496 for ; Fri, 14 Oct 2022 13:06:11 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A5471401693 for ; Fri, 14 Oct 2022 13:06:11 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 1/2] support: Add the xfchdir function In-Reply-To: References: X-From-Line: 704d7df1ae00370c8c52ca20eeac77d64dd9da3b Mon Sep 17 00:00:00 2001 Message-Id: <704d7df1ae00370c8c52ca20eeac77d64dd9da3b.1665752531.git.fweimer@redhat.com> Date: Fri, 14 Oct 2022 15:06:10 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- support/Makefile | 1 + support/xfchdir.c | 28 ++++++++++++++++++++++++++++ support/xunistd.h | 1 + 3 files changed, 30 insertions(+) create mode 100644 support/xfchdir.c diff --git a/support/Makefile b/support/Makefile index 4046b12fbd..2937316851 100644 --- a/support/Makefile +++ b/support/Makefile @@ -119,6 +119,7 @@ libsupport-routines = \ xdlfcn \ xdlmopen \ xdup2 \ + xfchdir \ xfchmod \ xfclose \ xfopen \ diff --git a/support/xfchdir.c b/support/xfchdir.c new file mode 100644 index 0000000000..602138a2ae --- /dev/null +++ b/support/xfchdir.c @@ -0,0 +1,28 @@ +/* fchdir with error checking. + Copyright (C) 2017-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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +void +xfchdir (int fd) +{ + if (fchdir (fd) != 0) + FAIL_EXIT1 ("fchdir (%d): %m", fd); +} diff --git a/support/xunistd.h b/support/xunistd.h index 960a62d412..47137152a8 100644 --- a/support/xunistd.h +++ b/support/xunistd.h @@ -59,6 +59,7 @@ long long xlseek (int fd, long long offset, int whence); void xftruncate (int fd, long long length); void xsymlink (const char *target, const char *linkpath); void xchdir (const char *path); +void xfchdir (int); void xfchmod (int fd, mode_t mode); void xchmod (const char *pathname, mode_t mode); void xmkfifo (const char *pathname, mode_t mode);