All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] support of hfsx ( case comparaison )
@ 2009-01-12 21:52 Michael Scherer
  2009-02-07 21:02 ` Robert Millan
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Scherer @ 2009-01-12 21:52 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

Hi,

Here is the second patch, for hfsx support. This patch replace the  
precedent.

It is slightly more complex, and I didn't tested it on hfsx as I do  
not have a proper partition.
But so far, it detect correctly config file on hfsplus.

-- 
Michael Scherer


[-- Attachment #2: grub.hfsx.support.diff --]
[-- Type: application/octet-stream, Size: 3127 bytes --]

diff --git a/ChangeLog b/ChangeLog
index b77f438..d52d8ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-12  Michael Scherer  <misc@mandriva.org>
+
+	* fs/hfsplus.c: Complete support of hfs+ and hfsx, by doing
+	case insensitive comparaison when needed ( ie for hfsplus, and depending
+	on some settings for hfsx, found in the header )
+
 2009-01-12  Christian Franke  <franke@computer.org>
 
 	* disk/ata.c (grub_ata_pciinit): Fix bit numbers of compatibility
diff --git a/fs/hfsplus.c b/fs/hfsplus.c
index e6493ce..3302724 100644
--- a/fs/hfsplus.c
+++ b/fs/hfsplus.c
@@ -96,6 +96,13 @@ struct grub_hfsplus_btheader
   grub_uint32_t last_leaf_node;
   grub_uint16_t nodesize;
   grub_uint16_t keysize;
+  grub_uint32_t total_nodes;
+  grub_uint32_t free_nodes;
+  grub_uint16_t reserved1;
+  grub_uint32_t clump_size;  // ignored
+  grub_uint8_t btree_type;
+  grub_uint8_t key_compare;
+  grub_uint32_t attributes;
 } __attribute__ ((packed));
 
 /* The on disk layout of a catalog key.  */
@@ -159,6 +166,9 @@ enum grub_hfsplus_filetype
     GRUB_HFSPLUS_FILETYPE_REG_THREAD = 4
   };
 
+#define GRUB_HFSPLUSX_BINARYCOMPARE 0xCF
+#define GRUB_HFSPLUSX_CASEFOLDING   0xBC
+
 /* Internal representation of a catalog key.  */
 struct grub_hfsplus_catkey_internal
 {
@@ -218,6 +228,7 @@ struct grub_hfsplus_data
   /* This is the offset into the physical disk for an embedded HFS+
      filesystem (one inside a plain HFS wrapper).  */
   int embedded_offset;
+  int catalog_cmp_key;
 };
 
 #ifndef GRUB_UTIL
@@ -460,6 +471,7 @@ grub_hfsplus_mount (grub_disk_t disk)
 
   data->catalog_tree.root = grub_be_to_cpu32 (header.root);
   data->catalog_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
+  data->catalog_cmp_key = header.key_compare;
 
   if (! grub_hfsplus_read_file (&data->extoverflow_tree.file, 0,
 				sizeof (struct grub_hfsplus_btnode),
@@ -691,6 +703,20 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
 }
 
 static int
+grub_hfsplus_is_case_insentive (struct grub_hfsplus_data *data)
+{
+  switch (grub_be_to_cpu16 (data->volheader.magic))
+    {
+      case GRUB_HFSPLUS_MAGIC:
+        return 1;
+      case GRUB_HFSPLUSX_MAGIC:
+        return data->catalog_cmp_key == GRUB_HFSPLUSX_CASEFOLDING;
+      default:
+        return 0;
+    }
+}
+
+static int
 grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
 			  int NESTED_FUNC_ATTR
 			  (*hook) (const char *filename,
@@ -698,6 +724,7 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
 				   grub_fshelp_node_t node))
 {
   int ret = 0;
+  int fs_case_insensitive = grub_hfsplus_is_case_insentive(dir->data);
   
   auto int list_nodes (void *record);
   int list_nodes (void *record)
@@ -767,6 +794,10 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
       for (i = 0; i < grub_be_to_cpu16 (catkey->namelen); i++)
 	catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]);
 
+      /* hfs+ is case insensitive */
+      if (fs_case_insensitive)
+          type |= GRUB_FSHELP_CASE_INSENSITIVE;
+
       /* Only accept valid nodes.  */
       if (grub_strlen (filename) == grub_be_to_cpu16 (catkey->namelen))
 	{

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-06-07 17:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-12 21:52 [PATCH] support of hfsx ( case comparaison ) Michael Scherer
2009-02-07 21:02 ` Robert Millan
2009-05-03 17:19   ` Michael Scherer
2009-06-01 10:11     ` Vladimir 'phcoder' Serbinenko
2009-06-03  7:56       ` Michael Scherer
2009-06-03  9:26         ` Vladimir 'phcoder' Serbinenko
2009-06-03 10:54           ` Michael Scherer
2009-06-03 21:23             ` Pavel Roskin
2009-06-05 19:23               ` Michael Scherer
2009-06-05 19:46                 ` Vladimir 'phcoder' Serbinenko
2009-06-07  2:18                   ` Pavel Roskin
2009-06-07  9:10                     ` Vladimir 'phcoder' Serbinenko
2009-06-07 17:40                       ` Pavel Roskin
2009-06-05 21:08                 ` Pavel Roskin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.