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 {
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 0x0070 /* 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 */
39 #define PR_LATCH(x) ((((x) & PR_LATCH_MASK) >> 4) - 1)
42 * Latch group descriptor flags
44 #define PRL_YES 0x0001 /* Answer yes */
45 #define PRL_NO 0x0002 /* Answer no */
46 #define PRL_LATCHED 0x0004 /* The latch group is latched */
47 #define PRL_SUPPRESS 0x0008 /* Suppress all latch group questions */
49 #define PRL_VARIABLE 0x000f /* All the flags that need to be reset */
55 /* Block bitmap not in group */
56 #define PR_0_BB_NOT_GROUP 0x000001
58 /* Inode bitmap not in group */
59 #define PR_0_IB_NOT_GROUP 0x000002
61 /* Inode table not in group */
62 #define PR_0_ITABLE_NOT_GROUP 0x000003
64 /* Superblock corrupt */
65 #define PR_0_SB_CORRUPT 0x000004
67 /* Filesystem size is wrong */
68 #define PR_0_FS_SIZE_WRONG 0x000005
70 /* Fragments not supported */
71 #define PR_0_NO_FRAGMENTS 0x000006
73 /* Bad blocks_per_group */
74 #define PR_0_BLOCKS_PER_GROUP 0x000007
76 /* Bad first_data_block */
77 #define PR_0_FIRST_DATA_BLOCK 0x000008
79 /* Adding UUID to filesystem */
80 #define PR_0_ADD_UUID 0x000009
83 #define PR_0_RELOCATE_HINT 0x00000A
85 /* Miscellaneous superblock corruption */
86 #define PR_0_MISC_CORRUPT_SUPER 0x00000B
88 /* Error determing physical device size of filesystem */
89 #define PR_0_GETSIZE_ERROR 0x00000C
91 /* Inode count in the superblock incorrect */
92 #define PR_0_INODE_COUNT_WRONG 0x00000D
94 /* The Hurd does not support the filetype feature */
95 #define PR_0_HURD_CLEAR_FILETYPE 0x00000E
101 /* Pass 1: Checking inodes, blocks, and sizes */
102 #define PR_1_PASS_HEADER 0x010000
104 /* Root directory is not an inode */
105 #define PR_1_ROOT_NO_DIR 0x010001
107 /* Root directory has dtime set */
108 #define PR_1_ROOT_DTIME 0x010002
110 /* Reserved inode has bad mode */
111 #define PR_1_RESERVED_BAD_MODE 0x010003
113 /* Deleted inode has zero dtime */
114 #define PR_1_ZERO_DTIME 0x010004
116 /* Inode in use, but dtime set */
117 #define PR_1_SET_DTIME 0x010005
119 /* Zero-length directory */
120 #define PR_1_ZERO_LENGTH_DIR 0x010006
122 /* Block bitmap conflicts with some other fs block */
123 #define PR_1_BB_CONFLICT 0x010007
125 /* Inode bitmap conflicts with some other fs block */
126 #define PR_1_IB_CONFLICT 0x010008
128 /* Inode table conflicts with some other fs block */
129 #define PR_1_ITABLE_CONFLICT 0x010009
131 /* Block bitmap is on a bad block */
132 #define PR_1_BB_BAD_BLOCK 0x01000A
134 /* Inode bitmap is on a bad block */
135 #define PR_1_IB_BAD_BLOCK 0x01000B
137 /* Inode has incorrect i_size */
138 #define PR_1_BAD_I_SIZE 0x01000C
140 /* Inode has incorrect i_blocks */
141 #define PR_1_BAD_I_BLOCKS 0x01000D
143 /* Illegal block number in inode */
144 #define PR_1_ILLEGAL_BLOCK_NUM 0x01000E
146 /* Block number overlaps fs metadata */
147 #define PR_1_BLOCK_OVERLAPS_METADATA 0x01000F
149 /* Inode has illegal blocks (latch question) */
150 #define PR_1_INODE_BLOCK_LATCH 0x010010
152 /* Too many bad blocks in inode */
153 #define PR_1_TOO_MANY_BAD_BLOCKS 0x010011
155 /* Illegal block number in bad block inode */
156 #define PR_1_BB_ILLEGAL_BLOCK_NUM 0x010012
158 /* Bad block inode has illegal blocks (latch question) */
159 #define PR_1_INODE_BBLOCK_LATCH 0x010013
161 /* Duplicate or bad blocks in use! */
162 #define PR_1_DUP_BLOCKS_PREENSTOP 0x010014
164 /* Bad block used as bad block indirect block */
165 #define PR_1_BBINODE_BAD_METABLOCK 0x010015
167 /* Inconsistency can't be fixed prompt */
168 #define PR_1_BBINODE_BAD_METABLOCK_PROMPT 0x010016
170 /* Bad primary block */
171 #define PR_1_BAD_PRIMARY_BLOCK 0x0100017
173 /* Bad primary block prompt */
174 #define PR_1_BAD_PRIMARY_BLOCK_PROMPT 0x0100018
176 /* Bad primary superblock */
177 #define PR_1_BAD_PRIMARY_SUPERBLOCK 0x0100019
179 /* Bad primary block group descriptors */
180 #define PR_1_BAD_PRIMARY_GROUP_DESCRIPTOR 0x010001A
182 /* Bad superblock in group */
183 #define PR_1_BAD_SUPERBLOCK 0x010001B
185 /* Bad block group descriptors in group */
186 #define PR_1_BAD_GROUP_DESCRIPTORS 0x010001C
188 /* Block claimed for no reason */
189 #define PR_1_PROGERR_CLAIMED_BLOCK 0x010001D
191 /* Error allocating blocks for relocating metadata */
192 #define PR_1_RELOC_BLOCK_ALLOCATE 0x010001E
194 /* Error allocating block buffer during relocation process */
195 #define PR_1_RELOC_MEMORY_ALLOCATE 0x010001F
197 /* Relocating metadata group information from X to Y */
198 #define PR_1_RELOC_FROM_TO 0x0100020
200 /* Relocating metatdata group information to X */
201 #define PR_1_RELOC_TO 0x0100021
203 /* Block read error during relocation process */
204 #define PR_1_RELOC_READ_ERR 0x0100022
206 /* Block write error during relocation process */
207 #define PR_1_RELOC_WRITE_ERR 0x0100023
209 /* Error allocating inode bitmap */
210 #define PR_1_ALLOCATE_IBITMAP_ERROR 0x0100024
212 /* Error allocating block bitmap */
213 #define PR_1_ALLOCATE_BBITMAP_ERROR 0x0100025
215 /* Error allocating icount structure */
216 #define PR_1_ALLOCATE_ICOUNT 0x0100026
218 /* Error allocating dbcount */
219 #define PR_1_ALLOCATE_DBCOUNT 0x0100027
221 /* Error while scanning inodes */
222 #define PR_1_ISCAN_ERROR 0x0100028
224 /* Error while iterating over blocks */
225 #define PR_1_BLOCK_ITERATE 0x0100029
227 /* Error while storing inode count information */
228 #define PR_1_ICOUNT_STORE 0x010002A
230 /* Error while storing directory block information */
231 #define PR_1_ADD_DBLOCK 0x010002B
233 /* Error while reading inode (for clearing) */
234 #define PR_1_READ_INODE 0x010002C
236 /* Suppress messages prompt */
237 #define PR_1_SUPPRESS_MESSAGES 0x010002D
239 /* Filesystem contains large files, but has no such flag in sb */
240 #define PR_1_FEATURE_LARGE_FILES 0x01002E
242 /* Imagic flag set on an inode when filesystem doesn't support it */
243 #define PR_1_SET_IMAGIC 0x01002F
245 /* Immutable flag set on a device or socket inode */
246 #define PR_1_SET_IMMUTABLE 0x010030
248 /* Compression flag set on a non-compressed filesystem */
249 #define PR_1_COMPR_SET 0x010031
251 /* Non-zero size on on device, fifo or socket inode */
252 #define PR_1_SET_NONZSIZE 0x010032
258 /* Pass 1B: Rescan for duplicate/bad blocks */
259 #define PR_1B_PASS_HEADER 0x011000
261 /* Duplicate/bad block(s) header */
262 #define PR_1B_DUP_BLOCK_HEADER 0x011001
264 /* Duplicate/bad block(s) in inode */
265 #define PR_1B_DUP_BLOCK 0x011002
267 /* Duplicate/bad block(s) end */
268 #define PR_1B_DUP_BLOCK_END 0x011003
270 /* Error while scanning inodes */
271 #define PR_1B_ISCAN_ERROR 0x011004
273 /* Error allocating inode bitmap */
274 #define PR_1B_ALLOCATE_IBITMAP_ERROR 0x011005
277 /* Pass 1C: Scan directories for inodes with dup blocks. */
278 #define PR_1C_PASS_HEADER 0x012000
281 /* Pass 1D: Reconciling duplicate blocks */
282 #define PR_1D_PASS_HEADER 0x013000
284 /* File has duplicate blocks */
285 #define PR_1D_DUP_FILE 0x013001
287 /* List of files sharing duplicate blocks */
288 #define PR_1D_DUP_FILE_LIST 0x013002
290 /* File sharing blocks with filesystem metadata */
291 #define PR_1D_SHARE_METADATA 0x013003
293 /* Report of how many duplicate/bad inodes */
294 #define PR_1D_NUM_DUP_INODES 0x013004
296 /* Duplicated blocks already reassigned or cloned. */
297 #define PR_1D_DUP_BLOCKS_DEALT 0x013005
299 /* Clone duplicate/bad blocks? */
300 #define PR_1D_CLONE_QUESTION 0x013006
303 #define PR_1D_DELETE_QUESTION 0x013007
305 /* Couldn't clone file (error) */
306 #define PR_1D_CLONE_ERROR 0x013008
312 /* Pass 2: Checking directory structure */
313 #define PR_2_PASS_HEADER 0x020000
315 /* Bad inode number for '.' */
316 #define PR_2_BAD_INODE_DOT 0x020001
318 /* Directory entry has bad inode number */
319 #define PR_2_BAD_INO 0x020002
321 /* Directory entry has deleted or unused inode */
322 #define PR_2_UNUSED_INODE 0x020003
324 /* Directry entry is link to '.' */
325 #define PR_2_LINK_DOT 0x020004
327 /* Directory entry points to inode now located in a bad block */
328 #define PR_2_BB_INODE 0x020005
330 /* Directory entry contains a link to a directory */
331 #define PR_2_LINK_DIR 0x020006
333 /* Directory entry contains a link to the root directry */
334 #define PR_2_LINK_ROOT 0x020007
336 /* Directory entry has illegal characters in its name */
337 #define PR_2_BAD_NAME 0x020008
339 /* Missing '.' in directory inode */
340 #define PR_2_MISSING_DOT 0x020009
342 /* Missing '..' in directory inode */
343 #define PR_2_MISSING_DOT_DOT 0x02000A
345 /* First entry in directory inode doesn't contain '.' */
346 #define PR_2_1ST_NOT_DOT 0x02000B
348 /* Second entry in directory inode doesn't contain '..' */
349 #define PR_2_2ND_NOT_DOT_DOT 0x02000C
351 /* i_faddr should be zero */
352 #define PR_2_FADDR_ZERO 0x02000D
354 /* i_file_acl should be zero */
355 #define PR_2_FILE_ACL_ZERO 0x02000E
357 /* i_dir_acl should be zero */
358 #define PR_2_DIR_ACL_ZERO 0x02000F
360 /* i_frag should be zero */
361 #define PR_2_FRAG_ZERO 0x020010
363 /* i_fsize should be zero */
364 #define PR_2_FSIZE_ZERO 0x020011
366 /* inode has bad mode */
367 #define PR_2_BAD_MODE 0x020012
369 /* directory corrupted */
370 #define PR_2_DIR_CORRUPTED 0x020013
372 /* filename too long */
373 #define PR_2_FILENAME_LONG 0x020014
375 /* Directory inode has a missing block (hole) */
376 #define PR_2_DIRECTORY_HOLE 0x020015
378 /* '.' is not NULL terminated */
379 #define PR_2_DOT_NULL_TERM 0x020016
381 /* '..' is not NULL terminated */
382 #define PR_2_DOT_DOT_NULL_TERM 0x020017
384 /* Illegal character device in inode */
385 #define PR_2_BAD_CHAR_DEV 0x020018
387 /* Illegal block device in inode */
388 #define PR_2_BAD_BLOCK_DEV 0x020019
390 /* Duplicate '.' entry */
391 #define PR_2_DUP_DOT 0x02001A
393 /* Duplicate '..' entry */
394 #define PR_2_DUP_DOT_DOT 0x02001B
396 /* Internal error: couldn't find dir_info */
397 #define PR_2_NO_DIRINFO 0x02001C
399 /* Final rec_len is wrong */
400 #define PR_2_FINAL_RECLEN 0x02001D
402 /* Error allocating icount structure */
403 #define PR_2_ALLOCATE_ICOUNT 0x02001E
405 /* Error iterating over directory blocks */
406 #define PR_2_DBLIST_ITERATE 0x02001F
408 /* Error reading directory block */
409 #define PR_2_READ_DIRBLOCK 0x020020
411 /* Error writing directory block */
412 #define PR_2_WRITE_DIRBLOCK 0x020021
414 /* Error allocating new directory block */
415 #define PR_2_ALLOC_DIRBOCK 0x020022
417 /* Error deallocating inode */
418 #define PR_2_DEALLOC_INODE 0x020023
420 /* Directory entry for '.' is big. Split? */
421 #define PR_2_SPLIT_DOT 0x020024
424 #define PR_2_BAD_FIFO 0x020025
427 #define PR_2_BAD_SOCKET 0x020026
429 /* Directory filetype not set */
430 #define PR_2_SET_FILETYPE 0x020027
432 /* Directory filetype incorrect */
433 #define PR_2_BAD_FILETYPE 0x020028
435 /* Directory filetype set when it shouldn't be */
436 #define PR_2_CLEAR_FILETYPE 0x020029
438 /* Directory filename can't be zero-length */
439 #define PR_2_NULL_NAME 0x020030
445 /* Pass 3: Checking directory connectivity */
446 #define PR_3_PASS_HEADER 0x030000
448 /* Root inode not allocated */
449 #define PR_3_NO_ROOT_INODE 0x030001
451 /* No room in lost+found */
452 #define PR_3_EXPAND_LF_DIR 0x030002
454 /* Unconnected directory inode */
455 #define PR_3_UNCONNECTED_DIR 0x030003
457 /* /lost+found not found */
458 #define PR_3_NO_LF_DIR 0x030004
460 /* .. entry is incorrect */
461 #define PR_3_BAD_DOT_DOT 0x030005
463 /* Bad or non-existent /lost+found. Cannot reconnect */
464 #define PR_3_NO_LPF 0x030006
466 /* Could not expand /lost+found */
467 #define PR_3_CANT_EXPAND_LPF 0x030007
469 /* Could not reconnect inode */
470 #define PR_3_CANT_RECONNECT 0x030008
472 /* Error while trying to find /lost+found */
473 #define PR_3_ERR_FIND_LPF 0x030009
475 /* Error in ext2fs_new_block while creating /lost+found */
476 #define PR_3_ERR_LPF_NEW_BLOCK 0x03000A
478 /* Error in ext2fs_new_inode while creating /lost+found */
479 #define PR_3_ERR_LPF_NEW_INODE 0x03000B
481 /* Error in ext2fs_new_dir_block while creating /lost+found */
482 #define PR_3_ERR_LPF_NEW_DIR_BLOCK 0x03000C
484 /* Error while writing directory block for /lost+found */
485 #define PR_3_ERR_LPF_WRITE_BLOCK 0x03000D
487 /* Error while adjusting inode count */
488 #define PR_3_ADJUST_INODE 0x03000E
490 /* Couldn't fix parent directory -- error */
491 #define PR_3_FIX_PARENT_ERR 0x03000F
493 /* Couldn't fix parent directory -- couldn't find it */
494 #define PR_3_FIX_PARENT_NOFIND 0x030010
496 /* Error allocating inode bitmap */
497 #define PR_3_ALLOCATE_IBITMAP_ERROR 0x030011
499 /* Error creating root directory */
500 #define PR_3_CREATE_ROOT_ERROR 0x030012
502 /* Error creating lost and found directory */
503 #define PR_3_CREATE_LPF_ERROR 0x030013
505 /* Root inode is not directory; aborting */
506 #define PR_3_ROOT_NOT_DIR_ABORT 0x030014
508 /* Cannot proceed without a root inode. */
509 #define PR_3_NO_ROOT_INODE_ABORT 0x030015
511 /* Internal error: couldn't find dir_info */
512 #define PR_3_NO_DIRINFO 0x030016
514 /* Lost+found is not a directory */
515 #define PR_3_LPF_NOTDIR 0x030017
521 /* Pass 4: Checking reference counts */
522 #define PR_4_PASS_HEADER 0x040000
524 /* Unattached zero-length inode */
525 #define PR_4_ZERO_LEN_INODE 0x040001
527 /* Unattached inode */
528 #define PR_4_UNATTACHED_INODE 0x040002
530 /* Inode ref count wrong */
531 #define PR_4_BAD_REF_COUNT 0x040003
533 /* Inconsistent inode count information cached */
534 #define PR_4_INCONSISTENT_COUNT 0x040004
540 /* Pass 5: Checking group summary information */
541 #define PR_5_PASS_HEADER 0x050000
543 /* Padding at end of inode bitmap is not set. */
544 #define PR_5_INODE_BMAP_PADDING 0x050001
546 /* Padding at end of block bitmap is not set. */
547 #define PR_5_BLOCK_BMAP_PADDING 0x050002
549 /* Block bitmap differences header */
550 #define PR_5_BLOCK_BITMAP_HEADER 0x050003
552 /* Block not used, but marked in bitmap */
553 #define PR_5_UNUSED_BLOCK 0x050004
555 /* Block used, but not marked used in bitmap */
556 #define PR_5_BLOCK_USED 0x050005
558 /* Block bitmap differences end */
559 #define PR_5_BLOCK_BITMAP_END 0x050006
561 /* Inode bitmap differences header */
562 #define PR_5_INODE_BITMAP_HEADER 0x050007
564 /* Inode not used, but marked in bitmap */
565 #define PR_5_UNUSED_INODE 0x050008
567 /* Inode used, but not marked used in bitmap */
568 #define PR_5_INODE_USED 0x050009
570 /* Inode bitmap differences end */
571 #define PR_5_INODE_BITMAP_END 0x05000A
573 /* Free inodes count for group wrong */
574 #define PR_5_FREE_INODE_COUNT_GROUP 0x05000B
576 /* Directories count for group wrong */
577 #define PR_5_FREE_DIR_COUNT_GROUP 0x05000C
579 /* Free inodes count wrong */
580 #define PR_5_FREE_INODE_COUNT 0x05000D
582 /* Free blocks count for group wrong */
583 #define PR_5_FREE_BLOCK_COUNT_GROUP 0x05000E
585 /* Free blocks count wrong */
586 #define PR_5_FREE_BLOCK_COUNT 0x05000F
588 /* Programming error: bitmap endpoints don't match */
589 #define PR_5_BMAP_ENDPOINTS 0x050010
591 /* Internal error: fudging end of bitmap */
592 #define PR_5_FUDGE_BITMAP_ERROR 0x050011
594 /* Error copying in replacement inode bitmap */
595 #define PR_5_COPY_IBITMAP_ERROR 0x050012
597 /* Error copying in replacement block bitmap */
598 #define PR_5_COPY_BBITMAP_ERROR 0x050013
601 * Function declarations
603 int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx);
604 int end_problem_latch(e2fsck_t ctx, int mask);
605 int set_latch_flags(int mask, int setflags, int clearflags);
606 int get_latch_flags(int mask, int *value);
607 void clear_problem_context(struct problem_context *ctx);
610 void print_e2fsck_message(e2fsck_t ctx, const char *msg,
611 struct problem_context *pctx, int first);