From: David Michael <fedora.dm0@gmail.com>
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 [thread overview]
Message-ID: <87v9nl8bw9.fsf@gmail.com> (raw)
This provides the node's attributes outside the search function.
Signed-off-by: David Michael <fedora.dm0@gmail.com>
---
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
next reply other threads:[~2020-03-03 19:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 19:40 David Michael [this message]
2020-03-06 12:02 ` [PATCH v2 1/2] exfat: Save the matching directory entry when iterating Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v9nl8bw9.fsf@gmail.com \
--to=fedora.dm0@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.