diff --git a/fs/fshelp.c b/fs/fshelp.c index df33fa1..f48b089 100644 --- a/fs/fshelp.c +++ b/fs/fshelp.c @@ -80,7 +80,13 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode, enum grub_fshelp_filetype filetype, grub_fshelp_node_t node) { - if (type == GRUB_FSHELP_UNKNOWN || grub_strcmp (name, filename)) + int case_insensitive = (filetype & GRUB_FSHELP_CASE_INSENSITIVE); + + filetype &= ~GRUB_FSHELP_CASE_INSENSITIVE; + if (filetype == GRUB_FSHELP_UNKNOWN || + (grub_strcmp (name, filename) && + (! case_insensitive || + grub_strncasecmp (name, filename, LONG_MAX)))) { grub_free (node); return 0; diff --git a/fs/ntfs.c b/fs/ntfs.c index 3174ab1..a590ade 100644 --- a/fs/ntfs.c +++ b/fs/ntfs.c @@ -575,13 +575,20 @@ list_file (struct grub_ntfs_file *diro, char *pos, while (1) { - char *ustr; + char *ustr, namespace; + if (pos[0xC] & 2) /* end signature */ break; - np = pos + 0x52; - ns = (unsigned char) *(np - 2); - if (ns) + np = pos + 0x50; + ns = (unsigned char) *(np++); + namespace = *(np++); + + /* + * Ignore files in DOS namespace, as they will reappear as Win32 + * names. + */ + if ((ns) && (namespace != 2)) { enum grub_fshelp_filetype type; struct grub_ntfs_file *fdiro; @@ -610,6 +617,9 @@ list_file (struct grub_ntfs_file *diro, char *pos, *grub_utf16_to_utf8 ((grub_uint8_t *) ustr, (grub_uint16_t *) np, ns) = '\0'; + if (namespace) + type |= GRUB_FSHELP_CASE_INSENSITIVE; + if (hook (ustr, type, fdiro)) { grub_free (ustr); diff --git a/include/grub/fshelp.h b/include/grub/fshelp.h index 698c7aa..7092cac 100644 --- a/include/grub/fshelp.h +++ b/include/grub/fshelp.h @@ -26,6 +26,8 @@ typedef struct grub_fshelp_node *grub_fshelp_node_t; +#define GRUB_FSHELP_CASE_INSENSITIVE 0x100 + enum grub_fshelp_filetype { GRUB_FSHELP_UNKNOWN, diff --git a/include/grub/types.h b/include/grub/types.h index d204429..6f256c1 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -94,8 +94,10 @@ typedef grub_int32_t grub_ssize_t; #if GRUB_CPU_SIZEOF_VOID_P == 8 # define ULONG_MAX 18446744073709551615UL +# define LONG_MAX 9223372036854775807UL #else # define ULONG_MAX 4294967295UL +# define LONG_MAX 2147483647UL #endif /* The type for representing a file offset. */