ChangeLog, .del-io.h~72680822, irel_ma.c, llseek.c, rw_bitmaps.c:
  io.h: Change the prototype of ext2fs_llseek() to use int's instead of
  	unsigned int's.
  llseek.c: Change to allow PIC and !HAVE_LLSEEK.  Add a prototype to
  	make life easer for GNU Libc 2.
  rw_bitmaps.c: 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 of each word.  Thus a bitmap with only bit 0 set would be, as a
  	string of bytes, 00 00 00 01 00 ...  To cope with this, we
  	byte-reverse each word of a bitmap if we have a big-endian filesystem,
  	that is, if we are *not* byte-swapping other word-sized numbers.
ChangeLog, expect.1, image.gz:
  f_badinode: Modify test to check for "bad" character and block devices
  	(i.e., ones which contain garbage block entries)

diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 68e9ed0..47ee666 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,19 @@
+Thu Aug 14 08:14:17 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* io.h: Change the prototype of ext2fs_llseek() to use int's
+		instead of unsigned int's.
+
+	* llseek.c: Change to allow PIC and !HAVE_LLSEEK.  Add a prototype
+		to make life easer for GNU Libc 2.
+
+	* rw_bitmaps.c: 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 of each word.  Thus a bitmap with only bit 0
+ 		set would be, as a string of bytes, 00 00 00 01 00 ...  To
+ 		cope with this, we byte-reverse each word of a bitmap if
+ 		we have a big-endian filesystem, that is, if we are *not*
+ 		byte-swapping other word-sized numbers.
+
 Mon Aug 11 03:30:48 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* dosio.c: New file to do DOS/BIOS disk accesses.
diff --git a/lib/ext2fs/io.h b/lib/ext2fs/io.h
index efc8ff8..f40d56e 100644
--- a/lib/ext2fs/io.h
+++ b/lib/ext2fs/io.h
@@ -19,7 +19,7 @@
 #endif
 
 /* llseek.c */
-ext2_loff_t ext2fs_llseek (unsigned int, ext2_loff_t, unsigned int);
+ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
 
 typedef struct struct_io_manager *io_manager;
 typedef struct struct_io_channel *io_channel;
diff --git a/lib/ext2fs/irel_ma.c b/lib/ext2fs/irel_ma.c
index 8a9ac74..54b71dd 100644
--- a/lib/ext2fs/irel_ma.c
+++ b/lib/ext2fs/irel_ma.c
@@ -336,7 +336,7 @@
 		free(ma->ref_entries[(unsigned) old].refs);
 	ma->orig_map[ma->entries[(unsigned) old].orig] = 0;
 	
-	ma->ref_entries[(unsinged) old].num = 0;
+	ma->ref_entries[(unsigned) old].num = 0;
 	ma->ref_entries[(unsigned) old].refs = 0;
 	return 0;
 }
diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c
index 9e9d484..cd47b2d 100644
--- a/lib/ext2fs/llseek.c
+++ b/lib/ext2fs/llseek.c
@@ -1,7 +1,7 @@
 /*
  * llseek.c -- stub calling the llseek system call
  *
- * Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
+ * Copyright (C) 1994, 1995, 1996, 1997 Theodore Ts'o.
  *
  * %Begin-Header%
  * This file may be redistributed under the terms of the GNU Public
@@ -30,6 +30,12 @@
 #endif
 #include <syscall.h>
 
+#if (__GLIBC__ == 2)
+ext2_loff_t llseek (int fd, ext2_loff_t offset, int origin)
+#endif
+
+#define my_llseek llseek
+
 #else	/* HAVE_LLSEEK */
 
 #ifdef __alpha__
@@ -44,21 +50,26 @@
 #define __NR__llseek            140
 #endif
 
+#ifndef __i386__
 static int _llseek (unsigned int, unsigned long,
 		   unsigned long, ext2_loff_t *, unsigned int);
 
 static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high,
 		 unsigned long, offset_low,ext2_loff_t *,result,
 		 unsigned int, origin)
+#endif
 
