From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1j9DPZ-0000v3-PH for mharc-grub-devel@gnu.org; Tue, 03 Mar 2020 14:41:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60840) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DPW-0000rO-Fl for grub-devel@gnu.org; Tue, 03 Mar 2020 14:40:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DPV-0003dB-9a for grub-devel@gnu.org; Tue, 03 Mar 2020 14:40:58 -0500 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:37305) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j9DPV-0003cb-3T for grub-devel@gnu.org; Tue, 03 Mar 2020 14:40:57 -0500 Received: by mail-qt1-x843.google.com with SMTP id j34so3796623qtk.4 for ; Tue, 03 Mar 2020 11:40:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=e7850NB8fQivv3HW1NGR7YU0mSyQll/KA3KDNMzAdfA=; b=gPO8q4wpF6cFugp+6CvzAIESW+q/qr+4n+FrDKU/Njzv7o1EZklYzQ1sUdQQt79t2L 3ygCntW6PI7jn5LmaQr9sWnKp8Zz+wmWIey6qd9i09PTQOCp9KcPkJgEHamBIUlJfp6u sZ0+OGA5mMOr0KeWhrsEH0jspvU/nsgM9tu9eEosF5teVGKbWHfPSE8xgupOiZhDpAND LG3NQCJnwjlwZpWv1HxSDdtCpCvtg0H3eSj6oxTGksrLYygVJY7tKytFSbN2azQN2GWG sg2aAKYbwk65Ks2V5ArK8QkdayJBTMVxR948/Id/PB+6R6xSrcRHQoOSuPgeXTl3E4fK PrSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=e7850NB8fQivv3HW1NGR7YU0mSyQll/KA3KDNMzAdfA=; b=C7RldTPfLt2HRsVXr8XVSclUhibdqeEGwaUjZaPh4t9emndYcsIkhLn8QEdrHBxhq+ TZ9t7CuLvX1odXEU/r3jV0xg5jw2Ahba3Qdj9H9lUdGlBmo/MD7KFjoGKHh0qoVEnqP2 NLmfAo/tW7Bs39VluDp/NJ/kQ0m7fcQLdMRUqucn1ha4uUgIZEPAxDuixLvcn404woOJ pf0SUMyFwYRlMy26eWxtC87b7IUf6keNTSLWKIpCwDTX/hJaXx1OQ5oarKadFI06OeZ7 QrwnPIRZW3Extj3Zti7nrlzZw+ClRV5Ch4Ho2gY3xZgI0Yy1rfxevw/giGVZEm6Sn8aG QAtA== X-Gm-Message-State: ANhLgQ0OXN+pOybqO9aXkYnI5hvROez9vwJJtsvrc5S4rLaZa5vizji6 TozWoo3pS1wKf7BYyEcjvWlYzHJg X-Google-Smtp-Source: ADFU+vv0BQpUiQ0+lm8oeAAd8Kba/9k1avG2ki8zS0L6hm6EV9VYOfo/mKwzaGZRn7tdHFowYMJVCw== X-Received: by 2002:ac8:108d:: with SMTP id a13mr469490qtj.230.1583264455915; Tue, 03 Mar 2020 11:40:55 -0800 (PST) Received: from callisto ([2601:986:200:7341:384b:df90:fb2f:c5df]) by smtp.gmail.com with ESMTPSA id 4sm8187649qky.106.2020.03.03.11.40.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 11:40:55 -0800 (PST) From: David Michael To: grub-devel@gnu.org Subject: [PATCH v2 1/2] exfat: Save the matching directory entry when iterating Date: Tue, 03 Mar 2020 14:40:54 -0500 Message-ID: <87v9nl8bw9.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Mar 2020 19:40:59 -0000 This provides the node's attributes outside the search function. Signed-off-by: David Michael --- I had to copy an extra struct to support exfat mtimes, so I put it in a separate patch for readability. grub-core/fs/fat.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index d544e0af1..dc493add2 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -596,6 +596,7 @@ struct grub_fat_iterate_context { #ifdef MODE_EXFAT struct grub_fat_dir_node dir; + struct grub_fat_dir_entry entry; #else struct grub_fat_dir_entry dir; #endif @@ -642,27 +643,27 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node, grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir)); while (1) { - struct grub_fat_dir_entry dir; + struct grub_fat_dir_entry *dir = &ctxt->entry; - ctxt->offset += sizeof (dir); + ctxt->offset += sizeof (*dir); - if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (dir), - (char *) &dir) - != sizeof (dir)) + if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (*dir), + (char *) dir) + != sizeof (*dir)) break; - if (dir.entry_type == 0) + if (dir->entry_type == 0) break; - if (!(dir.entry_type & 0x80)) + if (!(dir->entry_type & 0x80)) continue; - if (dir.entry_type == 0x85) + if (dir->entry_type == 0x85) { unsigned i, nsec, slots = 0; - nsec = dir.type_specific.file.secondary_count; + nsec = dir->type_specific.file.secondary_count; - ctxt->dir.attr = grub_cpu_to_le16 (dir.type_specific.file.attr); + ctxt->dir.attr = grub_cpu_to_le16 (dir->type_specific.file.attr); ctxt->dir.have_stream = 0; for (i = 0; i < nsec; i++) { @@ -705,7 +706,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node, if (i != nsec) { - ctxt->offset -= sizeof (dir); + ctxt->offset -= sizeof (*dir); continue; } @@ -715,16 +716,16 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node, return 0; } /* Allocation bitmap. */ - if (dir.entry_type == 0x81) + if (dir->entry_type == 0x81) continue; /* Upcase table. */ - if (dir.entry_type == 0x82) + if (dir->entry_type == 0x82) continue; /* Volume label. */ - if (dir.entry_type == 0x83) + if (dir->entry_type == 0x83) continue; grub_dprintf ("exfat", "unknown primary type 0x%02x\n", - dir.entry_type); + dir->entry_type); } return grub_errno ? : GRUB_ERR_EOF; } -- 2.21.1