From patchwork Thu Oct 24 19:23:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35289 Received: (qmail 105520 invoked by alias); 24 Oct 2019 19:23:13 -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 105489 invoked by uid 89); 24 Oct 2019 19:23:12 -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 autolearn=ham version=3.3.1 spammy=Perhaps, HX-Languages-Length:2230 X-HELO: mx1.osci.io X-Gerrit-PatchSet: 1 Date: Thu, 24 Oct 2019 15:23:08 -0400 From: "Carlos O'Donell (Code Review)" To: libc-alpha@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] localedef: Add verbose messages for failure paths. X-Gerrit-Change-Id: I28b9f680711ff00252a2cb15625b774cc58ecb9d X-Gerrit-Change-Number: 303 X-Gerrit-ChangeURL: X-Gerrit-Commit: 31f965ab9e8302ad087c72f799fa3c545f92d502 References: Reply-To: carlos@redhat.com, libc-alpha@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/303 ...................................................................... localedef: Add verbose messages for failure paths. 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 Change-Id: I28b9f680711ff00252a2cb15625b774cc58ecb9d --- M locale/programs/localedef.c 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index 3dcf15f..965751f 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -526,7 +526,11 @@ (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 @@ 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';