From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665752773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=reqlyrRNrBXZlAhlBen3DGOkuxk9aGB+dKFGgk8wUlU=; b=KVJPx5yBHmUev0acQr71in+BC6M7Xpguyu84wMbHH8qAB58VXGatSKfRxqJaiFRK0wQR5d W54HRIkedHc/71ycaofPkhQMzoB6Q4mff5h/ZrUZtVgd3pWVjlEjJ6kjU0gB2KxyOcYjJz Ojqp5fKXOjd2CYEE1Z8AShiT4oniDZA= 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) From: Florian Weimer 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 Content-Type: text/plain 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 List-Id: --- 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); -- 2.37.3