From patchwork Mon Jun 22 15:15:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39759 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 68E723954C4F; Mon, 22 Jun 2020 15:15:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 68E723954C4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1592838932; bh=DxiyC1t6kFHfYJ4aWetv+/iDOwPIS5fpdop44wNInL4=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=pugT1st1f/0TiI7xV37+JJSYhvicfFybQvmZOiQQZtJ+3W4sO+YwSeyg2rotvjDm0 snsWX4C4FvKPNmeac7k4Wckqmk71+C+FY4+PANyx8/J6uYHUC70UV4NUMU1yF075aP IY0olWQbdfN5+53FItp4n0ZEtxbEtzQwOJXup7kY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 11E063954C4F for ; Mon, 22 Jun 2020 15:15:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 11E063954C4F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-1cgMxBtiPQiffquX1dDIrA-1; Mon, 22 Jun 2020 11:15:27 -0400 X-MC-Unique: 1cgMxBtiPQiffquX1dDIrA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BA4E107B267 for ; Mon, 22 Jun 2020 15:15:25 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-185.ams2.redhat.com [10.36.112.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0AF21974D for ; Mon, 22 Jun 2020 15:15:24 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 28/30] elf: In ldconfig, extract the new_sub_entry function from search_dir In-Reply-To: References: Message-Id: <59c31c40df34e9c12810346ca0fb1c8a0d4708b2.1592836143.git.fweimer@redhat.com> Date: Mon, 22 Jun 2020 17:15:23 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --- elf/ldconfig.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 0c090dca15..3768267bac 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -328,6 +328,23 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "Andreas Jaeger"); } +/* Allocate a new subdirectory with full path PATH under ENTRY, using + inode data from *ST. */ +static struct dir_entry * +new_sub_entry (const struct dir_entry *entry, const char *path, + const struct stat64 *st) +{ + struct dir_entry *new_entry = xmalloc (sizeof (struct dir_entry)); + new_entry->from_file = entry->from_file; + new_entry->from_line = entry->from_line; + new_entry->path = xstrdup (path); + new_entry->flag = entry->flag; + new_entry->next = NULL; + new_entry->ino = st->st_ino; + new_entry->dev = st->st_dev; + return new_entry; +} + /* Add a single directory entry. */ static void add_single_dir (struct dir_entry *entry, int verbose) @@ -823,26 +840,17 @@ search_dir (const struct dir_entry *entry) if (is_dir && is_hwcap_platform (direntry->d_name)) { - /* Handle subdirectory later. */ - struct dir_entry *new_entry; - - new_entry = xmalloc (sizeof (struct dir_entry)); - new_entry->from_file = entry->from_file; - new_entry->from_line = entry->from_line; - new_entry->path = xstrdup (file_name); - new_entry->flag = entry->flag; - new_entry->next = NULL; if (!is_link && direntry->d_type != DT_UNKNOWN && __builtin_expect (lstat64 (real_file_name, &lstat_buf), 0)) { error (0, errno, _("Cannot lstat %s"), file_name); - free (new_entry->path); - free (new_entry); continue; } - new_entry->ino = lstat_buf.st_ino; - new_entry->dev = lstat_buf.st_dev; + + /* Handle subdirectory later. */ + struct dir_entry *new_entry = new_sub_entry (entry, file_name, + &lstat_buf); add_single_dir (new_entry, 0); continue; }