Many files:
  Checkin of e2fsprogs 0.5b

diff --git a/misc/.depend b/misc/.depend
index 40b033a..9466333 100644
--- a/misc/.depend
+++ b/misc/.depend
@@ -1,98 +1,104 @@
 badblocks.o : badblocks.c /usr/include/errno.h /usr/include/features.h /usr/include/sys/cdefs.h \
   /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h /usr/include/linux/types.h \
-  /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/signal.h /usr/include/linux/signal.h \
-  /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/stdlib.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
-  /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.h \
-  /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/termios.h /usr/include/linux/termios.h \
-  /usr/include/linux/fd.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 \
-  ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h 
-chattr.o : chattr.c /usr/include/dirent.h /usr/include/features.h /usr/include/sys/cdefs.h \
-  /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
-  /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \
-  /usr/include/linux/dirent.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \
-  /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.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/unistd.h /usr/include/posix_opt.h /usr/include/sys/param.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/param.h /usr/include/sys/stat.h \
-  /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
-  ../lib/e2p/e2p.h ../version.h 
-dumpe2fs.o : dumpe2fs.c /usr/include/getopt.h /usr/include/fcntl.h /usr/include/features.h \
-  /usr/include/sys/cdefs.h /usr/include/sys/types.h /usr/include/linux/types.h \
-  /usr/include/linux/fcntl.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \
-  /usr/include/stdlib.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/string.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/gnu/types.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 ../lib/e2p/e2p.h \
-  /usr/include/dirent.h /usr/include/linux/limits.h /usr/include/linux/dirent.h \
-  ../version.h 
-fsck.o : fsck.c /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/sys/wait.h \
-  /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/gnu/types.h /usr/include/waitflags.h \
-  /usr/include/waitstatus.h /usr/include/errno.h /usr/include/linux/errno.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/stdio.h /usr/include/libio.h \
-  /usr/include/_G_config.h /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h /usr/include/string.h /usr/include/mntent.h \
-  /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/getopt.h ../version.h \
-  fsck.h 
-lsattr.o : lsattr.c /usr/include/dirent.h /usr/include/features.h /usr/include/sys/cdefs.h \
-  /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
-  /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/limits.h \
-  /usr/include/linux/dirent.h /usr/include/errno.h /usr/include/linux/errno.h \
-  /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/stdio.h \
-  /usr/include/libio.h /usr/include/_G_config.h /usr/include/unistd.h /usr/include/posix_opt.h \
-  /usr/include/sys/param.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/param.h /usr/include/sys/stat.h \
-  /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
-  ../lib/e2p/e2p.h ../version.h 
-mke2fs.o : mke2fs.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/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/mntent.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \
-  /usr/include/malloc.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h /usr/include/linux/ext2_fs.h \
+  /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/signal.h \
+  /usr/include/linux/signal.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \
+  /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h \
+  /usr/include/gnu/types.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.h \
+  /usr/include/termios.h /usr/include/linux/termios.h /usr/include/linux/fd.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 ../lib/et/com_err.h \
-  /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h \
-  ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h ../version.h 
-mklost+found.o : mklost+found.c /usr/include/errno.h /usr/include/features.h \
-  /usr/include/sys/cdefs.h /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/sys/types.h \
-  /usr/include/linux/types.h /usr/include/linux/fcntl.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/param.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/linux/param.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
-  /usr/include/linux/ext2_fs.h ../version.h 
-tune2fs.o : tune2fs.c /usr/include/fcntl.h /usr/include/features.h /usr/include/sys/cdefs.h \
-  /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/linux/fcntl.h \
-  /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \
-  /usr/include/stdlib.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/include/errno.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 \
+  ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/ext2fs/io.h 
+chattr.o : chattr.c /usr/include/dirent.h /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
+  /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \
+  /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \
+  /usr/include/fcntl.h /usr/include/linux/fcntl.h /usr/include/getopt.h /usr/include/stdio.h \
+  /usr/include/libio.h /usr/include/_G_config.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/string.h /usr/include/time.h /usr/include/unistd.h /usr/include/posix_opt.h \
+  /usr/include/alloca.h /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/sys/param.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/posix2_lim.h /usr/include/linux/param.h /usr/include/asm/param.h \
+  /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \
+  ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/e2p/e2p.h \
+  ../version.h 
+dumpe2fs.o : dumpe2fs.c /usr/include/getopt.h /usr/include/fcntl.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/sys/types.h /usr/include/linux/types.h \
+  /usr/include/asm/types.h /usr/include/linux/fcntl.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/stdlib.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/alloca.h /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h \
   /usr/include/gnu/types.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 ../lib/e2p/e2p.h /usr/include/dirent.h \
