]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/globals.h
Update copyright dates
[thirdparty/xfsprogs-dev.git] / repair / globals.h
1 /*
2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33 #ifndef _XFS_REPAIR_GLOBAL_H
34 #define _XFS_REPAIR_GLOBAL_H
35
36 #ifndef EXTERN
37 #define EXTERN extern
38 #endif
39
40 /* useful macros */
41
42 #define rounddown(x, y) (((x)/(y))*(y))
43
44 /* error flags */
45
46 #define XR_OK 0 /* good */
47 #define XR_BAD_MAGIC 1 /* bad magic number */
48 #define XR_BAD_BLOCKSIZE 2 /* bad block size */
49 #define XR_BAD_BLOCKLOG 3 /* bad sb_blocklog field */
50 #define XR_BAD_VERSION 4 /* bad version number */
51 #define XR_BAD_INPROGRESS 5 /* in progress set */
52 #define XR_BAD_FS_SIZE_DATA 6 /* ag sizes, number, fs size mismatch */
53 #define XR_BAD_INO_SIZE_DATA 7 /* bad inode size or perblock fields */
54 #define XR_BAD_SECT_SIZE_DATA 8 /* bad sector size info */
55 #define XR_AGF_GEO_MISMATCH 9 /* agf info conflicts with sb */
56 #define XR_AGI_GEO_MISMATCH 10 /* agf info conflicts with sb */
57 #define XR_SB_GEO_MISMATCH 11 /* sb geo conflicts with fs sb geo */
58 #define XR_EOF 12 /* seeked beyond EOF */
59 #define XR_BAD_RT_GEO_DATA 13 /* realtime geometry inconsistent */
60 #define XR_BAD_INO_MAX_PCT 14 /* max % of inodes > 100% */
61 #define XR_BAD_INO_ALIGN 15 /* bad inode alignment value */
62 #define XR_INSUFF_SEC_SB 16 /* not enough matching secondary sbs */
63 #define XR_BAD_SB_UNIT 17 /* bad stripe unit */
64 #define XR_BAD_SB_WIDTH 18 /* bad stripe width */
65 #define XR_BAD_SVN 19 /* bad shared version number */
66 #define XR_BAD_ERR_CODE 20 /* Bad error code */
67
68 /* XFS filesystem (il)legal values */
69
70 #define XR_LOG2BSIZE_MIN 9 /* min/max fs blocksize (log2) */
71 #define XR_LOG2BSIZE_MAX 16 /* 2^XR_* == blocksize */
72
73 #define NUM_SBS 8 /* max # of sbs to verify */
74 #define NUM_AGH_SECTS 4 /* # of components in an ag header */
75
76 #define MEM_ALIGN 128 /* I/O buf alignment - a cache line */
77
78 /*
79 * secondary sb mask -- if the secondary sb feature bits has a
80 * the partial sb mask bit set, then you depend on the fields
81 * in it up to and including sb_inoalignmt but the unused part of the
82 * sector may have trash in it. If the sb has any bits set that are in
83 * the good mask, then the entire sb and sector are good (was bzero'ed
84 * by mkfs). The third mask is for filesystems made by pre-6.5 campus
85 * alpha mkfs's. Those are rare so we'll check for those under
86 * a special option.
87 */
88 #define XR_PART_SECSB_VNMASK 0x0F80 /* >= XFS_SB_VERSION_ALIGNBIT */
89 #define XR_GOOD_SECSB_VNMASK 0x0F00 /* >= XFS_SB_VERSION_DALIGNBIT */
90 #define XR_ALPHA_SECSB_VNMASK 0x0180 /* DALIGN|ALIGN bits */
91
92 /* global variables for xfs_repair */
93
94 /* arguments and argument flag variables */
95
96 EXTERN char *fs_name; /* name of filesystem */
97 EXTERN int verbose; /* verbose flag, mostly for debugging */
98
99
100 /* for reading stuff in manually (bypassing libsim) */
101
102 EXTERN char *iobuf; /* large buffer */
103 EXTERN int iobuf_size;
104 EXTERN char *smallbuf; /* small (1-4 page) buffer */
105 EXTERN int smallbuf_size;
106 EXTERN char *sb_bufs[NUM_SBS]; /* superblock buffers */
107 EXTERN int sbbuf_size;
108
109 /* direct I/O info */
110
111 EXTERN int minio_align; /* min I/O size and alignment */
112 EXTERN int mem_align; /* memory alignment */
113 EXTERN int max_iosize; /* max I/O size */
114
115 /* file descriptors */
116
117 EXTERN int fs_fd; /* filesystem fd */
118
119 /* command-line flags */
120
121 EXTERN int verbose;
122 EXTERN int no_modify;
123 EXTERN int isa_file;
124 EXTERN int zap_log;
125 EXTERN int dumpcore; /* abort, not exit on fatal errs */
126 EXTERN int delete_attr_ok; /* can clear attrs w/o clearing files */
127 EXTERN int force_geo; /* can set geo on low confidence info */
128 EXTERN int assume_xfs; /* assume we have an xfs fs */
129 EXTERN int pre_65_beta; /* fs was mkfs'ed by a version earlier * than 6.5-beta */
130 EXTERN char *log_name; /* Name of log device */
131 EXTERN int log_spec; /* Log dev specified as option */
132 EXTERN char *rt_name; /* Name of realtime device */
133 EXTERN int rt_spec; /* Realtime dev specified as option */
134
135 /* misc status variables */
136
137 EXTERN int primary_sb_modified;
138 EXTERN int bad_ino_btree;
139 EXTERN int clear_sunit;
140 EXTERN int fs_is_dirty;
141
142 /* for hunting down the root inode */
143
144 EXTERN int need_root_inode;
145 EXTERN int need_root_dotdot;
146
147 EXTERN int need_rbmino;
148 EXTERN int need_rsumino;
149
150 EXTERN int lost_quotas;
151 EXTERN int have_uquotino;
152 EXTERN int have_gquotino;
153 EXTERN int lost_uquotino;
154 EXTERN int lost_gquotino;
155
156 EXTERN xfs_agino_t first_prealloc_ino;
157 EXTERN xfs_agino_t last_prealloc_ino;
158 EXTERN xfs_agblock_t bnobt_root;
159 EXTERN xfs_agblock_t bcntbt_root;
160 EXTERN xfs_agblock_t inobt_root;
161
162 /* configuration vars -- fs geometry dependent */
163
164 EXTERN int inodes_per_block;
165 EXTERN int inodes_per_cluster; /* inodes per inode buffer */
166 EXTERN unsigned int glob_agcount;
167 EXTERN int chunks_pblock; /* # of 64-ino chunks per allocation */
168 EXTERN int max_symlink_blocks;
169 EXTERN __int64_t fs_max_file_offset;
170
171 /* block allocation bitmaps */
172
173 EXTERN __uint64_t **ba_bmap; /* see incore.h */
174 EXTERN __uint64_t *rt_ba_bmap; /* see incore.h */
175
176 /* realtime info */
177
178 EXTERN xfs_rtword_t *btmcompute;
179 EXTERN xfs_suminfo_t *sumcompute;
180
181 /* inode tree records have full or partial backptr fields ? */
182
183 EXTERN int full_backptrs; /*
184 * if 1, use backptrs_t component
185 * of ino_un union, if 0, use
186 * parent_list_t component. see
187 * incore.h for more details
188 */
189
190 #define ORPHANAGE "lost+found"
191
192 /* superblock counters */
193
194 EXTERN __uint64_t sb_icount; /* allocated (made) inodes */
195 EXTERN __uint64_t sb_ifree; /* free inodes */
196 EXTERN __uint64_t sb_fdblocks; /* free data blocks */
197 EXTERN __uint64_t sb_frextents; /* free realtime extents */
198
199 EXTERN xfs_ino_t orphanage_ino;
200 EXTERN xfs_ino_t old_orphanage_ino;
201
202 /* superblock geometry info */
203
204 EXTERN xfs_extlen_t sb_inoalignmt;
205 EXTERN __uint32_t sb_unit;
206 EXTERN __uint32_t sb_width;
207
208 #endif /* _XFS_REPAIR_GLOBAL_H */