2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef _XFS_REPAIR_GLOBAL_H
20 #define _XFS_REPAIR_GLOBAL_H
28 #define rounddown(x, y) (((x)/(y))*(y))
32 #define XR_OK 0 /* good */
33 #define XR_BAD_MAGIC 1 /* bad magic number */
34 #define XR_BAD_BLOCKSIZE 2 /* bad block size */
35 #define XR_BAD_BLOCKLOG 3 /* bad sb_blocklog field */
36 #define XR_BAD_VERSION 4 /* bad version number */
37 #define XR_BAD_INPROGRESS 5 /* in progress set */
38 #define XR_BAD_FS_SIZE_DATA 6 /* ag sizes, number, fs size mismatch */
39 #define XR_BAD_INO_SIZE_DATA 7 /* bad inode size or perblock fields */
40 #define XR_BAD_SECT_SIZE_DATA 8 /* bad sector size info */
41 #define XR_AGF_GEO_MISMATCH 9 /* agf info conflicts with sb */
42 #define XR_AGI_GEO_MISMATCH 10 /* agf info conflicts with sb */
43 #define XR_SB_GEO_MISMATCH 11 /* sb geo conflicts with fs sb geo */
44 #define XR_EOF 12 /* seeked beyond EOF */
45 #define XR_BAD_RT_GEO_DATA 13 /* realtime geometry inconsistent */
46 #define XR_BAD_INO_MAX_PCT 14 /* max % of inodes > 100% */
47 #define XR_BAD_INO_ALIGN 15 /* bad inode alignment value */
48 #define XR_INSUFF_SEC_SB 16 /* not enough matching secondary sbs */
49 #define XR_BAD_SB_UNIT 17 /* bad stripe unit */
50 #define XR_BAD_SB_WIDTH 18 /* bad stripe width */
51 #define XR_BAD_SVN 19 /* bad shared version number */
52 #define XR_BAD_ERR_CODE 20 /* Bad error code */
54 /* XFS filesystem (il)legal values */
56 #define XR_LOG2BSIZE_MIN 9 /* min/max fs blocksize (log2) */
57 #define XR_LOG2BSIZE_MAX 16 /* 2^XR_* == blocksize */
59 #define NUM_SBS 8 /* max # of sbs to verify */
60 #define NUM_AGH_SECTS 4 /* # of components in an ag header */
62 #define MEM_ALIGN 128 /* I/O buf alignment - a cache line */
65 * secondary sb mask -- if the secondary sb feature bits has a
66 * the partial sb mask bit set, then you depend on the fields
67 * in it up to and including sb_inoalignmt but the unused part of the
68 * sector may have trash in it. If the sb has any bits set that are in
69 * the good mask, then the entire sb and sector are good (was bzero'ed
70 * by mkfs). The third mask is for filesystems made by pre-6.5 campus
71 * alpha mkfs's. Those are rare so we'll check for those under
74 #define XR_PART_SECSB_VNMASK 0x0F80 /* >= XFS_SB_VERSION_ALIGNBIT */
75 #define XR_GOOD_SECSB_VNMASK 0x0F00 /* >= XFS_SB_VERSION_DALIGNBIT */
76 #define XR_ALPHA_SECSB_VNMASK 0x0180 /* DALIGN|ALIGN bits */
78 /* global variables for xfs_repair */
80 /* arguments and argument flag variables */
82 EXTERN
char *fs_name
; /* name of filesystem */
83 EXTERN
int verbose
; /* verbose flag, mostly for debugging */
86 /* for reading stuff in manually (bypassing libsim) */
88 EXTERN
char *iobuf
; /* large buffer */
89 EXTERN
int iobuf_size
;
90 EXTERN
char *smallbuf
; /* small (1-4 page) buffer */
91 EXTERN
int smallbuf_size
;
92 EXTERN
char *sb_bufs
[NUM_SBS
]; /* superblock buffers */
93 EXTERN
int sbbuf_size
;
97 EXTERN
int minio_align
; /* min I/O size and alignment */
98 EXTERN
int mem_align
; /* memory alignment */
99 EXTERN
int max_iosize
; /* max I/O size */
101 /* file descriptors */
103 EXTERN
int fs_fd
; /* filesystem fd */
105 /* command-line flags */
108 EXTERN
int no_modify
;
109 EXTERN
int dangerously
; /* live dangerously ... fix ro mount */
112 EXTERN
int dumpcore
; /* abort, not exit on fatal errs */
113 EXTERN
int delete_attr_ok
; /* can clear attrs w/o clearing files */
114 EXTERN
int force_geo
; /* can set geo on low confidence info */
115 EXTERN
int assume_xfs
; /* assume we have an xfs fs */
116 EXTERN
int pre_65_beta
; /* fs was mkfs'ed by a version earlier * than 6.5-beta */
117 EXTERN
char *log_name
; /* Name of log device */
118 EXTERN
int log_spec
; /* Log dev specified as option */
119 EXTERN
char *rt_name
; /* Name of realtime device */
120 EXTERN
int rt_spec
; /* Realtime dev specified as option */
122 /* misc status variables */
124 EXTERN
int primary_sb_modified
;
125 EXTERN
int bad_ino_btree
;
126 EXTERN
int clear_sunit
;
127 EXTERN
int fs_is_dirty
;
129 /* for hunting down the root inode */
131 EXTERN
int need_root_inode
;
132 EXTERN
int need_root_dotdot
;
134 EXTERN
int need_rbmino
;
135 EXTERN
int need_rsumino
;
137 EXTERN
int lost_quotas
;
138 EXTERN
int have_uquotino
;
139 EXTERN
int have_gquotino
;
140 EXTERN
int lost_uquotino
;
141 EXTERN
int lost_gquotino
;
142 EXTERN
int lost_pquotino
;
144 EXTERN xfs_agino_t first_prealloc_ino
;
145 EXTERN xfs_agino_t last_prealloc_ino
;
146 EXTERN xfs_agblock_t bnobt_root
;
147 EXTERN xfs_agblock_t bcntbt_root
;
148 EXTERN xfs_agblock_t inobt_root
;
150 /* configuration vars -- fs geometry dependent */
152 EXTERN
int inodes_per_block
;
153 EXTERN
int inodes_per_cluster
; /* inodes per inode buffer */
154 EXTERN
unsigned int glob_agcount
;
155 EXTERN
int chunks_pblock
; /* # of 64-ino chunks per allocation */
156 EXTERN
int max_symlink_blocks
;
157 EXTERN __int64_t fs_max_file_offset
;
159 /* block allocation bitmaps */
161 EXTERN __uint64_t
**ba_bmap
; /* see incore.h */
162 EXTERN __uint64_t
*rt_ba_bmap
; /* see incore.h */
166 EXTERN xfs_rtword_t
*btmcompute
;
167 EXTERN xfs_suminfo_t
*sumcompute
;
169 /* inode tree records have full or partial backptr fields ? */
171 EXTERN
int full_backptrs
; /*
172 * if 1, use backptrs_t component
173 * of ino_un union, if 0, use
174 * parent_list_t component. see
175 * incore.h for more details
178 #define ORPHANAGE "lost+found"
180 /* superblock counters */
182 EXTERN __uint64_t sb_icount
; /* allocated (made) inodes */
183 EXTERN __uint64_t sb_ifree
; /* free inodes */
184 EXTERN __uint64_t sb_fdblocks
; /* free data blocks */
185 EXTERN __uint64_t sb_frextents
; /* free realtime extents */
187 EXTERN xfs_ino_t orphanage_ino
;
188 EXTERN xfs_ino_t old_orphanage_ino
;
190 /* superblock geometry info */
192 EXTERN xfs_extlen_t sb_inoalignmt
;
193 EXTERN __uint32_t sb_unit
;
194 EXTERN __uint32_t sb_width
;
196 #endif /* _XFS_REPAIR_GLOBAL_H */