* grub-core/fs/hfsplus.c (grub_hfsplus_catfile): New field parentid.
(grub_hfsplus_iterate_dir): Add "." and "..".
This commit is contained in:
parent
fc977f485f
commit
df042ccb21
2 changed files with 47 additions and 12 deletions
|
@ -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 "..".
|
||||
|
|
|
@ -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,7 +796,9 @@ 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)
|
||||
{
|
||||
case grub_cpu_to_be16_compile_time (GRUB_HFSPLUS_FILETYPE_REG):
|
||||
{
|
||||
int mode = (grub_be_to_cpu16 (fileinfo->mode)
|
||||
& GRUB_HFSPLUS_FILEMODE_MASK);
|
||||
|
@ -807,9 +809,25 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
|
|||
type = GRUB_FSHELP_SYMLINK;
|
||||
else
|
||||
type = GRUB_FSHELP_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
else if (grub_be_to_cpu16 (fileinfo->type) == GRUB_HFSPLUS_FILETYPE_DIR)
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue