Home | History | Annotate | Download | only in fsck
      1 /**
      2  * fsck.h
      3  *
      4  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
      5  *             http://www.samsung.com/
      6  *
      7  * This program is free software; you can redistribute it and/or modify
      8  * it under the terms of the GNU General Public License version 2 as
      9  * published by the Free Software Foundation.
     10  */
     11 #ifndef _FSCK_H_
     12 #define _FSCK_H_
     13 
     14 #include "f2fs.h"
     15 
     16 /* fsck.c */
     17 struct orphan_info {
     18 	u32 nr_inodes;
     19 	u32 *ino_list;
     20 };
     21 
     22 struct f2fs_fsck {
     23 	struct f2fs_sb_info sbi;
     24 
     25 	struct orphan_info orphani;
     26 	struct chk_result {
     27 		u64 valid_blk_cnt;
     28 		u32 valid_nat_entry_cnt;
     29 		u32 valid_node_cnt;
     30 		u32 valid_inode_cnt;
     31 		u32 multi_hard_link_files;
     32 		u64 sit_valid_blocks;
     33 		u32 sit_free_segs;
     34 		u32 free_segs;
     35 	} chk;
     36 
     37 	struct hard_link_node *hard_link_list_head;
     38 
     39 	char *main_seg_usage;
     40 	char *main_area_bitmap;
     41 	char *nat_area_bitmap;
     42 	char *sit_area_bitmap;
     43 
     44 	u64 main_area_bitmap_sz;
     45 	u32 nat_area_bitmap_sz;
     46 	u32 sit_area_bitmap_sz;
     47 
     48 	u64 nr_main_blks;
     49 	u32 nr_nat_entries;
     50 
     51 	u32 dentry_depth;
     52 };
     53 
     54 #define BLOCK_SZ		4096
     55 struct block {
     56 	unsigned char buf[BLOCK_SZ];
     57 };
     58 
     59 enum NODE_TYPE {
     60 	TYPE_INODE = 37,
     61 	TYPE_DIRECT_NODE = 43,
     62 	TYPE_INDIRECT_NODE = 53,
     63 	TYPE_DOUBLE_INDIRECT_NODE = 67,
     64 	TYPE_XATTR = 77
     65 };
     66 
     67 struct hard_link_node {
     68 	u32 nid;
     69 	u32 links;
     70 	struct hard_link_node *next;
     71 };
     72 
     73 enum seg_type {
     74 	SEG_TYPE_DATA,
     75 	SEG_TYPE_CUR_DATA,
     76 	SEG_TYPE_NODE,
     77 	SEG_TYPE_CUR_NODE,
     78 	SEG_TYPE_MAX,
     79 };
     80 
     81 extern void fsck_chk_orphan_node(struct f2fs_sb_info *);
     82 extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32,
     83 		enum FILE_TYPE, enum NODE_TYPE, u32 *);
     84 extern void fsck_chk_inode_blk(struct f2fs_sb_info *, u32, enum FILE_TYPE,
     85 		struct f2fs_node *, u32 *, struct node_info *);
     86 extern int fsck_chk_dnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
     87 		u32, enum FILE_TYPE, struct f2fs_node *, u32 *,
     88 		struct node_info *);
     89 extern int fsck_chk_idnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
     90 		enum FILE_TYPE, struct f2fs_node *, u32 *);
     91 extern int fsck_chk_didnode_blk(struct f2fs_sb_info *, struct f2fs_inode *,
     92 		enum FILE_TYPE, struct f2fs_node *, u32 *);
     93 extern int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32, u32 *, u32 *,
     94 		int, enum FILE_TYPE, u32, u16, u8);
     95 extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, u32, u32 *, u32 *, int);
     96 int fsck_chk_inline_dentries(struct f2fs_sb_info *, struct f2fs_node *,
     97 		u32 *, u32 *);
     98 
     99 extern void print_node_info(struct f2fs_node *);
    100 extern void print_inode_info(struct f2fs_inode *);
    101 extern struct seg_entry *get_seg_entry(struct f2fs_sb_info *, unsigned int);
    102 extern int get_sum_block(struct f2fs_sb_info *, unsigned int,
    103 				struct f2fs_summary_block *);
    104 extern int get_sum_entry(struct f2fs_sb_info *, u32, struct f2fs_summary *);
    105 extern void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
    106 extern void nullify_nat_entry(struct f2fs_sb_info *, u32);
    107 extern void rewrite_sit_area_bitmap(struct f2fs_sb_info *);
    108 extern void build_nat_area_bitmap(struct f2fs_sb_info *);
    109 extern void build_sit_area_bitmap(struct f2fs_sb_info *);
    110 extern void fsck_init(struct f2fs_sb_info *);
    111 extern int fsck_verify(struct f2fs_sb_info *);
    112 extern void fsck_free(struct f2fs_sb_info *);
    113 extern int f2fs_do_mount(struct f2fs_sb_info *);
    114 extern void f2fs_do_umount(struct f2fs_sb_info *);
    115 
    116 /* dump.c */
    117 struct dump_option {
    118 	nid_t nid;
    119 	int start_sit;
    120 	int end_sit;
    121 	int start_ssa;
    122 	int end_ssa;
    123 	int32_t blk_addr;
    124 };
    125 
    126 extern void sit_dump(struct f2fs_sb_info *, int, int);
    127 extern void ssa_dump(struct f2fs_sb_info *, int, int);
    128 extern void dump_node(struct f2fs_sb_info *, nid_t);
    129 extern int dump_inode_from_blkaddr(struct f2fs_sb_info *, u32);
    130 
    131 #endif /* _FSCK_H_ */
    132