]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-09-05 Bean <bean123ch@gmail.com>
authorbean <bean@localhost>
Fri, 5 Sep 2008 15:48:37 +0000 (15:48 +0000)
committerbean <bean@localhost>
Fri, 5 Sep 2008 15:48:37 +0000 (15:48 +0000)
* fs/fshelp.c (grub_fshelp_find_file): Handle case insensitive names.

* fs/ntfs.c (list_file): Ignore names in DOS namespace, set the case
insensitive bit for names in Win32 and Win32 & DOS namespace.

* include/grub/fshelp.h (GRUB_FSHELP_CASE_INSENSITIVE): New macro.

* include/grub/types.h (LONG_MAX): Likewise.

ChangeLog
fs/fshelp.c
fs/ntfs.c
include/grub/fshelp.h
include/grub/types.h

index 571472959e0a976b6b6fad4465fe0022327f95aa..9e59ecdcb3acccbed7d08394d524034c38326151 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-09-05  Bean  <bean123ch@gmail.com>
+
+       * fs/fshelp.c (grub_fshelp_find_file): Handle case insensitive names.
+
+       * fs/ntfs.c (list_file): Ignore names in DOS namespace, set the case
+       insensitive bit for names in Win32 and Win32 & DOS namespace.
+
+       * include/grub/fshelp.h (GRUB_FSHELP_CASE_INSENSITIVE): New macro.
+
+       * include/grub/types.h (LONG_MAX): Likewise.
+
 2008-09-04  Felix Zielcke  <fzielcke@z-51.de>
 
        * util/getroot.c: Include <config.h>.
index df33fa1fad67d4bef9b5882ab2a09d13ee5cd237..a5eccdd682df33f955128273dfe0a74fd52d8b9b 100644 (file)
@@ -80,14 +80,17 @@ 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))
+         if (filetype == GRUB_FSHELP_UNKNOWN ||
+              (grub_strcmp (name, filename) &&
+               (! (filetype & GRUB_FSHELP_CASE_INSENSITIVE) ||
+                grub_strncasecmp (name, filename, LONG_MAX))))
            {
              grub_free (node);
              return 0;
            }
          
          /* The node is found, stop iterating over the nodes.  */
-         type = filetype;
+         type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE;
          oldnode = currnode;
          currnode = node;
          
index 3174ab18174dbd562825a06657b5cb3bc6fe79ec..a590ade1ee0089ab5c101d5778356d64218e4512 100644 (file)
--- 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);
index 698c7aae76a2103f7613f3abc963eb05e37b624d..7092cac45faf9de5ffdcaa531e1bd56af927b138 100644 (file)
@@ -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,
index d2044292dad5dbf246c499f03eb9a4a46a64e9b2..6f256c1651d8fc06c386215165d7c3ea5d013983 100644 (file)
@@ -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.  */