-  /usr/include/linux/limits.h /usr/include/linux/dirent.h ../version.h 
+  /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \
+  ../version.h 
+fsck.o : fsck.c /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \
+  /usr/include/sys/wait.h /usr/include/features.h /usr/include/sys/cdefs.h /usr/include/gnu/types.h \
+  /usr/include/waitflags.h /usr/include/linux/wait.h /usr/include/waitstatus.h \
+  /usr/include/endian.h /usr/include/bytesex.h /usr/include/sys/signal.h /usr/include/signal.h \
+  /usr/include/linux/signal.h /usr/include/sys/stat.h /usr/include/linux/stat.h \
+  /usr/include/errno.h /usr/include/linux/errno.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/stdio.h /usr/include/libio.h /usr/include/_G_config.h /usr/include/stdlib.h \
+  /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/float.h \
+  /usr/include/alloca.h /usr/include/string.h /usr/include/mntent.h /usr/include/unistd.h \
+  /usr/include/posix_opt.h /usr/include/getopt.h ../version.h fsck.h 
+lsattr.o : lsattr.c /usr/include/dirent.h /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/include/gnu/types.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
+  /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \
+  /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \
+  /usr/include/errno.h /usr/include/linux/errno.h /usr/include/fcntl.h /usr/include/linux/fcntl.h \
+  /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \
+  /usr/include/unistd.h /usr/include/posix_opt.h /usr/include/sys/param.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/posix2_lim.h /usr/include/linux/param.h /usr/include/asm/param.h \
+  /usr/include/sys/stat.h /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h \
+  ../lib/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h ../lib/e2p/e2p.h \
+  ../version.h 
+mke2fs.o : mke2fs.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/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/mntent.h /usr/include/stdio.h /usr/include/libio.h \
+  /usr/include/_G_config.h /usr/include/malloc.h /usr/include/sys/ioctl.h /usr/include/linux/ioctl.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/et/com_err.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stdarg.h \
+  ../lib/ext2fs/ext2fs.h ../lib/ext2fs/io.h ../lib/ext2fs/ext2_err.h ../lib/ext2fs/bitops.h \
+  ../version.h 
+mklost+found.o : mklost+found.c /usr/include/errno.h /usr/include/features.h \
+  /usr/include/sys/cdefs.h /usr/include/linux/errno.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/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/param.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/param.h /usr/include/asm/param.h /usr/include/sys/stat.h \
+  /usr/include/linux/stat.h /usr/include/linux/ext2_fs.h ../version.h 
+tune2fs.o : tune2fs.c /usr/include/fcntl.h /usr/include/features.h /usr/include/sys/cdefs.h \
+  /usr/include/sys/types.h /usr/include/linux/types.h /usr/include/asm/types.h \
+  /usr/include/linux/fcntl.h /usr/include/grp.h /usr/include/gnu/types.h /usr/include/stdio.h \
+  /usr/include/libio.h /usr/include/_G_config.h /usr/lib/gcc-lib/i486-linux/2.5.8/include/stddef.h \
+  /usr/include/getopt.h /usr/include/pwd.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/string.h /usr/include/time.h /usr/include/unistd.h \
+  /usr/include/posix_opt.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 ../lib/e2p/e2p.h /usr/include/dirent.h \
+  /usr/include/linux/limits.h /usr/include/linux/dirent.h /usr/include/posix1_lim.h \
+  ../version.h 
diff --git a/misc/ChangeLog b/misc/ChangeLog
new file mode 100644
index 0000000..9550ab8
--- /dev/null
+++ b/misc/ChangeLog
@@ -0,0 +1,102 @@
+Sat Mar 11 10:59:58 1995  Theodore Y. Ts'o  <tytso@localhost>
+
+	* mke2fs.c (main, zap_bootblock): Added new function
+		zap_bootblock() which clears the first 512 bytes of the
+		filesystem.  This protects the filesystem from being
+		misidentified as a MS-DOS FAT filesystem.
+
+	* badblocks.c (alarm_intr, test_ro, test_rw): Increase the space
+		allocated for printing the block numbers, so that the
+		display doesn't get corrupted when running badblocks on a
+		very large partition.
+
+	* badblocks.c (do_test, test_ro, test_rw): Added missing cast to
+		ext2_loff_t, so that when checking a large device,
+		spurious seek errors aren't reported.
+
+	* mke2fs.c (count_blocks): Declare mid to be of type ext2_loff_t
+		instead of type int, so that it works for filesystems
+		greater than 2 GB.  (Fortunately count_blocks is only
+		called if the device does not support the BLKGETSIZE
+		ioctl, which most do.)
+
+	* fsck.c (ignore): Add check to ignore filesystems with a pass
+		number of zero.  (This check was accidentally deleted at
+		during 0.5b development.)
+
+Sat Dec 31 00:47:16 1994    <tytso@rsx-11.mit.edu>
+
+	* mke2fs.c (new_table_block, alloc_tables, PRS, main): Add a new
+		option, -S, which only writes the superblock and group
+		descriptors.  Useful for recovering when all of the
+		superblocks are corrupted somehow (as a last ditch
+		measure).
+
+		Also, don't bother initializing the bitmap blocks in
+		alloc_tables(), since they will be overwritten at the end
+		anyway.  (Should speed up mke2fs by a little.)
+
+Tue Dec  6 02:20:55 1994    <tytso@rsx-11.mit.edu>
+
+	* fsck.c (main): Fix stupid typo where a null inst would be freed. 
+
+	* fsck.c (wait_one): Check WIFEXITED on status before trying to
+		extract the exit status.  In other cases, return
+		FSCK_ERROR if the back end processor exited with a signal.
+
+Tue Nov 15 10:20:00 1994  Remy Card  <card@bbj>
+
+	* tune2fs.c (main): Fixed a bug which prevented the use of the
+		new options.
+	Added the `w' (week) suffix recognition in the check interval.
+
+Sun Nov 13 15:58:48 1994    (tytso@rsx-11)
+
+	* fsck.c (load_fs_info): If the user has an obviously old
+		/etc/fstab file, issue a warning message and assume that
+		all partitions should be checked.
+
+Sat Nov 12 00:33:18 1994    (tytso@rsx-11)
+
+	* dumpe2fs.c (list_desc): Update to new inode and block bitmap
+		structures. 
+
+	* mke2fs.c (create_root_dir): Create the root directory owned by
+		the effective uid.
+
+Mon Nov  7 22:04:37 1994  Remy Card  <card@bbj>
+
+	* tune2fs.c (main.c): Added support for new options:
+	-r reserved_blocks_count, -g reserved_gid, -u reserved_uid.
+
+Sun Aug 21 00:57:33 1994  Theodore Y. Ts'o  (tytso@rt-11)
+
+	* fsck.c (ignore): If the pass number is 0, ignore the filesystem.
+
+Wed Aug 17 21:55:03 1994  Remy Card  (card@bbj)
+
+	* badblocks.c (test_rw): Added verbose output like in the
+	read-only test.
+
+	(do_test and test_rw): Use the llseek system call if available.
+
+	* chattr.c: Added support for new attributes.
+
+	* lsattr.c: Added support for long format.
+
+	* mke2fs.c (usage): Fixed bogus usage message.
+
+	(valid_offset): Use the llseek system call if available.
+
+Wed Aug 17 10:50:57 1994  Theodore Y. Ts'o  (tytso@rt-11)
+
+	* mke2fs.c (handle_bad_blocks): Check to see if a bad block is
+	where a backup superblock/group descriptor is stored.  If so,
+	print a warning message and adjust the superblock counts so that
+	they are correct.  (Otherwise, the bad block will get counted
+	twice and the # of free blocks count will be wrong.)
+
+	(alloc_tables): Removed code which calcualated the free block
+	statistics, which was moved to lib/ext2fs/initialize.c.  This
+	allows the bad block code to adjust the group descriptor
+	statistics if necessary.
diff --git a/misc/Makefile b/misc/Makefile
index 3b37dc7..4cb15b2 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -2,7 +2,8 @@
 
 CFLAGS=		$(OPT) $(WFLAGS) -I../lib
 LDFLAGS=	$(OPT)
-SPROGS=		tune2fs mklost+found mke2fs dumpe2fs badblocks fsck
+SPROGS=		mke2fs badblocks tune2fs dumpe2fs fsck
+USPROGS=	mklost+found
 SMANPAGES=	tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \
 			fsck.8
 
@@ -21,33 +22,39 @@
 LIBS= -L../lib -lext2fs -le2p -lcom_err 
 DEPLIBS= ../lib/libext2fs.a ../lib/libe2p.a ../lib/libcom_err.a 
 
-all: $(SPROGS) $(UPROGS)
+all: $(SPROGS) $(UPROGS) $(USPROGS)
 
 tune2fs: $(TUNE2FS_OBJS) $(DEPLIBS)
-	cc $(LDFLAGS) -o tune2fs $(TUNE2FS_OBJS) $(LIBS)
+	$(CC) $(LDFLAGS) -o tune2fs $(TUNE2FS_OBJS) $(LIBS)
 
 mklost+found: $(MKLPF_OBJS)
-	cc $(LDFLAGS) -o mklost+found $(MKLPF_OBJS)
+	$(CC) $(LDFLAGS) -o mklost+found $(MKLPF_OBJS)
 
 mke2fs: $(MKE2FS_OBJS) $(DEPLIBS)
-	cc $(LDFLAGS) -o mke2fs $(MKE2FS_OBJS) $(LIBS)
+	$(CC) $(LDFLAGS) -o mke2fs $(MKE2FS_OBJS) $(LIBS)
+
+mke2fs.static: $(MKE2FS_OBJS) $(DEPLIBS)
+	$(CC) $(LDFLAGS) -static -o mke2fs.static $(MKE2FS_OBJS) $(LIBS)
 
 chattr: $(CHATTR_OBJS) $(DEPLIBS)
-	cc $(LDFLAGS) -o chattr $(CHATTR_OBJS) $(LIBS)
+	$(CC) $(LDFLAGS) -o chattr $(CHATTR_OBJS) $(LIBS)
 
 lsattr: $(LSATTR_OBJS) $(DEPLIBS)
-	cc $(LDFLAGS) -o lsattr $(LSATTR_OBJS) $(LIBS)
+	$(CC) $(LDFLAGS) -o lsattr $(LSATTR_OBJS) $(LIBS)
 
 dumpe2fs: $(DUMPE2FS_OBJS) $(DEPLIBS)
-	cc $(LDFLAGS) -o dumpe2fs $(DUMPE2FS_OBJS) $(LIBS)
+	$(CC) $(LDFLAGS) -o dumpe2fs $(DUMPE2FS_OBJS) $(LIBS)
 
 badblocks: $(BADBLOCKS_OBJS) $(DEPLIBS)
-	cc $(LDFLAGS) -o badblocks $(BADBLOCKS_OBJS) $(LIBS)
+	$(CC) $(LDFLAGS) -o badblocks $(BADBLOCKS_OBJS) $(LIBS)
 
 install:: $(SPROGS) $(UPROGS)
 	for i in $(SPROGS); do \
 		$(INSTALLBIN) $$i $(SBINDIR)/$$i; \
 	done
+	for i in $(USPROGS); do \
+		$(INSTALLBIN) $$i $(USRSBINDIR)/$$i; \
+	done
 	ln -sf mke2fs $(SBINDIR)/mkfs.ext2
 	for i in $(UPROGS); do \
 		$(INSTALLBIN) $$i $(USRBINDIR)/$$i; \
@@ -61,8 +68,18 @@
 		$(INSTALLMAN) $$i $(UMANDIR)/$$i; \
 	done
 
+install-tree:: $(SPROGS) $(UPROGS)
+	for i in $(SPROGS) $(UPROGS); do \
+		rm -f ../bin/$$i; \
+		cp $$i ../bin; \
+		strip ../bin/$$i; \
+		chmod 555 ../bin/$$i; \
+	done
+	ln -sf mke2fs ../bin/mkfs.ext2
+
 clean:
-	rm -f $(SPROGS) $(UPROGS) \#* *.s *.o *.a *~ core
+	rm -f $(SPROGS) $(USPROGS) $(UPROGS) mke2fs.static \
+		\#* *.s *.o *.a *~ core
 
 really-clean: clean
 	rm -f .depend 
diff --git a/misc/badblocks.8 b/misc/badblocks.8
index 080ca5b..79a95c7 100644
--- a/misc/badblocks.8
+++ b/misc/badblocks.8
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.TH BADBLOCKS 8 "March 1994" "Version 0.5"
+.TH BADBLOCKS 8 "November 1994" "Version 0.5b"
 .SH NAME
 badblocks \- search a device for bad blocks
 .SH SYNOPSIS
@@ -59,8 +59,8 @@
 which remap bad blocks. I only made some tests on floppies.
 .SH AVAILABILITY
 .B badblocks
-is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in
-/pub/linux/BETA/ext2fs.
+is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
+/pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR e2fsck (8),
 .BR mke2fs (8)
diff --git a/misc/badblocks.c b/misc/badblocks.c
index 0560e67..b9bcaca 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -28,11 +28,13 @@
 #include <unistd.h>
 
 #include <sys/ioctl.h>
+#include <sys/types.h>
 
 #include <linux/fd.h>
 #include <linux/fs.h>
 
 #include "et/com_err.h"
+#include "ext2fs/io.h"
 
 const char * program_name = "badblocks";
 
@@ -42,7 +44,7 @@
 
 static volatile void usage (void)
 {
-	fprintf (stderr, "Usage: %s [-b block_size] [-o output_file] [-w] device blocks_count\n",
+	fprintf (stderr, "Usage: %s [-b block_size] [-o output_file] [-svw] device blocks_count\n [start_count]\n",
 		 program_name);
 	exit (1);
 }
@@ -56,16 +58,18 @@
 	long got;
 
 	/* Seek to the correct loc. */
-	if (lseek (dev, current_block * block_size, SEEK_SET) !=
-	    current_block * block_size)
-                 com_err (program_name, errno, "during seek");
+	if (ext2_llseek (dev, (ext2_loff_t) current_block * block_size,
+			 SEEK_SET) != (ext2_loff_t) current_block * block_size)
+		com_err (program_name, errno, "during seek");
 
 	/* Try the read */
 	got = read (dev, buffer, try * block_size);
 	if (got < 0)
 		got = 0;	
 	if (got & (block_size - 1))
-		fprintf (stderr, "Weird values in do_test: probably bugs\n");
+		fprintf (stderr,
+			 "Weird value (%ld) in do_test: probably bugs\n",
+			 got);
 	got /= block_size;
 	return got;
 }
@@ -79,13 +83,14 @@
 	alarm(1);
 	if (!num_blocks)
 		return;
-	fprintf(stderr, "%6ld/%6ld", currently_testing, num_blocks);
-	fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b");
+	fprintf(stderr, "%9ld/%9ld", currently_testing, num_blocks);
+	fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
 	fflush (stderr);
 }
 
 static void test_ro (int dev, unsigned long blocks_count,
-		     unsigned long block_size, FILE * out)
+		     unsigned long block_size, FILE * out,
+		     unsigned long from_count)
 {
 #define TEST_BUFFER_BLOCKS 16
 	char * blkbuf;
@@ -103,11 +108,13 @@
 		fprintf (stderr, "Flushing buffers\n");
 	ioctl (dev, BLKFLSBUF, 0);	/* In case this is a HD */
 	ioctl (dev, FDFLUSH, 0);	/* In case this is floppy */
-	if (v_flag) 
-		fprintf (stderr,
-			 "Checking for bad blocks in read-only mode\n");
+	if (v_flag) {
+	    fprintf (stderr,
+		     "Checking for bad blocks in read-only mode\n");
+	    fprintf (stderr, "From block %lu to %lu\n", from_count, blocks_count);
+	}
 	try = TEST_BUFFER_BLOCKS;
-	currently_testing = 0;
+	currently_testing = from_count;
 	num_blocks = blocks_count;
 	if (s_flag) {
 		fprintf(stderr, "Checking for bad blocks (read-only test): ");
@@ -131,15 +138,16 @@
 	num_blocks = 0;
 	alarm(0);
 	if (s_flag)
-		fprintf(stderr, "done         \n");
+		fprintf(stderr, "done               \n");
+	fflush (stderr);
 	free (blkbuf);
 }
 
 static void test_rw (int dev, unsigned long blocks_count,
-		     unsigned long block_size, FILE * out)
+		     unsigned long block_size, FILE * out,
+		     unsigned long from_count)
 {
 	int i;
-	int j;
 	char * buffer;
 	unsigned char pattern[] = {0xaa, 0x55, 0xff, 0x00};
 
@@ -159,35 +167,60 @@
 	for (i = 0; i < sizeof (pattern); i++)
 	{
 		memset (buffer, pattern[i], block_size);
-		if (v_flag)
-			fprintf (stderr, "Writing pattern 0x%08x\n",
+		if (s_flag | v_flag)
+			fprintf (stderr, "Writing pattern 0x%08x: ",
 				 *((int *) buffer));
-		for (j = 0; j < blocks_count; j++)
+		num_blocks = blocks_count;
+		currently_testing = from_count;
+		if (s_flag)
+			alarm_intr(SIGALRM);
+		for (;
+		     currently_testing < blocks_count;
+		     currently_testing++)
 		{
-			if (lseek (dev, j * block_size, SEEK_SET) != j * block_size)
+			if (ext2_llseek (dev, (ext2_loff_t) currently_testing *
+					 block_size, SEEK_SET) !=
+			    (ext2_loff_t) currently_testing * block_size)
 				com_err (program_name, errno,
-					 "during seek on block %d", j);
+					 "during seek on block %d",
+					 currently_testing);
 			write (dev, buffer, block_size);
 		}
+		num_blocks = 0;
+		alarm (0);
+		if (s_flag | v_flag)
+			fprintf(stderr, "done               \n");
 		if (v_flag)
 			fprintf (stderr, "Flushing buffers\n");
 		if (fsync (dev) == -1)
 			com_err (program_name, errno, "during fsync");
 		ioctl (dev, BLKFLSBUF, 0);	/* In case this is a HD */
 		ioctl (dev, FDFLUSH, 0);	/* In case this is floppy */
-		if (v_flag)
-			fprintf (stderr, "Reading and comparing\n");
-		for (j = 0; j < blocks_count; j++)
+		if (s_flag | v_flag)
+			fprintf (stderr, "Reading and comparing: ");
+		num_blocks = blocks_count;
+		currently_testing = from_count;
+		if (s_flag)
+			alarm_intr(SIGALRM);
+		for (;
+		     currently_testing < blocks_count;
+		     currently_testing++)
 		{
-			if (lseek (dev, j * block_size, SEEK_SET) != j * block_size)
+			if (ext2_llseek (dev, (ext2_loff_t) currently_testing *
+					 block_size, SEEK_SET) !=
+			    (ext2_loff_t) currently_testing * block_size)
 				com_err (program_name, errno,
-					 "during seek on block %d", j);
+					 "during seek on block %d",
+					 currently_testing);
 			if (read (dev, buffer + block_size, block_size) < block_size)
-				fprintf (out, "%d\n", j);
+				fprintf (out, "%ld\n", currently_testing);
 			else if (memcmp (buffer, buffer + block_size, block_size))
-				fprintf (out, "%d\n", j);
-				
+				fprintf (out, "%ld\n", currently_testing);
 		}
+		num_blocks = 0;
+		alarm (0);
+		if (s_flag | v_flag)
+			fprintf(stderr, "done           \n");
 		if (v_flag)
 			fprintf (stderr, "Flushing buffers\n");
 		ioctl (dev, BLKFLSBUF, 0);	/* In case this is a HD */
@@ -203,7 +236,7 @@
 	char * output_file = NULL;
 	FILE * out;
 	unsigned long block_size = 1024;
-	unsigned long blocks_count;
+	unsigned long blocks_count, from_count;
 	int dev;
 
 	setbuf(stdout, NULL);
@@ -247,6 +280,14 @@
 		com_err (program_name, 0, "bad blocks count - %s", argv[optind]);
 		exit (1);
 	}
+	if (++optind <= argc-1) {
+		from_count = strtoul (argv[optind], &tmp, 0);
+	} else from_count = 0;
+	if (from_count >= blocks_count) {
+	    com_err (program_name, 0, "bad blocks range: %lu-%lu",
+		     from_count, blocks_count);
+	    exit (1);
+	}
 	dev = open (device_name, w_flag ? O_RDWR : O_RDONLY);
 	if (dev == -1)
 	{
@@ -267,9 +308,9 @@
 	else
 		out = stdout;
 	if (w_flag)
-		test_rw (dev, blocks_count, block_size, out);
+		test_rw (dev, blocks_count, block_size, out, from_count);
 	else
-		test_ro (dev, blocks_count, block_size, out);
+		test_ro (dev, blocks_count, block_size, out, from_count);
 	close (dev);
 	if (out != stdout)
 		fclose (out);
diff --git a/misc/chattr.1 b/misc/chattr.1
index 6a8e119..2a45667 100644
--- a/misc/chattr.1
+++ b/misc/chattr.1
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.TH CHATTR 1 "March 1994" "Version 0.5"
+.TH CHATTR 1 "November 1994" "Version 0.5b"
 .SH NAME
 chattr \- change file attributes on a Linux second extended file system
 .SH SYNOPSIS
@@ -19,14 +19,15 @@
 .B chattr
 changes the files attributes on an second extended file system.
 .PP
-The format of a symbolic mode is +-=[Scsu].
+The format of a symbolic mode is +-=[Sacdisu].
 .PP
 The operator `+' causes the selected attributes to be added to the
 existing attributes of the files; `-' causes them to be removed; and
 `=' causes them to be the only attributes that the files have.
 .PP
