Test blkaddr is valid or not in option '-b'

Signed-off-by: Yunlei He <[email protected]>
---
 fsck/dump.c  | 9 +++++++++
 fsck/mount.c | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fsck/dump.c b/fsck/dump.c
index 9f0993e..7ccb03f 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -586,6 +586,8 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 
blk_addr)
        int type;
        struct f2fs_summary sum_entry;
        struct node_info ni, ino_ni;
+       struct seg_entry *se;
+       u32 offset;
        int ret = 0;
 
        MSG(0, "\n== Dump data from block address ==\n\n");
@@ -617,6 +619,13 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 
blk_addr)
                return ret;
        }
 
+       se = get_seg_entry(sbi, GET_SEGNO(sbi, blk_addr));
+       offset = OFFSET_IN_SEG(sbi, blk_addr);
+
+       if (f2fs_test_bit(offset, (const char *)se->cur_valid_map) == 0) {
+               MSG(0, "\nblkaddr is not valid\n");
+       }
+
        type = get_sum_entry(sbi, blk_addr, &sum_entry);
        nid = le32_to_cpu(sum_entry.nid);
 
diff --git a/fsck/mount.c b/fsck/mount.c
index 678eeae..665fa4b 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1869,7 +1869,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 
*to, int left, int type)
        struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
        struct seg_entry *se;
        u32 segno;
-       u64 offset;
+       u32 offset;
        int not_enough = 0;
        u64 end_blkaddr = (get_sb(segment_count_main) <<
                        get_sb(log_blocks_per_seg)) + get_sb(main_blkaddr);
-- 
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to