From patchwork Wed Jan 22 20:03:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1227409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108908-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=FOxzwiuH; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XJ0lQ+t5; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482xDJ5CTCz9sR0 for ; Thu, 23 Jan 2020 07:03:28 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=AtcSaVuBB7guqo8M 7vhiPmPGvUDiqW52C7XSzixB0W3qVYyf0kMVA5gWRptapsY6QHq3GpDDrIxm3k/p A+miMrxjCST2Y5FiXleNBjqoyPvM6n89SZ+BxpfB+KZDQd8d5qsnwS3M5y7FcHzT grIdPIbO/DJHHoG9n9RLxQk5XFU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=BuXq7r7tVqPn1dq4usBGPI W+GH8=; b=FOxzwiuHZeCq8/eBGgq2XxmvV5lH1rvUUAbJPITEvhU3URloMrGmiy fzEHZOOgF1SdnJLzdIi4bLf6Ac4vxbyatDPhRs3deYVKLCO6+OsE00XDtBTLPMLY asGi2DJBEk+YF7YS+FUi6QQUZ3A3ZC8+vbn/4OrlIlcTIEplzSnUk= Received: (qmail 100039 invoked by alias); 22 Jan 2020 20:03:23 -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 100030 invoked by uid 89); 22 Jan 2020 20:03:22 -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= X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579723399; 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=wuEpy8B9hu55nP7CQXBq5xP+z2Cr7DfnSkLUtrMqp0A=; b=XJ0lQ+t5N7LCMHrUQlVbN6ZoDgUkNVTrx/+eTee9sNJQyET4qiSNy7GReKDsytK7VKunhY 6pvWtcFeEYIld0OHfqzlkh+Ak4WPZOvuVl2XLZwKrVTPxAY5J4Bp1DVKESamU3e0lDG5XM 6Nmkpc74+Sde33TLyXsZwR2s8Q24W3Q= From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 1/5] support: Add the xlstat function In-Reply-To: References: Message-Id: Date: Wed, 22 Jan 2020 21:03:13 +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 --- support/Makefile | 1 + support/xlstat.c | 28 ++++++++++++++++++++++++++++ support/xunistd.h | 1 + 3 files changed, 30 insertions(+) create mode 100644 support/xlstat.c diff --git a/support/Makefile b/support/Makefile index 3325feb790..a0304e6def 100644 --- a/support/Makefile +++ b/support/Makefile @@ -98,6 +98,7 @@ libsupport-routines = \ xgetsockname \ xlisten \ xlseek \ + xlstat \ xmalloc \ xmemstream \ xmkdir \ diff --git a/support/xlstat.c b/support/xlstat.c new file mode 100644 index 0000000000..de45ef3df2 --- /dev/null +++ b/support/xlstat.c @@ -0,0 +1,28 @@ +/* lstat64 with error checking. + Copyright (C) 2017-2020 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 +xlstat (const char *path, struct stat64 *result) +{ + if (lstat64 (path, result) != 0) + FAIL_EXIT1 ("lstat64 (\"%s\"): %m", path); +} diff --git a/support/xunistd.h b/support/xunistd.h index 96f498f2e5..b299db77ba 100644 --- a/support/xunistd.h +++ b/support/xunistd.h @@ -36,6 +36,7 @@ void xpipe (int[2]); void xdup2 (int, int); int xopen (const char *path, int flags, mode_t); void xstat (const char *path, struct stat64 *); +void xlstat (const char *path, struct stat64 *); void xfstat (int fd, struct stat64 *); void xmkdir (const char *path, mode_t); void xchroot (const char *path);