2 * problem.h --- e2fsck problem error codes
4 * Copyright 1996 by Theodore Ts'o
7 * This file may be redistributed under the terms of the GNU Public
12 typedef __u32 problem_t;
14 struct problem_context {
16 ext2_ino_t ino, ino2, dir;
17 struct ext2_inode *inode;
18 struct ext2_dir_entry *dirent;
27 * We define a set of "latch groups"; these are problems which are
28 * handled as a set. The user answers once for a particular latch
31 #define PR_LATCH_MASK 0x0ff0 /* Latch mask */
32 #define PR_LATCH_BLOCK 0x0010 /* Latch for illegal blocks (pass 1) */
33 #define PR_LATCH_BBLOCK 0x0020 /* Latch for bad block inode blocks (pass 1) */
34 #define PR_LATCH_IBITMAP 0x0030 /* Latch for pass 5 inode bitmap proc. */
35 #define PR_LATCH_BBITMAP 0x0040 /* Latch for pass 5 inode bitmap proc. */
36 #define PR_LATCH_RELOC 0x0050 /* Latch for superblock relocate hint */
37 #define PR_LATCH_DBLOCK 0x0060 /* Latch for pass 1b dup block headers */
38 #define PR_LATCH_LOW_DTIME 0x0070 /* Latch for pass1 orphaned list refugees */
40 #define PR_LATCH(x) ((((x) & PR_LATCH_MASK) >> 4) - 1)
43 * Latch group descriptor flags
45 #define PRL_YES 0x0001 /* Answer yes */
46 #define PRL_NO 0x0002 /* Answer no */
47 #define PRL_LATCHED 0x0004 /* The latch group is latched */
48 #define PRL_SUPPRESS 0x0008 /* Suppress all latch group questions */
50 #define PRL_VARIABLE 0x000f /* All the flags that need to be reset */
56 /* Block bitmap not in group */
57 #define PR_0_BB_NOT_GROUP 0x000001
59 /* Inode bitmap not in group */
60 #define PR_0_IB_NOT_GROUP 0x000002
62 /* Inode table not in group */
63 #define PR_0_ITABLE_NOT_GROUP 0x000003
65 /* Superblock corrupt */
66 #define PR_0_SB_CORRUPT 0x000004
68 /* Filesystem size is wrong */
69 #define PR_0_FS_SIZE_WRONG 0x000005
71 /* Fragments not supported */
72 #define PR_0_NO_FRAGMENTS 0x000006
74 /* Bad blocks_per_group */
75 #define PR_0_BLOCKS_PER_GROUP 0x000007
77 /* Bad first_data_block */
78 #define PR_0_FIRST_DATA_BLOCK 0x000008
80 /* Adding UUID to filesystem */
81 #define PR_0_ADD_UUID 0x000009
84 #define PR_0_RELOCATE_HINT 0x00000A
86 /* Miscellaneous superblock corruption */
87 #define PR_0_MISC_CORRUPT_SUPER 0x00000B
89 /* Error determing physical device size of filesystem */
90 #define PR_0_GETSIZE_ERROR 0x00000C
92 /* Inode count in the superblock incorrect */
93 #define PR_0_INODE_COUNT_WRONG 0x00000D
95 /* The Hurd does not support the filetype feature */
96 #define PR_0_HURD_CLEAR_FILETYPE 0x00000E
98 /* Journal inode is invalid */
99 #define PR_0_JOURNAL_BAD_INODE 0x00000F
101 /* Superblock has a journal device (which we can't handle yet) */
102 #define PR_0_JOURNAL_UNSUPP_DEV 0x000010
104 /* Superblock has a bad journal device */
105 #define PR_0_JOURNAL_BAD_DEV 0x000011
107 /* Superblock has a journal UUID (which we can't handle yet) */
108 #define PR_0_JOURNAL_UNSUPP_UUID 0x000012
110 /* Superblock has a bad journal UUID */
111 #define PR_0_JOURNAL_BAD_UUID 0x000013
113 /* Journal has an unknown superblock type */
114 #define PR_0_JOURNAL_UNSUPP_SUPER 0x000014
116 /* Journal superblock is corrupt */
117 #define PR_0_JOURNAL_BAD_SUPER 0x000015
119 /* Journal superblock is corrupt */
120 #define PR_0_JOURNAL_HAS_JOURNAL 0x000016
122 /* Superblock has recovery flag set but no journal */
123 #define PR_0_JOURNAL_RECOVER_SET 0x000017
125 /* Warning message about leaving data in the journal */
126 #define PR_0_JOURNAL_RESET_JOURNAL 0x000018
128 /* Superblock recovery flag clear - journal needs to be reset */
129 #define PR_0_JOURNAL_RESET_PROMPT 0x000019
131 /* Filesystem revision is 0, but feature flags are set */
132 #define PR_0_FS_REV_LEVEL 0x00001A
134 /* Clearing orphan inode */
135 #define PR_0_ORPHAN_CLEAR_INODE 0x000020
137 /* Illegal block found in orphaned inode */
138 #define PR_0_ORPHAN_ILLEGAL_BLOCK_NUM 0x000021
140 /* Already cleared block found in orphaned inode */
141 #define PR_0_ORPHAN_ALREADY_CLEARED_BLOCK 0x000022
143 /* Illegal orphan inode in superblock */
144 #define PR_0_ORPHAN_ILLEGAL_HEAD_INODE 0x000023
146 /* Illegal inode in orphaned inode list */
147 #define PR_0_ORPHAN_ILLEGAL_INODE 0x000024
149 /* Journal has unsupported read-only feature - abort */
150 #define PR_0_JOURNAL_UNSUPP_ROCOMPAT 0x000025
152 /* Journal has unsupported incompatible feature - abort */
153 #define PR_0_JOURNAL_UNSUPP_INCOMPAT 0x000026
155 /* Journal has unsupported feature - reset */
156 #define PR_0_JOURNAL_RESET_COMPAT 0x000027
162 /* Pass 1: Checking inodes, blocks, and sizes */
163 #define PR_1_PASS_HEADER 0x010000
165 /* Root directory is not an inode */
166 #define PR_1_ROOT_NO_DIR 0x010001
168 /* Root directory has dtime set */
169 #define PR_1_ROOT_DTIME 0x010002
171 /* Reserved inode has bad mode */
172 #define PR_1_RESERVED_BAD_MODE 0x010003
174 /* Deleted inode has zero dtime */
175 #define PR_1_ZERO_DTIME 0x010004
177 /* Inode in use, but dtime set */
178 #define PR_1_SET_DTIME 0x010005
180 /* Zero-length directory */
181 #define PR_1_ZERO_LENGTH_DIR 0x010006
183 /* Block bitmap conflicts with some other fs block */
184 #define PR_1_BB_CONFLICT 0x010007
186 /* Inode bitmap conflicts with some other fs block */
187 #define PR_1_IB_CONFLICT 0x010008
189 /* Inode table conflicts with some other fs block */
190 #define PR_1_ITABLE_CONFLICT 0x010009
192 /* Block bitmap is on a bad block */
193 #define PR_1_BB_BAD_BLOCK 0x01000A
195 /* Inode bitmap is on a bad block */
196 #define PR_1_IB_BAD_BLOCK 0x01000B
198 /* Inode has incorrect i_size */
199 #define PR_1_BAD_I_SIZE 0x01000C
201 /* Inode has incorrect i_blocks */
202 #define PR_1_BAD_I_BLOCKS 0x01000D
204 /* Illegal block number in inode */
205 #define PR_1_ILLEGAL_BLOCK_NUM 0x01000E
207 /* Block number overlaps fs metadata */
208 #define PR_1_BLOCK_OVERLAPS_METADATA 0x01000F
210 /* Inode has illegal blocks (latch question) */
211 #define PR_1_INODE_BLOCK_LATCH 0x010010
213 /* Too many bad blocks in inode */
214 #define PR_1_TOO_MANY_BAD_BLOCKS 0x010011
216 /* Illegal block number in bad block inode */
217 #define PR_1_BB_ILLEGAL_BLOCK_NUM 0x010012
219 /* Bad block inode has illegal blocks (latch question) */
220 #define PR_1_INODE_BBLOCK_LATCH 0x010013
222 /* Duplicate or bad blocks in use! */
223 #define PR_1_DUP_BLOCKS_PREENSTOP 0x010014
225 /* Bad block used as bad block indirect block */
226 #define PR_1_BBINODE_BAD_METABLOCK 0x010015
228 /* Inconsistency can't be fixed prompt */
229 #define PR_1_BBINODE_BAD_METABLOCK_PROMPT 0x010016
231 /* Bad primary block */
232 #define PR_1_BAD_PRIMARY_BLOCK 0x010017
234 /* Bad primary block prompt */
235 #define PR_1_BAD_PRIMARY_BLOCK_PROMPT 0x010018
237 /* Bad primary superblock */
238 #define PR_1_BAD_PRIMARY_SUPERBLOCK 0x010019
240 /* Bad primary block group descriptors */
241 #define PR_1_BAD_PRIMARY_GROUP_DESCRIPTOR 0x01001A
243 /* Bad superblock in group */
244 #define PR_1_BAD_SUPERBLOCK 0x01001B
246 /* Bad block group descriptors in group */
247 #define PR_1_BAD_GROUP_DESCRIPTORS 0x01001C
249 /* Block claimed for no reason */
250 #define PR_1_PROGERR_CLAIMED_BLOCK 0x01001D
252 /* Error allocating blocks for relocating metadata */
253 #define PR_1_RELOC_BLOCK_ALLOCATE 0x01001E
255 /* Error allocating block buffer during relocation process */
256 #define PR_1_RELOC_MEMORY_ALLOCATE 0x01001F
258 /* Relocating metadata group information from X to Y */
259 #define PR_1_RELOC_FROM_TO 0x010020
261 /* Relocating metatdata group information to X */
262 #define PR_1_RELOC_TO 0x010021
264 /* Block read error during relocation process */
265 #define PR_1_RELOC_READ_ERR 0x010022
267 /* Block write error during relocation process */
268 #define PR_1_RELOC_WRITE_ERR 0x010023
270 /* Error allocating inode bitmap */
271 #define PR_1_ALLOCATE_IBITMAP_ERROR 0x010024
273 /* Error allocating block bitmap */
274 #define PR_1_ALLOCATE_BBITMAP_ERROR 0x010025
276 /* Error allocating icount structure */
277 #define PR_1_ALLOCATE_ICOUNT 0x010026
279 /* Error allocating dbcount */
280 #define PR_1_ALLOCATE_DBCOUNT 0x010027
282 /* Error while scanning inodes */
283 #define PR_1_ISCAN_ERROR 0x010028
285 /* Error while iterating over blocks */
286 #define PR_1_BLOCK_ITERATE 0x010029
288 /* Error while storing inode count information */
289 #define PR_1_ICOUNT_STORE 0x01002A
291 /* Error while storing directory block information */
292 #define PR_1_ADD_DBLOCK 0x01002B
294 /* Error while reading inode (for clearing) */
295 #define PR_1_READ_INODE 0x01002C
297 /* Suppress messages prompt */
298 #define PR_1_SUPPRESS_MESSAGES 0x01002D
300 /* Filesystem contains large files, but has no such flag in sb */
301 #define PR_1_FEATURE_LARGE_FILES 0x01002E
303 /* Imagic flag set on an inode when filesystem doesn't support it */
304 #define PR_1_SET_IMAGIC 0x01002F
306 /* Immutable flag set on a device or socket inode */
307 #define PR_1_SET_IMMUTABLE 0x010030
309 /* Compression flag set on a non-compressed filesystem */
310 #define PR_1_COMPR_SET 0x010031
312 /* Non-zero size on on device, fifo or socket inode */
313 #define PR_1_SET_NONZSIZE 0x010032
315 /* Filesystem revision is 0, but feature flags are set */
316 #define PR_1_FS_REV_LEVEL 0x010033
318 /* Journal inode not in use, needs clearing */
319 #define PR_1_JOURNAL_INODE_NOT_CLEAR 0x010034
321 /* Journal inode has wrong mode */
322 #define PR_1_JOURNAL_BAD_MODE 0x010035
324 /* Inode that was part of orphan linked list */
325 #define PR_1_LOW_DTIME 0x010036
327 /* Latch question which asks how to deal with low dtime inodes */
328 #define PR_1_ORPHAN_LIST_REFUGEES 0x010037
334 /* Pass 1B: Rescan for duplicate/bad blocks */
335 #define PR_1B_PASS_HEADER 0x011000
337 /* Duplicate/bad block(s) header */
338 #define PR_1B_DUP_BLOCK_HEADER 0x011001
340 /* Duplicate/bad block(s) in inode */
341 #define PR_1B_DUP_BLOCK 0x011002
343 /* Duplicate/bad block(s) end */
344 #define PR_1B_DUP_BLOCK_END 0x011003
346 /* Error while scanning inodes */
347 #define PR_1B_ISCAN_ERROR 0x011004
349 /* Error allocating inode bitmap */
350 #define PR_1B_ALLOCATE_IBITMAP_ERROR 0x011005
352 /* Error while iterating over blocks */
353 #define PR_1B_BLOCK_ITERATE 0x0110006
356 /* Pass 1C: Scan directories for inodes with dup blocks. */
357 #define PR_1C_PASS_HEADER 0x012000
360 /* Pass 1D: Reconciling duplicate blocks */
361 #define PR_1D_PASS_HEADER 0x013000
363 /* File has duplicate blocks */
364 #define PR_1D_DUP_FILE 0x013001
366 /* List of files sharing duplicate blocks */
367 #define PR_1D_DUP_FILE_LIST 0x013002
369 /* File sharing blocks with filesystem metadata */
370 #define PR_1D_SHARE_METADATA 0x013003
372 /* Report of how many duplicate/bad inodes */
373 #define PR_1D_NUM_DUP_INODES 0x013004
375 /* Duplicated blocks already reassigned or cloned. */
376 #define PR_1D_DUP_BLOCKS_DEALT 0x013005
378 /* Clone duplicate/bad blocks? */
379 #define PR_1D_CLONE_QUESTION 0x013006
382 #define PR_1D_DELETE_QUESTION 0x013007
384 /* Couldn't clone file (error) */
385 #define PR_1D_CLONE_ERROR 0x013008
391 /* Pass 2: Checking directory structure */
392 #define PR_2_PASS_HEADER 0x020000
394 /* Bad inode number for '.' */
395 #define PR_2_BAD_INODE_DOT 0x020001
397 /* Directory entry has bad inode number */
398 #define PR_2_BAD_INO 0x020002
400 /* Directory entry has deleted or unused inode */
401 #define PR_2_UNUSED_INODE 0x020003
403 /* Directry entry is link to '.' */
404 #define PR_2_LINK_DOT 0x020004
406 /* Directory entry points to inode now located in a bad block */
407 #define PR_2_BB_INODE 0x020005
409 /* Directory entry contains a link to a directory */
410 #define PR_2_LINK_DIR 0x020006
412 /* Directory entry contains a link to the root directry */
413 #define PR_2_LINK_ROOT 0x020007
415 /* Directory entry has illegal characters in its name */
416 #define PR_2_BAD_NAME 0x020008
418 /* Missing '.' in directory inode */
419 #define PR_2_MISSING_DOT 0x020009
421 /* Missing '..' in directory inode */
422 #define PR_2_MISSING_DOT_DOT 0x02000A
424 /* First entry in directory inode doesn't contain '.' */
425 #define PR_2_1ST_NOT_DOT 0x02000B
427 /* Second entry in directory inode doesn't contain '..' */
428 #define PR_2_2ND_NOT_DOT_DOT 0x02000C
430 /* i_faddr should be zero */
431 #define PR_2_FADDR_ZERO 0x02000D
433 /* i_file_acl should be zero */
434 #define PR_2_FILE_ACL_ZERO 0x02000E
436 /* i_dir_acl should be zero */
437 #define PR_2_DIR_ACL_ZERO 0x02000F
439 /* i_frag should be zero */
440 #define PR_2_FRAG_ZERO 0x020010
442 /* i_fsize should be zero */
443 #define PR_2_FSIZE_ZERO 0x020011
445 /* inode has bad mode */
446 #define PR_2_BAD_MODE 0x020012
448 /* directory corrupted */
449 #define PR_2_DIR_CORRUPTED 0x020013
451 /* filename too long */
452 #define PR_2_FILENAME_LONG 0x020014
454 /* Directory inode has a missing block (hole) */
455 #define PR_2_DIRECTORY_HOLE 0x020015
457 /* '.' is not NULL terminated */
458 #define PR_2_DOT_NULL_TERM 0x020016
460 /* '..' is not NULL terminated */
461 #define PR_2_DOT_DOT_NULL_TERM 0x020017
463 /* Illegal character device in inode */
464 #define PR_2_BAD_CHAR_DEV 0x020018
466 /* Illegal block device in inode */
467 #define PR_2_BAD_BLOCK_DEV 0x020019
469 /* Duplicate '.' entry */
470 #define PR_2_DUP_DOT 0x02001A
472 /* Duplicate '..' entry */
473 #define PR_2_DUP_DOT_DOT 0x02001B
475 /* Internal error: couldn't find dir_info */
476 #define PR_2_NO_DIRINFO 0x02001C
478 /* Final rec_len is wrong */
479 #define PR_2_FINAL_RECLEN 0x02001D
481 /* Error allocating icount structure */
482 #define PR_2_ALLOCATE_ICOUNT 0x02001E
484 /* Error iterating over directory blocks */
485 #define PR_2_DBLIST_ITERATE 0x02001F
487 /* Error reading directory block */
488 #define PR_2_READ_DIRBLOCK 0x020020
490 /* Error writing directory block */
491 #define PR_2_WRITE_DIRBLOCK 0x020021
493 /* Error allocating new directory block */
494 #define PR_2_ALLOC_DIRBOCK 0x020022
496 /* Error deallocating inode */
497 #define PR_2_DEALLOC_INODE 0x020023
499 /* Directory entry for '.' is big. Split? */
500 #define PR_2_SPLIT_DOT 0x020024
503 #define PR_2_BAD_FIFO 0x020025
506 #define PR_2_BAD_SOCKET 0x020026
508 /* Directory filetype not set */
509 #define PR_2_SET_FILETYPE 0x020027
511 /* Directory filetype incorrect */
512 #define PR_2_BAD_FILETYPE 0x020028
514 /* Directory filetype set when it shouldn't be */
515 #define PR_2_CLEAR_FILETYPE 0x020029
517 /* Directory filename can't be zero-length */
518 #define PR_2_NULL_NAME 0x020030
524 /* Pass 3: Checking directory connectivity */
525 #define PR_3_PASS_HEADER 0x030000
527 /* Root inode not allocated */
528 #define PR_3_NO_ROOT_INODE 0x030001
530 /* No room in lost+found */
531 #define PR_3_EXPAND_LF_DIR 0x030002
533 /* Unconnected directory inode */
534 #define PR_3_UNCONNECTED_DIR 0x030003
536 /* /lost+found not found */
537 #define PR_3_NO_LF_DIR 0x030004
539 /* .. entry is incorrect */
540 #define PR_3_BAD_DOT_DOT 0x030005
542 /* Bad or non-existent /lost+found. Cannot reconnect */
543 #define PR_3_NO_LPF 0x030006
545 /* Could not expand /lost+found */
546 #define PR_3_CANT_EXPAND_LPF 0x030007
548 /* Could not reconnect inode */
549 #define PR_3_CANT_RECONNECT 0x030008
551 /* Error while trying to find /lost+found */
552 #define PR_3_ERR_FIND_LPF 0x030009
554 /* Error in ext2fs_new_block while creating /lost+found */
555 #define PR_3_ERR_LPF_NEW_BLOCK 0x03000A
557 /* Error in ext2fs_new_inode while creating /lost+found */
558 #define PR_3_ERR_LPF_NEW_INODE 0x03000B
560 /* Error in ext2fs_new_dir_block while creating /lost+found */
561 #define PR_3_ERR_LPF_NEW_DIR_BLOCK 0x03000C
563 /* Error while writing directory block for /lost+found */
564 #define PR_3_ERR_LPF_WRITE_BLOCK 0x03000D
566 /* Error while adjusting inode count */
567 #define PR_3_ADJUST_INODE 0x03000E
569 /* Couldn't fix parent directory -- error */
570 #define PR_3_FIX_PARENT_ERR 0x03000F
572 /* Couldn't fix parent directory -- couldn't find it */
573 #define PR_3_FIX_PARENT_NOFIND 0x030010
575 /* Error allocating inode bitmap */
576 #define PR_3_ALLOCATE_IBITMAP_ERROR 0x030011
578 /* Error creating root directory */
579 #define PR_3_CREATE_ROOT_ERROR 0x030012
581 /* Error creating lost and found directory */
582 #define PR_3_CREATE_LPF_ERROR 0x030013
584 /* Root inode is not directory; aborting */
585 #define PR_3_ROOT_NOT_DIR_ABORT 0x030014
587 /* Cannot proceed without a root inode. */
588 #define PR_3_NO_ROOT_INODE_ABORT 0x030015
590 /* Internal error: couldn't find dir_info */
591 #define PR_3_NO_DIRINFO 0x030016
593 /* Lost+found is not a directory */
594 #define PR_3_LPF_NOTDIR 0x030017
600 /* Pass 4: Checking reference counts */
601 #define PR_4_PASS_HEADER 0x040000
603 /* Unattached zero-length inode */
604 #define PR_4_ZERO_LEN_INODE 0x040001
606 /* Unattached inode */
607 #define PR_4_UNATTACHED_INODE 0x040002
609 /* Inode ref count wrong */
610 #define PR_4_BAD_REF_COUNT 0x040003
612 /* Inconsistent inode count information cached */
613 #define PR_4_INCONSISTENT_COUNT 0x040004
619 /* Pass 5: Checking group summary information */
620 #define PR_5_PASS_HEADER 0x050000
622 /* Padding at end of inode bitmap is not set. */
623 #define PR_5_INODE_BMAP_PADDING 0x050001
625 /* Padding at end of block bitmap is not set. */
626 #define PR_5_BLOCK_BMAP_PADDING 0x050002
628 /* Block bitmap differences header */
629 #define PR_5_BLOCK_BITMAP_HEADER 0x050003
631 /* Block not used, but marked in bitmap */
632 #define PR_5_UNUSED_BLOCK 0x050004
634 /* Block used, but not marked used in bitmap */
635 #define PR_5_BLOCK_USED 0x050005
637 /* Block bitmap differences end */
638 #define PR_5_BLOCK_BITMAP_END 0x050006
640 /* Inode bitmap differences header */
641 #define PR_5_INODE_BITMAP_HEADER 0x050007
643 /* Inode not used, but marked in bitmap */
644 #define PR_5_UNUSED_INODE 0x050008
646 /* Inode used, but not marked used in bitmap */
647 #define PR_5_INODE_USED 0x050009
649 /* Inode bitmap differences end */
650 #define PR_5_INODE_BITMAP_END 0x05000A
652 /* Free inodes count for group wrong */
653 #define PR_5_FREE_INODE_COUNT_GROUP 0x05000B
655 /* Directories count for group wrong */
656 #define PR_5_FREE_DIR_COUNT_GROUP 0x05000C
658 /* Free inodes count wrong */
659 #define PR_5_FREE_INODE_COUNT 0x05000D
661 /* Free blocks count for group wrong */
662 #define PR_5_FREE_BLOCK_COUNT_GROUP 0x05000E
664 /* Free blocks count wrong */
665 #define PR_5_FREE_BLOCK_COUNT 0x05000F
667 /* Programming error: bitmap endpoints don't match */
668 #define PR_5_BMAP_ENDPOINTS 0x050010
670 /* Internal error: fudging end of bitmap */
671 #define PR_5_FUDGE_BITMAP_ERROR 0x050011
673 /* Error copying in replacement inode bitmap */
674 #define PR_5_COPY_IBITMAP_ERROR 0x050012
676 /* Error copying in replacement block bitmap */
677 #define PR_5_COPY_BBITMAP_ERROR 0x050013
680 * Function declarations
682 int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx);
683 int end_problem_latch(e2fsck_t ctx, int mask);
684 int set_latch_flags(int mask, int setflags, int clearflags);
685 int get_latch_flags(int mask, int *value);
686 void clear_problem_context(struct problem_context *ctx);
689 void print_e2fsck_message(e2fsck_t ctx, const char *msg,
690 struct problem_context *pctx, int first);