|
Kmods SIG |
d83023 |
From dbf59e2a33d2cb5ae0534523fd3d6d8bda808be8 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
d83023 |
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
d83023 |
Date: Tue, 28 Sep 2021 19:19:49 +0300
|
|
Kmods SIG |
d83023 |
Subject: [Backport dbf59e2a33d2] src: Refactoring of ntfs_init_from_boot
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
Remove ntfs_sb_info members sector_size and sector_bits.
|
|
Kmods SIG |
d83023 |
Print details why mount failed.
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
Reviewed-by: Kari Argillander <kari.argillander@gmail.com>
|
|
Kmods SIG |
d83023 |
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
d83023 |
---
|
|
Kmods SIG |
d83023 |
src/ntfs_fs.h | 2 --
|
|
Kmods SIG |
d83023 |
src/super.c | 19 +++++++++----------
|
|
Kmods SIG |
d83023 |
2 files changed, 9 insertions(+), 12 deletions(-)
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
diff --git a/src/ntfs_fs.h b/src/ntfs_fs.h
|
|
Kmods SIG |
d83023 |
index 6731b5d9e2d8efc742ce2200528e81eb22cbfa6e..38b7c1a9dc5209badca36b6a7cb8a2b38845b2e9 100644
|
|
Kmods SIG |
d83023 |
--- a/src/ntfs_fs.h
|
|
Kmods SIG |
d83023 |
+++ b/src/ntfs_fs.h
|
|
Kmods SIG |
d83023 |
@@ -211,10 +211,8 @@ struct ntfs_sb_info {
|
|
Kmods SIG |
d83023 |
u32 blocks_per_cluster; // cluster_size / sb->s_blocksize
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
u32 record_size;
|
|
Kmods SIG |
d83023 |
- u32 sector_size;
|
|
Kmods SIG |
d83023 |
u32 index_size;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
- u8 sector_bits;
|
|
Kmods SIG |
d83023 |
u8 cluster_bits;
|
|
Kmods SIG |
d83023 |
u8 record_bits;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
diff --git a/src/super.c b/src/super.c
|
|
Kmods SIG |
d83023 |
index e9b6a37345769700f682809832d84d8dfc7b9414..705d8b4f4894fbcc63f018e41437a54d6a0e1e6f 100644
|
|
Kmods SIG |
d83023 |
--- a/src/super.c
|
|
Kmods SIG |
d83023 |
+++ b/src/super.c
|
|
Kmods SIG |
d83023 |
@@ -682,7 +682,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
|
|
Kmods SIG |
d83023 |
struct ntfs_sb_info *sbi = sb->s_fs_info;
|
|
Kmods SIG |
d83023 |
int err;
|
|
Kmods SIG |
d83023 |
u32 mb, gb, boot_sector_size, sct_per_clst, record_size;
|
|
Kmods SIG |
d83023 |
- u64 sectors, clusters, fs_size, mlcn, mlcn2;
|
|
Kmods SIG |
d83023 |
+ u64 sectors, clusters, mlcn, mlcn2;
|
|
Kmods SIG |
d83023 |
struct NTFS_BOOT *boot;
|
|
Kmods SIG |
d83023 |
struct buffer_head *bh;
|
|
Kmods SIG |
d83023 |
struct MFT_REC *rec;
|
|
Kmods SIG |
d83023 |
@@ -740,20 +740,20 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
|
|
Kmods SIG |
d83023 |
goto out;
|
|
Kmods SIG |
d83023 |
}
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
- sbi->sector_size = boot_sector_size;
|
|
Kmods SIG |
d83023 |
- sbi->sector_bits = blksize_bits(boot_sector_size);
|
|
Kmods SIG |
d83023 |
- fs_size = (sectors + 1) << sbi->sector_bits;
|
|
Kmods SIG |
d83023 |
+ sbi->volume.size = sectors * boot_sector_size;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
- gb = format_size_gb(fs_size, &mb;;
|
|
Kmods SIG |
d83023 |
+ gb = format_size_gb(sbi->volume.size + boot_sector_size, &mb;;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
/*
|
|
Kmods SIG |
d83023 |
* - Volume formatted and mounted with the same sector size.
|
|
Kmods SIG |
d83023 |
* - Volume formatted 4K and mounted as 512.
|
|
Kmods SIG |
d83023 |
* - Volume formatted 512 and mounted as 4K.
|
|
Kmods SIG |
d83023 |
*/
|
|
Kmods SIG |
d83023 |
- if (sbi->sector_size != sector_size) {
|
|
Kmods SIG |
d83023 |
- ntfs_warn(sb,
|
|
Kmods SIG |
d83023 |
- "Different NTFS' sector size and media sector size");
|
|
Kmods SIG |
d83023 |
+ if (boot_sector_size != sector_size) {
|
|
Kmods SIG |
d83023 |
+ ntfs_warn(
|
|
Kmods SIG |
d83023 |
+ sb,
|
|
Kmods SIG |
d83023 |
+ "Different NTFS' sector size (%u) and media sector size (%u)",
|
|
Kmods SIG |
d83023 |
+ boot_sector_size, sector_size);
|
|
Kmods SIG |
d83023 |
dev_size += sector_size - 1;
|
|
Kmods SIG |
d83023 |
}
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
@@ -800,10 +800,9 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
|
|
Kmods SIG |
d83023 |
: (u32)boot->index_size << sbi->cluster_bits;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
sbi->volume.ser_num = le64_to_cpu(boot->serial_num);
|
|
Kmods SIG |
d83023 |
- sbi->volume.size = sectors << sbi->sector_bits;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
/* Warning if RAW volume. */
|
|
Kmods SIG |
d83023 |
- if (dev_size < fs_size) {
|
|
Kmods SIG |
d83023 |
+ if (dev_size < sbi->volume.size + boot_sector_size) {
|
|
Kmods SIG |
d83023 |
u32 mb0, gb0;
|
|
Kmods SIG |
d83023 |
|
|
Kmods SIG |
d83023 |
gb0 = format_size_gb(dev_size, &mb0);
|
|
Kmods SIG |
d83023 |
--
|
|
Kmods SIG |
d83023 |
2.31.1
|
|
Kmods SIG |
d83023 |
|