problem.c 38.8 KB
Newer Older
Theodore Ts'o's avatar
Theodore Ts'o committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * problem.c --- report filesystem problems to the user
 *
 * Copyright 1996, 1997 by Theodore Ts'o
 *
 * %Begin-Header%
 * This file may be redistributed under the terms of the GNU Public
 * License.
 * %End-Header%
 */

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <termios.h>

#include "e2fsck.h"

#include "problem.h"
Theodore Ts'o's avatar
Theodore Ts'o committed
21
#include "problemP.h"
Theodore Ts'o's avatar
Theodore Ts'o committed
22

Theodore Ts'o's avatar
Theodore Ts'o committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#define PROMPT_NONE	0
#define PROMPT_FIX	1
#define PROMPT_CLEAR	2
#define PROMPT_RELOCATE	3
#define PROMPT_ALLOCATE 4
#define PROMPT_EXPAND	5
#define PROMPT_CONNECT 	6
#define PROMPT_CREATE	7
#define PROMPT_SALVAGE	8
#define PROMPT_TRUNCATE	9
#define PROMPT_CLEAR_INODE 10
#define PROMPT_ABORT 	11
#define PROMPT_SPLIT 	12
#define PROMPT_CONTINUE	13
#define PROMPT_CLONE	14
#define PROMPT_DELETE 	15
Theodore Ts'o's avatar
Theodore Ts'o committed
39
#define PROMPT_SUPPRESS 16
40
#define PROMPT_UNLINK	17
41
#define PROMPT_NULL	18
Theodore Ts'o's avatar
Theodore Ts'o committed
42 43 44 45 46 47

/*
 * These are the prompts which are used to ask the user if they want
 * to fix a problem.
 */
static const char *prompt[] = {
Theodore Ts'o's avatar
Theodore Ts'o committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
	N_("(no prompt)"),	/* 0 */
	N_("Fix"),		/* 1 */
	N_("Clear"),		/* 2 */
	N_("Relocate"),		/* 3 */
	N_("Allocate"),		/* 4 */
	N_("Expand"),		/* 5 */
	N_("Connect to /lost+found"), /* 6 */
	N_("Create"),		/* 7 */	
	N_("Salvage"),		/* 8 */
	N_("Truncate"),		/* 9 */
	N_("Clear inode"),	/* 10 */
	N_("Abort"),		/* 11 */
	N_("Split"),		/* 12 */
	N_("Continue"),		/* 13 */
	N_("Clone duplicate/bad blocks"), /* 14 */
	N_("Delete file"),	/* 15 */
	N_("Suppress messages"),/* 16 */
	N_("Unlink"),		/* 17 */
66
	"",			/* 18 */
Theodore Ts'o's avatar
Theodore Ts'o committed
67
};
Theodore Ts'o's avatar
Theodore Ts'o committed
68 69 70 71 72 73

/*
 * These messages are printed when we are preen mode and we will be
 * automatically fixing the problem.
 */
static const char *preen_msg[] = {
Theodore Ts'o's avatar
Theodore Ts'o committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
	N_("(NONE)"),		/* 0 */
	N_("FIXED"),		/* 1 */
	N_("CLEARED"),		/* 2 */
	N_("RELOCATED"),	/* 3 */
	N_("ALLOCATED"),	/* 4 */
	N_("EXPANDED"),		/* 5 */
	N_("RECONNECTED"),	/* 6 */
	N_("CREATED"),		/* 7 */
	N_("SALVAGED"),		/* 8 */
	N_("TRUNCATED"),	/* 9 */
	N_("INODE CLEARED"),	/* 10 */
	N_("ABORTED"),		/* 11 */
	N_("SPLIT"),		/* 12 */
	N_("CONTINUING"),	/* 13 */
	N_("DUPLICATE/BAD BLOCKS CLONED"), /* 14 */
	N_("FILE DELETED"),	/* 15 */
	N_("SUPPRESSED"),	/* 16 */
	N_("UNLINKED"),		/* 17 */
Theodore Ts'o's avatar
Theodore Ts'o committed
92 93
};

