From patchwork Tue Dec 11 01:19:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 1010805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-98175-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (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.b="R4Irw/4g"; 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 43DMY616lDz9s0t for ; Tue, 11 Dec 2018 12:19:21 +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:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=wU6 7tH7Z3YOtyp/mWeiif9ZF7tueHrlli01RXTFTgBbMGtoql03SVYDWpkQNXTxfoAJ CjX5EcysOGQfBQFDrVyUvYwKHKtpWkGZATX/Mm1OkARfBJt7bYyfWOjIq52wDFGI w+wObY0JAL8vcI+R7bH5qdWQOdCopIpAAEXamsTc= 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:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; s=default; bh=a8G/nyUPN vIrsOAjysED4i8R4aA=; b=R4Irw/4gf86hV5xjI29fsGzmIBnZKeCRo+02VzHKe KtJzA6HccIpdp20uwL5JQXIalKwwQwF/MoghOn89A+ZV++Yc3H7j8OTQz+Zr2ocb nZnY/isjgq6gVCPJ1okCwHstZKqXd0UwbnA/c1/G+5bCcEGLGerI7mFOApNaqEKm Qo= Received: (qmail 110750 invoked by alias); 11 Dec 2018 01:19:15 -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 110727 invoked by uid 89); 11 Dec 2018 01:19:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=sk:constru, opportunity X-HELO: mail-qk1-f194.google.com To: GNU C Library From: Carlos O'Donell Subject: [PATCH] localedef: Add verbose messages for failure paths. Openpgp: preference=signencrypt Message-ID: <9ce1738a-1830-67d8-cad8-b8bec4963f03@redhat.com> Date: Mon, 10 Dec 2018 20:19:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 During testing of localedef running in a minimal container there were several error cases which were hard to diagnose since they appeared as strerror (errno) values printed by the higher level functions. This change adds three new verbose messages for potential failure paths. The new messages give the user the opportunity to use -v and display additional information about why localedef might be failing. I found these messages useful myself while writing a localedef container test for --no-hard-links. Signed-off-by: Carlos O'Donell --- ChangeLog | 5 +++++ locale/programs/localedef.c | 30 ++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d2494e054..0fd6dfc224 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-12-10 Carlos O'Donell + + * locale/programs/localedef.c (construct_output_path): Use + record_verbose to print verbose output in three failure modes. + 2018-12-10 Joseph Myers * scripts/gen-as-const.py (main): Handle --python option. diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index 6c4936be6b..10c08231fe 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -526,7 +526,11 @@ construct_output_path (char *path) (int) (startp - path), path, normal, endp, '\0'); if (n < 0) - return NULL; + { + record_verbose (stderr, + _("failed to allocate space for compiled locale path")); + return NULL; + } endp = result + n - 1; } @@ -546,13 +550,23 @@ construct_output_path (char *path) errno = 0; if (no_archive && euidaccess (result, W_OK) == -1) - /* Perhaps the directory does not exist now. Try to create it. */ - if (errno == ENOENT) - { - errno = 0; - if (mkdir (result, 0777) < 0) - return NULL; - } + { + /* Perhaps the directory does not exist now. Try to create it. */ + if (errno == ENOENT) + { + errno = 0; + if (mkdir (result, 0777) < 0) + { + record_verbose (stderr, + _("cannot create output path \"%s\": %s"), + result, strerror (errno)); + return NULL; + } + } + else + record_verbose (stderr, _("no write permission to output path: %s"), + strerror (errno)); + } *endp++ = '/'; *endp = '\0';