Blame gfs2/fsck/fsck.h.bz1622050-1-fsck_gfs2_Don_t_check_fs_formats_we_don_t_recognise

Packit c433c4
#ifndef _FSCK_H
Packit c433c4
#define _FSCK_H
Packit c433c4
Packit c433c4
#include "libgfs2.h"
Packit c433c4
#include "osi_tree.h"
Packit c433c4
Packit c433c4
#define FSCK_HASH_SHIFT         (13)
Packit c433c4
#define FSCK_HASH_SIZE          (1 << FSCK_HASH_SHIFT)
Packit c433c4
#define FSCK_HASH_MASK          (FSCK_HASH_SIZE - 1)
Packit c433c4
Packit c433c4
#define query(fmt, args...) fsck_query(fmt, ##args)
Packit c433c4
Packit c433c4
/*
Packit c433c4
 * Exit codes used by fsck-type programs
Packit c433c4
 * Copied from e2fsck's e2fsck.h
Packit c433c4
 */
Packit c433c4
#define FSCK_OK          0      /* No errors */
Packit c433c4
#define FSCK_NONDESTRUCT 1      /* File system errors corrected */
Packit c433c4
#define FSCK_REBOOT      2      /* System should be rebooted */
Packit c433c4
#define FSCK_UNCORRECTED 4      /* File system errors left uncorrected */
Packit c433c4
#define FSCK_ERROR       8      /* Operational error */
Packit c433c4
#define FSCK_USAGE       16     /* Usage or syntax error */
Packit c433c4
#define FSCK_CANCELED    32     /* Aborted with a signal or ^C */
Packit c433c4
#define FSCK_LIBRARY     128    /* Shared library error */
Packit c433c4
Packit c433c4
#define BAD_POINTER_TOLERANCE 10 /* How many bad pointers is too many? */
Packit c433c4
Packit c433c4
struct gfs2_bmap {
Packit c433c4
	uint64_t size;
Packit c433c4
	uint64_t mapsize;
Packit c433c4
	unsigned char *map;
Packit c433c4
};
Packit c433c4
Packit c433c4
struct inode_info
Packit c433c4
{
Packit c433c4
	struct osi_node node;
Packit c433c4
	struct gfs2_inum di_num;
Packit c433c4
	uint32_t   di_nlink;    /* the number of links the inode
Packit c433c4
				 * thinks it has */
Packit c433c4
	uint32_t   counted_links; /* the number of links we've found */
Packit c433c4
};
Packit c433c4
Packit c433c4
struct dir_info
Packit c433c4
{
Packit c433c4
	struct osi_node node;
Packit c433c4
	struct gfs2_inum dinode;
Packit c433c4
	uint64_t treewalk_parent;
Packit c433c4
	struct gfs2_inum dotdot_parent;
Packit c433c4
	uint32_t di_nlink;
Packit c433c4
	uint32_t counted_links;
Packit c433c4
	uint8_t  checked:1;
Packit c433c4
};
Packit c433c4
Packit c433c4
struct dir_status {
Packit c433c4
	uint8_t dotdir:1;
Packit c433c4
	uint8_t dotdotdir:1;
Packit c433c4
	int q;
Packit c433c4
	uint32_t entry_count;
Packit c433c4
};
Packit c433c4
Packit c433c4
#define DUPFLAG_REF1_FOUND 1 /* Has the original reference been found? */
Packit c433c4
#define DUPFLAG_REF1_IS_DUPL 2 /* The original reference is also where we
Packit c433c4
				  determined there was a duplicate. */
Packit c433c4
Packit c433c4
struct duptree {
Packit c433c4
	struct osi_node node;
Packit c433c4
	int dup_flags;
Packit c433c4
	int refs;
Packit c433c4
	uint64_t block;
Packit c433c4
	osi_list_t ref_inode_list; /* list of inodes referencing a dup block */
Packit c433c4
	osi_list_t ref_invinode_list; /* list of invalid inodes referencing */
Packit c433c4
};
Packit c433c4
Packit c433c4
enum dup_ref_type {
Packit c433c4
	ref_as_data = 0, /* dinode references this block as a data block */
Packit c433c4
	ref_as_meta = 1, /* dinode references this block as a metadata block */
Packit c433c4
	ref_as_ea   = 2, /* dinode references this block as an extended attr */
Packit c433c4
	ref_is_inode= 3, /* The reference is itself a dinode.  In other words,
Packit c433c4
			    it's a dinode, not pointed to as data or
Packit c433c4
			    metadata */
Packit c433c4
	ref_types   = 4,
Packit c433c4
};
Packit c433c4
Packit c433c4
struct inode_with_dups {
Packit c433c4
	osi_list_t list;
Packit c433c4
	uint64_t block_no;
Packit c433c4
	int dup_count;
Packit c433c4
	int reftypecount[ref_types];
Packit c433c4
	uint64_t parent;
Packit c433c4
	char *name;
Packit c433c4
};
Packit c433c4
Packit c433c4
enum rgindex_trust_level { /* how far can we trust our RG index? */
Packit c433c4
	blind_faith = 0, /* We'd like to trust the rgindex. We always used to
Packit c433c4
			    before bz 179069. This should cover most cases. */
Packit c433c4
	ye_of_little_faith = 1, /* The rindex seems trustworthy but there's
Packit c433c4
				   rg damage that need to be fixed. */
Packit c433c4
	open_minded = 2, /* At least 1 RG is corrupt. Try to calculate what it
Packit c433c4
			    should be, in a perfect world where our RGs are all
Packit c433c4
			    on even boundaries. Blue sky. Chirping birds. */
Packit c433c4
	distrust = 3,  /* The world isn't perfect, our RGs are not on nice neat
Packit c433c4
			  boundaries.  The fs must have been messed with by
Packit c433c4
			  gfs2_grow or something.  Count the RGs by hand. */
Packit c433c4
	indignation = 4 /* Not only do we have corruption, but the rgrps
Packit c433c4
			   aren't on even boundaries, so this file system
Packit c433c4
			   must have been converted from gfs2_convert. */
Packit c433c4
};
Packit c433c4
Packit c433c4
struct error_block {
Packit c433c4
	uint64_t metablk; /* metadata block where error was found */
Packit c433c4
	int metaoff; /* offset in that metadata block where error found */
Packit c433c4
	uint64_t errblk; /* error block */
Packit c433c4
};
Packit c433c4
Packit c433c4
extern struct gfs2_inode *fsck_load_inode(struct gfs2_sbd *sdp, uint64_t block);
Packit c433c4
extern struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
Packit c433c4
					 struct rgrp_tree *rgd,