-The letters `Scsu' select the new attributes for the files: synchronous
-updates (S), compressed (c), secure deletion (s), and undeletable (u).
+The letters `Sacdisu' select the new attributes for the files: synchronous
+updates (S), append only (a), compressed (c), immutable (i), no dump (d),
+secure deletion (s), and undeletable (u).
 .SH OPTIONS
 .TP
 .I -R
@@ -37,21 +38,42 @@
 .TP
 .I -v version
 Set the files version.
+.SH ATTRIBUTES
+A file with the `a' attribute set can only be open in append mode for writing.
+
+A file with the `c' attribute set is automatically compressed on the disk
+by the kernel. A read from this file returns uncompressed data. A write to
+this file compresses data before storing them on the disk.
+
+A file with the `d' attribute set is not candidate for backup when the
+.BR dump (8)
+program is run.
+
+A file with the `i' attribute cannot be modified: it cannot be deleted or
+renamed, no link can be created to this file and no data can be written
+to the file. Only the superuser can set or clear this attribute.
+
+When a file with the `s' attribute set is deleted, its blocks are zeroed and
+written back to the disk.
+
+When a file with the `S' attribute set is modified,
+the changes are written synchronously on the disk; this is equivalent to
+the `sync' mount option applied to a subset of the files.
+
+When a file with the `u' attribute set is deleted, its contents is saved.
+This allows the user to ask for its undeletion.
 .SH AUTHOR
 .B chattr
 has been written by Remy Card <card@masi.ibp.fr>, the developer and maintainer
 of the ext2 fs.
 .SH BUGS AND LIMITATIONS
-As of ext2 fs 0.4, the kernel code only honours the `s' and `S' attributes. When
-a file with the `s' attribute set is deleted, its blocks are zeroed and
-written back to the disk. When a file with the `S' attribute set is modified,
-the changes are written synchronously on the disk; this is equivalent to
-the `sync' mount option applied to a subset of the files.
+As of ext2 fs 0.5a, the `c' and `u' attribute are not honoured by the kernel
+code.
 .PP
-The other attributes will be implemented in a next ext2 fs version.
+These attributes will be implemented in a future ext2 fs version.
 .SH AVAILABILITY
 .B chattr
-is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in
-/pub/linux/BETA/ext2fs.
+is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
+/pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR lsattr (1)
diff --git a/misc/chattr.c b/misc/chattr.c
index 63c8108..8df57e9 100644
--- a/misc/chattr.c
+++ b/misc/chattr.c
@@ -53,7 +53,7 @@
 	exit (errcode);
 }
 
-#define usage() fatal_error ("usage: %s [-RV] [-+=csu] [-v version] files...\n", \
+#define usage() fatal_error ("usage: %s [-RV] [-+=acdisSu] [-v version] files...\n", \
 			     1)
 
 static int decode_arg (int * i, int argc, char ** argv)
@@ -77,10 +77,28 @@
 			case 'V':
 				verbose = 1;
 				break;
+#ifdef	EXT2_APPEND_FL
+			case 'a':
+				rf |= EXT2_APPEND_FL;
+				rem = 1;
+				break;
+#endif
 			case 'c':
 				rf |= EXT2_COMPR_FL;
 				rem = 1;
 				break;
+#ifdef	EXT2_NODUMP_FL
+			case 'd':
+				rf |= EXT2_NODUMP_FL;
+				rem = 1;
+				break;
+#endif
+#ifdef	EXT2_IMMUTABLE_FL
+			case 'i':
+				rf |= EXT2_IMMUTABLE_FL;
+				rem = 1;
+				break;
+#endif
 			case 's':
 				rf |= EXT2_SECRM_FL;
 				rem = 1;
@@ -116,9 +134,24 @@
 			case 'S':
 				af |= EXT2_SYNC_FL;
 				break;
+#ifdef	EXT2_APPEND_FL
+			case 'a':
+				af |= EXT2_APPEND_FL;
+				break;
+#endif
 			case 'c':
 				af |= EXT2_COMPR_FL;
 				break;
+#ifdef	EXT2_NODUMP_FL
+			case 'd':
+				af |= EXT2_NODUMP_FL;
+				break;
+#endif
+#ifdef	EXT2_IMMUTABLE_FL
+			case 'i':
+				af |= EXT2_IMMUTABLE_FL;
+				break;
+#endif
 			case 's':
 				af |= EXT2_SECRM_FL;
 				break;
@@ -137,9 +170,24 @@
 			case 'S':
 				sf |= EXT2_SYNC_FL;
 				break;
+#ifdef	EXT2_APPEND_FL
+			case 'a':
+				sf |= EXT2_APPEND_FL;
+				break;
+#endif
 			case 'c':
 				sf |= EXT2_COMPR_FL;
 				break;
+#ifdef	EXT2_NODUMP_FL
+			case 'd':
+				sf |= EXT2_NODUMP_FL;
+				break;
+#endif
+#ifdef	EXT2_IMMUTABLE_FL
+			case 'i':
+				sf |= EXT2_IMMUTABLE_FL;
+				break;
+#endif
 			case 's':
 				sf |= EXT2_SECRM_FL;
 				break;
@@ -174,7 +222,7 @@
 		if (verbose)
 		{
 			printf ("Flags of %s set as ", name);
-			print_flags (stdout, sf);
+			print_flags (stdout, sf, 0);
 			printf ("\n");
 		}
 		if (fsetflags (name, sf) == -1)
@@ -194,7 +242,7 @@
 			if (verbose)
 			{
 				printf ("Flags of %s set as ", name);
-				print_flags (stdout, flags);
+				print_flags (stdout, flags, 0);
 				printf ("\n");
 			}
 			if (fsetflags (name, flags) == -1)
diff --git a/misc/dumpe2fs.8 b/misc/dumpe2fs.8
index 30a90b5..8cb25cc 100644
--- a/misc/dumpe2fs.8
+++ b/misc/dumpe2fs.8
@@ -1,4 +1,4 @@
-.TH DUMPE2FS 8 "March 1994" "Version 0.5"
+.TH DUMPE2FS 8 "November 1994" "Version 0.5b"
 
 .SH NAME
 dumpe2fs \- dump filesystem information
@@ -24,8 +24,8 @@
 of the ext2 fs.
 .SH AVAILABILITY
 .B dumpe2fs
-is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in
-/pub/linux/BETA/ext2fs.
+is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
+/pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR e2fsck (8),
 .BR mke2fs (8),
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index fc0c45b..d820613 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -71,8 +71,8 @@
 static void list_desc (ext2_filsys fs)
 {
 	unsigned long i;
-	char * block_bitmap = fs->block_map;
-	char * inode_bitmap = fs->inode_map;
+	char * block_bitmap = fs->block_map->bitmap;
+	char * inode_bitmap = fs->inode_map->bitmap;
 
 	printf ("\n");
 	for (i = 0; i < fs->group_desc_count; i++)
@@ -125,38 +125,78 @@
 	printf("\n");
 }
 
+static void dump_bad_blocks(ext2_filsys fs)
+{
+	badblocks_list		bb_list = 0;
+	badblocks_iterate	bb_iter;
+	blk_t			blk;
+	errcode_t		retval;
+
+	retval = ext2fs_read_bb_inode(fs, &bb_list);
+	if (retval) {
+		com_err("ext2fs_read_bb_inode", retval, "");
+		exit(1);
+	}
+	retval = badblocks_list_iterate_begin(bb_list, &bb_iter);
+	if (retval) {
+		com_err("badblocks_list_iterate_begin", retval,
+			"while printing bad block list");
+		exit(1);
+	}
+	while (badblocks_list_iterate(bb_iter, &blk))
+		printf("%ld\n", blk);
+	badblocks_list_iterate_end(bb_iter);
+}
+
+
 void main (int argc, char ** argv)
 {
 	errcode_t	retval;
 	ext2_filsys	fs;
+	int		print_badblocks = 0;
+	char		c;
 
 	fprintf (stderr, "dumpe2fs %s, %s for EXT2 FS %s, %s\n",
 		 E2FSPROGS_VERSION, E2FSPROGS_DATE,
 		 EXT2FS_VERSION, EXT2FS_DATE);
 	if (argc && *argv)
 		program_name = *argv;
-	if (argc != 2)
+	
+	while ((c = getopt (argc, argv, "b")) != EOF) {
+		switch (c) {
+		case 'b':
+			print_badblocks++;
+			break;
+		default:
+			usage ();
+		}
+	}
+	if (optind > argc - 1)
 		usage ();
-	device_name = argv[1];
+	device_name = argv[optind++];
+	initialize_ext2_error_table();
 	retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs);
