]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/fs/hfsplus.c (grub_hfsplus_catfile): New field parentid.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 26 May 2012 22:56:55 +0000 (00:56 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 26 May 2012 22:56:55 +0000 (00:56 +0200)
(grub_hfsplus_iterate_dir): Add "." and "..".

ChangeLog
grub-core/fs/hfsplus.c

index 07cb1a78557fc359b7a73490c393369b2f6cad68..4575205c03a301d633992d358ff7772938b38a30 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-27  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/fs/hfsplus.c (grub_hfsplus_catfile): New field parentid.
+       (grub_hfsplus_iterate_dir): Add "." and "..".
+
 2012-05-27  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/cpio.c (canonicalize): Handle "..".
index 42b2c01f1d6a3f49a21faaa958b1ce60b5da24cd..9812464752ada1010359488e7dec2230851a97b6 100644 (file)
@@ -144,7 +144,7 @@ struct grub_hfsplus_catfile
 {
   grub_uint16_t type;
   grub_uint16_t flags;
-  grub_uint32_t reserved;
+  grub_uint32_t parentid; /* Thread only.  */
   grub_uint32_t fileid;
   grub_uint8_t unused1[4];
   grub_uint32_t mtime;
@@ -796,20 +796,38 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
        return 1;
 
       /* Determine the type of the node that is found.  */
-      if (grub_be_to_cpu16 (fileinfo->type) == GRUB_HFSPLUS_FILETYPE_REG)
+      switch (fileinfo->type)
        {
-         int mode = (grub_be_to_cpu16 (fileinfo->mode)
-                     & GRUB_HFSPLUS_FILEMODE_MASK);
-
-         if (mode == GRUB_HFSPLUS_FILEMODE_REG)
-           type = GRUB_FSHELP_REG;
-         else if (mode == GRUB_HFSPLUS_FILEMODE_SYMLINK)
-           type = GRUB_FSHELP_SYMLINK;
-         else
-           type = GRUB_FSHELP_UNKNOWN;
+       case grub_cpu_to_be16_compile_time (GRUB_HFSPLUS_FILETYPE_REG):
+         {
+           int mode = (grub_be_to_cpu16 (fileinfo->mode)
+                       & GRUB_HFSPLUS_FILEMODE_MASK);
+
+           if (mode == GRUB_HFSPLUS_FILEMODE_REG)
+             type = GRUB_FSHELP_REG;
+           else if (mode == GRUB_HFSPLUS_FILEMODE_SYMLINK)
+             type = GRUB_FSHELP_SYMLINK;
+           else
+             type = GRUB_FSHELP_UNKNOWN;
+           break;
+         }
+       case grub_cpu_to_be16_compile_time (GRUB_HFSPLUS_FILETYPE_DIR):
+         type = GRUB_FSHELP_DIR;
+         break;
+       case grub_cpu_to_be16_compile_time (GRUB_HFSPLUS_FILETYPE_DIR_THREAD):
+         if (dir->fileid == 2)
+           return 0;
+         node = grub_malloc (sizeof (*node));
+         if (!node)
+           return 1;
+         node->data = dir->data;
+         node->mtime = 0;
+         node->size = 0;
+         node->fileid = grub_be_to_cpu32 (fileinfo->parentid);
+
+         ret = hook ("..", GRUB_FSHELP_DIR, node);
+         return ret;
        }
-      else if (grub_be_to_cpu16 (fileinfo->type) == GRUB_HFSPLUS_FILETYPE_DIR)
-       type = GRUB_FSHELP_DIR;
 
       if (type == GRUB_FSHELP_UNKNOWN)
        return 0;
@@ -850,6 +868,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
       /* A valid node is found; setup the node and call the
         callback function.  */
       node = grub_malloc (sizeof (*node));
+      if (!node)
+       return 1;
       node->data = dir->data;
 
       grub_memcpy (node->extents, fileinfo->data.extents,
@@ -869,6 +889,16 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
   struct grub_hfsplus_btnode *node;
   grub_disk_addr_t ptr;
 
+  {
+    struct grub_fshelp_node *fsnode;
+    fsnode = grub_malloc (sizeof (*fsnode));
+    if (!fsnode)
+      return 1;
+    *fsnode = *dir;
+    if (hook (".", GRUB_FSHELP_DIR, fsnode))
+      return 1;
+  }
+
   /* Create a key that points to the first entry in the directory.  */
   intern.catkey.parent = dir->fileid;
   intern.catkey.name = 0;