summaryrefslogtreecommitdiff
path: root/e2fsprogs
diff options
context:
space:
mode:
authorRob Landley2006-05-03 21:58:45 +0000
committerRob Landley2006-05-03 21:58:45 +0000
commit7c94bed2345008b4b62014a846488319a7af0727 (patch)
tree4345ba7255410654b6c8c4d7f51122643f6d9584 /e2fsprogs
parentdb2ab89b7c66c97e7a849a4a25baca10de4576dc (diff)
downloadbusybox-7c94bed2345008b4b62014a846488319a7af0727.zip
busybox-7c94bed2345008b4b62014a846488319a7af0727.tar.gz
Big dead code elimination pass from Garrett.
Diffstat (limited to 'e2fsprogs')
-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 ddd1966..975e567 100644
--- a/e2fsprogs/e2fsbb.h
+++ b/e2fsprogs/e2fsbb.h
@@ -14,44 +14,27 @@
#define E2FSPROGS_VERSION "1.38"
#define E2FSPROGS_DATE "30-Jun-2005"
-/* make sure com_err.h isnt included before us */
-#ifdef __COM_ERR_H__
-#error You should not have included com_err.h !
-#endif
-#define __COM_ERR_H__
-
-/* com_err crap */
-#define com_err(w, c, fmt, args...) bb_error_msg(fmt, ## args)
typedef long errcode_t;
#define ERRCODE_RANGE 8
#define error_message(code) strerror((int) (code & ((1<<ERRCODE_RANGE)-1)))
-/* misc crap */
-#define fatal_error(err, msg) bb_error_msg_and_die(msg)
-#define usage() bb_show_usage()
-
/* header defines */
#define ENABLE_HTREE 1
#define HAVE_ERRNO_H 1
#define HAVE_EXT2_IOCTLS 1
-#define HAVE_INTTYPES_H 1
#define HAVE_LINUX_FD_H 1
-#define HAVE_MALLOC_H 1
#define HAVE_MNTENT_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_NET_IF_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_MOUNT_H 1
#define HAVE_SYS_QUEUE_H 1
-#define HAVE_SYS_RESOURCE_H 1
-#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1
/* Endianness */
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if BB_BIG_ENDIAN
#define ENABLE_SWAPFS 1
#define WORDS_BIGENDIAN 1
#endif
diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c
index e72739c..7e1c82e 100644
--- a/e2fsprogs/e2fsck.c
+++ b/e2fsprogs/e2fsck.c
@@ -2,6 +2,7 @@
* e2fsck
*
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
+ * Copyright (C) 2006 Garrett Kajmowicz
* This file may be
* redistributed under the terms of the GNU Public License.
*
@@ -38,14 +39,6 @@
#include "e2fsck.h" /*Put all of our defines here to clean things up*/
-#ifdef __GNUC__
-#define _INLINE_ __inline__
-#define EXT2FS_ATTR(x) __attribute__(x)
-#else
-#define _INLINE_
-#define EXT2FS_ATTR(x)
-#endif
-
/*
* Procedure declarations
*/
@@ -219,7 +212,7 @@ typedef struct {
* functions.
*/
-static _INLINE_ kmem_cache_t * do_cache_create(int len)
+static kmem_cache_t * do_cache_create(int len)
{
kmem_cache_t *new_cache;
@@ -229,7 +222,7 @@ static _INLINE_ kmem_cache_t * do_cache_create(int len)
return new_cache;
}
-static _INLINE_ void do_cache_destroy(kmem_cache_t *cache)
+static void do_cache_destroy(kmem_cache_t *cache)
{
free(cache);
}
@@ -266,8 +259,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0,
check_bb_inode_blocks, 0);
if (retval) {
- com_err("ext2fs_block_iterate", retval,
- _("while sanity checking the bad blocks inode"));
+ bb_error_msg(_("while sanity checking the bad blocks inode"));
goto fatal;
}
@@ -278,8 +270,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
if (!replace_bad_blocks) {
retval = ext2fs_read_bb_inode(fs, &bb_list);
if (retval) {
- com_err("ext2fs_read_bb_inode", retval,
- _("while reading the bad blocks inode"));
+ bb_error_msg(_("while reading the bad blocks inode"));
goto fatal;
}
}
@@ -292,8 +283,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
if (bad_blocks_file) {
f = fopen(bad_blocks_file, "r");
if (!f) {
- com_err("read_bad_blocks_file", errno,
- _("while trying to open %s"), bad_blocks_file);
+ bb_error_msg(_("while trying to open %s"), bad_blocks_file);
goto fatal;
}
} else {
@@ -303,8 +293,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
fs->device_name, fs->super->s_blocks_count);
f = popen(buf, "r");
if (!f) {
- com_err("read_bad_blocks_file", errno,
- _("while trying popen '%s'"), buf);
+ bb_error_msg(_("while trying popen '%s'"), buf);
goto fatal;
}
}
@@ -314,8 +303,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
else
pclose(f);
if (retval) {
- com_err("ext2fs_read_bb_FILE", retval,
- _("while reading in list of bad blocks from file"));
+ bb_error_msg(_("while reading in list of bad blocks from file"));
goto fatal;
}
@@ -324,8 +312,7 @@ static void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
*/
retval = ext2fs_update_bb_inode(fs, bb_list);
if (retval) {
- com_err("ext2fs_update_bb_inode", retval,
- _("while updating bad block inode"));
+ bb_error_msg(_("while updating bad block inode"));
goto fatal;
}
@@ -390,7 +377,6 @@ static int check_bb_inode_blocks(ext2_filsys fs,
#define dict_root(D) ((D)->nilnode.left)
#define dict_nil(D) (&(D)->nilnode)
-#define DICT_DEPTH_MAX 64
static void dnode_free(dnode_t *node);
@@ -1528,8 +1514,6 @@ static void ehandler_init(io_channel channel)
* any later version.
*/
-#define MNT_FL (MS_MGC_VAL | MS_RDONLY)
-
/*
* Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths.
* This creates a larger static binary, and a smaller binary using
@@ -1608,8 +1592,7 @@ static void ll_rw_block(int rw, int nr, struct buffer_head *bhp[])
bh->b_blocknr,
1, bh->b_data);
if (retval) {
- com_err(bh->b_ctx->device_name, retval,
- "while reading block %lu\n",
+ bb_error_msg("while reading block %lu\n",
(unsigned long) bh->b_blocknr);
bh->b_err = retval;
continue;
@@ -1620,8 +1603,7 @@ static void ll_rw_block(int rw, int nr, struct buffer_head *bhp[])
bh->b_blocknr,
1, bh->b_data);
if (retval) {
- com_err(bh->b_ctx->device_name, retval,
- "while writing block %lu\n",
+ bb_error_msg("while writing block %lu\n",
(unsigned long) bh->b_blocknr);
bh->b_err = retval;
continue;
@@ -1831,7 +1813,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
memcpy(&jsuper, start ? bh->b_data : bh->b_data + 1024,
sizeof(jsuper));
brelse(bh);
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (jsuper.s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
ext2fs_swap_super(&jsuper);
#endif
@@ -1937,8 +1919,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal)
ll_rw_block(READ, 1, &jbh);
if (jbh->b_err) {
- com_err(ctx->device_name, jbh->b_err,
- _("reading journal superblock\n"));
+ bb_error_msg(_("reading journal superblock\n"));
return jbh->b_err;
}
@@ -1994,8 +1975,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal)
* format to be able to proceed safely, so any other checks that
* fail we should attempt to recover from. */
if (jsb->s_blocksize != htonl(journal->j_blocksize)) {
- com_err(ctx->program_name, EXT2_ET_CORRUPT_SUPERBLOCK,
- _("%s: no valid journal superblock found\n"),
+ bb_error_msg(_("%s: no valid journal superblock found\n"),
ctx->device_name);
return EXT2_ET_CORRUPT_SUPERBLOCK;
}
@@ -2003,8 +1983,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal)
if (ntohl(jsb->s_maxlen) < journal->j_maxlen)
journal->j_maxlen = ntohl(jsb->s_maxlen);
else if (ntohl(jsb->s_maxlen) > journal->j_maxlen) {
- com_err(ctx->program_name, EXT2_ET_CORRUPT_SUPERBLOCK,
- _("%s: journal too short\n"),
+ bb_error_msg(_("%s: journal too short\n"),
ctx->device_name);
return EXT2_ET_CORRUPT_SUPERBLOCK;
}
@@ -2297,10 +2276,9 @@ static int e2fsck_run_ext3_journal(e2fsck_t ctx)
&ctx->fs);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while trying to re-open %s"),
+ bb_error_msg(_("while trying to re-open %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ctx->fs->priv_data = ctx;
@@ -2737,7 +2715,7 @@ static void expand_inode_expression(char ch,
/*
* This function expands '%dX' expressions
*/
-static _INLINE_ void expand_dirent_expression(char ch,
+static void expand_dirent_expression(char ch,
struct problem_context *ctx)
{
struct ext2_dir_entry *dirent;
@@ -2776,7 +2754,7 @@ static _INLINE_ void expand_dirent_expression(char ch,
}
}
-static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch,
+static void expand_percent_expression(ext2_filsys fs, char ch,
struct problem_context *ctx)
{
if (!ctx)
@@ -3036,7 +3014,7 @@ static void alloc_imagic_map(e2fsck_t ctx);
static void mark_inode_bad(e2fsck_t ctx, ino_t ino);
static void handle_fs_bad_blocks(e2fsck_t ctx);
static void process_inodes(e2fsck_t ctx, char *block_buf);
-static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b);
+static int process_inode_cmp(const void *a, const void *b);
static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
dgrp_t group, void * priv_data);
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)
ehandler_operation(old_operation);
}
-static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b)
+static int process_inode_cmp(const void *a, const void *b)
{
const struct process_inode_block *ib_a =
(const struct process_inode_block *) a;
@@ -4015,7 +3993,7 @@ static void alloc_imagic_map(e2fsck_t ctx)
* WARNING: Assumes checks have already been done to make sure block
* is valid. This is true in both process_block and process_bad_block.
*/
-static _INLINE_ void mark_block_used(e2fsck_t ctx, blk_t block)
+static void mark_block_used(e2fsck_t ctx, blk_t block)
{
struct problem_context pctx;
@@ -5522,8 +5500,7 @@ static int delete_file_block(ext2_filsys fs,
p = (struct dup_block *) dnode_get(n);
decrement_badcount(ctx, *block_nr, p);
} else
- com_err("delete_file_block", 0,
- _("internal error; can't find dup_blk for %d\n"),
+ bb_error_msg(_("internal error; can't find dup_blk for %d\n"),
*block_nr);
} else {
ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr);
@@ -5656,8 +5633,7 @@ static int clone_file_block(ext2_filsys fs,
ext2fs_mark_block_bitmap(fs->block_map, new_block);
return BLOCK_CHANGED;
} else
- com_err("clone_file_block", 0,
- _("internal error; can't find dup_blk for %d\n"),
+ bb_error_msg(_("internal error; can't find dup_blk for %d\n"),
*block_nr);
}
return 0;
@@ -5699,8 +5675,7 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
goto errout;
}
if (cs.errcode) {
- com_err("clone_file", cs.errcode,
- _("returned from clone_file_block"));
+ bb_error_msg(_("returned from clone_file_block"));
retval = cs.errcode;
goto errout;
}
@@ -5827,7 +5802,7 @@ static int update_dir_block(ext2_filsys fs,
static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
static int htree_depth(struct dx_dir_info *dx_dir,
struct dx_dirblock_info *dx_db);
-static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b);
+static int special_dir_block_cmp(const void *a, const void *b);
struct check_dir_struct {
char *buf;
@@ -6057,7 +6032,7 @@ static int dict_de_cmp(const void *a, const void *b)
* This guarantees that the root node of the htree directories are
* processed first, so we know what hash version to use.
*/
-static EXT2_QSORT_TYPE special_dir_block_cmp(const void *a, const void *b)
+static int special_dir_block_cmp(const void *a, const void *b)
{
const struct ext2_db_entry *db_a =
(const struct ext2_db_entry *) a;
@@ -6239,7 +6214,7 @@ static int ext2_file_type(unsigned int mode)
return 0;
}
-static _INLINE_ int check_filetype(e2fsck_t ctx,
+static int check_filetype(e2fsck_t ctx,
struct ext2_dir_entry *dirent,
struct problem_context *pctx)
{
@@ -6909,7 +6884,7 @@ static int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR) &&
fix_problem(ctx, PR_2_FILE_ACL_ZERO, &pctx)) {
inode.i_file_acl = 0;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
/*
* This is a special kludge to deal with long symlinks
* on big endian systems. i_blocks had already been
@@ -10166,7 +10141,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
preenhalt(ctx);
if (ptr->flags & PR_FATAL)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
if (ptr->prompt == PROMPT_NONE) {
if (ptr->flags & PR_NOCOLLATE)
@@ -10198,7 +10173,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
}
if ((ptr->prompt == PROMPT_ABORT) && answer)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
if (ptr->flags & PR_AFTER_CODE)
answer = fix_problem(ctx, ptr->second_code, pctx);
@@ -10773,7 +10748,7 @@ static int fill_dir_block(ext2_filsys fs,
}
/* Used for sorting the hash entry */
-static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b)
+static int name_cmp(const void *a, const void *b)
{
const struct hash_entry *he_a = (const struct hash_entry *) a;
const struct hash_entry *he_b = (const struct hash_entry *) b;
@@ -10797,7 +10772,7 @@ static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b)
}
/* Used for sorting the hash entry */
-static EXT2_QSORT_TYPE hash_cmp(const void *a, const void *b)
+static int hash_cmp(const void *a, const void *b)
{
const struct hash_entry *he_a = (const struct hash_entry *) a;
const struct hash_entry *he_b = (const struct hash_entry *) b;
@@ -11891,8 +11866,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
block_buf, release_inode_block, &pb);
if (retval) {
- com_err("release_inode_blocks", retval,
- _("while calling ext2fs_block_iterate for inode %d"),
+ bb_error_msg(_("while calling ext2fs_block_iterate for inode %d"),
ino);
return 1;
}
@@ -11914,8 +11888,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
count = 1;
}
if (retval) {
- com_err("release_inode_blocks", retval,
- _("while calling ext2fs_adjust_ea_refocunt for inode %d"),
+ bb_error_msg(_("while calling ext2fs_adjust_ea_refocunt for inode %d"),
ino);
return 1;
}
@@ -12486,14 +12459,12 @@ static void swap_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, char *block_buf,
retval = ext2fs_block_iterate(ctx->fs, ino, 0, block_buf,
swap_block, &sb);
if (retval) {
- com_err("swap_inode_blocks", retval,
- _("while calling ext2fs_block_iterate"));
+ bb_error_msg(_("while calling ext2fs_block_iterate"));
ctx->flags |= E2F_FLAG_ABORT;
return;
}
if (sb.errcode) {
- com_err("swap_inode_blocks", sb.errcode,
- _("while calling iterator function"));
+ bb_error_msg(_("while calling iterator function"));
ctx->flags |= E2F_FLAG_ABORT;
return;
}
@@ -12514,8 +12485,7 @@ static void swap_inodes(e2fsck_t ctx)
retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group,
&buf);
if (retval) {
- com_err("swap_inodes", retval,
- _("while allocating inode buffer"));
+ bb_error_msg(_("while allocating inode buffer"));
ctx->flags |= E2F_FLAG_ABORT;
return;
}
@@ -12526,8 +12496,7 @@ static void swap_inodes(e2fsck_t ctx)
fs->group_desc[group].bg_inode_table,
fs->inode_blocks_per_group, buf);
if (retval) {
- com_err("swap_inodes", retval,
- _("while reading inode table (group %d)"),
+ bb_error_msg(_("while reading inode table (group %d)"),
group);
ctx->flags |= E2F_FLAG_ABORT;
return;
@@ -12564,8 +12533,7 @@ static void swap_inodes(e2fsck_t ctx)
fs->group_desc[group].bg_inode_table,
fs->inode_blocks_per_group, buf);
if (retval) {
- com_err("swap_inodes", retval,
- _("while writing inode table (group %d)"),
+ bb_error_msg(_("while writing inode table (group %d)"),
group);
ctx->flags |= E2F_FLAG_ABORT;
return;
@@ -12577,7 +12545,7 @@ static void swap_inodes(e2fsck_t ctx)
ext2fs_flush_icache(fs);
}
-#if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS)
+#if defined(__powerpc__) && BB_BIG_ENDIAN
/*
* On the PowerPC, the big-endian variant of the ext2 filesystem
* has its bitmaps stored as 32-bit words with bit 0 as the LSB
@@ -12663,7 +12631,7 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
ret = malloc(size);
if (!ret) {
sprintf(buf, "Can't allocate %s\n", description);
- fatal_error(ctx, buf);
+ bb_error_msg_and_die(buf);
}
memset(ret, 0, size);
return ret;
@@ -12792,20 +12760,18 @@ void e2fsck_read_bitmaps(e2fsck_t ctx)
errcode_t retval;
if (ctx->invalid_bitmaps) {
- com_err(ctx->program_name, 0,
- _("e2fsck_read_bitmaps: illegal bitmap block(s) for %s"),
+ bb_error_msg(_("e2fsck_read_bitmaps: illegal bitmap block(s) for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ehandler_operation(_("reading inode and block bitmaps"));
retval = ext2fs_read_bitmaps(fs);
ehandler_operation(0);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to read bitmaps for %s"),
+ bb_error_msg(_("while retrying to read bitmaps for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
@@ -12819,10 +12785,9 @@ static void e2fsck_write_bitmaps(e2fsck_t ctx)
retval = ext2fs_write_block_bitmap(fs);
ehandler_operation(0);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to write block bitmaps for %s"),
+ bb_error_msg(_("while retrying to write block bitmaps for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
@@ -12831,10 +12796,9 @@ static void e2fsck_write_bitmaps(e2fsck_t ctx)
retval = ext2fs_write_inode_bitmap(fs);
ehandler_operation(0);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while retrying to write inode bitmaps for %s"),
+ bb_error_msg(_("while retrying to write inode bitmaps for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
}
@@ -12863,9 +12827,8 @@ void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino,
retval = ext2fs_read_inode(ctx->fs, ino, inode);
if (retval) {
- com_err("ext2fs_read_inode", retval,
- _("while reading inode %ld in %s"), ino, proc);
- fatal_error(ctx, 0);
+ bb_error_msg(_("while reading inode %ld in %s"), ino, proc);
+ bb_error_msg_and_die(0);
}
}
@@ -12877,9 +12840,8 @@ extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
retval = ext2fs_write_inode_full(ctx->fs, ino, inode, bufsize);
if (retval) {
- com_err("ext2fs_write_inode", retval,
- _("while writing inode %ld in %s"), ino, proc);
- fatal_error(ctx, 0);
+ bb_error_msg(_("while writing inode %ld in %s"), ino, proc);
+ bb_error_msg_and_die(0);
}
}
@@ -12890,9 +12852,8 @@ extern void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
retval = ext2fs_write_inode(ctx->fs, ino, inode);
if (retval) {
- com_err("ext2fs_write_inode", retval,
- _("while writing inode %ld in %s"), ino, proc);
- fatal_error(ctx, 0);
+ bb_error_msg(_("while writing inode %ld in %s"), ino, proc);
+ bb_error_msg_and_die(0);
}
}
@@ -12946,7 +12907,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
if (io_channel_read_blk(io, superblock,
-SUPERBLOCK_SIZE, buf))
continue;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
ext2fs_swap_super(sb);
#endif
@@ -13085,8 +13046,7 @@ static void check_mount(e2fsck_t ctx)
retval = ext2fs_check_if_mounted(ctx->filesystem_name,
&ctx->mount_flags);
if (retval) {
- com_err("ext2fs_check_if_mount", retval,
- _("while determining whether %s is mounted."),
+ bb_error_msg(_("while determining whether %s is mounted."),
ctx->filesystem_name);
return;
}
@@ -13107,7 +13067,7 @@ static void check_mount(e2fsck_t ctx)
printf(_("%s is mounted. "), ctx->filesystem_name);
if (!ctx->interactive)
- fatal_error(ctx, _("Cannot continue, aborting.\n\n"));
+ bb_error_msg_and_die(_("Cannot continue, aborting.\n\n"));
printf(_("\n\n\007\007\007\007WARNING!!! "
"Running e2fsck on a mounted filesystem may cause\n"
"SEVERE filesystem damage.\007\007\007\n\n"));
@@ -13502,8 +13462,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
_("Error validating file descriptor %d: %s\n"),
ctx->progress_fd,
error_message(errno));
- fatal_error(ctx,
- _("Invalid completion information file descriptor"));
+ bb_error_msg_and_die(_("Invalid completion information file descriptor"));
} else
close(fd);
break;
@@ -13517,8 +13476,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
case 'a':
if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) {
conflict_opt:
- fatal_error(ctx,
- _("Only one the options -p/-a, -n or -y may be specified."));
+ bb_error_msg_and_die(_("Only one the options -p/-a, -n or -y may be specified."));
}
ctx->options |= E2F_OPT_PREEN;
break;
@@ -13602,12 +13560,12 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
keep_bad_blocks++;
break;
default:
- usage();
+ bb_show_usage();
}
if (show_version_only)
return 0;
if (optind != argc - 1)
- usage();
+ bb_show_usage();
if ((ctx->options & E2F_OPT_NO) && !bad_blocks_file &&
!cflag && !swapfs && !(ctx->options & E2F_OPT_COMPRESS_DIRS))
ctx->options |= E2F_OPT_READONLY;
@@ -13616,9 +13574,8 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
*ctx->io_options++ = 0;
ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0);
if (!ctx->filesystem_name) {
- com_err(ctx->program_name, 0, _("Unable to resolve '%s'"),
- argv[optind]);
- fatal_error(ctx, 0);
+ bb_error_msg(_("Unable to resolve '%s'"), argv[optind]);
+ bb_error_msg_and_die(0);
}
if (extended_opts)
parse_extended_opts(ctx, extended_opts);
@@ -13626,16 +13583,14 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
if (flush) {
fd = open(ctx->filesystem_name, O_RDONLY, 0);
if (fd < 0) {
- com_err("open", errno,
- _("while opening %s for flushing"),
+ bb_error_msg(_("while opening %s for flushing"),
ctx->filesystem_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
if ((retval = ext2fs_sync_device(fd, 1))) {
- com_err("ext2fs_sync_device", retval,
- _("while trying to flush %s"),
+ bb_error_msg(_("while trying to flush %s"),
ctx->filesystem_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
close(fd);
}
@@ -13703,8 +13658,7 @@ int e2fsck_main (int argc, char *argv[])
retval = PRS(argc, argv, &ctx);
if (retval) {
- com_err("e2fsck", retval,
- _("while trying to initialize program"));
+ bb_error_msg(_("while trying to initialize program"));
exit(EXIT_ERROR);
}
reserve_stdio_fds();
@@ -13725,8 +13679,7 @@ int e2fsck_main (int argc, char *argv[])
!(ctx->options & E2F_OPT_NO) &&
!(ctx->options & E2F_OPT_YES)) {
if (!ctx->interactive)
- fatal_error(ctx,
- _("need terminal for interactive repairs"));
+ bb_error_msg_and_die(_("need terminal for interactive repairs"));
}
ctx->superblock = ctx->use_superblock;
restart:
@@ -13773,7 +13726,7 @@ restart:
}
}
if (retval) {
- com_err(ctx->program_name, retval, _("while trying to open %s"),
+ bb_error_msg(_("while trying to open %s"),
ctx->filesystem_name);
if (retval == EXT2_ET_REV_TOO_HIGH) {
printf(_("The filesystem revision is apparently "
@@ -13798,17 +13751,16 @@ restart:
#endif
else
fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ctx->fs = fs;
fs->priv_data = ctx;
sb = fs->super;
if (sb->s_rev_level > E2FSCK_CURRENT_REV) {
- com_err(ctx->program_name, EXT2_ET_REV_TOO_HIGH,
- _("while trying to open %s"),
+ bb_error_msg(_("while trying to open %s"),
ctx->filesystem_name);
get_newer:
- fatal_error(ctx, _("Get a newer version of e2fsck!"));
+ bb_error_msg_and_die(_("Get a newer version of e2fsck!"));
}
/*
@@ -13828,10 +13780,9 @@ restart:
*/
retval = e2fsck_check_ext3_journal(ctx);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while checking ext3 journal for %s"),
+ bb_error_msg(_("while checking ext3 journal for %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
/*
@@ -13852,16 +13803,14 @@ restart:
* happen, unless the hardware or
* device driver is being bogus.
*/
- com_err(ctx->program_name, 0,
- _("unable to set superblock flags on %s\n"), ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg(_("unable to set superblock flags on %s\n"), ctx->device_name);
+ bb_error_msg_and_die(0);
}
retval = e2fsck_run_ext3_journal(ctx);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while recovering ext3 journal of %s"),
+ bb_error_msg(_("while recovering ext3 journal of %s"),
ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
ext2fs_close(ctx->fs);
ctx->fs = 0;
@@ -13876,25 +13825,21 @@ restart:
*/
if ((sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
(sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) {
- com_err(ctx->program_name, EXT2_ET_UNSUPP_FEATURE,
- "(%s)", ctx->device_name);
+ bb_error_msg("(%s)", ctx->device_name);
goto get_newer;
}
if (sb->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
- com_err(ctx->program_name, EXT2_ET_RO_UNSUPP_FEATURE,
- "(%s)", ctx->device_name);
+ bb_error_msg("(%s)", ctx->device_name);
goto get_newer;
}
#ifdef ENABLE_COMPRESSION
/* FIXME - do we support this at all? */
if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION)
- com_err(ctx->program_name, 0,
- _("Warning: compression support is experimental.\n"));
+ bb_error_msg(_("Warning: compression support is experimental.\n"));
#endif
#ifndef ENABLE_HTREE
if (sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) {
- com_err(ctx->program_name, 0,
- _("E2fsck not compiled with HTREE support,\n\t"
+ bb_error_msg(_("E2fsck not compiled with HTREE support,\n\t"
"but filesystem %s has HTREE directories.\n"),
ctx->device_name);
goto get_newer;
@@ -13926,14 +13871,14 @@ restart:
ext2fs_mark_valid(fs);
check_super_block(ctx);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
check_if_skip(ctx);
if (bad_blocks_file)
read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks);
else if (cflag)
read_bad_blocks_file(ctx, 0, !keep_bad_blocks); /* Test disk */
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
#ifdef ENABLE_SWAPFS
#ifdef WORDS_BIGENDIAN
@@ -13947,13 +13892,13 @@ restart:
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) == NATIVE_FLAG) {
fprintf(stderr, _("%s: Filesystem byte order "
"already normalized.\n"), ctx->device_name);
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
}
if (swapfs) {
swap_filesys(ctx);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
- fatal_error(ctx, 0);
+ bb_error_msg_and_die(0);
}
#endif
@@ -13964,8 +13909,7 @@ restart:
retval = ext2fs_read_bb_inode(fs, &fs->badblocks);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while reading bad blocks inode"));
+ bb_error_msg(_("while reading bad blocks inode"));
preenhalt(ctx);
printf(_("This doesn't bode well,"
" but we'll try to go on...\n"));
@@ -13977,9 +13921,8 @@ restart:
printf(_("Restarting e2fsck from the beginning...\n"));
retval = e2fsck_reset_context(ctx);
if (retval) {
- com_err(ctx->program_name, retval,
- _("while resetting context"));
- fatal_error(ctx, 0);
+ bb_error_msg(_("while resetting context"));
+ bb_error_msg_and_die(0);
}
ext2fs_close(fs);
goto restart;
@@ -13990,7 +13933,7 @@ restart:
exit_value |= FSCK_CANCELED;
}
if (run_result & E2F_FLAG_ABORT)
- fatal_error(ctx, _("aborted"));
+ bb_error_msg_and_die(_("aborted"));
/* Cleanup */
if (ext2fs_test_changed(fs)) {
diff --git a/e2fsprogs/e2fsck.h b/e2fsprogs/e2fsck.h
index fb6028d..0957f20 100644
--- a/e2fsprogs/e2fsck.h
+++ b/e2fsprogs/e2fsck.h
@@ -27,7 +27,6 @@
#include <sys/types.h>
#include <linux/types.h>
-
/*
* Now pull in the real linux/jfs.h definitions.
*/
@@ -82,8 +81,6 @@ These defines are used in the type field of dx_dirblock_info
#define DX_DIRBLOCK_ROOT 1
#define DX_DIRBLOCK_LEAF 2
#define DX_DIRBLOCK_NODE 3
-#define DX_DIRBLOCK_CORRUPT 4
-#define DX_DIRBLOCK_CLEARED 8
/*
@@ -102,7 +99,6 @@ The following defines are used in the 'flags' field of a dx_dirblock_info
#define E2F_OPT_YES 0x0004
#define E2F_OPT_NO 0x0008
#define E2F_OPT_TIME 0x0010
-#define E2F_OPT_TIME2 0x0020
#define E2F_OPT_CHECKBLOCKS 0x0040
#define E2F_OPT_DEBUG 0x0080
#define E2F_OPT_FORCE 0x0100
@@ -127,21 +123,10 @@ The following defines are used in the 'flags' field of a dx_dirblock_info
#define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */
#define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */
-/*
- * Defines for indicating the e2fsck pass number
- */
-#define E2F_PASS_1 1
-#define E2F_PASS_2 2
-#define E2F_PASS_3 3
-#define E2F_PASS_4 4
-#define E2F_PASS_5 5
-#define E2F_PASS_1B 6
/*Don't know where these come from*/
#define READ 0
#define WRITE 1
-#define KERN_ERR ""
-#define KERN_DEBUG ""
#define cpu_to_be32(n) htonl(n)
#define be32_to_cpu(n) ntohl(n)
diff --git a/e2fsprogs/ext2fs/bitops.c b/e2fsprogs/ext2fs/bitops.c
index 77ac2a6..44c08ad 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,
{
#ifndef OMIT_COM_ERR
if (description)
- com_err(0, errcode, "#%lu for %s", arg, description);
+ bb_error_msg("#%lu for %s", arg, description);
else
- com_err(0, errcode, "#%lu", arg);
+ bb_error_msg("#%lu", arg);
#endif
}
@@ -82,10 +82,9 @@ void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
{
#ifndef OMIT_COM_ERR
if (bitmap->description)
- com_err(0, bitmap->base_error_code+code,
- "#%lu for %s", arg, bitmap->description);
+ bb_error_msg("#%lu for %s", arg, bitmap->description);
else
- com_err(0, bitmap->base_error_code + code, "#%lu", arg);
+ bb_error_msg("#%lu", arg);
#endif
}
diff --git a/e2fsprogs/ext2fs/bmap.c b/e2fsprogs/ext2fs/bmap.c
index 4a53ebc..0015ba2 100644
--- a/e2fsprogs/ext2fs/bmap.c
+++ b/e2fsprogs/ext2fs/bmap.c
@@ -18,12 +18,6 @@
#include "ext2_fs.h"
#include "ext2fs.h"
-#if defined(__GNUC__) && !defined(NO_INLINE_FUNCS)
-#define _BMAP_INLINE_ __inline__
-#else
-#define _BMAP_INLINE_
-#endif
-
extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
char *block_buf, int bmap_flags,
@@ -31,7 +25,7 @@ extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino,
#define inode_bmap(inode, nr) ((inode)->i_block[(nr)])
-static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
+static errcode_t block_ind_bmap(ext2_filsys fs, int flags,
blk_t ind, char *block_buf,
int *blocks_alloc,
blk_t nr, blk_t *ret_blk)
@@ -51,7 +45,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
if (flags & BMAP_SET) {
b = *ret_blk;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
b = ext2fs_swab32(b);
@@ -62,7 +56,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
b = ((blk_t *) block_buf)[nr];
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
b = ext2fs_swab32(b);
@@ -75,7 +69,7 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags,
if (retval)
return retval;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
((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,
return 0;
}
-static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags,
+static errcode_t block_dind_bmap(ext2_filsys fs, int flags,
blk_t dind, char *block_buf,
int *blocks_alloc,
blk_t nr, blk_t *ret_blk)
@@ -114,7 +108,7 @@ static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags,
return retval;
}
-static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags,
+static errcode_t block_tind_bmap(ext2_filsys fs, int flags,
blk_t tind, char *block_buf,
int *blocks_alloc,
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,
if (block < EXT2_NDIR_BLOCKS) {
if (bmap_flags & BMAP_SET) {
b = *phys_blk;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
b = ext2fs_swab32(b);
diff --git a/e2fsprogs/ext2fs/bmove.c b/e2fsprogs/ext2fs/bmove.c
index 7e98c0f..afc2710 100644
--- a/e2fsprogs/ext2fs/bmove.c
+++ b/e2fsprogs/ext2fs/bmove.c
@@ -14,9 +14,7 @@
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#if HAVE_SYS_TIME_H
#include <sys/time.h>
-#endif
#include "ext2_fs.h"
#include "ext2fsP.h"
diff --git a/e2fsprogs/ext2fs/closefs.c b/e2fsprogs/ext2fs/closefs.c
index da0016b..481d1c5 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,
if (sgrp > ((1 << 16) - 1))
sgrp = (1 << 16) - 1;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (fs->flags & EXT2_FLAG_SWAP_BYTES)
super_shadow->s_block_group_nr = ext2fs_swab16(sgrp);
else
@@ -213,7 +213,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
struct ext2_group_desc *group_shadow = 0;
char *group_ptr;
int old_desc_blocks;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
dgrp_t j;
struct ext2_group_desc *s, *t;
#endif
@@ -224,7 +224,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
fs->super->s_wtime = time(NULL);
fs->super->s_block_group_nr = 0;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
retval = EXT2_ET_NO_MEMORY;
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow);
@@ -267,7 +267,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
* we write out the backup superblocks.)
*/
fs->super->s_state &= ~EXT2_VALID_FS;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
*super_shadow = *fs->super;
ext2fs_swap_super(super_shadow);
@@ -316,7 +316,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
}
fs->super->s_block_group_nr = 0;
fs->super->s_state = fs_state;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
*super_shadow = *fs->super;
ext2fs_swap_super(super_shadow);
diff --git a/e2fsprogs/ext2fs/dblist.c b/e2fsprogs/ext2fs/dblist.c
index 73313fa..aaac3b3 100644
--- a/e2fsprogs/ext2fs/dblist.c
+++ b/e2fsprogs/ext2fs/dblist.c
@@ -20,7 +20,7 @@
#include "ext2_fs.h"
#include "ext2fsP.h"
-static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b);
+static int dir_block_cmp(const void *a, const void *b);
/*
* 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,
}
void ext2fs_dblist_sort(ext2_dblist dblist,
- EXT2_QSORT_TYPE (*sortfunc)(const void *,
+ int (*sortfunc)(const void *,
const void *))
{
if (!sortfunc)
@@ -237,7 +237,7 @@ errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
return 0;
}
-static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b)
+static int dir_block_cmp(const void *a, const void *b)
{
const struct ext2_db_entry *db_a =
(const struct ext2_db_entry *) a;
diff --git a/e2fsprogs/ext2fs/dirblock.c b/e2fsprogs/ext2fs/dirblock.c
index 9f82b50..4f2bbc1 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,
char *p, *end;
struct ext2_dir_entry *dirent;
unsigned int name_len, rec_len;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
unsigned int do_swap;
#endif
retval = io_channel_read_blk(fs->io, block, 1, buf);
if (retval)
return retval;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
do_swap = (fs->flags & (EXT2_FLAG_SWAP_BYTES|
EXT2_FLAG_SWAP_BYTES_READ)) != 0;
#endif
@@ -41,7 +41,7 @@ errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
end = (char *) buf + fs->blocksize;
while (p < end-8) {
dirent = (struct ext2_dir_entry *) p;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (do_swap) {
dirent->inode = ext2fs_swab32(dirent->inode);
dirent->rec_len = ext2fs_swab16(dirent->rec_len);
@@ -75,7 +75,7 @@ errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block,
void *inbuf, int flags EXT2FS_ATTR((unused)))
{
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
int do_swap = 0;
errcode_t retval;
char *p, *end;
diff --git a/e2fsprogs/ext2fs/ext2_ext_attr.h b/e2fsprogs/ext2fs/ext2_ext_attr.h
index 23444c5..79f23ee 100644
--- a/e2fsprogs/ext2fs/ext2_ext_attr.h
+++ b/e2fsprogs/ext2fs/ext2_ext_attr.h
@@ -28,9 +28,6 @@ struct ext2_ext_attr_entry {
__u32 e_value_block; /* disk block attribute is stored on (n/i) */
__u32 e_value_size; /* size of attribute value */
__u32 e_hash; /* hash value of name and value */
-#if 0
- char e_name[0]; /* attribute name */
-#endif
};
#define EXT2_EXT_ATTR_PAD_BITS 2
@@ -53,17 +50,3 @@ struct ext2_ext_attr_entry {
#define EXT2_XATTR_SIZE(size) \
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
-#ifdef __KERNEL__
-# ifdef CONFIG_EXT2_FS_EXT_ATTR
-extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
-extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
-extern void ext2_ext_attr_free_inode(struct inode *inode);
-extern void ext2_ext_attr_put_super(struct super_block *sb);
-extern int ext2_ext_attr_init(void);
-extern void ext2_ext_attr_done(void);
-# else
-# define ext2_get_ext_attr NULL
-# define ext2_set_ext_attr NULL
-# endif
-#endif /* __KERNEL__ */
-
diff --git a/e2fsprogs/ext2fs/ext2_fs.h b/e2fsprogs/ext2fs/ext2_fs.h
index 4005873..44b04be 100644
--- a/e2fsprogs/ext2fs/ext2_fs.h
+++ b/e2fsprogs/ext2fs/ext2_fs.h
@@ -19,27 +19,6 @@
#include "ext2_types.h" /* Changed from linux/types.h */
/*
- * The second extended filesystem constants/structures
- */
-
-/*
- * Define EXT2FS_DEBUG to produce debug messages
- */
-#undef EXT2FS_DEBUG
-
-/*
- * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
- */
-#define EXT2_PREALLOCATE
-#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
-
-/*
- * The second extended file system version
- */
-#define EXT2FS_DATE "95/08/09"
-#define EXT2FS_VERSION "0.5b"
-
-/*
* Special inode numbers
*/
#define EXT2_BAD_INO 1 /* Bad blocks inode */
@@ -59,14 +38,10 @@
*/
#define EXT2_SUPER_MAGIC 0xEF53
-#ifdef __KERNEL__
-#define EXT2_SB(sb) (&((sb)->u.ext2_sb))
-#else
/* Assume that user mode programs are passing in an ext2fs superblock, not
* a kernel struct super_block. This will allow us to call the feature-test
* macros from user land. */
#define EXT2_SB(sb) (sb)
-#endif
/*
* Maximal count of links to a file
@@ -80,20 +55,12 @@
#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */
#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE)
#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE)
-#ifdef __KERNEL__
-#define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
-#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
-#define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->addr_per_block_bits)
-#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size)
-#define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino)
-#else
#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino)
-#endif
#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32))
/*
@@ -102,13 +69,8 @@
#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
-#ifdef __KERNEL__
-# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size)
-# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block)
-#else
# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
-#endif
/*
* ACL structures
@@ -193,12 +155,7 @@ struct ext2_dx_countlimit {
/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */
#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8)
#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s))
-#ifdef __KERNEL__
-#define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block)
-#define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits)
-#else
#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
-#endif
/*
* Constants relative to the data blocks
@@ -365,38 +322,6 @@ struct ext2_inode_large {
#define i_size_high i_dir_acl
-#if defined(__KERNEL__) || defined(__linux__)
-#define i_reserved1 osd1.linux1.l_i_reserved1
-#define i_frag osd2.linux2.l_i_frag
-#define i_fsize osd2.linux2.l_i_fsize
-#define i_uid_low i_uid
-#define i_gid_low i_gid
-#define i_uid_high osd2.linux2.l_i_uid_high
-#define i_gid_high osd2.linux2.l_i_gid_high
-#define i_reserved2 osd2.linux2.l_i_reserved2
-
-#else
-#if defined(__GNU__)
-
-#define i_translator osd1.hurd1.h_i_translator
-#define i_frag osd2.hurd2.h_i_frag;
-#define i_fsize osd2.hurd2.h_i_fsize;
-#define i_uid_high osd2.hurd2.h_i_uid_high
-#define i_gid_high osd2.hurd2.h_i_gid_high
-#define i_author osd2.hurd2.h_i_author
-
-#else
-#if defined(__masix__)
-
-#define i_reserved1 osd1.masix1.m_i_reserved1
-#define i_frag osd2.masix2.m_i_frag
-#define i_fsize osd2.masix2.m_i_fsize
-#define i_reserved2 osd2.masix2.m_i_reserved2
-
-#endif /* __masix__ */
-#endif /* __GNU__ */
-#endif /* defined(__KERNEL__) || defined(__linux__) */
-
/*
* File system states
*/
diff --git a/e2fsprogs/ext2fs/ext2fs.h b/e2fsprogs/ext2fs/ext2fs.h
index b8752a5..76d2ddd 100644
--- a/e2fsprogs/ext2fs/ext2fs.h
+++ b/e2fsprogs/ext2fs/ext2fs.h
@@ -12,33 +12,14 @@
#ifndef _EXT2FS_EXT2FS_H
#define _EXT2FS_EXT2FS_H
-#ifdef __GNUC__
-#define EXT2FS_ATTR(x) __attribute__(x)
-#else
+
#define EXT2FS_ATTR(x)
-#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
- * Non-GNU C compilers won't necessarily understand inline
- */
-#if (!defined(__GNUC__) && !defined(__WATCOMC__))
-#define NO_INLINE_FUNCS
-#endif
-
-/*
- * Build in support for byte-swapping filesystems if we the feature
- * has been configured or if we're being built on a CPU architecture
- * with a non-native byte order.
- */
-#if defined(ENABLE_SWAPFS) || defined(WORDS_BIGENDIAN) || __BYTE_ORDER== __BIG_ENDIAN
-#define EXT2FS_ENABLE_SWAPFS
-#endif
-
-/*
* Where the master copy of the superblock is located, and how big
* superblocks are supposed to be. We define SUPERBLOCK_SIZE because
* the size of the superblock structure is not necessarily trustworthy
@@ -74,15 +55,6 @@ typedef __u32 ext2_dirhash_t;
#include "ext2_io.h"
#include "ext2_err.h"
-/*
- * Portability help for Microsoft Visual C++
- */
-#ifdef _MSC_VER
-#define EXT2_QSORT_TYPE int __cdecl
-#else
-#define EXT2_QSORT_TYPE int
-#endif
-
typedef struct struct_ext2_filsys *ext2_filsys;
struct ext2fs_struct_generic_bitmap {
@@ -104,12 +76,7 @@ typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
-#ifdef EXT2_DYNAMIC_REV
#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
-#else
-#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO
-#define EXT2_INODE_SIZE(s) sizeof(struct ext2_inode)
-#endif
/*
* badblocks list definitions
@@ -609,7 +576,7 @@ extern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist);
extern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino,
blk_t blk, int blockcnt);
extern void ext2fs_dblist_sort(ext2_dblist dblist,
- EXT2_QSORT_TYPE (*sortfunc)(const void *,
+ int (*sortfunc)(const void *,
const void *));
extern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist,
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 1202b35..07805b1 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,
void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((block < bitmap->start) || (block > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
- bitmap->description);
- return;
- }
-#endif
ext2fs_set_bit(block - bitmap->start, bitmap->bitmap);
}
void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((block < bitmap->start) || (block > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK,
- block, bitmap->description);
- return;
- }
-#endif
ext2fs_clear_bit(block - bitmap->start, bitmap->bitmap);
}
int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block)
{
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((block < bitmap->start) || (block > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
- block, bitmap->description);
- return 0;
- }
-#endif
return ext2fs_test_bit(block - bitmap->start, bitmap->bitmap);
}
void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((inode < bitmap->start) || (inode > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_MARK,
- inode, bitmap->description);
- return;
- }
-#endif
ext2fs_set_bit(inode - bitmap->start, bitmap->bitmap);
}
void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((inode < bitmap->start) || (inode > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_UNMARK,
- inode, bitmap->description);
- return;
- }
-#endif
ext2fs_clear_bit(inode - bitmap->start, bitmap->bitmap);
}
int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((inode < bitmap->start) || (inode > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_INODE_TEST,
- inode, bitmap->description);
- return 0;
- }
-#endif
return ext2fs_test_bit(inode - bitmap->start, bitmap->bitmap);
}
@@ -355,13 +313,6 @@ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
{
int i;
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST,
- block, bitmap->description);
- return 0;
- }
-#endif
for (i=0; i < num; i++) {
if (ext2fs_fast_test_block_bitmap(bitmap, block+i))
return 0;
@@ -388,13 +339,6 @@ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
{
int i;
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block,
- bitmap->description);
- return;
- }
-#endif
for (i=0; i < num; i++)
ext2fs_set_bit(block + i - bitmap->start, bitmap->bitmap);
}
@@ -417,14 +361,6 @@ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
blk_t block, int num)
{
int i;
-
-#ifdef EXT2FS_DEBUG_FAST_OPS
- if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
- ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block,
- bitmap->description);
- return;
- }
-#endif
for (i=0; i < num; i++)
ext2fs_clear_bit(block + i - bitmap->start, bitmap->bitmap);
}
diff --git a/e2fsprogs/ext2fs/ext_attr.c b/e2fsprogs/ext2fs/ext_attr.c
index 10b8bfd..17610a9 100644
--- a/e2fsprogs/ext2fs/ext_attr.c
+++ b/e2fsprogs/ext2fs/ext_attr.c
@@ -12,15 +12,12 @@
*/
#include <stdio.h>
-#if HAVE_UNISTD_H
#include <unistd.h>
-#endif
#include <string.h>
#include <time.h>
#include "ext2_fs.h"
#include "ext2_ext_attr.h"
-
#include "ext2fs.h"
errcode_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)
retval = io_channel_read_blk(fs->io, block, 1, buf);
if (retval)
return retval;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & (EXT2_FLAG_SWAP_BYTES|
EXT2_FLAG_SWAP_BYTES_READ)) != 0)
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)
char *write_buf;
char *buf = NULL;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)) {
retval = ext2fs_get_mem(fs->blocksize, &buf);
diff --git a/e2fsprogs/ext2fs/ind_block.c b/e2fsprogs/ext2fs/ind_block.c
index 3e6cdc1..4728fe7 100644
--- a/e2fsprogs/ext2fs/ind_block.c
+++ b/e2fsprogs/ext2fs/ind_block.c
@@ -22,7 +22,7 @@
errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
{
errcode_t retval;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
blk_t *block_nr;
int i;
int limit = fs->blocksize >> 2;
@@ -36,7 +36,7 @@ errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
if (retval)
return retval;
}
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_READ)) {
block_nr = (blk_t *) buf;
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)
errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf)
{
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
blk_t *block_nr;
int i;
int limit = fs->blocksize >> 2;
@@ -57,7 +57,7 @@ errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf)
if (fs->flags & EXT2_FLAG_IMAGE_FILE)
return 0;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (fs->flags & (EXT2_FLAG_SWAP_BYTES | EXT2_FLAG_SWAP_BYTES_WRITE)) {
block_nr = (blk_t *) buf;
for (i = 0; i < limit; i++, block_nr++)
diff --git a/e2fsprogs/ext2fs/inode.c b/e2fsprogs/ext2fs/inode.c
index 4c386c7..db52018 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,
scan->ptr += scan->inode_size - extra_bytes;
scan->bytes_left -= scan->inode_size - extra_bytes;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
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,
retval = EXT2_ET_BAD_BLOCK_IN_INODE_TABLE;
scan->scan_flags &= ~EXT2_SF_BAD_EXTRA_BYTES;
} else {
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
ext2fs_swap_inode_full(scan->fs,
@@ -574,7 +574,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
block_nr++;
}
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
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,
w_inode = &temp_inode;
memset(w_inode, 0, length);
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))
ext2fs_swap_inode_full(fs, w_inode,
diff --git a/e2fsprogs/ext2fs/openfs.c b/e2fsprogs/ext2fs/openfs.c
index aa60333..646ec4d 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,
int groups_per_block, blocks_per_group;
blk_t group_block, blk;
char *dest, *cp;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
int j;
struct ext2_group_desc *gdp;
#endif
@@ -175,7 +175,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
if (fs->orig_super)
memcpy(fs->orig_super, fs->super, SUPERBLOCK_SIZE);
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if ((fs->super->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) ||
(fs->flags & EXT2_FLAG_SWAP_BYTES)) {
fs->flags |= EXT2_FLAG_SWAP_BYTES;
@@ -277,7 +277,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
retval = io_channel_read_blk(fs->io, blk, 1, dest);
if (retval)
goto cleanup;
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
gdp = (struct ext2_group_desc *) dest;
for (j=0; j < groups_per_block; j++)
diff --git a/e2fsprogs/ext2fs/rw_bitmaps.c b/e2fsprogs/ext2fs/rw_bitmaps.c
index d5698a2..50f2a94 100644
--- a/e2fsprogs/ext2fs/rw_bitmaps.c
+++ b/e2fsprogs/ext2fs/rw_bitmaps.c
@@ -27,7 +27,7 @@
#include "ext2fs.h"
#include "e2image.h"
-#if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS)
+#if defined(__powerpc__) && BB_BIG_ENDIAN
/*
* On the PowerPC, the big-endian variant of the ext2 filesystem
* has its bitmaps stored as 32-bit words with bit 0 as the LSB
diff --git a/e2fsprogs/ext2fs/swapfs.c b/e2fsprogs/ext2fs/swapfs.c
index af8b6eb..0c01806 100644
--- a/e2fsprogs/ext2fs/swapfs.c
+++ b/e2fsprogs/ext2fs/swapfs.c
@@ -10,9 +10,7 @@
*/
#include <stdio.h>
-#if HAVE_UNISTD_H
#include <unistd.h>
-#endif
#include <string.h>
#include <time.h>
@@ -20,7 +18,7 @@
#include "ext2fs.h"
#include "ext2_ext_attr.h"
-#ifdef EXT2FS_ENABLE_SWAPFS
+#if BB_BIG_ENDIAN
void ext2fs_swap_super(struct ext2_super_block * sb)
{
int i;
diff --git a/e2fsprogs/ext2fs/unix_io.c b/e2fsprogs/ext2fs/unix_io.c
index 7f57afd..69d01f4 100644
--- a/e2fsprogs/ext2fs/unix_io.c
+++ b/e2fsprogs/ext2fs/unix_io.c
@@ -34,9 +34,7 @@
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
-#endif
#include "ext2_fs.h"
#include "ext2fs.h"
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c
index 9481556..adf34c4 100644
--- a/e2fsprogs/fsck.c
+++ b/e2fsprogs/fsck.c
@@ -1175,14 +1175,6 @@ static int check_all(void)
return status;
}
-#if 0
-static void usage(void)
-{
- fputs("Usage: fsck [-ANPRTV] [ -C [ fd ] ] [-t fstype] [fs-options] [filesys ...]\n", stderr);
- exit(EXIT_USAGE);
-}
-#endif
-
static void signal_cancel(int sig FSCK_ATTR((unused)))
{
cancel_requested++;
@@ -1300,13 +1292,13 @@ static void PRS(int argc, char *argv[])
case 't':
tmp = 0;
if (fstype)
- usage();
+ bb_show_usage();
if (arg[j+1])
tmp = arg+j+1;
else if ((i+1) < argc)
tmp = argv[++i];
else
- usage();
+ bb_show_usage();
fstype = string_copy(tmp);
compile_fs_type(fstype, &fs_type_compiled);
goto next_arg;
@@ -1314,7 +1306,7 @@ static void PRS(int argc, char *argv[])
opts_for_fsck++;
break;
case '?':
- usage();
+ bb_show_usage();
break;
default:
options[++opt] = arg[j];
diff --git a/e2fsprogs/fsck.h b/e2fsprogs/fsck.h
index 8ae8f42..12748a1 100644
--- a/e2fsprogs/fsck.h
+++ b/e2fsprogs/fsck.h
@@ -11,6 +11,5 @@
#define EXIT_ERROR 8
#define EXIT_USAGE 16
#define FSCK_CANCELED 32 /* Aborted with a signal or ^C */
-#define EXIT_LIBRARY 128
extern char *e2fs_set_sbin_path(void);
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index b5ec8ab..1f21766 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -33,12 +33,6 @@
#include "e2fsbb.h"
#include "e2p/e2p.h"
-#ifdef __GNUC__
-# define EXT2FS_ATTR(x) __attribute__(x)
-#else
-# define EXT2FS_ATTR(x)
-#endif
-
#define OPT_RECUR 1
#define OPT_ALL 2
#define OPT_DIRS_OPT 4
@@ -98,7 +92,7 @@ static void lsattr_args(const char *name)
}
static int lsattr_dir_proc(const char *dir_name, struct dirent *de,
- void *private EXT2FS_ATTR((unused)))
+ void *private)
{
STRUCT_STAT st;
char *path;
diff --git a/e2fsprogs/uuid/gen_uuid.c b/e2fsprogs/uuid/gen_uuid.c
index fca3ebe..d847774 100644
--- a/e2fsprogs/uuid/gen_uuid.c
+++ b/e2fsprogs/uuid/gen_uuid.c
@@ -44,9 +44,7 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
-#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
-#endif
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif