aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-05-03 21:58:45 +0000
committerRob Landley <rob@landley.net>2006-05-03 21:58:45 +0000
commit7c94bed2345008b4b62014a846488319a7af0727 (patch)
tree4345ba7255410654b6c8c4d7f51122643f6d9584
parentdb2ab89b7c66c97e7a849a4a25baca10de4576dc (diff)
downloadbusybox-w32-7c94bed2345008b4b62014a846488319a7af0727.tar.gz
busybox-w32-7c94bed2345008b4b62014a846488319a7af0727.tar.bz2
busybox-w32-7c94bed2345008b4b62014a846488319a7af0727.zip
Big dead code elimination pass from Garrett.
-rw-r--r--e2fsprogs/e2fsbb.h19
-rw-r--r--e2fsprogs/e2fsck.c243
-rw-r--r--e2fsprogs/e2fsck.h15
-rw-r--r--e2fsprogs/ext2fs/bitops.c9
-rw-r--r--e2fsprogs/ext2fs/bmap.c20
-rw-r--r--e2fsprogs/ext2fs/bmove.c2
-rw-r--r--e2fsprogs/ext2fs/closefs.c10
-rw-r--r--e2fsprogs/ext2fs/dblist.c6
-rw-r--r--e2fsprogs/ext2fs/dirblock.c8
-rw-r--r--e2fsprogs/ext2fs/ext2_ext_attr.h17
-rw-r--r--e2fsprogs/ext2fs/ext2_fs.h75
-rw-r--r--e2fsprogs/ext2fs/ext2fs.h37
-rw-r--r--e2fsprogs/ext2fs/ext2fs_inline.c64
-rw-r--r--e2fsprogs/ext2fs/ext_attr.c7
-rw-r--r--e2fsprogs/ext2fs/ind_block.c8
-rw-r--r--e2fsprogs/ext2fs/inode.c8
-rw-r--r--e2fsprogs/ext2fs/openfs.c6
-rw-r--r--e2fsprogs/ext2fs/rw_bitmaps.c2
-rw-r--r--e2fsprogs/ext2fs/swapfs.c4
-rw-r--r--e2fsprogs/ext2fs/unix_io.c2
-rw-r--r--e2fsprogs/fsck.c14
-rw-r--r--e2fsprogs/fsck.h1
-rw-r--r--e2fsprogs/lsattr.c8
-rw-r--r--e2fsprogs/uuid/gen_uuid.c2
24 files changed, 138 insertions, 449 deletions
diff --git a/e2fsprogs/e2fsbb.h b/e2fsprogs/e2fsbb.h
index ddd196644..975e5676c 100644
--- a/e2fsprogs/e2fsbb.h
+++ b/e2fsprogs/e2fsbb.h
@@ -14,44 +14,27 @@
14#define E2FSPROGS_VERSION "1.38" 14#define E2FSPROGS_VERSION "1.38"
15#define E2FSPROGS_DATE "30-Jun-2005" 15#define E2FSPROGS_DATE "30-Jun-2005"
16 16
17/* make sure com_err.h isnt included before us */
18#ifdef __COM_ERR_H__
19#error You should not have included com_err.h !
20#endif
21#define __COM_ERR_H__
22
23/* com_err crap */
24#define com_err(w, c, fmt, args...) bb_error_msg(fmt, ## args)
25typedef long errcode_t; 17typedef long errcode_t;
26#define ERRCODE_RANGE 8 18#define ERRCODE_RANGE 8
27#define error_message(code) strerror((int) (code & ((1<<ERRCODE_RANGE)-1))) 19#define error_message(code) strerror((int) (code & ((1<<ERRCODE_RANGE)-1)))
28 20
29/* misc crap */
30#define fatal_error(err, msg) bb_error_msg_and_die(msg)
31#define usage() bb_show_usage()
32
33/* header defines */ 21/* header defines */
34#define ENABLE_HTREE 1 22#define ENABLE_HTREE 1
35#define HAVE_ERRNO_H 1 23#define HAVE_ERRNO_H 1
36#define HAVE_EXT2_IOCTLS 1 24#define HAVE_EXT2_IOCTLS 1
37#define HAVE_INTTYPES_H 1
38#define HAVE_LINUX_FD_H 1 25#define HAVE_LINUX_FD_H 1
39#define HAVE_MALLOC_H 1
40#define HAVE_MNTENT_H 1 26#define HAVE_MNTENT_H 1
41#define HAVE_NETINET_IN_H 1 27#define HAVE_NETINET_IN_H 1
42#define HAVE_NET_IF_H 1 28#define HAVE_NET_IF_H 1
43#define HAVE_SYS_IOCTL_H 1 29#define HAVE_SYS_IOCTL_H 1
44#define HAVE_SYS_MOUNT_H 1 30#define HAVE_SYS_MOUNT_H 1
45#define HAVE_SYS_QUEUE_H 1 31#define HAVE_SYS_QUEUE_H 1
46#define HAVE_SYS_RESOURCE_H 1
47#define HAVE_SYS_SOCKET_H 1
48#define HAVE_SYS_STAT_H 1 32#define HAVE_SYS_STAT_H 1
49#define HAVE_SYS_TIME_H 1
50#define HAVE_SYS_TYPES_H 1 33#define HAVE_SYS_TYPES_H 1
51#define HAVE_UNISTD_H 1 34#define HAVE_UNISTD_H 1
52 35
53/* Endianness */ 36/* Endianness */
54#if __BYTE_ORDER == __BIG_ENDIAN 37#if BB_BIG_ENDIAN
55#define ENABLE_SWAPFS 1 38#define ENABLE_SWAPFS 1
56#define WORDS_BIGENDIAN 1 39#define WORDS_BIGENDIAN 1
57#endif 40#endif
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
222static _INLINE_ kmem_cache_t * do_cache_create(int len) 215static 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
232static _INLINE_ void do_cache_destroy(kmem_cache_t *cache) 225static 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
395static void dnode_free(dnode_t *node); 381static 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 */
2740static _INLINE_ void expand_dirent_expression(char ch, 2718static 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
2779static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch, 2757static 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);
3036static void mark_inode_bad(e2fsck_t ctx, ino_t ino); 3014static void mark_inode_bad(e2fsck_t ctx, ino_t ino);
3037static void handle_fs_bad_blocks(e2fsck_t ctx); 3015static void handle_fs_bad_blocks(e2fsck_t ctx);
3038static void process_inodes(e2fsck_t ctx, char *block_buf); 3016static void process_inodes(e2fsck_t ctx, char *block_buf);
3039static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b); 3017static int process_inode_cmp(const void *a, const void *b);
3040static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan, 3018static 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);
3042static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount, 3020static 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
3932static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b) 3910static 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 */
4018static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block) 3996static 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,
5827static void clear_htree(e2fsck_t ctx, ext2_ino_t ino); 5802static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
5828static int htree_depth(struct dx_dir_info *dx_dir, 5803static int htree_depth(struct dx_dir_info *dx_dir,
5829 struct dx_dirblock_info *dx_db); 5804 struct dx_dirblock_info *dx_db);
5830static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b); 5805static int special_dir_block_cmp(const void *a, const void *b);
5831 5806
5832struct check_dir_struct { 5807struct 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 */
6060static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b) 6035static 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
6242static _INLINE_ int check_filetype(e2fsck_t ctx, 6217static 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 */
10776static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b) 10751static 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 */
10800static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b) 10775static 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;
13732restart: 13685restart:
@@ -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)) {
diff --git a/e2fsprogs/e2fsck.h b/e2fsprogs/e2fsck.h
index fb6028da9..0957f20a8 100644
--- a/e2fsprogs/e2fsck.h
+++ b/e2fsprogs/e2fsck.h
@@ -27,7 +27,6 @@
27#include <sys/types.h> 27#include <sys/types.h>
28#include <linux/types.h> 28#include <linux/types.h>
29 29
30
31/* 30/*
32 * Now pull in the real linux/jfs.h definitions. 31 * Now pull in the real linux/jfs.h definitions.
33 */ 32 */
@@ -82,8 +81,6 @@ These defines are used in the type field of dx_dirblock_info
82#define DX_DIRBLOCK_ROOT 1 81#define DX_DIRBLOCK_ROOT 1
83#define DX_DIRBLOCK_LEAF 2 82#define DX_DIRBLOCK_LEAF 2
84#define DX_DIRBLOCK_NODE 3 83#define DX_DIRBLOCK_NODE 3
85#define DX_DIRBLOCK_CORRUPT 4
86#define DX_DIRBLOCK_CLEARED 8
87 84
88 85
89/* 86/*
@@ -102,7 +99,6 @@ The following defines are used in the 'flags' field of a dx_dirblock_info
102#define E2F_OPT_YES 0x0004 99#define E2F_OPT_YES 0x0004
103#define E2F_OPT_NO 0x0008 100#define E2F_OPT_NO 0x0008
104#define E2F_OPT_TIME 0x0010 101#define E2F_OPT_TIME 0x0010
105#define E2F_OPT_TIME2 0x0020
106#define E2F_OPT_CHECKBLOCKS 0x0040 102#define E2F_OPT_CHECKBLOCKS 0x0040
107#define E2F_OPT_DEBUG 0x0080 103#define E2F_OPT_DEBUG 0x0080
108#define E2F_OPT_FORCE 0x0100 104#define E2F_OPT_FORCE 0x0100
@@ -127,21 +123,10 @@ The following defines are used in the 'flags' field of a dx_dirblock_info
127#define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */ 123#define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */
128#define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */ 124#define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */
129 125
130/*
131 * Defines for indicating the e2fsck pass number
132 */
133#define E2F_PASS_1 1
134#define E2F_PASS_2 2
135#define E2F_PASS_3 3
136#define E2F_PASS_4 4
137#define E2F_PASS_5 5
138#define E2F_PASS_1B 6
139 126
140/*Don't know where these come from*/ 127/*Don't know where these come from*/
141#define READ 0 128#define READ 0
142#define WRITE 1 129#define WRITE 1
143#define KERN_ERR ""
144#define KERN_DEBUG ""
145#define cpu_to_be32(n) htonl(n) 130#define cpu_to_be32(n) htonl(n)
146#define be32_to_cpu(n) ntohl(n) 131#define be32_to_cpu(n) ntohl(n)
147 132
diff --git a/e2fsprogs/ext2fs/bitops.c b/e2fsprogs/ext2fs/bitops.c
index 77ac2a61f..44c08ad9f 100644
--- a/e2fsprogs/ext2fs/bitops.c
+++ b/e2fsprogs/ext2fs/bitops.c
@@ -71,9 +71,9 @@ void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
71{ 71{
72#ifndef OMIT_COM_ERR 72#ifndef OMIT_COM_ERR
73 if (description) 73 if (description)
74 com_err(0, errcode, "#%lu for %s", arg, description); 74 bb_error_msg("#%lu for %s", arg, description);
75 else 75 else
76 com_err(0, errcode, "#%lu", arg); 76 bb_error_msg("#%lu", arg);
77#endif 77#endif
78} 78}
79 79
@@ -82,10 +82,9 @@ void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
82{ 82{
83#ifndef OMIT_COM_ERR 83#ifndef OMIT_COM_ERR
84 if (bitmap->description) 84 if (bitmap->description)
85 com_err(0, bitmap->base_error_code+code, 85 bb_error_msg("#%lu for %s", arg, bitmap->description);
86 "#%lu for %s", arg, bitmap->description);
87 else 86 else
88 com_err(0, bitmap->base_error_code + code, "#%lu", arg); 87 bb_error_msg("#%lu", arg);
89#endif 88#endif
90} 89}
91 90
diff --git a/e2fsprogs/ext2fs/bmap.c b/e2fsprogs/ext2fs/bmap.c
index 4a53ebc4c..0015ba288 100644
--- a/e2fsprogs/ext2fs/bmap.c
+++ b/e2fsprogs/ext2fs/bmap.c
@@ -18,12 +18,6 @@
18#include "ext2_fs.h" 18#include "ext2_fs.h"
19#include "ext2fs.h" 19#include "ext2fs.h"
20 20
21#if defined(__GNUC__) && !defined(NO_INLINE_FUNCS)
22#define _BMAP_INLINE_ __inline__
23#else
24#define _BMAP_INLINE_
25#endif
26
27extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, 21extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
28 struct ext2_inode *inode, 22 struct ext2_inode *inode,
29 char *block_buf, int bmap_flags, 23 char *block_buf, int bmap_flags,
@@ -31,7 +25,7 @@ extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
31 25
32#define inode_bmap(inode, nr) ((inode)->i_block[(nr)]) 26#define inode_bmap(inode, nr) ((inode)->i_block[(nr)])
33 27
34static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, 28static errcode_t block_ind_bmap(ext2_filsys fs, int flags,
35 blk_t ind, char *block_buf, 29 blk_t ind, char *block_buf,
36 int *blocks_alloc, 30 int *blocks_alloc,
37 blk_t nr, blk_t *ret_blk) 31 blk_t nr, blk_t *ret_blk)
@@ -51,7 +45,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
51 45
52 if (flags & BMAP_SET) { 46 if (flags & BMAP_SET) {
53 b = *ret_blk; 47 b = *ret_blk;
54#ifdef EXT2FS_ENABLE_SWAPFS 48#if BB_BIG_ENDIAN
55 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || 49 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
56 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) 50 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
57 b = ext2fs_swab32(b); 51 b = ext2fs_swab32(b);
@@ -62,7 +56,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
62 56
63 b = ((blk_t *) block_buf)[nr]; 57 b = ((blk_t *) block_buf)[nr];
64 58
65#ifdef EXT2FS_ENABLE_SWAPFS 59#if BB_BIG_ENDIAN
66 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || 60 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
67 (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) 61 (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
68 b = ext2fs_swab32(b); 62 b = ext2fs_swab32(b);
@@ -75,7 +69,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
75 if (retval) 69 if (retval)
76 return retval; 70 return retval;
77 71
78#ifdef EXT2FS_ENABLE_SWAPFS 72#if BB_BIG_ENDIAN
79 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || 73 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
80 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) 74 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
81 ((blk_t *) block_buf)[nr] = ext2fs_swab32(b); 75 ((blk_t *) block_buf)[nr] = ext2fs_swab32(b);
@@ -94,7 +88,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
94 return 0; 88 return 0;
95} 89}
96 90
97static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags, 91static errcode_t block_dind_bmap(ext2_filsys fs, int flags,
98 blk_t dind, char *block_buf, 92 blk_t dind, char *block_buf,
99 int *blocks_alloc, 93 int *blocks_alloc,
100 blk_t nr, blk_t *ret_blk) 94 blk_t nr, blk_t *ret_blk)
@@ -114,7 +108,7 @@ static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags,
114 return retval; 108 return retval;
115} 109}
116 110
117static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags, 111static errcode_t block_tind_bmap(ext2_filsys fs, int flags,
118 blk_t tind, char *block_buf, 112 blk_t tind, char *block_buf,
119 int *blocks_alloc, 113 int *blocks_alloc,
120 blk_t nr, blk_t *ret_blk) 114 blk_t nr, blk_t *ret_blk)
@@ -167,7 +161,7 @@ errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
167 if (block < EXT2_NDIR_BLOCKS) { 161 if (block < EXT2_NDIR_BLOCKS) {
168 if (bmap_flags & BMAP_SET) { 162 if (bmap_flags & BMAP_SET) {
169 b = *phys_blk; 163 b = *phys_blk;
170#ifdef EXT2FS_ENABLE_SWAPFS 164#if BB_BIG_ENDIAN
171 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || 165 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
172 (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) 166 (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
173 b = ext2fs_swab32(b); 167 b = ext2fs_swab32(b);
diff --git a/e2fsprogs/ext2fs/bmove.c b/e2fsprogs/ext2fs/bmove.c
index 7e98c0fe5..afc271022 100644
--- a/e2fsprogs/ext2fs/bmove.c
+++ b/e2fsprogs/ext2fs/bmove.c
@@ -14,9 +14,7 @@
14#if HAVE_SYS_TYPES_H 14#if HAVE_SYS_TYPES_H
15#include <sys/types.h> 15#include <sys/types.h>
16#endif 16#endif
17#if HAVE_SYS_TIME_H
18#include <sys/time.h> 17#include <sys/time.h>
19#endif
20 18
21#include "ext2_fs.h" 19#include "ext2_fs.h"
22#include "ext2fsP.h" 20#include "ext2fsP.h"
diff --git a/e2fsprogs/ext2fs/closefs.c b/e2fsprogs/ext2fs/closefs.c
index da0016b0e..481d1c575 100644
--- a/e2fsprogs/ext2fs/closefs.c
+++ b/e2fsprogs/ext2fs/closefs.c
@@ -191,7 +191,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
191 191
192 if (sgrp > ((1 << 16) - 1)) 192 if (sgrp > ((1 << 16) - 1))
193 sgrp = (1 << 16) - 1; 193 sgrp = (1 << 16) - 1;
194#ifdef EXT2FS_ENABLE_SWAPFS 194#if BB_BIG_ENDIAN
195 if (fs->flags & EXT2_FLAG_SWAP_BYTES) 195 if (fs->flags & EXT2_FLAG_SWAP_BYTES)
196 super_shadow->s_block_group_nr = ext2fs_swab16(sgrp); 196 super_shadow->s_block_group_nr = ext2fs_swab16(sgrp);
197 else 197 else
@@ -213,7 +213,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
213 struct ext2_group_desc *group_shadow = 0; 213 struct ext2_group_desc *group_shadow = 0;
214 char *group_ptr; 214 char *group_ptr;
215 int old_desc_blocks; 215 int old_desc_blocks;
216#ifdef EXT2FS_ENABLE_SWAPFS 216#if BB_BIG_ENDIAN
217 dgrp_t j; 217 dgrp_t j;
218 struct ext2_group_desc *s, *t; 218 struct ext2_group_desc *s, *t;
219#endif 219#endif
@@ -224,7 +224,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
224 224
225 fs->super->s_wtime = time(NULL); 225 fs->super->s_wtime = time(NULL);
226 fs->super->s_block_group_nr = 0; 226 fs->super->s_block_group_nr = 0;
227#ifdef EXT2FS_ENABLE_SWAPFS 227#if BB_BIG_ENDIAN
228 if (fs->flags & EXT2_FLAG_SWAP_BYTES) { 228 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
229 retval = EXT2_ET_NO_MEMORY; 229 retval = EXT2_ET_NO_MEMORY;
230 retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow); 230 retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow);
@@ -267,7 +267,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
267 * we write out the backup superblocks.) 267 * we write out the backup superblocks.)
268 */ 268 */
269 fs->super->s_state &= ~EXT2_VALID_FS; 269 fs->super->s_state &= ~EXT2_VALID_FS;
270#ifdef EXT2FS_ENABLE_SWAPFS 270#if BB_BIG_ENDIAN
271 if (fs->flags & EXT2_FLAG_SWAP_BYTES) { 271 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
272 *super_shadow = *fs->super; 272 *super_shadow = *fs->super;
273 ext2fs_swap_super(super_shadow); 273 ext2fs_swap_super(super_shadow);
@@ -316,7 +316,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
316 } 316 }
317 fs->super->s_block_group_nr = 0; 317 fs->super->s_block_group_nr = 0;
318 fs->super->s_state = fs_state; 318 fs->super->s_state = fs_state;
319#ifdef EXT2FS_ENABLE_SWAPFS 319#if BB_BIG_ENDIAN
320 if (fs->flags & EXT2_FLAG_SWAP_BYTES) { 320 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
321 *super_shadow = *fs->super; 321 *super_shadow = *fs->super;
322 ext2fs_swap_super(super_shadow); 322 ext2fs_swap_super(super_shadow);
diff --git a/e2fsprogs/ext2fs/dblist.c b/e2fsprogs/ext2fs/dblist.c
index 73313faf3..aaac3b394 100644
--- a/e2fsprogs/ext2fs/dblist.c
+++ b/e2fsprogs/ext2fs/dblist.c
@@ -20,7 +20,7 @@
20#include "ext2_fs.h" 20#include "ext2_fs.h"
21#include "ext2fsP.h" 21#include "ext2fsP.h"
22 22
23static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b); 23static int dir_block_cmp(const void *a, const void *b);
24 24
25/* 25/*
26 * Returns the number of directories in the filesystem as reported by 26 * Returns the number of directories in the filesystem as reported by
@@ -203,7 +203,7 @@ errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
203} 203}
204 204
205void ext2fs_dblist_sort(ext2_dblist dblist, 205void ext2fs_dblist_sort(ext2_dblist dblist,
206 EXT2_QSORT_TYPE (*sortfunc)(const void *, 206 int (*sortfunc)(const void *,
207 const void *)) 207 const void *))
208{ 208{
209 if (!sortfunc) 209 if (!sortfunc)
@@ -237,7 +237,7 @@ errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
237 return 0; 237 return 0;
238} 238}
239 239
240static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b) 240static int dir_block_cmp(const void *a, const void *b)
241{ 241{
242 const struct ext2_db_entry *db_a = 242 const struct ext2_db_entry *db_a =
243 (const struct ext2_db_entry *) a; 243 (const struct ext2_db_entry *) a;
diff --git a/e2fsprogs/ext2fs/dirblock.c b/e2fsprogs/ext2fs/dirblock.c
index 9f82b5002..4f2bbc11f 100644
--- a/e2fsprogs/ext2fs/dirblock.c
+++ b/e2fsprogs/ext2fs/dirblock.c
@@ -26,14 +26,14 @@ errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
26 char *p, *end; 26 char *p, *end;
27 struct ext2_dir_entry *dirent; 27 struct ext2_dir_entry *dirent;
28 unsigned int name_len, rec_len; 28 unsigned int name_len, rec_len;
29#ifdef EXT2FS_ENABLE_SWAPFS 29#if BB_BIG_ENDIAN
30 unsigned int do_swap; 30 unsigned int do_swap;
31#endif 31#endif
32 32
33 retval = io_channel_read_blk(fs->io, block, 1, buf); 33 retval = io_channel_read_blk(fs->io, block, 1, buf);
34 if (retval) 34 if (retval)
35 return retval; 35 return retval;
36#ifdef EXT2FS_ENABLE_SWAPFS 36#if BB_BIG_ENDIAN
37 do_swap = (fs->flags & (EXT2_FLAG_SWAP_BYTES| 37 do_swap = (fs->flags & (EXT2_FLAG_SWAP_BYTES|
38 EXT2_FLAG_SWAP_BYTES_READ)) != 0; 38 EXT2_FLAG_SWAP_BYTES_READ)) != 0;
39#endif 39#endif
@@ -41,7 +41,7 @@ errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
41 end = (char *) buf + fs->blocksize; 41 end = (char *) buf + fs->blocksize;
42 while (p < end-8) { 42 while (p < end-8) {
43 dirent = (struct ext2_dir_entry *) p; 43 dirent = (struct ext2_dir_entry *) p;
44#ifdef EXT2FS_ENABLE_SWAPFS 44#if BB_BIG_ENDIAN
45 if (do_swap) { 45 if (do_swap) {
46 dirent->inode = ext2fs_swab32(dirent->inode); 46 dirent->inode = ext2fs_swab32(dirent->inode);
47 dirent->rec_len = ext2fs_swab16(dirent->rec_len); 47 dirent->rec_len = ext2fs_swab16(dirent->rec_len);
@@ -75,7 +75,7 @@ errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
75errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block, 75errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
76 void *inbuf, int flags EXT2FS_ATTR((unused))) 76 void *inbuf, int flags EXT2FS_ATTR((unused)))
77{ 77{
78#ifdef EXT2FS_ENABLE_SWAPFS 78#if BB_BIG_ENDIAN
79 int do_swap = 0; 79 int do_swap = 0;
80 errcode_t retval; 80 errcode_t retval;
81 char *p, *end; 81 char *p, *end;
diff --git a/e2fsprogs/ext2fs/ext2_ext_attr.h b/e2fsprogs/ext2fs/ext2_ext_attr.h
index 23444c508..79f23ee9a 100644
--- a/e2fsprogs/ext2fs/ext2_ext_attr.h
+++ b/e2fsprogs/ext2fs/ext2_ext_attr.h
@@ -28,9 +28,6 @@ struct ext2_ext_attr_entry {
28 __u32 e_value_block; /* disk block attribute is stored on (n/i) */ 28 __u32 e_value_block; /* disk block attribute is stored on (n/i) */
29 __u32 e_value_size; /* size of attribute value */ 29 __u32 e_value_size; /* size of attribute value */
30 __u32 e_hash; /* hash value of name and value */ 30 __u32 e_hash; /* hash value of name and value */
31#if 0
32 char e_name[0]; /* attribute name */
33#endif
34}; 31};
35 32
36#define EXT2_EXT_ATTR_PAD_BITS 2 33#define EXT2_EXT_ATTR_PAD_BITS 2
@@ -53,17 +50,3 @@ struct ext2_ext_attr_entry {
53#define EXT2_XATTR_SIZE(size) \ 50#define EXT2_XATTR_SIZE(size) \
54 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND) 51 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
55 52
56#ifdef __KERNEL__
57# ifdef CONFIG_EXT2_FS_EXT_ATTR
58extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
59extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
60extern void ext2_ext_attr_free_inode(struct inode *inode);
61extern void ext2_ext_attr_put_super(struct super_block *sb);
62extern int ext2_ext_attr_init(void);
63extern void ext2_ext_attr_done(void);
64# else
65# define ext2_get_ext_attr NULL
66# define ext2_set_ext_attr NULL
67# endif
68#endif /* __KERNEL__ */
69
diff --git a/e2fsprogs/ext2fs/ext2_fs.h b/e2fsprogs/ext2fs/ext2_fs.h
index 400587324..44b04beb7 100644
--- a/e2fsprogs/ext2fs/ext2_fs.h
+++ b/e2fsprogs/ext2fs/ext2_fs.h
@@ -19,27 +19,6 @@
19#include "ext2_types.h" /* Changed from linux/types.h */ 19#include "ext2_types.h" /* Changed from linux/types.h */
20 20
21/* 21/*
22 * The second extended filesystem constants/structures
23 */
24
25/*
26 * Define EXT2FS_DEBUG to produce debug messages
27 */
28#undef EXT2FS_DEBUG
29
30/*
31 * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
32 */
33#define EXT2_PREALLOCATE
34#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
35
36/*
37 * The second extended file system version
38 */
39#define EXT2FS_DATE "95/08/09"
40#define EXT2FS_VERSION "0.5b"
41
42/*
43 * Special inode numbers 22 * Special inode numbers
44 */ 23 */
45#define EXT2_BAD_INO 1 /* Bad blocks inode */ 24#define EXT2_BAD_INO 1 /* Bad blocks inode */
@@ -59,14 +38,10 @@
59 */ 38 */
60#define EXT2_SUPER_MAGIC 0xEF53 39#define EXT2_SUPER_MAGIC 0xEF53
61 40
62#ifdef __KERNEL__
63#define EXT2_SB(sb) (&((sb)->u.ext2_sb))
64#else
65/* Assume that user mode programs are passing in an ext2fs superblock, not 41/* Assume that user mode programs are passing in an ext2fs superblock, not
66 * a kernel struct super_block. This will allow us to call the feature-test 42 * a kernel struct super_block. This will allow us to call the feature-test
67 * macros from user land. */ 43 * macros from user land. */
68#define EXT2_SB(sb) (sb) 44#define EXT2_SB(sb) (sb)
69#endif
70 45
71/* 46/*
72 * Maximal count of links to a file 47 * Maximal count of links to a file
@@ -80,20 +55,12 @@
80#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */ 55#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
81#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE) 56#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
82#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE) 57#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
83#ifdef __KERNEL__
84#define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
85#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
86#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->addr_per_block_bits)
87#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size)
88#define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino)
89#else
90#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) 58#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
91#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) 59#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
92#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ 60#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
93 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size) 61 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
94#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ 62#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
95 EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino) 63 EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
96#endif
97#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32)) 64#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32))
98 65
99/* 66/*
@@ -102,13 +69,8 @@
102#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE 69#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
103#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE 70#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
104#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE 71#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
105#ifdef __KERNEL__
106# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size)
107# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block)
108#else
109# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) 72# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
110# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) 73# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
111#endif
112 74
113/* 75/*
114 * ACL structures 76 * ACL structures
@@ -193,12 +155,7 @@ struct ext2_dx_countlimit {
193/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */ 155/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
194#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8) 156#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
195#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s)) 157#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
196#ifdef __KERNEL__
197#define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
198#define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
199#else
200#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) 158#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
201#endif
202 159
203/* 160/*
204 * Constants relative to the data blocks 161 * Constants relative to the data blocks
@@ -365,38 +322,6 @@ struct ext2_inode_large {
365 322
366#define i_size_high i_dir_acl 323#define i_size_high i_dir_acl
367 324
368#if defined(__KERNEL__) || defined(__linux__)
369#define i_reserved1 osd1.linux1.l_i_reserved1
370#define i_frag osd2.linux2.l_i_frag
371#define i_fsize osd2.linux2.l_i_fsize
372#define i_uid_low i_uid
373#define i_gid_low i_gid
374#define i_uid_high osd2.linux2.l_i_uid_high
375#define i_gid_high osd2.linux2.l_i_gid_high
376#define i_reserved2 osd2.linux2.l_i_reserved2
377
378#else
379#if defined(__GNU__)
380
381#define i_translator osd1.hurd1.h_i_translator
382#define i_frag osd2.hurd2.h_i_frag;
383#define i_fsize osd2.hurd2.h_i_fsize;
384#define i_uid_high osd2.hurd2.h_i_uid_high
385#define i_gid_high osd2.hurd2.h_i_gid_high
386#define i_author osd2.hurd2.h_i_author
387
388#else
389#if defined(__masix__)
390
391#define i_reserved1 osd1.masix1.m_i_reserved1
392#define i_frag osd2.masix2.m_i_frag
393#define i_fsize osd2.masix2.m_i_fsize
394#define i_reserved2 osd2.masix2.m_i_reserved2
395
396#endif /* __masix__ */
397#endif /* __GNU__ */
398#endif /* defined(__KERNEL__) || defined(__linux__) */
399
400/* 325/*
401 * File system states 326 * File system states
402 */ 327 */
diff --git a/e2fsprogs/ext2fs/ext2fs.h b/e2fsprogs/ext2fs/ext2fs.h
index b8752a56e..76d2ddd45 100644
--- a/e2fsprogs/ext2fs/ext2fs.h
+++ b/e2fsprogs/ext2fs/ext2fs.h
@@ -12,33 +12,14 @@
12#ifndef _EXT2FS_EXT2FS_H 12#ifndef _EXT2FS_EXT2FS_H
13#define _EXT2FS_EXT2FS_H 13#define _EXT2FS_EXT2FS_H
14 14
15#ifdef __GNUC__ 15
16#define EXT2FS_ATTR(x) __attribute__(x)
17#else
18#define EXT2FS_ATTR(x) 16#define EXT2FS_ATTR(x)
19#endif
20 17
21#ifdef __cplusplus 18#ifdef __cplusplus
22extern "C" { 19extern "C" {
23#endif 20#endif
24 21
25/* 22/*
26 * Non-GNU C compilers won't necessarily understand inline
27 */
28#if (!defined(__GNUC__) && !defined(__WATCOMC__))
29#define NO_INLINE_FUNCS
30#endif
31
32/*
33 * Build in support for byte-swapping filesystems if we the feature
34 * has been configured or if we're being built on a CPU architecture
35 * with a non-native byte order.
36 */
37#if defined(ENABLE_SWAPFS) || defined(WORDS_BIGENDIAN) || __BYTE_ORDER== __BIG_ENDIAN
38#define EXT2FS_ENABLE_SWAPFS
39#endif
40
41/*
42 * Where the master copy of the superblock is located, and how big 23 * Where the master copy of the superblock is located, and how big
43 * superblocks are supposed to be. We define SUPERBLOCK_SIZE because 24 * superblocks are supposed to be. We define SUPERBLOCK_SIZE because
44 * the size of the superblock structure is not necessarily trustworthy 25 * the size of the superblock structure is not necessarily trustworthy
@@ -74,15 +55,6 @@ typedef __u32 ext2_dirhash_t;
74#include "ext2_io.h" 55#include "ext2_io.h"
75#include "ext2_err.h" 56#include "ext2_err.h"
76 57
77/*
78 * Portability help for Microsoft Visual C++
79 */
80#ifdef _MSC_VER
81#define EXT2_QSORT_TYPE int __cdecl
82#else
83#define EXT2_QSORT_TYPE int
84#endif
85
86typedef struct struct_ext2_filsys *ext2_filsys; 58typedef struct struct_ext2_filsys *ext2_filsys;
87 59
88struct ext2fs_struct_generic_bitmap { 60struct ext2fs_struct_generic_bitmap {
@@ -104,12 +76,7 @@ typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
104typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap; 76typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
105typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap; 77typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
106 78
107#ifdef EXT2_DYNAMIC_REV
108#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s) 79#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
109#else
110#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO
111#define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode)
112#endif
113 80
114/* 81/*
115 * badblocks list definitions 82 * badblocks list definitions
@@ -609,7 +576,7 @@ extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
609extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, 576extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino,
610 blk_t blk, int blockcnt); 577 blk_t blk, int blockcnt);
611extern void ext2fs_dblist_sort(ext2_dblist dblist, 578extern void ext2fs_dblist_sort(ext2_dblist dblist,
612 EXT2_QSORT_TYPE (*sortfunc)(const void *, 579 int (*sortfunc)(const void *,
613 const void *)); 580 const void *));
614extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, 581extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
615 int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info, 582 int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info,
diff --git a/e2fsprogs/ext2fs/ext2fs_inline.c b/e2fsprogs/ext2fs/ext2fs_inline.c
index 1202b3526..07805b10d 100644
--- a/e2fsprogs/ext2fs/ext2fs_inline.c
+++ b/e2fsprogs/ext2fs/ext2fs_inline.c
@@ -238,78 +238,36 @@ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
238void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap, 238void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
239 blk_t block) 239 blk_t block)
240{ 240{
241#ifdef EXT2FS_DEBUG_FAST_OPS
242 if ((block < bitmap->start) || (block > bitmap->end)) {
243 ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
244 bitmap->description);
245 return;
246 }
247#endif
248 ext2fs_set_bit(block - bitmap->start, bitmap->bitmap); 241 ext2fs_set_bit(block - bitmap->start, bitmap->bitmap);
249} 242}
250 243
251void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap, 244void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
252 blk_t block) 245 blk_t block)
253{ 246{
254#ifdef EXT2FS_DEBUG_FAST_OPS
255 if ((block < bitmap->start) || (block > bitmap->end)) {
256 ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK,
257 block, bitmap->description);
258 return;
259 }
260#endif
261 ext2fs_clear_bit(block - bitmap->start, bitmap->bitmap); 247 ext2fs_clear_bit(block - bitmap->start, bitmap->bitmap);
262} 248}
263 249
264int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap, 250int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
265 blk_t block) 251 blk_t block)
266{ 252{
267#ifdef EXT2FS_DEBUG_FAST_OPS
268 if ((block < bitmap->start) || (block > bitmap->end)) {
269 ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
270 block, bitmap->description);
271 return 0;
272 }
273#endif
274 return ext2fs_test_bit(block - bitmap->start, bitmap->bitmap); 253 return ext2fs_test_bit(block - bitmap->start, bitmap->bitmap);
275} 254}
276 255
277void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, 256void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
278 ext2_ino_t inode) 257 ext2_ino_t inode)
279{ 258{
280#ifdef EXT2FS_DEBUG_FAST_OPS
281 if ((inode < bitmap->start) || (inode > bitmap->end)) {
282 ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_MARK,
283 inode, bitmap->description);
284 return;
285 }
286#endif
287 ext2fs_set_bit(inode - bitmap->start, bitmap->bitmap); 259 ext2fs_set_bit(inode - bitmap->start, bitmap->bitmap);
288} 260}
289 261
290void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, 262void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
291 ext2_ino_t inode) 263 ext2_ino_t inode)
292{ 264{
293#ifdef EXT2FS_DEBUG_FAST_OPS
294 if ((inode < bitmap->start) || (inode > bitmap->end)) {
295 ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_UNMARK,
296 inode, bitmap->description);
297 return;
298 }
299#endif
300 ext2fs_clear_bit(inode - bitmap->start, bitmap->bitmap); 265 ext2fs_clear_bit(inode - bitmap->start, bitmap->bitmap);
301} 266}
302 267
303int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap, 268int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
304 ext2_ino_t inode) 269 ext2_ino_t inode)
305{ 270{
306#ifdef EXT2FS_DEBUG_FAST_OPS
307 if ((inode < bitmap->start) || (inode > bitmap->end)) {
308 ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_TEST,
309 inode, bitmap->description);
310 return 0;
311 }
312#endif
313 return ext2fs_test_bit(inode - bitmap->start, bitmap->bitmap); 271 return ext2fs_test_bit(inode - bitmap->start, bitmap->bitmap);
314} 272}
315 273
@@ -355,13 +313,6 @@ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
355{ 313{
356 int i; 314 int i;
357 315
358#ifdef EXT2FS_DEBUG_FAST_OPS
359 if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
360 ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
361 block, bitmap->description);
362 return 0;
363 }
364#endif
365 for (i=0; i < num; i++) { 316 for (i=0; i < num; i++) {
366 if (ext2fs_fast_test_block_bitmap(bitmap, block+i)) 317 if (ext2fs_fast_test_block_bitmap(bitmap, block+i))
367 return 0; 318 return 0;
@@ -388,13 +339,6 @@ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
388{ 339{
389 int i; 340 int i;
390 341
391#ifdef EXT2FS_DEBUG_FAST_OPS
392 if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
393 ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
394 bitmap->description);
395 return;
396 }
397#endif
398 for (i=0; i < num; i++) 342 for (i=0; i < num; i++)
399 ext2fs_set_bit(block + i - bitmap->start, bitmap->bitmap); 343 ext2fs_set_bit(block + i - bitmap->start, bitmap->bitmap);
400} 344}
@@ -417,14 +361,6 @@ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
417 blk_t block, int num) 361 blk_t block, int num)
418{ 362{
419 int i; 363 int i;
420
421#ifdef EXT2FS_DEBUG_FAST_OPS
422 if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
423 ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block,
424 bitmap->description);
425 return;
426 }
427#endif
428 for (i=0; i < num; i++) 364 for (i=0; i < num; i++)
429 ext2fs_clear_bit(block + i - bitmap->start, bitmap->bitmap); 365 ext2fs_clear_bit(block + i - bitmap->start, bitmap->bitmap);
430} 366}
diff --git a/e2fsprogs/ext2fs/ext_attr.c b/e2fsprogs/ext2fs/ext_attr.c
index 10b8bfd9d..17610a914 100644
--- a/e2fsprogs/ext2fs/ext_attr.c
+++ b/e2fsprogs/ext2fs/ext_attr.c
@@ -12,15 +12,12 @@
12 */ 12 */
13 13
14#include <stdio.h> 14#include <stdio.h>
15#if HAVE_UNISTD_H
16#include <unistd.h> 15#include <unistd.h>
17#endif
18#include <string.h> 16#include <string.h>
19#include <time.h> 17#include <time.h>
20 18
21#include "ext2_fs.h" 19#include "ext2_fs.h"
22#include "ext2_ext_attr.h" 20#include "ext2_ext_attr.h"
23
24#include "ext2fs.h" 21#include "ext2fs.h"
25 22
26errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf) 23errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
@@ -30,7 +27,7 @@ errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
30 retval = io_channel_read_blk(fs->io, block, 1, buf); 27 retval = io_channel_read_blk(fs->io, block, 1, buf);
31 if (retval) 28 if (retval)
32 return retval; 29 return retval;
33#ifdef EXT2FS_ENABLE_SWAPFS 30#if BB_BIG_ENDIAN
34 if ((fs->flags & (EXT2_FLAG_SWAP_BYTES| 31 if ((fs->flags & (EXT2_FLAG_SWAP_BYTES|
35 EXT2_FLAG_SWAP_BYTES_READ)) != 0) 32 EXT2_FLAG_SWAP_BYTES_READ)) != 0)
36 ext2fs_swap_ext_attr(buf, buf, fs->blocksize, 1); 33 ext2fs_swap_ext_attr(buf, buf, fs->blocksize, 1);
@@ -44,7 +41,7 @@ errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, void *inbuf)
44 char *write_buf; 41 char *write_buf;
45 char *buf = NULL; 42 char *buf = NULL;
46 43
47#ifdef EXT2FS_ENABLE_SWAPFS 44#if BB_BIG_ENDIAN
48 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || 45 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
49 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) { 46 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) {
50 retval = ext2fs_get_mem(fs->blocksize, &buf); 47 retval = ext2fs_get_mem(fs->blocksize, &buf);
diff --git a/e2fsprogs/ext2fs/ind_block.c b/e2fsprogs/ext2fs/ind_block.c
index 3e6cdc138..4728fe7b5 100644
--- a/e2fsprogs/ext2fs/ind_block.c
+++ b/e2fsprogs/ext2fs/ind_block.c
@@ -22,7 +22,7 @@
22errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf) 22errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
23{ 23{
24 errcode_t retval; 24 errcode_t retval;
25#ifdef EXT2FS_ENABLE_SWAPFS 25#if BB_BIG_ENDIAN
26 blk_t *block_nr; 26 blk_t *block_nr;
27 int i; 27 int i;
28 int limit = fs->blocksize >> 2; 28 int limit = fs->blocksize >> 2;
@@ -36,7 +36,7 @@ errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
36 if (retval) 36 if (retval)
37 return retval; 37 return retval;
38 } 38 }
39#ifdef EXT2FS_ENABLE_SWAPFS 39#if BB_BIG_ENDIAN
40 if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_READ)) { 40 if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_READ)) {
41 block_nr = (blk_t *) buf; 41 block_nr = (blk_t *) buf;
42 for (i = 0; i < limit; i++, block_nr++) 42 for (i = 0; i < limit; i++, block_nr++)
@@ -48,7 +48,7 @@ errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
48 48
49errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf) 49errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf)
50{ 50{
51#ifdef EXT2FS_ENABLE_SWAPFS 51#if BB_BIG_ENDIAN
52 blk_t *block_nr; 52 blk_t *block_nr;
53 int i; 53 int i;
54 int limit = fs->blocksize >> 2; 54 int limit = fs->blocksize >> 2;
@@ -57,7 +57,7 @@ errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf)
57 if (fs->flags & EXT2_FLAG_IMAGE_FILE) 57 if (fs->flags & EXT2_FLAG_IMAGE_FILE)
58 return 0; 58 return 0;
59 59
60#ifdef EXT2FS_ENABLE_SWAPFS 60#if BB_BIG_ENDIAN
61 if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_WRITE)) { 61 if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_WRITE)) {
62 block_nr = (blk_t *) buf; 62 block_nr = (blk_t *) buf;
63 for (i = 0; i < limit; i++, block_nr++) 63 for (i = 0; i < limit; i++, block_nr++)
diff --git a/e2fsprogs/ext2fs/inode.c b/e2fsprogs/ext2fs/inode.c
index 4c386c77c..db5201829 100644
--- a/e2fsprogs/ext2fs/inode.c
+++ b/e2fsprogs/ext2fs/inode.c
@@ -446,7 +446,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
446 scan->ptr += scan->inode_size - extra_bytes; 446 scan->ptr += scan->inode_size - extra_bytes;
447 scan->bytes_left -= scan->inode_size - extra_bytes; 447 scan->bytes_left -= scan->inode_size - extra_bytes;
448 448
449#ifdef EXT2FS_ENABLE_SWAPFS 449#if BB_BIG_ENDIAN
450 if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) || 450 if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
451 (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) 451 (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
452 ext2fs_swap_inode_full(scan->fs, 452 ext2fs_swap_inode_full(scan->fs,
@@ -460,7 +460,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
460 retval = EXT2_ET_BAD_BLOCK_IN_INODE_TABLE; 460 retval = EXT2_ET_BAD_BLOCK_IN_INODE_TABLE;
461 scan->scan_flags &= ~EXT2_SF_BAD_EXTRA_BYTES; 461 scan->scan_flags &= ~EXT2_SF_BAD_EXTRA_BYTES;
462 } else { 462 } else {
463#ifdef EXT2FS_ENABLE_SWAPFS 463#if BB_BIG_ENDIAN
464 if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) || 464 if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
465 (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) 465 (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
466 ext2fs_swap_inode_full(scan->fs, 466 ext2fs_swap_inode_full(scan->fs,
@@ -574,7 +574,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
574 block_nr++; 574 block_nr++;
575 } 575 }
576 576
577#ifdef EXT2FS_ENABLE_SWAPFS 577#if BB_BIG_ENDIAN
578 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || 578 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
579 (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)) 579 (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
580 ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, 580 ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode,
@@ -646,7 +646,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
646 w_inode = &temp_inode; 646 w_inode = &temp_inode;
647 memset(w_inode, 0, length); 647 memset(w_inode, 0, length);
648 648
649#ifdef EXT2FS_ENABLE_SWAPFS 649#if BB_BIG_ENDIAN
650 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) || 650 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
651 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) 651 (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
652 ext2fs_swap_inode_full(fs, w_inode, 652 ext2fs_swap_inode_full(fs, w_inode,
diff --git a/e2fsprogs/ext2fs/openfs.c b/e2fsprogs/ext2fs/openfs.c
index aa603337d..646ec4d30 100644
--- a/e2fsprogs/ext2fs/openfs.c
+++ b/e2fsprogs/ext2fs/openfs.c
@@ -89,7 +89,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
89 int groups_per_block, blocks_per_group; 89 int groups_per_block, blocks_per_group;
90 blk_t group_block, blk; 90 blk_t group_block, blk;
91 char *dest, *cp; 91 char *dest, *cp;
92#ifdef EXT2FS_ENABLE_SWAPFS 92#if BB_BIG_ENDIAN
93 int j; 93 int j;
94 struct ext2_group_desc *gdp; 94 struct ext2_group_desc *gdp;
95#endif 95#endif
@@ -175,7 +175,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
175 if (fs->orig_super) 175 if (fs->orig_super)
176 memcpy(fs->orig_super, fs->super, SUPERBLOCK_SIZE); 176 memcpy(fs->orig_super, fs->super, SUPERBLOCK_SIZE);
177 177
178#ifdef EXT2FS_ENABLE_SWAPFS 178#if BB_BIG_ENDIAN
179 if ((fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) || 179 if ((fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) ||
180 (fs->flags & EXT2_FLAG_SWAP_BYTES)) { 180 (fs->flags & EXT2_FLAG_SWAP_BYTES)) {
181 fs->flags |= EXT2_FLAG_SWAP_BYTES; 181 fs->flags |= EXT2_FLAG_SWAP_BYTES;
@@ -277,7 +277,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
277 retval = io_channel_read_blk(fs->io, blk, 1, dest); 277 retval = io_channel_read_blk(fs->io, blk, 1, dest);
278 if (retval) 278 if (retval)
279 goto cleanup; 279 goto cleanup;
280#ifdef EXT2FS_ENABLE_SWAPFS 280#if BB_BIG_ENDIAN
281 if (fs->flags & EXT2_FLAG_SWAP_BYTES) { 281 if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
282 gdp = (struct ext2_group_desc *) dest; 282 gdp = (struct ext2_group_desc *) dest;
283 for (j=0; j < groups_per_block; j++) 283 for (j=0; j < groups_per_block; j++)
diff --git a/e2fsprogs/ext2fs/rw_bitmaps.c b/e2fsprogs/ext2fs/rw_bitmaps.c
index d5698a221..50f2a9447 100644
--- a/e2fsprogs/ext2fs/rw_bitmaps.c
+++ b/e2fsprogs/ext2fs/rw_bitmaps.c
@@ -27,7 +27,7 @@
27#include "ext2fs.h" 27#include "ext2fs.h"
28#include "e2image.h" 28#include "e2image.h"
29 29
30#if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS) 30#if defined(__powerpc__) && BB_BIG_ENDIAN
31/* 31/*
32 * On the PowerPC, the big-endian variant of the ext2 filesystem 32 * On the PowerPC, the big-endian variant of the ext2 filesystem
33 * has its bitmaps stored as 32-bit words with bit 0 as the LSB 33 * has its bitmaps stored as 32-bit words with bit 0 as the LSB
diff --git a/e2fsprogs/ext2fs/swapfs.c b/e2fsprogs/ext2fs/swapfs.c
index af8b6eb87..0c0180613 100644
--- a/e2fsprogs/ext2fs/swapfs.c
+++ b/e2fsprogs/ext2fs/swapfs.c
@@ -10,9 +10,7 @@
10 */ 10 */
11 11
12#include <stdio.h> 12#include <stdio.h>
13#if HAVE_UNISTD_H
14#include <unistd.h> 13#include <unistd.h>
15#endif
16#include <string.h> 14#include <string.h>
17#include <time.h> 15#include <time.h>
18 16
@@ -20,7 +18,7 @@
20#include "ext2fs.h" 18#include "ext2fs.h"
21#include "ext2_ext_attr.h" 19#include "ext2_ext_attr.h"
22 20
23#ifdef EXT2FS_ENABLE_SWAPFS 21#if BB_BIG_ENDIAN
24void ext2fs_swap_super(struct ext2_super_block * sb) 22void ext2fs_swap_super(struct ext2_super_block * sb)
25{ 23{
26 int i; 24 int i;
diff --git a/e2fsprogs/ext2fs/unix_io.c b/e2fsprogs/ext2fs/unix_io.c
index 7f57afddc..69d01f49b 100644
--- a/e2fsprogs/ext2fs/unix_io.c
+++ b/e2fsprogs/ext2fs/unix_io.c
@@ -34,9 +34,7 @@
34#if HAVE_SYS_TYPES_H 34#if HAVE_SYS_TYPES_H
35#include <sys/types.h> 35#include <sys/types.h>
36#endif 36#endif
37#if HAVE_SYS_RESOURCE_H
38#include <sys/resource.h> 37#include <sys/resource.h>
39#endif
40 38
41#include "ext2_fs.h" 39#include "ext2_fs.h"
42#include "ext2fs.h" 40#include "ext2fs.h"
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c
index 94815565e..adf34c44d 100644
--- a/e2fsprogs/fsck.c
+++ b/e2fsprogs/fsck.c
@@ -1175,14 +1175,6 @@ static int check_all(void)
1175 return status; 1175 return status;
1176} 1176}
1177 1177
1178#if 0
1179static void usage(void)
1180{
1181 fputs("Usage: fsck [-ANPRTV] [ -C [ fd ] ] [-t fstype] [fs-options] [filesys ...]\n", stderr);
1182 exit(EXIT_USAGE);
1183}
1184#endif
1185
1186static void signal_cancel(int sig FSCK_ATTR((unused))) 1178static void signal_cancel(int sig FSCK_ATTR((unused)))
1187{ 1179{
1188 cancel_requested++; 1180 cancel_requested++;
@@ -1300,13 +1292,13 @@ static void PRS(int argc, char *argv[])
1300 case 't': 1292 case 't':
1301 tmp = 0; 1293 tmp = 0;
1302 if (fstype) 1294 if (fstype)
1303 usage(); 1295 bb_show_usage();
1304 if (arg[j+1]) 1296 if (arg[j+1])
1305 tmp = arg+j+1; 1297 tmp = arg+j+1;
1306 else if ((i+1) < argc) 1298 else if ((i+1) < argc)
1307 tmp = argv[++i]; 1299 tmp = argv[++i];
1308 else 1300 else
1309 usage(); 1301 bb_show_usage();
1310 fstype = string_copy(tmp); 1302 fstype = string_copy(tmp);
1311 compile_fs_type(fstype, &fs_type_compiled); 1303 compile_fs_type(fstype, &fs_type_compiled);
1312 goto next_arg; 1304 goto next_arg;
@@ -1314,7 +1306,7 @@ static void PRS(int argc, char *argv[])
1314 opts_for_fsck++; 1306 opts_for_fsck++;
1315 break; 1307 break;
1316 case '?': 1308 case '?':
1317 usage(); 1309 bb_show_usage();
1318 break; 1310 break;
1319 default: 1311 default:
1320 options[++opt] = arg[j]; 1312 options[++opt] = arg[j];
diff --git a/e2fsprogs/fsck.h b/e2fsprogs/fsck.h
index 8ae8f427a..12748a121 100644
--- a/e2fsprogs/fsck.h
+++ b/e2fsprogs/fsck.h
@@ -11,6 +11,5 @@
11#define EXIT_ERROR 8 11#define EXIT_ERROR 8
12#define EXIT_USAGE 16 12#define EXIT_USAGE 16
13#define FSCK_CANCELED 32 /* Aborted with a signal or ^C */ 13#define FSCK_CANCELED 32 /* Aborted with a signal or ^C */
14#define EXIT_LIBRARY 128
15 14
16extern char *e2fs_set_sbin_path(void); 15extern char *e2fs_set_sbin_path(void);
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index b5ec8ab98..1f2176600 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -33,12 +33,6 @@
33#include "e2fsbb.h" 33#include "e2fsbb.h"
34#include "e2p/e2p.h" 34#include "e2p/e2p.h"
35 35
36#ifdef __GNUC__
37# define EXT2FS_ATTR(x) __attribute__(x)
38#else
39# define EXT2FS_ATTR(x)
40#endif
41
42#define OPT_RECUR 1 36#define OPT_RECUR 1
43#define OPT_ALL 2 37#define OPT_ALL 2
44#define OPT_DIRS_OPT 4 38#define OPT_DIRS_OPT 4
@@ -98,7 +92,7 @@ static void lsattr_args(const char *name)
98} 92}
99 93
100static int lsattr_dir_proc(const char *dir_name, struct dirent *de, 94static int lsattr_dir_proc(const char *dir_name, struct dirent *de,
101 void *private EXT2FS_ATTR((unused))) 95 void *private)
102{ 96{
103 STRUCT_STAT st; 97 STRUCT_STAT st;
104 char *path; 98 char *path;
diff --git a/e2fsprogs/uuid/gen_uuid.c b/e2fsprogs/uuid/gen_uuid.c
index fca3ebe91..d84777498 100644
--- a/e2fsprogs/uuid/gen_uuid.c
+++ b/e2fsprogs/uuid/gen_uuid.c
@@ -44,9 +44,7 @@
44#ifdef HAVE_SYS_IOCTL_H 44#ifdef HAVE_SYS_IOCTL_H
45#include <sys/ioctl.h> 45#include <sys/ioctl.h>
46#endif 46#endif
47#ifdef HAVE_SYS_SOCKET_H
48#include <sys/socket.h> 47#include <sys/socket.h>
49#endif
50#ifdef HAVE_SYS_SOCKIO_H 48#ifdef HAVE_SYS_SOCKIO_H
51#include <sys/sockio.h> 49#include <sys/sockio.h>
52#endif 50#endif