From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with UTF8SMTPS id 875C0385800F for ; Mon, 28 Dec 2020 20:05:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 875C0385800F Received: by mail-wm1-x32d.google.com with SMTP id v14so396642wml.1 for ; Mon, 28 Dec 2020 12:05:43 -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=noUv6KWwLhKjkWXpSdt5gxi3khKO67lqX9kOfPacesI=; b=iozQ/TFG0tL5dlA4fPbCqL0cj/btdPAKEUHiZ9llhYkqxjNXTy0RrYVHY5eEEBqada WfeZyWhKdESlEYZniKDEQ7mK2GiVvZJJEtr0aZZ7jAsSUWl/vQTtzllrN0M+uUFrrjm3 S76xP1SFKl8ZkFFBw0dV/njCs6q69ooCmwtqUitoq7Ad2gGHe1WivAL0nayY54Vhu1fF C/jCAAiIRz+dAGWH37LQ5igPSFRVGOz3h5f/OE7w4BalgQCkK1l9HvG77/RR2lCqkLXG wI3QIIrbWllheeNTF0WzUNf4b6gbNA4JKH4u9/fJ8p3GlRHcOeEU2v8Js+1HIiBlFC19 orOg== X-Gm-Message-State: AOAM53230Y2scsH4BRhFIgbg3sbEZ/M+evjanyp8aeRTXRyOMwECvAiY nl1yIJNXIivvHibxOOnRCtZJtFRDgL4= X-Google-Smtp-Source: ABdhPJziN5zdS6RpO2Q5Zya4cOPJC68BWfq1YtnubgP8F80TVyZWlrc6dIe/ymqRt7YtQKMN1NHZiw== X-Received: by 2002:a1c:9ccd:: with SMTP id f196mr471241wme.82.1609185942253; Mon, 28 Dec 2020 12:05:42 -0800 (PST) Received: from localhost.localdomain (ip-244-183.pel.cz. [213.226.244.183]) by smtp.gmail.com with ESMTPSA id x66sm474312wmg.26.2020.12.28.12.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 12:05:41 -0800 (PST) From: =?UTF-8?Q?Alexandra_H=C3=A1jkov=C3=A1?= X-Google-Original-From: Alexandra Hájková ahajkova@redhat.com To: libc-alpha@sourceware.org Cc: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= Subject: [PATCH] Add xchdir to libsupport. Date: Mon, 28 Dec 2020 21:05:28 +0100 Message-Id: <20201228200528.2150980-1-ahajkova@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201226174936.985576-1-ahajkova@redhat.com> References: <20201226174936.985576-1-ahajkova@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.1 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-List-Received-Date: Mon, 28 Dec 2020 20:05:45 -0000 From: Alexandra Hájková --- support/Makefile | 1 + support/xchdir.c | 28 ++++++++++++++++++++++++++++ support/xunistd.h | 1 + 3 files changed, 30 insertions(+) create mode 100644 support/xchdir.c diff --git a/support/Makefile b/support/Makefile index 3198eb5022..26e4ab1c4c 100644 --- a/support/Makefile +++ b/support/Makefile @@ -87,6 +87,7 @@ libsupport-routines = \ xasprintf \ xbind \ xcalloc \ + xchdir \ xchroot \ xclock_gettime \ xclose \ diff --git a/support/xchdir.c b/support/xchdir.c new file mode 100644 index 0000000000..beb4feff72 --- /dev/null +++ b/support/xchdir.c @@ -0,0 +1,28 @@ +/* chdir 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 +xchdir (const char *path) +{ + if (chdir (path) != 0) + FAIL_EXIT1 ("chdir (\"%s\"): %m", path); +} diff --git a/support/xunistd.h b/support/xunistd.h index b299db77ba..c4b7aa01c9 100644 --- a/support/xunistd.h +++ b/support/xunistd.h @@ -45,6 +45,7 @@ long xsysconf (int name); 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); /* Equivalent of "mkdir -p". */ void xmkdirp (const char *, mode_t); -- 2.26.2