From fb022c79ef2b7eb4deb1d76890c74d7d1c183811 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 25 Jun 2012 17:47:52 +0200 Subject: [PATCH] * grub-core/fs/fat.c (grub_fat_iterate_dir_next): Don't stop on a space character but still remove trainling spaces. (grub_fat_label): Ignore archive flag. --- ChangeLog | 6 ++++++ grub-core/fs/fat.c | 32 +++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b229ee8d..ca8b4abe0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-06-25 Vladimir Serbinenko + + * grub-core/fs/fat.c (grub_fat_iterate_dir_next): Don't stop on a space + character but still remove trainling spaces. + (grub_fat_label): Ignore archive flag. + 2012-06-25 Vladimir Serbinenko * grub-core/loader/i386/linux.c (grub_cmd_initrd): Avoid unnecessarry diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 003dbd86c..119fc945f 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -798,22 +798,36 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, filep = ctxt->filename; if (ctxt->dir.attr & GRUB_FAT_ATTR_VOLUME_ID) { - for (i = 0; i < sizeof (ctxt->dir.name) && ctxt->dir.name[i] - && ! grub_isspace (ctxt->dir.name[i]); i++) + for (i = 0; i < sizeof (ctxt->dir.name) && ctxt->dir.name[i]; i++) *filep++ = ctxt->dir.name[i]; + while (i > 0 && ctxt->dir.name[i - 1] == ' ') + { + filep--; + i--; + } } else { - for (i = 0; i < 8 && ctxt->dir.name[i] && ! grub_isspace (ctxt->dir.name[i]); i++) + for (i = 0; i < 8 && ctxt->dir.name[i]; i++) *filep++ = grub_tolower (ctxt->dir.name[i]); + while (i > 0 && ctxt->dir.name[i - 1] == ' ') + { + filep--; + i--; + } - *filep = '.'; + *filep++ = '.'; - for (i = 8; i < 11 && ctxt->dir.name[i] && ! grub_isspace (ctxt->dir.name[i]); i++) - *++filep = grub_tolower (ctxt->dir.name[i]); + for (i = 8; i < 11 && ctxt->dir.name[i]; i++) + *filep++ = grub_tolower (ctxt->dir.name[i]); + while (i > 8 && ctxt->dir.name[i - 1] == ' ') + { + filep--; + i--; + } - if (*filep != '.') - filep++; + if (i == 8) + filep--; } *filep = '\0'; return GRUB_ERR_NONE; @@ -1117,7 +1131,7 @@ grub_fat_label (grub_device_t device, char **label) goto fail; while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt))) - if (ctxt.dir.attr == GRUB_FAT_ATTR_VOLUME_ID) + if ((ctxt.dir.attr & ~GRUB_FAT_ATTR_ARCHIVE) == GRUB_FAT_ATTR_VOLUME_ID) { *label = grub_strdup (ctxt.filename); break;