-	if (retval)
-	{
+	if (retval) {
 		com_err (program_name, retval, "while trying to open %s",
 			 device_name);
 		printf ("Couldn't find valid filesystem superblock.\n");
 		exit (1);
 	}
-	retval = ext2fs_read_bitmaps (fs);
-	if (retval)
-	{
-		com_err (program_name, retval, "while trying to read the bitmaps",
-			 device_name);
-		ext2fs_close (fs);
-		exit (1);
+	if (print_badblocks) {
+		dump_bad_blocks(fs);
+	} else {
+		retval = ext2fs_read_bitmaps (fs);
+		if (retval) {
+			com_err (program_name, retval,
+				 "while trying to read the bitmaps",
+				 device_name);
+			ext2fs_close (fs);
+			exit (1);
+		}
+		list_super (fs->super);
+		list_bad_blocks (fs);
+		list_desc (fs);
 	}
-	list_super (fs->super);
-	list_bad_blocks (fs);
-	list_desc (fs);
 	ext2fs_close (fs);
 	exit (0);
 }
diff --git a/misc/fsck.8 b/misc/fsck.8
index 620a7fc..cfc8832 100644
--- a/misc/fsck.8
+++ b/misc/fsck.8
@@ -1,14 +1,14 @@
 .\" -*- nroff -*-
-.TH FSCK 8 "Mar 1994" "Version 0.5"
+.TH FSCK 8 "November 1994" "Version 0.5b"
 .SH NAME
 fsck \- check and repair a Linux file system
 .SH SYNOPSIS
 .B fsck
 [
-.B \-A
+.B \-AVRTN
 ]
 [
-.B \-V
+.B \-s
 ]
 [
 .B \-t
@@ -69,10 +69,18 @@
 typically used from the
 .I /etc/rc
 system initalization file, instead of multiple commands for checking
-a single file system.  Note, that with this option, you cannot give
-the
-.I filesys
-argument as well.
+a single file system.
+.TP
+.B -R
+When checking all file systems with the
+.B \-A
+flag, skip the root file system (in case it's already mounted read-write).
+.TP
+.B -T
+Don't show the title on startup.
+.TP
+.B -N
+Don't execute, just show what would be done.
 .TP
 .B -s
 Serialize fsck operations.  This is a good idea if you checking multiple
@@ -92,19 +100,32 @@
 .B -V
 Produce verbose output, including all file system-specific commands
 that are executed.
-Specifying this option more than once inhibits execution of any
-file system-specific commands.
-This is really only useful for testing.
 .TP
 .BI -t \ fstype
-Specifies the type of file system to be checked.
-If not specified, the type is deduced by searching for
+Specifies the type of file system to be checked.  When the
+.B \-A 
+flag is specified, only filesystems that match 
+.I fstype
+are checked.  If 
+.I fstype
+is prefixed with 
+.B no
+only filesystems whose filesystem do not match
+.I fstype
+are checked.
+.sp
+Normally, the filesystem type is deduced by searching for
 .I filesys
-in
-.I /etc/fstab
-and using the corresponding entry.
-If the type can not be deduced, the default file system type
-(currently ext2) is used.
+in the 
+.I /etc/fstab 
+file and using the corresponding entry.
+If the type can not be deduced, 
+.B fsck
+will use the type specified by the 
+.B \-t
+option if it specifies a unique filesystem type.  If this type is not
+available, the the default file system type
+(currently ext2) is used. 
 .TP
 .B fs-options
 Any options which are not understood by 
@@ -112,7 +133,7 @@
 or which follow the
 .B --
 option are treated as file system-specific options to be passed to the
-realm file system checker.
+file system-specific checker.
 .PP
 Currently, standardized file system-specific options are somewhat in
 flux.  Although not guaranteed, the following options are supported
@@ -143,7 +164,10 @@
 The manual page was shamelessly adapted from David Engel and Fred van
 Kempen's generic fsck front end program, which was in turn shamelessly
 adapted from Remy Card's version for the ext2 file system.
+.SH FILES
+.IR /etc/fstab .
 .SH SEE ALSO
+.BR fstab (5),
 .BR mkfs (8),
 .BR fsck.minix (8),
 .BR fsck.ext2 (8)
diff --git a/misc/fsck.c b/misc/fsck.c
index eb01fc5..40f715f 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -8,14 +8,24 @@
  *
  * Written by Theodore Ts'o, <tytso@mit.edu>
  * 
- * Usage:	fsck [-AV] [-t fstype] [fs-options] device
+ * Usage:	fsck [-AVRNTM] [-s] [-t fstype] [fs-options] device
  * 
+ * Miquel van Smoorenburg (miquels@drinkel.ow.org) 20-Oct-1994:
+ *   o Changed -t fstype to behave like with mount when -A (all file
+ *     systems) or -M (like mount) is specified.
+ *   o fsck looks if it can find the fsck.type program to decide
+ *     if it should ignore the fs type. This way more fsck programs
+ *     can be added without changing this front-end.
+ *   o -R flag skip root file system.
+ *
  * Copyright (C) 1993, 1994 Theodore Ts'o.  This file may be
  * redistributed under the terms of the GNU Public License.
  */
 
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/signal.h>
+#include <sys/stat.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
@@ -32,7 +42,6 @@
 static const char *ignored_types[] = {
 	"ignore",
 	"iso9660",
-	"msdos",
 	"nfs",
 	"proc",
 	"sw",
@@ -40,11 +49,42 @@
 	NULL
 };
 
+static const char *really_wanted[] = {
+	"minix",
+	"ext2",
+	"xiafs",
+	NULL
+};
+
+#ifdef DEV_DSK_DEVICES
+static const char *base_devices[] = {
+	"/dev/dsk/hda",
+	"/dev/dsk/hdb",
+	"/dev/dsk/hdc",
+	"/dev/dsk/hdd",
+	"/dev/dsk/hd1a",
+	"/dev/dsk/hd1b",
+	"/dev/dsk/hd1c",
+	"/dev/dsk/hd1d",
+	"/dev/dsk/sda",
+	"/dev/dsk/sdb",
+	"/dev/dsk/sdc",
+	"/dev/dsk/sdd",
+	"/dev/dsk/sde",
+	"/dev/dsk/sdf",
+	"/dev/dsk/sdg",
+	NULL
+};
+#else
 static const char *base_devices[] = {
 	"/dev/hda",
 	"/dev/hdb",
 	"/dev/hdc",
 	"/dev/hdd",
+	"/dev/hd1a",
+	"/dev/hd1b",
+	"/dev/hd1c",
+	"/dev/hd1d",
 	"/dev/sda",
 	"/dev/sdb",
 	"/dev/sdc",
@@ -54,6 +94,7 @@
 	"/dev/sdg",
 	NULL
 };
+#endif
 
 /*
  * Global variables for options
@@ -66,12 +107,17 @@
 int doall = 0;
 int noexecute = 0;
 int serialize = 0;
+int skip_root = 0;
+int like_mount = 0;
+int notitle = 0;
 char *progname;
 char *fstype = NULL;
 struct fs_info *filesys_info;
 struct fsck_instance *instance_list;
+static char fsck_path[PATH_MAX + 32];
+static int ignore(struct fs_info *);
 
-static char *strdup(char *s)
+static char *strdup(const char *s)
 {
 	char	*ret;
 
@@ -99,6 +145,7 @@
 	FILE *mntfile;
 	struct mntent *mp;
 	struct fs_info *fs;
+	int	old_fstab = 1;
 
 	filesys_info = NULL;
 	
@@ -119,9 +166,24 @@
 		fs->passno = mp->mnt_passno;
 		fs->next = filesys_info;
 		filesys_info = fs;
+		if (fs->passno)
+			old_fstab = 0;
 	}
 
 	(void) endmntent(mntfile);
+
+	if (old_fstab) {
+		fprintf(stderr, "\007\007\007"
+	"WARNING: Your /etc/fstab does not contain the fsck passno\n");
+		fprintf(stderr,
+	"	field.  I will kludge around things for you, but you\n");
+		fprintf(stderr,
+	"	should fix your /etc/fstab file as soon as you can.\n\n");
+		
+		for (fs = filesys_info; fs; fs = fs->next) {
+			fs->passno = 1;
+		}
+	}
 }
 	
 /* Lookup filesys in /etc/fstab and return the corresponding entry. */
@@ -142,13 +204,33 @@
 	return fs;
 }
 
+/* Find fsck program for a given fs type. */
+static char *find_fsck(char *type)
+{
+  char *s;
+  const char *tpl;
+  static char prog[256];
+  char *p = strdup(fsck_path);
+  struct stat st;
+
+  /* Are we looking for a program or just a type? */
+  tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
+
+  for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
+	sprintf(prog, tpl, s, type);
+	if (stat(prog, &st) == 0) break;
+  }
+  free(p);
+  return(s ? prog : NULL);
+}
+
 /*
  * Execute a particular fsck program, and link it into the list of
  * child processes we are waiting for.
  */
 static int execute(char *prog, char *device)
 {
-	char *argv[80];
+	char *s, *argv[80];
 	int  argc, i;
 	struct fsck_instance *inst;
 	pid_t	pid;
@@ -162,7 +244,14 @@
 	argv[argc++] = strdup(device);
 	argv[argc] = 0;
 
+	s = find_fsck(prog);
+	if (s == NULL) {
+		fprintf(stderr, "fsck: %s: not found\n", prog);
+		return ENOENT;
+	}
+
 	if (verbose || noexecute) {
+		printf("[%s] ", s);
 		for (i=0; i < argc; i++)
 			printf("%s ", argv[i]);
 		printf("\n");
@@ -175,8 +264,8 @@
 		perror("fork");
 		return errno;
 	} else if (pid == 0) {
-		(void) execvp(prog, argv);
-		perror(args[0]);
+		(void) execv(s, argv);
+		perror(argv[0]);
 		exit(EXIT_ERROR);
 	}
 	inst = malloc(sizeof(struct fsck_instance));
@@ -199,6 +288,7 @@
 static struct fsck_instance *wait_one(NOARGS)
 {
 	int	status;
+	int	sig;
 	struct fsck_instance *inst, *prev;
 	pid_t	pid;
 
@@ -207,7 +297,6 @@
 
 retry:
 	pid = wait(&status);
-	status = WEXITSTATUS(status);
 	if (pid < 0) {
 		if ((errno == EINTR) || (errno == EAGAIN))
 			goto retry;
@@ -231,7 +320,23 @@
 		       pid, status);
 		goto retry;
 	}
-	
+	if (WIFEXITED(status)) 
+		status = WEXITSTATUS(status);
+	else if (WIFSIGNALED(status)) {
+		sig = WTERMSIG(status);
+		if (sig == SIGINT) {
+			status = EXIT_UNCORRECTED;
+		} else {
+			printf("Warning... %s for device %s exited "
+			       "with signal %d.\n",
+			       inst->prog, inst->device, sig);
+			status = EXIT_ERROR;
+		}
+	} else {
+		printf("%s %s: status is %x, should never happen.\n",
+		       inst->prog, inst->device, status);
+		status = EXIT_ERROR;
+	}
 	inst->exit_status = status;
 	if (prev)
 		prev->next = inst->next;
@@ -269,12 +374,13 @@
 	int retval;
 	char prog[80];
 
-	if (fstype)
-		type = fstype;
-	else if ((fsent = lookup(device))) {
+	if ((fsent = lookup(device))) {
 		device = fsent->device;
 		type = fsent->type;
-	} else
+	} else if (fstype && strncmp(fstype, "no", 2) &&
+		   !strchr(fstype, ','))
+		type = fstype;
+	else
 		type = DEFAULT_FSTYPE;
 
 	sprintf(prog, "fsck.%s", type);
@@ -285,31 +391,77 @@
 	}
 }
 
+/* See if filesystem type matches the list. */
+static int fs_match(char *type, char *fs_type)
+{
+  int ret = 0, negate = 0;
+  char list[128];
+  char *s;
+
+  if (!fs_type) return(1);
+
+  if (strncmp(fs_type, "no", 2) == 0) {
+	fs_type += 2;
+	negate = 1;
+  }
+  strcpy(list, fs_type);
+  s = strtok(list, ",");
+  while(s) {
+	if (strcmp(s, type) == 0) {
+		ret = 1;
+		break;
+	}
+	s = strtok(NULL, ",");
+  }
+  return(negate ? !ret : ret);
+}
+
+
 /* Check if we should ignore this filesystem. */
 static int ignore(struct fs_info *fs)
 {
 	const char *cp;
 	const char **ip;
+	int wanted = 0;
+
+	/*
+	 * If the pass number is 0, ignore it.
+	 */
+	if (fs->passno == 0)
+		return 1;
 
 	/*
 	 * If a specific fstype is specified, and it doesn't match,
 	 * ignore it.
 	 */
-	if (fstype && strcmp(fstype, fs->type))
-		return 1;
+	if (!fs_match(fs->type, fstype)) return 1;
 	
-	ip = ignored_types;
-	while (*ip != NULL) {
-		if (!strcmp(fs->type, *ip))
-			return 1;
-		ip++;
-	}
-
+	/* Noauto never matches. */
 	for (cp = strtok(fs->opts, ","); cp != NULL; cp = strtok(NULL, ",")) {
 		if (!strcmp(cp, "noauto"))
 			return 1;
 	}
 
+	/* Are we ignoring this type? */
+	for(ip = ignored_types; *ip; ip++)
+		if (strcmp(fs->type, *ip) == 0) return(1);
+
+	/* Do we really really want to check this fs? */
+	for(ip = really_wanted; *ip; ip++)
+		if (strcmp(fs->type, *ip) == 0) {
+			wanted = 1;
+			break;
+		}
+
+	/* See if the <fsck.fs> program is available. */
+	if (find_fsck(fs->type) == NULL) {
+		if (wanted)
+			fprintf(stderr, "fsck: cannot check %s: fsck.%s not found\n",
+				fs->device, fs->type);
+		return(1);
+	}
+
+	/* We can and want to check this file system type. */
 	return 0;
 }
 
