From patchwork Mon Dec 28 20:13:29 2020 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: 41575 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 BC2F63861011; Mon, 28 Dec 2020 20:13:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC2F63861011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609186422; bh=9kyazZoiibhCsXPYhzxr+Q2CA7IlEM+nCw25gbfzv7c=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=yr36Wh9zNq/lk7Q029ai/7wDAeKd0tXyo7BbtFFklpRXOvjcytyUg12Bi2ZRPbW3/ myuBZZ0K4e96Ch3G5Y7gaj0Zo31gMTb4/FIJELQXMm5BOWhQxH8S3+8r/4qDG14oRj 5EU9IVoxgoOee3Yxs4zBcKqqz7isLrxyxTMzB8+g= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with UTF8SMTPS id CD0F6385800F for ; Mon, 28 Dec 2020 20:13:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CD0F6385800F Received: by mail-ed1-x52a.google.com with SMTP id p22so10747403edu.11 for ; Mon, 28 Dec 2020 12:13:39 -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:mime-version :content-transfer-encoding; bh=9kyazZoiibhCsXPYhzxr+Q2CA7IlEM+nCw25gbfzv7c=; b=oroeVC9vXKHeoDJbUsFtOkUm2CpAnp5v/2whQnwl+pyyIj2G3owmRRZC9OsSrjkyuB vK1/qpYVYt1Di2XLHfmZJng7a7YMPENk21/CQZU34uCKjwDVskTvW0wzK/+sn9dcJtb6 K2g74LAXzhnTLgk/13gmXmSPB1Kv4cG92EwsJR9bpmL6c1S/P8h4CZe7aQ3dW2X3UoGX 5qx3hf7B/sbaJDlwC6S/4EaTQg9+6Wf6zuP+qqFdz7X6EuBOrccFWe83nw9ezEOJpyQP GnKVIjQZ3fh1B253heeeoEoaD82Muf2r13MKqYbA6PkBxZOMTyCLXNzQMdqqSTArMsto B+kg== X-Gm-Message-State: AOAM532HMPZ0HmF23C1UbCZLZ6RMrwBB7UwHfDqpxyHmfQTOjZ35mL1n wht9O/7zbrUv/O53AXFO4zP2LO8t4/A= X-Google-Smtp-Source: ABdhPJx/KIUyyXfHgwjCYHHCX4ocE5Cb5zVUL+qjz2MeTvlACXGbDDVjN6kEPyKkNrOeVeCORSMMqQ== X-Received: by 2002:a50:f9cc:: with SMTP id a12mr42795483edq.335.1609186418918; Mon, 28 Dec 2020 12:13:38 -0800 (PST) Received: from localhost.localdomain (ip-244-183.pel.cz. [213.226.244.183]) by smtp.gmail.com with ESMTPSA id n2sm17378998ejj.24.2020.12.28.12.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 12:13:38 -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: Mon, 28 Dec 2020 21:13:29 +0100 Message-Id: <20201228201329.2151654-1-ahajkova@redhat.com> X-Mailer: git-send-email 2.26.2 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á --- This patch is needed for my pending execveat syscall wrapper patch. 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 26e4ab1c4c..94a88bf819 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..4a6daa99e2 --- /dev/null +++ b/support/xfchmod.c @@ -0,0 +1,28 @@ +/* fchmod with error checking. + Copyright (C) 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 +xfchmod (int fd, mode_t mode) +{ + if (fchmod (fd, mode) != 0) + FAIL_EXIT1 ("mkdir (\"%d\", 0%o): %m", fd, mode); +} diff --git a/support/xunistd.h b/support/xunistd.h index c4b7aa01c9..dcccf78372 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);