aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs/ext2fs
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/ext2fs')
-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
17 files changed, 40 insertions, 245 deletions
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,
{
#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 4a53ebc4c..0015ba288 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 7e98c0fe5..afc271022 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 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,
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 73313faf3..aaac3b394 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 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,
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 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 {
__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 400587324..44b04beb7 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 b8752a56e..76d2ddd45 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 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,
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 10b8bfd9d..17610a914 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 3e6cdc138..4728fe7b5 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 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,
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 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,
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 d5698a221..50f2a9447 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 af8b6eb87..0c0180613 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 7f57afddc..69d01f49b 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"