@@ -326,7 +478,6 @@
 	for (base = base_devices; *base; base++) {
 		if (!strncmp(*base, device, strlen(*base)))
 			return *base;
-		base++;
 	}
 	return device;
 }
@@ -370,14 +521,14 @@
 		if (!strcmp(fs->mountpt, "/"))
 			break;
 	}
-	if (fs &&
-	    (!fstype || !strcmp(fstype, fs->type))) {
+	if (fs && !skip_root && !ignore(fs)) {
 		fsck_device(fs->device);
 		fs->flags |= FLAG_DONE;
 		status |= wait_all();
 		if (status > EXIT_NONDESTRUCT)
 			return status;
 	}
+	if (fs) fs->flags |= FLAG_DONE;
 
 	/*
 	 * Mark filesystems that should be ignored as done.
@@ -498,6 +649,15 @@
 			case 'N':
 				noexecute++;
 				break;
+			case 'R':
+				skip_root++;
+				break;
+			case 'T':
+				notitle++;
+				break;
+			case 'M':
+				like_mount++;
+				break;
 			case 's':
 				serialize++;
 				break;
@@ -539,20 +699,20 @@
 
 int main(int argc, char *argv[])
 {
-	char *oldpath, newpath[PATH_MAX];
+	char *oldpath;
 	int status = 0;
 	int i;
 
 	PRS(argc, argv);
 
-	printf("Parallelizing fsck version %s (%s)\n", E2FSPROGS_VERSION,
-	       E2FSPROGS_DATE);
+	if (!notitle)
+		printf("Parallelizing fsck version %s (%s)\n",
+			E2FSPROGS_VERSION, E2FSPROGS_DATE);
 
-	/* Update our PATH to include /sbin, /etc/fs, and /etc. */
-	strcpy(newpath, "PATH=/sbin:/etc/fs:/etc:");
+	/* Update our search path to include uncommon directories. */
+	strcpy(fsck_path, "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc:");
 	if ((oldpath = getenv("PATH")) != NULL)
-		strcat(newpath, oldpath);
-	putenv(newpath);
+		strcat(fsck_path, oldpath);
     
 	/* If -A was specified ("check all"), do that! */
 	if (doall)
@@ -564,7 +724,7 @@
 			struct fsck_instance *inst;
 
 			inst = wait_one();
-			if (!inst) {
+			if (inst) {
 				status |= inst->exit_status;
 				free_instance(inst);
 			}
diff --git a/misc/fsck.h b/misc/fsck.h
index b79714b..3e13e9c 100644
--- a/misc/fsck.h
+++ b/misc/fsck.h
@@ -10,7 +10,7 @@
 #endif
 
 #ifndef DEFAULT_FSTYPE
-#   define DEFAULT_FSTYPE	"ext2"
+#define DEFAULT_FSTYPE	"ext2"
 #endif
 
 #define MAX_DEVICES 32
diff --git a/misc/lsattr.1 b/misc/lsattr.1
index 51a0d5a..ea61acd 100644
--- a/misc/lsattr.1
+++ b/misc/lsattr.1
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.TH LSATTR 1 "March 1994" "Version 0.5"
+.TH LSATTR 1 "November 1994" "Version 0.5b"
 .SH NAME
 lsattr \- list file attributes on a Linux second extended file system
 .SH SYNOPSIS
@@ -34,7 +34,7 @@
 There are none :-).
 .SH AVAILABILITY
 .B lsattr
-is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in
-/pub/linux/BETA/ext2fs.
+is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
+/pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR chattr (1)
diff --git a/misc/lsattr.c b/misc/lsattr.c
index ae337d6..6ce190c 100644
--- a/misc/lsattr.c
+++ b/misc/lsattr.c
@@ -35,12 +35,13 @@
 
 int all = 0;
 int d_opt = 0;
+int l_opt = 0;
 int recursive = 0;
 int v_opt = 0;
 
 static void volatile usage (void)
 {
-	fprintf (stderr, "Usage: %s [-Radv] [files...]\n", program_name);
+	fprintf (stderr, "Usage: %s [-Radlv] [files...]\n", program_name);
 	exit (1);
 }
 
@@ -59,7 +60,7 @@
 	{
 		if (v_opt)
 			printf ("%5lu ", version);
-		print_flags (stdout, flags);
+		print_flags (stdout, flags, l_opt);
 		printf (" %s\n", name);
 	}
 }
@@ -128,6 +129,9 @@
 			case 'd':
 				d_opt = 1;
 				break;
+			case 'l':
+				l_opt = 1;
+				break;
 			case 'v':
 				v_opt = 1;
 				break;
diff --git a/misc/mke2fs.8 b/misc/mke2fs.8
index 5b1e5bc..c398986 100644
--- a/misc/mke2fs.8
+++ b/misc/mke2fs.8
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.TH MKE2FS 8 "March 1994" "Version 0.5"
+.TH MKE2FS 8 "November 1994" "Version 0.5b"
 .SH NAME
 mke2fs \- create a Linux second extended file system
 .SH SYNOPSIS
@@ -30,8 +30,14 @@
 reserved-blocks-percentage
 ]
 [
+.B \-q
+]
+[
 .B \-v
 ]
+[
+.B \-S
+]
 device
 [
 blocks-count
@@ -82,8 +88,21 @@
 .\" Check the device for bad blocks before creating the file system
 .\" using the specified test.
 .TP
+.I -q
+Quiet execution.  Useful if mke2fs is run in a script.
+.TP
 .I -v
 Verbose execution.
+.TP
+.I -S
+Write superblock and group descriptors only.  This is useful if all of
+the superblock and backup superblocks are corrupted, and a last-ditch
+recovery method is desired.  It causes mke2fs to reinitialize the
+superblock and group descriptors, while not touching the inode table
+and the block and inode bitmaps.  The
+.B e2fsck
+program should be run immediately after this option is used, and there
+is no gaurantee that any data will be salvageable.
 .SH AUTHOR
 This version of
 .B mke2fs
@@ -96,9 +115,10 @@
 There may be some other ones.  Please, report them to the author.
 .SH AVAILABILITY
 .B mke2fs
-is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in
-/pub/linux/BETA/ext2fs.
+is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
+/pub/linux/packages/ext2fs.
 .SH SEE ALSO
+.BT badblocks (8),
 .BR dumpe2fs (8),
 .BR e2fsck (8),
 .BR tune2fs (8)
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 9d36ee9..13f536a 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -22,8 +22,10 @@
 #include <mntent.h>
 #include <malloc.h>
 #include <sys/ioctl.h>
-#include <linux/ext2_fs.h>
+#include <sys/types.h>
+
 #include <linux/fs.h>
+#include <linux/ext2_fs.h>
 
 #include "et/com_err.h"
 #include "ext2fs/ext2fs.h"
@@ -32,6 +34,7 @@
 #define STRIDE_LENGTH 8
 
 extern int isatty(int);
+extern FILE *fpopen(const char *cmd, const char *mode);
 
 const char * program_name = "mke2fs";
 const char * device_name = NULL;
@@ -40,6 +43,7 @@
 int	cflag = 0;
 int	verbose = 0;
 int	quiet = 0;
+int	super_only = 0;
 char	*bad_blocks_filename = 0;
 
 struct ext2_super_block param;
@@ -49,8 +53,8 @@
 	fprintf(stderr,
 		"Usage: %s [-c|-t|-l filename] [-b block-size] "
 		"[-f fragment-size]\n\t[-i bytes-per-inode] "
-		"[-m reserved-blocks-percentage] [-v]\n"
-		"\tdevice [blocks-count]\n",
+		"[-m reserved-blocks-percentage] [-qvS]\n"
+		"\t[-g blocks-per-group] device [blocks-count]\n",
 		program_name);
 	exit(1);
 }
@@ -67,11 +71,11 @@
 	return l;
 }
 
