Many files:
  Checkin of e2fsprogs 0.5b

diff --git a/e2fsck/.depend b/e2fsck/.depend
index e48c1af..e9715c6 100644
--- a/e2fsck/.depend
+++ b/e2fsck/.depend
@@ -3,227 +3,231 @@
   /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \
   /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \
   /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \
-  /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
-  /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \
+  /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \
+  /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \
   /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \
   /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \
   /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \
   /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \
   /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \
-  /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \
-  /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \
-  /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \
-  /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \
-  /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \
-  ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
+  /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
+  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \
+  /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \
+  ../lib/ext2fs/bitops.h 
 dirinfo.o : dirinfo.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
   e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
   /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
-  /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \
-  /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \
-  /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \
-  /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \
-  /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \
-  /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \
-  /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
-  /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \
-  /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \
-  /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \
-  /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
-  ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
-e2fsck.o : e2fsck.c /usr/include/string.h /usr/include/features.h /usr/include/sys/cdefs.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/fcntl.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/linux/fcntl.h /usr/include/ctype.h /usr/include/termios.h \
-  /usr/include/linux/termios.h /usr/include/time.h /usr/include/getopt.h /usr/include/unistd.h \
-  /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/mntent.h /usr/include/stdio.h \
-  /usr/include/libio.h /usr/include/_G_config.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \
-  /usr/include/malloc.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
-  e2fsck.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
-  /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \
+  /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
   /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
   /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
   /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
   /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
-  /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
-  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \
-  /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \
-  /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \
-  /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \
-  /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \
-  ../lib/ext2fs/bitops.h ../version.h 
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
+e2fsck.o : e2fsck.c /usr/include/string.h /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/fcntl.h /usr/include/sys/types.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/linux/fcntl.h \
+  /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h /usr/include/time.h \
+  /usr/include/getopt.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \
+  /usr/include/mntent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \
+  /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/malloc.h ../lib/et/com_err.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h e2fsck.h /usr/include/stdlib.h \
+  /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
+  /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
+  /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
+  /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
+  /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h ../version.h 
 ehandler.o : ehandler.c /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/unistd.h /usr/include/posix_opt.h \
-  /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \
-  /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h \
-  /usr/include/sys/resource.h /usr/include/sys/time.h /usr/include/linux/time.h \
-  /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h \
-  /usr/include/limits.h /usr/include/posix1_lim.h /usr/include/linux/limits.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/unistd.h \
+  /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \
+  /usr/include/asm/types.h /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h \
+  /usr/include/linux/termios.h /usr/include/sys/resource.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \
+  /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \
   /usr/include/linux/resource.h e2fsck.h /usr/include/stdio.h /usr/include/libio.h \
   /usr/include/_G_config.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \
   /usr/include/linux/linkage.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
   /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
   /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
   /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
-  /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
-  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \
-  /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \
-  /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \
-  /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \
-  /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
-  ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \
+  ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
 flushb.o : flushb.c /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
   /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \
-  /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \
+  /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/sys/ioctl.h \
+  /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \
   /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \
   /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \
   /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \
   /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \
   /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \
-  /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \
-  /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \
-  /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \
-  /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \
-  /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h 
+  /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
+  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h 
 mtrace.o : mtrace.c ./malloc.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
   /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/libio.h \
   /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \
   /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \
-  /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/stdlib.h \
-  /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h 
+  /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \
+  /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h 
 pass1.o : pass1.c /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \
   ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h e2fsck.h \
   /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \
   /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \
   /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \
-  /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
-  /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \
+  /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \
+  /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \
   /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \
   /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \
   /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \
   /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \
   /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \
-  /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \
-  /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \
-  /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \
-  /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \
-  /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \
-  ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
+  /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
+  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \
+  /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \
+  ../lib/ext2fs/bitops.h 
 pass1b.o : pass1b.c /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \
   ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h e2fsck.h \
   /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h \
   /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/unistd.h /usr/include/posix_opt.h \
   /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \
-  /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
-  /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \
+  /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \
+  /usr/include/linux/stat.h /usr/include/sys/time.h /usr/include/linux/time.h \
   /usr/include/linux/fs.h /usr/include/linux/linkage.h /usr/include/linux/limits.h \
   /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \
   /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \
   /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \
   /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \
-  /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h \
-  /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h \
-  /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h \
-  /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h \
-  /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h \
-  ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
+  /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
+  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \
+  /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \
+  ../lib/ext2fs/bitops.h 
 pass2.o : pass2.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
   e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
   /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
-  /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \
-  /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \
-  /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \
-  /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \
-  /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \
-  /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \
+  /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
+  /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
+  /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
+  /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
+  /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
   /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
-  /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \
-  /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \
-  /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \
-  /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
   ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
 pass3.o : pass3.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
   e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
   /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
-  /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \
-  /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \
-  /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \
-  /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \
-  /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \
-  /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \
+  /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
+  /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
+  /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
+  /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
+  /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
   /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
-  /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \
-  /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \
-  /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \
-  /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
   ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
 pass4.o : pass4.c e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
   /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
-  /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \
-  /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \
-  /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \
-  /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \
-  /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \
-  /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \
+  /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
+  /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
+  /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
+  /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
+  /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
   /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
-  /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \
-  /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \
-  /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \
-  /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
   ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \
   ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
 pass5.o : pass5.c ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
   e2fsck.h /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/include/libio.h /usr/include/_G_config.h /usr/include/string.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
   /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
-  /usr/include/sys/time.h /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h \
-  /usr/include/linux/linkage.h /usr/include/linux/limits.h /usr/include/linux/wait.h \
-  /usr/include/linux/dirent.h /usr/include/linux/vfs.h /usr/include/linux/net.h \
-  /usr/include/linux/socket.h /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h \
-  /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h \
-  /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/stdlib.h /usr/include/errno.h \
+  /usr/include/linux/errno.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/time.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
+  /usr/include/linux/limits.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
+  /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
+  /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
+  /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
   /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
-  /usr/include/linux/sysv_fs_i.h /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h \
-  /usr/include/linux/ext2_fs_sb.h /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h \
-  /usr/include/linux/iso_fs_sb.h /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h \
-  /usr/include/linux/sysv_fs_sb.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
   ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
+scantest.o : scantest.c /usr/include/string.h /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/fcntl.h /usr/include/sys/types.h \
+  /usr/include/linux/types.h /usr/include/asm/types.h /usr/include/linux/fcntl.h \
+  /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h /usr/include/time.h \
+  /usr/include/getopt.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \
+  /usr/include/mntent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \
+  /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/malloc.h /usr/include/sys/resource.h \
+  /usr/include/sys/time.h /usr/include/linux/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \
+  /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \
+  /usr/include/linux/resource.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
+  ../version.h /usr/include/stdlib.h /usr/include/errno.h /usr/include/linux/errno.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/sys/stat.h \
+  /usr/include/linux/stat.h /usr/include/linux/fs.h /usr/include/linux/linkage.h \
+  /usr/include/linux/wait.h /usr/include/linux/dirent.h /usr/include/linux/vfs.h \
+  /usr/include/linux/net.h /usr/include/linux/socket.h /usr/include/linux/sockios.h \
+  /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h /usr/include/linux/ext_fs_i.h \
+  /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h /usr/include/linux/msdos_fs_i.h \
+  /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
+  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \
+  /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h \
+  ../lib/ext2fs/bitops.h 
 util.o : util.c /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/unistd.h /usr/include/posix_opt.h \
-  /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \
-  /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h /usr/include/linux/termios.h \
-  /usr/include/sys/resource.h /usr/include/sys/time.h /usr/include/linux/time.h \
-  /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h \
-  /usr/include/limits.h /usr/include/posix1_lim.h /usr/include/linux/limits.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/alloca.h /usr/include/unistd.h \
+  /usr/include/posix_opt.h /usr/include/gnu/types.h /usr/include/sys/types.h /usr/include/linux/types.h \
+  /usr/include/asm/types.h /usr/include/string.h /usr/include/ctype.h /usr/include/termios.h \
+  /usr/include/linux/termios.h /usr/include/sys/resource.h /usr/include/sys/time.h \
+  /usr/include/linux/time.h /usr/include/time.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/limits.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/syslimits.h /usr/include/limits.h \
+  /usr/include/posix1_lim.h /usr/include/linux/limits.h /usr/include/posix2_lim.h \
   /usr/include/linux/resource.h e2fsck.h /usr/include/stdio.h /usr/include/libio.h \
   /usr/include/_G_config.h /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/fs.h \
   /usr/include/linux/linkage.h /usr/include/linux/wait.h /usr/include/linux/dirent.h \
   /usr/include/linux/vfs.h /usr/include/linux/net.h /usr/include/linux/socket.h \
   /usr/include/linux/sockios.h /usr/include/linux/pipe_fs_i.h /usr/include/linux/minix_fs_i.h \
   /usr/include/linux/ext_fs_i.h /usr/include/linux/ext2_fs_i.h /usr/include/linux/hpfs_fs_i.h \
-  /usr/include/linux/msdos_fs_i.h /usr/include/linux/iso_fs_i.h /usr/include/linux/nfs_fs_i.h \
-  /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h /usr/include/linux/sysv_fs_i.h \
-  /usr/include/linux/minix_fs_sb.h /usr/include/linux/ext_fs_sb.h /usr/include/linux/ext2_fs_sb.h \
-  /usr/include/linux/hpfs_fs_sb.h /usr/include/linux/msdos_fs_sb.h /usr/include/linux/iso_fs_sb.h \
-  /usr/include/linux/nfs_fs_sb.h /usr/include/linux/xia_fs_sb.h /usr/include/linux/sysv_fs_sb.h \
-  /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
-  ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
+  /usr/include/linux/msdos_fs_i.h /usr/include/linux/umsdos_fs_i.h /usr/include/linux/iso_fs_i.h \
+  /usr/include/linux/nfs_fs_i.h /usr/include/linux/nfs.h /usr/include/linux/xia_fs_i.h \
+  /usr/include/linux/sysv_fs_i.h /usr/include/linux/ext2_fs.h ../lib/ext2fs/ext2fs.h \
+  ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h \
+  ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h 
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
new file mode 100644
index 0000000..be0ac6c
--- /dev/null
+++ b/e2fsck/ChangeLog
@@ -0,0 +1,70 @@
+Sat Mar 11 13:12:16 1995  Theodore Y. Ts'o  <tytso@localhost>
+
+	* pass1.c (unwind_pass1): Clear the file type statistics counter
+		when pass 1 needs to be restarted from scratch.
+
+	* pass1.c (handle_fs_bad_blocks): Fix bug where bitmap blocks were
+		being reallocated to blocks in the next block group,
+		instead of the current block grup.
+
+	* pass1.c (pass1, check_blocks): Set inode_link_info[ino] whenever
+		inode.i_links_count is set.
+
+Tue Feb 14 01:38:04 1995  Theodore Y. Ts'o  (tytso@rt-11)
+
+	* pass1.c (process_block): Add checks for if the block is
+		trepassing on a superblock or group descriptor table.
+
+Sat Dec 31 00:52:11 1994    <tytso@rsx-11.mit.edu>
+
+	* main.c (corrupt_msg): Extend the message which is printed out
+		when the superblock is corrupt, to include the suggestion
+		of using the -b option to specify an alternate superblock.
+
+Thu Nov 24 09:29:58 1994  Theodore Y. Ts'o  (tytso@rt-11)
+
+	* badblocks.c (read_bad_blocks_file): If we are adding or
+		replacing bad blocks in the bad blocks inode, sanity check
+		the bad block inode first, and clear out any illegal blocks.
+
+	* pass2.c (check_name): Don't bomb out if the attempt to get the
+		pathname of the containing directory returns an error; the
+		directory may be too badly damaged to expect that
+		ext2fs_get_pathname will always succeed.  Use "???" if the
+		pathname can't be obtained (it's only for a printf to the
+		user anyway).
+
+		The name of the containing directory and the bad filename
+		were incorrectly interchanged in the user message.  Fixed.
+
+	* pass2.c (check_name, check_dir_block): Use a common static
+		string for the unknown pathname.
+
+Mon Nov  7 22:30:54 1994  Remy Card  <card@bbj>
+
+	* Fixed lots of printf formats to make sure that block and inode
+	numbers are printed as unsigned integers.
+
+Mon Oct 24 14:10:46 1994    (tytso@rsx-11)
+
+	* pass5.c (check_block_end): Fix calculation of how the last block
+		in the block bitmap should be calculated.
+
+Wed Sep  7 10:01:13 1994    (tytso@rsx-11)
+
+	* pass1b.c (pass1_dupblocks): Fix declaration of dup_inode_map to
+		be an ext2fs_inode_bitmap, and free it properly.
+
+	* e2fsck.h
+	* e2fsck.c (main): Folded in Remy Card's changes to add a revision
+	level to the superblock.
+
+Wed Aug 17 22:00:20 1994  Remy Card  (card@bbj)
+
+	* e2fsck.c (usage): Fixed bogus usage message.
+
+Wed Aug 17 11:21:45 1994  Theodore Y. Ts'o  (tytso@rt-11)
+
+	* pass1.c (process_bad_block): Fixed bug so that blocks in the
+	backup superblocks and group descriptors are handled gracefully.
+
diff --git a/e2fsck/Makefile b/e2fsck/Makefile
index c0c64c6..a8e0f75 100644
--- a/e2fsck/Makefile
+++ b/e2fsck/Makefile
@@ -9,8 +9,6 @@
 LDFLAGS=	$(PROF) $(OPT)
 PROGS=		e2fsck flushb
 MANPAGES=	e2fsck.8
-BINDIR=		$(SBINDIR)
-MANDIR=		$(SMANDIR)
 
 LIBS= -L../lib -lss -lcom_err -lext2fs $(CHECKLIB)
 DEPLIBS= ../lib/libss.a ../lib/libcom_err.a ../lib/libext2fs.a
@@ -20,7 +18,7 @@
 #	Note: The optimization flags must include -g
 #
 #MCHECK=	-checker
-#LIBS= -L../lib -lss -lcom_err -lext2fs $(CHECKLIB)
+#LIBS= -L../lib -lss -lcom_err -le2fs $(CHECKLIB)
 #DEPLIBS= ../lib/libss.a ../lib/libcom_err.a ../lib/libext2fs.a
 #CHECKLIB= /usr/lib/libchecker.o
 
@@ -54,26 +52,34 @@
 #	cc $(LDFLAGS) -o e2fsck $(OBJS) $(LIBS) 
 
 e2fsck: $(OBJS)  $(DEPLIBS)
-	cc $(LDFLAGS) -static -o e2fsck $(OBJS) $(LIBS) 
+	$(CC) $(LDFLAGS) -static -o e2fsck $(OBJS) $(LIBS) 
 
 flushb: flushb.o
-	cc $(LDFLAGS) -o flushb flushb.o $(CHECKLIB)
+	$(CC) $(LDFLAGS) -o flushb flushb.o $(CHECKLIB)
 
 install:: $(PROGS)
-	for i in $(PROGS); do \
-		$(INSTALLBIN) $$i $(BINDIR)/$$i; \
-	done
-	ln -sf e2fsck $(BINDIR)/fsck.ext2
+	$(INSTALLBIN) e2fsck $(SBINDIR)/e2fsck
+	$(INSTALLBIN) flushb $(USRSBINDIR)/flushb
+	ln -sf e2fsck $(SBINDIR)/fsck.ext2
 
 install:: $(MANPAGES)
 	for i in $(MANPAGES); do \
-		$(INSTALLMAN) $$i $(MANDIR)/$$i; \
+		$(INSTALLMAN) $$i $(SMANDIR)/$$i; \
 	done
 
+install-tree:: $(PROGS)
+	for i in $(PROGS); do \
+		rm -f ../bin/$$i; \
+		cp $$i ../bin; \
+		strip ../bin/$$i; \
+		chmod 555 ../bin/$$i; \
+	done
+	ln -sf e2fsck ../bin/fsck.ext2
+
 clean:
 	rm -f $(PROGS) \#* *\# *.s *.o *.a *~ core
 
-really-clean:
+really-clean: clean
 	rm -f .depend
 
 dep depend .depend:
diff --git a/e2fsck/badblocks.c b/e2fsck/badblocks.c
index 6dff23d..62f99c9 100644
--- a/e2fsck/badblocks.c
+++ b/e2fsck/badblocks.c
@@ -10,6 +10,10 @@
 #include <et/com_err.h>
 #include "e2fsck.h"
 