Packit c433c4
					 struct gfs2_buffer_head *bh);
Packit c433c4
extern void fsck_inode_put(struct gfs2_inode **ip);
Packit c433c4
Packit c433c4
extern int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
Packit c433c4
		      int *all_clean);
Packit c433c4
extern void destroy(struct gfs2_sbd *sdp);
Packit c433c4
extern int pass1(struct gfs2_sbd *sdp);
Packit c433c4
extern int pass1b(struct gfs2_sbd *sdp);
Packit c433c4
extern int pass1c(struct gfs2_sbd *sdp);
Packit c433c4
extern int pass2(struct gfs2_sbd *sdp);
Packit c433c4
extern int pass3(struct gfs2_sbd *sdp);
Packit c433c4
extern int pass4(struct gfs2_sbd *sdp);
Packit c433c4
extern int pass5(struct gfs2_sbd *sdp, struct gfs2_bmap *bl);
Packit c433c4
extern int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count,
Packit c433c4
		     int *sane);
Packit c433c4
extern int fsck_query(const char *format, ...)
Packit c433c4
	__attribute__((format(printf,1,2)));
Packit c433c4
extern struct dir_info *dirtree_find(uint64_t block);
Packit c433c4
extern void dup_delete(struct duptree *dt);
Packit c433c4
extern void dirtree_delete(struct dir_info *b);
Packit c433c4
Packit c433c4
/* FIXME: Hack to get this going for pass2 - this should be pulled out
Packit c433c4
 * of pass1 and put somewhere else... */
Packit c433c4
struct dir_info *dirtree_insert(struct gfs2_inum inum);
Packit c433c4
Packit c433c4
struct gfs2_options {
Packit c433c4
	char *device;
Packit c433c4
	unsigned int yes:1;
Packit c433c4
	unsigned int no:1;
Packit c433c4
	unsigned int query:1;
Packit c433c4
};
Packit c433c4
Packit c433c4
extern struct gfs2_options opts;
Packit c433c4
extern struct gfs2_inode *lf_dip; /* Lost and found directory inode */
Packit c433c4
extern int lf_was_created;
Packit c433c4
extern uint64_t last_fs_block, last_reported_block;
Packit c433c4
extern int64_t last_reported_fblock;
Packit c433c4
extern int skip_this_pass, fsck_abort;
Packit c433c4
extern int errors_found, errors_corrected;
Packit c433c4
extern uint64_t last_data_block;
Packit c433c4
extern uint64_t first_data_block;
Packit c433c4
extern struct osi_root dup_blocks;
Packit c433c4
extern struct osi_root dirtree;
Packit c433c4
extern struct osi_root inodetree;
Packit c433c4
extern int dups_found; /* How many duplicate references have we found? */
Packit c433c4
extern int dups_found_first; /* How many duplicates have we found the original
Packit c433c4
				reference for? */
Packit c433c4
extern struct gfs_sb *sbd1;
Packit c433c4
Packit c433c4
static inline int valid_block(struct gfs2_sbd *sdp, uint64_t blkno)
Packit c433c4
{
Packit c433c4
	return !((blkno > sdp->fssize) || (blkno <= LGFS2_SB_ADDR(sdp)) ||
Packit c433c4
	         (lgfs2_get_bitmap(sdp, blkno, NULL) < 0));
Packit c433c4
}
Packit c433c4
Packit c433c4
static inline int rgrp_contains_block(struct rgrp_tree *rgd, uint64_t blk)
Packit c433c4
{
Packit c433c4
	if (blk < rgd->ri.ri_addr)
Packit c433c4
		return 0;
Packit c433c4
	if (blk >= rgd->ri.ri_data0 + rgd->ri.ri_data)
Packit c433c4
		return 0;
Packit c433c4
	return 1;
Packit c433c4
}
Packit c433c4
Packit c433c4
static inline int valid_block_ip(struct gfs2_inode *ip, uint64_t blk)
Packit c433c4
{
Packit c433c4
	struct gfs2_sbd *sdp = ip->i_sbd;
Packit c433c4
	struct rgrp_tree *rgd = ip->i_rgd;
Packit c433c4
Packit c433c4
	if (blk > sdp->fssize)
Packit c433c4
		return 0;
Packit c433c4
	if (blk <= LGFS2_SB_ADDR(sdp))
Packit c433c4
		return 0;
Packit c433c4
	if (rgd == NULL || !rgrp_contains_block(rgd, blk)) {
Packit c433c4
		rgd = gfs2_blk2rgrpd(sdp, blk);
Packit c433c4
		if (rgd == NULL)
Packit c433c4
			return 0;
Packit c433c4
	}
Packit c433c4
Packit c433c4
	return rgrp_contains_block(rgd, blk);
Packit c433c4
}
Packit c433c4
Packit c433c4
#endif /* _FSCK_H */