-static long valid_offset (int fd, int offset)
+static long valid_offset (int fd, ext2_loff_t offset)
 {
 	char ch;
 
-	if (lseek (fd, offset, 0) < 0)
+	if (ext2_llseek (fd, offset, 0) < 0)
 		return 0;
 	if (read (fd, &ch, 1) < 1)
 		return 0;
@@ -80,14 +84,14 @@
 
 static int count_blocks (int fd)
 {
-	int high, low;
+	ext2_loff_t high, low;
 
 	low = 0;
 	for (high = 1; valid_offset (fd, high); high *= 2)
 		low = high;
 	while (low < high - 1)
 	{
-		const int mid = (low + high) / 2;
+		const ext2_loff_t mid = (low + high) / 2;
 
 		if (valid_offset (fd, mid))
 			low = mid;
@@ -192,7 +196,7 @@
 		exit(1);
 	}
 	retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
-	fclose (f);
+	pclose(f);
 	if (retval) {
 		com_err("ext2fs_read_bb_FILE", retval,
 			"while processing list of bad blocks from program");
@@ -202,11 +206,14 @@
 
 static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
 {
-	int			i;
+	int			i, j;
 	int			must_be_good;
 	blk_t			blk;
 	badblocks_iterate	bb_iter;
 	errcode_t		retval;
+	blk_t			group_block;
+	int			group;
+	int			group_bad;
 
 	if (!bb_list)
 		return;
@@ -227,6 +234,33 @@
 			exit(1);
 		}
 	}
+
+	/*
+	 * See if any of the bad blocks are showing up in the backup
+	 * superblocks and/or group descriptors.  If so, issue a
+	 * warning and adjust the block counts appropriately.
+	 */
+	group_block = fs->super->s_first_data_block +
+		fs->super->s_blocks_per_group;
+	group_bad = 0;
+	
+	for (i = 1; i < fs->group_desc_count; i++) {
+		for (j=0; j < fs->desc_blocks+1; j++) {
+			if (badblocks_list_test(bb_list, group_block +
+						j)) {
+				if (!group_bad) 
+					fprintf(stderr,
+"Warning: the backup superblock/group descriptors at block %ld contain\n"
+"	bad blocks.\n\n",
+						group_block);
+				group_bad++;
+				group = ext2fs_group_of_blk(fs, group_block+j);
+				fs->group_desc[group].bg_free_blocks_count++;
+				fs->super->s_free_blocks_count++;
+			}
+		}
+		group_block += fs->super->s_blocks_per_group;
+	}
 	
 	/*
 	 * Mark all the bad blocks as used...
@@ -238,13 +272,13 @@
 		exit(1);
 	}
 	while (badblocks_list_iterate(bb_iter, &blk)) 
-		ext2fs_mark_block_bitmap(fs, fs->block_map, blk);
+		ext2fs_mark_block_bitmap(fs->block_map, blk);
 	badblocks_list_iterate_end(bb_iter);
 }
 
 static void new_table_block(ext2_filsys fs, blk_t first_block,
-			    const char *name, int num, const char *buf,
-			    blk_t *new_block)
+			    const char *name, int num, int initialize,
+			    const char *buf, blk_t *new_block)
 {
 	errcode_t	retval;
 	blk_t		blk;
@@ -260,21 +294,24 @@
 		ext2fs_unmark_valid(fs);
 		return;
 	}
-	blk = *new_block;
-	for (i=0; i < num; i += STRIDE_LENGTH, blk += STRIDE_LENGTH) {
-		if (num-i > STRIDE_LENGTH)
-			count = STRIDE_LENGTH;
-		else
-			count = num - i;
-		retval = io_channel_write_blk(fs->io, blk, count, buf);
-		if (retval)
-			printf("Warning: could not write %d blocks starting "
-			       "at %ld for %s: %s\n",
-			       count, blk, name, error_message(retval));
+	if (initialize) {
+		blk = *new_block;
+		for (i=0; i < num; i += STRIDE_LENGTH, blk += STRIDE_LENGTH) {
+			if (num-i > STRIDE_LENGTH)
+				count = STRIDE_LENGTH;
+			else
+				count = num - i;
+			retval = io_channel_write_blk(fs->io, blk, count, buf);
+			if (retval)
+				printf("Warning: could not write %d blocks "
+				       "starting at %ld for %s: %s\n",
+				       count, blk, name,
+				       error_message(retval));
+		}
 	}
 	blk = *new_block;
 	for (i = 0; i < num; i++, blk++)
-		ext2fs_mark_block_bitmap(fs, fs->block_map, blk);
+		ext2fs_mark_block_bitmap(fs->block_map, blk);
 }	
 
 static void alloc_tables(ext2_filsys fs)
@@ -282,7 +319,6 @@
 	blk_t	group_blk;
 	int	i;
 	char	*buf;
-	int	numblocks;
 
 	buf = malloc(fs->blocksize * STRIDE_LENGTH);
 	if (!buf) {
@@ -297,28 +333,15 @@
 	for (i = 0; i < fs->group_desc_count; i++) {
 		if (!quiet)
 			printf("%4d/%4ld", i, fs->group_desc_count);
-		new_table_block(fs, group_blk, "block bitmap", 1, buf,
+		new_table_block(fs, group_blk, "block bitmap", 1, 0, buf,
 				&fs->group_desc[i].bg_block_bitmap);
-		new_table_block(fs, group_blk, "inode bitmap", 1, buf,
+		new_table_block(fs, group_blk, "inode bitmap", 1, 0, buf,
 				&fs->group_desc[i].bg_inode_bitmap);
 		new_table_block(fs, group_blk, "inode table",
-				fs->inode_blocks_per_group, buf,
+				fs->inode_blocks_per_group,
+				!super_only, buf,
 				&fs->group_desc[i].bg_inode_table);
 		
-		if (i == fs->group_desc_count-1) {
-			numblocks = (fs->super->s_blocks_count -
-				     fs->super->s_first_data_block) %
-					     fs->super->s_blocks_per_group;
-			if (!numblocks)
-				numblocks = fs->super->s_blocks_per_group;
-		} else
-			numblocks = fs->super->s_blocks_per_group;
-		numblocks -= 3 + fs->desc_blocks + fs->inode_blocks_per_group;
-		
-		fs->group_desc[i].bg_free_blocks_count = numblocks;
-		fs->group_desc[i].bg_free_inodes_count =
-			fs->super->s_inodes_per_group;
-		fs->group_desc[i].bg_used_dirs_count = 0;
 		group_blk += fs->super->s_blocks_per_group;
 		if (!quiet) 
 			printf("\b\b\b\b\b\b\b\b\b");
@@ -330,12 +353,28 @@
 static void create_root_dir(ext2_filsys fs)
 {
 	errcode_t	retval;
+	struct ext2_inode	inode;
 
 	retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
 	if (retval) {
 		com_err("ext2fs_mkdir", retval, "while creating root dir");
 		exit(1);
 	}
+	if (geteuid()) {
+		retval = ext2fs_read_inode(fs, EXT2_ROOT_INO, &inode);
+		if (retval) {
+			com_err("ext2fs_read_inode", retval,
+				"while reading root inode");
+			exit(1);
+		}
+		inode.i_uid = geteuid();
+		retval = ext2fs_write_inode(fs, EXT2_ROOT_INO, &inode);
+		if (retval) {
+			com_err("ext2fs_write_inode", retval,
+				"while setting root inode ownership");
+			exit(1);
+		}
+	}
 }
 
 static void create_lost_and_found(ext2_filsys fs)
@@ -371,7 +410,7 @@
 {
 	errcode_t	retval;
 	
-	ext2fs_mark_inode_bitmap(fs, fs->inode_map, EXT2_BAD_INO);
+	ext2fs_mark_inode_bitmap(fs->inode_map, EXT2_BAD_INO);
 	fs->group_desc[0].bg_free_inodes_count--;
 	fs->super->s_free_inodes_count--;
 	retval = ext2fs_update_bb_inode(fs, bb_list);
@@ -389,7 +428,7 @@
 	int	group;
 
 	for (i = EXT2_ROOT_INO + 1; i < EXT2_FIRST_INO; i++) {
-		ext2fs_mark_inode_bitmap (fs, fs->inode_map, i);
+		ext2fs_mark_inode_bitmap(fs->inode_map, i);
 		group = ext2fs_group_of_ino(fs, i);
 		fs->group_desc[group].bg_free_inodes_count--;
 		fs->super->s_free_inodes_count--;
@@ -397,6 +436,20 @@
 	ext2fs_mark_ib_dirty(fs);
 }
 
+static void zap_bootblock(ext2_filsys fs)
+{
+	char buf[512];
+	int retval;
+
+	memset(buf, 0, 512);
+	
+	retval = io_channel_write_blk(fs->io, 0, -512, buf);
+	if (retval)
+		printf("Warning: could not erase block 0: %s\n", 
+		       error_message(retval));
+}
+	
+
 static void show_stats(ext2_filsys fs)
 {
 	struct ext2_super_block	*s = fs->super;
@@ -449,7 +502,8 @@
 	char	c;
 	int	size;
 	char	* tmp;
-	char *oldpath, newpath[PATH_MAX];
+	char	*oldpath;
+	static char newpath[PATH_MAX];
 	int	inode_ratio = 4096;
 	int	reserved_ratio = 5;
 
@@ -469,7 +523,7 @@
 		 EXT2FS_VERSION, EXT2FS_DATE);
 	if (argc && *argv)
 		program_name = *argv;
-	while ((c = getopt (argc, argv, "b:cf:g:i:l:m:qtv")) != EOF)
+	while ((c = getopt (argc, argv, "b:cf:g:i:l:m:qtvS")) != EOF)
 		switch (c) {
 		case 'b':
 			size = strtoul(optarg, &tmp, 0);
@@ -499,11 +553,20 @@
 			break;
 		case 'g':
 			param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
+			if (*tmp) {
+				com_err(program_name, 0,
+					"Illegal number for blocks per group");
+				exit(1);
+			}
 			if (param.s_blocks_per_group < 256 ||
 			    param.s_blocks_per_group > 8192 || *tmp) {
 				com_err(program_name, 0,
-					"bad blocks per group count - %s",
-					optarg);
+					"blocks per group count out of range");
+				exit(1);
+			}
+			if ((param.s_blocks_per_group % 8) != 0) {
+				com_err(program_name, 0,
+				"blocks per group must be multiple of 8");
 				exit(1);
 			}
 			break;
@@ -517,7 +580,13 @@
 			}
 			break;
 		case 'l':
-			bad_blocks_filename = strdup(optarg);
+			bad_blocks_filename = malloc(strlen(optarg)+1);
+			if (!bad_blocks_filename) {
+				com_err(program_name, ENOMEM,
+					"in malloc for bad_blocks_filename");
+				exit(1);
+			}
+			strcpy(bad_blocks_filename, optarg);
 			break;
 		case 'm':
 			reserved_ratio = strtoul(optarg, &tmp, 0);
@@ -534,6 +603,9 @@
 		case 'q':
 			quiet = 1;
 			break;
+		case 'S':
+			super_only = 1;
+			break;
 		default:
 			usage();
 		}
@@ -560,7 +632,8 @@
 	 * Calculate number of inodes based on the inode ratio
 	 */
 	param.s_inodes_count =
-		(param.s_blocks_count * EXT2_BLOCK_SIZE(&param)) / inode_ratio;
+		((long long) param.s_blocks_count * EXT2_BLOCK_SIZE(&param))
+			/ inode_ratio;
 
 	/*
 	 * Calculate number of blocks to reserve
@@ -598,10 +671,16 @@
 
 	handle_bad_blocks(fs, bb_list);
 	alloc_tables(fs);
-	create_root_dir(fs);
-	create_lost_and_found(fs);
-	reserve_inodes(fs);
-	create_bad_block_inode(fs, bb_list);
+	if (super_only) {
+		fs->super->s_state |= EXT2_ERROR_FS;
+		fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY);
+	} else {
+		create_root_dir(fs);
+		create_lost_and_found(fs);
+		reserve_inodes(fs);
+		create_bad_block_inode(fs, bb_list);
+		zap_bootblock(fs);
+	}
 	
 	if (!quiet)
 		printf("Writing superblocks and "
diff --git a/misc/mklost+found.8 b/misc/mklost+found.8
index b566318..e757ff8 100644
--- a/misc/mklost+found.8
+++ b/misc/mklost+found.8
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.TH MKLOST+FOUND 8 "March 1994" "Version 0.5"
+.TH MKLOST+FOUND 8 "November 1994" "Version 0.5b"
 .SH NAME
 mklost+found \- create a lost+found directory on a mounted Linux
 second extended file system
@@ -23,8 +23,8 @@
 There are none :-)
 .SH AVAILABILITY
 .B mklost+found
-is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in
-/pub/linux/BETA/ext2fs.
+is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
+/pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR e2fsck (8),
 .BR mke2fs (8)
diff --git a/misc/tune2fs.8 b/misc/tune2fs.8
index 3d99704..a3cbf35 100644
--- a/misc/tune2fs.8
+++ b/misc/tune2fs.8
@@ -2,14 +2,42 @@
 .\" Initial revision
 .\"
 .\"
-.TH TUNE2FS 8 "March 1994" "Version 0.5"
+.TH TUNE2FS 8 "November 1994" "Version 0.5b"
 
 .SH NAME
 tune2fs \- adjust tunable filesystem parameters on second extended filesystems
 .SH SYNOPSIS
 .B tune2fs
 [
-.B options
+.B -l
+]
+[
+.B -c
+.I max-mount-counts
+]
+[
+.B -e
+.I errors-behavior
+]
+[
+.B -i
+.I interval-between-checks
+]
+[
+.B -m
+.I reserved-blocks-percentage
+]
+[
+.B -r
+.I reserved-blocks-count
+]
+[
+.B -u
+.I user
+]
+[
+.B -g
+.I group
 ]
 device
 .SH DESCRIPTION
@@ -34,9 +62,15 @@
 .br
 \	panic\	\	Causes a kernel panic.
 .TP
-.I -i interval-between-checks[d|m]
+.I -g group
+set the user group which can benefit from the reserved blocks.
+.br
+.I group
+can be a numerical gid or a group name.
+.TP
+.I -i interval-between-checks[d|m|w]
 adjust the maximal time between two filesystem checks. 
-No postfix or `d' result in days, and 'm' in months.
+No postfix or `d' result in days, `m' in months, and `w' in weeks.
 A value of zero will disable the timedependent checking.
 .TP
 .I -l
@@ -44,6 +78,14 @@
 .TP
 .I -m reserved-blocks-percentage
 adjust the reserved blocks percentage on the given device.
+.TP
+.I -r reserved-blocks-count
+adjust the reserved blocks count on the given device.
+.TP
+.I -u user
+set the user who can benefit from the reserved blocks.
+.I user
+can be a numerical uid or a user name.
 .PP
 .SH BUGS
 We didn't find any bugs yet. Perhaps there are bugs but it's unlikely.
@@ -63,8 +105,8 @@
 Timedependent checking was added by Uwe Ohse <uwe@tirka.gun.de>.
 .SH AVAILABILITY
 .B tune2fs
-is available for anonymous ftp from ftp.ibp.fr (132.227.60.2) in
-/pub/linux/BETA/ext2fs.
+is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
+/pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR dumpe2fs (8),
 .BR e2fsck (8),
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 2f0d860..cd2d622 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -23,12 +23,15 @@
  */
 
 #include <fcntl.h>
+#include <grp.h>
 #include <getopt.h>
+#include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/types.h>
 
 #include <linux/ext2_fs.h>
 
@@ -42,19 +45,26 @@
 char * device_name = NULL;
 int c_flag = 0;
 int e_flag = 0;
+int g_flag = 0;
 int i_flag = 0;
 int l_flag = 0;
 int m_flag = 0;
+int r_flag = 0;
+int u_flag = 0;
 int max_mount_count;
 unsigned long interval;
 unsigned long reserved_ratio = 0;
+unsigned long reserved_blocks = 0;
 unsigned short errors;
+unsigned long resgid = 0;
+unsigned long resuid = 0;
 
 static volatile void usage (void)
 {
 	fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] "
-		 "[-i interval[d|m]]\n"
-		 "\t[-l] [-m reserved-blocks-percent] device\n", program_name);
+		 "[-g group]\n"
+		 "\t[-i interval[d|m|w]] [-l] [-m reserved-blocks-percent]\n"
+		 "\t[-r reserved-blocks-count] [-u user] device\n", program_name);
 	exit (1);
 }
 
