2 * problem.c --- report filesystem problems to the user
4 * Copyright 1996, 1997 by Theodore Ts'o
7 * This file may be redistributed under the terms of the GNU Public
25 #define PROMPT_CLEAR 2
26 #define PROMPT_RELOCATE 3
27 #define PROMPT_ALLOCATE 4
28 #define PROMPT_EXPAND 5
29 #define PROMPT_CONNECT 6
30 #define PROMPT_CREATE 7
31 #define PROMPT_SALVAGE 8
32 #define PROMPT_TRUNCATE 9
33 #define PROMPT_CLEAR_INODE 10
34 #define PROMPT_ABORT 11
35 #define PROMPT_SPLIT 12
36 #define PROMPT_CONTINUE 13
37 #define PROMPT_CLONE 14
38 #define PROMPT_DELETE 15
39 #define PROMPT_SUPPRESS 16
40 #define PROMPT_UNLINK 17
41 #define PROMPT_NULL 18
44 * These are the prompts which are used to ask the user if they want
47 static const char *prompt[] = {
48 N_("(no prompt)"), /* 0 */
51 N_("Relocate"), /* 3 */
52 N_("Allocate"), /* 4 */
54 N_("Connect to /lost+found"), /* 6 */
56 N_("Salvage"), /* 8 */
57 N_("Truncate"), /* 9 */
58 N_("Clear inode"), /* 10 */
61 N_("Continue"), /* 13 */
62 N_("Clone duplicate/bad blocks"), /* 14 */
63 N_("Delete file"), /* 15 */
64 N_("Suppress messages"),/* 16 */
65 N_("Unlink"), /* 17 */
70 * These messages are printed when we are preen mode and we will be
71 * automatically fixing the problem.
73 static const char *preen_msg[] = {
76 N_("CLEARED"), /* 2 */
77 N_("RELOCATED"), /* 3 */
78 N_("ALLOCATED"), /* 4 */
79 N_("EXPANDED"), /* 5 */
80 N_("RECONNECTED"), /* 6 */
81 N_("CREATED"), /* 7 */
82 N_("SALVAGED"), /* 8 */
83 N_("TRUNCATED"), /* 9 */
84 N_("INODE CLEARED"), /* 10 */
85 N_("ABORTED"), /* 11 */
87 N_("CONTINUING"), /* 13 */
88 N_("DUPLICATE/BAD BLOCKS CLONED"), /* 14 */
89 N_("FILE DELETED"), /* 15 */
90 N_("SUPPRESSED"), /* 16 */
91 N_("UNLINKED"), /* 17 */
94 static const struct e2fsck_problem problem_table[] = {
96 /* Pre-Pass 1 errors */
98 /* Block bitmap not in group */
99 { PR_0_BB_NOT_GROUP, N_("@b @B for @g %g is not in @g. (@b %b)\n"),
100 PROMPT_RELOCATE, PR_LATCH_RELOC },
102 /* Inode bitmap not in group */
103 { PR_0_IB_NOT_GROUP, N_("@i @B for @g %g is not in @g. (@b %b)\n"),
104 PROMPT_RELOCATE, PR_LATCH_RELOC },
106 /* Inode table not in group */
107 { PR_0_ITABLE_NOT_GROUP,
108 N_("@i table for @g %g is not in @g. (@b %b)\n"
109 "WARNING: SEVERE DATA LOSS POSSIBLE.\n"),
110 PROMPT_RELOCATE, PR_LATCH_RELOC },
112 /* Superblock corrupt */
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"
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"),
119 PROMPT_NONE, PR_FATAL },
121 /* Filesystem size is wrong */
122 { PR_0_FS_SIZE_WRONG,
123 N_("The @f size (according to the @S) is %b @bs\n"
124 "The physical size of the @v is %c @bs\n"
125 "Either the @S or the partition table is likely to be corrupt!\n"),
128 /* Fragments not supported */
130 N_("@S @b_size = %b, fragsize = %c.\n"
131 "This version of e2fsck does not support fragment sizes different\n"
132 "from the @b size.\n"),
133 PROMPT_NONE, PR_FATAL },
135 /* Bad blocks_per_group */
136 { PR_0_BLOCKS_PER_GROUP,
137 N_("@S @bs_per_group = %b, should have been %c\n"),
138 PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },
140 /* Bad first_data_block */
141 { PR_0_FIRST_DATA_BLOCK,
142 N_("@S first_data_@b = %b, should have been %c\n"),
143 PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },
145 /* Adding UUID to filesystem */
147 N_("@f did not have a UUID; generating one.\n\n"),
151 { PR_0_RELOCATE_HINT,
152 N_("Note: if there is several inode or block bitmap blocks\n"
153 "which require relocation, or one part of the inode table\n"
154 "which must be moved, you may wish to try running e2fsck\n"
155 "with the '-b %S' option first. The problem may lie only\n"
156 "with the primary block group descriptor, and the backup\n"
157 "block group descriptor may be OK.\n\n"),
158 PROMPT_NONE, PR_PREEN_OK | PR_NOCOLLATE },
160 /* Miscellaneous superblock corruption */
161 { PR_0_MISC_CORRUPT_SUPER,
162 N_("Corruption found in @S. (%s = %N).\n"),
163 PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },
165 /* Error determing physical device size of filesystem */
166 { PR_0_GETSIZE_ERROR,
167 N_("Error determining size of the physical @v: %m\n"),
168 PROMPT_NONE, PR_FATAL },
170 /* Inode count in superblock is incorrect */
171 { PR_0_INODE_COUNT_WRONG,
172 N_("@i count in @S is %i, should be %j.\n"),
175 { PR_0_HURD_CLEAR_FILETYPE,
176 N_("The Hurd does not support the filetype feature.\n"),
179 /* Journal inode is invalid */
180 { PR_0_JOURNAL_BAD_INODE,
181 N_("@S has a bad ext3 @j (@i %i).\n"),
182 PROMPT_CLEAR, PR_PREEN_OK },
184 /* The external journal has (unsupported) multiple filesystems */
185 { PR_0_JOURNAL_UNSUPP_MULTIFS,
186 N_("External @j has multiple @f users (unsupported).\n"),
187 PROMPT_NONE, PR_FATAL },
189 /* Can't find external journal */
190 { PR_0_CANT_FIND_JOURNAL,
191 N_("Can't find external @j\n"),
192 PROMPT_NONE, PR_FATAL },
194 /* External journal has bad superblock */
195 { PR_0_EXT_JOURNAL_BAD_SUPER,
196 N_("External @j has bad @S\n"),
197 PROMPT_NONE, PR_FATAL },
199 /* Superblock has a bad journal UUID */
200 { PR_0_JOURNAL_BAD_UUID,
201 N_("External @j does not support this @f\n"),
202 PROMPT_NONE, PR_FATAL },
204 /* Journal has an unknown superblock type */
205 { PR_0_JOURNAL_UNSUPP_SUPER,
206 N_("Ext3 @j @S is unknown type %N (unsupported).\n"
207 "It is likely that your copy of e2fsck is old and/or doesn't "
208 "support this @j format.\n"
209 "It is also possible the @j @S is corrupt.\n"),
210 PROMPT_ABORT, PR_NO_OK | PR_AFTER_CODE, PR_0_JOURNAL_BAD_SUPER },
212 /* Journal superblock is corrupt */
213 { PR_0_JOURNAL_BAD_SUPER,
214 N_("Ext3 @j @S is corrupt.\n"),
215 PROMPT_FIX, PR_PREEN_OK },
217 /* Superblock flag should be cleared */
218 { PR_0_JOURNAL_HAS_JOURNAL,
219 N_("@S doesn't have has_@j flag, but has ext3 @j %s.\n"),
220 PROMPT_CLEAR, PR_PREEN_OK },
222 /* Superblock flag is incorrect */
223 { PR_0_JOURNAL_RECOVER_SET,
224 N_("@S has ext3 needs_recovery flag set, but no @j.\n"),
225 PROMPT_CLEAR, PR_PREEN_OK },
227 /* Journal has data, but recovery flag is clear */
228 { PR_0_JOURNAL_RECOVERY_CLEAR,
229 N_("ext3 recovery flag clear, but @j has data.\n"),
232 /* Ask if we should clear the journal */
233 { PR_0_JOURNAL_RESET_JOURNAL,
235 PROMPT_NULL, PR_PREEN_NOMSG },
237 /* Ask if we should run the journal anyway */
242 /* Run the journal by default */
243 { PR_0_JOURNAL_RUN_DEFAULT,
244 N_("Recovery flag not set in backup @S, so running @j anyway.\n"),
247 /* Clearing orphan inode */
248 { PR_0_ORPHAN_CLEAR_INODE,
249 N_("%s @o @i %i (uid=%Iu, gid=%Ig, mode=%Im, size=%Is)\n"),
252 /* Illegal block found in orphaned inode */
253 { PR_0_ORPHAN_ILLEGAL_BLOCK_NUM,
254 N_("@I @b #%B (%b) found in @o @i %i.\n"),
257 /* Already cleared block found in orphaned inode */
258 { PR_0_ORPHAN_ALREADY_CLEARED_BLOCK,
259 N_("Already cleared @b #%B (%b) found in @o @i %i.\n"),
262 /* Illegal orphan inode in superblock */
263 { PR_0_ORPHAN_ILLEGAL_HEAD_INODE,
264 N_("@I @o @i %i in @S.\n"),
267 /* Illegal inode in orphaned inode list */
268 { PR_0_ORPHAN_ILLEGAL_INODE,
269 N_("@I @i %i in @o @i list.\n"),
272 /* Filesystem revision is 0, but feature flags are set */
274 "@f has feature flag(s) set, but is a revision 0 @f. ",
275 PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
277 /* Journal superblock has an unknown read-only feature flag set */
278 { PR_0_JOURNAL_UNSUPP_ROCOMPAT,
279 N_("Ext3 @j @S has an unknown read-only feature flag set.\n"),
282 /* Journal superblock has an unknown incompatible feature flag set */
283 { PR_0_JOURNAL_UNSUPP_INCOMPAT,
284 N_("Ext3 @j @S has an unknown incompatible feature flag set.\n"),
287 /* Journal has unsupported version number */
288 { PR_0_JOURNAL_UNSUPP_VERSION,
289 N_("@j version not supported by this e2fsck.\n"),
292 /* Moving journal to hidden file */
294 N_("Moving @j from /%s to hidden inode.\n\n"),
297 /* Error moving journal to hidden file */
298 { PR_0_ERR_MOVE_JOURNAL,
299 N_("Error moving @j: %m\n\n"),
302 /* Clearing V2 journal superblock */
303 { PR_0_CLEAR_V2_JOURNAL,
304 N_("Found invalid V2 @j @S fields (from V1 journal).\n"
305 "Clearing fields beyond the V1 @j @S...\n\n"),
310 /* Pass 1: Checking inodes, blocks, and sizes */
312 N_("Pass 1: Checking @is, @bs, and sizes\n"),
315 /* Root directory is not an inode */
316 { PR_1_ROOT_NO_DIR, N_("@r is not a @d. "),
319 /* Root directory has dtime set */
321 N_("@r has dtime set (probably due to old mke2fs). "),
322 PROMPT_FIX, PR_PREEN_OK },
324 /* Reserved inode has bad mode */
325 { PR_1_RESERVED_BAD_MODE,
326 N_("Reserved @i %i %Q has bad mode. "),
327 PROMPT_CLEAR, PR_PREEN_OK },
329 /* Deleted inode has zero dtime */
331 N_("@D @i %i has zero dtime. "),
332 PROMPT_FIX, PR_PREEN_OK },
334 /* Inode in use, but dtime set */
336 N_("@i %i is in use, but has dtime set. "),
337 PROMPT_FIX, PR_PREEN_OK },
339 /* Zero-length directory */
340 { PR_1_ZERO_LENGTH_DIR,
341 N_("@i %i is a @z @d. "),
342 PROMPT_CLEAR, PR_PREEN_OK },
344 /* Block bitmap conflicts with some other fs block */
346 N_("@g %g's @b @B at %b @C.\n"),
347 PROMPT_RELOCATE, 0 },
349 /* Inode bitmap conflicts with some other fs block */
351 N_("@g %g's @i @B at %b @C.\n"),
352 PROMPT_RELOCATE, 0 },
354 /* Inode table conflicts with some other fs block */
355 { PR_1_ITABLE_CONFLICT,
356 N_("@g %g's @i table at %b @C.\n"),
357 PROMPT_RELOCATE, 0 },
359 /* Block bitmap is on a bad block */
361 N_("@g %g's @b @B (%b) is bad. "),
362 PROMPT_RELOCATE, 0 },
364 /* Inode bitmap is on a bad block */
366 N_("@g %g's @i @B (%b) is bad. "),
367 PROMPT_RELOCATE, 0 },
369 /* Inode has incorrect i_size */
371 N_("@i %i, i_size is %Is, @s %N. "),
372 PROMPT_FIX, PR_PREEN_OK },
374 /* Inode has incorrect i_blocks */
376 N_("@i %i, i_@bs is %Ib, @s %N. "),
377 PROMPT_FIX, PR_PREEN_OK },
379 /* Illegal blocknumber in inode */
380 { PR_1_ILLEGAL_BLOCK_NUM,
381 N_("@I @b #%B (%b) in @i %i. "),
382 PROMPT_CLEAR, PR_LATCH_BLOCK },
384 /* Block number overlaps fs metadata */
385 { PR_1_BLOCK_OVERLAPS_METADATA,
386 N_("@b #%B (%b) overlaps @f metadata in @i %i. "),
387 PROMPT_CLEAR, PR_LATCH_BLOCK },
389 /* Inode has illegal blocks (latch question) */
390 { PR_1_INODE_BLOCK_LATCH,
391 N_("@i %i has illegal @b(s). "),
394 /* Too many bad blocks in inode */
395 { PR_1_TOO_MANY_BAD_BLOCKS,
396 N_("Too many illegal @bs in @i %i.\n"),
397 PROMPT_CLEAR_INODE, PR_NO_OK },
399 /* Illegal block number in bad block inode */
400 { PR_1_BB_ILLEGAL_BLOCK_NUM,
401 N_("@I @b #%B (%b) in bad @b @i. "),
402 PROMPT_CLEAR, PR_LATCH_BBLOCK },
404 /* Bad block inode has illegal blocks (latch question) */
405 { PR_1_INODE_BBLOCK_LATCH,
406 N_("Bad @b @i has illegal @b(s). "),
409 /* Duplicate or bad blocks in use! */
410 { PR_1_DUP_BLOCKS_PREENSTOP,
411 N_("Duplicate or bad @b in use!\n"),
414 /* Bad block used as bad block indirect block */
415 { PR_1_BBINODE_BAD_METABLOCK,
416 N_("Bad @b %b used as bad @b indirect @b?!?\n"),
417 PROMPT_NONE, PR_AFTER_CODE, PR_1_BBINODE_BAD_METABLOCK_PROMPT },
419 /* Inconsistency can't be fixed prompt */
420 { PR_1_BBINODE_BAD_METABLOCK_PROMPT,
421 N_("\nThis inconsistency can not be fixed with e2fsck; to fix it, use\n"
422 """dumpe2fs -b"" to dump out the bad @b "
423 "list and ""e2fsck -L filename""\n"
424 "to read it back in again.\n"),
425 PROMPT_CONTINUE, PR_PREEN_NOMSG },
427 /* Bad primary block */
428 { PR_1_BAD_PRIMARY_BLOCK,
429 N_("\nIf the @b is really bad, the @f can not be fixed.\n"),
430 PROMPT_NONE, PR_AFTER_CODE, PR_1_BAD_PRIMARY_BLOCK_PROMPT },
432 /* Bad primary block prompt */
433 { PR_1_BAD_PRIMARY_BLOCK_PROMPT,
434 N_("You can clear the this @b (and hope for the best) from the\n"
435 "bad @b list and hope that @b is really OK, but there are no\n"
437 PROMPT_CLEAR, PR_PREEN_NOMSG },
439 /* Bad primary superblock */
440 { PR_1_BAD_PRIMARY_SUPERBLOCK,
441 N_("The primary @S (%b) is on the bad @b list.\n"),
442 PROMPT_NONE, PR_AFTER_CODE, PR_1_BAD_PRIMARY_BLOCK },
444 /* Bad primary block group descriptors */
445 { PR_1_BAD_PRIMARY_GROUP_DESCRIPTOR,
446 N_("Block %b in the primary @g descriptors "
447 "is on the bad @b list\n"),
448 PROMPT_NONE, PR_AFTER_CODE, PR_1_BAD_PRIMARY_BLOCK },
450 /* Bad superblock in group */
451 { PR_1_BAD_SUPERBLOCK,
452 N_("Warning: Group %g's @S (%b) is bad.\n"),
453 PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },
455 /* Bad block group descriptors in group */
456 { PR_1_BAD_GROUP_DESCRIPTORS,
457 N_("Warning: Group %g's copy of the @g descriptors has a bad "
459 PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },
461 /* Block claimed for no reason */
462 { PR_1_PROGERR_CLAIMED_BLOCK,
463 N_("Programming error? @b #%b claimed for no reason in "
464 "process_bad_@b.\n"),
465 PROMPT_NONE, PR_PREEN_OK },
467 /* Error allocating blocks for relocating metadata */
468 { PR_1_RELOC_BLOCK_ALLOCATE,
469 N_("@A %N @b(s) for %s: %m\n"),
470 PROMPT_NONE, PR_PREEN_OK },
472 /* Error allocating block buffer during relocation process */
473 { PR_1_RELOC_MEMORY_ALLOCATE,
474 N_("@A @b buffer for relocating %s\n"),
475 PROMPT_NONE, PR_PREEN_OK },
477 /* Relocating metadata group information from X to Y */
478 { PR_1_RELOC_FROM_TO,
479 N_("Relocating @g %g's %s from %b to %c...\n"),
480 PROMPT_NONE, PR_PREEN_OK },
482 /* Relocating metatdata group information to X */
484 N_("Relocating @g %g's %s to %c...\n"),
485 PROMPT_NONE, PR_PREEN_OK },
487 /* Block read error during relocation process */
488 { PR_1_RELOC_READ_ERR,
489 N_("Warning: could not read @b %b of %s: %m\n"),
490 PROMPT_NONE, PR_PREEN_OK },
492 /* Block write error during relocation process */
493 { PR_1_RELOC_WRITE_ERR,
494 N_("Warning: could not write @b %b for %s: %m\n"),
495 PROMPT_NONE, PR_PREEN_OK },
497 /* Error allocating inode bitmap */
498 { PR_1_ALLOCATE_IBITMAP_ERROR,
499 "@A @i @B (%N): %m\n",
500 PROMPT_NONE, PR_FATAL },
502 /* Error allocating block bitmap */
503 { PR_1_ALLOCATE_BBITMAP_ERROR,
504 "@A @b @B (%N): %m\n",
505 PROMPT_NONE, PR_FATAL },
507 /* Error allocating icount structure */
508 { PR_1_ALLOCATE_ICOUNT,
509 N_("@A icount link information: %m\n"),
510 PROMPT_NONE, PR_FATAL },
512 /* Error allocating dbcount */
513 { PR_1_ALLOCATE_DBCOUNT,
514 N_("@A @d @b array: %m\n"),
515 PROMPT_NONE, PR_FATAL },
517 /* Error while scanning inodes */
519 N_("Error while scanning @is (%i): %m\n"),
520 PROMPT_NONE, PR_FATAL },
522 /* Error while iterating over blocks */
523 { PR_1_BLOCK_ITERATE,
524 N_("Error while iterating over @bs in @i %i: %m\n"),
525 PROMPT_NONE, PR_FATAL },
527 /* Error while storing inode count information */
529 N_("Error storing @i count information (@i=%i, count=%N): %m\n"),
530 PROMPT_NONE, PR_FATAL },
532 /* Error while storing directory block information */
534 N_("Error storing @d @b information "
535 "(@i=%i, @b=%b, num=%N): %m\n"),
536 PROMPT_NONE, PR_FATAL },
538 /* Error while reading inode (for clearing) */
540 N_("Error reading @i %i: %m\n"),
541 PROMPT_NONE, PR_FATAL },
543 /* Suppress messages prompt */
544 { PR_1_SUPPRESS_MESSAGES, "", PROMPT_SUPPRESS, PR_NO_OK },
546 /* Imagic flag set on an inode when filesystem doesn't support it */
548 N_("@i %i has imagic flag set. "),
551 /* Immutable flag set on a device or socket inode */
552 { PR_1_SET_IMMUTABLE,
553 N_("Special (@v/socket/fifo/symlink) file (@i %i) has immutable\n"
554 "or append-only flag set. "),
555 PROMPT_CLEAR, PR_PREEN_OK | PR_PREEN_NO | PR_NO_OK },
557 /* Compression flag set on an inode when filesystem doesn't support it */
559 N_("@i %i has @cion flag set on @f without @cion support. "),
562 /* Non-zero size for device, fifo or socket inode */
564 "Special (@v/socket/fifo) @i %i has non-zero size. ",
565 PROMPT_FIX, PR_PREEN_OK },
567 /* Filesystem revision is 0, but feature flags are set */
569 "@f has feature flag(s) set, but is a revision 0 @f. ",
570 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 "@j @i is not in use, but contains data. ",
575 PROMPT_CLEAR, PR_PREEN_OK },
577 /* Journal has bad mode */
578 { PR_1_JOURNAL_BAD_MODE,
579 N_("@j is not regular file. "),
580 PROMPT_FIX, PR_PREEN_OK },
582 /* Deal with inodes that were part of orphan linked list */
584 N_("@i %i was part of the orphaned @i list. "),
585 PROMPT_FIX, PR_LATCH_LOW_DTIME, 0 },
587 /* Deal with inodes that were part of corrupted orphan linked
588 list (latch question) */
589 { PR_1_ORPHAN_LIST_REFUGEES,
590 N_("@is that were part of a corrupted orphan linked list found. "),
593 /* Error allocating refcount structure */
594 { PR_1_ALLOCATE_REFCOUNT,
595 "@A refcount structure (%N): %m\n",
596 PROMPT_NONE, PR_FATAL },
598 /* Error reading extended attribute block */
599 { PR_1_READ_EA_BLOCK,
600 N_("Error reading @a @b %b for @i %i. "),
603 /* Invalid extended attribute block */
605 N_("@i %i has a bad @a @b %b. "),
608 /* Error reading Extended Attribute block while fixing refcount */
609 { PR_1_EXTATTR_READ_ABORT,
610 N_("Error reading @a @b %b (%m). "),
613 /* Extended attribute reference count incorrect */
614 { PR_1_EXTATTR_REFCOUNT,
615 N_("@a @b %b has reference count %B, should be %N. "),
618 /* Error writing Extended Attribute block while fixing refcount */
619 { PR_1_EXTATTR_WRITE,
620 N_("Error writing @a @b %b (%m). "),
623 /* Multiple EA blocks not supported */
624 { PR_1_EA_MULTI_BLOCK,
625 N_("@a @b %b has h_blocks > 1. "),
628 /* Error allocating EA region allocation structure */
629 { PR_1_EA_ALLOC_REGION,
630 N_("Error allocating @a @b %b. "),
633 /* Error EA allocation collision */
634 { PR_1_EA_ALLOC_COLLISION,
635 N_("@a @b %b is corrupt (allocation collision). "),
638 /* Bad extended attribute name */
640 N_("@a @b %b is corrupt (invalid name). "),
643 /* Bad extended attribute value */
645 N_("@a @b %b is corrupt (invalid value). "),
650 /* Pass 1B: Rescan for duplicate/bad blocks */
652 N_("Duplicate @bs found... invoking duplicate @b passes.\n"
653 "Pass 1B: Rescan for duplicate/bad @bs\n"),
656 /* Duplicate/bad block(s) header */
657 { PR_1B_DUP_BLOCK_HEADER,
658 N_("Duplicate/bad @b(s) in @i %i:"),
661 /* Duplicate/bad block(s) in inode */
664 PROMPT_NONE, PR_LATCH_DBLOCK },
666 /* Duplicate/bad block(s) end */
667 { PR_1B_DUP_BLOCK_END,
671 /* Error while scanning inodes */
673 N_("Error while scanning inodes (%i): %m\n"),
674 PROMPT_NONE, PR_FATAL },
676 /* Error allocating inode bitmap */
677 { PR_1B_ALLOCATE_IBITMAP_ERROR,
678 N_("@A @i @B (inode_dup_map): %m\n"),
679 PROMPT_NONE, PR_FATAL },
681 /* Error while iterating over blocks */
682 { PR_1B_BLOCK_ITERATE,
683 N_("Error while iterating over @bs in @i %i (%s): %m\n"),
686 /* Pass 1C: Scan directories for inodes with dup blocks. */
688 N_("Pass 1C: Scan directories for @is with dup @bs.\n"),
692 /* Pass 1D: Reconciling duplicate blocks */
694 N_("Pass 1D: Reconciling duplicate @bs\n"),
697 /* File has duplicate blocks */
699 N_("File %Q (@i #%i, mod time %IM) \n"
700 " has %B duplicate @b(s), shared with %N file(s):\n"),
703 /* List of files sharing duplicate blocks */
704 { PR_1D_DUP_FILE_LIST,
705 N_("\t%Q (@i #%i, mod time %IM)\n"),
708 /* File sharing blocks with filesystem metadata */
709 { PR_1D_SHARE_METADATA,
710 N_("\t<@f metadata>\n"),
713 /* Report of how many duplicate/bad inodes */
714 { PR_1D_NUM_DUP_INODES,
715 N_("(There are %N @is containing duplicate/bad @bs.)\n\n"),
718 /* Duplicated blocks already reassigned or cloned. */
719 { PR_1D_DUP_BLOCKS_DEALT,
720 N_("Duplicated @bs already reassigned or cloned.\n\n"),
723 /* Clone duplicate/bad blocks? */
724 { PR_1D_CLONE_QUESTION,
725 "", PROMPT_CLONE, PR_NO_OK },
728 { PR_1D_DELETE_QUESTION,
729 "", PROMPT_DELETE, 0 },
731 /* Couldn't clone file (error) */
733 N_("Couldn't clone file: %m\n"), PROMPT_NONE, 0 },
737 /* Pass 2: Checking directory structure */
739 N_("Pass 2: Checking @d structure\n"),
742 /* Bad inode number for '.' */
743 { PR_2_BAD_INODE_DOT,
744 N_("Bad @i number for '.' in @d @i %i.\n"),
747 /* Directory entry has bad inode number */
749 N_("@E has bad @i #: %Di.\n"),
752 /* Directory entry has deleted or unused inode */
754 N_("@E has @D/unused @i %Di. "),
755 PROMPT_CLEAR, PR_PREEN_OK },
757 /* Directry entry is link to '.' */
762 /* Directory entry points to inode now located in a bad block */
764 N_("@E points to @i (%Di) located in a bad @b.\n"),
767 /* Directory entry contains a link to a directory */
769 N_("@E @L to @d %P (%Di).\n"),
772 /* Directory entry contains a link to the root directry */
774 N_("@E @L to the @r.\n"),
777 /* Directory entry has illegal characters in its name */
779 N_("@E has illegal characters in its name.\n"),
782 /* Missing '.' in directory inode */
784 N_("Missing '.' in @d @i %i.\n"),
787 /* Missing '..' in directory inode */
788 { PR_2_MISSING_DOT_DOT,
789 N_("Missing '..' in @d @i %i.\n"),
792 /* First entry in directory inode doesn't contain '.' */
794 N_("First @e '%Dn' (inode=%Di) in @d @i %i (%p) @s '.'\n"),
797 /* Second entry in directory inode doesn't contain '..' */
798 { PR_2_2ND_NOT_DOT_DOT,
799 N_("Second @e '%Dn' (inode=%Di) in @d @i %i @s '..'\n"),
802 /* i_faddr should be zero */
804 N_("i_faddr @F %IF, @s zero.\n"),
807 /* i_file_acl should be zero */
808 { PR_2_FILE_ACL_ZERO,
809 N_("i_file_acl @F %If, @s zero.\n"),
812 /* i_dir_acl should be zero */
814 N_("i_dir_acl @F %Id, @s zero.\n"),
817 /* i_frag should be zero */
819 N_("i_frag @F %N, @s zero.\n"),
822 /* i_fsize should be zero */
824 N_("i_fsize @F %N, @s zero.\n"),
827 /* inode has bad mode */
829 N_("@i %i (%Q) has a bad mode (%Im).\n"),
832 /* directory corrupted */
833 { PR_2_DIR_CORRUPTED,
834 N_("@d @i %i, @b %B, offset %N: @d corrupted\n"),
837 /* filename too long */
838 { PR_2_FILENAME_LONG,
839 N_("@d @i %i, @b %B, offset %N: filename too long\n"),
840 PROMPT_TRUNCATE, 0 },
842 /* Directory inode has a missing block (hole) */
843 { PR_2_DIRECTORY_HOLE,
844 N_("@d @i %i has an unallocated @b #%B. "),
845 PROMPT_ALLOCATE, 0 },
847 /* '.' is not NULL terminated */
848 { PR_2_DOT_NULL_TERM,
849 N_("'.' @d @e in @d @i %i is not NULL terminated\n"),
852 /* '..' is not NULL terminated */
853 { PR_2_DOT_DOT_NULL_TERM,
854 N_("'..' @d @e in @d @i %i is not NULL terminated\n"),
857 /* Illegal character device inode */
859 N_("@i %i (%Q) is an @I character @v.\n"),
862 /* Illegal block device inode */
863 { PR_2_BAD_BLOCK_DEV,
864 N_("@i %i (%Q) is an @I @b @v.\n"),
867 /* Duplicate '.' entry */
869 N_("@E is duplicate '.' @e.\n"),
872 /* Duplicate '..' entry */
874 N_("@E is duplicate '..' @e.\n"),
877 /* Internal error: couldn't find dir_info */
879 N_("Internal error: couldn't find dir_info for %i.\n"),
880 PROMPT_NONE, PR_FATAL },
882 /* Final rec_len is wrong */
884 N_("@E has rec_len of %Dr, should be %N.\n"),
887 /* Error allocating icount structure */
888 { PR_2_ALLOCATE_ICOUNT,
889 N_("@A icount structure: %m\n"),
890 PROMPT_NONE, PR_FATAL },
892 /* Error iterating over directory blocks */
893 { PR_2_DBLIST_ITERATE,
894 N_("Error interating over @d @bs: %m\n"),
895 PROMPT_NONE, PR_FATAL },
897 /* Error reading directory block */
898 { PR_2_READ_DIRBLOCK,
899 N_("Error reading @d @b %b (@i %i): %m\n"),
900 PROMPT_CONTINUE, 0 },
902 /* Error writing directory block */
903 { PR_2_WRITE_DIRBLOCK,
904 N_("Error writing @d @b %b (@i %i): %m\n"),
905 PROMPT_CONTINUE, 0 },
907 /* Error allocating new directory block */
908 { PR_2_ALLOC_DIRBOCK,
909 N_("@A new @d @b for @i %i (%s): %m\n"),
912 /* Error deallocating inode */
913 { PR_2_DEALLOC_INODE,
914 N_("Error deallocating @i %i: %m\n"),
915 PROMPT_NONE, PR_FATAL },
917 /* Directory entry for '.' is big. Split? */
919 N_("@d @e for '.' is big. "),
920 PROMPT_SPLIT, PR_NO_OK },
922 /* Illegal FIFO inode */
924 N_("@i %i (%Q) is an @I FIFO.\n"),
927 /* Illegal socket inode */
929 N_("@i %i (%Q) is an @I socket.\n"),
932 /* Directory filetype not set */
934 N_("Setting filetype for @E to %N.\n"),
935 PROMPT_NONE, PR_PREEN_OK | PR_NO_OK | PR_NO_NOMSG },
937 /* Directory filetype incorrect */
939 N_("@E has an incorrect filetype (was %Dt, should be %N).\n"),
942 /* Directory filetype set on filesystem */
943 { PR_2_CLEAR_FILETYPE,
944 N_("@E has filetype set.\n"),
945 PROMPT_CLEAR, PR_PREEN_OK },
947 /* Directory filename is null */
949 N_("@E has a zero-length name.\n"),
952 /* Invalid fast symlink size */
954 N_("Symlink %Q (@i #%i) has an invalid size (%Is).\n"),
957 /* i_file_acl (extended attribute block) is bad */
959 N_("@a @b @F is invalid (%If).\n"),
962 /* Filesystem contains large files, but has no such flag in sb */
963 { PR_2_FEATURE_LARGE_FILES,
964 N_("@f contains large files, but lacks LARGE_FILE flag in @S.\n"),
969 /* Pass 3: Checking directory connectivity */
971 N_("Pass 3: Checking @d connectivity\n"),
974 /* Root inode not allocated */
975 { PR_3_NO_ROOT_INODE,
976 N_("@r not allocated. "),
977 PROMPT_ALLOCATE, 0 },
979 /* No room in lost+found */
980 { PR_3_EXPAND_LF_DIR,
981 N_("No room in @l @d. "),
984 /* Unconnected directory inode */
985 { PR_3_UNCONNECTED_DIR,
986 N_("Unconnected @d @i %i (%p)\n"),
989 /* /lost+found not found */
991 N_("/@l not found. "),
992 PROMPT_CREATE, PR_PREEN_OK },
994 /* .. entry is incorrect */
996 N_("'..' in %Q (%i) is %P (%j), @s %q (%d).\n"),
999 /* Bad or non-existent /lost+found. Cannot reconnect */
1001 N_("Bad or non-existent /@l. Cannot reconnect.\n"),
1004 /* Could not expand /lost+found */
1005 { PR_3_CANT_EXPAND_LPF,
1006 N_("Could not expand /@l: %m\n"),
1009 /* Could not reconnect inode */
1010 { PR_3_CANT_RECONNECT,
1011 N_("Could not reconnect %i: %m\n"),
1014 /* Error while trying to find /lost+found */
1015 { PR_3_ERR_FIND_LPF,
1016 N_("Error while trying to find /@l: %m\n"),
1019 /* Error in ext2fs_new_block while creating /lost+found */
1020 { PR_3_ERR_LPF_NEW_BLOCK,
1021 N_("ext2fs_new_@b: %m while trying to create /@l @d\n"),
1024 /* Error in ext2fs_new_inode while creating /lost+found */
1025 { PR_3_ERR_LPF_NEW_INODE,
1026 N_("ext2fs_new_@i: %m while trying to create /@l @d\n"),
1029 /* Error in ext2fs_new_dir_block while creating /lost+found */
1030 { PR_3_ERR_LPF_NEW_DIR_BLOCK,
1031 N_("ext2fs_new_dir_@b: %m while creating new @d @b\n"),
1034 /* Error while writing directory block for /lost+found */
1035 { PR_3_ERR_LPF_WRITE_BLOCK,
1036 N_("ext2fs_write_dir_@b: %m while writing the @d @b for /@l\n"),
1039 /* Error while adjusting inode count */
1040 { PR_3_ADJUST_INODE,
1041 N_("Error while adjusting @i count on @i %i\n"),
1044 /* Couldn't fix parent directory -- error */
1045 { PR_3_FIX_PARENT_ERR,
1046 N_("Couldn't fix parent of @i %i: %m\n\n"),
1049 /* Couldn't fix parent directory -- couldn't find it */
1050 { PR_3_FIX_PARENT_NOFIND,
1051 N_("Couldn't fix parent of @i %i: Couldn't find parent @d entry\n\n"),
1054 /* Error allocating inode bitmap */
1055 { PR_3_ALLOCATE_IBITMAP_ERROR,
1056 N_("@A @i @B (%N): %m\n"),
1057 PROMPT_NONE, PR_FATAL },
1059 /* Error creating root directory */
1060 { PR_3_CREATE_ROOT_ERROR,
1061 N_("Error creating root @d (%s): %m\n"),
1062 PROMPT_NONE, PR_FATAL },
1064 /* Error creating lost and found directory */
1065 { PR_3_CREATE_LPF_ERROR,
1066 N_("Error creating /@l @d (%s): %m\n"),
1067 PROMPT_NONE, PR_FATAL },
1069 /* Root inode is not directory; aborting */
1070 { PR_3_ROOT_NOT_DIR_ABORT,
1071 N_("@r is not a @d; aborting.\n"),
1072 PROMPT_NONE, PR_FATAL },
1074 /* Cannot proceed without a root inode. */
1075 { PR_3_NO_ROOT_INODE_ABORT,
1076 N_("Cannot proceed without a @r.\n"),
1077 PROMPT_NONE, PR_FATAL },
1079 /* Internal error: couldn't find dir_info */
1081 N_("Internal error: couldn't find dir_info for %i.\n"),
1082 PROMPT_NONE, PR_FATAL },
1084 /* Lost+found not a directory */
1086 N_("/@l is not a @d (ino=%i)\n"),
1091 /* Pass 4: Checking reference counts */
1093 N_("Pass 4: Checking reference counts\n"),
1096 /* Unattached zero-length inode */
1097 { PR_4_ZERO_LEN_INODE,
1099 PROMPT_CLEAR, PR_PREEN_OK|PR_NO_OK },
1101 /* Unattached inode */
1102 { PR_4_UNATTACHED_INODE,
1104 PROMPT_CONNECT, 0 },
1106 /* Inode ref count wrong */
1107 { PR_4_BAD_REF_COUNT,
1108 N_("@i %i ref count is %Il, @s %N. "),
1109 PROMPT_FIX, PR_PREEN_OK },
1111 { PR_4_INCONSISTENT_COUNT,
1112 N_("WARNING: PROGRAMMING BUG IN E2FSCK!\n"
1113 "\tOR SOME BONEHEAD (YOU) IS CHECKING A MOUNTED (LIVE) FILESYSTEM.\n"
1114 "@i_link_info[%i] is %N, @i.i_links_count is %Il. "
1115 "They should be the same!\n"),
1120 /* Pass 5: Checking group summary information */
1122 N_("Pass 5: Checking @g summary information\n"),
1125 /* Padding at end of inode bitmap is not set. */
1126 { PR_5_INODE_BMAP_PADDING,
1127 N_("Padding at end of @i @B is not set. "),
1128 PROMPT_FIX, PR_PREEN_OK },
1130 /* Padding at end of block bitmap is not set. */
1131 { PR_5_BLOCK_BMAP_PADDING,
1132 N_("Padding at end of @b @B is not set. "),
1133 PROMPT_FIX, PR_PREEN_OK },
1135 /* Block bitmap differences header */
1136 { PR_5_BLOCK_BITMAP_HEADER,
1137 N_("@b @B differences: "),
1138 PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG},
1140 /* Block not used, but marked in bitmap */
1141 { PR_5_UNUSED_BLOCK,
1143 PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
1145 /* Block used, but not marked used in bitmap */
1148 PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
1150 /* Block bitmap differences end */
1151 { PR_5_BLOCK_BITMAP_END,
1153 PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
1155 /* Inode bitmap differences header */
1156 { PR_5_INODE_BITMAP_HEADER,
1157 N_("@i @B differences: "),
1158 PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG },
1160 /* Inode not used, but marked in bitmap */
1161 { PR_5_UNUSED_INODE,
1163 PROMPT_NONE, PR_LATCH_IBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
1165 /* Inode used, but not marked used in bitmap */
1168 PROMPT_NONE, PR_LATCH_IBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
1170 /* Inode bitmap differences end */
1171 { PR_5_INODE_BITMAP_END,
1173 PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
1175 /* Free inodes count for group wrong */
1176 { PR_5_FREE_INODE_COUNT_GROUP,
1177 N_("Free @is count wrong for @g #%g (%i, counted=%j).\n"),
1178 PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
1180 /* Directories count for group wrong */
1181 { PR_5_FREE_DIR_COUNT_GROUP,
1182 N_("Directories count wrong for @g #%g (%i, counted=%j).\n"),
1183 PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
1185 /* Free inodes count wrong */
1186 { PR_5_FREE_INODE_COUNT,
1187 N_("Free @is count wrong (%i, counted=%j).\n"),
1188 PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
1190 /* Free blocks count for group wrong */
1191 { PR_5_FREE_BLOCK_COUNT_GROUP,
1192 N_("Free @bs count wrong for @g #%g (%b, counted=%c).\n"),
1193 PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
1195 /* Free blocks count wrong */
1196 { PR_5_FREE_BLOCK_COUNT,
1197 N_("Free @bs count wrong (%b, counted=%c).\n"),
1198 PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
1200 /* Programming error: bitmap endpoints don't match */
1201 { PR_5_BMAP_ENDPOINTS,
1202 N_("PROGRAMMING ERROR: @f (#%N) @B endpoints (%b, %c) don't "
1203 "match calculated @B endpoints (%i, %j)\n"),
1204 PROMPT_NONE, PR_FATAL },
1206 /* Internal error: fudging end of bitmap */
1207 { PR_5_FUDGE_BITMAP_ERROR,
1208 N_("Internal error: fudging end of bitmap (%N)\n"),
1209 PROMPT_NONE, PR_FATAL },
1211 /* Error copying in replacement inode bitmap */
1212 { PR_5_COPY_IBITMAP_ERROR,
1213 "Error copying in replacement @i @B: %m\n",
1214 PROMPT_NONE, PR_FATAL },
1216 /* Error copying in replacement block bitmap */
1217 { PR_5_COPY_BBITMAP_ERROR,
1218 "Error copying in replacement @b @B: %m\n",
1219 PROMPT_NONE, PR_FATAL },
1225 * This is the latch flags register. It allows several problems to be
1226 * "latched" together. This means that the user has to answer but one
1227 * question for the set of problems, and all of the associated
1228 * problems will be either fixed or not fixed.
1230 static struct latch_descr pr_latch_info[] = {
1231 { PR_LATCH_BLOCK, PR_1_INODE_BLOCK_LATCH, 0 },
1232 { PR_LATCH_BBLOCK, PR_1_INODE_BBLOCK_LATCH, 0 },
1233 { PR_LATCH_IBITMAP, PR_5_INODE_BITMAP_HEADER, PR_5_INODE_BITMAP_END },
1234 { PR_LATCH_BBITMAP, PR_5_BLOCK_BITMAP_HEADER, PR_5_BLOCK_BITMAP_END },
1235 { PR_LATCH_RELOC, PR_0_RELOCATE_HINT, 0 },
1236 { PR_LATCH_DBLOCK, PR_1B_DUP_BLOCK_HEADER, PR_1B_DUP_BLOCK_END },
1237 { PR_LATCH_LOW_DTIME, PR_1_ORPHAN_LIST_REFUGEES, 0 },
1241 static const struct e2fsck_problem *find_problem(int code)
1245 for (i=0; problem_table[i].e2p_code; i++) {
1246 if (problem_table[i].e2p_code == code)
1247 return &problem_table[i];
1252 static struct latch_descr *find_latch(int code)
1256 for (i=0; pr_latch_info[i].latch_code >= 0; i++) {
1257 if (pr_latch_info[i].latch_code == code)
1258 return &pr_latch_info[i];
1263 int end_problem_latch(e2fsck_t ctx, int mask)
1265 struct latch_descr *ldesc;
1266 struct problem_context pctx;
1269 ldesc = find_latch(mask);
1270 if (ldesc->end_message && (ldesc->flags & PRL_LATCHED)) {
1271 clear_problem_context(&pctx);
1272 answer = fix_problem(ctx, ldesc->end_message, &pctx);
1274 ldesc->flags &= ~(PRL_VARIABLE);
1278 int set_latch_flags(int mask, int setflags, int clearflags)
1280 struct latch_descr *ldesc;
1282 ldesc = find_latch(mask);
1285 ldesc->flags |= setflags;
1286 ldesc->flags &= ~clearflags;
1290 int get_latch_flags(int mask, int *value)
1292 struct latch_descr *ldesc;
1294 ldesc = find_latch(mask);
1297 *value = ldesc->flags;
1301 void clear_problem_context(struct problem_context *ctx)
1303 memset(ctx, 0, sizeof(struct problem_context));
1308 int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
1310 ext2_filsys fs = ctx->fs;
1311 const struct e2fsck_problem *ptr;
1312 struct latch_descr *ldesc = 0;
1313 const char *message;
1314 int def_yn, answer, ans;
1315 int print_answer = 0;
1318 ptr = find_problem(code);
1320 printf(_("Unhandled error code (%d)!\n"), code);
1324 if ((ptr->flags & PR_NO_DEFAULT) ||
1325 ((ptr->flags & PR_PREEN_NO) && (ctx->options & E2F_OPT_PREEN)) ||
1326 (ctx->options & E2F_OPT_NO))
1330 * Do special latch processing. This is where we ask the
1331 * latch question, if it exists
1333 if (ptr->flags & PR_LATCH_MASK) {
1334 ldesc = find_latch(ptr->flags & PR_LATCH_MASK);
1335 if (ldesc->question && !(ldesc->flags & PRL_LATCHED)) {
1336 ans = fix_problem(ctx, ldesc->question, pctx);
1338 ldesc->flags |= PRL_YES;
1340 ldesc->flags |= PRL_NO;
1341 ldesc->flags |= PRL_LATCHED;
1343 if (ldesc->flags & PRL_SUPPRESS)
1346 if ((ptr->flags & PR_PREEN_NOMSG) &&
1347 (ctx->options & E2F_OPT_PREEN))
1349 if ((ptr->flags & PR_NO_NOMSG) &&
1350 (ctx->options & E2F_OPT_NO))
1353 message = ptr->e2p_description;
1354 if (ctx->options & E2F_OPT_PREEN) {
1355 printf("%s: ", ctx->device_name);
1357 if (ptr->e2p_preen_msg)
1358 message = ptr->e2p_preen_msg;
1361 print_e2fsck_message(ctx, _(message), pctx, 1);
1363 if (!(ptr->flags & PR_PREEN_OK) && (ptr->prompt != PROMPT_NONE))
1366 if (ptr->flags & PR_FATAL)
1367 fatal_error(ctx, 0);
1369 if (ptr->prompt == PROMPT_NONE) {
1370 if (ptr->flags & PR_NOCOLLATE)
1375 if (ctx->options & E2F_OPT_PREEN) {
1377 if (!(ptr->flags & PR_PREEN_NOMSG))
1379 } else if ((ptr->flags & PR_LATCH_MASK) &&
1380 (ldesc->flags & (PRL_YES | PRL_NO))) {
1383 if (ldesc->flags & PRL_YES)
1388 answer = ask(ctx, _(prompt[(int) ptr->prompt]), def_yn);
1389 if (!answer && !(ptr->flags & PR_NO_OK))
1390 ext2fs_unmark_valid(fs);
1393 printf("%s.\n", answer ?
1394 _(preen_msg[(int) ptr->prompt]) : _("IGNORED"));
1398 if ((ptr->prompt == PROMPT_ABORT) && answer)
1399 fatal_error(ctx, 0);
1401 if (ptr->flags & PR_AFTER_CODE)
1402 answer = fix_problem(ctx, ptr->second_code, pctx);