+static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt,
+				 void *private);
+
+
 static void invalid_block(ext2_filsys fs, blk_t blk)
 {
 	printf("Bad block %lu out of range; ignored.\n", blk);
@@ -24,6 +28,19 @@
 	FILE		*f;
 
 	read_bitmaps(fs);
+
+	/*
+	 * Make sure the bad block inode is sane.  If there are any
+	 * illegal blocks, clear them.
+	 */
+	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");
+		fatal_error(0);
+	}
+	
 	
 	/*
 	 * If we're appending to the bad blocks inode, read in the
@@ -69,6 +86,25 @@
 	return;
 }
 
+static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt,
+				 void *private)
+{
+	if (!*block_nr)
+		return 0;
+
+	/*
+	 * If the block number is outrageous, clear it and ignore it.
+	 */
+	if (*block_nr >= fs->super->s_blocks_count ||
+	    *block_nr < fs->super->s_first_data_block) {
+		printf("Warning illegal block %lu found in bad block inode.  Cleared.\n", *block_nr);
+		*block_nr = 0;
+		return BLOCK_CHANGED;
+	}
+
+	return 0;
+}
+
 void test_disk(ext2_filsys fs)
 {
 	errcode_t	retval;
diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c
index 101ccee..6c78dd1 100644
--- a/e2fsck/dirinfo.c
+++ b/e2fsck/dirinfo.c
@@ -35,7 +35,7 @@
 	int	i, j;
 
 #if 0
-	printf("add_dir_info for inode %d...\n", ino);
+	printf("add_dir_info for inode %lu...\n", ino);
 #endif
 	if (!dir_info) {
 		dir_info_count = 0;
diff --git a/e2fsck/e2fsck.8 b/e2fsck/e2fsck.8
index d79903c..ca82963 100644
--- a/e2fsck/e2fsck.8
+++ b/e2fsck/e2fsck.8
@@ -2,7 +2,7 @@
 .\" Copyright 1993, 1994 by Theodore Ts'o.  All Rights Reserved.
 .\" This file may be copied under the terms of the GNU Public License.
 .\" 
-.TH NEW-E2FSCK 8 "March 1994" "Version 0.5"
+.TH E2FSCK 8 "November 1994" "Version 0.5b"
 .SH NAME
 e2fsck \- check a Linux second extended file system
 .SH SYNOPSIS
@@ -31,11 +31,26 @@
 is the special file corresponding to the device (e.g /dev/hdXX).
 .SH OPTIONS
 .TP
+.I -a 
+This option does the same thing as the 
+.I -p
+option.  It is provided for backwards compatibility only; it is
+suggested that people use 
+.I -p 
+option whever possible.
+.TP
 .I -b superblock
 Instead of using the normal superblock, use the alternative superblock
 specified by 
 .IR superblock .
 .TP
+.I -B blocksize
+Normally, e2fsck will search for the superblock at various different
+block sizes in an attempt to find the appropriate block size.  This
+search can be fooled in some cases.  This option forces e2fsck to only
+try locating the superblock at a particular blocksize.  If the
+superblock is not found, e2fsck will terminate with a fatal error.
+.TP
 .I -d
 Print debugging output (useless unless you are debugging
 .B e2fsck
@@ -77,9 +92,10 @@
 .TP
 .I -p
 Automatically repair ("preen") the file system without any questions.
-The
-.I -a
-option is provided for backwards compatibility.
+.TP
+.I -r
+This option does nothing at all; it is provided only for backwards
+compatibility.
 .TP
 .I -t
 Print timing statistics for
@@ -118,10 +134,48 @@
 .br
 \	128\	\-\ Shared library error
 .br
+.SH BUGS
+Almost any piece of software will have bugs.  If you manage to find a
+filesystem which causes 
+.B e2fsck
+to crash, or which 
+.B e2fsck
+is unable to repair, please report it to the author.
+.PP
+Please include as much information as possible in your bug report.
+Ideally, include a complete transcript of the
+.B e2fsck
+run, so I can see exactly what error messages are displayed.  If you
+have a writeable filesystem where the transcript can be stored, the 
+.BR script (1)
+program is a handy way to save the output of
+.e2fsck
+to a file.
+.PP
+It is also useful to send the output of 
+.BR dumpe2fs (8).
+If a specific inode or inodes seems to be giving 
+.B e2fsck 
+trouble, try running the
+.BR debugfs (8)
+command and send the output of the 
+.I stat
+command run on the relevant inode(s).  If the inode is a directory, 
+the debugfs
+.I dump
+command will allow you to extract the contents of the directory inode,
+which can sent to me after being first run through
+.BR uuencode (1).
+.PP
+Always include the full version string which 
+.B e2fsck
+displays when it is run, so I know which version you are running.
 .SH AUTHOR
 This version of 
 .B e2fsck
 is written by Theodore Ts'o <tytso@mit.edu>.
 .SH SEE ALSO
 .BR mke2fs (8),
-.BR tune2fs (8)
+.BR tune2fs (8),
+.BR dumpe2fs (8),
+.BR debugfs (8)
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index 37d202b..78fe3c9 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -51,6 +51,7 @@
 int list = 0;
 int debug = 0;
 int force = 0;
+int invalid_bitmaps = 0;
 static int show_version_only = 0;
 
 static int replace_bad_blocks = 0;
@@ -63,11 +64,17 @@
 static int root_filesystem = 0;
 static int read_only_root = 0;
 
+int *invalid_inode_bitmap;
+int *invalid_block_bitmap;
+int *invalid_inode_table;
+int restart_e2fsck = 0;
+
 static void usage(NOARGS)
 {
 	fprintf(stderr,
-		"Usage: %s [-panyrdfvtFV] [-b superblock] [-B blocksize]\n"
-		"\t\tdevice\n", program_name);
+		"Usage: %s [-panyrcdfvtFV] [-b superblock] [-B blocksize]\n"
+		"\t\t[-I inode_buffer_blocks] [-P process_inode_size]\n"
+		"\t\t[-l|-L bad_blocks_file] device\n", program_name);
 	exit(FSCK_USAGE);
 }
 
@@ -182,34 +189,133 @@
 	sync();
 }
 
+#define MIN_CHECK 1
+#define MAX_CHECK 2
+
+static const char *corrupt_msg = "\nThe filesystem superblock is corrupt.  "
+	"Try running e2fsck with an alternate\n"
+	"superblock using the -b option.  "
+	"(8193 is commonly an alternate superblock;\n"
+	"Hence, 'e2fsck -b 8193 <device>' may recover the filesystem.)\n\n";
+
+static void check_super_value(const char *descr, unsigned long value,
+			      int flags, unsigned long min, unsigned long max)
+{
+	if (((flags & MIN_CHECK) && (value < min)) ||
+	    ((flags & MAX_CHECK) && (value > max))) {
+		printf("Corruption found in superblock.  (%s = %lu).\n",
+		       descr, value);
+		printf(corrupt_msg);
+		fatal_error(0);
+	}
+}
+
 static void check_super_block(ext2_filsys fs)
 {
 	blk_t	first_block, last_block;
-	int	blocks_per_group = fs->super->s_blocks_per_group;
+	struct ext2_super_block *s = fs->super;
+	blk_t	blocks_per_group = fs->super->s_blocks_per_group;
 	int	i;
+	blk_t	should_be;
 
+	/*
+	 * Verify the super block constants...
+	 */
+	check_super_value("inodes_count", s->s_inodes_count,
+			  MIN_CHECK, 1, 0);
+	check_super_value("blocks_count", s->s_blocks_count,
+			  MIN_CHECK, 1, 0);
+	check_super_value("first_data_block", s->s_first_data_block,
+			  MAX_CHECK, 0, s->s_blocks_count);
+	check_super_value("log_frag_size", s->s_log_frag_size,
+			  MAX_CHECK, 0, 2);
+	check_super_value("log_block_size", s->s_log_block_size,
+			  MIN_CHECK | MAX_CHECK, s->s_log_frag_size,
+			  2);
+	check_super_value("frags_per_group", s->s_frags_per_group,
+			  MIN_CHECK | MAX_CHECK, 1, 8 * EXT2_BLOCK_SIZE(s));
+	check_super_value("blocks_per_group", s->s_blocks_per_group,
+			  MIN_CHECK | MAX_CHECK, 1, 8 * EXT2_BLOCK_SIZE(s));
+	check_super_value("inodes_per_group", s->s_inodes_per_group,
+			  MIN_CHECK, 1, 0);
+	check_super_value("r_blocks_count", s->s_r_blocks_count,
+			  MAX_CHECK, 0, s->s_blocks_count);
+
+	if (s->s_log_block_size != s->s_log_frag_size) {
+		printf("Superblock block_size = %d, fragsize = %d.\n",
+		       EXT2_BLOCK_SIZE(s), EXT2_FRAG_SIZE(s));
+		printf("This version of e2fsck does not support fragment "
+		       "sizes different\n"
+		       "from the block size.\n");
+		fatal_error(0);
+	}
+
+	should_be = s->s_frags_per_group /
+		(s->s_log_block_size - s->s_log_frag_size + 1);
+	if (s->s_blocks_per_group != should_be) {
+		printf("Superblock blocks_per_group = %lu, should "
+		       "have been %lu\n", s->s_blocks_per_group,
+		       should_be);
+		printf(corrupt_msg);
+	}
+
+	should_be = (s->s_log_block_size == 0) ? 1 : 0;
+	if (s->s_first_data_block != should_be) {
+		printf("Superblock first_data_block = %lu, should "
+		       "have been %lu\n", s->s_first_data_block,
+		       should_be);
+		printf(corrupt_msg);
+	}
+
+	/*
+	 * Verify the group descriptors....
+	 */
 	first_block =  fs->super->s_first_data_block;
 	last_block = first_block + blocks_per_group;
 
 	for (i = 0; i < fs->group_desc_count; i++) {
+		if (i == fs->group_desc_count - 1)
+			last_block = fs->super->s_blocks_count;
 		if ((fs->group_desc[i].bg_block_bitmap < first_block) ||
 		    (fs->group_desc[i].bg_block_bitmap >= last_block)) {
-			printf("Block bitmap %ld for group %d not in group.\n",
+			printf("Block bitmap %lu for group %d is "
+			       "not in group.\n",
 			       fs->group_desc[i].bg_block_bitmap, i);
-			fatal_error(0);
+			preenhalt();
+			if (!ask("Continue (and relocate)", 1)) {
+				fatal_error(0);
+			}
+			fs->group_desc[i].bg_block_bitmap = 0;
+			invalid_block_bitmap[i]++;
+			invalid_bitmaps++;
 		}
 		if ((fs->group_desc[i].bg_inode_bitmap < first_block) ||
 		    (fs->group_desc[i].bg_inode_bitmap >= last_block)) {
-			printf("Inode bitmap %ld for group %d not in group.\n",
+			printf("Warning: Inode bitmap %lu for group %d "
+			       "not in group.\n",
 			       fs->group_desc[i].bg_inode_bitmap, i);
-			fatal_error(0);
+			preenhalt();
+			if (!ask("Continue", 1)) {
+				fatal_error(0);
+			}
+			fs->group_desc[i].bg_inode_bitmap = 0;
+			invalid_inode_bitmap[i]++;
+			invalid_bitmaps++;
 		}
 		if ((fs->group_desc[i].bg_inode_table < first_block) ||
 		    ((fs->group_desc[i].bg_inode_table +
 		      fs->inode_blocks_per_group - 1) >= last_block)) {
-			printf("Inode table %ld for group %d not in group.\n",
+			printf("Warning: Inode table %lu for group %d "
+			       "not in group.\n",
 			       fs->group_desc[i].bg_inode_table, i);
-			fatal_error(0);
+			printf("WARNING: SEVERE DATA LOSS POSSIBLE.\n");
+			preenhalt();
+			if (!ask("Continue", 1)) {
+				fatal_error(0);
+			}
+			fs->group_desc[i].bg_inode_table = 0;
+			invalid_inode_table[i]++;
+			invalid_bitmaps++;
 		}
 		first_block += fs->super->s_blocks_per_group;
 		last_block += fs->super->s_blocks_per_group;
@@ -250,12 +356,13 @@
 
 static void PRS(int argc, char *argv[])
 {
-	int flush = 0;
-	char c;
+	int		flush = 0;
+	char		c;
 #ifdef MTRACE
-	extern void *mallwatch;
+	extern void	*mallwatch;
 #endif
-	char *oldpath, newpath[PATH_MAX];
+	char		*oldpath;
+	static char	newpath[PATH_MAX];
 
 	/* Update our PATH to include /sbin  */
 	strcpy(newpath, "PATH=/sbin:");
@@ -392,6 +499,7 @@
 		if (!isatty (0) || !isatty (1))
 			die ("need terminal for interactive repairs");
 	}
+restart:
 	sync_disks();
 	if (superblock && blocksize) {
 		retval = ext2fs_open(device_name, rwflag ? EXT2_FLAG_RW : 0,
@@ -413,9 +521,21 @@
 	if (retval) {
 		com_err(program_name, retval, "while trying to open %s",
 			device_name);
-		printf("Couldn't find valid filesystem superblock.\n");
+		if (retval == EXT2_ET_REV_TOO_HIGH)
+			printf ("Get a newer version of e2fsck!\n");
+		else
+			printf(corrupt_msg);
 		fatal_error(0);
 	}
+
+#ifdef	EXT2_CURRENT_REV
+	if (fs->super->s_rev_level > E2FSCK_CURRENT_REV) {
+		com_err(program_name, retval, "while trying to open %s",
+			device_name);
+		printf ("Get a newer version of e2fsck!\n");
+		fatal_error(0);
+	}
+#endif
 	/*
 	 * If the user specified a specific superblock, presumably the
 	 * master superblock has been trashed.  So we mark the
@@ -426,6 +546,16 @@
 
 	ehandler_init(fs->io);
 
+	invalid_inode_bitmap = allocate_memory(sizeof(int) *
+					       fs->group_desc_count,
+					       "invalid_inode_bitmap");
+	invalid_block_bitmap = allocate_memory(sizeof(int) *
+					       fs->group_desc_count,
+					       "invalid_block_bitmap");
+	invalid_inode_table = allocate_memory(sizeof(int) *
+					      fs->group_desc_count,
+					      "invalid_inode_table");
+		
 	check_super_block(fs);
 	check_if_skip(fs);
 	if (bad_blocks_file)
@@ -439,6 +569,12 @@
 	ext2fs_mark_valid(fs);
 	
 	pass1(fs);
+	if (restart_e2fsck) {
+		ext2fs_close(fs);
+		printf("Restarting e2fsck from the beginning...\n");
+		restart_e2fsck = 0;
+		goto restart;
+	}
 	pass2(fs);
 	pass3(fs);
 	pass4(fs);
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index a25f461..e978844 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -38,6 +38,12 @@
 #define FSCK_LIBRARY     128	/* Shared library error */
 
 /*
+ * The last ext2fs revision level that this version of e2fsck is able to
+ * support
+ */
+#define E2FSCK_CURRENT_REV	0
+
+/*
  * Inode count arrays
  */
 extern unsigned short * inode_count;
@@ -81,16 +87,21 @@
 extern const char * program_name;
 extern const char * device_name;
 
-extern char * inode_used_map;	/* Inodes which are in use */
-extern char * inode_bad_map;	/* Inodes which are bad in some way */
-extern char * inode_dir_map;	/* Inodes which are directories */
+extern ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */
+extern ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */
+extern ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */
 
-extern char * block_found_map;	/* Blocks which are used by an inode */
-extern char * block_dup_map;	/* Blocks which are used by more than once */
+extern ext2fs_block_bitmap block_found_map; /* Blocks which are in use */
+extern ext2fs_block_bitmap block_dup_map; /* Blocks which are used by more than once */
 
 extern const char *fix_msg[2];	/* Fixed or ignored! */
 extern const char *clear_msg[2]; /* Cleared or ignored! */
 
+extern int *invalid_inode_bitmap;
+extern int *invalid_block_bitmap;
+extern int *invalid_inode_table;
+extern int restart_e2fsck;
+
 /* Command line options */
 extern int nflag;
 extern int yflag;
@@ -126,6 +137,8 @@
 
 extern struct resource_track	global_rtrack;
 
+extern int invalid_bitmaps;
+
 /*
  * Procedure declarations
  */
@@ -164,6 +177,10 @@
 extern void print_resource_track(struct resource_track *track);
 extern void init_resource_track(struct resource_track *track);
 extern int inode_has_valid_blocks(struct ext2_inode *inode);
+extern void e2fsck_read_inode(ext2_filsys fs, unsigned long ino,
+			      struct ext2_inode * inode, const char * proc);
+extern void e2fsck_write_inode(ext2_filsys fs, unsigned long ino,
+			       struct ext2_inode * inode, const char * proc);
 #ifdef MTRACE
 extern void mtrace_print(char *mesg);
 #endif
diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c
index 96aedfb..4873a95 100644
--- a/e2fsck/ehandler.c
+++ b/e2fsck/ehandler.c
@@ -44,10 +44,10 @@
 		return 0;
 	}
 	if (operation)
-		printf("Error reading block %ld (%s) while %s.  ", block,
+		printf("Error reading block %lu (%s) while %s.  ", block,
 		       error_message(error), operation);
 	else
-		printf("Error reading block %ld (%s).  ", block,
+		printf("Error reading block %lu (%s).  ", block,
 		       error_message(error));
 	preenhalt();
 	if (ask("Ignore error", 1))
@@ -84,10 +84,10 @@
 	}
 	
 	if (operation)
-		printf("Error writing block %ld (%s) while %s.  ", block,
+		printf("Error writing block %lu (%s) while %s.  ", block,
 		       error_message(error), operation);
 	else
-		printf("Error writing block %ld (%s).  ", block,
+		printf("Error writing block %lu (%s).  ", block,
 		       error_message(error));
 	preenhalt();
 	if (ask("Ignore error", 1))
diff --git a/e2fsck/images/README b/e2fsck/images/README
index bd111fd..73e2681 100644
--- a/e2fsck/images/README
+++ b/e2fsck/images/README
@@ -15,14 +15,14 @@
 				prepared to deal with)
 	16		Usage or syntax error
 
-During the regression test, the first exit code should be 1 (with the
-exception of the empty filesystem, empty.img, which will have an exit
-code of 0), and the second exit code should be 0.  In other words, all
-of the test filesystems in this directory (with the exception of
-empty.img) have some sort of filesystem corruption, which e2fsck
-should fix on the first pass.  After the first pass, e2fsck should
-leave a fully consistent filesystem with no detectable errors found in
-the second pass.
+During the regression test, the first exit code should be 1, and the
+second exit code should be 0.  In other words, all (with one
+exception) of the test filesystems in this directory have some sort of
+filesystem corruption, which e2fsck should fix on the first pass.
+After the first pass, e2fsck should leave a fully consistent
+filesystem with no detectable errors found in the second pass.  The
+exception is the okgroup.img filesystem, which contains no errors, and
+so both exit codes should be 0.
 
 NOTE: It appears that at least some versions of the original e2fsck do
 not exit with an exit status code of 1 after correcting filesystem
@@ -35,6 +35,7 @@
 directory:
 
 baddir.img		Filesystem with a corrupted directory
+badbblocks.img		Filesystem with illegal blocks in the bad block inode.
 badinode.img		Filesystem with various different corrupted inode
 				entries.
 badlkcnt.img		Filesystem with deleted files with non-zero link count
@@ -46,6 +47,10 @@
 dirlink.img		Filesystem with a hard link to a directory
 dup.img			Filesystem with blocks claimed by two different files
 dup2.img		Filesystem with blocks claimed by three different files
+dupfsblks.img		Filesystem with blocks claimed by a file and
+				inode/block bitmaps and inode tables
+dupsuper.img		Filesystem with blocks claimed by a file and
+				the superblock / group descriptors
 end-bitmap.img		Filesystem with corruption at the end of the block 
 				bitmap
 expand.img		Tests e2fsck's ability to expand lost+found if 
@@ -54,6 +59,9 @@
 				directory
 mke2fs2b.img		Filesystem with corruption similar to that
 				created by mke2fs version 0.2b
-noroot.img		Filesystem with a deleted root directory.
+noroot.img		Filesystem with a deleted root directory
+okgroup.img		Filesystem that's exactly 8193 blocks long 
+				(otherwise OK)
+overfsblks.img		Filesystem with overlapping inode and block bitmaps
 
 
diff --git a/e2fsck/images/badbblocks.img.gz b/e2fsck/images/badbblocks.img.gz
new file mode 100644
index 0000000..3fd89cb
--- /dev/null
+++ b/e2fsck/images/badbblocks.img.gz
Binary files differ
diff --git a/e2fsck/images/bbfile.img.gz b/e2fsck/images/bbfile.img.gz
index 155363a..1924a3f 100644
--- a/e2fsck/images/bbfile.img.gz
+++ b/e2fsck/images/bbfile.img.gz
Binary files differ
diff --git a/e2fsck/images/bitmapblks.img.gz b/e2fsck/images/bitmapblks.img.gz
new file mode 100644
index 0000000..d5aa60f
--- /dev/null
+++ b/e2fsck/images/bitmapblks.img.gz
Binary files differ
diff --git a/e2fsck/images/dupfsblks.img.gz b/e2fsck/images/dupfsblks.img.gz
new file mode 100644
index 0000000..d3fd2a1
--- /dev/null
+++ b/e2fsck/images/dupfsblks.img.gz
Binary files differ
diff --git a/e2fsck/images/dupsuper.img.gz b/e2fsck/images/dupsuper.img.gz
new file mode 100644
index 0000000..f5c2f3e
--- /dev/null
+++ b/e2fsck/images/dupsuper.img.gz
Binary files differ
diff --git a/e2fsck/images/illfsblks.img.gz b/e2fsck/images/illfsblks.img.gz
new file mode 100644
index 0000000..f218c57
--- /dev/null
+++ b/e2fsck/images/illfsblks.img.gz
Binary files differ
diff --git a/e2fsck/images/lotsbad.img.gz b/e2fsck/images/lotsbad.img.gz
new file mode 100644
index 0000000..8e49295
--- /dev/null
+++ b/e2fsck/images/lotsbad.img.gz
Binary files differ
diff --git a/e2fsck/images/messy_inode.img.gz b/e2fsck/images/messy_inode.img.gz
new file mode 100644
index 0000000..a7eab4a
--- /dev/null
+++ b/e2fsck/images/messy_inode.img.gz
Binary files differ
diff --git a/e2fsck/images/okgroup.img.gz b/e2fsck/images/okgroup.img.gz
new file mode 100644
index 0000000..e353032
--- /dev/null
+++ b/e2fsck/images/okgroup.img.gz
Binary files differ
diff --git a/e2fsck/images/overfsblks.img.gz b/e2fsck/images/overfsblks.img.gz
new file mode 100644
index 0000000..15f391f
--- /dev/null
+++ b/e2fsck/images/overfsblks.img.gz
Binary files differ
diff --git a/e2fsck/images/test_script.log b/e2fsck/images/test_script.log
deleted file mode 100644
index c583fe5..0000000
--- a/e2fsck/images/test_script.log
+++ /dev/null
@@ -1,1289 +0,0 @@
-Testing baddir.img.gz...
-../e2fsck -yft /tmp/baddir.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Inode 13 is a zero length directory.  Clear? yes
-
-Pass 2: Checking directory structure
-Entry 'zero' in / (2) has deleted/unused inode 13.
-Clear? yes
-
-Directory inode 12, block 0, offset 0: directory corrupted
-Salvage? yes
-
-Missing '.' in directory inode 12.
-Fix? yes
-
-Missing '..' in directory inode 12.
-Fix? yes
-
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  2.354/ 0.000/ 0.320
-'..' in /block.h (12) is . (0), should be / (2).
-Fix? yes
-
-Pass 4: Check reference counts.
-Inode 12 has ref count 1, expecting 2.
-Set i_nlinks to count? yes
-
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Block bitmap differences: -22.  FIXED
-Free blocks count wrong (76, counted=77).  FIXED
-Inode bitmap differences: -13.  FIXED
-Free inodes count wrong for group #0 (19, counted=20).  FIXED
-Directories count wrong for group #0 (4, counted=3).  FIXED
-Free inodes count wrong (19, counted=20).  FIXED
-
-/tmp/baddir.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/baddir.img.gz.994: 12/32 files, 23/100 blocks
-Memory used: 74192, elapsed time:  3.648/ 0.020/ 0.590
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/baddir.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.369/ 0.010/ 0.280
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/baddir.img.gz.994: 12/32 files, 23/100 blocks
-Memory used: 78288, elapsed time:  2.638/ 0.030/ 0.520
-Exit status is 0
----------------------------------------------------
-Testing badinode.img.gz...
-../e2fsck -yft /tmp/badinode.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Inode 12 (/motd) has a bad mode (0110444).
-Clear? yes
-
-i_fsize for inode 13 (/timings) is 4, should be zero.
-Clear i_fsize? yes
-
-i_file_acl for inode 13 (/timings) is 39, should be zero.
-Clear i_file_acl? yes
-
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.882/ 0.010/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-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
-
-/tmp/badinode.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/badinode.img.gz.994: 12/32 files, 23/100 blocks
-Memory used: 78288, elapsed time:  3.171/ 0.040/ 0.550
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/badinode.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.380/ 0.000/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/badinode.img.gz.994: 12/32 files, 23/100 blocks
-Memory used: 78288, elapsed time:  2.659/ 0.010/ 0.560
-Exit status is 0
----------------------------------------------------
-Testing badlkcnt.img.gz...
-../e2fsck -yft /tmp/badlkcnt.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-
-Deleted inode detected with non-zero link count.
-This is probably due to old ext2fs kernel code.  
-Fix inode(s)? yes
-
-Inode 13 is deleted w/ non-zero link_count.  CLEARED
-Inode 15 is deleted w/ non-zero link_count.  CLEARED
-Inode 16 is deleted w/ non-zero link_count.  CLEARED
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.935/ 0.030/ 0.270
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-
-/tmp/badlkcnt.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/badlkcnt.img.gz.994: 29/32 files, 32/100 blocks
-Memory used: 78288, elapsed time:  3.211/ 0.050/ 0.520
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/badlkcnt.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.382/ 0.010/ 0.280
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/badlkcnt.img.gz.994: 29/32 files, 32/100 blocks
-Memory used: 78288, elapsed time:  2.659/ 0.020/ 0.540
-Exit status is 0
----------------------------------------------------
-Testing badroot.img.gz...
-../e2fsck -yft /tmp/badroot.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Root inode is not a directory.  Clear? yes
-
-Pass 2: Checking directory structure
-Entry '..' in ??? (11) has deleted/unused inode 2.
-Clear? yes
-
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.920/ 0.020/ 0.280
-Root inode not allocated.  Rellocate? yes
-
-Unconnected directory inode 11 (...)
-Connect to /lost+found? yes
-
-/lost+found not found.  Create? yes
-
-Pass 4: Check reference counts.
-Inode 11 has ref count 3, expecting 2.
-Set i_nlinks to count? yes
-
-Unattached inode 12
-Connect to /lost+found? yes
-
-Inode 12 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Free blocks count wrong for group 0 (77, counted=76).  FIXED
-Free blocks count wrong (77, counted=76).  FIXED
-Free inodes count wrong for group #0 (20, counted=19).  FIXED
-Directories count wrong for group #0 (2, counted=3).  FIXED
-Free inodes count wrong (20, counted=19).  FIXED
-
-/tmp/badroot.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/badroot.img.gz.994: 13/32 files, 24/100 blocks
-Memory used: 78288, elapsed time:  3.222/ 0.040/ 0.560
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/badroot.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.380/ 0.010/ 0.290
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/badroot.img.gz.994: 13/32 files, 24/100 blocks
-Memory used: 78288, elapsed time:  2.658/ 0.020/ 0.540
-Exit status is 0
----------------------------------------------------
-Testing badtable.img.gz...
-../e2fsck -yft /tmp/badtable.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Warning: Bad block(s) found in filesystem-reserved blocks.
-Bad block 3 in group 0's block bitmap.  Relocate? yes
-
-Bad block 4 in group 0's inode bitmap.  Relocate? yes
-
-WARNING: Severe data loss possible!!!!
-Bad block 6 in group 0's inode table.  Relocate? yes
-
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.939/ 0.020/ 0.280
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Block bitmap differences: -5 -7 +22 +23 +24 +25 +26 +27.  FIXED
-Free blocks count wrong for group 0 (78, counted=74).  FIXED
-Free blocks count wrong (78, counted=74).  FIXED
-
-/tmp/badtable.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/badtable.img.gz.994: 11/32 files, 26/100 blocks
-Memory used: 78288, elapsed time:  3.232/ 0.040/ 0.550
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/badtable.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.379/ 0.010/ 0.290
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/badtable.img.gz.994: 11/32 files, 26/100 blocks
-Memory used: 78288, elapsed time:  2.658/ 0.020/ 0.550
-Exit status is 0
----------------------------------------------------
-Testing bbfile.img.gz...
-../e2fsck -yft /tmp/bbfile.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Duplicate blocks found... invoking duplicate block passes.
-Pass 1B: Rescan for duplicate/bad blocks
-Duplicate/bad block(s) in inode 2: 21
-Duplicate/bad block(s) in inode 11: 9 10 11 12 13 14 15 16 17 18 19 20
-Duplicate/bad block(s) in inode 12: 25 26
-Pass 1C: Scan directories for inodes with dup blocks.
-Pass 1D: Reconciling duplicate blocks
-(There are 3 inodes containing duplicate/bad blocks.)
-
-File /termcap (inode #12, mod time Sun Jan  2 03:29:13 1994) 
-  has 2 duplicate blocks, shared with 1 file:
-	<The bad blocks inode> (inode #1, mod time Sun Jan  2 03:32:04 1994)
-Clone duplicate/bad blocks? yes
-
-
-File /lost+found (inode #11, mod time Sun Jan  2 03:28:40 1994) 
-  has 12 duplicate blocks, shared with 1 file:
-	<The bad blocks inode> (inode #1, mod time Sun Jan  2 03:32:04 1994)
-Clone duplicate/bad blocks? yes
-
-
-File / (inode #2, mod time Sun Jan  2 03:29:13 1994) 
-  has 1 duplicate blocks, shared with 1 file:
-	<The bad blocks inode> (inode #1, mod time Sun Jan  2 03:32:04 1994)
-Clone duplicate/bad blocks? yes
-
-
-Warning: Bad block(s) found in filesystem-reserved blocks.
-Bad block 4 in group 0's inode bitmap.  Relocate? yes
-
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  2.031/ 0.070/ 0.280
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Block bitmap differences: +22 +23 +24 +57.  FIXED
-Free blocks count wrong for group 0 (61, counted=42).  FIXED
-Free blocks count wrong (61, counted=42).  FIXED
-
-/tmp/bbfile.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/bbfile.img.gz.994: 12/32 files, 58/100 blocks
-Memory used: 78288, elapsed time:  3.322/ 0.100/ 0.530
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/bbfile.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Warning: Bad block(s) found in filesystem-reserved blocks.
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.374/ 0.000/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/bbfile.img.gz.994: 12/32 files, 58/100 blocks
-Memory used: 78288, elapsed time:  2.649/ 0.020/ 0.550
-Exit status is 0
----------------------------------------------------
-Testing bitmaps.img.gz...
-../e2fsck -yft /tmp/bitmaps.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.811/ 0.020/ 0.290
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Block bitmap differences: +12 -20 +41 -50.  FIXED
-Inode bitmap differences: +11 -15.  FIXED
-
-/tmp/bitmaps.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/bitmaps.img.gz.994: 11/32 files, 22/100 blocks
-Memory used: 78288, elapsed time:  3.101/ 0.040/ 0.550
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/bitmaps.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.359/ 0.000/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/bitmaps.img.gz.994: 11/32 files, 22/100 blocks
-Memory used: 78288, elapsed time:  2.639/ 0.010/ 0.560
-Exit status is 0
----------------------------------------------------
-Testing dirlink.img.gz...
-../e2fsck -yft /tmp/dirlink.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Entry 'quux' in /foo (12) is a link to directory /bar (13).
-Clear? yes
-
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.928/ 0.000/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-
-/tmp/dirlink.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/dirlink.img.gz.994: 13/32 files, 24/100 blocks
-Memory used: 74192, elapsed time:  3.203/ 0.010/ 0.560
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/dirlink.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.370/ 0.010/ 0.280
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/dirlink.img.gz.994: 13/32 files, 24/100 blocks
-Memory used: 74192, elapsed time:  2.649/ 0.030/ 0.530
-Exit status is 0
----------------------------------------------------
-Testing dup.img.gz...
-../e2fsck -yft /tmp/dup.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Duplicate blocks found... invoking duplicate block passes.
-Pass 1B: Rescan for duplicate/bad blocks
-Duplicate/bad block(s) in inode 12: 25 26
-Duplicate/bad block(s) in inode 13: 25 26
-Pass 1C: Scan directories for inodes with dup blocks.
-Pass 1D: Reconciling duplicate blocks
-(There are 2 inodes containing duplicate/bad blocks.)
-
-File /motd (inode #13, mod time Mon Sep 20 23:19:20 1993) 
-  has 2 duplicate blocks, shared with 1 file:
-	/termcap (inode #12, mod time Mon Sep 20 23:19:14 1993)
-Clone duplicate/bad blocks? yes
-
-
-File /termcap (inode #12, mod time Mon Sep 20 23:19:14 1993) 
-  has 2 duplicate blocks, shared with 1 file:
-	/motd (inode #13, mod time Mon Sep 20 23:19:20 1993)
-Duplicated blocks already reassigned or cloned.
-
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.652/ 0.020/ 0.310
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Free blocks count wrong for group 0 (44, counted=60).  FIXED
-Free blocks count wrong (62, counted=60).  FIXED
-Padding at end of block bitmap is not set. Fix? yes
-
-
-/tmp/dup.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/dup.img.gz.994: 13/16 files, 40/100 blocks
-Memory used: 78288, elapsed time:  2.955/ 0.060/ 0.570
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/dup.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.370/ 0.000/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/dup.img.gz.994: 13/16 files, 40/100 blocks
-Memory used: 78288, elapsed time:  2.647/ 0.010/ 0.560
-Exit status is 0
----------------------------------------------------
-Testing dup2.img.gz...
-../e2fsck -yft /tmp/dup2.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Duplicate blocks found... invoking duplicate block passes.
-Pass 1B: Rescan for duplicate/bad blocks
-Duplicate/bad block(s) in inode 12: 25 26
-Duplicate/bad block(s) in inode 13: 25 26 57 58
-Duplicate/bad block(s) in inode 14: 57 58
-Pass 1C: Scan directories for inodes with dup blocks.
-Pass 1D: Reconciling duplicate blocks
-(There are 3 inodes containing duplicate/bad blocks.)
-
-File /pass1.c (inode #14, mod time Tue Sep 21 00:28:37 1993) 
-  has 2 duplicate blocks, shared with 1 file:
-	/motd (inode #13, mod time Mon Sep 20 23:19:20 1993)
-Clone duplicate/bad blocks? yes
-
-
-File /motd (inode #13, mod time Mon Sep 20 23:19:20 1993) 
-  has 4 duplicate blocks, shared with 2 files:
-	/pass1.c (inode #14, mod time Tue Sep 21 00:28:37 1993)
-	/termcap (inode #12, mod time Mon Sep 20 23:19:14 1993)
-Clone duplicate/bad blocks? yes
-
-
-File /termcap (inode #12, mod time Mon Sep 20 23:19:14 1993) 
-  has 2 duplicate blocks, shared with 1 file:
-	/motd (inode #13, mod time Mon Sep 20 23:19:20 1993)
-Duplicated blocks already reassigned or cloned.
-
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.969/ 0.020/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Free blocks count wrong for group 0 (8, counted=22).  FIXED
-Free blocks count wrong (26, counted=22).  FIXED
-Padding at end of block bitmap is not set. Fix? yes
-
-
-/tmp/dup2.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/dup2.img.gz.994: 16/16 files, 78/100 blocks
-Memory used: 78288, elapsed time:  3.270/ 0.060/ 0.560
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/dup2.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.383/ 0.000/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/dup2.img.gz.994: 16/16 files, 78/100 blocks
-Memory used: 78288, elapsed time:  2.659/ 0.020/ 0.550
-Exit status is 0
----------------------------------------------------
-Testing end-bitmap.img.gz...
-../e2fsck -yft /tmp/end-bitmap.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.998/ 0.010/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Free blocks count wrong for group 0 (44, counted=63).  FIXED
-Padding at end of block bitmap is not set. Fix? yes
-
-
-/tmp/end-bitmap.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/end-bitmap.img.gz.994: 12/16 files, 37/100 blocks
-Memory used: 78288, elapsed time:  3.285/ 0.030/ 0.560
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/end-bitmap.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 78288, elapsed time:  1.391/ 0.020/ 0.270
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/end-bitmap.img.gz.994: 12/16 files, 37/100 blocks
-Memory used: 78288, elapsed time:  2.668/ 0.030/ 0.530
-Exit status is 0
----------------------------------------------------
-Testing expand.img.gz...
-../e2fsck -yft /tmp/expand.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Deleted inode 2 has zero dtime.
-Set dtime? yes
-
-Pass 2: Checking directory structure
-Entry '..' in /lost+found (11) has deleted/unused inode 2.
-Clear? yes
-
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  2.008/ 0.030/ 0.280
-Root inode not allocated.  Rellocate? yes
-
-Unconnected directory inode 11 (...)
-Connect to /lost+found? yes
-
-/lost+found not found.  Create? yes
-
-Pass 4: Check reference counts.
-Inode 11 has ref count 3, expecting 2.
-Set i_nlinks to count? yes
-
-Unattached inode 12
-Connect to /lost+found? yes
-
-Inode 12 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 13
-Connect to /lost+found? yes
-
-Inode 13 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 14
-Connect to /lost+found? yes
-
-Inode 14 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 15
-Connect to /lost+found? yes
-
-Inode 15 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 16
-Connect to /lost+found? yes
-
-Inode 16 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 17
-Connect to /lost+found? yes
-
-Inode 17 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 18
-Connect to /lost+found? yes
-
-Inode 18 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 19
-Connect to /lost+found? yes
-
-Inode 19 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 20
-Connect to /lost+found? yes
-
-Inode 20 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 21
-Connect to /lost+found? yes
-
-Inode 21 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 22
-Connect to /lost+found? yes
-
-Inode 22 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 23
-Connect to /lost+found? yes
-
-Inode 23 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 24
-Connect to /lost+found? yes
-
-Inode 24 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 25
-Connect to /lost+found? yes
-
-Inode 25 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 26
-Connect to /lost+found? yes
-
-Inode 26 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 27
-Connect to /lost+found? yes
-
-Inode 27 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 28
-Connect to /lost+found? yes
-
-Inode 28 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 29
-Connect to /lost+found? yes
-
-Inode 29 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 30
-Connect to /lost+found? yes
-
-Inode 30 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 31
-Connect to /lost+found? yes
-
-Inode 31 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 32
-Connect to /lost+found? yes
-
-Inode 32 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 33
-Connect to /lost+found? yes
-
-Inode 33 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 34
-Connect to /lost+found? yes
-
-Inode 34 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 35
-Connect to /lost+found? yes
-
-Inode 35 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 36
-Connect to /lost+found? yes
-
-Inode 36 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 37
-Connect to /lost+found? yes
-
-Inode 37 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 38
-Connect to /lost+found? yes
-
-Inode 38 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 39
-Connect to /lost+found? yes
-
-Inode 39 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 40
-Connect to /lost+found? yes
-
-Inode 40 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 41
-Connect to /lost+found? yes
-
-Inode 41 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 42
-Connect to /lost+found? yes
-
-Inode 42 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 43
-Connect to /lost+found? yes
-
-Inode 43 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 44
-Connect to /lost+found? yes
-
-Inode 44 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 45
-Connect to /lost+found? yes
-
-Inode 45 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 46
-Connect to /lost+found? yes
-
-Inode 46 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 47
-Connect to /lost+found? yes
-
-Inode 47 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 48
-Connect to /lost+found? yes
-
-Inode 48 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 49
-Connect to /lost+found? yes
-
-Inode 49 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 50
-Connect to /lost+found? yes
-
-Inode 50 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 51
-Connect to /lost+found? yes
-
-Inode 51 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 52
-Connect to /lost+found? yes
-
-Inode 52 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 53
-Connect to /lost+found? yes
-
-Inode 53 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 54
-Connect to /lost+found? yes
-
-Inode 54 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 55
-Connect to /lost+found? yes
-
-Inode 55 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 56
-Connect to /lost+found? yes
-
-Inode 56 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 57
-Connect to /lost+found? yes
-
-Inode 57 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 58
-Connect to /lost+found? yes
-
-Inode 58 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 59
-Connect to /lost+found? yes
-
-Inode 59 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 60
-Connect to /lost+found? yes
-
-Inode 60 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 61
-Connect to /lost+found? yes
-
-Inode 61 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 62
-Connect to /lost+found? yes
-
-Inode 62 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 63
-Connect to /lost+found? yes
-
-Inode 63 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 64
-Connect to /lost+found? yes
-
-Inode 64 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 65
-Connect to /lost+found? yes
-
-Inode 65 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 66
-Connect to /lost+found? yes
-
-Inode 66 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 67
-Connect to /lost+found? yes
-
-Inode 67 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 68
-Connect to /lost+found? yes
-
-Inode 68 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 69
-Connect to /lost+found? yes
-
-Inode 69 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 70
-Connect to /lost+found? yes
-
-Inode 70 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 71
-Connect to /lost+found? yes
-
-Inode 71 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 72
-Connect to /lost+found? yes
-
-Inode 72 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 73
-Connect to /lost+found? yes
-
-Inode 73 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 74
-Connect to /lost+found? yes
-
-Inode 74 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 75
-Connect to /lost+found? yes
-
-Inode 75 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 76
-Connect to /lost+found? yes
-
-Inode 76 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 77
-Connect to /lost+found? yes
-
-Inode 77 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 78
-Connect to /lost+found? yes
-
-Inode 78 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 79
-Connect to /lost+found? yes
-
-Inode 79 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 80
-Connect to /lost+found? yes
-
-Inode 80 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 81
-Connect to /lost+found? yes
-
-Inode 81 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 82
-Connect to /lost+found? yes
-
-Inode 82 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 83
-Connect to /lost+found? yes
-
-Inode 83 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 84
-Connect to /lost+found? yes
-
-Inode 84 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 85
-Connect to /lost+found? yes
-
-Inode 85 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 86
-Connect to /lost+found? yes
-
-Inode 86 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 87
-Connect to /lost+found? yes
-
-Inode 87 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 88
-Connect to /lost+found? yes
-
-Inode 88 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 89
-Connect to /lost+found? yes
-
-Inode 89 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 90
-Connect to /lost+found? yes
-
-Inode 90 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 91
-Connect to /lost+found? yes
-
-Inode 91 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 92
-Connect to /lost+found? yes
-
-Inode 92 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 93
-Connect to /lost+found? yes
-
-Inode 93 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 94
-Connect to /lost+found? yes
-
-No room in /lost+found; expand /lost+found? yes
-
-Inode 94 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 95
-Connect to /lost+found? yes
-
-Inode 95 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 96
-Connect to /lost+found? yes
-
-Inode 96 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 97
-Connect to /lost+found? yes
-
-Inode 97 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 98
-Connect to /lost+found? yes
-
-Inode 98 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 99
-Connect to /lost+found? yes
-
-Inode 99 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 100
-Connect to /lost+found? yes
-
-Inode 100 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 102
-Connect to /lost+found? yes
-
-Inode 102 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 103
-Connect to /lost+found? yes
-
-Inode 103 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 104
-Connect to /lost+found? yes
-
-Inode 104 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Block bitmap differences: -33.  FIXED
-Free blocks count wrong for group 0 (68, counted=67).  FIXED
-Free blocks count wrong (68, counted=67).  FIXED
-Free inodes count wrong for group #0 (1, counted=0).  FIXED
-Directories count wrong for group #0 (2, counted=3).  FIXED
-Free inodes count wrong (1, counted=0).  FIXED
-
-/tmp/expand.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/expand.img.gz.994: 104/104 files, 33/100 blocks
-Memory used: 74192, elapsed time:  3.652/ 0.210/ 0.740
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/expand.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.387/ 0.010/ 0.300
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/expand.img.gz.994: 104/104 files, 33/100 blocks
-Memory used: 74192, elapsed time:  2.668/ 0.020/ 0.560
-Exit status is 0
----------------------------------------------------
-Testing lpf.img.gz...
-../e2fsck -yft /tmp/lpf.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-
-Deleted inode detected with non-zero link count.
-This is probably due to old ext2fs kernel code.  
-Fix inode(s)? yes
-
-Inode 11 is deleted w/ non-zero link_count.  CLEARED
-Inode 13 is deleted w/ non-zero link_count.  CLEARED
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.933/ 0.010/ 0.290
-Pass 4: Check reference counts.
-Unattached inode 14
-Connect to /lost+found? yes
-
-/lost+found not found.  Create? yes
-
-Inode 14 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Unattached inode 15
-Connect to /lost+found? yes
-
-Inode 15 has ref count 2, expecting 1.
-Set i_nlinks to count? yes
-
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Free blocks count wrong for group 0 (25, counted=38).  FIXED
-Free blocks count wrong (39, counted=38).  FIXED
-Free inodes count wrong for group #0 (2, counted=1).  FIXED
-Directories count wrong for group #0 (1, counted=2).  FIXED
-Free inodes count wrong (2, counted=1).  FIXED
-Padding at end of block bitmap is not set. Fix? yes
-
-
-/tmp/lpf.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/lpf.img.gz.994: 15/16 files, 62/100 blocks
-Memory used: 74192, elapsed time:  3.242/ 0.050/ 0.550
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/lpf.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.438/ 0.000/ 0.290
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/lpf.img.gz.994: 15/16 files, 62/100 blocks
-Memory used: 74192, elapsed time:  2.717/ 0.010/ 0.550
-Exit status is 0
----------------------------------------------------
-Testing mke2fs2b.img.gz...
-../e2fsck -yft /tmp/mke2fs2b.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Root inode has dtime set (probably due to old mke2fs).  Fix? yes
-
-Note: /lost+found will probably be deleted as well, due to the mke2fs bug.
-Be sure to run mklost+found to recreate it after e2fsck finishes.
-
-
-Deleted inode detected with non-zero link count.
-This is probably due to old ext2fs kernel code.  
-Fix inode(s)? yes
-
-Inode 11 is deleted w/ non-zero link_count.  CLEARED
-Inode 15 is deleted w/ non-zero link_count.  CLEARED
-Pass 2: Checking directory structure
-Entry 'lost+found' in / (2) has deleted/unused inode 11.
-Clear? yes
-
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.911/ 0.000/ 0.300
-Pass 4: Check reference counts.
-Inode 2 has ref count 4, expecting 3.
-Set i_nlinks to count? yes
-
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Block bitmap differences: -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20.  FIXED
-Free blocks count wrong for group 0 (75, counted=87).  FIXED
-Free blocks count wrong (75, counted=87).  FIXED
-Inode bitmap differences: -11.  FIXED
-Free inodes count wrong for group #0 (17, counted=18).  FIXED
-Directories count wrong for group #0 (4, counted=3).  FIXED
-Free inodes count wrong (17, counted=18).  FIXED
-
-/tmp/mke2fs2b.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/mke2fs2b.img.gz.994: 14/32 files, 13/100 blocks
-Memory used: 74192, elapsed time:  3.208/ 0.020/ 0.570
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/mke2fs2b.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.364/ 0.010/ 0.280
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/mke2fs2b.img.gz.994: 14/32 files, 13/100 blocks
-Memory used: 74192, elapsed time:  2.637/ 0.030/ 0.530
-Exit status is 0
----------------------------------------------------
-Testing noroot.img.gz...
-../e2fsck -yft /tmp/noroot.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-
-Deleted inode detected with non-zero link count.
-This is probably due to old ext2fs kernel code.  
-Fix inode(s)? yes
-
-Inode 15 is deleted w/ non-zero link_count.  CLEARED
-Pass 2: Checking directory structure
-Entry '..' in /lost+found (11) has deleted/unused inode 2.
-Clear? yes
-
-Entry '..' in /foo (12) has deleted/unused inode 2.
-Clear? yes
-
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.951/ 0.030/ 0.280
-Root inode not allocated.  Rellocate? yes
-
-Unconnected directory inode 11 (...)
-Connect to /lost+found? yes
-
-/lost+found not found.  Create? yes
-
-Unconnected directory inode 12 (...)
-Connect to /lost+found? yes
-
-Pass 4: Check reference counts.
-Inode 11 has ref count 3, expecting 2.
-Set i_nlinks to count? yes
-
-Inode 12 has ref count 4, expecting 3.
-Set i_nlinks to count? yes
-
-Pass 5: Checking group summary information.
-Fix summary information? yes
-
-Free blocks count wrong for group 0 (75, counted=74).  FIXED
-Free blocks count wrong (75, counted=74).  FIXED
-Free inodes count wrong for group #0 (17, counted=16).  FIXED
-Directories count wrong for group #0 (4, counted=5).  FIXED
-Free inodes count wrong (17, counted=16).  FIXED
-
-/tmp/noroot.img.gz.994: ***** FILE SYSTEM WAS MODIFIED *****
-/tmp/noroot.img.gz.994: 16/32 files, 26/100 blocks
-Memory used: 74192, elapsed time:  3.259/ 0.050/ 0.560
-Exit status is 1
- 
-Running e2fsck again....
-../e2fsck -yft /tmp/noroot.img.gz.994
-e2fsck 0.5, 28-Mar-94 for EXT2 FS 0.5, 94/03/10
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Peak memory: Memory used: 74192, elapsed time:  1.360/ 0.000/ 0.290
-Pass 4: Check reference counts.
-Pass 5: Checking group summary information.
-/tmp/noroot.img.gz.994: 16/32 files, 26/100 blocks
-Memory used: 74192, elapsed time:  2.638/ 0.010/ 0.550
-Exit status is 0
----------------------------------------------------
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 2f23b9d..7eadea8 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -48,13 +48,12 @@
 int fs_badblocks_count = 0;
 int fs_sockets_count = 0;
 
-char * inode_used_map = 0;	/* Inodes which are in use */
-char * inode_bad_map = 0;	/* Inodes which are bad in some way */
-char * inode_dir_map = 0;	/* Inodes which are directories */
+ext2fs_inode_bitmap inode_used_map = 0;	/* Inodes which are in use */
+ext2fs_inode_bitmap inode_bad_map = 0;	/* Inodes which are bad in some way */
+ext2fs_inode_bitmap inode_dir_map = 0;	/* Inodes which are directories */
 
-char * block_found_map = 0;
-char * block_dup_map = 0;
-static char * bad_fs_block_map = 0;
+ext2fs_block_bitmap block_found_map = 0;
+ext2fs_block_bitmap block_dup_map = 0;
 
 static int fix_link_count = -1;
 
@@ -64,25 +63,27 @@
 			 int	blockcnt, void	*private);
 static int process_bad_block(ext2_filsys fs, blk_t *block_nr,
 			     int blockcnt, void *private);
-static int process_fs_bad_block(ext2_filsys fs, blk_t *block_nr,
-				int blockcnt, void *private);
 static void check_blocks(ext2_filsys fs, ino_t ino, struct ext2_inode *inode,
 			 char *block_buf);
 static void mark_table_blocks(ext2_filsys fs);
 static errcode_t pass1_check_directory(ext2_filsys fs, ino_t ino);
 static errcode_t pass1_get_blocks(ext2_filsys fs, ino_t ino, blk_t *blocks);
 static void alloc_bad_map(ext2_filsys fs);
-static void handle_fs_bad_blocks(ext2_filsys fs, char *block_buf);
+static void handle_fs_bad_blocks(ext2_filsys fs);
 static void process_inodes(ext2_filsys fs, char *block_buf);
 static int process_inode_cmp(const void *a, const void *b);
 static int dir_block_cmp(const void *a, const void *b);
+static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
+				  dgrp_t group, void * private);
 
 struct process_block_struct {
 	ino_t	ino;
-	int	is_dir;
+	int	is_dir:1, clear:1, suppress:1;
 	int	num_blocks;
 	int	last_block;
+	int	num_illegal_blocks;
 	int	fix;
+	struct ext2_inode *inode;
 };
 
 struct process_inode_block {
@@ -101,7 +102,7 @@
  */
 static struct process_inode_block *inodes_to_process;
 static int process_inode_count;
-int process_inode_size = 128;
+int process_inode_size = 256;
 
 /*
  * For the directory blocks list.
@@ -110,6 +111,37 @@
 int	dir_block_count = 0;
 int	dir_block_size = 0;
 
+/*
+ * Free all memory allocated by pass1 in preparation for restarting
+ * things.
+ */
+static void unwind_pass1(ext2_filsys fs)
+{
+	ext2fs_free_inode_bitmap(inode_used_map);	inode_used_map = 0;
+	ext2fs_free_inode_bitmap(inode_dir_map);	inode_dir_map = 0;
+	ext2fs_free_block_bitmap(block_found_map);	block_found_map = 0;
+	free(inode_link_info);	inode_link_info = 0;
+	free(inodes_to_process);inodes_to_process = 0;
+	free(dir_blocks);	dir_blocks = 0;
+	dir_block_size = 0;
+	if (block_dup_map) {
+		free(block_dup_map); block_dup_map = 0;
+	}
+
+	/* Clear statistic counters */
+	fs_directory_count = 0;
+	fs_regular_count = 0;
+	fs_blockdev_count = 0;
+	fs_chardev_count = 0;
+	fs_links_count = 0;
+	fs_symlinks_count = 0;
+	fs_fast_symlinks_count = 0;
+	fs_fifo_count = 0;
+	fs_total_count = 0;
+	fs_badblocks_count = 0;
+	fs_sockets_count = 0;
+}
+
 void pass1(ext2_filsys fs)
 {
 	ino_t	ino;
@@ -131,19 +163,22 @@
 	/*
 	 * Allocate bitmaps structures
 	 */
-	retval = ext2fs_allocate_inode_bitmap(fs, &inode_used_map);
+	retval = ext2fs_allocate_inode_bitmap(fs, "in-use inode map",
+					      &inode_used_map);
 	if (retval) {
 		com_err("ext2fs_allocate_inode_bitmap", retval,
 			"while allocating inode_used_map");
 		fatal_error(0);
 	}
-	retval = ext2fs_allocate_inode_bitmap(fs, &inode_dir_map);
+	retval = ext2fs_allocate_inode_bitmap(fs, "directory inode map",
+					      &inode_dir_map);
 	if (retval) {
 		com_err("ext2fs_allocate_inode_bitmap", retval,
 			"while allocating inode_dir_map");
 		fatal_error(0);
 	}
-	retval = ext2fs_allocate_block_bitmap(fs, &block_found_map);
+	retval = ext2fs_allocate_block_bitmap(fs, "in-use block map",
+					      &block_found_map);
 	if (retval) {
 		com_err("ext2fs_allocate_block_bitmap", retval,
 			"while allocating block_found_map");
@@ -179,6 +214,7 @@
 		fatal_error(0);
 	}
 	stashed_inode = &inode;
+	ext2fs_set_inode_callback(scan, scan_callback, block_buf);
 	while (ino) {
 		stashed_ino = ino;
 		inode_link_info[ino] = inode.i_links_count;
@@ -187,14 +223,16 @@
 			
 			pb.ino = EXT2_BAD_INO;
 			pb.num_blocks = pb.last_block = 0;
-			pb.is_dir = 0;
+			pb.num_illegal_blocks = 0;
+			pb.suppress = pb.clear = pb.is_dir = 0;
 			pb.fix = -1;
+			pb.inode = &inode;
 			retval = ext2fs_block_iterate(fs, ino, 0, block_buf,
 						      process_bad_block, &pb);
 			if (retval)
 				com_err(program_name, retval, "while calling e2fsc_block_interate in pass 1");
 
-			ext2fs_mark_inode_bitmap(fs, inode_used_map, ino);
+			ext2fs_mark_inode_bitmap(inode_used_map, ino);
 			goto next;
 		}
 		if (ino == EXT2_ROOT_INO) {
@@ -209,7 +247,9 @@
 				if (ask("Clear", 1)) {
 					inode.i_dtime = time(0);
 					inode.i_links_count = 0;
-					ext2fs_write_inode(fs, ino, &inode);
+					inode_link_info[ino] = 0;
+					e2fsck_write_inode(fs, ino, &inode,
+							   "pass1");
 				} else 
 					ext2fs_unmark_valid(fs);
 			}
@@ -227,7 +267,8 @@
 					"(probably due to old mke2fs).  Fix",
 					1)) {
 					inode.i_dtime = 0;
-					ext2fs_write_inode(fs, ino, &inode);
+					e2fsck_write_inode(fs, ino, &inode,
+							   "pass1");
 					printf("Note: /lost+found will "
 					       "probably be deleted as well, "
 					       "due to the mke2fs bug.\n"
@@ -239,7 +280,7 @@
 			}
 		}
 		if ((ino != EXT2_ROOT_INO) && (ino < EXT2_FIRST_INO)) {
-			ext2fs_mark_inode_bitmap(fs, inode_used_map, ino);
+			ext2fs_mark_inode_bitmap(inode_used_map, ino);
 			check_blocks(fs, ino, &inode, block_buf);
 			goto next;
 		}
@@ -249,11 +290,12 @@
 		 */
 		if (!inode.i_links_count) {
 			if (!inode.i_dtime && inode.i_mode) {
-				printf("Deleted inode %ld has zero dtime.\n",
+				printf("Deleted inode %lu has zero dtime.\n",
 				       ino);
 				if (ask("Set dtime", 1)) {
 					inode.i_dtime = time(0);
-					ext2fs_write_inode(fs, ino, &inode);
+					e2fsck_write_inode(fs, ino, &inode,
+							   "pass1");
 				} else
 					ext2fs_unmark_valid(fs);
 			}
@@ -275,26 +317,27 @@
 				printf("This is probably due to old ext2fs kernel code.  \n");
 				fix_link_count = ask("Fix inode(s)", 1);
 			}
-			printf("Inode %ld is deleted w/ non-zero link_count.  %s\n",
+			printf("Inode %lu is deleted w/ non-zero link_count.  %s\n",
 			       ino, clear_msg[fix_link_count]);
 			if (fix_link_count) {
 				inode.i_links_count = 0;
-				ext2fs_write_inode(fs, ino, &inode);
+				inode_link_info[ino] = 0;
+				e2fsck_write_inode(fs, ino, &inode, "pass1");
 			} else
 				ext2fs_unmark_valid(fs);
 			goto next;
 		}
 		
-		ext2fs_mark_inode_bitmap(fs, inode_used_map, ino);
+		ext2fs_mark_inode_bitmap(inode_used_map, ino);
 		if (inode.i_faddr || inode.i_frag || inode.i_fsize ||
 		    inode.i_file_acl || inode.i_dir_acl) {
 			if (!inode_bad_map)
 				alloc_bad_map(fs);
-			ext2fs_mark_inode_bitmap(fs, inode_bad_map, ino);
+			ext2fs_mark_inode_bitmap(inode_bad_map, ino);
 		}
 		
 		if (S_ISDIR(inode.i_mode)) {
-			ext2fs_mark_inode_bitmap(fs, inode_dir_map, ino);
+			ext2fs_mark_inode_bitmap(inode_dir_map, ino);
 			add_dir_info(fs, ino, 0, &inode);
 			fs_directory_count++;
 		} else if (S_ISREG (inode.i_mode))
@@ -315,7 +358,7 @@
 		else {
 			if (!inode_bad_map)
 				alloc_bad_map(fs);
-			ext2fs_mark_inode_bitmap(fs, inode_bad_map, ino);
+			ext2fs_mark_inode_bitmap(inode_bad_map, ino);
 		}
 		if (inode.i_block[EXT2_IND_BLOCK] ||
 		    inode.i_block[EXT2_DIND_BLOCK] ||
@@ -323,9 +366,8 @@
 			inodes_to_process[process_inode_count].ino = ino;
 			inodes_to_process[process_inode_count].inode = inode;
 			process_inode_count++;
-		} else 
+		} else
 			check_blocks(fs, ino, &inode, block_buf);
-		inode_link_info[ino] = inode.i_links_count;
 
 		if (process_inode_count >= process_inode_size)
 			process_inodes(fs, block_buf);
@@ -344,6 +386,14 @@
 	qsort(dir_blocks, dir_block_count, sizeof(struct dir_block_struct),
 	      dir_block_cmp);
 
+	if (invalid_bitmaps)
+		handle_fs_bad_blocks(fs);
+
+	if (restart_e2fsck) {
+		unwind_pass1(fs);
+		goto endit;
+	}
+
 	if (block_dup_map) {
 		if (preen) {
 			printf("Duplicate or bad blocks in use!\n");
@@ -354,12 +404,8 @@
 	fs->get_blocks = 0;
 	fs->check_directory = 0;
 	free(inodes_to_process);
-	if (bad_fs_block_map) {
-		handle_fs_bad_blocks(fs, block_buf);
-		free(bad_fs_block_map);
-	}
+endit:
 	free(block_buf);
-
 	if (tflag > 1) {
 		printf("Pass 1: ");
 		print_resource_track(&rtrack);
@@ -367,6 +413,17 @@
 }
 
 /*
+ * When the inode_scan routines call this callback at the end of the
+ * glock group, call process_inodes.
+ */
+static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
+			       dgrp_t group, void * private)
+{
+	process_inodes(fs, (char *) private);
+	return 0;
+}
+
+/*
  * Process the inodes in the "inodes to process" list.
  */
 static void process_inodes(ext2_filsys fs, char *block_buf)
@@ -378,7 +435,7 @@
 	char			buf[80];
 
 #if 0
-	printf("process_inodes: ");
+	printf("begin process_inodes: ");
 #endif
 	old_operation = ehandler_operation(0);
 	old_stashed_inode = stashed_inode;
@@ -389,9 +446,9 @@
 		ino = inodes_to_process[i].ino;
 		stashed_ino = ino;
 #if 0
-		printf("%d ", ino);
+		printf("%lu ", ino);
 #endif
-		sprintf(buf, "reading indirect blocks of inode %ld", ino);
+		sprintf(buf, "reading indirect blocks of inode %lu", ino);
 		ehandler_operation(buf);
 		check_blocks(fs, ino, stashed_inode, block_buf);
 		
@@ -399,7 +456,7 @@
 	stashed_inode = old_stashed_inode;
 	process_inode_count = 0;
 #if 0
-	printf("\n");
+	printf("end process inodes\n");
 #endif
 	ehandler_operation(old_operation);
 }
@@ -432,7 +489,8 @@
 {
 	errcode_t	retval;
 	
-	retval = ext2fs_allocate_inode_bitmap(fs, &inode_bad_map);
+	retval = ext2fs_allocate_inode_bitmap(fs, "bad inode map",
+					      &inode_bad_map);
 	if (retval) {
 		com_err("ext2fs_allocate_inode_bitmap", retval,
 			"while allocating inode_bad_map");
@@ -448,19 +506,19 @@
 {
 	errcode_t	retval;
 	
-	if (ext2fs_test_block_bitmap(fs, block_found_map, block)) {
+	if (ext2fs_test_block_bitmap(block_found_map, block)) {
 		if (!block_dup_map) {
 			retval = ext2fs_allocate_block_bitmap(fs,
-							      &block_dup_map);
+			      "multiply claimed block map", &block_dup_map);
 			if (retval) {
 				com_err("ext2fs_allocate_block_bitmap", retval,
 					"while allocating block_dup_map");
 				fatal_error(0);
 			}
 		}
-		ext2fs_mark_block_bitmap(fs, block_dup_map, block);
+		ext2fs_mark_block_bitmap(block_dup_map, block);
 	} else {
-		ext2fs_mark_block_bitmap(fs, block_found_map, block);
+		ext2fs_mark_block_bitmap(block_found_map, block);
 	}
 }
 
@@ -479,48 +537,77 @@
 	
 	pb.ino = ino;
 	pb.num_blocks = pb.last_block = 0;
+	pb.num_illegal_blocks = 0;
+	pb.suppress = pb.clear = 0;
 	pb.is_dir = S_ISDIR(inode->i_mode);
 	pb.fix = -1;
+	pb.inode = inode;
 	retval = ext2fs_block_iterate(fs, ino, 0, block_buf,
 				      process_block, &pb);
 	if (retval)
 		com_err(program_name, retval,
 			"while calling ext2fs_block_iterate in check_blocks");
 
+	if (pb.clear) {
+		e2fsck_read_inode(fs, ino, inode, "check_blocks");
+		if (retval) {
+			com_err("check_blocks", retval,
+				"while reading to be cleared inode %d", ino);
+			fatal_error(0);
+		}
+		inode->i_links_count = 0;
+		inode_link_info[ino] = 0;
+		inode->i_dtime = time(0);
+		e2fsck_write_inode(fs, ino, inode, "check_blocks");
+		ext2fs_unmark_inode_bitmap(inode_dir_map, ino);
+		ext2fs_unmark_inode_bitmap(inode_used_map, ino);
+		/*
+		 * The inode was probably partially accounted for
+		 * before processing was aborted, so we need to
+		 * restart the pass 1 scan.
+		 */
+		restart_e2fsck++;
+		return;
+	}
+
+	if (pb.fix > 0)
+		e2fsck_read_inode(fs, ino, inode, "check_blocks");
+
 	pb.num_blocks *= (fs->blocksize / 512);
 #if 0
-	printf("inode %d, i_size = %d, last_block = %d, i_blocks=%d, num_blocks = %d\n",
+	printf("inode %lu, i_size = %lu, last_block = %lu, i_blocks=%lu, num_blocks = %lu\n",
 	       ino, inode->i_size, pb.last_block, inode->i_blocks,
 	       pb.num_blocks);
 #endif
 	if (!pb.num_blocks && pb.is_dir) {
-		printf("Inode %ld is a zero length directory.  ", ino);
+		printf("Inode %lu is a zero length directory.  ", ino);
 		if (ask("Clear", 1)) {
 			inode->i_links_count = 0;
+			inode_link_info[ino] = 0;
 			inode->i_dtime = time(0);
-			ext2fs_write_inode(fs, ino, inode);
-			ext2fs_unmark_inode_bitmap(fs, inode_dir_map, ino);
-			ext2fs_unmark_inode_bitmap(fs, inode_used_map, ino);
+			e2fsck_write_inode(fs, ino, inode, "check_blocks");
+			ext2fs_unmark_inode_bitmap(inode_dir_map, ino);
+			ext2fs_unmark_inode_bitmap(inode_used_map, ino);
 			fs_directory_count--;
 		} else
 			ext2fs_unmark_valid(fs);
 	}
 	if (inode->i_size < pb.last_block * fs->blocksize) {
-		printf ("Inode %ld, incorrect size, %ld (counted = %d). ",
+		printf ("Inode %lu, incorrect size, %lu (counted = %u). ",
 			ino, inode->i_size,
 			(pb.last_block+1) * fs->blocksize);
 		if (ask ("Set size to counted", 1)) {
 			inode->i_size = (pb.last_block+1) * fs->blocksize;
-			ext2fs_write_inode(fs, ino, inode);
+			e2fsck_write_inode(fs, ino, inode, "check_blocks");
 		} else
 			ext2fs_unmark_valid(fs);
 	}
 	if (pb.num_blocks != inode->i_blocks) {
-		printf ("Inode %ld, i_blocks wrong %ld (counted=%d) .",
+		printf ("Inode %lu, i_blocks wrong %lu (counted=%u).  ",
 			ino, inode->i_blocks, pb.num_blocks);
 		if (ask ("Set i_blocks to counted", 1)) {
 			inode->i_blocks = pb.num_blocks;
-			ext2fs_write_inode(fs, ino, inode);
+			e2fsck_write_inode(fs, ino, inode, "check_blocks");
 		} else
 				ext2fs_unmark_valid(fs);
 	}
@@ -538,7 +625,7 @@
 	int	group;
 	int	illegal_block = 0;
 	char	problem[80];
-	blk_t	firstblock;
+	blk_t	firstblock, group_super;
 	blk_t	blk = *block_nr;
 
 	if (!blk)
@@ -546,21 +633,27 @@
 	p = (struct process_block_struct *) private;
 
 #if 0
-	printf("Process_block, inode %d, block %d, #%d\n", p->ino, blk,
+	printf("Process_block, inode %lu, block %lu, #%d\n", p->ino, blk,
 	       blockcnt);
 #endif	
 	
-	p->num_blocks++;
-	if (blockcnt > 0)
-		p->last_block = blockcnt;
-
 	firstblock = fs->super->s_first_data_block;
 	group = (blk - firstblock) / fs->super->s_blocks_per_group;
+	group_super = ((group * fs->super->s_blocks_per_group) +
+		       fs->super->s_first_data_block);
 	if (blk < firstblock) {
-		sprintf(problem, "< FIRSTBLOCK (%ld)", firstblock);
+		sprintf(problem, "< FIRSTBLOCK (%lu)", firstblock);
 		illegal_block++;
 	} else if (blk >= fs->super->s_blocks_count) {
-		sprintf(problem, "> BLOCKS (%ld)", fs->super->s_blocks_count);
+		sprintf(problem, "> BLOCKS (%lu)", fs->super->s_blocks_count);
+		illegal_block++;
+	} else if (blk == group_super) {
+		sprintf(problem, "is the superblock in group %d", group);
+		illegal_block++;
+	} else if (blk > group_super &&
+		   blk <= (group_super + fs->desc_blocks)) {
+		sprintf(problem, "is in the group descriptors in group %d",
+			group);
 		illegal_block++;
 	} else if (blk == fs->group_desc[group].bg_block_bitmap) {
 		sprintf(problem, "is the block bitmap of group %d", group);
@@ -575,16 +668,29 @@
 	}
 	if (illegal_block) {
 		if (preen) {
-			printf("Block %ld of inode %ld %s\n", blk, p->ino,
+			printf("Block %lu of inode %lu %s\n", blk, p->ino,
 			       problem);
 			preenhalt();
 		}
 		if (p->fix == -1) {
-			printf("Remove illegal block(s) in inode %ld", p->ino);
+			printf("Remove illegal block(s) in inode %lu", p->ino);
 			p->fix = ask("", 1);
 		}
-		printf("Block #%d (%ld) %s.  %s\n", blockcnt, blk, problem,
-		       clear_msg[p->fix]);
+		p->num_illegal_blocks++;
+		if (!p->suppress && (p->num_illegal_blocks % 20) == 0) {
+			printf("Too many illegal blocks in inode %lu.\n",
+			       p->ino);
+			if (ask("Clear inode", 1)) {
+				p->clear = 1;
+				return BLOCK_ABORT;
+			}
+			if (ask("Supress messages", 0)) {
+				p->suppress = 1;
+			}
+		}
+		if (!p->suppress)
+			printf("Block #%d (%lu) %s.  %s\n", blockcnt, blk,
+			       problem, clear_msg[p->fix]);
 		if (p->fix) {
 			*block_nr = 0;
 			return BLOCK_CHANGED;
@@ -594,6 +700,9 @@
 		}
 	}
 
+	p->num_blocks++;
+	if (blockcnt > 0)
+		p->last_block = blockcnt;
 	mark_block_used(fs, blk);
 	
 	if (p->is_dir && (blockcnt >= 0)) {
@@ -611,21 +720,36 @@
 	}
 	
 #if 0
-	printf("process block, inode %d, block #%d is %d\n",
+	printf("process block, inode %lu, block #%d is %lu\n",
 	       p->ino, blockcnt, blk);
 #endif
 	
 	return 0;
 }
 
+static void bad_block_indirect(blk_t blk)
+{
+	printf("Bad block %lu used as bad block indirect block?!?\n", blk);
+	preenhalt();
+	printf("\nThis inconsistency can not be fixed with "
+	       "e2fsck; to fix it, use\n"
+	       """dumpe2fs -b"" to dump out the bad block "
+	       "list and ""e2fsck -L filename""\n"
+	       "to read it back in again.\n");
+	if (ask("Continue", 0))
+		return;
+	fatal_error(0);
+}
+
 int process_bad_block(ext2_filsys fs,
 		      blk_t *block_nr,
 		      int blockcnt,
 		      void *private)
 {
 	struct process_block_struct *p;
-	errcode_t	retval;
 	blk_t		blk = *block_nr;
+	int		first_block;
+	int		i;
 	
 	if (!blk)
 		return 0;
@@ -634,12 +758,12 @@
 	if ((blk < fs->super->s_first_data_block) ||
 	    (blk >= fs->super->s_blocks_count)) {
 		if (preen) {
-			printf("Illegal block %ld in bad block inode\n", blk);
+			printf("Illegal block %lu in bad block inode\n", blk);
 			preenhalt();
 		}
 		if (p->fix == -1)
 			p->fix = ask("Remove illegal block(s) in bad block inode", 1);
-		printf("Illegal block %ld in bad block inode.  %s\n", blk,
+		printf("Illegal block %lu in bad block inode.  %s\n", blk,
 		       clear_msg[p->fix]);
 		if (p->fix) {
 			*block_nr = 0;
@@ -651,11 +775,14 @@
 	}
 
 	if (blockcnt < 0) {
-		mark_block_used(fs, blk);
+		if (ext2fs_test_block_bitmap(block_found_map, blk))
+			bad_block_indirect(blk);
+		else
+			mark_block_used(fs, blk);
 		return 0;
 	}
 #if 0 
-	printf ("DEBUG: Marking %d as bad.\n", blk);
+	printf ("DEBUG: Marking %lu as bad.\n", blk);
 #endif
 	fs_badblocks_count++;
 	/*
@@ -664,40 +791,93 @@
 	 * there's an overlap between the filesystem table blocks
 	 * (bitmaps and inode table) and the bad block list.
 	 */
-	if (!ext2fs_test_block_bitmap(fs, block_found_map, blk)) {
-		ext2fs_mark_block_bitmap(fs, block_found_map, blk);
+	if (!ext2fs_test_block_bitmap(block_found_map, blk)) {
+		ext2fs_mark_block_bitmap(block_found_map, blk);
 		return 0;
 	}
-	if (!bad_fs_block_map) {
-		retval = ext2fs_allocate_inode_bitmap(fs, &bad_fs_block_map);
-		if (retval) {
-			com_err("ext2fs_allocate_block_bitmap", retval,
-				"while allocating bad_fs_block_map");
-		fatal_error(0);
+	/*
+	 * Try to find the where the filesystem block was used...
+	 */
+	first_block = fs->super->s_first_data_block;
+	
+	for (i = 0; i < fs->group_desc_count; i++ ) {
+		if (blk == first_block) {
+			if (i == 0) {
+				printf("The primary superblock (%lu) is "
+				       "bad.  Aiiieeee....\n", blk);
+				fatal_error(0);
+			}
+			if (!preen)
+				printf("Warning: Group %d's superblock "
+				       "(%lu) is bad.\n", i, blk);
+			return 0;
 		}
+		if ((blk > first_block) &&
+		    (blk <= first_block + fs->desc_blocks)) {
+			if (i == 0) {
+				printf("Bad block %lu is in the primary "
+				       "group descriptors.  Aiiieeee....\n",
+				       blk);
+				fatal_error(0);
+			}
+			if (!preen)
+				printf("Warning: Group %d's copy of the "
+				       "group descriptors has a bad "
+				       "block (%lu).\n", i, blk);
+			return 0;
+		}
+		if (blk == fs->group_desc[i].bg_block_bitmap) {
+			printf("Group %d's block bitmap (%lu) is bad.  ",
+			       i, blk);
+			if (ask("Relocate", 1)) {
+				invalid_block_bitmap[i]++;
+				invalid_bitmaps++;
+			} else
+				ext2fs_unmark_valid(fs);
+			return 0;
+		}
+		if (blk == fs->group_desc[i].bg_inode_bitmap) {
+			printf("Group %d's inode bitmap (%lu) is bad.  ",
+			       i, blk);
+			if (ask("Relocate", 1)) {
+				invalid_inode_bitmap[i]++;
+				invalid_bitmaps++;
+			} else
+				ext2fs_unmark_valid(fs);
+			return 0;
+		}
+		if ((blk >= fs->group_desc[i].bg_inode_table) &&
+		    (blk < (fs->group_desc[i].bg_inode_table +
+			    fs->inode_blocks_per_group))) {
+			printf("WARNING: Severe data loss possible!!!!\n");
+			printf("Bad block %lu in group %d's inode table.  ",
+			       blk, i);
+			if (ask("Relocate", 1)) {
+				invalid_inode_table[i]++;
+				invalid_bitmaps++;
+			} else
+				ext2fs_unmark_valid(fs);
+			return 0;
+		}
+		first_block += fs->super->s_blocks_per_group;
 	}
-	ext2fs_mark_block_bitmap(fs, bad_fs_block_map, blk);
+	/*
+	 * If we've gotten to this point, then the only
+	 * possibility is that the bad block inode meta data
+	 * is using a bad block.
+	 */
+	if ((blk == p->inode->i_block[EXT2_IND_BLOCK]) ||
+	    p->inode->i_block[EXT2_DIND_BLOCK]) {
+		bad_block_indirect(blk);
+		return 0;
+	}
+	
+	printf("Programming error?  block #%lu claimed for no reason "
+	       "in process_bad_block.\n", blk);
 	return 0;
 }
 
-/*
- * This routine gets called at the end of pass 1 if bad blocks are
- * detected in the superblock, group descriptors, inode_bitmaps, or
- * block bitmaps.  At this point, all of the blocks have been mapped
- * out, so we can try to allocate new block(s) to replace the bad
- * blocks.
- */
-static void handle_fs_bad_blocks(ext2_filsys fs, char *block_buf)
-{
-	errcode_t	retval;
-	
-	printf("Warning: Bad block(s) found in filesystem-reserved blocks.\n");
-	
-	retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, block_buf,
-				      process_fs_bad_block, 0);
-}
-
-static void new_table_block(ext2_filsys fs, blk_t first_block,
+static void new_table_block(ext2_filsys fs, blk_t first_block, int group, 
 			    const char *name, int num, blk_t *new_block)
 {
 	errcode_t	retval;
@@ -722,99 +902,62 @@
 		return;
 	}
 	ext2fs_mark_super_dirty(fs);
+	printf("Relocating group %d's %s ", group, name);
+	if (old_block)
+		printf("from %lu ", old_block);
+	printf("to %lu...\n", *new_block);
 	for (i = 0; i < num; i++) {
-		ext2fs_mark_block_bitmap(fs, block_found_map, (*new_block)+i);
-		retval = io_channel_read_blk(fs->io, old_block + i,
-					     1, buf);
-		if (retval)
-			printf("Warning: could not read block %ld of %s: %s\n",
-			       old_block + i, name, error_message(retval));
+		ext2fs_mark_block_bitmap(block_found_map, (*new_block)+i);
+		if (old_block) {
+			retval = io_channel_read_blk(fs->io, old_block + i,
+						     1, buf);
+			if (retval)
+				printf("Warning: could not read block %lu "
+				       "of %s: %s\n",
+				       old_block + i, name,
+				       error_message(retval));
+		} else
+			memset(buf, 0, fs->blocksize);
+
 		retval = io_channel_write_blk(fs->io, (*new_block) + i,
 					      1, buf);
 		if (retval)
-			printf("Warning: could not write block %ld for %s: %s\n",
+			printf("Warning: could not write block %lu for %s: %s\n",
 			       (*new_block) + i, name, error_message(retval));
-		/*
-		 * If this particular block is not marked as bad, then
-		 * clear its bit in the block_found map.  Otherwise,
-		 * leave it set, since it is included in the bad
-		 * blocks inode.
-		 */
-		if (!ext2fs_test_block_bitmap(fs, bad_fs_block_map,
-					      old_block + i))
-			ext2fs_unmark_block_bitmap(fs, block_found_map,
-						   old_block + i);
-		/*
-		 * Clear the bitmap since this block has now been moved.
-		 */
-		ext2fs_unmark_block_bitmap(fs, bad_fs_block_map,
-					   old_block + i);
 	}
 	free(buf);
 }
 
 /*
- * Helper function for handle_fs_bad_blocks()
+ * This routine gets called at the end of pass 1 if bad blocks are
+ * detected in the superblock, group descriptors, inode_bitmaps, or
+ * block bitmaps.  At this point, all of the blocks have been mapped
+ * out, so we can try to allocate new block(s) to replace the bad
+ * blocks.
  */
-static int process_fs_bad_block(ext2_filsys fs, blk_t *block_nr,
-			     int blockcnt, void *private)
+static void handle_fs_bad_blocks(ext2_filsys fs)
 {
-	int	i;
-	blk_t	block = *block_nr;
-	int	first_block = fs->super->s_first_data_block;
-
-	/*
-	 * If this block isn't one that is marked as a bad block in
-	 * the filesystem tables, return
-	 */
-	if (!ext2fs_test_block_bitmap(fs, bad_fs_block_map, block))
-		return 0;
+	int		i;
+	int		first_block = fs->super->s_first_data_block;
 
 	for (i = 0; i < fs->group_desc_count; i++) {
-		if (block == first_block)
-			printf("Bad block %ld in group %d's superblock.\n",
-			       block, i);
-		if (block == fs->group_desc[i].bg_block_bitmap) {
-			printf("Bad block %ld in group %d's block bitmap.  ",
-			       block, i);
-			if (ask("Relocate", 1)) {
-				new_table_block(fs, first_block,
-						"block bitmap", 1, 
+		if (invalid_block_bitmap[i]) {
+			new_table_block(fs, first_block, i, "block bitmap", 1, 
 					&fs->group_desc[i].bg_block_bitmap);
-			} else
-				ext2fs_unmark_valid(fs);
 		}
-		if (block == fs->group_desc[i].bg_inode_bitmap) {
-			printf("Bad block %ld in group %d's inode bitmap.  ",
-			       block, i);
-			if (ask("Relocate", 1)) {
-				new_table_block(fs, first_block,
-						"inode bitmap", 1, 
+		if (invalid_inode_bitmap[i]) {
+			new_table_block(fs, first_block, i, "inode bitmap", 1, 
 					&fs->group_desc[i].bg_inode_bitmap);
-			} else
-				ext2fs_unmark_valid(fs);
 		}
-		if ((block >= fs->group_desc[i].bg_inode_table) &&
-		    (block < (fs->group_desc[i].bg_inode_table +
-			      fs->inode_blocks_per_group))) {
-			printf("WARNING: Severe data loss possible!!!!\n");
-			printf("Bad block %ld in group %d's inode table.  ",
-			       block, i);
-			if (ask("Relocate", 1)) {
-				new_table_block(fs, first_block,
-						"inode table",
-						fs->inode_blocks_per_group, 
+		if (invalid_inode_table[i]) {
+			new_table_block(fs, first_block, i, "inode table",
+					fs->inode_blocks_per_group, 
 					&fs->group_desc[i].bg_inode_table);
-			} else
-				ext2fs_unmark_valid(fs);
+			restart_e2fsck++;
 		}
-		if ((block > first_block) &&
-		    (block <= first_block + fs->desc_blocks))
-			printf("Bad block %ld in group %d's copy of the descriptors.\n",
-			       block, i);
 		first_block += fs->super->s_blocks_per_group;
 	}
-	return 0;
+	invalid_bitmaps = 0;
 }
 
 /*
@@ -823,7 +966,7 @@
  */
 static void mark_table_blocks(ext2_filsys fs)
 {
-	blk_t	block;
+	blk_t	block, b;
 	int	i,j;
 	
 	block = fs->super->s_first_data_block;
@@ -831,29 +974,80 @@
 		/*
 		 * Mark block used for the block bitmap 
 		 */
-		ext2fs_mark_block_bitmap(fs, block_found_map,
-					 fs->group_desc[i].bg_block_bitmap);
+		if (fs->group_desc[i].bg_block_bitmap) {
+			if (ext2fs_test_block_bitmap(block_found_map,
+				     fs->group_desc[i].bg_block_bitmap)) {
+				printf("Group %i's block bitmap at %lu "
+				       "conflicts with some other fs block.\n",
+				       i, fs->group_desc[i].bg_block_bitmap);
+				preenhalt();
+				if (ask("Relocate", 1)) {
+					invalid_block_bitmap[i]++;
+					invalid_bitmaps++;
+				} else {
+					ext2fs_unmark_valid(fs);
+				}
+			} else
+			    ext2fs_mark_block_bitmap(block_found_map,
+				     fs->group_desc[i].bg_block_bitmap);
+		}
 		/*
 		 * Mark block used for the inode bitmap 
 		 */
-		ext2fs_mark_block_bitmap(fs, block_found_map,
-					 fs->group_desc[i].bg_inode_bitmap);
+		if (fs->group_desc[i].bg_inode_bitmap) {
+			if (ext2fs_test_block_bitmap(block_found_map,
+				     fs->group_desc[i].bg_inode_bitmap)) {
+				printf("Group %i's inode bitmap at %lu "
+				       "conflicts with some other fs block.\n",
+				       i, fs->group_desc[i].bg_inode_bitmap);
+				preenhalt();
+				if (ask("Relocate", 1)) {
+					invalid_inode_bitmap[i]++;
+					invalid_bitmaps++;
+				} else {
+					ext2fs_unmark_valid(fs);
+				}
+			} else
+			    ext2fs_mark_block_bitmap(block_found_map,
+				     fs->group_desc[i].bg_inode_bitmap);
+		}
+		    
 		/*
 		 * Mark the blocks used for the inode table
 		 */
-		for (j = 0; j < fs->inode_blocks_per_group; j++)
-			ext2fs_mark_block_bitmap(fs, block_found_map,
-						 fs->group_desc[i].bg_inode_table + j);
+		if (fs->group_desc[i].bg_inode_table) {
+			for (j = 0, b = fs->group_desc[i].bg_inode_table;
+			     j < fs->inode_blocks_per_group;
+			     j++, b++) {
+				if (ext2fs_test_block_bitmap(block_found_map,
+							     b)) {
+					printf("Group %i's inode table at %lu "
+					       "conflicts with some other "
+					       "fs block.\n",
+					       i, b);
+					preenhalt();
+					if (ask("Relocate", 1)) {
+						invalid_inode_table[i]++;
+						invalid_bitmaps++;
+					} else {
+						ext2fs_unmark_valid(fs);
+					}
+				} else
+				    ext2fs_mark_block_bitmap(block_found_map,
+							     b);
+			}
+		}
+			    
 		/*
 		 * Mark this group's copy of the superblock
 		 */
-		ext2fs_mark_block_bitmap(fs, block_found_map, block);
+		ext2fs_mark_block_bitmap(block_found_map, block);
 		
 		/*
 		 * Mark this group's copy of the descriptors
 		 */
 		for (j = 0; j < fs->desc_blocks; j++)
-			ext2fs_mark_block_bitmap(fs, block_found_map,
+			ext2fs_mark_block_bitmap(block_found_map,
 						 block + j + 1);
 		block += fs->super->s_blocks_per_group;
 	}
@@ -874,9 +1068,9 @@
 			blocks[i] = stashed_inode->i_block[i];
 		return 0;
 	}
-	printf("INTERNAL ERROR: pass1_get_blocks: unexpected inode #%ld\n",
+	printf("INTERNAL ERROR: pass1_get_blocks: unexpected inode #%lu\n",
 	       ino);
-	printf("\t(was expecting %ld)\n", stashed_ino);
+	printf("\t(was expecting %lu)\n", stashed_ino);
 	exit(FSCK_ERROR);
 }
 
@@ -887,8 +1081,8 @@
 			return ENOTDIR;
 		return 0;
 	}
-	printf("INTERNAL ERROR: pass1_check_directory: unexpected inode #%ld\n",
+	printf("INTERNAL ERROR: pass1_check_directory: unexpected inode #%lu\n",
 	       ino);
-	printf("\t(was expecting %ld)\n", stashed_ino);
+	printf("\t(was expecting %lu)\n", stashed_ino);
 	exit(FSCK_ERROR);
 }
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index dd657bf..c98030f 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -101,7 +101,7 @@
 extern ino_t stashed_ino;
 extern struct ext2_inode *stashed_inode;
 
-static char *inode_dup_map;
+static ext2fs_inode_bitmap inode_dup_map;
 
 /*
  * Main procedure for handling duplicate blocks
@@ -112,7 +112,8 @@
 	struct dup_block	*p, *q, *next_p, *next_q;
 	struct dup_inode	*r, *next_r;
 	
-	retval = ext2fs_allocate_inode_bitmap(fs, &inode_dup_map);
+	retval = ext2fs_allocate_inode_bitmap(fs,
+		      "multiply claimed inode map", &inode_dup_map);
 	if (retval) {
 		com_err("ext2fs_allocate_inode_bitmap", retval,
 			"while allocating inode_dup_map");
@@ -127,8 +128,8 @@
 	 * Time to free all of the accumulated data structures that we
 	 * don't need anymore.
 	 */
-	free(inode_dup_map);   	inode_dup_map = 0;
-	free(block_dup_map);    block_dup_map = 0;
+	ext2fs_free_inode_bitmap(inode_dup_map);   	inode_dup_map = 0;
+	ext2fs_free_block_bitmap(block_dup_map);    block_dup_map = 0;
 	for (p = dup_blk; p; p = next_p) {
 		next_p = p->next_block;
 		for (q = p; q; q = next_q) {
@@ -177,7 +178,7 @@
 	while (ino) {
 		stashed_ino = ino;
 		if ((ino != EXT2_BAD_INO) &&
-		    (!ext2fs_test_inode_bitmap(fs, inode_used_map, ino) ||
+		    (!ext2fs_test_inode_bitmap(inode_used_map, ino) ||
 		     !inode_has_valid_blocks(&inode)))
 			goto next;
 
@@ -230,17 +231,17 @@
 		return 0;
 	p = (struct process_block_struct *) private;
 	
-	if (ext2fs_test_block_bitmap(fs, block_dup_map, *block_nr)) {
+	if (ext2fs_test_block_bitmap(block_dup_map, *block_nr)) {
 		/* OK, this is a duplicate block */
 		if (p->ino != EXT2_BAD_INO) {
 			if (!p->dup_blocks)
-				printf("Duplicate/bad block(s) in inode %ld:",
+				printf("Duplicate/bad block(s) in inode %lu:",
 				       p->ino);
-			printf(" %ld", *block_nr);
+			printf(" %lu", *block_nr);
 		}
 		p->dup_blocks++;
-		ext2fs_mark_block_bitmap(fs, block_dup_map, *block_nr);
-		ext2fs_mark_inode_bitmap(fs, inode_dup_map, p->ino);
+		ext2fs_mark_block_bitmap(block_dup_map, *block_nr);
+		ext2fs_mark_inode_bitmap(inode_dup_map, p->ino);
 		dp = allocate_memory(sizeof(struct dup_block),
 				      "duplicate block record");
 		dp->block = *block_nr;
@@ -340,7 +341,7 @@
 			    ((dir_blocks[i].blockcnt == 0) && (entry <= 2)))
 				goto next;
 
-			if (!ext2fs_test_inode_bitmap(fs, inode_dup_map,
+			if (!ext2fs_test_inode_bitmap(inode_dup_map,
 						      dirent->inode))
 				goto next;
 
@@ -369,7 +370,7 @@
 	 */
 	for (p = dup_ino; p; p = p->next) {
 		if (!p->pathname) {
-			sprintf(buf, "<Unknown inode #%ld>", p->ino);
+			sprintf(buf, "<Unknown inode #%lu>", p->ino);
 			p->pathname = malloc(strlen(buf)+1);
 			if (!p->pathname) {
 				fprintf(stderr,	"pass1c: couldn't malloc "
@@ -440,7 +441,7 @@
 		}
 		time_str = ctime(&p->mtime);
 		time_str[24] = 0;
-		printf("File %s (inode #%ld, mod time %s) \n",
+		printf("File %s (inode #%lu, mod time %s) \n",
 		       p->pathname, p->ino, time_str);
 		printf("  has %d duplicate blocks, shared with %d file%s:\n",
 		       p->num_dupblocks, shared_len,
@@ -453,7 +454,7 @@
 				continue;
 			time_str = ctime(&s->mtime);
 			time_str[24] = 0;
-			printf("\t%s (inode #%ld, mod time %s)\n",
+			printf("\t%s (inode #%lu, mod time %s)\n",
 			       s->pathname, s->ino, time_str);
 		}
 		if (file_ok) {
@@ -489,22 +490,22 @@
 	if (!*block_nr)
 		return 0;
 
-	if (ext2fs_test_block_bitmap(fs, block_dup_map, *block_nr)) {
+	if (ext2fs_test_block_bitmap(block_dup_map, *block_nr)) {
 		for (p = dup_blk; p; p = p->next_block)
 			if (p->block == *block_nr)
 				break;
 		if (p) {
 			p->num_bad--;
 			if (p->num_bad == 1)
-				ext2fs_unmark_block_bitmap(fs, block_dup_map,
+				ext2fs_unmark_block_bitmap(block_dup_map,
 							   *block_nr);
 		} else
 			com_err("delete_file_block", 0,
 				"internal error; can't find dup_blk for %d\n",
 				*block_nr);
 	} else {
-		ext2fs_unmark_block_bitmap(fs, block_found_map, *block_nr);
-		ext2fs_unmark_block_bitmap(fs, fs->block_map, *block_nr);
+		ext2fs_unmark_block_bitmap(block_found_map, *block_nr);
+		ext2fs_unmark_block_bitmap(fs->block_map, *block_nr);
 	}
 		
 	return 0;
@@ -525,27 +526,17 @@
 		com_err("delete_file", retval,
 			"while calling ext2fs_block_iterate for inode %d",
 			dp->ino);
-	ext2fs_unmark_inode_bitmap(fs, inode_used_map, dp->ino);
-	ext2fs_unmark_inode_bitmap(fs, inode_dir_map, dp->ino);
+	ext2fs_unmark_inode_bitmap(inode_used_map, dp->ino);
+	ext2fs_unmark_inode_bitmap(inode_dir_map, dp->ino);
 	if (inode_bad_map)
-		ext2fs_unmark_inode_bitmap(fs, inode_bad_map, dp->ino);
-	ext2fs_unmark_inode_bitmap(fs, fs->inode_map, dp->ino);
+		ext2fs_unmark_inode_bitmap(inode_bad_map, dp->ino);
+	ext2fs_unmark_inode_bitmap(fs->inode_map, dp->ino);
 	ext2fs_mark_ib_dirty(fs);
 	ext2fs_mark_bb_dirty(fs);
-	retval = ext2fs_read_inode(fs, dp->ino, &inode);
-	if (retval) {
-		com_err("delete_file", retval, "while reading inode %d",
-			dp->ino);
-		return;
-	}
+	e2fsck_read_inode(fs, dp->ino, &inode, "delete_file");
 	inode.i_links_count = 0;
 	inode.i_dtime = time(0);
-	retval = ext2fs_write_inode(fs, dp->ino, &inode);
-	if (retval) {
-		com_err("delete_file", retval, "while writing inode %d",
-			dp->ino);
-		return;
-	}
+	e2fsck_write_inode(fs, dp->ino, &inode, "delete_file");
 }
 
 struct clone_struct {
@@ -566,7 +557,7 @@
 	if (!*block_nr)
 		return 0;
 
-	if (ext2fs_test_block_bitmap(fs, block_dup_map, *block_nr)) {
+	if (ext2fs_test_block_bitmap(block_dup_map, *block_nr)) {
 		for (p = dup_blk; p; p = p->next_block)
 			if (p->block == *block_nr)
 				break;
@@ -591,12 +582,12 @@
 			}
 			p->num_bad--;
 			if (p->num_bad == 1)
-				ext2fs_unmark_block_bitmap(fs, block_dup_map,
+				ext2fs_unmark_block_bitmap(block_dup_map,
 							   *block_nr);
 			*block_nr = new_block;
-			ext2fs_mark_block_bitmap(fs, block_found_map,
+			ext2fs_mark_block_bitmap(block_found_map,
 						 new_block);
-			ext2fs_mark_block_bitmap(fs, fs->block_map, new_block);
+			ext2fs_mark_block_bitmap(fs->block_map, new_block);
 			return BLOCK_CHANGED;
 		} else
 			com_err("clone_file_block", 0,
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 327cf16..3331cb9 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -79,7 +79,7 @@
 	free(buf);
 	free(dir_blocks);
 	if (inode_bad_map) {
-		free(inode_bad_map);
+		ext2fs_free_inode_bitmap(inode_bad_map);
 		inode_bad_map = 0;
 	}
 	if (tflag > 1) {
@@ -103,7 +103,7 @@
 	char	name[BLOCK_SIZE];
 	
 	if (!dirent->inode) {
-		printf("Missing '.' in directory inode %ld.\n", ino);
+		printf("Missing '.' in directory inode %lu.\n", ino);
 		if (dirent->rec_len < 12)
 			fatal_error("Cannot fix, insufficient space to add '.'");
 		preenhalt();
@@ -122,13 +122,13 @@
 	    strncmp(dirent->name, ".", dirent->name_len)) {
 		strncpy(name, dirent->name, dirent->name_len);
 		name[dirent->name_len] = '\0';
-		printf("Missing '.' in directory inode %ld.\n", ino);
+		printf("Missing '.' in directory inode %lu.\n", ino);
 		printf("Cannot fix, first entry in directory contains '%s'\n",
 		       name);
 		exit(FSCK_ERROR);
 	}
 	if (dirent->inode != ino) {
-		printf("Bad inode number for '.' in directory inode %ld.\n",
+		printf("Bad inode number for '.' in directory inode %lu.\n",
 		       ino);
 		preenhalt();
 		if (ask("Fix", 1)) {
@@ -166,10 +166,10 @@
 			struct dir_info *dir)
 {
 	char	name[BLOCK_SIZE];
-	int	ino = dir->ino;
+	ino_t	ino = dir->ino;
 	
 	if (!dirent->inode) {
-		printf("Missing '..' in directory inode %d.\n", ino);
+		printf("Missing '..' in directory inode %lu.\n", ino);
 		if (dirent->rec_len < 12)
 			fatal_error("Cannot fix, insufficient space to add '..'");
 		preenhalt();
@@ -192,7 +192,7 @@
 	    strncmp(dirent->name, "..", dirent->name_len)) {
 		strncpy(name, dirent->name, dirent->name_len);
 		name[dirent->name_len] = '\0';
-		printf("Missing '..' in directory inode %d.\n", ino);
+		printf("Missing '..' in directory inode %lu.\n", ino);
 		printf("Cannot fix, first entry in directory contains %s\n",
 		       name);
 		exit(FSCK_ERROR);
@@ -201,6 +201,8 @@
 	return 0;
 }
 
+static char unknown_pathname[] = "???";
+
 /*
  * Check to make sure a directory entry doesn't contain any illegal
  * characters.
@@ -223,12 +225,13 @@
 							     0, &pathname);
 				if (retval) {
 					com_err(program_name, retval, "while getting pathname in check_name");
-					fatal_error(0);
+					pathname = unknown_pathname;
 				}
 				printf ("Bad file name '%s' (contains '/' or "
-					" null) in directory '%s'",
-					pathname, name);
-				free(pathname);
+					" null) in directory '%s' (%lu)\n",
+					name, pathname, dir_ino);
+				if (pathname != unknown_pathname)
+					free(pathname);
 				preenhalt();
 				fixup = ask("Replace '/' or null by '.'", 1);
 			}
@@ -256,13 +259,12 @@
 	int			dot_state;
 	blk_t			block_nr = db->blk;
 	ino_t 			ino = db->ino;
-	static char 		unknown[] = "???";
 
 	/*
 	 * Make sure the inode is still in use (could have been 
 	 * deleted in the duplicate/bad blocks pass.
 	 */
-	if (!(ext2fs_test_inode_bitmap(fs, inode_used_map, ino))) 
+	if (!(ext2fs_test_inode_bitmap(inode_used_map, ino))) 
 		return 0;
 	
 	if (db->blockcnt)
@@ -271,7 +273,7 @@
 		dot_state = 0;
 
 #if 0
-	printf("In process_dir_block block %d, #%d, inode %d\n", block_nr,
+	printf("In process_dir_block block %lu, #%d, inode %lu\n", block_nr,
 	       db->blockcnt, ino);
 #endif
 	
@@ -287,7 +289,7 @@
 		if (((offset + dirent->rec_len) > fs->blocksize) ||
 		    (dirent->rec_len < 8) ||
 		    ((dirent->name_len+8) > dirent->rec_len)) {
-			printf("Directory inode %ld, block %d, offset %d: directory corrupted\n",
+			printf("Directory inode %lu, block %d, offset %d: directory corrupted\n",
 			       ino, db->blockcnt, offset);
 			preenhalt();
 			if (ask("Salvage", 1)) {
@@ -308,7 +310,7 @@
 		} else if (dot_state == 2) {
 			dir = get_dir_info(ino);
 			if (!dir) {
-				printf("Internal error: couldn't find dir_info for %ld\n",
+				printf("Internal error: couldn't find dir_info for %lu\n",
 				       ino);
 				fatal_error(0);
 			}
@@ -317,10 +319,10 @@
 		} else if (dirent->inode == ino) {
 			retval = ext2fs_get_pathname(fs, ino, 0, &path1);
 			if (retval)
-				path1 = unknown;
-			printf("Entry '%s' in %s (%ld) is a link to '.'  ",
+				path1 = unknown_pathname;
+			printf("Entry '%s' in %s (%lu) is a link to '.'  ",
 			       name, path1, ino);
-			if (path1 != unknown)
+			if (path1 != unknown_pathname)
 				free(path1);
 			preenhalt();
 			if (ask("Clear", 1)) {
@@ -332,7 +334,7 @@
 			goto next;
 		
 #if 0
-		printf("Entry '%s', name_len %d, rec_len %d, inode %d... ",
+		printf("Entry '%s', name_len %d, rec_len %d, inode %lu... ",
 		       name, dirent->name_len, dirent->rec_len, dirent->inode);
 #endif
 		if (check_name(fs, dirent, ino, name))
@@ -346,10 +348,10 @@
 		    (dirent->inode > fs->super->s_inodes_count)) {
 			retval = ext2fs_get_pathname(fs, ino, 0, &path1);
 			if (retval)
-				path1 = unknown;
-			printf("Entry '%s' in %s (%ld) has bad inode #: %ld.\n",
+				path1 = unknown_pathname;
+			printf("Entry '%s' in %s (%lu) has bad inode #: %lu.\n",
 			       name, path1, ino, dirent->inode);
-			if (path1 != unknown)
+			if (path1 != unknown_pathname)
 				free(path1);
 			preenhalt();
 			if (ask("Clear", 1)) {
@@ -363,14 +365,14 @@
 		/*
 		 * If the inode is unusued, offer to clear it.
 		 */
-		if (!(ext2fs_test_inode_bitmap(fs, inode_used_map,
+		if (!(ext2fs_test_inode_bitmap(inode_used_map,
 					       dirent->inode))) {
 			retval = ext2fs_get_pathname(fs, ino, 0, &path1);
 			if (retval)
-				path1 = unknown;
-			printf("Entry '%s' in %s (%ld) has deleted/unused inode %ld.\n",
+				path1 = unknown_pathname;
+			printf("Entry '%s' in %s (%lu) has deleted/unused inode %lu.\n",
 			       name, path1, ino, dirent->inode);
-			if (path1 != unknown)
+			if (path1 != unknown_pathname)
 				free(path1);
 			if (ask("Clear", 1)) {
 				dirent->inode = 0;
@@ -387,7 +389,7 @@
 		 * pathname to the user.)
 		 */
 		if (inode_bad_map &&
-		    ext2fs_test_inode_bitmap(fs, inode_bad_map,
+		    ext2fs_test_inode_bitmap(inode_bad_map,
 					     dirent->inode)) {
 			if (process_bad_inode(fs, ino, dirent->inode)) {
 				dirent->inode = 0;
@@ -404,11 +406,11 @@
 		 * and ask the user if he/she wants to clear this one.
 		 */
 		if ((dot_state > 2) &&
-		    (ext2fs_test_inode_bitmap(fs, inode_dir_map,
+		    (ext2fs_test_inode_bitmap(inode_dir_map,
 					      dirent->inode))) {
 			subdir = get_dir_info(dirent->inode);
 			if (!subdir) {
-				printf("INTERNAL ERROR: missing dir %ld\n",
+				printf("INTERNAL ERROR: missing dir %lu\n",
 				       dirent->inode);
 				fatal_error(0);
 			}
@@ -416,19 +418,19 @@
 				retval = ext2fs_get_pathname(fs, ino,
 							     0, &path1);
 				if (retval)
-					path1 = unknown;
+					path1 = unknown_pathname;
 				retval = ext2fs_get_pathname(fs,
 							     subdir->parent,
 							     dirent->inode,
 							     &path2);
 				if (retval)
-					path2 = unknown;
-				printf("Entry '%s' in %s (%ld) is a link to directory %s (%ld).\n",
+					path2 = unknown_pathname;
+				printf("Entry '%s' in %s (%lu) is a link to directory %s (%lu).\n",
 				       name, path1, ino, path2, 
 				       dirent->inode);
-				if (path1 != unknown)
+				if (path1 != unknown_pathname)
 					free(path1);
-				if (path2 != unknown)
+				if (path2 != unknown_pathname)
 					free(path2);
 				if (ask("Clear", 1)) {
 					dirent->inode = 0;
@@ -477,8 +479,8 @@
 {
 	if (!*block_nr)
 		return 0;
-	ext2fs_unmark_block_bitmap(fs, block_found_map, *block_nr);
-	ext2fs_unmark_block_bitmap(fs, fs->block_map, *block_nr);
+	ext2fs_unmark_block_bitmap(block_found_map, *block_nr);
+	ext2fs_unmark_block_bitmap(fs->block_map, *block_nr);
 	return 0;
 }
 		
@@ -491,29 +493,20 @@
 	errcode_t		retval;
 	struct ext2_inode	inode;
 
-	retval = ext2fs_read_inode(fs, ino, &inode);
-	if (retval) {
-		com_err("deallocate_inode", retval, "while reading inode %d",
-			ino);
-		return;
-	}
+	e2fsck_read_inode(fs, ino, &inode, "deallocate_inode");
 	inode.i_links_count = 0;
 	inode.i_dtime = time(0);
-	retval = ext2fs_write_inode(fs, ino, &inode);
-	if (retval) {
-		com_err("deallocate_inode", retval, "while writing inode %d",
-			ino);
-		return;
-	}
+	e2fsck_write_inode(fs, ino, &inode, "deallocate_inode");
+
 	/*
 	 * Fix up the bitmaps...
 	 */
 	read_bitmaps(fs);
-	ext2fs_unmark_inode_bitmap(fs, inode_used_map, ino);
-	ext2fs_unmark_inode_bitmap(fs, inode_dir_map, ino);
+	ext2fs_unmark_inode_bitmap(inode_used_map, ino);
+	ext2fs_unmark_inode_bitmap(inode_dir_map, ino);
 	if (inode_bad_map)
-		ext2fs_unmark_inode_bitmap(fs, inode_bad_map, ino);
-	ext2fs_unmark_inode_bitmap(fs, fs->inode_map, ino);
+		ext2fs_unmark_inode_bitmap(inode_bad_map, ino);
+	ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
 	ext2fs_mark_ib_dirty(fs);
 
 	if (!inode_has_valid_blocks(&inode))
@@ -540,7 +533,7 @@
 	char prompt[80];
 	
 	if (*val) {
-		printf("%s for inode %ld (%s) is %ld, should be zero.\n",
+		printf("%s for inode %lu (%s) is %lu, should be zero.\n",
 		       name, ino, pathname, *val);
 		preenhalt();
 		sprintf(prompt, "Clear %s", name);
@@ -559,7 +552,7 @@
 	char prompt[80];
 	
 	if (*val) {
-		printf("%s for inode %ld (%s) is %d, should be zero.\n",
+		printf("%s for inode %lu (%s) is %d, should be zero.\n",
 		       name, ino, pathname, *val);
 		preenhalt();
 		sprintf(prompt, "Clear %s", name);
@@ -580,12 +573,7 @@
 	int			inode_modified = 0;
 	char			*pathname;
 
-	retval = ext2fs_read_inode(fs, ino, &inode);
-	if (retval) {
-		com_err("process_bad_inode", retval, "while reading inode %d",
-			ino);
-		return 0;
-	}	
+	e2fsck_read_inode(fs, ino, &inode, "process_bad_inode");
 	retval = ext2fs_get_pathname(fs, dir, ino, &pathname);
 	if (retval) {
 		com_err("process_bad_inode", retval,
@@ -597,7 +585,7 @@
 	    !S_ISCHR(inode.i_mode) && !S_ISBLK(inode.i_mode) &&
 	    !S_ISLNK(inode.i_mode) && !S_ISFIFO(inode.i_mode) &&
 	    !(S_ISSOCK(inode.i_mode))) {
-		printf("Inode %ld (%s) has a bad mode (0%o).\n",
+		printf("Inode %lu (%s) has a bad mode (0%o).\n",
 		       ino, pathname, inode.i_mode);
 		preenhalt();
 		if (ask("Clear", 1)) {
@@ -617,15 +605,8 @@
 	check_for_zero_long(fs, ino, pathname, "i_dir_acl", &inode.i_dir_acl,
 			    &inode_modified);
 	free(pathname);
-	if (inode_modified) {
-		retval = ext2fs_write_inode(fs, ino, &inode);
-		if (retval) {
-			com_err("process_bad_inode", retval,
-				"while writing inode %d",
-				ino);
-			return 0;
-		}
-	}
+	if (inode_modified)
+		e2fsck_write_inode(fs, ino, &inode, "process_bad_inode");
 	return 0;
 }
 
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index b34acd2..7e3ad97 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -38,14 +38,14 @@
 static void check_directory(ext2_filsys fs, ino_t dir);
 static ino_t get_lost_and_found(ext2_filsys fs);
 static void fix_dotdot(ext2_filsys fs, struct dir_info *dir, ino_t parent);
-static int adjust_inode_count(ext2_filsys fs, ino_t ino, int adj);
+static errcode_t adjust_inode_count(ext2_filsys fs, ino_t ino, int adj);
 static errcode_t expand_directory(ext2_filsys fs, ino_t dir);
 
 static ino_t lost_and_found = 0;
 static int bad_lost_and_found = 0;
 
-static char *inode_loop_detect;
-static char *inode_done_map;
+static ext2fs_inode_bitmap inode_loop_detect;
+static ext2fs_inode_bitmap inode_done_map;
 	
 void pass3(ext2_filsys fs)
 {
@@ -65,13 +65,16 @@
 	/*
 	 * Allocate some bitmaps to do loop detection.
 	 */
-	retval = ext2fs_allocate_inode_bitmap(fs, &inode_loop_detect);
+	retval = ext2fs_allocate_inode_bitmap(fs,
+					      "inode loop detection bitmap",
+					      &inode_loop_detect);
 	if (retval) {
 		com_err("ext2fs_allocate_inode_bitmap", retval,
 			"while allocating inode_loop_detect");
 		fatal_error(0);
 	}
-	retval = ext2fs_allocate_inode_bitmap(fs, &inode_done_map);
+	retval = ext2fs_allocate_inode_bitmap(fs, "inode done bitmap",
+					      &inode_done_map);
 	if (retval) {
 		com_err("ext2fs_allocate_inode_bitmap", retval,
 			"while allocating inode_done_map");
@@ -83,16 +86,16 @@
 	}
 
 	check_root(fs, EXT2_ROOT_INO);
-	ext2fs_mark_inode_bitmap(fs, inode_done_map, EXT2_ROOT_INO);
+	ext2fs_mark_inode_bitmap(inode_done_map, EXT2_ROOT_INO);
 
 	for (i=1; i <= fs->super->s_inodes_count; i++) {
-		if (ext2fs_test_inode_bitmap(fs, inode_dir_map, i))
+		if (ext2fs_test_inode_bitmap(inode_dir_map, i))
 			check_directory(fs, i);
 	}
 	
 	free_dir_info(fs);
-	free(inode_loop_detect);
-	free(inode_done_map);
+	ext2fs_free_inode_bitmap(inode_loop_detect);
+	ext2fs_free_inode_bitmap(inode_done_map);
 	if (tflag > 1) {
 		printf("Pass 3: ");
 		print_resource_track(&rtrack);
@@ -111,13 +114,13 @@
 	char *			block;
 	struct dir_info		*dir;
 	
-	if (ext2fs_test_inode_bitmap(fs, inode_used_map, root_ino)) {
+	if (ext2fs_test_inode_bitmap(inode_used_map, root_ino)) {
 		/*
 		 * If the root inode is a directory, die here.  The
 		 * user must have answered 'no' in pass1 when we
 		 * offered to clear it.
 		 */
-		if (!(ext2fs_test_inode_bitmap(fs, inode_dir_map, root_ino)))
+		if (!(ext2fs_test_inode_bitmap(inode_dir_map, root_ino)))
 			fatal_error("Root inode not directory");
 		
 		/*
@@ -148,8 +151,8 @@
 			"while trying to create root directory");
 		fatal_error(0);
 	}
-	ext2fs_mark_block_bitmap(fs, block_found_map, blk);
-	ext2fs_mark_block_bitmap(fs, fs->block_map, blk);
+	ext2fs_mark_block_bitmap(block_found_map, blk);
+	ext2fs_mark_block_bitmap(fs->block_map, blk);
 	ext2fs_mark_bb_dirty(fs);
 
 	/*
@@ -199,9 +202,9 @@
 	inode_count[EXT2_ROOT_INO] = 2;
 	inode_link_info[EXT2_ROOT_INO] = 2;
 
-	ext2fs_mark_inode_bitmap(fs, inode_used_map, EXT2_ROOT_INO);
-	ext2fs_mark_inode_bitmap(fs, inode_dir_map, EXT2_ROOT_INO);
-	ext2fs_mark_inode_bitmap(fs, fs->inode_map, EXT2_ROOT_INO);
+	ext2fs_mark_inode_bitmap(inode_used_map, EXT2_ROOT_INO);
+	ext2fs_mark_inode_bitmap(inode_dir_map, EXT2_ROOT_INO);
+	ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_ROOT_INO);
 	ext2fs_mark_ib_dirty(fs);
 }
 
@@ -223,12 +226,12 @@
 
 	dir = get_dir_info(ino);
 	if (!dir) {
-		printf("Internal error: couldn't find dir_info for %ld\n",
+		printf("Internal error: couldn't find dir_info for %lu\n",
 		       ino);
 		fatal_error(0);
 	}
 
-	memset(inode_loop_detect, 0, (fs->super->s_inodes_count / 8) + 1);
+	ext2fs_clear_inode_bitmap(inode_loop_detect);
 	p = dir;
 	while (p) {
 		/*
@@ -238,7 +241,7 @@
 		 * already told us he doesn't want us to reconnect the
 		 * disconnected subtree.
 		 */
-		if (ext2fs_test_inode_bitmap(fs, inode_done_map, p->ino))
+		if (ext2fs_test_inode_bitmap(inode_done_map, p->ino))
 			goto check_dot_dot;
 		/*
 		 * Mark this inode as being "done"; by the time we
@@ -247,17 +250,17 @@
 		 * or we will have offered to reconnect this to
 		 * lost+found.
 		 */
-		ext2fs_mark_inode_bitmap(fs, inode_done_map, p->ino);
+		ext2fs_mark_inode_bitmap(inode_done_map, p->ino);
 		/*
 		 * If this directory doesn't have a parent, or we've
 		 * seen the parent once already, then offer to
 		 * reparent it to lost+found
 		 */
 		if (!p->parent ||
-		    (ext2fs_test_inode_bitmap(fs, inode_loop_detect,
+		    (ext2fs_test_inode_bitmap(inode_loop_detect,
 					      p->parent)))
 			break;
-		ext2fs_mark_inode_bitmap(fs, inode_loop_detect,
+		ext2fs_mark_inode_bitmap(inode_loop_detect,
 					 p->parent);
 		p = get_dir_info(p->parent);
 	}
@@ -269,7 +272,7 @@
 	if (retval)
 		path1 = unknown;
 
-	printf("Unconnected directory inode %li (%s)\n", p->ino, path1);
+	printf("Unconnected directory inode %lu (%s)\n", p->ino, path1);
 	if (path1 != unknown)
 		free(path1);
 	preenhalt();
@@ -301,7 +304,7 @@
 		if (retval)
 			path3 = unknown;
 		
-		printf("'..' in %s (%ld) is %s (%ld), should be %s (%ld).\n",
+		printf("'..' in %s (%lu) is %s (%lu), should be %s (%lu).\n",
 		       path1, ino, path2, dir->dotdot,
 		       path3, dir->parent);
 		if (path1 != unknown)
@@ -359,8 +362,8 @@
 			"while trying to create /lost+found directory");
 		return 0;
 	}
-	ext2fs_mark_block_bitmap(fs, block_found_map, blk);
-	ext2fs_mark_block_bitmap(fs, fs->block_map, blk);
+	ext2fs_mark_block_bitmap(block_found_map, blk);
+	ext2fs_mark_block_bitmap(fs->block_map, blk);
 	ext2fs_mark_bb_dirty(fs);
 
 	/*
@@ -373,9 +376,9 @@
 			"while trying to create /lost+found directory");
 		return 0;
 	}
-	ext2fs_mark_inode_bitmap(fs, inode_used_map, ino);
-	ext2fs_mark_inode_bitmap(fs, inode_dir_map, ino);
-	ext2fs_mark_inode_bitmap(fs, fs->inode_map, ino);
+	ext2fs_mark_inode_bitmap(inode_used_map, ino);
+	ext2fs_mark_inode_bitmap(inode_dir_map, ino);
+	ext2fs_mark_inode_bitmap(fs->inode_map, ino);
 	ext2fs_mark_ib_dirty(fs);
 
 	/*
@@ -433,7 +436,7 @@
 	inode_count[ino] = 2;
 	inode_link_info[ino] = 2;
 #if 0
-	printf("/lost+found created; inode #%d\n", ino);
+	printf("/lost+found created; inode #%lu\n", ino);
 #endif
 	return ino;
 }
@@ -459,7 +462,7 @@
 		}
 	}
 
-	sprintf(name, "#%ld", inode);
+	sprintf(name, "#%lu", inode);
 	retval = ext2fs_link(fs, lost_and_found, name, inode, 0);
 	if (retval == EXT2_ET_DIR_NO_SPACE) {
 		if (!ask("No room in /lost+found; expand /lost+found", 1))
@@ -473,7 +476,7 @@
 		retval = ext2fs_link(fs, lost_and_found, name, inode, 0);
 	}
 	if (retval) {
-		printf("Could not reconnect %ld: %s\n", inode,
+		printf("Could not reconnect %lu: %s\n", inode,
 		       error_message(retval));
 		return 1;
 	}
@@ -486,7 +489,7 @@
 /*
  * Utility routine to adjust the inode counts on an inode.
  */
-static int adjust_inode_count(ext2_filsys fs, ino_t ino, int adj)
+static errcode_t adjust_inode_count(ext2_filsys fs, ino_t ino, int adj)
 {
 	errcode_t		retval;
 	struct ext2_inode 	inode;
@@ -499,7 +502,7 @@
 		return retval;
 
 #if 0
-	printf("Adjusting link count for inode %d by %d (from %d)\n", ino, adj,
+	printf("Adjusting link count for inode %lu by %d (from %d)\n", ino, adj,
 	       inode.i_links_count);
 #endif
 
@@ -539,11 +542,11 @@
 	
 	retval = adjust_inode_count(fp->fs, dirent->inode, -1);
 	if (retval)
-		printf("Error while adjusting inode count on inode %ld\n",
+		printf("Error while adjusting inode count on inode %lu\n",
 		       dirent->inode);
 	retval = adjust_inode_count(fp->fs, fp->parent, 1);
 	if (retval)
-		printf("Error while adjusting inode count on inode %ld\n",
+		printf("Error while adjusting inode count on inode %lu\n",
 		       fp->parent);
 
 	dirent->inode = fp->parent;
@@ -562,13 +565,13 @@
 	fp.done = 0;
 
 #if 0
-	printf("Fixing '..' of inode %d to be %d...\n", dir->ino, parent);
+	printf("Fixing '..' of inode %lu to be %lu...\n", dir->ino, parent);
 #endif
 	
 	retval = ext2fs_dir_iterate(fs, dir->ino, DIRENT_FLAG_INCLUDE_EMPTY,
 				    0, fix_dotdot_proc, &fp);
 	if (retval || !fp.done) {
-		printf("Couldn't fix parent of inode %ld: %s\n\n",
+		printf("Couldn't fix parent of inode %lu: %s\n\n",
 		       dir->ino, retval ? error_message(retval) :
 		       "Couldn't find parent direntory entry");
 		ext2fs_unmark_valid(fs);
@@ -630,8 +633,8 @@
 	}
 	free(block);
 	*blocknr = new_blk;
-	ext2fs_mark_block_bitmap(fs, block_found_map, new_blk);
-	ext2fs_mark_block_bitmap(fs, fs->block_map, new_blk);
+	ext2fs_mark_block_bitmap(block_found_map, new_blk);
+	ext2fs_mark_block_bitmap(fs->block_map, new_blk);
 	ext2fs_mark_bb_dirty(fs);
 	if (es->done)
 		return (BLOCK_CHANGED | BLOCK_ABORT);
@@ -673,9 +676,7 @@
 	inode.i_size += fs->blocksize;
 	inode.i_blocks += fs->blocksize / 512;
 
-	retval = ext2fs_write_inode(fs, dir, &inode);
-	if (retval)
-		return retval;
+	e2fsck_write_inode(fs, dir, &inode, "expand_directory");
 
 	return 0;
 }
diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c
index 290e1b9..1075731 100644
--- a/e2fsck/pass4.c
+++ b/e2fsck/pass4.c
@@ -10,7 +10,7 @@
 
 void pass4(ext2_filsys fs)
 {
-	int	i;
+	ino_t	i;
 	struct ext2_inode	inode;
 	struct resource_track	rtrack;
 	
@@ -21,19 +21,19 @@
 #endif
 
 	if (!preen)
-		printf("Pass 4: Check reference counts.\n");
+		printf("Pass 4: Checking reference counts\n");
 	for (i=1; i <= fs->super->s_inodes_count; i++) {
 		if (i == EXT2_BAD_INO ||
 		    (i > EXT2_ROOT_INO && i < EXT2_FIRST_INO))
 			continue;
-		if (!(ext2fs_test_inode_bitmap(fs, inode_used_map, i)))
+		if (!(ext2fs_test_inode_bitmap(inode_used_map, i)))
 			continue;
 		if (inode_count[i] == 0) {
 			/*
 			 * Inode isn't attached to the filesystem;
 			 * prompt to reconnect.
 			 */
-			printf("Unattached inode %d\n", i);
+			printf("Unattached inode %lu\n", i);
 			preenhalt();
 			if (ask("Connect to /lost+found", 1)) {
 				if (reconnect_file(fs, i))
@@ -42,20 +42,20 @@
 				ext2fs_unmark_valid(fs);
 		}
 		if (inode_count[i] != inode_link_info[i]) {
-			ext2fs_read_inode(fs, i, &inode);
+			e2fsck_read_inode(fs, i, &inode, "pass4");
 			if (inode_link_info[i] != inode.i_links_count) {
 				printf("WARNING: PROGRAMMING BUG IN E2FSCK!\n");
-				printf("inode_link_info[%d] is %d, "
+				printf("inode_link_info[%d] is %lu, "
 				       "inode.i_links_count is %d.  "
 				       "They should be the same!\n",
 				       i, inode_link_info[i],
 				       inode.i_links_count);
 			}
-			printf("Inode %d has ref count %d, expecting %d.\n",
+			printf("Inode %lu has ref count %d, expecting %d.\n",
 			       i, inode.i_links_count, inode_count[i]);
 			if (ask("Set i_nlinks to count", 1)) {
 				inode.i_links_count = inode_count[i];
-				ext2fs_write_inode(fs, i, &inode);
+				e2fsck_write_inode(fs, i, &inode, "pass4");
 			} else
 				ext2fs_unmark_valid(fs);
 		}
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index cd0cf5b..888ac97 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -29,7 +29,7 @@
 	init_resource_track(&rtrack);
 	
 	if (!preen)
-		printf("Pass 5: Checking group summary information.\n");
+		printf("Pass 5: Checking group summary information\n");
 
 	read_bitmaps(fs);
 
@@ -38,9 +38,9 @@
 	check_inode_end(fs);
 	check_block_end(fs);
 
-	free(inode_used_map);
-	free(inode_dir_map);
-	free(block_found_map);
+	ext2fs_free_inode_bitmap(inode_used_map);
+	ext2fs_free_inode_bitmap(inode_dir_map);
+	ext2fs_free_block_bitmap(block_found_map);
 
 	if (tflag > 1) {
 		printf("Pass 5: ");
@@ -50,7 +50,7 @@
 
 static void check_block_bitmaps(ext2_filsys fs)
 {
-	int	i;
+	blk_t	i;
 	int	*free_array;
 	int	group = 0;
 	int	blocks = 0;
@@ -65,15 +65,15 @@
 	for (i = fs->super->s_first_data_block;
 	     i < fs->super->s_blocks_count;
 	     i++) {
-		actual = ext2fs_test_block_bitmap(fs, block_found_map, i);
-		bitmap = ext2fs_test_block_bitmap(fs, fs->block_map, i);
+		actual = ext2fs_test_block_bitmap(block_found_map, i);
+		bitmap = ext2fs_test_block_bitmap(fs->block_map, i);
 		
 		if (actual == bitmap)
 			goto do_counts;
 
 		if (do_fix < 0)
 			do_fix = ask(fix_question, 1);
-		if (print_header) {
+		if (!preen && print_header) {
 			printf(print_header);
 			print_header = 0;
 		}
@@ -81,17 +81,19 @@
 			/*
 			 * Block not used, but marked in use in the bitmap.
 			 */
-			printf(" -%d", i);
+			if (!preen)
+				printf(" -%lu", i);
 			if (do_fix)
-				ext2fs_unmark_block_bitmap(fs, fs->block_map,
+				ext2fs_unmark_block_bitmap(fs->block_map,
 							   i);
 		} else {
 			/*
 			 * Block used, but not marked in use in the bitmap.
 			 */
-			printf(" +%d", i);
+			if (!preen)
+				printf(" +%lu", i);
 			if (do_fix)
-				ext2fs_mark_block_bitmap(fs, fs->block_map,
+				ext2fs_mark_block_bitmap(fs->block_map,
 							 i);
 		}
 		if (do_fix) {
@@ -120,9 +122,11 @@
 		if (free_array[i] != fs->group_desc[i].bg_free_blocks_count) {
 			if (do_fix < 0)
 				do_fix = ask(fix_question, 1);
-			printf("Free blocks count wrong for group %d (%d, counted=%d).  %s\n",
-			       i, fs->group_desc[i].bg_free_blocks_count,
-			       free_array[i], fix_msg[do_fix]);
+			if (!preen)
+				printf("Free blocks count wrong for "
+				       "group %lu (%u, counted=%d).  %s\n", i,
+				       fs->group_desc[i].bg_free_blocks_count,
+				       free_array[i], fix_msg[do_fix]);
 			if (do_fix) {
 				fs->group_desc[i].bg_free_blocks_count =
 					free_array[i];
@@ -134,9 +138,11 @@
 	if (free_blocks != fs->super->s_free_blocks_count) {
 		if (do_fix < 0)
 			do_fix = ask(fix_question, 1);
-		printf("Free blocks count wrong (%ld, counted=%d).  %s\n",
-		       fs->super->s_free_blocks_count, free_blocks,
-		       fix_msg[do_fix]);
+		if (!preen)
+			printf("Free blocks count wrong "
+			       "(%lu, counted=%d).  %s\n",
+			       fs->super->s_free_blocks_count, free_blocks,
+			       fix_msg[do_fix]);
 		if (do_fix) {
 			fs->super->s_free_blocks_count = free_blocks;
 			ext2fs_mark_super_dirty(fs);
@@ -147,7 +153,7 @@
 			
 static void check_inode_bitmaps(ext2_filsys fs)
 {
-	int	i;
+	ino_t	i;
 	int	free_inodes = 0;
 	int	group_free = 0;
 	int	dirs_count = 0;
@@ -165,15 +171,15 @@
 				    "directory count array");
 				     
 	for (i = 1; i <= fs->super->s_inodes_count; i++) {
-		actual = ext2fs_test_inode_bitmap(fs, inode_used_map, i);
-		bitmap = ext2fs_test_inode_bitmap(fs, fs->inode_map, i);
+		actual = ext2fs_test_inode_bitmap(inode_used_map, i);
+		bitmap = ext2fs_test_inode_bitmap(fs->inode_map, i);
 		
 		if (actual == bitmap)
 			goto do_counts;
 		
 		if (do_fix < 0)
 			do_fix = ask(fix_question, 1);
-		if (print_header) {
+		if (!preen && print_header) {
 			printf(print_header);
 			print_header = 0;
 		}
@@ -181,17 +187,18 @@
 			/*
 			 * Inode wasn't used, but marked in bitmap
 			 */
-			printf(" -%d", i);
+			if (!preen)
+				printf(" -%lu", i);
 			if (do_fix)
-				ext2fs_unmark_inode_bitmap(fs, fs->inode_map,
-							   i);
+				ext2fs_unmark_inode_bitmap(fs->inode_map, i);
 		} else if (actual && !bitmap) {
 			/*
 			 * Inode used, but not in bitmap
 			 */
-			printf (" +%d", i);
+			if (!preen)
+				printf (" +%lu", i);
 			if (do_fix)
-				ext2fs_mark_inode_bitmap(fs, fs->inode_map, i);
+				ext2fs_mark_inode_bitmap(fs->inode_map, i);
 		}
 		if (do_fix) {
 			ext2fs_mark_ib_dirty(fs);
@@ -204,7 +211,7 @@
 			group_free++;
 			free_inodes++;
 		} else {
-			if (ext2fs_test_inode_bitmap(fs, inode_dir_map, i))
+			if (ext2fs_test_inode_bitmap(inode_dir_map, i))
 				dirs_count++;
 		}
 		inodes++;
@@ -225,9 +232,11 @@
 		if (free_array[i] != fs->group_desc[i].bg_free_inodes_count) {
 			if (do_fix < 0)
 				do_fix = ask(fix_question, 1);
-			printf ("Free inodes count wrong for group #%d (%d, counted=%d).  %s\n",
-				i, fs->group_desc[i].bg_free_inodes_count,
-				free_array[i], fix_msg[do_fix]);
+			if (!preen)
+				printf ("Free inodes count wrong for "
+					"group #%lu (%u, counted=%d).  %s\n", i,
+					fs->group_desc[i].bg_free_inodes_count,
+					free_array[i], fix_msg[do_fix]);
 			if (do_fix) {
 				fs->group_desc[i].bg_free_inodes_count =
 					free_array[i];
@@ -238,9 +247,11 @@
 		if (dir_array[i] != fs->group_desc[i].bg_used_dirs_count) {
 			if (do_fix < 0)
 				do_fix = ask(fix_question, 1);
-			printf ("Directories count wrong for group #%d (%d, counted=%d).  %s\n",
-				i, fs->group_desc[i].bg_used_dirs_count,
-				dir_array[i], fix_msg[do_fix]);
+			if (!preen)
+				printf ("Directories count wrong for "
+					"group #%lu (%u, counted=%d).  %s\n", i,
+					fs->group_desc[i].bg_used_dirs_count,
+					dir_array[i], fix_msg[do_fix]);
 			if (do_fix) {
 				fs->group_desc[i].bg_used_dirs_count =
 					dir_array[i];
@@ -252,9 +263,11 @@
 	if (free_inodes != fs->super->s_free_inodes_count) {
 		if (do_fix < 0)
 			do_fix = ask(fix_question, 1);
-		printf("Free inodes count wrong (%ld, counted=%d).  %s\n",
-		       fs->super->s_free_inodes_count, free_inodes,
-		       fix_msg[do_fix]);
+		if (!preen)
+			printf("Free inodes count wrong "
+			       "(%lu, counted=%d).  %s\n",
+			       fs->super->s_free_inodes_count, free_inodes,
+			       fix_msg[do_fix]);
 		if (do_fix) {
 			fs->super->s_free_inodes_count = free_inodes;
 			ext2fs_mark_super_dirty(fs);
@@ -265,23 +278,26 @@
 
 static void check_inode_end(ext2_filsys fs)
 {
-	ino_t	end;
-	ino_t	save_inodes_count = fs->super->s_inodes_count;
-	ino_t	i;
+	ino_t	end, save_inodes_count, i;
+	errcode_t	retval;
 
 	end = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
+	retval = ext2fs_fudge_inode_bitmap_end(fs->inode_map, end,
+					       &save_inodes_count);
+	if (retval) {
+		com_err("check_inode_end", retval,
+			"while trying to fudge end of inode bitmap");
+		fatal_error(0);
+	}
 	if (save_inodes_count == end)
 		return;
 	
-	fs->super->s_inodes_count = end;
-
 	for (i = save_inodes_count + 1; i <= end; i++) {
-		if (!ext2fs_test_inode_bitmap(fs, fs->inode_map, i)) {
+		if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) {
 			printf("Padding at end of inode bitmap is not set. ");
 			if (ask("Fix", 1)) {
 				for (i = save_inodes_count + 1; i <= end; i++)
-					ext2fs_mark_inode_bitmap(fs,
-								 fs->inode_map,
+					ext2fs_mark_inode_bitmap(fs->inode_map,
 								 i);
 				ext2fs_mark_ib_dirty(fs);
 			} else
@@ -290,31 +306,39 @@
 		}
 	}
 
-	fs->super->s_inodes_count = save_inodes_count;
+	retval = ext2fs_fudge_inode_bitmap_end(fs->inode_map,
+					       save_inodes_count, 0);
+	if (retval) {
+		com_err("check_inode_end", retval,
+			"while trying to fudge end of inode bitmap back");
+		fatal_error(0);
+	}
 }
 
 static void check_block_end(ext2_filsys fs)
 {
-	blk_t	end;
-	blk_t	save_blocks_count = fs->super->s_blocks_count;
-	blk_t	i;
+	blk_t	end, save_blocks_count, i;
+	errcode_t	retval;
 
-	end = fs->super->s_first_data_block +
-		(EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count);
-
+	end = fs->block_map->start +
+		(EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count) - 1;
+	retval = ext2fs_fudge_block_bitmap_end(fs->block_map, end,
+					       &save_blocks_count);
+	if (retval) {
+		com_err("check_block_end", retval,
+			"while trying to fudge end of block bitmap");
+		fatal_error(0);
+	}
 	if (save_blocks_count == end)
 		return;
 	
-	fs->super->s_blocks_count = end;
-
-	for (i = save_blocks_count; i < end; i++) {
-		if (!ext2fs_test_block_bitmap(fs, fs->block_map, i)) {
+	for (i = save_blocks_count + 1; i <= end; i++) {
+		if (!ext2fs_test_block_bitmap(fs->block_map, i)) {
 			printf("Padding at end of block bitmap is not set. ");
 
 			if (ask("Fix", 1)) {
 				for (i = save_blocks_count + 1; i < end; i++)
-					ext2fs_mark_block_bitmap(fs,
-								 fs->block_map,
+					ext2fs_mark_block_bitmap(fs->block_map,
 								 i);
 				ext2fs_mark_bb_dirty(fs);
 			} else
@@ -323,6 +347,12 @@
 		}
 	}
 
-	fs->super->s_blocks_count = save_blocks_count;
+	retval = ext2fs_fudge_block_bitmap_end(fs->block_map,
+					       save_blocks_count, 0);
+	if (retval) {
+		com_err("check_block_end", retval,
+			"while trying to fudge end of block bitmap back");
+		fatal_error(0);
+	}
 }
 
diff --git a/e2fsck/scantest.c b/e2fsck/scantest.c
new file mode 100644
index 0000000..a0b078d
--- /dev/null
+++ b/e2fsck/scantest.c
@@ -0,0 +1,139 @@
+/*
+ * scantest.c - test the speed of the inode scan routine
+ */
+
+#include <string.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <termios.h>
+#include <time.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <mntent.h>
+#include <sys/ioctl.h>
+#include <malloc.h>
+#include <sys/resource.h>
+
+#include "et/com_err.h"
+#include "../version.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <linux/fs.h>
+#include <linux/ext2_fs.h>
+
+#include "ext2fs/ext2fs.h"
+
+
+extern int isatty(int);
+
+const char * device_name = NULL;
+
+/*
+ * This structure is used for keeping track of how much resources have
+ * been used for a particular pass of e2fsck.
+ */
+struct resource_track {
+	struct timeval time_start;
+	struct timeval user_start;
+	struct timeval system_start;
+	void	*brk_start;
+};
+
+struct resource_track	global_rtrack;
+
+void init_resource_track(struct resource_track *track)
+{
+	struct rusage r;
+	
+	track->brk_start = sbrk(0);
+	gettimeofday(&track->time_start, 0);
+	getrusage(RUSAGE_SELF, &r);
+	track->user_start = r.ru_utime;
+	track->system_start = r.ru_stime;
+}
+
+static __inline__ float timeval_subtract(struct timeval *tv1,
+					 struct timeval *tv2)
+{
+	return ((tv1->tv_sec - tv2->tv_sec) +
+		((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
+}
+
+void print_resource_track(struct resource_track *track)
+{
+	struct rusage r;
+	struct timeval time_end;
+
+	gettimeofday(&time_end, 0);
+	getrusage(RUSAGE_SELF, &r);
+
+	printf("Memory used: %d, elapsed time: %6.3f/%6.3f/%6.3f\n",
+	       (int) (((char *) sbrk(0)) - ((char *) track->brk_start)),
+	       timeval_subtract(&time_end, &track->time_start),
+	       timeval_subtract(&r.ru_utime, &track->user_start),
+	       timeval_subtract(&r.ru_stime, &track->system_start));
+}
+
+
+
+int main (int argc, char *argv[])
+{
+	errcode_t	retval = 0;
+	int		exit_value = 0;
+	int		i;
+	ext2_filsys	fs;
+	ext2_inode_scan	scan;
+	ino_t	ino;
+	struct ext2_inode inode;
+
+	printf("size of inode=%d\n", sizeof(inode));
+
+	device_name = "/dev/hda3";
+	
+	init_resource_track(&global_rtrack);
+
+	retval = ext2fs_open(device_name, 0,
+			     0, 0, unix_io_manager, &fs);
+	if (retval) {
+		com_err(argv[0], retval, "while trying to open %s",
+			device_name);
+		exit(1);
+	}
+
+	retval = ext2fs_open_inode_scan(fs, 0, &scan);
+	if (retval) {
+		com_err(argv[0], retval, "while opening inode scan");
+		exit(1);
+	}
+	retval = ext2fs_get_next_inode(scan, &ino, &inode);
+	if (retval) {
+		com_err(argv[0], retval, "while starting inode scan");
+		exit(1);
+	}
+	while (ino) {
+		if (!inode.i_links_count)
+			goto next;
+		printf("%lu\n", inode.i_blocks);
+	next:
+		retval = ext2fs_get_next_inode(scan, &ino, &inode);
+		if (retval) {
+			com_err(argv[0], retval,
+				"while doing inode scan");
+			exit(1);
+		}
+	}
+	
+
+	ext2fs_close(fs);
+	
+	print_resource_track(&global_rtrack);
+	
+	return exit_value;
+}
diff --git a/e2fsck/util.c b/e2fsck/util.c
index c9e6396..3f5447d 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -105,28 +105,21 @@
 {
 	errcode_t	retval;
 
-	if (!fs->inode_map) {
-		ehandler_operation("reading inode bitmaps");
-		retval = ext2fs_read_inode_bitmap(fs);
-		ehandler_operation(0);
-		if (retval) {
-			com_err(program_name, retval,
-				"while retrying to read inode bitmaps for %s",
-				device_name);
-			fatal_error(0);
-		}
+	if (invalid_bitmaps) {
+		com_err(program_name, 0,
+			"read_bitmaps: illegal bitmap block(s) for %s",
+			device_name);
+		fatal_error(0);
 	}
-	
-	if (!fs->block_map) {
-		ehandler_operation("reading block bitmaps");
-		retval = ext2fs_read_block_bitmap(fs);
-		ehandler_operation(0);
-		if (retval) {
-			com_err(program_name, retval,
-				"while retrying to read block bitmaps for %s",
-				device_name);
-			fatal_error(0);
-		}
+
+	ehandler_operation("reading inode and block bitmaps");
+	retval = ext2fs_read_bitmaps(fs);
+	ehandler_operation(0);
+	if (retval) {
+		com_err(program_name, retval,
+			"while retrying to read bitmaps for %s",
+			device_name);
+		fatal_error(0);
 	}
 }
 
@@ -201,6 +194,32 @@
 	       timeval_subtract(&r.ru_stime, &track->system_start));
 }
 
+void e2fsck_read_inode(ext2_filsys fs, unsigned long ino,
+			      struct ext2_inode * inode, const char *proc)
+{
+	int retval;
+
+	retval = ext2fs_read_inode(fs, ino, inode);
+	if (retval) {
+		com_err("ext2fs_read_inode", retval,
+			"while reading inode %ld in %s", ino, proc);
+		fatal_error(0);
+	}
+}
+
+extern void e2fsck_write_inode(ext2_filsys fs, unsigned long ino,
+			       struct ext2_inode * inode, const char *proc)
+{
+	int retval;
+
+	retval = ext2fs_write_inode(fs, ino, inode);
+	if (retval) {
+		com_err("ext2fs_write_inode", retval,
+			"while writing inode %ld in %s", ino, proc);
+		fatal_error(0);
+	}
+}
+
 /*
  * This function returns 1 if the inode's block entries actually
  * contain block entries.