* grub-core/fs/jfs.c: Remove nested functions.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-02-28 10:51:32 +01:00
parent be42d97a79
commit 4fc40ff8f3
2 changed files with 65 additions and 60 deletions

View file

@ -1,3 +1,7 @@
2013-02-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/jfs.c: Remove nested functions.
2013-02-28 Vladimir Serbinenko <phcoder@gmail.com> 2013-02-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/minix.c: Remove nested functions. * grub-core/fs/minix.c: Remove nested functions.

View file

@ -255,60 +255,60 @@ static grub_dl_t my_mod;
static grub_err_t grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino); static grub_err_t grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino);
static grub_int64_t
getblk (struct grub_jfs_treehead *treehead,
struct grub_jfs_tree_extent *extents,
struct grub_jfs_data *data,
grub_uint64_t blk)
{
int found = -1;
int i;
for (i = 0; i < grub_le_to_cpu16 (treehead->count) - 2; i++)
{
if (treehead->flags & GRUB_JFS_TREE_LEAF)
{
/* Read the leafnode. */
if (grub_le_to_cpu32 (extents[i].offset2) <= blk
&& ((grub_le_to_cpu16 (extents[i].extent.length))
+ (extents[i].extent.length2 << 16)
+ grub_le_to_cpu32 (extents[i].offset2)) > blk)
return (blk - grub_le_to_cpu32 (extents[i].offset2)
+ grub_le_to_cpu32 (extents[i].extent.blk2));
}
else
if (blk >= grub_le_to_cpu32 (extents[i].offset2))
found = i;
}
if (found != -1)
{
struct
{
struct grub_jfs_treehead treehead;
struct grub_jfs_tree_extent extents[254];
} tree;
if (grub_disk_read (data->disk,
((grub_disk_addr_t) grub_le_to_cpu32 (extents[found].extent.blk2))
<< (grub_le_to_cpu16 (data->sblock.log2_blksz)
- GRUB_DISK_SECTOR_BITS), 0,
sizeof (tree), (char *) &tree))
return -1;
return getblk (&tree.treehead, &tree.extents[0], data, blk);
}
return -1;
}
/* Get the block number for the block BLK in the node INODE in the /* Get the block number for the block BLK in the node INODE in the
mounted filesystem DATA. */ mounted filesystem DATA. */
static grub_int64_t static grub_int64_t
grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode, grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode,
grub_uint64_t blk) grub_uint64_t blk)
{ {
auto grub_int64_t getblk (struct grub_jfs_treehead *treehead, return getblk (&inode->file.tree, &inode->file.extents[0], data, blk);
struct grub_jfs_tree_extent *extents);
grub_int64_t getblk (struct grub_jfs_treehead *treehead,
struct grub_jfs_tree_extent *extents)
{
int found = -1;
int i;
for (i = 0; i < grub_le_to_cpu16 (treehead->count) - 2; i++)
{
if (treehead->flags & GRUB_JFS_TREE_LEAF)
{
/* Read the leafnode. */
if (grub_le_to_cpu32 (extents[i].offset2) <= blk
&& ((grub_le_to_cpu16 (extents[i].extent.length))
+ (extents[i].extent.length2 << 16)
+ grub_le_to_cpu32 (extents[i].offset2)) > blk)
return (blk - grub_le_to_cpu32 (extents[i].offset2)
+ grub_le_to_cpu32 (extents[i].extent.blk2));
}
else
if (blk >= grub_le_to_cpu32 (extents[i].offset2))
found = i;
}
if (found != -1)
{
struct
{
struct grub_jfs_treehead treehead;
struct grub_jfs_tree_extent extents[254];
} tree;
if (grub_disk_read (data->disk,
((grub_disk_addr_t) grub_le_to_cpu32 (extents[found].extent.blk2))
<< (grub_le_to_cpu16 (data->sblock.log2_blksz)
- GRUB_DISK_SECTOR_BITS), 0,
sizeof (tree), (char *) &tree))
return -1;
return getblk (&tree.treehead, &tree.extents[0]);
}
return -1;
}
return getblk (&inode->file.tree, &inode->file.extents[0]);
} }
@ -489,6 +489,13 @@ grub_jfs_closedir (struct grub_jfs_diropen *diro)
grub_free (diro); grub_free (diro);
} }
static void
le_to_cpu16_copy (grub_uint16_t *out, grub_uint16_t *in, grub_size_t len)
{
while (len--)
*out++ = grub_le_to_cpu16 (*in++);
}
/* Read in the next dirent from the directory described by DIRO. */ /* Read in the next dirent from the directory described by DIRO. */
static grub_err_t static grub_err_t
@ -501,15 +508,6 @@ grub_jfs_getent (struct grub_jfs_diropen *diro)
int nextent; int nextent;
grub_uint16_t filename[256]; grub_uint16_t filename[256];
auto void addstr (grub_uint16_t *uname, int ulen);
/* Add the unicode string to the utf16 filename buffer. */
void addstr (grub_uint16_t *name, int ulen)
{
while (ulen--)
filename[strpos++] = grub_le_to_cpu16 (*(name++));
}
/* The last node, read in more. */ /* The last node, read in more. */
if (diro->index == diro->count) if (diro->index == diro->count)
{ {
@ -547,8 +545,10 @@ grub_jfs_getent (struct grub_jfs_diropen *diro)
return grub_jfs_getent (diro); return grub_jfs_getent (diro);
} }
addstr (leaf->namepart, len < diro->data->namecomponentlen ? len le_to_cpu16_copy (filename + strpos, leaf->namepart, len < diro->data->namecomponentlen ? len
: diro->data->namecomponentlen); : diro->data->namecomponentlen);
strpos += len < diro->data->namecomponentlen ? len
: diro->data->namecomponentlen;
diro->ino = grub_le_to_cpu32 (leaf->inode); diro->ino = grub_le_to_cpu32 (leaf->inode);
len -= diro->data->namecomponentlen; len -= diro->data->namecomponentlen;
@ -558,7 +558,8 @@ grub_jfs_getent (struct grub_jfs_diropen *diro)
do do
{ {
next_leaf = &diro->next_leaf[nextent]; next_leaf = &diro->next_leaf[nextent];
addstr (next_leaf->namepart, len < 15 ? len : 15 ); le_to_cpu16_copy (filename + strpos, next_leaf->namepart, len < 15 ? len : 15);
strpos += len < 15 ? len : 15;
len -= 15; len -= 15;
nextent = next_leaf->next; nextent = next_leaf->next;