Ignore case when opening files in FAT
PATCH 1/1 Ignore case when opening files in FAT
Hi,
As FAT is basically a case insensitive file system, we should ignore case when opening files.
For example, normally efi image would be placed in EFI/grub directory. After startup, the prefix would be set to something like (hd0,1)/EFI/grub/. But inside grub, it convert pathname to lowercase, EFI would become efi, so grub can't open it anymore. With this patch, fat ignore case, so we can access files using /efi/grub as well as /EFI/grub.
Signature · 1 line
Bean
fs/fat.c +3 -1
@@ -35,6 +35,8 @@#define GRUB_FAT_ATTR_DIRECTORY 0x10#define GRUB_FAT_ATTR_ARCHIVE 0x20 +#define GRUB_FAT_MAXPATH 260 +#define GRUB_FAT_ATTR_LONG_NAME (GRUB_FAT_ATTR_READ_ONLY \ | GRUB_FAT_ATTR_HIDDEN \ | GRUB_FAT_ATTR_SYSTEM \
@@ -629,7 +631,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,if (hook (filename, dir.attr &GRUB_FAT_ATTR_DIRECTORY ))break ; } -else if (grub_strcmp (dirname, filename) ==0 ) +else if (grub_strncasecmp (dirname, filename,GRUB_FAT_MAXPATH ) ==0 ) {if (call_hook)hook (filename, dir.attr &GRUB_FAT_ATTR_DIRECTORY );
Hi,
Quoted 1 line
+#define
GRUB_FAT_MAXPATH260
I may be wrong, but AFAIK FAT only supports a length of 255 chars for filenames, including the path. So this should be set to 255 instead of 260. Or did I miss something?
---
Markus
Quoted 6 lines · Markus Halm
Hi,
Quoted 1 line
+#define
GRUB_FAT_MAXPATH260I may be wrong, but AFAIK FAT only supports a length of 255 chars for filenames, including the path. So this should be set to 255 instead of 260. Or did I miss something?
Hi,
Well, this number is only used in grub_strncasecmp, it doesn't need to be precise, just to make sure it's long enough. 255 is fine as well.
Signature · 1 line
Bean
Quoted 4 lines · Bean
Hi,
As FAT is basically a case insensitive file system, we should ignore case when opening files.
I don't agree with this. FAT itself just stores names in ASCII, which provides both cases. It's up to the reader whether to be case sensitive or not (btw I recall this was discussed before).
IMHO, case unsensitivity is a bug. It's only included in EFI for legacy reasons.
Quoted 4 lines
For example, normally efi image would be placed in EFI/grub directory. After startup, the prefix would be set to something like (hd0,1)/EFI/grub/. But inside grub, it convert pathname to lowercase, EFI would become efi, so grub can't open it anymore.
If the problem is that GRUB converts pathnames to lowercase, why not drop that conversion and let filenames be of any case?
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 6 lines · Robert Millan
Quoted 4 lines · Bean
Hi,
As FAT is basically a case insensitive file system, we should ignore case when opening files.
Quoted 6 lines
I don't agree with this. FAT itself just stores names in ASCII, which provides both cases. It's up to the reader whether to be case sensitive or not (btw I recall this was discussed before).
IMHO, case unsensitivity is a bug. It's only included in EFI for legacy reasons.
We also need to consider scripts, like update-grub. It retrieve pathname using host os. We need to be sure grub can read those pathname. Our fat driver uses the same scheme as linux, which convert all uppercase name to lowercase, but it doesn't match windows, which preserves them.
Also, what's the drawback of this ? The linux drive also does the same, it lists files using lowercase, but you can open files in any case.
Quoted 8 lines
Quoted 5 lines
For example, normally efi image would be placed in EFI/grub directory. After startup, the prefix would be set to something like (hd0,1)/EFI/grub/. But inside grub, it convert pathname to lowercase, EFI would become efi, so grub can't open it anymore.
If the problem is that GRUB converts pathnames to lowercase, why not drop that conversion and let filenames be of any case?
FAT can have long filename, which preserve case. The problem is when long filename is not used, in that case, it store them in 8.3 format, which uses all uppercase.
Signature · 1 line
Bean
Quoted 11 lines · Bean
Quoted 10 lines · Robert Millan
Quoted 4 lines · Bean
Hi,
As FAT is basically a case insensitive file system, we should ignore case when opening files.
I don't agree with this. FAT itself just stores names in ASCII, which provides both cases. It's up to the reader whether to be case sensitive or not (btw I recall this was discussed before).
Quoted 8 lines
Quoted 2 lines
IMHO, case unsensitivity is a bug. It's only included in EFI for legacy reasons.
We also need to consider scripts, like update-grub. It retrieve pathname using host os. We need to be sure grub can read those pathname. Our fat driver uses the same scheme as linux, which convert all uppercase name to lowercase, but it doesn't match windows, which preserves them.
Argh, you're right. Linux is messing up the case! This is so annoying.
Oh well..
Quoted 3 lines
FAT can have long filename, which preserve case. The problem is when long filename is not used, in that case, it store them in 8.3 format, which uses all uppercase.
You just managed to convince me that FAT is far worse than I initially thought.
Anyway, please have GRUB deal with this madness as you see fit. I don't care anymore.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 29 lines · Robert Millan
Quoted 11 lines · Bean
Quoted 10 lines · Robert Millan
Quoted 4 lines · Bean
Hi,
As FAT is basically a case insensitive file system, we should ignore case when opening files.
I don't agree with this. FAT itself just stores names in ASCII, which provides both cases. It's up to the reader whether to be case sensitive or not (btw I recall this was discussed before).
Quoted 8 lines
Quoted 2 lines
IMHO, case unsensitivity is a bug. It's only included in EFI for legacy reasons.
We also need to consider scripts, like update-grub. It retrieve pathname using host os. We need to be sure grub can read those pathname. Our fat driver uses the same scheme as linux, which convert all uppercase name to lowercase, but it doesn't match windows, which preserves them.
Argh, you're right. Linux is messing up the case! This is so annoying.
Oh well..
Quoted 3 lines
FAT can have long filename, which preserve case. The problem is when long filename is not used, in that case, it store them in 8.3 format, which uses all uppercase.
Quoted 5 lines
You just managed to convince me that FAT is far worse than I initially thought.
Anyway, please have GRUB deal with this madness as you see fit. I don't care anymore.
ok, committed.
Signature · 1 line
Bean