grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] fix calculation of 2nd superblock position.


From: Jiro SEKIBA
Subject: [PATCH] fix calculation of 2nd superblock position.
Date: Wed, 07 Jul 2010 20:39:42 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/22.3 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI)

Hi,

This patch fixes calculation of 2nd superblock position.

nilfs2 has two super blocks, the 1st one is at beginning of the partition,
the 2nd one is the end of partition.  2nd one resides at last 4k block.
However when the partition size is not a multiple of 4k bytes, the
remainder will be ignored.

2010-07-07  Jiro SEKIBA <address@hidden>

            * fs/nilfs2.c: fix macro NILFS_2ND_SUPER_BLOCK to calculate
              2nd superblock position from partition size.


=== modified file 'fs/nilfs2.c'
--- fs/nilfs2.c 2010-05-31 18:49:42 +0000
+++ fs/nilfs2.c 2010-07-07 10:58:13 +0000
@@ -52,9 +52,9 @@
 /* nilfs 1st super block posission from beginning of the partition
    in 512 block size */
 #define NILFS_1ST_SUPER_BLOCK  2
-/* nilfs 2nd super block posission from end of the partition
+/* nilfs 2nd super block posission from beginning of the partition
    in 512 block size */
-#define NILFS_2ND_SUPER_BLOCK  8
+#define NILFS_2ND_SUPER_BLOCK(devsize) (((devsize >> 3) - 1) << 3)
 
 struct grub_nilfs2_inode
 {
@@ -729,7 +729,7 @@
   if (partition_size != GRUB_DISK_SIZE_UNKNOWN)
     {
       /* Read second super block. */
-      grub_disk_read (disk, partition_size - NILFS_2ND_SUPER_BLOCK, 0,
+      grub_disk_read (disk, NILFS_2ND_SUPER_BLOCK (partition_size), 0,
                      sizeof (struct grub_nilfs2_super_block), &sb2);
       /* Make sure if 2nd super block is valid.  */
       valid[1] = grub_nilfs2_valid_sb (&sb2);


-- 
Jiro SEKIBA <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]