+/* vi: set sw=4 ts=4: */
/*
* e2fsck
*
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
- * This file may be
- * redistributed under the terms of the GNU Public License.
- *
+ * Copyright (C) 2006 Garrett Kajmowicz
*
* Dictionary Abstract Data Type
* Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>
*
* Copyright 1999-2000 Red Hat Software --- All Rights Reserved
*
- * This file is part of the Linux kernel and is made available under
- * the terms of the GNU General Public License, version 2, or at your
- * option, any later version, incorporated herein by reference.
- *
* Journal recovery routines for the generic filesystem journaling code;
* part of the ext2fs journaling system.
+ *
+ * Licensed under GPLv2 or later, see file License in this tarball for details.
*/
#ifndef _GNU_SOURCE
#include "e2fsck.h" /*Put all of our defines here to clean things up*/
-#ifdef __GNUC__
-#define _INLINE_ __inline__
-#define EXT2FS_ATTR(x) __attribute__(x)
-#else
-#define _INLINE_
-#define EXT2FS_ATTR(x)
-#endif
+#define _(x) x
+#define N_(x) x
/*
* Procedure declarations
const char *str;
};
-/*
- * We define a set of "latch groups"; these are problems which are
- * handled as a set. The user answers once for a particular latch
- * group.
- */
-#define PR_LATCH_MASK 0x0ff0 /* Latch mask */
-#define PR_LATCH_BLOCK 0x0010 /* Latch for illegal blocks (pass 1) */
-#define PR_LATCH_BBLOCK 0x0020 /* Latch for bad block inode blocks (pass 1) */
-#define PR_LATCH_IBITMAP 0x0030 /* Latch for pass 5 inode bitmap proc. */
-#define PR_LATCH_BBITMAP 0x0040 /* Latch for pass 5 inode bitmap proc. */
-#define PR_LATCH_RELOC 0x0050 /* Latch for superblock relocate hint */
-#define PR_LATCH_DBLOCK 0x0060 /* Latch for pass 1b dup block headers */
-#define PR_LATCH_LOW_DTIME 0x0070 /* Latch for pass1 orphaned list refugees */
-#define PR_LATCH_TOOBIG 0x0080 /* Latch for file to big errors */
-#define PR_LATCH_OPTIMIZE_DIR 0x0090 /* Latch for optimize directories */
-
-#define PR_LATCH(x) ((((x) & PR_LATCH_MASK) >> 4) - 1)
-
-/*
- * Latch group descriptor flags
- */
-#define PRL_YES 0x0001 /* Answer yes */
-#define PRL_NO 0x0002 /* Answer no */
-#define PRL_LATCHED 0x0004 /* The latch group is latched */
-#define PRL_SUPPRESS 0x0008 /* Suppress all latch group questions */
-
-#define PRL_VARIABLE 0x000f /* All the flags that need to be reset */
-
-/*
- * Pre-Pass 1 errors
- */
-
-/* Block bitmap not in group */
-#define PR_0_BB_NOT_GROUP 0x000001
-
-/* Inode bitmap not in group */
-#define PR_0_IB_NOT_GROUP 0x000002
-
-/* Inode table not in group */
-#define PR_0_ITABLE_NOT_GROUP 0x000003
-
-/* Superblock corrupt */
-#define PR_0_SB_CORRUPT 0x000004
-
-/* Filesystem size is wrong */
-#define PR_0_FS_SIZE_WRONG 0x000005
-
-/* Fragments not supported */
-#define PR_0_NO_FRAGMENTS 0x000006
-
-/* Bad blocks_per_group */
-#define PR_0_BLOCKS_PER_GROUP 0x000007
-
-/* Bad first_data_block */
-#define PR_0_FIRST_DATA_BLOCK 0x000008
-
-/* Adding UUID to filesystem */
-#define PR_0_ADD_UUID 0x000009
-
-/* Relocate hint */
-#define PR_0_RELOCATE_HINT 0x00000A
-
-/* Miscellaneous superblock corruption */
-#define PR_0_MISC_CORRUPT_SUPER 0x00000B
-
-/* Error determing physical device size of filesystem */
-#define PR_0_GETSIZE_ERROR 0x00000C
-
-/* Inode count in the superblock incorrect */
-#define PR_0_INODE_COUNT_WRONG 0x00000D
-
-/* The Hurd does not support the filetype feature */
-#define PR_0_HURD_CLEAR_FILETYPE 0x00000E
-
-/* Journal inode is invalid */
-#define PR_0_JOURNAL_BAD_INODE 0x00000F
-
-/* The external journal has multiple filesystems (which we can't handle yet) */
-#define PR_0_JOURNAL_UNSUPP_MULTIFS 0x000010
-
-/* Can't find external journal */
-#define PR_0_CANT_FIND_JOURNAL 0x000011
-
-/* External journal has bad superblock */
-#define PR_0_EXT_JOURNAL_BAD_SUPER 0x000012
-
-/* Superblock has a bad journal UUID */
-#define PR_0_JOURNAL_BAD_UUID 0x000013
-
-/* Journal has an unknown superblock type */
-#define PR_0_JOURNAL_UNSUPP_SUPER 0x000014
-
-/* Journal superblock is corrupt */
-#define PR_0_JOURNAL_BAD_SUPER 0x000015
-
-/* Journal superblock is corrupt */
-#define PR_0_JOURNAL_HAS_JOURNAL 0x000016
-
-/* Superblock has recovery flag set but no journal */
-#define PR_0_JOURNAL_RECOVER_SET 0x000017
-
-/* Journal has data, but recovery flag is clear */
-#define PR_0_JOURNAL_RECOVERY_CLEAR 0x000018
-
-/* Ask if we should clear the journal */
-#define PR_0_JOURNAL_RESET_JOURNAL 0x000019
-
-/* Filesystem revision is 0, but feature flags are set */
-#define PR_0_FS_REV_LEVEL 0x00001A
-
-/* Clearing orphan inode */
-#define PR_0_ORPHAN_CLEAR_INODE 0x000020
-
-/* Illegal block found in orphaned inode */
-#define PR_0_ORPHAN_ILLEGAL_BLOCK_NUM 0x000021
-
-/* Already cleared block found in orphaned inode */
-#define PR_0_ORPHAN_ALREADY_CLEARED_BLOCK 0x000022
-
-/* Illegal orphan inode in superblock */
-#define PR_0_ORPHAN_ILLEGAL_HEAD_INODE 0x000023
-
-/* Illegal inode in orphaned inode list */
-#define PR_0_ORPHAN_ILLEGAL_INODE 0x000024
-
-/* Journal has unsupported read-only feature - abort */
-#define PR_0_JOURNAL_UNSUPP_ROCOMPAT 0x000025
-
-/* Journal has unsupported incompatible feature - abort */
-#define PR_0_JOURNAL_UNSUPP_INCOMPAT 0x000026
-
-/* Journal has unsupported version number */
-#define PR_0_JOURNAL_UNSUPP_VERSION 0x000027
-
-/* Moving journal to hidden file */
-#define PR_0_MOVE_JOURNAL 0x000028
-
-/* Error moving journal */
-#define PR_0_ERR_MOVE_JOURNAL 0x000029
-
-/* Clearing V2 journal superblock */
-#define PR_0_CLEAR_V2_JOURNAL 0x00002A
-
-/* Run journal anyway */
-#define PR_0_JOURNAL_RUN 0x00002B
-
-/* Run journal anyway by default */
-#define PR_0_JOURNAL_RUN_DEFAULT 0x00002C
-
-/* Backup journal inode blocks */
-#define PR_0_BACKUP_JNL 0x00002D
-
-/* Reserved blocks w/o resize_inode */
-#define PR_0_NONZERO_RESERVED_GDT_BLOCKS 0x00002E
-
-/* Resize_inode not enabled, but resize inode is non-zero */
-#define PR_0_CLEAR_RESIZE_INODE 0x00002F
-
-/* Resize inode invalid */
-#define PR_0_RESIZE_INODE_INVALID 0x000030
-
-/*
- * Pass 1 errors
- */
-
-/* Pass 1: Checking inodes, blocks, and sizes */
-#define PR_1_PASS_HEADER 0x010000
-
-/* Root directory is not an inode */
-#define PR_1_ROOT_NO_DIR 0x010001
-
-/* Root directory has dtime set */
-#define PR_1_ROOT_DTIME 0x010002
-
-/* Reserved inode has bad mode */
-#define PR_1_RESERVED_BAD_MODE 0x010003
-
-/* Deleted inode has zero dtime */
-#define PR_1_ZERO_DTIME 0x010004
-
-/* Inode in use, but dtime set */
-#define PR_1_SET_DTIME 0x010005
-
-/* Zero-length directory */
-#define PR_1_ZERO_LENGTH_DIR 0x010006
-
-/* Block bitmap conflicts with some other fs block */
-#define PR_1_BB_CONFLICT 0x010007
-
-/* Inode bitmap conflicts with some other fs block */
-#define PR_1_IB_CONFLICT 0x010008
-
-/* Inode table conflicts with some other fs block */
-#define PR_1_ITABLE_CONFLICT 0x010009
-
-/* Block bitmap is on a bad block */
-#define PR_1_BB_BAD_BLOCK 0x01000A
-
-/* Inode bitmap is on a bad block */
-#define PR_1_IB_BAD_BLOCK 0x01000B
-
-/* Inode has incorrect i_size */
-#define PR_1_BAD_I_SIZE 0x01000C
-
-/* Inode has incorrect i_blocks */
-#define PR_1_BAD_I_BLOCKS 0x01000D
-
-/* Illegal block number in inode */
-#define PR_1_ILLEGAL_BLOCK_NUM 0x01000E
-
-/* Block number overlaps fs metadata */
-#define PR_1_BLOCK_OVERLAPS_METADATA 0x01000F
-
-/* Inode has illegal blocks (latch question) */
-#define PR_1_INODE_BLOCK_LATCH 0x010010
-
-/* Too many bad blocks in inode */
-#define PR_1_TOO_MANY_BAD_BLOCKS 0x010011
-
-/* Illegal block number in bad block inode */
-#define PR_1_BB_ILLEGAL_BLOCK_NUM 0x010012
-
-/* Bad block inode has illegal blocks (latch question) */
-#define PR_1_INODE_BBLOCK_LATCH 0x010013
-
-/* Duplicate or bad blocks in use! */
-#define PR_1_DUP_BLOCKS_PREENSTOP 0x010014
-
-/* Bad block used as bad block indirect block */
-#define PR_1_BBINODE_BAD_METABLOCK 0x010015
-
-/* Inconsistency can't be fixed prompt */
-#define PR_1_BBINODE_BAD_METABLOCK_PROMPT 0x010016
-
-/* Bad primary block */
-#define PR_1_BAD_PRIMARY_BLOCK 0x010017
-
-/* Bad primary block prompt */
-#define PR_1_BAD_PRIMARY_BLOCK_PROMPT 0x010018
-
-/* Bad primary superblock */
-#define PR_1_BAD_PRIMARY_SUPERBLOCK 0x010019
-
-/* Bad primary block group descriptors */
-#define PR_1_BAD_PRIMARY_GROUP_DESCRIPTOR 0x01001A
-
-/* Bad superblock in group */
-#define PR_1_BAD_SUPERBLOCK 0x01001B
-
-/* Bad block group descriptors in group */
-#define PR_1_BAD_GROUP_DESCRIPTORS 0x01001C
-
-/* Block claimed for no reason */
-#define PR_1_PROGERR_CLAIMED_BLOCK 0x01001D
-
-/* Error allocating blocks for relocating metadata */
-#define PR_1_RELOC_BLOCK_ALLOCATE 0x01001E
-
-/* Error allocating block buffer during relocation process */
-#define PR_1_RELOC_MEMORY_ALLOCATE 0x01001F
-
-/* Relocating metadata group information from X to Y */
-#define PR_1_RELOC_FROM_TO 0x010020
-
-/* Relocating metatdata group information to X */
-#define PR_1_RELOC_TO 0x010021
-
-/* Block read error during relocation process */
-#define PR_1_RELOC_READ_ERR 0x010022
-
-/* Block write error during relocation process */
-#define PR_1_RELOC_WRITE_ERR 0x010023
-
-/* Error allocating inode bitmap */
-#define PR_1_ALLOCATE_IBITMAP_ERROR 0x010024
-
-/* Error allocating block bitmap */
-#define PR_1_ALLOCATE_BBITMAP_ERROR 0x010025
-
-/* Error allocating icount structure */
-#define PR_1_ALLOCATE_ICOUNT 0x010026
-
-/* Error allocating dbcount */
-#define PR_1_ALLOCATE_DBCOUNT 0x010027
-
-/* Error while scanning inodes */
-#define PR_1_ISCAN_ERROR 0x010028
-
-/* Error while iterating over blocks */
-#define PR_1_BLOCK_ITERATE 0x010029
-
-/* Error while storing inode count information */
-#define PR_1_ICOUNT_STORE 0x01002A
-
-/* Error while storing directory block information */
-#define PR_1_ADD_DBLOCK 0x01002B
-
-/* Error while reading inode (for clearing) */
-#define PR_1_READ_INODE 0x01002C
-
-/* Suppress messages prompt */
-#define PR_1_SUPPRESS_MESSAGES 0x01002D
-
-/* Imagic flag set on an inode when filesystem doesn't support it */
-#define PR_1_SET_IMAGIC 0x01002F
-
-/* Immutable flag set on a device or socket inode */
-#define PR_1_SET_IMMUTABLE 0x010030
-
-/* Compression flag set on a non-compressed filesystem */
-#define PR_1_COMPR_SET 0x010031
-
-/* Non-zero size on on device, fifo or socket inode */
-#define PR_1_SET_NONZSIZE 0x010032
-
-/* Filesystem revision is 0, but feature flags are set */
-#define PR_1_FS_REV_LEVEL 0x010033
-
-/* Journal inode not in use, needs clearing */
-#define PR_1_JOURNAL_INODE_NOT_CLEAR 0x010034
-
-/* Journal inode has wrong mode */
-#define PR_1_JOURNAL_BAD_MODE 0x010035
-
-/* Inode that was part of orphan linked list */
-#define PR_1_LOW_DTIME 0x010036
-
-/* Latch question which asks how to deal with low dtime inodes */
-#define PR_1_ORPHAN_LIST_REFUGEES 0x010037
-
-/* Error allocating refcount structure */
-#define PR_1_ALLOCATE_REFCOUNT 0x010038
-
-/* Error reading Extended Attribute block */
-#define PR_1_READ_EA_BLOCK 0x010039
-
-/* Invalid Extended Attribute block */
-#define PR_1_BAD_EA_BLOCK 0x01003A
-
-/* Error reading Extended Attribute block while fixing refcount -- abort */
-#define PR_1_EXTATTR_READ_ABORT 0x01003B
-
-/* Extended attribute reference count incorrect */
-#define PR_1_EXTATTR_REFCOUNT 0x01003C
-
-/* Error writing Extended Attribute block while fixing refcount */
-#define PR_1_EXTATTR_WRITE 0x01003D
-
-/* Multiple EA blocks not supported */
-#define PR_1_EA_MULTI_BLOCK 0x01003E
-
-/* Error allocating EA region allocation structure */
-#define PR_1_EA_ALLOC_REGION 0x01003F
-
-/* Error EA allocation collision */
-#define PR_1_EA_ALLOC_COLLISION 0x010040
-
-/* Bad extended attribute name */
-#define PR_1_EA_BAD_NAME 0x010041
-
-/* Bad extended attribute value */
-#define PR_1_EA_BAD_VALUE 0x010042
-
-/* Inode too big (latch question) */
-#define PR_1_INODE_TOOBIG 0x010043
-
-/* Directory too big */
-#define PR_1_TOOBIG_DIR 0x010044
-
-/* Regular file too big */
-#define PR_1_TOOBIG_REG 0x010045
-
-/* Symlink too big */
-#define PR_1_TOOBIG_SYMLINK 0x010046
-
-/* INDEX_FL flag set on a non-HTREE filesystem */
-#define PR_1_HTREE_SET 0x010047
-
-/* INDEX_FL flag set on a non-directory */
-#define PR_1_HTREE_NODIR 0x010048
-
-/* Invalid root node in HTREE directory */
-#define PR_1_HTREE_BADROOT 0x010049
-
-/* Unsupported hash version in HTREE directory */
-#define PR_1_HTREE_HASHV 0x01004A
-
-/* Incompatible flag in HTREE root node */
-#define PR_1_HTREE_INCOMPAT 0x01004B
-
-/* HTREE too deep */
-#define PR_1_HTREE_DEPTH 0x01004C
-
-/* Bad block has indirect block that conflicts with filesystem block */
-#define PR_1_BB_FS_BLOCK 0x01004D
-
-/* Resize inode failed */
-#define PR_1_RESIZE_INODE_CREATE 0x01004E
-
-/* inode->i_size is too long */
-#define PR_1_EXTRA_ISIZE 0x01004F
-
-/* attribute name is too long */
-#define PR_1_ATTR_NAME_LEN 0x010050
-
-/* wrong EA value offset */
-#define PR_1_ATTR_VALUE_OFFSET 0x010051
-
-/* wrong EA blocknumber */
-#define PR_1_ATTR_VALUE_BLOCK 0x010052
-
-/* wrong EA value size */
-#define PR_1_ATTR_VALUE_SIZE 0x010053
-
-/* wrong EA hash value */
-#define PR_1_ATTR_HASH 0x010054
-
-/*
- * Pass 1b errors
- */
-
-/* Pass 1B: Rescan for duplicate/bad blocks */
-#define PR_1B_PASS_HEADER 0x011000
-
-/* Duplicate/bad block(s) header */
-#define PR_1B_DUP_BLOCK_HEADER 0x011001
-
-/* Duplicate/bad block(s) in inode */
-#define PR_1B_DUP_BLOCK 0x011002
-
-/* Duplicate/bad block(s) end */
-#define PR_1B_DUP_BLOCK_END 0x011003
-
-/* Error while scanning inodes */
-#define PR_1B_ISCAN_ERROR 0x011004
-
-/* Error allocating inode bitmap */
-#define PR_1B_ALLOCATE_IBITMAP_ERROR 0x011005
-
-/* Error while iterating over blocks */
-#define PR_1B_BLOCK_ITERATE 0x0110006
-
-/* Error adjusting EA refcount */
-#define PR_1B_ADJ_EA_REFCOUNT 0x0110007
-
-
-/* Pass 1C: Scan directories for inodes with dup blocks. */
-#define PR_1C_PASS_HEADER 0x012000
-
-
-/* Pass 1D: Reconciling duplicate blocks */
-#define PR_1D_PASS_HEADER 0x013000
-
-/* File has duplicate blocks */
-#define PR_1D_DUP_FILE 0x013001
-
-/* List of files sharing duplicate blocks */
-#define PR_1D_DUP_FILE_LIST 0x013002
-
-/* File sharing blocks with filesystem metadata */
-#define PR_1D_SHARE_METADATA 0x013003
-
-/* Report of how many duplicate/bad inodes */
-#define PR_1D_NUM_DUP_INODES 0x013004
-
-/* Duplicated blocks already reassigned or cloned. */
-#define PR_1D_DUP_BLOCKS_DEALT 0x013005
-
-/* Clone duplicate/bad blocks? */
-#define PR_1D_CLONE_QUESTION 0x013006
-
-/* Delete file? */
-#define PR_1D_DELETE_QUESTION 0x013007
-
-/* Couldn't clone file (error) */
-#define PR_1D_CLONE_ERROR 0x013008
-
-/*
- * Pass 2 errors
- */
-
-/* Pass 2: Checking directory structure */
-#define PR_2_PASS_HEADER 0x020000
-
-/* Bad inode number for '.' */
-#define PR_2_BAD_INODE_DOT 0x020001
-
-/* Directory entry has bad inode number */
-#define PR_2_BAD_INO 0x020002
-
-/* Directory entry has deleted or unused inode */
-#define PR_2_UNUSED_INODE 0x020003
-
-/* Directry entry is link to '.' */
-#define PR_2_LINK_DOT 0x020004
-
-/* Directory entry points to inode now located in a bad block */
-#define PR_2_BB_INODE 0x020005
-
-/* Directory entry contains a link to a directory */
-#define PR_2_LINK_DIR 0x020006
-
-/* Directory entry contains a link to the root directry */
-#define PR_2_LINK_ROOT 0x020007
-
-/* Directory entry has illegal characters in its name */
-#define PR_2_BAD_NAME 0x020008
-
-/* Missing '.' in directory inode */
-#define PR_2_MISSING_DOT 0x020009
-
-/* Missing '..' in directory inode */
-#define PR_2_MISSING_DOT_DOT 0x02000A
-
-/* First entry in directory inode doesn't contain '.' */
-#define PR_2_1ST_NOT_DOT 0x02000B
-
-/* Second entry in directory inode doesn't contain '..' */
-#define PR_2_2ND_NOT_DOT_DOT 0x02000C
-
-/* i_faddr should be zero */
-#define PR_2_FADDR_ZERO 0x02000D
-
-/* i_file_acl should be zero */
-#define PR_2_FILE_ACL_ZERO 0x02000E
-
-/* i_dir_acl should be zero */
-#define PR_2_DIR_ACL_ZERO 0x02000F
-
-/* i_frag should be zero */
-#define PR_2_FRAG_ZERO 0x020010
-
-/* i_fsize should be zero */
-#define PR_2_FSIZE_ZERO 0x020011
-
-/* inode has bad mode */
-#define PR_2_BAD_MODE 0x020012
-
-/* directory corrupted */
-#define PR_2_DIR_CORRUPTED 0x020013
-
-/* filename too long */
-#define PR_2_FILENAME_LONG 0x020014
-
-/* Directory inode has a missing block (hole) */
-#define PR_2_DIRECTORY_HOLE 0x020015
-
-/* '.' is not NULL terminated */
-#define PR_2_DOT_NULL_TERM 0x020016
-
-/* '..' is not NULL terminated */
-#define PR_2_DOT_DOT_NULL_TERM 0x020017
-
-/* Illegal character device in inode */
-#define PR_2_BAD_CHAR_DEV 0x020018
-
-/* Illegal block device in inode */
-#define PR_2_BAD_BLOCK_DEV 0x020019
-
-/* Duplicate '.' entry */
-#define PR_2_DUP_DOT 0x02001A
-
-/* Duplicate '..' entry */
-#define PR_2_DUP_DOT_DOT 0x02001B
-
-/* Internal error: couldn't find dir_info */
-#define PR_2_NO_DIRINFO 0x02001C
-
-/* Final rec_len is wrong */
-#define PR_2_FINAL_RECLEN 0x02001D
-
-/* Error allocating icount structure */
-#define PR_2_ALLOCATE_ICOUNT 0x02001E
-
-/* Error iterating over directory blocks */
-#define PR_2_DBLIST_ITERATE 0x02001F
-
-/* Error reading directory block */
-#define PR_2_READ_DIRBLOCK 0x020020
-
-/* Error writing directory block */
-#define PR_2_WRITE_DIRBLOCK 0x020021
-
-/* Error allocating new directory block */
-#define PR_2_ALLOC_DIRBOCK 0x020022
-
-/* Error deallocating inode */
-#define PR_2_DEALLOC_INODE 0x020023
-
-/* Directory entry for '.' is big. Split? */
-#define PR_2_SPLIT_DOT 0x020024
-
-/* Illegal FIFO */
-#define PR_2_BAD_FIFO 0x020025
-
-/* Illegal socket */
-#define PR_2_BAD_SOCKET 0x020026
-
-/* Directory filetype not set */
-#define PR_2_SET_FILETYPE 0x020027
-
-/* Directory filetype incorrect */
-#define PR_2_BAD_FILETYPE 0x020028
-
-/* Directory filetype set when it shouldn't be */
-#define PR_2_CLEAR_FILETYPE 0x020029
-
-/* Directory filename can't be zero-length */
-#define PR_2_NULL_NAME 0x020030
-
-/* Invalid symlink */
-#define PR_2_INVALID_SYMLINK 0x020031
-
-/* i_file_acl (extended attribute) is bad */
-#define PR_2_FILE_ACL_BAD 0x020032
-
-/* Filesystem contains large files, but has no such flag in sb */
-#define PR_2_FEATURE_LARGE_FILES 0x020033
-
-/* Node in HTREE directory not referenced */
-#define PR_2_HTREE_NOTREF 0x020034
-
-/* Node in HTREE directory referenced twice */
-#define PR_2_HTREE_DUPREF 0x020035
-
-/* Node in HTREE directory has bad min hash */
-#define PR_2_HTREE_MIN_HASH 0x020036
-
-/* Node in HTREE directory has bad max hash */
-#define PR_2_HTREE_MAX_HASH 0x020037
-
-/* Clear invalid HTREE directory */
-#define PR_2_HTREE_CLEAR 0x020038
-
-/* Clear the htree flag forcibly */
-/* #define PR_2_HTREE_FCLR 0x020039 */
-
-/* Bad block in htree interior node */
-#define PR_2_HTREE_BADBLK 0x02003A
-
-/* Error adjusting EA refcount */
-#define PR_2_ADJ_EA_REFCOUNT 0x02003B
-
-/* Invalid HTREE root node */
-#define PR_2_HTREE_BAD_ROOT 0x02003C
-
-/* Invalid HTREE limit */
-#define PR_2_HTREE_BAD_LIMIT 0x02003D
-
-/* Invalid HTREE count */
-#define PR_2_HTREE_BAD_COUNT 0x02003E
-
-/* HTREE interior node has out-of-order hashes in table */
-#define PR_2_HTREE_HASH_ORDER 0x02003F
-
-/* Node in HTREE directory has bad depth */
-#define PR_2_HTREE_BAD_DEPTH 0x020040
-
-/* Duplicate directory entry found */
-#define PR_2_DUPLICATE_DIRENT 0x020041
-
-/* Non-unique filename found */
-#define PR_2_NON_UNIQUE_FILE 0x020042
-
-/* Duplicate directory entry found */
-#define PR_2_REPORT_DUP_DIRENT 0x020043
-
-/*
- * Pass 3 errors
- */
-
-/* Pass 3: Checking directory connectivity */
-#define PR_3_PASS_HEADER 0x030000
-
-/* Root inode not allocated */
-#define PR_3_NO_ROOT_INODE 0x030001
-
-/* No room in lost+found */
-#define PR_3_EXPAND_LF_DIR 0x030002
-
-/* Unconnected directory inode */
-#define PR_3_UNCONNECTED_DIR 0x030003
-
-/* /lost+found not found */
-#define PR_3_NO_LF_DIR 0x030004
-
-/* .. entry is incorrect */
-#define PR_3_BAD_DOT_DOT 0x030005
-
-/* Bad or non-existent /lost+found. Cannot reconnect */
-#define PR_3_NO_LPF 0x030006
-
-/* Could not expand /lost+found */
-#define PR_3_CANT_EXPAND_LPF 0x030007
-
-/* Could not reconnect inode */
-#define PR_3_CANT_RECONNECT 0x030008
-
-/* Error while trying to find /lost+found */
-#define PR_3_ERR_FIND_LPF 0x030009
-
-/* Error in ext2fs_new_block while creating /lost+found */
-#define PR_3_ERR_LPF_NEW_BLOCK 0x03000A
-
-/* Error in ext2fs_new_inode while creating /lost+found */
-#define PR_3_ERR_LPF_NEW_INODE 0x03000B
-
-/* Error in ext2fs_new_dir_block while creating /lost+found */
-#define PR_3_ERR_LPF_NEW_DIR_BLOCK 0x03000C
-
-/* Error while writing directory block for /lost+found */
-#define PR_3_ERR_LPF_WRITE_BLOCK 0x03000D
-
-/* Error while adjusting inode count */
-#define PR_3_ADJUST_INODE 0x03000E
-
-/* Couldn't fix parent directory -- error */
-#define PR_3_FIX_PARENT_ERR 0x03000F
-
-/* Couldn't fix parent directory -- couldn't find it */
-#define PR_3_FIX_PARENT_NOFIND 0x030010
-
-/* Error allocating inode bitmap */
-#define PR_3_ALLOCATE_IBITMAP_ERROR 0x030011
-
-/* Error creating root directory */
-#define PR_3_CREATE_ROOT_ERROR 0x030012
-
-/* Error creating lost and found directory */
-#define PR_3_CREATE_LPF_ERROR 0x030013
-
-/* Root inode is not directory; aborting */
-#define PR_3_ROOT_NOT_DIR_ABORT 0x030014
-
-/* Cannot proceed without a root inode. */
-#define PR_3_NO_ROOT_INODE_ABORT 0x030015
-
-/* Internal error: couldn't find dir_info */
-#define PR_3_NO_DIRINFO 0x030016
-
-/* Lost+found is not a directory */
-#define PR_3_LPF_NOTDIR 0x030017
-
-/*
- * Pass 3a --- rehashing diretories
- */
-/* Pass 3a: Reindexing directories */
-#define PR_3A_PASS_HEADER 0x031000
-
-/* Error iterating over directories */
-#define PR_3A_OPTIMIZE_ITER 0x031001
-
-/* Error rehash directory */
-#define PR_3A_OPTIMIZE_DIR_ERR 0x031002
-
-/* Rehashing dir header */
-#define PR_3A_OPTIMIZE_DIR_HEADER 0x031003
-
-/* Rehashing directory %d */
-#define PR_3A_OPTIMIZE_DIR 0x031004
-
-/* Rehashing dir end */
-#define PR_3A_OPTIMIZE_DIR_END 0x031005
-
-/*
- * Pass 4 errors
- */
-
-/* Pass 4: Checking reference counts */
-#define PR_4_PASS_HEADER 0x040000
-
-/* Unattached zero-length inode */
-#define PR_4_ZERO_LEN_INODE 0x040001
-
-/* Unattached inode */
-#define PR_4_UNATTACHED_INODE 0x040002
-
-/* Inode ref count wrong */
-#define PR_4_BAD_REF_COUNT 0x040003
-
-/* Inconsistent inode count information cached */
-#define PR_4_INCONSISTENT_COUNT 0x040004
-
-/*
- * Pass 5 errors
- */
-
-/* Pass 5: Checking group summary information */
-#define PR_5_PASS_HEADER 0x050000
-
-/* Padding at end of inode bitmap is not set. */
-#define PR_5_INODE_BMAP_PADDING 0x050001
-
-/* Padding at end of block bitmap is not set. */
-#define PR_5_BLOCK_BMAP_PADDING 0x050002
-
-/* Block bitmap differences header */
-#define PR_5_BLOCK_BITMAP_HEADER 0x050003
-
-/* Block not used, but marked in bitmap */
-#define PR_5_BLOCK_UNUSED 0x050004
-
-/* Block used, but not marked used in bitmap */
-#define PR_5_BLOCK_USED 0x050005
-
-/* Block bitmap differences end */
-#define PR_5_BLOCK_BITMAP_END 0x050006
-
-/* Inode bitmap differences header */
-#define PR_5_INODE_BITMAP_HEADER 0x050007
-
-/* Inode not used, but marked in bitmap */
-#define PR_5_INODE_UNUSED 0x050008
-
-/* Inode used, but not marked used in bitmap */
-#define PR_5_INODE_USED 0x050009
-
-/* Inode bitmap differences end */
-#define PR_5_INODE_BITMAP_END 0x05000A
-
-/* Free inodes count for group wrong */
-#define PR_5_FREE_INODE_COUNT_GROUP 0x05000B
-
-/* Directories count for group wrong */
-#define PR_5_FREE_DIR_COUNT_GROUP 0x05000C
-
-/* Free inodes count wrong */
-#define PR_5_FREE_INODE_COUNT 0x05000D
-
-/* Free blocks count for group wrong */
-#define PR_5_FREE_BLOCK_COUNT_GROUP 0x05000E
-
-/* Free blocks count wrong */
-#define PR_5_FREE_BLOCK_COUNT 0x05000F
-
-/* Programming error: bitmap endpoints don't match */
-#define PR_5_BMAP_ENDPOINTS 0x050010
-
-/* Internal error: fudging end of bitmap */
-#define PR_5_FUDGE_BITMAP_ERROR 0x050011
-
-/* Error copying in replacement inode bitmap */
-#define PR_5_COPY_IBITMAP_ERROR 0x050012
-
-/* Error copying in replacement block bitmap */
-#define PR_5_COPY_BBITMAP_ERROR 0x050013
-
-/* Block range not used, but marked in bitmap */
-#define PR_5_BLOCK_RANGE_UNUSED 0x050014
-
-/* Block range used, but not marked used in bitmap */
-#define PR_5_BLOCK_RANGE_USED 0x050015
-
-/* Inode range not used, but marked in bitmap */
-#define PR_5_INODE_RANGE_UNUSED 0x050016
-
-/* Inode rangeused, but not marked used in bitmap */
-#define PR_5_INODE_RANGE_USED 0x050017
/*
* Function declarations
* functions.
*/
-static _INLINE_ kmem_cache_t * do_cache_create(int len)
+static kmem_cache_t * do_cache_create(int len)
{
kmem_cache_t *new_cache;
return new_cache;
}
-static _INLINE_ void do_cache_destroy(kmem_cache_t *cache)
+static void do_cache_destroy(kmem_cache_t *cache)
{
free(cache);
}
-/*
- * badblocks.c --- replace/append bad blocks to the bad block inode
- */
-
-static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt,
- void *priv_data);
-
-
-static void invalid_block(ext2_filsys fs FSCK_ATTR((unused)), blk_t blk)
-{
- printf(_("Bad block %u out of range; ignored.\n"), blk);
- return;
-}
-
-static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
- int replace_bad_blocks)
-{
- ext2_filsys fs = ctx->fs;
- errcode_t retval;
- badblocks_list bb_list = 0;
- FILE *f;
- char buf[1024];
-
- e2fsck_read_bitmaps(ctx);
-
- /*
- * Make sure the bad block inode is sane. If there are any
- * illegal blocks, clear them.
- */
- retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0,
- check_bb_inode_blocks, 0);
- if (retval) {
- com_err("ext2fs_block_iterate", retval,
- _("while sanity checking the bad blocks inode"));
- goto fatal;
- }
-
- /*
- * If we're appending to the bad blocks inode, read in the
- * current bad blocks.
- */
- if (!replace_bad_blocks) {
- retval = ext2fs_read_bb_inode(fs, &bb_list);
- if (retval) {
- com_err("ext2fs_read_bb_inode", retval,
- _("while reading the bad blocks inode"));
- goto fatal;
- }
- }
-
- /*
- * Now read in the bad blocks from the file; if
- * bad_blocks_file is null, then try to run the badblocks
- * command.
- */
- if (bad_blocks_file) {
- f = fopen(bad_blocks_file, "r");
- if (!f) {
- com_err("read_bad_blocks_file", errno,
- _("while trying to open %s"), bad_blocks_file);
- goto fatal;
- }
- } else {
- sprintf(buf, "badblocks -b %d %s%s%s %d", fs->blocksize,
- (ctx->options & E2F_OPT_PREEN) ? "" : "-s ",
- (ctx->options & E2F_OPT_WRITECHECK) ? "-n " : "",
- fs->device_name, fs->super->s_blocks_count);
- f = popen(buf, "r");
- if (!f) {
- com_err("read_bad_blocks_file", errno,
- _("while trying popen '%s'"), buf);
- goto fatal;
- }
- }
- retval = ext2fs_read_bb_FILE(fs, f, &bb_list, invalid_block);
- if (bad_blocks_file)
- fclose(f);
- else
- pclose(f);
- if (retval) {
- com_err("ext2fs_read_bb_FILE", retval,
- _("while reading in list of bad blocks from file"));
- goto fatal;
- }
-
- /*
- * Finally, update the bad blocks from the bad_block_map
- */
- retval = ext2fs_update_bb_inode(fs, bb_list);
- if (retval) {
- com_err("ext2fs_update_bb_inode", retval,
- _("while updating bad block inode"));
- goto fatal;
- }
-
- ext2fs_badblocks_list_free(bb_list);
- return;
-
-fatal:
- ctx->flags |= E2F_FLAG_ABORT;
- return;
-
-}
-
-static int check_bb_inode_blocks(ext2_filsys fs,
- blk_t *block_nr,
- int blockcnt FSCK_ATTR((unused)),
- void *priv_data FSCK_ATTR((unused)))
-{
- if (!*block_nr)
- return 0;
-
- /*
- * If the block number is outrageous, clear it and ignore it.
- */
- if (*block_nr >= fs->super->s_blocks_count ||
- *block_nr < fs->super->s_first_data_block) {
- printf(_("Warning illegal block %u found in bad block inode. Cleared.\n"), *block_nr);
- *block_nr = 0;
- return BLOCK_CHANGED;
- }
-
- return 0;
-}
/*
* Dictionary Abstract Data Type
#define dict_root(D) ((D)->nilnode.left)
#define dict_nil(D) (&(D)->nilnode)
-#define DICT_DEPTH_MAX 64
static void dnode_free(dnode_t *node);
/*
* Return the count of number of directories in the dir_info structure
*/
-static inline int e2fsck_get_num_dirinfo(e2fsck_t ctx)
+static int e2fsck_get_num_dirinfo(e2fsck_t ctx)
{
return ctx->dir_info_count;
}
ctx->block_dup_map = 0;
ext2fs_free_block_bitmap(ctx->block_ea_map);
ctx->block_ea_map = 0;
- ext2fs_free_inode_bitmap(ctx->inode_bb_map);
- ctx->inode_bb_map = 0;
ext2fs_free_inode_bitmap(ctx->inode_bad_map);
ctx->inode_bad_map = 0;
ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
ctx->fs_fast_symlinks_count = 0;
ctx->fs_fifo_count = 0;
ctx->fs_total_count = 0;
- ctx->fs_badblocks_count = 0;
ctx->fs_sockets_count = 0;
ctx->fs_ind_count = 0;
ctx->fs_dind_count = 0;
return error;
}
-static inline const char *ehandler_operation(const char *op)
+static const char *ehandler_operation(const char *op)
{
const char *ret = operation;
* any later version.
*/
-#define MNT_FL (MS_MGC_VAL | MS_RDONLY)
-
/*
* Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths.
* This creates a larger static binary, and a smaller binary using
bh->b_blocknr,
1, bh->b_data);
if (retval) {
- com_err(bh->b_ctx->device_name, retval,
- "while reading block %lu\n",
+ bb_error_msg("while reading block %lu",
(unsigned long) bh->b_blocknr);
bh->b_err = retval;
continue;
bh->b_blocknr,
1, bh->b_data);
if (retval) {
- com_err(bh->b_ctx->device_name, retval,
- "while writing block %lu\n",
+ bb_error_msg("while writing block %lu",
(unsigned long) bh->b_blocknr);
bh->b_err = retval;
continue;
}
}
-static inline void mark_buffer_dirty(struct buffer_head *bh)
+static void mark_buffer_dirty(struct buffer_head *bh)
{
bh->b_dirty = 1;
}
ext2fs_free_mem(&bh);
}
-static inline int buffer_uptodate(struct buffer_head *bh)
+static int buffer_uptodate(struct buffer_head *bh)
{
return bh->b_uptodate;
}
memcpy(&jsuper, start ? bh->b_data : bh->b_data + 1024,
sizeof(jsuper));
brelse(bh);
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
ext2fs_swap_super(&jsuper);
#endif
ll_rw_block(READ, 1, &jbh);
if (jbh->b_err) {
- com_err(ctx->device_name, jbh->b_err,
- _("reading journal superblock\n"));
+ bb_error_msg(_("reading journal superblock"));
return jbh->b_err;
}
* format to be able to proceed safely, so any other checks that
* fail we should attempt to recover from. */
if (jsb->s_blocksize != htonl(journal->j_blocksize)) {
- com_err(ctx->program_name, EXT2_ET_CORRUPT_SUPERBLOCK,
- _("%s: no valid journal superblock found\n"),
+ bb_error_msg(_("%s: no valid journal superblock found"),
ctx->device_name);
return EXT2_ET_CORRUPT_SUPERBLOCK;
}
if (ntohl(jsb->s_maxlen) < journal->j_maxlen)
journal->j_maxlen = ntohl(jsb->s_maxlen);
else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) {
- com_err(ctx->program_name, EXT2_ET_CORRUPT_SUPERBLOCK,
- _("%s: journal too short\n"),
+ bb_error_msg(_("%s: journal too short"),
ctx->device_name);
return EXT2_ET_CORRUPT_SUPERBLOCK;
}
&ctx->fs);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while trying to re-open %s"),
+ bb_error_msg(_("while trying to re-open %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ctx->fs->priv_data = ctx;
if (LINUX_S_ISDIR(inode->i_mode))
printf("%u", inode->i_size);
else {
-#ifdef EXT2_NO_64_TYPE
- if (inode->i_size_high)
- printf("0x%x%08x", inode->i_size_high,
- inode->i_size);
- else
- printf("%u", inode->i_size);
-#else
- printf("%llu", (inode->i_size |
- ((__u64) inode->i_size_high << 32)));
-#endif
+ printf("%"PRIu64, (inode->i_size |
+ ((uint64_t) inode->i_size_high << 32)));
}
break;
case 'S':
/*
* This function expands '%dX' expressions
*/
-static _INLINE_ void expand_dirent_expression(char ch,
+static void expand_dirent_expression(char ch,
struct problem_context *ctx)
{
struct ext2_dir_entry *dirent;
}
}
-static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch,
+static void expand_percent_expression(ext2_filsys fs, char ch,
struct problem_context *ctx)
{
if (!ctx)
printf("%u", ctx->blk);
break;
case 'B':
-#ifdef EXT2_NO_64_TYPE
- printf("%d", ctx->blkcount);
-#else
- printf("%lld", ctx->blkcount);
-#endif
+ printf("%"PRIi64, ctx->blkcount);
break;
case 'c':
printf("%u", ctx->blk2);
printf("%s", error_message(ctx->errcode));
break;
case 'N':
-#ifdef EXT2_NO_64_TYPE
- printf("%u", ctx->num);
-#else
- printf("%llu", ctx->num);
-#endif
+ printf("%"PRIi64, ctx->num);
break;
case 'p':
print_pathname(fs, ctx->ino, 0);
printf("%s", ctx->str ? ctx->str : "NULL");
break;
case 'X':
-#ifdef EXT2_NO_64_TYPE
- printf("0x%x", ctx->num);
-#else
- printf("0x%llx", ctx->num);
-#endif
+ printf("0x%"PRIi64, ctx->num);
break;
default:
no_context:
* - A bitmap of which inodes are directories. (inode_dir_map)
* - A bitmap of which inodes are regular files. (inode_reg_map)
* - A bitmap of which inodes have bad fields. (inode_bad_map)
- * - A bitmap of which inodes are in bad blocks. (inode_bb_map)
* - A bitmap of which inodes are imagic inodes. (inode_imagic_map)
* - A bitmap of which blocks are in use. (block_found_map)
* - A bitmap of which blocks are in use by two inodes (block_dup_map)
static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
char *block_buf);
static void mark_table_blocks(e2fsck_t ctx);
-static void alloc_bb_map(e2fsck_t ctx);
static void alloc_imagic_map(e2fsck_t ctx);
static void mark_inode_bad(e2fsck_t ctx, ino_t ino);
static void handle_fs_bad_blocks(e2fsck_t ctx);
static void process_inodes(e2fsck_t ctx, char *block_buf);
-static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b);
-static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
+static int process_inode_cmp(const void *a, const void *b);
+static errcode_t scan_callback(ext2_filsys fs,
dgrp_t group, void * priv_data);
static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
char *block_buf, int adjust_sign);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE) {
- if (!ctx->inode_bb_map)
- alloc_bb_map(ctx);
- ext2fs_mark_inode_bitmap(ctx->inode_bb_map, ino);
- ext2fs_mark_inode_bitmap(ctx->inode_used_map, ino);
continue;
}
if (pctx.errcode) {
e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
"recreate inode");
inode->i_mtime = time(0);
- e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
+ e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
"recreate inode");
fs->block_map = save_bmap;
ctx->flags &= ~E2F_FLAG_RESIZE_INODE;
* glock group, call process_inodes.
*/
static errcode_t scan_callback(ext2_filsys fs,
- ext2_inode_scan scan FSCK_ATTR((unused)),
dgrp_t group, void * priv_data)
{
struct scan_callback_struct *scan_struct;
ehandler_operation(old_operation);
}
-static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b)
+static int process_inode_cmp(const void *a, const void *b)
{
const struct process_inode_block *ib_a =
(const struct process_inode_block *) a;
}
-/*
- * This procedure will allocate the inode "bb" (badblock) map table
- */
-static void alloc_bb_map(e2fsck_t ctx)
-{
- struct problem_context pctx;
-
- clear_problem_context(&pctx);
- pctx.errcode = ext2fs_allocate_inode_bitmap(ctx->fs,
- _("inode in bad block map"),
- &ctx->inode_bb_map);
- if (pctx.errcode) {
- pctx.num = 4;
- fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
- /* Should never get here */
- ctx->flags |= E2F_FLAG_ABORT;
- return;
- }
-}
-
/*
* This procedure will allocate the inode imagic table
*/
* WARNING: Assumes checks have already been done to make sure block
* is valid. This is true in both process_block and process_bad_block.
*/
-static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
+static void mark_block_used(e2fsck_t ctx, blk_t block)
{
struct problem_context pctx;
* Should never happen, since only directories
* get called with BLOCK_FLAG_HOLE
*/
-#if DEBUG_E2FSCK
+#ifdef DEBUG_E2FSCK
printf("process_block() called with blk == 0, "
"blockcnt=%d, inode %lu???\n",
blockcnt, p->ino);
return ret_code;
}
-static int process_bad_block(ext2_filsys fs,
+static int process_bad_block(ext2_filsys fs FSCK_ATTR((unused)),
blk_t *block_nr,
e2_blkcnt_t blockcnt,
blk_t ref_block FSCK_ATTR((unused)),
int ref_offset FSCK_ATTR((unused)),
- void *priv_data)
+ void *priv_data EXT2FS_ATTR((unused)))
{
- struct process_block_struct_1 *p;
- blk_t blk = *block_nr;
- blk_t first_block;
- dgrp_t i;
- struct problem_context *pctx;
- e2fsck_t ctx;
-
/*
* Note: This function processes blocks for the bad blocks
* inode, which is never compressed. So we don't use HOLE_BLKADDR().
*/
- if (!blk)
- return 0;
-
- p = (struct process_block_struct_1 *) priv_data;
- ctx = p->ctx;
- pctx = p->pctx;
-
- pctx->ino = EXT2_BAD_INO;
- pctx->blk = blk;
- pctx->blkcount = blockcnt;
-
- if ((blk < fs->super->s_first_data_block) ||
- (blk >= fs->super->s_blocks_count)) {
- if (fix_problem(ctx, PR_1_BB_ILLEGAL_BLOCK_NUM, pctx)) {
- *block_nr = 0;
- return BLOCK_CHANGED;
- } else
- return 0;
- }
-
- if (blockcnt < 0) {
- if (ext2fs_test_block_bitmap(p->fs_meta_blocks, blk)) {
- p->bbcheck = 1;
- if (fix_problem(ctx, PR_1_BB_FS_BLOCK, pctx)) {
- *block_nr = 0;
- return BLOCK_CHANGED;
- }
- } else if (ext2fs_test_block_bitmap(ctx->block_found_map,
- blk)) {
- p->bbcheck = 1;
- if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK,
- pctx)) {
- *block_nr = 0;
- return BLOCK_CHANGED;
- }
- if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- return BLOCK_ABORT;
- } else
- mark_block_used(ctx, blk);
- return 0;
- }
-
- ctx->fs_badblocks_count++;
- /*
- * If the block is not used, then mark it as used and return.
- * If it is already marked as found, this must mean that
- * there's an overlap between the filesystem table blocks
- * (bitmaps and inode table) and the bad block list.
- */
- if (!ext2fs_test_block_bitmap(ctx->block_found_map, blk)) {
- ext2fs_mark_block_bitmap(ctx->block_found_map, blk);
- return 0;
- }
- /*
- * Try to find the where the filesystem block was used...
- */
- first_block = fs->super->s_first_data_block;
-
- for (i = 0; i < fs->group_desc_count; i++ ) {
- pctx->group = i;
- pctx->blk = blk;
- if (!ext2fs_bg_has_super(fs, i))
- goto skip_super;
- if (blk == first_block) {
- if (i == 0) {
- if (fix_problem(ctx,
- PR_1_BAD_PRIMARY_SUPERBLOCK,
- pctx)) {
- *block_nr = 0;
- return BLOCK_CHANGED;
- }
- return 0;
- }
- fix_problem(ctx, PR_1_BAD_SUPERBLOCK, pctx);
- return 0;
- }
- if ((blk > first_block) &&
- (blk <= first_block + fs->desc_blocks)) {
- if (i == 0) {
- pctx->blk = *block_nr;
- if (fix_problem(ctx,
- PR_1_BAD_PRIMARY_GROUP_DESCRIPTOR, pctx)) {
- *block_nr = 0;
- return BLOCK_CHANGED;
- }
- return 0;
- }
- fix_problem(ctx, PR_1_BAD_GROUP_DESCRIPTORS, pctx);
- return 0;
- }
- skip_super:
- if (blk == fs->group_desc[i].bg_block_bitmap) {
- if (fix_problem(ctx, PR_1_BB_BAD_BLOCK, pctx)) {
- ctx->invalid_block_bitmap_flag[i]++;
- ctx->invalid_bitmaps++;
- }
- return 0;
- }
- if (blk == fs->group_desc[i].bg_inode_bitmap) {
- if (fix_problem(ctx, PR_1_IB_BAD_BLOCK, pctx)) {
- ctx->invalid_inode_bitmap_flag[i]++;
- ctx->invalid_bitmaps++;
- }
- return 0;
- }
- if ((blk >= fs->group_desc[i].bg_inode_table) &&
- (blk < (fs->group_desc[i].bg_inode_table +
- fs->inode_blocks_per_group))) {
- /*
- * If there are bad blocks in the inode table,
- * the inode scan code will try to do
- * something reasonable automatically.
- */
- return 0;
- }
- first_block += fs->super->s_blocks_per_group;
- }
- /*
- * If we've gotten to this point, then the only
- * possibility is that the bad block inode meta data
- * is using a bad block.
- */
- if ((blk == p->inode->i_block[EXT2_IND_BLOCK]) ||
- (blk == p->inode->i_block[EXT2_DIND_BLOCK]) ||
- (blk == p->inode->i_block[EXT2_TIND_BLOCK])) {
- p->bbcheck = 1;
- if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK, pctx)) {
- *block_nr = 0;
- return BLOCK_CHANGED;
- }
- if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- return BLOCK_ABORT;
- return 0;
- }
-
- pctx->group = -1;
-
- /* Warn user that the block wasn't claimed */
- fix_problem(ctx, PR_1_PROGERR_CLAIMED_BLOCK, pctx);
-
- return 0;
-}
-
-static void new_table_block(e2fsck_t ctx, blk_t first_block, int group,
- const char *name, int num, blk_t *new_block)
-{
- ext2_filsys fs = ctx->fs;
- blk_t old_block = *new_block;
- int i;
- char *buf;
- struct problem_context pctx;
-
- clear_problem_context(&pctx);
-
- pctx.group = group;
- pctx.blk = old_block;
- pctx.str = name;
-
- pctx.errcode = ext2fs_get_free_blocks(fs, first_block,
- first_block + fs->super->s_blocks_per_group,
- num, ctx->block_found_map, new_block);
- if (pctx.errcode) {
- pctx.num = num;
- fix_problem(ctx, PR_1_RELOC_BLOCK_ALLOCATE, &pctx);
- ext2fs_unmark_valid(fs);
- return;
- }
- pctx.errcode = ext2fs_get_mem(fs->blocksize, &buf);
- if (pctx.errcode) {
- fix_problem(ctx, PR_1_RELOC_MEMORY_ALLOCATE, &pctx);
- ext2fs_unmark_valid(fs);
- return;
- }
- ext2fs_mark_super_dirty(fs);
- fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
- pctx.blk2 = *new_block;
- fix_problem(ctx, (old_block ? PR_1_RELOC_FROM_TO :
- PR_1_RELOC_TO), &pctx);
- pctx.blk2 = 0;
- for (i = 0; i < num; i++) {
- pctx.blk = i;
- ext2fs_mark_block_bitmap(ctx->block_found_map, (*new_block)+i);
- if (old_block) {
- pctx.errcode = io_channel_read_blk(fs->io,
- old_block + i, 1, buf);
- if (pctx.errcode)
- fix_problem(ctx, PR_1_RELOC_READ_ERR, &pctx);
- } else
- memset(buf, 0, fs->blocksize);
-
- pctx.blk = (*new_block) + i;
- pctx.errcode = io_channel_write_blk(fs->io, pctx.blk,
- 1, buf);
- if (pctx.errcode)
- fix_problem(ctx, PR_1_RELOC_WRITE_ERR, &pctx);
- }
- ext2fs_free_mem(&buf);
+ printf("Unrecoverable Error: Found %"PRIi64" bad blocks starting at block number: %u\n", blockcnt, *block_nr);
+ return BLOCK_ERROR;
}
/*
*/
static void handle_fs_bad_blocks(e2fsck_t ctx)
{
- ext2_filsys fs = ctx->fs;
- dgrp_t i;
- int first_block = fs->super->s_first_data_block;
-
- for (i = 0; i < fs->group_desc_count; i++) {
- if (ctx->invalid_block_bitmap_flag[i]) {
- new_table_block(ctx, first_block, i, _("block bitmap"),
- 1, &fs->group_desc[i].bg_block_bitmap);
- }
- if (ctx->invalid_inode_bitmap_flag[i]) {
- new_table_block(ctx, first_block, i, _("inode bitmap"),
- 1, &fs->group_desc[i].bg_inode_bitmap);
- }
- if (ctx->invalid_inode_table_flag[i]) {
- new_table_block(ctx, first_block, i, _("inode table"),
- fs->inode_blocks_per_group,
- &fs->group_desc[i].bg_inode_table);
- ctx->flags |= E2F_FLAG_RESTART;
- }
- first_block += fs->super->s_blocks_per_group;
- }
- ctx->invalid_bitmaps = 0;
+ printf("Bad blocks detected on your filesystem\n"
+ "You should get your data off as the device will soon die\n");
}
/*
p = (struct dup_block *) dnode_get(n);
decrement_badcount(ctx, *block_nr, p);
} else
- com_err("delete_file_block", 0,
- _("internal error; can't find dup_blk for %d\n"),
+ bb_error_msg(_("internal error; can't find dup_blk for %d"),
*block_nr);
} else {
ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr);
ext2fs_mark_block_bitmap(fs->block_map, new_block);
return BLOCK_CHANGED;
} else
- com_err("clone_file_block", 0,
- _("internal error; can't find dup_blk for %d\n"),
+ bb_error_msg(_("internal error; can't find dup_blk for %d"),
*block_nr);
}
return 0;
goto errout;
}
if (cs.errcode) {
- com_err("clone_file", cs.errcode,
- _("returned from clone_file_block"));
+ bb_error_msg(_("returned from clone_file_block"));
retval = cs.errcode;
goto errout;
}
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
static int htree_depth(struct dx_dir_info *dx_dir,
struct dx_dirblock_info *dx_db);
-static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b);
+static int special_dir_block_cmp(const void *a, const void *b);
struct check_dir_struct {
char *buf;
* This guarantees that the root node of the htree directories are
* processed first, so we know what hash version to use.
*/
-static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b)
+static int special_dir_block_cmp(const void *a, const void *b)
{
const struct ext2_db_entry *db_a =
(const struct ext2_db_entry *) a;
return 0;
}
-static _INLINE_ int check_filetype(e2fsck_t ctx,
+static int check_filetype(e2fsck_t ctx,
struct ext2_dir_entry *dirent,
struct problem_context *pctx)
{
* If the inode is unused, offer to clear it.
*/
problem = PR_2_UNUSED_INODE;
- } else if (ctx->inode_bb_map &&
- (ext2fs_test_inode_bitmap(ctx->inode_bb_map,
- dirent->inode))) {
- /*
- * If the inode is in a bad block, offer to
- * clear it.
- */
- problem = PR_2_BB_INODE;
} else if ((dot_state > 1) &&
((dirent->name_len & 0xFF) == 1) &&
(dirent->name[0] == '.')) {
!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) &&
fix_problem(ctx, PR_2_FILE_ACL_ZERO, &pctx)) {
inode.i_file_acl = 0;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
/*
* This is a special kludge to deal with long symlinks
* on big endian systems. i_blocks had already been
* Then, pass3 interates over all directory inodes; for each directory
* it attempts to trace up the filesystem tree, using dirinfo.parent
* until it reaches a directory which has been marked "done". If it
- * can not do so, then the directory must be disconnected, and e2fsck
+ * cannot do so, then the directory must be disconnected, and e2fsck
* will offer to reconnect it to /lost+found. While it is chasing
* parent pointers up the filesystem tree, if pass3 sees a directory
* twice, then it has detected a filesystem loop, and it will again
* pass4.c -- pass #4 of e2fsck: Check reference counts
*
* Pass 4 frees the following data structures:
- * - A bitmap of which inodes are in bad blocks. (inode_bb_map)
* - A bitmap of which inodes are imagic inodes. (inode_imagic_map)
*/
continue;
if (!(ext2fs_test_inode_bitmap(ctx->inode_used_map, i)) ||
(ctx->inode_imagic_map &&
- ext2fs_test_inode_bitmap(ctx->inode_imagic_map, i)) ||
- (ctx->inode_bb_map &&
- ext2fs_test_inode_bitmap(ctx->inode_bb_map, i)))
+ ext2fs_test_inode_bitmap(ctx->inode_imagic_map, i)))
continue;
ext2fs_icount_fetch(ctx->inode_link_info, i, &link_count);
ext2fs_icount_fetch(ctx->inode_count, i, &link_counted);
}
ext2fs_free_icount(ctx->inode_link_info); ctx->inode_link_info = 0;
ext2fs_free_icount(ctx->inode_count); ctx->inode_count = 0;
- ext2fs_free_inode_bitmap(ctx->inode_bb_map);
- ctx->inode_bb_map = 0;
ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
ctx->inode_imagic_map = 0;
ext2fs_free_mem(&buf);
/* Bad primary block */
{ PR_1_BAD_PRIMARY_BLOCK,
- N_("\nIf the @b is really bad, the @f can not be fixed.\n"),
+ N_("\nIf the @b is really bad, the @f cannot be fixed.\n"),
PROMPT_NONE, PR_AFTER_CODE, PR_1_BAD_PRIMARY_BLOCK_PROMPT },
/* Bad primary block prompt */
/* File has duplicate blocks */
{ PR_1D_DUP_FILE,
- N_("File %Q (@i #%i, mod time %IM) \n"
+ N_("File %Q (@i #%i, mod time %IM)\n"
" has %B @m @b(s), shared with %N file(s):\n"),
PROMPT_NONE, 0 },
/* Internal error: couldn't find dir_info */
{ PR_2_NO_DIRINFO,
- N_("Internal error: couldn't find dir_info for %i.\n"),
+ N_("Internal error: cannot find dir_info for %i.\n"),
PROMPT_NONE, PR_FATAL },
/* Final rec_len is wrong */
/* Internal error: couldn't find dir_info */
{ PR_3_NO_DIRINFO,
- N_("Internal error: couldn't find dir_info for %i.\n"),
+ N_("Internal error: cannot find dir_info for %i.\n"),
PROMPT_NONE, PR_FATAL },
/* Lost+found not a directory */
preenhalt(ctx);
if (ptr->flags & PR_FATAL)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
if (ptr->prompt == PROMPT_NONE) {
if (ptr->flags & PR_NOCOLLATE)
}
if ((ptr->prompt == PROMPT_ABORT) && answer)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
if (ptr->flags & PR_AFTER_CODE)
answer = fix_problem(ctx, ptr->second_code, pctx);
err = journal_bmap(journal, offset, &blocknr);
if (err) {
- printf ("JBD: bad block at offset %u\n", offset);
+ printf("JBD: bad block at offset %u\n", offset);
return err;
}
}
if (!buffer_uptodate(bh)) {
- printf ("JBD: Failed to read block at offset %u\n", offset);
+ printf("JBD: Failed to read block at offset %u\n", offset);
brelse(bh);
return -EIO;
}
/* Recover what we can, but
* report failure at the end. */
success = err;
- printf ("JBD: IO error %d recovering "
+ printf("JBD: IO error %d recovering "
"block %ld in log\n",
err, io_block);
} else {
blocknr,
journal->j_blocksize);
if (nbh == NULL) {
- printf ("JBD: Out of memory "
+ printf("JBD: Out of memory "
"during recovery.\n");
err = -ENOMEM;
brelse(bh);
/* It's really bad news if different passes end up at
* different places (but possible due to IO errors). */
if (info->end_transaction != next_commit_ID) {
- printf ("JBD: recovery pass %d ended at "
+ printf("JBD: recovery pass %d ended at "
"transaction %u, expected %u\n",
pass, next_commit_ID, info->end_transaction);
if (!success)
}
/* Used for sorting the hash entry */
-static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b)
+static int name_cmp(const void *a, const void *b)
{
const struct hash_entry *he_a = (const struct hash_entry *) a;
const struct hash_entry *he_b = (const struct hash_entry *) b;
}
/* Used for sorting the hash entry */
-static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b)
+static int hash_cmp(const void *a, const void *b)
{
const struct hash_entry *he_a = (const struct hash_entry *) a;
const struct hash_entry *he_b = (const struct hash_entry *) b;
/* Utility functions to maintain the revoke table */
/* Borrowed from buffer.c: this is a tried and tested block hash function */
-static inline int hash(journal_t *journal, unsigned long block)
+static int hash(journal_t *journal, unsigned long block)
{
struct jbd_revoke_table_s *table = journal->j_revoke;
int hash_shift = table->hash_shift;
retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
block_buf, release_inode_block, &pb);
if (retval) {
- com_err("release_inode_blocks", retval,
- _("while calling ext2fs_block_iterate for inode %d"),
+ bb_error_msg(_("while calling ext2fs_block_iterate for inode %d"),
ino);
return 1;
}
count = 1;
}
if (retval) {
- com_err("release_inode_blocks", retval,
- _("while calling ext2fs_adjust_ea_refocunt for inode %d"),
+ bb_error_msg(_("while calling ext2fs_adjust_ea_refocunt for inode %d"),
ino);
return 1;
}
retval = ext2fs_block_iterate(ctx->fs, ino, 0, block_buf,
swap_block, &sb);
if (retval) {
- com_err("swap_inode_blocks", retval,
- _("while calling ext2fs_block_iterate"));
+ bb_error_msg(_("while calling ext2fs_block_iterate"));
ctx->flags |= E2F_FLAG_ABORT;
return;
}
if (sb.errcode) {
- com_err("swap_inode_blocks", sb.errcode,
- _("while calling iterator function"));
+ bb_error_msg(_("while calling iterator function"));
ctx->flags |= E2F_FLAG_ABORT;
return;
}
retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group,
&buf);
if (retval) {
- com_err("swap_inodes", retval,
- _("while allocating inode buffer"));
+ bb_error_msg(_("while allocating inode buffer"));
ctx->flags |= E2F_FLAG_ABORT;
return;
}
fs->group_desc[group].bg_inode_table,
fs->inode_blocks_per_group, buf);
if (retval) {
- com_err("swap_inodes", retval,
- _("while reading inode table (group %d)"),
+ bb_error_msg(_("while reading inode table (group %d)"),
group);
ctx->flags |= E2F_FLAG_ABORT;
return;
fs->group_desc[group].bg_inode_table,
fs->inode_blocks_per_group, buf);
if (retval) {
- com_err("swap_inodes", retval,
- _("while writing inode table (group %d)"),
+ bb_error_msg(_("while writing inode table (group %d)"),
group);
ctx->flags |= E2F_FLAG_ABORT;
return;
ext2fs_flush_icache(fs);
}
-#if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS)
+#if defined(__powerpc__) && BB_BIG_ENDIAN
/*
* On the PowerPC, the big-endian variant of the ext2 filesystem
* has its bitmaps stored as 32-bit words with bit 0 as the LSB
ret = malloc(size);
if (!ret) {
sprintf(buf, "Can't allocate %s\n", description);
- fatal_error(ctx, buf);
+ bb_error_msg_and_die(buf);
}
memset(ret, 0, size);
return ret;
int ask (e2fsck_t ctx, const char * string, int def)
{
if (ctx->options & E2F_OPT_NO) {
- printf (_("%s? no\n\n"), string);
+ printf(_("%s? no\n\n"), string);
return 0;
}
if (ctx->options & E2F_OPT_YES) {
- printf (_("%s? yes\n\n"), string);
+ printf(_("%s? yes\n\n"), string);
return 1;
}
if (ctx->options & E2F_OPT_PREEN) {
- printf ("%s? %s\n\n", string, def ? _("yes") : _("no"));
+ printf("%s? %s\n\n", string, def ? _("yes") : _("no"));
return def;
}
return ask_yn(string, def);
errcode_t retval;
if (ctx->invalid_bitmaps) {
- com_err(ctx->program_name, 0,
- _("e2fsck_read_bitmaps: illegal bitmap block(s) for %s"),
+ bb_error_msg(_("e2fsck_read_bitmaps: illegal bitmap block(s) for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ehandler_operation(_("reading inode and block bitmaps"));
retval = ext2fs_read_bitmaps(fs);
ehandler_operation(0);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to read bitmaps for %s"),
+ bb_error_msg(_("while retrying to read bitmaps for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
retval = ext2fs_write_block_bitmap(fs);
ehandler_operation(0);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to write block bitmaps for %s"),
+ bb_error_msg(_("while retrying to write block bitmaps for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
retval = ext2fs_write_inode_bitmap(fs);
ehandler_operation(0);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to write inode bitmaps for %s"),
+ bb_error_msg(_("while retrying to write inode bitmaps for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
}
retval = ext2fs_read_inode(ctx->fs, ino, inode);
if (retval) {
- com_err("ext2fs_read_inode", retval,
- _("while reading inode %ld in %s"), ino, proc);
- fatal_error(ctx, 0);
+ bb_error_msg(_("while reading inode %ld in %s"), ino, proc);
+ bb_error_msg_and_die(0);
}
}
retval = ext2fs_write_inode_full(ctx->fs, ino, inode, bufsize);
if (retval) {
- com_err("ext2fs_write_inode", retval,
- _("while writing inode %ld in %s"), ino, proc);
- fatal_error(ctx, 0);
+ bb_error_msg(_("while writing inode %ld in %s"), ino, proc);
+ bb_error_msg_and_die(0);
}
}
retval = ext2fs_write_inode(ctx->fs, ino, inode);
if (retval) {
- com_err("ext2fs_write_inode", retval,
- _("while writing inode %ld in %s"), ino, proc);
- fatal_error(ctx, 0);
+ bb_error_msg(_("while writing inode %ld in %s"), ino, proc);
+ bb_error_msg_and_die(0);
}
}
if (io_channel_read_blk(io, superblock,
-SUPERBLOCK_SIZE, buf))
continue;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
ext2fs_swap_super(sb);
#endif
static int show_version_only;
static int verbose;
-static int replace_bad_blocks;
-static int keep_bad_blocks;
-static char *bad_blocks_file;
-
#define P_E2(singular, plural, n) n, ((n) == 1 ? singular : plural)
static void show_stats(e2fsck_t ctx)
blocks_used, blocks);
return;
}
- printf ("\n%8d inode%s used (%d%%)\n", P_E2("", "s", inodes_used),
+ printf("\n%8d inode%s used (%d%%)\n", P_E2("", "s", inodes_used),
100 * inodes_used / inodes);
- printf ("%8d non-contiguous inode%s (%0d.%d%%)\n",
+ printf("%8d non-contiguous inode%s (%0d.%d%%)\n",
P_E2("", "s", ctx->fs_fragmented),
frag_percent / 10, frag_percent % 10);
- printf (_(" # of inodes with ind/dind/tind blocks: %d/%d/%d\n"),
+ printf(_(" # of inodes with ind/dind/tind blocks: %d/%d/%d\n"),
ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count);
- printf ("%8d block%s used (%d%%)\n", P_E2("", "s", blocks_used),
+ printf("%8d block%s used (%d%%)\n", P_E2("", "s", blocks_used),
(int) ((long long) 100 * blocks_used / blocks));
- printf ("%8d bad block%s\n", P_E2("", "s", ctx->fs_badblocks_count));
- printf ("%8d large file%s\n", P_E2("", "s", ctx->large_files));
- printf ("\n%8d regular file%s\n", P_E2("", "s", ctx->fs_regular_count));
- printf ("%8d director%s\n", P_E2("y", "ies", ctx->fs_directory_count));
- printf ("%8d character device file%s\n", P_E2("", "s", ctx->fs_chardev_count));
- printf ("%8d block device file%s\n", P_E2("", "s", ctx->fs_blockdev_count));
- printf ("%8d fifo%s\n", P_E2("", "s", ctx->fs_fifo_count));
- printf ("%8d link%s\n", P_E2("", "s", ctx->fs_links_count - dir_links));
- printf ("%8d symbolic link%s", P_E2("", "s", ctx->fs_symlinks_count));
- printf (" (%d fast symbolic link%s)\n", P_E2("", "s", ctx->fs_fast_symlinks_count));
- printf ("%8d socket%s--------\n\n", P_E2("", "s", ctx->fs_sockets_count));
- printf ("%8d file%s\n", P_E2("", "s", ctx->fs_total_count - dir_links));
+ printf("%8d large file%s\n", P_E2("", "s", ctx->large_files));
+ printf("\n%8d regular file%s\n", P_E2("", "s", ctx->fs_regular_count));
+ printf("%8d director%s\n", P_E2("y", "ies", ctx->fs_directory_count));
+ printf("%8d character device file%s\n", P_E2("", "s", ctx->fs_chardev_count));
+ printf("%8d block device file%s\n", P_E2("", "s", ctx->fs_blockdev_count));
+ printf("%8d fifo%s\n", P_E2("", "s", ctx->fs_fifo_count));
+ printf("%8d link%s\n", P_E2("", "s", ctx->fs_links_count - dir_links));
+ printf("%8d symbolic link%s", P_E2("", "s", ctx->fs_symlinks_count));
+ printf(" (%d fast symbolic link%s)\n", P_E2("", "s", ctx->fs_fast_symlinks_count));
+ printf("%8d socket%s--------\n\n", P_E2("", "s", ctx->fs_sockets_count));
+ printf("%8d file%s\n", P_E2("", "s", ctx->fs_total_count - dir_links));
}
static void check_mount(e2fsck_t ctx)
retval = ext2fs_check_if_mounted(ctx->filesystem_name,
&ctx->mount_flags);
if (retval) {
- com_err("ext2fs_check_if_mount", retval,
- _("while determining whether %s is mounted."),
+ bb_error_msg(_("while determining whether %s is mounted."),
ctx->filesystem_name);
return;
}
printf(_("%s is mounted. "), ctx->filesystem_name);
if (!ctx->interactive)
- fatal_error(ctx, _("Cannot continue, aborting.\n\n"));
+ bb_error_msg_and_die(_("Cannot continue, aborting."));
printf(_("\n\n\007\007\007\007WARNING!!! "
"Running e2fsck on a mounted filesystem may cause\n"
"SEVERE filesystem damage.\007\007\007\n\n"));
cont = ask_yn(_("Do you really want to continue"), -1);
if (!cont) {
- printf (_("check aborted.\n"));
+ printf(_("check aborted.\n"));
exit (0);
}
return;
int batt = is_on_batt();
time_t now = time(0);
- if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file ||
- cflag || swapfs)
+ if ((ctx->options & E2F_OPT_FORCE) || cflag || swapfs)
return;
if ((fs->super->s_state & EXT2_ERROR_FS) ||
if (fd > 2)
break;
if (fd < 0) {
- fprintf(stderr, _("ERROR: Couldn't open "
+ fprintf(stderr, _("ERROR: Cannot open "
"/dev/null (%s)\n"),
strerror(errno));
break;
_("Error validating file descriptor %d: %s\n"),
ctx->progress_fd,
error_message(errno));
- fatal_error(ctx,
- _("Invalid completion information file descriptor"));
+ bb_error_msg_and_die(_("Invalid completion information file descriptor"));
} else
close(fd);
break;
case 'a':
if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) {
conflict_opt:
- fatal_error(ctx,
- _("Only one the options -p/-a, -n or -y may be specified."));
+ bb_error_msg_and_die(_("Only one the options -p/-a, -n or -y may be specified."));
}
ctx->options |= E2F_OPT_PREEN;
break;
case 'P':
ctx->process_inode_size = atoi(optarg);
break;
- case 'L':
- replace_bad_blocks++;
- case 'l':
- bad_blocks_file = string_copy(optarg, 0);
- break;
case 'd':
ctx->options |= E2F_OPT_DEBUG;
break;
"of e2fsck\n"));
exit(1);
#endif
- case 'k':
- keep_bad_blocks++;
- break;
default:
- usage();
+ bb_show_usage();
}
if (show_version_only)
return 0;
if (optind != argc - 1)
- usage();
- if ((ctx->options & E2F_OPT_NO) && !bad_blocks_file &&
+ bb_show_usage();
+ if ((ctx->options & E2F_OPT_NO) &&
!cflag && !swapfs && !(ctx->options & E2F_OPT_COMPRESS_DIRS))
ctx->options |= E2F_OPT_READONLY;
ctx->io_options = strchr(argv[optind], '?');
*ctx->io_options++ = 0;
ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0);
if (!ctx->filesystem_name) {
- com_err(ctx->program_name, 0, _("Unable to resolve '%s'"),
- argv[optind]);
- fatal_error(ctx, 0);
+ bb_error_msg(_("Unable to resolve '%s'"), argv[optind]);
+ bb_error_msg_and_die(0);
}
if (extended_opts)
parse_extended_opts(ctx, extended_opts);
if (flush) {
fd = open(ctx->filesystem_name, O_RDONLY, 0);
if (fd < 0) {
- com_err("open", errno,
- _("while opening %s for flushing"),
+ bb_error_msg(_("while opening %s for flushing"),
ctx->filesystem_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
if ((retval = ext2fs_sync_device(fd, 1))) {
- com_err("ext2fs_sync_device", retval,
- _("while trying to flush %s"),
+ bb_error_msg(_("while trying to flush %s"),
ctx->filesystem_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
close(fd);
}
#ifdef ENABLE_SWAPFS
- if (swapfs) {
- if (cflag || bad_blocks_file) {
+ if (swapfs && cflag) {
fprintf(stderr, _("Incompatible options not "
"allowed when byte-swapping.\n"));
exit(EXIT_USAGE);
- }
}
#endif
- if (cflag && bad_blocks_file) {
- fprintf(stderr, _("The -c and the -l/-L options may "
- "not be both used at the same time.\n"));
- exit(EXIT_USAGE);
- }
/*
* Set up signal action
*/
retval = PRS(argc, argv, &ctx);
if (retval) {
- com_err("e2fsck", retval,
- _("while trying to initialize program"));
+ bb_error_msg(_("while trying to initialize program"));
exit(EXIT_ERROR);
}
reserve_stdio_fds();
!(ctx->options & E2F_OPT_NO) &&
!(ctx->options & E2F_OPT_YES)) {
if (!ctx->interactive)
- fatal_error(ctx,
- _("need terminal for interactive repairs"));
+ bb_error_msg_and_die(_("need terminal for interactive repairs"));
}
ctx->superblock = ctx->use_superblock;
restart:
}
}
if (retval) {
- com_err(ctx->program_name, retval, _("while trying to open %s"),
+ bb_error_msg(_("while trying to open %s"),
ctx->filesystem_name);
if (retval == EXT2_ET_REV_TOO_HIGH) {
printf(_("The filesystem revision is apparently "
#endif
else
fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ctx->fs = fs;
fs->priv_data = ctx;
sb = fs->super;
if (sb->s_rev_level > E2FSCK_CURRENT_REV) {
- com_err(ctx->program_name, EXT2_ET_REV_TOO_HIGH,
- _("while trying to open %s"),
+ bb_error_msg(_("while trying to open %s"),
ctx->filesystem_name);
get_newer:
- fatal_error(ctx, _("Get a newer version of e2fsck!"));
+ bb_error_msg_and_die(_("Get a newer version of e2fsck!"));
}
/*
*/
retval = e2fsck_check_ext3_journal(ctx);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while checking ext3 journal for %s"),
+ bb_error_msg(_("while checking ext3 journal for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
/*
* happen, unless the hardware or
* device driver is being bogus.
*/
- com_err(ctx->program_name, 0,
- _("unable to set superblock flags on %s\n"), ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg(_("cannot set superblock flags on %s"), ctx->device_name);
+ bb_error_msg_and_die(0);
}
retval = e2fsck_run_ext3_journal(ctx);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while recovering ext3 journal of %s"),
+ bb_error_msg(_("while recovering ext3 journal of %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ext2fs_close(ctx->fs);
ctx->fs = 0;
*/
if ((sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
(sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) {
- com_err(ctx->program_name, EXT2_ET_UNSUPP_FEATURE,
- "(%s)", ctx->device_name);
+ bb_error_msg("(%s)", ctx->device_name);
goto get_newer;
}
if (sb->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
- com_err(ctx->program_name, EXT2_ET_RO_UNSUPP_FEATURE,
- "(%s)", ctx->device_name);
+ bb_error_msg("(%s)", ctx->device_name);
goto get_newer;
}
#ifdef ENABLE_COMPRESSION
/* FIXME - do we support this at all? */
if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION)
- com_err(ctx->program_name, 0,
- _("Warning: compression support is experimental.\n"));
+ bb_error_msg(_("Warning: compression support is experimental."));
#endif
#ifndef ENABLE_HTREE
if (sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) {
- com_err(ctx->program_name, 0,
- _("E2fsck not compiled with HTREE support,\n\t"
- "but filesystem %s has HTREE directories.\n"),
+ bb_error_msg(_("E2fsck not compiled with HTREE support,\n\t"
+ "but filesystem %s has HTREE directories."),
ctx->device_name);
goto get_newer;
}
ext2fs_mark_valid(fs);
check_super_block(ctx);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
check_if_skip(ctx);
- if (bad_blocks_file)
- read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks);
- else if (cflag)
- read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
#ifdef ENABLE_SWAPFS
#ifdef WORDS_BIGENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) == NATIVE_FLAG) {
fprintf(stderr, _("%s: Filesystem byte order "
"already normalized.\n"), ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
if (swapfs) {
swap_filesys(ctx);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
#endif
retval = ext2fs_read_bb_inode(fs, &fs->badblocks);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while reading bad blocks inode"));
+ bb_error_msg(_("while reading bad blocks inode"));
preenhalt(ctx);
printf(_("This doesn't bode well,"
" but we'll try to go on...\n"));
printf(_("Restarting e2fsck from the beginning...\n"));
retval = e2fsck_reset_context(ctx);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while resetting context"));
- fatal_error(ctx, 0);
+ bb_error_msg(_("while resetting context"));
+ bb_error_msg_and_die(0);
}
ext2fs_close(fs);
goto restart;
exit_value |= FSCK_CANCELED;
}
if (run_result & E2F_FLAG_ABORT)
- fatal_error(ctx, _("aborted"));
+ bb_error_msg_and_die(_("aborted"));
/* Cleanup */
if (ext2fs_test_changed(fs)) {