@@ -64,6 +74,8 @@
 	char * tmp;
 	errcode_t retval;
 	ext2_filsys fs;
+	struct group * gr;
+	struct passwd * pw;
 
 	fprintf (stderr, "tune2fs %s, %s for EXT2 FS %s, %s\n",
 		 E2FSPROGS_VERSION, E2FSPROGS_DATE,
@@ -71,7 +83,7 @@
 	if (argc && *argv)
 		program_name = *argv;
 	initialize_ext2_error_table();
-	while ((c = getopt (argc, argv, "c:e:i:lm:")) != EOF)
+	while ((c = getopt (argc, argv, "c:e:g:i:lm:r:u:")) != EOF)
 		switch (c)
 		{
 			case 'c':
@@ -101,6 +113,25 @@
 				}
 				e_flag = 1;
 				break;
+			case 'g':
+				resgid = strtoul (optarg, &tmp, 0);
+				if (*tmp)
+				{
+					gr = getgrnam (optarg);
+					if (gr == NULL)
+						tmp = optarg;
+					else
+						resgid = gr->gr_gid;
+				}
+				if (*tmp)
+				{
+					com_err (program_name, 0,
+						 "bad gid/group name - %s",
+						 optarg);
+					usage ();
+				}
+				g_flag = 1;
+				break;
 			case 'i':
 				interval = strtoul (optarg, &tmp, 0);
 				switch (*tmp)
@@ -117,6 +148,11 @@
 						interval *= 86400 * 30;
 						tmp++;
 						break;
+					case 'w':
+					case 'W': /* weeks */
+						interval *= 86400 * 7;
+						tmp++;
+						break;
 				}
 				if (*tmp || interval > (365 * 86400))
 				{
@@ -140,16 +176,48 @@
 				}
 				m_flag = 1;
 				break;
+			case 'r':
+				reserved_blocks = strtoul (optarg, &tmp, 0);
+				if (*tmp)
+				{
+					com_err (program_name, 0,
+						 "bad reserved blocks count - %s",
+						 optarg);
+					usage ();
+				}
+				r_flag = 1;
+				break;
+			case 'u':
+				resuid = strtoul (optarg, &tmp, 0);
+				if (*tmp)
+				{
+					pw = getpwnam (optarg);
+					if (pw == NULL)
+						tmp = optarg;
+					else
+						resuid = pw->pw_uid;
+				}
+				if (*tmp)
+				{
+					com_err (program_name, 0,
+						 "bad uid/user name - %s",
+						 optarg);
+					usage ();
+				}
+				u_flag = 1;
+				break;
 			default:
 				usage ();
 		}
 	if (optind < argc - 1 || optind == argc)
 		usage ();
-	if (!c_flag && !e_flag && !i_flag && !m_flag && !l_flag)
+	if (!c_flag && !e_flag && !g_flag && !i_flag && !l_flag && !m_flag
+	    && !r_flag && !u_flag)
 		usage ();
 	device_name = argv[optind];
 	retval = ext2fs_open (device_name,
-			      (c_flag || e_flag || i_flag || m_flag) ? EXT2_FLAG_RW : 0,
+			      (c_flag || e_flag || g_flag || i_flag || m_flag
+			       || r_flag || u_flag) ? EXT2_FLAG_RW : 0,
 			      0, 0, unix_io_manager, &fs);
         if (retval)
 	{
@@ -171,6 +239,18 @@
 		ext2fs_mark_super_dirty(fs);
 		printf ("Setting error behavior to %d\n", errors);
 	}
+	if (g_flag)
+#ifdef	EXT2_DEF_RESGID
+	{
+		fs->super->s_def_resgid = resgid;
+		ext2fs_mark_super_dirty(fs);
+		printf ("Setting reserved blocks gid to %lu\n", resgid);
+	}
+#else
+		com_err (program_name, 0,
+			 "The -g option is not supported by this version -- "
+			 "Recompile with a newer kernel");
+#endif
 	if (i_flag)
 	{
 		fs->super->s_checkinterval = interval;
@@ -185,6 +265,32 @@
 		printf ("Setting reserved blocks percentage to %lu (%lu blocks)\n",
 			reserved_ratio, fs->super->s_r_blocks_count);
 	}
+	if (r_flag)
+	{
+		if (reserved_blocks >= fs->super->s_blocks_count)
+		{
+			com_err (program_name, 0,
+				 "reserved blocks count is too big (%ul)",
+				 reserved_blocks);
+			exit (1);
+		}
+		fs->super->s_r_blocks_count = reserved_blocks;
+		ext2fs_mark_super_dirty(fs);
+		printf ("Setting reserved blocks count to %lu\n",
+			reserved_blocks);
+	}
+	if (u_flag)
+#ifdef	EXT2_DEF_RESUID
+	{
+		fs->super->s_def_resuid = resuid;
+		ext2fs_mark_super_dirty(fs);
+		printf ("Setting reserved blocks uid to %lu\n", resuid);
+	}
+#else
+		com_err (program_name, 0,
+			 "The -u option is not supported by this version -- "
+			 "Recompile with a newer kernel");
+#endif
 	if (l_flag)
 		list_super (fs->super);
 	ext2fs_close (fs);