@@ -846,7 +846,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
846
846
struct ntfs_sb_info * sbi = sb -> s_fs_info ;
847
847
int err ;
848
848
u32 mb , gb , boot_sector_size , sct_per_clst , record_size ;
849
- u64 sectors , clusters , mlcn , mlcn2 ;
849
+ u64 sectors , clusters , mlcn , mlcn2 , dev_size0 ;
850
850
struct NTFS_BOOT * boot ;
851
851
struct buffer_head * bh ;
852
852
struct MFT_REC * rec ;
@@ -855,6 +855,9 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
855
855
u32 boot_off = 0 ;
856
856
const char * hint = "Primary boot" ;
857
857
858
+ /* Save original dev_size. Used with alternative boot. */
859
+ dev_size0 = dev_size ;
860
+
858
861
sbi -> volume .blocks = dev_size >> PAGE_SHIFT ;
859
862
860
863
bh = ntfs_bread (sb , 0 );
@@ -1087,9 +1090,9 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
1087
1090
}
1088
1091
1089
1092
out :
1090
- if (err == - EINVAL && !bh -> b_blocknr && dev_size > PAGE_SHIFT ) {
1093
+ if (err == - EINVAL && !bh -> b_blocknr && dev_size0 > PAGE_SHIFT ) {
1091
1094
u32 block_size = min_t (u32 , sector_size , PAGE_SIZE );
1092
- u64 lbo = dev_size - sizeof (* boot );
1095
+ u64 lbo = dev_size0 - sizeof (* boot );
1093
1096
1094
1097
/*
1095
1098
* Try alternative boot (last sector)
@@ -1103,6 +1106,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
1103
1106
1104
1107
boot_off = lbo & (block_size - 1 );
1105
1108
hint = "Alternative boot" ;
1109
+ dev_size = dev_size0 ; /* restore original size. */
1106
1110
goto check_boot ;
1107
1111
}
1108
1112
brelse (bh );
0 commit comments