dump.f2fs: remove unavailable optiont -g
PATCH 1/4 dump.f2fs: remove unavailable optiont -g
Option "-g" for dump.f2fs is unavailable and not used in dump.f2fs.
--- fsck/main.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
fsck/main.c +3 -9
@@ -273,8 +273,10 @@ void f2fs_parse_options(int argc, char *argv[])atoi (optarg);break ;case 'g' : -if (!strcmp (optarg,"android" )) +if (!strcmp (optarg,"android" )) { c.defset =CONF_ANDROID ; +MSG (0 ,"Info: Set conf for android\n" ); + }break ;case 'l' : c.layout =1 ;
@@ -409,14 +411,6 @@ void f2fs_parse_options(int argc, char *argv[])MSG (0 ,"Info: Debug level = %d\n" , c.dbg_lv);break ; -case 'g' : -if (!strcmp (optarg,"android" )) { - c.defset =CONF_ANDROID ; -MSG (0 ,"Info: Set conf for android\n" ); -break ; - } - err =EWRONG_OPT ; -break ;case 'i' :if (strncmp (optarg,"0x" ,2 )) ret = sscanf(optarg, "%d",
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 2/4 fsck.f2fs: add parentheses for SB_MASK
--- fsck/fsck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/fsck.h +1 -1
@@ -50,7 +50,7 @@ enum SB_ADDR { SB_MAX_ADDR, }; -#define SB_MASK (i) (1 << i) +#define SB_MASK (i) (1 << (i))#define SB_MASK_ALL (SB_MASK(SB0_ADDR) | SB_MASK(SB1_ADDR))/* fsck.c */
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK
Quoted 1 line · Sheng Yong
Signed-off-by Sheng Yong <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 3/4 fsck.f2fs: fix potential overflow of copying i_name
In reply to Sheng Yong via Linux-f2fs-develIf i_namelen is corrupted, there may be an overflow when doing memcpy.
--- fsck/fsck.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fsck/fsck.c +4 -2
@@ -742,8 +742,10 @@ check_next:if (ftype ==F2FS_FT_DIR ) {f2fs_set_main_bitmap (sbi, ni->blk_addr,CURSEG_HOT_NODE ); -memcpy (child.p_name, node_blk->i.i_name, - node_blk->i.i_namelen); + namelen =le32_to_cpu (node_blk->i.i_namelen); +if (namelen >F2FS_NAME_LEN ) + namelen =F2FS_NAME_LEN ; +memcpy (child.p_name, node_blk->i.i_name, namelen); }else {if (f2fs_test_main_bitmap (sbi, ni->blk_addr) ==0 ) { f2fs_set_main_bitmap(sbi, ni->blk_addr,
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/4] fsck.f2fs: fix potential overflow of copying i_name
Quoted 3 lines · Sheng Yong
If
i_namelenis corrupted, there may be an overflow when doing memcpy.Signed-off-by Sheng Yong <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 4/4 fsck.f2fs: avoid uncessary recalculation
In reply to Sheng Yong via Linux-f2fs-develThere is no need to recalculate ADDRS_PER_INODE and ADDRS_PER_BLOCK, especially in a for loop.
--- fsck/fsck.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
fsck/fsck.c +9 -10
@@ -706,7 +706,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,int ofs;char *en;u32 namelen; -unsigned int idx =0 ; +unsigned int addrs, idx =0 ;unsigned short i_gc_failures;int need_fix =0 ;int ret;
@@ -932,17 +932,16 @@ check_next: }/* check data blocks in inode */ + addrs =ADDRS_PER_INODE (&node_blk->i);if (cur_qtype !=-1 ) { +unsigned int addrs_per_blk =ADDRS_PER_BLOCK (&node_blk->i); qf_szchk_type[cur_qtype] =QF_SZCHK_REGFILE ; - qf_maxsize[cur_qtype] = (ADDRS_PER_INODE (&node_blk->i) + -2 *ADDRS_PER_BLOCK (&node_blk->i) + -2 *ADDRS_PER_BLOCK (&node_blk->i) * -NIDS_PER_BLOCK + - (u64 )ADDRS_PER_BLOCK (&node_blk->i) * -NIDS_PER_BLOCK *NIDS_PER_BLOCK ) *F2FS_BLKSIZE ; - } -for (idx =0 ; idx <ADDRS_PER_INODE (&node_blk->i); - idx++, child.pgofs++) { + qf_maxsize[cur_qtype] = (addrs +2 * addrs_per_blk + +2 * addrs_per_blk *NIDS_PER_BLOCK + + (u64 ) addrs_per_blk *NIDS_PER_BLOCK * +NIDS_PER_BLOCK ) *F2FS_BLKSIZE ; + } +for (idx =0 ; idx < addrs; idx++, child.pgofs++) {block_t blkaddr =le32_to_cpu (node_blk->i.i_addr[ofs + idx]);/* check extent info */
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 4/4] fsck.f2fs: avoid uncessary recalculation
Quoted 29 lines · Sheng Yong
There is no need to recalculate
ADDRS_PER_INODEandADDRS_PER_BLOCK, especially in a for loop.Signed-off-by Sheng Yong <[email protected]>--- fsck/fsck.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)fsck/fsck.c +3
-1@@ -706,7 +706,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,int ofs;char *en;u32 namelen; -unsigned int idx =0 ; +unsigned int addrs, idx =0 ;unsigned short i_gc_failures;int need_fix =0 ;int ret;@@ -932,17 +932,16 @@ check_next: }/* check data blocks in inode */ + addrs =ADDRS_PER_INODE (&node_blk->i);if (cur_qtype !=-1 ) { +unsigned int addrs_per_blk =ADDRS_PER_BLOCK (&node_blk->i); qf_szchk_type[cur_qtype] =QF_SZCHK_REGFILE ;
fsck/fsck.c check_next: · line 939
Quoted 10 lines
fsck/fsck.c +1
-9- qf_maxsize[cur_qtype] = (ADDRS_PER_INODE (&node_blk->i) + -2 *ADDRS_PER_BLOCK (&node_blk->i) + -2 *ADDRS_PER_BLOCK (&node_blk->i) * -NIDS_PER_BLOCK + - (u64 )ADDRS_PER_BLOCK (&node_blk->i) * -NIDS_PER_BLOCK *NIDS_PER_BLOCK ) *F2FS_BLKSIZE ; - } -for (idx =0 ; idx <ADDRS_PER_INODE (&node_blk->i); - idx++, child.pgofs++) { + qf_maxsize[cur_qtype] = (addrs + 2 * addrs_per_blk +
u64(addrs + 2 * addrs_per_blk +
Otherwise, the result may overflow...
Thanks,
fsck/fsck.c check_next: · line 947
Quoted 8 lines
fsck/fsck.c +5
-0+2 * addrs_per_blk *NIDS_PER_BLOCK + + (u64 ) addrs_per_blk *NIDS_PER_BLOCK * + NIDS_PER_BLOCK) * F2FS_BLKSIZE; + } +for (idx =0 ; idx < addrs; idx++, child.pgofs++) {block_t blkaddr =le32_to_cpu (node_blk->i.i_addr[ofs + idx]);/* check extent info */
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH v2 1/1 fsck.f2fs: avoid uncessary recalculation
There is no need to recalculate ADDRS_PER_INODE and ADDRS_PER_BLOCK, especially in a for loop.
--- fsck/fsck.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
fsck/fsck.c +9 -10
@@ -706,7 +706,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,int ofs;char *en;u32 namelen; -unsigned int idx =0 ; +unsigned int addrs, idx =0 ;unsigned short i_gc_failures;int need_fix =0 ;int ret;
@@ -932,17 +932,16 @@ check_next: }/* check data blocks in inode */ + addrs =ADDRS_PER_INODE (&node_blk->i);if (cur_qtype !=-1 ) { +u64 addrs_per_blk = (u64 )ADDRS_PER_BLOCK (&node_blk->i); qf_szchk_type[cur_qtype] =QF_SZCHK_REGFILE ; - qf_maxsize[cur_qtype] = (ADDRS_PER_INODE (&node_blk->i) + -2 *ADDRS_PER_BLOCK (&node_blk->i) + -2 *ADDRS_PER_BLOCK (&node_blk->i) * -NIDS_PER_BLOCK + - (u64 )ADDRS_PER_BLOCK (&node_blk->i) * -NIDS_PER_BLOCK *NIDS_PER_BLOCK ) *F2FS_BLKSIZE ; - } -for (idx =0 ; idx <ADDRS_PER_INODE (&node_blk->i); - idx++, child.pgofs++) { + qf_maxsize[cur_qtype] = (u64)(addrs +2 * addrs_per_blk + +2 * addrs_per_blk *NIDS_PER_BLOCK + + addrs_per_blk *NIDS_PER_BLOCK * +NIDS_PER_BLOCK ) *F2FS_BLKSIZE ; + } +for (idx =0 ; idx < addrs; idx++, child.pgofs++) {block_t blkaddr =le32_to_cpu (node_blk->i.i_addr[ofs + idx]);/* check extent info */
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH v2] fsck.f2fs: avoid uncessary recalculation
Quoted 4 lines · Sheng Yong
There is no need to recalculate
ADDRS_PER_INODEandADDRS_PER_BLOCK, especially in a for loop.Signed-off-by Sheng Yong <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 3 lines · Sheng Yong
Option "-g" for dump.f2fs is unavailable and not used in dump.f2fs.
Signed-off-by Sheng Yong <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel