xref: /aosp_15_r20/external/f2fs-tools/fsck/fsck.h (revision 59bfda1f02d633cd6b8b69f31eee485d40f6eef6)
1*59bfda1fSAndroid Build Coastguard Worker /**
2*59bfda1fSAndroid Build Coastguard Worker  * fsck.h
3*59bfda1fSAndroid Build Coastguard Worker  *
4*59bfda1fSAndroid Build Coastguard Worker  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
5*59bfda1fSAndroid Build Coastguard Worker  *             http://www.samsung.com/
6*59bfda1fSAndroid Build Coastguard Worker  *
7*59bfda1fSAndroid Build Coastguard Worker  * This program is free software; you can redistribute it and/or modify
8*59bfda1fSAndroid Build Coastguard Worker  * it under the terms of the GNU General Public License version 2 as
9*59bfda1fSAndroid Build Coastguard Worker  * published by the Free Software Foundation.
10*59bfda1fSAndroid Build Coastguard Worker  */
11*59bfda1fSAndroid Build Coastguard Worker #ifndef _FSCK_H_
12*59bfda1fSAndroid Build Coastguard Worker #define _FSCK_H_
13*59bfda1fSAndroid Build Coastguard Worker 
14*59bfda1fSAndroid Build Coastguard Worker #include "f2fs.h"
15*59bfda1fSAndroid Build Coastguard Worker 
16*59bfda1fSAndroid Build Coastguard Worker enum {
17*59bfda1fSAndroid Build Coastguard Worker 	FSCK_SUCCESS                 = 0,
18*59bfda1fSAndroid Build Coastguard Worker 	FSCK_ERROR_CORRECTED         = 1 << 0,
19*59bfda1fSAndroid Build Coastguard Worker 	FSCK_SYSTEM_SHOULD_REBOOT    = 1 << 1,
20*59bfda1fSAndroid Build Coastguard Worker 	FSCK_ERRORS_LEFT_UNCORRECTED = 1 << 2,
21*59bfda1fSAndroid Build Coastguard Worker 	FSCK_OPERATIONAL_ERROR       = 1 << 3,
22*59bfda1fSAndroid Build Coastguard Worker 	FSCK_USAGE_OR_SYNTAX_ERROR   = 1 << 4,
23*59bfda1fSAndroid Build Coastguard Worker 	FSCK_USER_CANCELLED          = 1 << 5,
24*59bfda1fSAndroid Build Coastguard Worker 	FSCK_SHARED_LIB_ERROR        = 1 << 7,
25*59bfda1fSAndroid Build Coastguard Worker };
26*59bfda1fSAndroid Build Coastguard Worker 
27*59bfda1fSAndroid Build Coastguard Worker struct quota_ctx;
28*59bfda1fSAndroid Build Coastguard Worker 
29*59bfda1fSAndroid Build Coastguard Worker #define FSCK_UNMATCHED_EXTENT		0x00000001
30*59bfda1fSAndroid Build Coastguard Worker #define FSCK_INLINE_INODE		0x00000002
31*59bfda1fSAndroid Build Coastguard Worker 
32*59bfda1fSAndroid Build Coastguard Worker enum {
33*59bfda1fSAndroid Build Coastguard Worker 	PREEN_MODE_0,
34*59bfda1fSAndroid Build Coastguard Worker 	PREEN_MODE_1,
35*59bfda1fSAndroid Build Coastguard Worker 	PREEN_MODE_2,
36*59bfda1fSAndroid Build Coastguard Worker 	PREEN_MODE_MAX
37*59bfda1fSAndroid Build Coastguard Worker };
38*59bfda1fSAndroid Build Coastguard Worker 
39*59bfda1fSAndroid Build Coastguard Worker enum {
40*59bfda1fSAndroid Build Coastguard Worker 	NOERROR,
41*59bfda1fSAndroid Build Coastguard Worker 	EWRONG_OPT,
42*59bfda1fSAndroid Build Coastguard Worker 	ENEED_ARG,
43*59bfda1fSAndroid Build Coastguard Worker 	EUNKNOWN_OPT,
44*59bfda1fSAndroid Build Coastguard Worker 	EUNKNOWN_ARG,
45*59bfda1fSAndroid Build Coastguard Worker };
46*59bfda1fSAndroid Build Coastguard Worker 
47*59bfda1fSAndroid Build Coastguard Worker enum SB_ADDR {
48*59bfda1fSAndroid Build Coastguard Worker 	SB0_ADDR = 0,
49*59bfda1fSAndroid Build Coastguard Worker 	SB1_ADDR,
50*59bfda1fSAndroid Build Coastguard Worker 	SB_MAX_ADDR,
51*59bfda1fSAndroid Build Coastguard Worker };
52*59bfda1fSAndroid Build Coastguard Worker 
53*59bfda1fSAndroid Build Coastguard Worker #define SB_MASK(i)	(1 << (i))
54*59bfda1fSAndroid Build Coastguard Worker #define SB_MASK_ALL	(SB_MASK(SB0_ADDR) | SB_MASK(SB1_ADDR))
55*59bfda1fSAndroid Build Coastguard Worker 
56*59bfda1fSAndroid Build Coastguard Worker /* fsck.c */
57*59bfda1fSAndroid Build Coastguard Worker struct orphan_info {
58*59bfda1fSAndroid Build Coastguard Worker 	u32 nr_inodes;
59*59bfda1fSAndroid Build Coastguard Worker 	u32 *ino_list;
60*59bfda1fSAndroid Build Coastguard Worker };
61*59bfda1fSAndroid Build Coastguard Worker 
62*59bfda1fSAndroid Build Coastguard Worker struct extent_info {
63*59bfda1fSAndroid Build Coastguard Worker 	u32 fofs;		/* start offset in a file */
64*59bfda1fSAndroid Build Coastguard Worker 	u32 blk;		/* start block address of the extent */
65*59bfda1fSAndroid Build Coastguard Worker 	u32 len;		/* length of the extent */
66*59bfda1fSAndroid Build Coastguard Worker };
67*59bfda1fSAndroid Build Coastguard Worker 
68*59bfda1fSAndroid Build Coastguard Worker struct child_info {
69*59bfda1fSAndroid Build Coastguard Worker 	u32 state;
70*59bfda1fSAndroid Build Coastguard Worker 	u32 links;
71*59bfda1fSAndroid Build Coastguard Worker 	u32 files;
72*59bfda1fSAndroid Build Coastguard Worker 	u32 pgofs;
73*59bfda1fSAndroid Build Coastguard Worker 	u8 dot;
74*59bfda1fSAndroid Build Coastguard Worker 	u8 dotdot;
75*59bfda1fSAndroid Build Coastguard Worker 	u8 dir_level;
76*59bfda1fSAndroid Build Coastguard Worker 	u32 p_ino;		/* parent ino */
77*59bfda1fSAndroid Build Coastguard Worker 	char p_name[F2FS_NAME_LEN + 1]; /* parent name */
78*59bfda1fSAndroid Build Coastguard Worker 	u32 pp_ino;		/* parent parent ino*/
79*59bfda1fSAndroid Build Coastguard Worker 	struct extent_info ei;
80*59bfda1fSAndroid Build Coastguard Worker 	u32 last_blk;
81*59bfda1fSAndroid Build Coastguard Worker 	u32 i_namelen;  /* dentry namelen */
82*59bfda1fSAndroid Build Coastguard Worker };
83*59bfda1fSAndroid Build Coastguard Worker 
84*59bfda1fSAndroid Build Coastguard Worker struct f2fs_dentry {
85*59bfda1fSAndroid Build Coastguard Worker 	char name[F2FS_NAME_LEN + 1];
86*59bfda1fSAndroid Build Coastguard Worker 	int depth;
87*59bfda1fSAndroid Build Coastguard Worker 	struct f2fs_dentry *next;
88*59bfda1fSAndroid Build Coastguard Worker };
89*59bfda1fSAndroid Build Coastguard Worker 
90*59bfda1fSAndroid Build Coastguard Worker struct f2fs_fsck {
91*59bfda1fSAndroid Build Coastguard Worker 	struct f2fs_sb_info sbi;
92*59bfda1fSAndroid Build Coastguard Worker 
93*59bfda1fSAndroid Build Coastguard Worker 	struct orphan_info orphani;
94*59bfda1fSAndroid Build Coastguard Worker 	struct chk_result {
95*59bfda1fSAndroid Build Coastguard Worker 		u64 checked_node_cnt;
96*59bfda1fSAndroid Build Coastguard Worker 		u64 valid_blk_cnt;
97*59bfda1fSAndroid Build Coastguard Worker 		u32 valid_nat_entry_cnt;
98*59bfda1fSAndroid Build Coastguard Worker 		u32 valid_node_cnt;
99*59bfda1fSAndroid Build Coastguard Worker 		u32 valid_inode_cnt;
100*59bfda1fSAndroid Build Coastguard Worker 		u32 multi_hard_link_files;
101*59bfda1fSAndroid Build Coastguard Worker 		u64 sit_valid_blocks;
102*59bfda1fSAndroid Build Coastguard Worker 		u32 sit_free_segs;
103*59bfda1fSAndroid Build Coastguard Worker 		u32 wp_fixed;
104*59bfda1fSAndroid Build Coastguard Worker 		u32 wp_inconsistent_zones;
105*59bfda1fSAndroid Build Coastguard Worker 	} chk;
106*59bfda1fSAndroid Build Coastguard Worker 
107*59bfda1fSAndroid Build Coastguard Worker 	struct hard_link_node *hard_link_list_head;
108*59bfda1fSAndroid Build Coastguard Worker 
109*59bfda1fSAndroid Build Coastguard Worker 	char *main_seg_usage;
110*59bfda1fSAndroid Build Coastguard Worker 	char *main_area_bitmap;
111*59bfda1fSAndroid Build Coastguard Worker 	char *nat_area_bitmap;
112*59bfda1fSAndroid Build Coastguard Worker 	char *sit_area_bitmap;
113*59bfda1fSAndroid Build Coastguard Worker 
114*59bfda1fSAndroid Build Coastguard Worker 	u64 main_area_bitmap_sz;
115*59bfda1fSAndroid Build Coastguard Worker 	u32 nat_area_bitmap_sz;
116*59bfda1fSAndroid Build Coastguard Worker 	u32 sit_area_bitmap_sz;
117*59bfda1fSAndroid Build Coastguard Worker 
118*59bfda1fSAndroid Build Coastguard Worker 	u64 nr_main_blks;
119*59bfda1fSAndroid Build Coastguard Worker 	u32 nr_nat_entries;
120*59bfda1fSAndroid Build Coastguard Worker 
121*59bfda1fSAndroid Build Coastguard Worker 	u32 dentry_depth;
122*59bfda1fSAndroid Build Coastguard Worker 	struct f2fs_dentry *dentry;
123*59bfda1fSAndroid Build Coastguard Worker 	struct f2fs_dentry *dentry_end;
124*59bfda1fSAndroid Build Coastguard Worker 	struct f2fs_nat_entry *entries;
125*59bfda1fSAndroid Build Coastguard Worker 	u32 nat_valid_inode_cnt;
126*59bfda1fSAndroid Build Coastguard Worker 
127*59bfda1fSAndroid Build Coastguard Worker 	struct quota_ctx *qctx;
128*59bfda1fSAndroid Build Coastguard Worker };
129*59bfda1fSAndroid Build Coastguard Worker 
130*59bfda1fSAndroid Build Coastguard Worker enum NODE_TYPE {
131*59bfda1fSAndroid Build Coastguard Worker 	TYPE_INODE = 37,
132*59bfda1fSAndroid Build Coastguard Worker 	TYPE_DIRECT_NODE = 43,
133*59bfda1fSAndroid Build Coastguard Worker 	TYPE_INDIRECT_NODE = 53,
134*59bfda1fSAndroid Build Coastguard Worker 	TYPE_DOUBLE_INDIRECT_NODE = 67,
135*59bfda1fSAndroid Build Coastguard Worker 	TYPE_XATTR = 77
136*59bfda1fSAndroid Build Coastguard Worker };
137*59bfda1fSAndroid Build Coastguard Worker 
138*59bfda1fSAndroid Build Coastguard Worker struct hard_link_node {
139*59bfda1fSAndroid Build Coastguard Worker 	u32 nid;
140*59bfda1fSAndroid Build Coastguard Worker 	u32 links;
141*59bfda1fSAndroid Build Coastguard Worker 	u32 actual_links;
142*59bfda1fSAndroid Build Coastguard Worker 	struct hard_link_node *next;
143*59bfda1fSAndroid Build Coastguard Worker };
144*59bfda1fSAndroid Build Coastguard Worker 
145*59bfda1fSAndroid Build Coastguard Worker enum seg_type {
146*59bfda1fSAndroid Build Coastguard Worker 	SEG_TYPE_DATA,
147*59bfda1fSAndroid Build Coastguard Worker 	SEG_TYPE_CUR_DATA,
148*59bfda1fSAndroid Build Coastguard Worker 	SEG_TYPE_NODE,
149*59bfda1fSAndroid Build Coastguard Worker 	SEG_TYPE_CUR_NODE,
150*59bfda1fSAndroid Build Coastguard Worker 	SEG_TYPE_MAX,
151*59bfda1fSAndroid Build Coastguard Worker };
152*59bfda1fSAndroid Build Coastguard Worker 
153*59bfda1fSAndroid Build Coastguard Worker struct selabel_handle;
154*59bfda1fSAndroid Build Coastguard Worker 
need_fsync_data_record(struct f2fs_sb_info * sbi)155*59bfda1fSAndroid Build Coastguard Worker static inline bool need_fsync_data_record(struct f2fs_sb_info *sbi)
156*59bfda1fSAndroid Build Coastguard Worker {
157*59bfda1fSAndroid Build Coastguard Worker 	return !is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG);
158*59bfda1fSAndroid Build Coastguard Worker }
159*59bfda1fSAndroid Build Coastguard Worker 
160*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_orphan_node(struct f2fs_sb_info *);
161*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_quota_node(struct f2fs_sb_info *);
162*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_quota_files(struct f2fs_sb_info *);
163*59bfda1fSAndroid Build Coastguard Worker extern int fsck_sanity_check_nid(struct f2fs_sb_info *, u32,
164*59bfda1fSAndroid Build Coastguard Worker 					enum FILE_TYPE, enum NODE_TYPE);
165*59bfda1fSAndroid Build Coastguard Worker extern int fsck_sanity_check_nat(struct f2fs_sb_info *sbi, u32 nid);
166*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32,
167*59bfda1fSAndroid Build Coastguard Worker 		enum FILE_TYPE, enum NODE_TYPE, u32 *,
168*59bfda1fSAndroid Build Coastguard Worker 		struct f2fs_compr_blk_cnt *, struct child_info *);
169*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_root_inode(struct f2fs_sb_info *);
170*59bfda1fSAndroid Build Coastguard Worker extern void fsck_chk_inode_blk(struct f2fs_sb_info *, u32, enum FILE_TYPE,
171*59bfda1fSAndroid Build Coastguard Worker 		struct f2fs_node *, u32 *, struct f2fs_compr_blk_cnt *,
172*59bfda1fSAndroid Build Coastguard Worker 		struct node_info *, struct child_info *);
173*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_dnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
174*59bfda1fSAndroid Build Coastguard Worker 		u32, enum FILE_TYPE, struct f2fs_node *, u32 *,
175*59bfda1fSAndroid Build Coastguard Worker 		struct f2fs_compr_blk_cnt *, struct child_info *,
176*59bfda1fSAndroid Build Coastguard Worker 		struct node_info *);
177*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_idnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
178*59bfda1fSAndroid Build Coastguard Worker 		enum FILE_TYPE, struct f2fs_node *, u32 *,
179*59bfda1fSAndroid Build Coastguard Worker 		struct f2fs_compr_blk_cnt *, struct child_info *);
180*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_didnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
181*59bfda1fSAndroid Build Coastguard Worker 		enum FILE_TYPE, struct f2fs_node *, u32 *,
182*59bfda1fSAndroid Build Coastguard Worker 		struct f2fs_compr_blk_cnt *, struct child_info *);
183*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_data_blk(struct f2fs_sb_info *, struct f2fs_inode *,
184*59bfda1fSAndroid Build Coastguard Worker 		u32, struct child_info *, int, enum FILE_TYPE, u32, u16, u8,
185*59bfda1fSAndroid Build Coastguard Worker 		struct f2fs_node *);
186*59bfda1fSAndroid Build Coastguard Worker extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, int,
187*59bfda1fSAndroid Build Coastguard Worker 		u32, struct child_info *, int, int, struct f2fs_node *);
188*59bfda1fSAndroid Build Coastguard Worker int fsck_chk_inline_dentries(struct f2fs_sb_info *, struct f2fs_node *,
189*59bfda1fSAndroid Build Coastguard Worker 		struct child_info *);
190*59bfda1fSAndroid Build Coastguard Worker void fsck_chk_checkpoint(struct f2fs_sb_info *sbi);
191*59bfda1fSAndroid Build Coastguard Worker int fsck_chk_meta(struct f2fs_sb_info *sbi);
192*59bfda1fSAndroid Build Coastguard Worker void fsck_chk_and_fix_write_pointers(struct f2fs_sb_info *);
193*59bfda1fSAndroid Build Coastguard Worker int fsck_chk_curseg_info(struct f2fs_sb_info *);
194*59bfda1fSAndroid Build Coastguard Worker void pretty_print_filename(const u8 *raw_name, u32 len,
195*59bfda1fSAndroid Build Coastguard Worker 			   char out[F2FS_PRINT_NAMELEN], int enc_name);
196*59bfda1fSAndroid Build Coastguard Worker 
197*59bfda1fSAndroid Build Coastguard Worker extern void update_free_segments(struct f2fs_sb_info *);
198*59bfda1fSAndroid Build Coastguard Worker void print_cp_state(u32);
199*59bfda1fSAndroid Build Coastguard Worker extern void print_node_info(struct f2fs_sb_info *, struct f2fs_node *, int);
200*59bfda1fSAndroid Build Coastguard Worker extern void print_inode_info(struct f2fs_sb_info *, struct f2fs_node *, int);
201*59bfda1fSAndroid Build Coastguard Worker extern struct seg_entry *get_seg_entry(struct f2fs_sb_info *, unsigned int);
202*59bfda1fSAndroid Build Coastguard Worker extern struct f2fs_summary_block *get_sum_block(struct f2fs_sb_info *,
203*59bfda1fSAndroid Build Coastguard Worker 				unsigned int, int *);
204*59bfda1fSAndroid Build Coastguard Worker extern int get_sum_entry(struct f2fs_sb_info *, u32, struct f2fs_summary *);
205*59bfda1fSAndroid Build Coastguard Worker extern void update_sum_entry(struct f2fs_sb_info *, block_t,
206*59bfda1fSAndroid Build Coastguard Worker 				struct f2fs_summary *);
207*59bfda1fSAndroid Build Coastguard Worker extern void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
208*59bfda1fSAndroid Build Coastguard Worker extern void nullify_nat_entry(struct f2fs_sb_info *, u32);
209*59bfda1fSAndroid Build Coastguard Worker extern void rewrite_sit_area_bitmap(struct f2fs_sb_info *);
210*59bfda1fSAndroid Build Coastguard Worker extern void build_nat_area_bitmap(struct f2fs_sb_info *);
211*59bfda1fSAndroid Build Coastguard Worker extern void build_sit_area_bitmap(struct f2fs_sb_info *);
212*59bfda1fSAndroid Build Coastguard Worker extern int f2fs_set_main_bitmap(struct f2fs_sb_info *, u32, int);
213*59bfda1fSAndroid Build Coastguard Worker extern int f2fs_clear_main_bitmap(struct f2fs_sb_info *, u32);
214*59bfda1fSAndroid Build Coastguard Worker extern int f2fs_set_sit_bitmap(struct f2fs_sb_info *, u32);
215*59bfda1fSAndroid Build Coastguard Worker extern int f2fs_clear_sit_bitmap(struct f2fs_sb_info *, u32);
216*59bfda1fSAndroid Build Coastguard Worker extern void fsck_init(struct f2fs_sb_info *);
217*59bfda1fSAndroid Build Coastguard Worker extern int fsck_verify(struct f2fs_sb_info *);
218*59bfda1fSAndroid Build Coastguard Worker extern void fsck_free(struct f2fs_sb_info *);
219*59bfda1fSAndroid Build Coastguard Worker extern bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
220*59bfda1fSAndroid Build Coastguard Worker 					block_t blkaddr, int type);
221*59bfda1fSAndroid Build Coastguard Worker extern int f2fs_ra_meta_pages(struct f2fs_sb_info *, block_t, int, int);
222*59bfda1fSAndroid Build Coastguard Worker extern int f2fs_do_mount(struct f2fs_sb_info *);
223*59bfda1fSAndroid Build Coastguard Worker extern void f2fs_do_umount(struct f2fs_sb_info *);
224*59bfda1fSAndroid Build Coastguard Worker extern int f2fs_sparse_initialize_meta(struct f2fs_sb_info *);
225*59bfda1fSAndroid Build Coastguard Worker 
226*59bfda1fSAndroid Build Coastguard Worker extern void flush_journal_entries(struct f2fs_sb_info *);
227*59bfda1fSAndroid Build Coastguard Worker extern void update_curseg_info(struct f2fs_sb_info *, int);
228*59bfda1fSAndroid Build Coastguard Worker extern void zero_journal_entries(struct f2fs_sb_info *);
229*59bfda1fSAndroid Build Coastguard Worker extern void flush_sit_entries(struct f2fs_sb_info *);
230*59bfda1fSAndroid Build Coastguard Worker extern void move_curseg_info(struct f2fs_sb_info *, u64, int);
231*59bfda1fSAndroid Build Coastguard Worker extern void move_one_curseg_info(struct f2fs_sb_info *sbi, u64 from, int left,
232*59bfda1fSAndroid Build Coastguard Worker 				 int i);
233*59bfda1fSAndroid Build Coastguard Worker extern void write_curseg_info(struct f2fs_sb_info *);
234*59bfda1fSAndroid Build Coastguard Worker extern void save_curseg_warm_node_info(struct f2fs_sb_info *);
235*59bfda1fSAndroid Build Coastguard Worker extern void restore_curseg_warm_node_info(struct f2fs_sb_info *);
236*59bfda1fSAndroid Build Coastguard Worker extern int find_next_free_block(struct f2fs_sb_info *, u64 *, int, int, bool);
237*59bfda1fSAndroid Build Coastguard Worker extern void duplicate_checkpoint(struct f2fs_sb_info *);
238*59bfda1fSAndroid Build Coastguard Worker extern void write_checkpoint(struct f2fs_sb_info *);
239*59bfda1fSAndroid Build Coastguard Worker extern void write_checkpoints(struct f2fs_sb_info *);
240*59bfda1fSAndroid Build Coastguard Worker extern void write_raw_cp_blocks(struct f2fs_sb_info *sbi,
241*59bfda1fSAndroid Build Coastguard Worker 			struct f2fs_checkpoint *cp, int which);
242*59bfda1fSAndroid Build Coastguard Worker extern void update_superblock(struct f2fs_super_block *, int);
243*59bfda1fSAndroid Build Coastguard Worker extern void update_data_blkaddr(struct f2fs_sb_info *, nid_t, u16, block_t,
244*59bfda1fSAndroid Build Coastguard Worker 			struct f2fs_node *);
245*59bfda1fSAndroid Build Coastguard Worker extern void update_nat_blkaddr(struct f2fs_sb_info *, nid_t, nid_t, block_t);
246*59bfda1fSAndroid Build Coastguard Worker 
247*59bfda1fSAndroid Build Coastguard Worker extern void print_raw_sb_info(struct f2fs_super_block *);
248*59bfda1fSAndroid Build Coastguard Worker extern void print_ckpt_info(struct f2fs_sb_info *);
249*59bfda1fSAndroid Build Coastguard Worker extern bool is_checkpoint_stop(struct f2fs_super_block *, bool);
250*59bfda1fSAndroid Build Coastguard Worker extern bool is_inconsistent_error(struct f2fs_super_block *);
251*59bfda1fSAndroid Build Coastguard Worker extern pgoff_t current_nat_addr(struct f2fs_sb_info *, nid_t, int *);
252*59bfda1fSAndroid Build Coastguard Worker 
253*59bfda1fSAndroid Build Coastguard Worker extern u32 get_free_segments(struct f2fs_sb_info *);
254*59bfda1fSAndroid Build Coastguard Worker extern void get_current_sit_page(struct f2fs_sb_info *,
255*59bfda1fSAndroid Build Coastguard Worker 			unsigned int, struct f2fs_sit_block *);
256*59bfda1fSAndroid Build Coastguard Worker extern void rewrite_current_sit_page(struct f2fs_sb_info *, unsigned int,
257*59bfda1fSAndroid Build Coastguard Worker 			struct f2fs_sit_block *);
258*59bfda1fSAndroid Build Coastguard Worker 
259*59bfda1fSAndroid Build Coastguard Worker extern u32 update_nat_bits_flags(struct f2fs_super_block *,
260*59bfda1fSAndroid Build Coastguard Worker 				struct f2fs_checkpoint *, u32);
261*59bfda1fSAndroid Build Coastguard Worker extern void write_nat_bits(struct f2fs_sb_info *, struct f2fs_super_block *,
262*59bfda1fSAndroid Build Coastguard Worker 			struct f2fs_checkpoint *, int);
263*59bfda1fSAndroid Build Coastguard Worker extern unsigned int get_usable_seg_count(struct f2fs_sb_info *);
264*59bfda1fSAndroid Build Coastguard Worker extern bool is_usable_seg(struct f2fs_sb_info *, unsigned int);
265*59bfda1fSAndroid Build Coastguard Worker 
266*59bfda1fSAndroid Build Coastguard Worker /* dump.c */
267*59bfda1fSAndroid Build Coastguard Worker struct dump_option {
268*59bfda1fSAndroid Build Coastguard Worker 	nid_t nid;
269*59bfda1fSAndroid Build Coastguard Worker 	nid_t start_nat;
270*59bfda1fSAndroid Build Coastguard Worker 	nid_t end_nat;
271*59bfda1fSAndroid Build Coastguard Worker 	int start_sit;
272*59bfda1fSAndroid Build Coastguard Worker 	int end_sit;
273*59bfda1fSAndroid Build Coastguard Worker 	int start_ssa;
274*59bfda1fSAndroid Build Coastguard Worker 	int end_ssa;
275*59bfda1fSAndroid Build Coastguard Worker 	int32_t blk_addr;
276*59bfda1fSAndroid Build Coastguard Worker 	nid_t scan_nid;
277*59bfda1fSAndroid Build Coastguard Worker 	int use_root_nid;
278*59bfda1fSAndroid Build Coastguard Worker 	char *base_path;
279*59bfda1fSAndroid Build Coastguard Worker };
280*59bfda1fSAndroid Build Coastguard Worker 
281*59bfda1fSAndroid Build Coastguard Worker extern void nat_dump(struct f2fs_sb_info *, nid_t, nid_t);
282*59bfda1fSAndroid Build Coastguard Worker extern void sit_dump(struct f2fs_sb_info *, unsigned int, unsigned int);
283*59bfda1fSAndroid Build Coastguard Worker extern void ssa_dump(struct f2fs_sb_info *, int, int);
284*59bfda1fSAndroid Build Coastguard Worker extern int dump_node(struct f2fs_sb_info *, nid_t, int, char *, int, int, char *);
285*59bfda1fSAndroid Build Coastguard Worker extern int dump_info_from_blkaddr(struct f2fs_sb_info *, u32);
286*59bfda1fSAndroid Build Coastguard Worker extern unsigned int start_bidx_of_node(unsigned int, struct f2fs_node *);
287*59bfda1fSAndroid Build Coastguard Worker extern void dump_node_scan_disk(struct f2fs_sb_info *sbi, nid_t nid);
288*59bfda1fSAndroid Build Coastguard Worker extern bool is_sit_bitmap_set(struct f2fs_sb_info *sbi, u32 blk_addr);
289*59bfda1fSAndroid Build Coastguard Worker 
290*59bfda1fSAndroid Build Coastguard Worker /* defrag.c */
291*59bfda1fSAndroid Build Coastguard Worker int f2fs_defragment(struct f2fs_sb_info *, u64, u64, u64, int);
292*59bfda1fSAndroid Build Coastguard Worker 
293*59bfda1fSAndroid Build Coastguard Worker /* resize.c */
294*59bfda1fSAndroid Build Coastguard Worker int f2fs_resize(struct f2fs_sb_info *);
295*59bfda1fSAndroid Build Coastguard Worker 
296*59bfda1fSAndroid Build Coastguard Worker /* sload.c */
297*59bfda1fSAndroid Build Coastguard Worker int f2fs_sload(struct f2fs_sb_info *);
298*59bfda1fSAndroid Build Coastguard Worker 
299*59bfda1fSAndroid Build Coastguard Worker /* segment.c */
300*59bfda1fSAndroid Build Coastguard Worker int reserve_new_block(struct f2fs_sb_info *, block_t *,
301*59bfda1fSAndroid Build Coastguard Worker 					struct f2fs_summary *, int, bool);
302*59bfda1fSAndroid Build Coastguard Worker int new_data_block(struct f2fs_sb_info *, void *,
303*59bfda1fSAndroid Build Coastguard Worker 					struct dnode_of_data *, int);
304*59bfda1fSAndroid Build Coastguard Worker int f2fs_build_file(struct f2fs_sb_info *, struct dentry *);
305*59bfda1fSAndroid Build Coastguard Worker void f2fs_alloc_nid(struct f2fs_sb_info *, nid_t *);
306*59bfda1fSAndroid Build Coastguard Worker void set_data_blkaddr(struct dnode_of_data *);
307*59bfda1fSAndroid Build Coastguard Worker block_t new_node_block(struct f2fs_sb_info *,
308*59bfda1fSAndroid Build Coastguard Worker 					struct dnode_of_data *, unsigned int);
309*59bfda1fSAndroid Build Coastguard Worker int f2fs_rebuild_qf_inode(struct f2fs_sb_info *sbi, int qtype);
310*59bfda1fSAndroid Build Coastguard Worker int update_block(struct f2fs_sb_info *sbi, void *buf, u32 *blkaddr,
311*59bfda1fSAndroid Build Coastguard Worker 					struct f2fs_node *node_blk);
312*59bfda1fSAndroid Build Coastguard Worker 
313*59bfda1fSAndroid Build Coastguard Worker /* segment.c */
314*59bfda1fSAndroid Build Coastguard Worker struct quota_file;
315*59bfda1fSAndroid Build Coastguard Worker u64 f2fs_quota_size(struct quota_file *);
316*59bfda1fSAndroid Build Coastguard Worker u64 f2fs_read(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
317*59bfda1fSAndroid Build Coastguard Worker enum wr_addr_type {
318*59bfda1fSAndroid Build Coastguard Worker 	WR_NORMAL = 1,
319*59bfda1fSAndroid Build Coastguard Worker 	WR_COMPRESS_DATA = 2,
320*59bfda1fSAndroid Build Coastguard Worker 	WR_NULL_ADDR = NULL_ADDR,		/* 0 */
321*59bfda1fSAndroid Build Coastguard Worker 	WR_NEW_ADDR = NEW_ADDR,			/* -1U */
322*59bfda1fSAndroid Build Coastguard Worker 	WR_COMPRESS_ADDR = COMPRESS_ADDR,	/* -2U */
323*59bfda1fSAndroid Build Coastguard Worker };
324*59bfda1fSAndroid Build Coastguard Worker u64 f2fs_write(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
325*59bfda1fSAndroid Build Coastguard Worker u64 f2fs_write_compress_data(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
326*59bfda1fSAndroid Build Coastguard Worker u64 f2fs_write_addrtag(struct f2fs_sb_info *, nid_t, pgoff_t, unsigned int);
327*59bfda1fSAndroid Build Coastguard Worker void f2fs_filesize_update(struct f2fs_sb_info *, nid_t, u64);
328*59bfda1fSAndroid Build Coastguard Worker 
329*59bfda1fSAndroid Build Coastguard Worker int get_dnode_of_data(struct f2fs_sb_info *, struct dnode_of_data *,
330*59bfda1fSAndroid Build Coastguard Worker 					pgoff_t, int);
331*59bfda1fSAndroid Build Coastguard Worker void make_dentry_ptr(struct f2fs_dentry_ptr *, struct f2fs_node *, void *, int);
332*59bfda1fSAndroid Build Coastguard Worker int f2fs_create(struct f2fs_sb_info *, struct dentry *);
333*59bfda1fSAndroid Build Coastguard Worker int f2fs_mkdir(struct f2fs_sb_info *, struct dentry *);
334*59bfda1fSAndroid Build Coastguard Worker int f2fs_symlink(struct f2fs_sb_info *, struct dentry *);
335*59bfda1fSAndroid Build Coastguard Worker int inode_set_selinux(struct f2fs_sb_info *, u32, const char *);
336*59bfda1fSAndroid Build Coastguard Worker int f2fs_find_path(struct f2fs_sb_info *, char *, nid_t *);
337*59bfda1fSAndroid Build Coastguard Worker nid_t f2fs_lookup(struct f2fs_sb_info *, struct f2fs_node *, u8 *, int);
338*59bfda1fSAndroid Build Coastguard Worker int f2fs_add_link(struct f2fs_sb_info *, struct f2fs_node *,
339*59bfda1fSAndroid Build Coastguard Worker 		const unsigned char *, int, nid_t, int, block_t *, int);
340*59bfda1fSAndroid Build Coastguard Worker struct hardlink_cache_entry *f2fs_search_hardlink(struct f2fs_sb_info *sbi,
341*59bfda1fSAndroid Build Coastguard Worker 						struct dentry *de);
342*59bfda1fSAndroid Build Coastguard Worker 
343*59bfda1fSAndroid Build Coastguard Worker /* xattr.c */
344*59bfda1fSAndroid Build Coastguard Worker void *read_all_xattrs(struct f2fs_sb_info *, struct f2fs_node *, bool);
345*59bfda1fSAndroid Build Coastguard Worker void write_all_xattrs(struct f2fs_sb_info *sbi,
346*59bfda1fSAndroid Build Coastguard Worker 		struct f2fs_node *inode, __u32 hsize, void *txattr_addr);
347*59bfda1fSAndroid Build Coastguard Worker 
348*59bfda1fSAndroid Build Coastguard Worker /* dir.c */
349*59bfda1fSAndroid Build Coastguard Worker int convert_inline_dentry(struct f2fs_sb_info *sbi, struct f2fs_node *node,
350*59bfda1fSAndroid Build Coastguard Worker 		block_t *p_blkaddr);
351*59bfda1fSAndroid Build Coastguard Worker 
352*59bfda1fSAndroid Build Coastguard Worker /* node.c */
353*59bfda1fSAndroid Build Coastguard Worker int update_inode(struct f2fs_sb_info *sbi, struct f2fs_node *inode,
354*59bfda1fSAndroid Build Coastguard Worker 		u32 *blkaddr);
355*59bfda1fSAndroid Build Coastguard Worker 
356*59bfda1fSAndroid Build Coastguard Worker /* mount.c */
357*59bfda1fSAndroid Build Coastguard Worker int flush_nat_journal_entries(struct f2fs_sb_info *sbi);
358*59bfda1fSAndroid Build Coastguard Worker int flush_sit_journal_entries(struct f2fs_sb_info *sbi);
359*59bfda1fSAndroid Build Coastguard Worker 
360*59bfda1fSAndroid Build Coastguard Worker /* main.c */
361*59bfda1fSAndroid Build Coastguard Worker int is_digits(char *optarg);
362*59bfda1fSAndroid Build Coastguard Worker 
363*59bfda1fSAndroid Build Coastguard Worker #endif /* _FSCK_H_ */
364