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,
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"