From patchwork Sat Jan 9 19:31:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= X-Patchwork-Id: 41687 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 621DB38708E8; Sat, 9 Jan 2021 19:31:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 621DB38708E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610220700; bh=Z1Jp6Yl7M/qoKjpRXjNriPBEHp037BttAA5XiniMBeA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=HElB0zknNysVbOYKQUSyV/HcOixx4lJI8PEv7tD2Hd+vG8P6mmHdz7XP1QIN+ARq2 tnPuEFJwKq6U3On9hkzD6ROqIj/+W5SYTVpyvKAzy9hxmFL7ef+iCxh5ZgOa/TqC5O ycpm9A5H0RezgWjbvlyl10n2nXL4yLlMCd7VLCWQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with UTF8SMTPS id 2090D38708E5 for ; Sat, 9 Jan 2021 19:31:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2090D38708E5 Received: by mail-wr1-x434.google.com with SMTP id r7so12210810wrc.5 for ; Sat, 09 Jan 2021 11:31:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z1Jp6Yl7M/qoKjpRXjNriPBEHp037BttAA5XiniMBeA=; b=n20gHQO26KLQE9ntgOj1Oj2ISIfNCliJBth+3Cq/Doa0u5PyXzG+PWKGdGMTriKBxH xSc5jkpZEY7HseqSS7hSKgKGuKmE0kkmDM51GAJsZ88oVzCgpKHRRGG9vr+GFO06Qe/0 37+LKgJ/c3NdDf5GIrBwghvQ5wVwBm61V/RqvJ3AcyLWmSFv0AthvMlB3CfkDsWjPwvd qaBv9VsTH4qDQIGIZhscm23a7VYkauVD5EG8Q5m5jxNamBHZ5Q9twm1cr8siOG0FbE75 aYw4wpAnH0JeX0Cd1KqMpZmddqO4QC7WzrPJ8DiVY2wBlYOSK4vV+rBJA5DNOOYURobk YX6Q== X-Gm-Message-State: AOAM532WBpUl63QrBDN9ivMkBmipYEEb/J2w1GVm1snz0hXouMghxBNf 0Db5JTWwKiyU1mV9YkDeAnSB3VhnKZ4= X-Google-Smtp-Source: ABdhPJwXYTESL1w0tXKrUsrMKsW1Q0+6IBTCrjn9HP3sX+G2g0hOuN90w0cFM+n7qQYcGI3lKD8L0w== X-Received: by 2002:adf:80d0:: with SMTP id 74mr9450561wrl.110.1610220695849; Sat, 09 Jan 2021 11:31:35 -0800 (PST) Received: from picard.redhat.com (ip-244-183.pel.cz. [213.226.244.183]) by smtp.gmail.com with ESMTPSA id c20sm16348781wmb.38.2021.01.09.11.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 11:31:35 -0800 (PST) X-Google-Original-From: =?unknown-8bit?q?Alexandra_H=C3=A1jkov=C3=A1_ahajkov?= =?unknown-8bit?q?a=40redhat=2Ecom?= To: libc-alpha@sourceware.org Subject: [PATCH] Add xfchmod to libsupport Date: Sat, 9 Jan 2021 20:31:25 +0100 Message-Id: <20210109193125.361115-1-ahajkova@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201228201329.2151654-1-ahajkova@redhat.com> References: <20201228201329.2151654-1-ahajkova@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1_via_Libc-alpha?= From: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= Reply-To: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= Cc: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Alexandra Hájková --- support/Makefile | 1 + support/xfchmod.c | 28 ++++++++++++++++++++++++++++ support/xunistd.h | 1 + 3 files changed, 30 insertions(+) create mode 100644 support/xfchmod.c diff --git a/support/Makefile b/support/Makefile index f4d157dded..fce5c9cd4a 100644 --- a/support/Makefile +++ b/support/Makefile @@ -97,6 +97,7 @@ libsupport-routines = \ xdlmopen \ xdup2 \ xfclose \ + xfchmod \ xfopen \ xfork \ xftruncate \ diff --git a/support/xfchmod.c b/support/xfchmod.c new file mode 100644 index 0000000000..4323b9ca8e --- /dev/null +++ b/support/xfchmod.c @@ -0,0 +1,28 @@ +/* fchmod with error checking. + Copyright (C) 2021 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 +xfchmod (int fd, mode_t mode) +{ + if (fchmod (fd, mode) != 0) + FAIL_EXIT1 ("fchmod (%d, 0%o): %m", fd, mode); +} diff --git a/support/xunistd.h b/support/xunistd.h index 12a5ab677c..eb1b5519ff 100644 --- a/support/xunistd.h +++ b/support/xunistd.h @@ -46,6 +46,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 xfchmod (int fd, mode_t mode); /* Equivalent of "mkdir -p". */ void xmkdirp (const char *, mode_t);