diff options
Diffstat (limited to 'e2fsprogs/e2fsck.c')
-rw-r--r-- | e2fsprogs/e2fsck.c | 243 |
1 files changed, 93 insertions, 150 deletions
diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c index e72739cba..7e1c82e54 100644 --- a/e2fsprogs/e2fsck.c +++ b/e2fsprogs/e2fsck.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * e2fsck | 2 | * e2fsck |
3 | * | 3 | * |
4 | * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. | 4 | * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. |
5 | * Copyright (C) 2006 Garrett Kajmowicz | ||
5 | * This file may be | 6 | * This file may be |
6 | * redistributed under the terms of the GNU Public License. | 7 | * redistributed under the terms of the GNU Public License. |
7 | * | 8 | * |
@@ -38,14 +39,6 @@ | |||
38 | 39 | ||
39 | #include "e2fsck.h" /*Put all of our defines here to clean things up*/ | 40 | #include "e2fsck.h" /*Put all of our defines here to clean things up*/ |
40 | 41 | ||
41 | #ifdef __GNUC__ | ||
42 | #define _INLINE_ __inline__ | ||
43 | #define EXT2FS_ATTR(x) __attribute__(x) | ||
44 | #else | ||
45 | #define _INLINE_ | ||
46 | #define EXT2FS_ATTR(x) | ||
47 | #endif | ||
48 | |||
49 | /* | 42 | /* |
50 | * Procedure declarations | 43 | * Procedure declarations |
51 | */ | 44 | */ |
@@ -219,7 +212,7 @@ typedef struct { | |||
219 | * functions. | 212 | * functions. |
220 | */ | 213 | */ |
221 | 214 | ||
222 | static _INLINE_ kmem_cache_t * do_cache_create(int len) | 215 | static kmem_cache_t * do_cache_create(int len) |
223 | { | 216 | { |
224 | kmem_cache_t *new_cache; | 217 | kmem_cache_t *new_cache; |
225 | 218 | ||
@@ -229,7 +222,7 @@ static _INLINE_ kmem_cache_t * do_cache_create(int len) | |||
229 | return new_cache; | 222 | return new_cache; |
230 | } | 223 | } |
231 | 224 | ||
232 | static _INLINE_ void do_cache_destroy(kmem_cache_t *cache) | 225 | static void do_cache_destroy(kmem_cache_t *cache) |
233 | { | 226 | { |
234 | free(cache); | 227 | free(cache); |
235 | } | 228 | } |
@@ -266,8 +259,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, | |||
266 | retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0, | 259 | retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0, |
267 | check_bb_inode_blocks, 0); | 260 | check_bb_inode_blocks, 0); |
268 | if (retval) { | 261 | if (retval) { |
269 | com_err("ext2fs_block_iterate", retval, | 262 | bb_error_msg(_("while sanity checking the bad blocks inode")); |
270 | _("while sanity checking the bad blocks inode")); | ||
271 | goto fatal; | 263 | goto fatal; |
272 | } | 264 | } |
273 | 265 | ||
@@ -278,8 +270,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, | |||
278 | if (!replace_bad_blocks) { | 270 | if (!replace_bad_blocks) { |
279 | retval = ext2fs_read_bb_inode(fs, &bb_list); | 271 | retval = ext2fs_read_bb_inode(fs, &bb_list); |
280 | if (retval) { | 272 | if (retval) { |
281 | com_err("ext2fs_read_bb_inode", retval, | 273 | bb_error_msg(_("while reading the bad blocks inode")); |
282 | _("while reading the bad blocks inode")); | ||
283 | goto fatal; | 274 | goto fatal; |
284 | } | 275 | } |
285 | } | 276 | } |
@@ -292,8 +283,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, | |||
292 | if (bad_blocks_file) { | 283 | if (bad_blocks_file) { |
293 | f = fopen(bad_blocks_file, "r"); | 284 | f = fopen(bad_blocks_file, "r"); |
294 | if (!f) { | 285 | if (!f) { |
295 | com_err("read_bad_blocks_file", errno, | 286 | bb_error_msg(_("while trying to open %s"), bad_blocks_file); |
296 | _("while trying to open %s"), bad_blocks_file); | ||
297 | goto fatal; | 287 | goto fatal; |
298 | } | 288 | } |
299 | } else { | 289 | } else { |
@@ -303,8 +293,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, | |||
303 | fs->device_name, fs->super->s_blocks_count); | 293 | fs->device_name, fs->super->s_blocks_count); |
304 | f = popen(buf, "r"); | 294 | f = popen(buf, "r"); |
305 | if (!f) { | 295 | if (!f) { |
306 | com_err("read_bad_blocks_file", errno, | 296 | bb_error_msg(_("while trying popen '%s'"), buf); |
307 | _("while trying popen '%s'"), buf); | ||
308 | goto fatal; | 297 | goto fatal; |
309 | } | 298 | } |
310 | } | 299 | } |
@@ -314,8 +303,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, | |||
314 | else | 303 | else |
315 | pclose(f); | 304 | pclose(f); |
316 | if (retval) { | 305 | if (retval) { |
317 | com_err("ext2fs_read_bb_FILE", retval, | 306 | bb_error_msg(_("while reading in list of bad blocks from file")); |
318 | _("while reading in list of bad blocks from file")); | ||
319 | goto fatal; | 307 | goto fatal; |
320 | } | 308 | } |
321 | 309 | ||
@@ -324,8 +312,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file, | |||
324 | */ | 312 | */ |
325 | retval = ext2fs_update_bb_inode(fs, bb_list); | 313 | retval = ext2fs_update_bb_inode(fs, bb_list); |
326 | if (retval) { | 314 | if (retval) { |
327 | com_err("ext2fs_update_bb_inode", retval, | 315 | bb_error_msg(_("while updating bad block inode")); |
328 | _("while updating bad block inode")); | ||
329 | goto fatal; | 316 | goto fatal; |
330 | } | 317 | } |
331 | 318 | ||
@@ -390,7 +377,6 @@ static int check_bb_inode_blocks(ext2_filsys fs, | |||
390 | 377 | ||
391 | #define dict_root(D) ((D)->nilnode.left) | 378 | #define dict_root(D) ((D)->nilnode.left) |
392 | #define dict_nil(D) (&(D)->nilnode) | 379 | #define dict_nil(D) (&(D)->nilnode) |
393 | #define DICT_DEPTH_MAX 64 | ||
394 | 380 | ||
395 | static void dnode_free(dnode_t *node); | 381 | static void dnode_free(dnode_t *node); |
396 | 382 | ||
@@ -1528,8 +1514,6 @@ static void ehandler_init(io_channel channel) | |||
1528 | * any later version. | 1514 | * any later version. |
1529 | */ | 1515 | */ |
1530 | 1516 | ||
1531 | #define MNT_FL (MS_MGC_VAL | MS_RDONLY) | ||
1532 | |||
1533 | /* | 1517 | /* |
1534 | * Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths. | 1518 | * Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths. |
1535 | * This creates a larger static binary, and a smaller binary using | 1519 | * This creates a larger static binary, and a smaller binary using |
@@ -1608,8 +1592,7 @@ static void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) | |||
1608 | bh->b_blocknr, | 1592 | bh->b_blocknr, |
1609 | 1, bh->b_data); | 1593 | 1, bh->b_data); |
1610 | if (retval) { | 1594 | if (retval) { |
1611 | com_err(bh->b_ctx->device_name, retval, | 1595 | bb_error_msg("while reading block %lu\n", |
1612 | "while reading block %lu\n", | ||
1613 | (unsigned long) bh->b_blocknr); | 1596 | (unsigned long) bh->b_blocknr); |
1614 | bh->b_err = retval; | 1597 | bh->b_err = retval; |
1615 | continue; | 1598 | continue; |
@@ -1620,8 +1603,7 @@ static void ll_rw_block(int rw, int nr, struct buffer_head *bhp[]) | |||
1620 | bh->b_blocknr, | 1603 | bh->b_blocknr, |
1621 | 1, bh->b_data); | 1604 | 1, bh->b_data); |
1622 | if (retval) { | 1605 | if (retval) { |
1623 | com_err(bh->b_ctx->device_name, retval, | 1606 | bb_error_msg("while writing block %lu\n", |
1624 | "while writing block %lu\n", | ||
1625 | (unsigned long) bh->b_blocknr); | 1607 | (unsigned long) bh->b_blocknr); |
1626 | bh->b_err = retval; | 1608 | bh->b_err = retval; |
1627 | continue; | 1609 | continue; |
@@ -1831,7 +1813,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) | |||
1831 | memcpy(&jsuper, start ? bh->b_data : bh->b_data + 1024, | 1813 | memcpy(&jsuper, start ? bh->b_data : bh->b_data + 1024, |
1832 | sizeof(jsuper)); | 1814 | sizeof(jsuper)); |
1833 | brelse(bh); | 1815 | brelse(bh); |
1834 | #ifdef EXT2FS_ENABLE_SWAPFS | 1816 | #if BB_BIG_ENDIAN |
1835 | if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) | 1817 | if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) |
1836 | ext2fs_swap_super(&jsuper); | 1818 | ext2fs_swap_super(&jsuper); |
1837 | #endif | 1819 | #endif |
@@ -1937,8 +1919,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal) | |||
1937 | 1919 | ||
1938 | ll_rw_block(READ, 1, &jbh); | 1920 | ll_rw_block(READ, 1, &jbh); |
1939 | if (jbh->b_err) { | 1921 | if (jbh->b_err) { |
1940 | com_err(ctx->device_name, jbh->b_err, | 1922 | bb_error_msg(_("reading journal superblock\n")); |
1941 | _("reading journal superblock\n")); | ||
1942 | return jbh->b_err; | 1923 | return jbh->b_err; |
1943 | } | 1924 | } |
1944 | 1925 | ||
@@ -1994,8 +1975,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal) | |||
1994 | * format to be able to proceed safely, so any other checks that | 1975 | * format to be able to proceed safely, so any other checks that |
1995 | * fail we should attempt to recover from. */ | 1976 | * fail we should attempt to recover from. */ |
1996 | if (jsb->s_blocksize != htonl(journal->j_blocksize)) { | 1977 | if (jsb->s_blocksize != htonl(journal->j_blocksize)) { |
1997 | com_err(ctx->program_name, EXT2_ET_CORRUPT_SUPERBLOCK, | 1978 | bb_error_msg(_("%s: no valid journal superblock found\n"), |
1998 | _("%s: no valid journal superblock found\n"), | ||
1999 | ctx->device_name); | 1979 | ctx->device_name); |
2000 | return EXT2_ET_CORRUPT_SUPERBLOCK; | 1980 | return EXT2_ET_CORRUPT_SUPERBLOCK; |
2001 | } | 1981 | } |
@@ -2003,8 +1983,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal) | |||
2003 | if (ntohl(jsb->s_maxlen) < journal->j_maxlen) | 1983 | if (ntohl(jsb->s_maxlen) < journal->j_maxlen) |
2004 | journal->j_maxlen = ntohl(jsb->s_maxlen); | 1984 | journal->j_maxlen = ntohl(jsb->s_maxlen); |
2005 | else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) { | 1985 | else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) { |
2006 | com_err(ctx->program_name, EXT2_ET_CORRUPT_SUPERBLOCK, | 1986 | bb_error_msg(_("%s: journal too short\n"), |
2007 | _("%s: journal too short\n"), | ||
2008 | ctx->device_name); | 1987 | ctx->device_name); |
2009 | return EXT2_ET_CORRUPT_SUPERBLOCK; | 1988 | return EXT2_ET_CORRUPT_SUPERBLOCK; |
2010 | } | 1989 | } |
@@ -2297,10 +2276,9 @@ static int e2fsck_run_ext3_journal(e2fsck_t ctx) | |||
2297 | &ctx->fs); | 2276 | &ctx->fs); |
2298 | 2277 | ||
2299 | if (retval) { | 2278 | if (retval) { |
2300 | com_err(ctx->program_name, retval, | 2279 | bb_error_msg(_("while trying to re-open %s"), |
2301 | _("while trying to re-open %s"), | ||
2302 | ctx->device_name); | 2280 | ctx->device_name); |
2303 | fatal_error(ctx, 0); | 2281 | bb_error_msg_and_die(0); |
2304 | } | 2282 | } |
2305 | ctx->fs->priv_data = ctx; | 2283 | ctx->fs->priv_data = ctx; |
2306 | 2284 | ||
@@ -2737,7 +2715,7 @@ static void expand_inode_expression(char ch, | |||
2737 | /* | 2715 | /* |
2738 | * This function expands '%dX' expressions | 2716 | * This function expands '%dX' expressions |
2739 | */ | 2717 | */ |
2740 | static _INLINE_ void expand_dirent_expression(char ch, | 2718 | static void expand_dirent_expression(char ch, |
2741 | struct problem_context *ctx) | 2719 | struct problem_context *ctx) |
2742 | { | 2720 | { |
2743 | struct ext2_dir_entry *dirent; | 2721 | struct ext2_dir_entry *dirent; |
@@ -2776,7 +2754,7 @@ static _INLINE_ void expand_dirent_expression(char ch, | |||
2776 | } | 2754 | } |
2777 | } | 2755 | } |
2778 | 2756 | ||
2779 | static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch, | 2757 | static void expand_percent_expression(ext2_filsys fs, char ch, |
2780 | struct problem_context *ctx) | 2758 | struct problem_context *ctx) |
2781 | { | 2759 | { |
2782 | if (!ctx) | 2760 | if (!ctx) |
@@ -3036,7 +3014,7 @@ static void alloc_imagic_map(e2fsck_t ctx); | |||
3036 | static void mark_inode_bad(e2fsck_t ctx, ino_t ino); | 3014 | static void mark_inode_bad(e2fsck_t ctx, ino_t ino); |
3037 | static void handle_fs_bad_blocks(e2fsck_t ctx); | 3015 | static void handle_fs_bad_blocks(e2fsck_t ctx); |
3038 | static void process_inodes(e2fsck_t ctx, char *block_buf); | 3016 | static void process_inodes(e2fsck_t ctx, char *block_buf); |
3039 | static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b); | 3017 | static int process_inode_cmp(const void *a, const void *b); |
3040 | static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan, | 3018 | static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan, |
3041 | dgrp_t group, void * priv_data); | 3019 | dgrp_t group, void * priv_data); |
3042 | static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, | 3020 | static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, |
@@ -3929,7 +3907,7 @@ static void process_inodes(e2fsck_t ctx, char *block_buf) | |||
3929 | ehandler_operation(old_operation); | 3907 | ehandler_operation(old_operation); |
3930 | } | 3908 | } |
3931 | 3909 | ||
3932 | static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b) | 3910 | static int process_inode_cmp(const void *a, const void *b) |
3933 | { | 3911 | { |
3934 | const struct process_inode_block *ib_a = | 3912 | const struct process_inode_block *ib_a = |
3935 | (const struct process_inode_block *) a; | 3913 | (const struct process_inode_block *) a; |
@@ -4015,7 +3993,7 @@ static void alloc_imagic_map(e2fsck_t ctx) | |||
4015 | * WARNING: Assumes checks have already been done to make sure block | 3993 | * WARNING: Assumes checks have already been done to make sure block |
4016 | * is valid. This is true in both process_block and process_bad_block. | 3994 | * is valid. This is true in both process_block and process_bad_block. |
4017 | */ | 3995 | */ |
4018 | static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block) | 3996 | static void mark_block_used(e2fsck_t ctx, blk_t block) |
4019 | { | 3997 | { |
4020 | struct problem_context pctx; | 3998 | struct problem_context pctx; |
4021 | 3999 | ||
@@ -5522,8 +5500,7 @@ static int delete_file_block(ext2_filsys fs, | |||
5522 | p = (struct dup_block *) dnode_get(n); | 5500 | p = (struct dup_block *) dnode_get(n); |
5523 | decrement_badcount(ctx, *block_nr, p); | 5501 | decrement_badcount(ctx, *block_nr, p); |
5524 | } else | 5502 | } else |
5525 | com_err("delete_file_block", 0, | 5503 | bb_error_msg(_("internal error; can't find dup_blk for %d\n"), |
5526 | _("internal error; can't find dup_blk for %d\n"), | ||
5527 | *block_nr); | 5504 | *block_nr); |
5528 | } else { | 5505 | } else { |
5529 | ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr); | 5506 | ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr); |
@@ -5656,8 +5633,7 @@ static int clone_file_block(ext2_filsys fs, | |||
5656 | ext2fs_mark_block_bitmap(fs->block_map, new_block); | 5633 | ext2fs_mark_block_bitmap(fs->block_map, new_block); |
5657 | return BLOCK_CHANGED; | 5634 | return BLOCK_CHANGED; |
5658 | } else | 5635 | } else |
5659 | com_err("clone_file_block", 0, | 5636 | bb_error_msg(_("internal error; can't find dup_blk for %d\n"), |
5660 | _("internal error; can't find dup_blk for %d\n"), | ||
5661 | *block_nr); | 5637 | *block_nr); |
5662 | } | 5638 | } |
5663 | return 0; | 5639 | return 0; |
@@ -5699,8 +5675,7 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino, | |||
5699 | goto errout; | 5675 | goto errout; |
5700 | } | 5676 | } |
5701 | if (cs.errcode) { | 5677 | if (cs.errcode) { |
5702 | com_err("clone_file", cs.errcode, | 5678 | bb_error_msg(_("returned from clone_file_block")); |
5703 | _("returned from clone_file_block")); | ||
5704 | retval = cs.errcode; | 5679 | retval = cs.errcode; |
5705 | goto errout; | 5680 | goto errout; |
5706 | } | 5681 | } |
@@ -5827,7 +5802,7 @@ static int update_dir_block(ext2_filsys fs, | |||
5827 | static void clear_htree(e2fsck_t ctx, ext2_ino_t ino); | 5802 | static void clear_htree(e2fsck_t ctx, ext2_ino_t ino); |
5828 | static int htree_depth(struct dx_dir_info *dx_dir, | 5803 | static int htree_depth(struct dx_dir_info *dx_dir, |
5829 | struct dx_dirblock_info *dx_db); | 5804 | struct dx_dirblock_info *dx_db); |
5830 | static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b); | 5805 | static int special_dir_block_cmp(const void *a, const void *b); |
5831 | 5806 | ||
5832 | struct check_dir_struct { | 5807 | struct check_dir_struct { |
5833 | char *buf; | 5808 | char *buf; |
@@ -6057,7 +6032,7 @@ static int dict_de_cmp(const void *a, const void *b) | |||
6057 | * This guarantees that the root node of the htree directories are | 6032 | * This guarantees that the root node of the htree directories are |
6058 | * processed first, so we know what hash version to use. | 6033 | * processed first, so we know what hash version to use. |
6059 | */ | 6034 | */ |
6060 | static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b) | 6035 | static int special_dir_block_cmp(const void *a, const void *b) |
6061 | { | 6036 | { |
6062 | const struct ext2_db_entry *db_a = | 6037 | const struct ext2_db_entry *db_a = |
6063 | (const struct ext2_db_entry *) a; | 6038 | (const struct ext2_db_entry *) a; |
@@ -6239,7 +6214,7 @@ static int ext2_file_type(unsigned int mode) | |||
6239 | return 0; | 6214 | return 0; |
6240 | } | 6215 | } |
6241 | 6216 | ||
6242 | static _INLINE_ int check_filetype(e2fsck_t ctx, | 6217 | static int check_filetype(e2fsck_t ctx, |
6243 | struct ext2_dir_entry *dirent, | 6218 | struct ext2_dir_entry *dirent, |
6244 | struct problem_context *pctx) | 6219 | struct problem_context *pctx) |
6245 | { | 6220 | { |
@@ -6909,7 +6884,7 @@ static int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir, | |||
6909 | !(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) && | 6884 | !(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) && |
6910 | fix_problem(ctx, PR_2_FILE_ACL_ZERO, &pctx)) { | 6885 | fix_problem(ctx, PR_2_FILE_ACL_ZERO, &pctx)) { |
6911 | inode.i_file_acl = 0; | 6886 | inode.i_file_acl = 0; |
6912 | #ifdef EXT2FS_ENABLE_SWAPFS | 6887 | #if BB_BIG_ENDIAN |
6913 | /* | 6888 | /* |
6914 | * This is a special kludge to deal with long symlinks | 6889 | * This is a special kludge to deal with long symlinks |
6915 | * on big endian systems. i_blocks had already been | 6890 | * on big endian systems. i_blocks had already been |
@@ -10166,7 +10141,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) | |||
10166 | preenhalt(ctx); | 10141 | preenhalt(ctx); |
10167 | 10142 | ||
10168 | if (ptr->flags & PR_FATAL) | 10143 | if (ptr->flags & PR_FATAL) |
10169 | fatal_error(ctx, 0); | 10144 | bb_error_msg_and_die(0); |
10170 | 10145 | ||
10171 | if (ptr->prompt == PROMPT_NONE) { | 10146 | if (ptr->prompt == PROMPT_NONE) { |
10172 | if (ptr->flags & PR_NOCOLLATE) | 10147 | if (ptr->flags & PR_NOCOLLATE) |
@@ -10198,7 +10173,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) | |||
10198 | } | 10173 | } |
10199 | 10174 | ||
10200 | if ((ptr->prompt == PROMPT_ABORT) && answer) | 10175 | if ((ptr->prompt == PROMPT_ABORT) && answer) |
10201 | fatal_error(ctx, 0); | 10176 | bb_error_msg_and_die(0); |
10202 | 10177 | ||
10203 | if (ptr->flags & PR_AFTER_CODE) | 10178 | if (ptr->flags & PR_AFTER_CODE) |
10204 | answer = fix_problem(ctx, ptr->second_code, pctx); | 10179 | answer = fix_problem(ctx, ptr->second_code, pctx); |
@@ -10773,7 +10748,7 @@ static int fill_dir_block(ext2_filsys fs, | |||
10773 | } | 10748 | } |
10774 | 10749 | ||
10775 | /* Used for sorting the hash entry */ | 10750 | /* Used for sorting the hash entry */ |
10776 | static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b) | 10751 | static int name_cmp(const void *a, const void *b) |
10777 | { | 10752 | { |
10778 | const struct hash_entry *he_a = (const struct hash_entry *) a; | 10753 | const struct hash_entry *he_a = (const struct hash_entry *) a; |
10779 | const struct hash_entry *he_b = (const struct hash_entry *) b; | 10754 | const struct hash_entry *he_b = (const struct hash_entry *) b; |
@@ -10797,7 +10772,7 @@ static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b) | |||
10797 | } | 10772 | } |
10798 | 10773 | ||
10799 | /* Used for sorting the hash entry */ | 10774 | /* Used for sorting the hash entry */ |
10800 | static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b) | 10775 | static int hash_cmp(const void *a, const void *b) |
10801 | { | 10776 | { |
10802 | const struct hash_entry *he_a = (const struct hash_entry *) a; | 10777 | const struct hash_entry *he_a = (const struct hash_entry *) a; |
10803 | const struct hash_entry *he_b = (const struct hash_entry *) b; | 10778 | const struct hash_entry *he_b = (const struct hash_entry *) b; |
@@ -11891,8 +11866,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, | |||
11891 | retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, | 11866 | retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, |
11892 | block_buf, release_inode_block, &pb); | 11867 | block_buf, release_inode_block, &pb); |
11893 | if (retval) { | 11868 | if (retval) { |
11894 | com_err("release_inode_blocks", retval, | 11869 | bb_error_msg(_("while calling ext2fs_block_iterate for inode %d"), |
11895 | _("while calling ext2fs_block_iterate for inode %d"), | ||
11896 | ino); | 11870 | ino); |
11897 | return 1; | 11871 | return 1; |
11898 | } | 11872 | } |
@@ -11914,8 +11888,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, | |||
11914 | count = 1; | 11888 | count = 1; |
11915 | } | 11889 | } |
11916 | if (retval) { | 11890 | if (retval) { |
11917 | com_err("release_inode_blocks", retval, | 11891 | bb_error_msg(_("while calling ext2fs_adjust_ea_refocunt for inode %d"), |
11918 | _("while calling ext2fs_adjust_ea_refocunt for inode %d"), | ||
11919 | ino); | 11892 | ino); |
11920 | return 1; | 11893 | return 1; |
11921 | } | 11894 | } |
@@ -12486,14 +12459,12 @@ static void swap_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, char *block_buf, | |||
12486 | retval = ext2fs_block_iterate(ctx->fs, ino, 0, block_buf, | 12459 | retval = ext2fs_block_iterate(ctx->fs, ino, 0, block_buf, |
12487 | swap_block, &sb); | 12460 | swap_block, &sb); |
12488 | if (retval) { | 12461 | if (retval) { |
12489 | com_err("swap_inode_blocks", retval, | 12462 | bb_error_msg(_("while calling ext2fs_block_iterate")); |
12490 | _("while calling ext2fs_block_iterate")); | ||
12491 | ctx->flags |= E2F_FLAG_ABORT; | 12463 | ctx->flags |= E2F_FLAG_ABORT; |
12492 | return; | 12464 | return; |
12493 | } | 12465 | } |
12494 | if (sb.errcode) { | 12466 | if (sb.errcode) { |
12495 | com_err("swap_inode_blocks", sb.errcode, | 12467 | bb_error_msg(_("while calling iterator function")); |
12496 | _("while calling iterator function")); | ||
12497 | ctx->flags |= E2F_FLAG_ABORT; | 12468 | ctx->flags |= E2F_FLAG_ABORT; |
12498 | return; | 12469 | return; |
12499 | } | 12470 | } |
@@ -12514,8 +12485,7 @@ static void swap_inodes(e2fsck_t ctx) | |||
12514 | retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group, | 12485 | retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group, |
12515 | &buf); | 12486 | &buf); |
12516 | if (retval) { | 12487 | if (retval) { |
12517 | com_err("swap_inodes", retval, | 12488 | bb_error_msg(_("while allocating inode buffer")); |
12518 | _("while allocating inode buffer")); | ||
12519 | ctx->flags |= E2F_FLAG_ABORT; | 12489 | ctx->flags |= E2F_FLAG_ABORT; |
12520 | return; | 12490 | return; |
12521 | } | 12491 | } |
@@ -12526,8 +12496,7 @@ static void swap_inodes(e2fsck_t ctx) | |||
12526 | fs->group_desc[group].bg_inode_table, | 12496 | fs->group_desc[group].bg_inode_table, |
12527 | fs->inode_blocks_per_group, buf); | 12497 | fs->inode_blocks_per_group, buf); |
12528 | if (retval) { | 12498 | if (retval) { |
12529 | com_err("swap_inodes", retval, | 12499 | bb_error_msg(_("while reading inode table (group %d)"), |
12530 | _("while reading inode table (group %d)"), | ||
12531 | group); | 12500 | group); |
12532 | ctx->flags |= E2F_FLAG_ABORT; | 12501 | ctx->flags |= E2F_FLAG_ABORT; |
12533 | return; | 12502 | return; |
@@ -12564,8 +12533,7 @@ static void swap_inodes(e2fsck_t ctx) | |||
12564 | fs->group_desc[group].bg_inode_table, | 12533 | fs->group_desc[group].bg_inode_table, |
12565 | fs->inode_blocks_per_group, buf); | 12534 | fs->inode_blocks_per_group, buf); |
12566 | if (retval) { | 12535 | if (retval) { |
12567 | com_err("swap_inodes", retval, | 12536 | bb_error_msg(_("while writing inode table (group %d)"), |
12568 | _("while writing inode table (group %d)"), | ||
12569 | group); | 12537 | group); |
12570 | ctx->flags |= E2F_FLAG_ABORT; | 12538 | ctx->flags |= E2F_FLAG_ABORT; |
12571 | return; | 12539 | return; |
@@ -12577,7 +12545,7 @@ static void swap_inodes(e2fsck_t ctx) | |||
12577 | ext2fs_flush_icache(fs); | 12545 | ext2fs_flush_icache(fs); |
12578 | } | 12546 | } |
12579 | 12547 | ||
12580 | #if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS) | 12548 | #if defined(__powerpc__) && BB_BIG_ENDIAN |
12581 | /* | 12549 | /* |
12582 | * On the PowerPC, the big-endian variant of the ext2 filesystem | 12550 | * On the PowerPC, the big-endian variant of the ext2 filesystem |
12583 | * has its bitmaps stored as 32-bit words with bit 0 as the LSB | 12551 | * has its bitmaps stored as 32-bit words with bit 0 as the LSB |
@@ -12663,7 +12631,7 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size, | |||
12663 | ret = malloc(size); | 12631 | ret = malloc(size); |
12664 | if (!ret) { | 12632 | if (!ret) { |
12665 | sprintf(buf, "Can't allocate %s\n", description); | 12633 | sprintf(buf, "Can't allocate %s\n", description); |
12666 | fatal_error(ctx, buf); | 12634 | bb_error_msg_and_die(buf); |
12667 | } | 12635 | } |
12668 | memset(ret, 0, size); | 12636 | memset(ret, 0, size); |
12669 | return ret; | 12637 | return ret; |
@@ -12792,20 +12760,18 @@ void e2fsck_read_bitmaps(e2fsck_t ctx) | |||
12792 | errcode_t retval; | 12760 | errcode_t retval; |
12793 | 12761 | ||
12794 | if (ctx->invalid_bitmaps) { | 12762 | if (ctx->invalid_bitmaps) { |
12795 | com_err(ctx->program_name, 0, | 12763 | bb_error_msg(_("e2fsck_read_bitmaps: illegal bitmap block(s) for %s"), |
12796 | _("e2fsck_read_bitmaps: illegal bitmap block(s) for %s"), | ||
12797 | ctx->device_name); | 12764 | ctx->device_name); |
12798 | fatal_error(ctx, 0); | 12765 | bb_error_msg_and_die(0); |
12799 | } | 12766 | } |
12800 | 12767 | ||
12801 | ehandler_operation(_("reading inode and block bitmaps")); | 12768 | ehandler_operation(_("reading inode and block bitmaps")); |
12802 | retval = ext2fs_read_bitmaps(fs); | 12769 | retval = ext2fs_read_bitmaps(fs); |
12803 | ehandler_operation(0); | 12770 | ehandler_operation(0); |
12804 | if (retval) { | 12771 | if (retval) { |
12805 | com_err(ctx->program_name, retval, | 12772 | bb_error_msg(_("while retrying to read bitmaps for %s"), |
12806 | _("while retrying to read bitmaps for %s"), | ||
12807 | ctx->device_name); | 12773 | ctx->device_name); |
12808 | fatal_error(ctx, 0); | 12774 | bb_error_msg_and_die(0); |
12809 | } | 12775 | } |
12810 | } | 12776 | } |
12811 | 12777 | ||
@@ -12819,10 +12785,9 @@ static void e2fsck_write_bitmaps(e2fsck_t ctx) | |||
12819 | retval = ext2fs_write_block_bitmap(fs); | 12785 | retval = ext2fs_write_block_bitmap(fs); |
12820 | ehandler_operation(0); | 12786 | ehandler_operation(0); |
12821 | if (retval) { | 12787 | if (retval) { |
12822 | com_err(ctx->program_name, retval, | 12788 | bb_error_msg(_("while retrying to write block bitmaps for %s"), |
12823 | _("while retrying to write block bitmaps for %s"), | ||
12824 | ctx->device_name); | 12789 | ctx->device_name); |
12825 | fatal_error(ctx, 0); | 12790 | bb_error_msg_and_die(0); |
12826 | } | 12791 | } |
12827 | } | 12792 | } |
12828 | 12793 | ||
@@ -12831,10 +12796,9 @@ static void e2fsck_write_bitmaps(e2fsck_t ctx) | |||
12831 | retval = ext2fs_write_inode_bitmap(fs); | 12796 | retval = ext2fs_write_inode_bitmap(fs); |
12832 | ehandler_operation(0); | 12797 | ehandler_operation(0); |
12833 | if (retval) { | 12798 | if (retval) { |
12834 | com_err(ctx->program_name, retval, | 12799 | bb_error_msg(_("while retrying to write inode bitmaps for %s"), |
12835 | _("while retrying to write inode bitmaps for %s"), | ||
12836 | ctx->device_name); | 12800 | ctx->device_name); |
12837 | fatal_error(ctx, 0); | 12801 | bb_error_msg_and_die(0); |
12838 | } | 12802 | } |
12839 | } | 12803 | } |
12840 | } | 12804 | } |
@@ -12863,9 +12827,8 @@ void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino, | |||
12863 | 12827 | ||
12864 | retval = ext2fs_read_inode(ctx->fs, ino, inode); | 12828 | retval = ext2fs_read_inode(ctx->fs, ino, inode); |
12865 | if (retval) { | 12829 | if (retval) { |
12866 | com_err("ext2fs_read_inode", retval, | 12830 | bb_error_msg(_("while reading inode %ld in %s"), ino, proc); |
12867 | _("while reading inode %ld in %s"), ino, proc); | 12831 | bb_error_msg_and_die(0); |
12868 | fatal_error(ctx, 0); | ||
12869 | } | 12832 | } |
12870 | } | 12833 | } |
12871 | 12834 | ||
@@ -12877,9 +12840,8 @@ extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino, | |||
12877 | 12840 | ||
12878 | retval = ext2fs_write_inode_full(ctx->fs, ino, inode, bufsize); | 12841 | retval = ext2fs_write_inode_full(ctx->fs, ino, inode, bufsize); |
12879 | if (retval) { | 12842 | if (retval) { |
12880 | com_err("ext2fs_write_inode", retval, | 12843 | bb_error_msg(_("while writing inode %ld in %s"), ino, proc); |
12881 | _("while writing inode %ld in %s"), ino, proc); | 12844 | bb_error_msg_and_die(0); |
12882 | fatal_error(ctx, 0); | ||
12883 | } | 12845 | } |
12884 | } | 12846 | } |
12885 | 12847 | ||
@@ -12890,9 +12852,8 @@ extern void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino, | |||
12890 | 12852 | ||
12891 | retval = ext2fs_write_inode(ctx->fs, ino, inode); | 12853 | retval = ext2fs_write_inode(ctx->fs, ino, inode); |
12892 | if (retval) { | 12854 | if (retval) { |
12893 | com_err("ext2fs_write_inode", retval, | 12855 | bb_error_msg(_("while writing inode %ld in %s"), ino, proc); |
12894 | _("while writing inode %ld in %s"), ino, proc); | 12856 | bb_error_msg_and_die(0); |
12895 | fatal_error(ctx, 0); | ||
12896 | } | 12857 | } |
12897 | } | 12858 | } |
12898 | 12859 | ||
@@ -12946,7 +12907,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, | |||
12946 | if (io_channel_read_blk(io, superblock, | 12907 | if (io_channel_read_blk(io, superblock, |
12947 | -SUPERBLOCK_SIZE, buf)) | 12908 | -SUPERBLOCK_SIZE, buf)) |
12948 | continue; | 12909 | continue; |
12949 | #ifdef EXT2FS_ENABLE_SWAPFS | 12910 | #if BB_BIG_ENDIAN |
12950 | if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) | 12911 | if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) |
12951 | ext2fs_swap_super(sb); | 12912 | ext2fs_swap_super(sb); |
12952 | #endif | 12913 | #endif |
@@ -13085,8 +13046,7 @@ static void check_mount(e2fsck_t ctx) | |||
13085 | retval = ext2fs_check_if_mounted(ctx->filesystem_name, | 13046 | retval = ext2fs_check_if_mounted(ctx->filesystem_name, |
13086 | &ctx->mount_flags); | 13047 | &ctx->mount_flags); |
13087 | if (retval) { | 13048 | if (retval) { |
13088 | com_err("ext2fs_check_if_mount", retval, | 13049 | bb_error_msg(_("while determining whether %s is mounted."), |
13089 | _("while determining whether %s is mounted."), | ||
13090 | ctx->filesystem_name); | 13050 | ctx->filesystem_name); |
13091 | return; | 13051 | return; |
13092 | } | 13052 | } |
@@ -13107,7 +13067,7 @@ static void check_mount(e2fsck_t ctx) | |||
13107 | 13067 | ||
13108 | printf(_("%s is mounted. "), ctx->filesystem_name); | 13068 | printf(_("%s is mounted. "), ctx->filesystem_name); |
13109 | if (!ctx->interactive) | 13069 | if (!ctx->interactive) |
13110 | fatal_error(ctx, _("Cannot continue, aborting.\n\n")); | 13070 | bb_error_msg_and_die(_("Cannot continue, aborting.\n\n")); |
13111 | printf(_("\n\n\007\007\007\007WARNING!!! " | 13071 | printf(_("\n\n\007\007\007\007WARNING!!! " |
13112 | "Running e2fsck on a mounted filesystem may cause\n" | 13072 | "Running e2fsck on a mounted filesystem may cause\n" |
13113 | "SEVERE filesystem damage.\007\007\007\n\n")); | 13073 | "SEVERE filesystem damage.\007\007\007\n\n")); |
@@ -13502,8 +13462,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) | |||
13502 | _("Error validating file descriptor %d: %s\n"), | 13462 | _("Error validating file descriptor %d: %s\n"), |
13503 | ctx->progress_fd, | 13463 | ctx->progress_fd, |
13504 | error_message(errno)); | 13464 | error_message(errno)); |
13505 | fatal_error(ctx, | 13465 | bb_error_msg_and_die(_("Invalid completion information file descriptor")); |
13506 | _("Invalid completion information file descriptor")); | ||
13507 | } else | 13466 | } else |
13508 | close(fd); | 13467 | close(fd); |
13509 | break; | 13468 | break; |
@@ -13517,8 +13476,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) | |||
13517 | case 'a': | 13476 | case 'a': |
13518 | if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) { | 13477 | if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) { |
13519 | conflict_opt: | 13478 | conflict_opt: |
13520 | fatal_error(ctx, | 13479 | bb_error_msg_and_die(_("Only one the options -p/-a, -n or -y may be specified.")); |
13521 | _("Only one the options -p/-a, -n or -y may be specified.")); | ||
13522 | } | 13480 | } |
13523 | ctx->options |= E2F_OPT_PREEN; | 13481 | ctx->options |= E2F_OPT_PREEN; |
13524 | break; | 13482 | break; |
@@ -13602,12 +13560,12 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) | |||
13602 | keep_bad_blocks++; | 13560 | keep_bad_blocks++; |
13603 | break; | 13561 | break; |
13604 | default: | 13562 | default: |
13605 | usage(); | 13563 | bb_show_usage(); |
13606 | } | 13564 | } |
13607 | if (show_version_only) | 13565 | if (show_version_only) |
13608 | return 0; | 13566 | return 0; |
13609 | if (optind != argc - 1) | 13567 | if (optind != argc - 1) |
13610 | usage(); | 13568 | bb_show_usage(); |
13611 | if ((ctx->options & E2F_OPT_NO) && !bad_blocks_file && | 13569 | if ((ctx->options & E2F_OPT_NO) && !bad_blocks_file && |
13612 | !cflag && !swapfs && !(ctx->options & E2F_OPT_COMPRESS_DIRS)) | 13570 | !cflag && !swapfs && !(ctx->options & E2F_OPT_COMPRESS_DIRS)) |
13613 | ctx->options |= E2F_OPT_READONLY; | 13571 | ctx->options |= E2F_OPT_READONLY; |
@@ -13616,9 +13574,8 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) | |||
13616 | *ctx->io_options++ = 0; | 13574 | *ctx->io_options++ = 0; |
13617 | ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0); | 13575 | ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0); |
13618 | if (!ctx->filesystem_name) { | 13576 | if (!ctx->filesystem_name) { |
13619 | com_err(ctx->program_name, 0, _("Unable to resolve '%s'"), | 13577 | bb_error_msg(_("Unable to resolve '%s'"), argv[optind]); |
13620 | argv[optind]); | 13578 | bb_error_msg_and_die(0); |
13621 | fatal_error(ctx, 0); | ||
13622 | } | 13579 | } |
13623 | if (extended_opts) | 13580 | if (extended_opts) |
13624 | parse_extended_opts(ctx, extended_opts); | 13581 | parse_extended_opts(ctx, extended_opts); |
@@ -13626,16 +13583,14 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) | |||
13626 | if (flush) { | 13583 | if (flush) { |
13627 | fd = open(ctx->filesystem_name, O_RDONLY, 0); | 13584 | fd = open(ctx->filesystem_name, O_RDONLY, 0); |
13628 | if (fd < 0) { | 13585 | if (fd < 0) { |
13629 | com_err("open", errno, | 13586 | bb_error_msg(_("while opening %s for flushing"), |
13630 | _("while opening %s for flushing"), | ||
13631 | ctx->filesystem_name); | 13587 | ctx->filesystem_name); |
13632 | fatal_error(ctx, 0); | 13588 | bb_error_msg_and_die(0); |
13633 | } | 13589 | } |
13634 | if ((retval = ext2fs_sync_device(fd, 1))) { | 13590 | if ((retval = ext2fs_sync_device(fd, 1))) { |
13635 | com_err("ext2fs_sync_device", retval, | 13591 | bb_error_msg(_("while trying to flush %s"), |
13636 | _("while trying to flush %s"), | ||
13637 | ctx->filesystem_name); | 13592 | ctx->filesystem_name); |
13638 | fatal_error(ctx, 0); | 13593 | bb_error_msg_and_die(0); |
13639 | } | 13594 | } |
13640 | close(fd); | 13595 | close(fd); |
13641 | } | 13596 | } |
@@ -13703,8 +13658,7 @@ int e2fsck_main (int argc, char *argv[]) | |||
13703 | 13658 | ||
13704 | retval = PRS(argc, argv, &ctx); | 13659 | retval = PRS(argc, argv, &ctx); |
13705 | if (retval) { | 13660 | if (retval) { |
13706 | com_err("e2fsck", retval, | 13661 | bb_error_msg(_("while trying to initialize program")); |
13707 | _("while trying to initialize program")); | ||
13708 | exit(EXIT_ERROR); | 13662 | exit(EXIT_ERROR); |
13709 | } | 13663 | } |
13710 | reserve_stdio_fds(); | 13664 | reserve_stdio_fds(); |
@@ -13725,8 +13679,7 @@ int e2fsck_main (int argc, char *argv[]) | |||
13725 | !(ctx->options & E2F_OPT_NO) && | 13679 | !(ctx->options & E2F_OPT_NO) && |
13726 | !(ctx->options & E2F_OPT_YES)) { | 13680 | !(ctx->options & E2F_OPT_YES)) { |
13727 | if (!ctx->interactive) | 13681 | if (!ctx->interactive) |
13728 | fatal_error(ctx, | 13682 | bb_error_msg_and_die(_("need terminal for interactive repairs")); |
13729 | _("need terminal for interactive repairs")); | ||
13730 | } | 13683 | } |
13731 | ctx->superblock = ctx->use_superblock; | 13684 | ctx->superblock = ctx->use_superblock; |
13732 | restart: | 13685 | restart: |
@@ -13773,7 +13726,7 @@ restart: | |||
13773 | } | 13726 | } |
13774 | } | 13727 | } |
13775 | if (retval) { | 13728 | if (retval) { |
13776 | com_err(ctx->program_name, retval, _("while trying to open %s"), | 13729 | bb_error_msg(_("while trying to open %s"), |
13777 | ctx->filesystem_name); | 13730 | ctx->filesystem_name); |
13778 | if (retval == EXT2_ET_REV_TOO_HIGH) { | 13731 | if (retval == EXT2_ET_REV_TOO_HIGH) { |
13779 | printf(_("The filesystem revision is apparently " | 13732 | printf(_("The filesystem revision is apparently " |
@@ -13798,17 +13751,16 @@ restart: | |||
13798 | #endif | 13751 | #endif |
13799 | else | 13752 | else |
13800 | fix_problem(ctx, PR_0_SB_CORRUPT, &pctx); | 13753 | fix_problem(ctx, PR_0_SB_CORRUPT, &pctx); |
13801 | fatal_error(ctx, 0); | 13754 | bb_error_msg_and_die(0); |
13802 | } | 13755 | } |
13803 | ctx->fs = fs; | 13756 | ctx->fs = fs; |
13804 | fs->priv_data = ctx; | 13757 | fs->priv_data = ctx; |
13805 | sb = fs->super; | 13758 | sb = fs->super; |
13806 | if (sb->s_rev_level > E2FSCK_CURRENT_REV) { | 13759 | if (sb->s_rev_level > E2FSCK_CURRENT_REV) { |
13807 | com_err(ctx->program_name, EXT2_ET_REV_TOO_HIGH, | 13760 | bb_error_msg(_("while trying to open %s"), |
13808 | _("while trying to open %s"), | ||
13809 | ctx->filesystem_name); | 13761 | ctx->filesystem_name); |
13810 | get_newer: | 13762 | get_newer: |
13811 | fatal_error(ctx, _("Get a newer version of e2fsck!")); | 13763 | bb_error_msg_and_die(_("Get a newer version of e2fsck!")); |
13812 | } | 13764 | } |
13813 | 13765 | ||
13814 | /* | 13766 | /* |
@@ -13828,10 +13780,9 @@ restart: | |||
13828 | */ | 13780 | */ |
13829 | retval = e2fsck_check_ext3_journal(ctx); | 13781 | retval = e2fsck_check_ext3_journal(ctx); |
13830 | if (retval) { | 13782 | if (retval) { |
13831 | com_err(ctx->program_name, retval, | 13783 | bb_error_msg(_("while checking ext3 journal for %s"), |
13832 | _("while checking ext3 journal for %s"), | ||
13833 | ctx->device_name); | 13784 | ctx->device_name); |
13834 | fatal_error(ctx, 0); | 13785 | bb_error_msg_and_die(0); |
13835 | } | 13786 | } |
13836 | 13787 | ||
13837 | /* | 13788 | /* |
@@ -13852,16 +13803,14 @@ restart: | |||
13852 | * happen, unless the hardware or | 13803 | * happen, unless the hardware or |
13853 | * device driver is being bogus. | 13804 | * device driver is being bogus. |
13854 | */ | 13805 | */ |
13855 | com_err(ctx->program_name, 0, | 13806 | bb_error_msg(_("unable to set superblock flags on %s\n"), ctx->device_name); |
13856 | _("unable to set superblock flags on %s\n"), ctx->device_name); | 13807 | bb_error_msg_and_die(0); |
13857 | fatal_error(ctx, 0); | ||
13858 | } | 13808 | } |
13859 | retval = e2fsck_run_ext3_journal(ctx); | 13809 | retval = e2fsck_run_ext3_journal(ctx); |
13860 | if (retval) { | 13810 | if (retval) { |
13861 | com_err(ctx->program_name, retval, | 13811 | bb_error_msg(_("while recovering ext3 journal of %s"), |
13862 | _("while recovering ext3 journal of %s"), | ||
13863 | ctx->device_name); | 13812 | ctx->device_name); |
13864 | fatal_error(ctx, 0); | 13813 | bb_error_msg_and_die(0); |
13865 | } | 13814 | } |
13866 | ext2fs_close(ctx->fs); | 13815 | ext2fs_close(ctx->fs); |
13867 | ctx->fs = 0; | 13816 | ctx->fs = 0; |
@@ -13876,25 +13825,21 @@ restart: | |||
13876 | */ | 13825 | */ |
13877 | if ((sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) || | 13826 | if ((sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) || |
13878 | (sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) { | 13827 | (sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) { |
13879 | com_err(ctx->program_name, EXT2_ET_UNSUPP_FEATURE, | 13828 | bb_error_msg("(%s)", ctx->device_name); |
13880 | "(%s)", ctx->device_name); | ||
13881 | goto get_newer; | 13829 | goto get_newer; |
13882 | } | 13830 | } |
13883 | if (sb->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) { | 13831 | if (sb->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) { |
13884 | com_err(ctx->program_name, EXT2_ET_RO_UNSUPP_FEATURE, | 13832 | bb_error_msg("(%s)", ctx->device_name); |
13885 | "(%s)", ctx->device_name); | ||
13886 | goto get_newer; | 13833 | goto get_newer; |
13887 | } | 13834 | } |
13888 | #ifdef ENABLE_COMPRESSION | 13835 | #ifdef ENABLE_COMPRESSION |
13889 | /* FIXME - do we support this at all? */ | 13836 | /* FIXME - do we support this at all? */ |
13890 | if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION) | 13837 | if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION) |
13891 | com_err(ctx->program_name, 0, | 13838 | bb_error_msg(_("Warning: compression support is experimental.\n")); |
13892 | _("Warning: compression support is experimental.\n")); | ||
13893 | #endif | 13839 | #endif |
13894 | #ifndef ENABLE_HTREE | 13840 | #ifndef ENABLE_HTREE |
13895 | if (sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) { | 13841 | if (sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) { |
13896 | com_err(ctx->program_name, 0, | 13842 | bb_error_msg(_("E2fsck not compiled with HTREE support,\n\t" |
13897 | _("E2fsck not compiled with HTREE support,\n\t" | ||
13898 | "but filesystem %s has HTREE directories.\n"), | 13843 | "but filesystem %s has HTREE directories.\n"), |
13899 | ctx->device_name); | 13844 | ctx->device_name); |
13900 | goto get_newer; | 13845 | goto get_newer; |
@@ -13926,14 +13871,14 @@ restart: | |||
13926 | ext2fs_mark_valid(fs); | 13871 | ext2fs_mark_valid(fs); |
13927 | check_super_block(ctx); | 13872 | check_super_block(ctx); |
13928 | if (ctx->flags & E2F_FLAG_SIGNAL_MASK) | 13873 | if (ctx->flags & E2F_FLAG_SIGNAL_MASK) |
13929 | fatal_error(ctx, 0); | 13874 | bb_error_msg_and_die(0); |
13930 | check_if_skip(ctx); | 13875 | check_if_skip(ctx); |
13931 | if (bad_blocks_file) | 13876 | if (bad_blocks_file) |
13932 | read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks); | 13877 | read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks); |
13933 | else if (cflag) | 13878 | else if (cflag) |
13934 | read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */ | 13879 | read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */ |
13935 | if (ctx->flags & E2F_FLAG_SIGNAL_MASK) | 13880 | if (ctx->flags & E2F_FLAG_SIGNAL_MASK) |
13936 | fatal_error(ctx, 0); | 13881 | bb_error_msg_and_die(0); |
13937 | #ifdef ENABLE_SWAPFS | 13882 | #ifdef ENABLE_SWAPFS |
13938 | 13883 | ||
13939 | #ifdef WORDS_BIGENDIAN | 13884 | #ifdef WORDS_BIGENDIAN |
@@ -13947,13 +13892,13 @@ restart: | |||
13947 | if ((fs->flags & EXT2_FLAG_SWAP_BYTES) == NATIVE_FLAG) { | 13892 | if ((fs->flags & EXT2_FLAG_SWAP_BYTES) == NATIVE_FLAG) { |
13948 | fprintf(stderr, _("%s: Filesystem byte order " | 13893 | fprintf(stderr, _("%s: Filesystem byte order " |
13949 | "already normalized.\n"), ctx->device_name); | 13894 | "already normalized.\n"), ctx->device_name); |
13950 | fatal_error(ctx, 0); | 13895 | bb_error_msg_and_die(0); |
13951 | } | 13896 | } |
13952 | } | 13897 | } |
13953 | if (swapfs) { | 13898 | if (swapfs) { |
13954 | swap_filesys(ctx); | 13899 | swap_filesys(ctx); |
13955 | if (ctx->flags & E2F_FLAG_SIGNAL_MASK) | 13900 | if (ctx->flags & E2F_FLAG_SIGNAL_MASK) |
13956 | fatal_error(ctx, 0); | 13901 | bb_error_msg_and_die(0); |
13957 | } | 13902 | } |
13958 | #endif | 13903 | #endif |
13959 | 13904 | ||
@@ -13964,8 +13909,7 @@ restart: | |||
13964 | 13909 | ||
13965 | retval = ext2fs_read_bb_inode(fs, &fs->badblocks); | 13910 | retval = ext2fs_read_bb_inode(fs, &fs->badblocks); |
13966 | if (retval) { | 13911 | if (retval) { |
13967 | com_err(ctx->program_name, retval, | 13912 | bb_error_msg(_("while reading bad blocks inode")); |
13968 | _("while reading bad blocks inode")); | ||
13969 | preenhalt(ctx); | 13913 | preenhalt(ctx); |
13970 | printf(_("This doesn't bode well," | 13914 | printf(_("This doesn't bode well," |
13971 | " but we'll try to go on...\n")); | 13915 | " but we'll try to go on...\n")); |
@@ -13977,9 +13921,8 @@ restart: | |||
13977 | printf(_("Restarting e2fsck from the beginning...\n")); | 13921 | printf(_("Restarting e2fsck from the beginning...\n")); |
13978 | retval = e2fsck_reset_context(ctx); | 13922 | retval = e2fsck_reset_context(ctx); |
13979 | if (retval) { | 13923 | if (retval) { |
13980 | com_err(ctx->program_name, retval, | 13924 | bb_error_msg(_("while resetting context")); |
13981 | _("while resetting context")); | 13925 | bb_error_msg_and_die(0); |
13982 | fatal_error(ctx, 0); | ||
13983 | } | 13926 | } |
13984 | ext2fs_close(fs); | 13927 | ext2fs_close(fs); |
13985 | goto restart; | 13928 | goto restart; |
@@ -13990,7 +13933,7 @@ restart: | |||
13990 | exit_value |= FSCK_CANCELED; | 13933 | exit_value |= FSCK_CANCELED; |
13991 | } | 13934 | } |
13992 | if (run_result & E2F_FLAG_ABORT) | 13935 | if (run_result & E2F_FLAG_ABORT) |
13993 | fatal_error(ctx, _("aborted")); | 13936 | bb_error_msg_and_die(_("aborted")); |
13994 | 13937 | ||
13995 | /* Cleanup */ | 13938 | /* Cleanup */ |
13996 | if (ext2fs_test_changed(fs)) { | 13939 | if (ext2fs_test_changed(fs)) { |