[1852] 2008-09-05 Bean <[email protected]>

Bean <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 1852
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=1852
Author:   bean
Date:     2008-09-05 15:48:37 +0000 (Fri, 05 Sep 2008)

Log Message:
-----------
2008-09-05  Bean  <[email protected]>

	* 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.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/fs/fshelp.c
    trunk/grub2/fs/ntfs.c
    trunk/grub2/include/grub/fshelp.h
    trunk/grub2/include/grub/types.h

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2008-09-04 19:54:59 UTC (rev 1851)
+++ trunk/grub2/ChangeLog	2008-09-05 15:48:37 UTC (rev 1852)
@@ -1,3 +1,14 @@
+2008-09-05  Bean  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* util/getroot.c: Include <config.h>.

Modified: trunk/grub2/fs/fshelp.c
===================================================================
--- trunk/grub2/fs/fshelp.c	2008-09-04 19:54:59 UTC (rev 1851)
+++ trunk/grub2/fs/fshelp.c	2008-09-05 15:48:37 UTC (rev 1852)
@@ -80,14 +80,17 @@
 				    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;
 	  

Modified: trunk/grub2/fs/ntfs.c
===================================================================
--- trunk/grub2/fs/ntfs.c	2008-09-04 19:54:59 UTC (rev 1851)
+++ trunk/grub2/fs/ntfs.c	2008-09-05 15:48:37 UTC (rev 1852)
@@ -575,13 +575,20 @@
 
   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 @@
 	  *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);

Modified: trunk/grub2/include/grub/fshelp.h
===================================================================
--- trunk/grub2/include/grub/fshelp.h	2008-09-04 19:54:59 UTC (rev 1851)
+++ trunk/grub2/include/grub/fshelp.h	2008-09-05 15:48:37 UTC (rev 1852)
@@ -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,

Modified: trunk/grub2/include/grub/types.h
===================================================================
--- trunk/grub2/include/grub/types.h	2008-09-04 19:54:59 UTC (rev 1851)
+++ trunk/grub2/include/grub/types.h	2008-09-05 15:48:37 UTC (rev 1852)
@@ -94,8 +94,10 @@
 
 #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.  */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.