-static ext2_loff_t llseek (unsigned int fd, ext2_loff_t offset,
-		unsigned int origin)
+static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin)
 {
 	ext2_loff_t result;
 	int retval;
 
-	retval = _llseek (fd, ((unsigned long long) offset) >> 32,
-			((unsigned long long) offset) & 0xffffffff,
+#ifndef __i386__
+	retval = _llseek(fd, ((unsigned long long) offset) >> 32,
+#else			  
+	retval = syscall(__NR__llseek, fd, (unsigned long long) (offset >> 32),
+#endif
+			  ((unsigned long long) offset) & 0xffffffff,
 			&result, origin);
 	return (retval == -1 ? (ext2_loff_t) retval : result);
 }
@@ -67,8 +78,7 @@
 
 #endif /* __alpha__ */
 
-ext2_loff_t ext2fs_llseek (unsigned int fd, ext2_loff_t offset,
-			 unsigned int origin)
+ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin)
 {
 	ext2_loff_t result;
 	static int do_compat = 0;
@@ -82,7 +92,7 @@
 		return -1;
 	}
 	
-	result = llseek (fd, offset, origin);
+	result = my_llseek (fd, offset, origin);
 	if (result == -1 && errno == ENOSYS) {
 		/*
 		 * Just in case this code runs on top of an old kernel
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 5deca2c..d3aa7bb 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -27,6 +27,30 @@
 
 #include "ext2fs.h"
 
+#ifdef __powerpc__
+/*
+ * 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
+ * of each word.  Thus a bitmap with only bit 0 set would be, as
+ * a string of bytes, 00 00 00 01 00 ...
+ * To cope with this, we byte-reverse each word of a bitmap if
+ * we have a big-endian filesystem, that is, if we are *not*
+ * byte-swapping other word-sized numbers.
+ */
+#define EXT2_BIG_ENDIAN_BITMAPS
+#endif
+
+#ifdef EXT2_BIG_ENDIAN_BITMAPS
+void ext2fs_swap_bitmap(ext2_filsys fs, char *bitmap, int nbytes)
+{
+	__u32 *p = (__u32 *) bitmap;
+	int n;
+		
+	for (n = nbytes / sizeof(__u32); n > 0; --n, ++p)
+		*p = ext2fs_swab32(*p);
+}
+#endif
+
 errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs)
 {
 	int 		i;
@@ -52,6 +76,11 @@
 		memcpy(bitmap_block, inode_bitmap, nbytes);
 		blk = fs->group_desc[i].bg_inode_bitmap;
 		if (blk) {
+#ifdef EXT2_BIG_ENDIAN_BITMAPS
+			if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
+			      (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)))
+				ext2fs_swap_bitmap(fs, bitmap_block, nbytes);
+#endif
 			retval = io_channel_write_blk(fs->io, blk, 1,
 						      bitmap_block);
 			if (retval)
@@ -100,6 +129,11 @@
 		}
 		blk = fs->group_desc[i].bg_block_bitmap;
 		if (blk) {
+#ifdef EXT2_BIG_ENDIAN_BITMAPS
+			if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
+			      (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)))
+				ext2fs_swap_bitmap(fs, bitmap_block, nbytes);
+#endif
 			retval = io_channel_write_blk(fs->io, blk, 1,
 						      bitmap_block);
 			if (retval)
@@ -158,6 +192,11 @@
 					retval = EXT2_ET_BLOCK_BITMAP_READ;
 					goto cleanup;
 				}
+#ifdef EXT2_BIG_ENDIAN_BITMAPS
+				if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
+				      (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)))
+					ext2fs_swap_bitmap(fs, block_bitmap, block_nbytes);
+#endif
 			} else
 				memset(block_bitmap, 0, block_nbytes);
 			block_bitmap += block_nbytes;
@@ -171,6 +210,11 @@
 					retval = EXT2_ET_INODE_BITMAP_READ;
 					goto cleanup;
 				}
+#ifdef EXT2_BIG_ENDIAN_BITMAPS
+				if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) ||
+				      (fs->flags & EXT2_FLAG_SWAP_BYTES_READ)))
+					ext2fs_swap_bitmap(fs, inode_bitmap, inode_nbytes);
+#endif
 			} else
 				memset(inode_bitmap, 0, inode_nbytes);
 			inode_bitmap += inode_nbytes;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index f9534ce..0543a9d 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 14 11:25:23 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* f_badinode: Modify test to check for "bad" character and block
+		devices (i.e., ones which contain garbage block entries)
+
 Tue Jun 17 01:33:20 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* Release of E2fsprogs 1.11
diff --git a/tests/f_badinode/expect.1 b/tests/f_badinode/expect.1
index b2da205..67120d0 100644
--- a/tests/f_badinode/expect.1
+++ b/tests/f_badinode/expect.1
@@ -11,6 +11,12 @@
 i_file_acl for inode 13 (/timings) is 39, should be zero.
 Clear? yes
 
+Inode 14 (/block_dev) is an illegal block device.
+Clear? yes
+
+Inode 15 (/char_dev) is an illegal character device.
+Clear? yes
+
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
@@ -19,8 +25,8 @@
 Block bitmap differences: -25.  FIXED
 Free blocks count wrong for group 0 (76, counted=77).  FIXED
 Free blocks count wrong (76, counted=77).  FIXED
-Free inodes count wrong for group #0 (19, counted=20).  FIXED
-Free inodes count wrong (19, counted=20).  FIXED
+Free inodes count wrong for group #0 (17, counted=20).  FIXED
+Free inodes count wrong (17, counted=20).  FIXED
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/32 files (0.0% non-contiguous), 23/100 blocks
diff --git a/tests/f_badinode/image.gz b/tests/f_badinode/image.gz
index 7b3ccd2..e399c4b 100644
--- a/tests/f_badinode/image.gz
+++ b/tests/f_badinode/image.gz
Binary files differ