grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: grub-devel@gnu.org
Cc: Jan Kara <jack@suse.cz>
Subject: [PATCH 1/4] xfs: Add helper for inode size
Date: Mon, 14 Jul 2014 17:21:28 +0200	[thread overview]
Message-ID: <1405351291-24767-2-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1405351291-24767-1-git-send-email-jack@suse.cz>

Signed-off-by: Jan Kara <jack@suse.cz>
---
 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



  reply	other threads:[~2014-07-14 15:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14 15:21 [PATCH 0/4] Support for XFS v5 superblock Jan Kara
2014-07-14 15:21 ` Jan Kara [this message]
2015-05-11 11:53   ` [PATCH 1/4] xfs: Add helper for inode size Andrei Borzenkov
2015-05-11 12:15     ` Jan Kara
2015-05-12  5:26       ` Andrei Borzenkov
2015-05-12  8:07         ` Jan Kara
2014-07-14 15:21 ` [PATCH 2/4] xfs: Fix termination loop for directory iteration Jan Kara
2015-05-11 11:49   ` Andrei Borzenkov
2014-07-14 15:21 ` [PATCH 3/4] xfs: Convert inode numbers to cpu endianity immediately after reading Jan Kara
2015-05-12  5:22   ` Andrei Borzenkov
2014-07-14 15:21 ` [PATCH 4/4] xfs: V5 filesystem format support Jan Kara
2015-05-12  5:23   ` Andrei Borzenkov
2015-05-12 13:47     ` Jan Kara
2015-05-13  4:50       ` Andrei Borzenkov
2015-05-13  7:12         ` Jan Kara
2014-07-21 17:31 ` [PATCH 0/4] Support for XFS v5 superblock Jan Kara
2014-07-21 21:42   ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-09-23  7:39 ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405351291-24767-2-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).