From 34231b28cbb6b2e10d7668c5b6d2432e8563bd1d Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 5 Jun 2014 20:56:21 +0200 Subject: [PATCH 1/4] xfs: Add helper for inode size Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 16ffd3f1ebd9..a2fc942707c1 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -255,6 +255,11 @@ grub_xfs_inode_offset (struct grub_xfs_data *data, data->sblock.log2_inode); } +static inline int +grub_xfs_inode_size(struct grub_xfs_data *data) +{ + return 1 << data->sblock.log2_inode; +} static grub_err_t grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, @@ -264,8 +269,8 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, int offset = grub_xfs_inode_offset (data, ino); /* Read the inode. */ - if (grub_disk_read (data->disk, block, offset, - 1 << data->sblock.log2_inode, inode)) + if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data), + inode)) return grub_errno; if (grub_strncmp ((char *) inode->magic, "IN", 2)) @@ -297,7 +302,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (node->inode.fork_offset) recoffset = (node->inode.fork_offset - 1) / 2; else - recoffset = ((1 << node->data->sblock.log2_inode) + recoffset = (grub_xfs_inode_size(node->data) - ((char *) &node->inode.data.btree.keys - (char *) &node->inode)) / (2 * sizeof (grub_uint64_t)); @@ -458,7 +463,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename, fdiro = grub_malloc (sizeof (struct grub_fshelp_node) - sizeof (struct grub_xfs_inode) - + (1 << ctx->diro->data->sblock.log2_inode) + 1); + + grub_xfs_inode_size(ctx->diro->data) + 1); if (!fdiro) { grub_print_error (); @@ -684,7 +689,7 @@ grub_xfs_mount (grub_disk_t disk) data = grub_realloc (data, sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) - + (1 << data->sblock.log2_inode) + 1); + + grub_xfs_inode_size(data) + 1); if (! data) goto fail; @@ -802,7 +807,7 @@ grub_xfs_open (struct grub_file *file, const char *name) grub_memcpy (&data->diropen, fdiro, sizeof (struct grub_fshelp_node) - sizeof (struct grub_xfs_inode) - + (1 << data->sblock.log2_inode)); + + grub_xfs_inode_size(data)); grub_free (fdiro); } -- 1.8.1.4