diff options
author | Chao Yu <chao@kernel.org> | 2023-05-12 18:03:51 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2023-05-17 18:28:40 -0700 |
commit | d92e06eedb64850831902b68dfb0bc6bfd4f87ba (patch) | |
tree | 2dc936d0e1660c5941d2902f541295c26210eb87 | |
parent | 6701168961ce2b96e09f65fa69b603cfcdb0eb52 (diff) | |
download | f2fs-tools-d92e06eedb64850831902b68dfb0bc6bfd4f87ba.tar.gz |
fsck.f2fs: wrap openned codes into fsck_sanity_check_nid()
read_all_xattrs() is the only user of fsck_sanity_check_nid(), wrap
openned codes of read_all_xattrs() into fsck_sanity_check_nid().
Then fsck_sanity_check_nid() can be reused later.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/fsck.c | 16 | ||||
-rw-r--r-- | fsck/fsck.h | 3 | ||||
-rw-r--r-- | fsck/xattr.c | 12 |
3 files changed, 14 insertions, 17 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index 324c3d5..64db1e5 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -515,11 +515,19 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid, } int fsck_sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid, - struct f2fs_node *node_blk, - enum FILE_TYPE ftype, enum NODE_TYPE ntype, - struct node_info *ni) + enum FILE_TYPE ftype, enum NODE_TYPE ntype) { - return sanity_check_nid(sbi, nid, node_blk, ftype, ntype, ni); + struct f2fs_node *node_blk = NULL; + struct node_info ni; + int ret; + + node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1); + ASSERT(node_blk != NULL); + + ret = sanity_check_nid(sbi, nid, node_blk, ftype, ntype, &ni); + + free(node_blk); + return ret; } static int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino, diff --git a/fsck/fsck.h b/fsck/fsck.h index dabd8b9..02dcff8 100644 --- a/fsck/fsck.h +++ b/fsck/fsck.h @@ -166,8 +166,7 @@ extern int fsck_chk_orphan_node(struct f2fs_sb_info *); extern int fsck_chk_quota_node(struct f2fs_sb_info *); extern int fsck_chk_quota_files(struct f2fs_sb_info *); extern int fsck_sanity_check_nid(struct f2fs_sb_info *, u32, - struct f2fs_node *, enum FILE_TYPE, enum NODE_TYPE, - struct node_info *); + enum FILE_TYPE, enum NODE_TYPE); extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32, enum FILE_TYPE, enum NODE_TYPE, u32 *, struct f2fs_compr_blk_cnt *, struct child_info *); diff --git a/fsck/xattr.c b/fsck/xattr.c index 8e66873..04c2879 100644 --- a/fsck/xattr.c +++ b/fsck/xattr.c @@ -25,17 +25,7 @@ void *read_all_xattrs(struct f2fs_sb_info *sbi, struct f2fs_node *inode) nid_t xnid = le32_to_cpu(inode->i.i_xattr_nid); if (c.func == FSCK && xnid) { - struct f2fs_node *node_blk = NULL; - struct node_info ni; - int ret; - - node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1); - ASSERT(node_blk != NULL); - - ret = fsck_sanity_check_nid(sbi, xnid, node_blk, - F2FS_FT_XATTR, TYPE_XATTR, &ni); - free(node_blk); - if (ret) + if (fsck_sanity_check_nid(sbi, xnid, F2FS_FT_XATTR, TYPE_XATTR)) return NULL; } |