Theodore Ts'o's avatar
Theodore Ts'o committed
94
static const struct e2fsck_problem problem_table[] = {
Theodore Ts'o's avatar
Theodore Ts'o committed
95 96 97 98

	/* Pre-Pass 1 errors */

	/* Block bitmap not in group */
Theodore Ts'o's avatar
Theodore Ts'o committed
99
	{ PR_0_BB_NOT_GROUP, N_("@b @B for @g %g is not in @g.  (@b %b)\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
100
	  PROMPT_RELOCATE, PR_LATCH_RELOC }, 
Theodore Ts'o's avatar
Theodore Ts'o committed
101 102

	/* Inode bitmap not in group */
Theodore Ts'o's avatar
Theodore Ts'o committed
103
	{ PR_0_IB_NOT_GROUP, N_("@i @B for @g %g is not in @g.  (@b %b)\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
104
	  PROMPT_RELOCATE, PR_LATCH_RELOC }, 
Theodore Ts'o's avatar
Theodore Ts'o committed
105 106 107

	/* Inode table not in group */
	{ PR_0_ITABLE_NOT_GROUP,
Theodore Ts'o's avatar
Theodore Ts'o committed
108 109
	  N_("@i table for @g %g is not in @g.  (@b %b)\n"
	  "WARNING: SEVERE DATA LOSS POSSIBLE.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
110 111 112 113
	  PROMPT_RELOCATE, PR_LATCH_RELOC },

	/* Superblock corrupt */
	{ PR_0_SB_CORRUPT,
Theodore Ts'o's avatar
Theodore Ts'o committed
114
	  N_("\nThe @S could not be read or does not describe a correct ext2\n"
115
	  "@f.  If the @v is valid and it really contains an ext2\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
116
	  "@f (and not swap or ufs or something else), then the @S\n"
117
	  "is corrupt, and you might try running e2fsck with an alternate @S:\n"
118
	  "    e2fsck -b %S <@v>\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
119 120 121 122
	  PROMPT_NONE, PR_FATAL },

	/* Filesystem size is wrong */
	{ PR_0_FS_SIZE_WRONG,
Theodore Ts'o's avatar
Theodore Ts'o committed
123
	  N_("The @f size (according to the @S) is %b @bs\n"
124
	  "The physical size of the @v is %c @bs\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
125
	  "Either the @S or the partition table is likely to be corrupt!\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
126 127 128 129
	  PROMPT_ABORT, 0 },

	/* Fragments not supported */		  
	{ PR_0_NO_FRAGMENTS,
Theodore Ts'o's avatar
Theodore Ts'o committed
130
	  N_("@S @b_size = %b, fragsize = %c.\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
131
	  "This version of e2fsck does not support fragment sizes different\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
132
	  "from the @b size.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
133 134 135 136
	  PROMPT_NONE, PR_FATAL },

	  /* Bad blocks_per_group */
	{ PR_0_BLOCKS_PER_GROUP,
Theodore Ts'o's avatar
Theodore Ts'o committed
137
	  N_("@S @bs_per_group = %b, should have been %c\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
138 139 140 141
	  PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },

	/* Bad first_data_block */
	{ PR_0_FIRST_DATA_BLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
142
	  N_("@S first_data_@b = %b, should have been %c\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
143
	  PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },
Theodore Ts'o's avatar
Theodore Ts'o committed
144
	
Theodore Ts'o's avatar
Theodore Ts'o committed
145 146
	/* Adding UUID to filesystem */
	{ PR_0_ADD_UUID,
Theodore Ts'o's avatar
Theodore Ts'o committed
147
	  N_("@f did not have a UUID; generating one.\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
148 149 150 151
	  PROMPT_NONE, 0 },

	/* Relocate hint */
	{ PR_0_RELOCATE_HINT,
Theodore Ts'o's avatar
Theodore Ts'o committed
152
	  N_("Note: if there is several inode or block bitmap blocks\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
153 154 155 156
	  "which require relocation, or one part of the inode table\n"
	  "which must be moved, you may wish to try running e2fsck\n"
	  "with the '-b %S' option first.  The problem may lie only\n"
	  "with the primary block group descriptor, and the backup\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
157
	  "block group descriptor may be OK.\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
158 159 160 161
	  PROMPT_NONE, PR_PREEN_OK | PR_NOCOLLATE },

	/* Miscellaneous superblock corruption */
	{ PR_0_MISC_CORRUPT_SUPER,
Theodore Ts'o's avatar
Theodore Ts'o committed
162
	  N_("Corruption found in @S.  (%s = %N).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
163 164 165 166
	  PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },

	/* Error determing physical device size of filesystem */
	{ PR_0_GETSIZE_ERROR,	  
167
	  N_("Error determining size of the physical @v: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
168
	  PROMPT_NONE, PR_FATAL },
169 170 171

	/* Inode count in superblock is incorrect */
	{ PR_0_INODE_COUNT_WRONG,
172
	  N_("@i count in @S is %i, should be %j.\n"),
173
	  PROMPT_FIX, 0 },
174 175 176

	{ PR_0_HURD_CLEAR_FILETYPE,
	  N_("The Hurd does not support the filetype feature.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
177 178 179 180
	  PROMPT_CLEAR, 0 },

	/* Journal inode is invalid */
	{ PR_0_JOURNAL_BAD_INODE,
181
	  N_("@S has a bad ext3 @j (@i %i).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
182 183
	  PROMPT_CLEAR, PR_PREEN_OK },

184 185 186 187
	/* The external journal has (unsupported) multiple filesystems */
	{ PR_0_JOURNAL_UNSUPP_MULTIFS,
	  N_("External @j has multiple @f users (unsupported).\n"),
	  PROMPT_NONE, PR_FATAL },
Theodore Ts'o's avatar
Theodore Ts'o committed
188

189 190 191 192 193 194 195 196 197
	/* Can't find external journal */
	{ PR_0_CANT_FIND_JOURNAL,
	  N_("Can't find external @j\n"),
	  PROMPT_NONE, PR_FATAL },

	/* External journal has bad superblock */
	{ PR_0_EXT_JOURNAL_BAD_SUPER,
	  N_("External @j has bad @S\n"),
	  PROMPT_NONE, PR_FATAL },
Theodore Ts'o's avatar
Theodore Ts'o committed
198 199 200

	/* Superblock has a bad journal UUID */
	{ PR_0_JOURNAL_BAD_UUID,
201 202
	  N_("External @j does not support this @f\n"),
	  PROMPT_NONE, PR_FATAL },
Theodore Ts'o's avatar
Theodore Ts'o committed
203 204

	/* Journal has an unknown superblock type */
Theodore Ts'o's avatar
Theodore Ts'o committed
205 206 207 208 209 210
	{ PR_0_JOURNAL_UNSUPP_SUPER,
	  N_("Ext3 @j @S is unknown type %N (unsupported).\n"
	     "It is likely that your copy of e2fsck is old and/or doesn't "
	     "support this @j format.\n"
	     "It is also possible the @j @S is corrupt.\n"),
	  PROMPT_ABORT, PR_NO_OK | PR_AFTER_CODE, PR_0_JOURNAL_BAD_SUPER },
Theodore Ts'o's avatar
Theodore Ts'o committed
211 212 213

	/* Journal superblock is corrupt */
	{ PR_0_JOURNAL_BAD_SUPER,
214
	  N_("Ext3 @j @S is corrupt.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
215 216 217 218
	  PROMPT_FIX, PR_PREEN_OK },

	/* Superblock flag should be cleared */
	{ PR_0_JOURNAL_HAS_JOURNAL,
219
	  N_("@S doesn't have has_@j flag, but has ext3 @j %s.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
220
	  PROMPT_CLEAR, PR_PREEN_OK },
Theodore Ts'o's avatar
Theodore Ts'o committed
221 222 223

	/* Superblock flag is incorrect */
	{ PR_0_JOURNAL_RECOVER_SET,
224
	  N_("@S has ext3 needs_recovery flag set, but no @j.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
225 226
	  PROMPT_CLEAR, PR_PREEN_OK },

227 228 229 230 231 232
	/* Journal has data, but recovery flag is clear */
	{ PR_0_JOURNAL_RECOVERY_CLEAR,
	  N_("ext3 recovery flag clear, but @j has data.\n"),
	  PROMPT_NONE, 0 },

	/* Ask if we should clear the journal */
Theodore Ts'o's avatar
Theodore Ts'o committed
233
	{ PR_0_JOURNAL_RESET_JOURNAL,
234 235
	  N_("Clear @j"),
	  PROMPT_NULL, PR_PREEN_NOMSG },
Theodore Ts'o's avatar
Theodore Ts'o committed
236

237 238 239 240 241 242 243 244 245
	/* Ask if we should run the journal anyway */
	{ PR_0_JOURNAL_RUN,
	  N_("Run @j anyway"),
	  PROMPT_NULL, 0 },

	/* Run the journal by default */
	{ PR_0_JOURNAL_RUN_DEFAULT,
	  N_("Recovery flag not set in backup @S, so running @j anyway.\n"),
	  PROMPT_NONE, 0 },
246

247
	/* Clearing orphan inode */
248 249
	{ PR_0_ORPHAN_CLEAR_INODE,
	  N_("%s @o @i %i (uid=%Iu, gid=%Ig, mode=%Im, size=%Is)\n"),
250 251
	  PROMPT_NONE, 0 },

Theodore Ts'o's avatar
Theodore Ts'o committed
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
	/* Illegal block found in orphaned inode */
	{ PR_0_ORPHAN_ILLEGAL_BLOCK_NUM,
	   N_("@I @b #%B (%b) found in @o @i %i.\n"),
	  PROMPT_NONE, 0 },
		  
	/* Already cleared block found in orphaned inode */
	{ PR_0_ORPHAN_ALREADY_CLEARED_BLOCK,
	   N_("Already cleared @b #%B (%b) found in @o @i %i.\n"),
	  PROMPT_NONE, 0 },
  
	/* Illegal orphan inode in superblock */
	{ PR_0_ORPHAN_ILLEGAL_HEAD_INODE,
	  N_("@I @o @i %i in @S.\n"),
	  PROMPT_NONE, 0 },

	/* Illegal inode in orphaned inode list */
	{ PR_0_ORPHAN_ILLEGAL_INODE,
	  N_("@I @i %i in @o @i list.\n"),
	  PROMPT_NONE, 0 },

272 273
	/* Filesystem revision is 0, but feature flags are set */
	{ PR_0_FS_REV_LEVEL,
Theodore Ts'o's avatar
Theodore Ts'o committed
274
	  "@f has feature flag(s) set, but is a revision 0 @f.  ",
275 276
	  PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },

277 278 279
	/* Journal superblock has an unknown read-only feature flag set */
	{ PR_0_JOURNAL_UNSUPP_ROCOMPAT,
	  N_("Ext3 @j @S has an unknown read-only feature flag set.\n"),
280
	  PROMPT_ABORT, 0 },
281 282 283 284

	/* Journal superblock has an unknown incompatible feature flag set */
	{ PR_0_JOURNAL_UNSUPP_INCOMPAT,
	  N_("Ext3 @j @S has an unknown incompatible feature flag set.\n"),
285
	  PROMPT_ABORT, 0 },
286 287 288 289 290

	/* Journal has unsupported version number */
	{ PR_0_JOURNAL_UNSUPP_VERSION,
	  N_("@j version not supported by this e2fsck.\n"),
	  PROMPT_ABORT, 0 },
291 292 293 294 295 296 297 298 299 300 301

	/* Moving journal to hidden file */
	{ PR_0_MOVE_JOURNAL,
	  N_("Moving @j from /%s to hidden inode.\n\n"),
	  PROMPT_NONE, 0 },

	/* Error moving journal to hidden file */
	{ PR_0_ERR_MOVE_JOURNAL,
	  N_("Error moving @j: %m\n\n"),
	  PROMPT_NONE, 0 },

302 303 304 305 306 307
	/* Clearing V2 journal superblock */
	{ PR_0_CLEAR_V2_JOURNAL,
	  N_("Found invalid V2 @j @S fields (from V1 journal).\n"
	     "Clearing fields beyond the V1 @j @S...\n\n"),
	  PROMPT_NONE, 0 },

Theodore Ts'o's avatar
Theodore Ts'o committed
308 309
	/* Pass 1 errors */
	
Theodore Ts'o's avatar
Theodore Ts'o committed
310 311
	/* Pass 1: Checking inodes, blocks, and sizes */
	{ PR_1_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
312
	  N_("Pass 1: Checking @is, @bs, and sizes\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
313 314
	  PROMPT_NONE, 0 },
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
315
	/* Root directory is not an inode */
Theodore Ts'o's avatar
Theodore Ts'o committed
316
	{ PR_1_ROOT_NO_DIR, N_("@r is not a @d.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
317 318 319 320
	  PROMPT_CLEAR, 0 }, 

	/* Root directory has dtime set */
	{ PR_1_ROOT_DTIME,
Theodore Ts'o's avatar
Theodore Ts'o committed
321
	  N_("@r has dtime set (probably due to old mke2fs).  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
322 323 324 325
	  PROMPT_FIX, PR_PREEN_OK },

	/* Reserved inode has bad mode */
	{ PR_1_RESERVED_BAD_MODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
326
	  N_("Reserved @i %i %Q has bad mode.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
327 328 329 330
	  PROMPT_CLEAR, PR_PREEN_OK },

	/* Deleted inode has zero dtime */
	{ PR_1_ZERO_DTIME,
Theodore Ts'o's avatar
Theodore Ts'o committed
331
	  N_("@D @i %i has zero dtime.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
332 333 334 335
	  PROMPT_FIX, PR_PREEN_OK },

	/* Inode in use, but dtime set */
	{ PR_1_SET_DTIME,
Theodore Ts'o's avatar
Theodore Ts'o committed
336
	  N_("@i %i is in use, but has dtime set.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
337 338 339 340
	  PROMPT_FIX, PR_PREEN_OK },

	/* Zero-length directory */
	{ PR_1_ZERO_LENGTH_DIR,
Theodore Ts'o's avatar
Theodore Ts'o committed
341
	  N_("@i %i is a @z @d.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
342 343 344 345
	  PROMPT_CLEAR, PR_PREEN_OK },

	/* Block bitmap conflicts with some other fs block */
	{ PR_1_BB_CONFLICT,
Theodore Ts'o's avatar
Theodore Ts'o committed
346
	  N_("@g %g's @b @B at %b @C.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
347 348 349 350
	  PROMPT_RELOCATE, 0 },

	/* Inode bitmap conflicts with some other fs block */
	{ PR_1_IB_CONFLICT,
Theodore Ts'o's avatar
Theodore Ts'o committed
351
	  N_("@g %g's @i @B at %b @C.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
352 353 354 355
	  PROMPT_RELOCATE, 0 },

	/* Inode table conflicts with some other fs block */
	{ PR_1_ITABLE_CONFLICT,
Theodore Ts'o's avatar
Theodore Ts'o committed
356
	  N_("@g %g's @i table at %b @C.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
357 358 359 360
	  PROMPT_RELOCATE, 0 },

	/* Block bitmap is on a bad block */
	{ PR_1_BB_BAD_BLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
361
	  N_("@g %g's @b @B (%b) is bad.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
362 363 364 365
	  PROMPT_RELOCATE, 0 },

	/* Inode bitmap is on a bad block */
	{ PR_1_IB_BAD_BLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
366
	  N_("@g %g's @i @B (%b) is bad.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
367 368 369 370
	  PROMPT_RELOCATE, 0 },

	/* Inode has incorrect i_size */
	{ PR_1_BAD_I_SIZE,
Theodore Ts'o's avatar
Theodore Ts'o committed
371
	  N_("@i %i, i_size is %Is, @s %N.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
372
	  PROMPT_FIX, PR_PREEN_OK },
Theodore Ts'o's avatar
Theodore Ts'o committed
373 374 375
		  
	/* Inode has incorrect i_blocks */
	{ PR_1_BAD_I_BLOCKS,
Theodore Ts'o's avatar
Theodore Ts'o committed
376
	  N_("@i %i, i_@bs is %Ib, @s %N.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
377
	  PROMPT_FIX, PR_PREEN_OK },
Theodore Ts'o's avatar
Theodore Ts'o committed
378

Theodore Ts'o's avatar
Theodore Ts'o committed
379
	/* Illegal blocknumber in inode */
Theodore Ts'o's avatar
Theodore Ts'o committed
380
	{ PR_1_ILLEGAL_BLOCK_NUM,
Theodore Ts'o's avatar
Theodore Ts'o committed
381
	  N_("@I @b #%B (%b) in @i %i.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
382 383 384 385
	  PROMPT_CLEAR, PR_LATCH_BLOCK },

	/* Block number overlaps fs metadata */
	{ PR_1_BLOCK_OVERLAPS_METADATA,
Theodore Ts'o's avatar
Theodore Ts'o committed
386
	  N_("@b #%B (%b) overlaps @f metadata in @i %i.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
387 388 389 390
	  PROMPT_CLEAR, PR_LATCH_BLOCK },

	/* Inode has illegal blocks (latch question) */
	{ PR_1_INODE_BLOCK_LATCH,
Theodore Ts'o's avatar
Theodore Ts'o committed
391
	  N_("@i %i has illegal @b(s).  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
392 393 394 395
	  PROMPT_CLEAR, 0 },

	/* Too many bad blocks in inode */
	{ PR_1_TOO_MANY_BAD_BLOCKS,
Theodore Ts'o's avatar
Theodore Ts'o committed
396
	  N_("Too many illegal @bs in @i %i.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
397 398 399 400
	  PROMPT_CLEAR_INODE, PR_NO_OK }, 	

	/* Illegal block number in bad block inode */
	{ PR_1_BB_ILLEGAL_BLOCK_NUM,
Theodore Ts'o's avatar
Theodore Ts'o committed
401
	  N_("@I @b #%B (%b) in bad @b @i.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
402 403 404 405
	  PROMPT_CLEAR, PR_LATCH_BBLOCK },

	/* Bad block inode has illegal blocks (latch question) */
	{ PR_1_INODE_BBLOCK_LATCH,
Theodore Ts'o's avatar
Theodore Ts'o committed
406
	  N_("Bad @b @i has illegal @b(s).  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
407 408
	  PROMPT_CLEAR, 0 },

Theodore Ts'o's avatar
Theodore Ts'o committed
409 410
	/* Duplicate or bad blocks in use! */
	{ PR_1_DUP_BLOCKS_PREENSTOP,
Theodore Ts'o's avatar
Theodore Ts'o committed
411
	  N_("Duplicate or bad @b in use!\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
412 413 414 415
	  PROMPT_NONE, 0 },

	/* Bad block used as bad block indirect block */	  
	{ PR_1_BBINODE_BAD_METABLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
416
	  N_("Bad @b %b used as bad @b indirect @b?!?\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
417 418 419 420
	  PROMPT_NONE, PR_AFTER_CODE, PR_1_BBINODE_BAD_METABLOCK_PROMPT },

	/* Inconsistency can't be fixed prompt */	  
	{ PR_1_BBINODE_BAD_METABLOCK_PROMPT,
Theodore Ts'o's avatar
Theodore Ts'o committed
421
	  N_("\nThis inconsistency can not be fixed with e2fsck; to fix it, use\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
422 423
	  """dumpe2fs -b"" to dump out the bad @b "
	  "list and ""e2fsck -L filename""\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
424
	  "to read it back in again.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
425 426 427 428
	  PROMPT_CONTINUE, PR_PREEN_NOMSG },

	/* Bad primary block */
	{ PR_1_BAD_PRIMARY_BLOCK,  
Theodore Ts'o's avatar
Theodore Ts'o committed
429
	  N_("\nIf the @b is really bad, the @f can not be fixed.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
430 431 432 433
	  PROMPT_NONE, PR_AFTER_CODE, PR_1_BAD_PRIMARY_BLOCK_PROMPT },
		  
	/* Bad primary block prompt */
	{ PR_1_BAD_PRIMARY_BLOCK_PROMPT,	  
Theodore Ts'o's avatar
Theodore Ts'o committed
434
	  N_("You can clear the this @b (and hope for the best) from the\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
435
	  "bad @b list and hope that @b is really OK, but there are no\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
436
	  "guarantees.\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
437 438 439 440
	  PROMPT_CLEAR, PR_PREEN_NOMSG },

	/* Bad primary superblock */
	{ PR_1_BAD_PRIMARY_SUPERBLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
441
	  N_("The primary @S (%b) is on the bad @b list.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
442 443 444 445
	  PROMPT_NONE, PR_AFTER_CODE, PR_1_BAD_PRIMARY_BLOCK },
		  
	/* Bad primary block group descriptors */
	{ PR_1_BAD_PRIMARY_GROUP_DESCRIPTOR,
Theodore Ts'o's avatar
Theodore Ts'o committed
446 447
	  N_("Block %b in the primary @g descriptors "
	  "is on the bad @b list\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
448 449 450 451
	  PROMPT_NONE, PR_AFTER_CODE, PR_1_BAD_PRIMARY_BLOCK },
		  
	/* Bad superblock in group */
	{ PR_1_BAD_SUPERBLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
452
	  N_("Warning: Group %g's @S (%b) is bad.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
453 454 455 456
	  PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },
		  
	/* Bad block group descriptors in group */
	{ PR_1_BAD_GROUP_DESCRIPTORS,
Theodore Ts'o's avatar
Theodore Ts'o committed
457 458
	  N_("Warning: Group %g's copy of the @g descriptors has a bad "
	  "@b (%b).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
459 460 461 462
	  PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Block claimed for no reason */	  
	{ PR_1_PROGERR_CLAIMED_BLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
463 464
	  N_("Programming error?  @b #%b claimed for no reason in "
	  "process_bad_@b.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
465 466
	  PROMPT_NONE, PR_PREEN_OK },

Theodore Ts'o's avatar
Theodore Ts'o committed
467
	/* Error allocating blocks for relocating metadata */
Theodore Ts'o's avatar
Theodore Ts'o committed
468
	{ PR_1_RELOC_BLOCK_ALLOCATE,
Theodore Ts'o's avatar
Theodore Ts'o committed
469
	  N_("@A %N @b(s) for %s: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
470 471
	  PROMPT_NONE, PR_PREEN_OK },
		
Theodore Ts'o's avatar
Theodore Ts'o committed
472
	/* Error allocating block buffer during relocation process */
Theodore Ts'o's avatar
Theodore Ts'o committed
473
	{ PR_1_RELOC_MEMORY_ALLOCATE,
Theodore Ts'o's avatar
Theodore Ts'o committed
474
	  N_("@A @b buffer for relocating %s\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
475 476 477 478
	  PROMPT_NONE, PR_PREEN_OK },
		
	/* Relocating metadata group information from X to Y */	
	{ PR_1_RELOC_FROM_TO,
Theodore Ts'o's avatar
Theodore Ts'o committed
479
	  N_("Relocating @g %g's %s from %b to %c...\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
480 481 482 483
	  PROMPT_NONE, PR_PREEN_OK },
		
	/* Relocating metatdata group information to X */
	{ PR_1_RELOC_TO,
Theodore Ts'o's avatar
Theodore Ts'o committed
484
	  N_("Relocating @g %g's %s to %c...\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
485 486 487 488
	  PROMPT_NONE, PR_PREEN_OK },
		
	/* Block read error during relocation process */
	{ PR_1_RELOC_READ_ERR,
Theodore Ts'o's avatar
Theodore Ts'o committed
489
	  N_("Warning: could not read @b %b of %s: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
490 491 492 493
	  PROMPT_NONE, PR_PREEN_OK },
		
	/* Block write error during relocation process */
	{ PR_1_RELOC_WRITE_ERR,
Theodore Ts'o's avatar
Theodore Ts'o committed
494
	  N_("Warning: could not write @b %b for %s: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
495 496 497 498
	  PROMPT_NONE, PR_PREEN_OK },

	/* Error allocating inode bitmap */
	{ PR_1_ALLOCATE_IBITMAP_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
499
	  "@A @i @B (%N): %m\n",
Theodore Ts'o's avatar
Theodore Ts'o committed
500 501 502 503
	  PROMPT_NONE, PR_FATAL },

	/* Error allocating block bitmap */
	{ PR_1_ALLOCATE_BBITMAP_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
504
	  "@A @b @B (%N): %m\n",
Theodore Ts'o's avatar
Theodore Ts'o committed
505 506 507 508
	  PROMPT_NONE, PR_FATAL },

	/* Error allocating icount structure */
	{ PR_1_ALLOCATE_ICOUNT,
Theodore Ts'o's avatar
Theodore Ts'o committed
509
	  N_("@A icount link information: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
510 511 512 513
	  PROMPT_NONE, PR_FATAL },

	/* Error allocating dbcount */
	{ PR_1_ALLOCATE_DBCOUNT,
Theodore Ts'o's avatar
Theodore Ts'o committed
514
	  N_("@A @d @b array: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
515 516 517 518
	  PROMPT_NONE, PR_FATAL },

	/* Error while scanning inodes */
	{ PR_1_ISCAN_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
519
	  N_("Error while scanning @is (%i): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
520 521 522 523
	  PROMPT_NONE, PR_FATAL },

	/* Error while iterating over blocks */
	{ PR_1_BLOCK_ITERATE,
524
	  N_("Error while iterating over @bs in @i %i: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
525 526 527 528
	  PROMPT_NONE, PR_FATAL },

	/* Error while storing inode count information */	  
	{ PR_1_ICOUNT_STORE,
529
	  N_("Error storing @i count information (@i=%i, count=%N): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
530 531 532 533
	  PROMPT_NONE, PR_FATAL },

	/* Error while storing directory block information */	  
	{ PR_1_ADD_DBLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
534
	  N_("Error storing @d @b information "
535
	  "(@i=%i, @b=%b, num=%N): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
536 537 538 539
	  PROMPT_NONE, PR_FATAL },

	/* Error while reading inode (for clearing) */	  
	{ PR_1_READ_INODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
540
	  N_("Error reading @i %i: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
541
	  PROMPT_NONE, PR_FATAL },
Theodore Ts'o's avatar
Theodore Ts'o committed
542 543 544

	/* Suppress messages prompt */
	{ PR_1_SUPPRESS_MESSAGES, "", PROMPT_SUPPRESS, PR_NO_OK },
Theodore Ts'o's avatar
Theodore Ts'o committed
545
		  
546 547
	/* Imagic flag set on an inode when filesystem doesn't support it */
	{ PR_1_SET_IMAGIC,
Theodore Ts'o's avatar
Theodore Ts'o committed
548
	  N_("@i %i has imagic flag set.  "),
549 550 551 552
	  PROMPT_CLEAR, 0 },

	/* Immutable flag set on a device or socket inode */
	{ PR_1_SET_IMMUTABLE,
553 554
	  N_("Special (@v/socket/fifo/symlink) file (@i %i) has immutable\n"
	     "or append-only flag set.  "),
555
	  PROMPT_CLEAR, PR_PREEN_OK | PR_PREEN_NO | PR_NO_OK },
556

Theodore Ts'o's avatar
Theodore Ts'o committed
557
	/* Compression flag set on an inode when filesystem doesn't support it */
Theodore Ts'o's avatar
Theodore Ts'o committed
558 559 560 561
	{ PR_1_COMPR_SET,
	  N_("@i %i has @cion flag set on @f without @cion support.  "),
	  PROMPT_CLEAR, 0 },

562 563
	/* Non-zero size for device, fifo or socket inode */
	{ PR_1_SET_NONZSIZE,
564
	  "Special (@v/socket/fifo) @i %i has non-zero size.  ",
565
	  PROMPT_FIX, PR_PREEN_OK },
566 567 568

	/* Filesystem revision is 0, but feature flags are set */
	{ PR_1_FS_REV_LEVEL,
569
	  "@f has feature flag(s) set, but is a revision 0 @f.  ",
570 571
	  PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },

572
	/* Journal inode is not in use, but contains data */	  
573
	{ PR_1_JOURNAL_INODE_NOT_CLEAR,
574 575 576
	  "@j @i is not in use, but contains data.  ",
	  PROMPT_CLEAR, PR_PREEN_OK },	  
	  
577 578
	/* Journal has bad mode */
	{ PR_1_JOURNAL_BAD_MODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
579
	  N_("@j is not regular file.  "),
580 581
	  PROMPT_FIX, PR_PREEN_OK },

582 583 584 585 586 587 588 589 590 591 592
	/* Deal with inodes that were part of orphan linked list */
	{ PR_1_LOW_DTIME,
	  N_("@i %i was part of the orphaned @i list.  "),
	  PROMPT_FIX, PR_LATCH_LOW_DTIME, 0 },    

	/* Deal with inodes that were part of corrupted orphan linked
	   list (latch question) */
	{ PR_1_ORPHAN_LIST_REFUGEES,
	  N_("@is that were part of a corrupted orphan linked list found.  "),
	  PROMPT_FIX, 0 },		  
		  
593 594 595 596 597 598 599 600 601 602
	/* Error allocating refcount structure */
	{ PR_1_ALLOCATE_REFCOUNT,
	  "@A refcount structure (%N): %m\n",
	  PROMPT_NONE, PR_FATAL },

	/* Error reading extended attribute block */
	{ PR_1_READ_EA_BLOCK,
	  N_("Error reading @a @b %b for @i %i.  "),
	  PROMPT_CLEAR, 0 },

603
	/* Invalid extended attribute block */
604 605 606 607
	{ PR_1_BAD_EA_BLOCK,
	  N_("@i %i has a bad @a @b %b.  "),
	  PROMPT_CLEAR, 0 },

608 609 610 611 612 613 614 615 616 617 618 619 620 621
	/* Error reading Extended Attribute block while fixing refcount */
	{ PR_1_EXTATTR_READ_ABORT,
	  N_("Error reading @a @b %b (%m).  "),
	  PROMPT_ABORT, 0 },
		  
	/* Extended attribute reference count incorrect */
	{ PR_1_EXTATTR_REFCOUNT,
	  N_("@a @b %b has reference count %B, should be %N.  "),
	  PROMPT_FIX, 0 },
		  
	/* Error writing Extended Attribute block while fixing refcount */ 
	{ PR_1_EXTATTR_WRITE,
	  N_("Error writing @a @b %b (%m).  "),
	  PROMPT_ABORT, 0 },
622 623 624 625 626 627 628 629 630 631 632 633 634 635

	/* Multiple EA blocks not supported */
	{ PR_1_EA_MULTI_BLOCK,
	  N_("@a @b %b has h_blocks > 1.  "),
	  PROMPT_CLEAR, 0},	  

	/* Error allocating EA region allocation structure */
	{ PR_1_EA_ALLOC_REGION,
	  N_("Error allocating @a @b %b.  "),
	  PROMPT_ABORT, 0},
	
	/* Error EA allocation collision */
	{ PR_1_EA_ALLOC_COLLISION,
	  N_("@a @b %b is corrupt (allocation collision).  "),
636
	  PROMPT_CLEAR, 0},
637 638 639 640 641 642 643 644 645 646
	
	/* Bad extended attribute name */
	{ PR_1_EA_BAD_NAME,
	  N_("@a @b %b is corrupt (invalid name).  "),
	  PROMPT_CLEAR, 0},	  

	/* Bad extended attribute value */
	{ PR_1_EA_BAD_VALUE,
	  N_("@a @b %b is corrupt (invalid value).  "),
	  PROMPT_CLEAR, 0},	  
647
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
648 649
	/* Pass 1b errors */

Theodore Ts'o's avatar
Theodore Ts'o committed
650 651
	/* Pass 1B: Rescan for duplicate/bad blocks */
	{ PR_1B_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
652 653
	  N_("Duplicate @bs found... invoking duplicate @b passes.\n"
	  "Pass 1B: Rescan for duplicate/bad @bs\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
654 655 656 657
	  PROMPT_NONE, 0 },

	/* Duplicate/bad block(s) header */
	{ PR_1B_DUP_BLOCK_HEADER,	  
Theodore Ts'o's avatar
Theodore Ts'o committed
658
	  N_("Duplicate/bad @b(s) in @i %i:"),
Theodore Ts'o's avatar
Theodore Ts'o committed
659 660 661 662 663 664 665 666 667 668 669 670 671 672
	  PROMPT_NONE, 0 },

	/* Duplicate/bad block(s) in inode */
	{ PR_1B_DUP_BLOCK,	  
	  " %b",
	  PROMPT_NONE, PR_LATCH_DBLOCK },

	/* Duplicate/bad block(s) end */
	{ PR_1B_DUP_BLOCK_END,
	  "\n",
	  PROMPT_NONE, 0 },
		  
	/* Error while scanning inodes */
	{ PR_1B_ISCAN_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
673
	  N_("Error while scanning inodes (%i): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
674 675 676 677
	  PROMPT_NONE, PR_FATAL },

	/* Error allocating inode bitmap */
	{ PR_1B_ALLOCATE_IBITMAP_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
678
	  N_("@A @i @B (inode_dup_map): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
679 680
	  PROMPT_NONE, PR_FATAL },

681 682 683 684 685
	/* Error while iterating over blocks */
	{ PR_1B_BLOCK_ITERATE,
	  N_("Error while iterating over @bs in @i %i (%s): %m\n"),
	  PROMPT_NONE, 0 },
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
686 687
	/* Pass 1C: Scan directories for inodes with dup blocks. */
	{ PR_1C_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
688
	  N_("Pass 1C: Scan directories for @is with dup @bs.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
689 690 691 692 693
	  PROMPT_NONE, 0 },

		  
	/* Pass 1D: Reconciling duplicate blocks */
	{ PR_1D_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
694
	  N_("Pass 1D: Reconciling duplicate @bs\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
695 696
	  PROMPT_NONE, 0 },
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
697
	/* File has duplicate blocks */
Theodore Ts'o's avatar
Theodore Ts'o committed
698
	{ PR_1D_DUP_FILE,
Theodore Ts'o's avatar
Theodore Ts'o committed
699 700
	  N_("File %Q (@i #%i, mod time %IM) \n"
	  "  has %B duplicate @b(s), shared with %N file(s):\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
701
	  PROMPT_NONE, 0 },
Theodore Ts'o's avatar
Theodore Ts'o committed
702 703
		  
	/* List of files sharing duplicate blocks */	
Theodore Ts'o's avatar
Theodore Ts'o committed
704
	{ PR_1D_DUP_FILE_LIST,
Theodore Ts'o's avatar
Theodore Ts'o committed
705
	  N_("\t%Q (@i #%i, mod time %IM)\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
706
	  PROMPT_NONE, 0 },
Theodore Ts'o's avatar
Theodore Ts'o committed
707
	  
Theodore Ts'o's avatar
Theodore Ts'o committed
708
	/* File sharing blocks with filesystem metadata  */	
Theodore Ts'o's avatar
Theodore Ts'o committed
709
	{ PR_1D_SHARE_METADATA,
Theodore Ts'o's avatar
Theodore Ts'o committed
710
	  N_("\t<@f metadata>\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
711 712 713 714
	  PROMPT_NONE, 0 },

	/* Report of how many duplicate/bad inodes */	
	{ PR_1D_NUM_DUP_INODES,
Theodore Ts'o's avatar
Theodore Ts'o committed
715
	  N_("(There are %N @is containing duplicate/bad @bs.)\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
716 717 718 719
	  PROMPT_NONE, 0 },

	/* Duplicated blocks already reassigned or cloned. */
	{ PR_1D_DUP_BLOCKS_DEALT,
Theodore Ts'o's avatar
Theodore Ts'o committed
720
	  N_("Duplicated @bs already reassigned or cloned.\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
721 722 723 724 725 726 727 728 729 730 731 732
	  PROMPT_NONE, 0 },

	/* Clone duplicate/bad blocks? */
	{ PR_1D_CLONE_QUESTION,
	  "", PROMPT_CLONE, PR_NO_OK },
		  
	/* Delete file? */
	{ PR_1D_DELETE_QUESTION,
	  "", PROMPT_DELETE, 0 },

	/* Couldn't clone file (error) */
	{ PR_1D_CLONE_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
733
	  N_("Couldn't clone file: %m\n"), PROMPT_NONE, 0 },
Theodore Ts'o's avatar
Theodore Ts'o committed
734 735 736

	/* Pass 2 errors */

Theodore Ts'o's avatar
Theodore Ts'o committed
737 738
	/* Pass 2: Checking directory structure */
	{ PR_2_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
739
	  N_("Pass 2: Checking @d structure\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
740 741
	  PROMPT_NONE, 0 },
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
742 743
	/* Bad inode number for '.' */
	{ PR_2_BAD_INODE_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
744
	  N_("Bad @i number for '.' in @d @i %i.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
745 746 747 748
	  PROMPT_FIX, 0 },

	/* Directory entry has bad inode number */
	{ PR_2_BAD_INO, 
Theodore Ts'o's avatar
Theodore Ts'o committed
749
	  N_("@E has bad @i #: %Di.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
750 751 752 753
	  PROMPT_CLEAR, 0 },

	/* Directory entry has deleted or unused inode */
	{ PR_2_UNUSED_INODE, 
Theodore Ts'o's avatar
Theodore Ts'o committed
754
	  N_("@E has @D/unused @i %Di.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
755 756 757 758
	  PROMPT_CLEAR, PR_PREEN_OK },

	/* Directry entry is link to '.' */
	{ PR_2_LINK_DOT, 
Theodore Ts'o's avatar
Theodore Ts'o committed
759
	  N_("@E @L to '.'  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
760 761 762 763
	  PROMPT_CLEAR, 0 },

	/* Directory entry points to inode now located in a bad block */
	{ PR_2_BB_INODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
764
	  N_("@E points to @i (%Di) located in a bad @b.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
765 766 767 768
	  PROMPT_CLEAR, 0 },

	/* Directory entry contains a link to a directory */
	{ PR_2_LINK_DIR, 
Theodore Ts'o's avatar
Theodore Ts'o committed
769
	  N_("@E @L to @d %P (%Di).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
770 771 772 773
	  PROMPT_CLEAR, 0 },

	/* Directory entry contains a link to the root directry */
	{ PR_2_LINK_ROOT, 
Theodore Ts'o's avatar
Theodore Ts'o committed
774
	  N_("@E @L to the @r.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
775 776 777 778
	  PROMPT_CLEAR, 0 },

	/* Directory entry has illegal characters in its name */
	{ PR_2_BAD_NAME, 
Theodore Ts'o's avatar
Theodore Ts'o committed
779
	  N_("@E has illegal characters in its name.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
780 781 782 783
	  PROMPT_FIX, 0 },

	/* Missing '.' in directory inode */	  
	{ PR_2_MISSING_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
784
	  N_("Missing '.' in @d @i %i.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
785 786 787 788
	  PROMPT_FIX, 0 },

	/* Missing '..' in directory inode */	  
	{ PR_2_MISSING_DOT_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
789
	  N_("Missing '..' in @d @i %i.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
790 791 792 793
	  PROMPT_FIX, 0 },

	/* First entry in directory inode doesn't contain '.' */
	{ PR_2_1ST_NOT_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
794
	  N_("First @e '%Dn' (inode=%Di) in @d @i %i (%p) @s '.'\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
795 796 797 798
	  PROMPT_FIX, 0 },

	/* Second entry in directory inode doesn't contain '..' */
	{ PR_2_2ND_NOT_DOT_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
799
	  N_("Second @e '%Dn' (inode=%Di) in @d @i %i @s '..'\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
800 801 802 803
	  PROMPT_FIX, 0 },
		  
	/* i_faddr should be zero */
	{ PR_2_FADDR_ZERO,
Theodore Ts'o's avatar
Theodore Ts'o committed
804
	  N_("i_faddr @F %IF, @s zero.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
805 806 807 808
	  PROMPT_CLEAR, 0 },

  	/* i_file_acl should be zero */
	{ PR_2_FILE_ACL_ZERO,
Theodore Ts'o's avatar
Theodore Ts'o committed
809
	  N_("i_file_acl @F %If, @s zero.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
810 811 812 813
	  PROMPT_CLEAR, 0 },

  	/* i_dir_acl should be zero */
	{ PR_2_DIR_ACL_ZERO,
Theodore Ts'o's avatar
Theodore Ts'o committed
814
	  N_("i_dir_acl @F %Id, @s zero.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
815 816 817 818
	  PROMPT_CLEAR, 0 },

  	/* i_frag should be zero */
	{ PR_2_FRAG_ZERO,
Theodore Ts'o's avatar
Theodore Ts'o committed
819
	  N_("i_frag @F %N, @s zero.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
820 821 822 823
	  PROMPT_CLEAR, 0 },

  	/* i_fsize should be zero */
	{ PR_2_FSIZE_ZERO,
Theodore Ts'o's avatar
Theodore Ts'o committed
824
	  N_("i_fsize @F %N, @s zero.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
825 826 827 828
	  PROMPT_CLEAR, 0 },

	/* inode has bad mode */
	{ PR_2_BAD_MODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
829
	  N_("@i %i (%Q) has a bad mode (%Im).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
830 831 832 833
	  PROMPT_CLEAR, 0 },

	/* directory corrupted */
	{ PR_2_DIR_CORRUPTED,	  
Theodore Ts'o's avatar
Theodore Ts'o committed
834
	  N_("@d @i %i, @b %B, offset %N: @d corrupted\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
835 836 837 838
	  PROMPT_SALVAGE, 0 },
		  
	/* filename too long */
	{ PR_2_FILENAME_LONG,	  
Theodore Ts'o's avatar
Theodore Ts'o committed
839
	  N_("@d @i %i, @b %B, offset %N: filename too long\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
840 841 842 843
	  PROMPT_TRUNCATE, 0 },

	/* Directory inode has a missing block (hole) */
	{ PR_2_DIRECTORY_HOLE,	  
Theodore Ts'o's avatar
Theodore Ts'o committed
844
	  N_("@d @i %i has an unallocated @b #%B.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
845 846 847 848
	  PROMPT_ALLOCATE, 0 },

	/* '.' is not NULL terminated */
	{ PR_2_DOT_NULL_TERM,
Theodore Ts'o's avatar
Theodore Ts'o committed
849
	  N_("'.' @d @e in @d @i %i is not NULL terminated\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
850 851 852 853
	  PROMPT_FIX, 0 },

	/* '..' is not NULL terminated */
	{ PR_2_DOT_DOT_NULL_TERM,
Theodore Ts'o's avatar
Theodore Ts'o committed
854
	  N_("'..' @d @e in @d @i %i is not NULL terminated\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
855 856
	  PROMPT_FIX, 0 },

857 858
	/* Illegal character device inode */
	{ PR_2_BAD_CHAR_DEV,
859
	  N_("@i %i (%Q) is an @I character @v.\n"),
860 861 862 863
	  PROMPT_CLEAR, 0 },

	/* Illegal block device inode */
	{ PR_2_BAD_BLOCK_DEV,
864
	  N_("@i %i (%Q) is an @I @b @v.\n"),
865 866
	  PROMPT_CLEAR, 0 },

Theodore Ts'o's avatar
Theodore Ts'o committed
867 868
	/* Duplicate '.' entry */
	{ PR_2_DUP_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
869
	  N_("@E is duplicate '.' @e.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
870
	  PROMPT_FIX, 0 },	  
Theodore Ts'o's avatar
Theodore Ts'o committed
871

Theodore Ts'o's avatar
Theodore Ts'o committed
872 873
	/* Duplicate '..' entry */
	{ PR_2_DUP_DOT_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
874
	  N_("@E is duplicate '..' @e.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
875 876 877 878
	  PROMPT_FIX, 0 },

	/* Internal error: couldn't find dir_info */
	{ PR_2_NO_DIRINFO,
Theodore Ts'o's avatar
Theodore Ts'o committed
879
	  N_("Internal error: couldn't find dir_info for %i.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
880 881 882 883
	  PROMPT_NONE, PR_FATAL },

	/* Final rec_len is wrong */
	{ PR_2_FINAL_RECLEN,
884
	  N_("@E has rec_len of %Dr, should be %N.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
885 886 887 888
	  PROMPT_FIX, 0 },
		  
	/* Error allocating icount structure */
	{ PR_2_ALLOCATE_ICOUNT,
Theodore Ts'o's avatar
Theodore Ts'o committed
889
	  N_("@A icount structure: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
890 891 892 893
	  PROMPT_NONE, PR_FATAL },

	/* Error iterating over directory blocks */
	{ PR_2_DBLIST_ITERATE,
Theodore Ts'o's avatar
Theodore Ts'o committed
894
	  N_("Error interating over @d @bs: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
895 896 897 898
	  PROMPT_NONE, PR_FATAL },

	/* Error reading directory block */
	{ PR_2_READ_DIRBLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
899
	  N_("Error reading @d @b %b (@i %i): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
900 901 902 903
	  PROMPT_CONTINUE, 0 },

	/* Error writing directory block */
	{ PR_2_WRITE_DIRBLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
904
	  N_("Error writing @d @b %b (@i %i): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
905 906 907 908
	  PROMPT_CONTINUE, 0 },

	/* Error allocating new directory block */
	{ PR_2_ALLOC_DIRBOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
909
	  N_("@A new @d @b for @i %i (%s): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
910 911 912 913
	  PROMPT_NONE, 0 },

	/* Error deallocating inode */
	{ PR_2_DEALLOC_INODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
914
	  N_("Error deallocating @i %i: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
915 916
	  PROMPT_NONE, PR_FATAL },

Theodore Ts'o's avatar
Theodore Ts'o committed
917 918
	/* Directory entry for '.' is big.  Split? */
	{ PR_2_SPLIT_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
919
	  N_("@d @e for '.' is big.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
920
	  PROMPT_SPLIT, PR_NO_OK },
Theodore Ts'o's avatar
Theodore Ts'o committed
921

922 923
	/* Illegal FIFO inode */
	{ PR_2_BAD_FIFO,
Theodore Ts'o's avatar
Theodore Ts'o committed
924
	  N_("@i %i (%Q) is an @I FIFO.\n"),
925 926 927 928
	  PROMPT_CLEAR, 0 },

	/* Illegal socket inode */
	{ PR_2_BAD_SOCKET,
Theodore Ts'o's avatar
Theodore Ts'o committed
929
	  N_("@i %i (%Q) is an @I socket.\n"),
930 931
	  PROMPT_CLEAR, 0 },

Theodore Ts'o's avatar
Theodore Ts'o committed
932 933
	/* Directory filetype not set */
	{ PR_2_SET_FILETYPE,
Theodore Ts'o's avatar
Theodore Ts'o committed
934
	  N_("Setting filetype for @E to %N.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
935 936 937 938
	  PROMPT_NONE, PR_PREEN_OK | PR_NO_OK | PR_NO_NOMSG },

	/* Directory filetype incorrect */
	{ PR_2_BAD_FILETYPE,
939
	  N_("@E has an incorrect filetype (was %Dt, should be %N).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
940 941
	  PROMPT_FIX, 0 },

942 943
	/* Directory filetype set on filesystem */
	{ PR_2_CLEAR_FILETYPE,
944
	  N_("@E has filetype set.\n"),
945 946
	  PROMPT_CLEAR, PR_PREEN_OK },

947 948
	/* Directory filename is null */
	{ PR_2_NULL_NAME,
949
	  N_("@E has a zero-length name.\n"),
950 951
	  PROMPT_CLEAR, 0 },

952 953
	/* Invalid fast symlink size */
	{ PR_2_SYMLINK_SIZE,
954
	  N_("Symlink %Q (@i #%i) has an invalid size (%Is).\n"),
955 956 957 958 959
	  PROMPT_CLEAR, 0 },

  	/* i_file_acl (extended attribute block) is bad */
	{ PR_2_FILE_ACL_BAD,
	  N_("@a @b @F is invalid (%If).\n"),
960 961
	  PROMPT_CLEAR, 0 },

962 963 964 965 966
	/* Filesystem contains large files, but has no such flag in sb */
	{ PR_2_FEATURE_LARGE_FILES,
	  N_("@f contains large files, but lacks LARGE_FILE flag in @S.\n"),
	  PROMPT_FIX, 0 },
	  
Theodore Ts'o's avatar
Theodore Ts'o committed
967 968 969 970
	/* Pass 3 errors */

	/* Pass 3: Checking directory connectivity */
	{ PR_3_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
971
	  N_("Pass 3: Checking @d connectivity\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
972 973
	  PROMPT_NONE, 0 },
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
974 975
	/* Root inode not allocated */
	{ PR_3_NO_ROOT_INODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
976
	  N_("@r not allocated.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
977 978 979 980
	  PROMPT_ALLOCATE, 0 },	
		  
	/* No room in lost+found */
	{ PR_3_EXPAND_LF_DIR,
Theodore Ts'o's avatar
Theodore Ts'o committed
981
	  N_("No room in @l @d.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
982 983 984 985
	  PROMPT_EXPAND, 0 },

	/* Unconnected directory inode */
	{ PR_3_UNCONNECTED_DIR,
Theodore Ts'o's avatar
Theodore Ts'o committed
986
	  N_("Unconnected @d @i %i (%p)\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
987 988 989 990
	  PROMPT_CONNECT, 0 },

	/* /lost+found not found */
	{ PR_3_NO_LF_DIR,
Theodore Ts'o's avatar
Theodore Ts'o committed
991
	  N_("/@l not found.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
992
	  PROMPT_CREATE, PR_PREEN_OK },
Theodore Ts'o's avatar
Theodore Ts'o committed
993 994 995

	/* .. entry is incorrect */
	{ PR_3_BAD_DOT_DOT,
Theodore Ts'o's avatar
Theodore Ts'o committed
996
	  N_("'..' in %Q (%i) is %P (%j), @s %q (%d).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
997 998
	  PROMPT_FIX, 0 },

Theodore Ts'o's avatar
Theodore Ts'o committed
999 1000
	/* Bad or non-existent /lost+found.  Cannot reconnect */
	{ PR_3_NO_LPF,
1001
	  N_("Bad or non-existent /@l.  Cannot reconnect.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1002 1003 1004 1005
	  PROMPT_NONE, 0 },

	/* Could not expand /lost+found */
	{ PR_3_CANT_EXPAND_LPF,
Theodore Ts'o's avatar
Theodore Ts'o committed
1006
	  N_("Could not expand /@l: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1007 1008 1009 1010
	  PROMPT_NONE, 0 },

	/* Could not reconnect inode */
	{ PR_3_CANT_RECONNECT,
Theodore Ts'o's avatar
Theodore Ts'o committed
1011
	  N_("Could not reconnect %i: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1012 1013 1014 1015
	  PROMPT_NONE, 0 },

	/* Error while trying to find /lost+found */
	{ PR_3_ERR_FIND_LPF,
Theodore Ts'o's avatar
Theodore Ts'o committed
1016
	  N_("Error while trying to find /@l: %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1017 1018 1019 1020
	  PROMPT_NONE, 0 },

	/* Error in ext2fs_new_block while creating /lost+found */
	{ PR_3_ERR_LPF_NEW_BLOCK, 
Theodore Ts'o's avatar
Theodore Ts'o committed
1021
	  N_("ext2fs_new_@b: %m while trying to create /@l @d\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1022 1023 1024 1025
	  PROMPT_NONE, 0 },
		  
	/* Error in ext2fs_new_inode while creating /lost+found */
	{ PR_3_ERR_LPF_NEW_INODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
1026
	  N_("ext2fs_new_@i: %m while trying to create /@l @d\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1027 1028 1029 1030
	  PROMPT_NONE, 0 },

	/* Error in ext2fs_new_dir_block while creating /lost+found */	  
	{ PR_3_ERR_LPF_NEW_DIR_BLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
1031
	  N_("ext2fs_new_dir_@b: %m while creating new @d @b\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1032 1033 1034 1035
	  PROMPT_NONE, 0 },
		  
	/* Error while writing directory block for /lost+found */
	{ PR_3_ERR_LPF_WRITE_BLOCK,
Theodore Ts'o's avatar
Theodore Ts'o committed
1036
	  N_("ext2fs_write_dir_@b: %m while writing the @d @b for /@l\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1037 1038 1039 1040
	  PROMPT_NONE, 0 },

	/* Error while adjusting inode count */
	{ PR_3_ADJUST_INODE,
Theodore Ts'o's avatar
Theodore Ts'o committed
1041
	  N_("Error while adjusting @i count on @i %i\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1042 1043 1044 1045
	  PROMPT_NONE, 0 },

	/* Couldn't fix parent directory -- error */
	{ PR_3_FIX_PARENT_ERR,
Theodore Ts'o's avatar
Theodore Ts'o committed
1046
	  N_("Couldn't fix parent of @i %i: %m\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1047 1048 1049 1050
	  PROMPT_NONE, 0 },

	/* Couldn't fix parent directory -- couldn't find it */	  
	{ PR_3_FIX_PARENT_NOFIND,
Theodore Ts'o's avatar
Theodore Ts'o committed
1051
	  N_("Couldn't fix parent of @i %i: Couldn't find parent @d entry\n\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1052 1053 1054 1055
	  PROMPT_NONE, 0 },

	/* Error allocating inode bitmap */
	{ PR_3_ALLOCATE_IBITMAP_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
1056
	  N_("@A @i @B (%N): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1057 1058 1059 1060
	  PROMPT_NONE, PR_FATAL },

	/* Error creating root directory */
	{ PR_3_CREATE_ROOT_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
1061
	  N_("Error creating root @d (%s): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1062 1063 1064 1065
	  PROMPT_NONE, PR_FATAL },	  

	/* Error creating lost and found directory */
	{ PR_3_CREATE_LPF_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
1066
	  N_("Error creating /@l @d (%s): %m\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1067 1068
	  PROMPT_NONE, PR_FATAL },  

Theodore Ts'o's avatar
Theodore Ts'o committed
1069 1070
	/* Root inode is not directory; aborting */
	{ PR_3_ROOT_NOT_DIR_ABORT,
Theodore Ts'o's avatar
Theodore Ts'o committed
1071
	  N_("@r is not a @d; aborting.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1072 1073 1074 1075
	  PROMPT_NONE, PR_FATAL },  

	/* Cannot proceed without a root inode. */
	{ PR_3_NO_ROOT_INODE_ABORT,
Theodore Ts'o's avatar
Theodore Ts'o committed
1076
	  N_("Cannot proceed without a @r.\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1077 1078
	  PROMPT_NONE, PR_FATAL },  

1079 1080
	/* Internal error: couldn't find dir_info */
	{ PR_3_NO_DIRINFO,
Theodore Ts'o's avatar
Theodore Ts'o committed
1081
	  N_("Internal error: couldn't find dir_info for %i.\n"),
1082 1083
	  PROMPT_NONE, PR_FATAL },

1084 1085
	/* Lost+found not a directory */
	{ PR_3_LPF_NOTDIR,
Theodore Ts'o's avatar
Theodore Ts'o committed
1086
	  N_("/@l is not a @d (ino=%i)\n"),
1087 1088
	  PROMPT_UNLINK, 0 }, 

Theodore Ts'o's avatar
Theodore Ts'o committed
1089 1090
	/* Pass 4 errors */
	
Theodore Ts'o's avatar
Theodore Ts'o committed
1091 1092
	/* Pass 4: Checking reference counts */
	{ PR_4_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
1093
	  N_("Pass 4: Checking reference counts\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1094 1095
	  PROMPT_NONE, 0 },
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
	/* Unattached zero-length inode */
	{ PR_4_ZERO_LEN_INODE,
	  "@u @z @i %i.  ",
	  PROMPT_CLEAR, PR_PREEN_OK|PR_NO_OK },

	/* Unattached inode */
	{ PR_4_UNATTACHED_INODE,
	  "@u @i %i\n",
	  PROMPT_CONNECT, 0 },

	/* Inode ref count wrong */
	{ PR_4_BAD_REF_COUNT,
Theodore Ts'o's avatar
Theodore Ts'o committed
1108
	  N_("@i %i ref count is %Il, @s %N.  "),
Theodore Ts'o's avatar
Theodore Ts'o committed
1109
	  PROMPT_FIX, PR_PREEN_OK },
Theodore Ts'o's avatar
Theodore Ts'o committed
1110 1111

	{ PR_4_INCONSISTENT_COUNT,
Theodore Ts'o's avatar
Theodore Ts'o committed
1112
	  N_("WARNING: PROGRAMMING BUG IN E2FSCK!\n"
Theodore Ts'o's avatar
Theodore Ts'o committed
1113 1114
	  "\tOR SOME BONEHEAD (YOU) IS CHECKING A MOUNTED (LIVE) FILESYSTEM.\n"
	  "@i_link_info[%i] is %N, @i.i_links_count is %Il.  "
Theodore Ts'o's avatar
Theodore Ts'o committed
1115
	  "They should be the same!\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1116 1117 1118 1119 1120 1121
	  PROMPT_NONE, 0 },

	/* Pass 5 errors */
		  
	/* Pass 5: Checking group summary information */
	{ PR_5_PASS_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
1122
	  N_("Pass 5: Checking @g summary information\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1123 1124 1125 1126
	  PROMPT_NONE, 0 },
		  
	/* Padding at end of inode bitmap is not set. */
	{ PR_5_INODE_BMAP_PADDING,
Theodore Ts'o's avatar
Theodore Ts'o committed
1127
	  N_("Padding at end of @i @B is not set. "),
Theodore Ts'o's avatar
Theodore Ts'o committed
1128 1129 1130 1131
	  PROMPT_FIX, PR_PREEN_OK },
		  
	/* Padding at end of block bitmap is not set. */
	{ PR_5_BLOCK_BMAP_PADDING,
Theodore Ts'o's avatar
Theodore Ts'o committed
1132
	  N_("Padding at end of @b @B is not set. "),
Theodore Ts'o's avatar
Theodore Ts'o committed
1133 1134 1135 1136
	  PROMPT_FIX, PR_PREEN_OK },
		
	/* Block bitmap differences header */
	{ PR_5_BLOCK_BITMAP_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
1137
	  N_("@b @B differences: "),
Theodore Ts'o's avatar
Theodore Ts'o committed
1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
	  PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG},

	/* Block not used, but marked in bitmap */
	{ PR_5_UNUSED_BLOCK,
	  " -%b",
	  PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
		  
	/* Block used, but not marked used in bitmap */
	{ PR_5_BLOCK_USED,
	  " +%b",
	  PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Block bitmap differences end */	  
	{ PR_5_BLOCK_BITMAP_END,
	  "\n",
	  PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Inode bitmap differences header */
	{ PR_5_INODE_BITMAP_HEADER,
Theodore Ts'o's avatar
Theodore Ts'o committed
1157
	  N_("@i @B differences: "),
Theodore Ts'o's avatar
Theodore Ts'o committed
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
	  PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Inode not used, but marked in bitmap */
	{ PR_5_UNUSED_INODE,
	  " -%i",
	  PROMPT_NONE, PR_LATCH_IBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
		  
	/* Inode used, but not marked used in bitmap */
	{ PR_5_INODE_USED,
	  " +%i",
	  PROMPT_NONE, PR_LATCH_IBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Inode bitmap differences end */	  
	{ PR_5_INODE_BITMAP_END,
	  "\n",
	  PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Free inodes count for group wrong */
	{ PR_5_FREE_INODE_COUNT_GROUP,
Theodore Ts'o's avatar
Theodore Ts'o committed
1177
	  N_("Free @is count wrong for @g #%g (%i, counted=%j).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1178 1179 1180 1181
	  PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Directories count for group wrong */
	{ PR_5_FREE_DIR_COUNT_GROUP,
Theodore Ts'o's avatar
Theodore Ts'o committed
1182
	  N_("Directories count wrong for @g #%g (%i, counted=%j).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1183 1184 1185 1186
	  PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Free inodes count wrong */
	{ PR_5_FREE_INODE_COUNT,
Theodore Ts'o's avatar
Theodore Ts'o committed
1187
	  N_("Free @is count wrong (%i, counted=%j).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1188 1189 1190 1191
	  PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Free blocks count for group wrong */
	{ PR_5_FREE_BLOCK_COUNT_GROUP,
Theodore Ts'o's avatar
Theodore Ts'o committed
1192
	  N_("Free @bs count wrong for @g #%g (%b, counted=%c).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1193 1194 1195 1196
	  PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Free blocks count wrong */
	{ PR_5_FREE_BLOCK_COUNT,
Theodore Ts'o's avatar
Theodore Ts'o committed
1197
	  N_("Free @bs count wrong (%b, counted=%c).\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1198 1199 1200 1201
	  PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },

	/* Programming error: bitmap endpoints don't match */
	{ PR_5_BMAP_ENDPOINTS,
Theodore Ts'o's avatar
Theodore Ts'o committed
1202 1203
	  N_("PROGRAMMING ERROR: @f (#%N) @B endpoints (%b, %c) don't "
	  "match calculated @B endpoints (%i, %j)\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1204 1205 1206 1207
	  PROMPT_NONE, PR_FATAL },

	/* Internal error: fudging end of bitmap */
	{ PR_5_FUDGE_BITMAP_ERROR,
Theodore Ts'o's avatar
Theodore Ts'o committed
1208
	  N_("Internal error: fudging end of bitmap (%N)\n"),
Theodore Ts'o's avatar
Theodore Ts'o committed
1209
	  PROMPT_NONE, PR_FATAL },	  
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220

	/* Error copying in replacement inode bitmap */
	{ PR_5_COPY_IBITMAP_ERROR,
	  "Error copying in replacement @i @B: %m\n",
	  PROMPT_NONE, PR_FATAL },

	/* Error copying in replacement block bitmap */
	{ PR_5_COPY_BBITMAP_ERROR,
	  "Error copying in replacement @b @B: %m\n",
	  PROMPT_NONE, PR_FATAL },
		  
Theodore Ts'o's avatar
Theodore Ts'o committed
1221 1222 1223 1224 1225 1226 1227 1228 1229
	{ 0 }
};

/*
 * This is the latch flags register.  It allows several problems to be
 * "latched" together.  This means that the user has to answer but one
 * question for the set of problems, and all of the associated
 * problems will be either fixed or not fixed.
 */
Theodore Ts'o's avatar
Theodore Ts'o committed
1230 1231 1232 1233 1234 1235 1236
static struct latch_descr pr_latch_info[] = {
	{ PR_LATCH_BLOCK, PR_1_INODE_BLOCK_LATCH, 0 },
	{ PR_LATCH_BBLOCK, PR_1_INODE_BBLOCK_LATCH, 0 },
	{ PR_LATCH_IBITMAP, PR_5_INODE_BITMAP_HEADER, PR_5_INODE_BITMAP_END },
	{ PR_LATCH_BBITMAP, PR_5_BLOCK_BITMAP_HEADER, PR_5_BLOCK_BITMAP_END },
	{ PR_LATCH_RELOC, PR_0_RELOCATE_HINT, 0 },
	{ PR_LATCH_DBLOCK, PR_1B_DUP_BLOCK_HEADER, PR_1B_DUP_BLOCK_END },
1237
	{ PR_LATCH_LOW_DTIME, PR_1_ORPHAN_LIST_REFUGEES, 0 },
Theodore Ts'o's avatar
Theodore Ts'o committed
1238
	{ -1, 0, 0 },
Theodore Ts'o's avatar
Theodore Ts'o committed
1239 1240
};

Theodore Ts'o's avatar
Theodore Ts'o committed
1241
static const struct e2fsck_problem *find_problem(int code)
Theodore Ts'o's avatar
Theodore Ts'o committed
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
{
	int 	i;

	for (i=0; problem_table[i].e2p_code; i++) {
		if (problem_table[i].e2p_code == code)
			return &problem_table[i];
	}
	return 0;
}

Theodore Ts'o's avatar
Theodore Ts'o committed
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278
static struct latch_descr *find_latch(int code)
{
	int	i;

	for (i=0; pr_latch_info[i].latch_code >= 0; i++) {
		if (pr_latch_info[i].latch_code == code)
			return &pr_latch_info[i];
	}
	return 0;
}

int end_problem_latch(e2fsck_t ctx, int mask)
{
	struct latch_descr *ldesc;
	struct problem_context pctx;
	int answer = -1;
	
	ldesc = find_latch(mask);
	if (ldesc->end_message && (ldesc->flags & PRL_LATCHED)) {
		clear_problem_context(&pctx);
		answer = fix_problem(ctx, ldesc->end_message, &pctx);
	}
	ldesc->flags &= ~(PRL_VARIABLE);
	return answer;
}

int set_latch_flags(int mask, int setflags, int clearflags)
Theodore Ts'o's avatar
Theodore Ts'o committed
1279
{
Theodore Ts'o's avatar
Theodore Ts'o committed
1280 1281 1282 1283 1284 1285 1286 1287
	struct latch_descr *ldesc;

	ldesc = find_latch(mask);
	if (!ldesc)
		return -1;
	ldesc->flags |= setflags;
	ldesc->flags &= ~clearflags;
	return 0;
Theodore Ts'o's avatar
Theodore Ts'o committed
1288 1289
}

Theodore Ts'o's avatar
Theodore Ts'o committed
1290
int get_latch_flags(int mask, int *value)
Theodore Ts'o's avatar
Theodore Ts'o committed
1291
{
Theodore Ts'o's avatar
Theodore Ts'o committed
1292 1293 1294 1295 1296 1297 1298
	struct latch_descr *ldesc;

	ldesc = find_latch(mask);
	if (!ldesc)
		return -1;
	*value = ldesc->flags;
	return 0;
Theodore Ts'o's avatar
Theodore Ts'o committed
1299 1300 1301 1302 1303 1304 1305 1306 1307
}

void clear_problem_context(struct problem_context *ctx)
{
	memset(ctx, 0, sizeof(struct problem_context));
	ctx->blkcount = -1;
	ctx->group = -1;
}

Theodore Ts'o's avatar
Theodore Ts'o committed
1308
int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
Theodore Ts'o's avatar
Theodore Ts'o committed
1309
{
Theodore Ts'o's avatar
Theodore Ts'o committed
1310 1311 1312 1313 1314
	ext2_filsys fs = ctx->fs;
	const struct e2fsck_problem *ptr;
	struct latch_descr *ldesc = 0;
	const char *message;
	int 		def_yn, answer, ans;
Theodore Ts'o's avatar
Theodore Ts'o committed
1315 1316 1317 1318 1319
	int		print_answer = 0;
	int		suppress = 0;

	ptr = find_problem(code);
	if (!ptr) {
Theodore Ts'o's avatar
Theodore Ts'o committed
1320
		printf(_("Unhandled error code (%d)!\n"), code);
Theodore Ts'o's avatar
Theodore Ts'o committed
1321 1322
		return 0;
	}
Theodore Ts'o's avatar
Theodore Ts'o committed
1323
	def_yn = 1;
1324 1325 1326
	if ((ptr->flags & PR_NO_DEFAULT) ||
	    ((ptr->flags & PR_PREEN_NO) && (ctx->options & E2F_OPT_PREEN)) ||
	    (ctx->options & E2F_OPT_NO))
Theodore Ts'o's avatar
Theodore Ts'o committed
1327
		def_yn= 0;
Theodore Ts'o's avatar
Theodore Ts'o committed
1328 1329 1330 1331 1332 1333

	/*
	 * Do special latch processing.  This is where we ask the
	 * latch question, if it exists
	 */
	if (ptr->flags & PR_LATCH_MASK) {
Theodore Ts'o's avatar
Theodore Ts'o committed
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
		ldesc = find_latch(ptr->flags & PR_LATCH_MASK);
		if (ldesc->question && !(ldesc->flags & PRL_LATCHED)) {
			ans = fix_problem(ctx, ldesc->question, pctx);
			if (ans == 1)
				ldesc->flags |= PRL_YES;
			if (ans == 0)
				ldesc->flags |= PRL_NO;
			ldesc->flags |= PRL_LATCHED;
		}
		if (ldesc->flags & PRL_SUPPRESS)
Theodore Ts'o's avatar
Theodore Ts'o committed
1344 1345
			suppress++;
	}
Theodore Ts'o's avatar
Theodore Ts'o committed
1346 1347 1348
	if ((ptr->flags & PR_PREEN_NOMSG) &&
	    (ctx->options & E2F_OPT_PREEN))
		suppress++;
Theodore Ts'o's avatar
Theodore Ts'o committed
1349 1350 1351
	if ((ptr->flags & PR_NO_NOMSG) &&
	    (ctx->options & E2F_OPT_NO))
		suppress++;
Theodore Ts'o's avatar
Theodore Ts'o committed
1352
	if (!suppress) {
Theodore Ts'o's avatar
Theodore Ts'o committed
1353 1354
		message = ptr->e2p_description;
		if (ctx->options & E2F_OPT_PREEN) {
1355 1356
			printf("%s: ", ctx->device_name ?
			       ctx->device_name : ctx->filesystem_name);
Theodore Ts'o's avatar
Theodore Ts'o committed
1357 1358 1359 1360 1361
#if 0
			if (ptr->e2p_preen_msg)
				message = ptr->e2p_preen_msg;
#endif
		}
Theodore Ts'o's avatar
Theodore Ts'o committed
1362
		print_e2fsck_message(ctx, _(message), pctx, 1);
Theodore Ts'o's avatar
Theodore Ts'o committed
1363
	}
Theodore Ts'o's avatar
Theodore Ts'o committed
1364 1365
	if (!(ptr->flags & PR_PREEN_OK) && (ptr->prompt != PROMPT_NONE))
		preenhalt(ctx);
Theodore Ts'o's avatar
Theodore Ts'o committed
1366

Theodore Ts'o's avatar
Theodore Ts'o committed
1367
	if (ptr->flags & PR_FATAL)
Theodore Ts'o's avatar
Theodore Ts'o committed
1368
		fatal_error(ctx, 0);
Theodore Ts'o's avatar
Theodore Ts'o committed
1369 1370 1371 1372

	if (ptr->prompt == PROMPT_NONE) {
		if (ptr->flags & PR_NOCOLLATE)
			answer = -1;
Theodore Ts'o's avatar
Theodore Ts'o committed
1373
		else
Theodore Ts'o's avatar
Theodore Ts'o committed
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388
			answer = def_yn;
	} else {
		if (ctx->options & E2F_OPT_PREEN) {
			answer = def_yn;
			if (!(ptr->flags & PR_PREEN_NOMSG))
				print_answer = 1;
		} else if ((ptr->flags & PR_LATCH_MASK) &&
			   (ldesc->flags & (PRL_YES | PRL_NO))) {
			if (!suppress)
				print_answer = 1;
			if (ldesc->flags & PRL_YES)
				answer = 1;
			else
				answer = 0;
		} else
Theodore Ts'o's avatar
Theodore Ts'o committed
1389
			answer = ask(ctx, _(prompt[(int) ptr->prompt]), def_yn);
Theodore Ts'o's avatar
Theodore Ts'o committed
1390 1391
		if (!answer && !(ptr->flags & PR_NO_OK))
			ext2fs_unmark_valid(fs);
Theodore Ts'o's avatar
Theodore Ts'o committed
1392
	
Theodore Ts'o's avatar
Theodore Ts'o committed
1393 1394
		if (print_answer)
			printf("%s.\n", answer ?
Theodore Ts'o's avatar
Theodore Ts'o committed
1395
			       _(preen_msg[(int) ptr->prompt]) : _("IGNORED"));
Theodore Ts'o's avatar
Theodore Ts'o committed
1396
	
Theodore Ts'o's avatar
Theodore Ts'o committed
1397 1398
	}

Theodore Ts'o's avatar
Theodore Ts'o committed
1399 1400
	if ((ptr->prompt == PROMPT_ABORT) && answer)
		fatal_error(ctx, 0);
Theodore Ts'o's avatar
Theodore Ts'o committed
1401

Theodore Ts'o's avatar
Theodore Ts'o committed
1402 1403 1404
	if (ptr->flags & PR_AFTER_CODE)
		answer = fix_problem(ctx, ptr->second_code, pctx);

Theodore Ts'o's avatar
Theodore Ts'o committed
1405 1406
	return answer;
}