Imported reiserfsprogs-3.6.9
diff --git a/CREDITS b/CREDITS
new file mode 100644
index 0000000..a24c3d0
--- /dev/null
+++ b/CREDITS
@@ -0,0 +1,90 @@
+/*
+   Copyright 1996-2003 by Hans Reiser, licensing governed by 
+   reiserfsprogs/README.
+*/
+
+Hans Reiser was the project initiator,  source of all funding for the first 5.5
+years. He is the architect and official maintainer.
+
+Vladimir Saveliev started as the most junior programmer on the team, and became
+the lead programmer.  He is now an experienced highly productive programmer. He
+wrote the extent  handling code for Reiser4,  plus parts of  the balancing code 
+and file write and file read.
+
+Alexander Zarochentcev  (zam)  wrote the high low priority locking code, online
+resizer for V3 and V4, online repacker for V4, block allocation code, and major
+parts of  the flush code,  and maintains the transaction manager code.  We give
+him the stuff  that we know will be hard to debug,  or needs to be very cleanly
+structured.
+
+Nikita Danilov  wrote  most of the core  balancing code, plugin infrastructure,
+and directory code. He steadily worked long hours, and is the reason so much of
+the Reiser4 plugin infrastructure is well abstracted in its details.  The carry 
+function, and the use of non-recursive balancing, are his idea.
+
+Vladimir Demidov wrote the parser for sys_reiser4(), the V3 alpha port, part of
+the V3  journal  relocation code,  and helped  Hans keep  the business  side of
+things running.
+
+Chris Mason wrote the journaling code for V3,  which was enormously more useful
+to users than just waiting until  we could create a wandering log filesystem as
+Hans would have unwisely done without him.
+Jeff Mahoney optimized the bitmap  scanning code for V3,  and performed the big
+endian cleanups. 
+
+Elena Gryaznova performed testing and benchmarking.
+
+Oleg Drokin was the debugger for  V3 during most of the time that  V4 was under
+development,  and was quite  skilled and fast at it.  He wrote  the large write
+optimization of V3.
+
+Edward Shushkin wrote the encryption and compression  file plugins,  and the V3
+journal relocation code.
+
+Alexander  Lyamin  keeps our hardware  running,  and was very  generous  to our
+project in many little ways.
+
+Vitaly Fertman wrote  fsck for V3 and  maintains the reiserfsprogs package now.
+He wrote librepair,  userspace plugins repair code, fsck for V4,  and worked on
+developing libreiser4 and userspace plugins with Umka.
+
+Yury Umanets  (aka Umka)  developed  libreiser4,  userspace  plugins,  and  all
+userspace tools (reiser4progs) except of fsck.
+ 
+Joshua Macdonald wrote the first draft of the transaction manager. Yuri Rupasov
+did testing  and benchmarking,  plus he invented the r5 hash  (also used by the
+dcache  code).  Yura  Rupasov,  Anatoly Pinchuk,  Igor Krasheninnikov,  Grigory
+Zaigralin,  Mikhail  Gilula,   Igor  Zagorovsky,  Roman  Pozlevich,  Konstantin
+Shvachko, and Joshua MacDonald are former contributors to the project.
+
+Jeremy  Fitzhardinge  wrote  the  teahash.c  code  for  V3.  Colin  Plumb  also
+contributed to that.
+
+The  Defense  Advanced  Research  Projects Agency (DARPA, www.darpa.mil) is the
+primary sponsor of Reiser4.  DARPA  does  not  endorse  this project; it merely 
+sponsors it.
+
+Continuing core development of ReiserFS is  mostly paid for by Hans Reiser from
+money made selling licenses  in addition to the GPL to companies who don't want
+it known that they use ReiserFS  as a foundation for their proprietary product.
+And my lawyer asked 'People pay you money for this?'. Yup. Life is good. If you
+buy ReiserFS, you can focus on your value add rather than reinventing an entire
+FS.
+
+BigStorage  (www.bigstorage.com)  contributes to our general fund  every month,
+and has done so for quite a long time.
+
+SuSE (www.suse.com)  pays for continuing work on journaling for version 3, paid
+for much of the previous version 3 work, and is paying for Chris and Jeff to do
+V3 maintenance. Reiserfs integration in their distro is consistently solid, and
+they were key to our becoming widely used.
+
+Lycos (www.lycos.com) has a support contract with us that consistently comes in
+just when  we would otherwise miss payroll,  and  that they keep doubling every 
+year. Much thanks to them.
+
+Many persons came to www.namesys.com/support.html,  and got a question answered
+for $25, or just gave us a small donation there.
+
+Thanks to all  of those sponsors,  including  the secret ones.  Without you, we
+would each still have that day job.
diff --git a/ChangeLog b/ChangeLog
index 3fd2c05..20e4d8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,139 @@
+2003-07-16
+	*reiserfsprogs
+		Credits were changed.
+		A pair of them are printed at mkfs time.
+	*reiserfsprogs
+		3.6.9 release.
+2003-06-25
+	*reiserfsprogs
+		Bugs were fixed:
+		- in reiserfsck rebuild-sb of relocated journal;
+		- in reiserfstune --no-journal-available;
+		- in bitmap handling during resizing;
+		- in mkreiserfs with notstandard journal on the main device 
+		with not standard offset;
+		- in not standard journal creation.
+2003-05-29
+	*reiserfsprogs
+		Bugs in journal traversing and in rebuild-sb were fixed.
+2003-05-20
+	*reiserfsck
+		Forks another process with openned file descriptor of the 
+		partition being checked when fscking on boot and sleep for 
+		5 secs to avoid reading of all bitmaps on mount again.
+2003-05-16
+	*mkreiserfs
+		A bug with not standard journal cretion was fixed.
+	*reiserfsprogs
+		3.6.8 release.
+2003-05-07
+	*reiserfsck
+		Exit codes were fixed;
+		--yes option was added into fsck
+	*mkreiserfs
+		--quiet option was added into mkfs
+2003-05-06
+	*reiserfsprogs
+		A bug in journal replaying code when the only transaction 
+		exists was fixed.
+2003-05-01
+	*reiserfsprogs
+		Make fsck to proceed when wrong journal parameters in the journal
+		header on a fs with standard journal detected fixing them with the
+		warning.
+	*reiserfsprogs
+		3.6.7 release.
+2003-04-24
+	*reiserfsprogs
+		3.6.6 release.
+2003-04-01
+	*reiserfsprogs
+		Bug with flushing buffers on bad file descriptor was fixed.
+	*reiserfstune
+		Bugs with not standard journal were fixed.
+2003-03-13
+	*reiserfsck
+		Leaves recovery was improved - if some items are detected, try
+		to recover the leaf even if block head is corrupted.
+2003-03-04
+	*reiserfsck
+		The objectid handling was improved, significant speedup at
+		semantic pass and lost+found pass.
+2003-02-27
+	*reiserfsprogs
+		The check if the last block on fs is readable was moved from
+		bitmap check to fs_open.
+		Check transactions content before replaying, sware on invalid
+		content instead of replay attempts, print about results.
+	*reiserfsprogs
+		3.6.5 release.
+2003-02-21
+	*reiserfsck
+		a critical bug on pass0 of rebuild-tree with overflowing while
+		checking unformatted item offsets was fixed.
+	*reiserfsprogs
+		3.6.5-pre2 release.
+2003-02-20
+	*reiserfsck
+		reiserfsck -a (started at boot) replays journal, checks error 
+		flags in sb, bitmaps, fs size, 2 levels of internal tree and 
+		switches to fixble mode if any problem is detected. For root 
+		fs fixable cannot be performed (as fs is mounted) and just 
+		--check will be done.
+2003-02-14
+	*reiserfsck
+		fix-fixable does not relocated shared object ids anymore.
+		Bug in relocation - entry key was not updated correctly with 
+		the new key of relocated file.
+2003-02-12
+	*reiserfsprogs
+		Journal replay was improved - check blocks if they are journable
+		before replaying; - replay only transactions which has trans_id
+		== last replayed transaction trans_id + 1.
+2003-02-10
+	*reiserfsprogs
+		le bitops operations were added back to avoid arch dependence 
+		with including asm/bitops.h - we should use le operations even
+		on be mashins.
+2003-01-31
+	*reiserfsprogs
+		Warning messages about the broken hardware were improved.
+2003-01-30
+	*reiserfsprogs
+		Check for bits in ondisk bitmaps after the last valid bit was
+		added - all these bits should be set to 1.
+2002-12-13
+	*reiserfsck
+		Keep only permanent fields of the super block, but not the whole
+	       	super block, in separate memory while replaying.
+2002-12-11
+	*reiserfsck
+		While openning the journal check that journal parameters in 
+		super block and in jheader mathches; Advice to run rebuild-sb
+		if not. While rebuilding super block, do the same check and ask
+		the user if he wants to rebuild the jheader or continue without 
+		the journal or he wants to change the start of the partition 
+		before using reiserfsck.
+2002-12-04
+	*reiserfsprogs
+		3.6.5-pre1 is released.
+2002-12-02
+	*reiserfsck
+		a few bugs were fixed:
+		- bug in balancing code led to abort when a leaf could be viewed 
+		as a super block;
+		- bug in checking statdata size for symlinks - there cannot be a 
+		hole at the end of symlink.
+2002-11-28
+	*reiserfsck
+		pass0 does not need a true objectid map, just those objectids
+		which are not used. This sppedups pass0 a lot as many memoves
+		are eliminated.
+	*reiserfsck
+		bug with item format for symlinks was fixed.
+2002-10-02
+	*reiserfsprogs
+		3.6.4 is released.
 2002-09-24
 	*reiserfsck
 		bitmap handling was improved: fix-fixable fixes not only those 
@@ -213,7 +349,7 @@
 	* reiserfsprogs.spec (Anthon van der Neut)
 		rpm can be built as non-root
 		link from reiserfsck to fsck.reiserfs
-		rpm -e reiserfsprogs should now work w/o rmdir of /
+		rpm -e reiserfsprogs should now work without rmdir of /
 2001-03-13
 	* reiserfsck
 		--quiet option is added
diff --git a/Makefile.am b/Makefile.am
index ce451a7..f6b0759 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,8 +1,8 @@
-SUBDIRS = include lib reiserfscore fsck debugreiserfs resize_reiserfs mkreiserfs tune
+SUBDIRS = include lib reiserfscore fsck debugreiserfs resize_reiserfs mkreiserfs tune tests
 
 noinst_DATA = reiserfsprogs.spec
 
-EXTRA_DIST = version.h
+EXTRA_DIST = CREDITS version.h
 
 dist-hook:
 	cp -f reiserfsprogs.spec $(distdir)
diff --git a/Makefile.in b/Makefile.in
index d61620d..ede2b8a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,124 +12,141 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = .
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
-SUBDIRS = include lib reiserfscore fsck debugreiserfs resize_reiserfs mkreiserfs tune
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+SUBDIRS = include lib reiserfscore fsck debugreiserfs resize_reiserfs mkreiserfs tune tests
 
 noinst_DATA = reiserfsprogs.spec
 
-EXTRA_DIST = version.h
+EXTRA_DIST = CREDITS version.h
+subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ./include/config.h
-CONFIG_CLEAN_FILES = 
-DATA =  $(noinst_DATA)
-
-DIST_COMMON =  README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
-Makefile.in NEWS acconfig.h aclocal.m4 configure configure.in \
-include/config.h.in include/stamp-h.in install-sh missing mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+DATA = $(noinst_DATA)
 
 
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
+	ps-recursive install-info-recursive uninstall-info-recursive \
+	all-recursive install-data-recursive install-exec-recursive \
+	installdirs-recursive install-recursive uninstall-recursive \
+	check-recursive installcheck-recursive
+DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
+	Makefile.in NEWS aclocal.m4 configure configure.in depcomp \
+	install-sh missing mkinstalldirs
+DIST_SUBDIRS = $(SUBDIRS)
+all: all-recursive
 
-TAR = tar
-GZIP_ENV = --best
-all: all-redirect
 .SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)
 
-$(ACLOCAL_M4):  configure.in 
-	cd $(srcdir) && $(ACLOCAL)
-
-config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	$(SHELL) ./config.status --recheck
-$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+$(srcdir)/configure:  $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
 	cd $(srcdir) && $(AUTOCONF)
 
-include/config.h: include/stamp-h
-	@if test ! -f $@; then \
-		rm -f include/stamp-h; \
-		$(MAKE) include/stamp-h; \
-	else :; fi
-include/stamp-h: $(srcdir)/include/config.h.in $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES= CONFIG_HEADERS=include/config.h \
-	     $(SHELL) ./config.status
-	@echo timestamp > include/stamp-h 2> /dev/null
-$(srcdir)/include/config.h.in: $(srcdir)/include/stamp-h.in
-	@if test ! -f $@; then \
-		rm -f $(srcdir)/include/stamp-h.in; \
-		$(MAKE) $(srcdir)/include/stamp-h.in; \
-	else :; fi
-$(srcdir)/include/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
-	cd $(top_srcdir) && $(AUTOHEADER)
-	@echo timestamp > $(srcdir)/include/stamp-h.in 2> /dev/null
-
-mostlyclean-hdr:
-
-clean-hdr:
-
-distclean-hdr:
-	-rm -f include/config.h
-
-maintainer-clean-hdr:
+$(ACLOCAL_M4):  configure.in 
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+uninstall-info-am:
 
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
@@ -135,13 +154,8 @@
 # (1) if the variable is set in `config.status', edit `config.status'
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
-
-@SET_MAKE@
-
-all-recursive install-data-recursive install-exec-recursive \
-installdirs-recursive install-recursive uninstall-recursive  \
-check-recursive installcheck-recursive info-recursive dvi-recursive:
-	@set fnord $(MAKEFLAGS); amf=$$2; \
+$(RECURSIVE_TARGETS):
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -161,13 +175,18 @@
 
 mostlyclean-recursive clean-recursive distclean-recursive \
 maintainer-clean-recursive:
-	@set fnord $(MAKEFLAGS); amf=$$2; \
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
-	rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
-	  rev="$$subdir $$rev"; \
-	  test "$$subdir" != "." || dot_seen=yes; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
 	done; \
-	test "$$dot_seen" = "no" && rev=". $$rev"; \
+	rev="$$rev ."; \
 	target=`echo $@ | sed s/-recursive//`; \
 	for subdir in $$rev; do \
 	  echo "Making $$target in $$subdir"; \
@@ -183,174 +202,294 @@
 	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-   if test "$$subdir" = .; then :; else \
+	  if test "$$subdir" = .; then :; else \
 	    test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
-   fi; \
+	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
+top_distdir = .
 distdir = $(PACKAGE)-$(VERSION)
-top_distdir = $(distdir)
+
+am__remove_distdir = \
+  { test ! -d $(distdir) \
+    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr $(distdir); }; }
+
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	mkdir $(distdir)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d $(distdir)/$$subdir \
+	    || mkdir $(distdir)/$$subdir \
+	    || exit 1; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$(top_distdir)" \
+	        distdir=../$(distdir)/$$subdir \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+	$(MAKE) $(AM_MAKEFLAGS) \
+	  top_distdir="$(top_distdir)" distdir="$(distdir)" \
+	  dist-hook
+	-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r $(distdir)
+dist-gzip: distdir
+	$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+
+dist dist-all: distdir
+	$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
 
 # This target untars the dist file and tries a VPATH configuration.  Then
 # it guarantees that the distribution is self-contained by making another
 # tarfile.
 distcheck: dist
-	-rm -rf $(distdir)
-	GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+	$(am__remove_distdir)
+	GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
+	chmod -R a-w $(distdir); chmod a+w $(distdir)
 	mkdir $(distdir)/=build
 	mkdir $(distdir)/=inst
-	dc_install_base=`cd $(distdir)/=inst && pwd`; \
-	cd $(distdir)/=build \
-	  && ../configure --srcdir=.. --prefix=$$dc_install_base \
+	chmod a-w $(distdir)
+	dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \
+	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+	  && cd $(distdir)/=build \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(DISTCHECK_CONFIGURE_FLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
 	  && $(MAKE) $(AM_MAKEFLAGS) install \
 	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
-	  && $(MAKE) $(AM_MAKEFLAGS) dist
-	-rm -rf $(distdir)
-	@banner="$(distdir).tar.gz is ready for distribution"; \
-	dashes=`echo "$$banner" | sed s/./=/g`; \
-	echo "$$dashes"; \
-	echo "$$banner"; \
-	echo "$$dashes"
-dist: distdir
-	-chmod -R a+r $(distdir)
-	GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-	-rm -rf $(distdir)
-dist-all: distdir
-	-chmod -R a+r $(distdir)
-	GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-	-rm -rf $(distdir)
-distdir: $(DISTFILES)
-	-rm -rf $(distdir)
-	mkdir $(distdir)
-	-chmod 777 $(distdir)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
-	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
-	  fi; \
-	done
-	for subdir in $(SUBDIRS); do \
-	  if test "$$subdir" = .; then :; else \
-	    test -d $(distdir)/$$subdir \
-	    || mkdir $(distdir)/$$subdir \
-	    || exit 1; \
-	    chmod 777 $(distdir)/$$subdir; \
-	    (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
-	      || exit 1; \
-	  fi; \
-	done
-	$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook
-info-am:
-info: info-recursive
-dvi-am:
-dvi: dvi-recursive
+	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+	        distuninstallcheck \
+	  && chmod -R a-w "$$dc_install_base" \
+	  && ({ \
+	       (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
+	  && rm -rf "$$dc_destdir" \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
+	  && rm -f $(distdir).tar.gz \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+	$(am__remove_distdir)
+	@echo "$(distdir).tar.gz is ready for distribution" | \
+	  sed 'h;s/./=/g;p;x;p;x'
+distuninstallcheck:
+	cd $(distuninstallcheck_dir) \
+	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+	   || { echo "ERROR: files left after uninstall:" ; \
+	        if test -n "$(DESTDIR)"; then \
+	          echo "  (check DESTDIR support)"; \
+	        fi ; \
+	        $(distuninstallcheck_listfiles) ; \
+	        exit 1; } >&2
+distcleancheck: distclean
+	if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
 check-am: all-am
 check: check-recursive
-installcheck-am:
-installcheck: installcheck-recursive
-install-exec-am:
-install-exec: install-exec-recursive
-
-install-data-am:
-install-data: install-data-recursive
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-recursive
-uninstall-am:
-uninstall: uninstall-recursive
 all-am: Makefile $(DATA)
-all-redirect: all-recursive
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
 installdirs: installdirs-recursive
 installdirs-am:
 
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
 
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-hdr mostlyclean-tags mostlyclean-generic
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-recursive
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf autom4te.cache
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
 mostlyclean: mostlyclean-recursive
 
-clean-am:  clean-hdr clean-tags clean-generic mostlyclean-am
+mostlyclean-am: mostlyclean-generic
 
-clean: clean-recursive
+pdf: pdf-recursive
 
-distclean-am:  distclean-hdr distclean-tags distclean-generic clean-am
+pdf-am:
 
-distclean: distclean-recursive
-	-rm -f config.status
+ps: ps-recursive
 
-maintainer-clean-am:  maintainer-clean-hdr maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+ps-am:
 
-maintainer-clean: maintainer-clean-recursive
-	-rm -f config.status
+uninstall-am: uninstall-info-am
 
-.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
-install-data-recursive uninstall-data-recursive install-exec-recursive \
-uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
-all-recursive check-recursive installcheck-recursive info-recursive \
-dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
-maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
-dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
-install-exec install-data-am install-data install-am install \
-uninstall-am uninstall all-redirect all-am all installdirs-am \
-installdirs mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+uninstall-info: uninstall-info-recursive
+
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
+	clean-generic clean-recursive ctags ctags-recursive dist \
+	dist-all dist-gzip distcheck distclean distclean-generic \
+	distclean-recursive distclean-tags distcleancheck distdir \
+	distuninstallcheck dvi dvi-am dvi-recursive info info-am \
+	info-recursive install install-am install-data install-data-am \
+	install-data-recursive install-exec install-exec-am \
+	install-exec-recursive install-info install-info-am \
+	install-info-recursive install-man install-recursive \
+	install-strip installcheck installcheck-am installdirs \
+	installdirs-am installdirs-recursive maintainer-clean \
+	maintainer-clean-generic maintainer-clean-recursive mostlyclean \
+	mostlyclean-generic mostlyclean-recursive pdf pdf-am \
+	pdf-recursive ps ps-am ps-recursive tags tags-recursive \
+	uninstall uninstall-am uninstall-info-am \
+	uninstall-info-recursive uninstall-recursive
 
 
 dist-hook:
 	cp -f reiserfsprogs.spec $(distdir)
-
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/README b/README
index 4254a42..baba6df 100644
--- a/README
+++ b/README
@@ -1,157 +1,47 @@
-[LICENSING] 
 
-ReiserFS is hereby licensed under the GNU General
-Public License version 2.
+Reiserfs is a file system based on balanced tree algorithms, which is described
+at www.namesys.com.
 
-Source code files that contain the phrase "licensing governed by
-reiserfs/README" are "governed files" throughout this file.  Governed
-files are licensed under the GPL.  The portions of them owned by Hans
-Reiser, or authorized to be licensed by him, have been in the past,
-and likely will be in the future, licensed to other parties under
-other licenses.  If you add your code to governed files, and don't
-want it to be owned by Hans Reiser, put your copyright label on that
-code so the poor blight and his customers can keep things straight.
-All portions of governed files not labeled otherwise are owned by Hans
-Reiser, and by adding your code to it, widely distributing it to
-others or sending us a patch, and leaving the sentence in stating that
-licensing is governed by the statement in this file, you accept this.
-It will be a kindness if you identify whether Hans Reiser is allowed
-to license code labeled as owned by you on your behalf other than
-under the GPL, because he wants to know if it is okay to do so and put
-a check in the mail to you (for non-trivial improvements) when he
-makes his next sale.  He makes no guarantees as to the amount if any,
-though he feels motivated to motivate contributors, and you can surely
-discuss this with him before or after contributing.  You have the
-right to decline to allow him to license your code contribution other
-than under the GPL.
+[LICENSING]
 
-Further licensing options are available for commercial and/or other
-interests directly from Hans Reiser: hans@reiser.to.  If you interpret
-the GPL as not allowing those additional licensing options, you read
-it wrongly, and Richard Stallman agrees with me, when carefully read
-you can see that those restrictions on additional terms do not apply
-to the owner of the copyright, and my interpretation of this shall
-govern for this license.  
+ReiserFSprogs is hereby licensed under the GNU General Public License version 2
+but with the following "Anti-Plagiarism" modification:   You may not remove any
+credits  or  brand marks,  or cause them to not display,  unless you are an end
+user  (that is,  you are not redistributing to others).  Yes,  there really are
+people with the nerve  to remove credits from software  they did not write,  or
+only wrote a small part of,  and they are even frequently occurring sad to say.
+Credits are not ads,  credits describe  someone's  contribution  to the project
+(e.g. labor or money) whereas an ad says something else.
 
-Finally, nothing in this license shall be interpreted to allow you to
-fail to fairly credit me, or to remove my credits, without my
-permission, unless you are an end user not redistributing to others.
-If you have doubts about how to properly do that, or about what is
-fair, ask.  (Last I spoke with him Richard was contemplating how best
-to address the fair crediting issue in the next GPL version.)
-
+Source   code   files   that   contain   the   phrase  "licensing  governed  by
+reiserfsprogs/README" are "governed files" throughout that file. Governed files
+are licensed under this license.  The portions of them owned by Hans Reiser, or
+authorized to be licensed by him, have been in the past,  and likely will be in
+the future,  licensed to other parties  under  other licenses.  If you add your
+code to governed files,  and don't want it to be owned by Hans Reiser, put your
+copyright label on that code  so  we  can  keep  things straight.  It will be a
+kindness if you identify whether Hans Reiser is allowed to license code labeled
+as owned by you on your behalf other than under this license,  because he wants
+to  know  if  it  is  okay  to  do  so and  put a check in the mail to you (for
+non-trivial improvements)  when he makes his next sale.  He makes no guarantees
+as to  the amount if any,  though he feels motivated  to motivate contributors,
+and you can surely discuss this with him before or after contributing. You have
+the right to decline  to allow him to license your code contribution other than
+under  this  license or the GPL.  Further  licensing  options are available for
+commercial and/or other interests directly from reiser@namesys.com<P>
 [END LICENSING]
 
-Reiserfs is a file system based on balanced tree algorithms, which is
-described at http://www.namesys.com .
+Send bug reports to reiserfs-dev@namesys.com.
 
-Stop reading here.  Go there, then return.
+Hideous  Commercial  Pitch: Spread  your  development  costs  across  other  OS
+vendors.  Select from the best in the world,  not the best in your building, by
+buying from third party OS component suppliers. Leverage the software component
+development power  of the internet.  Be the most aggressive in taking advantage
+of the commercial possibilities of decentralized internet development,  and add
+value through your branded integration  that  you  sell as an operating system. 
+Let your competitors  be the ones  to compete  against  the entire  internet by
+themselves.  Be hip,  get with the new economic trend,  before your competitors 
+do. Send email to reiser@namesys.com.
 
-Send bug reports to yura@namesys.botik.ru.
-
-mkreiserfs and other utilities are in reiserfs/utils, or wherever your
-Linux provider put them.  There is some disagreement about how useful
-it is for users to get their fsck and mkreiserfs out of sync with the
-version of reiserfs that is in their kernel, with many important
-distributors wanting them out of sync.:-) Please try to remember to
-recompile and reinstall fsck and mkreiserfs with every update of
-reiserfs, this is a common source of confusion.  Note that some of the
-utilities cannot be compiled without accessing the balancing code
-which is in the kernel code, and relocating the utilities may require
-you to specify where that code can be found.
-
-Yes, if you update your reiserfs kernel module you do have to
-recompile your kernel, most of the time.  The errors you get will be
-quite cryptic if your forget to do so.
-
-Real users, as opposed to folks who want to hack and then understand
-what went wrong, will want REISERFS_CHECK off.
-
-Hideous Commercial Pitch: Spread your development costs across other OS
-vendors.  Select from the best in the world, not the best in your
-building, by buying from third party OS component suppliers.  Leverage
-the software component development power of the internet.  Be the most
-aggressive in taking advantage of the commercial possibilities of
-decentralized internet development, and add value through your branded
-integration that you sell as an operating system.  Let your competitors
-be the ones to compete against the entire internet by themselves.  Be
-hip, get with the new economic trend, before your competitors do.  Send
-email to hans@reiser.to.
-
-To understand the code, after reading the website, start reading the
-code by reading reiserfs_fs.h first.
-
-Hans Reiser was the project initiator, primary architect, source of all
-funding for the first 5.5 years, and one of the programmers.  He owns
-the copyright.
-
-Vladimir Saveljev was one of the programmers, and he worked long hours
-writing the cleanest code.  He always made the effort to be the best he
-could be, and to make his code the best that it could be.  What resulted
-was quite remarkable. I don't think that money can ever motivate someone
-to work the way he did, he is one of the most selfless men I know.
-
-Yura helps with benchmarking, coding hashes, and block pre-allocation
-code.
-
-Anatoly Pinchuk is a former member of our team who worked closely with
-Vladimir throughout the project's development.  He wrote a quite
-substantial portion of the total code.  He realized that there was a
-space problem with packing tails of files for files larger than a node
-that start on a node aligned boundary (there are reasons to want to node
-align files), and he invented and implemented indirect items and
-unformatted nodes as the solution.
-
-Konstantin Shvachko, with the help of the Russian version of a VC,
-tried to put me in a position where I was forced into giving control
-of the project to him.  (Fortunately, as the person paying the money
-for all salaries from my dayjob I owned all copyrights, and you can't
-really force takeovers of sole proprietorships.)  This was something
-curious, because he never really understood the value of our project,
-why we should do what we do, or why innovation was possible in
-general, but he was sure that he ought to be controlling it.  Every
-innovation had to be forced past him while he was with us.  He added
-two years to the time required to complete reiserfs, and was a net
-loss for me.  Mikhail Gilula was a brilliant innovator who also left
-in a destructive way that erased the value of his contributions, and
-that he was shown much generosity just makes it more painful.
-
-Grigory Zaigralin was an extremely effective system administrator for
-our group.
-
-Igor Krasheninnikov was wonderful at hardware procurement, repair, and
-network installation.
-
-Jeremy Fitzhardinge wrote the teahash.c code, and he gives credit to a
-textbook he got the algorithm from in the code.  Note that his analysis
-of how we could use the hashing code in making 32 bit NFS cookies work
-was probably more important than the actual algorithm.  Colin Plumb also
-contributed to it.
-
-Chris Mason dived right into our code, and in just a few months produced
-the journaling code that dramatically increased the value of ReiserFS.
-He is just an amazing programmer.
-
-Igor Zagorovsky is writing much of the new item handler and extent code
-for our next major release.
-
-Alexander Zarochentcev (sometimes known as zam, or sasha), wrote the
-resizer, and is hard at work on implementing allocate on flush.  SGI
-implemented allocate on flush before us for XFS, and generously took
-the time to convince me we should do it also.  They are great people,
-and a great company.
-
-Yuri Shevchuk and Nikita Danilov are doing squid cache optimization.
-
-Vitaly Fertman is doing fsck.
-
-SuSE, IntegratedLinux.com, Ecila, MP3.com, bigstorage.com, and the
-Alpha PC Company made it possible for me to not have a day job
-anymore, and to dramatically increase our staffing.  Ecila funded
-hypertext feature development, MP3.com funded journaling, SuSE funded
-core development, IntegratedLinux.com funded squid web cache
-appliances, bigstorage.com funded HSM, and the alpha PC company funded
-the alpha port.  Many of these tasks were helped by sponsors other
-than the ones just named.  SuSE has helped in much more than just
-funding....
-
+To understand the code,  after reading the website,  start reading  the code by
+reading reiserfs_fs.h first.
diff --git a/acconfig.h b/acconfig.h
deleted file mode 100644
index 37eddd1..0000000
--- a/acconfig.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * Copyright 1996, 1997 Hans Reiser, see reiserfs/README for licensing and copyright details
- */
diff --git a/aclocal.m4 b/aclocal.m4
index c461ff3..057771e 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,70 +1,255 @@
-dnl aclocal.m4 generated automatically by aclocal 1.4-p5
+# generated automatically by aclocal 1.7.2 -*- Autoconf -*-
 
-dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-dnl PARTICULAR PURPOSE.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
-# Do all the work for Automake.  This macro actually does too much --
-# some checks are only needed if your package does certain things.
-# But this isn't really a big deal.
+# Do all the work for Automake.                            -*- Autoconf -*-
 
-# serial 1
+# This macro actually does too much some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
 
-dnl Usage:
-dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 8
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+AC_PREREQ([2.54])
+
+# Autoconf 2.50 wants to disallow AM_ names.  We explicitly allow
+# the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_REQUIRE([AC_PROG_INSTALL])
-PACKAGE=[$1]
-AC_SUBST(PACKAGE)
-VERSION=[$2]
-AC_SUBST(VERSION)
-dnl test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+ AC_REQUIRE([AC_PROG_INSTALL])dnl
+# test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+   test -f $srcdir/config.status; then
   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
 fi
-ifelse([$3],,
-AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
-AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
-AC_REQUIRE([AM_SANITY_CHECK])
-AC_REQUIRE([AC_ARG_PROGRAM])
-dnl FIXME This is truly gross.
-missing_dir=`cd $ac_aux_dir && pwd`
-AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
-AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
-AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
-AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
-AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
-AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+ AC_SUBST([PACKAGE], [AC_PACKAGE_TARNAME])dnl
+ AC_SUBST([VERSION], [AC_PACKAGE_VERSION])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_MISSING_PROG(AMTAR, tar)
+AM_PROG_INSTALL_SH
+AM_PROG_INSTALL_STRIP
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                  [_AM_DEPENDENCIES(CC)],
+                  [define([AC_PROG_CC],
+                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                  [_AM_DEPENDENCIES(CXX)],
+                  [define([AC_PROG_CXX],
+                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+])
+])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[_am_stamp_count=`expr ${_am_stamp_count-0} + 1`
+echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
+
+# Copyright 2002  Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION so it can be traced.
+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+	 [AM_AUTOMAKE_VERSION([1.7.2])])
+
+# Helper functions for option handling.                    -*- Autoconf -*-
+
+# Copyright 2001, 2002  Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
 #
 # Check to make sure that the build environment is sane.
 #
 
+# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_SANITY_CHECK
+# ---------------
 AC_DEFUN([AM_SANITY_CHECK],
 [AC_MSG_CHECKING([whether build environment is sane])
 # Just in case
 sleep 1
-echo timestamp > conftestfile
+echo timestamp > conftest.file
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
-   if test "[$]*" = "X"; then
+   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftestfile`
+      set X `ls -t $srcdir/configure conftest.file`
    fi
-   if test "[$]*" != "X $srcdir/configure conftestfile" \
-      && test "[$]*" != "X conftestfile $srcdir/configure"; then
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
 
       # If neither matched, then we have a broken ls.  This can happen
       # if, for instance, CONFIG_SHELL is bash and it inherits a
@@ -74,7 +259,7 @@
 alias in your environment])
    fi
 
-   test "[$]2" = conftestfile
+   test "$[2]" = conftest.file
    )
 then
    # Ok.
@@ -83,45 +268,544 @@
    AC_MSG_ERROR([newly created file is older than distributed files!
 Check your system clock])
 fi
-rm -f conftest*
 AC_MSG_RESULT(yes)])
 
-dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
-dnl The program must properly implement --version.
+#  -*- Autoconf -*-
+
+
+# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
 AC_DEFUN([AM_MISSING_PROG],
-[AC_MSG_CHECKING(for working $2)
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf.  Sigh.
-if ($2 --version) < /dev/null > /dev/null 2>&1; then
-   $1=$2
-   AC_MSG_RESULT(found)
-else
-   $1="$3/missing $2"
-   AC_MSG_RESULT(missing)
-fi
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
 AC_SUBST($1)])
 
-# Like AC_CONFIG_HEADER, but automatically create stamp file.
 
-AC_DEFUN([AM_CONFIG_HEADER],
-[AC_PREREQ([2.12])
-AC_CONFIG_HEADER([$1])
-dnl When config.status generates a header, we must update the stamp-h file.
-dnl This file resides in the same directory as the config header
-dnl that is generated.  We must strip everything past the first ":",
-dnl and everything past the last "/".
-AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
-ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
-<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
-<<am_indx=1
-for am_file in <<$1>>; do
-  case " <<$>>CONFIG_HEADERS " in
-  *" <<$>>am_file "*<<)>>
-    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
-    ;;
-  esac
-  am_indx=`expr "<<$>>am_indx" + 1`
-done<<>>dnl>>)
-changequote([,]))])
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# AM_AUX_DIR_EXPAND
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+# Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])
+
+AC_DEFUN([AM_AUX_DIR_EXPAND], [
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
+AC_SUBST(install_sh)])
+
+# AM_PROG_INSTALL_STRIP
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# serial 4						-*- Autoconf -*-
+
+# Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    echo '#include "conftest.h"' > conftest.c
+    echo 'int i;' > conftest.h
+    echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=conftest.c object=conftest.o \
+       depfile=conftest.Po tmpdepfile=conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c >/dev/null 2>&1 &&
+       grep conftest.h conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      am_cv_$1_dependencies_compiler_type=$depmode
+      break
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[rm -f .deps 2>/dev/null
+mkdir .deps 2>/dev/null
+if test -d .deps; then
+  DEPDIR=.deps
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  DEPDIR=_deps
+fi
+rmdir .deps 2>/dev/null
+AC_SUBST([DEPDIR])
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking Speeds up one-time builds
+  --enable-dependency-tracking  Do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])
+])
+
+# Generate code to set up dependency tracking.   -*- Autoconf -*-
+
+# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+#serial 2
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[for mf in $CONFIG_FILES; do
+  # Strip MF so we end up with the name of the file.
+  mf=`echo "$mf" | sed -e 's/:.*$//'`
+  # Check whether this is an Automake generated Makefile or not.
+  # We used to match only the files named `Makefile.in', but
+  # some people rename them; so instead we look at the file content.
+  # Grep'ing the first line is not enough: some people post-process
+  # each Makefile.in and add a new line on top of each file to say so.
+  # So let's grep whole file.
+  if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+    dirpart=`AS_DIRNAME("$mf")`
+  else
+    continue
+  fi
+  grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
+  # Extract the definition of DEP_FILES from the Makefile without
+  # running `make'.
+  DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n -e '/^U = / s///p' < "$mf"`
+  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
+  # We invoke sed twice because it is the simplest approach to
+  # changing $(DEPDIR) to its actual value in the expansion.
+  for file in `sed -n -e '
+    /^DEP_FILES = .*\\\\$/ {
+      s/^DEP_FILES = //
+      :loop
+	s/\\\\$//
+	p
+	n
+	/\\\\$/ b loop
+      p
+    }
+    /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+    # Make sure the directory exists.
+    test -f "$dirpart/$file" && continue
+    fdir=`AS_DIRNAME(["$file"])`
+    AS_MKDIR_P([$dirpart/$fdir])
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Check to see how 'make' treats includes.	-*- Autoconf -*-
+
+# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+doit:
+	@echo done
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+   am__include=include
+   am__quote=
+   _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+      am__include=.include
+      am__quote="\""
+      _am_result=BSD
+   fi
+fi
+AC_SUBST(am__include)
+AC_SUBST(am__quote)
+AC_MSG_RESULT($_am_result)
+rm -f confinc confmf
+])
+
+# AM_CONDITIONAL                                              -*- Autoconf -*-
+
+# Copyright 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 5
+
+AC_PREREQ(2.52)
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+        [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])
+AC_SUBST([$1_FALSE])
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.])
+fi])])
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
+
+# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_PREREQ([2.52])
+
+# serial 6
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
 
diff --git a/configure b/configure
index c7e9a02..abd1644 100755
--- a/configure
+++ b/configure
@@ -1,12 +1,81 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by Autoconf 2.52.
+# Generated by GNU Autoconf 2.57.
 #
-# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
 # Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
 
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)$' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\/\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
 # Avoid depending upon Character Ranges.
 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
@@ -14,22 +83,113 @@
 as_cr_digits='0123456789'
 as_cr_alnum=$as_cr_Letters$as_cr_digits
 
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
-  set -o posix
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
 fi
 
-# Name of the executable.
-as_me=`echo "$0" |sed 's,.*[\\/],,'`
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  case $0 in
+    *[\\/]* ) as_myself=$0 ;;
+    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+       ;;
+  esac
+  # We did not find ourselves, most probably we were run as `sh COMMAND'
+  # in which case we are not to be found in the path.
+  if test "x$as_myself" = x; then
+    as_myself=$0
+  fi
+  if test ! -f "$as_myself"; then
+    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+   { (exit 1); exit 1; }; }
+  fi
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+	 case $as_dir in
+	 /*)
+	   if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+	     CONFIG_SHELL=$as_dir/$as_base
+	     export CONFIG_SHELL
+	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+	   fi;;
+	 esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='	' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
 
 if expr a : '\(a\)' >/dev/null 2>&1; then
   as_expr=expr
@@ -55,24 +215,20 @@
 fi
 rm -f conf$$ conf$$.exe conf$$.file
 
-as_executable_p="test -f"
-
-# Support unset when possible.
-if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
-  as_unset=unset
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
 else
-  as_unset=false
+  as_mkdir_p=false
 fi
 
-# NLS nuisances.
-$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
-$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
-$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
-$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
-$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
-$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
-$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
-$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
 
 # IFS
 # We need space, tab and new line, in precisely that order.
@@ -81,7 +237,8 @@
 IFS=" 	$as_nl"
 
 # CDPATH.
-$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+$as_unset CDPATH
+
 
 # Name of the host.
 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
@@ -94,9 +251,11 @@
 # Initializations.
 #
 ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
 cross_compiling=no
 subdirs=
-MFLAGS= MAKEFLAGS=
+MFLAGS=
+MAKEFLAGS=
 SHELL=${CONFIG_SHELL-/bin/sh}
 
 # Maximum number of lines to put in a shell here document.
@@ -104,6 +263,13 @@
 # only ac_max_sed_lines should be used.
 : ${ac_max_here_lines=38}
 
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
 ac_unique_file="version.h"
 # Factoring default headers for most tests.
 ac_includes_default="\
@@ -142,6 +308,9 @@
 # include <unistd.h>
 #endif"
 
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB CPP EGREP LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
 # Initialize some variables set by options.
 ac_init_help=
 ac_init_version=false
@@ -180,13 +349,6 @@
 infodir='${prefix}/info'
 mandir='${prefix}/man'
 
-# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-
 ac_prev=
 for ac_option
 do
@@ -319,7 +481,7 @@
     with_fp=no ;;
 
   -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c)
+  | --no-cr | --no-c | -n)
     no_create=yes ;;
 
   -no-recursion | --no-recursion | --no-recursio | --no-recursi \
@@ -498,7 +660,7 @@
   eval ac_val=$`echo $ac_var`
   case $ac_val in
     [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
-    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
    { (exit 1); exit 1; }; };;
   esac
 done
@@ -510,18 +672,19 @@
   eval ac_val=$`echo $ac_var`
   case $ac_val in
     [\\/$]* | ?:[\\/]* ) ;;
-    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
    { (exit 1); exit 1; }; };;
   esac
 done
 
 # There might be people who depend on the old broken behavior: `$host'
 # used to hold the argument of --host etc.
+# FIXME: To remove some day.
 build=$build_alias
 host=$host_alias
 target=$target_alias
 
-# FIXME: should be removed in autoconf 3.0.
+# FIXME: To remove some day.
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
@@ -537,13 +700,23 @@
 
 test "$silent" = yes && exec 6>/dev/null
 
+
 # Find the source files, if location was not specified.
 if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
   # Try the directory containing this script, then its parent.
-  ac_prog=$0
-  ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'`
-  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$0" : 'X\(//\)[^/]' \| \
+         X"$0" : 'X\(//\)$' \| \
+         X"$0" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
   srcdir=$ac_confdir
   if test ! -r $srcdir/$ac_unique_file; then
     srcdir=..
@@ -553,13 +726,16 @@
 fi
 if test ! -r $srcdir/$ac_unique_file; then
   if test "$ac_srcdir_defaulted" = yes; then
-    { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
    { (exit 1); exit 1; }; }
   else
-    { echo "$as_me: error: cannot find sources in $srcdir" >&2
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
    { (exit 1); exit 1; }; }
   fi
 fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+  { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+   { (exit 1); exit 1; }; }
 srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
 ac_env_build_alias_set=${build_alias+set}
 ac_env_build_alias_value=$build_alias
@@ -600,7 +776,7 @@
 if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
-  cat <<EOF
+  cat <<_ACEOF
 \`configure' configures this package to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -621,9 +797,9 @@
   -n, --no-create         do not create output files
       --srcdir=DIR        find the sources in DIR [configure dir or \`..']
 
-EOF
+_ACEOF
 
-  cat <<EOF
+  cat <<_ACEOF
 Installation directories:
   --prefix=PREFIX         install architecture-independent files in PREFIX
                           [$ac_default_prefix]
@@ -650,24 +826,26 @@
   --oldincludedir=DIR    C header files for non-gcc [/usr/include]
   --infodir=DIR          info documentation [PREFIX/info]
   --mandir=DIR           man documentation [PREFIX/man]
-EOF
+_ACEOF
 
-  cat <<\EOF
+  cat <<\_ACEOF
 
 Program names:
   --program-prefix=PREFIX            prepend PREFIX to installed program names
   --program-suffix=SUFFIX            append SUFFIX to installed program names
   --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
-EOF
+_ACEOF
 fi
 
 if test -n "$ac_init_help"; then
 
-  cat <<\EOF
+  cat <<\_ACEOF
 
 Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-dependency-tracking Speeds up one-time builds
+  --enable-dependency-tracking  Do not reject slow dependency extractors
   --enable-io-failure-emulation      Never use that. It is for debugging only
 
 Some influential environment variables:
@@ -682,40 +860,60 @@
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
-EOF
+_ACEOF
 fi
 
 if test "$ac_init_help" = "recursive"; then
   # If there are subdirs, report their specific --help.
   ac_popdir=`pwd`
-  for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue
-    cd $ac_subdir
-    # A "../" for each directory in /$ac_subdir.
-    ac_dots=`echo $ac_subdir |
-             sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'`
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d $ac_dir || continue
+    ac_builddir=.
 
-    case $srcdir in
-    .) # No --srcdir option.  We are building in place.
-      ac_sub_srcdir=$srcdir ;;
-    [\\/]* | ?:[\\/]* ) # Absolute path.
-      ac_sub_srcdir=$srcdir/$ac_subdir ;;
-    *) # Relative path.
-      ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;;
-    esac
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
 
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+    cd $ac_dir
     # Check for guested configure; otherwise get Cygnus style configure.
-    if test -f $ac_sub_srcdir/configure.gnu; then
+    if test -f $ac_srcdir/configure.gnu; then
       echo
-      $SHELL $ac_sub_srcdir/configure.gnu  --help=recursive
-    elif test -f $ac_sub_srcdir/configure; then
+      $SHELL $ac_srcdir/configure.gnu  --help=recursive
+    elif test -f $ac_srcdir/configure; then
       echo
-      $SHELL $ac_sub_srcdir/configure  --help=recursive
-    elif test -f $ac_sub_srcdir/configure.ac ||
-           test -f $ac_sub_srcdir/configure.in; then
+      $SHELL $ac_srcdir/configure  --help=recursive
+    elif test -f $ac_srcdir/configure.ac ||
+           test -f $ac_srcdir/configure.in; then
       echo
       $ac_configure --help
     else
-      echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2
+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
     fi
     cd $ac_popdir
   done
@@ -723,31 +921,31 @@
 
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
-  cat <<\EOF
+  cat <<\_ACEOF
 
-Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
-EOF
+_ACEOF
   exit 0
 fi
 exec 5>config.log
-cat >&5 <<EOF
+cat >&5 <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.52.  Invocation command line was
+generated by GNU Autoconf 2.57.  Invocation command line was
 
   $ $0 $@
 
-EOF
+_ACEOF
 {
 cat <<_ASUNAME
-## ---------- ##
-## Platform.  ##
-## ---------- ##
+## --------- ##
+## Platform. ##
+## --------- ##
 
 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
 uname -m = `(uname -m) 2>/dev/null || echo unknown`
@@ -766,51 +964,96 @@
 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
 
-PATH = $PATH
-
 _ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  echo "PATH: $as_dir"
+done
+
 } >&5
 
-cat >&5 <<EOF
-## ------------ ##
-## Core tests.  ##
-## ------------ ##
+cat >&5 <<_ACEOF
 
-EOF
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
 
 # Keep a trace of the command line.
 # Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
 # Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
 ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
 ac_sep=
-for ac_arg
+ac_must_keep_next=false
+for ac_pass in 1 2
 do
-  case $ac_arg in
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c) ;;
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
-  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
-    ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
-    ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
-    ac_sep=" " ;;
-  *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg"
-     ac_sep=" " ;;
-  esac
-  # Get rid of the leading space.
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    2)
+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+        ac_must_keep_next=false # Got value, back to normal.
+      else
+        case $ac_arg in
+          *=* | --config-cache | -C | -disable-* | --disable-* \
+          | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+          | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+          | -with-* | --with-* | -without-* | --without-* | --x)
+            case "$ac_configure_args0 " in
+              "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+            esac
+            ;;
+          -* ) ac_must_keep_next=true ;;
+        esac
+      fi
+      ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+      # Get rid of the leading space.
+      ac_sep=" "
+      ;;
+    esac
+  done
 done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
 
 # When interrupted or exit'd, cleanup temporary files, and complete
 # config.log.  We remove comments because anyway the quotes in there
 # would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
 trap 'exit_status=$?
   # Save into config.log some information that might help in debugging.
-  echo >&5
-  echo "## ----------------- ##" >&5
-  echo "## Cache variables.  ##" >&5
-  echo "## ----------------- ##" >&5
-  echo >&5
-  # The following way of writing the cache mishandles newlines in values,
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
 {
   (set) 2>&1 |
     case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
@@ -824,21 +1067,53 @@
         "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
       ;;
     esac;
-} >&5
-  sed "/^$/d" confdefs.h >conftest.log
-  if test -s conftest.log; then
-    echo >&5
-    echo "## ------------ ##" >&5
-    echo "## confdefs.h.  ##" >&5
-    echo "## ------------ ##" >&5
-    echo >&5
-    cat conftest.log >&5
-  fi
-  (echo; echo) >&5
-  test "$ac_signal" != 0 &&
-    echo "$as_me: caught signal $ac_signal" >&5
-  echo "$as_me: exit $exit_status" >&5
-  rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files &&
+}
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=$`echo $ac_var`
+      echo "$ac_var='"'"'$ac_val'"'"'"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=$`echo $ac_var`
+        echo "$ac_var='"'"'$ac_val'"'"'"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      sed "/^$/d" confdefs.h | sort
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      echo "$as_me: caught signal $ac_signal"
+    echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core core.* *.core &&
+  rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
      ' 0
 for ac_signal in 1 2 13 15; do
@@ -851,6 +1126,33 @@
 # AIX cpp loses on an empty file, so make sure it contains at least a newline.
 echo >confdefs.h
 
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
 # Let the site file select an alternate cache file if it wants to.
 # Prefer explicitly selected file to automatically selected ones.
 if test -z "$CONFIG_SITE"; then
@@ -862,9 +1164,9 @@
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
-    { echo "$as_me:865: loading site script $ac_site_file" >&5
+    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
 echo "$as_me: loading site script $ac_site_file" >&6;}
-    cat "$ac_site_file" >&5
+    sed 's/^/| /' "$ac_site_file" >&5
     . "$ac_site_file"
   fi
 done
@@ -873,7 +1175,7 @@
   # Some versions of bash will fail to source /dev/null (special
   # files actually), so we avoid doing that.
   if test -f "$cache_file"; then
-    { echo "$as_me:876: loading cache $cache_file" >&5
+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
 echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . $cache_file;;
@@ -881,7 +1183,7 @@
     esac
   fi
 else
-  { echo "$as_me:884: creating cache $cache_file" >&5
+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
 echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
@@ -897,42 +1199,42 @@
   eval ac_new_val="\$ac_env_${ac_var}_value"
   case $ac_old_set,$ac_new_set in
     set,)
-      { echo "$as_me:900: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { echo "$as_me:904: error: \`$ac_var' was not set in the previous run" >&5
+      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
-        { echo "$as_me:910: error: \`$ac_var' has changed since the previous run:" >&5
+        { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-        { echo "$as_me:912:   former value:  $ac_old_val" >&5
+        { echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
 echo "$as_me:   former value:  $ac_old_val" >&2;}
-        { echo "$as_me:914:   current value: $ac_new_val" >&5
+        { echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
 echo "$as_me:   current value: $ac_new_val" >&2;}
         ac_cache_corrupted=:
       fi;;
   esac
-  # Pass precious variables to config.status.  It doesn't matter if
-  # we pass some twice (in addition to the command line arguments).
+  # Pass precious variables to config.status.
   if test "$ac_new_set" = set; then
     case $ac_new_val in
     *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
-      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"`
-      ac_configure_args="$ac_configure_args '$ac_arg'"
-      ;;
-    *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val"
-       ;;
+      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
     esac
   fi
 done
 if $ac_cache_corrupted; then
-  { echo "$as_me:933: error: changes in the environment can compromise the build" >&5
+  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
 echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:935: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -943,27 +1245,26 @@
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)      ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-echo "#! $SHELL" >conftest.sh
-echo  "exit 0"   >>conftest.sh
-chmod +x conftest.sh
-if { (echo "$as_me:955: PATH=\".;.\"; conftest.sh") >&5
-  (PATH=".;."; conftest.sh) 2>&5
-  ac_status=$?
-  echo "$as_me:958: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  ac_path_separator=';'
-else
-  ac_path_separator=:
-fi
-PATH_SEPARATOR="$ac_path_separator"
-rm -f conftest.sh
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+am__api_version="1.7"
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
   if test -f $ac_dir/install-sh; then
@@ -981,7 +1282,7 @@
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:984: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1001,43 +1302,48 @@
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:1004: checking for a BSD compatible install" >&5
-echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-    ac_save_IFS=$IFS; IFS=$ac_path_separator
-  for ac_dir in $PATH; do
-    IFS=$ac_save_IFS
-    # Account for people who put trailing slashes in PATH elements.
-    case $ac_dir/ in
-    / | ./ | .// | /cC/* \
-    | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \
-    | /usr/ucb/* ) ;;
-    *)
-      # OSF1 and SCO ODT 3.0 have their own names for install.
-      # Don't use installbsd from OSF since it installs stuff as root
-      # by default.
-      for ac_prog in ginstall scoinst install; do
-        if $as_executable_p "$ac_dir/$ac_prog"; then
-	  if test $ac_prog = install &&
-            grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then
-	    # AIX install.  It has an incompatible calling convention.
-	    :
-	  elif test $ac_prog = install &&
-	    grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then
-	    # program-specific install script used by HP pwplus--don't use.
-	    :
-	  else
-	    ac_cv_path_install="$ac_dir/$ac_prog -c"
-	    break 2
-	  fi
-	fi
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+        if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+          if test $ac_prog = install &&
+            grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+            # AIX install.  It has an incompatible calling convention.
+            :
+          elif test $ac_prog = install &&
+            grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+            # program-specific install script used by HP pwplus--don't use.
+            :
+          else
+            ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+            break 3
+          fi
+        fi
       done
-      ;;
-    esac
-  done
+    done
+    ;;
+esac
+done
+
 
 fi
   if test "${ac_cv_path_install+set}" = set; then
@@ -1050,7 +1356,7 @@
     INSTALL=$ac_install_sh
   fi
 fi
-echo "$as_me:1053: result: $INSTALL" >&5
+echo "$as_me:$LINENO: result: $INSTALL" >&5
 echo "${ECHO_T}$INSTALL" >&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
@@ -1061,50 +1367,50 @@
 
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
-echo "$as_me:1064: checking whether build environment is sane" >&5
+echo "$as_me:$LINENO: checking whether build environment is sane" >&5
 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
 # Just in case
 sleep 1
-echo timestamp > conftestfile
+echo timestamp > conftest.file
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
    if test "$*" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftestfile`
+      set X `ls -t $srcdir/configure conftest.file`
    fi
-   if test "$*" != "X $srcdir/configure conftestfile" \
-      && test "$*" != "X conftestfile $srcdir/configure"; then
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
 
       # If neither matched, then we have a broken ls.  This can happen
       # if, for instance, CONFIG_SHELL is bash and it inherits a
       # broken ls alias from the environment.  This has actually
       # happened.  Such a system could not be considered "sane".
-      { { echo "$as_me:1087: error: ls -t appears to fail.  Make sure there is not a broken
+      { { echo "$as_me:$LINENO: error: ls -t appears to fail.  Make sure there is not a broken
 alias in your environment" >&5
 echo "$as_me: error: ls -t appears to fail.  Make sure there is not a broken
 alias in your environment" >&2;}
    { (exit 1); exit 1; }; }
    fi
 
-   test "$2" = conftestfile
+   test "$2" = conftest.file
    )
 then
    # Ok.
    :
 else
-   { { echo "$as_me:1100: error: newly created file is older than distributed files!
+   { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
 Check your system clock" >&5
 echo "$as_me: error: newly created file is older than distributed files!
 Check your system clock" >&2;}
    { (exit 1); exit 1; }; }
 fi
-rm -f conftest*
-echo "$as_me:1107: result: yes" >&5
+echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 test "$program_prefix" != NONE &&
   program_transform_name="s,^,$program_prefix,;$program_transform_name"
@@ -1119,16 +1425,70 @@
 program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
 rm conftest.sed
 
-echo "$as_me:1122: checking whether ${MAKE-make} sets \${MAKE}" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
+echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AWK+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AWK="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  echo "$as_me:$LINENO: result: $AWK" >&5
+echo "${ECHO_T}$AWK" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$AWK" && break
+done
+
+echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
 if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.make <<\EOF
+  cat >conftest.make <<\_ACEOF
 all:
-	@echo 'ac_maketemp="${MAKE}"'
-EOF
+	@echo 'ac_maketemp="$(MAKE)"'
+_ACEOF
 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
 eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
 if test -n "$ac_maketemp"; then
@@ -1139,112 +1499,167 @@
 rm -f conftest.make
 fi
 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:1142: result: yes" >&5
+  echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
   SET_MAKE=
 else
-  echo "$as_me:1146: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
-PACKAGE=reiserfsprogs
-
-VERSION=3.6.4
-
-if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
-  { { echo "$as_me:1156: error: source directory already configured; run \"make distclean\" there first" >&5
+ # test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+   test -f $srcdir/config.status; then
+  { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
-cat >>confdefs.h <<EOF
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE=reiserfsprogs
+ VERSION=3.6.9
+
+
+cat >>confdefs.h <<_ACEOF
 #define PACKAGE "$PACKAGE"
-EOF
+_ACEOF
 
-cat >>confdefs.h <<EOF
+
+cat >>confdefs.h <<_ACEOF
 #define VERSION "$VERSION"
-EOF
+_ACEOF
 
-missing_dir=`cd $ac_aux_dir && pwd`
-echo "$as_me:1170: checking for working aclocal" >&5
-echo $ECHO_N "checking for working aclocal... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf.  Sigh.
-if (aclocal --version) < /dev/null > /dev/null 2>&1; then
-   ACLOCAL=aclocal
-   echo "$as_me:1177: result: found" >&5
-echo "${ECHO_T}found" >&6
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-   ACLOCAL="$missing_dir/missing aclocal"
-   echo "$as_me:1181: result: missing" >&5
-echo "${ECHO_T}missing" >&6
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:1185: checking for working autoconf" >&5
-echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf.  Sigh.
-if (autoconf --version) < /dev/null > /dev/null 2>&1; then
-   AUTOCONF=autoconf
-   echo "$as_me:1192: result: found" >&5
-echo "${ECHO_T}found" >&6
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-   AUTOCONF="$missing_dir/missing autoconf"
-   echo "$as_me:1196: result: missing" >&5
-echo "${ECHO_T}missing" >&6
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:1200: checking for working automake" >&5
-echo $ECHO_N "checking for working automake... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf.  Sigh.
-if (automake --version) < /dev/null > /dev/null 2>&1; then
-   AUTOMAKE=automake
-   echo "$as_me:1207: result: found" >&5
-echo "${ECHO_T}found" >&6
+  STRIP=$ac_ct_STRIP
 else
-   AUTOMAKE="$missing_dir/missing automake"
-   echo "$as_me:1211: result: missing" >&5
-echo "${ECHO_T}missing" >&6
+  STRIP="$ac_cv_prog_STRIP"
 fi
 
-echo "$as_me:1215: checking for working autoheader" >&5
-echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf.  Sigh.
-if (autoheader --version) < /dev/null > /dev/null 2>&1; then
-   AUTOHEADER=autoheader
-   echo "$as_me:1222: result: found" >&5
-echo "${ECHO_T}found" >&6
-else
-   AUTOHEADER="$missing_dir/missing autoheader"
-   echo "$as_me:1226: result: missing" >&5
-echo "${ECHO_T}missing" >&6
 fi
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
 
-echo "$as_me:1230: checking for working makeinfo" >&5
-echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6
-# Run test in a subshell; some versions of sh will print an error if
-# an executable is not found, even if stderr is redirected.
-# Redirect stdin to placate older versions of autoconf.  Sigh.
-if (makeinfo --version) < /dev/null > /dev/null 2>&1; then
-   MAKEINFO=makeinfo
-   echo "$as_me:1237: result: found" >&5
-echo "${ECHO_T}found" >&6
-else
-   MAKEINFO="$missing_dir/missing makeinfo"
-   echo "$as_me:1241: result: missing" >&5
-echo "${ECHO_T}missing" >&6
-fi
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
 
-ac_config_headers="$ac_config_headers include/config.h"
 
-ac_config_commands="$ac_config_commands default-1"
+
+
+
+          ac_config_headers="$ac_config_headers include/config.h"
+
+
+
 
 PRESET_CFLAGS=$CFLAGS
 ac_ext=c
@@ -1255,7 +1670,7 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:1258: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1263,25 +1678,28 @@
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_CC="${ac_tool_prefix}gcc"
-echo "$as_me:1273: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1281: result: $CC" >&5
+  echo "$as_me:$LINENO: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1284: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1290,7 +1708,7 @@
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo "$as_me:1293: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1298,25 +1716,28 @@
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_CC="gcc"
-echo "$as_me:1308: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1316: result: $ac_ct_CC" >&5
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1319: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1329,7 +1750,7 @@
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:1332: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1337,25 +1758,28 @@
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_CC="${ac_tool_prefix}cc"
-echo "$as_me:1347: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1355: result: $CC" >&5
+  echo "$as_me:$LINENO: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1358: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1364,7 +1788,7 @@
   ac_ct_CC=$CC
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1367: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1372,25 +1796,28 @@
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_CC="cc"
-echo "$as_me:1382: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1390: result: $ac_ct_CC" >&5
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1393: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1403,7 +1830,7 @@
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1406: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1412,19 +1839,22 @@
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
   ac_prog_rejected=no
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
-  ac_prog_rejected=yes
-  continue
-fi
-ac_cv_prog_CC="cc"
-echo "$as_me:1426: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 
 if test $ac_prog_rejected = yes; then
@@ -1436,19 +1866,17 @@
     # However, it has the same basename, so the bogon will be chosen
     # first if we set CC to just the basename; use the full file name.
     shift
-    set dummy "$ac_dir/$ac_word" ${1+"$@"}
-    shift
-    ac_cv_prog_CC="$@"
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
   fi
 fi
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1448: result: $CC" >&5
+  echo "$as_me:$LINENO: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1451: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1459,7 +1887,7 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:1462: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1467,25 +1895,28 @@
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-echo "$as_me:1477: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1485: result: $CC" >&5
+  echo "$as_me:$LINENO: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1488: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1498,7 +1929,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1501: checking for $ac_word" >&5
+echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1506,25 +1937,28 @@
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_CC="$ac_prog"
-echo "$as_me:1516: found $ac_dir/$ac_word" >&5
-break
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
 done
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1524: result: $ac_ct_CC" >&5
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1527: result: no" >&5
+  echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1536,33 +1970,40 @@
 
 fi
 
-test -z "$CC" && { { echo "$as_me:1539: error: no acceptable cc found in \$PATH" >&5
-echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }
 
 # Provide some information about the compiler.
-echo "$as_me:1544:" \
+echo "$as_me:$LINENO:" \
      "checking for C compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:1547: \"$ac_compiler --version </dev/null >&5\"") >&5
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1550: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:1552: \"$ac_compiler -v </dev/null >&5\"") >&5
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
   (eval $ac_compiler -v </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1555: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:1557: \"$ac_compiler -V </dev/null >&5\"") >&5
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
   (eval $ac_compiler -V </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1560: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 1564 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 int
 main ()
@@ -1573,100 +2014,120 @@
 }
 _ACEOF
 ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe"
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-echo "$as_me:1580: checking for C compiler default output" >&5
+echo "$as_me:$LINENO: checking for C compiler default output" >&5
 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:1583: \"$ac_link_default\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
   (eval $ac_link_default) 2>&5
   ac_status=$?
-  echo "$as_me:1586: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   # Find the output, starting from the most likely.  This scheme is
 # not robust to junk in `.', hence go to wildcards (a.*) only as a last
 # resort.
-for ac_file in `ls a.exe conftest.exe 2>/dev/null;
-                ls a.out conftest 2>/dev/null;
-                ls a.* conftest.* 2>/dev/null`; do
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+  test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
-    a.out ) # We found the default executable, but exeext='' is most
-            # certainly right.
-            break;;
-    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-          # FIXME: I believe we export ac_cv_exeext for Libtool --akim.
-          export ac_cv_exeext
-          break;;
-    * ) break;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+        ;;
+    conftest.$ac_ext )
+        # This is the source file.
+        ;;
+    [ab].out )
+        # We found the default executable, but exeext='' is most
+        # certainly right.
+        break;;
+    *.* )
+        ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+        # FIXME: I believe we export ac_cv_exeext for Libtool,
+        # but it would be cool to find out if it's true.  Does anybody
+        # maintain Libtool? --akim.
+        export ac_cv_exeext
+        break;;
+    * )
+        break;;
   esac
 done
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-{ { echo "$as_me:1609: error: C compiler cannot create executables" >&5
-echo "$as_me: error: C compiler cannot create executables" >&2;}
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
    { (exit 77); exit 77; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
-echo "$as_me:1615: result: $ac_file" >&5
+echo "$as_me:$LINENO: result: $ac_file" >&5
 echo "${ECHO_T}$ac_file" >&6
 
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1620: checking whether the C compiler works" >&5
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if { ac_try='./$ac_file'
-  { (eval echo "$as_me:1626: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1629: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { echo "$as_me:1636: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'." >&5
+	{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
 echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'." >&2;}
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }
     fi
   fi
 fi
-echo "$as_me:1644: result: yes" >&5
+echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
-rm -f a.out a.exe conftest$ac_cv_exeext
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1651: checking whether we are cross compiling" >&5
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:1653: result: $cross_compiling" >&5
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
 echo "${ECHO_T}$cross_compiling" >&6
 
-echo "$as_me:1656: checking for executable suffix" >&5
-echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
-if { (eval echo "$as_me:1658: \"$ac_link\"") >&5
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:1661: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 # work properly (i.e., refer to `conftest.exe'), while it won't with
 # `rm'.
-for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
     *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
           export ac_cv_exeext
           break;;
@@ -1674,26 +2135,32 @@
   esac
 done
 else
-  { { echo "$as_me:1677: error: cannot compute EXEEXT: cannot compile and link" >&5
-echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
+  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f conftest$ac_cv_exeext
-echo "$as_me:1683: result: $ac_cv_exeext" >&5
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
 echo "${ECHO_T}$ac_cv_exeext" >&6
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-echo "$as_me:1689: checking for object suffix" >&5
-echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
 if test "${ac_cv_objext+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1695 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 int
 main ()
@@ -1704,40 +2171,47 @@
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:1707: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1710: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
        break;;
   esac
 done
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-{ { echo "$as_me:1722: error: cannot compute OBJEXT: cannot compile" >&5
-echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-echo "$as_me:1729: result: $ac_cv_objext" >&5
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
 echo "${ECHO_T}$ac_cv_objext" >&6
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-echo "$as_me:1733: checking whether we are using the GNU C compiler" >&5
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
 if test "${ac_cv_c_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1739 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 int
 main ()
@@ -1751,41 +2225,46 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1754: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1757: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1760: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1763: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_compiler_gnu=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 ac_compiler_gnu=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:1775: result: $ac_cv_c_compiler_gnu" >&5
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
 GCC=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
 CFLAGS="-g"
-echo "$as_me:1781: checking whether $CC accepts -g" >&5
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1787 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 int
 main ()
@@ -1796,26 +2275,27 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1799: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1802: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1805: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1808: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cc_g=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 ac_cv_prog_cc_g=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:1818: result: $ac_cv_prog_cc_g" >&5
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
@@ -1832,582 +2312,7 @@
     CFLAGS=
   fi
 fi
-# Some people use a C++ compiler to compile C.  Since we use `exit',
-# in C++ we need to declare it.  In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
-  choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1845: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:1848: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1851: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:1854: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  for ac_declaration in \
-   ''\
-   '#include <stdlib.h>' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
-#line 1866 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-$ac_declaration
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1879: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:1882: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1885: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:1888: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-continue
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
-#line 1898 "configure"
-#include "confdefs.h"
-$ac_declaration
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1910: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:1913: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1916: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:1919: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  break
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-if test "x" = "x$PRESET_CFLAGS"; then
-    CFLAGS="${RPM_OPT_FLAGS} $CFLAGS -Wall"
-fi
-
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:1953: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-echo "$as_me:1968: found $ac_dir/$ac_word" >&5
-break
-done
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  echo "$as_me:1976: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
-else
-  echo "$as_me:1979: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:1988: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-  ac_save_IFS=$IFS; IFS=$ac_path_separator
-ac_dummy="$PATH"
-for ac_dir in $ac_dummy; do
-  IFS=$ac_save_IFS
-  test -z "$ac_dir" && ac_dir=.
-  $as_executable_p "$ac_dir/$ac_word" || continue
-ac_cv_prog_ac_ct_RANLIB="ranlib"
-echo "$as_me:2003: found $ac_dir/$ac_word" >&5
-break
-done
-
-  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  echo "$as_me:2012: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
-else
-  echo "$as_me:2015: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  RANLIB=$ac_ct_RANLIB
-else
-  RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:2029: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2050 "configure"
-#include "confdefs.h"
-#include <assert.h>
-                     Syntax error
-_ACEOF
-if { (eval echo "$as_me:2055: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:2061: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether non-existent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2084 "configure"
-#include "confdefs.h"
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:2088: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:2094: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  # Broken: success on invalid input.
-continue
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-echo "$as_me:2131: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2141 "configure"
-#include "confdefs.h"
-#include <assert.h>
-                     Syntax error
-_ACEOF
-if { (eval echo "$as_me:2146: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:2152: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether non-existent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2175 "configure"
-#include "confdefs.h"
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:2179: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:2185: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  # Broken: success on invalid input.
-continue
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  :
-else
-  { { echo "$as_me:2213: error: C preprocessor \"$CPP\" fails sanity check" >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-echo "$as_me:2224: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2230 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-_ACEOF
-if { (eval echo "$as_me:2238: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:2244: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_cv_header_stdc=yes
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2266 "configure"
-#include "confdefs.h"
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "memchr" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2284 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "free" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2305 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
-                     || ('j' <= (c) && (c) <= 'r') \
-                     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-        || toupper (i) != TOUPPER (i))
-      exit(2);
-  exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:2331: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:2334: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:2336: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:2339: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_header_stdc=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:2352: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-for ac_header in fcntl.h limits.h malloc.h sys/ioctl.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:2365: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2371 "configure"
-#include "confdefs.h"
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:2375: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:2381: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
-echo "$as_me:2400: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-EOF
-
-fi
-done
-
-echo "$as_me:2410: checking for $CC option to accept ANSI C" >&5
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2415,8 +2320,12 @@
   ac_cv_prog_cc_stdc=no
 ac_save_CC=$CC
 cat >conftest.$ac_ext <<_ACEOF
-#line 2418 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -2464,22 +2373,23 @@
 do
   CC="$ac_save_CC $ac_arg"
   rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2467: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2470: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2473: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2476: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cc_stdc=$ac_arg
 break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 fi
 rm -f conftest.$ac_objext
 done
@@ -2490,22 +2400,1009 @@
 
 case "x$ac_cv_prog_cc_stdc" in
   x|xno)
-    echo "$as_me:2493: result: none needed" >&5
+    echo "$as_me:$LINENO: result: none needed" >&5
 echo "${ECHO_T}none needed" >&6 ;;
   *)
-    echo "$as_me:2496: result: $ac_cv_prog_cc_stdc" >&5
+    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
     CC="$CC $ac_cv_prog_cc_stdc" ;;
 esac
 
-echo "$as_me:2501: checking for an ANSI C-conforming const" >&5
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  for ac_declaration in \
+   ''\
+   '#include <stdlib.h>' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+rm -f .deps 2>/dev/null
+mkdir .deps 2>/dev/null
+if test -d .deps; then
+  DEPDIR=.deps
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  DEPDIR=_deps
+fi
+rmdir .deps 2>/dev/null
+
+
+          ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+doit:
+	@echo done
+END
+# If we don't find an include directive, just comment out the code.
+echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+   am__include=include
+   am__quote=
+   _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+      am__include=.include
+      am__quote="\""
+      _am_result=BSD
+   fi
+fi
+
+
+echo "$as_me:$LINENO: result: $_am_result" >&5
+echo "${ECHO_T}$_am_result" >&6
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then
+  enableval="$enable_dependency_tracking"
+
+fi;
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+
+
+if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+
+depcc="$CC"   am_compiler_list=
+
+echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    echo '#include "conftest.h"' > conftest.c
+    echo 'int i;' > conftest.h
+    echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=conftest.c object=conftest.o \
+       depfile=conftest.Po tmpdepfile=conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c >/dev/null 2>&1 &&
+       grep conftest.h conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      am_cv_CC_dependencies_compiler_type=$depmode
+      break
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+
+
+if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+if test "x" = "x$PRESET_CFLAGS"; then
+    CFLAGS="${RPM_OPT_FLAGS} $CFLAGS -Wall"
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  RANLIB=$ac_ct_RANLIB
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                   (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      exit(2);
+  exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+
+for ac_header in fcntl.h limits.h malloc.h sys/ioctl.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
 if test "${ac_cv_c_const+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 2507 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 int
 main ()
@@ -2562,36 +3459,37 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2565: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2568: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2571: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2574: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_const=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 ac_cv_c_const=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:2584: result: $ac_cv_c_const" >&5
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
 echo "${ECHO_T}$ac_cv_c_const" >&6
 if test $ac_cv_c_const = no; then
 
-cat >>confdefs.h <<\EOF
+cat >>confdefs.h <<\_ACEOF
 #define const
-EOF
+_ACEOF
 
 fi
 
-echo "$as_me:2594: checking for inline" >&5
+echo "$as_me:$LINENO: checking for inline" >&5
 echo $ECHO_N "checking for inline... $ECHO_C" >&6
 if test "${ac_cv_c_inline+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2599,105 +3497,68 @@
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat >conftest.$ac_ext <<_ACEOF
-#line 2602 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #ifndef __cplusplus
-static $ac_kw int static_foo () {return 0; }
-$ac_kw int foo () {return 0; }
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
 #endif
 
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2611: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2614: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2617: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2620: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_inline=$ac_kw; break
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 done
 
 fi
-echo "$as_me:2631: result: $ac_cv_c_inline" >&5
+echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
 echo "${ECHO_T}$ac_cv_c_inline" >&6
 case $ac_cv_c_inline in
   inline | yes) ;;
   no)
-cat >>confdefs.h <<\EOF
+cat >>confdefs.h <<\_ACEOF
 #define inline
-EOF
+_ACEOF
  ;;
-  *)  cat >>confdefs.h <<EOF
+  *)  cat >>confdefs.h <<_ACEOF
 #define inline $ac_cv_c_inline
-EOF
+_ACEOF
  ;;
 esac
 
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-                  inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:2652: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 2658 "configure"
-#include "confdefs.h"
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2664: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:2667: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2670: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:2673: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:2683: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-EOF
-
-fi
-done
-
-echo "$as_me:2693: checking for size_t" >&5
+echo "$as_me:$LINENO: checking for size_t" >&5
 echo $ECHO_N "checking for size_t... $ECHO_C" >&6
 if test "${ac_cv_type_size_t+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 2699 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 $ac_includes_default
 int
 main ()
@@ -2711,45 +3572,51 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2714: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2717: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2720: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2723: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_type_size_t=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 ac_cv_type_size_t=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:2733: result: $ac_cv_type_size_t" >&5
+echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
 echo "${ECHO_T}$ac_cv_type_size_t" >&6
 if test $ac_cv_type_size_t = yes; then
   :
 else
 
-cat >>confdefs.h <<EOF
+cat >>confdefs.h <<_ACEOF
 #define size_t unsigned
-EOF
+_ACEOF
 
 fi
 
-echo "$as_me:2745: checking for struct stat.st_rdev" >&5
+
+echo "$as_me:$LINENO: checking for struct stat.st_rdev" >&5
 echo $ECHO_N "checking for struct stat.st_rdev... $ECHO_C" >&6
 if test "${ac_cv_member_struct_stat_st_rdev+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 2751 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 $ac_includes_default
 int
 main ()
@@ -2762,83 +3629,133 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2765: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2768: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2771: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2774: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_member_struct_stat_st_rdev=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static struct stat ac_aggr;
+if (sizeof ac_aggr.st_rdev)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_member_struct_stat_st_rdev=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 ac_cv_member_struct_stat_st_rdev=no
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:2784: result: $ac_cv_member_struct_stat_st_rdev" >&5
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_rdev" >&5
 echo "${ECHO_T}$ac_cv_member_struct_stat_st_rdev" >&6
 if test $ac_cv_member_struct_stat_st_rdev = yes; then
 
-cat >>confdefs.h <<EOF
+cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_STAT_ST_RDEV 1
-EOF
+_ACEOF
 
-cat >>confdefs.h <<\EOF
+
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_ST_RDEV 1
-EOF
+_ACEOF
 
 fi
 
+
+
 if test $ac_cv_c_compiler_gnu = yes; then
-    echo "$as_me:2799: checking whether $CC needs -traditional" >&5
+    echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5
 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6
 if test "${ac_cv_prog_gcc_traditional+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
     ac_pattern="Autoconf.*'x'"
   cat >conftest.$ac_ext <<_ACEOF
-#line 2806 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <sgtty.h>
 Autoconf TIOCGETP
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "$ac_pattern" >/dev/null 2>&1; then
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then
   ac_cv_prog_gcc_traditional=yes
 else
   ac_cv_prog_gcc_traditional=no
 fi
 rm -f conftest*
 
+
   if test $ac_cv_prog_gcc_traditional = no; then
     cat >conftest.$ac_ext <<_ACEOF
-#line 2821 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <termio.h>
 Autoconf TCGETA
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "$ac_pattern" >/dev/null 2>&1; then
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then
   ac_cv_prog_gcc_traditional=yes
 fi
 rm -f conftest*
 
   fi
 fi
-echo "$as_me:2834: result: $ac_cv_prog_gcc_traditional" >&5
+echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5
 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
-echo "$as_me:2841: checking for working memcmp" >&5
+echo "$as_me:$LINENO: checking for working memcmp" >&5
 echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6
 if test "${ac_cv_func_memcmp_working+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2847,8 +3764,12 @@
   ac_cv_func_memcmp_working=no
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 2850 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 int
 main ()
@@ -2883,99 +3804,116 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:2886: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:2889: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:2891: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2894: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func_memcmp_working=yes
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
 ac_cv_func_memcmp_working=no
 fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
-echo "$as_me:2906: result: $ac_cv_func_memcmp_working" >&5
+echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5
 echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6
 test $ac_cv_func_memcmp_working = no && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
 
+
 for ac_func in strftime
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:2913: checking for $ac_func" >&5
+echo "$as_me:$LINENO: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 2919 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
+{
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
 char $ac_func ();
-char (*f) ();
-
-int
-main ()
-{
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-f = $ac_func;
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
 #endif
 
+int
+main ()
+{
+return f != $ac_func;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:2950: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:2953: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:2956: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2959: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 eval "$as_ac_var=no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:2969: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<EOF
+  cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-EOF
+_ACEOF
 
 else
   # strftime is in -lintl on SCO UNIX.
-echo "$as_me:2978: checking for strftime in -lintl" >&5
+echo "$as_me:$LINENO: checking for strftime in -lintl" >&5
 echo $ECHO_N "checking for strftime in -lintl... $ECHO_C" >&6
 if test "${ac_cv_lib_intl_strftime+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2983,8 +3921,12 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lintl  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 2986 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
@@ -3002,32 +3944,33 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:3005: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:3008: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:3011: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3014: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_intl_strftime=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 ac_cv_lib_intl_strftime=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:3025: result: $ac_cv_lib_intl_strftime" >&5
+echo "$as_me:$LINENO: result: $ac_cv_lib_intl_strftime" >&5
 echo "${ECHO_T}$ac_cv_lib_intl_strftime" >&6
 if test $ac_cv_lib_intl_strftime = yes; then
-  cat >>confdefs.h <<\EOF
+  cat >>confdefs.h <<\_ACEOF
 #define HAVE_STRFTIME 1
-EOF
+_ACEOF
 
 LIBS="-lintl $LIBS"
 fi
@@ -3035,225 +3978,385 @@
 fi
 done
 
+
 for ac_func in vprintf
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:3041: checking for $ac_func" >&5
+echo "$as_me:$LINENO: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 3047 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
+{
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
 char $ac_func ();
-char (*f) ();
-
-int
-main ()
-{
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-f = $ac_func;
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
 #endif
 
+int
+main ()
+{
+return f != $ac_func;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:3078: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:3081: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:3084: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3087: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 eval "$as_ac_var=no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:3097: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<EOF
+  cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-EOF
+_ACEOF
 
-echo "$as_me:3104: checking for _doprnt" >&5
+echo "$as_me:$LINENO: checking for _doprnt" >&5
 echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6
 if test "${ac_cv_func__doprnt+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 3110 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char _doprnt (); below.  */
-#include <assert.h>
+    which can conflict with char _doprnt (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
+{
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
 char _doprnt ();
-char (*f) ();
-
-int
-main ()
-{
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub__doprnt) || defined (__stub____doprnt)
 choke me
 #else
-f = _doprnt;
+char (*f) () = _doprnt;
+#endif
+#ifdef __cplusplus
+}
 #endif
 
+int
+main ()
+{
+return f != _doprnt;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:3141: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:3144: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:3147: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3150: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func__doprnt=yes
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 ac_cv_func__doprnt=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:3160: result: $ac_cv_func__doprnt" >&5
+echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5
 echo "${ECHO_T}$ac_cv_func__doprnt" >&6
 if test $ac_cv_func__doprnt = yes; then
 
-cat >>confdefs.h <<\EOF
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_DOPRNT 1
-EOF
+_ACEOF
 
 fi
 
 fi
 done
 
+
+
+
+
 for ac_func in strerror strstr strtol
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:3176: checking for $ac_func" >&5
+echo "$as_me:$LINENO: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 3182 "configure"
-#include "confdefs.h"
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
+{
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
 char $ac_func ();
-char (*f) ();
-
-int
-main ()
-{
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-f = $ac_func;
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
 #endif
 
+int
+main ()
+{
+return f != $ac_func;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:3213: \"$ac_link\"") >&5
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:3216: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:3219: \"$ac_try\"") >&5
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:3222: \$? = $ac_status" >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
   echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 eval "$as_ac_var=no"
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:3232: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<EOF
+  cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-EOF
+_ACEOF
 
 fi
 done
 
+
 # Check whether --enable-io-failure-emulation or --disable-io-failure-emulation was given.
 if test "${enable_io_failure_emulation+set}" = set; then
   enableval="$enable_io_failure_emulation"
    if test "$enableval" = "yes" ; then
     echo -e "\nCarefull! IO failure emulation is ON\n"
 
-cat >>confdefs.h <<\EOF
+cat >>confdefs.h <<\_ACEOF
 #define IO_FAILURE_EMULATION 1
-EOF
+_ACEOF
 
   fi
 
 fi;
 
-ac_config_files="$ac_config_files include/Makefile mkreiserfs/Makefile resize_reiserfs/Makefile fsck/Makefile lib/Makefile Makefile reiserfscore/Makefile debugreiserfs/Makefile tune/Makefile"
+
+
+
+
+echo "$as_me:$LINENO: checking for CREDITS" >&5
+echo $ECHO_N "checking for CREDITS... $ECHO_C" >&6
+
+if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#define _GNU_SOURSE
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+int main (void) {
+    FILE *fin, *fout;
+    char *line = NULL;
+    unsigned int len = 0;
+    int start, count;
+
+    if ((fin = fopen("CREDITS", "r")) == NULL) {
+	fprintf(stderr, "Error occured while openning the file 'CREDITS': "
+	    "%s.\n", strerror(errno));
+
+	return 1;
+    }
+
+    if ((fout = fopen("include/credits.h", "w")) == NULL) {
+	fprintf(stderr, "Error occured while openning the file 'credits.h': "
+	    "%s.\n", strerror(errno));
+
+	return 1;
+    }
+
+    /* Replicate the header. */
+    while (getline(&line, &len, fin) != -1) {
+	fprintf(fout, line);
+
+	if (!strcmp(line, "\n"))
+	    break;
+    }
+
+    fprintf(fout, "char *credits[] = {\n");
+
+    start = 2; count = 0;
+
+    while (getline(&line, &len, fin) != -1) {
+	if (!strcmp(line, "\n") || strlen(line) < 1) {
+	    start = 1;
+	    count++;
+	} else {
+	    if (!start)
+		fprintf(fout, "\t\\\" "\n");
+	    else if (start == 1)
+		fprintf(fout, ",\n\n");
+
+	    line[strlen(line) - 1] = 0;
+	    fprintf(fout, "\t\"%s\\\n\"", line);
+	    start = 0;
+	}
+    }
+
+    fprintf(fout, "\n};\n");
+    fprintf(fout, "#define CREDITS_COUNT %d\n", count);
+
+    free(line);
+    fclose(fin);
+    fclose(fout);
+
+    return 0;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6 ; exit
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+                                                                                                              ac_config_files="$ac_config_files include/Makefile mkreiserfs/Makefile resize_reiserfs/Makefile fsck/Makefile lib/Makefile Makefile reiserfscore/Makefile debugreiserfs/Makefile tune/Makefile tests/Makefile tests/PROGS/Makefile"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -3264,7 +4367,7 @@
 # config.status only pays attention to the cache file if you give it
 # the --recheck option to rerun configure.
 #
-# `ac_cv_env_foo' variables (set or unset) will be overriden when
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
 # loading this file, other *unset* `ac_cv_foo' will be assigned the
 # following values.
 
@@ -3299,7 +4402,7 @@
      t end
      /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
      : end' >>confcache
-if cmp -s $cache_file confcache; then :; else
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
   if test -w $cache_file; then
     test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
     cat confcache >$cache_file
@@ -3330,35 +4433,241 @@
 
 DEFS=-DHAVE_CONFIG_H
 
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_i=`echo "$ac_i" |
+         sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+  # 2. Add them.
+  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:3336: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
 echo "$as_me: creating $CONFIG_STATUS" >&6;}
 cat >$CONFIG_STATUS <<_ACEOF
 #! $SHELL
-# Generated automatically by configure.
+# Generated by $as_me.
 # Run this file to recreate the current configuration.
 # Compiler output produced by configure, useful for debugging
 # configure, is in config.log if it exists.
 
 debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
 SHELL=\${CONFIG_SHELL-$SHELL}
-ac_cs_invocation="\$0 \$@"
-
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
 # Be Bourne compatible
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
   NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
   set -o posix
 fi
 
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
 # Name of the executable.
-as_me=`echo "$0" |sed 's,.*[\\/],,'`
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)$' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\/\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  case $0 in
+    *[\\/]* ) as_myself=$0 ;;
+    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+       ;;
+  esac
+  # We did not find ourselves, most probably we were run as `sh COMMAND'
+  # in which case we are not to be found in the path.
+  if test "x$as_myself" = x; then
+    as_myself=$0
+  fi
+  if test ! -f "$as_myself"; then
+    { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+	 case $as_dir in
+	 /*)
+	   if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+	     CONFIG_SHELL=$as_dir/$as_base
+	     export CONFIG_SHELL
+	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+	   fi;;
+	 esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='	' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
 
 if expr a : '\(a\)' >/dev/null 2>&1; then
   as_expr=expr
@@ -3384,24 +4693,20 @@
 fi
 rm -f conf$$ conf$$.exe conf$$.file
 
-as_executable_p="test -f"
-
-# Support unset when possible.
-if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
-  as_unset=unset
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
 else
-  as_unset=false
+  as_mkdir_p=false
 fi
 
-# NLS nuisances.
-$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
-$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
-$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
-$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
-$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
-$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
-$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
-$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
 
 # IFS
 # We need space, tab and new line, in precisely that order.
@@ -3410,10 +4715,34 @@
 IFS=" 	$as_nl"
 
 # CDPATH.
-$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+$as_unset CDPATH
 
 exec 6>&1
 
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.  Logging --version etc. is OK.
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.57.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
 _ACEOF
 
 # Files that config.status was made for.
@@ -3433,7 +4762,7 @@
   echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
 fi
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 
 ac_cs_usage="\
 \`$as_me' instantiates files from templates according to the
@@ -3443,6 +4772,7 @@
 
   -h, --help       print this help, then exit
   -V, --version    print version number, then exit
+  -q, --quiet      do not print progress messages
   -d, --debug      don't remove temporary files
       --recheck    update $as_me by reconfiguring in the same conditions
   --file=FILE[:TEMPLATE]
@@ -3460,12 +4790,12 @@
 $config_commands
 
 Report bugs to <bug-autoconf@gnu.org>."
-EOF
+_ACEOF
 
-cat >>$CONFIG_STATUS <<EOF
+cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.52,
+configured by $0, generated by GNU Autoconf 2.57,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
@@ -3474,9 +4804,9 @@
 gives unlimited permission to copy, distribute and modify it."
 srcdir=$srcdir
 INSTALL="$INSTALL"
-EOF
+_ACEOF
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 # If no file are specified by the user, then we need to provide default
 # value.  By we need to know if files were specified by the user.
 ac_need_defaults=:
@@ -3486,30 +4816,30 @@
   --*=*)
     ac_option=`expr "x$1" : 'x\([^=]*\)='`
     ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
-    shift
-    set dummy "$ac_option" "$ac_optarg" ${1+"$@"}
-    shift
+    ac_shift=:
     ;;
-  -*);;
+  -*)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
   *) # This is not an option, so the user has probably given explicit
      # arguments.
+     ac_option=$1
      ac_need_defaults=false;;
   esac
 
-  case $1 in
+  case $ac_option in
   # Handling of the options.
-EOF
-cat >>$CONFIG_STATUS <<EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion"
-    exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;;
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+    ac_cs_recheck=: ;;
   --version | --vers* | -V )
     echo "$ac_cs_version"; exit 0 ;;
   --he | --h)
     # Conflict between --help and --header
-    { { echo "$as_me:3512: error: ambiguous option: $1
+    { { echo "$as_me:$LINENO: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -3519,16 +4849,19 @@
   --debug | --d* | -d )
     debug=: ;;
   --file | --fil | --fi | --f )
-    shift
-    CONFIG_FILES="$CONFIG_FILES $1"
+    $ac_shift
+    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
     ac_need_defaults=false;;
   --header | --heade | --head | --hea )
-    shift
-    CONFIG_HEADERS="$CONFIG_HEADERS $1"
+    $ac_shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
     ac_need_defaults=false;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
 
   # This is an error.
-  -*) { { echo "$as_me:3531: error: unrecognized option: $1
+  -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -3540,32 +4873,34 @@
   shift
 done
 
-exec 5>>config.log
-cat >&5 << _ACEOF
+ac_configure_extra_args=
 
-## ----------------------- ##
-## Running config.status.  ##
-## ----------------------- ##
-
-This file was extended by $as_me 2.52, executed with
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  > $ac_cs_invocation
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
 
 _ACEOF
-EOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+  echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
 
-cat >>$CONFIG_STATUS <<EOF
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
 #
 # INIT-COMMANDS section.
 #
 
-EOF
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
 
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
 for ac_config_target in $ac_config_targets
 do
   case "$ac_config_target" in
@@ -3579,9 +4914,11 @@
   "reiserfscore/Makefile" ) CONFIG_FILES="$CONFIG_FILES reiserfscore/Makefile" ;;
   "debugreiserfs/Makefile" ) CONFIG_FILES="$CONFIG_FILES debugreiserfs/Makefile" ;;
   "tune/Makefile" ) CONFIG_FILES="$CONFIG_FILES tune/Makefile" ;;
-  "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
+  "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
+  "tests/PROGS/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/PROGS/Makefile" ;;
+  "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
   "include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
-  *) { { echo "$as_me:3584: error: invalid argument: $ac_config_target" >&5
+  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
@@ -3597,6 +4934,9 @@
   test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
 fi
 
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
 # Create a temporary directory, and hook for its removal unless debugging.
 $debug ||
 {
@@ -3605,23 +4945,23 @@
 }
 
 # Create a (secure) tmp directory for tmp files.
-: ${TMPDIR=/tmp}
+
 {
-  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
+  tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
   test -n "$tmp" && test -d "$tmp"
 }  ||
 {
-  tmp=$TMPDIR/cs$$-$RANDOM
+  tmp=./confstat$$-$RANDOM
   (umask 077 && mkdir $tmp)
 } ||
 {
-   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+   echo "$me: cannot create a temporary directory in ." >&2
    { (exit 1); exit 1; }
 }
 
-EOF
+_ACEOF
 
-cat >>$CONFIG_STATUS <<EOF
+cat >>$CONFIG_STATUS <<_ACEOF
 
 #
 # CONFIG_FILES section.
@@ -3634,6 +4974,12 @@
   sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
    s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
 s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
 s,@exec_prefix@,$exec_prefix,;t t
 s,@prefix@,$prefix,;t t
 s,@program_transform_name@,$program_transform_name,;t t
@@ -3649,23 +4995,18 @@
 s,@oldincludedir@,$oldincludedir,;t t
 s,@infodir@,$infodir,;t t
 s,@mandir@,$mandir,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
 s,@build_alias@,$build_alias,;t t
 s,@host_alias@,$host_alias,;t t
 s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
 s,@ECHO_C@,$ECHO_C,;t t
 s,@ECHO_N@,$ECHO_N,;t t
 s,@ECHO_T@,$ECHO_T,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@DEFS@,$DEFS,;t t
 s,@LIBS@,$LIBS,;t t
 s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
 s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
 s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@CYGPATH_W@,$CYGPATH_W,;t t
 s,@PACKAGE@,$PACKAGE,;t t
 s,@VERSION@,$VERSION,;t t
 s,@ACLOCAL@,$ACLOCAL,;t t
@@ -3673,6 +5014,12 @@
 s,@AUTOMAKE@,$AUTOMAKE,;t t
 s,@AUTOHEADER@,$AUTOHEADER,;t t
 s,@MAKEINFO@,$MAKEINFO,;t t
+s,@AMTAR@,$AMTAR,;t t
+s,@install_sh@,$install_sh,;t t
+s,@STRIP@,$STRIP,;t t
+s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
+s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
+s,@AWK@,$AWK,;t t
 s,@SET_MAKE@,$SET_MAKE,;t t
 s,@CC@,$CC,;t t
 s,@CFLAGS@,$CFLAGS,;t t
@@ -3681,15 +5028,26 @@
 s,@ac_ct_CC@,$ac_ct_CC,;t t
 s,@EXEEXT@,$EXEEXT,;t t
 s,@OBJEXT@,$OBJEXT,;t t
+s,@DEPDIR@,$DEPDIR,;t t
+s,@am__include@,$am__include,;t t
+s,@am__quote@,$am__quote,;t t
+s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t
+s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t
+s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
+s,@CCDEPMODE@,$CCDEPMODE,;t t
+s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
+s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
 s,@RANLIB@,$RANLIB,;t t
 s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
 s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
 
-EOF
+_ACEOF
 
-  cat >>$CONFIG_STATUS <<\EOF
+  cat >>$CONFIG_STATUS <<\_ACEOF
   # Split the substitutions into bite-sized pieces for seds with
   # small command number limits, like on Digital OSF/1 and HP-UX.
   ac_max_sed_lines=48
@@ -3728,8 +5086,8 @@
   fi
 fi # test -n "$CONFIG_FILES"
 
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
   case $ac_file in
@@ -3743,7 +5101,8 @@
   esac
 
   # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
-  ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+  ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
          X"$ac_file" : 'X\(//\)[^/]' \| \
          X"$ac_file" : 'X\(//\)$' \| \
          X"$ac_file" : 'X\(/\)' \| \
@@ -3754,60 +5113,84 @@
   	  /^X\(\/\/\)$/{ s//\1/; q; }
   	  /^X\(\/\).*/{ s//\1/; q; }
   	  s/.*/./; q'`
-  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-    { case "$ac_dir" in
-  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
-  *)                      as_incr_dir=.;;
-esac
-as_dummy="$ac_dir"
-for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
-  case $as_mkdir_dir in
-    # Skip DOS drivespec
-    ?:) as_incr_dir=$as_mkdir_dir ;;
-    *)
-      as_incr_dir=$as_incr_dir/$as_mkdir_dir
-      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
-    ;;
-  esac
-done; }
-
-    ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
-    # A "../" for each directory in $ac_dir_suffix.
-    ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
+  { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
   else
-    ac_dir_suffix= ac_dots=
-  fi
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
 
-  case $srcdir in
-  .)  ac_srcdir=.
-      if test -z "$ac_dots"; then
-         ac_top_srcdir=.
-      else
-         ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
-      fi ;;
-  [\\/]* | ?:[\\/]* )
-      ac_srcdir=$srcdir$ac_dir_suffix;
-      ac_top_srcdir=$srcdir ;;
+  ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
   *) # Relative path.
-    ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_dots$srcdir ;;
-  esac
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
 
   case $INSTALL in
   [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
-  *) ac_INSTALL=$ac_dots$INSTALL ;;
+  *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
   esac
 
   if test x"$ac_file" != x-; then
-    { echo "$as_me:3802: creating $ac_file" >&5
+    { echo "$as_me:$LINENO: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
     rm -f "$ac_file"
   fi
   # Let's still pretend it is `configure' which instantiates (i.e., don't
   # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated automatically by config.status.  */
-  configure_input="Generated automatically from `echo $ac_file_in |
-                                                 sed 's,.*/,,'` by configure."
+  #    /* config.h.  Generated by config.status.  */
+  if test x"$ac_file" = x-; then
+    configure_input=
+  else
+    configure_input="$ac_file.  "
+  fi
+  configure_input=$configure_input"Generated from `echo $ac_file_in |
+                                     sed 's,.*/,,'` by configure."
 
   # First look for the input files in the build tree, otherwise in the
   # src tree.
@@ -3817,7 +5200,7 @@
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:3820: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -3830,23 +5213,29 @@
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:3833: error: cannot find input file: $f" >&5
+           { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
       esac
     done` || { (exit 1); exit 1; }
-EOF
-cat >>$CONFIG_STATUS <<EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
   sed "$ac_vpsub
 $extrasub
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 :t
 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
 s,@configure_input@,$configure_input,;t t
 s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
 s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
 s,@INSTALL@,$ac_INSTALL,;t t
 " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
   rm -f $tmp/stdin
@@ -3858,8 +5247,8 @@
   fi
 
 done
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 
 #
 # CONFIG_HEADER section.
@@ -3891,7 +5280,7 @@
   * )   ac_file_in=$ac_file.in ;;
   esac
 
-  test x"$ac_file" != x- && { echo "$as_me:3894: creating $ac_file" >&5
+  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
 
   # First look for the input files in the build tree, otherwise in the
@@ -3902,7 +5291,7 @@
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:3905: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -3915,7 +5304,7 @@
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:3918: error: cannot find input file: $f" >&5
+           { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -3924,7 +5313,7 @@
   # Remove the trailing spaces.
   sed 's/[ 	]*$//' $ac_file_inputs >$tmp/in
 
-EOF
+_ACEOF
 
 # Transform confdefs.h into two sed scripts, `conftest.defines' and
 # `conftest.undefs', that substitutes the proper values into
@@ -3940,16 +5329,16 @@
 # `end' is used to avoid that the second main sed command (meant for
 # 0-ary CPP macros) applies to n-ary macro definitions.
 # See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\EOF
+cat >confdef2sed.sed <<\_ACEOF
 s/[\\&,]/\\&/g
 s,[\\$`],\\&,g
 t clear
 : clear
-s,^[ 	]*#[ 	]*define[ 	][ 	]*\(\([^ 	(][^ 	(]*\)([^)]*)\)[ 	]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	(][^ 	(]*\)\(([^)]*)\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
 t end
 s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
 : end
-EOF
+_ACEOF
 # If some macros were called several times there might be several times
 # the same #defines, which is useless.  Nevertheless, we may not want to
 # sort them, since we want the *last* AC-DEFINE to be honored.
@@ -3960,14 +5349,14 @@
 # This sed command replaces #undef with comments.  This is necessary, for
 # example, in the case of _POSIX_SOURCE, which is predefined and required
 # on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\EOF
+cat >>conftest.undefs <<\_ACEOF
 s,^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-EOF
+_ACEOF
 
 # Break up conftest.defines because some shells have a limit on the size
 # of here documents, and old seds have small limits too (100 cmds).
 echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo '  if egrep "^[ 	]*#[ 	]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo '  if grep "^[ 	]*#[ 	]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
 echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
 echo '  :' >>$CONFIG_STATUS
 rm -f conftest.tail
@@ -3991,7 +5380,7 @@
   mv conftest.tail conftest.defines
 done
 rm -f conftest.defines
-echo '  fi # egrep' >>$CONFIG_STATUS
+echo '  fi # grep' >>$CONFIG_STATUS
 echo >>$CONFIG_STATUS
 
 # Break up conftest.undefs because some shells have a limit on the size
@@ -4019,23 +5408,24 @@
 done
 rm -f conftest.undefs
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
   # Let's still pretend it is `configure' which instantiates (i.e., don't
   # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated automatically by config.status.  */
+  #    /* config.h.  Generated by config.status.  */
   if test x"$ac_file" = x-; then
-    echo "/* Generated automatically by configure.  */" >$tmp/config.h
+    echo "/* Generated by configure.  */" >$tmp/config.h
   else
-    echo "/* $ac_file.  Generated automatically by configure.  */" >$tmp/config.h
+    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
   fi
   cat $tmp/in >>$tmp/config.h
   rm -f $tmp/in
   if test x"$ac_file" != x-; then
-    if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
-      { echo "$as_me:4035: $ac_file is unchanged" >&5
+    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
-      ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
          X"$ac_file" : 'X\(//\)[^/]' \| \
          X"$ac_file" : 'X\(//\)$' \| \
          X"$ac_file" : 'X\(/\)' \| \
@@ -4046,24 +5436,31 @@
   	  /^X\(\/\/\)$/{ s//\1/; q; }
   	  /^X\(\/\).*/{ s//\1/; q; }
   	  s/.*/./; q'`
-      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-        { case "$ac_dir" in
-  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
-  *)                      as_incr_dir=.;;
-esac
-as_dummy="$ac_dir"
-for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
-  case $as_mkdir_dir in
-    # Skip DOS drivespec
-    ?:) as_incr_dir=$as_mkdir_dir ;;
-    *)
-      as_incr_dir=$as_incr_dir/$as_mkdir_dir
-      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
-    ;;
-  esac
-done; }
+      { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
 
-      fi
       rm -f $ac_file
       mv $tmp/config.h $ac_file
     fi
@@ -4071,9 +5468,22 @@
     cat $tmp/config.h
     rm -f $tmp/config.h
   fi
+_am_stamp_count=`expr ${_am_stamp_count-0} + 1`
+echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
+$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X$ac_file : 'X\(//\)[^/]' \| \
+         X$ac_file : 'X\(//\)$' \| \
+         X$ac_file : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X$ac_file |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`/stamp-h$_am_stamp_count
 done
-EOF
-cat >>$CONFIG_STATUS <<\EOF
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 
 #
 # CONFIG_COMMANDS section.
@@ -4081,20 +5491,157 @@
 for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
   ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
   ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
+  ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
+$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_dest" : 'X\(//\)[^/]' \| \
+         X"$ac_dest" : 'X\(//\)$' \| \
+         X"$ac_dest" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_dest" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+  ac_builddir=.
 
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+
+  { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
+echo "$as_me: executing $ac_dest commands" >&6;}
   case $ac_dest in
-    default-1 ) test -z "$CONFIG_HEADERS" || echo timestamp > include/stamp-h ;;
+    depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
+  # Strip MF so we end up with the name of the file.
+  mf=`echo "$mf" | sed -e 's/:.*$//'`
+  # Check whether this is an Automake generated Makefile or not.
+  # We used to match only the files named `Makefile.in', but
+  # some people rename them; so instead we look at the file content.
+  # Grep'ing the first line is not enough: some people post-process
+  # each Makefile.in and add a new line on top of each file to say so.
+  # So let's grep whole file.
+  if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+    dirpart=`(dirname "$mf") 2>/dev/null ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$mf" : 'X\(//\)[^/]' \| \
+         X"$mf" : 'X\(//\)$' \| \
+         X"$mf" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+  else
+    continue
+  fi
+  grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
+  # Extract the definition of DEP_FILES from the Makefile without
+  # running `make'.
+  DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n -e '/^U = / s///p' < "$mf"`
+  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
+  # We invoke sed twice because it is the simplest approach to
+  # changing $(DEPDIR) to its actual value in the expansion.
+  for file in `sed -n -e '
+    /^DEP_FILES = .*\\\\$/ {
+      s/^DEP_FILES = //
+      :loop
+	s/\\\\$//
+	p
+	n
+	/\\\\$/ b loop
+      p
+    }
+    /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+    # Make sure the directory exists.
+    test -f "$dirpart/$file" && continue
+    fdir=`(dirname "$file") 2>/dev/null ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$file" : 'X\(//\)[^/]' \| \
+         X"$file" : 'X\(//\)$' \| \
+         X"$file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    { if $as_mkdir_p; then
+    mkdir -p $dirpart/$fdir
+  else
+    as_dir=$dirpart/$fdir
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5
+echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+ ;;
   esac
 done
-EOF
+_ACEOF
 
-cat >>$CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 
 { (exit 0); exit 0; }
-EOF
+_ACEOF
 chmod +x $CONFIG_STATUS
 ac_clean_files=$ac_clean_files_save
 
+
 # configure is writing to config.log, and then calls config.status.
 # config.status does its own redirection, appending to config.log.
 # Unfortunately, on DOS this fails, as config.log is still kept open
@@ -4105,8 +5652,11 @@
 # need to make the FD available again.
 if test "$no_create" != yes; then
   ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
   exec 5>/dev/null
-  $SHELL $CONFIG_STATUS || ac_cs_success=false
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
diff --git a/configure.in b/configure.in
index 13156ff..c91ad6c 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(version.h)
 
-AM_INIT_AUTOMAKE(reiserfsprogs, 3.6.4)
+AM_INIT_AUTOMAKE(reiserfsprogs, 3.6.9)
 
 dnl We install in /sbin, the utils are to be available on boot
 dnl AC_PREFIX(/)
@@ -50,4 +50,88 @@
   fi
 ])
 
-AC_OUTPUT(include/Makefile mkreiserfs/Makefile resize_reiserfs/Makefile fsck/Makefile lib/Makefile Makefile reiserfscore/Makefile debugreiserfs/Makefile tune/Makefile)
+AC_DEFUN(AC_PREPARE_CREDITS,
+[
+
+AC_MSG_CHECKING(for CREDITS)
+
+AC_TRY_RUN([
+#define _GNU_SOURSE
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+int main (void) {
+    FILE *fin, *fout;
+    char *line = NULL;
+    unsigned int len = 0;
+    int start, count;
+    
+    if ((fin = fopen("CREDITS", "r")) == NULL) {
+	fprintf(stderr, "Error occured while openning the file 'CREDITS': "
+	    "%s.\n", strerror(errno));
+
+	return 1;
+    }
+
+    if ((fout = fopen("include/credits.h", "w")) == NULL) {
+	fprintf(stderr, "Error occured while openning the file 'credits.h': "
+	    "%s.\n", strerror(errno));
+	
+	return 1;
+    }
+     
+    /* Replicate the header. */
+    while (getline(&line, &len, fin) != -1) {
+	fprintf(fout, line);
+	
+	if (!strcmp(line, "\n"))
+	    break;
+    }
+    
+    fprintf(fout, "char *credits[] = {\n");
+    
+    start = 2; count = 0;
+    
+    while (getline(&line, &len, fin) != -1) {
+	if (!strcmp(line, "\n") || strlen(line) < 1) {
+	    start = 1;
+	    count++;
+	} else {
+	    if (!start)
+		fprintf(fout, "\t\\\" "\n");
+	    else if (start == 1)
+		fprintf(fout, ",\n\n");
+	    
+	    line[strlen(line) - 1] = 0;
+	    fprintf(fout, "\t\"%s\\\n\"", line);
+	    start = 0;
+	}
+    }
+    
+    fprintf(fout, "\n};\n");
+    fprintf(fout, "#define CREDITS_COUNT %d\n", count);
+    
+    free(line);
+    fclose(fin);
+    fclose(fout);
+    
+    return 0;
+}
+], AC_MSG_RESULT(yes), AC_MSG_RESULT(no) ; exit)
+])
+
+AC_PREPARE_CREDITS()
+
+AC_OUTPUT(
+    include/Makefile 
+    mkreiserfs/Makefile 
+    resize_reiserfs/Makefile 
+    fsck/Makefile 
+    lib/Makefile 
+    Makefile 
+    reiserfscore/Makefile 
+    debugreiserfs/Makefile 
+    tune/Makefile 
+    tests/Makefile 
+    tests/PROGS/Makefile)
diff --git a/debugreiserfs/Makefile.am b/debugreiserfs/Makefile.am
index 8bec80f..2d8f9af 100644
--- a/debugreiserfs/Makefile.am
+++ b/debugreiserfs/Makefile.am
@@ -1,6 +1,6 @@
 sbin_PROGRAMS = debugreiserfs unpack
 
-debugreiserfs_SOURCES = debugreiserfs.c pack.c stat.c corruption.c scan.c recover.c journal.c
+debugreiserfs_SOURCES = debugreiserfs.c pack.c stat.c corruption.c scan.c recover.c
 unpack_SOURCES = unpack.c pack.c debugreiserfs.h
 man_MANS = debugreiserfs.8
 EXTRA_DIST = $(man_MANS)
diff --git a/debugreiserfs/Makefile.in b/debugreiserfs/Makefile.in
index 4c25cb4..823dd31 100644
--- a/debugreiserfs/Makefile.in
+++ b/debugreiserfs/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,174 +12,233 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 sbin_PROGRAMS = debugreiserfs unpack
 
-debugreiserfs_SOURCES = debugreiserfs.c pack.c stat.c corruption.c scan.c recover.c journal.c
+debugreiserfs_SOURCES = debugreiserfs.c pack.c stat.c corruption.c scan.c recover.c
 unpack_SOURCES = unpack.c pack.c debugreiserfs.h
 man_MANS = debugreiserfs.8
 EXTRA_DIST = $(man_MANS)
 
 LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+subdir = debugreiserfs
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../include/config.h
-CONFIG_CLEAN_FILES = 
-PROGRAMS =  $(sbin_PROGRAMS)
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+sbin_PROGRAMS = debugreiserfs$(EXEEXT) unpack$(EXEEXT)
+PROGRAMS = $(sbin_PROGRAMS)
 
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I../include
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-debugreiserfs_OBJECTS =  debugreiserfs.o pack.o stat.o corruption.o \
-scan.o recover.o journal.o
+am_debugreiserfs_OBJECTS = debugreiserfs.$(OBJEXT) pack.$(OBJEXT) \
+	stat.$(OBJEXT) corruption.$(OBJEXT) scan.$(OBJEXT) \
+	recover.$(OBJEXT)
+debugreiserfs_OBJECTS = $(am_debugreiserfs_OBJECTS)
 debugreiserfs_LDADD = $(LDADD)
-debugreiserfs_DEPENDENCIES =  $(top_srcdir)/lib/libmisc.a \
-$(top_srcdir)/reiserfscore/libcore.a
-debugreiserfs_LDFLAGS = 
-unpack_OBJECTS =  unpack.o pack.o
+debugreiserfs_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
+	$(top_srcdir)/reiserfscore/libcore.a
+debugreiserfs_LDFLAGS =
+am_unpack_OBJECTS = unpack.$(OBJEXT) pack.$(OBJEXT)
+unpack_OBJECTS = $(am_unpack_OBJECTS)
 unpack_LDADD = $(LDADD)
-unpack_DEPENDENCIES =  $(top_srcdir)/lib/libmisc.a \
-$(top_srcdir)/reiserfscore/libcore.a
-unpack_LDFLAGS = 
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+unpack_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
+	$(top_srcdir)/reiserfscore/libcore.a
+unpack_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/corruption.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/debugreiserfs.Po ./$(DEPDIR)/pack.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/recover.Po ./$(DEPDIR)/scan.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/stat.Po ./$(DEPDIR)/unpack.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-man8dir = $(mandir)/man8
-MANS = $(man_MANS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(debugreiserfs_SOURCES) $(unpack_SOURCES)
 
 NROFF = nroff
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
+MANS = $(man_MANS)
+DIST_COMMON = Makefile.am Makefile.in
 SOURCES = $(debugreiserfs_SOURCES) $(unpack_SOURCES)
-OBJECTS = $(debugreiserfs_OBJECTS) $(unpack_OBJECTS)
 
-all: all-redirect
+all: all-am
+
 .SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps debugreiserfs/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-sbinPROGRAMS:
-
-clean-sbinPROGRAMS:
-	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
-
-distclean-sbinPROGRAMS:
-
-maintainer-clean-sbinPROGRAMS:
-
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  debugreiserfs/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(sbindir)
 	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  if test -f $$p; then \
-	    echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
-	     $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \
 	  else :; fi; \
 	done
 
 uninstall-sbinPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
+	  rm -f $(DESTDIR)$(sbindir)/$$f; \
 	done
 
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+debugreiserfs$(EXEEXT): $(debugreiserfs_OBJECTS) $(debugreiserfs_DEPENDENCIES) 
+	@rm -f debugreiserfs$(EXEEXT)
+	$(LINK) $(debugreiserfs_LDFLAGS) $(debugreiserfs_OBJECTS) $(debugreiserfs_LDADD) $(LIBS)
+unpack$(EXEEXT): $(unpack_OBJECTS) $(unpack_DEPENDENCIES) 
+	@rm -f unpack$(EXEEXT)
+	$(LINK) $(unpack_LDFLAGS) $(unpack_OBJECTS) $(unpack_LDADD) $(LIBS)
 
 mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
+	-rm -f *.$(OBJEXT) core *.core
 
 distclean-compile:
 	-rm -f *.tab.c
 
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corruption.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debugreiserfs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recover.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unpack.Po@am__quote@
 
-debugreiserfs: $(debugreiserfs_OBJECTS) $(debugreiserfs_DEPENDENCIES)
-	@rm -f debugreiserfs
-	$(LINK) $(debugreiserfs_LDFLAGS) $(debugreiserfs_OBJECTS) $(debugreiserfs_LDADD) $(LIBS)
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
 
-unpack: $(unpack_OBJECTS) $(unpack_DEPENDENCIES)
-	@rm -f unpack
-	$(LINK) $(unpack_LDFLAGS) $(unpack_OBJECTS) $(unpack_LDADD) $(LIBS)
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
 
-install-man8:
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+man8dir = $(mandir)/man8
+install-man8: $(man8_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(man8dir)
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
@@ -186,173 +247,212 @@
 	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
 	  else file=$$i; fi; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \
 	  $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \
 	done
-
 uninstall-man8:
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@$(NORMAL_UNINSTALL)
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
 	done; \
 	for i in $$list; do \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \
 	  rm -f $(DESTDIR)$(man8dir)/$$inst; \
 	done
-install-man: $(MANS)
-	@$(NORMAL_INSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) install-man8
-uninstall-man:
-	@$(NORMAL_UNINSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) uninstall-man8
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = debugreiserfs
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-corruption.o: corruption.c debugreiserfs.h ../include/io.h \
-	../include/misc.h ../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-debugreiserfs.o: debugreiserfs.c debugreiserfs.h ../include/io.h \
-	../include/misc.h ../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-journal.o: journal.c debugreiserfs.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-pack.o: pack.c debugreiserfs.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-recover.o: recover.c debugreiserfs.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-scan.o: scan.c debugreiserfs.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-stat.o: stat.c debugreiserfs.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-unpack.o: unpack.c debugreiserfs.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am: install-sbinPROGRAMS
-install-exec: install-exec-am
+all-am: Makefile $(PROGRAMS) $(MANS)
 
-install-data-am: install-man
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir)
+
+install: install-am
+install-exec: install-exec-am
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-sbinPROGRAMS uninstall-man
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS) $(MANS)
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-	$(mkinstalldirs)  $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-sbinPROGRAMS mostlyclean-compile \
-		mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-sbinPROGRAMS clean-compile clean-tags clean-generic \
-		mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-sbinPROGRAMS distclean-compile distclean-tags \
-		distclean-generic clean-am
+clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-sbinPROGRAMS \
-		maintainer-clean-compile maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-exec-am: install-sbinPROGRAMS
+
+install-info: install-info-am
+
+install-man: install-man8
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
-clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
-install-sbinPROGRAMS mostlyclean-compile distclean-compile \
-clean-compile maintainer-clean-compile install-man8 uninstall-man8 \
-install-man uninstall-man tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-man uninstall-sbinPROGRAMS
+
+uninstall-man: uninstall-man8
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-sbinPROGRAMS ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-man8 install-sbinPROGRAMS \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-info-am uninstall-man \
+	uninstall-man8 uninstall-sbinPROGRAMS
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/debugreiserfs/corruption.c b/debugreiserfs/corruption.c
index a913bad..d6da7f5 100644
--- a/debugreiserfs/corruption.c
+++ b/debugreiserfs/corruption.c
@@ -1,9 +1,18 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "debugreiserfs.h"
 
+extern struct reiserfs_fsstat g_stat_info;
+
+int  do_one_ih_corrupt (struct item_head * ih, unsigned int nr_bytes);
+int  do_one_ih_random_corrupt (struct item_head * ih);
+
+void do_one_corruption_in_one_block (reiserfs_filsys_t * fs, struct buffer_head * bh, char * corruption_command);
+int corrupt_block_header (struct block_head * blkh, unsigned int offset, unsigned int bytes );
+void do_one_block_random_corrupt (struct buffer_head * bh);
 
 static int str2int (char * str, int * res)
 {
@@ -12,12 +21,23 @@
 
     val = (int) strtol (str, &tmp, 0);
     if (tmp == str)
-	/* could not convert string into a number */
-	return 0;
+		/* could not convert string into a number */
+		return 0;
     *res = val;
     return 1;
 }
 
+static int get_rand (double min, double max) {
+
+	/* srand (time (0)); */
+	int ret;
+
+	ret =  (int)(min + (int)((max - min + 1) * rand() / (RAND_MAX + 1.0)));
+	if ((ret < min) || (ret > max))
+		die ("get_rand failed: min %d, max %d, returned %d\n", (int)min, (int)max, ret);
+
+	return ret;
+}
 
 static void edit_journal_params (struct journal_params * jp)
 {
@@ -29,44 +49,43 @@
     printf ("\tDevice: current: %x: new:", get_jp_journal_dev (jp));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_jp_journal_dev (jp, num);
+		set_jp_journal_dev (jp, num);
 
     printf ("\tFirst block: current: %d: new:",
-	    get_jp_journal_1st_block (jp));
+			get_jp_journal_1st_block (jp));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_jp_journal_1st_block (jp, num);
+		set_jp_journal_1st_block (jp, num);
 
     printf ("\tSize: current: %d: new:", get_jp_journal_size (jp));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_jp_journal_size (jp, num);
+		set_jp_journal_size (jp, num);
 
     printf ("\tMagic number: current: %d: new:", get_jp_journal_magic (jp));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_jp_journal_magic (jp, num);
+		set_jp_journal_magic (jp, num);
 
     printf ("\tMax transaction size: current: %d: new:",
-	    get_jp_journal_max_trans_len (jp));
+			get_jp_journal_max_trans_len (jp));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_jp_journal_max_trans_len (jp, num);
+		set_jp_journal_max_trans_len (jp, num);
 
     printf ("\tMax batch size: current: %d: new:",
-	    get_jp_journal_max_batch (jp));
+			get_jp_journal_max_batch (jp));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_jp_journal_max_batch (jp, num);
+		set_jp_journal_max_batch (jp, num);
 
     printf ("\tMax commit age: current: %d: new:",
-	    get_jp_journal_max_commit_age (jp));
+			get_jp_journal_max_commit_age (jp));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_jp_journal_max_commit_age (jp, num);
+		set_jp_journal_max_commit_age (jp, num);
 }
 
-
 /* this allows to edit all super block fields */
 static void edit_super_block (reiserfs_filsys_t * fs)
 {
@@ -74,124 +93,122 @@
     size_t n;
     int num;
 
-
     str = 0;
     n = 0;
 
     /* bs_block_count */
     printf ("\tBlock count: current: %u: new:",
-	    get_sb_block_count (fs->fs_ondisk_sb));
+			get_sb_block_count (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_block_count (fs->fs_ondisk_sb, num);
+		set_sb_block_count (fs->fs_ondisk_sb, num);
 
     
     /* sb_free_blocks */
     printf ("\tFree block count: current: %u: new:",
-	    get_sb_free_blocks (fs->fs_ondisk_sb));
+			get_sb_free_blocks (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_free_blocks (fs->fs_ondisk_sb, num);
+		set_sb_free_blocks (fs->fs_ondisk_sb, num);
 
     /* sb_root_block */
     printf ("\tRoot block: current: %u: new:",
-	    get_sb_root_block (fs->fs_ondisk_sb));
+			get_sb_root_block (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_root_block (fs->fs_ondisk_sb, num);
+		set_sb_root_block (fs->fs_ondisk_sb, num);
 
     /* sb_journal */
     edit_journal_params (sb_jp (fs->fs_ondisk_sb));
     
     /* sb_blocksize */
     printf ("\tBlocksize: current: %u: new:",
-	    get_sb_block_size (fs->fs_ondisk_sb));
+			get_sb_block_size (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_block_size (fs->fs_ondisk_sb, num);
+		set_sb_block_size (fs->fs_ondisk_sb, num);
 
     /* sb_oid_maxsize */
     printf ("\tMax objectid size: current: %u: new:",
-	    get_sb_oid_maxsize (fs->fs_ondisk_sb));
+			get_sb_oid_maxsize (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_oid_maxsize (fs->fs_ondisk_sb, num);
+		set_sb_oid_maxsize (fs->fs_ondisk_sb, num);
 
     /* sb_oid_cursize */
     printf ("\tCur objectid size: current: %u: new:",
-	    get_sb_oid_cursize (fs->fs_ondisk_sb));
+			get_sb_oid_cursize (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_oid_cursize (fs->fs_ondisk_sb, num);
-
+		set_sb_oid_cursize (fs->fs_ondisk_sb, num);
+	
     /* sb_state */
     printf ("\tUmount state: current: %u: new:",
-	    get_sb_umount_state (fs->fs_ondisk_sb));
+			get_sb_umount_state (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_umount_state (fs->fs_ondisk_sb, num);
+		set_sb_umount_state (fs->fs_ondisk_sb, num);
 
     /* char s_magic [10]; */
     printf ("\tMagic: current: \"%s\": new:", fs->fs_ondisk_sb->s_v1.s_magic);
     getline (&str, &n, stdin);
     if (strcmp (str, "\n"))
-	strncpy (fs->fs_ondisk_sb->s_v1.s_magic, str, n > 10 ? 10 : n);
+		strncpy (fs->fs_ondisk_sb->s_v1.s_magic, str, n > 10 ? 10 : n);
     
     /* __u16 sb_fsck_state; */
     printf ("\tFielsystem state: current: %u: new:", get_sb_fs_state (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_fs_state (fs->fs_ondisk_sb, num);
-
+		set_sb_fs_state (fs->fs_ondisk_sb, num);
+	
     /* __u32 sb_hash_function_code; */
     printf ("\tHash code: current: %u: new (tea %d, r5 %d, rupasov %d):",
-	    get_sb_hash_code (fs->fs_ondisk_sb), TEA_HASH, R5_HASH, YURA_HASH);
+			get_sb_hash_code (fs->fs_ondisk_sb), TEA_HASH, R5_HASH, YURA_HASH);
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_hash_code (fs->fs_ondisk_sb, num);
+		set_sb_hash_code (fs->fs_ondisk_sb, num);
     
     /* __u16 sb_tree_height; */
     printf ("\tTree height: current: %u: new:",
-	    get_sb_tree_height (fs->fs_ondisk_sb));
+			get_sb_tree_height (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_tree_height (fs->fs_ondisk_sb, num);
+		set_sb_tree_height (fs->fs_ondisk_sb, num);
     
     /* __u16 sb_bmap_nr; */
     printf ("\tNumber of bitmaps: current: %u: new:",
-	    get_sb_bmap_nr (fs->fs_ondisk_sb));
+			get_sb_bmap_nr (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_bmap_nr (fs->fs_ondisk_sb, num);
+		set_sb_bmap_nr (fs->fs_ondisk_sb, num);
 
     /* __u16 sb_version; */
     printf ("\tFilesystem format: current: %u: new:",
-	    le16_to_cpu (fs->fs_ondisk_sb->s_v1.sb_version));
+			le16_to_cpu (fs->fs_ondisk_sb->s_v1.sb_version));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_version (fs->fs_ondisk_sb, num);
+		set_sb_version (fs->fs_ondisk_sb, num);
 
     /* __u16 sb_reserved_for_journal; */
     printf ("\tSpace reserved for journal: current: %u: new:",
-	    get_sb_reserved_for_journal (fs->fs_ondisk_sb));
+			get_sb_reserved_for_journal (fs->fs_ondisk_sb));
     getline (&str, &n, stdin);
     if (str2int (str, &num))
-	set_sb_reserved_for_journal (fs->fs_ondisk_sb, num);
-
+		set_sb_reserved_for_journal (fs->fs_ondisk_sb, num);
 
     print_block (stdout, fs, fs->fs_super_bh);
     if (user_confirmed (stderr, "Is this ok ? [N/Yes]: ", "Yes\n")) {
-	mark_buffer_dirty (fs->fs_super_bh);
-	bwrite (fs->fs_super_bh);
+		mark_buffer_dirty (fs->fs_super_bh);
+		bwrite (fs->fs_super_bh);
     }
 }
 
 
 static void corrupt_clobber_hash (char * name, struct item_head * ih, 
-				  struct reiserfs_de_head * deh)
+								  struct reiserfs_de_head * deh)
 {
     printf ("\tCorrupting deh_offset of entry \"%s\" of [%u %u]\n", name,
-	    get_key_dirid (&ih->ih_key), get_key_objectid (&ih->ih_key));
+			get_key_dirid (&ih->ih_key), get_key_objectid (&ih->ih_key));
     set_deh_offset (deh, 700);
 }
 
@@ -209,28 +226,22 @@
    J item_num objectid
    E name objectid new - change entry's deh_objectid to new
    P                   - print the block
+   B offset bytes_to_corrupt - corrupt bytes_to_corrupt bytes in block header,
+                               start from offset
 */
-void do_corrupt_one_block (reiserfs_filsys_t * fs)
+
+void do_corrupt_one_block (reiserfs_filsys_t * fs, char * fline)
 {
     struct buffer_head * bh;
-    int i, j;
-    struct item_head * ih;
-    int item_num;
     char * line = 0;
     size_t n = 0;
-    char code, name [100];
-    __u32 objectid, new_objectid;
-    int value;
-    int hash_code;
-    int pos_in_item;
     unsigned long block;
-    int type, format;
-
 
     block = certain_block (fs);
+    printf ("block = %lu\n", block);
     if (block == fs->fs_super_bh->b_blocknr) {
-	edit_super_block (fs);
-	return;
+		edit_super_block (fs);
+		return;
     }
 
     if (!fs->fs_bitmap2) {
@@ -239,249 +250,1058 @@
         
         if (spread_bitmaps (fs))
             bm_block = ( block / (fs->fs_blocksize * 8) ) ? 
-                    (block / (fs->fs_blocksize * 8)) * (fs->fs_blocksize * 8) : 
-                    fs->fs_super_bh->b_blocknr + 1;
+				(block / (fs->fs_blocksize * 8)) * (fs->fs_blocksize * 8) : 
+			fs->fs_super_bh->b_blocknr + 1;
         else
             bm_block = fs->fs_super_bh->b_blocknr + 1 + (block / (fs->fs_blocksize * 8));
         
         bm_bh = bread (fs->fs_dev, bm_block, fs->fs_blocksize);
         if (bm_bh) {
-            if ( test_bit((block % (fs->fs_blocksize * 8)), bm_bh->b_data) )
+            if ( misc_test_bit((block % (fs->fs_blocksize * 8)), bm_bh->b_data) )
                 fprintf (stderr, "%lu is used in ondisk bitmap\n", block);
             else
-	        fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
+				fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
 	        
             brelse (bm_bh);
         }
     } else {
         if (reiserfs_bitmap_test_bit (fs->fs_bitmap2, block))
-	    fprintf (stderr, "%lu is used in ondisk bitmap\n", block);
+			fprintf (stderr, "%lu is used in ondisk bitmap\n", block);
         else
-	    fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
+			fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
     }
     
+    /* READ block */
     bh = bread (fs->fs_dev, block, fs->fs_blocksize);
     if (!bh) {
-	printf ("corrupt_one_block: bread fialed\n");
-	return;
+		printf ("corrupt_one_block: bread fialed\n");
+		return;
     }
 
     if (who_is_this (bh->b_data, fs->fs_blocksize) != THE_LEAF) {
-	printf ("Can not corrupt not a leaf node\n");
-	brelse (bh);
-	return;
+		printf ("Can not corrupt not a leaf node\n");
+		brelse (bh);
+		return;
     }
 
     printf ("Corrupting block %lu..\n", bh->b_blocknr);
 
-    while (getline (&line, &n, stdin) != -1) {
-	switch (line[0]) {
-	case '#':
-	case '\n':
-	    continue;
-	case '?':
-	    printf ("A hash_code     - reset hAsh code in super block\n"
-		    "T item_num type (0, 1, 2, 3) format (0, 1)\n"
-		    "C name objectid - Cut entry 'name' from directory item with 'objectid'\n"
-		    "H name objectid - clobber Hash of entry 'name' of directory 'objectid'\n"
-		    "I item_num pos_in_item  make pos_in_tem-th slot of Indirect item to point out of device\n"
-		    "O item_num      - destroy item Order - make 'item_num'-th to have key bigger than 'item_num' + 1-th item\n"
-		    "D item_num      - Delete item_num-th item\n"
-		    "S item_num value - change file Size (item_num-th item must be stat data)\n"
-		    "F item_num value - change sd_First_direct_byte of stat data\n"
-		    "J item_num objectid - set 'obJectid' of 'item_num'-th item\n"
-		    "E name objectid objectid - set deh_objectid of an entry to objectid\n");
-
-	    continue;
-
-	case 'P':
-	    print_block (stderr, fs, bh, 3, -1, -1);
-	    break;
-	    
-	case 'A':
-	    /* corrupt hash record in super block */
-	    if (sscanf (line, "%c %d\n", &code, &hash_code) != 2) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-	    
-	case 'C': /* cut entry */
-	case 'H': /* make hash wrong */
-	    if (sscanf (line, "%c %s %u\n", &code, name, &objectid) != 3) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-
-	case 'T': /* set type of item */
-	    if (sscanf (line, "%c %d %d %d\n", &code, &item_num, &type, &format) != 4) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-
-	case 'J': /* set objectid : used to simulate objectid sharing problem */
-	    if (sscanf (line, "%c %d %d\n", &code, &item_num, &objectid) != 3) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-
-	case 'E': /* set objectid : used to simulate objectid sharing problem */
-	    if (sscanf (line, "%c %s %u %d\n", &code, name, &objectid, &new_objectid) != 4) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-
-	case 'I': /* break unformatted node pointer */
-	    if (sscanf (line, "%c %d %d\n", &code, &item_num, &pos_in_item) != 3) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-	    
-	case 'D': /* delete item */
-	case 'O': /* make item out of order */
-	    if (sscanf (line, "%c %d\n", &code, &item_num) != 2) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-	    
-	case 'S': /* corrupt st_size */
-	case 'F': /*         st_first_direct_byte */
-	    if (sscanf (line, "%c %d %d\n", &code, &item_num, &value) != 3) {
-		printf ("Wrong format \'%c\'\n", line [0]);
-		continue;
-	    }
-	    break;
-	}
-	
-	if (code == 'A') {
-	    reiserfs_warning (stderr, "Changing %s to %s\n", code2name (get_sb_hash_code (fs->fs_ondisk_sb)),
-			       code2name (hash_code));
-	    set_sb_hash_code (fs->fs_ondisk_sb, hash_code);
-	    mark_buffer_dirty (fs->fs_super_bh);
-	    continue;
-	}
-
-	ih = B_N_PITEM_HEAD (bh, 0);
-	for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
-	    struct reiserfs_de_head * deh;
-
-	    if (code == 'T' && i == item_num) {
-		set_ih_key_format (ih, format);
-		set_type (format, &ih->ih_key, type);
-		mark_buffer_dirty (bh);
-		goto cont;
-	    }
-
-	    if (code == 'I' && i == item_num) {
-		if (!is_indirect_ih (ih) || pos_in_item >= I_UNFM_NUM (ih)) {
-		    reiserfs_warning (stderr, "Not an indirect item or there is "
-				       "not so many unfm ptrs in it\n");
-		    continue;
-		}
-		* ((__u32 *)B_I_PITEM (bh, ih) + pos_in_item) = get_sb_block_count (fs->fs_ondisk_sb) + 100;
-		mark_buffer_dirty (bh);
-		goto cont;
-	    }
-
-	    if (code == 'J' && i == item_num) {
-		set_key_objectid (&ih->ih_key, objectid);
-		mark_buffer_dirty (bh);
-		goto cont;
-	    }
-
-	    if (code == 'S' && i == item_num) {
-		/* fixme: old stat data only */
-		struct stat_data_v1 * sd;
-
-		sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih); 
-		reiserfs_warning (stderr, "Changing sd_size of %k from %d to %d\n",
-				   &ih->ih_key, sd_v1_size(sd), value);
-                set_sd_v1_size( sd, value );
-		mark_buffer_dirty (bh);
-		goto cont;		
-	    }
-
-	    if (code == 'F' && i == item_num) {
-		/* fixme: old stat data only */
-		struct stat_data_v1 * sd;
-
-		sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih); 
-		reiserfs_warning (stderr, "Changing sd_first_direct_byte of %k from %d to %d\n",
-				   &ih->ih_key, sd_v1_first_direct_byte(sd), value);		
-		set_sd_v1_first_direct_byte( sd, value );
-		mark_buffer_dirty (bh);
-		goto cont;		
-	    }
-
-	    if (code == 'D' && i == item_num) {
-		delete_item (fs, bh, item_num);
-		mark_buffer_dirty (bh);
-		goto cont;
-	    }
-
-	    if (code == 'O' && i == item_num) {
-		/* destroy item order */
-		struct key * key;
-		if (i == get_blkh_nr_items (B_BLK_HEAD (bh)) - 1) {
-		    printf ("can not destroy order\n");
-		    continue;
-		}
-		key = &(ih + 1)->ih_key;
-		set_key_dirid (&ih->ih_key, get_key_dirid (key) + 1);
-		mark_buffer_dirty (bh);
-	    }
-
-	    if (get_key_objectid (&ih->ih_key) != objectid || !is_direntry_ih (ih))
-		continue;
-
-	    deh = B_I_DEH (bh, ih);
-
-	    for (j = 0; j < get_ih_entry_count (ih); j ++, deh ++) {
-		/* look for proper entry */
-		if (name_in_entry_length (ih, deh, j) != strlen (name) ||
-		    strncmp (name, name_in_entry (deh, j), strlen (name)))
-		    continue;
-
-		/* ok, required entry found, make a corruption */
-		switch (code) {
-		case 'C': /* cut entry */
-		    cut_entry (fs, bh, i, j, 1);
-		    mark_buffer_dirty (bh);
-
-		    if (!B_IS_IN_TREE (bh)) {
-			printf ("NOTE: block is deleted from the tree\n");
-			exit (0);
-		    }
-		    goto cont;
-		    break;
-
-		case 'H': /* clobber hash */
-		    corrupt_clobber_hash (name, ih, deh);
-		    goto cont;
-		    break;
-
-		case 'E': /* change entry's deh_objectid */
-		    set_deh_objectid (deh, new_objectid);
-		    break;
-
-		default:
-		    printf ("Unknown command found\n");
-		}
-		mark_buffer_dirty (bh);
-	    }
-	}
-    cont:
+    if (data(fs)->log_file_name) {
+		printf ("Log file : %s\n", data(fs)->log_file_name);
+    } else {
+		printf ("No Log file specified\n");
     }
-    free (line);
+
+    if (fline != NULL) {
+		do_one_corruption_in_one_block (fs, bh, fline);
+		if ((data(fs)->log_file_name) && (data(fs)->log)) {
+			fprintf (data(fs)->log, "%lu\n", block);
+			fprintf (data(fs)->log, "%s\n", fline);
+		}
+    } else {
+		/* Get list of corruptions from stdin */
+        while (getline (&line, &n, stdin) != -1) {
+			if ( line [0] == '\n' ) {
+				free (line);
+				line = 0;
+				n = 0;
+				break;
+			}
+			do_one_corruption_in_one_block (fs, bh, line);
+			if ((data(fs)->log_file_name) && (data(fs)->log)) {
+				fprintf (data(fs)->log, "%lu\n", block);
+				fprintf (data(fs)->log, "%s\n", line);
+			}
+			
+			free (line);
+			line = 0;
+			n = 0;
+		}
+    }
+
     printf ("Done\n");
+    bwrite(bh);
     brelse (bh);
     return;
 }
 
+void do_one_corruption_in_one_block (reiserfs_filsys_t * fs,
+									 struct buffer_head * bh,
+									 char * corruption_command)
+{
+    int i, j;
+    struct item_head * ih;
+    int item_num;
+    int item_numbers;
+    int bytes_to_corrupt;
+    char code, name [100];
+    __u32 objectid, new_objectid;
+    int value;
+    int hash_code;
+    unsigned int pos_in_item;
+    int type, format;
+
+    printf ("corruption_command  : %s", corruption_command);
+
+    switch (corruption_command [0]) {
+	case '#':
+	case '\n':
+		break;
+		
+	case '?':
+		printf ("A hash_code     - reset hAsh code in super block\n"
+				"T item_num type (0, 1, 2, 3) format (0, 1)\n"
+				"C name objectid - Cut entry 'name' from directory item with 'objectid'\n"
+				"H name objectid - clobber Hash of entry 'name' of directory 'objectid'\n"
+				"I item_num pos_in_item  make pos_in_tem-th slot of Indirect item to point out of device\n"
+				"O item_num      - destroy item Order - make 'item_num'-th to have key bigger than 'item_num' + 1-th item\n"
+				"D item_num      - Delete item_num-th item\n"
+				"S item_num value - change file Size (item_num-th item must be stat data)\n"
+				"F item_num value - change sd_First_direct_byte of stat data\n"
+				"J item_num objectid - set 'obJectid' of 'item_num'-th item\n"
+				"E name objectid objectid - set deh_objectid of an entry to objectid\n"
+				"N item_numbers bytes_to_corrupt - corrupt bytes_to_corrupt in number of bytes in item_numbers items\n"
+				"B offset bytes_to_corrupt - corrupt bytes_to_corrupt in block_header, start corruption from offset\n");
+		
+	    break;
+		
+	case 'P':
+		print_block (stderr, fs, bh, 3, -1, -1);
+		break;
+	    
+	case 'A':
+		/* corrupt hash record in super block */
+		if (sscanf (corruption_command, "%c %d\n", &code, &hash_code) != 2) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+		}
+		reiserfs_warning (stderr, "Changing %s to %s\n",
+						  code2name (get_sb_hash_code (fs->fs_ondisk_sb)),
+						  code2name (hash_code));
+		set_sb_hash_code (fs->fs_ondisk_sb, hash_code);
+		break;
+	    
+	case 'C': /* cut entry */
+	case 'H': /* make hash wrong */
+		if (sscanf (corruption_command, "%c %s %u\n", &code, name, &objectid) != 3) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+	  }
+		
+		ih = B_N_PITEM_HEAD (bh, 0);
+		for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
+			struct reiserfs_de_head * deh;
+			/* look for property objectid */
+			if (get_key_objectid (&ih->ih_key) != objectid || !is_direntry_ih (ih))
+				continue;
+
+			deh = B_I_DEH (bh, ih);
+			
+			for (j = 0; j < get_ih_entry_count (ih); j ++, deh ++) {
+				/* look for proper entry */
+				if (name_in_entry_length (ih, deh, j) == (int)strlen (name) &&
+					!strncmp (name, name_in_entry (deh, j), strlen (name)))
+					break;
+			}
+			if (j == get_ih_entry_count (ih)) {
+				printf ("Can't find entry %s\n", name);
+				exit (1);
+			}
+			switch (code) {
+			case 'H' : /* clobber hash */
+				corrupt_clobber_hash (name, ih, deh);
+				break;
+
+			case 'C' : /* cut entry */
+				cut_entry (fs, bh, i, j, 1);
+				break;
+
+			default:
+				printf ("Unknown command found\n");
+			}
+		}
+
+		if (!B_IS_IN_TREE (bh)) {
+			printf ("NOTE: block is deleted from the tree\n");
+			exit (0);
+		}
+		break;
+		
+	case 'E': /* set objectid : used to simulate objectid sharing problem */
+		if (sscanf (corruption_command, "%c %s %u %d\n", &code, name, &objectid, &new_objectid) != 4) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+		}
+		ih = B_N_PITEM_HEAD (bh, 0);
+		for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
+			struct reiserfs_de_head * deh;
+			/* look for property objectid */
+			if (get_key_objectid (&ih->ih_key) != objectid || !is_direntry_ih (ih))
+				continue;
+			deh = B_I_DEH (bh, ih);
+			set_deh_objectid (deh, new_objectid);
+			break;
+		}  
+		break;
+		
+	case 'T': /* set type of item */
+	    if (sscanf (corruption_command, "%c %d %d %d\n", &code, &item_num, &type, &format) != 4) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+	    }
+	    if (item_num > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+			printf ("Wrong format \'%c\', wrong item_num \n", corruption_command [0]);
+			return;
+	    }
+		
+	    ih = B_N_PITEM_HEAD (bh, item_num);
+	    set_ih_key_format (ih, format);
+	    set_type (format, &ih->ih_key, type);
+		
+	    break;
+		
+	case 'J': /* set objectid : used to simulate objectid sharing problem */
+	    if (sscanf (corruption_command, "%c %d %d\n", &code, &item_num, &objectid) != 3) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+	    }
+	    if (item_num > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+			printf ("Wrong format \'%c\', wrong item_num \n", corruption_command [0]);
+			return;
+	    }
+	    ih = B_N_PITEM_HEAD (bh, item_num);
+	    set_key_objectid (&ih->ih_key, objectid);
+	    break;
+		
+	case 'I': /* break unformatted node pointer */
+	    if (sscanf (corruption_command, "%c %d %u\n", &code, &item_num, &pos_in_item) != 3) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+	    }
+	    if (item_num > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+			printf ("Wrong format \'%c\', wrong item_num \n", corruption_command [0]);
+			return;
+	    }
+	    ih = B_N_PITEM_HEAD (bh, item_num);
+	    if (!is_indirect_ih (ih) || pos_in_item >= I_UNFM_NUM (ih)) {
+	        reiserfs_warning (stderr, "Not an indirect item or there is "
+							  "not so many unfm ptrs in it\n");
+			return;
+	    }
+	    * ((__u32 *)B_I_PITEM (bh, ih) + pos_in_item) = get_sb_block_count (fs->fs_ondisk_sb) + 100;
+	    break;
+	    
+	case 'D': /* delete item */
+	    if (sscanf (corruption_command, "%c %d\n", &code, &item_num) != 2) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+	    }
+	    if (item_num > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+			printf ("Wrong format \'%c\', wrong item_num \n", corruption_command [0]);
+			return;
+	    }
+	    delete_item (fs, bh, item_num);
+	    break;
+		
+	case 'O': /* make item out of order */
+		{
+			struct key * key;
+			if (sscanf (corruption_command, "%c %d\n", &code, &item_num) != 2) {
+				printf ("Wrong format \'%c\'\n", corruption_command [0]);
+				return;
+			}
+			if (item_num > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+				printf ("Wrong format \'%c\', wrong item_num \n", corruption_command [0]);
+				return;
+			}
+			
+			/* destroy item order */
+			
+			if (item_num == get_blkh_nr_items (B_BLK_HEAD (bh)) - 1) {
+				printf ("can not destroy order\n");
+				return;
+			}
+			ih = B_N_PITEM_HEAD (bh, item_num);
+			key = &(ih + 1)->ih_key;
+			set_key_dirid (&ih->ih_key, get_key_dirid (key) + 1);
+			
+			break;
+		}  
+	case 'S': /* corrupt st_size */
+		{
+			/* fixme: old stat data only */
+			struct stat_data_v1 * sd;
+			
+			if (sscanf (corruption_command, "%c %d %d\n", &code, &item_num, &value) != 3) {
+				printf ("Wrong format \'%c\'\n", corruption_command [0]);
+				return;
+			}
+			if (item_num > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+				printf ("Wrong format \'%c\', wrong item_num \n", corruption_command [0]);
+				return;
+			}
+			ih = B_N_PITEM_HEAD (bh, item_num);
+			
+			sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih); 
+			reiserfs_warning (stderr, "Changing sd_size of %k from %d to %d\n",
+							  &ih->ih_key, sd_v1_size(sd), value);
+			set_sd_v1_size( sd, value );
+			break;
+		}
+		
+    case 'F': /*         st_first_direct_byte */
+		{
+			/* fixme: old stat data only */
+			struct stat_data_v1 * sd;
+			
+			if (sscanf (corruption_command, "%c %d %d\n", &code, &item_num, &value) != 3) {
+				printf ("Wrong format \'%c\'\n", corruption_command [0]);
+				return;
+			}
+			if (item_num > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+				printf ("Wrong format \'%c\', wrong item_num \n",
+						corruption_command [0]);
+				return;
+			}
+			ih = B_N_PITEM_HEAD (bh, item_num);
+			
+			sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih); 
+			reiserfs_warning (stderr, "Changing sd_first_direct_byte of %k from %d to %d\n",
+							  &ih->ih_key, sd_v1_first_direct_byte(sd), value);		
+			set_sd_v1_first_direct_byte( sd, value );
+			break;
+		}
+		
+	case 'N': /* corrupt N number of items */
+	    if (sscanf (corruption_command, "%c %d %d\n",
+					&code, &item_numbers, &bytes_to_corrupt) != 3) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+	    }
+		
+	    if (item_numbers > get_blkh_nr_items (B_BLK_HEAD (bh))) {
+			printf ("Wrong item_numbers %d expected not more then %d\n",
+					item_numbers,
+					get_blkh_nr_items (B_BLK_HEAD (bh)));
+			return;
+	    }
+		
+	    for (i = 0; i < item_numbers; i++) { 
+			printf ("Do corruptions :  %d item header; \n", i );
+			ih = B_N_PITEM_HEAD (bh, i);
+			do_one_ih_corrupt (ih, bytes_to_corrupt);
+			printf ("Ok\n");
+	    }
+		
+	    break;
+	case 'B' :
+		{
+			struct block_head * blkh;
+			unsigned int offset;
+			
+			if (sscanf (corruption_command, "%c %d %d\n",
+						&code, &offset, &bytes_to_corrupt) != 3) {
+				printf ("Wrong format \'%c\'\n", corruption_command [0]);
+				return;
+			}
+			
+			blkh = B_BLK_HEAD (bh);
+			corrupt_block_header (blkh, offset, bytes_to_corrupt);
+			break;
+		}
+		
+	default:
+		printf ("Unknown command found\n");
+	} 
+    mark_buffer_dirty (bh);
+    return;
+}
+
+/* corrupt first nr_bytes bytes in item header */
+int do_one_ih_corrupt (struct item_head * ih, unsigned int nr_bytes)
+{
+	if (nr_bytes > IH_SIZE) {
+		printf ("Bad byte number %u expected not more then %d\n", nr_bytes,
+				IH_SIZE);
+		exit (1);
+	}
+
+	if (memset ((char *)ih, 0, nr_bytes) != ih ) {
+		perror ("do_one_ih_corrupt: memset failed");
+		exit (1);
+	}
+
+	if ((data(fs)->log_file_name) && (data(fs)->log))
+		fprintf (data(fs)->log, "\tfirst %u bytes corrupted\n", nr_bytes);
+
+	printf ("\tfirst %u bytes corrupted\n", nr_bytes);
+	return 0;
+}
+
+/* item header random corruption */
+int do_one_ih_random_corrupt (struct item_head * ih)
+{
+	unsigned int i;
+	unsigned int from;
+	unsigned int count;
+		
+	from = get_rand (0,  IH_SIZE - 1);
+	count = get_rand (1, IH_SIZE);
+
+	if (from + count > IH_SIZE)
+		count = IH_SIZE - from;
+
+	for (i = from; i < from + count; i ++)
+		((char *)ih)[i] = get_rand(0, 255);
+
+	if ((data(fs)->log_file_name) && (data(fs)->log))
+		fprintf (data(fs)->log, "\tfrom %u ( %u )\n", from, count);
+
+	printf ("\tfrom %u ( %u )\n",  from, count);
+	return 0;
+}
+
+/* Corrupt n bytes in block header */
+int corrupt_block_header (struct block_head * blkh, unsigned int offset, unsigned int bytes ) 
+{
+	if ((offset + bytes) > BLKH_SIZE) {
+		printf ("Bad offset number: %u or bad bytes number: %u, the suumary value expected not more then %d\n", offset, bytes, BLKH_SIZE );
+		exit (1);
+	} 
+
+	if (memset ((char *)blkh, 0, bytes) != blkh ) {
+		perror ("corrupt_block_head: memset failed");
+		exit (1);   
+	}
+
+	printf ("offset : %u, corrupt %u bytes\n", offset, bytes);
+	return 0;
+}
+
+/* corrupt random number of bytes within block header started from random
+   offset */
+void do_one_blkh_random_corrupt (struct buffer_head * bh)
+{
+	struct block_head * blkh;
+	unsigned int from;
+	unsigned int count;
+	int i;
+
+	from = get_rand (0, BLKH_SIZE - 1);
+	count = get_rand (1, BLKH_SIZE);
+
+	blkh = B_BLK_HEAD (bh);
+
+	if (from + count > BLKH_SIZE)
+		count = BLKH_SIZE - from;
+
+	for (i = from; i < from + count; i ++)
+		((char *)blkh)[i] = get_rand(0, 255);
+
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "# : %lu #    ", bh->b_blocknr);
+		fprintf (data(fs)->log, "from %u (%u)\n", from, count);
+	}
+
+	printf ("# : %lu #   ", bh->b_blocknr);
+	printf ("from %u (%u)\n", from, count);
+
+}
+
+void do_leaves_corruption (reiserfs_filsys_t * fs,
+						   unsigned long nr_leaves_cr) 
+						   
+{
+	struct buffer_head * bh;
+    unsigned long nr_leaves = 0;
+	unsigned int i, should_be_corrupted;
+
+	srand (time (0));
+	printf ("%lu leaves will be corrupted\n", nr_leaves_cr);
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "Block headers in %lu leaves will be corrupted\n", nr_leaves_cr);
+	}
+
+    if (reiserfs_open_ondisk_bitmap (fs) < 0)
+		reiserfs_panic ("Could not open ondisk bitmap");
+
+    for (i = 0; (i < get_sb_block_count (fs->fs_ondisk_sb)) &&
+			 nr_leaves < nr_leaves_cr; i ++) {
+
+		if (!reiserfs_bitmap_test_bit (fs->fs_bitmap2, i))
+			continue;
+
+		bh = bread (fs->fs_dev, i, fs->fs_blocksize);
+		if (!bh) {
+			reiserfs_warning (stderr, "could not read block %lu\n", i);
+			continue;
+		}
+
+		if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
+			brelse (bh);	
+			continue;
+		}
+
+		if ((!is_leaf_node (bh)) || (block_of_journal (fs, i))) {
+			brelse (bh);	
+			continue;
+		}
+
+		should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+		if (should_be_corrupted == 0)
+		{
+			brelse (bh);
+			continue;
+		}
+		do_one_blkh_random_corrupt (bh);
+		/* do_one_block_random_corrupt (bh); */
+		mark_buffer_dirty (bh);
+		bwrite(bh);
+		brelse (bh);
+		nr_leaves ++;
+	}
+
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log,
+				 "%lu leaves WERE corrupted\n",
+				 nr_leaves);
+	}
+
+	printf ("%lu leaves WERE corrupted\n", nr_leaves);
+
+	reiserfs_close_ondisk_bitmap (fs);
+	return;
+}
+
+void do_one_block_random_corrupt (struct buffer_head * bh) 
+{
+	unsigned int from = get_rand (0, bh->b_size - 1);
+	unsigned int count = get_rand (1, bh->b_size);
+	int i;
+
+	if (from + count > bh->b_size)
+		count = bh->b_size - from;
+
+	for (i = from; i < from + count; i ++)
+		((char *)bh->b_data)[i] = get_rand(0, 255);
+
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "# block %lu: ", bh->b_blocknr);
+		fprintf (data(fs)->log, "from %u ( %u )\n", from, count);
+	}
+
+	printf ("# block %lu: ", bh->b_blocknr);
+	printf ("from %u ( %u )\n", from, count);
+	
+}
+
+void do_bitmap_corruption (reiserfs_filsys_t * fs)
+{
+
+    unsigned long first = fs->fs_super_bh->b_blocknr + 1;
+	unsigned long nr_bitmap_to_corrupt;
+	unsigned long block;
+    struct buffer_head * bh;
+	int i;
+
+	nr_bitmap_to_corrupt = (unsigned long)get_rand (1, get_sb_bmap_nr (fs->fs_ondisk_sb) - 1);
+
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "%lu bitmaps will be corrupted\n", nr_bitmap_to_corrupt);
+	}
+	printf ("%lu bitmaps will be corrupted\n", nr_bitmap_to_corrupt);
+	for (i = 0; i < nr_bitmap_to_corrupt; i ++ )
+		{
+			block = ( i == 0 ) ? first 
+				: fs->fs_blocksize * 8 * i;
+			bh = bread (fs->fs_dev, block, fs->fs_blocksize);
+
+			if (!bh) {
+				printf ("do_bitmap_corruption: bread failed for bitmap %d: %lu\n",
+						i, block); 
+				exit (1);
+			}
+			do_one_block_random_corrupt (bh);
+			mark_buffer_dirty (bh);
+			bwrite(bh);
+			brelse (bh);
+		}
+
+} 
+
+/* corrupt the random number of item headers in random number of leaves */
+void do_ih_random_corrupt (reiserfs_filsys_t * fs,
+							  unsigned long nr_leaves_cr) 
+{
+	unsigned int nr_ih_cr;
+	int i, j;
+	struct buffer_head * bh;
+	struct item_head * ih;
+	unsigned long nr_leaves = 0;
+	unsigned int should_be_corrupted = 0;
+
+	srand (time (0));
+
+	printf ("item headers in %lu leaves will be corrupted\n", nr_leaves_cr);
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "item headers in %lu leaves will be corrupted\n", nr_leaves_cr);
+	}
+
+    if (reiserfs_open_ondisk_bitmap (fs) < 0)
+		reiserfs_panic ("Could not open ondisk bitmap");
+
+    for (i = 0; (i < get_sb_block_count (fs->fs_ondisk_sb)) &&
+			 nr_leaves < nr_leaves_cr; i ++) {
+
+		if (!reiserfs_bitmap_test_bit (fs->fs_bitmap2, i))
+			continue;
+
+		bh = bread (fs->fs_dev, i, fs->fs_blocksize);
+		if (!bh) {
+			reiserfs_warning (stderr, "could not read block %lu\n", i);
+			continue;
+		}
+
+		if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
+			brelse (bh);	
+			continue;
+		}
+
+		if ((!is_leaf_node (bh)) || (block_of_journal (fs, i))) {
+			brelse (bh);	
+			continue;
+		}
+
+		should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+		if (should_be_corrupted == 0)
+		{
+			brelse (bh);
+			continue;
+		}
+
+		nr_ih_cr = get_rand (1, get_blkh_nr_items (B_BLK_HEAD (bh))); 
+		for (j = 0; j < nr_ih_cr; j ++ ) {
+			should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+			if (should_be_corrupted == 0)
+				continue;
+
+			if ((data(fs)->log_file_name) && (data(fs)->log))
+				fprintf (data(fs)->log, "# block %lu , item header %d\n",
+						 bh->b_blocknr, j);
+			printf ("# block %lu , item header %d\n", bh->b_blocknr, j);
+			
+			ih = B_N_PITEM_HEAD (bh, j);
+			do_one_ih_random_corrupt (ih);
+		}
+		mark_buffer_dirty (bh);
+		bwrite(bh);
+		brelse (bh);
+		nr_leaves ++ ;
+	}
+
+	if ((data(fs)->log_file_name) && (data(fs)->log))
+		fprintf (data(fs)->log, "item headers in %lu leaves WERE corrupted\n",
+				 nr_leaves);
+	printf ("item headers in %lu leaves WERE corrupted\n", nr_leaves);
+
+	reiserfs_close_ondisk_bitmap (fs);
+}
+
+/* corrupt item */
+void do_one_item_random_corrupt (struct buffer_head * bh,
+								 struct item_head * ih)
+{
+	unsigned int i;
+	unsigned int from;
+	unsigned int count;
+	char * p;
+
+	p = (char *)B_I_PITEM(bh, ih);
+
+	from = get_rand (0, get_ih_item_len(ih)  - 1);
+	count = get_rand (1, get_ih_item_len(ih));
+
+	if (from + count > get_ih_item_len(ih))
+		count = get_ih_item_len(ih) - from;
+
+	for (i = from; i < from + count; i ++)
+		((char *)p)[i] = get_rand(0, 255);
+
+	if ((data(fs)->log_file_name) && (data(fs)->log))
+		fprintf (data(fs)->log, "item body \tfrom %u ( %u )\n", from, count);
+
+	printf ("item body \tfrom %u ( %u )\n",  from, count);
+	return ;
+
+}
+
+
+/* corrupt the random number of directory items in random number of leaves */
+void do_dir_random_corrupt (reiserfs_filsys_t * fs,
+							unsigned long nr_leaves_cr) 
+{
+ 	unsigned int nr_ih_cr;
+	int i, j;
+	struct buffer_head * bh;
+	struct item_head * ih;
+	unsigned long nr_leaves = 0;
+	unsigned int should_be_corrupted = 0;
+
+	srand (time (0));
+
+	printf ("DIR items in %lu leaves will be corrupted\n", nr_leaves_cr);
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "DIR items in %lu leaves will be corrupted\n", nr_leaves_cr);
+	}
+
+    if (reiserfs_open_ondisk_bitmap (fs) < 0)
+		reiserfs_panic ("Could not open ondisk bitmap");
+
+    for (i = 0; (i < get_sb_block_count (fs->fs_ondisk_sb)) &&
+			 nr_leaves < nr_leaves_cr; i ++) {
+
+		if (!reiserfs_bitmap_test_bit (fs->fs_bitmap2, i))
+			continue;
+
+		bh = bread (fs->fs_dev, i, fs->fs_blocksize);
+		if (!bh) {
+			reiserfs_warning (stderr, "could not read block %lu\n", i);
+			continue;
+		}
+
+		if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
+			brelse (bh);	
+			continue;
+		}
+
+		if ((!is_leaf_node (bh)) || (block_of_journal (fs, i))) {
+			brelse (bh);	
+			continue;
+		}
+
+		should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+		if (should_be_corrupted == 0)
+		{
+			brelse (bh);
+			continue;
+		}
+
+		/* get next item, look is it a DIR */
+		nr_ih_cr = get_rand (1, get_blkh_nr_items (B_BLK_HEAD (bh))); 
+		for (j = 0; j < nr_ih_cr; j ++ ) {
+			should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+			if (should_be_corrupted == 0)
+				continue;
+
+			if ((data(fs)->log_file_name) && (data(fs)->log))
+				fprintf (data(fs)->log, "# block %lu , item %d\n",
+						 bh->b_blocknr, j);
+			printf ("# block %lu , item %d\n", bh->b_blocknr, j);
+			
+			ih = B_N_PITEM_HEAD (bh, j);
+			if (get_type (&ih->ih_key) != TYPE_DIRENTRY)
+				continue;
+			do_one_item_random_corrupt (bh, ih);
+		}
+		mark_buffer_dirty (bh);
+		bwrite(bh);
+		brelse (bh);
+		nr_leaves ++ ;
+	}
+
+	if ((data(fs)->log_file_name) && (data(fs)->log))
+		fprintf (data(fs)->log, "DIR items in %lu leaves WERE corrupted\n",
+				 nr_leaves);
+	printf ("DIR items in %lu leaves WERE corrupted\n", nr_leaves);
+
+	reiserfs_close_ondisk_bitmap (fs);
+}
+
+/* corrupt the random number of stat data items in random number of leaves */
+void do_sd_random_corrupt (reiserfs_filsys_t * fs,
+						   unsigned long nr_leaves_cr) 
+{
+ 	unsigned int nr_ih_cr;
+	int i, j;
+	struct buffer_head * bh;
+	struct item_head * ih;
+	unsigned long nr_leaves = 0;
+	unsigned int should_be_corrupted = 0;
+
+	srand (time (0));
+
+	printf ("SD items in %lu leaves will be corrupted\n", nr_leaves_cr);
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "SD items in %lu leaves will be corrupted\n", nr_leaves_cr);
+	}
+
+    if (reiserfs_open_ondisk_bitmap (fs) < 0)
+		reiserfs_panic ("Could not open ondisk bitmap");
+
+    for (i = 0; (i < get_sb_block_count (fs->fs_ondisk_sb)) &&
+			 nr_leaves < nr_leaves_cr; i ++) {
+
+		if (!reiserfs_bitmap_test_bit (fs->fs_bitmap2, i))
+			continue;
+
+		bh = bread (fs->fs_dev, i, fs->fs_blocksize);
+		if (!bh) {
+			reiserfs_warning (stderr, "could not read block %lu\n", i);
+			continue;
+		}
+
+		if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
+			brelse (bh);	
+			continue;
+		}
+
+		if ((!is_leaf_node (bh)) || (block_of_journal (fs, i))) {
+			brelse (bh);	
+			continue;
+		}
+		
+		should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+		if (should_be_corrupted == 0)
+		{
+			brelse (bh);
+			continue;
+		}
+
+		/* get next item, look is it a SD */
+		nr_ih_cr = get_rand (1, get_blkh_nr_items (B_BLK_HEAD (bh))); 
+		for (j = 0; j < nr_ih_cr; j ++ ) {
+			should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+			if (should_be_corrupted == 0)
+				continue;
+
+			if ((data(fs)->log_file_name) && (data(fs)->log))
+				fprintf (data(fs)->log, "# block %lu , item %d\n",
+						 bh->b_blocknr, j);
+			printf ("# block %lu , item %d\n", bh->b_blocknr, j);
+			
+			ih = B_N_PITEM_HEAD (bh, j);
+			if (get_type (&ih->ih_key) != TYPE_STAT_DATA)
+				continue;
+			do_one_item_random_corrupt (bh, ih);
+		}
+		mark_buffer_dirty (bh);
+		bwrite(bh);
+		brelse (bh);
+		nr_leaves ++ ;
+	}
+
+	if ((data(fs)->log_file_name) && (data(fs)->log))
+		fprintf (data(fs)->log, "SD items in %lu leaves WERE corrupted\n",
+				 nr_leaves);
+	printf ("SD items in %lu leaves WERE corrupted\n", nr_leaves);
+
+	reiserfs_close_ondisk_bitmap (fs);
+}
+
+/* corrupt the random number of indierct items in random number of leaves */
+void do_ind_random_corrupt (reiserfs_filsys_t * fs,
+						   unsigned long nr_leaves_cr) 
+{
+ 	unsigned int nr_ih_cr;
+	int i, j;
+	struct buffer_head * bh;
+	struct item_head * ih;
+	unsigned long nr_leaves = 0;
+	unsigned int should_be_corrupted = 0;
+
+	srand (time (0));
+
+	printf ("IND items in %lu leaves will be corrupted\n", nr_leaves_cr);
+	if ((data(fs)->log_file_name) && (data(fs)->log)) {
+		fprintf (data(fs)->log, "IND items in %lu leaves will be corrupted\n", nr_leaves_cr);
+	}
+
+    if (reiserfs_open_ondisk_bitmap (fs) < 0)
+		reiserfs_panic ("Could not open ondisk bitmap");
+
+    for (i = 0; (i < get_sb_block_count (fs->fs_ondisk_sb)) &&
+			 nr_leaves < nr_leaves_cr; i ++) {
+
+		if (!reiserfs_bitmap_test_bit (fs->fs_bitmap2, i))
+			continue;
+
+		bh = bread (fs->fs_dev, i, fs->fs_blocksize);
+		if (!bh) {
+			reiserfs_warning (stderr, "could not read block %lu\n", i);
+			continue;
+		}
+
+		if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
+			brelse (bh);	
+			continue;
+		}
+
+		if ((!is_leaf_node (bh)) || (block_of_journal (fs, i))) {
+			brelse (bh);	
+			continue;
+		}
+		
+		should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+		if (should_be_corrupted == 0)
+		{
+			brelse (bh);
+			continue;
+		}
+
+		/* get next item, look is it an IND */
+		nr_ih_cr = get_rand (1, get_blkh_nr_items (B_BLK_HEAD (bh))); 
+		for (j = 0; j < nr_ih_cr; j ++ ) {
+			should_be_corrupted = (unsigned int) get_rand ((double)0, (double)1);
+			if (should_be_corrupted == 0)
+				continue;
+
+			ih = B_N_PITEM_HEAD (bh, j);
+			if (get_type (&ih->ih_key) != TYPE_INDIRECT)
+				continue;
+			if ((data(fs)->log_file_name) && (data(fs)->log))
+				fprintf (data(fs)->log, "# block %lu , item %d\n",
+						 bh->b_blocknr, j);
+			printf ("# block %lu , item %d\n", bh->b_blocknr, j);
+
+			do_one_item_random_corrupt (bh, ih);
+		}
+		mark_buffer_dirty (bh);
+		bwrite(bh);
+		brelse (bh);
+		nr_leaves ++ ;
+	}
+
+	if ((data(fs)->log_file_name) && (data(fs)->log))
+		fprintf (data(fs)->log, "IND items in %lu leaves WERE corrupted\n",
+				 nr_leaves);
+	printf ("IND items in %lu leaves WERE corrupted\n", nr_leaves);
+
+	reiserfs_close_ondisk_bitmap (fs);
+}
+
+/* this reads list of desired corruptions from stdin and performs the
+   corruptions. Format of that list:
+   B           - the random number of bitmap to be corrupted
+   L nr_leaves - block headers in nr_leaves leaves to be corupted
+   H nr_leaves - the random number of item headers in nr_leaves to be corrupted
+   S nr_leaves - the random number of stat data items in nr_leaves to be
+                 corrupted
+   D nr_leaves - the random number of directory items in nr_leaves to be
+                 corrupted
+   I nr_leaves - the random number of indirect items in nr_leaves to be
+                 corrupted
+*/
+
+void what_to_corrupt (reiserfs_filsys_t * fs, char * corruption_command)
+{
+	unsigned long nr_leaves_cr;
+	char code;
+
+	switch (corruption_command [0]){
+	case 'B' :
+		/* bitmap */
+		do_bitmap_corruption (fs);
+		break;
+
+	case 'L' :
+		/* leaves */
+		if (sscanf (corruption_command, "%c %lu\n", &code, &nr_leaves_cr) != 2) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+		}
+		do_leaves_corruption (fs, nr_leaves_cr);		
+		break;
+
+	case 'H' :
+		/* item headers */
+		if (sscanf (corruption_command, "%c %lu\n", &code, &nr_leaves_cr) != 2) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+		}
+		do_ih_random_corrupt (fs, nr_leaves_cr);
+		break;
+
+	case 'D' :
+		/* directory items */
+		if (sscanf (corruption_command, "%c %lu\n", &code, &nr_leaves_cr) != 2) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+		}
+		do_dir_random_corrupt (fs, nr_leaves_cr);
+		break;
+
+	case 'S' :
+		/* stat data items */
+		if (sscanf (corruption_command, "%c %lu\n", &code, &nr_leaves_cr) != 2) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+		}
+		do_sd_random_corrupt (fs, nr_leaves_cr);
+		break;
+
+	case 'I' :
+		/* indirect items */
+		if (sscanf (corruption_command, "%c %lu\n", &code, &nr_leaves_cr) != 2) {
+			printf ("Wrong format \'%c\'\n", corruption_command [0]);
+			return;
+		}
+		do_ind_random_corrupt (fs, nr_leaves_cr);
+		break;
+
+	default :
+		printf ("Unknown command specified\n");
+	}
+}
+
+void do_fs_random_corrupt (reiserfs_filsys_t * fs)
+{
+    char * line = 0;
+    size_t n = 0;
+
+    printf ("Corrupting fs. Please insert one of the following command\n"
+			" B - the random number of bitmap to be corrupted\n"
+			" L nr_leaves - block headers in nr_leaves leaves to be corupted\n"
+			" H nr_leaves - the random number of item headers in nr_leaves to be corrupted\n"
+			" S nr_leaves - the random number of stat data items in nr_leaves to be corrupted\n"
+			" D nr_leaves - the random number of directory items in nr_leaves to be corrupted\n"
+			" I nr_leaves - the random number of indirect items in nr_leaves to be corrupted\n"
+			".. ->\n");
+
+	/* Get list of corruptions from stdin */
+	while (getline (&line, &n, stdin) != -1) {
+		if ( line [0] == '\n' ) {
+			free (line);
+			line = 0;
+			n = 0;
+			break;
+		}
+		printf ("################## command : %s", line);
+		if ((data(fs)->log_file_name) && (data(fs)->log)) {
+			fprintf (data(fs)->log, "################## command : %s", line);
+		}
+
+		what_to_corrupt (fs, line);
+		
+		free (line);
+		line = 0;
+		n = 0;
+	}
+}
+
+/*
+   Local variables:
+   c-indentation-style: "K&R"
+   mode-name: "LC"
+   c-basic-offset: 4
+   tab-width: 4
+   fill-column: 80
+   End:
+*/
+
+
+
+
+
+
+
 
diff --git a/debugreiserfs/debugreiserfs.8 b/debugreiserfs/debugreiserfs.8
index fac7a1d..b3c981a 100644
--- a/debugreiserfs/debugreiserfs.8
+++ b/debugreiserfs/debugreiserfs.8
@@ -1,7 +1,7 @@
 .\" -*- nroff -*-
-.\" Copyright 1996-2002 Hans Reiser.
+.\" Copyright 1996-2003 Hans Reiser.
 .\" 
-.TH DEBUGREISERFS 8 "January 2002" "Reiserfsprogs 3.6.4"
+.TH DEBUGREISERFS 8 "April 2003" "Reiserfsprogs 3.6.9"
 .SH NAME
 debugreiserfs
 .SH SYNOPSIS
@@ -20,7 +20,7 @@
 .I device
 .SH DESCRIPTION
 It helps sometimes to solve problems with reiserfs filesystems. Being
-called w/o options it prints super block of reiserfs filesystem found
+called without options it prints super block of reiserfs filesystem found
 on the \fIdevice\fR.
 .TP
 .I device
@@ -76,7 +76,7 @@
 .\" -s or 
 -p is in use
 .SH AUTHOR
-This version of \fBdebugreiserfs\fR has been written by Hans Reiser <reiser@idiom.com>.
+This version of \fBdebugreiserfs\fR has been written by Hans Reiser <reiser@namesys.com>.
 .SH BUGS
 There are probably few of them. Please, report bugs to ReiserFS mail-list <reiserfs-list@namesys.com>.
 .SH SEE ALSO
diff --git a/debugreiserfs/debugreiserfs.c b/debugreiserfs/debugreiserfs.c
index 3e3feb9..2034747 100644
--- a/debugreiserfs/debugreiserfs.c
+++ b/debugreiserfs/debugreiserfs.c
@@ -1,13 +1,12 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "debugreiserfs.h"
 
-
 reiserfs_filsys_t * fs;
 
-
 #define print_usage_and_exit() {\
 fprintf (stderr, "Usage: %s [options] device\n\n\
 Options:\n\
@@ -24,7 +23,6 @@
   exit (16);\
 }
 
-
 /*
    -B file\textract list of badblocks\n\
 
@@ -44,7 +42,6 @@
   -t\tstat the device\n\
 */
 
-
 #if 1
 struct reiserfs_fsstat {
     int nr_internals;
@@ -55,46 +52,55 @@
 } g_stat_info;
 #endif
 
-
 static void print_disk_tree (reiserfs_filsys_t * fs, unsigned long block_nr)
 {
     struct buffer_head * bh;
+    int i, count;
     static int level = -1;
-
+	
     if (level == -1)
-	level = get_sb_tree_height (fs->fs_ondisk_sb);
+		level = get_sb_tree_height (fs->fs_ondisk_sb);
 
     bh = bread (fs->fs_dev, block_nr, fs->fs_blocksize);
     if (!bh) {
-	die ("Could not read block %lu\n", block_nr);
+		die ("Could not read block %lu\n", block_nr);
     }
     level --;
 
     if (level < 1)
-	die ("level too small");
-
+		die ("level too small");
+	
     if (level != get_blkh_level (B_BLK_HEAD (bh))) {
-	printf ("%d expected, %d found in %lu\n", level, get_blkh_level (B_BLK_HEAD (bh)),
-		bh->b_blocknr);
+		printf ("%d expected, %d found in %lu\n", level, get_blkh_level (B_BLK_HEAD (bh)),
+				bh->b_blocknr);
     }
 
     if (is_internal_node (bh)) {
-	int i;
-	struct disk_child * dc;
+		struct disk_child * dc;
 
-	g_stat_info.nr_internals ++;
-	print_block (stdout, fs, bh, data (fs)->options & PRINT_TREE_DETAILS, -1, -1);
-      
-	dc = B_N_CHILD (bh, 0);
-	for (i = 0; i <= B_NR_ITEMS (bh); i ++, dc ++)
-	    print_disk_tree (fs, get_dc_child_blocknr (dc));
+		g_stat_info.nr_internals ++;
+		print_block (stdout, fs, bh, data (fs)->options & PRINT_TREE_DETAILS, -1, -1);
+
+		dc = B_N_CHILD (bh, 0);
+		count = B_NR_ITEMS(bh);
+		for (i = 0; i <= count; i++, dc++)
+			print_disk_tree (fs, get_dc_child_blocknr (dc));
       
     } else if (is_leaf_node (bh)) {
-	g_stat_info.nr_leaves ++;
-	print_block (stdout, fs, bh, data (fs)->options & PRINT_TREE_DETAILS, -1, -1);
+		struct item_head *ih;
+	
+		g_stat_info.nr_leaves ++;
+		print_block (stdout, fs, bh, data (fs)->options & PRINT_TREE_DETAILS, -1, -1);
+	
+		ih = B_N_PITEM_HEAD (bh, 0);
+		count = leaf_item_number_estimate(bh);
+		for (i = 0; i <= count; i++, ih++) {
+			if (is_indirect_ih(ih))
+				g_stat_info.nr_unformatted += I_UNFM_NUM(ih);
+		}
     } else {
-	print_block (stdout, fs, bh, data (fs)->options & PRINT_TREE_DETAILS, -1, -1);
-	reiserfs_warning (stdout,  "print_disk_tree: bad block type (%b)\n", bh);
+		print_block (stdout, fs, bh, data (fs)->options & PRINT_TREE_DETAILS, -1, -1);
+		reiserfs_warning (stdout,  "print_disk_tree: bad block type (%b)\n", bh);
     }
     brelse (bh);
     level ++;
@@ -102,33 +108,34 @@
 
 static void print_disk_blocks (reiserfs_filsys_t * fs)
 {
-    int j, type;
+    int type;
     unsigned long done = 0, total;
     struct buffer_head * bh;
-
-    total = reiserfs_bitmap_ones (input_bitmap(fs));
-
-    for (j = 0; j < get_sb_block_count (fs->fs_ondisk_sb); j ++) {
-	if (!reiserfs_bitmap_test_bit (input_bitmap (fs), j))
-	    continue;
+    unsigned int j;
 	
-	print_how_far (stderr, &done, total, 1, be_quiet (fs));
-
-	bh = bread (fs->fs_dev, j, fs->fs_blocksize);
-	if (!bh) {
-	    reiserfs_warning (stderr, "could not read block %lu\n", j);
-	    continue;
-	}
-
-	type = who_is_this (bh->b_data, bh->b_size);
-	if (type != THE_UNKNOWN)
-	    print_block (stdout, fs, bh, PRINT_TREE_DETAILS | PRINT_DIRECT_ITEMS, -1, -1);
-	if (type == THE_INTERNAL)
-	    g_stat_info.nr_internals ++;
-	else if (type == THE_LEAF)
-	    g_stat_info.nr_leaves ++;
+    total = reiserfs_bitmap_ones (input_bitmap(fs));
+	
+    for (j = 0; j < get_sb_block_count (fs->fs_ondisk_sb); j ++) {
+		if (!reiserfs_bitmap_test_bit (input_bitmap (fs), j))
+			continue;
+		
+		print_how_far (stderr, &done, total, 1, be_quiet (fs));
+		
+		bh = bread (fs->fs_dev, j, fs->fs_blocksize);
+		if (!bh) {
+			reiserfs_warning (stderr, "could not read block %lu\n", j);
+			continue;
+		}
+		
+		type = who_is_this (bh->b_data, bh->b_size);
+		if (type != THE_UNKNOWN)
+			print_block (stdout, fs, bh, PRINT_TREE_DETAILS | PRINT_DIRECT_ITEMS, -1, -1);
+		if (type == THE_INTERNAL)
+			g_stat_info.nr_internals ++;
+		else if (type == THE_LEAF || type == HAS_IH_ARRAY)
+			g_stat_info.nr_leaves ++;
 	    
-	brelse (bh);
+		brelse (bh);
     }
     fprintf (stderr, "\n");
 }
@@ -145,202 +152,219 @@
         
         if (spread_bitmaps (fs))
             bm_block = ( block / (fs->fs_blocksize * 8) ) ? 
-                    (block / (fs->fs_blocksize * 8)) * (fs->fs_blocksize * 8) : 
-                    fs->fs_super_bh->b_blocknr + 1;
+				(block / (fs->fs_blocksize * 8)) * (fs->fs_blocksize * 8) : 
+			fs->fs_super_bh->b_blocknr + 1;
         else
             bm_block = fs->fs_super_bh->b_blocknr + 1 + (block / (fs->fs_blocksize * 8));
         
         bm_bh = bread (fs->fs_dev, bm_block, fs->fs_blocksize);
         if (bm_bh) {
-            if ( test_bit((block % (fs->fs_blocksize * 8)), bm_bh->b_data) )
+            if ( misc_test_bit((block % (fs->fs_blocksize * 8)), bm_bh->b_data) )
                 fprintf (stderr, "%lu is used in ondisk bitmap\n", block);
             else
-	        fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
+				fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
 	        
             brelse (bm_bh);
         }
     } else {
         if (reiserfs_bitmap_test_bit (fs->fs_bitmap2, block))
-	    fprintf (stderr, "%lu is used in ondisk bitmap\n", block);
+			fprintf (stderr, "%lu is used in ondisk bitmap\n", block);
         else
-	    fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
+			fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
     }
     
     bh = bread (fs->fs_dev, block, fs->fs_blocksize);
     if (!bh) {
-	printf ("print_one_block: bread failed\n");
-	return;
+		printf ("print_one_block: bread failed\n");
+		return;
     }
-
+	
     if (debug_mode (fs) == DO_PACK) {
-	pack_one_block (fs, bh->b_blocknr);
-	brelse (bh);
-	return;
+		pack_one_block (fs, bh->b_blocknr);
+		brelse (bh);
+		return;
     }
-
+	
     if (who_is_this (bh->b_data, bh->b_size) != THE_UNKNOWN)
-	print_block (stdout, fs, bh, PRINT_TREE_DETAILS, -1, -1);
+		print_block (stdout, fs, bh, PRINT_TREE_DETAILS, -1, -1);
     else
-	printf ("Looks like unformatted\n");
+		printf ("Looks like unformatted\n");
     brelse (bh);
     return;
 }
 
-
-
-
 /* debugreiserfs -p or -P compresses reiserfs meta data: super block, journal,
    bitmap blocks and blocks looking like leaves. It may save "bitmap" of
    blocks they packed in the file of special format. Reiserfsck can then load
    "bitmap" saved in that file and build the tree of blocks marked used in
-   that "bitmap" */
+   that "bitmap"
+*/
 char * where_to_save;
 char * badblocks_file;
+char * corruption_list_file;
 
 static char * parse_options (struct debugreiserfs_data * data, int argc, char * argv [])
 {
     int c;
     char * tmp;
-  
-
+    
     data->scan_area = USED_BLOCKS;
     data->mode = DO_DUMP;
 
-    while ((c = getopt (argc, argv, "a:b:C:SU1:psn:Nfr:dDomj:J:qt")) != EOF) {
-	switch (c) {
-	case 'a': /* -r will read this, -n and -N will write to it */
-	    asprintf (&data->map_file, "%s", optarg);
-	    break;
-
-	case 'b':
-	    /* will load bitmap from a file and read only blocks
+    while ((c = getopt (argc, argv, "a:b:C:F:SU1:psn:Nfr:dDomj:J:qtZl:L")) != EOF) {
+		switch (c) {
+		case 'a': /* -r will read this, -n and -N will write to it */
+			asprintf (&data->map_file, "%s", optarg);
+			break;
+			
+		case 'b':
+			/* will load bitmap from a file and read only blocks
                marked in it. This is for -p and -s */
-	    asprintf (&data->input_bitmap, "%s", optarg);
-	    data->scan_area = EXTERN_BITMAP;
-	    break;
+			asprintf (&data->input_bitmap, "%s", optarg);
+			data->scan_area = EXTERN_BITMAP;
+			break;
+			
+		case 'S':
+			/* have debugreiserfs -p or -s to read all the device */
+			data->scan_area = ALL_BLOCKS;
+			break;
+			
+		case 'U':
+			/* have debugreiserfs -p or -s to read unused blocks only */
+			data->scan_area = UNUSED_BLOCKS;
+			break;
+			
+		case '1':	/* print a single node */
+			data->block = strtol (optarg, &tmp, 0);
+			if (*tmp)
+				die ("parse_options: bad block number");
+			break;
+			
+		case 'C':
+			data->mode = DO_CORRUPT_ONE;
+			data->block = strtol (optarg, &tmp, 0);
+			if (*tmp) {
+				die ("parse_options: bad block number");
+			}
+			break;
+			
+		case 'F':
+			data->mode = DO_CORRUPT_FILE;
+			if (asprintf (&corruption_list_file, "%s", optarg) == -1 ) {    
+				die ("parse_options: bad list corruption file");
+			}
+			break;
+			
+		case 'p':
+			data->mode = DO_PACK;
+			break;
+			
+		case 't':
+			data->mode = DO_STAT;
+			break;
+			
+		case 's':
+			/* read the device and print reiserfs blocks which contain defined key */
+			data->mode = DO_SCAN;
+			break;
+			
+		case 'n': /* scan for names matching a specified pattern */
+			data->mode = DO_SCAN_FOR_NAME;
+			data->pattern = optarg;
+			/*asprintf (&data->pattern, "%s", optarg);*/
+			break;
+			
+		case 'N': /* search name in the tree */
+			data->mode = DO_LOOK_FOR_NAME;
+			break;
+			
+		case 'f':
+			data->mode = DO_FILE_MAP;
+			break;
 
-	case 'S':
-	    /* have debugreiserfs -p or -s to read all the device */
-	    data->scan_area = ALL_BLOCKS;
-	    break;
-	
-	case 'U':
-	    /* have debugreiserfs -p or -s to read unused blocks only */
-	    data->scan_area = UNUSED_BLOCKS;
-	    break;
+		case 'r':
+			asprintf (&data->recovery_file, "%s", optarg);
+			data->mode = DO_RECOVER;
+			break;
 
-	case '1':	/* print a single node */
-	    data->block = strtol (optarg, &tmp, 0);
-	    if (*tmp)
-		die ("parse_options: bad block number");
-	    break;
-
-	case 'C':
-	    data->mode = DO_CORRUPT;
-	
-	    data->block = strtol (optarg, &tmp, 0);
-	    if (*tmp)
-		die ("parse_options: bad block number");
-	
-	    break;
-	    
-	case 'p':
-	    data->mode = DO_PACK;
-	    break;
-
-	case 't':
-	    data->mode = DO_STAT;
-	    break;
-
-	case 's':
-	    /* read the device and print reiserfs blocks which contain defined key */
-	    data->mode = DO_SCAN;
-	    break;
-
-	case 'n': /* scan for names matching a specified pattern */
-	    data->mode = DO_SCAN_FOR_NAME;
-	    data->pattern = optarg;
-	    /*asprintf (&data->pattern, "%s", optarg);*/
-	    break;
-
-	case 'N': /* search name in the tree */
-	    data->mode = DO_LOOK_FOR_NAME;
-	    break;
-
-	case 'f':
-	    data->mode = DO_FILE_MAP;
-	    break;
-
-	case 'r':
-	    asprintf (&data->recovery_file, "%s", optarg);
-	    data->mode = DO_RECOVER;
-	    break;
-
-	case 'd':
-	    /*  print leaf details from internal tree */
-	    data->options |= PRINT_TREE_DETAILS;
-	    break;
-
-	case 'D':
-	    /*  print leaf details accordingly the bitmap - can be used with -S */
-	    data->options |= PRINT_DETAILS;
-	    break;
-	
-	case 'o':
-	    /* print objectid map */
-	    data->options |= PRINT_OBJECTID_MAP;
-	    break;
-
-	case 'm':	/* print a block map */
-	case 'M':	/* print a block map with details */
-	    data->options |= PRINT_BITMAP;
-	    break;
-
-	case 'j': /* -j must have a parameter */
-	    data->options |= PRINT_JOURNAL;
-	    data->journal_device_name = optarg;
-	    break;
-
-	case 'J':
-	    data->options |= PRINT_JOURNAL_HEADER;
-	    data->journal_device_name = optarg;
-	    break;
-	
-	case 'R': /* read block numbers from stdin and look for them in the
+		case 'd':
+			/*  print leaf details from internal tree */
+			data->options |= PRINT_TREE_DETAILS;
+			break;
+			
+		case 'D':
+			/*  print leaf details accordingly the bitmap - can be used with -S */
+			data->options |= PRINT_DETAILS;
+			break;
+			
+		case 'o':
+			/* print objectid map */
+			data->options |= PRINT_OBJECTID_MAP;
+			break;
+			
+		case 'm':	/* print a block map */
+		case 'M':	/* print a block map with details */
+			data->options |= PRINT_BITMAP;
+			break;
+			
+		case 'j': /* -j must have a parameter */
+			data->options |= PRINT_JOURNAL;
+			data->journal_device_name = optarg;
+			break;
+			
+		case 'J':
+			data->options |= PRINT_JOURNAL_HEADER;
+			data->journal_device_name = optarg;
+			break;
+			
+		case 'R': /* read block numbers from stdin and look for them in the
                      journal */
-	    data->mode = DO_SCAN_JOURNAL;
-	    data->JJ ++;
-	    break;
-	
-	case 'B':              /*disabled for a while*/
-	    asprintf (&badblocks_file, "%s", optarg);
-	    data->mode = DO_EXTRACT_BADBLOCKS;
-	    break;
-	case 'q':
-	    /* this makes packing to not show speed info during -p or -P */
-	    data->options |= BE_QUIET;
-	    break;
-	}
+			data->mode = DO_SCAN_JOURNAL;
+			data->JJ ++;
+			break;
+			
+		case 'B':              /*disabled for a while*/
+			asprintf (&badblocks_file, "%s", optarg);
+			data->mode = DO_EXTRACT_BADBLOCKS;
+			break;
+		case 'q':
+			/* this makes packing to not show speed info during -p or -P */
+			data->options |= BE_QUIET;
+			break;
+		case 'Z':
+			data->mode = DO_ZERO_BITMAP;
+			break;
+			
+		case 'l': /* --logfile */
+			data->log_file_name = optarg;
+			data->log = fopen (optarg, "w");
+			if (!data->log)
+				fprintf (stderr, "debugreiserfs: Cannot not open \'%s\': %s", 
+						 optarg, strerror(errno));	    
+			break;
+		case 'L' :
+			/* random fs corruption */
+			data->mode = DO_RANDOM_CORRUPTION;
+			break;
+		}
     }
     
     if (optind != argc - 1)
-	/* only one non-option argument is permitted */
-	print_usage_and_exit();
-  
+		/* only one non-option argument is permitted */
+		print_usage_and_exit();
+	
     data->device_name = argv[optind];
     return argv[optind];
 }
 
-
 void pack_partition (reiserfs_filsys_t * fs);
 
 static void do_pack (reiserfs_filsys_t * fs)
 {
     if (certain_block (fs))
-	pack_one_block (fs, certain_block (fs));
+		pack_one_block (fs, certain_block (fs));
     else
-	pack_partition (fs);
-	
+		pack_partition (fs);
 }
 
 /*
@@ -362,54 +386,54 @@
 {
     FILE * fp;
     unsigned long block_count;
-
-
-    if (!reiserfs_open_ondisk_bitmap (fs))
-	reiserfs_panic ("Could not open ondisk bitmap");
-
+	
+	
+    if (reiserfs_open_ondisk_bitmap (fs) < 0)
+		reiserfs_panic ("Could not open ondisk bitmap");
+	
     block_count = get_sb_block_count (fs->fs_ondisk_sb);
-
+	
     switch (scan_area (fs)) {
     case ALL_BLOCKS:
-	input_bitmap (fs) = reiserfs_create_bitmap (block_count);
-	reiserfs_bitmap_fill (input_bitmap (fs));
-	reiserfs_warning (stderr, "Whole device (%d blocks) is to be scanned\n", 
-			  reiserfs_bitmap_ones (input_bitmap (fs)));	
-	break;
-	
+		input_bitmap (fs) = reiserfs_create_bitmap (block_count);
+		reiserfs_bitmap_fill (input_bitmap (fs));
+		reiserfs_warning (stderr, "Whole device (%d blocks) is to be scanned\n", 
+						  reiserfs_bitmap_ones (input_bitmap (fs)));	
+		break;
+		
     case USED_BLOCKS:
-	reiserfs_warning (stderr, "Loading on-disk bitmap .. ");
-	input_bitmap (fs) = reiserfs_create_bitmap (block_count);
-	reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2);
-	reiserfs_warning (stderr, "%d bits set - done\n",
-			  reiserfs_bitmap_ones (input_bitmap (fs)));
-	break;
-
+		reiserfs_warning (stderr, "Loading on-disk bitmap .. ");
+		input_bitmap (fs) = reiserfs_create_bitmap (block_count);
+		reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2);
+		reiserfs_warning (stderr, "%d bits set - done\n",
+						  reiserfs_bitmap_ones (input_bitmap (fs)));
+		break;
+		
     case UNUSED_BLOCKS:
-	reiserfs_warning (stderr, "Loading on-disk bitmap .. ");
-	input_bitmap (fs) = reiserfs_create_bitmap (block_count);
-	reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2);
-	reiserfs_bitmap_invert (input_bitmap (fs));
-	reiserfs_warning (stderr, "%d bits set - done\n",
-			  reiserfs_bitmap_ones (input_bitmap (fs)));
-	break;
-	
+		reiserfs_warning (stderr, "Loading on-disk bitmap .. ");
+		input_bitmap (fs) = reiserfs_create_bitmap (block_count);
+		reiserfs_bitmap_copy (input_bitmap (fs), fs->fs_bitmap2);
+		reiserfs_bitmap_invert (input_bitmap (fs));
+		reiserfs_warning (stderr, "%d bits set - done\n",
+						  reiserfs_bitmap_ones (input_bitmap (fs)));
+		break;
+		
     case EXTERN_BITMAP:
-	fp = fopen (input_bitmap_file_name(fs), "r");
-	if (!fp)
-	    reiserfs_panic ("init_bitmap: could not load bitmap: %m\n");
-	
-	input_bitmap (fs) = reiserfs_bitmap_load (fp);
-	if (!input_bitmap (fs))
-	    reiserfs_panic ("could not load fitmap from \"%s\"", 
-			    input_bitmap_file_name(fs));
-	reiserfs_warning (stderr, "%d blocks marked in the given bitmap\n",
-			  reiserfs_bitmap_ones (input_bitmap (fs)));
-	fclose (fp);
-	break;
-
+		fp = fopen (input_bitmap_file_name(fs), "r");
+		if (!fp)
+			reiserfs_panic ("init_bitmap: could not load bitmap: %m\n");
+		
+		input_bitmap (fs) = reiserfs_bitmap_load (fp);
+		if (!input_bitmap (fs))
+			reiserfs_panic ("could not load fitmap from \"%s\"", 
+							input_bitmap_file_name(fs));
+		reiserfs_warning (stderr, "%d blocks marked in the given bitmap\n",
+						  reiserfs_bitmap_ones (input_bitmap (fs)));
+		fclose (fp);
+		break;
+		
     default:
-	reiserfs_panic ("No area to scan specified");
+		reiserfs_panic ("No area to scan specified");
     }
 }
 
@@ -417,45 +441,47 @@
 static void do_dump_tree (reiserfs_filsys_t * fs)
 {
     if (certain_block (fs)) {
-	print_one_block (fs, certain_block (fs));
-	return;
+		print_one_block (fs, certain_block (fs));
+		return;
     }
-
+	
     if (data (fs)->options & PRINT_JOURNAL || data (fs)->options & PRINT_JOURNAL_HEADER) {
-	if (!reiserfs_journal_opened (fs) && !reiserfs_open_journal (fs, data (fs)->journal_device_name, O_RDONLY)) {
-	    printf ("Could not open journal\n");
-	    return;
-	}
+		if (!reiserfs_journal_opened (fs) && 
+			reiserfs_open_journal (fs, data (fs)->journal_device_name, O_RDONLY)) 
+			{
+				printf ("Could not open journal\n");
+				return;
+			}
     }
-
+	
     print_filesystem_state (stdout, fs);
     print_block (stdout, fs, fs->fs_super_bh);
-
+	
     if (data (fs)->options & PRINT_JOURNAL)
-	print_journal (fs);
+		print_journal (fs);
 
     if (data (fs)->options & PRINT_JOURNAL_HEADER)
-	print_journal_header (fs);
-
+		print_journal_header (fs);
+	
     if (data (fs)->options & PRINT_OBJECTID_MAP)
-	print_objectid_map (stdout, fs);
-
+		print_objectid_map (stdout, fs);
+	
     if (data (fs)->options & PRINT_BITMAP)
-	print_bmap (stdout, fs, 0/*opt_print_block_map == 1 ? 1 : 0*/);
-
+		print_bmap (stdout, fs, 0/*opt_print_block_map == 1 ? 1 : 0*/);
+	
     if (data (fs)->options & PRINT_DETAILS)
         init_bitmap (fs);
-
-    if (data (fs)->options & PRINT_DETAILS || data (fs)->options & PRINT_TREE_DETAILS) {
-	if (data (fs)->options & PRINT_DETAILS)
-	    print_disk_blocks (fs);
-	else
-	    print_disk_tree (fs, get_sb_root_block (fs->fs_ondisk_sb));
 	
-	/* print the statistic */
-	printf ("File system uses %d internal + %d leaves + %d unformatted nodes = %d blocks\n",
-		g_stat_info.nr_internals, g_stat_info.nr_leaves, g_stat_info.nr_unformatted,
-		g_stat_info.nr_internals + g_stat_info.nr_leaves + g_stat_info.nr_unformatted);
+    if (data (fs)->options & PRINT_DETAILS || data (fs)->options & PRINT_TREE_DETAILS) {
+		if (data (fs)->options & PRINT_DETAILS)
+			print_disk_blocks (fs);
+		else
+			print_disk_tree (fs, get_sb_root_block (fs->fs_ondisk_sb));
+		
+		/* print the statistic */
+		printf ("File system uses %d internal + %d leaves + %d unformatted nodes = %d blocks\n",
+				g_stat_info.nr_internals, g_stat_info.nr_leaves, g_stat_info.nr_unformatted,
+				g_stat_info.nr_internals + g_stat_info.nr_leaves + g_stat_info.nr_unformatted);
     }
 }
 
@@ -468,123 +494,240 @@
     struct item_head * tmp_ih;
     __u32 i;
     __u32 * ind_item;
-
-
+	
+	
     fd = fopen (badblocks_file, "w");
-
+	
     if (fd == NULL) {
         reiserfs_warning (stderr, "debugreiserfs: could not open badblock file %s\n",
-        	badblocks_file);
+						  badblocks_file);
         exit (1);
     }
-
+	
     badblock_path.path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
-
+	
     set_type_and_offset (KEY_FORMAT_2, &badblock_key, 1, TYPE_INDIRECT);
-
+	
     while (1) {
-	reiserfs_search_by_key_4 (fs, &badblock_key, &badblock_path);
-
-	if (get_blkh_nr_items ( B_BLK_HEAD (get_bh(&badblock_path))) <= PATH_LAST_POSITION (&badblock_path)) {
+		reiserfs_search_by_key_4 (fs, &badblock_key, &badblock_path);
+		
+		if (get_blkh_nr_items ( B_BLK_HEAD (get_bh(&badblock_path))) <= PATH_LAST_POSITION (&badblock_path)) {
             break;
-	}
-
-	tmp_ih = get_ih(&badblock_path);
-	
-	if (get_key_dirid(&tmp_ih->ih_key) != (__u32)-1 ||
-	    get_key_objectid(&tmp_ih->ih_key) != (__u32)-1) {
-	    break;
-	}
-	
-	/* even if offset or type are corrupted it could be a badblock list */
-	if (!is_indirect_ih (tmp_ih)) {
-	    reiserfs_warning (stderr, "$s: a badblock item which was found has a wrong type.\n"
-	    " It probable contains not correct bad block list, check it.\n", __FUNCTION__);
-	}
-	
-	ind_item = (__u32 *)B_I_PITEM (get_bh (&badblock_path), tmp_ih);
-	for (i = 0; i < get_ih_item_len (tmp_ih) / UNFM_P_SIZE; i++, ind_item++)
-	    fprintf (fd, "%u\n", le32_to_cpu (*ind_item));
-	
-	if ((rdkey = get_next_key_2 (&badblock_path)) == NULL)	
-	    break;
-	else
-	    badblock_key = *rdkey;
-	
-	pathrelse (&badblock_path);
+		}
+		
+		tmp_ih = get_ih(&badblock_path);
+		
+		if (get_key_dirid(&tmp_ih->ih_key) != (__u32)-1 ||
+			get_key_objectid(&tmp_ih->ih_key) != (__u32)-1) {
+			break;
+		}
+		
+		/* even if offset or type are corrupted it could be a badblock list */
+		if (!is_indirect_ih (tmp_ih)) {
+			reiserfs_warning (stderr, "$s: a badblock item which was found has a wrong type.\n"
+							  " It probable contains not correct bad block list, check it.\n", __FUNCTION__);
+		}
+		
+		ind_item = (__u32 *)B_I_PITEM (get_bh (&badblock_path), tmp_ih);
+		for (i = 0; i < get_ih_item_len (tmp_ih) / UNFM_P_SIZE; i++, ind_item++)
+			fprintf (fd, "%u\n", le32_to_cpu (*ind_item));
+		
+		if ((rdkey = get_next_key_2 (&badblock_path)) == NULL)	
+			break;
+		else
+			badblock_key = *rdkey;
+		
+		pathrelse (&badblock_path);
     }
-
+	
     pathrelse (&badblock_path);
     fclose (fd);
 }
 
+static int str2int (char * str, int * res)
+{
+    int val;
+    char * tmp;
+	
+    val = (int) strtol (str, &tmp, 0);
+    if (tmp == str)
+		/* could not convert string into a number */
+		return 0;
+    *res = val;
+    return 1;
+}
+
+void do_corrupt_blocks (reiserfs_filsys_t * fs)
+{
+	char * line;
+	FILE * fd;
+	size_t n = 0;
+	int numblock;
+	
+	fd = fopen (corruption_list_file, "r");
+	if (fd == NULL) {
+		reiserfs_warning (stderr, "debugreiserfs: could not open corruption_list_file %s\n",
+						  corruption_list_file);
+		exit (1);
+	}
+	
+	while (1) {
+		line = NULL;
+		n = 0;
+		if (getline (&line, &n, fd) == -1) {
+			break;
+		}
+		
+		/* remove '\n' */
+		line [strlen (line) - 1] = '\0';
+		
+		if (str2int(line, &numblock)) {
+			data (fs)->block = (unsigned long) numblock;
+		} else {
+			do_corrupt_one_block(fs, line);
+		}
+		printf ("before free line : %s\n", line);
+		free (line);
+		printf ("after free\n");
+		reiserfs_reopen (fs, O_RDWR);
+	}
+	fclose (fd);
+	return;
+}
+
+void zero_bitmap_blocks(reiserfs_filsys_t * fs) {
+    unsigned long done, total, i;
+    struct buffer_head * bh;
+	
+    reiserfs_reopen (fs, O_RDWR);
+    
+    total = reiserfs_bitmap_ones (input_bitmap (fs));
+    done = 0;
+	
+    for (i = 0; i < input_bitmap(fs)->bm_bit_size; i ++) {
+		if (!reiserfs_bitmap_test_bit (input_bitmap(fs), i))
+			continue;
+		
+		bh = getblk(fs->fs_dev, i, fs->fs_blocksize);
+		
+		if (!bh)
+			die("Could not get block %lu\n", i);
+		
+		memset(bh->b_data, 0, fs->fs_blocksize);
+		mark_buffer_dirty(bh);
+		mark_buffer_uptodate(bh, 0);
+		
+		bwrite(bh);
+		
+		brelse (bh);
+		print_how_far (stderr, &done, total, 1, be_quiet (fs));
+    }
+	
+    fprintf(stderr, "\n");
+    fflush(stderr);
+}
+
 /* FIXME: need to open reiserfs filesystem first */
 int main (int argc, char * argv[])
 {
     char * file_name;
     int error;
     struct debugreiserfs_data * data;
-
-
+	
     print_banner ("debugreiserfs");
- 
+	
     data = getmem (sizeof (struct debugreiserfs_data));
     file_name = parse_options (data, argc, argv);
-    fs = reiserfs_open (file_name, O_RDONLY, &error, data);
+    
+    fs = reiserfs_open (file_name, O_RDONLY, &error, data, 0);
+    
     if (no_reiserfs_found (fs)) {
-	fprintf (stderr, "\n\ndumpreiserfs: can not open reiserfs on \"%s\": %s\n\n",
-		 file_name, error ? strerror (error) : "no filesystem found");
-	exit(1) ;
+		fprintf (stderr, "\n\ndebugreiserfs: can not open reiserfs on \"%s\": %s\n\n",
+				 file_name, error ? strerror (error) : "no filesystem found");
+		exit(1) ;
     }
-    reiserfs_open_journal (fs, data (fs)->journal_device_name, O_RDONLY);
-
+    
+    if (reiserfs_open_journal (fs, data (fs)->journal_device_name, O_RDONLY)) {
+		fprintf(stderr, "\ndebugreiserfs: Failed to open the fs journal.\n");
+		exit(1);
+    }
+	
     switch (debug_mode (fs)) {
     case DO_STAT:
-	init_bitmap (fs);
-	do_stat (fs);
-	break;
-
+		init_bitmap (fs);
+		do_stat (fs);
+		break;
+		
     case DO_PACK:
-	init_bitmap (fs);
-	do_pack (fs);
-	break;
-
-    case DO_CORRUPT:
-	reiserfs_reopen (fs, O_RDWR);
-	do_corrupt_one_block (fs);
-	break;
-
+		init_bitmap (fs);
+		do_pack (fs);
+		break;
+		
+    case DO_CORRUPT_ONE:
+        reiserfs_reopen (fs, O_RDWR);
+		do_corrupt_one_block (fs, (char *)NULL);
+		break;
+		
+    case DO_CORRUPT_FILE:
+        reiserfs_reopen (fs, O_RDWR);
+        do_corrupt_blocks (fs);
+		break;
+	case DO_RANDOM_CORRUPTION:
+        reiserfs_reopen (fs, O_RDWR);
+		/*
+		do_leaves_corruption (fs);
+		do_bitmap_corruption (fs);
+		*/		
+		do_fs_random_corrupt (fs);
+		break;
+		
     case DO_DUMP:
-	do_dump_tree (fs);
-	break;
-
+		do_dump_tree (fs);
+		break;
+		
     case DO_SCAN:
     case DO_SCAN_FOR_NAME:
     case DO_LOOK_FOR_NAME:
     case DO_SCAN_JOURNAL:
-	init_bitmap (fs);
-	do_scan (fs);
-	break;
-
+		init_bitmap (fs);
+		do_scan (fs);
+		break;
+		
     case DO_FILE_MAP:
-	print_map(fs);
-	break;
-
-
+		print_map(fs);
+		break;
+		
+		
     case DO_RECOVER:
-	do_recover (fs);
-	break;
-
+		do_recover (fs);
+		break;
+		
     case DO_TEST:
-	/*do_test (fs);*/
-	break;
+		/*do_test (fs);*/
+		break;
     case DO_EXTRACT_BADBLOCKS:
         reiserfs_warning (stderr, "Will try to extract list of bad blocks and save it to '%s' file\n", badblocks_file);
-	extract_badblock_list ();
+		extract_badblock_list ();
         reiserfs_warning (stderr, "Done\n\n");
     	break;
     }
-
-    reiserfs_free (fs);
+	
+    reiserfs_close (fs);
+    if (data(fs)->log) {
+		fclose (data(fs)->log); 
+    }
     return 0;
 }
+
+/*
+   Local variables:
+   c-indentation-style: "K&R"
+   mode-name: "LC"
+   c-basic-offset: 4
+   tab-width: 4
+   fill-column: 80
+   End:
+*/
+
+
+
diff --git a/debugreiserfs/debugreiserfs.h b/debugreiserfs/debugreiserfs.h
index 2950354..e7a9f2e 100644
--- a/debugreiserfs/debugreiserfs.h
+++ b/debugreiserfs/debugreiserfs.h
@@ -1,5 +1,6 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #define _GNU_SOURCE
@@ -30,17 +31,21 @@
  */
 #define DO_DUMP    		1  /* not a real dump, just printing to stdout contents of
                       			tree nodes */
-#define DO_CORRUPT 		2 /* used to make filesystem corruption and then test fsck */
-#define DO_SCAN    		3
-#define DO_RECOVER 		4
-#define DO_TEST    		6
-#define DO_PACK    		7  /* -p extract meta data of reiserfs filesystem */
-#define DO_STAT    		8
-#define DO_SCAN_FOR_NAME 	9 /* -n */
-#define DO_LOOK_FOR_NAME 	10 /* -N */
-#define DO_SCAN_JOURNAL  	11 /* -J */
-#define DO_EXTRACT_BADBLOCKS	12
-#define DO_FILE_MAP 		13
+#define DO_CORRUPT_ONE 		2 /* used to make filesystem corruption and then test fsck */
+#define DO_CORRUPT_FILE		3 /* used to make filesystem corruption and then test fsck, the list of corruption is set on the file */
+#define DO_RANDOM_CORRUPTION 4
+#define DO_SCAN    		5
+#define DO_RECOVER 		6
+#define DO_TEST    		7
+#define DO_PACK    		8  /* -p extract meta data of reiserfs filesystem */
+#define DO_STAT    		9
+#define DO_SCAN_FOR_NAME 	10 /* -n */
+#define DO_LOOK_FOR_NAME 	11 /* -N */
+#define DO_SCAN_JOURNAL  	12 /* -J */
+#define DO_EXTRACT_BADBLOCKS	13
+#define DO_FILE_MAP 		14
+#define DO_ZERO_BITMAP		15
+
 
 
 /*first bits are in reiserfs_fs.b*/
@@ -210,13 +215,13 @@
 
 
 struct debugreiserfs_data {
-    int mode; /* DO_DUMP | DO_PACK | DO_CORRUPT... */
+    int mode; /* DO_DUMP | DO_PACK | DO_CORRUPT_ONE... */
 #define USED_BLOCKS 	1
 #define EXTERN_BITMAP 	2
 #define ALL_BLOCKS 	3
 #define UNUSED_BLOCKS 	4
 
-    int scan_area; /* for -p, -s and -n */
+	int scan_area; /* for -p, -s and -n */
     char * input_bitmap; /* when ->scan_area is set to EXTERN_BITMAP */
     reiserfs_bitmap_t * bitmap; /* bitmap is read from ->input_bitmap */
     unsigned long block; /* set by -B. this is a must for -C, option for -p and -d */
@@ -228,6 +233,10 @@
 
     unsigned long options; /* -q only yet*/
     int JJ;
+  /* log file name and handle */
+    char * log_file_name;
+    FILE * log ;
+    
 };
 
 #define data(fs) ((struct debugreiserfs_data *)((fs)->fs_vp))
@@ -249,7 +258,10 @@
 void do_stat (reiserfs_filsys_t * fs);
 
 /* corruption.c */
-void do_corrupt_one_block (reiserfs_filsys_t * fs);
+void do_corrupt_one_block (reiserfs_filsys_t * fs, char * fline);
+void do_leaves_corruption (reiserfs_filsys_t * fs, unsigned long nr_leaves_cr);
+void do_bitmap_corruption (reiserfs_filsys_t * fs);
+void do_fs_random_corrupt (reiserfs_filsys_t * fs);
 
 /* recover.c */
 void do_recover (reiserfs_filsys_t * fs);
@@ -269,4 +281,15 @@
     struct saved_item * si_next; /* list of items having the same key */
 };
 
+/*
+   Local variables:
+   c-indentation-style: "K&R"
+   mode-name: "LC"
+   c-basic-offset: 4
+   tab-width: 4
+   fill-column: 80
+   End:
+*/
+
+
 
diff --git a/debugreiserfs/journal.c b/debugreiserfs/journal.c
deleted file mode 100644
index a2bf6c8..0000000
--- a/debugreiserfs/journal.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright 2002 Hans Reiser
- */
-
-#include "debugreiserfs.h"
-
-
-extern unsigned long * badblocks;
-extern int badblocks_nr;
-
-#if 0
-static void look_in_transaction (reiserfs_filsys_t * fs,
-				 reiserfs_trans_t * trans)
-{
-    struct buffer_head * d_bh, * c_bh, * logged, * in_place;
-    struct reiserfs_journal_desc * desc;
-    struct reiserfs_journal_commit * commit;
-    int i, j;
-    int who;
-
-
-    d_bh = bread (fs->fs_dev, trans->desc_blocknr, fs->fs_blocksize);
-    if (!d_bh) {
-	reiserfs_warning (stdout, "reading descriptor block %lu failed\n",
-			  trans->desc_blocknr);
-	return;
-    }
-
-    c_bh = bread (fs->fs_dev, trans->commit_blocknr, fs->fs_blocksize);
-    if (!c_bh) {
-	reiserfs_warning (stdout, "reading commit block %lu failed\n",
-			  trans->commit_blocknr);
-	brelse (d_bh);
-	return;
-    }
-
-//    desc = (struct reiserfs_journal_desc *)(d_bh->b_data);
-//    commit = (struct reiserfs_journal_commit *)(c_bh->b_data);
-
-    reiserfs_warning (stdout, "Transaction %lu\n", trans->trans_id);
-
-    for (i = 0; i < badblocks_nr; i ++) {
-	for (j = 0; j < get_jd_len (d_bh); j ++) {
-	    if ((j < JOURNAL_TRANS_HALF && badblocks [i] == le32_to_cpu (desc->j2_realblock[j])) ||
-		(j >= JOURNAL_TRANS_HALF && badblocks [i] == le32_to_cpu (commit->j3_realblock[j - JOURNAL_TRANS_HALF]))) {
-		reiserfs_warning (stdout,
-				  "\tblock %lu is logged in it (block of journal area %lu - ",
-				  badblocks [i], d_bh->b_blocknr + j + 1);
-		
-		logged = 0;
-		in_place = 0;
-
-		logged = bread (fs->fs_dev, d_bh->b_blocknr + j + 1, fs->fs_blocksize);
-		in_place = bread (fs->fs_dev, badblocks [i], fs->fs_blocksize);
-		if (!logged || !in_place) {
-		    reiserfs_warning (stdout, "Could not read blocks\n");
-		    brelse (logged);
-		    brelse (in_place);
-		    continue;
-		}
-
-		who = who_is_this (logged->b_data, logged->b_size);
-		if (who != THE_LEAF && who != HAS_IH_ARRAY) {
-		    brelse (logged);
-		    brelse (in_place);
-		    continue;
-		}
-
-		reiserfs_warning (stdout, "%s\n", which_block (who));
-		if (data (fs)->JJ > 1) {
-		    /* overwrite in-place block with a logged version */
-		    if (who_is_this (in_place->b_data, in_place->b_size) == THE_LEAF)
-			reiserfs_warning (stderr, "Block %d is leaf already, skip it\n",
-					  in_place->b_blocknr);
-		    else {
-			memcpy (in_place->b_data, logged->b_data, fs->fs_blocksize);
-			mark_buffer_dirty (in_place);
-			bwrite (in_place);
-			if (input_bitmap (fs))
-			    reiserfs_bitmap_set_bit (input_bitmap (fs), in_place->b_blocknr);
-		    }
-		}
-
-		brelse (logged);
-		brelse (in_place);
-	    }
-	}
-    }
-
-    brelse (d_bh);
-    brelse (c_bh);
-}
-    
-/* go through all transactions in the journal to check whether block is there */
-static void find_in_journal (reiserfs_filsys_t * fs)
-{
-    for_each_transaction (fs, look_in_transaction);
-}
-#endif
-
-#define BLOCK_IN_Q 12762
-
-static void check_block_9555 (reiserfs_filsys_t * fs, reiserfs_trans_t * trans,
-			      int index,
-			      unsigned long in_journal, unsigned long in_place)
-{
-    struct buffer_head * bh;
-    
-
-    if (in_place == 17) {
-	/* read block of journal which contains block 17 abd check whether bit
-	   BLOCK_IN_Q is set */
-	bh = bread (fs->fs_journal_dev, in_journal, fs->fs_blocksize);
-	if (!bh) {
-	    reiserfs_warning (stderr, "could not read block %lu (of journal area)\n",
-			      in_journal);
-	    return;
-	}
-	
-	if (test_bit (BLOCK_IN_Q, bh->b_data))
-	    reiserfs_warning (stdout, "trans %lu, pos %d - block 17: block %d is marked used in it\n",
-			      trans->trans_id, index, BLOCK_IN_Q);
-	else
-	    reiserfs_warning (stdout, "trans %lu, pos %d - block 17: block %d is marked free in it\n",
-			      trans->trans_id, index, BLOCK_IN_Q);
-	brelse (bh);
-    }
-
-    if (in_place == BLOCK_IN_Q) {
-	reiserfs_warning (stdout, "trans %lu, block %d is logged at pos %d\n",
-			  trans->trans_id, BLOCK_IN_Q, index);
-    }
-}
-
-
-/* remove when the problem is found */
-static void check_transaction (reiserfs_filsys_t * fs, reiserfs_trans_t * trans)
-{
-    for_each_block (fs, trans, check_block_9555);
-}
-
-
-void scan_journal (reiserfs_filsys_t * fs)
-{
-    for_each_transaction (fs, check_transaction);
-}
-
-
-
-#if 0
-/* read block numbers from stdin, look for them in the journal, and (if -JJ is
-   given) write then "in-place" amd mark overwritten blocks used in the bitmap
-   specified with -b */
-void scan_journal (reiserfs_filsys_t * fs)
-{
-    char * str = 0;
-    size_t n = 0;
-
-
-    /* store all blocks which come from stdin */
-    while (1) {
-	if (getline (&str, &n, stdin) == -1)
-	    break;
-	if (!strcmp (str, "\n"))
-	    break;
-	str [strlen (str) - 1] = 0;
-
-	badblocks = realloc (badblocks, (badblocks_nr + 1) * 4);
-	if (!badblocks)
-	    reiserfs_panic ("realloc failed");
-	badblocks [badblocks_nr ++] = atol (str);
-
-	free (str);
-	str = 0;
-	n = 0;
-    }
-
-    if (data (fs)->JJ > 1)
-	reiserfs_reopen (fs, O_RDWR);
-    reiserfs_warning (stdout, "%d blocks given\n", badblocks_nr); fflush (stdout);
-    find_in_journal (fs);
-
-    if (data (fs)->JJ > 1 && input_bitmap (fs)) {
-	FILE * fp;
-
-	fp = fopen (input_bitmap_file_name (fs), "w+");
-	if (!fp) {
-	    reiserfs_warning (stderr, "reiserfs_bitmap_save: could not save bitmap in %s: %m",
-			      input_bitmap_file_name (fs));
-	    return;
-	}
-	reiserfs_bitmap_save (fp, input_bitmap (fs));
-	fclose (fp);
-    }
-}
-#endif
diff --git a/debugreiserfs/pack.c b/debugreiserfs/pack.c
index 4a3d155..48f2709 100644
--- a/debugreiserfs/pack.c
+++ b/debugreiserfs/pack.c
@@ -1,6 +1,6 @@
-
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "debugreiserfs.h"
@@ -147,7 +147,7 @@
 static void pack_indirect (struct packed_item * pi, struct buffer_head * bh, 
 			   struct item_head * ih)
 {
-    int i;
+    unsigned int i;
     __u32 * ind_item;
     __u16 len;
 
@@ -305,14 +305,14 @@
             set_pi_mask (pi, get_pi_mask (pi) | NLINK_BITS_32);
 	    nlink32 = sd->sd_nlink;
 	} else {
-            /* This is required to deal w/ big endian systems */
+            /* This is required to deal with big endian systems */
 	    nlink16 = cpu_to_le16 ((__u16)sd_v2_nlink (sd));
 	}
 	if (sd_v2_size (sd) > 0xffffffff) {
             set_pi_mask (pi, get_pi_mask (pi) | SIZE_BITS_64);
 	    size64 = sd->sd_size;
 	} else {
-            /* This is required to deal w/ big endian systems */
+            /* This is required to deal with big endian systems */
 	    size32 = cpu_to_le32 ((__u32)sd_v2_size (sd));
 	}
 
@@ -561,11 +561,11 @@
 /* super block, journal, bitmaps */
 static void pack_frozen_data (reiserfs_filsys_t * fs)
 {
-    int i;
     struct buffer_head * bh;
     unsigned long block;
     __u16 magic16;
     int sent_journal_start_magic = 0;
+    unsigned int i;
     
     if (is_reiserfs_jr_magic_string(fs->fs_ondisk_sb) &&
 	get_jp_journal_dev(sb_jp(fs->fs_ondisk_sb)) &&
@@ -646,12 +646,12 @@
 /* pack all "not data blocks" and correct leaf */
 void pack_partition (reiserfs_filsys_t * fs)
 {
-    int i;
     struct buffer_head * bh;
     __u32 magic32;
     __u16 blocksize;
     __u16 magic16;
     unsigned long done = 0, total;
+    unsigned int i;
     
 
     magic32 = REISERFS_SUPER_MAGIC;
@@ -724,6 +724,9 @@
     
     bh = bread (fs->fs_dev, block, fs->fs_blocksize);
 
+    if (!bh) 
+	return;
+
     if (who_is_this (bh->b_data, bh->b_size) == THE_LEAF)
 	pack_leaf (fs, bh);
     else
@@ -738,93 +741,3 @@
     fprintf (stderr, "Done\n");
 }
 
-
-#if 0
-//
-// this test program has two modes: 'pack file blocknr'
-// and 'unpack file'
-// in the first mode blocknr-th 4k block of the 'file' will be packed out to stdout
-// the the second mode standard input will be converted to the reiserfs leaf on 'file'
-//
-static int do_unpack (char * file)
-{
-    char * buf;
-    int fd;
-
-    fd = open (file, O_RDONLY);
-    if (fd == -1) {
-	perror ("open failed");
-	return 0;
-    }
-    
-    buf = malloc (4096);
-    if (!buf) {
-	perror ("malloc failed");
-	return 0;
-    }
-
-    fread (buf, 4096, 1, stdin);
-    if (!feof (stdin)) {
-	printf ("fread returned not eof\n");
-	return 0;
-    }
-
-    unpack_leaf (buf, fd);
-
-    free (buf);
-    close (fd);
-    return 0;
-}
-
-static int do_pack (char * file, unsigned long block)
-{
-    int fd;
-    struct buffer_head * bh;
-    char * buf;
-    int len;
-
-    fprintf (stderr, "dumping block %d of the \"%s\"\n", block, file);
-
-    fd = open (file, O_RDONLY);
-    if (fd == -1) {
-	perror ("open failed");
-	return 0;
-    }
-    
-    bh = bread (fd, block, 4096);
-    if (!bh) {
-	fprintf (stderr, "bread failed\n");
-	return 0;
-    }
-
-    if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
-	fprintf (stderr, "block %d is not a leaf\n", block);
-	return 0;
-    }
-
-    len = pack_leaf (bh, buf);
-    fwrite (buf, len, 1, stdout);
-
-    free (buf);
-    close (fd);
-    return 0;
-}
-
-
-int main (int argc, char ** argv)
-{
-    if (argc == 3 && !strcmp (argv[1], "unpack"))
-	return do_unpack (argv[2]);
-
-    if (argc == 4 && !strcmp (argv[1], "pack"))
-	return do_pack (argv[2], atoi (argv[3]));
-
-    fprintf (stderr, "Usage: \n\t%s pack filename block\nor\n"
-	     "\t%s unpack filename\n", argv[0], argv[0]);
-    return 0;
-}
-
-#endif /* 0 */
-
-
-
diff --git a/debugreiserfs/recover.c b/debugreiserfs/recover.c
index 7a65835..4ea48b4 100644
--- a/debugreiserfs/recover.c
+++ b/debugreiserfs/recover.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "debugreiserfs.h"
@@ -264,7 +265,8 @@
     int size = sizeof(struct saved_item) - sizeof(struct saved_item *);
     struct saved_item *map = NULL;
     __u32 map_size = 0;
-    int i, start = 0, j;
+    int start = 0;
+    unsigned int i, j;
     __u64 offset = 0, length;
     long int result = 0;
     unsigned long unfm_ptr;
@@ -285,7 +287,7 @@
 	if (i == map_size / sizeof(struct saved_item)) {
 	    if (start != -1) {
 		reiserfs_print_item(stdout, bh, B_N_PITEM_HEAD (bh, (cur - 1)->si_item_num));
-		result = get_answer((long int)i - start) + start;
+		result = get_answer(i - start) + start;
 	    } else {
 		result = i - 1;
 	    }
diff --git a/debugreiserfs/scan.c b/debugreiserfs/scan.c
index c0b1a23..18a253d 100644
--- a/debugreiserfs/scan.c
+++ b/debugreiserfs/scan.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "debugreiserfs.h"
@@ -169,7 +170,7 @@
 /* take each name matching to a given pattern, */
 static void scan_for_name (struct buffer_head * bh)
 {
-    int i, j;
+    int i, j, i_num;
     struct item_head * ih;
     struct reiserfs_de_head * deh;
     int namelen;
@@ -181,7 +182,8 @@
     int ih_entry_count = 0;
 
     ih = B_N_PITEM_HEAD (bh, 0);
-    for (i = 0; i < B_NR_ITEMS (bh); i ++, ih ++) {
+    i_num = leaf_item_number_estimate(bh);
+    for (i = 0; i < i_num; i ++, ih ++) {
 	if (!is_direntry_ih (ih))
 	    continue;
 	if (is_it_bad_item (fs, ih, B_I_PITEM (bh, ih), 0, 1))
@@ -254,14 +256,15 @@
    item in the sorted list of items of a file */
 static void scan_items (struct buffer_head * bh)
 {
-    int i;
+    int i, i_num;
     struct item_head * ih;
     struct saved_name * name_in_store;
     void * res;
 
 
     ih = B_N_PITEM_HEAD (bh, 0);
-    for (i = 0; i < B_NR_ITEMS (bh); i ++, ih ++) {
+    i_num = leaf_item_number_estimate(bh);
+    for (i = 0; i < i_num; i ++, ih ++) {
 	res = tfind (&ih->ih_key, &key_index, comp_pointed);
 	if (!res)
 	    /* there were no names pointing to this key */
@@ -340,7 +343,7 @@
 {
     int i;
     int padd;
-    loff_t off = get_offset (&ih->ih_key);
+    unsigned long long off = get_offset (&ih->ih_key);
 
     if (is_indirect_ih (ih)) {
 
@@ -354,8 +357,7 @@
 	map.head_len += (padd + I_UNFM_NUM (ih));
 
     } else if (is_direct_ih (ih)) {
-	int tail_start;
-	int skip;
+	unsigned int tail_start, skip;
 	
 	// find correct tail first 
 	tail_start = (off & ~(fs->fs_blocksize - 1)) + 1;
@@ -391,18 +393,18 @@
 // map contains 
 static void do_overwrite (struct item_head * ih, void * data)
 {
-    int skip; // now may bytes/pointers to skip 
-    int to_compare;
-    int to_append;
-    loff_t off = get_offset (&ih->ih_key);
-    char * p;
+    unsigned long long off, skip;
+    int to_compare, to_append;
     struct item_head tmp_ih;
+    char * p;
+    
+    off = get_offset (&ih->ih_key);
     
     if (is_indirect_ih (ih)) {
 
 	skip = (off - 1) / fs->fs_blocksize;
-	to_compare = (map.head_len - skip > I_UNFM_NUM (ih)) ? I_UNFM_NUM (ih) :
-	    (map.head_len - skip);
+	to_compare = (map.head_len - skip > I_UNFM_NUM (ih)) ? 
+	    I_UNFM_NUM (ih) : (map.head_len - skip);
 	to_append = I_UNFM_NUM (ih) - to_compare;
 	
 	p = (char *)map.head + skip * 4;
@@ -418,7 +420,7 @@
 	}
 
     } else if (is_direct_ih (ih)) {
-	int tail_start;
+	unsigned int tail_start;
 	int i;
 
 	// find correct tail first 
@@ -652,12 +654,16 @@
 
     print_items(fp, fs);
     
-    if (fp != stdin)
+    if (fp != stdin) {
 	fclose (fp); 
+	fp = NULL;
+    }
 }
 
 
 static FILE *fp = 0;
+FILE * log_to;
+
 static void save_items(const void *nodep, VISIT value, int level) {
     struct saved_item *item;
     
@@ -683,7 +689,7 @@
     if (value == leaf || value == postorder) {
 	while (name) {
 	    asprintf(&file_name, "%s.%d", map_file(fs), ++nr);
-	    reiserfs_warning (stdout, "%d - (%d): [%K]:\"%s\": stored in the %s\n", 
+	    reiserfs_warning (log_to, "%d - (%d): [%K]:\"%s\": stored in the %s\n", 
 		nr, name->count, &name->parent_dirid, name->name, file_name);
 	    
 	    if (fp == 0) {
@@ -697,6 +703,7 @@
 
 	    name = name->name_next;
 	    fclose(fp);
+	    fp = NULL;
 	    free(file_name);
 	}
     }
@@ -800,25 +807,23 @@
     }
 }
 
-
-FILE * log;
-
 static void scan_for_key (struct buffer_head * bh, struct key * key)
 {
-    int i, j;
+    int i, j, i_num;
     struct item_head * ih;
     struct reiserfs_de_head * deh;
     int min_entry_size = 1;
     int ih_entry_count = 0;
 
-
     ih = B_N_PITEM_HEAD (bh, 0);
-    for (i = 0; i < B_NR_ITEMS (bh); i ++, ih ++) {
-	if ((get_key_dirid (&ih->ih_key) == get_key_dirid (key) || 
-	     (int)get_key_dirid (key) == -1) &&
-	    (get_key_objectid (&ih->ih_key) == get_key_objectid (key) || 
-	     (int)get_key_objectid (key) == -1)) {
-	    reiserfs_warning (log, "%d-th item of block %lu is item of file %K: %H\n",
+    i_num = leaf_item_number_estimate(bh);
+    for (i = 0; i < i_num; i ++, ih ++) {
+	if ((get_key_dirid(&ih->ih_key) == get_key_dirid(key) || 
+	     get_key_dirid(key) == ~0ul) &&
+	    (get_key_objectid(&ih->ih_key) == get_key_objectid(key) || 
+	     get_key_objectid(key) == ~0ul)) 
+	{
+	    reiserfs_warning(log_to, "%d-th item of block %lu is item of file %K: %H\n",
 			      i, bh->b_blocknr, key, ih);
 	}
 	if (!is_direntry_ih (ih))
@@ -835,7 +840,7 @@
 	for (j = 0; j < ih_entry_count; j ++, deh ++) {
 	    if ((get_deh_dirid (deh) == get_key_dirid (key) || (int)get_key_dirid (key) == -1) &&
 		(get_deh_objectid (deh) == get_key_objectid (key) || (int)get_key_objectid (key) == -1)) {
-		reiserfs_warning (log, "dir item %d (%H) of block %lu has "
+		reiserfs_warning (log_to, "dir item %d (%H) of block %lu has "
 				  "entry (%d-th) %.*s pointing to %K\n",
 				  i, ih, bh->b_blocknr, j,
 				  name_in_entry_length (ih, deh, j), name_in_entry (deh, j), key);
@@ -857,12 +862,6 @@
     struct key key = {0, 0, };
     unsigned long done, total;
 
-
-    if (debug_mode (fs) == DO_SCAN_JOURNAL) {
-	scan_journal (fs);
-	return;
-    }
-
     if (debug_mode (fs) == DO_LOOK_FOR_NAME) {
 	/* look for a file in using tree algorithms */
 	look_for_name (fs);
@@ -879,7 +878,7 @@
 
     total = reiserfs_bitmap_ones (input_bitmap (fs));
 
-    log = fopen ("scan.log", "w+");
+    log_to = fopen ("scan.log", "w+");
     printf ("Log file 'scan.log' is opened\n");
 
     if (debug_mode (fs) == DO_SCAN_FOR_NAME) {
@@ -928,6 +927,7 @@
 	    reiserfs_bitmap_clear_bit (input_bitmap (fs), i);
 	    break;
 	case THE_LEAF:
+	case HAS_IH_ARRAY:
 	    if (debug_mode (fs) == DO_SCAN_FOR_NAME) {
 		scan_for_name (bh);
 	    } else if (get_key_dirid (&key)) {
@@ -959,6 +959,8 @@
     total = reiserfs_bitmap_ones (input_bitmap (fs));
     printf ("%ld bits set in bitmap\n", total);
     for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
+	int type;
+	
 	if (!reiserfs_bitmap_test_bit (input_bitmap (fs), i))
 	    continue;
 	bh = bread (fs->fs_dev, i, fs->fs_blocksize);
@@ -966,7 +968,8 @@
 	    printf ("could not read block %lu\n", i);
 	    continue;
 	}
-	if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
+	type = who_is_this (bh->b_data, bh->b_size);
+	if (type != THE_LEAF && type != HAS_IH_ARRAY) {
 	    brelse (bh);
 	    continue;
 	}
diff --git a/debugreiserfs/stat.c b/debugreiserfs/stat.c
index 81e5125..1da15f1 100644
--- a/debugreiserfs/stat.c
+++ b/debugreiserfs/stat.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2002-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "debugreiserfs.h"
@@ -114,14 +115,15 @@
 
 static void stat1_the_leaf (reiserfs_filsys_t * fs, struct buffer_head * bh)
 {
-    int i;
+    int i, i_num;
     struct item_head * ih;
     int is_there_unique_item;
 
 
     ih = B_N_PITEM_HEAD (bh, 0);
     is_there_unique_item = 0;
-    for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
+    i_num = leaf_item_number_estimate(bh);
+    for (i = 0; i < i_num; i ++, ih ++) {
 	/* count all items */
 	fs_stat.all ++;
 
@@ -140,7 +142,7 @@
     } else {
 	ih = B_N_PITEM_HEAD (bh, 0);
 	/* node contains at least one unique item. We will put it in, count items of each type */
-	for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
+	for (i = 0; i < i_num; i ++, ih ++) {
 	    fs_stat.items [get_type (&ih->ih_key)] ++;
 	}
     }
@@ -178,10 +180,6 @@
     return;
 */
 
-
-
-    total = reiserfs_bitmap_ones (input_bitmap (fs));
-
     /* pass 0 of stating */
     total = reiserfs_bitmap_ones (input_bitmap (fs));
     done = 0;
@@ -197,7 +195,7 @@
 	    continue;
 	}
 	type = who_is_this (bh->b_data, bh->b_size);
-	if (type != THE_LEAF) {
+	if (type != THE_LEAF && type != HAS_IH_ARRAY) {
 	    reiserfs_bitmap_clear_bit (input_bitmap (fs), i);
 	    brelse (bh);
 	    continue;
diff --git a/debugreiserfs/unpack.c b/debugreiserfs/unpack.c
index 9f2028c..b8f85fa 100644
--- a/debugreiserfs/unpack.c
+++ b/debugreiserfs/unpack.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
   
 #include "debugreiserfs.h"
@@ -88,8 +89,8 @@
     int location;
     char * item;
 
-    if (!hash_func)
-	die ("unpack_direntry: hash function is not set");
+/*    if (!hash_func)
+	die ("unpack_direntry: hash function is not set");*/
 
     if (!(get_pi_mask(pi) & IH_FREE_SPACE))
         die ("ih_entry_count must be packed for directory items");
@@ -126,7 +127,7 @@
 	else if (*(item + location) == '.' && *(item + location + 1) == '.' && namelen == 2)
 	    /* old or new ".." */
 	    set_deh_offset (deh, DOT_DOT_OFFSET);
-	else
+	else if (hash_func)
 	    set_deh_offset (deh, GET_HASH_VALUE (hash_func (item + location,
 							    namelen)));
 	if (mask & HAS_GEN_COUNTER) {
@@ -488,7 +489,7 @@
 // read packed reiserfs partition metadata from stdin
 void unpack_partition (int fd, int jfd)
 {
-    __u32 magic32;
+    __u32 magic32, position;
     __u16 magic16;
     __u16 blocksize;
     int dev = fd;
@@ -562,13 +563,18 @@
 	    break;
 	    
 	case END_MAGIC:
-	    break;
+	    goto out;
 
 	default:
-	    die ("unpack_partition: bad magic found - %x", magic16 & 0xff);
+	    position = ftell(stdin);
+	    if (position == ~0ul)
+		die ("unpack_partition: bad magic found - %x", magic16 & 0xff);
+	    else
+		die ("unpack_partition: bad magic found - %x, position %lu", 
+		    magic16 & 0xff, ftell(stdin));
 	}
     }
-
+out:
     fprintf (stderr, "Unpacked %d leaves, %d full blocks\n", leaves, full);
 
 
diff --git a/depcomp b/depcomp
new file mode 100755
index 0000000..807b991
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,423 @@
+#! /bin/sh
+
+# depcomp - compile a program generating dependencies as side-effects
+# Copyright 1999, 2000 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+# `libtool' can also be set to `yes' or `no'.
+
+if test -z "$depfile"; then
+   base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
+   dir=`echo "$object" | sed 's,/.*$,/,'`
+   if test "$dir" = "$object"; then
+      dir=
+   fi
+   # FIXME: should be _deps on DOS.
+   depfile="$dir.deps/$base"
+fi
+
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> $depfile
+    echo >> $depfile
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> $depfile
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  This file always lives in the current directory.
+  # Also, the AIX compiler puts `$object:' at the start of each line;
+  # $object doesn't have directory information.
+  stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
+  tmpdepfile="$stripped.u"
+  outname="$stripped.o"
+  if test "$libtool" = yes; then
+    "$@" -Wc,-M
+  else
+    "$@" -M
+  fi
+
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      tmpdepfile1="$dir.libs/$base.lo.d"
+      tmpdepfile2="$dir.libs/$base.d"
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1="$dir$base.o.d"
+      tmpdepfile2="$dir$base.d"
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2"
+      exit $stat
+   fi
+
+   if test -f "$tmpdepfile1"; then
+      tmpdepfile="$tmpdepfile1"
+   else
+      tmpdepfile="$tmpdepfile2"
+   fi
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a space and a tab in the [].
+      sed -e 's,^.*\.[a-z]*:[ 	]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.  We will use -o /dev/null later,
+  # however we can't do the remplacement now because
+  # `-o $object' might simply not be used
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  "$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ 	]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # X makedepend
+  shift
+  cleared=no
+  for arg in "$@"; do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    -*)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  "$@" || exit $?
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+	set fnord "$@"
+	shift
+	shift
+	;;
+    *)
+	set fnord "$@" "$arg"
+	shift
+	shift
+	;;
+    esac
+  done
+  "$@" -E |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
+  echo "	" >> "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
diff --git a/fsck/Makefile.am b/fsck/Makefile.am
index 29d7b4a..b93c8ae 100644
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -7,5 +7,5 @@
 man_MANS = reiserfsck.8
 EXTRA_DIST = $(man_MANS)
 
-LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+LDADD = $(LDFLAGS) $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
 
diff --git a/fsck/Makefile.in b/fsck/Makefile.in
index bd929cd..5476496 100644
--- a/fsck/Makefile.in
+++ b/fsck/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,167 +12,243 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 sbin_PROGRAMS = reiserfsck
 
-reiserfsck_SOURCES = main.c pass0.c pass1.c pass2.c semantic_check.c semantic_rebuild.c pass4.c lost+found.c ubitmap.c uobjectid.c ustree.c ufile.c check_tree.c info.c super.c fsck.h
+reiserfsck_SOURCES = main.c pass0.c pass1.c pass2.c semantic_check.c \
+semantic_rebuild.c pass4.c lost+found.c ubitmap.c uobjectid.c ustree.c \
+ufile.c check_tree.c info.c super.c fsck.h
 
 
 man_MANS = reiserfsck.8
 EXTRA_DIST = $(man_MANS)
 
-LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+LDADD = $(LDFLAGS) $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+subdir = fsck
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../include/config.h
-CONFIG_CLEAN_FILES = 
-PROGRAMS =  $(sbin_PROGRAMS)
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+sbin_PROGRAMS = reiserfsck$(EXEEXT)
+PROGRAMS = $(sbin_PROGRAMS)
 
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I../include
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-reiserfsck_OBJECTS =  main.o pass0.o pass1.o pass2.o semantic_check.o \
-semantic_rebuild.o pass4.o lost+found.o ubitmap.o uobjectid.o ustree.o \
-ufile.o check_tree.o info.o super.o
+am_reiserfsck_OBJECTS = main.$(OBJEXT) pass0.$(OBJEXT) pass1.$(OBJEXT) \
+	pass2.$(OBJEXT) semantic_check.$(OBJEXT) \
+	semantic_rebuild.$(OBJEXT) pass4.$(OBJEXT) lost+found.$(OBJEXT) \
+	ubitmap.$(OBJEXT) uobjectid.$(OBJEXT) ustree.$(OBJEXT) \
+	ufile.$(OBJEXT) check_tree.$(OBJEXT) info.$(OBJEXT) \
+	super.$(OBJEXT)
+reiserfsck_OBJECTS = $(am_reiserfsck_OBJECTS)
 reiserfsck_LDADD = $(LDADD)
-reiserfsck_DEPENDENCIES =  $(top_srcdir)/lib/libmisc.a \
-$(top_srcdir)/reiserfscore/libcore.a
-reiserfsck_LDFLAGS = 
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+reiserfsck_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
+	$(top_srcdir)/reiserfscore/libcore.a
+reiserfsck_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/check_tree.Po ./$(DEPDIR)/info.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/lost+found.Po ./$(DEPDIR)/main.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/pass0.Po ./$(DEPDIR)/pass1.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/pass2.Po ./$(DEPDIR)/pass4.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/semantic_check.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/semantic_rebuild.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/super.Po ./$(DEPDIR)/ubitmap.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/ufile.Po ./$(DEPDIR)/uobjectid.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/ustree.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-man8dir = $(mandir)/man8
-MANS = $(man_MANS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(reiserfsck_SOURCES)
 
 NROFF = nroff
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
+MANS = $(man_MANS)
+DIST_COMMON = Makefile.am Makefile.in
 SOURCES = $(reiserfsck_SOURCES)
-OBJECTS = $(reiserfsck_OBJECTS)
 
-all: all-redirect
+all: all-am
+
 .SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps fsck/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-sbinPROGRAMS:
-
-clean-sbinPROGRAMS:
-	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
-
-distclean-sbinPROGRAMS:
-
-maintainer-clean-sbinPROGRAMS:
-
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  fsck/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(sbindir)
 	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  if test -f $$p; then \
-	    echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
-	     $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \
 	  else :; fi; \
 	done
 
 uninstall-sbinPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
+	  rm -f $(DESTDIR)$(sbindir)/$$f; \
 	done
 
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+reiserfsck$(EXEEXT): $(reiserfsck_OBJECTS) $(reiserfsck_DEPENDENCIES) 
+	@rm -f reiserfsck$(EXEEXT)
+	$(LINK) $(reiserfsck_LDFLAGS) $(reiserfsck_OBJECTS) $(reiserfsck_LDADD) $(LIBS)
 
 mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
+	-rm -f *.$(OBJEXT) core *.core
 
 distclean-compile:
 	-rm -f *.tab.c
 
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_tree.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lost+found.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pass0.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pass1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pass2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pass4.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/semantic_check.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/semantic_rebuild.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/super.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ubitmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ufile.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uobjectid.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ustree.Po@am__quote@
 
-reiserfsck: $(reiserfsck_OBJECTS) $(reiserfsck_DEPENDENCIES)
-	@rm -f reiserfsck
-	$(LINK) $(reiserfsck_LDFLAGS) $(reiserfsck_OBJECTS) $(reiserfsck_LDADD) $(LIBS)
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
 
-install-man8:
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+man8dir = $(mandir)/man8
+install-man8: $(man8_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(man8dir)
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
@@ -179,194 +257,212 @@
 	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
 	  else file=$$i; fi; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \
 	  $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \
 	done
-
 uninstall-man8:
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@$(NORMAL_UNINSTALL)
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
 	done; \
 	for i in $$list; do \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \
 	  rm -f $(DESTDIR)$(man8dir)/$$inst; \
 	done
-install-man: $(MANS)
-	@$(NORMAL_INSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) install-man8
-uninstall-man:
-	@$(NORMAL_UNINSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) uninstall-man8
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = fsck
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-check_tree.o: check_tree.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-info.o: info.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-lost+found.o: lost+found.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-main.o: main.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-pass0.o: pass0.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-pass1.o: pass1.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-pass2.o: pass2.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-pass4.o: pass4.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-semantic_check.o: semantic_check.c fsck.h ../include/io.h \
-	../include/misc.h ../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-semantic_rebuild.o: semantic_rebuild.c fsck.h ../include/io.h \
-	../include/misc.h ../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-super.o: super.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-ubitmap.o: ubitmap.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-ufile.o: ufile.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-uobjectid.o: uobjectid.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-ustree.o: ustree.c fsck.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am: install-sbinPROGRAMS
-install-exec: install-exec-am
+all-am: Makefile $(PROGRAMS) $(MANS)
 
-install-data-am: install-man
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir)
+
+install: install-am
+install-exec: install-exec-am
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-sbinPROGRAMS uninstall-man
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS) $(MANS)
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-	$(mkinstalldirs)  $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-sbinPROGRAMS mostlyclean-compile \
-		mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-sbinPROGRAMS clean-compile clean-tags clean-generic \
-		mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-sbinPROGRAMS distclean-compile distclean-tags \
-		distclean-generic clean-am
+clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-sbinPROGRAMS \
-		maintainer-clean-compile maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-exec-am: install-sbinPROGRAMS
+
+install-info: install-info-am
+
+install-man: install-man8
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
-clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
-install-sbinPROGRAMS mostlyclean-compile distclean-compile \
-clean-compile maintainer-clean-compile install-man8 uninstall-man8 \
-install-man uninstall-man tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-man uninstall-sbinPROGRAMS
+
+uninstall-man: uninstall-man8
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-sbinPROGRAMS ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-man8 install-sbinPROGRAMS \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-info-am uninstall-man \
+	uninstall-man8 uninstall-sbinPROGRAMS
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/fsck/check_tree.c b/fsck/check_tree.c
index 1a83ab0..44d5709 100644
--- a/fsck/check_tree.c
+++ b/fsck/check_tree.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 1999, 2000, 2001, 2002 Hans Reiser
+ * Copyright 1999-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "fsck.h"
@@ -11,7 +12,7 @@
     struct check_relocated * next;
 };
 
-struct check_relocated * relocated_list;
+static struct check_relocated * relocated_list;
 
 void to_be_relocated (struct key * key)
 {
@@ -34,32 +35,51 @@
         new_relocated->next = prev->next;
         prev->next = new_relocated;
     } else {
-        new_relocated->next = 0;
+        new_relocated->next = relocated_list;
         relocated_list = new_relocated;
     }
 }
 
 int should_be_relocated (struct key * key)
 {
-    struct check_relocated * cur, * next;
+    struct check_relocated *cur, *prev;
     int ret = 0;
 
+    if (!key)
+	return 0;
+    
     cur = relocated_list;
 
+    prev = NULL;
     while (cur && comp_short_keys(key, (struct key *)cur) != 1) {
 	if (comp_short_keys (key, (struct key *)cur) == 0) {
 	    ret = 1;
 	    break;
 	}
-        cur = cur->next;
+	prev = cur;
+	cur = cur->next;
     }
-        
-    while (relocated_list != cur) {
+ 
+    if (ret) {
+	/* cur is found */
+	if (prev) /* not the first */
+	    prev->next = cur->next;
+	else /* first */
+	    relocated_list = cur->next;
+	freemem (cur);
+    }
+ 
+    return ret;    
+}
+
+void clear_relocated_list() {
+    struct check_relocated *next;
+
+    while (relocated_list) {
         next = relocated_list->next;
         freemem (relocated_list);
         relocated_list = next;
     }
-    return ret;    
 }
 
 //
@@ -116,7 +136,7 @@
 
 static void init_control_bitmap (reiserfs_filsys_t * fs)
 {
-    int i;
+    unsigned int i;
     unsigned long block;
     unsigned long reserved;
     
@@ -223,8 +243,8 @@
         } else if (problem) {
 	    fsck_log ("vpf-10640: The on-disk and the correct bitmaps differs.\n");	    
             while (problem) {
-                /* fixable corruptions because we can try to recover them w/out rebuilding the tree */
-        	one_more_corruption (fs, fixable); 
+                /* fixable corruptions because we can try to recover them without rebuilding the tree */
+        	one_more_corruption (fs, FIXABLE); 
         	problem --;
             }
         }
@@ -234,6 +254,21 @@
     return;
 }
 
+static int auto_handle_bitmaps (reiserfs_filsys_t *fs) {
+    unsigned long i;
+    
+    if (source_bitmap->bm_byte_size != control_bitmap->bm_byte_size)
+	return -1;
+    
+    for (i = 0; i < source_bitmap->bm_byte_size; i ++) {
+	if (control_bitmap->bm_map[i] & ~source_bitmap->bm_map[i]) {
+	    return 1;
+	}
+    }
+    
+    return 0;
+}
+
 
 /* is this block legal to be pointed to by some place of the tree? */
 static int bad_block_number (reiserfs_filsys_t * fs, unsigned long block)
@@ -276,58 +311,12 @@
     return 0;
 }
 
-
-/* 1 if some of fields in the block head of bh look bad */
-static int bad_block_head (reiserfs_filsys_t * fs, struct buffer_head * bh)
-{
-    struct block_head * blkh;
-    int sum_length = 0;
-
-    blkh = B_BLK_HEAD (bh);
-    if (get_blkh_nr_items (blkh) > (bh->b_size - BLKH_SIZE) / IH_SIZE) {
-	fsck_log ("block %lu: The number of items (%u) exceeds the limit.\n",
-		  bh->b_blocknr, get_blkh_nr_items (blkh));
-	one_more_corruption (fs, fatal);
-	return 1;
-    }
-
-    if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF) {
-	fsck_log ("block %lu: The block has wrong structure of items.\n", bh->b_blocknr);
-        one_more_corruption (fs, fatal);
-	return 1;
-    }
-
-    sum_length = (get_blkh_nr_items (blkh) > 0) ?
-	get_ih_location (B_N_PITEM_HEAD (bh, get_blkh_nr_items (blkh) - 1)) : bh->b_size;
-
-    if (get_blkh_free_space (blkh) !=
-	sum_length - BLKH_SIZE - IH_SIZE * get_blkh_nr_items (blkh))
-    {
-	fsck_log ("block %lu: The free space (%lu) is incorrect, should be (%lu)",
-		bh->b_blocknr, get_blkh_free_space (blkh), sum_length - BLKH_SIZE - IH_SIZE * get_blkh_nr_items (blkh) );
-	if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
-	    set_blkh_free_space (blkh, sum_length - BLKH_SIZE - IH_SIZE * get_blkh_nr_items (blkh));
-	    fsck_log (" - corrected\n");
-	    mark_buffer_dirty (bh);
-	} else {
-	    fsck_log ("\n");
-	    one_more_corruption (fs, fixable);
-	    return 1;
-	}
-    }
-
-    return 0;
-}
-
 /* 1 if it does not look like reasonable stat data */
 static int bad_stat_data (reiserfs_filsys_t * fs, struct buffer_head * bh, struct item_head * ih)
 {
     unsigned long objectid;
-    struct stat_data * sd;
-    __u32 pos;
 //    __u32 links;
 
-
     objectid = get_key_objectid (&ih->ih_key);
     if (!is_objectid_used (fs, objectid)) {
 	/* FIXME: this could be cured right here */
@@ -338,21 +327,21 @@
            no way to call one_less_corruption later
         */
 	if (fsck_mode (fs) != FSCK_FIX_FIXABLE)
-	    one_more_corruption (fs, fixable);
+	    one_more_corruption (fs, FIXABLE);
     }
 
-    if (is_objectid_really_used (proper_id_map (fs), objectid, &pos)) {
+    if (id_map_mark(proper_id_map (fs), objectid)) {
 	fsck_log ("bad_stat_data: The objectid (%lu) is shared by at least two files\n", objectid);
 	if (fsck_mode (fs) == FSCK_FIX_FIXABLE) 
             to_be_relocated (&ih->ih_key);
 	    
-	one_more_corruption (fs, fixable);	
-	
-	return 0;
+//	one_more_corruption (fs, FIXABLE);	
     }
 
-    sd = (struct stat_data *)B_I_PITEM(bh,ih);
+    return 0;
 /* Check this on semantic_check pass.    
+
+    sd = (struct stat_data *)B_I_PITEM(bh,ih);
     get_sd_nlink (ih, sd, &links);
     if (S_ISDIR(sd->sd_mode)) {
         if (links < 2) {
@@ -368,8 +357,6 @@
         }
     }
 */    
-    __mark_objectid_really_used (proper_id_map (fs), objectid, pos);
-    return 0;
 }
 
 
@@ -386,7 +373,7 @@
 	*ptr = 0;
 	mark_buffer_dirty (bh);
     } else {
-	one_more_corruption (fs, fixable);
+	one_more_corruption (fs, FIXABLE);
     }
 }
 
@@ -455,13 +442,13 @@
 static int bad_indirect_item (reiserfs_filsys_t * fs, struct buffer_head * bh,
 			      struct item_head * ih)
 {
-    int i;
     __u32 * ind = (__u32 *)B_I_PITEM (bh, ih);
+    unsigned int i;
 
     if (get_ih_item_len (ih) % 4) {
 	fsck_log ("%s: block %lu: The item (%H) has the bad length (%u)\n",
 	    __FUNCTION__, bh->b_blocknr, ih, get_ih_item_len (ih));
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
 	return 1;
     }
 
@@ -513,9 +500,9 @@
 /* FIXME: this was is_bad_directory from pass0.c */
 static int bad_directory_item (reiserfs_filsys_t * fs, struct buffer_head * bh, struct item_head * ih)
 {
-    int i;
     char * name;
     int namelen;
+    unsigned int count, i;
     struct reiserfs_de_head * deh = B_I_DEH (bh, ih);
     int min_entry_size = 1;/* We have no way to understand whether the
                               filesystem was created in 3.6 format or
@@ -523,31 +510,38 @@
                               length is 1 */
     __u16 state;
 
+    count = get_ih_entry_count (ih);
+
+    if (count == 0) {
+	one_more_corruption (fs, FATAL);	
+	return 1;
+    }
+    
     /* make sure item looks like a directory */
-    if (get_ih_item_len (ih) / (DEH_SIZE + min_entry_size) < get_ih_entry_count (ih)) {
+    if (get_ih_item_len (ih) / (DEH_SIZE + min_entry_size) < count) {
 	/* entry count can not be that big */
 	fsck_log ("%s: block %lu: The directory item %k has the exsessively big entry count (%u)\n",
-	    __FUNCTION__, bh->b_blocknr, &ih->ih_key, get_ih_entry_count (ih));
-	one_more_corruption (fs, fatal);	
+	    __FUNCTION__, bh->b_blocknr, &ih->ih_key, count);
+	one_more_corruption (fs, FATAL);	
 	return 1;
     }
 
-    if (get_deh_location (&deh[get_ih_entry_count (ih) - 1]) != DEH_SIZE * get_ih_entry_count (ih)) {
+    if (get_deh_location (&deh[count - 1]) != DEH_SIZE * count) {
 	/* last entry should start right after array of dir entry headers */
 	fsck_log ("%s: block %lu: The directory item %k has the corrupted entry structure\n",
 	    __FUNCTION__, bh->b_blocknr, &ih->ih_key);
-	one_more_corruption (fs, fatal);	
+	one_more_corruption (fs, FATAL);
 	return 1;
     }
-
+    
     /* check name hashing */
-    for (i = 0; i < get_ih_entry_count (ih); i ++, deh ++) {
+    for (i = 0; i < count; i ++, deh ++) {
 	namelen = name_in_entry_length (ih, deh, i);
 	name = name_in_entry (deh, i);
 	if (!is_properly_hashed (fs, name, namelen, get_deh_offset (deh))) {
 	    fsck_log ("%s: block %lu: The directory item %k has a not properly hashed entry (%d)\n",
 			__FUNCTION__, bh->b_blocknr, &ih->ih_key, i);
-	    one_more_corruption (fs, fatal);	
+	    one_more_corruption (fs, FATAL);	
 	    return 1;
 	}
     }
@@ -555,7 +549,7 @@
     deh = B_I_DEH (bh, ih);
     state = (1 << DEH_Visible2);
     /* ok, items looks like a directory */
-    for (i = 0; i < get_ih_entry_count (ih); i ++, deh ++) {
+    for (i = 0; i < count; i ++, deh ++) {
 	if (get_deh_state (deh) != state) {
 	    fsck_log ("bad_directory_item: block %lu: The directory item %k has the entry (%d) "
 		      "\"%.*s\" with a not legal state (%o), (%o) expected",
@@ -566,7 +560,7 @@
 		mark_buffer_dirty (bh);
 		fsck_log (" - corrected\n");
 	    } else 
-		one_more_corruption (fs, fixable);
+		one_more_corruption (fs, FIXABLE);
 	    
 	    fsck_log ("\n");
 	}
@@ -584,8 +578,8 @@
     ih = B_N_PITEM_HEAD (bh, num);
 
     if ((get_ih_flags(ih)) != 0) {
-	if (fsck_mode(fs) == FSCK_CHECK) {
-	    one_more_corruption (fs, fixable);
+	if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
+	    one_more_corruption (fs, FIXABLE);
 	    fsck_log ("%s: vpf-10570: block %lu: The item header (%d) has not cleaned flags.\n", 
 		__FUNCTION__, bh->b_blocknr, num);
 	} else {
@@ -605,8 +599,8 @@
 	format = key_format(&ih->ih_key);
     
     if (format != get_ih_key_format(ih)) {
-	if (fsck_mode(fs) == FSCK_CHECK) {
-	    one_more_corruption (fs, fixable);
+	if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
+	    one_more_corruption (fs, FIXABLE);
 	    fsck_log ("%s: vpf-10710: block %lu: The format (%d) specified in the item header (%d) "
 		"differs from the key format (%d).\n", __FUNCTION__, bh->b_blocknr, 
 		get_ih_key_format(ih), num, format);
@@ -646,7 +640,7 @@
 	    /* it does not look like safe link */
 
 	    /* dir_id == -1 can be used only by safe links */
-	    one_more_corruption (fs, fatal);
+	    one_more_corruption (fs, FATAL);
 	    fsck_log ("%s: vpf-10290: block %lu, item %d: The item has a wrong key %k\n", 
 		__FUNCTION__, num, bh->b_blocknr, &ih->ih_key);
 	    return 1;
@@ -661,13 +655,13 @@
 		return bad_badblocks_item (fs, bh, ih);
 	} else  {*/
 
-	    one_more_corruption (fs, fatal);
+	    one_more_corruption (fs, FATAL);
 	    fsck_log ("%s: vpf-10300: block %lu, item %d: The item has a wrong key %k\n", 
 		__FUNCTION__, num, bh->b_blocknr, &ih->ih_key);
 	    return 1;
 	}
     } else if (get_key_objectid (&ih->ih_key) == (__u32)-1) {
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
 	fsck_log ("%s: vpf-10310: block %lu, item %d: The item has a wrong key %k\n", 
 	    __FUNCTION__, num, bh->b_blocknr, &ih->ih_key);
 	return 1;
@@ -695,7 +689,7 @@
 
     if (comp_keys (&((ih - 1)->ih_key), &ih->ih_key) != -1) {
 	if (fsck_mode (fs) != FSCK_REBUILD)
-	    one_more_corruption (fs, fatal);	
+	    one_more_corruption (fs, FATAL);	
 	return 1;
     }
 
@@ -703,7 +697,7 @@
 	/* left item must be of another object */
 	if (comp_short_keys (&((ih - 1)->ih_key), &ih->ih_key) != -1) {
 	    if (fsck_mode (fs) != FSCK_REBUILD)
-		one_more_corruption (fs, fatal);	
+		one_more_corruption (fs, FATAL);	
 	    return 1;
 	}
 
@@ -733,7 +727,7 @@
 	   file */
 	if (not_of_one_file (&((ih - 1)->ih_key), &ih->ih_key)) {
 	    if (fsck_mode (fs) != FSCK_REBUILD)
-		one_more_corruption (fs, fatal);
+		one_more_corruption (fs, FATAL);
 	    return 1;
 	}
 
@@ -742,7 +736,7 @@
 	       get_offset (&(ih - 1)->ih_key) + get_bytes_number (ih-1, bh->b_size) ==
 	       get_offset (&ih->ih_key)))) {
 	    if (fsck_mode (fs) != FSCK_REBUILD)
-		one_more_corruption (fs, fatal);
+		one_more_corruption (fs, FATAL);
 	    return 1;
 	}
     }
@@ -752,7 +746,7 @@
 	if (not_of_one_file (&((ih - 1)->ih_key), &ih->ih_key) ||
 	    !is_stat_data_ih (ih - 1)) {
 	    if (fsck_mode (fs) != FSCK_REBUILD)
-		one_more_corruption (fs, fatal);
+		one_more_corruption (fs, FATAL);
 	    return 1;
 	}
     }
@@ -765,9 +759,8 @@
 {
     int i;
 
-    if (bad_block_head (fs, bh)) {
+    if (leaf_structure_check(fs, bh))
 	return 1;
-    }
     
     for (i = 0; i < B_NR_ITEMS (bh); i ++) {
 	if (bad_item (fs, bh, i)) {
@@ -777,7 +770,8 @@
 
 	if (i && bad_pair (fs, bh, i)) {
 	    fsck_log ("bad_leaf: block %lu, items %d and %d: The wrong order of items: %k, %k\n",
-		bh->b_blocknr, i-1, i, &B_N_PITEM_HEAD (bh, i-1)->ih_key, &B_N_PITEM_HEAD (bh, i)->ih_key);
+		bh->b_blocknr, i-1, i, &B_N_PITEM_HEAD (bh, i-1)->ih_key, 
+		&B_N_PITEM_HEAD (bh, i)->ih_key);
 	}
     }
     return 0;
@@ -792,17 +786,19 @@
         if (i != B_NR_ITEMS (bh) && i != B_NR_ITEMS (bh) - 1)
 	    /* make sure that keys are in increasing order */
             if (comp_keys (B_N_PDELIM_KEY (bh, i), B_N_PDELIM_KEY (bh, i + 1)) != -1) {
-		fsck_log ("%s: vpf-10320: block %lu, items %d and %d: The wrong order of items: %k, %k\n",
-		    __FUNCTION__, bh->b_blocknr, i, i+1, B_N_PDELIM_KEY (bh, i), B_N_PDELIM_KEY (bh, i + 1));
-		one_more_corruption (fs, fatal);
+		fsck_log ("%s: vpf-10320: block %lu, items %d and %d: The wrong order "
+		    "of items: %k, %k\n", __FUNCTION__, bh->b_blocknr, i, i+1, 
+		    B_N_PDELIM_KEY (bh, i), B_N_PDELIM_KEY (bh, i + 1));
+		one_more_corruption (fs, FATAL);
                 return 1;
 	    }
 
 	/* make sure that the child is correct */
         if (bad_block_number (fs, get_dc_child_blocknr (B_N_CHILD (bh,i)))) {
-	    fsck_log ("%s: vpf-10330: block %lu, item %d: The internal item points to the not legal block (%lu)\n",
-		__FUNCTION__, bh->b_blocknr, i, get_dc_child_blocknr (B_N_CHILD (bh,i)));
-            one_more_corruption (fs, fatal);
+	    fsck_log ("%s: vpf-10330: block %lu, item %d: The internal item points to the "
+		"not legal block (%lu)\n", __FUNCTION__, bh->b_blocknr, i, 
+		get_dc_child_blocknr (B_N_CHILD (bh,i)));
+            one_more_corruption (fs, FATAL);
             return 1;
 	}
     }
@@ -818,29 +814,28 @@
 
 
 /* bh must be formatted node. blk_level must be tree_height - h + 1 */
-static int bad_node (reiserfs_filsys_t * fs, struct buffer_head ** path,
-		     int h)
+static int bad_node (reiserfs_filsys_t * fs, struct buffer_head ** path, int h)
 {
     struct buffer_head ** pbh = &path[h];
 
     if (B_LEVEL (*pbh) != h_to_level (fs, h)) {
        	fsck_log ("block %lu: The level of the node (%d) is not correct, (%d) expected\n",
 	    (*pbh)->b_blocknr, B_LEVEL (*pbh), h_to_level (fs, h));
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
         return 1;
     }
 
     if (bad_block_number (fs, (*pbh)->b_blocknr)) {
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
 	fsck_log ("%s: vpf-10340: The node in the wrong block number (%lu) found in the tree\n",
 	      __FUNCTION__, (*pbh)->b_blocknr);
 	return 1;
     }
 
     if (got_already (fs, (*pbh)->b_blocknr)) {
-	fsck_log ("%s: vpf-10350: The block (%lu) is used more then once in the tree.\n",
+	fsck_log ("%s: vpf-10350: The block (%lu) is used more than once in the tree.\n",
 	      __FUNCTION__, (*pbh)->b_blocknr);
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
         return 1;
     }
     
@@ -922,9 +917,10 @@
     if (dk && comp_keys (dk, B_N_PKEY (path[h], 0))) {
 	/* left delimiting key must be equal to the key of 0-th item in the
 	   node */
-	fsck_log ("bad_path: The left delimiting key %k of the node (%lu) must be equal to the first element's "
-	    "key %k within the node.\n", dk, path[h]->b_blocknr, B_N_PKEY (path[h], 0));
-	one_more_corruption (fs, fatal);
+	fsck_log ("bad_path: The left delimiting key %k of the node (%lu) must "
+	    "be equal to the first element's key %k within the node.\n", dk, 
+	    path[h]->b_blocknr, B_N_PKEY (path[h], 0));
+	one_more_corruption (fs, FATAL);
 	return 1;
     }
     
@@ -932,10 +928,11 @@
     if (dk && comp_keys (dk, B_N_PKEY (path[h],
        get_blkh_nr_items (B_BLK_HEAD (path[h])) - 1)) != 1) {
 	/* right delimiting key must be greater than the key of the last item in the node */
-	fsck_log ("bad_path: The right delimiting key %k of the node (%lu) must be greater then the last (%d) element's"
-	    "key %k within the node.\n", dk, path[h]->b_blocknr, get_blkh_nr_items (B_BLK_HEAD (path[h])) - 1, 
+	fsck_log ("bad_path: The right delimiting key %k of the node (%lu) must "
+	    "be greater than the last (%d) element's key %k within the node.\n", 
+	    dk, path[h]->b_blocknr, get_blkh_nr_items (B_BLK_HEAD (path[h])) - 1, 
 	    B_N_PKEY (path[h], get_blkh_nr_items (B_BLK_HEAD (path[h])) - 1));
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
 	return 1;
     }
 
@@ -944,10 +941,12 @@
     	BLKH_SIZE != path[h]->b_size))
     {
 	/* wrong dc_size */
-	fsck_log ("bad_path: block %lu, pointer %d: The used space (%d) of the child block (%lu)",
-	    path[h-1]->b_blocknr, pos, get_dc_child_size (B_N_CHILD(path[h-1],pos)), path[h]->b_blocknr);
-	fsck_log (" is not equal to the (blocksize (4096) - free space (%d) - header size (%u))",
-		get_blkh_free_space ((struct block_head *)path[h]->b_data), BLKH_SIZE);
+	fsck_log ("bad_path: block %lu, pointer %d: The used space (%d) of the "
+	    "child block (%lu)", path[h-1]->b_blocknr, pos, 
+	    get_dc_child_size(B_N_CHILD(path[h-1],pos)), path[h]->b_blocknr);
+	fsck_log (" is not equal to the (blocksize (4096) - free space (%d) - "
+	    "header size (%u))", 
+	    get_blkh_free_space((struct block_head *)path[h]->b_data), BLKH_SIZE);
 	
 	if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
 	    set_dc_child_size (B_N_CHILD(path[h-1],pos), path[h]->b_size -
@@ -955,7 +954,7 @@
 	    fsck_log (" - corrected to (%lu)\n", get_dc_child_size (B_N_CHILD(path[h-1],pos)));
 	    mark_buffer_dirty (path[h-1]);
 	} else {
-	    one_more_corruption (fs, fixable);
+	    one_more_corruption (fs, FIXABLE);
 	    fsck_log ("\n");
 	    return 1;
 	}
@@ -970,14 +969,14 @@
     source_bitmap = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
     reiserfs_bitmap_copy (source_bitmap, fs->fs_bitmap2);
 
-    proper_id_map (fs) = init_id_map ();
+    proper_id_map (fs) = id_map_init();
 }
 
 static void after_check_fs_tree (reiserfs_filsys_t * fs) {
     if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
-        fs->fs_dirt = 1;
         reiserfs_flush_to_ondisk_bitmap (fs->fs_bitmap2, fs);
         reiserfs_flush (fs);
+        fs->fs_dirt = 1;
 	reiserfs_bitmap_delta (source_bitmap, control_bitmap);
 	fsck_deallocate_bitmap(fs) = source_bitmap;
     } else 
@@ -993,13 +992,20 @@
     before_check_fs_tree (fs);
     
     fsck_progress ("Checking internal tree..");
-    pass_through_tree (fs, bad_node, bad_path);
+    pass_through_tree (fs, bad_node, bad_path, fsck_mode(fs) == FSCK_AUTO ? 2 : -1);
     /* internal tree is correct (including all objects have correct
        sequences of items) */
     fsck_progress ("finished\n");
     
     /* compare created bitmap with the original */
-    handle_bitmaps (fs);
+    if (fsck_mode(fs) == FSCK_AUTO) {
+	if (auto_handle_bitmaps(fs)) {
+	    fprintf(stderr, "The on-disk bitmap looks corrupted.");
+	    one_more_corruption(fs, FIXABLE);
+	}
+	id_map_free(proper_id_map(fs));
+    } else
+	handle_bitmaps (fs);
     
     after_check_fs_tree (fs);
 }
@@ -1028,8 +1034,9 @@
 }
 
 void do_clean_attributes (reiserfs_filsys_t * fs) {
-    pass_through_tree (fs, clean_attributes_handler, NULL);
+    pass_through_tree (fs, clean_attributes_handler, NULL, -1);
     set_sb_v2_flag (fs->fs_ondisk_sb, reiserfs_attrs_cleared);
     mark_buffer_dirty (fs->fs_super_bh);
 }
 
+
diff --git a/fsck/fsck.h b/fsck/fsck.h
index fc9da78..b71b68c 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #define _GNU_SOURCE
@@ -26,18 +27,25 @@
 extern reiserfs_filsys_t * fs;
 int main (int argc, char * argv []);
 
+/* Exit codes. */
+#define EXIT_OK		0
+#define EXIT_FIXED	1
+#define EXIT_FATAL	4
+#define EXIT_FIXABLE	6
+#define EXIT_OPER	8   /* Some operation returns error. */
+#define EXIT_USER	16
 
 /*
  * modes
  */
-#define DO_NOTHING              0 /* -a specified */
+#define DO_NOTHING              0
 #define FSCK_CHECK              1
 #define FSCK_FIX_FIXABLE        2
 #define FSCK_SB                 3
 #define FSCK_REBUILD            4
 #define FSCK_ROLLBACK_CHANGES   5
 #define FSCK_CLEAN_ATTRIBUTES	7
-#define AUTO                    8 /* -p specified */
+#define FSCK_AUTO               8 /* -a || -p specified */
 
 /* temporary */
 #define DO_TEST                 9
@@ -45,30 +53,32 @@
 /*
  * options
  */
-#define OPT_INTERACTIVE                 0x1
-//#define OPT_FIX_FIXABLE               0x2 /* not default yet */
-#define OPT_ADJUST_FILE_SIZE            0x4   /* not default yet */
-#define OPT_QUIET                       0x8	  /* no "speed" info */
-/*#define OPT_SAVE_EXTERN_BITMAP        0x10*/
-#define OPT_SILENT                      0x20	  /* no complains about found corruptions */
-#define OPT_BACKGROUND                  0x40
-#define OPT_SKIP_JOURNAL                0x80
-#define OPT_HASH_DEFINED                0x100
-#define OPT_SAVE_PASSES_DUMP            0x200
-#define BADBLOCKS_FILE               	0x400
-#define OPT_SAVE_ROLLBACK               0x800
+
+#define OPT_INTERACTIVE                 1 << 0
+#define OPT_ADJUST_FILE_SIZE            1 << 1	/* not default yet */
+#define OPT_QUIET                       1 << 2	/* no "speed" info */
+#define OPT_SILENT                      1 << 3	/* no complains about found corruptions */
+#define OPT_BACKGROUND                  1 << 4
+#define OPT_SKIP_JOURNAL                1 << 5
+#define OPT_HASH_DEFINED                1 << 6
+#define OPT_SAVE_PASSES_DUMP            1 << 7
+#define OPT_SAVE_ROLLBACK               1 << 8
+#define OPT_YES				1 << 9
+#define BADBLOCKS_FILE               	1 << 10
 
 
 /* pass0.c */
 void pass_0 (reiserfs_filsys_t *);
 void load_pass_0_result (FILE *, reiserfs_filsys_t *);
 
+int leaf_structure_check(reiserfs_filsys_t * fs, struct buffer_head * bh);
+
 int is_used_leaf (unsigned long block);
 int is_good_unformatted (unsigned long block);
 void mark_good_unformatted (unsigned long block);
 int is_bad_unformatted (unsigned long block);
 
-int are_there_allocable_blocks (int amout_needed);
+int are_there_allocable_blocks (unsigned int amout_needed);
 unsigned long alloc_block (void);
 void make_allocable (unsigned long block);
 void register_uninsertable (unsigned long block);
@@ -117,11 +127,11 @@
 void pass_2_take_bad_blocks_put_into_tree (void);
 /*int is_remapped (struct item_head * ih);*/
 void link_relocated_files (void);
-//void relocate_file (struct item_head * ih, int change_ih);
 int should_relocate (struct item_head * ih);
 void relocate_dir (struct item_head * ih, int change_ih);
-__u32 objectid_for_relocation (struct key * key);
-int should_be_relocated (struct key * key);
+
+extern __u32 objectid_for_relocation (struct key * key);
+extern void linked_already(struct key *new_key);
 
 /* file.c */
 struct si {
@@ -134,7 +144,7 @@
     struct si * last_known;
 };
 void put_saved_items_into_tree (struct si *);
-int reiserfsck_file_write (struct item_head * ih, char * item, int);
+int reiserfsck_file_write (struct item_head * ih, char * item, int was_in_tree);
 int are_file_items_correct (struct item_head * sd_ih, void * sd, __u64 * size, __u32 * blocks, int mark_passed_items, int * symlink);
 int delete_N_items_after_key(struct key * start_key, struct si ** save_here, int skip_dir_items, int n_to_delete);
 void rewrite_file (struct item_head * ih, int should_relocate, int should_change_ih);
@@ -182,11 +192,9 @@
 
 /* check.c */
 int is_leaf_bad (struct buffer_head * bh);
-int is_internal_bad (struct buffer_head * bh);
 int is_bad_item (struct buffer_head * bh, struct item_head *, char *);
 /*int check_file_system (void);*/
 void reiserfsck_check_pass1 (void);
-void reiserfsck_check_after_all (void);
 /*char * bad_name (char * name, int namelen);*/
 /* to test result of direcotry item recovering on pass 0 */
 int is_bad_directory (struct item_head * ih, char * item, int dev, int blocksize);
@@ -200,7 +208,9 @@
 int bad_pair (reiserfs_filsys_t *, struct buffer_head * bh, int i);
 int bad_leaf_2 (reiserfs_filsys_t *, struct buffer_head * bh);
 
-
+extern int should_be_relocated (struct key * key);
+extern void to_be_relocated (struct key * key);
+extern void clear_relocated_list(void);
 
 /* ustree.c */
 void reiserfsck_paste_into_item (struct path * path, const char * body, int size);
@@ -217,7 +227,7 @@
 
 typedef int do_after_read_t (reiserfs_filsys_t *, struct buffer_head **, int h);
 typedef int do_on_full_path_t (reiserfs_filsys_t *, struct buffer_head **, int);
-void pass_through_tree (reiserfs_filsys_t *, do_after_read_t, do_on_full_path_t);
+void pass_through_tree (reiserfs_filsys_t *, do_after_read_t, do_on_full_path_t, int depth);
 
 //int comp_keys_3 (void * key1, void * key2);
 //int comp_dir_entries (void * key1, void * key2);
@@ -239,50 +249,31 @@
 /* objectid.c */
 int comp_ids(const void *p1, const void *p2);
 int is_objectid_used (reiserfs_filsys_t *, __u32 objectid);
-__u32 get_unused_objectid (reiserfs_filsys_t *);
 
-struct id_map * init_id_map (void);
-void free_id_map (struct id_map *);
-int is_objectid_really_used (struct id_map *, __u32 id, __u32 * ppos);
-int mark_objectid_really_used (struct id_map *, __u32 id);
-int __mark_objectid_really_used (struct id_map *, __u32 id, __u32 pos);
-void flush_objectid_map (struct id_map * map, reiserfs_filsys_t * fs);
+typedef struct id_map {
+    void **index;
+    __u32 count, last_used;
+} id_map_t;
+
+id_map_t *id_map_init();
+void id_map_free(id_map_t *);
+int id_map_test(id_map_t *map, __u32 id);
+int id_map_mark(id_map_t *map, __u32 id);
+__u32 id_map_alloc(id_map_t *map);
+void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs);
+    
+/* FIXME: Needs to be implemented
 void fetch_objectid_map (struct id_map * map, reiserfs_filsys_t * fs);
 
 void reiserfs_objectid_map_save (FILE * fp, struct id_map * id_map);
 struct id_map * reiserfs_objectid_map_load (FILE * fp);
-
-/* segments.c */
-/*
-struct overwritten_unfm_segment {
-    int ous_begin;
-    int ous_end;
-    struct overwritten_unfm_segment * ous_next;  
-};
-struct overwritten_unfm * look_for_overwritten_unfm (__u32);
-struct overwritten_unfm_segment * find_overwritten_unfm (unsigned long unfm, int length, struct overwritten_unfm_segment * segment_to_init);
-int get_unoverwritten_segment (struct overwritten_unfm_segment * list_head, struct overwritten_unfm_segment * unoverwritten_segment);
-void save_unfm_overwriting (unsigned long unfm, struct item_head * direct_ih);
-void free_overwritten_unfms (void);
 */
 
 void mark_formatted_pointed_by_indirect (__u32);
 int is_formatted_pointed_by_indirect (__u32);
 
-
-/* size of 1 piece of in-memory map */
-#define MAP_SIZE   4096
-
-struct id_map {
-    __u32 * m_begin; /* pointer to map area */
-    __u32 m_used_slots_count;
-    int m_page_count; /* objectid map expands by one page at
-                         time. This is size of objectid map size in
-                         pages */
-    unsigned long objectids_marked; /* number of objectids marked used
-                                       in a map */
-};			
-
+#define MAP_NOT_PACKED	0
+#define MAP_PACKED	1
 
 struct pass0_stat {
     unsigned long dealt_with; /* number of blocks read during pass 0 */
@@ -357,8 +348,10 @@
 	struct pass0_stat pass0;
 	struct pass1_stat pass1;
 	struct pass2_stat pass2;
-	struct semantic_stat semantic;
-	struct lost_found_stat lost_found;
+	struct {
+	    struct semantic_stat semantic;
+	    struct lost_found_stat lost_found;
+	} tree;
 	struct pass_4_stat pass4;
     } pass_u;
 
@@ -428,8 +421,8 @@
     FILE * progress;
 
     /* objectid maps */
-    struct id_map * proper_id_map;
-    struct id_map * semantic_id_map; /* this objectid map is used to
+    id_map_t * proper_id_map;
+    id_map_t * semantic_id_map; /* this objectid map is used to
                                         cure objectid sharing problem */
 };
 
@@ -438,8 +431,8 @@
 #define pass_0_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.pass0))
 #define pass_1_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.pass1))
 #define pass_2_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.pass2))
-#define sem_pass_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.semantic))
-#define lost_found_pass_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.lost_found))
+#define sem_pass_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.tree.semantic))
+#define lost_found_pass_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.tree.lost_found))
 #define pass_4_stat(fs) (&(fsck_data(fs)->rebuild.pass_u.pass4))
 
 #define fsck_check_stat(fs) (&(fsck_data(fs)->check))
@@ -470,10 +463,10 @@
 #define fsck_adjust_file_size(fs) (fsck_data(fs)->options & OPT_ADJUST_FILE_SIZE)
 #define fsck_quiet(fs)	(fsck_data(fs)->options & OPT_QUIET)
 #define fsck_silent(fs)	(fsck_data(fs)->options & OPT_SILENT)
-#define fsck_save_leaf_bitmap(fs) (fsck_data(fs)->options & OPT_SAVE_EXTERN_BITMAP)
 #define fsck_in_background(fs) (fsck_data(fs)->options & OPT_BACKGROUND)
 #define fsck_hash_defined(fs) (fsck_data(fs)->options & OPT_HASH_DEFINED)
 #define fsck_skip_journal(fs) (fsck_data(fs)->options & OPT_SKIP_JOURNAL)
+#define fsck_yes_all(fs) (fsck_data(fs)->options & OPT_YES)
 
 
 #define fsck_mode(fs) (fsck_data(fs)->mode)
@@ -508,11 +501,19 @@
 fflush (fsck_progress_file(fs));\
 }
 
+#define FATAL	1
+#define FIXABLE 2
+
+void one_more_corruption(reiserfs_filsys_t *fs, int kind);
+void one_less_corruption(reiserfs_filsys_t *fs, int kind);
+
+/*
 #define one_more_corruption(fs,kind) fsck_check_stat (fs)->kind##_corruptions++
 #define one_less_corruption(fs,kind) fsck_check_stat (fs)->kind##_corruptions--
+*/
 
 #define fsck_exit(fmt, list...) \
 {\
 reiserfs_warning (fsck_progress_file(fs), fmt, ## list);\
-exit (16);\
+exit (EXIT_USER);\
 }
diff --git a/fsck/info.c b/fsck/info.c
index 37a48d2..a82d9fa 100644
--- a/fsck/info.c
+++ b/fsck/info.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "fsck.h"
@@ -35,7 +36,7 @@
 	if (stat->wrong_pointers)
 	    fsck_progress ("\t\tpointers in indirect items to wrong area %lu (zeroed)\n",
 			   stat->wrong_pointers);
-	fsck_progress ("\t\tObjectids found %lu\n", proper_id_map (fs)->objectids_marked);
+	fsck_progress ("\t\tObjectids found %lu\n", proper_id_map(fs)->count);
     }
     break;
 	
@@ -74,7 +75,7 @@
 	if (stat->shared_objectids)
 	    fsck_progress ("\t%lu shared objectids\n", stat->shared_objectids);
 	if (stat->relocated)
-	    fsck_progress ("\tFiles relocated because of key conflicts w/ a directory %lu\n",
+	    fsck_progress ("\tFiles relocated because of key conflicts with a directory %lu\n",
 			   stat->relocated);
 	if (stat->rewritten)
 	    fsck_progress ("\tFiles rewritten %lu\n", stat->rewritten);
diff --git a/fsck/lost+found.c b/fsck/lost+found.c
index f92fef3..2b3fa34 100644
--- a/fsck/lost+found.c
+++ b/fsck/lost+found.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 2000-2002 Hans Reiser
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "fsck.h"
@@ -87,7 +88,7 @@
 		}
 		lost_found_pass_stat (fs)->dir_recovered ++;
 		create_dir_sd (fs, &tmp, &sd, modify_item);
-                mark_objectid_really_used (proper_id_map (fs), get_key_objectid (&sd));			
+                id_map_mark(proper_id_map (fs), get_key_objectid (&sd));
 		key = sd;
 		pathrelse (&path);
 		goto cont;
@@ -137,30 +138,28 @@
 		struct key obj_key = {0, 0, {{0, 0},}};
 		char * lost_name;
 		struct item_head tmp_ih;
-		__u32 pos_in_map;
 
 		/* key to continue */
 		key = ih->ih_key;
 		set_key_objectid (&key, get_key_objectid (&key) + 1);
 
 		tmp_ih = *ih;
-		if (is_objectid_really_used (semantic_id_map (fs), 
-					     get_key_objectid (&ih->ih_key),
-					     &pos_in_map)) {
+		if (id_map_test(semantic_id_map (fs), get_key_objectid (&ih->ih_key))) {
 		    /* objectid is used, relocate an object */
 		    lost_found_pass_stat (fs)->oid_sharing ++;
-		    if (1/*fsck_adjust_file_size (fs)*/) {
-			if (is_it_dir) {
-			    relocate_dir (&tmp_ih, 1);
-			    lost_found_pass_stat (fs)->oid_sharing_dirs_relocated ++;
-			} else {
-			    rewrite_file (&tmp_ih, 1, 1);
-			    lost_found_pass_stat (fs)->oid_sharing_files_relocated ++;
-			}
-		    }
+		    
+		    if (is_it_dir) {
+			relocate_dir (&tmp_ih, 1);
+			lost_found_pass_stat (fs)->oid_sharing_dirs_relocated ++;
+		    } else {
+			rewrite_file (&tmp_ih, 1, 1);
+			lost_found_pass_stat (fs)->oid_sharing_files_relocated ++;
+		    }		    
+		    
+		    linked_already(&tmp_ih.ih_key);
 		} else {
 		    if (!is_it_dir)
-			mark_objectid_really_used (semantic_id_map (fs), get_key_objectid (&ih->ih_key));
+			id_map_mark(semantic_id_map (fs), get_key_objectid (&ih->ih_key));
 		}
 
 		asprintf (&lost_name, "%u_%u", get_key_dirid (&tmp_ih.ih_key),
@@ -172,11 +171,12 @@
 
 		pathrelse (&path);
 		
-		/* 0 does not mean anyting - item w/ "." and ".." already
+		/* 0 does not mean anyting - item with "." and ".." already
 		   exists and reached, so only name will be added */
 		size += reiserfs_add_entry (fs, &lost_found_dir_key, lost_name,
 			name_length (lost_name, lost_found_dir_format), &obj_key, 0/*fsck_need*/);
 
+		
 		if (is_it_dir) {
 		    /* fixme: we hope that if we will try to pull all the
 		       directory right now - then there will be less
@@ -238,10 +238,6 @@
     fsck_progress ("finished\n");
 #endif
 
-    if (!link_lost_dirs && lost_files)
-	fsck_log ("look_for_lost: %d files seem to be left not linked to lost+found\n",
-	    lost_files);
-
     return size;
 
 }
@@ -261,7 +257,6 @@
     reiserfs_end_stage_info_save (file);
     close_file (file);
 
-    retval = unlink (state_dump_file (fs));
     retval = rename ("temp_fsck_file.deleteme", state_dump_file (fs));
     if (retval != 0)
 	fsck_progress ("pass 0: Could not rename the temporary file temp_fsck_file.deleteme to %s",
@@ -283,8 +278,10 @@
     fs->block_deallocator = reiserfsck_reiserfs_free_block;
 
     /* we need objectid map on semantic pass to be able to relocate files */
-    proper_id_map (fs) = init_id_map ();
+    proper_id_map (fs) = id_map_init();
+    /* Not implemented yet.
     fetch_objectid_map (proper_id_map (fs), fs);
+    */
 }
 
 void after_lost_found (reiserfs_filsys_t * fs)
@@ -295,7 +292,7 @@
 
     /* write all dirty blocks */
     fsck_progress ("Flushing..");
-    flush_objectid_map (proper_id_map (fs), fs);
+    id_map_flush(proper_id_map (fs), fs);
     fs->fs_dirt = 1;
     reiserfs_flush_to_ondisk_bitmap (fsck_new_bitmap(fs), fs);
     reiserfs_flush (fs);
@@ -311,12 +308,12 @@
 
     save_lost_found_result (fs);
 
-    free_id_map (proper_id_map (fs));
+    id_map_free(proper_id_map (fs));
     proper_id_map (fs) = 0;
 
     fs->fs_dirt = 1;
     reiserfs_close (fs);
-    exit(0);
+    exit(EXIT_OK);
 }
 
 void pass_3a_look_for_lost (reiserfs_filsys_t * fs)
@@ -328,10 +325,10 @@
     __u32 blocks;
     __u16 mode;
     __u32 objectid;
-    int gen_counter;
+    unsigned int gen_counter;
     fsck_progress ("Pass 3a (looking for lost dir/files):\n");
 
-    /* when warnings go not to stderr - separate then in the log */
+    /* when warnings go not to stderr - separate them in the log */
     if (fsck_log_file (fs) != stderr)
 	fsck_log ("####### Pass 3a (lost+found pass) #########\n");
 
diff --git a/fsck/main.c b/fsck/main.c
index 44efea5..a16d6b1 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 1996-2002  Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "fsck.h"
 #include <getopt.h>
 #include <sys/resource.h>
@@ -15,47 +17,46 @@
 reiserfs_filsys_t * fs;
 char * badblocks_file;
 
-#define print_usage_and_exit() {\
-fsck_progress ("Usage: %s [mode] [options] "\
-" device\n"\
-"\n"\
-"Modes:\n"\
-"  --check\t\tconsistency checking (default)\n"\
-"  --fix-fixable\t\tfix corruptions which can be fixed w/o --rebuild-tree\n"\
-"  --rebuild-sb\t\tsuper block checking and rebuilding if needed\n"\
-"  \t\t\t(require rebuild-tree afterwards)\n"\
-"  --rebuild-tree\tforce fsck to rebuild filesystem from scratch\n"\
-"  \t\t\t(takes a long time)\n"\
-"  --clean-attributes\tclean garbage in reserved fields in StatDatas on fs\n"\
-"Options:\n"\
-"  -j | --journal-device device\n"\
-"  \t\t\tspecify journal if relocated\n"\
-"  -l | --logfile logfile\n"\
-"  \t\t\tmake fsck to complain to specifed file\n"\
-"  -n | --nolog\t\tmake fsck to not complain\n"\
-"  -z | --adjust-file-size\n"\
-"  \t\t\tfix file sizes to real size\n"\
-"  \t\t\tlist of all bad blocks on the fs\n"\
-"  -q | --quiet\t\tno speed info\n"\
-"  -V\t\t\tprints version and exits\n"\
-"  -a and -p\t\tprint fs info and exits\n"\
-"  -f, -r and -y\t\tignored\n"\
-"Expert options:\n"\
-"  --no-journal-available\n"\
-"  \t\t\tdo not open nor replay journal\n"\
-"  -S | --scan-whole-partition\n"\
-"  \t\t\tbuild tree of all blocks of the device\n", argv[0]);\
-  exit(16);\
+#define print_usage_and_exit() {						\
+fsck_progress ("\nUsage: %s [mode] [options] "					\
+" device\n"									\
+"\n"										\
+"Modes:\n"									\
+"  --check\t\t\tconsistency checking (default)\n"				\
+"  --fix-fixable\t\t\tfix corruptions which can be fixed without \n"		\
+"  \t\t\t\t--rebuild-tree\n"							\
+"  --rebuild-sb\t\t\tsuper block checking and rebuilding if needed\n"		\
+"  \t\t\t\t(may require --rebuild-tree afterwards)\n"				\
+"  --rebuild-tree\t\tforce fsck to rebuild filesystem from scratch\n"		\
+"  \t\t\t\t(takes a long time)\n"						\
+"  --clean-attributes\t\tclean garbage in reserved fields in StatDatas \n"	\
+"Options:\n"									\
+"  -j | --journal device\t\tspecify journal if relocated\n"			\
+"  -l | --logfile file\t\tmake fsck to complain to specifed file\n"		\
+"  -n | --nolog\t\t\tmake fsck to not complain\n"				\
+"  -z | --adjust-size\t\tfix file sizes to real size\n"				\
+"  -q | --quiet\t\t\tno speed info\n"						\
+"  -y | --yes\t\t\tno confirmations\n"						\
+"  -V\t\t\t\tprints version and exits\n"					\
+"  -a and -p\t\t\tsome light-weight auto checks for bootup\n"			\
+"  -f and -r\t\t\tignored\n"							\
+"Expert options:\n"								\
+"  --no-journal-available\tdo not open nor replay journal\n"			\
+"  -S | --scan-whole-partition\tbuild tree of all blocks of the device\n\n",	\
+  argv[0]);									\
+										\
+  exit(EXIT_OK);								\
 }
 
 /*
 "  -B badblocks-file\n"\
+"  \t\t\tlist of all bad blocks on the fs\n"\
 
    -B works with --fix-fixable
         fixes indirect pointers pointed to
 	badblocks, adds badblocks to badblock list in fs.
     and with --rebuild
-        builds the tree w/out pointers to badblocks (internal,
+        builds the tree without pointers to badblocks (internal,
 	indirect), adds badblocks to badblock list in fs.  
 */
 
@@ -69,7 +70,7 @@
 "  -R | --rollback-data file\n"\
 "  \t\t\tback up all changes to this file or rollback from this file\n"\
 "  \t\t\tpreviously backed up changes with --rollback-fsck-changes\n"\
-"  -d dumpfile\n\"\
+"  -d dumpfile\n"\
 "  \t\t\tto test fsck pass by pass - dump into dumpfile all needed\n"\
 "  \t\t\tinfo for the next pass and load on the start of the next pass\n"\
 "  -i | --interactive\tmake fsck to stop after every stage\n"\
@@ -101,8 +102,9 @@
 	    /* options */
 	    {"logfile", required_argument, 0, 'l'},
 	    {"interactive", no_argument, 0, 'i'},
-	    {"adjust-file-size", no_argument, 0, 'z'},
+	    {"adjust-size", no_argument, 0, 'z'},
 	    {"quiet", no_argument, 0, 'q'},
+	    {"yes", no_argument, 0, 'y'},
 	    {"nolog", no_argument, 0, 'n'},
 	    
 	    /* if file exists ad reiserfs can be load of it - only
@@ -119,7 +121,7 @@
             /* preparing rollback data*/
 	    {"rollback-data", required_argument, 0, 'R'},
 	    
-	    {"journal-device", required_argument, 0, 'j'},
+	    {"journal", required_argument, 0, 'j'},
 	    {"no-journal-available", no_argument, &flag, OPT_SKIP_JOURNAL},
 	    
 //	    {"bad-block-file", required_argument, 0, 'B'},
@@ -154,12 +156,17 @@
 	    data->options |= OPT_QUIET;
 	    break;
 
+	case 'y': /* --quiet */
+	    data->options |= OPT_YES;
+	    break;
+
 	case 'l': /* --logfile */
 	    data->log_file_name = optarg;
 	    /*asprintf (&data->log_file_name, "%s", optarg);*/
 	    data->log = fopen (optarg, "w");
 	    if (!data->log)
-		fprintf (stderr, "reiserfsck: Cannot not open \'%s\': %m", optarg);
+		fprintf (stderr, "reiserfsck: Cannot not open \'%s\': %s", 
+		    optarg, strerror(errno));	    
 	    break;
 
 	case 'n': /* --nolog */
@@ -198,7 +205,7 @@
 	case 'h': /* --hash: suppose that this hash was used on a filesystem */
 	    asprintf (&data->rebuild.defined_hash, "%s", optarg);
 	    if (name2func (data->rebuild.defined_hash) == 0)
-		reiserfs_panic ("reiserfsck: Unknown hash is defined: %s",
+		reiserfs_panic ("reiserfsck: Unknown hash is specified: %s",
 				data->rebuild.defined_hash);
 	    data->options |= OPT_HASH_DEFINED;
 	    break;
@@ -223,12 +230,11 @@
 
 	case 'a':
 	case 'p':
-		mode = AUTO;
+		mode = FSCK_AUTO;
 		break;
 	
 	case 'f':
 	case 'r': /* ignored */
-	case 'y':
 	    break;
 	    
 	case 'V': /* cause fsck to do nothing */
@@ -257,11 +263,12 @@
 	/* wrong options for this mode */
 	print_usage_and_exit();
 
+/*
     if (data->options & OPT_ADJUST_FILE_SIZE) {
         if ((mode != FSCK_REBUILD) && (mode != FSCK_FIX_FIXABLE)) 
             print_usage_and_exit();
     }
-    
+*/    
     
     if (data->options & OPT_SAVE_ROLLBACK) {
         if (mode == FSCK_SB)
@@ -277,26 +284,26 @@
     	|| (mode == FSCK_CLEAN_ATTRIBUTES) || (mode == FSCK_CHECK)))
 	print_usage_and_exit();
 
+    if ((mode == FSCK_REBUILD) && (data->options & OPT_YES))
+	data->options &= ~OPT_YES;
+    
     data->mode = mode;
     if (!data->log)
 	data->log = stdout;   
 
-    if (data->journal_dev_name == NULL)
-	data->journal_dev_name = argv[optind];
-    
     return argv[optind];
 }
 
 
 #define REBUILD_WARNING \
 "  *************************************************************\n\
-  ** Do not run rebuild-tree unless something is broken  and **\n\
-  ** MAKE A BACKUP before using it.  If you have bad sectors **\n\
-  ** on a drive  it is usually a bad idea  to continue using **\n\
-  ** it.  Then you probably should get a working hard drive, **\n\
-  ** copy the file system from the bad drive to the good one **\n\
-  ** -- dd_rescue is  a good tool for  that -- and only then **\n\
-  ** run this program.                                       **\n\
+  ** Do not  run  the  program  with  --rebuild-tree  unless **\n\
+  ** something is broken and MAKE A BACKUP  before using it. **\n\
+  ** If you have bad sectors on a drive  it is usually a bad **\n\
+  ** idea to continue using it. Then you probably should get **\n\
+  ** a working hard drive, copy the file system from the bad **\n\
+  ** drive  to the good one -- dd_rescue is  a good tool for **\n\
+  ** that -- and only then run this program.                 **\n\
   ** If you are using the latest reiserfsprogs and  it fails **\n\
   ** please  email bug reports to reiserfs-list@namesys.com, **\n\
   ** providing  as  much  information  as  possible --  your **\n\
@@ -313,7 +320,7 @@
   ** If you are using the latest reiserfsprogs and  it fails **\n\
   ** please  email bug reports to reiserfs-list@namesys.com, **\n\
   ** providing  as  much  information  as  possible --  your **\n\
-  ** hardware,  kernel,  patches,  settings,  all  reiserfsk **\n\
+  ** hardware,  kernel,  patches,  settings,  all reiserfsck **\n\
   ** messages  (including version),  the reiserfsck logfile, **\n\
   ** check  the  syslog file  for  any  related information. **\n\
   ** If you would like advice on using this program, support **\n\
@@ -321,14 +328,6 @@
   *************************************************************\n\
 \n"
 
-#define AUTO_WARNING \
-"  **********************************************************\n\
-  ** WARNING:  You seem to be running this automatically. **\n\
-  ** You are almost certainly  doing  it  by  mistake  as **\n\
-  ** a result of some script  that  doesn't  know what it **\n\
-  ** does. Nothing will be done. If  you really intend to **\n\
-  ** run reiserfsck, rerun it without -a and -p options.  **\n\
-  **********************************************************\n\n"
 
 void warn_what_will_be_done (char * file_name, struct fsck_data * data)
 {
@@ -344,79 +343,79 @@
     /* warn about fsck mode */
     switch (data->mode) {
     case FSCK_CHECK:
-	reiserfs_warning (warn_to,
-	    "Will read-only check consistency of the filesystem on %s\n", file_name);
+	reiserfs_warning (warn_to, "Will read-only check consistency of the "
+	    "filesystem on %s\n", file_name);
+	
 	break;
 
     case FSCK_FIX_FIXABLE:
         
-	reiserfs_warning (warn_to, 
-	    "Will check consistency of the filesystem on %s\n", file_name);
-        reiserfs_warning (warn_to, 
-	    "and will fix what can be fixed w/o --rebuild-tree\n");
+	reiserfs_warning (warn_to, "Will check consistency of the filesystem "
+	    "on %s\n", file_name);
+        reiserfs_warning (warn_to, "and will fix what can be fixed without "
+	    "--rebuild-tree\n");
+	
 	break;
 
     case FSCK_SB:
-	reiserfs_warning (warn_to,
-            "Will check superblock and rebuild it if needed\n");
+	reiserfs_warning (warn_to, "Will check superblock and rebuild it if "
+	    "needed\n");
+	
 	break;
 
     case FSCK_REBUILD:
 	if (data->options & OPT_SAVE_PASSES_DUMP) {
-	    reiserfs_warning (warn_to,
-		"Will run only 1 step of the rebuilding, write state file '%s' and exit\n",
-			      data->rebuild.passes_dump_file_name);
+	    reiserfs_warning (warn_to, "Will run only 1 step of the rebuilding, "
+		"write state file '%s' and exit\n", 
+		data->rebuild.passes_dump_file_name);
 	} else if (data->options & OPT_INTERACTIVE)
-	    reiserfs_warning (warn_to,
-                "Will stop after every stage and ask for "
+	    reiserfs_warning (warn_to, "Will stop after every stage and ask for "
                 "confirmation before continuing\n");
 
 	if (data->rebuild.bitmap_file_name)
-	    reiserfs_warning (warn_to,
-                "Will try to load a bitmap--of all ReiserFS leaves in the partition--from the file \n'%s'\n",
+	    reiserfs_warning (warn_to, "Will try to load a bitmap--of all "
+		"ReiserFS leaves in the partition--from the file \n'%s'\n",
 		data->rebuild.bitmap_file_name);
 
 	if (data->options & OPT_ADJUST_FILE_SIZE)
-	    reiserfs_warning (warn_to,
-		"\tWill set file sizes in their metadata to real file sizes actually found by fsck.\n");
+	    reiserfs_warning (warn_to, "\tWill set file sizes in their metadata "
+		"to real file sizes actually found by fsck.\n");
 
 	if (data->options & OPT_HASH_DEFINED)
-	    reiserfs_warning (warn_to,
-                "\tSuppose \"%s\" hash is in use\n",
-			      data->rebuild.defined_hash);
+	    reiserfs_warning (warn_to, "\tSuppose \"%s\" hash is in use\n",
+		data->rebuild.defined_hash);
+	
 	break;
 	
     case FSCK_ROLLBACK_CHANGES:
-	reiserfs_warning (warn_to,
-	        "Will rollback all data saved in %s into %s\n", 
-	                data->rebuild.rollback_file, file_name);
+	reiserfs_warning (warn_to, "Will rollback all data saved in %s into %s\n",
+	    data->rebuild.rollback_file, file_name);
+	
         break;
     case FSCK_CLEAN_ATTRIBUTES:
-	reiserfs_warning (warn_to,
-	        "Will clean file attributes on %s\n", file_name);
+	reiserfs_warning (warn_to, "Will clean file attributes on %s\n", 
+	    file_name);
         break;
-    case AUTO:
-	reiserfs_warning (warn_to, AUTO_WARNING);
-	exit(0);
+    case FSCK_AUTO:
+	return;
     }
 
     if (data->options & OPT_SAVE_ROLLBACK && data->mode != FSCK_ROLLBACK_CHANGES)
-        reiserfs_warning (warn_to, 
-                "Will save all blocks to be changed into file '%s'\n", 
-                data->rebuild.rollback_file);
+        reiserfs_warning (warn_to, "Will save all blocks to be changed into "
+	    "file '%s'\n", data->rebuild.rollback_file);
 
     if (data->options & BADBLOCKS_FILE)
         reiserfs_warning (warn_to,
-                "Bad block list will contain only blocks specified in '%s' file\n",
-                badblocks_file);
+            "Bad block list will contain only blocks specified in '%s' "
+	    "file\n", badblocks_file);
 
-    reiserfs_warning (warn_to,
-                "Will put log info to '%s'\n", 
-                        (data->log == stdout) ? "stdout" : (data->log_file_name ?: "fsck.run"));
-
-    if (!user_confirmed (warn_to, 
-                "\nDo you want to run this program?[N/Yes] (note need to type Yes if you do):", "Yes\n"))
-	exit (0);
+    reiserfs_warning (warn_to, "Will put log info to '%s'\n", 
+	(data->log == stdout) ? "stdout" : 
+				(data->log_file_name ? : "fsck.run"));
+    
+    if (!(data->options & OPT_YES) && !user_confirmed (warn_to, "\nDo you want to "
+	"run this program?[N/Yes] (note need to type Yes if you do):", "Yes\n"))
+	exit (EXIT_USER);
 }
 
 static dma_info_t dma_info;
@@ -435,8 +434,8 @@
 	    printf("* Warning: It was just detected that dma mode was turned off while *\n");
 	    printf("* operating -- probably  due  to some  problem with your hardware. *\n");
 	    printf("* Please check your hardware and have a look into the syslog file. *\n");
-	    printf("* Note:  run of  rebuild-tree on faulty  hardware may destroy your *\n");
-	    printf("* data.                                                            *\n");
+	    printf("* Note: running with --rebuild-tree on faulty hardware may destroy *\n");
+	    printf("* your data.                                                       *\n");
 	    printf("********************************************************************\n");
 	    if (fsck_log_file (fs) != stdout)
 		fsck_log("WARNING: dma mode has been turned off.\n");
@@ -445,11 +444,11 @@
     if (dma_info.speed != old_dma_info.speed) {
 	if (dma_info.speed < old_dma_info.speed) {
 	    printf("\n********************************************************************\n");
-	    printf("* Warning:It was just detected that dma speed was descreased while *\n");
+	    printf("* Warning: It was just detected that dma speed was descreased while*\n");
 	    printf("* operating -- probably  due  to some  problem with your hardware. *\n");
 	    printf("* Please check your hardware and have a look into the syslog file. *\n");
-	    printf("* Note:  run of  rebuild-tree on faulty  hardware may destroy your *\n");
-	    printf("* data.                                                            *\n");
+	    printf("* Note: running with --rebuild-tree on faulty hardware may destroy *\n");
+	    printf("* your data.                                                       *\n");
 	    printf("********************************************************************\n");
 	    if (fsck_log_file (fs) != stdout)
 		fsck_log("WARNING: dma speed has been descreased.\n");	    
@@ -489,15 +488,16 @@
 static void reset_super_block (reiserfs_filsys_t * fs)
 {
     struct reiserfs_super_block * sb;
-
+    struct reiserfs_journal_header * jh;
+    
     sb = fs->fs_ondisk_sb;
 
     set_sb_free_blocks (sb, get_sb_block_count (sb));
-    set_sb_root_block (sb, ~0);
+    set_sb_root_block (sb, 0);
     set_sb_tree_height (sb, ~0);
 
     /* make file system invalid unless fsck finished () */
-    set_sb_fs_state (sb, get_sb_fs_state (sb) || REISERFS_CORRUPTED);
+    set_sb_fs_state (sb, get_sb_fs_state (sb) | FS_FATAL);
 
 /*
     if ( is_reiser2fs_jr_magic_string (sb) ) {???
@@ -518,30 +518,47 @@
 	fs->fs_hash_function = name2func (fsck_data (fs)->rebuild.defined_hash);
 	set_sb_hash_code (sb, func2code (fs->fs_hash_function));
     }
-   
-    /* reset journal params */
-    if (!fsck_skip_journal(fs)) {
-        if (is_reiserfs_jr_magic_string (sb)) {
-	    struct reiserfs_journal_header * jh;
-
-	    jh = (struct reiserfs_journal_header *)fs->fs_jh_bh->b_data;
-            memcpy (sb_jp(sb), &jh->jh_journal, sizeof (struct journal_params));
-            /* FIXME: copy reserved from jheader to SB */
-        } else {
-	    /* standard journal */
-            set_jp_journal_dev (sb_jp(sb), 0);
-            set_jp_journal_magic (sb_jp(sb) ,0);
-            set_sb_reserved_for_journal (sb, 0);
-	    set_jp_journal_1st_block (sb_jp(sb), get_journal_start_must (fs));
-	    set_jp_journal_size (sb_jp(sb), journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize));	    
- 	    set_jp_journal_max_trans_len (sb_jp(sb),
- 	    	advise_journal_max_trans_len(	get_jp_journal_max_trans_len (sb_jp(sb)),
- 	    					get_jp_journal_size (sb_jp(sb)),
- 	    					fs->fs_blocksize));
- 	    set_jp_journal_max_batch (sb_jp(sb), advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb))));
- 	    set_jp_journal_max_commit_age (sb_jp(sb), advise_journal_max_commit_age());
- 	    set_jp_journal_max_trans_age (sb_jp(sb), advise_journal_max_trans_age());
-        }
+    
+    if (reiserfs_journal_opened (fs)) {	
+	jh = (struct reiserfs_journal_header *)fs->fs_jh_bh->b_data;
+    
+	/* reset journal params if needed. */
+	if (memcmp(sb_jp(sb), &jh->jh_journal, sizeof (struct journal_params))) {
+	    if (is_reiserfs_jr_magic_string (sb)) 
+		memcpy (sb_jp(sb), &jh->jh_journal, sizeof (struct journal_params));
+	    else {
+		set_sb_reserved_for_journal (sb, 0);
+	    
+		set_jp_journal_dev (sb_jp(sb), 0);
+		set_jp_journal_magic (sb_jp(sb) ,0);
+		set_jp_journal_1st_block (sb_jp(sb), get_journal_start_must (fs));
+		set_jp_journal_size (sb_jp(sb),
+		    journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize));	    
+		set_jp_journal_max_trans_len (sb_jp(sb),
+		    advise_journal_max_trans_len(
+			get_jp_journal_max_trans_len (sb_jp(sb)),
+			get_jp_journal_size (sb_jp(sb)),
+			fs->fs_blocksize, 0));
+		set_jp_journal_max_batch (sb_jp(sb), 
+		    advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb))));
+		set_jp_journal_max_commit_age (sb_jp(sb), advise_journal_max_commit_age());
+		set_jp_journal_max_trans_age (sb_jp(sb), advise_journal_max_trans_age());
+		
+		set_jp_journal_dev (&jh->jh_journal, 0);
+		set_jp_journal_magic (&jh->jh_journal ,0);
+		set_jp_journal_1st_block (&jh->jh_journal, 
+		    get_jp_journal_1st_block(sb_jp(sb)));
+		set_jp_journal_size (&jh->jh_journal, get_jp_journal_size(sb_jp(sb)));
+		set_jp_journal_max_trans_len (&jh->jh_journal, 
+		    get_jp_journal_max_trans_len(sb_jp(sb)));
+		set_jp_journal_max_batch (&jh->jh_journal, 
+		    get_jp_journal_max_batch(sb_jp(sb)));
+		set_jp_journal_max_commit_age (&jh->jh_journal, 
+		    get_jp_journal_max_commit_age(sb_jp(sb)));
+		set_jp_journal_max_trans_age (&jh->jh_journal, 
+		    get_jp_journal_max_trans_age(sb_jp(sb))); 
+	    }
+	}
     }
 
     /* objectid map is not touched */
@@ -599,33 +616,43 @@
 	
     case PASS_1_DONE:
 	/* skip pass 1 */
-	if (!fsck_user_confirmed (fs, "Passes 0 and 1 seems finished. Start from pass 2?(Yes)",
-				  "Yes\n", 1))
+	if (!fsck_user_confirmed (fs, "Passes 0 and 1 seems finished. Start from "
+	    "pass 2?(Yes)", "Yes\n", 1)) 
+	{
 	    fsck_exit ("Run without -d then\n");
+	}
 	
 	load_pass_1_result (fp, fs);
 	fclose (fp);
 	return START_FROM_PASS_2;
 	
     case TREE_IS_BUILT:
-	if (!fsck_user_confirmed (fs, "Internal tree of filesystem looks built. Skip rebuilding?(Yes)",
-				  "Yes\n", 1))
+	if (!fsck_user_confirmed (fs, "Internal tree of filesystem looks built. "
+	    "Skip rebuilding?(Yes)", "Yes\n", 1))
+	{
 	    fsck_exit ("Run without -d then\n");
+	}
 	
 	load_pass_2_result (fs);
 	fclose (fp);
 	return START_FROM_SEMANTIC;
     case SEMANTIC_DONE:
-	if (!fsck_user_confirmed (fs, "Passes 0 and 1 seems finished. Start from pass 2?(Yes)",
-				  "Yes\n", 1))
+	if (!fsck_user_confirmed (fs, "Passes 0 and 1 seems finished. Start from "
+	    "pass 2?(Yes)", "Yes\n", 1))
+	{
 	    fsck_exit ("Run without -d then\n");
+	}
+	
 	load_semantic_result (fp, fs);
 	fclose (fp);
 	return START_FROM_LOST_FOUND;
     case LOST_FOUND_DONE:
-	if (!fsck_user_confirmed (fs, "Passes 0 and 1 seems finished. Start from pass 2?(Yes)",
-				  "Yes\n", 1))
+	if (!fsck_user_confirmed (fs, "Passes 0 and 1 seems finished. Start from "
+	    "pass 2?(Yes)", "Yes\n", 1))
+	{
 	    fsck_exit ("Run without -d then\n");
+	}
+	
 	load_lost_found_result (fs);
 	fclose (fp);
 	return START_FROM_PASS_4;
@@ -643,32 +670,56 @@
     if (!reiserfs_journal_opened (fs)) {
 	/* make sure journal is not standard */
 	if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb))
-	    die ("Filesystem with standard journal must be opened.");
+	    die ("Filesystem with default journal must be opened.");
 	
-	fsck_progress ("WARNING: You must use reiserfstune to specify a new journal before mounting it.\n");
+	fsck_progress ("WARNING: You must use reiserfstune to specify a new "
+	    "journal before mounting it.\n");
+	
 	/* mark filesystem such that it is not mountable until 
 	 * new journaldevice is defined */	
 	set_jp_journal_magic (sb_jp (fs->fs_ondisk_sb), NEED_TUNE);
     }
 
-    set_sb_umount_state (fs->fs_ondisk_sb, REISERFS_CLEANLY_UMOUNTED);
-    set_sb_fs_state (fs->fs_ondisk_sb, REISERFS_CONSISTENT);
+    set_sb_umount_state (fs->fs_ondisk_sb, FS_CLEANLY_UMOUNTED);
+    set_sb_fs_state (fs->fs_ondisk_sb, FS_CONSISTENT);
     
     mark_buffer_dirty (fs->fs_super_bh);
 }
 
-static void reiserfsck_replay_journal () {
-    /* keep the super_block in the separate memory to avoid problems with replayed broken parameters */
-    fs->fs_ondisk_sb = getmem (fs->fs_blocksize);
-    memcpy (fs->fs_ondisk_sb, fs->fs_super_bh->b_data, fs->fs_blocksize);
+static void reiserfsck_replay_journal (reiserfs_filsys_t * fs) {
+    struct reiserfs_super_block *on_place_sb;
+    int sb_size = reiserfs_super_block_size(fs->fs_ondisk_sb);
+    
+    /* keep the super_block in the separate memory to avoid problems with replaying 
+     * broken parameters. */
+    on_place_sb = (struct reiserfs_super_block *)fs->fs_super_bh->b_data;
+    fs->fs_ondisk_sb = getmem (sb_size);
+    memcpy (fs->fs_ondisk_sb, on_place_sb, sb_size);
 
     replay_journal (fs);
 
-    /* get rid of SB copy */
-    memcpy (fs->fs_super_bh->b_data, fs->fs_ondisk_sb, fs->fs_blocksize);
-    freemem (fs->fs_ondisk_sb);
-    fs->fs_ondisk_sb = (struct reiserfs_super_block *)fs->fs_super_bh->b_data;
+    /* Copy checked reliable sb fields from backed up sb to a new one. */
+    set_sb_block_count(on_place_sb, get_sb_block_count(fs->fs_ondisk_sb));
+    memcpy(sb_jp(on_place_sb), sb_jp(fs->fs_ondisk_sb), 
+	sizeof(struct journal_params));    
+    set_sb_block_size(on_place_sb, get_sb_block_size(fs->fs_ondisk_sb));
+    set_sb_oid_maxsize(on_place_sb, get_sb_oid_maxsize(fs->fs_ondisk_sb));
+    memcpy(on_place_sb->s_v1.s_magic, fs->fs_ondisk_sb->s_v1.s_magic, 10);
+    set_sb_hash_code(on_place_sb, get_sb_hash_code(fs->fs_ondisk_sb));
+    set_sb_bmap_nr(on_place_sb, get_sb_bmap_nr(fs->fs_ondisk_sb));
+    set_sb_version(on_place_sb, get_sb_version(fs->fs_ondisk_sb));
+    set_sb_reserved_for_journal(on_place_sb, 
+	get_sb_reserved_for_journal(fs->fs_ondisk_sb));
+    
+    if (sb_size == SB_SIZE) {
+	set_sb_v2_flags(on_place_sb, get_sb_v2_flags(fs->fs_ondisk_sb));
+	memcpy(on_place_sb->s_uuid, fs->fs_ondisk_sb->s_uuid, 16);
+	memcpy(on_place_sb->s_label, fs->fs_ondisk_sb->s_label, 16);
+    }
 
+    /* get rid of SB copy */
+    freemem (fs->fs_ondisk_sb);
+    fs->fs_ondisk_sb = on_place_sb;
 }
 
 static void the_end (reiserfs_filsys_t * fs)
@@ -683,9 +734,10 @@
     if (!fs->fs_bitmap2->bm_dirty)
 	die ("Bitmap not dirty");
 
-    flush_objectid_map (proper_id_map (fs), fs);
-    free_id_map(proper_id_map (fs));
-    free_id_map(semantic_id_map (fs));
+//    id_map_flush(proper_id_map (fs), fs);
+    id_map_flush(semantic_id_map (fs), fs);
+    id_map_free(proper_id_map (fs));
+    id_map_free(semantic_id_map (fs));
 
 /*    set_sb_free_blocks (sb, reiserfs_bitmap_zeros (fsck_new_bitmap (fs)));*/
 
@@ -704,28 +756,39 @@
 static void rebuild_tree (reiserfs_filsys_t * fs)
 {
     time_t t;
-
+    int ret;
 
     if (is_mounted (fs->fs_file_name)) {
 	fsck_progress ("rebuild_tree: Cannot rebuild tree of mounted filesystem\n");
-	exit(16);
+	exit(EXIT_USER);
     }
 
-    init_rollback_file (state_rollback_file(fs), &fs->fs_blocksize, fsck_data(fs)->log);
+    init_rollback_file (state_rollback_file(fs), &fs->fs_blocksize, 
+	fsck_data(fs)->log);
+    
     reiserfs_reopen (fs, O_RDWR);
 
-    /* FIXME: for regular file take care of of file size */
+    if (!fsck_skip_journal (fs)) {
+       if (reiserfs_journal_params_check(fs)) {
+	    reiserfs_close(fs);
+	    exit(EXIT_FATAL);
+	}
 
-    if (!reiserfs_open_ondisk_bitmap (fs)) {
-        fsck_progress ("reiserfsck: Could not open bitmap\n");
-	reiserfs_close (fs);
-	exit(8);
+	/* rebuild starts with journal replaying */
+	if (!fsck_skip_journal (fs))
+	    reiserfsck_replay_journal (fs);
     }
 
-    /* rebuild starts with journal replaying */
-    if (!fsck_skip_journal (fs))
-        reiserfsck_replay_journal ();
-
+    ret = reiserfs_open_ondisk_bitmap (fs);
+    if (ret < 0) {
+        fsck_progress ("reiserfsck: Could not open bitmap\n");
+	reiserfs_close (fs);
+	exit(EXIT_OPER);
+    } else if (ret > 0) {
+	fsck_log("Zero bit found in on-disk bitmap after the last valid bit. "
+	    "Fixed.\n");
+    }
+ 
     time (&t);
     fsck_progress ("###########\n"
 		   "reiserfsck --rebuild-tree started at %s"
@@ -764,43 +827,57 @@
     fsck_progress ("###########\n"
 		   "reiserfsck finished at %s"
 		   "###########\n", ctime (&t));
-    exit (0);
+    exit (EXIT_OK);
 }
 
 
 /* check umounted or read-only mounted filesystems only */
-static void prepare_fs_for_pass_through_tree (reiserfs_filsys_t * fs)
+static void prepare_fs_for_check(reiserfs_filsys_t * fs) 
 {
+    /* The method could be called from auto_check already. */
+    if (fs->fs_flags == O_RDWR) 
+	return;
+
+    reiserfs_reopen (fs, O_RDWR);
+    
     if (is_mounted (fs->fs_file_name)) {
 	/* filesystem seems mounted. */
         if (fsck_mode (fs) == FSCK_CLEAN_ATTRIBUTES) {
-	    fsck_progress ("Partition %s is mounted, cannot clean attributes on mounted device\n",
-			   fs->fs_file_name);
+	    fsck_progress ("Partition %s is mounted, cannot clean attributes "
+		"on mounted device\n", fs->fs_file_name);
 	    reiserfs_close (fs);
-	    exit(16);
+	    exit(EXIT_USER);
         }
 
 	if (!is_mounted_read_only (fs->fs_file_name)) {
-	    fsck_progress ("Partition %s is mounted w/ write permissions, cannot check it\n",
-			   fs->fs_file_name);
+	    fsck_progress ("Partition %s is mounted with write permissions, "
+		"cannot check it\n", fs->fs_file_name);
 	    reiserfs_close (fs);
-	    exit(16);
+	    exit(EXIT_USER);
 	}
-	if (!reiserfs_journal_opened (fs))
+	if (!reiserfs_journal_opened (fs)) {
 	    /* just to make sure */
 	    reiserfs_panic ("Journal is not opened");
-
-	fsck_progress ("Filesystem seems mounted read-only. Skipping journal replay.\n");
+	} else if (reiserfs_journal_params_check(fs)) {
+	    reiserfs_close (fs);
+	    exit(EXIT_FATAL);
+	}
+	
+	fsck_progress ("Filesystem seems mounted read-only. Skipping journal "
+	    "replay.\n");
 
 	if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
 	    fsck_progress ("--fix-fixable ignored\n");
 	    fsck_mode (fs) = FSCK_CHECK;
 	}
-    } else {
-        reiserfs_reopen (fs, O_RDWR);
-	if (!fsck_skip_journal (fs))
-	    /* filesystem is not mounted, replay journal before checking */
-            reiserfsck_replay_journal ();
+    } else if (!fsck_skip_journal (fs)) {
+	if (reiserfs_journal_params_check(fs)) {
+	    reiserfs_close (fs);
+	    exit(EXIT_FATAL);
+	}
+	
+	/* filesystem is not mounted, replay journal before checking */
+        reiserfsck_replay_journal (fs);
     }
 }
 
@@ -809,28 +886,31 @@
 
     time (&t);
 
-    if (get_sb_umount_state (fs->fs_ondisk_sb) != REISERFS_CLEANLY_UMOUNTED) {
+    if (get_sb_umount_state (fs->fs_ondisk_sb) != FS_CLEANLY_UMOUNTED) {
         fsck_progress ("Filesystem does not look cleanly umounted\n"
 	    "Check consistency of the partition first.\n");
-        exit(16);
+        exit(EXIT_USER);
     }
-    if (get_sb_fs_state (fs->fs_ondisk_sb) != REISERFS_CONSISTENT) {
+    if (get_sb_fs_state (fs->fs_ondisk_sb) != FS_CONSISTENT) {
         fsck_progress ("Filesystem seems to be in unconsistent state.\n"
-				  "Check consistency of the partition first.\n");
-        exit(16);
+	    "Check consistency of the partition first.\n");
+        exit(EXIT_USER);
     }
 
     if (get_reiserfs_format (fs->fs_ondisk_sb) != REISERFS_FORMAT_3_6) {
-        fsck_progress ("Filesystems of 3_5 format do not support extended attributes.\n");
-        exit(16);
+        fsck_progress ("Filesystems of 3_5 format do not support extended "
+	    "attributes.\n");
+	
+        exit(EXIT_USER);
     }
     fsck_progress ("###########\n"
 	           "reiserfsck --clean-attributes started at %s"
                    "###########\n", ctime (&t));
 
-    init_rollback_file (state_rollback_file(fs), &fs->fs_blocksize, fsck_data(fs)->log);
+    init_rollback_file (state_rollback_file(fs), &fs->fs_blocksize, 
+	fsck_data(fs)->log);
 
-    prepare_fs_for_pass_through_tree (fs);
+    prepare_fs_for_check(fs);
 
     do_clean_attributes (fs);
 
@@ -842,14 +922,110 @@
 		   "reiserfsck finished at %s"
 		   "###########\n", ctime (&t));
 
-    exit (0);
+    exit (EXIT_FIXED);
 
 }
 
+/* Do not allow buffers to be flushed after finishing to avoid another bitmap 
+ * reading on mounting. */
+static void fsck_sleep() {
+    int res;
+    
+    res = fork();
+    
+    if (res == -1) {
+	reiserfs_panic ("reiserfsck: Fork failed: %s", strerror(errno));
+    } else if (res == 0) {
+	/* Make the child process to sleep for 5 secs. */
+	sleep(5);
+    }
+}
+
+static int auto_check (reiserfs_filsys_t *fs) {
+    __u16 state;
+    int retval = 0;
+    
+    print_super_block (stdout, fs, fs->fs_file_name, fs->fs_super_bh, 1);
+    
+    state = get_sb_fs_state (fs->fs_ondisk_sb);
+    if ((state & FS_FATAL) == FS_FATAL) {
+	fprintf(stderr, "Filesystem seems to have fatal corruptions. Running "
+	    "with --rebuild-tree is required.\n");
+	goto error;
+    }
+
+    if ((state & FS_ERROR) == FS_ERROR) {
+	fprintf(stderr, "Some corruptions on the filesystem were detected. Switching to "
+	    "the --fix-fixable mode.\n");
+	/* run fixable pass. */
+	return 0;
+    }
+    
+    if (state != FS_CONSISTENT)
+	fprintf(stderr, "Some strange state was specified in the super block. "
+	    "Do usual check.\n");
+
+    prepare_fs_for_check(fs);
+
+    /* Check bitmaps. */
+    retval = reiserfs_open_ondisk_bitmap (fs);
+    
+    if (retval > 0) {
+	fsck_log("Zero bit found in on-disk bitmap after the last valid bit. "
+	    "Switching to --fix-fixable mode.\n");
+	/* run fixable pass. */
+	return 0;
+    } else if (retval < 0) {
+        fsck_progress ("reiserfsck: Could not open bitmap\n");
+	goto error;
+    }
+    
+    if (get_sb_block_count (fs->fs_ondisk_sb) - 
+	get_sb_free_blocks(fs->fs_ondisk_sb) != 
+	fs->fs_bitmap2->bm_set_bits)
+    {
+	fsck_log("Wrong amount of used blocks. Switching to the --fix-fixable mode.\n");
+	/* run fixable pass. */
+	return 0;
+    }
+
+    check_fs_tree (fs);
+    if (fsck_data (fs)->check.fatal_corruptions) {		
+	fprintf(stderr, "%lu fatal corruption(s) found in the root block. Running "
+	    "with the --rebuild-tree is required.\n", 
+	    fsck_data (fs)->check.fatal_corruptions);
+	goto fatal_error;
+    } else if (fsck_data (fs)->check.fixable_corruptions) {
+        /* seems that this cannot happen. */
+	fprintf(stderr, "%lu fixable corruption(s) found. Switching to "
+	    "the --fix-fixable mode.\n", fsck_data (fs)->check.fixable_corruptions);
+	fsck_data (fs)->check.fixable_corruptions = 0;
+	/* run fixable pass. */
+	return 0;
+    }
+    
+    clean_after_dma_check(fs->fs_dev, &dma_info);
+    
+    fsck_sleep();
+    
+    reiserfs_close (fs);
+    /* do not do anything else. */    
+    exit (EXIT_OK);
+
+fatal_error:
+    set_sb_fs_state(fs->fs_ondisk_sb, FS_FATAL);
+    mark_buffer_dirty (fs->fs_super_bh);
+    bwrite(fs->fs_super_bh);	
+error:
+    clean_after_dma_check(fs->fs_dev, &dma_info);
+    reiserfs_close(fs);
+    exit(EXIT_FATAL);
+}
+
 /* check umounted or read-only mounted filesystems only */
 static void check_fs (reiserfs_filsys_t * fs)
 {
-    int retval;
+    int retval = EXIT_OK;
     time_t t;
 
     time (&t);
@@ -864,59 +1040,77 @@
                        "###########\n", ctime (&t));
     }
 
-    init_rollback_file (state_rollback_file(fs), &fs->fs_blocksize, fsck_data(fs)->log);
+    init_rollback_file (state_rollback_file(fs), &fs->fs_blocksize, 
+	fsck_data(fs)->log);
     
-    if (!reiserfs_open_ondisk_bitmap (fs)) {
+    prepare_fs_for_check (fs);
+
+    if (!fs->fs_bitmap2)
+	/* It could be done on auto_check already. */
+	retval = reiserfs_open_ondisk_bitmap (fs);
+
+    if (retval > 0) {
+	if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
+	    fsck_log("Zero bit found in on-disk bitmap after the last valid "
+		"bit.\n");
+	    
+	    one_more_corruption(fs, FIXABLE);
+	} else {
+	    fsck_log("Zero bit found in on-disk bitmap after the last valid "
+		"bit. Fixed.\n");
+	}
+    } else if (retval < 0) {
         fsck_progress ("reiserfsck: Could not open bitmap\n");
 	reiserfs_close (fs);
-	exit(8);
+	exit(EXIT_OPER);
     }
 
-    prepare_fs_for_pass_through_tree (fs);
-
     check_fs_tree (fs);
 
     semantic_check ();
-
+    
     if (fsck_data (fs)->check.fatal_corruptions) {
-	fsck_progress ("%d found corruptions can be fixed only during --rebuild-tree\n",
-		       fsck_data (fs)->check.fatal_corruptions);
-        set_sb_fs_state (fs->fs_ondisk_sb, REISERFS_CORRUPTED);
+	fsck_progress ("%lu found corruptions can be fixed only when running with "
+	    "--rebuild-tree\n", fsck_data (fs)->check.fatal_corruptions);
+	
+        set_sb_fs_state (fs->fs_ondisk_sb, FS_FATAL);
         mark_buffer_dirty (fs->fs_super_bh);
-	retval = 2;
+	retval = EXIT_FATAL;
     } else if (fsck_data (fs)->check.fixable_corruptions) {
         /* fixable corruptions found */
 	if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
-            /* fixable corruptions found and fix-fixable has not fixed them, do rebuild-tree */
-            fsck_log ("Fatal error: %d fixable corruptions found after fix-fixable.\n",
-                                fsck_data (fs)->check.fixable_corruptions);
-	    retval = 2;
+            /* fixable corruptions found and fix-fixable has not fixed them, 
+	     * do rebuild-tree */
+	    
+            fsck_progress ("Fatal error: %lu fixable corruptions found after "
+		"--fix-fixable.\n", fsck_data (fs)->check.fixable_corruptions);
+	    retval = EXIT_OPER;
         } else {
-	    fsck_progress ("%d found corruptions can be fixed with --fix-fixable\n",
-                          fsck_data (fs)->check.fixable_corruptions);
-	    retval = 1;
+	    fsck_progress ("%lu found corruptions can be fixed when running with "
+		"--fix-fixable\n", fsck_data (fs)->check.fixable_corruptions);
+	    
+	    retval = EXIT_FIXABLE;
         }
-        set_sb_fs_state (fs->fs_ondisk_sb, REISERFS_CORRUPTED);
+        set_sb_fs_state (fs->fs_ondisk_sb, FS_ERROR);
         mark_buffer_dirty (fs->fs_super_bh);
     } else {
 	fsck_progress ("No corruptions found\n");
 	stage_report (5, fs);
-	retval = 0;
+	retval = fsck_mode(fs) == FSCK_CHECK ? EXIT_OK : EXIT_FIXED;
 
 	mark_filesystem_consistent (fs);
     }
-
-    if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
-        flush_objectid_map (proper_id_map (fs), fs);
-
-        fs->fs_dirt = 1;
-    }
+   
+    if (fsck_mode (fs) == FSCK_FIX_FIXABLE)
+        id_map_flush(proper_id_map (fs), fs);
         
-    free_id_map (proper_id_map (fs));
+    id_map_free(proper_id_map (fs));
     clean_after_dma_check(fs->fs_dev, &dma_info);
     reiserfs_close (fs);
     close_rollback_file ();
     
+    clear_relocated_list();    
+    
     time (&t);
     fsck_progress ("###########\n"
 		   "reiserfsck finished at %s"
@@ -925,13 +1119,17 @@
     exit(retval);
 }
 
-static int open_devices_for_rollback (char * file_name, struct fsck_data * data) {
+static int open_devices_for_rollback (char * file_name, 
+    struct fsck_data * data) 
+{
     int fd;
 
     fd = open (file_name, O_RDWR | O_LARGEFILE);
 
     if (fd == -1) {
-        reiserfs_warning (stderr, "reiserfsck: Cannot not open the fs partition %s\"", file_name);
+        reiserfs_warning (stderr, "reiserfsck: Cannot not open the fs "
+	    "partition %s\n", file_name);
+
         return -1;
     }
 
@@ -940,8 +1138,11 @@
     fs->fs_vp = data;
     asprintf (&fs->fs_file_name, "%s", file_name);
 
-    if (data->journal_dev_name && strcmp (data->journal_dev_name, file_name)) {
-	fs->fs_journal_dev = open (data->journal_dev_name, O_RDWR | O_LARGEFILE);
+    if (data->journal_dev_name && 
+	strcmp (data->journal_dev_name, file_name)) 
+    {
+	fs->fs_journal_dev = open (data->journal_dev_name, 
+	    O_RDWR | O_LARGEFILE);
 	if (fs->fs_journal_dev == -1) {
 	    reiserfs_warning (stderr, "Cannot open journal partition\n");
      	    return -1;
@@ -976,7 +1177,7 @@
 		   "reiserfsck finished at %s"
 		   "###########\n", ctime (&t));
 
-    exit(0);
+    exit(EXIT_FIXED);
 }
 
 int main (int argc, char * argv [])
@@ -1002,19 +1203,20 @@
     lost_found_dir_key.k2_objectid = cpu_to_le32(lost_found_dir_key.k2_objectid);
     /* this is only needed (and works) when running under 2.4 on regular files */
     if (setrlimit (RLIMIT_FSIZE, &rlim) == -1) {
-	reiserfs_warning (stderr, "Cannot change the system limit for file size with setrlimit: %m\n");
+	reiserfs_warning (stderr, "Cannot change the system limit for file size "
+	    "with setrlimit: %s\n", strerror(errno));
     }
 
     data = getmem (sizeof (struct fsck_data));
 
     file_name = parse_options (data, argc, argv);
 
-    if (data->mode != AUTO)
+    if (data->mode != FSCK_AUTO)
 	print_banner ("reiserfsck");
 
     if (data->mode == DO_NOTHING) {
 	freemem (data);
-	return 0;
+	exit(EXIT_OK);
     }
 
     if (data->options & OPT_BACKGROUND) {
@@ -1030,50 +1232,50 @@
 	    data->log = data->progress;
 
 	retval = fork ();
-	if (retval == -1)
-	    reiserfs_panic ("reiserfsck: Fork failed: %m");
-	if (retval != 0) {
-	    return 8;
+	if (retval == -1) {
+	    reiserfs_panic ("reiserfsck: Fork failed: %s", strerror(errno));
+	} else if (retval != 0) {
+	    exit(EXIT_OPER);
 	}
-	reiserfs_warning (stderr, "\nReiserfsck is running in background as [%d],\n"
-	    "make sure that it gets all the confirmations from stdin that it requests.\n\n",
-	    getpid ());
+	reiserfs_warning (stderr, "\nReiserfsck is running in background as "
+	    "[%d],\nmake sure that it gets all the confirmations from stdin "
+	    "that it requests.\n\n", getpid ());
     }
 
-
-    if (data->mode != AUTO)
-	warn_what_will_be_done (file_name, data); /* and ask confirmation Yes */
+    /* This asks for confirmation also. */
+    if (data->mode != FSCK_AUTO)
+	warn_what_will_be_done(file_name, data);
 
     if (data->mode == FSCK_ROLLBACK_CHANGES) {
     	if (open_devices_for_rollback (file_name, data) == -1)
-    	    exit(8);
+    	    exit(EXIT_OPER);
     } else {
-	fs = reiserfs_open (file_name, O_RDONLY, 0, data);
+	fs = reiserfs_open (file_name, O_RDONLY, 0, data, 
+	    data->mode != FSCK_SB);
 
 	if (data->mode != FSCK_SB) {
-	    if (no_reiserfs_found (fs))
-    	    	die ("reiserfsck: Cannot not open filesystem on \"%s\"", file_name);
+	    if (no_reiserfs_found (fs)) 
+    	    	die ("Failed to open the filesystem.\n\n"
+		    "If the partition table has not been changed, and the partition is\n"
+		    "valid  and  it really  contains  a reiserfs  partition,  then the\n"
+		    "superblock  is corrupted and you need to run this utility with\n"
+		    "--rebuild-sb.\n");
 
-	    if (data->mode == AUTO) {
-		print_super_block (stdout, fs, fs->fs_file_name, fs->fs_super_bh, 1);
-		reiserfs_close(fs);
-	
-		exit(0);
-	    }
-	
-	    if (fsck_skip_journal (fs) && !is_reiserfs_jr_magic_string (fs->fs_ondisk_sb)) {
-		reiserfs_warning (stderr, "Filesystem with standard journal found, "
+	    if (fsck_skip_journal (fs) && 
+		!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb)) 
+	    {
+		reiserfs_warning (stderr, "Filesystem with default journal found, "
 			"--no-journal-available is ignored\n");
 		fsck_data(fs)->options &= ~OPT_SKIP_JOURNAL;
 	    }
 	
 	    if (!fsck_skip_journal (fs)) {
-		if (!reiserfs_open_journal (fs, data->journal_dev_name, O_RDONLY)) {	
-	            fsck_progress ("\nEither make journal partition available or use --no-journal-available\n");
-		    fsck_progress ("If you have the standard journal or if your partition is available\n");
-        	    fsck_progress ("and you specified it correctly, you must run rebuild-sb\n");
+		if (reiserfs_open_journal(fs, data->journal_dev_name, O_RDONLY)) {	    
+	            fsck_progress ("Failed to open the journal device (%s).\n", 
+			data->journal_dev_name);
+		    
 		    reiserfs_close (fs);
-      		    return 8;
+		    exit(EXIT_OPER);
 	        }
 	    }
 	
@@ -1091,7 +1293,12 @@
     case FSCK_SB:
 	rebuild_sb (fs, file_name, data);
 	break;
-	
+    
+    case FSCK_AUTO:
+	/* perform some light-weight checks. If error, do fixable job. */
+	if (auto_check (fs))
+	    break;
+	data->mode = FSCK_FIX_FIXABLE;
     case FSCK_CHECK:
     case FSCK_FIX_FIXABLE:
 	check_fs (fs);
@@ -1109,6 +1316,6 @@
 	clean_attributes (fs);
     }
     
-    return 8;
+    exit(EXIT_OPER);
 }
 
diff --git a/fsck/pass0.c b/fsck/pass0.c
index d52b137..8a0702b 100644
--- a/fsck/pass0.c
+++ b/fsck/pass0.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "fsck.h"
@@ -31,7 +32,14 @@
 #define pass0_mark_bad_unfm(block) __mark (bad_unfm, block)
 #define pass0_unmark_bad_unfm(block) __unmark (bad_unfm, block)
 
-
+static int correct_direct_item_offset (__u64 offset, int format) {
+    if (format == KEY_FORMAT_2) {
+        return (offset && ((offset - 1) % 8 == 0));
+    } else {
+	return (offset);
+    }
+    return 0;
+}
 
 /* bitmaps which are built on pass 0 and are used on pass 1 */
 static void make_aux_bitmaps (reiserfs_filsys_t * fs)
@@ -110,7 +118,7 @@
 
 
 /* return 1 if something was changed */
-static int correct_key_format (struct item_head * ih)
+static int correct_key_format (struct item_head * ih, int symlink)
 {
     int dirty = 0;
 
@@ -139,6 +147,12 @@
 	die ("stat_data item of the wrong length");
     }
     
+    if (symlink && is_direct_ih(ih) && (key_format(&ih->ih_key) != KEY_FORMAT_1)) {	
+	/* All symlinks are of 3.5 format */
+	/*fsck_log ("correct_key_format: Symlink keys should be of 3.5 format. %k - fixed.\n", &ih->ih_key); */
+	set_type_and_offset(KEY_FORMAT_1, &ih->ih_key, get_offset(&ih->ih_key), get_type(&ih->ih_key));
+    }
+	
     if (key_format (&ih->ih_key) != get_ih_key_format (ih)) {
 	/*fsck_log ("correct_key_format: ih_key_format of (%H) is set to format found in the key\n",
 	  ih);*/
@@ -227,7 +241,7 @@
     struct reiserfs_de_head * deh;
     char * name;
     int name_len;
-    int bad;
+    int bad, lost_found;
     int i, j;
     char buf[4096];
     int dirty;
@@ -471,7 +485,7 @@
     }
 #endif
 
-    bad = 0;
+    bad = lost_found = 0;
     tmp = *ih;
 
     /* mark enries of /lost+found as bad */
@@ -491,6 +505,7 @@
 	
 	/* entry in lost+found */
 //	printf ("%s - will be deleted\n", buf);
+	lost_found++;
 	mark_de_bad_offset (deh);
     }
 
@@ -509,9 +524,9 @@
 	}
     }
     
-    if (bad == get_ih_entry_count (&tmp)) {
+    if (bad == get_ih_entry_count (&tmp) && lost_found != bad) {	
 	fsck_log ("%s: block %lu, item %H: All entries were deleted from the directory\n", 
-	    __FUNCTION__, bh->b_blocknr, &tmp);
+	    __FUNCTION__, bh->b_blocknr, &tmp);	
 	return -1;
     }
 
@@ -523,29 +538,28 @@
 	mark_buffer_dirty (bh);
     }
     
-    if (bad)
+    if (bad > lost_found)
 	fsck_log ("pass0: block %lu, item %H: %d entries were deleted\n",
-		  bh->b_blocknr, &tmp, bad);
+		  bh->b_blocknr, &tmp, bad - lost_found);
 	
     return 0;
 
 }
 
 
-static int does_it_fit_into_dev (__u64 offset) {
+static __inline__ int does_it_fit_into_dev (__u64 offset, __u64 fs_size) {
 /* 
    Count of unformatted pointers - offset / blocksize
    Count of blocks to store them - UNFM_P_SIZE * offset / blocksize / MAX_ITEM_LEN
    Size to store it              - blocksize * UNFM_P_SIZE * offset / blocksize / MAX_ITEM_LEN
 */
-   return ( UNFM_P_SIZE * offset / MAX_ITEM_LEN(fs->fs_blocksize) < 
-	fs->fs_blocksize * get_sb_block_count (fs->fs_ondisk_sb)) ? 1 : 0;
+   return ( UNFM_P_SIZE * offset / MAX_ITEM_LEN(fs->fs_blocksize) < fs_size) ? 1 : 0;
 }
 
 
 static int is_wrong_short_key (struct key * key) {
     if (get_key_dirid (key) == 0 || get_key_objectid (key) == 0 || get_key_objectid (key) == 1 ||
-	get_key_dirid (key) == -1 || get_key_objectid (key) == -1 ||
+	get_key_dirid (key) == ~0ul || get_key_objectid (key) == ~0ul ||
 	get_key_dirid (key) == get_key_objectid (key) ||
 	(get_key_dirid (key) == 1 && get_key_objectid (key) != 2) ||
 	(get_key_dirid (key) != 1 && get_key_objectid (key) == 2) )
@@ -554,6 +568,55 @@
     return 0;
 }
 
+/* 1 if some of fields in the block head of bh look bad */
+int leaf_structure_check (reiserfs_filsys_t * fs, struct buffer_head * bh) {
+    struct block_head * blkh;
+    int free_space, counted;
+
+    blkh = B_BLK_HEAD (bh);
+    
+    if (!is_leaf_block_head(bh->b_data)) {
+	/* We should not get here on rebuild. */
+	fsck_log ("block %lu: The block does not look like a leaf.\n", bh->b_blocknr);
+        one_more_corruption (fs, FATAL);
+	return 1;
+    }
+
+    counted = leaf_count_ih(bh->b_data, bh->b_size);
+
+    if (counted < get_blkh_nr_items (blkh)) {
+	fsck_log ("block %lu: The number of items (%lu) is incorrect, should be (%lu)",
+		bh->b_blocknr, get_blkh_nr_items(blkh), counted);
+	if (fsck_mode(fs) == FSCK_REBUILD) {
+	    set_blkh_nr_items(blkh, counted);	    
+	    fsck_log (" - corrected\n");
+	    mark_buffer_dirty (bh);
+	} else {
+	    fsck_log ("\n");
+	    one_more_corruption (fs, FATAL);
+	    return 1;
+	}
+    }
+    
+    free_space = leaf_free_space_estimate(bh->b_data, bh->b_size);
+    if (get_blkh_free_space (blkh) != free_space) {
+	fsck_log ("block %lu: The free space (%lu) is incorrect, should be (%lu)",
+		bh->b_blocknr, get_blkh_free_space (blkh), free_space);
+	
+	if (fsck_mode(fs) != FSCK_CHECK && fsck_mode(fs) != FSCK_AUTO) {
+	    set_blkh_free_space (blkh, free_space);	    
+	    fsck_log (" - corrected\n");
+	    mark_buffer_dirty (bh);
+	} else {
+	    fsck_log ("\n");
+	    one_more_corruption (fs, FIXABLE);
+	    return 1;
+	}
+    }
+
+    return 0;
+}
+
 /* do this on pass 0 with every leaf marked used */
 
 /* FIXME: we can improve fixing of broken keys: we can ssfe direct items which
@@ -561,25 +624,31 @@
 static void pass0_correct_leaf (reiserfs_filsys_t * fs,
 				struct buffer_head * bh)
 {
-    int i, j;
-    struct item_head * ih;
-    __u32 * ind_item;
-    __u64 offset;
-    unsigned long unfm_ptr;
-    int dirty = 0;
-    int nr_items;
     int file_format = KEY_FORMAT_UNDEFINED;
+    struct item_head * ih;
+    
+    __u32 * ind_item;
+    __u64 fs_size;
+    __u64 offset;
     int symlnk = 0;
     int bad_order;
+    
+    unsigned long unfm_ptr;
+//    unsigned int nr_items;
+    int i, j, nr_items;
+    int dirty = 0;
 
+    leaf_structure_check(fs, bh);
 
     /* Delete all safe links. */
     for (i = get_blkh_nr_items (B_BLK_HEAD (bh)) - 1; i >= 0; i--) {
-	if (get_key_dirid (&B_N_PITEM_HEAD (bh, i)->ih_key) == -1) {
+	if (get_key_dirid (&B_N_PITEM_HEAD (bh, i)->ih_key) == ~0ul) {
 	    delete_item (fs, bh, i);
 	}
     }
 
+    fs_size = (__u64)fs->fs_blocksize * get_sb_block_count (fs->fs_ondisk_sb);
+
  start_again:
 
     ih = B_N_PITEM_HEAD (bh, 0);
@@ -605,7 +674,6 @@
             }
         }
 
-
 	if (is_wrong_short_key (&ih->ih_key)) {
 	    /* sometimes stat datas get k_objectid==0 or k_dir_id==0 */
 	    
@@ -685,7 +753,7 @@
 			"change the type of the key %k to StatData\n", bh->b_blocknr, i + 1, &(ih + 1)->ih_key);
                     set_type_and_offset (KEY_FORMAT_1, &(ih + 1)->ih_key, SD_OFFSET, TYPE_STAT_DATA);
 		    dirty = 1;
-                } else {
+                } else if (is_indirect_ih(ih)) {
                     fsck_log("pass0: vpf-10420: block %lu, item %d: Wrong order of items - "
 			"change the type of the key %k to Direct\n", bh->b_blocknr, i+1, &(ih + 1)->ih_key);
                     set_type (get_ih_key_format(ih+1), &(ih + 1)->ih_key, TYPE_DIRECT);
@@ -807,15 +875,15 @@
             int err = 0;
             if (i > 1) {
                 if (comp_short_keys (&(ih - 2)->ih_key, &(ih - 1)->ih_key) != -1)
-                    set_bit (1, &err);
+                    misc_set_bit (1, &err);
                 if (comp_short_keys (&(ih - 2)->ih_key, &ih->ih_key) != -1)
-                    set_bit (2, &err);
+                    misc_set_bit (2, &err);
             }
             if (i + 1 < nr_items) {
                 if (comp_short_keys (&(ih - 1)->ih_key, &(ih + 1)->ih_key) != -1)
-                    set_bit (3, &err);
+                    misc_set_bit (3, &err);
                 if (comp_short_keys (&ih->ih_key, &(ih + 1)->ih_key) != -1)
-                    set_bit (4, &err);
+                    misc_set_bit (4, &err);
             }
 /*
             if ((test_bit (1, err) || test_bit (3, err)) &&
@@ -826,8 +894,8 @@
                 goto start_again;
       	    }
 */
-            if (!test_bit (1, &err) && !test_bit (3, &err) &&
-		!test_bit (2, &err) && !test_bit (4, &err)) {
+            if (!misc_test_bit (1, &err) && !misc_test_bit (3, &err) &&
+		!misc_test_bit (2, &err) && !misc_test_bit (4, &err)) {
       		if (i <= 1) {
             	    /* take bigger */
                     if (comp_short_keys (&(ih - 1)->ih_key, &ih->ih_key) == 1) {
@@ -856,14 +924,14 @@
                     }
                 }
 		dirty = 1;
-	    } else if (!test_bit (1, &err) && !test_bit (3, &err)) {
+	    } else if (!misc_test_bit (1, &err) && !misc_test_bit (3, &err)) {
       		/* take i - 1 */
 		fsck_log("pass0: vpf-10590: block %lu, item %d: Wrong order of items - "
 		    "change the object_id of the key %k to %lu\n",
                     bh->b_blocknr, i, &ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));
 		set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));
 		dirty = 1;
- 	    } else if (!test_bit (2, &err) && !test_bit (4, &err)) {
+ 	    } else if (!misc_test_bit (2, &err) && !misc_test_bit (4, &err)) {
       		/* take i */
 		fsck_log("pass0: vpf-10600: block %lu, item %d: Wrong order of items - "
 		    "change the object_id of the key %k to %lu\n",
@@ -897,7 +965,7 @@
 		    if (get_ih_item_len (ih - 1) == SD_SIZE) {
 			/* stat data is new, therefore this item is new too */
 			set_offset (KEY_FORMAT_2, &(ih->ih_key), 1);
-			if (get_ih_entry_count (ih) != 0xffff)
+			if ((get_ih_entry_count (ih) != 0xffff) && (get_ih_item_len (ih) % 4 == 0))
 			    set_type (KEY_FORMAT_2, &(ih->ih_key), TYPE_INDIRECT);
 			else
 			    set_type (KEY_FORMAT_2, &(ih->ih_key), TYPE_DIRECT);
@@ -905,7 +973,7 @@
 		    } else {
 			/* stat data is old, therefore this item is old too */
 			set_offset (KEY_FORMAT_1, &(ih->ih_key), 1);
-			if (get_ih_entry_count (ih) != 0xffff && (get_ih_item_len (ih) % 4 == 0))
+			if ((get_ih_entry_count (ih) != 0xffff) && (get_ih_item_len (ih) % 4 == 0))
 			    set_type (KEY_FORMAT_1, &(ih->ih_key), TYPE_INDIRECT);
 			else {
 			    set_type (KEY_FORMAT_1, &(ih->ih_key), TYPE_DIRECT);
@@ -962,6 +1030,7 @@
                     goto start_again;
                 }
 		
+		/* Check the lenght of the direct item; offset should be ok already. */
 		if (is_direct_ih (ih)) {
 		    if (STORE_TAIL_IN_UNFM (get_offset (&ih->ih_key) + get_ih_item_len (ih) - 1, 
 			    get_ih_item_len (ih), bh->b_size)) 
@@ -993,11 +1062,11 @@
 			delete_item (fs, bh, i);
 			goto start_again;
 		    }
-		}
-		
-		if (is_direct_ih (ih)) {
+		} else if (is_direct_ih (ih)) {
 		    if (!correct_direct_item_offset (get_offset (&ih->ih_key), key_format (&ih->ih_key)) ||
-          		STORE_TAIL_IN_UNFM (offset + get_ih_item_len (ih) - 1, get_ih_item_len (ih), bh->b_size)) {
+			((get_offset (&ih->ih_key) % bh->b_size - 1) + get_ih_item_len (ih) > bh->b_size) || 
+          		STORE_TAIL_IN_UNFM (offset + get_ih_item_len (ih) - 1, get_ih_item_len (ih), bh->b_size)) 
+		    {
                             fsck_log("pass0: vpf-10210: block %lu, item %d: The item with wrong offset ", 
                                 bh->b_blocknr, i);
                             fsck_log("or length found %k, len % lu - deleted\n", &ih->ih_key, get_ih_item_len (ih));
@@ -1007,7 +1076,7 @@
   		}
 		
 		offset += get_bytes_number (ih, fs->fs_blocksize);
-		if (!does_it_fit_into_dev (offset)) {
+		if (!does_it_fit_into_dev (offset, fs_size)) {
                     fsck_log("pass0: vpf-10230: block %lu, item %d: The item offset is is too big %k - deleted\n",
                                         bh->b_blocknr, i, &ih->ih_key);
                     delete_item (fs, bh, i);
@@ -1054,6 +1123,7 @@
 
 		default:
 		    /* upper item was the first item of a node */
+		    /* to make gcc 3.2 do not sware here */;
 		}
 
 		retval = lower_correct (bh, ih, i);
@@ -1073,8 +1143,8 @@
 		    goto start_again;
 
 		default:
-		    /* there were only two items in a node, so we could not
-                       decide what to delete, go and ask user */
+		    /* only 2 items in the node, how to decide what to delete, go and ask user */
+		    /* to make gcc 3.2 do not sware here */;
 		}
 		fsck_log ("pass0: block %lu, items %d and %d: Which of these items looks better (the other will be deleted.)?\n"
 			  "%k\n%k\n", bh->b_blocknr, i-1, i, &(ih - 1)->ih_key, &ih->ih_key);
@@ -1094,7 +1164,7 @@
 	    goto start_again;
 	}
 
-	dirty += correct_key_format (ih);
+	dirty += correct_key_format (ih, symlnk);
 	
 	if (is_stat_data_ih (ih)) {
 	    __u16 mode;
@@ -1112,9 +1182,11 @@
             fsck_log("pass0: vpf-10240: block %lu, item (%d): Item %k, which format (%d) is not equal to StatData "
 		"format (%d), is deleted\n", bh->b_blocknr, i, &ih->ih_key, get_ih_key_format(ih), file_format);
             delete_item (fs, bh, i);
-	    file_format = KEY_FORMAT_UNDEFINED;
             goto start_again;
-        }
+        } else {
+	    file_format = KEY_FORMAT_UNDEFINED;
+	    symlnk = 0;
+	}
 
 
 	if (i && is_stat_data_ih (ih - 1) && !not_of_one_file (&ih->ih_key, &(ih - 1)->ih_key)) {
@@ -1208,7 +1280,7 @@
 	}
 */
 	ind_item = (__u32 *)B_I_PITEM (bh, ih);
-	for (j = 0; j < I_UNFM_NUM (ih); j ++) {
+	for (j = 0; j < (int)I_UNFM_NUM (ih); j ++) {
 	    unfm_ptr = le32_to_cpu (ind_item [j]);
 	    if (!unfm_ptr)
 		continue;
@@ -1247,11 +1319,11 @@
     for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
 	struct reiserfs_de_head * deh;
 
-	mark_objectid_really_used (proper_id_map (fs), get_key_dirid (&ih->ih_key));
-	mark_objectid_really_used (proper_id_map (fs), get_key_objectid (&ih->ih_key));
+	id_map_mark(proper_id_map (fs), get_key_dirid (&ih->ih_key));
+	id_map_mark(proper_id_map (fs), get_key_objectid (&ih->ih_key));
 	if (is_direntry_ih(ih)) {
 	    for (j = 0, deh = B_I_DEH (bh, ih); j < get_ih_entry_count (ih); j ++, deh++) 
-		mark_objectid_really_used(proper_id_map (fs), get_deh_objectid(deh));	    
+		id_map_mark(proper_id_map(fs), get_deh_objectid(deh));	    
 	}
     }
 
@@ -1259,11 +1331,14 @@
 	/* pass 1 will skip this */
 	pass_0_stat (fs)->all_contents_removed ++;
 //	fsck_log ("pass0: block %lu: All items were deleted.\n", bh->b_blocknr);
+	dirty = 0;
+	mark_buffer_clean (bh);
     } else {
 	/* pass1 will use this bitmap */
 	pass0_mark_leaf (bh->b_blocknr);
 	/*fsck_data (fs)->rebuild.leaves ++;*/
     }
+    
     if (dirty) {
 	pass_0_stat (fs)->leaves_corrected ++;
 	mark_buffer_dirty (bh);
@@ -1318,24 +1393,23 @@
 
     for (i = 0; i < get_ih_entry_count (ih); i ++, deh ++) {
 	entrylen = entry_length(ih, deh, i);
-	if (entrylen > REISERFS_MAX_NAME_LEN (blocksize)) {
+	if (entrylen > (int)REISERFS_MAX_NAME_LEN (blocksize))
 	    return 1;
-	}
-	if (get_deh_offset (deh) <= prev_offset) {
+	
+	if (get_deh_offset (deh) <= prev_offset)
 	    return 1;
-	}
+	
 	prev_offset = get_deh_offset (deh);
 
-	if (get_deh_location(deh) + entrylen != prev_location) {
+	if (get_deh_location(deh) + entrylen != prev_location)
 	    return 1;
-	}
+	
 	prev_location = get_deh_location (deh);
 
 	namelen = name_in_entry_length (ih, deh, i);
 	name = name_in_entry (deh, i);
-	if (!is_properly_hashed (fs, name, namelen, get_deh_offset (deh))) {
+	if (!is_properly_hashed (fs, name, namelen, get_deh_offset (deh)))
 	    return 1;
-	}
     }
     return 0;
 }
@@ -1344,9 +1418,9 @@
 /* change incorrect block adresses by 0. Do not consider such item as incorrect */
 static int is_bad_indirect (struct item_head * ih, char * item, int dev, int blocksize)
 {
-    int i;
-    int bad = 0;
     unsigned long blocks;
+    unsigned int i;
+    int bad = 0;
 
     if (get_ih_item_len(ih) % UNFM_P_SIZE) {
 	fsck_log ("is_bad_indirect: indirect item of %H of invalid length\n", ih);
@@ -1445,11 +1519,18 @@
 	/* just to test pass0_correct_leaf */
 	bh = bread (fs->fs_dev, fsck_data (fs)->rebuild.test, fs->fs_blocksize);
 
-	/*
+	if (!bh) {
+	    /* we were reading one block at time, and failed, so mark block bad */
+	    fsck_progress ("%s: Reading of the block %lu failed\n", __FUNCTION__, 
+		fsck_data (fs)->rebuild.test);
+	    reiserfs_free (fs);
+	    exit(0);
+	}
+
 	if (is_leaf_bad (bh)) {
 	    fsck_progress ("###############  bad #################\n");
 	}
-	*/
+
 	pass0_correct_leaf (fs, bh);
 	
 	print_block (stdout, fs, bh, 3, -1, -1);
@@ -1489,7 +1570,7 @@
 
 	pass_0_stat (fs)->dealt_with ++;
 	what_node = who_is_this (bh->b_data, bh->b_size);
-	if ( what_node != THE_LEAF ) {
+	if ( what_node != THE_LEAF && what_node != HAS_IH_ARRAY ) {
 	    brelse (bh);
 	    continue;
 	}
@@ -1502,7 +1583,7 @@
 
 
     /* just in case */
-    mark_objectid_really_used (proper_id_map (fs), REISERFS_ROOT_OBJECTID);
+    id_map_mark(proper_id_map (fs), REISERFS_ROOT_OBJECTID);
 
 }
 
@@ -1572,16 +1653,16 @@
 
 
 /* these are used to allocate blocks for tree building */
-int are_there_allocable_blocks (int amout_needed)
-{
+int are_there_allocable_blocks (unsigned int amout_needed) {
     if (reiserfs_bitmap_zeros (fsck_allocable_bitmap (fs)) < amout_needed) {
-	int zeros = 0, i;
+	unsigned int zeros = 0, i;
 	
 	fsck_progress ("Not enough allocable blocks, checking bitmap...");
-	for (i = 0; i < fsck_allocable_bitmap (fs)->bm_bit_size; i ++)
+	for (i = 0; i < fsck_allocable_bitmap (fs)->bm_bit_size; i ++) {
 	    if (!reiserfs_bitmap_test_bit (fsck_allocable_bitmap (fs), i))
 		zeros ++;
-	fsck_progress ("there are %d allocable blocks, btw\n", zeros);
+	}
+	fsck_progress ("there are %u allocable blocks, btw\n", zeros);
 	return 0;
     }
     return 1;
@@ -1609,7 +1690,7 @@
 static void choose_hash_function (reiserfs_filsys_t * fs)
 {
     unsigned long max;
-    int hash_code;
+    unsigned int hash_code;
     int i;
 
     if (fsck_hash_defined (fs))
@@ -1682,7 +1763,7 @@
     case EXTERN_BITMAP:
 	fp = fopen (fsck_data (fs)->rebuild.bitmap_file_name, "r");
 	if (!fp)
-	    reiserfs_panic ("Could not load bitmap: %m\n");
+	    reiserfs_panic ("Could not load bitmap: %s\n", strerror(errno));
 	fsck_source_bitmap (fs) = reiserfs_bitmap_load (fp);
 	if (!fsck_source_bitmap (fs))
 	    reiserfs_panic ("Could not load fitmap from \"%s\"", 
@@ -1778,7 +1859,7 @@
     make_aux_bitmaps (fs);
 
     /* on pass0 all objectids will be marked here as used */
-    proper_id_map (fs) = init_id_map ();
+    proper_id_map (fs) = id_map_init();
 
     /* pass0 gathers statistics about hash hits */
     hash_hits_init (fs);
@@ -1802,7 +1883,6 @@
     reiserfs_bitmap_save (file,  bad_unfm_bitmap);
     reiserfs_end_stage_info_save (file);
     close_file (file);
-    retval = unlink (state_dump_file (fs));
     retval = rename ("temp_fsck_file.deleteme", state_dump_file (fs));
     if (retval != 0)
 	fsck_progress ("%s: Could not rename the temporary file temp_fsck_file.deleteme to %s",
@@ -1837,7 +1917,7 @@
 
     /* update super block: hash, objectid map, fsck state */
     choose_hash_function (fs);
-    flush_objectid_map (proper_id_map (fs), fs);
+    id_map_flush(proper_id_map (fs), fs);
     set_sb_fs_state (fs->fs_ondisk_sb, PASS_0_DONE);
     mark_buffer_dirty (fs->fs_super_bh);
 
@@ -1862,7 +1942,7 @@
     } else
 	save_pass_0_result (fs);
 
-    free_id_map (proper_id_map (fs));
+    id_map_free(proper_id_map (fs));
     proper_id_map (fs) = 0;
     
     time (&t);
diff --git a/fsck/pass1.c b/fsck/pass1.c
index bea2575..95a4c0a 100644
--- a/fsck/pass1.c
+++ b/fsck/pass1.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README 
  */
+
 #include "fsck.h"
 #include <stdlib.h>
 
@@ -20,17 +22,16 @@
 	return bh;
 //    die ("make_buffer: uptodate buffer found");
     memcpy (bh->b_data, data, size);
-    set_bit (BH_Uptodate, (char *)&bh->b_state);
+    misc_set_bit (BH_Uptodate, (char *)&bh->b_state);
     return bh;
 }
 
 
-int find_not_of_one_file(struct key * to_find, struct key * key)
-{
-    if ((get_key_objectid (to_find) != -1) &&
+int find_not_of_one_file(struct key * to_find, struct key * key) {
+    if ((get_key_objectid (to_find) != ~0ul) &&
         (get_key_objectid (to_find) != get_key_objectid (key)))
         return 1;
-    if ((get_key_dirid (to_find) != -1) &&
+    if ((get_key_dirid (to_find) != ~0ul) &&
         (get_key_dirid (to_find) != get_key_dirid (key)))
         return 1;
     return 0;
@@ -97,9 +98,10 @@
 static void indirect_in_tree (struct buffer_head * bh,
 			      struct item_head * ih)
 {
-    int i, ret;
+    unsigned int i;
     __u32 * unp;
     __u32 unfm_ptr;
+    int ret;
 
     unp = (__u32 *)B_I_PITEM (bh, ih);
     
@@ -244,7 +246,7 @@
 
 int tree_is_empty (void)
 {
-    return (get_sb_root_block (fs->fs_ondisk_sb) == ~0) ? 1 : 0;
+    return (get_sb_root_block (fs->fs_ondisk_sb) == ~0ul || get_sb_root_block (fs->fs_ondisk_sb) == 0) ? 1 : 0;
 }
 
 
@@ -336,7 +338,7 @@
 static void pass1_correct_leaf (reiserfs_filsys_t * fs,
 				struct buffer_head * bh)
 {
-    int i, j;
+    unsigned int i, j;
     struct item_head * ih;
     __u32 * ind_item;
     __u32 unfm_ptr;
@@ -349,7 +351,7 @@
 	    struct reiserfs_de_head * deh;
 	    char * name;
 	    int name_len;
-	    int hash_code;
+	    unsigned int hash_code;
 
 	    deh = B_I_DEH (bh, ih);
 	    for (j = 0; j < get_ih_entry_count (ih); j ++) {
@@ -448,7 +450,7 @@
    on-disk bitmap */
 static void init_new_bitmap (reiserfs_filsys_t * fs)
 {
-    int i;
+    unsigned int i;
     unsigned long block;
     unsigned long reserved;
     
@@ -549,7 +551,7 @@
 	    pass_1_stat (fs)->allocable_blocks ++;
 	}
     }
-    fsck_progress ("fininshed\n");
+    fsck_progress ("finished\n");
 
     fs->block_allocator = reiserfsck_reiserfs_new_blocknrs;
     fs->block_deallocator = reiserfsck_reiserfs_free_block;
@@ -586,7 +588,7 @@
 	return;
 
     /* to be able to get a new bitmap on pass2 we should flush it on disk
-       new_bitmap should not be flushed on disk if run w/out -d option, as
+       new_bitmap should not be flushed on disk if run without -d option, as
        if fsck fails on pass1 we get wrong bitmap on the next fsck start */
     reiserfs_flush_to_ondisk_bitmap (fsck_new_bitmap (fs), fs);
     
@@ -597,7 +599,6 @@
     reiserfs_bitmap_save (file,  fsck_allocable_bitmap(fs));
     reiserfs_end_stage_info_save (file);
     close_file (file);
-    retval = unlink (state_dump_file (fs));
     retval = rename ("temp_fsck_file.deleteme", state_dump_file (fs));
     if (retval != 0)
 	fsck_progress ("pass 1: Could not rename the temporary file temp_fsck_file.deleteme to %s",
@@ -622,8 +623,10 @@
 
 
     /* we need objectid map on pass 2 to be able to relocate files */
-    proper_id_map (fs) = init_id_map ();
+    proper_id_map (fs) = id_map_init();
+    /* Not implemented yet.
     fetch_objectid_map (proper_id_map (fs), fs);
+    */
 
     fsck_progress ("Pass 1 result loaded. %d blocks used, %d allocable, "
 		   "still to be inserted %d\n",
@@ -666,11 +669,9 @@
 
 	what_node = who_is_this (bh->b_data, bh->b_size);
 	if ( what_node != THE_LEAF ) {
-	    fsck_progress ("build_the_tree: Nothing but leaves are expected. "
-			   "Block %lu - %s\n", i,
-			   (what_node == THE_INTERNAL) ? "internal" : "??");
-	    brelse (bh);
-	    continue;
+	    check_memory_msg();
+	    die ("build_the_tree: Nothing but leaves are expected. Block %lu - %s\n", 
+		i, which_block(what_node));
 	}
 	
 	if (is_block_used (i) && !(block_of_journal (fs, i) &&
@@ -770,7 +771,7 @@
 
     if (proper_id_map (fs)) {
 	/* when we run pass 1 only - we do not have proper_id_map */
-	free_id_map (proper_id_map (fs));
+	id_map_free(proper_id_map (fs));
 	proper_id_map (fs) = 0;
     }
     
diff --git a/fsck/pass2.c b/fsck/pass2.c
index b3a91a1..7ffecba 100644
--- a/fsck/pass2.c
+++ b/fsck/pass2.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "fsck.h"
@@ -20,26 +21,22 @@
    of directory */
 
 
-/* in list of this structures we store what has been
-   relocated. */
+/* in list of this structures we store what has been relocated. */
 struct relocated {
     unsigned long old_dir_id;
     unsigned long old_objectid;
+    
     unsigned long new_objectid;
-    /*mode_t mode;*/
+    
     struct relocated * next;
 };
 
-
 /* all relocated files will be linked into lost+found directory at the
    beginning of semantic pass */
-struct relocated * relocated_list;
+static struct relocated * relocated_list = NULL;
 
-
-__u32 get_relocated_objectid_from_list (struct key * key) {
-    struct relocated * cur;
-
-    cur = relocated_list;
+static __u32 get_relocated_objectid_from_list (struct key * key) {
+    struct relocated *cur = relocated_list;
 
     while (cur) {
 	if (cur->old_dir_id == get_key_dirid (key) &&
@@ -63,7 +60,7 @@
     cur = getmem (sizeof (struct relocated));
     cur->old_dir_id = get_key_dirid (key);
     cur->old_objectid = get_key_objectid (key);
-    cur->new_objectid = get_unused_objectid (fs);
+    cur->new_objectid = id_map_alloc(proper_id_map(fs));
     cur->next = relocated_list;
     relocated_list = cur;
 /*    fsck_log ("relocation: (%K) is relocated to (%lu, %lu)\n",
@@ -71,6 +68,65 @@
     return cur->new_objectid;
 }
 
+/* relocated files get added into lost+found with slightly different names */
+static __u64 link_one (struct relocated * file) {
+    char * name;
+    struct key obj_key;
+    __u64 len = 0;
+
+    asprintf (&name, "%lu,%lu", file->old_dir_id, file->new_objectid);
+    set_key_dirid (&obj_key, file->old_dir_id);
+    set_key_objectid (&obj_key, file->new_objectid);
+
+    /* 0 for fsck_need does not mean too much - it would make effect if there 
+     * were no this directory yet. But /lost_found is there already */
+    len = reiserfs_add_entry (fs, &lost_found_dir_key, name, 
+	name_length(name, lost_found_dir_format), &obj_key, 0/*fsck_need*/);
+    pass_2_stat (fs)->relocated ++;
+    free (name);
+
+    return len;
+}
+
+void linked_already(struct key *new_key /*, link_func_t link_func*/) {
+    struct relocated *cur = relocated_list;
+    struct relocated *prev = NULL;
+
+    while (cur) {
+	if (cur->old_dir_id == get_key_dirid(new_key) && 
+	    cur->new_objectid == get_key_objectid(new_key))
+	    break;
+
+	prev = cur;
+	cur = cur->next;
+    }
+
+    if (cur) {	
+	/* len = link_func(cur); */
+
+	if (prev) 
+	    prev->next = cur->next;
+	else
+	    relocated_list = cur->next;
+
+	freemem (cur);
+    }
+}
+
+void link_relocated_files (void)
+{
+    struct relocated * tmp;
+    int count;
+    
+    count = 0;
+    while (relocated_list) {
+	link_one (relocated_list);
+	tmp = relocated_list;
+	relocated_list = relocated_list->next;
+	freemem (tmp);
+	count ++;
+    }
+}
 
 /* this item is in tree. All unformatted pointer are correct. Do not
    check them */
@@ -318,42 +374,6 @@
 }
 
 
-/* relocated files get added into lost+found with slightly different names */
-static void link_one (struct relocated * file)
-{
-    char * name;
-    struct key obj_key;
-
-    asprintf (&name, "%lu,%lu", file->old_dir_id, file->new_objectid);
-    set_key_dirid (&obj_key, file->old_dir_id);
-    set_key_objectid (&obj_key, file->new_objectid);
-
-
-    /* 0 for fsck_need does not mean too much - it would make effect
-       if there were no this directory yet. But /lost_found is there
-       already */
-    reiserfs_add_entry (fs, &lost_found_dir_key, name, name_length (name, lost_found_dir_format),
-    		&obj_key, 0/*fsck_need*/);
-    pass_2_stat (fs)->relocated ++;
-    free (name);
-}
-
-
-void link_relocated_files (void)
-{
-    struct relocated * tmp;
-    int count;
-    
-    count = 0;
-    while (relocated_list) {
-	link_one (relocated_list);
-	tmp = relocated_list;
-	relocated_list = relocated_list->next;
-	freemem (tmp);
-	count ++;
-    }
-}
-
 
 void insert_item_separately (struct item_head * ih,
 			     char * item, int was_in_tree)
@@ -424,7 +444,6 @@
     reiserfs_begin_stage_info_save(file, TREE_IS_BUILT);
     reiserfs_end_stage_info_save (file);
     close_file (file);
-    retval = unlink (state_dump_file (fs));
     retval = rename ("temp_fsck_file.deleteme", state_dump_file (fs));
     if (retval != 0)
 	fsck_progress ("%s: Could not rename the temporary file temp_fsck_file.deleteme to %s",
@@ -447,8 +466,10 @@
     fs->block_deallocator = reiserfsck_reiserfs_free_block;
 
     /* we need objectid map on semantic pass to be able to relocate files */
-    proper_id_map (fs) = init_id_map ();
+    proper_id_map (fs) = id_map_init();
+    /* Not implemented yet.
     fetch_objectid_map (proper_id_map (fs), fs);    
+    */
 }
 
     
@@ -475,21 +496,21 @@
 	    if (bh == 0) {
 	        fsck_log ("pass_2: Reading of the block (%lu) failed on the device 0x%x\n",
 		      j, fs->fs_dev);
-                goto next;
+                goto cont;
             }
 	
             if (is_block_used (bh->b_blocknr) && !(block_of_journal (fs, bh->b_blocknr) &&
 					       fsck_data(fs)->rebuild.use_journal_area)) {
-	        fsck_log ("%s: The block (%lu) is in the tree already. Should not happen.\n", 
+		fsck_log("%s: The block (%lu) is in the tree already. Should not happen.\n", 
 		    __FUNCTION__, bh->b_blocknr);
-	        goto next;
+		goto cont;
             }
             /* this must be leaf */
             what_node = who_is_this (bh->b_data, bh->b_size);
 	    if (what_node != THE_LEAF) { // || B_IS_KEYS_LEVEL(bh)) {
 	        fsck_log ("%s: The block (%b), marked as a leaf on the first two passes, is not a leaf! Will be skipped.\n", 
 		    __FUNCTION__, bh);
-	        goto next;
+	        goto cont;
 	    }
 /*	
 	    fsck_log ("block %lu is being inserted\n", bh->b_blocknr);
@@ -506,7 +527,7 @@
                 put_stat_data_items (bh);
 
             print_how_far (fsck_progress_file (fs), &done, total, 1, fsck_quiet (fs));
-        next:
+        cont:
 	    brelse (bh);
 	    j ++;
         }
@@ -547,7 +568,7 @@
   
     /* write all dirty blocks */
     fsck_progress ("Flushing..");
-    flush_objectid_map (proper_id_map (fs), fs);
+    id_map_flush(proper_id_map (fs), fs);
     fs->fs_dirt = 1;
     reiserfs_flush_to_ondisk_bitmap (fs->fs_bitmap2, fs);
     reiserfs_flush (fs);
@@ -571,7 +592,7 @@
 	save_pass_2_result (fs);
 
     
-    free_id_map (proper_id_map (fs));
+    id_map_free(proper_id_map (fs));
     proper_id_map (fs) = 0;
     
     reiserfs_delete_bitmap (fsck_new_bitmap (fs));
@@ -601,8 +622,18 @@
     
     after_pass_2 (fs);
 
-    if (get_sb_root_block (fs->fs_ondisk_sb) == -1)
-	die ("\n\nNo reiserfs metadata found");
+    if (get_sb_root_block (fs->fs_ondisk_sb) == ~0ul || 
+	get_sb_root_block (fs->fs_ondisk_sb) == 0)
+	die ( "\nNo reiserfs metadata found.  If you are sure that you had the reiserfs\n"
+		"on this partition,  then the start  of the partition  might be changed\n"
+		"or all data were wiped out. The start of the partition may get changed\n"
+		"by a partitioner  if you have used one.  Then you probably rebuilt the\n"
+		"superblock as there was no one.  Zero the block at 64K offset from the\n"
+		"start of the partition (a new super block you have just built) and try\n"
+	        "to move the start of the partition a few cylinders aside  and check if\n" 
+		"debugreiserfs /dev/xxx detects a reiserfs super block. If it does this\n"
+	        "is likely to be the right super block version.                        \n"
+		"If this makes you nervous, try  www.namesys.com/support.html,  and for\n"
+		"$25 the author of fsck,  or a colleague  if he is out,  will  step you\n"
+		"through it all.\n");
 }
-
-
diff --git a/fsck/pass4.c b/fsck/pass4.c
index da90257..22e100d 100644
--- a/fsck/pass4.c
+++ b/fsck/pass4.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "fsck.h"
 
 void pass_4_check_unaccessed_items (void)
@@ -58,6 +60,7 @@
 	pathrelse (&path);
 
     cont:
+	/* to make gcc 3.2 do not sware here */;
     }
 
     pathrelse (&path);
@@ -77,7 +80,7 @@
     /* write all dirty blocks */
     fsck_progress ("Flushing..");
     fs->fs_dirt = 1;
-    flush_objectid_map (proper_id_map (fs), fs);
+    id_map_flush(proper_id_map (fs), fs);
     reiserfs_flush_to_ondisk_bitmap (fs->fs_bitmap2, fs);
     reiserfs_flush (fs);
     fsck_progress ("finished\n");
diff --git a/fsck/reiserfsck.8 b/fsck/reiserfsck.8
index a57cd8f..7762656 100644
--- a/fsck/reiserfsck.8
+++ b/fsck/reiserfsck.8
@@ -1,25 +1,26 @@
 .\" -*- nroff -*-
-.\" Copyright 1996-2002 Hans Reiser.
+.\" Copyright 1996-2003 Hans Reiser.
 .\" 
-.TH REISERFSCK 8 "January 2002" "Reiserfsprogs-3.6.4"
+.TH REISERFSCK 8 "April 2003" "Reiserfsprogs-3.6.9"
 .SH NAME
 reiserfsck \- check a Linux Reiserfs file system
 .SH SYNOPSIS
 .B reiserfsck 
 [ \fB-afprVy\fR ]
-[ \fB--check\fR | \fB--fix-fixable\fR | \fB--rebuild-sb\fR
+[ \fB--rebuild-sb\fR | \fB--check\fR | \fB--fix-fixable\fR
 | \fB--rebuild-tree\fR | \fB--clean-attributes\fR ]
 .\" [ \fB-i\fR | \fB--interactive\fR ]
-[ \fB-j\fR | \fB--journal-device\fR \fIdevice\fR ]
-[ \fB--no-journal-available\fR ]
-[ \fB-z\fR | \fB--adjust-file-size\fR ]
-[ \fB-S\fR | \fB--scan-whole-partition\fR ]
-[ \fB-l\fR | \fB--logfile \fIfilename\fR ]
+[ \fB-j\fR | \fB--journal\fR \fIdevice\fR ]
+[ \fB-z\fR | \fB--adjust-size\fR ]
 [ \fB-n\fR | \fB--nolog\fR ]
+[ \fB-l\fR | \fB--logfile \fIfile\fR ]
 [ \fB-q\fR | \fB--quiet\fR ]
+[ \fB-y\fR | \fB--yes\fR ]
 .\" [ \fB-b\fR | \fB--scan-marked-in-bitmap \fIbitmap-filename\fR ]
 .\" [ \fB-h\fR | \fB--hash \fIhash-name\fR ]
 .\" [ \fB-g\fR | \fB--background\fR ]
+[ \fB-S\fR | \fB--scan-whole-partition\fR ]
+[ \fB--no-journal-available\fR ]
 .I device
 .SH DESCRIPTION
 \fBReiserfsck\fR searches for a Reiserfs filesystem on a device, replays 
@@ -30,14 +31,16 @@
 for IDE disk partition or /dev/sdXX for SCSI disk partition).
 .SH OPTIONS
 .TP
+.B --rebuild-sb
+This option recovers the superblock on a Reiserfs partition.  Normally you 
+only need this option if mount reports "read_super_block: can't find 
+a reiserfs file system" and you are sure that a Reiserfs file system is 
+there.
+.TP
 .B --check
 This default action checks file system consistency and reports but 
 does not repair any corruption that it finds. This option may be 
-used on a read-only file system mount.  The \fB--check\fR option exits 
-with status 0 to indicate that no corruption was found.  Otherwise,
-\fBreiserfsck\fR returns 1 to indicate corruption that can be fixed with 
-\fB--fix-fixable\fR and 2 to indicate corruption that requires 
-\fB--rebuild-tree\fR.
+used on a read-only file system mount.  
 .TP
 .B --fix-fixable
 This option recovers certain kinds of corruption that do not require 
@@ -47,12 +50,6 @@
 zeroing invalid data-block pointers, correcting st_size and st_blocks 
 for directories, and deleting invalid directory entries.
 .TP
-.B --rebuild-sb
-This option recovers the superblock on a Reiserfs partition.  Normally you 
-only need this option if mount reports "read_super_block: can't find 
-a reiserfs file system" and you are sure that a Reiserfs file system is 
-there.
-.TP
 .B --rebuild-tree
 This option rebuilds the entire file system tree using leaf nodes found 
 on the device.  Normally you only need this option if the \fB--check\fR 
@@ -63,7 +60,7 @@
 .B --clean-attributes
 This option cleans reserved fields of Stat-Data items.
 .TP
-.B \fB--journal-device \fIdevice \fR, \fB-j \fIdevice \fR
+.B \fB--journal \fIdevice \fR, \fB-j \fIdevice \fR
 This option supplies the device name of the current file system journal.  
 This option is required when the journal resides on a separate device 
 from the main data device (although it can be avoided with the expert
@@ -72,14 +69,14 @@
 .\" .B --interactive, -i
 .\" This makes \fBreiserfsck\fR to stop after each pass completed.
 .\" .TP
-.B --adjust-file-size, -z
+.B --adjust-size, -z
 This option causes \fBreiserfsck\fR to correct file sizes that
 are larger than the offset of the last discovered byte.  This
 implies that holes at the end of a file will be removed.  File
 sizes that are smaller than the offset of the last discovered
 byte are corrected by --fix-fixable.
 .TP
-\fB--logfile \fIfilename\fR, \fB-l \fI filename\fR
+\fB--logfile \fIfile\fR, \fB-l \fI file\fR
 This option causes \fBreiserfsck\fR to report any corruption it finds 
 to the specified log file rather than stderr.
 .TP
@@ -89,22 +86,26 @@
 .B --quiet, -q
 This option prevents \fBreiserfsck\fR from reporting its rate of progress.
 .TP
+.B --yes, -y
+This option inhibits \fBreiserfsck\fR from asking you for confirmation after
+telling you what it is going to do, assuming yes. For safety, it does not 
+work with the --rebuild-tree option.
+.TP
 \fB-a\fR, \fB-p\fR
-These options are usually passed by fsck -A during the automatic 
-checking of /etc/fstab partitions.  For compatibility, these options
-simply cause reiserfsck to print information about the specified file 
-system.  No checks are performed. 
-When it is set - \fBreiserfsck\fR assumes that it is called by \fBfsck\fR -A,
-provides some information about the specified filesystem and exits. 
+These options are usually passed by fsck -A during the automatic checking 
+of those partitions listed in /etc/fstab. These options cause \fBreiserfsck\fR 
+to print some information about the specified file system, check if error 
+flags in the superblock are set and do some light-weight checks. If these 
+checks reveal a corruption or the flag indicating a (possibly fixable) 
+corruption is found set in the superblock, then \fBreiserfsck\fR switches 
+to the fix-fixable mode. If the flag indicating a fatal corruption is found 
+set in the superblock, then \fBreiserfsck\fR finishes with an error.
 .TP
 .B -V
 This option prints the reiserfsprogs version and exit.
 .TP
-\fB-r\fR, \fB-p\fR, \fB-y\fR
+\fB-r\fR, \fB-f\fR
 These options are ignored.
-.TP
-.B -V\fR, \fB-f\fR
-prints version and exits
 .SH EXPERT OPTIONS
 DO NOT USE THESE OPTIONS UNLESS YOU KNOW WHAT YOU ARE DOING. 
 WE ARE NOT RESPONSIBLE IF YOU LOSE DATA AS A RESULT OF THESE
@@ -142,28 +143,34 @@
 6. If the \fB--rebuild-tree\fR step fails or does not recover what you expected, 
 please submit this as a bug report. Try to provide as much information as 
 possible and we will try to help solve the problem.
-SH EXIT CODES
-\freiserfsck\fR uses the following exit codes:
+.SH EXIT CODES
+\fBreiserfsck\fR uses the following exit codes:
 .br
-\   0\  \-\ No errors.
+\   \fI0\fR \-\ No errors.
 .br
-\   1\  \-\ Errors found, \fresierfsck\fR \fB--fix-fixable\fR needs to be launched.
+\   \fI1\fR \-\ File system errors corrected.
 .br
-\   2\  \-\ Errors found, \fresierfsck\fR \fB--rebuild-tree\fR needs to be launched.
+\   \fI4\fR \-\ File system fatal errors left uncorrected,
 .br
-\   8\  \-\ Operational error.
+\	  \fBreiserfsck --rebuild-tree\fR needs to be launched.
 .br
-\   16\ \-\ Usage or syntax error.
+\   \fI6\fR \-\ File system fixable errors left uncorrected,
+.br
+\	  \fBreiserfsck --fix-fixable\fR needs to be launched.
+.br
+\   \fI8\fR \-\ Operational error.
+.br
+\   \fI16\fR \-\ Usage or syntax error.
 .br
 .SH AUTHOR
-This version of \fBreiserfsck\fR has been written by Vitaly Fertman <vitaly@namesys.com>
-and Vladimir Saveliev <vs@namesys.com>.
+This version of \fBreiserfsck\fR has been written by Vitaly Fertman <vitaly@namesys.com>.
 .SH BUGS
 There are likely to be some bugs. Please report bugs to the ReiserFS mail-list 
 <reiserfs-list@namesys.com>.
 .SH TODO
-Faster recovering, signal handling, i/o error handling, return reasonable exit codes, etc.
+Faster recovering, signal handling, i/o error handling, etc.
 .SH SEE ALSO
 .BR mkreiserfs (8),
-.BR debugreiserfs (8),
 .BR reiserfstune (8)
+.BR resize_reiserfs (8),
+.BR debugreiserfs (8),
diff --git a/fsck/semantic_check.c b/fsck/semantic_check.c
index 8034439..d97bc31 100644
--- a/fsck/semantic_check.c
+++ b/fsck/semantic_check.c
@@ -1,6 +1,7 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by reiserfsprogs/README
  */
+
 #include "fsck.h"
 
 static struct key *trunc_links = NULL;
@@ -9,8 +10,8 @@
 int wrong_mode (struct key * key, __u16 * mode, __u64 real_size, int symlink);
 int wrong_st_blocks(struct key * key, __u32 * blocks, __u32 sd_blocks, __u16 mode, 
 		    int new_format);
-int wrong_st_size (struct key * key, loff_t max_file_size, int blocksize,
-		   __u64 * size, __u64 sd_size, int is_dir);
+int wrong_st_size (struct key * key, unsigned long long max_file_size, int blocksize,
+		   __u64 * size, __u64 sd_size, int type);
 int wrong_first_direct_byte (struct key * key, int blocksize, __u32 * first_direct_byte,
 			     __u32 sd_first_direct_byte, __u32 size);
 void get_object_key (struct reiserfs_de_head * deh, struct key * key, 
@@ -97,7 +98,6 @@
     __u32 blocks, sd_blocks;	/* proper values and value in stat data */
     __u32 first_direct_byte, sd_first_direct_byte;
 
-    struct buffer_head * bh;
     struct item_head * ih, sd_ih;
     int fix_sd;
     int symlnk = 0;
@@ -106,14 +106,14 @@
 
 
     ih = get_ih (path);
-    bh = get_bh (path);
 
     if (new_ih) {
 	/* this objectid is used already */
 	*new_ih = *ih;
 	pathrelse (path);
 	rewrite_file (new_ih, 1, 1);
-	one_less_corruption (fs, fixable);
+	linked_already(&new_ih->ih_key);
+	one_less_corruption (fs, FIXABLE);
 	sem_pass_stat (fs)->oid_sharing_files_relocated ++;
 	retval = RELOCATED;
 	if (reiserfs_search_by_key_4 (fs, &(new_ih->ih_key), path) == ITEM_NOT_FOUND)
@@ -121,7 +121,6 @@
 		"the relocated file %K", &new_ih->ih_key);
 	/* stat data is marked unreachable again due to relocation, fix that */
 	ih = get_ih (path);
-	bh = get_bh (path);
 	sd = get_item (path);
     }
     
@@ -162,7 +161,7 @@
     if (are_file_items_correct (&sd_ih, sd, &real_size, &blocks, 0/* do not mark reachable */,
 	&symlnk) != 1) 
     {
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
 	fsck_log ("check_regular_file: The file %K with the corrupted structure found\n", 
 	    &sd_ih.ih_key);
     } else {
@@ -177,7 +176,8 @@
 	    &tmp_position, comp_short_keys) != POSITION_FOUND) 
 	{
 	    fix_sd += wrong_st_size (&sd_ih.ih_key, is_new_file ? MAX_FILE_SIZE_V2 : 
-		MAX_FILE_SIZE_V1, fs->fs_blocksize, &real_size, sd_size, 0/*not dir*/);
+		MAX_FILE_SIZE_V1, fs->fs_blocksize, &real_size, sd_size, 
+		symlnk ? TYPE_SYMLINK : 0);
 	} else {
 	    real_size = sd_size;
 	}
@@ -186,12 +186,13 @@
 
 	if (fix_sd) {
 	    if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
+    		struct buffer_head * bh;
   	        /* find stat data and correct it */
   	        set_type_and_offset (KEY_FORMAT_1, &sd_ih.ih_key, SD_OFFSET, TYPE_STAT_DATA);
 	        if (reiserfs_search_by_key_4 (fs, &sd_ih.ih_key, path) != ITEM_FOUND) {
 		    fsck_log ("check_regular_file: A StatData of the file %K cannot be "
 			"found\n", &sd_ih.ih_key);
-                    one_more_corruption (fs, fatal);
+                    one_more_corruption (fs, FATAL);
                     return STAT_DATA_NOT_FOUND;
 	        }
 	    
@@ -209,7 +210,7 @@
 	    }
 	}
     }    
-    return OK;
+    return retval;
 }
 
 /* returns buffer, containing found directory item.*/
@@ -256,7 +257,7 @@
 	    fsck_log (" - entry was added\n");
 	    goto start_again;
 	} else {
-	    one_more_corruption (fs, fixable);
+	    one_more_corruption (fs, FIXABLE);
 	    fsck_log ("\n");
 	    if (retval == DIRECTORY_NOT_FOUND)
 	        return 0;
@@ -279,12 +280,12 @@
     /* mark hidden entries as visible, set "." and ".." correctly */
     deh += *pos_in_item;
     for (i = *pos_in_item; i < get_ih_entry_count (ih); i ++, deh ++) {
-	int namelen;
+/*	int namelen;
 	char * name;
 
 	name = name_in_entry (deh, i);
 	namelen = name_in_entry_length (ih, deh, i);
-/*	if (de_hidden (deh)) // handled in check_tree
+	if (de_hidden (deh)) // handled in check_tree
 	    reiserfs_panic ("get_next_directory_item: item %k: hidden entry %d \'%.*s\'\n",
 			    key, i, namelen, name);
 */
@@ -337,7 +338,7 @@
 	set_key_objectid (key, 0);
     }
 
-    if (fsck_mode (fs) != FSCK_CHECK && fsck_mode (fs) != FSCK_FIX_FIXABLE)
+    if (fsck_mode (fs) == FSCK_REBUILD)
         mark_item_reachable (get_ih (&path), bh);
     pathrelse (&path);
 
@@ -364,17 +365,17 @@
     __u64 sd_size;
     __u32 sd_blocks;
     int fix_sd;
-    int relocate;
+    /*int relocate;*/
     int dir_format = 0;
     __u16 mode;
     	
     retval = OK;
 
- start_again: /* when directory was relocated */
+ /* start_again: when directory was relocated */
 
     if (!KEY_IS_STAT_DATA_KEY (key)) {
 	fsck_log ("check_semantic_pass: The key %k must be key of a StatData\n", key);
-	one_more_corruption (fs, fatal);
+	one_more_corruption (fs, FATAL);
         return STAT_DATA_NOT_FOUND;
     }
 
@@ -389,27 +390,39 @@
     sd = get_item(&path);
 
     get_sd_nlink (ih, sd, &nlink);
-    relocate = should_be_relocated(&ih->ih_key);
+
+    /* It seems quite difficult to relocate objects on fix-fixable - 
+     * rewrite_file calls reiserfs_file_write which can convert tails 
+     * to unfm, plus unreachable, was_tail flags, etc. */
+    if ((/* relocate = */ should_be_relocated(&ih->ih_key))) {
+	/*
+	if (fsck_mode(fs) == FSCK_CHECK)
+	    relocate = 0;
+	*/
+	one_more_corruption(fs, FATAL);
+    }
 
     if (fix_obviously_wrong_sd_mode (&path)) {
-        one_more_corruption (fs, fixable);
+        one_more_corruption (fs, FIXABLE);
+	pathrelse (&path);
         return OK;
     }
     
     if (nlink == 0) {
 	fsck_log ("%s: block %lu: The StatData %k has bad nlink number (%u)\n",
             __FUNCTION__, get_bh(&path)->b_blocknr, &ih->ih_key, nlink);
-	one_more_corruption (fs, fatal); 
+	one_more_corruption (fs, FATAL); 
     }
     
     if (not_a_directory (sd)) {
 	fsck_check_stat (fs)->files ++;
 	
-	retval = check_check_regular_file (&path, sd, relocate ? new_ih : 0);
+	retval = check_check_regular_file (&path, sd, /* relocate ? new_ih : */ 0);
 	pathrelse (&path);
 	return retval;
     }
-        
+
+/*
     if (relocate) {
 	if (!new_ih)
 	    reiserfs_panic ("check_semantic_pass: Memory is not prepared for relocation of "
@@ -418,12 +431,13 @@
 	pathrelse (&path);
 	sem_pass_stat (fs)->oid_sharing_dirs_relocated ++;
 	relocate_dir (new_ih, 1);
-	one_less_corruption (fs, fixable);
+	linked_already(&new_ih->ih_key);
+	one_less_corruption (fs, FIXABLE);
 	*key = new_ih->ih_key;
 	retval = RELOCATED;
 	goto start_again;
     }
-
+*/
 
 /* 
     if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
@@ -489,6 +503,7 @@
 	
 	for (i = pos_in_item; i < get_ih_entry_count (&tmp_ih); i ++, deh ++) {
 	    struct item_head relocated_ih;
+	    int ret = OK;
 	    
 	    if (name) {
 		free (name);
@@ -515,7 +530,7 @@
 		    fsck_log ("Entry %K (\"%.*s\") in the directory %K is not formated "
 			"properly.\n", (struct key *)&(deh->deh2_dir_id), namelen, name, 
 			&tmp_ih.ih_key);
-		    one_more_corruption (fs, fixable);
+		    one_more_corruption (fs, FIXABLE);
 		}
 	    }
 	
@@ -523,17 +538,17 @@
 	    print_name (name, namelen);
 	    
 	    if (!is_properly_hashed (fs, name, namelen, get_deh_offset (deh))) {
-		one_more_corruption (fs, fatal);
+		one_more_corruption (fs, FATAL);
 		fsck_log ("check_semantic_pass: Hash mismatch detected for (%.*s) in "
 		    "directory %K\n", namelen, name, &tmp_ih.ih_key);
 	    }
 	
 	    if (is_dot (name, namelen) || (is_dot_dot (name, namelen))) {
 		/* do not go through "." and ".." */
-		retval = OK;
+		ret = OK;
 	    } else {
-		if ((retval = add_path_key (&object_key)) == 0) {
-		    retval = check_semantic_pass (&object_key, key, 
+		if ((ret = add_path_key (&object_key)) == 0) {
+		    ret = check_semantic_pass (&object_key, key, 
 			is_dot_dot(name, namelen), &relocated_ih);
 		    del_path_key ();
 		}
@@ -542,7 +557,7 @@
 	    erase_name (namelen);
 	    
 	    /* check what check_semantic_tree returned */
-	    switch (retval) {
+	    switch (ret) {
 	    case OK:
 		dir_size += DEH_SIZE + entry_len;
 		break;
@@ -555,7 +570,7 @@
 		    reiserfs_remove_entry (fs, &entry_key);
 		    fsck_log (" - removed");
 		} else {
-		    one_more_corruption (fs, fixable);
+		    one_more_corruption (fs, FIXABLE);
 		}
 		fsck_log ("\n");
 		break;
@@ -619,7 +634,7 @@
     fix_sd = 0;
     fix_sd += wrong_st_blocks (key, &blocks, sd_blocks, mode, is_new_dir);
     fix_sd += wrong_st_size (key, is_new_dir ? MAX_FILE_SIZE_V2 : MAX_FILE_SIZE_V1,
-			     fs->fs_blocksize, &dir_size, sd_size, 1/*dir*/);
+			     fs->fs_blocksize, &dir_size, sd_size, TYPE_DIRENTRY);
 
     if (fix_sd) {
 	if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
@@ -627,7 +642,7 @@
 	    if (reiserfs_search_by_key_4 (fs, key, &path) != ITEM_FOUND) {
 		fsck_log ("check_semantic_tree: The StatData of the file %K was not found\n", 
 		    key);
-		one_more_corruption(fs, fatal);
+		one_more_corruption(fs, FATAL);
                 return STAT_DATA_NOT_FOUND;
 	    }
 	
@@ -692,7 +707,7 @@
 	    if (fsck_mode(fs) == FSCK_CHECK) {
 		fsck_log ("Invalid safe link %k: cannot find the pointed object (%K)\n", 
 		    &tmp_ih->ih_key, &key);
-		one_more_corruption (fs, fixable);
+		one_more_corruption (fs, FIXABLE);
 	    } else if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
 		fsck_log ("Invalid safe link %k: cannot find the pointed object (%K) - "
 		    "safe link was deleted\n", &tmp_ih->ih_key, &key);
@@ -709,7 +724,7 @@
 		if (fsck_mode(fs) == FSCK_CHECK) {
 		    fsck_log ("Invalid 'truncate' safe link %k, cannot happen for "
 			"directory (%K)\n", &tmp_ih->ih_key, &key);
-		    one_more_corruption (fs, fixable);
+		    one_more_corruption (fs, FIXABLE);
 		} else if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
 		    fsck_log ("Invalid 'truncate' safe link %k, cannot happen for "
 			"a directory (%K) - safe link was deleted\n", &tmp_ih->ih_key, &key);
@@ -725,7 +740,7 @@
 		if (reiserfs_bin_search (&key, trunc_links, links_num, sizeof(key), 
 		    &position, comp_short_keys) != POSITION_FOUND) 
 		{
-		    blocklist__insert_in_position(&key, (void **)&trunc_links, &links_num, 
+		    blocklist__insert_in_position(&key, (void *)&trunc_links, &links_num, 
 			sizeof(key), &position);
 		}		
 	    }
@@ -771,7 +786,7 @@
     
     if (check_semantic_pass (&root_dir_key, &parent_root_dir_key, 0, 0) != OK) {
         fsck_log ("check_semantic_tree: No root directory found");
-        one_more_corruption (fs, fatal);
+        one_more_corruption (fs, FATAL);
     }
 
     release_safe_links ();
diff --git a/fsck/semantic_rebuild.c b/fsck/semantic_rebuild.c
index a00ce19..e4250e3 100644
--- a/fsck/semantic_rebuild.c
+++ b/fsck/semantic_rebuild.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "fsck.h"
 
 int screen_width;
@@ -93,14 +95,14 @@
 
 
 /* *size is "real" file size, sd_size - size from stat data */
-int wrong_st_size (struct key * key, loff_t max_file_size, int blocksize,
-		   __u64 * size, __u64 sd_size, int is_dir)
+int wrong_st_size (struct key * key, unsigned long long max_file_size, 
+    int blocksize, __u64 * size, __u64 sd_size, int type)
 {
     if (sd_size <= max_file_size) {
 	if (sd_size == *size)
 	    return 0;
 
-	if (is_dir) {
+	if (type == TYPE_DIRENTRY) {
 	    /* directory size must match to the sum of length of its entries */
 	    fsck_log ("vpf-10650: The directory %K has the wrong size in the StatData "
 		"(%Ld)%s(%Ld)\n", key, sd_size, fsck_mode(fs) == FSCK_CHECK ? 
@@ -110,10 +112,11 @@
 	
 	if (sd_size > *size) {
 	    /* size in stat data can be bigger than size calculated by items */
-	    if (fsck_adjust_file_size (fs)) {
+	    if (fsck_adjust_file_size (fs) || type == TYPE_SYMLINK) {
 		/* but it -o is given - fix that */
-		fsck_log ("vpf-10660: The file %K has too big size in the StatData (%Ld) "
-		    "- corrected to (%Ld)\n", key, sd_size, *size);
+		fsck_log ("vpf-10660: The file %K has too big size in the StatData "
+		    "(%Ld)%s(%Ld)\n", key, sd_size, fsck_mode(fs) == FSCK_CHECK ? 
+		    ", should be " : " - corrected to ", *size);
 		sem_pass_stat (fs)->fixed_sizes ++;
 		return 1;
 	    }
@@ -142,7 +145,7 @@
 	}
     }
 
-    fsck_log ("vpf-10670: The file %K has wrong size in StatData (%Ld)%s(%Ld)\n", key, 
+    fsck_log ("vpf-10670: The file %K has the wrong size in the StatData (%Ld)%s(%Ld)\n", key, 
 	sd_size, fsck_mode(fs) == FSCK_CHECK ? ", should be " : " - corrected to ", 
 	*size);
     sem_pass_stat (fs)->fixed_sizes ++;
@@ -404,6 +407,7 @@
 	*new_ih = *ih;
 	pathrelse (path);
 	rewrite_file (new_ih, 1, 1);
+	linked_already(&new_ih->ih_key);
 	sem_pass_stat (fs)->oid_sharing_files_relocated ++;
 	retval = RELOCATED;
 	if (reiserfs_search_by_key_4 (fs, &(new_ih->ih_key), path) == ITEM_NOT_FOUND)
@@ -414,7 +418,10 @@
 	bh = get_bh (path);
 	mark_item_reachable (ih, bh);
 	sd = get_item (path);
+	
     }
+	
+    id_map_mark(semantic_id_map(fs), get_key_objectid (&ih->ih_key));
 
     /* check and set nlink first */
     get_sd_nlink (ih, sd, &nlink);
@@ -423,7 +430,7 @@
     mark_buffer_dirty (bh);
 
     if (nlink > 1)
-	return OK;
+	return retval;
 
     /* firts name of a file found */
     if (get_ih_item_len (ih) == SD_SIZE)
@@ -452,7 +459,9 @@
 //    sd_key = sd_ih.ih_key;
     pathrelse (path);
     
-    if (are_file_items_correct (&sd_ih, sd, &real_size, &blocks, 1/*mark items reachable*/, &symlnk) != 1) {
+    if (are_file_items_correct (&sd_ih, sd, &real_size, &blocks, 1/*mark items reachable*/, 
+	&symlnk) != 1) 
+    {
 	/* unpassed items will be deleted in pass 4 as they left unaccessed */
 	sem_pass_stat (fs)->broken_files ++;
     }
@@ -463,10 +472,11 @@
 
     if (!is_new_file)
 	fix_sd += wrong_first_direct_byte (&sd_ih.ih_key, fs->fs_blocksize,
-					   &first_direct_byte, saved_first_direct_byte, real_size);
+	    &first_direct_byte, saved_first_direct_byte, real_size);
 
-    fix_sd += wrong_st_size (/*&sd_key,*/ &sd_ih.ih_key, is_new_file ? MAX_FILE_SIZE_V2 : MAX_FILE_SIZE_V1,
-			     fs->fs_blocksize, &real_size, saved_size, 0/*not dir*/);
+    fix_sd += wrong_st_size (/*&sd_key,*/ &sd_ih.ih_key, 
+	is_new_file ? MAX_FILE_SIZE_V2 : MAX_FILE_SIZE_V1,
+	fs->fs_blocksize, &real_size, saved_size, symlnk ? TYPE_SYMLINK : 0);
 
     fix_sd += wrong_st_blocks (&sd_ih.ih_key, &blocks, saved_blocks, mode, is_new_file);
 
@@ -474,7 +484,8 @@
 	/* find stat data and correct it */
 	set_type_and_offset (KEY_FORMAT_1, &sd_ih.ih_key, SD_OFFSET, TYPE_STAT_DATA);
 	if (reiserfs_search_by_key_4 (fs, &sd_ih.ih_key, path) != ITEM_FOUND)
-	    reiserfs_panic ("%s: The StatData of the file %k could not be found", __FUNCTION__, &sd_ih.ih_key);
+	    reiserfs_panic ("%s: The StatData of the file %k could not be found", 
+		__FUNCTION__, &sd_ih.ih_key);
 	
 	bh = get_bh (path);
 	ih = get_ih (path);
@@ -517,7 +528,8 @@
 
 
     if ((retval = reiserfs_search_by_entry_key (fs, key, &path)) != POSITION_FOUND)
-	reiserfs_panic ("get_next_directory_item: The current directory %k cannot be found", key);
+	reiserfs_panic ("get_next_directory_item: The current directory %k cannot be "
+	    "found", key);
 
     /* leaf containing directory item */
     bh = PATH_PLAST_BUFFER (&path);
@@ -590,7 +602,7 @@
 	set_key_objectid (key, 0);
     }
 
-    if (fsck_mode (fs) != FSCK_CHECK && fsck_mode (fs) != FSCK_FIX_FIXABLE)
+    if (fsck_mode (fs) == FSCK_REBUILD)
         mark_item_reachable (get_ih (&path), bh);
     pathrelse (&path);
 
@@ -640,8 +652,8 @@
 	    mark_buffer_dirty (get_bh(path));
 	} else {
 	    fsck_log ("\n");
+	    retval = 1;
 	}
-	retval = 1;
     } else if (!not_a_directory (get_item (path)) && !is_direntry_key (next_key)) {
         /* make SD mode SD of regular file */
 	get_sd_mode (get_ih (path), get_item (path), &mode);
@@ -654,9 +666,9 @@
 	    mark_buffer_dirty (get_bh(path));
 	} else {
 	    fsck_log ("\n");
+	    retval = 1;
 	}
 	    
-	retval = 1;
     }
 
     return retval;
@@ -719,15 +731,14 @@
     relocate = 0;
     if (!nlink) {
 	/* we reached the stat data for the first time */
-	if (is_objectid_really_used (semantic_id_map (fs), get_key_objectid (&ih->ih_key), &pos_in_item)) {
+	if (id_map_mark(semantic_id_map(fs), get_key_objectid (&ih->ih_key))) {
 	    /* calculate number of found files/dirs who are using objectid
 	       which is used by another file */
 	    sem_pass_stat (fs)->oid_sharing ++;
 	    if (1/*fsck_adjust_file_size (fs)*/)
 		/* this works for files only */
 		relocate = 1;
-	} else
-	    __mark_objectid_really_used (semantic_id_map (fs), get_key_objectid (&ih->ih_key), pos_in_item);
+	} 
 
 	mark_item_reachable (ih, bh);
     }
@@ -742,13 +753,16 @@
 
     if (relocate) {
 	if (!new_ih)
-	    reiserfs_panic ("rebuild_semantic_pass: Memory is not prepared for relocation of %K", &ih->ih_key);
+	    reiserfs_panic ("rebuild_semantic_pass: Memory is not prepared for relocation of %K",
+		   &ih->ih_key);
 	*new_ih = *ih;
 	pathrelse (&path);
 	sem_pass_stat (fs)->oid_sharing_dirs_relocated ++;
 	relocate_dir (new_ih, 1);
-	*key = new_ih->ih_key;
+	linked_already(&new_ih->ih_key);
+	*key = new_ih->ih_key;	
 	retval = RELOCATED;
+	
 	goto start_again;
     }
 
@@ -859,7 +873,7 @@
 	
 	    if ((dir_format == KEY_FORMAT_2) && (entry_len % 8 != 0)) {
 	    	/* not alighed directory of new format - delete it */
-		fsck_log ("Entry %K (\"%.*s\") in the directory %K is not formated properly - deleted\n",
+		fsck_log ("Entry %K (\"%.*s\") in the directory %K is not formated properly - fixed.\n",
 			  (struct key *)&(deh->deh2_dir_id), namelen, name, &tmp_ih.ih_key);
 		reiserfs_remove_entry (fs, &entry_key);
 		entry_len = name_length (name, dir_format);
@@ -957,7 +971,7 @@
     fix_sd = 0;
     fix_sd += wrong_st_blocks (key, &blocks, saved_blocks, mode, is_new_dir);
     fix_sd += wrong_st_size (key, is_new_dir ? MAX_FILE_SIZE_V2 : MAX_FILE_SIZE_V1,
-			     fs->fs_blocksize, &dir_size, saved_size, 1/*dir*/);
+			     fs->fs_blocksize, &dir_size, saved_size, TYPE_DIRENTRY);
 
     if (fix_sd) {
 	/* we have to fix either sd_size or sd_blocks, so look for stat data again */
@@ -1042,7 +1056,7 @@
 {
     int retval;
     INITIALIZE_PATH (path);
-    int gen_counter;
+    unsigned int gen_counter;
     __u32 objectid;
     __u64 sd_size;
     __u32 sd_blocks;
@@ -1057,7 +1071,7 @@
 				  "lost+found", &gen_counter,
 				  &lost_found_dir_key);
     if (!retval) {
-	objectid = get_unused_objectid (fs);
+	objectid = id_map_alloc(proper_id_map(fs));
 	if (!objectid) {
 	    fsck_progress ("Could not allocate an objectid for \"/lost+found\", \
 		lost files will not be linked\n");
@@ -1133,10 +1147,11 @@
 	return;
 
     reiserfs_begin_stage_info_save (file, SEMANTIC_DONE);
+    /*  Method not implemented yet.
     reiserfs_objectid_map_save (file, semantic_id_map (fs));
+    */
     reiserfs_end_stage_info_save (file);
     close_file (file);
-    retval = unlink (state_dump_file (fs));
     retval = rename ("temp_fsck_file.deleteme", state_dump_file (fs));
     if (retval != 0)
 	fsck_progress ("%s: Could not rename the temporary file temp_fsck_file.deleteme to %s",
@@ -1158,14 +1173,16 @@
     fs->block_deallocator = reiserfsck_reiserfs_free_block;
 
     /* we need objectid map on semantic pass to be able to relocate files */
-    proper_id_map (fs) = init_id_map ();
+    proper_id_map (fs) = id_map_init();
+    /* Not implemented yet.    
     fetch_objectid_map (proper_id_map (fs), fs);
     semantic_id_map (fs) = reiserfs_objectid_map_load (file);
+    */
 }
 
 static void before_pass_3 (reiserfs_filsys_t * fs)
 {
-    semantic_id_map (fs) = init_id_map ();
+    semantic_id_map (fs) = id_map_init();
 }
 
 static void after_pass_3 (reiserfs_filsys_t * fs)
@@ -1176,7 +1193,7 @@
 
     /* write all dirty blocks */
     fsck_progress ("Flushing..");
-    flush_objectid_map (proper_id_map (fs), fs);
+    id_map_flush(proper_id_map (fs), fs);
     fs->fs_dirt = 1;
     reiserfs_flush_to_ondisk_bitmap (fsck_new_bitmap(fs), fs);
     reiserfs_flush (fs);
@@ -1192,7 +1209,7 @@
 
     save_rebuild_semantic_result (fs);
 
-    free_id_map (proper_id_map (fs));
+    id_map_free(proper_id_map (fs));
     proper_id_map (fs) = 0;
 
     fs->fs_dirt = 1;
@@ -1207,7 +1224,7 @@
 
     fsck_progress ("Pass 3 (semantic):\n");
 
-    /* when warnings go not to stderr - separate then in the log */
+    /* when warnings go not to stderr - separate them in the log */
     if (fsck_log_file (fs) != stderr)
 	fsck_log ("####### Pass 3 #########\n");
 
@@ -1218,8 +1235,8 @@
     make_sure_root_dir_exists (fs, modify_item, 1 << IH_Unreachable);
     make_sure_lost_found_exists (fs);
 
-    mark_objectid_really_used (proper_id_map (fs), get_key_objectid (&root_dir_key));
-    mark_objectid_really_used (proper_id_map (fs), get_key_objectid (&lost_found_dir_key));
+    id_map_mark(proper_id_map(fs), get_key_objectid(&root_dir_key));
+    id_map_mark(proper_id_map(fs), get_key_objectid(&lost_found_dir_key));
     
     /* link all relocated files into /lost+found directory */
     link_relocated_files ();
diff --git a/fsck/super.c b/fsck/super.c
index 4bb4f2e..dab146c 100644
--- a/fsck/super.c
+++ b/fsck/super.c
@@ -1,5 +1,11 @@
+/*
+ * Copyright 2001-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
+ */
+
 #include "fsck.h"
 #include <stdlib.h>
+#include <errno.h>
 
 #define fsck_conditional_log(sb_found, fmt, list...) {	\
     if (sb_found)					\
@@ -11,7 +17,7 @@
     size_t n = 0;
     char * answer = 0;
     int version;
-    printf("\nwhat is version of ReiserFS you use[1-4]\n"
+    printf("\nwhat the version of ReiserFS do you use[1-4]\n"
         "\t(1)   3.6.x\n"
         "\t(2) >=3.5.9 (introduced in the middle of 1999) (if you use linux 2.2, choose this one)\n"
         "\t(3) < 3.5.9 converted to new format (don't choose if unsure)\n"
@@ -24,12 +30,12 @@
     return version;
 }
 
+/*
 #define super_error(exit_code, text) {	\
     fsck_log(text);			\
     return exit_code;			\
 }
     
-/*
 int check_sb (reiserfs_filsys_t * fs) {
     int magic = 0, version = 0;
     
@@ -165,6 +171,7 @@
     int version = 0;
     struct reiserfs_super_block * ondisk_sb = 0;
     struct reiserfs_super_block * sb = 0;
+    struct reiserfs_journal_header *j_head;
 
     int magic_was_found = 0;
     unsigned long block_count = 0;
@@ -179,8 +186,8 @@
 
     char * answer = 0;
     size_t n = 0;
-    struct stat stat_buf;
-    int retval;
+    struct stat64 stat_buf;
+    int retval, exit_code = EXIT_OK;
 
     if (!no_reiserfs_found (fs)) {
         sb = getmem (sizeof (*sb));
@@ -195,9 +202,10 @@
 	    if (strcmp(answer, "\n")) {
 		retval = (int) strtol (answer, &tmp, 0);
 		if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
-		    reiserfs_exit (16, "rebuild_sb: wrong block size specified\n");
+		    reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified\n");
 		if (!is_blocksize_correct (retval))
-		    reiserfs_exit (16, "rebuild_sb: wrong block size specified, only divisible by 1024 are supported currently\n");
+		    reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified, "
+			"only power of 2 from 512-8192 interval are supported.\n");
 	    } else
 		retval = 4096;
 	
@@ -215,42 +223,57 @@
             /* 3_6 magic */
             if (fsck_data (fs)->journal_dev_name)
                 /* journal dev must not be specified with standard journal */
-                reiserfs_exit (16, "Reiserfs with standard journal found, but there was specified a journal dev");
+                reiserfs_exit (EXIT_USER, "ReiserFS with default journal "
+		    "is found, but there was specified a journal device.");
 
-            if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_new_start_must (fs))
+            if (fs->fs_super_bh->b_blocknr ==
+		REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                 version = 1;
-            else if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_old_start_must (fs))
+	    else if (fs->fs_super_bh->b_blocknr ==
+		REISERFS_OLD_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                 version = 3;
+	    
             magic_was_found = 2;
         } else if (is_reiserfs_3_5_magic_string (sb)) {
             if (fsck_data (fs)->journal_dev_name)
                 /* journal dev must not be specified with standard journal */
-                reiserfs_exit (16, "Reiserfs with standard journal found, but there was specified a journal dev");
+                reiserfs_exit (EXIT_USER, "ReiserFS with default journal "
+		    "is found, but there was specified a journal device.");
 
             /* 3_5 magic */
-            if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_new_start_must (fs))
+            if (fs->fs_super_bh->b_blocknr ==
+		REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                 version = 2;
-            else if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_old_start_must (fs))
+	    else if (fs->fs_super_bh->b_blocknr ==
+		REISERFS_OLD_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                 version = 4;
-            magic_was_found = 1;
+	    
+	    magic_was_found = 1;
         } else if (is_reiserfs_jr_magic_string (sb)) {
-            if (!fsck_data (fs)->journal_dev_name)
+            if (!fsck_data (fs)->journal_dev_name && !fsck_skip_journal(fs))
                 /* journal dev must be specified with non standard journal */
-                reiserfs_exit (16, "Reiserfs with non standard journal found, but there was not specified any journal dev");
+                reiserfs_exit (EXIT_USER, "ReiserFS with non default journal "
+		    "is found, but there was not specified any journal device.");
 
             if (get_sb_version (sb) == REISERFS_FORMAT_3_6) {
                 /*non-standard magic + sb_format == 3_6*/
-                if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_new_start_must (fs))
+		if (fs->fs_super_bh->b_blocknr ==
+		    REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                     version = 1;
-                else if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_old_start_must (fs))
+		else if (fs->fs_super_bh->b_blocknr == 
+		    REISERFS_OLD_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                     version = 3;
+		
                 magic_was_found = 3;
             } else if (get_sb_version (sb) == REISERFS_FORMAT_3_5) {
                 /* non-standard magic + sb_format == 3_5 */
-                if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_new_start_must (fs))
+                if (fs->fs_super_bh->b_blocknr ==
+		    REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                     version = 2;
-                else if (get_jp_journal_1st_block(sb_jp(sb)) == get_journal_old_start_must (fs))
+		else if (fs->fs_super_bh->b_blocknr ==
+		    REISERFS_OLD_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
                     version = 4;
+		
                 magic_was_found = 3;
             } else {
                 /* non-standard magic + bad sb_format */
@@ -258,7 +281,8 @@
                 magic_was_found = 3;
             }
         } else
-            reiserfs_exit (16, "we opened device but there is no magic and there is no correct superbblock format found");
+            reiserfs_exit (EXIT_USER, "We opened device but there is no magic "
+		"and there is no correct superblock format found.");
 
         if (magic_was_found == 1 || magic_was_found == 2)
             standard_journal = 1;
@@ -272,7 +296,10 @@
             do {
                 printf("\nDid you use resizer(y/n)[n]: ");
                 getline (&answer, &n, stdin);
-            } while (strcmp ("y\n", answer) && strcmp ("n\n", answer) && strcmp ("\n", answer));
+            } while(strcmp ("y\n", answer) && 
+		    strcmp ("n\n", answer) && 
+		    strcmp ("\n", answer));
+
             if (!strcmp ("y\n", answer)) {
                 printf("\nEnter partition size [%lu]: ", block_count);
                 getline (&answer, &n, stdin);
@@ -280,26 +307,31 @@
                     block_count = atoi (answer);
                 set_sb_block_count (sb, block_count);
             } else {
-                fsck_conditional_log (magic_was_found, "rebuild-sb: wrong block count occured (%lu), fixed (%lu)\n",
-                     get_sb_block_count(sb), block_count);
+                fsck_conditional_log (magic_was_found, "rebuild-sb: wrong block count "
+		    "occured (%lu), fixed (%lu)\n", get_sb_block_count(sb), block_count);
+
                 set_sb_block_count (sb, block_count);
             }
         }
 
         if (get_sb_block_size (sb) != fs->fs_blocksize) {
-            fsck_log("rebuild-sb: wrong block size occured (%lu), fixed (%lu)\n", get_sb_block_size (sb), fs->fs_blocksize);
+            fsck_log("rebuild-sb: wrong block size occured (%lu), fixed (%lu)\n", 
+		    get_sb_block_size (sb), fs->fs_blocksize);
   	    set_sb_block_size (sb, fs->fs_blocksize);
         }
     }
 
-    /* if no reiserfs_found or bad data found in that SB, what was checked in previous clause */
+    /* if no reiserfs_found or bad data found in that SB, what was checked in previous 
+     * clause */
     if (no_reiserfs_found (fs)) {
         int fd;
 
         fd = open (filename, O_RDWR | O_LARGEFILE);
 
-        if (fd == -1)
-            reiserfs_exit (8, "rebuils_sb: cannot open device %s", filename);
+        if (fd == -1) {
+            reiserfs_exit (EXIT_OPER, "rebuils_sb: cannot open device %s", 
+		filename);
+	}
 
         version = what_fs_version ();
 
@@ -311,9 +343,10 @@
 	    if (strcmp(answer, "\n")) {
 		retval = (int) strtol (answer, &tmp, 0);
 		if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
-		    reiserfs_exit (16, "rebuild_sb: wrong block size specified\n");
+		    reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified\n");
 		if (!is_blocksize_correct (retval))
-		    reiserfs_exit (16, "rebuild_sb: wrong block size specified, only divisible by 1024 are supported currently\n");
+		    reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified, "
+			"only divisible by 1024 are supported currently\n");
 	    } else
 		retval = 4096;
 	}
@@ -335,19 +368,27 @@
             break;
         }
 
+	if (fs == NULL)
+	    return;
+	
         sb = fs->fs_ondisk_sb;
         fs->fs_vp = data;
 
         if (!fsck_skip_journal (fs)) {
             if (!fsck_data (fs)->journal_dev_name) {
                 do {
-                    printf("\nNo journal device was specified. (If journal is not available, re-run with --no-journal-available).\n"\
-                            "Is journal standard? (y/n)[y]: ");
+                    printf("\nNo journal device was specified. (If journal is not "
+			"available, re-run with --no-journal-available option specified).\n"
+                        "Is journal default? (y/n)[y]: ");
+		    
                     getline (&answer, &n, stdin);
-                } while (strcmp ("y\n", answer) && strcmp ("n\n", answer) && strcmp ("\n", answer));
+                } while(strcmp ("y\n", answer) && 
+			strcmp ("n\n", answer) && 
+			strcmp ("\n", answer));
+		
                 if (!strcmp ("n\n", answer)) {
                     printf("\nSpecify journal device with -j option.\n");
-                    exit(16);
+                    exit(EXIT_USER);
                 }
                 standard_journal = 1;
             } else {
@@ -358,7 +399,7 @@
         }
 
         do {
-            printf("\nDid you use resiser(y/n)[n]: ");
+            printf("\nDid you use resizer(y/n)[n]: ");
             getline (&answer, &n, stdin);
         } while (strcmp ("y\n", answer) && strcmp ("n\n", answer) && strcmp ("\n", answer));
         if (!strcmp ("y\n", answer)) {
@@ -369,64 +410,83 @@
             set_sb_block_count (sb, block_count);
         }
 	
-	set_sb_fs_state (sb, REISERFS_CORRUPTED);
+	set_sb_fs_state (sb, FS_ERROR);
     }
 
 
     if (version == 1 || version == 3) {
         if (get_reiserfs_format (sb) != REISERFS_FORMAT_3_6) {
-            fsck_log("rebuild-sb: wrong reiserfs version occured (%lu), fixed (%lu)\n", get_reiserfs_format (sb), REISERFS_FORMAT_3_6);
+            fsck_log("rebuild-sb: wrong reiserfs version occured (%lu), fixed (%lu)\n", 
+		    get_reiserfs_format (sb), REISERFS_FORMAT_3_6);
             set_sb_version (sb, REISERFS_FORMAT_3_6);
         }
     } else if (version == 2 || version == 4) {
         if (get_reiserfs_format (sb) != REISERFS_FORMAT_3_5) {
-            fsck_log("rebuild-sb: wrong reiserfs version occured (%lu), fixed (%lu)\n", get_reiserfs_format (sb), REISERFS_FORMAT_3_5);
+            fsck_log("rebuild-sb: wrong reiserfs version occured (%lu), fixed (%lu)\n", 
+		    get_reiserfs_format (sb), REISERFS_FORMAT_3_5);
             set_sb_version (sb, REISERFS_FORMAT_3_5);
         }
     }
 
-    p_oid_maxsize = (fs->fs_blocksize - reiserfs_super_block_size (sb)) / sizeof(__u32) / 2 * 2;
+    p_oid_maxsize = (fs->fs_blocksize - reiserfs_super_block_size (sb)) / 
+	sizeof(__u32) / 2 * 2;
+    
     if (get_sb_oid_maxsize (sb) != p_oid_maxsize) {
-	fsck_log("rebuild-sb: wrong objectid map max size occured (%lu), fixed (%lu)\n", get_sb_oid_maxsize (sb), p_oid_maxsize);
+	fsck_log("rebuild-sb: wrong objectid map max size occured (%lu), fixed (%lu)\n", 
+		get_sb_oid_maxsize (sb), p_oid_maxsize);
 	set_sb_oid_maxsize (sb, p_oid_maxsize);
     }
 
     p_bmap_nr = (block_count + (fs->fs_blocksize * 8 - 1)) / (fs->fs_blocksize * 8);
     if (get_sb_bmap_nr (sb) != p_bmap_nr) {
-	fsck_log("rebuild-sb: wrong bitmap number occured (%lu), fixed (%lu)\n", get_sb_bmap_nr (sb), p_bmap_nr);
-	set_sb_bmap_nr (sb, (block_count + (fs->fs_blocksize * 8 - 1)) / (fs->fs_blocksize * 8));
+	fsck_log("rebuild-sb: wrong bitmap number occured (%lu), fixed (%lu)\n", 
+		get_sb_bmap_nr (sb), p_bmap_nr);
+	set_sb_bmap_nr (sb, 
+		(block_count + (fs->fs_blocksize * 8 - 1)) / (fs->fs_blocksize * 8));
     }
 
     if (get_sb_root_block (sb) > block_count) {
-	fsck_log("rebuild-sb: wrong root block occured (%lu), zeroed\n", get_sb_root_block (sb));
+	fsck_log("rebuild-sb: wrong root block occured (%lu), zeroed\n", 
+		get_sb_root_block (sb));
 	set_sb_root_block (sb, 0);
     }
 
     if (get_sb_free_blocks (sb) > block_count) {
-	fsck_log ("rebuild-sb: wrong free block count occured (%lu), zeroed\n", get_sb_free_blocks (sb));
+	fsck_log ("rebuild-sb: wrong free block count occured (%lu), zeroed\n", 
+		get_sb_free_blocks (sb));
         set_sb_free_blocks (sb, 0);
     }
 
-    if (get_sb_umount_state (sb) != REISERFS_CLEANLY_UMOUNTED && get_sb_umount_state (sb) != REISERFS_NOT_CLEANLY_UMOUNTED) {
-	fsck_conditional_log (magic_was_found, "rebuild-sb: wrong umount state, fixed to (REISERFS_NOT_CLEANLY_UMOUNTED)\n",
-                  get_sb_umount_state (sb));
-        set_sb_umount_state (sb, REISERFS_NOT_CLEANLY_UMOUNTED);
+    if (get_sb_umount_state (sb) != FS_CLEANLY_UMOUNTED && 
+	get_sb_umount_state (sb) != FS_NOT_CLEANLY_UMOUNTED) 
+    {
+	fsck_conditional_log (magic_was_found, "rebuild-sb: wrong umount state (%u), "
+	    "fixed to (FS_NOT_CLEANLY_UMOUNTED)\n", get_sb_umount_state (sb));
+        set_sb_umount_state (sb, FS_NOT_CLEANLY_UMOUNTED);
     }
 
-    if (get_sb_oid_cursize (sb) == 1 || get_sb_oid_cursize (sb) > get_sb_oid_maxsize (sb)) {
-        fsck_log("rebuild-sb: wrong objectid map occured (%lu), zeroed\n", get_sb_oid_cursize (sb));
+    if (get_sb_oid_cursize (sb) == 1 || 
+	get_sb_oid_cursize (sb) > get_sb_oid_maxsize (sb)) 
+    {
+        fsck_log("rebuild-sb: wrong objectid map occured (%lu), zeroed\n", 
+	    get_sb_oid_cursize (sb));
+	
         set_sb_oid_cursize (sb, 0);
     }
 
     if ( get_sb_tree_height (sb) &&
         ((get_sb_tree_height (sb) < DISK_LEAF_NODE_LEVEL + 1) ||
 	(get_sb_tree_height (sb) > MAX_HEIGHT)) ) {
-	fsck_log("rebuild-sb: wrong tree height occured, zeroed\n", get_sb_tree_height (sb));
+	fsck_log("rebuild-sb: wrong tree height occured (%u), zeroed\n", 
+	    get_sb_tree_height (sb));
+
 	set_sb_tree_height (sb, 0);
     }
 
     if (get_sb_hash_code (sb) && code2name (get_sb_hash_code (sb)) == 0) {
-	fsck_log("rebuild-sb: wrong hash occured (%lu), zeroed\n", get_sb_hash_code (sb));
+	fsck_log("rebuild-sb: wrong hash occured (%lu), zeroed\n", 
+	    get_sb_hash_code (sb));
+	
 	set_sb_hash_code (sb, 0);
     }
 
@@ -435,7 +495,8 @@
 	    if (generate_random_uuid (sb->s_uuid)) {
 		fsck_log ("rebuild-sb: no uuid found, failed to genetate UUID\n");
 	    } else {
-		fsck_log ("rebuild-sb: no uuid found, a new uuid generated (%U)\n", sb->s_uuid);
+		fsck_log ("rebuild-sb: no uuid found, a new uuid generated (%U)\n", 
+		    sb->s_uuid);
 	    }
         }
 	if (sb->s_flags != 0 && sb->s_flags != 1) {
@@ -465,112 +526,87 @@
 
     p_jp_journal_1st_block = get_journal_start_must (fs);
 
-    if (!fsck_skip_journal (fs) && standard_journal == 1) {
-        if (get_jp_journal_dev (sb_jp(sb)) != 0) {
- 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal device occured (%lu), fixed (0)\n",
- 	                get_jp_journal_dev (sb_jp(sb)));
+    if (standard_journal == 1) {
+	if (get_jp_journal_dev (sb_jp(sb)) != 0) {
+ 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal device "
+		"occured (%lu), fixed (0)\n", get_jp_journal_dev (sb_jp(sb)));
  	    set_jp_journal_dev (sb_jp(sb), 0);
         }
         if (get_sb_reserved_for_journal (sb) != 0) {
- 	    fsck_log ("rebuild-sb: wrong size reserved for standard journal occured (%lu), fixed (0)\n",
- 	                get_sb_reserved_for_journal (sb));
+ 	    fsck_log ("rebuild-sb: wrong size reserved for default journal occured "
+		"(%lu), fixed (0)\n", get_sb_reserved_for_journal (sb));
             set_sb_reserved_for_journal (sb, 0);
         }
         if (get_jp_journal_1st_block (sb_jp(sb)) != p_jp_journal_1st_block) {
-            fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal first block occured (%lu), fixed (%lu)\n",
-                get_jp_journal_1st_block (sb_jp(sb)), p_jp_journal_1st_block);
+            fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal first "
+		"block occured (%lu), fixed (%lu)\n", get_jp_journal_1st_block (sb_jp(sb)),
+		p_jp_journal_1st_block);
+	    
             set_jp_journal_1st_block (sb_jp(sb) , p_jp_journal_1st_block);
         }
-        if (get_jp_journal_size (sb_jp(sb)) != journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize)) {
- 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal size occured (%lu), fixed (%lu)\n",
- 	                get_jp_journal_size (sb_jp(sb)) + 1,
- 	                journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1);
-            set_jp_journal_size (sb_jp(sb), journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
-        }
-        if (get_jp_journal_max_trans_len (sb_jp(sb)) !=
-	    advise_journal_max_trans_len(	get_jp_journal_max_trans_len (sb_jp(sb)),
-	    					get_jp_journal_size (sb_jp(sb)),
-	    					fs->fs_blocksize))
+        if (get_jp_journal_size (sb_jp(sb)) != 
+	    journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize)) 
 	{
- 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal max transaction length occured (%lu), fixed (%d)\n",
- 	        get_jp_journal_max_trans_len (sb_jp(sb)),
-        	advise_journal_max_trans_len (	get_jp_journal_max_trans_len (sb_jp(sb)),
-        					get_jp_journal_size (sb_jp(sb)),
-        					fs->fs_blocksize));
- 	    set_jp_journal_max_trans_len (sb_jp(sb),
- 	    	advise_journal_max_trans_len(	get_jp_journal_max_trans_len (sb_jp(sb)),
- 	    					get_jp_journal_size (sb_jp(sb)),
- 	    					fs->fs_blocksize));
-        }
-/*        if (get_jp_journal_magic (sb_jp(sb)) != 0) {
- 	    fsck_log ("rebuild-sb: wrong journal magic occured (%lu), fixed (0)\n", get_jp_journal_magic (sb_jp(sb)));
- 	    set_jp_journal_magic (sb_jp(sb), 0);
-        }*/
-        if (get_jp_journal_max_batch (sb_jp(sb)) != advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb)))) {
- 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal max batch size occured (%lu), fixed (%d)\n",
- 	        get_jp_journal_max_batch (sb_jp(sb)), advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb))));
- 	    set_jp_journal_max_batch (sb_jp(sb), advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb))));
-        }
-        if (get_jp_journal_max_commit_age (sb_jp(sb)) != advise_journal_max_commit_age()) {
- 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal  max commit age occured (%lu), fixed (%d)\n",
- 	        get_jp_journal_max_commit_age (sb_jp(sb)), advise_journal_max_commit_age());
- 	    set_jp_journal_max_commit_age (sb_jp(sb), advise_journal_max_commit_age());
-        }
-        if (get_jp_journal_max_trans_age (sb_jp(sb)) != advise_journal_max_trans_age()) {
- 	    fsck_log ("rebuild-sb: wrong journal  max commit age occured (%lu), fixed (0)\n",
- 	        get_jp_journal_max_trans_age (sb_jp(sb)), advise_journal_max_trans_age());
- 	    set_jp_journal_max_trans_age (sb_jp(sb), advise_journal_max_trans_age());
+ 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal size "
+		"occured (%lu), fixed (%lu)\n", get_jp_journal_size (sb_jp(sb)) + 1,
+ 	        journal_default_size (fs->fs_super_bh->b_blocknr, 
+		fs->fs_blocksize) + 1);
+	    
+            set_jp_journal_size (sb_jp(sb), 
+		journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
         }
 
+	if ((retval = reiserfs_open_journal(fs, filename, O_RDWR | O_LARGEFILE))) {
+	    fsck_log("\nrebuild-sb: Failed to open the journal device (%s).", 
+		filename);
 
+	    exit(retval == 1 ? EXIT_USER : EXIT_OPER);
+	}	
+    } else if (!fsck_skip_journal(fs)) {
+	/* Check that specified non-standard journal device exists. */
+	    
+	journal_dev_name = fsck_data (fs)->journal_dev_name;	    
+	retval = stat64(journal_dev_name, &stat_buf);
+	    
+	if (retval == -1)
+	    reiserfs_exit (EXIT_USER, "rebuild_sb: error while detecting the "
+		"specified journal device (%s): %s\n", journal_dev_name,
+		strerror(errno));
+	
+	retval = 0;
+	if (magic_was_found) {
+	    /* Super block was found. Try to open the journal on the base of its 
+	     * journal parameters. */
+	    
+	    retval = reiserfs_open_journal(fs, journal_dev_name, 
+		O_RDWR | O_LARGEFILE);
+	    
+	    if (retval == 0) {
+		j_head = (struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data);
+		retval = memcmp(&j_head->jh_journal, sb_jp(sb), 
+		    sizeof(struct journal_params));
+	    
+		if (retval) {
+		    /* journal parameters from the SB and from the J_Header does not 
+		     * match. Close the jouranl, ask the user about correct journal 
+		     * parameters. */
+		    reiserfs_close_journal(fs);
+		}
+	    }
 
-    } else if (!fsck_skip_journal(fs) && standard_journal == 0) {
-        /* non standard journal */
-        struct reiserfs_journal_header * jh;
+	    if (!reiserfs_journal_opened(fs)) {
+		fsck_log ("Journal cannot be opened, assuming specified journal device "
+			"is correct\n");
+	    }
+	}
+	
+	if (!reiserfs_journal_opened(fs)) {
+	    __u64 default_value;
 
-        journal_dev_name = fsck_data (fs)->journal_dev_name;
-        retval = stat(journal_dev_name, &stat_buf);
-        if (retval == -1)
-            reiserfs_exit (16, "rebuild_sb: wrong journal device specified\n");
-        if (strcmp (fs->fs_file_name, journal_dev_name))
-            set_jp_journal_dev (sb_jp(sb), stat_buf.st_rdev);
-        else
-            set_jp_journal_dev (sb_jp(sb), 0);
-
-/*
-        if (journal_dev_name == 0) {
-            // ask user about the dev
-            printf("\nEnter dev with journal[%s]: \n", fs->fs_file_name);
-            getline (&answer, &n, stdin);
-            if (strcmp(answer, "\n")) {
-		journal_dev_name = malloc (strlen(answer));
-                strncpy(journal_dev_name, answer, strlen(answer) - 1);
-                retval = stat(journal_dev_name, &stat_buf);
-                if (retval == -1)
-                    die ("rebuild_sb: wrong device specified\n");
-                if (strcmp (fs->fs_file_name, journal_dev_name))
-                    set_jp_journal_dev (sb_jp(sb), stat_buf.st_rdev);
-                else
-                    set_jp_journal_dev (sb_jp(sb), 0);
-            } else {
-                    set_jp_journal_dev (sb_jp(sb), 0);
-		    journal_dev_name = fs->fs_file_name;
-            }
-        }
-*/
-        retval = -1;
-        if (magic_was_found == 0 || (retval = reiserfs_open_journal (fs, journal_dev_name, O_RDONLY)) == 0) {
-            __u64 default_value;
-            /* journal header was not found or journal cannot be opened -> adjust journal size and offset */
-
-            /* default offset if magic was not found is 0 for relocated journal and get_journal_start_must
-               for any journal on the same device;
-               default offset if magic was found is found value */
-            if (retval == 0)
-                fsck_log ("Journal cannot be opened, assuming specified journal device is correct\n");
-
-            if (magic_was_found == 0)
-                default_value = (!strcmp(fs->fs_file_name, journal_dev_name)) ? p_jp_journal_1st_block : 0;
+	    /* journal was not found or SB and J_Header parameters does not match. */
+	    if (magic_was_found == 0)
+                default_value = (!strcmp(fs->fs_file_name, journal_dev_name)) ? 
+		    p_jp_journal_1st_block : 0;
             else
                 default_value = get_jp_journal_1st_block (sb_jp(sb));
 
@@ -581,7 +617,8 @@
             if (strcmp(answer, "\n")) {
                 retval = (int) strtol (answer, &tmp, 0);
                 if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
-                    reiserfs_exit(16, "rebuild_sb: wrong offset specified\n");
+                    reiserfs_exit(EXIT_USER, "rebuild_sb: wrong offset specified\n");
+
                 set_jp_journal_1st_block (sb_jp(sb), retval);
             } else
                 set_jp_journal_1st_block (sb_jp(sb), default_value);
@@ -590,27 +627,31 @@
             /* some checks for journal offset */
             if (strcmp(fs->fs_file_name, journal_dev_name) != 0) {
                 if (p_jp_dev_size < get_jp_journal_1st_block (sb_jp(sb)) + 1)
-        	    reiserfs_exit(16, "rebuild_sb: offset is much then device size\n");
+        	    reiserfs_exit(EXIT_USER, "rebuild_sb: offset is much than device size\n");
             }
 
             /* default size if magic was not found is device size - journal_1st_block;
-               default size if magic was found is found value + 1 block for journal header */
+               default size if magic was found is found value + 1 block for journal 
+	       header */
             if (magic_was_found == 0)
                 default_value = (!strcmp(fs->fs_file_name, journal_dev_name)) ?
-                                journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1 :
-                                p_jp_dev_size - get_jp_journal_1st_block (sb_jp(sb));
+                    journal_default_size (fs->fs_super_bh->b_blocknr,
+					  fs->fs_blocksize) + 1 :
+                    p_jp_dev_size - get_jp_journal_1st_block (sb_jp(sb));
             else
                 default_value = get_jp_journal_size (sb_jp(sb)) + 1;
 		
 
-            printf("\nEnter journal size (including 1 block for journal header) on %s in blocks [%Lu]: \n",
-                        journal_dev_name, (unsigned long long)default_value);
+            printf("\nEnter journal size (including 1 block for journal header) on "
+		"%s in blocks [%Lu]: \n", journal_dev_name, 
+		(unsigned long long)default_value);
 
             getline (&answer, &n, stdin);
             if (strcmp(answer, "\n")) {
                 retval = (int) strtol (answer, &tmp, 0);
                 if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
-        	    reiserfs_exit(16, "rebuild_sb: wrong offset specified\n");
+        	    reiserfs_exit(EXIT_USER, "rebuild_sb: wrong offset specified\n");
+
                 set_jp_journal_size (sb_jp(sb), retval - 1);
             } else {
                 set_jp_journal_size (sb_jp(sb), default_value - 1);
@@ -619,26 +660,143 @@
             /* some checks for journal size */
             if (get_jp_journal_size (sb_jp(sb)) +
                 get_jp_journal_1st_block (sb_jp(sb)) + 1 > p_jp_dev_size)
-        	    reiserfs_exit(16, "rebuild_sb: journal offset + journal size is much then device size\n");
+        	    reiserfs_exit(EXIT_USER, "rebuild_sb: journal offset + journal size is "
+			"greater than device size\n");
+            
+	    /* some checks for journal size */
+            if (get_jp_journal_size (sb_jp(sb)) < JOURNAL_MIN_SIZE)
+        	    reiserfs_exit(EXIT_USER, "rebuild_sb: journal size cannot be less than "
+			"%lu blocks.\n", JOURNAL_MIN_SIZE + 1);
 
-            if (reiserfs_open_journal (fs, journal_dev_name, O_RDONLY) == 0)
-                reiserfs_exit(16, "rebuild-sb: journal header is not found, wrong dev/offset/size configuration\n");
-        }
+	    if ((retval = reiserfs_open_journal(fs, journal_dev_name, 
+		O_RDWR | O_LARGEFILE)))
+	    {
+		fsck_log("\nrebuild-sb: Failed to open a journal device (%s).", 
+		    journal_dev_name);
+		
+		exit(retval == 1 ? EXIT_USER : EXIT_OPER);
+	    }
+	
+	    /* SB was found, but journal params were broken and have been recovered. 
+	     * Futher work goes as SB would not be found. */
+	    magic_was_found = 0;
+	}
+	
+	if (strcmp (fs->fs_file_name, journal_dev_name))
+	    set_jp_journal_dev (sb_jp(sb), stat_buf.st_rdev);
+	else
+	    set_jp_journal_dev (sb_jp(sb), 0);
 
-	jh = (struct reiserfs_journal_header *)fs->fs_jh_bh->b_data;
-        memcpy (sb_jp(sb), &jh->jh_journal, sizeof (struct journal_params));
     } else {
-        fsck_log ("Journal was specified as not available, zeroing all journal fields in super block..");
-        set_jp_journal_dev (sb_jp(sb), 0);
-        set_sb_reserved_for_journal (sb, 0);
-        set_jp_journal_1st_block (sb_jp(sb) , 0);
-        set_jp_journal_size (sb_jp(sb), 0);
-        set_jp_journal_max_trans_len (sb_jp(sb), 0);
-        set_jp_journal_max_batch (sb_jp(sb), 0);
-        set_jp_journal_max_commit_age (sb_jp(sb), 0);
-        set_jp_journal_max_commit_age (sb_jp(sb), 0);
+	fsck_log ("\nJournal was specified as not available. reiserfstune is "
+	    "needed.\n\n");
+	
+	set_jp_journal_magic (sb_jp(sb), NEED_TUNE);
     }
 
+    if (reiserfs_journal_opened(fs)) {
+	/* Journal was openned. Check/fix journal parameters and copy it the journal 
+	 * header. */
+	
+        if (get_jp_journal_max_trans_len (sb_jp(sb)) !=
+	    advise_journal_max_trans_len(   get_jp_journal_max_trans_len (sb_jp(sb)),
+					    get_jp_journal_size (sb_jp(sb)), 
+					    fs->fs_blocksize, 0))
+	{
+ 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal max "
+		"transaction length occured (%lu), fixed (%d)\n",
+		get_jp_journal_max_trans_len (sb_jp(sb)),
+		advise_journal_max_trans_len (	get_jp_journal_max_trans_len (sb_jp(sb)),
+        					get_jp_journal_size (sb_jp(sb)),
+        					fs->fs_blocksize, 0));
+	    
+ 	    set_jp_journal_max_trans_len (sb_jp(sb),
+ 	    	advise_journal_max_trans_len (	get_jp_journal_max_trans_len (sb_jp(sb)),
+						get_jp_journal_size (sb_jp(sb)),
+ 	    					fs->fs_blocksize, 0));
+        }
+	
+        if (get_jp_journal_max_batch (sb_jp(sb)) != 
+	    advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb)))) 
+	{
+ 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal max "
+		"batch size occured (%lu), fixed (%d)\n", 
+		get_jp_journal_max_batch (sb_jp(sb)), 
+		advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb))));
+	    
+ 	    set_jp_journal_max_batch (sb_jp(sb), 
+		advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb))));
+        }
+
+        if (get_jp_journal_max_commit_age (sb_jp(sb)) != 
+	    advise_journal_max_commit_age()) 
+	{
+ 	    fsck_conditional_log (magic_was_found, "rebuild-sb: wrong journal "
+		"max commit age occured (%lu), fixed (%d)\n", 
+ 	        get_jp_journal_max_commit_age (sb_jp(sb)), advise_journal_max_commit_age());
+	    
+ 	    set_jp_journal_max_commit_age (sb_jp(sb), advise_journal_max_commit_age());
+        }
+	
+        if (get_jp_journal_max_trans_age (sb_jp(sb)) != advise_journal_max_trans_age()) {
+ 	    fsck_log ("rebuild-sb: wrong journal  max commit age occured (%u), "
+		"fixed (%u)\n", get_jp_journal_max_trans_age (sb_jp(sb)), 
+		advise_journal_max_trans_age());
+	    
+ 	    set_jp_journal_max_trans_age (sb_jp(sb), advise_journal_max_trans_age());
+        }
+		
+	j_head = (struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data);
+
+	if (standard_journal == 0) {
+	    if (get_jp_journal_magic (sb_jp(sb)) == 0 || 
+		get_jp_journal_magic (sb_jp(sb)) == NEED_TUNE) 
+	    {
+		int magic;
+		
+		magic = random();
+		fsck_log ("rebuild-sb: genarate the new journal magic (%d)\n", magic);
+		set_jp_journal_magic (sb_jp(sb), magic);
+		set_jp_journal_magic (&j_head->jh_journal, magic);
+
+	    }
+	} else {
+	    set_jp_journal_magic (sb_jp(sb), 0);	    
+	}
+	
+	retval = memcmp(&j_head->jh_journal, sb_jp(sb), sizeof(struct journal_params));
+	
+	if (retval) {
+	    if (standard_journal == 1) {
+		fsck_log("\nrebuild-sb: You either have a corrupted journal or have just "
+		    "changed\nthe start of the partition with some partition table editor. "
+		    "If you are\nsure that the start of the partition is ok, rebuild the "
+		    "journal header.\n");
+	    } else if (!magic_was_found) {
+		fsck_log("\nrebuild-sb: journal header is not found. You either have "
+		    "a corrupted,\nbad configured(device/offset/size), not available "
+		    "journal or have just changed\nthe start of the journal partition "
+		    "with some partition table editor. In the \ncase of corrupted "
+		    "journal you need to use --no-journal-available. If you are\n"
+		    "sure that the start of the partition is ok and journal is "
+		    "available, rebuild\nthe journal header.\n");
+	    }
+	    
+	    if (standard_journal || !magic_was_found) {
+		if (!user_confirmed (stdout, "Do you want to rebuild the journal header? "
+		    "(y/n)[n]: ", "y\n"))
+		{
+		    exit(EXIT_USER);
+		} else 
+		    exit_code = EXIT_FIXED;
+	    }
+	    
+	    memcpy(&j_head->jh_journal, sb_jp(sb), sizeof(struct journal_params));
+	    mark_buffer_dirty(fs->fs_jh_bh);
+	    bwrite (fs->fs_jh_bh);
+	}
+    }
+    
     /*  whether journal header contains params with the same dev, offset, size will be 
 	checked in open_journal */
 
@@ -647,11 +805,12 @@
     else
         sb_size = SB_SIZE_V1;
 
-    if (!magic_was_found || memcmp(ondisk_sb, sb, sb_size - 
-		((sb_size == SB_SIZE) ? sizeof(fs->fs_ondisk_sb->s_unused) : 0)) ) 
+    if (ondisk_sb == NULL || 
+	memcmp(ondisk_sb, sb, sb_size - ((sb_size == SB_SIZE) ? 
+	    sizeof(fs->fs_ondisk_sb->s_unused) : 0))) 
     {
         /* smth was changed in SB or a new one has been built */
-	set_sb_fs_state (sb, get_sb_fs_state (sb) || REISERFS_CORRUPTED);
+	set_sb_fs_state (sb, get_sb_fs_state (sb) | FS_ERROR);
 	
 	if (ondisk_sb) {
 	    /* if super_block was found, we keep sb in ondisk_sb */
@@ -660,13 +819,15 @@
 	    freemem(sb);
 	}
 
+	fflush(stdout); 
 	print_block (stderr, fs, fs->fs_super_bh);
 	
 	if (user_confirmed (stderr, "Is this ok ? (y/n)[n]: ", "y\n")) {
 	    mark_buffer_uptodate (fs->fs_super_bh, 1);
 	    mark_buffer_dirty (fs->fs_super_bh);
 	    bwrite (fs->fs_super_bh);
-	    fsck_progress ("\nDo not forget to run reiserfsck --rebuild-tree\n\n");
+	    fsck_progress ("The fs may still be unconsistent. Run reiserfsck --check.\n\n");
+	    exit_code = EXIT_FIXED;
 	} else {
 	    mark_buffer_clean (fs->fs_super_bh);
 	    fsck_progress ("Super block was not written\n");
@@ -677,6 +838,8 @@
 	mark_buffer_clean (fs->fs_super_bh);
 	fsck_progress ("\nSuper block seems to be correct\n\n");
     }
+
+    exit(exit_code);
 }
 
 /*	if (version == 0) {
diff --git a/fsck/ubitmap.c b/fsck/ubitmap.c
index 1e43901..9348e89 100644
--- a/fsck/ubitmap.c
+++ b/fsck/ubitmap.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "fsck.h"
diff --git a/fsck/ufile.c b/fsck/ufile.c
index a8abf83..063eef3 100644
--- a/fsck/ufile.c
+++ b/fsck/ufile.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "fsck.h"
 
 static int do_items_have_the_same_type (struct item_head * ih, struct key * key)
@@ -46,8 +48,9 @@
     }
     set_key_dirid (&ins_ih.ih_key, get_key_dirid (&ih->ih_key));
     set_key_objectid (&ins_ih.ih_key, get_key_objectid (&ih->ih_key));
-    set_type_and_offset (get_ih_key_format (ih), &ins_ih.ih_key,
-			 get_offset (&ih->ih_key) + (I_UNFM_NUM (ih) - 1) * bh->b_size, TYPE_DIRECT);
+    set_type_and_offset (get_ih_key_format (&ins_ih), &ins_ih.ih_key,
+			 get_offset (&ih->ih_key) + (I_UNFM_NUM (ih) - 1) * bh->b_size, 
+			 TYPE_DIRECT);
 
     // we do not know what length this item should be
     indirect = get_item (path);
@@ -96,24 +99,6 @@
     return get_offset (&ins_ih.ih_key); //offset;
 }
 
-/*
-static __u64 get_min_bytes_number (struct item_head * ih, int blocksize)
-{
-    switch (get_type (&ih->ih_key)) {
-    case TYPE_DIRECT:
-	if (fs->fs_format == REISERFS_FORMAT_3_6)
-	    return ROUND_UP(get_ih_item_len (ih) - 8);
-        else
-	    return get_ih_item_len (ih);
-
-    case TYPE_INDIRECT:
-	return (I_UNFM_NUM(ih) - 1) * blocksize;
-    }
-    fsck_log ("get_min_bytes_number: called for wrong type of item %H\n", ih);
-    return 0;
-}
-*/
-
 /*  start_key is the key after which N items need to be deleted
     save_here is a pointer where deleted items need to be saved if save is set.
     start_key is the first undeleted item.
@@ -194,7 +179,8 @@
     struct key * next_key, * key;
     __u32 sd_first_direct_byte = 0;
     __u64 sd_size;
-    int retval, i, was_tail = 0;
+    unsigned int i;
+    int retval, was_tail = 0;
     int had_direct = 0;
     int key_version = get_ih_key_format (sd_ih);
     int next_is_another_object = 0;
@@ -245,7 +231,7 @@
 		(!is_indirect_key (next_key) && !is_direct_key(next_key))) 
 	    {
 		next_is_another_object = 1;
-		will_convert = (is_indirect_ih (ih) && sd_size && I_UNFM_NUM (ih) > 0);
+		will_convert = (is_indirect_ih (ih) && sd_size && (I_UNFM_NUM (ih) > 0));
 		if (will_convert) {
 		    last_unfm_offset = get_offset (key) + fs->fs_blocksize * (I_UNFM_NUM (ih) - 1);
 		    /* if symlink or
@@ -269,18 +255,41 @@
 			fsck_log("are_file_items_correct: vpf-10250: block %lu, item (%d): The item format (%H)"\
 			    " is not equal to SD format (%d)\n",
 			    get_bh(&path)->b_blocknr, PATH_LAST_POSITION(&path), ih, key_version);
-			one_more_corruption (fs, fixable);
+			one_more_corruption (fs, FIXABLE);
 		    } else {
 			fsck_log("are_file_items_correct: vpf-10280: block %lu, item (%d): The item format (%H)"\
-			    " is not equal to SD format (%d) - item was deleted\n",
+			    " is not equal to SD format (%d) - fixed.\n",
 			    get_bh(&path)->b_blocknr, PATH_LAST_POSITION(&path), ih, key_version);
 		
-			pathrelse (&path);
-			delete_N_items_after_key (key, NULL, 0 /* do not skip dir items */, 0);
-			return 1;
+
+			set_type_and_offset (key_version, &ih->ih_key, get_offset (&ih->ih_key), get_type (&ih->ih_key));
+			set_ih_key_format(ih, key_version);
+			mark_buffer_dirty(get_bh(&path));
 		    }
 		}
 
+		if (*symlink && is_direct_key(&ih->ih_key)) {
+		    /* symlink. Check that it is of KEY_FORMAT_1 */
+		    if (fsck_mode(fs) == FSCK_CHECK) {
+			if ((get_ih_key_format(ih) != KEY_FORMAT_1) || (key_format(&ih->ih_key) != KEY_FORMAT_1)) {
+			    fsck_log("are_file_items_correct: vpf-10732: block %lu, item (%d): The symlink format (%H)"\
+				" is not equal to 3.5 format (%d)\n", get_bh(&path)->b_blocknr, PATH_LAST_POSITION(&path), 
+				ih, KEY_FORMAT_1);
+			    one_more_corruption (fs, FIXABLE);
+			}
+		    } else {
+			if ((get_ih_key_format(ih) != KEY_FORMAT_1) || (key_format(&ih->ih_key) != KEY_FORMAT_1)) {
+			    fsck_log("are_file_items_correct: vpf-10732: block %lu, item (%d): The symlink format (%H)"\
+				" is not equal to 3.5 format (%d)\n", get_bh(&path)->b_blocknr, PATH_LAST_POSITION(&path), 
+				ih, KEY_FORMAT_1);
+			    set_type_and_offset(KEY_FORMAT_1, &ih->ih_key, get_offset(&ih->ih_key), get_type(&ih->ih_key));
+			    set_ih_key_format(ih, KEY_FORMAT_1);
+			    mark_buffer_dirty(get_bh(&path));
+			}
+			
+		    }
+		}
+		
 		if (will_convert)
 		    *size = sd_size;
 		else
@@ -316,7 +325,7 @@
 			/* here it can be symlink only */
 			fsck_log ("are_file_items_correct: The indirect item should be converted back"
 			    " to direct %K\n", &ih->ih_key);
-			one_more_corruption (fs, fixable);
+			one_more_corruption (fs, FIXABLE);
 			pathrelse (&path);
 		    } else {
 			__u32 * ind = (__u32 *)get_item(&path);
@@ -325,6 +334,8 @@
 			*/
 			if (ind [I_UNFM_NUM (ih) - 1] == 0)
 			    *blocks += (fs->fs_blocksize >> 9);
+
+			/* path is released here. */
 			sd_first_direct_byte = indirect_to_direct (&path, sd_size - last_unfm_offset + 1, *symlink);
 			/* last item of the file is direct item */
 			set_offset (key_version, key, sd_first_direct_byte);
@@ -359,7 +370,7 @@
 		    fsck_log ("are_file_items_correct: "
 			      "item must be indirect and must have invalid free space (%H)", ih);
 	
-                if (fsck_mode (fs) != FSCK_CHECK && fsck_mode (fs) != FSCK_FIX_FIXABLE)
+                if (fsck_mode (fs) == FSCK_REBUILD)
                 {		
                     set_ih_free_space(ih, 0);
                     mark_buffer_dirty (PATH_PLAST_BUFFER (&path));
@@ -511,16 +522,17 @@
 
 /* this inserts __first__ indirect item (having k_offset == 1 and only
    one unfm pointer) into tree */
-int create_first_item_of_file (struct item_head * ih, char * item, struct path * path, int was_in_tree)
+static int create_first_item_of_file (struct item_head * ih, char * item, struct path * path, int was_in_tree)
 {
     __u32 unfm_ptr;
     __u32 * ni = 0;
     struct buffer_head * unbh;
     struct item_head indih;
-    int retval, i;
-    __u32 free_sp = 0;
+    unsigned int i;
+    int retval;
 
     mark_item_unreachable (&indih);
+
     copy_key (&(indih.ih_key), &(ih->ih_key));
     set_ih_item_len (&indih, UNFM_P_SIZE);
 
@@ -528,29 +540,21 @@
 	/* insert indirect item containing 0 unfm pointer */
 	unfm_ptr = 0;
 	set_ih_free_space (&indih, 0);
-	free_sp = 0;
 	retval = 0;
     } else {
 	if (is_direct_ih (ih)) {
 	    /* copy direct item to new unformatted node. Save information about it */
-	    //__u64 len = get_bytes_number(0, ih, item, CHECK_FREE_BYTES);
-	    __u64 len = get_bytes_number (ih, fs->fs_blocksize);
+	    int len = get_bytes_number (ih, fs->fs_blocksize);
 
 	    unbh = reiserfsck_get_new_buffer (PATH_PLAST_BUFFER (path)->b_blocknr);
 	    memset (unbh->b_data, 0, unbh->b_size);
 	    unfm_ptr = cpu_to_le32 (unbh->b_blocknr);
-/* this is for check only */
-	    /*mark_block_unformatted (le32_to_cpu (unfm_ptr));*/
 	    memcpy (unbh->b_data + get_offset (&ih->ih_key) - 1, item, len);
 
-//	    save_unfm_overwriting (le32_to_cpu (unfm_ptr), ih);
-
 	    set_ih_free_space (&indih, fs->fs_blocksize - len - (get_offset (&ih->ih_key) - 1));
 	    mark_ih_was_tail (&indih);
 	
-	    free_sp = fs->fs_blocksize - len - (get_offset (&ih->ih_key) - 1);
 	    mark_buffer_dirty (unbh);
-//      mark_buffer_uptodate (unbh, 0);
 	    mark_buffer_uptodate (unbh, 1);
 	    brelse (unbh);
 
@@ -558,11 +562,6 @@
 	} else {
 	    /* take first unformatted pointer from an indirect item */
 	    //free_sp = ih_get_free_space(0, ih, item);
-/*	    free_sp = 0;//get_ih_free_space (ih);
-	    set_ih_free_space (&indih, ((get_ih_item_len(ih) == UNFM_P_SIZE) ? free_sp : 0));
-	    if (get_ih_item_len (ih) != UNFM_P_SIZE)
-		free_sp = 0;
-*/
 
 	    set_ih_item_len (&indih, get_ih_item_len (ih));
 	    ni = getmem (get_ih_item_len (ih));
@@ -593,46 +592,12 @@
 	reiserfsck_insert_item (path, &indih, (const char *)&unfm_ptr);
     }
 
-    /* update sd_first_direct_byte */
-    /*
-    if (get_ih_key_format (&indih) == KEY_FORMAT_1) {
-	struct key sd_key;
-
-	sd_key = indih.ih_key;
-	set_type_and_offset (KEY_FORMAT_1, &sd_key, SD_OFFSET, TYPE_STAT_DATA);
-
-	if (reiserfs_search_by_key_4 (fs, &sd_key, path) == ITEM_FOUND) {
-	    struct buffer_head * bh;
-	    struct stat_data_v1 * sd;
-	    __u32 fdb;
-
-	    bh = get_bh (path);
-	    ih = get_ih (path);
-	    if (get_ih_item_len (ih) != SD_V1_SIZE) {
-		// symlink?
-		if (get_ih_item_len (ih) != SD_SIZE)
-		    die ("create_first_item_of_file: wrong stat data found");
-	    } else {
-		sd = get_item (path);
-		get_sd_first_direct_byte (ih, sd, &fdb);
-		if (fdb != NO_BYTES_IN_DIRECT_ITEM) {
-		    fdb = NO_BYTES_IN_DIRECT_ITEM;
-		    set_sd_first_direct_byte (ih, sd, &fdb);
-		    mark_buffer_dirty (bh);
-		}
-	    }
-	    pathrelse (path);
-	}
-    }
-
-*/
     return retval;
 }
 
 
 /* path points to first part of tail. Function copies file tail into unformatted node and returns
-   its block number. If we are going to overwrite direct item then keep free space (keep_free_space
-   == YES). Else (we will append file) set free space to 0 */
+   its block number. */
 /* we convert direct item that is on the path to indirect. we need a number of free block for
    unformatted node. reiserfs_new_blocknrs will start from block number returned by this function */
 static unsigned long block_to_start (struct path * path)
@@ -650,7 +615,7 @@
 }
 
 
-static void direct2indirect2 (unsigned long unfm, struct path * path, int keep_free_space)
+static void direct2indirect2 (unsigned long unfm, struct path * path)
 {
     struct item_head * ih;
     struct key key;
@@ -733,43 +698,6 @@
     mark_buffer_uptodate (unbh, 1);
     brelse (unbh);
 
-    /* update sd_first_direct_byte */
-/*
-    while (file_format == KEY_FORMAT_1) {
-	struct key sd_key;
-
-	sd_key = key;
-	set_type_and_offset (KEY_FORMAT_1, &sd_key, SD_OFFSET, TYPE_STAT_DATA);
-
-	if (reiserfs_search_by_key_4 (fs, &sd_key, path) == ITEM_FOUND) {
-	    struct buffer_head * bh;
-	    struct stat_data_v1 * sd;
-	    __u32 fdb;
-	    __u16 mode;
-
-	    bh = get_bh (path);
-	    ih = get_ih (path);
-	    get_sd_mode (ih, get_item(path), &mode);
-	
-//	    if (get_ih_item_len (ih) != SD_V1_SIZE)
-	    if (get_ih_item_len (ih) != SD_V1_SIZE) {
-		if (S_ISLNK(mode)) {
-		    pathrelse (path);
-		    break;
-		} else
-		    reiserfs_panic ("direct2indirect: wrong stat data found %H", ih);
-	    }
-
-	    sd = get_item (path);
-	    fdb = NO_BYTES_IN_DIRECT_ITEM;
-	    set_sd_first_direct_byte (ih, sd, &fdb);
-	    mark_buffer_dirty (bh);
-	    pathrelse (path);
-	}
-	break;
-    }
-*/
-
     if (usearch_by_position (fs, &key, file_format, path) != POSITION_FOUND ||
 	!is_indirect_ih (PATH_PITEM_HEAD (path)))
 	reiserfs_panic ("direct2indirect: The data %k, which are supposed to be converted, are not found", &key);
@@ -780,31 +708,32 @@
 
 
 static int append_to_unformatted_node (struct item_head * comingih, struct item_head * ih, char * item,
-                                        struct path * path, __u16 * free_sp, __u64 coming_len)
+                                        struct path * path, unsigned int coming_len)
 {
-    struct buffer_head * bh, * unbh;
-    __u64 end_of_data; //ih->u.ih_free_space;
-    __u64 offset = get_offset (&comingih->ih_key) % fs->fs_blocksize - 1;
-    int zero_number;
+    struct buffer_head * bh, * unbh = NULL;
+    __u64 end_of_data, free_space;
+    __u16 offset = get_offset (&comingih->ih_key) % fs->fs_blocksize - 1;
     __u32 unfm_ptr;
+    int zero_number;
     
     bh = PATH_PLAST_BUFFER (path);
     unfm_ptr = le32_to_cpu (B_I_POS_UNFM_POINTER (bh, ih, I_UNFM_NUM (ih) - 1));
 
     /* append to free space of the last unformatted node of indirect item ih */
-    if (*free_sp /*ih->u.ih_free_space*/ < coming_len)
-    {
-	*free_sp = get_offset (&ih->ih_key) + fs->fs_blocksize * I_UNFM_NUM (ih) - get_offset (&comingih->ih_key);
-	if (*free_sp < coming_len)
-	    reiserfs_panic ("%s: block %lu: The unformatted node %u, pointed by the file %k, has not enough free space"
-		"for appending %llu bytes", __FUNCTION__, bh->b_blocknr, unfm_ptr, &ih->ih_key, coming_len);
-    }
-    end_of_data = fs->fs_blocksize - *free_sp;
+    free_space = get_offset (&ih->ih_key) + fs->fs_blocksize * I_UNFM_NUM (ih) - get_offset (&comingih->ih_key);
+	
+    if (free_space < coming_len)
+	reiserfs_panic ("%s: block %lu: The unformatted node %u, pointed by the file %k, does not have enough free space"
+	    "for appending %llu bytes", __FUNCTION__, bh->b_blocknr, unfm_ptr, &ih->ih_key, coming_len);
+	
+    if (fs->fs_blocksize < free_space)
+	reiserfs_panic ("%s: block %lu: The unformatted node %u, pointed by the file %k, does not have enough free space"
+	    "for appending %llu bytes", __FUNCTION__, bh->b_blocknr, &ih->ih_key, unfm_ptr, &ih->ih_key, coming_len);	
+    
+    end_of_data = fs->fs_blocksize - free_space;
     zero_number = offset - end_of_data;
 
-   /*if (unfm_ptr != 0 && unfm_ptr < SB_BLOCK_COUNT (fs))*/
-    if (unfm_ptr && !not_data_block (fs, unfm_ptr))
-    {
+    if (unfm_ptr && !not_data_block (fs, unfm_ptr)) {
 	unbh = bread (fs->fs_dev, unfm_ptr, fs->fs_blocksize);
 	if (!is_block_used (unfm_ptr))
 	    reiserfs_panic ("%s: block %lu: The unformatted node %u, pointed by the file %k, is marked as unused", 
@@ -812,7 +741,9 @@
 
 	if (unbh == 0)
 	    unfm_ptr = 0;
-    } else {
+    }
+    
+    if (!unfm_ptr || not_data_block (fs, unfm_ptr)) {
 	/* indirect item points to block which can not be pointed or to 0, in
            any case we have to allocate new node */
 	/*if (unfm_ptr == 0 || unfm_ptr >= SB_BLOCK_COUNT (fs)) {*/
@@ -827,9 +758,9 @@
 
 //    save_unfm_overwriting (unbh->b_blocknr, comingih);
 
-    *free_sp /*ih->u.ih_free_space*/ -= (zero_number + coming_len);
+    free_space -= (zero_number + coming_len);
     set_ih_free_space(ih, get_ih_free_space(ih) - (zero_number + coming_len));
-    memset (unbh->b_data + offset + coming_len, 0, *free_sp);
+    memset (unbh->b_data + offset + coming_len, 0, free_space);
 //  mark_buffer_uptodate (unbh, 0);
     mark_buffer_uptodate (unbh, 1);
     mark_buffer_dirty (unbh);
@@ -838,31 +769,6 @@
     return coming_len;
 }
 
-
-static void adjust_free_space (struct buffer_head * bh, struct item_head * ih, struct item_head * comingih, __u16 *free_sp)
-{
-  //    printf ("adjust_free_space does nothing\n");
-    return;
-    if (is_indirect_ih (comingih)) {
-	set_ih_free_space(ih, 0);//??
-	*free_sp = (__u16)0;
-    } else {
-	if (get_offset (&comingih->ih_key) < get_offset (&ih->ih_key) + fs->fs_blocksize * I_UNFM_NUM (ih))
-	{
-	    /* append to the last unformatted node */
-	    set_ih_free_space (ih, fs->fs_blocksize - get_offset(&ih->ih_key) % fs->fs_blocksize + 1);//??
-	    *free_sp = (__u16)fs->fs_blocksize - get_offset(&ih->ih_key) % fs->fs_blocksize + 1;
-	}
-	else
-	{
-	    set_ih_free_space(ih,0);//??
-	    *free_sp =0;
-	}
-    }
-    mark_buffer_dirty (bh);
-}
-
-
 /* this appends file with one unformatted node pointer (since balancing
    algorithm limitation). This pointer can be 0, or new allocated block or
    pointer from indirect item that is being inserted into tree */
@@ -873,41 +779,26 @@
     struct buffer_head * unbh;
     int retval;
     struct item_head * ih = PATH_PITEM_HEAD (path);
-    __u16 keep_free_space;
     __u32 bytes_number;
     int i, count = 0;
 
     if (!is_indirect_ih (ih))
 	reiserfs_panic ("reiserfsck_append_file: Operation is not allowed for non-indirect item %k", &ih->ih_key);
 
-    //keep_free_space = ih_get_free_space(PATH_PLAST_BUFFER (path), PATH_PITEM_HEAD(path), 0);
-    keep_free_space = 0;//get_ih_free_space (ih);
-
-    if (get_offset (&ih->ih_key) + get_bytes_number (ih, fs->fs_blocksize)
-	//get_bytes_number (PATH_PLAST_BUFFER (path), PATH_PITEM_HEAD(path), 0, CHECK_FREE_BYTES)
-	!= get_offset (&comingih->ih_key)){
-	adjust_free_space (PATH_PLAST_BUFFER (path), ih, comingih, &keep_free_space);
-    }
-
     if (is_direct_ih (comingih)) {
-	//__u64 coming_len = get_bytes_number (0,comingih, item, CHECK_FREE_BYTES);
-	__u64 coming_len = get_bytes_number (comingih, fs->fs_blocksize);
+	unsigned int coming_len = get_bytes_number (comingih, fs->fs_blocksize);
 
 	if (get_offset (&comingih->ih_key) < get_offset (&ih->ih_key) + fs->fs_blocksize * I_UNFM_NUM (ih)) {
 	    /* direct item fits to free space of indirect item */
-	    return append_to_unformatted_node (comingih, ih, item, path, &keep_free_space, coming_len);
+	    return append_to_unformatted_node (comingih, ih, item, path, coming_len);
 	}
 
 	unbh = reiserfsck_get_new_buffer (PATH_PLAST_BUFFER (path)->b_blocknr);
 	memset (unbh->b_data, 0, unbh->b_size);
-	/* this is for check only */
-	/*mark_block_unformatted (unbh->b_blocknr);*/
 	memcpy (unbh->b_data + get_offset (&comingih->ih_key) % unbh->b_size - 1, item, coming_len);
 
-//	save_unfm_overwriting (unbh->b_blocknr, comingih);
 
 	mark_buffer_dirty (unbh);
-//    mark_buffer_uptodate (unbh, 0);
 	mark_buffer_uptodate (unbh, 1);
 
 	ni = getmem (UNFM_P_SIZE);
@@ -951,7 +842,7 @@
     struct item_head * ih = PATH_PITEM_HEAD (path);
 
     if (is_direct_ih (ih)) {
-	direct2indirect2 (0, path, 1);
+	direct2indirect2 (0, path);
 	ih = PATH_PITEM_HEAD (path);
     }
 
@@ -973,7 +864,7 @@
 
     if (is_direct_ih (PATH_PITEM_HEAD (path)))
 	/* convert direct item to indirect */
-	direct2indirect2 (0, path, 0);
+	direct2indirect2 (0, path);
 	
     count = MAX_INDIRECT_ITEM_LEN (fs->fs_blocksize) / UNFM_P_SIZE;
     	
@@ -1098,10 +989,7 @@
     struct item_head * ih = PATH_PITEM_HEAD (path);
     int written;
     __u32 * item_in_tree;
-    int src_unfm_ptrs, dest_unfm_ptrs, to_copy;
-    int i;
-    __u16 free_sp;
-    int dirty = 0;
+    int src_unfm_ptrs, dest_unfm_ptrs, to_copy, i, dirty = 0;
 
     item_in_tree = (__u32 *)B_I_PITEM (bh, ih) + path->pos_in_item;
     coming_item += *pos_in_coming_item;
@@ -1113,14 +1001,13 @@
 	/* whole coming item (comingih) fits into item in tree (ih) starting with path->pos_in_item */
 
 	//free_sp = ih_get_free_space(0, comingih, (char *)coming_item);
-	free_sp = 0;//ih_free_space (comingih);
 
 	written = get_bytes_number (comingih, fs->fs_blocksize) -
-	    free_sp - *pos_in_coming_item * fs->fs_blocksize;
+	    /* free_sp - */ *pos_in_coming_item * fs->fs_blocksize;
 	*pos_in_coming_item = I_UNFM_NUM (comingih);
 	to_copy = src_unfm_ptrs;
 	if (dest_unfm_ptrs == src_unfm_ptrs)
-	    set_ih_free_space(ih, free_sp); //comingih->u.ih_free_space;
+	    set_ih_free_space(ih, 0 /* free_sp */ );
     } else {
 	/* only part of coming item overlaps item in the tree */
 	*pos_in_coming_item += dest_unfm_ptrs;
@@ -1137,20 +1024,6 @@
 	    mark_block_used (le32_to_cpu (coming_item[i]), 0);
 	    dirty ++;
 	}
-
-#if 0
-
-	if (!is_block_used (coming_item[i]) && !is_block_uninsertable (coming_item[i])) {
-	    if (item_in_tree[i]) {
-		/* do not overwrite unformatted pointer. We must save everything what is there already from
-		   direct items */
-		overwrite_unfm_by_unfm (item_in_tree[i], coming_item[i], fs->fs_blocksize);
-	    } else {
-		item_in_tree[i] = coming_item[i];
-		mark_block_used (coming_item[i]);
-	    }
-	}
-#endif
     }
     if (dirty)
 	mark_buffer_dirty (bh);
@@ -1164,7 +1037,6 @@
 {
     __u32 unfm_ptr;
     int written = 0;
-    int keep_free_space;
     struct item_head * ih = PATH_PITEM_HEAD (path);
 
 
@@ -1187,7 +1059,7 @@
 	    }
 	}
 	/* */
-	direct2indirect2 (unfm_ptr, path, keep_free_space = 1);
+	direct2indirect2 (unfm_ptr, path);
     }
     if (is_direct_ih (comingih))
     {
@@ -1205,14 +1077,12 @@
 
 /*
  */
-int reiserfsck_file_write (struct item_head * ih, char * item, int was_in_tree)
-{
+int reiserfsck_file_write (struct item_head * ih, char * item, int was_in_tree) {
     struct path path;
     int count, pos_in_coming_item;
     int retval, written;
     struct key key;
     int file_format = KEY_FORMAT_UNDEFINED;
-    int symlink = 0;
     int relocated = 0;
 
     if (!was_in_tree) {
@@ -1225,7 +1095,7 @@
         copy_short_key (&key, &(ih->ih_key));
 	
         if (reiserfs_search_by_key_4 (fs, &key, &path) != ITEM_FOUND) {
-            fsck_log ("vpf-10260: The file we are inserting the new item (%H) into has not"
+            fsck_log ("vpf-10260: The file we are inserting the new item (%H) into has no"
 		" StatData, insertion was skipped\n", ih);
             pathrelse (&path);
             return 0;
@@ -1234,20 +1104,27 @@
         /*SD found*/
         file_format = get_ih_key_format (get_ih(&path));
         get_sd_mode (get_ih(&path), get_item(&path), &mode);
-        symlink = S_ISLNK(mode);
 
-        if (!symlink && file_format != get_ih_key_format (ih)) {
-            fsck_log ("vpf-10270: The file we are inserting the new item into has the different"
-		" format then found StatData, insertion was skipped\n\tSD: (%H)\n\tNew:(%H)\n", 
-		ih, get_ih(&path));
-            pathrelse (&path);
-            return 0;
+        if (file_format != get_ih_key_format (ih)) {
+	    /* Not for symlinks and not for items which should be relocted. */
+	    if (((S_ISDIR(mode) && is_direntry_ih(ih)) || 
+		(!S_ISDIR(mode) && !is_direntry_ih(ih))) && 
+		!S_ISLNK(mode))
+	    {
+		set_type_and_offset (file_format, &ih->ih_key, get_offset (&ih->ih_key), get_type (&ih->ih_key));
+		set_ih_key_format(ih, file_format);		
+	    }
         }
 
 	if (!relocated && should_relocate (ih)) {
 	    rewrite_file (ih, 1, 1/*change new_ih*/);
 	    pathrelse(&path);
 	    relocated = 1;
+	    
+	    /* object has been relocated but we should not mark it as used in semantic map,
+	       as it does not exist at pass2 and we do not get here for relocation as 
+	       was_in_tree == 1 */
+	    
 	    goto check_again;
 	}
 	
@@ -1328,3 +1205,17 @@
     return get_bytes_number (ih, fs->fs_blocksize);
 }
 
+
+void one_more_corruption(reiserfs_filsys_t *fs, int kind) {
+    if (kind == FATAL)
+	fsck_check_stat (fs)->fatal_corruptions++;
+    else if (kind == FIXABLE)
+	fsck_check_stat (fs)->fixable_corruptions++;
+}
+
+void one_less_corruption(reiserfs_filsys_t *fs, int kind) {
+    if (kind == FATAL)
+	fsck_check_stat (fs)->fatal_corruptions--;
+    else if (kind == FIXABLE)
+	fsck_check_stat (fs)->fixable_corruptions--;
+}
diff --git a/fsck/uobjectid.c b/fsck/uobjectid.c
index dddf7a2..581bf28 100644
--- a/fsck/uobjectid.c
+++ b/fsck/uobjectid.c
@@ -1,380 +1,269 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "fsck.h"
 
 
 /* when --check fsck builds a map of objectids of files it finds in the tree
-   when --rebuild-tree - fsck builds map of objectids it inserts into tree
-   FIXME: objectid gets into map when stat data item
-*/
+   when --rebuild-tree - fsck builds map of objectids it inserts into tree */
 
+#define ALLOC_SIZE			1024
+#define MAX_ID				(~0ul)
 
-#if 0
-/* is it marked used in super block's objectid map. fixme: binary search could
-   be used here */
-int is_objectid_used (reiserfs_filsys_t * fs, __u32 objectid)
-{
-    __u32 * objectid_map;
-    int i = 0;
+/* 2 bytes for the counter */
+#define BM_SIZE				(ALLOC_SIZE - sizeof(__u16))
+#define BM_INTERVAL			(BM_SIZE * 8)
+#define INDEX_COUNT			(MAX_ID / BM_INTERVAL)
 
+#define id_map_interval(map, id)	(map->index + (id / BM_INTERVAL))
 
-    objectid_map = (__u32 *)((char *)(fs->fs_ondisk_sb) + (sb_size(fs)));
-  
-    while (i < get_sb_oid_cursize (fs->fs_ondisk_sb)) {
-	if (objectid == le32_to_cpu (objectid_map[i])) {
-	    return 1;      /* objectid is used */
-	}
-	
-	if (objectid > le32_to_cpu(objectid_map[i]) &&
-             objectid < le32_to_cpu(objectid_map[i+1])) {
-	    return 1;	/* objectid is used */
-	}
-	
-	if (objectid < le32_to_cpu(objectid_map[i]))
-	    break;
+#define id_map_local_count(interval)	(interval + BM_SIZE)
 
-	i += 2;
+typedef struct sb_id_map {
+    __u32 * m_begin;
+    __u32 m_size, m_used_slot_count;
+} sb_id_map_t;
+
+id_map_t *id_map_init() {
+    id_map_t *map;
+    __u32 i;
+ 
+    map = getmem(sizeof(id_map_t));
+    map->index = mem_alloc(INDEX_COUNT * sizeof(void *));
+
+    for (i = 0; i < INDEX_COUNT; i++) {
+	if (map->index[i] != (void *)0)
+	    map->index[i] = (void *)0;
     }
+
+    id_map_mark(map, 0);
+    id_map_mark(map, 1);
+
+    /* id == 0 should not be there, just for convinient usage */
+    map->count--;
     
-    /* objectid is free */
-    return 0;
-}
-#endif
-
-
-
-/* true objectid map */
-
-
-/* increase area by MAP_SIZE bytes */
-static void grow_id_map (struct id_map * map)
-{
-/*
-    if (map->m_page_count && ((map->m_page_count % 5) == 0)) {
-	fsck_log ("grow_id_map: objectid map expanded: used %lu, %d blocks\n",
-		  map->m_used_slots_count, map->m_page_count);
-    }
-*/
-    map->m_begin = expandmem (map->m_begin, map->m_page_count * MAP_SIZE, MAP_SIZE);
-    map->m_page_count ++;
-}
-
-
-static void try_to_shrink_id_map (struct id_map * map)
-{
-    if (map->m_used_slots_count * sizeof(__u32) <= (map->m_page_count - 1) * MAP_SIZE) {
-	/*
-	if (map->m_page_count && ((map->m_page_count % 5) == 0))
-	    fsck_log ("shrink_id_map: objectid map shrinked: used %lu, %d blocks\n",
-		      map->m_used_slots_count, map->m_page_count);
-	*/
-	map->m_begin = expandmem (map->m_begin, map->m_page_count * MAP_SIZE,
-				  -MAP_SIZE);
-        map->m_page_count--;
-    }
-}
-
-
-/* ubin_search_id is used to find id in the map (or proper place to
-   insert the new id).  if smth goes wrong or ubin_search_id stops
-   working properly check_id_search_result should help to find raised
-   problems */
-static void check_id_search_result(struct id_map * map, int res, __u32 pos,
-				   __u32 id)
-{
-    if (res != POSITION_FOUND && res != POSITION_NOT_FOUND)
-        die("check_id_search_result: get wrong result from ubin_search (%d)", res);
-
-    if (res == 1 && le32_to_cpu (map->m_begin[pos]) != id)
-        die("check_id_search_result: wrong id found %u %u", id, le32_to_cpu(map->m_begin[pos]));
-
-    if (res == 1)
-    {
-        if (pos > map->m_used_slots_count)
-            die("check_id_search_result: get bad position (%u), used %u",
-		pos, map->m_used_slots_count);
-        if (pos >= 0 && pos <= map->m_used_slots_count && le32_to_cpu(map->m_begin[pos - 1]) >= id)
-            die("check_id_search_result: previous id (%u) not less than (%u)",
-		le32_to_cpu(map->m_begin[pos - 1]), id);
-        if (pos >= 0 && pos < map->m_used_slots_count && le32_to_cpu(map->m_begin[pos]) < id)
-            die("check_id_search_result: found id (%u) not much than (%u)",
-		le32_to_cpu(map->m_begin[pos]), id);
-    }
-}
-
-/* */
-struct id_map * init_id_map (void)
-{
-    struct id_map * map;
-
-    map = getmem (sizeof (struct id_map));
-    map->m_begin = NULL;
-    map->m_used_slots_count = 0;
-    map->m_page_count = 0;
-    mark_objectid_really_used (map, 1);
     return map;
 }
 
-
-/* free whole map */
-void free_id_map (struct id_map * map)
-{
-    freemem (map->m_begin);
-    freemem (map);
-}
-
-
-/* return 1 if id is marked used, 0 otherwise */
-int is_objectid_really_used (struct id_map * map, __u32 id, __u32 * ppos)
-{
-    int res;
-    __u32 le_id = cpu_to_le32 (id);
-
-    *ppos = 0;
-
-    if (map->m_begin == NULL)
-        return 0;
-
-    /* smth exists in the map, find proper place to insert or this id */
-    res = reiserfs_bin_search (&le_id, map->m_begin, map->m_used_slots_count,
-			       sizeof (__u32), ppos, comp_ids);
-#if 1
-    check_id_search_result (map, res, *ppos, id);
-#endif
-    /* *ppos is position in objectid map of the element which is equal id
-       or position of an element which is smallest and greater than id */
-    if (res == POSITION_NOT_FOUND)
-	/* id is not found in the map. if returned position is odd -
-	   id is marked used */
-	return (*ppos % 2);
-
-    /* if returned position is odd - id is marked free */
-    return !(*ppos % 2);
-}
-
-static void check_objectid_map (struct id_map * map, int pos)
-{
-    /* check only previous id, current and 2 next ones,
-       if not specified to check evth */
-    int count = 3;
-    int i;
-    int first = pos;
-
-    if (first == 0) {
-    	first = 1;    	
-    } else if (first == -1) {
-	count = map->m_used_slots_count - 1;
-    	first = 1;
-    }
-
-    if (first + count > map->m_used_slots_count)
-        count = map->m_used_slots_count - first;
-
-    for (i = first; i < first + count; i ++)
-	if (le32_to_cpu(map->m_begin [i - 1]) >= le32_to_cpu(map->m_begin [i]))
-	    die ("check_objectid_map: map corrupted");
-}
-
-int __mark_objectid_really_used(struct id_map *map, __u32 id, __u32 pos) {
-
-    map->objectids_marked ++;
-    if (pos % 2 == 0){
-        /* id not found in the map. why? is_id_used() knows */
-
-        if (map->m_begin == NULL)
-	    /* map is empty */
-            grow_id_map (map);
-
-        /* id + 1 is used, change id + 1 to id and exit */
-        if ( id + 1 == le32_to_cpu (map->m_begin[pos]) ) {
-	    /* we can mark id as used w/o expanding of id map */
-	    map->m_begin[pos] = cpu_to_le32 (id);
-
-	    check_objectid_map (map, pos);
-	    return 0;
-        }
-
-        if (map->m_page_count * MAP_SIZE == map->m_used_slots_count * sizeof(__u32))
-	    /* fixme: do not grow too much */
-            grow_id_map (map);
-
-        if (map->m_used_slots_count - pos > 0)
-            memmove (map->m_begin + pos + 2, map->m_begin + pos, (map->m_used_slots_count - pos) * sizeof (__u32));
-
-        map->m_used_slots_count += 2;
-        map->m_begin[pos] = cpu_to_le32 (id);
-        map->m_begin[pos+1] = cpu_to_le32 (id + 1);
-
-	check_objectid_map (map, pos);
-
-        return 0;
-    }
-
-    /* id found in the map. pos is odd position () */
-    map->m_begin[pos] = cpu_to_le32 (id + 1);
-    
-    /* if end id of current interval == start id of next interval we
-       eliminated a sequence of unused objectids */
-    if (pos + 1 < map->m_used_slots_count &&
-	map->m_begin[pos + 1] == map->m_begin[pos]) { /* safe, both are le */
-	memmove (map->m_begin + pos, map->m_begin + pos + 2, (map->m_used_slots_count - pos - 2) * sizeof (__u32));
-	map->m_used_slots_count -= 2;
-	try_to_shrink_id_map (map);
-    }
-
-    check_objectid_map (map, pos);
-
-    return 0;
-}
-
-/* returns 1 objectid is marked used already, 0 otherwise */
-int mark_objectid_really_used (struct id_map * map, __u32 id)
-{
-    __u32 pos;
-
-    /* check whether id is used and get place if used or place to insert if not */
-    if (is_objectid_really_used (map, id, &pos) == 1)
-        return 1;
-
-    return __mark_objectid_really_used(map, id, pos) ;
-}
-
-
-static __u32 get_free_id (reiserfs_filsys_t * fs)
-{
-    struct id_map * map;
-
-    map = proper_id_map (fs);
-
-    /* If map is not NULL return the second element (first position in
-       the map).  This allocates the first unused objectid. That is to
-       say, the first entry on the objectid map is the first unused
-       objectid. */
-    if (map->m_begin == NULL) {
-	fprintf (stderr, "get_free_id: hmm, 1 is allocated as objectid\n");
-	return 1;
-    }
-    return (le32_to_cpu (map->m_begin[1]));
-}
-
-
-__u32 get_unused_objectid (reiserfs_filsys_t * fs)
-{
-    __u32 objectid;
-
-    objectid = get_free_id (fs);
-    if (mark_objectid_really_used (proper_id_map (fs), objectid))
-	die ("get_unused_objectid: could not mark %lu used", 
-	     ( long unsigned ) objectid);
-
-    return objectid;
-}
-
-
-#define objectid_map(fs) ((char *)((char *)((fs)->s_rs) + sb_size (fs)))
-
-
-#if 0
-/* returns 0 if on-disk objectid map matches to the correct one, 1
-   otherwise */
-int compare_id_maps (reiserfs_filsys_t * fs)
-{
-    struct id_map * map;
-    int disk_size;
-  
-    map = proper_id_map (fs);
-    
-    disk_size = rs_objectid_map_size (fs->s_rs);
-    if (disk_size != map->m_used_slots_count ||
-	memcmp ((char *)((char *)((fs)->s_rs) + sb_size (fs)), map->m_begin, sizeof(__u32) * disk_size)) {
-	fprintf (stderr, "Objectid maps mismatch\n");
-	return 1;
-    }
-
-    return 0;
-}
-
-
-/* copy objectid map into buffer containing super block */
-void correct_objectid_map (reiserfs_filsys_t * fs)
-{
-    struct id_map * map;
-    int size, disk_max;
+void id_map_free(id_map_t *map) {
+    __u32 i;
  
-    map = proper_id_map (fs);
-    
-    size = map->m_used_slots_count;
-    disk_max = rs_objectid_map_max_size (fs->s_rs);
-    if (disk_max < size) {
-	size = disk_max;
-    } else {
-	memset (fu_objectid_map (fs) + size, 0, (disk_max - size) * sizeof (__u32));
+    for (i = 0; i < INDEX_COUNT; i++) {
+	if (map->index[i] != (void *)0 && map->index[i] != (void *)1)
+	    freemem(map->index[i]);
     }
     
-    memcpy (fu_objectid_map (fs), map->m_begin, size * sizeof (__u32));
-    set_objectid_map_size (fs->s_rs, size);
-    mark_buffer_dirty (SB_BUFFER_WITH_SB (fs));
+    freemem(map->index);
+    freemem(map);
+}
 
+int id_map_test(id_map_t *map, __u32 id) {
+    void **interval = id_map_interval(map, id);
+
+    if (*interval == (void *)0)
+	return 0;
+    
+    if (*interval == (void *)1)
+	return 1;
+    
+    return misc_test_bit(id % BM_INTERVAL, *interval);
+}
+
+int id_map_mark(id_map_t *map, __u32 id) {
+    void **interval = id_map_interval(map, id);
+
+    if (*interval == (void *)0)
+	*interval = getmem(ALLOC_SIZE);
+
+    if (*interval == (void *)1)
+	return 1;
+
+    if (misc_test_bit(id % BM_INTERVAL, *interval))
+	return 1;
+	
+    misc_set_bit(id % BM_INTERVAL, *interval);
+    
+    (*(__u16 *)id_map_local_count(*interval))++;
+    map->count++;
+
+    if ((*(__u16 *)id_map_local_count(*interval)) == BM_INTERVAL) {
+	/* Dealloc fully used bitmap */
+	freemem(*interval);
+	*interval = (void *)1;
+    }
+
+    if (map->last_used < (id / BM_INTERVAL))
+	map->last_used = id / BM_INTERVAL;
+    
+    return 0;
+}
+
+/* call this for proper_id_map only!! */
+__u32 id_map_alloc(id_map_t *map) {
+    __u32 i, zero_count;
+    __u32 id = 0, first = ~0ul;
+
+    for (i = 0, zero_count = 0; zero_count < 10 && i < INDEX_COUNT - 1; i++) {
+	if (map->index[i] == (void *)0) {
+	    if (zero_count == 0)
+		first = i;
+	    
+	    zero_count++;
+	} else if (map->index[i] != (void *)1)
+	    break;
+    }
+
+    if (map->index[i] != (void *)1 && map->index[i] != (void *)0) {
+	id = misc_find_first_zero_bit(map->index[i], BM_INTERVAL);
+	if (id >= BM_INTERVAL)
+	    die ("Id is out of interval size, interval looks corrupted.");
+	
+	id += i * BM_INTERVAL;
+    } else if (first != ~0ul) {
+	id = first * BM_INTERVAL;
+	if (id == 0) 
+	    id = 2;
+    } else 
+	die ("%s: No more free objectid is available.", __FUNCTION__);
+
+    id_map_mark(map, id);
+
+    return id;
+}
+
+/* this could be used if some more sofisticated flushing will be needed. */
 /*
-    if (fs->fu_job->verbose)
-	fprintf (stderr, "Objectid map corrected\n");
-*/
-}
-#endif
+static void sb_id_map_pack(sb_id_map_t *map) {
+    map->m_begin[1] = map->m_begin[map->m_used_slot_count - 1];
+    memset(map->m_begin + 2, 0, map->m_used_slot_count - 2);
+    map->m_used_slot_count = 2;
+}*/
 
+static __u32 id_map_next_bound(id_map_t *map, __u32 start) {
+    __u32 index = start / BM_INTERVAL;
+    __u32 offset = start % BM_INTERVAL;
+    int look_for;
+    
+    if (map->index[index] == (void *)0)
+	look_for = 1;
+    else if (map->index[index] == (void *)1)
+	look_for = 0;
+    else 
+	look_for = !misc_test_bit(offset, map->index[index]);
 
-/* print the map of objectids */
-void print_objectid_list (__u32 *map, int count)
-{
-    int i;
-    for (i = 0; i < count ; i += 2)
-           printf ("\n[%u-%u]", le32_to_cpu(map[i]),le32_to_cpu(map[i+1]));
+    offset++;
+
+start_again:
+    
+    if (look_for) {	
+	while (index < INDEX_COUNT && map->index[index] == (void *)0)
+	    index++;
+	
+	if (index == INDEX_COUNT)
+	    return 0;
+	
+	if (map->index[index] == (void *)1)
+	    return index * BM_INTERVAL;
+	
+	offset = misc_find_next_set_bit(map->index[index], BM_INTERVAL, offset);
+
+	if (offset >= BM_INTERVAL) {
+	    offset = 0;
+	    index++;
+	    goto start_again;
+	}
+	
+	return index * BM_INTERVAL + offset;
+    } else {
+	while (index < INDEX_COUNT && map->index[index] == (void *)1)
+	    index++;
+	
+	if (index == INDEX_COUNT)
+	    return 0;
+	
+	if (map->index[index] == (void *)0)
+	    return index * BM_INTERVAL;
+
+	offset = misc_find_next_zero_bit(map->index[index], BM_INTERVAL, offset);
+	
+	if (offset >= BM_INTERVAL) {
+	    offset = 0;
+	    index++;
+	    goto start_again;
+	}
+	
+	return index * BM_INTERVAL + offset;
+    }
 }
 
-#if 0
-/* print on-disk map of objectids */
-void print_disk_objectid_list (void)
-{
-    int i;
-    __u32 * objectid_map = (__u32 *)((char *)SB_DISK_SUPER_BLOCK (&g_sb) + (sb_size(&g_sb)));
-    printf ("\n on-disk id map. used:%lu", SB_OBJECTID_MAP_SIZE(&g_sb));
-
-    for (i = 0; i < SB_OBJECTID_MAP_SIZE(&g_sb); i += 2)
-	printf ("\n[%u-%u]", objectid_map[i], objectid_map[i + 1] - 1);
-}
-#endif
-
-
-void flush_objectid_map (struct id_map * map, reiserfs_filsys_t * fs)
-{
-    int size, max;
-    int sb_size;
+void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
+    int size, max, i;
+    __u32 id, prev_id;
     __u32 * sb_objectid_map;
 
-    sb_size = reiserfs_super_block_size (fs->fs_ondisk_sb);
-    sb_objectid_map = (__u32 *)((char *)(fs->fs_ondisk_sb) + sb_size);
+    size = reiserfs_super_block_size (fs->fs_ondisk_sb);
+    sb_objectid_map = (__u32 *)((char *)(fs->fs_ondisk_sb) + size);
 
-    max = ((fs->fs_blocksize - sb_size) >> 3 << 1);
+    max = ((fs->fs_blocksize - size) >> 3 << 1);
     set_sb_oid_maxsize (fs->fs_ondisk_sb, max);
-    if (map->m_used_slots_count > max)
-	size = max;
-    else
-	size = map->m_used_slots_count;
+    
+    sb_objectid_map[0] = id = 1;
 
-    check_objectid_map (map, -1);
+    for (i = 1; i < max - 1; i++) {	
+	sb_objectid_map[i] = id = id_map_next_bound(map, id);
+	if (id == 0) {
+	    if (i % 2)
+		die ("%s: Used interval is not closed on flushing.", __FUNCTION__);
+	    break;
+	}
+    }
 
-    memcpy (sb_objectid_map, map->m_begin, size * sizeof (__u32));
-    memset (sb_objectid_map + size, 0, (max - size) * sizeof (__u32));
+    if (map->index[map->last_used] == (void *)0)
+	die ("Object id map looks corrupted - last used interval cannot be zeroed.");
+    
+    i++;
+    
+    if (i == max) {
+	if (id == 0)
+	    die ("Objectid interval does not contain any set bit what is expected.");
+	
+	if (map->index[map->last_used] == (void *)1) {
+	    prev_id = BM_INTERVAL - 1;
+	} else {	    
+	    prev_id = ~0ul;
+	    
+	    if (id < map->last_used * BM_INTERVAL)
+		id = 0;
+	    else 
+		id %= BM_INTERVAL;
+	    
+	    if (misc_test_bit(id, map->index[map->last_used]))
+		prev_id = id;
+	    
+	    while ((id = misc_find_next_set_bit(map->index[map->last_used], 
+		BM_INTERVAL, (id + 1))) != BM_INTERVAL) 
+	    {
+		prev_id = id;
+	    }
 
-    set_sb_oid_cursize (fs->fs_ondisk_sb, size);
-    if (size == max)
-	sb_objectid_map [max - 1] = map->m_begin [map->m_used_slots_count - 1];
+	    if (prev_id == ~0ul)
+		die ("Objectid interval does not contain any set bit what is expected.");
 
-//    check_objectid_map (map);
+	    prev_id++;
+	}
+	
+	sb_objectid_map[max - 1] = prev_id + map->last_used * BM_INTERVAL;
+    } else { 
+	i--;
+	memset(sb_objectid_map + i, 0, (max - i) * sizeof (__u32));
+    }
 
+    set_sb_oid_cursize (fs->fs_ondisk_sb, i);
 }
 
+/* FIXME: these 3 methods must be implemented also.
 
 void fetch_objectid_map (struct id_map * map, reiserfs_filsys_t * fs)
 {
@@ -386,9 +275,10 @@
 
     if (map->m_page_count != 1)
 	die ("fetch_objectid_map: can not fetch long map");
-    grow_id_map (map);
+    
+    make_id_space(map, 0);
     memcpy (map->m_begin, sb_objectid_map, get_sb_oid_cursize (fs->fs_ondisk_sb) * sizeof (__u32));
-    map->m_used_slots_count = get_sb_oid_cursize (fs->fs_ondisk_sb);
+    map->m_used_slot_count = get_sb_oid_cursize (fs->fs_ondisk_sb);
 }
 
 #define OBJMAP_START_MAGIC 375331
@@ -402,14 +292,14 @@
     v = OBJMAP_START_MAGIC;
     fwrite (&v, 4, 1, fp);
 
-    v = id_map->m_used_slots_count;
+    v = id_map->m_used_slot_count;
     fwrite (&v, 4, 1, fp);
 
     for (i = 0; i < id_map->m_page_count - 1; i++) {
 	fwrite ((char *)id_map->m_begin + MAP_SIZE * i, 4, 1, fp);
     }
 
-    for (i = 0; i < id_map->m_used_slots_count * sizeof(__u32) - (id_map->m_page_count - 1) * MAP_SIZE; i++) {
+    for (i = 0; i < id_map->m_used_slot_count * sizeof(__u32) - (id_map->m_page_count - 1) * MAP_SIZE; i++) {
 	fwrite ((char *)id_map->m_begin + MAP_SIZE * (id_map->m_page_count - 1) + i, 4, 1, fp);
     }
 
@@ -429,12 +319,12 @@
 	return 0;
     }
 	
-    /* read bit size of objectid map */
+    // read bit size of objectid map 
     fread (&v, 4, 1, fp);
 
-    id_map = init_id_map ();
+    id_map = init_id_map (MAP_NOT_PACKED);
 
-    id_map->m_used_slots_count = v;
+    id_map->m_used_slot_count = v;
     id_map->m_page_count = v / MAP_SIZE + 1;
 
     id_map->m_begin = expandmem (id_map->m_begin, 0, id_map->m_page_count * MAP_SIZE);
@@ -443,7 +333,7 @@
 	fread ((char *)id_map->m_begin + MAP_SIZE * i, 4, 1, fp);
     }
 
-    for (i = 0; i < id_map->m_used_slots_count * sizeof(__u32) - (id_map->m_page_count - 1) * MAP_SIZE; i++) {
+    for (i = 0; i < id_map->m_used_slot_count * sizeof(__u32) - (id_map->m_page_count - 1) * MAP_SIZE; i++) {
 	fread ((char *)id_map->m_begin + MAP_SIZE * (id_map->m_page_count - 1) + i, 4, 1, fp);
     }
 
@@ -457,4 +347,4 @@
     fflush (stderr);
     return id_map;
 }
-
+*/
diff --git a/fsck/ustree.c b/fsck/ustree.c
index 9edcb6b..7e5d7e0 100644
--- a/fsck/ustree.c
+++ b/fsck/ustree.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "fsck.h"
 
 
@@ -50,7 +52,7 @@
 static void free_unformatted_nodes (struct item_head * ih, struct buffer_head * bh)
 {
     __u32 * punfm = (__u32 *)B_I_PITEM (bh, ih);
-    int i;
+    unsigned int i;
 
     for (i = 0; i < I_UNFM_NUM (ih); i ++, punfm ++)
 	if (*punfm != 0) {
@@ -67,7 +69,6 @@
 	}
 }
 
-
 void reiserfsck_delete_item (struct path * path, int temporary)
 {
     struct tree_balance tb;
@@ -201,7 +202,7 @@
 }
 
 void pass_through_tree (reiserfs_filsys_t * fs, do_after_read_t action1,
-			do_on_full_path_t action2)
+			do_on_full_path_t action2, int depth)
 {
     struct buffer_head * path[MAX_HEIGHT] = {0,};
     int total[MAX_HEIGHT] = {0,};
@@ -227,7 +228,7 @@
 	    fsck_log ("%s: block %lu specified in badblock list found in tree, whole subtree skipped\n",
 		__FUNCTION__, block);
 	    fsck_data (fs)->check.bad_nodes++;
-	    one_more_corruption (fs, fatal);
+	    one_more_corruption (fs, FATAL);
 
 	    if (h == 0) {
 		brelse (path[h]);
@@ -256,6 +257,10 @@
 		}
 	}
 
+	/* Time to stop. */
+	if (h == depth)
+	    problem ++;
+
         if (problem || is_leaf_node (path[h])) {
             if (!problem && action2)
                 action2 (fs, path, h);
diff --git a/include/Makefile.in b/include/Makefile.in
index dfd02cb..21e7c11 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,221 +12,302 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 noinst_HEADERS = io.h  misc.h  reiserfs_fs.h  reiserfs_lib.h swab.h
+subdir = include
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES = 
-HEADERS =  $(noinst_HEADERS)
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+HEADERS = $(noinst_HEADERS)
 
-DIST_COMMON =  ./stamp-h.in Makefile.am Makefile.in config.h.in
+DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in config.h.in
+all: config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-am
 
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
-all: all-redirect
 .SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps include/Makefile
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  include/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-config.h: stamp-h
+config.h: stamp-h1
 	@if test ! -f $@; then \
-		rm -f stamp-h; \
-		$(MAKE) stamp-h; \
+	  rm -f stamp-h1; \
+	  $(MAKE) stamp-h1; \
 	else :; fi
-stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES= CONFIG_HEADERS=include/config.h \
-	     $(SHELL) ./config.status
-	@echo timestamp > stamp-h 2> /dev/null
-$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
-	@if test ! -f $@; then \
-		rm -f $(srcdir)/stamp-h.in; \
-		$(MAKE) $(srcdir)/stamp-h.in; \
-	else :; fi
-$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status include/config.h
+
+$(srcdir)/config.h.in:  $(top_srcdir)/configure.in $(ACLOCAL_M4) 
 	cd $(top_srcdir) && $(AUTOHEADER)
-	@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
-
-mostlyclean-hdr:
-
-clean-hdr:
+	touch $(srcdir)/config.h.in
 
 distclean-hdr:
-	-rm -f config.h
+	-rm -f config.h stamp-h1
+uninstall-info-am:
 
-maintainer-clean-hdr:
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = include
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-all-recursive-am: config.h
-	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+all-am: Makefile $(HEADERS) config.h
 
-install-exec-am:
+installdirs:
+
+install: install-am
 install-exec: install-exec-am
-
-install-data-am:
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile $(HEADERS) config.h
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-hdr mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-hdr clean-tags clean-generic mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-hdr distclean-tags distclean-generic clean-am
+clean-am: clean-generic mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-hdr maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
-tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
-distdir info-am info dvi-am dvi check check-am installcheck-am \
-installcheck all-recursive-am install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic ctags \
+	distclean distclean-generic distclean-hdr distclean-tags \
+	distdir dvi dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+	pdf-am ps ps-am tags uninstall uninstall-am uninstall-info-am
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/include/config.h.in b/include/config.h.in
index ef58491..dfd9c60 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -1,70 +1,67 @@
-/* include/config.h.in.  Generated automatically from configure.in by autoheader.  */
-/*
- * Copyright 1996, 1997 Hans Reiser, see reiserfs/README for licensing and copyright details
- */
+/* include/config.h.in.  Generated from configure.in by autoheader.  */
 
-/* Define if you don't have `vprintf' but do have `_doprnt.' */
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
 #undef HAVE_DOPRNT
 
-/* Define if you have the <fcntl.h> header file. */
+/* Define to 1 if you have the <fcntl.h> header file. */
 #undef HAVE_FCNTL_H
 
-/* Define if you have the <inttypes.h> header file. */
+/* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define if you have the <limits.h> header file. */
+/* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 
-/* Define if you have the <malloc.h> header file. */
+/* Define to 1 if you have the <malloc.h> header file. */
 #undef HAVE_MALLOC_H
 
-/* Define if you have the <memory.h> header file. */
+/* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
-/* Define if you have the <stdint.h> header file. */
+/* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
-/* Define if you have the <stdlib.h> header file. */
+/* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
-/* Define if you have the `strerror' function. */
+/* Define to 1 if you have the `strerror' function. */
 #undef HAVE_STRERROR
 
-/* Define if you have the `strftime' function. */
+/* Define to 1 if you have the `strftime' function. */
 #undef HAVE_STRFTIME
 
-/* Define if you have the <strings.h> header file. */
+/* Define to 1 if you have the <strings.h> header file. */
 #undef HAVE_STRINGS_H
 
-/* Define if you have the <string.h> header file. */
+/* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Define if you have the `strstr' function. */
+/* Define to 1 if you have the `strstr' function. */
 #undef HAVE_STRSTR
 
-/* Define if you have the `strtol' function. */
+/* Define to 1 if you have the `strtol' function. */
 #undef HAVE_STRTOL
 
-/* Define if `st_rdev' is member of `struct stat'. */
+/* Define to 1 if `st_rdev' is member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_RDEV
 
-/* Define if your `struct stat' has `st_rdev'. Deprecated, use
+/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
    `HAVE_STRUCT_STAT_ST_RDEV' instead. */
 #undef HAVE_ST_RDEV
 
-/* Define if you have the <sys/ioctl.h> header file. */
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
 #undef HAVE_SYS_IOCTL_H
 
-/* Define if you have the <sys/stat.h> header file. */
+/* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
-/* Define if you have the <sys/types.h> header file. */
+/* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
-/* Define if you have the <unistd.h> header file. */
+/* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
-/* Define if you have the `vprintf' function. */
+/* Define to 1 if you have the `vprintf' function. */
 #undef HAVE_VPRINTF
 
 /* gets set when configure --enable-io-failure-emulation */
@@ -73,7 +70,22 @@
 /* Name of package */
 #undef PACKAGE
 
-/* Define if you have the ANSI C header files. */
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
 /* Version number of package */
diff --git a/include/io.h b/include/io.h
index 1576fcb..94b357d 100644
--- a/include/io.h
+++ b/include/io.h
@@ -1,11 +1,11 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
-
 struct buffer_head {
     unsigned long b_blocknr;
-    unsigned short b_dev;
+    int b_dev;
     unsigned long b_size;
     char * b_data;
     unsigned long b_state;
@@ -26,16 +26,16 @@
 #define BH_Do_not_flush 3
 
 
-#define buffer_uptodate(bh) test_bit(BH_Uptodate, &(bh)->b_state)
-#define buffer_dirty(bh) test_bit(BH_Dirty, &(bh)->b_state)
-#define buffer_locked(bh) test_bit(BH_Lock, &(bh)->b_state)
-#define buffer_clean(bh) !test_bit(BH_Dirty, &(bh)->b_state)
-#define buffer_do_not_flush(bh) test_bit(BH_Do_not_flush, &(bh)->b_state)
-#define mark_buffer_dirty(bh) set_bit(BH_Dirty, &(bh)->b_state)
-#define mark_buffer_uptodate(bh,i) set_bit(BH_Uptodate, &(bh)->b_state)
-#define mark_buffer_clean(bh) clear_bit(BH_Dirty, &(bh)->b_state)
-#define mark_buffer_do_not_flush(bh) set_bit(BH_Do_not_flush, &(bh)->b_state)
-#define clear_buffer_do_not_flush(bh) clear_bit(BH_Do_not_flush, &(bh)->b_state)
+#define buffer_uptodate(bh) misc_test_bit(BH_Uptodate, &(bh)->b_state)
+#define buffer_dirty(bh) misc_test_bit(BH_Dirty, &(bh)->b_state)
+#define buffer_locked(bh) misc_test_bit(BH_Lock, &(bh)->b_state)
+#define buffer_clean(bh) !misc_test_bit(BH_Dirty, &(bh)->b_state)
+#define buffer_do_not_flush(bh) misc_test_bit(BH_Do_not_flush, &(bh)->b_state)
+#define mark_buffer_dirty(bh) misc_set_bit(BH_Dirty, &(bh)->b_state)
+#define mark_buffer_uptodate(bh,i) misc_set_bit(BH_Uptodate, &(bh)->b_state)
+#define mark_buffer_clean(bh) misc_clear_bit(BH_Dirty, &(bh)->b_state)
+#define mark_buffer_do_not_flush(bh) misc_set_bit(BH_Do_not_flush, &(bh)->b_state)
+#define clear_buffer_do_not_flush(bh) misc_clear_bit(BH_Do_not_flush, &(bh)->b_state)
 
 /*
 printf ("%s:%s:%u %p %p %p\n", 
@@ -51,7 +51,7 @@
 struct buffer_head * getblk (int dev, unsigned long block, int size);
 struct buffer_head * reiserfs_getblk (int dev, unsigned long block, int size, int *repeat);
 
-struct buffer_head * find_buffer (int dev, unsigned long block, int size);
+struct buffer_head * find_buffer (int dev, unsigned long block, unsigned long size);
 struct buffer_head * get_hash_table(dev_t dev, unsigned long block, int size);
 struct buffer_head * bread (int dev, unsigned long block, size_t size);
 struct buffer_head * reiserfs_bread (int dev, unsigned long block, int size, int *repeat);
@@ -59,15 +59,14 @@
 int bwrite (struct buffer_head * bh);
 void brelse (struct buffer_head * bh);
 void bforget (struct buffer_head * bh);
-void check_and_free_buffer_mem (void);
 void init_rollback_file (char * rollback_file, int *bloksize, FILE * log);
 int open_rollback_file (char * rollback_file, FILE * log);
 void close_rollback_file ();
 void do_fsck_rollback (int fd_device, int fd_journal_device, FILE * log); 
 
-void flush_buffers (dev_t);
+void flush_buffers (int);
 void free_buffers (void);
-void invalidate_buffers (dev_t dev);
+void invalidate_buffers (int);
 
 
 int user_confirmed (FILE * fp, char * q, char * yes);
diff --git a/include/misc.h b/include/misc.h
index 3149207..05b3376 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 /* nothing abount reiserfs here */
@@ -19,15 +20,18 @@
 void check_memory_msg(void);
 void die (char * fmt, ...) __attribute__ ((format (printf, 1, 2)));
 void * getmem (int size);
+void *mem_alloc(int size);
 void freemem (void * p);
 void checkmem (char * p, int size);
 void * expandmem (void * p, int size, int by);
-int get_mem_size (char * p);
+unsigned int get_mem_size (char * p);
 int is_mounted (char * device_name);
 int is_mounted_read_only (char * device_name);
 void check_and_free_mem (void);
 char * kdevname (int dev);
 
+void misc_print_credit(FILE *out);
+
 typedef struct dma_info {
     int fd;
     struct stat64 stat;
@@ -40,7 +44,7 @@
 int get_dma_info(dma_info_t *dma_info);
 void clean_after_dma_check(int fd, dma_info_t *dma_info);
 
-void print_how_far (FILE * fp, unsigned long * passed, unsigned long total, int inc, int quiet);
+void print_how_far (FILE * fp, unsigned long *passed, unsigned long total, unsigned int inc, int quiet);
 void print_how_fast (unsigned long total, 
 		     unsigned long passed, int cursor_pos, int reset_time);
 __u32 get_random (void);
@@ -49,27 +53,34 @@
 int uuid_is_correct (unsigned char * uuid);
 int set_uuid (const unsigned char * text, unsigned char * UUID);
 
-#include <asm/bitops.h>
+//#include <asm/bitops.h>
+
+extern inline int misc_set_bit (unsigned long long nr, void * addr);
+extern inline int misc_clear_bit (unsigned long long nr, void * addr);
+extern inline int misc_test_bit(unsigned long long nr, const void * addr);
+extern inline unsigned long long misc_find_first_zero_bit (const void *vaddr, unsigned long long size);
+extern inline unsigned long long misc_find_next_zero_bit (const void *vaddr, unsigned long long size, unsigned long long offset);
+extern inline unsigned long long misc_find_next_set_bit(const void *vaddr, unsigned long long size, unsigned long long offset);
+extern inline unsigned long long misc_find_first_set_bit (const void *vaddr, unsigned long long size);
+ 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-int le_set_bit (int nr, void * addr);
-int le_clear_bit (int nr, void * addr);
-int le_test_bit(int nr, const void * addr);
-int le_find_first_zero_bit (const void *vaddr, unsigned size);
-int le_find_next_zero_bit (const void *vaddr, unsigned size, unsigned offset);
+
 # define cpu_to_le16(val)                 (val)
 # define le16_to_cpu(val)                 (val)
 # define cpu_to_le32(val)                 (val)
 # define le32_to_cpu(val)                 (val)
 # define cpu_to_le64(val)                 (val)
 # define le64_to_cpu(val)                 (val)
+
 #elif __BYTE_ORDER == __BIG_ENDIAN
 
-# define cpu_to_le16(val)                 swab16(val)
-# define le16_to_cpu(val)                 swab16(val)
-# define cpu_to_le32(val)                 swab32(val)
-# define le32_to_cpu(val)                 swab32(val)
-# define cpu_to_le64(val)                 swab64(val)
-# define le64_to_cpu(val)                 swab64(val)
+# define cpu_to_le16(val)                 __swab16(val)
+# define le16_to_cpu(val)                 __swab16(val)
+# define cpu_to_le32(val)                 __swab32(val)
+# define le32_to_cpu(val)                 __swab32(val)
+# define cpu_to_le64(val)                 __swab64(val)
+# define le64_to_cpu(val)                 __swab64(val)
+
 #else
 # error "nuxi/pdp-endian archs are not supported"
 #endif
diff --git a/include/reiserfs_fs.h b/include/reiserfs_fs.h
index 291eee7..5008dc7 100644
--- a/include/reiserfs_fs.h
+++ b/include/reiserfs_fs.h
@@ -1,7 +1,8 @@
 /*
- * Copyright 1996-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
-  
+
 /*
  *  Reiser File System constants and structures
  */
@@ -167,8 +168,8 @@
                                    
 
 /* values for sb_mount_state field */
-#define REISERFS_CLEANLY_UMOUNTED    1 /* this was REISERFS_VALID_FS */
-#define REISERFS_NOT_CLEANLY_UMOUNTED    2 /* this was REISERFS_ERROR. It
+#define FS_CLEANLY_UMOUNTED    1 /* this was REISERFS_VALID_FS */
+#define FS_NOT_CLEANLY_UMOUNTED    2 /* this was REISERFS_ERROR. It
                                               means that filesystem was not
                                               cleanly unmounted */
 
@@ -244,9 +245,10 @@
 #define get_sb_v2_inode_generation(sb)		get_le32 (sb, sb_inode_generation)
 #define set_sb_v2_inode_generation(sb,val)	set_le32 (sb, sb_inode_generation, val)
 
-//#define get_sb_v2_flag(sb, flag)	test_bit ((flag), &((struct reiserfs_super_block *)sb)->s_flags)	
-//#define set_sb_v2_flag(sb, flag)	set_bit  ((flag), &((struct reiserfs_super_block *)sb)->s_flags)
-#define get_sb_v2_flag(sb, flag)	(get_le32 (sb, s_flags) & flag)
+#define get_sb_v2_flags(sb)		get_le32 (sb, s_flags)
+#define set_sb_v2_flags(sb, val)	set_le32 (sb, s_flags, val)
+
+#define get_sb_v2_flag(sb, flag)       (get_le32 (sb, s_flags) & flag)
 #define set_sb_v2_flag(sb, flag)	set_le32 (sb, s_flags, get_le32 (sb, s_flags) | flag)
 #define clear_sb_v2_flag(sb, flag)	set_le32 (sb, s_flags, get_le32 (sb, s_flags) & ~(flag))
 
@@ -255,22 +257,20 @@
 */
 
 /* these are possible values for sb_fs_state */
-#define REISERFS_CONSISTENT   0   /* this is set by mkreiserfs and by reiserfsck */
-#define REISERFS_CORRUPTED  0x1   /* this will be set by kernel code when it
-                                   encounters suspicious metadata */
-#define PASS_0_DONE      0xfaa1   /* set by fsck when pass-by-pass (-d),
-                                     REISERFS_CORRUPTED flag included */
-#define PASS_1_DONE      0xfaa3   /* set by fsck when pass-by-pass (-d),
-                                     REISERFS_CORRUPTED flag included */
-#define TREE_IS_BUILT    0xfaa5   /* set by fsck when pass-by-pass (-d),
-                                     REISERFS_CORRUPTED flag included */
-#define SEMANTIC_DONE    0xfaa7   /* set by fsck when pass-by-pass (-d),
-                                     REISERFS_CORRUPTED flag included */
-#define LOST_FOUND_DONE  0xfaa9   /* set by fsck when pass-by-pass (-d),
-                                     REISERFS_CORRUPTED flag included */
-//#define FIX_FIXABLE_IS_ALLOWED 0xfaa7
-
-
+#define FS_CONSISTENT   0x0	    /* this is set by mkreiserfs and by reiserfsck */
+#define FS_ERROR	0x1	    /* this is set by the kernel when fsck is wanted. */
+#define FS_FATAL	0x2	    /* this is set by fsck when fatal corruption is found */
+#define IO_ERROR	0x4	    /* this is set by kernel when io error occures */
+#define PASS_0_DONE     0xfa02	    /* set by fsck when pass-by-pass (-d),
+				       FS_FATAL flag included */
+#define PASS_1_DONE     0xfb02	    /* set by fsck when pass-by-pass (-d),
+                                       FS_FATAL flag included */
+#define TREE_IS_BUILT   0xfc02	    /* set by fsck when pass-by-pass (-d),
+                                       FS_FATAL flag included */
+#define SEMANTIC_DONE   0xfd02	    /* set by fsck when pass-by-pass (-d),
+                                       FS_FATAL flag included */
+#define LOST_FOUND_DONE 0xfe02	    /* set by fsck when pass-by-pass (-d),
+                                       FS_FATAL flag included */
 
 /* struct stat_data* access macros */
 /* v1 */
@@ -462,7 +462,7 @@
 	blocksize * 8 - (block_of_super_block + 1 + 1 + 1)
 
 #define journal_default_size(block_of_super_block,blocksize) \
-	((8192 > journal_max_size (block_of_super_block,blocksize)) ? \
+	(unsigned long long)((8192 > journal_max_size (block_of_super_block,blocksize)) ? \
 		journal_max_size (block_of_super_block,blocksize) : 8192)
 
 //#define JOURNAL_DEFAULT_SIZE 8192  number of blocks in the journal
@@ -555,6 +555,8 @@
 
 #define TYPE_UNKNOWN 15
 
+/* special type for symlink not conflicting to any of item types. */
+#define TYPE_SYMLINK	4
 
 #define KEY_FORMAT_1 0
 #define KEY_FORMAT_2 1
@@ -1062,12 +1064,12 @@
 };
 
 
-#define MAX_HEIGHT 5 /* maximal height of a tree. don't change this without changing JOURNAL_PER_BALANCE_CNT */
-#define EXTENDED_MAX_HEIGHT         7 /* Must be equals MAX_HEIGHT + FIRST_PATH_ELEMENT_OFFSET */
-#define FIRST_PATH_ELEMENT_OFFSET   2 /* Must be equal to at least 2. */
+#define MAX_HEIGHT 6
+#define FIRST_PATH_ELEMENT_OFFSET   2
+#define EXTENDED_MAX_HEIGHT         (MAX_HEIGHT + FIRST_PATH_ELEMENT_OFFSET)
 
-#define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to FIRST_PATH_ELEMENT_OFFSET - 1 */
-#define MAX_FEB_SIZE 6   /* this MUST be MAX_HEIGHT + 1. See about FEB below */
+#define ILLEGAL_PATH_ELEMENT_OFFSET 1
+#define MAX_FEB_SIZE (MAX_HEIGHT + 1)
 
 
 
@@ -1081,9 +1083,9 @@
    in it, especially about decrement_counters_in_path(), to understand
    this structure. */
 struct path {
-  int                   path_length;                      	/* Length of the array above.   */
+  unsigned int          path_length;                      	/* Length of the array above.   */
   struct  path_element  path_elements[EXTENDED_MAX_HEIGHT];	/* Array of the path elements.  */
-  int			pos_in_item;
+  unsigned int		pos_in_item;
 };
 
 #define INITIALIZE_PATH(var) \
@@ -1136,21 +1138,21 @@
 
 
 // search_by_key (and clones) and fix_nodes error code
-#define CARRY_ON          	0
-#define IO_ERROR		3
+#define CARRY_ON		    0
 
-#define NO_DISK_SPACE           4
-#define NO_BALANCING_NEEDED     5
-#define ITEM_FOUND              6
-#define ITEM_NOT_FOUND          7
-#define GOTO_PREVIOUS_ITEM      10
-#define POSITION_FOUND_INVISIBLE 11
-#define FILE_NOT_FOUND          12
+#define NO_DISK_SPACE		    3
+/* #define IO_ERROR		    0x4 - defined above as 0x4 */
+#define NO_BALANCING_NEEDED	    5
+#define ITEM_FOUND		    6
+#define ITEM_NOT_FOUND		    7
+#define GOTO_PREVIOUS_ITEM	    10
+#define POSITION_FOUND_INVISIBLE    11
+#define FILE_NOT_FOUND		    12
 
 // used by fsck
-#define DIRECTORY_NOT_FOUND     13 
-#define REGULAR_FILE_FOUND     14
-#define DIRECTORY_FOUND        15
+#define DIRECTORY_NOT_FOUND	    13 
+#define REGULAR_FILE_FOUND	    14
+#define DIRECTORY_FOUND		    15
 
 
 struct unfm_nodeinfo {
@@ -1167,17 +1169,19 @@
 #define MAX_KEY2_OFFSET  0xfffffffffffffffLL
 
 /* this is aggressive tail suppression policy taken from the kernel */
+/* It should be MAX_DIRECT_ITEM_LEN used here, but sometimes it is not enough,
+ * and items got deleted. */
 #define STORE_TAIL_IN_UNFM(n_file_size,n_tail_size,n_block_size) \
 (\
   (!(n_tail_size)) || \
-  (((n_tail_size) > MAX_DIRECT_ITEM_LEN(n_block_size)) || \
+  (((n_tail_size) > MAX_ITEM_LEN(n_block_size)) || \
    ( (n_file_size) >= (n_block_size) * 4 ) || \
    ( ( (n_file_size) >= (n_block_size) * 3 ) && \
-     ( (n_tail_size) >=   (MAX_DIRECT_ITEM_LEN(n_block_size))/4) ) || \
+     ( (n_tail_size) >=   (MAX_ITEM_LEN(n_block_size))/4) ) || \
    ( ( (n_file_size) >= (n_block_size) * 2 ) && \
-     ( (n_tail_size) >=   (MAX_DIRECT_ITEM_LEN(n_block_size))/2) ) || \
+     ( (n_tail_size) >=   (MAX_ITEM_LEN(n_block_size))/2) ) || \
    ( ( (n_file_size) >= (n_block_size) ) && \
-     ( (n_tail_size) >=   (MAX_DIRECT_ITEM_LEN(n_block_size) * 3)/4) ) ) \
+     ( (n_tail_size) >=   (MAX_ITEM_LEN(n_block_size) * 3)/4) ) ) \
 )
 
 
@@ -1434,7 +1438,7 @@
 #define B_I_STAT_DATA(bh, ih) ( (struct stat_data * )B_I_PITEM(bh,ih) )
 
 #define MAX_DIRECT_ITEM_LEN(size) ((size) - BLKH_SIZE - 2*IH_SIZE - SD_SIZE - UNFM_P_SIZE)
-#define MAX_INDIRECT_ITEM_LEN(size) ((size) - BLKH_SIZE - IH_SIZE)
+#define MAX_INDIRECT_ITEM_LEN(size) MAX_ITEM_LEN(size)
 
 /* indirect items consist of entries which contain blocknrs, pos
    indicates which entry, and B_I_POS_UNFM_POINTER resolves to the
@@ -1532,7 +1536,7 @@
 struct buffer_head * get_FEB (struct tree_balance *);
 
 
-__u64 get_bytes_number (struct item_head * ih, int blocksize);
+__u32 get_bytes_number (struct item_head * ih, int blocksize);
 
 
 
@@ -1545,9 +1549,9 @@
 
 
 /* node_format.c */
-int get_journal_old_start_must (reiserfs_filsys_t * fs);
-int get_journal_new_start_must (reiserfs_filsys_t * fs);
-int get_journal_start_must (reiserfs_filsys_t * fs);
+extern unsigned int get_journal_old_start_must (reiserfs_filsys_t * fs);
+extern unsigned int get_journal_new_start_must (reiserfs_filsys_t * fs);
+extern unsigned int get_journal_start_must (reiserfs_filsys_t * fs);
 /*extern hashf_t hashes [];*/
 
 
diff --git a/include/reiserfs_lib.h b/include/reiserfs_lib.h
index a3c30ef..899563f 100644
--- a/include/reiserfs_lib.h
+++ b/include/reiserfs_lib.h
@@ -1,5 +1,6 @@
 /*
- *  Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ *  Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ *  reiserfsprogs/README
  */
 
 #ifndef REISERFS_LIB_H
@@ -24,7 +25,7 @@
 typedef __u32 (*hashf_t) (const char *, int);
 
 struct reiserfs_filsys {
-    int fs_blocksize;
+    unsigned int fs_blocksize;
     int fs_format;	      /* on-disk format version */
     hashf_t fs_hash_function; /* pointer to function which is used to sort
 				 names in directory. It is set by
@@ -76,7 +77,7 @@
 
 void init_tb_struct (struct tree_balance * tb, reiserfs_filsys_t *, struct path * path, int size);
 
-reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int * error, void * vp);
+reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int * error, void * vp, int skip_check);
 reiserfs_filsys_t * reiserfs_create (char * filename, int version, unsigned long block_count,
 				     int block_size, int default_journal, int new_format);
 void reiserfs_flush (reiserfs_filsys_t *);
@@ -92,7 +93,7 @@
 void reiserfs_free_bitmap_blocks (reiserfs_filsys_t *);
 */
 int no_reiserfs_found (reiserfs_filsys_t *);
-int is_block_count_correct (unsigned long block_of_super_block, int block_size,
+int is_block_count_correct (unsigned long block_of_super_block, unsigned int block_size,
 	unsigned long block_count, unsigned long journal_size);
 //unsigned long min_block_amount (int block_size, unsigned long journal_size);
 unsigned long get_size_of_journal_or_reserved_area (struct reiserfs_super_block * sb);
@@ -113,9 +114,9 @@
 int reiserfs_locate_entry (reiserfs_filsys_t *, struct key * dir, char * name,
 			   struct path * path);
 int reiserfs_find_entry (reiserfs_filsys_t *, struct key * dir, char * name,
-			 int * min_gen_counter, struct key * key);
+			 unsigned int * min_gen_counter, struct key * key);
 int reiserfs_add_entry (reiserfs_filsys_t *, struct key * dir, char * name, int name_len,
-			struct key * key, int fsck_need);
+			struct key * key, __u16 fsck_need);
 
 
 /*int reiserfs_bin_search (void * key, void * base, int num, int width,
@@ -180,8 +181,8 @@
 /*int reiserfs_flush_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t *);*/
 void reiserfs_bitmap_zero (reiserfs_bitmap_t * bm);
 void reiserfs_bitmap_fill (reiserfs_bitmap_t * bm);
-int reiserfs_bitmap_ones (reiserfs_bitmap_t * bm);
-int reiserfs_bitmap_zeros (reiserfs_bitmap_t * bm);
+unsigned int reiserfs_bitmap_ones (reiserfs_bitmap_t * bm);
+unsigned int reiserfs_bitmap_zeros (reiserfs_bitmap_t * bm);
 
 FILE * open_file(char * filename, char * option);
 void close_file(FILE * fp);
@@ -210,8 +211,7 @@
 #define HAS_IH_ARRAY 5
 #define THE_UNKNOWN 6
 
-int correct_direct_item_offset (__u64 offset, int format);
-int is_blocksize_correct (int blocksize);
+int is_blocksize_correct (unsigned int blocksize);
 int is_reiserfs_3_5_magic_string (struct reiserfs_super_block * rs);
 int is_reiserfs_3_6_magic_string (struct reiserfs_super_block * rs);
 int is_reiserfs_jr_magic_string (struct reiserfs_super_block * rs);
@@ -222,6 +222,12 @@
 /*int magic_2_version (struct reiserfs_super_block * rs);*/
 int is_prejournaled_reiserfs (struct reiserfs_super_block * rs);
 int who_is_this (char * buf, int blocksize);
+
+int leaf_count_ih(char * buf, int blocksize);
+int leaf_free_space_estimate(char * buf, int blocksize);
+int is_a_leaf(char * buf, int blocksize);
+int leaf_item_number_estimate(struct buffer_head * bh);
+
 char * which_block (int code);
 int get_journal_size (reiserfs_filsys_t *);
 int not_data_block (reiserfs_filsys_t *, unsigned long block);
@@ -249,7 +255,7 @@
 void for_every_item (struct buffer_head * bh, item_head_action_t action,
 		     item_action_t * actions);
 int key_format (const struct key * key);
-loff_t get_offset (const struct key * key);
+unsigned long long get_offset (const struct key * key);
 int uniqueness2type (__u32 uniqueness);
 __u32 type2uniqueness (int type);
 int get_type (const struct key * key);
@@ -263,19 +269,16 @@
 typedef int (*check_unfm_func_t) (reiserfs_filsys_t *, __u32);
 int is_it_bad_item (reiserfs_filsys_t *, struct item_head *, char *,
 		    check_unfm_func_t, int bad_dir);
-int does_node_have_ih_array (char * buf, int blocksize);
-
-
 
 #define hash_func_is_unknown(fs) ((fs)->fs_hash_function == 0)
 #define reiserfs_hash(fs) ((fs)->fs_hash_function)
 
 int known_hashes (void);
-char * code2name (int code);
+char *code2name (unsigned int code);
 int func2code (hashf_t func);
-hashf_t code2func (int code);
+hashf_t code2func (unsigned int code);
 hashf_t name2func (char * hash);
-int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, int code_to_try_first);
+int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, unsigned int code_to_try_first);
 
 int entry_length (struct item_head * ih, struct reiserfs_de_head * deh,
 		  int pos_in_item);
@@ -330,14 +333,14 @@
 void for_each_transaction (reiserfs_filsys_t *, action_on_trans_t);
 
 typedef void (*action_on_block_t) (reiserfs_filsys_t *, reiserfs_trans_t *,
-				   int index,
+				   unsigned int index,
 				   unsigned long in_journal,
 				   unsigned long in_place);
 void for_each_block (reiserfs_filsys_t * fs, reiserfs_trans_t * trans,
 		     action_on_block_t action);
 
-void reiserfs_only_reopen (reiserfs_filsys_t * fs, int flag);
 int reiserfs_open_journal (reiserfs_filsys_t *, char *, int flags);
+int reiserfs_journal_params_check(reiserfs_filsys_t *fs);
 int reiserfs_create_journal (reiserfs_filsys_t * fs, char * j_filename,
 			     unsigned long offset, unsigned long len, 
 			     int transaction_max_size);
@@ -349,7 +352,7 @@
 __u32 advise_journal_max_trans_age (void);
 __u32 advise_journal_max_commit_age (void);
 __u32 advise_journal_max_batch (unsigned long journal_trans_max);
-__u32 advise_journal_max_trans_len (__u32 desired, __u32 journal_size, int blocksize);
+__u32 advise_journal_max_trans_len (__u32 desired, __u32 journal_size, int blocksize, int verbose);
 
 
 
diff --git a/include/stamp-h.in b/include/stamp-h.in
deleted file mode 100644
index 9788f70..0000000
--- a/include/stamp-h.in
+++ /dev/null
@@ -1 +0,0 @@
-timestamp
diff --git a/include/swab.h b/include/swab.h
index 35e3e80..3a77716 100644
--- a/include/swab.h
+++ b/include/swab.h
@@ -1,8 +1,24 @@
 /*
- *  Copyright 2002 by Hans Reiser, licensing governed by reiserfs/README
+ *  Copyright 2002-2003 by Hans Reiser, licensing governed by 
+ *  reiserfsprogs/README
  */
+
 #ifndef _REISERFS_SWAB_H_
 #define _REISERFS_SWAB_H_
 
+#include <endian.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+
+#define extern static
+#define __BYTEORDER_HAS_U64__
 #include <linux/byteorder/swab.h>
+#undef extern
+
+#else
+
+#include <linux/byteorder/swab.h>
+
+#endif
+
 #endif /* _REISERFS_SWAB_H_ */
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 3fcac5c..8322bb3 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,251 +12,348 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 noinst_LIBRARIES = libmisc.a
 
 libmisc_a_SOURCES = io.c misc.c 
+subdir = lib
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../include/config.h
-CONFIG_CLEAN_FILES = 
-LIBRARIES =  $(noinst_LIBRARIES)
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
 
+libmisc_a_AR = $(AR) cru
+libmisc_a_LIBADD =
+am_libmisc_a_OBJECTS = io.$(OBJEXT) misc.$(OBJEXT)
+libmisc_a_OBJECTS = $(am_libmisc_a_OBJECTS)
 
-DEFS = @DEFS@ -I. -I$(srcdir) -I../include
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-libmisc_a_LIBADD = 
-libmisc_a_OBJECTS =  io.o misc.o
-AR = ar
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/io.Po ./$(DEPDIR)/misc.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(libmisc_a_SOURCES)
+DIST_COMMON = Makefile.am Makefile.in
 SOURCES = $(libmisc_a_SOURCES)
-OBJECTS = $(libmisc_a_OBJECTS)
 
-all: all-redirect
+all: all-am
+
 .SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps lib/Makefile
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  lib/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-noinstLIBRARIES:
+AR = ar
 
 clean-noinstLIBRARIES:
 	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
-
-distclean-noinstLIBRARIES:
-
-maintainer-clean-noinstLIBRARIES:
-
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
+libmisc.a: $(libmisc_a_OBJECTS) $(libmisc_a_DEPENDENCIES) 
+	-rm -f libmisc.a
+	$(libmisc_a_AR) libmisc.a $(libmisc_a_OBJECTS) $(libmisc_a_LIBADD)
+	$(RANLIB) libmisc.a
 
 mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
+	-rm -f *.$(OBJEXT) core *.core
 
 distclean-compile:
 	-rm -f *.tab.c
 
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@
 
-libmisc.a: $(libmisc_a_OBJECTS) $(libmisc_a_DEPENDENCIES)
-	-rm -f libmisc.a
-	$(AR) cru libmisc.a $(libmisc_a_OBJECTS) $(libmisc_a_LIBADD)
-	$(RANLIB) libmisc.a
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
+
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = lib
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-io.o: io.c ../include/io.h ../include/misc.h ../include/swab.h \
-	../include/config.h
-misc.o: misc.c ../include/swab.h ../include/io.h ../include/misc.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
+all-am: Makefile $(LIBRARIES)
 
-install-data-am:
+installdirs:
+
+install: install-am
+install-exec: install-exec-am
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile $(LIBRARIES)
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-noinstLIBRARIES mostlyclean-compile \
-		mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
-		mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-noinstLIBRARIES distclean-compile \
-		distclean-tags distclean-generic clean-am
+clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-noinstLIBRARIES \
-		maintainer-clean-compile maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
-clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-noinstLIBRARIES ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-info-am
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lib/io.c b/lib/io.c
index 8c0b621..8701db6 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 1996-2002 Hans Reiser, see reiserfs/README for licensing and copyright details
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #define _GNU_SOURCE
 
 #include <stdio.h>
@@ -20,15 +22,28 @@
 
 void check_memory_msg (void) {
     fprintf(stderr, 
-	"\nThe problem has occurred looks like a hardware problem. Send us the bug\n"
-	"report only if the second run dies at the same place with the same block\n"
-	"number.\n");
+	"\nThe problem has occurred looks like a hardware problem (perhaps memory).\n"
+        "Send us the bug report only if the second run dies at the same place with\n"
+        "the same block number.\n");
 }
 
 void check_hd_msg (void) {
     fprintf(stderr, 
 	"\nThe problem has occurred looks like a hardware problem.\n"
-	"Check your hard drive for badblocks.\n");
+	"If you have bad blocks, we advise you to get a new hard\n"
+	"drive, because once you get one bad block that the disk\n"
+        "drive internals cannot hide from your sight, the chances\n"
+        "of getting more are generally said to become much higher\n"
+        "(precise statistics are unknown to us), and this disk drive\n"
+        "is probably not expensive enough for you to risk your time\n"
+        "and data on it. If you don't want to follow that advice,\n"
+        "then if you have just a few bad blocks, try writing to the\n"
+        "bad blocks and see if the drive remaps the bad blocks (that\n"
+        "means it takes a block it has in reserve and allocates it\n"
+        "for use for requests of that block number).  If it cannot\n"
+        "remap the block, this could be quite bad, as it may mean\n"
+        "that so many blocks have gone bad that none remain in \n"
+	"reserve to allocate.\n");
 }
 
 static int is_bad_block (unsigned long block)
@@ -74,7 +89,7 @@
 **
 */
 #define BUFFER_SOFT_LIMIT (500 * 1024)
-static int buffer_soft_limit = BUFFER_SOFT_LIMIT;
+static unsigned long buffer_soft_limit = BUFFER_SOFT_LIMIT;
 
 
 #define NR_HASH_QUEUES 4096
@@ -89,8 +104,7 @@
 
 
 
-static void _show_buffers(struct buffer_head **list, int dev, int size)
-{
+static void _show_buffers(struct buffer_head **list, int dev, unsigned long size) {
     int all = 0;
     int dirty = 0;
     int in_use = 0; /* count != 0 */
@@ -119,8 +133,8 @@
 	    break;
     }
 
-    printf ("show_buffers (dev %d, size %d): free %d, count != 0 %d, dirty %d, all %d\n",
-	dev, size, free, in_use, dirty, all);
+    printf("show_buffers (dev %d, size %lu): free %d, count != 0 %d, dirty %d, "
+	"all %d\n", dev, size, free, in_use, dirty, all);
 }
 
 
@@ -149,7 +163,7 @@
 static void remove_from_hash_queue (struct buffer_head * bh)
 {
     if (bh->b_hash_next == 0 && bh->b_hash_prev == 0 && bh != g_a_hash_queues[bh->b_blocknr % NR_HASH_QUEUES])
-	/* (b_dev == 0) ? */
+	/* (b_dev == -1) ? */
 	return;
 
     if (bh == g_a_hash_queues[bh->b_blocknr % NR_HASH_QUEUES]) {
@@ -226,7 +240,7 @@
 	addr = mmap (0, len, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 	if (addr == MAP_FAILED) {
 	    if (errno != ENOMEM)
-		die ("mmap failed: %m\n");
+		die ("mmap failed: %s\n", strerror(errno));
 	    break;
 	}
 	if (mlock (addr, len) != 0) {
@@ -278,7 +292,7 @@
 	tmp->b_data = getmem (size);
 	if (tmp->b_data == 0)
 	    die ("grow_buffers: no memory for new buffer data");
-	tmp->b_dev = 0;
+	tmp->b_dev = -1;
 	tmp->b_size = size;
 	put_buffer_list_head (&g_free_buffers, tmp);
     }
@@ -288,7 +302,7 @@
 }
 
 
-struct buffer_head * find_buffer (int dev, unsigned long block, int size)
+struct buffer_head *find_buffer(int dev, unsigned long block, unsigned long size)
 {		
     struct buffer_head * next;
 
@@ -308,7 +322,7 @@
 
 
 static struct buffer_head * get_free_buffer (struct buffer_head **list,
-                                             int size)
+                                             unsigned long size)
 {
     struct buffer_head * next;
 
@@ -334,8 +348,7 @@
 
 /* to_write == 0 when all blocks have to be flushed. Otherwise - write only
    buffers with b_count == 0 */
-static int sync_buffers (struct buffer_head **list, dev_t dev, int to_write)
-{
+static int sync_buffers (struct buffer_head **list, int dev, int to_write) {
     struct buffer_head * next;
     int written = 0;
 
@@ -376,10 +389,11 @@
 }
 
 
-void flush_buffers (dev_t dev)
+void flush_buffers (int dev)
 {
-    if (!dev)
-	die ("flush_buffers: device is not specifed");
+    if (dev == -1)
+	die ("flush_buffers: device is not specified");
+
     sync_buffers (&Buffer_list_head, dev, 0/*all*/);
     buffer_soft_limit = BUFFER_SOFT_LIMIT;
 }
@@ -428,8 +442,8 @@
     bh->b_blocknr = block;
     bh->b_end_io = NULL ;
     memset (bh->b_data, 0, size);
-    clear_bit(BH_Dirty, &bh->b_state);
-    clear_bit(BH_Uptodate, &bh->b_state);
+    misc_clear_bit(BH_Dirty, &bh->b_state);
+    misc_clear_bit(BH_Uptodate, &bh->b_state);
 
     put_buffer_list_end (&Buffer_list_head, bh);
     insert_into_hash_queue (bh);
@@ -443,9 +457,9 @@
 {
     if (bh == 0)
 	return;
-    if (bh->b_count == 0) {
+    
+    if (bh->b_count == 0)
 	die ("brelse: can not free a free buffer %lu", bh->b_blocknr);
-    }
     
     /*checkmem (bh->b_data, get_mem_size (bh->b_data));*/
     
@@ -460,36 +474,32 @@
 	brelse (bh);
 	remove_from_hash_queue (bh);
 	remove_from_buffer_list(&Buffer_list_head, bh);
-	if (bh->b_count == 0)
-	    put_buffer_list_head(&g_free_buffers, bh);
-	else
-	    put_buffer_list_head(&Buffer_list_head, bh);
+	put_buffer_list_head(&Buffer_list_head, bh);
     }
 }
 
-
+/* Returns 0 on success; 1 - end of file; 0 - OK. */
 static int f_read(struct buffer_head * bh)
 {
-    loff_t offset;
+    unsigned long long offset;
     ssize_t bytes;
 
     buffer_reads++ ;
 
-    offset = (loff_t)bh->b_size * (loff_t)bh->b_blocknr;
-    if (lseek64 (bh->b_dev, offset, SEEK_SET) == (loff_t)-1)
-	return 0;
+    offset = (unsigned long long)bh->b_size * bh->b_blocknr;
+    if (lseek64 (bh->b_dev, offset, SEEK_SET) < 0)
+	return -1;
 
     bytes = read (bh->b_dev, bh->b_data, bh->b_size);
-    if (bytes != (ssize_t)bh->b_size)
-	return 0;
-
-    return 1;
+    
+    return bytes < 0 ? -1 : (bytes != (ssize_t)bh->b_size ? 1 : 0);
 }
 
 
 struct buffer_head * bread (int dev, unsigned long block, size_t size)
 {
     struct buffer_head * bh;
+    int ret;
 
     if (is_bad_block (block))
 	return 0;
@@ -501,13 +511,25 @@
     if (buffer_uptodate (bh))
 	return bh;
 
-    if (f_read(bh) == 0 || is_bad_block (block)) {
-/*      BAD BLOCK LIST SUPPORT
-    	die ("%s: Cannot read a block # %lu. Specify list of badblocks\n",*/
-	check_hd_msg();
-    	die ("%s: Cannot read the block (%lu).\n", __FUNCTION__, bh->b_blocknr);
-    }
+    ret = f_read(bh);
+    
+    if (ret > 0)
+	die ("%s: End of file, cannot read the block (%lu).\n", __FUNCTION__, bh->b_blocknr);
+    else if (ret < 0) {
+	/* BAD BLOCK LIST SUPPORT
+	 * die ("%s: Cannot read a block # %lu. Specify list of badblocks\n",*/
 
+	if (errno == EIO) {
+	    check_hd_msg();
+	    die ("%s: Cannot read the block (%lu): (%s).\n", __FUNCTION__, 
+		bh->b_blocknr, strerror(errno));
+	} else	{
+	    fprintf (stderr, "%s: Cannot read the block (%lu): (%s).\n", __FUNCTION__, 
+		bh->b_blocknr, strerror(errno));
+	    return NULL;
+	}
+    }
+       
     mark_buffer_uptodate (bh, 0);
     return bh;
 }
@@ -554,7 +576,7 @@
     
     s_rollback_file = fopen (rollback_file, "w+");    
     if (s_rollback_file == NULL) {
-	fprintf (stderr, "Cannot create file %s, work w/out a rollback file\n", rollback_file);
+	fprintf (stderr, "Cannot create file %s, work without a rollback file\n", rollback_file);
         return;
     }
 
@@ -738,8 +760,9 @@
         }
         
         if (write (descriptor, rollback_data, rollback_blocksize) == -1) {
-            fprintf (stderr, "rollback: write %d bytes returned error (block=%Ld, dev=%Ld): %s\n",
-		rollback_blocksize, (long long)offset/rollback_blocksize, (long long)b_dev, strerror (errno));
+            fprintf (stderr, "rollback: write %d bytes returned error "
+		"(block=%lld, dev=%lld): %s\n", rollback_blocksize, 
+		offset/rollback_blocksize, b_dev, strerror (errno));
             count_failed ++;
         } else {
             count_rollbacked ++;
@@ -781,9 +804,8 @@
 /* for now - just make sure that bad blocks did not get here */
 int bwrite (struct buffer_head * bh)
 {
-    loff_t offset;
-    ssize_t bytes;
-    size_t size;
+    unsigned long long offset;
+    long long bytes, size;
 
     if (is_bad_block (bh->b_blocknr)) {
 	fprintf (stderr, "bwrite: bad block is going to be written: %lu\n",
@@ -803,12 +825,12 @@
     offset = (loff_t)size * (loff_t)bh->b_blocknr;
 
     if (lseek64 (bh->b_dev, offset, SEEK_SET) == (loff_t)-1){
-	fprintf (stderr, "bwrite: lseek to position %Ld (block=%lu, dev=%d): %s\n",
-		 (long long)offset, bh->b_blocknr, bh->b_dev, strerror (errno));
+	fprintf (stderr, "bwrite: lseek to position %llu (block=%lu, dev=%d): %s\n",
+	    offset, bh->b_blocknr, bh->b_dev, strerror(errno));
 	exit(8); /* File system errors left uncorrected */
     }
 
-    if (s_rollback_file != NULL && bh->b_size == rollback_blocksize) {
+    if (s_rollback_file != NULL && bh->b_size == (unsigned long)rollback_blocksize) {
         struct stat64 buf;
         __u32 position;
 	struct block_handler block_h;
@@ -817,47 +839,54 @@
         if (!fstat64 (bh->b_dev, &buf)) {
 	    block_h.blocknr = bh->b_blocknr;
 	    block_h.device = buf.st_rdev;
-	    if (reiserfs_bin_search (&block_h, rollback_blocks_array, rollback_blocks_number,
-		sizeof (block_h), &position, blockdev_list_compare) != POSITION_FOUND) {
+	    if (reiserfs_bin_search(&block_h, rollback_blocks_array, 
+				    rollback_blocks_number, sizeof (block_h), 
+				    &position, blockdev_list_compare)
+		!= POSITION_FOUND)
+	    {
                 /*read initial data from the disk*/
-                if (read (bh->b_dev, rollback_data, bh->b_size) == bh->b_size) {
-                    fwrite (&buf.st_rdev, sizeof (buf.st_rdev), 1, s_rollback_file);
-                    fwrite (&offset, sizeof (offset), 1, s_rollback_file);
-                    fwrite (rollback_data, rollback_blocksize, 1, s_rollback_file);
+                if (read(bh->b_dev, rollback_data, bh->b_size) == (long long)bh->b_size) {
+                    fwrite(&buf.st_rdev, sizeof (buf.st_rdev), 1, s_rollback_file);
+                    fwrite(&offset, sizeof (offset), 1, s_rollback_file);
+                    fwrite(rollback_data, rollback_blocksize, 1, s_rollback_file);
                     fflush(s_rollback_file);
-                    blocklist__insert_in_position(&block_h, (void **)&rollback_blocks_array, 
+                    blocklist__insert_in_position(&block_h, (void *)(&rollback_blocks_array),
 			&rollback_blocks_number, sizeof(block_h), &position);
+		    
                     /*if you want to know what gets saved, uncomment it*/
 /*                    if (log_file != 0 && log_file != stdout) {
-                        fprintf (log_file, "rollback: block %lu of device %Lu was backed up\n", 
-                                bh->b_blocknr, buf.st_rdev);
+                        fprintf (log_file, "rollback: block %lu of device %Lu was "
+			    "backed up\n", bh->b_blocknr, buf.st_rdev);
                     }
 */
                     
                 } else {
-                    fprintf (stderr, "bwrite: read (block=%lu, dev=%d): %s\n", bh->b_blocknr,
-                    		bh->b_dev, strerror (errno));
+                    fprintf (stderr, "bwrite: read (block=%lu, dev=%d): %s\n", 
+			bh->b_blocknr, bh->b_dev, strerror (errno));
                     exit(8);
                 }
+		
                 if (lseek64 (bh->b_dev, offset, SEEK_SET) == (loff_t)-1) {
-                    fprintf (stderr, "bwrite: lseek to position %Ld (block=%lu, dev=%d): %s\n",
-        		 (long long)offset, bh->b_blocknr, bh->b_dev, strerror (errno));
+                    fprintf (stderr, "bwrite: lseek to position %llu (block=%lu, "
+			"dev=%d): %s\n", offset, bh->b_blocknr, bh->b_dev, 
+			strerror(errno));
                     exit(8);
                 }
             }
         } else {
-            fprintf (stderr, "bwrite: fstat of (%d) returned -1: %s\n", bh->b_dev, 
-		strerror(errno));
+            fprintf (stderr, "bwrite: fstat of (%d) returned -1: %s\n", 
+		bh->b_dev, strerror(errno));
         }
     } else if (s_rollback_file != NULL) {
-	fprintf (stderr, "rollback: block (%lu) has the size different from the fs uses, "
-	    "block skipped\n",	bh->b_blocknr);
+	fprintf (stderr, "rollback: block (%lu) has the size different from "
+	    "the fs uses, block skipped\n", bh->b_blocknr);
     }
     
-    bytes = write (bh->b_dev, bh->b_data, size);
-    if (bytes != (ssize_t)size) {
-	fprintf (stderr, "bwrite: write %ld bytes returned %ld (block=%ld, dev=%d): %s\n",
-		(long)size, (long)bytes, bh->b_blocknr, bh->b_dev, strerror (errno));
+    bytes = write(bh->b_dev, bh->b_data, size);
+    if (bytes != size) {
+	fprintf (stderr, "bwrite: write %lld bytes returned %lld (block=%ld, "
+	    "dev=%d): %s\n", size, bytes, bh->b_blocknr, bh->b_dev, 
+	    strerror(errno));
 	exit(8);
     }
 
@@ -879,12 +908,13 @@
 
     for(;;) {
 	if (next->b_count != 0)
-	    fprintf (stderr, "check_and_free_buffer_mem: not free buffer (%x, %ld, %ld, %d)\n",
-		     next->b_dev, next->b_blocknr, next->b_size, next->b_count);
+	    fprintf (stderr, "check_and_free_buffer_mem: not free buffer "
+		"(%d, %ld, %ld, %d)\n", next->b_dev, next->b_blocknr, 
+		next->b_size, next->b_count);
 
 	if (buffer_dirty (next) && buffer_uptodate (next))
-	    fprintf (stderr, "check_and_free_buffer_mem: dirty buffer (%x %lu) found\n",
-		     next->b_dev, next->b_blocknr);
+	    fprintf (stderr, "check_and_free_buffer_mem: dirty buffer "
+		"(%d %lu) found\n", next->b_dev, next->b_blocknr);
 
 	freemem (next->b_data);
 	count++;
@@ -895,7 +925,7 @@
     return count;
 }
 
-void check_and_free_buffer_mem (void)
+static void check_and_free_buffer_mem (void)
 {
     int count = 0;
     struct buffer_head * next ;
@@ -927,7 +957,7 @@
 }
 
 
-static void _invalidate_buffer_list(struct buffer_head *list, dev_t dev)
+static void _invalidate_buffer_list(struct buffer_head *list, int dev)
 {
     struct buffer_head * next;
 
@@ -951,7 +981,7 @@
 }
 
 /* forget all buffers of the given device */
-void invalidate_buffers (dev_t dev)
+void invalidate_buffers (int dev)
 {
     _invalidate_buffer_list(Buffer_list_head, dev) ;
     _invalidate_buffer_list(g_free_buffers, dev) ;
@@ -964,7 +994,7 @@
     size_t n = 0;
 
     fprintf (fp, "%s", q);
-    if (getline (&answer, &n, stdin) != strlen (yes) || strcmp (yes, answer))
+    if (getline (&answer, &n, stdin) != (ssize_t)strlen (yes) || strcmp (yes, answer))
 	return 0;
 
     return 1;
diff --git a/lib/misc.c b/lib/misc.c
index fbb2f61..6f43736 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 /* for stat64() */
@@ -22,14 +23,12 @@
 #include <linux/hdreg.h>
 #include <dirent.h>
 
+#include <asm/ioctl.h>
 #include <unistd.h>
-//#include <linux/unistd.h>
-//#include <sys/stat.h>
 
 #if defined(__linux__) && defined(_IOR) && !defined(BLKGETSIZE64)
 #   define BLKGETSIZE64 _IOR(0x12, 114, sizeof(__u64))
 #endif
-    
 
 #include "swab.h"
 
@@ -61,11 +60,10 @@
 #define CONTROL_SIZE (strlen (MEM_BEGIN) + 1 + sizeof (int) + strlen (MEM_END) + 1)
 
 
-int get_mem_size (char * p)
-{
-    char * begin;
-
-    begin = p - strlen (MEM_BEGIN) - 1 - sizeof (int);
+unsigned int get_mem_size(char *p) {
+    char *begin;
+    
+    begin = p - strlen (MEM_BEGIN) - 1 - sizeof(int);
     return *(int *)(begin + strlen (MEM_BEGIN) + 1);
 }
 
@@ -88,8 +86,20 @@
 }
 
 
-void * getmem (int size)
+void *getmem (int size)
 {
+    char * mem;
+
+    if ((mem = mem_alloc(size)) == NULL)
+	die ("getmem: no more memory (%d)", size);
+    
+    memset (mem, 0, size);
+//    checkmem (mem, size);
+
+    return mem;
+}
+
+void *mem_alloc(int size) {
     char * p;
     char * mem;
 
@@ -97,21 +107,19 @@
     if (!p)
 	die ("getmem: no more memory (%d)", size);
 
+    /* Write the MEM_BEGIN magic in the beginning of allocated memory. */
     strcpy (p, MEM_BEGIN);
     p += strlen (MEM_BEGIN) + 1;
+    /* Write the size after the magic. */
     *(int *)p = size;
     p += sizeof (int);
     mem = p;
-    memset (mem, 0, size);
     p += size;
     strcpy (p, MEM_END);
 
-//    checkmem (mem, size);
-
     return mem;
 }
 
-
 void * expandmem (void * vp, int size, int by)
 {
     int allocated;
@@ -250,7 +258,7 @@
     mode_t mode;
 
     if (stat ("/", &root_st) == -1)
-	die ("is_mounted: could not stat \"/\": %m\n");
+	die ("is_mounted: could not stat \"/\": %s\n", strerror(errno));
 
 
     mode = get_st_mode (device_name);
@@ -272,11 +280,12 @@
 	/* proc filesystem is not mounted, or /proc/mounts does not
            exist */
 	if (f)
-	    return (user_confirmed (stderr, " (could not figure out) Is filesystem mounted read-only? (Yes)",
-				    "Yes\n"));
+	    return (user_confirmed (stderr, 
+		" (could not figure out) Is filesystem mounted read-only? (Yes)",
+		"Yes\n"));
 	else
-	    return (user_confirmed (stderr, " (could not figure out) Is filesystem mounted? (Yes)",
-				    "Yes\n"));
+	    return (user_confirmed (stderr, 
+		" (could not figure out) Is filesystem mounted? (Yes)", "Yes\n"));
     }
     
     retval = 0;
@@ -366,7 +375,7 @@
 
 void print_how_far (FILE * fp,
 		    unsigned long * passed, unsigned long total,
-		    int inc, int quiet)
+		    unsigned int inc, int quiet)
 {
     int percent;
 
@@ -390,9 +399,10 @@
 
     strcat (current_progress, progress_to_be + strlen (current_progress));
 
-    if (!quiet)
-	print_how_fast (*passed/* - inc*/, total, strlen (progress_to_be),
-			(*passed == inc) ? 1 : 0);
+    if (!quiet) {
+	print_how_fast(*passed /* - inc*/, total, strlen (progress_to_be),
+	    (*passed == inc) ? 1 : 0);
+    }
 
     fflush (fp);
 }
@@ -419,10 +429,11 @@
 #ifdef BLKGETSIZE64
     {
 	if (ioctl (fd, BLKGETSIZE64, &size) >= 0) {
+	    size = (size / 4096) * 4096 / blocksize;
 	    sz = size;
 	    if ((__u64)sz != size)
 		    die ("count_blocks: block device too large");
-	    return (size / 4096) * 4096 / blocksize;
+	    return sz;
 	}
     }
 #endif
@@ -580,8 +591,8 @@
     return 0;
 }
 */
-void blocklist__insert_in_position (void *elem, void **base, __u32 *count, int elem_size, 
-    __u32 * position) 
+void blocklist__insert_in_position (void *elem, void **base, __u32 *count, 
+    int elem_size, __u32 *position) 
 {
     if (elem_size == 0)
     	return;
@@ -589,7 +600,7 @@
     if (*base == NULL)
         *base = getmem (BLOCKLIST__ELEMENT_NUMBER * elem_size);
     
-    if (*count == get_mem_size ((void *)*base) / elem_size)
+    if (*count == get_mem_size((void *)*base) / elem_size)
         *base = expandmem (*base, get_mem_size((void *)*base), 
                         BLOCKLIST__ELEMENT_NUMBER * elem_size);
     
@@ -643,11 +654,11 @@
     if (i == 16)
 	return 0;
 
-    if (!test_bit(7, &uuid[8]) || test_bit(6, &uuid[8]))
+    if (!misc_test_bit(7, &uuid[8]) || misc_test_bit(6, &uuid[8]))
     	return 0;
 
-    if (test_bit(7, &uuid[6]) || !test_bit(6, &uuid[6]) ||
-    	test_bit(5, &uuid[6]) ||  test_bit(4, &uuid[6]))
+    if (misc_test_bit(7, &uuid[6]) || !misc_test_bit(6, &uuid[6]) ||
+    	misc_test_bit(5, &uuid[6]) ||  misc_test_bit(4, &uuid[6]))
     	return 0;
     	
     return 1;
@@ -822,3 +833,151 @@
     if (dma_info->fd && fd != dma_info->fd)
 	close(dma_info->fd);
 }
+
+/* Only le bitops operations are used. */
+
+inline int misc_set_bit (unsigned long long nr, void * addr) {
+    __u8 * p, mask;
+    int retval;
+
+    p = (__u8 *)addr;
+    p += nr >> 3;
+    mask = 1 << (nr & 0x7);
+    /*cli();*/
+    retval = (mask & *p) != 0;
+    *p |= mask;
+    /*sti();*/
+    return retval;
+}
+
+
+inline int misc_clear_bit (unsigned long long nr, void * addr) {
+    __u8 * p, mask;
+    int retval;
+
+    p = (__u8 *)addr;
+    p += nr >> 3;
+    mask = 1 << (nr & 0x7);
+    /*cli();*/
+    retval = (mask & *p) != 0;
+    *p &= ~mask;
+    /*sti();*/
+    return retval;
+}
+
+inline int misc_test_bit(unsigned long long nr, const void * addr) {
+    __u8 * p, mask;
+
+    p = (__u8 *)addr;
+    p += nr >> 3;
+    mask = 1 << (nr & 0x7);
+    return ((mask & *p) != 0);
+}
+
+inline unsigned long long misc_find_first_zero_bit (const void *vaddr, 
+    unsigned long long size) 
+{
+    const __u8 *p = vaddr, *addr = vaddr;
+    unsigned long long res;
+
+    if (!size)
+        return 0;
+
+    size = (size >> 3) + ((size & 0x7) > 0);
+    while (*p++ == 255) {
+        if (--size == 0)
+            return (unsigned long long)(p - addr) << 3;
+    }
+
+    --p;
+    for (res = 0; res < 8; res++)
+        if (!misc_test_bit (res, p))
+            break;
+    return res + (p - addr) * 8;
+}
+
+
+inline unsigned long long misc_find_next_zero_bit (const void *vaddr, 
+    unsigned long long size, unsigned long long offset) 
+{
+    const __u8 *addr = vaddr;
+    const __u8 *p = addr + (offset >> 3);
+    int bit = offset & 7;
+    unsigned long long res;
+
+    if (offset >= size)
+        return size;
+
+    if (bit) {
+        /* Look for zero in first char */
+        for (res = bit; res < 8; res++)
+            if (!misc_test_bit (res, p))
+                return res + (p - addr) * 8;
+        p++;
+    }
+    /* No zero yet, search remaining full bytes for a zero */
+    res = misc_find_first_zero_bit (p, size - 8 * (p - addr));
+    return res + (p - addr) * 8;
+}
+
+inline unsigned long long misc_find_first_set_bit (const void *vaddr, 
+    unsigned long long size) 
+{
+    const __u8 *p = vaddr, *addr = vaddr;
+    unsigned long long res;
+
+    if (!size)
+        return 0;
+
+    size = (size >> 3) + ((size & 0x7) > 0);
+    while (*p++ == 0) {
+        if (--size == 0)
+            return (unsigned long long)(p - addr) << 3;
+    }
+
+    --p;
+    for (res = 0; res < 8; res++)
+        if (misc_test_bit (res, p))
+            break;
+
+    return res + (p - addr) * 8;
+}
+
+inline unsigned long long misc_find_next_set_bit(const void *vaddr, 
+    unsigned long long size, unsigned long long offset)
+{
+    const __u8 *addr = vaddr;
+    const __u8 *p = addr + (offset >> 3);
+    int bit = offset & 7;
+    unsigned long long res;
+
+    if (offset >= size)
+        return size;
+
+    if (bit) {
+        /* Look for zero in first char */
+        for (res = bit; res < 8; res++)
+            if (misc_test_bit (res, p))
+                return res + (p - addr) * 8;
+        p++;
+    }
+    /* No set bit yet, search remaining full bytes for a 1 */
+    res = misc_find_first_set_bit (p, size - 8 * (p - addr));
+    return res + (p - addr) * 8;
+}
+
+#include "credits.h"
+
+/* Reads the "CREDITS" file and prints one paragraph from it. */
+void misc_print_credit(FILE *out) {
+    char *line;
+    
+    fprintf(out, "\nA pair of credits:\n");
+    
+    line = credits[(random() % CREDITS_COUNT)];
+    fprintf(out, "%s", line);
+    
+    line = credits[(random() % CREDITS_COUNT)];
+    fprintf(out, "%s", line);
+}
+
diff --git a/missing b/missing
index 7789652..6a37006 100755
--- a/missing
+++ b/missing
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Common stub for a few missing GNU programs while installing.
-# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
-# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,11 +18,37 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 # 02111-1307, USA.
 
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
 if test $# -eq 0; then
   echo 1>&2 "Try \`$0 --help' for more information"
   exit 1
 fi
 
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+case "$1" in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
 case "$1" in
 
   -h|--h|--he|--hel|--help)
@@ -35,6 +61,7 @@
 Options:
   -h, --help      display this help and exit
   -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
 
 Supported PROGRAM values:
   aclocal      touch file \`aclocal.m4'
@@ -43,13 +70,15 @@
   automake     touch all \`Makefile.in' files
   bison        create \`y.tab.[ch]', if possible, from existing .[ch]
   flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
   lex          create \`lex.yy.c', if possible, from existing .c
   makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
   yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
     ;;
 
   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
-    echo "missing - GNU libit 0.0"
+    echo "missing 0.4 - GNU automake"
     ;;
 
   -*)
@@ -58,31 +87,46 @@
     exit 1
     ;;
 
-  aclocal)
+  aclocal*)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
     echo 1>&2 "\
 WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`acinclude.m4' or \`configure.in'.  You might want
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
          to install the \`Automake' and \`Perl' packages.  Grab them from
          any GNU archive site."
     touch aclocal.m4
     ;;
 
   autoconf)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
     echo 1>&2 "\
 WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`configure.in'.  You might want to install the
+         you modified \`${configure_ac}'.  You might want to install the
          \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
          archive site."
     touch configure
     ;;
 
   autoheader)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
     echo 1>&2 "\
 WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`acconfig.h' or \`configure.in'.  You might want
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
          to install the \`Autoconf' and \`GNU m4' packages.  Grab them
          from any GNU archive site."
-    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
     test -z "$files" && files="config.h"
     touch_files=
     for f in $files; do
@@ -95,10 +139,15 @@
     touch $touch_files
     ;;
 
-  automake)
+  automake*)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
     echo 1>&2 "\
 WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
          You might want to install the \`Automake' and \`Perl' packages.
          Grab them from any GNU archive site."
     find . -type f -name Makefile.am -print |
@@ -106,6 +155,34 @@
 	   while read f; do touch "$f"; done
     ;;
 
+  autom4te)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo "#! /bin/sh"
+	echo "# Created by GNU Automake missing as a replacement of"
+	echo "#  $ $@"
+	echo "exit 0"
+	chmod +x $file
+	exit 1
+    fi
+    ;;
+
   bison|yacc)
     echo 1>&2 "\
 WARNING: \`$1' is missing on your system.  You should only need it if
@@ -159,7 +236,37 @@
     fi
     ;;
 
+  help2man)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+	 you modified a dependency of a manual page.  You may need the
+	 \`Help2man' package in order for those modifications to take
+	 effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+    fi
+    if [ -f "$file" ]; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo ".ab help2man is required to generate this page"
+	exit 1
+    fi
+    ;;
+
   makeinfo)
+    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
+       # We have makeinfo, but it failed.
+       exit 1
+    fi
+
     echo 1>&2 "\
 WARNING: \`$1' is missing on your system.  You should only need it if
          you modified a \`.texi' or \`.texinfo' file, or any other file
@@ -175,6 +282,45 @@
     touch $file
     ;;
 
+  tar)
+    shift
+    if test -n "$run"; then
+      echo 1>&2 "ERROR: \`tar' requires --run"
+      exit 1
+    fi
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+	case "$firstarg" in
+	*o*)
+	    firstarg=`echo "$firstarg" | sed s/o//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+	case "$firstarg" in
+	*h*)
+	    firstarg=`echo "$firstarg" | sed s/h//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
   *)
     echo 1>&2 "\
 WARNING: \`$1' is needed, and you do not seem to have it handy on your
diff --git a/mkreiserfs/Makefile.in b/mkreiserfs/Makefile.in
index 62bb9f0..9535178 100644
--- a/mkreiserfs/Makefile.in
+++ b/mkreiserfs/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,60 +12,98 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 sbin_PROGRAMS = mkreiserfs
 
 mkreiserfs_SOURCES = mkreiserfs.c
@@ -71,102 +111,113 @@
 EXTRA_DIST = $(man_MANS)
 
 LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+subdir = mkreiserfs
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../include/config.h
-CONFIG_CLEAN_FILES = 
-PROGRAMS =  $(sbin_PROGRAMS)
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+sbin_PROGRAMS = mkreiserfs$(EXEEXT)
+PROGRAMS = $(sbin_PROGRAMS)
 
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I../include
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-mkreiserfs_OBJECTS =  mkreiserfs.o
+am_mkreiserfs_OBJECTS = mkreiserfs.$(OBJEXT)
+mkreiserfs_OBJECTS = $(am_mkreiserfs_OBJECTS)
 mkreiserfs_LDADD = $(LDADD)
-mkreiserfs_DEPENDENCIES =  $(top_srcdir)/lib/libmisc.a \
-$(top_srcdir)/reiserfscore/libcore.a
-mkreiserfs_LDFLAGS = 
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+mkreiserfs_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
+	$(top_srcdir)/reiserfscore/libcore.a
+mkreiserfs_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/mkreiserfs.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-man8dir = $(mandir)/man8
-MANS = $(man_MANS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(mkreiserfs_SOURCES)
 
 NROFF = nroff
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
+MANS = $(man_MANS)
+DIST_COMMON = Makefile.am Makefile.in
 SOURCES = $(mkreiserfs_SOURCES)
-OBJECTS = $(mkreiserfs_OBJECTS)
 
-all: all-redirect
+all: all-am
+
 .SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps mkreiserfs/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-sbinPROGRAMS:
-
-clean-sbinPROGRAMS:
-	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
-
-distclean-sbinPROGRAMS:
-
-maintainer-clean-sbinPROGRAMS:
-
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  mkreiserfs/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(sbindir)
 	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  if test -f $$p; then \
-	    echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
-	     $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \
 	  else :; fi; \
 	done
 
 uninstall-sbinPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
+	  rm -f $(DESTDIR)$(sbindir)/$$f; \
 	done
 
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+mkreiserfs$(EXEEXT): $(mkreiserfs_OBJECTS) $(mkreiserfs_DEPENDENCIES) 
+	@rm -f mkreiserfs$(EXEEXT)
+	$(LINK) $(mkreiserfs_LDFLAGS) $(mkreiserfs_OBJECTS) $(mkreiserfs_LDADD) $(LIBS)
 
 mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
+	-rm -f *.$(OBJEXT) core *.core
 
 distclean-compile:
 	-rm -f *.tab.c
 
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkreiserfs.Po@am__quote@
 
-mkreiserfs: $(mkreiserfs_OBJECTS) $(mkreiserfs_DEPENDENCIES)
-	@rm -f mkreiserfs
-	$(LINK) $(mkreiserfs_LDFLAGS) $(mkreiserfs_OBJECTS) $(mkreiserfs_LDADD) $(LIBS)
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
 
-install-man8:
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+man8dir = $(mandir)/man8
+install-man8: $(man8_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(man8dir)
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
@@ -175,152 +226,212 @@
 	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
 	  else file=$$i; fi; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \
 	  $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \
 	done
-
 uninstall-man8:
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@$(NORMAL_UNINSTALL)
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
 	done; \
 	for i in $$list; do \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \
 	  rm -f $(DESTDIR)$(man8dir)/$$inst; \
 	done
-install-man: $(MANS)
-	@$(NORMAL_INSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) install-man8
-uninstall-man:
-	@$(NORMAL_UNINSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) uninstall-man8
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = mkreiserfs
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-mkreiserfs.o: mkreiserfs.c ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am: install-sbinPROGRAMS
-install-exec: install-exec-am
+all-am: Makefile $(PROGRAMS) $(MANS)
 
-install-data-am: install-man
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir)
+
+install: install-am
+install-exec: install-exec-am
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-sbinPROGRAMS uninstall-man
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS) $(MANS)
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-	$(mkinstalldirs)  $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-sbinPROGRAMS mostlyclean-compile \
-		mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-sbinPROGRAMS clean-compile clean-tags clean-generic \
-		mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-sbinPROGRAMS distclean-compile distclean-tags \
-		distclean-generic clean-am
+clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-sbinPROGRAMS \
-		maintainer-clean-compile maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-exec-am: install-sbinPROGRAMS
+
+install-info: install-info-am
+
+install-man: install-man8
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
-clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
-install-sbinPROGRAMS mostlyclean-compile distclean-compile \
-clean-compile maintainer-clean-compile install-man8 uninstall-man8 \
-install-man uninstall-man tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-man uninstall-sbinPROGRAMS
+
+uninstall-man: uninstall-man8
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-sbinPROGRAMS ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-man8 install-sbinPROGRAMS \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-info-am uninstall-man \
+	uninstall-man8 uninstall-sbinPROGRAMS
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/mkreiserfs/mkreiserfs.8 b/mkreiserfs/mkreiserfs.8
index 0afaf01..bb40127 100644
--- a/mkreiserfs/mkreiserfs.8
+++ b/mkreiserfs/mkreiserfs.8
@@ -1,7 +1,7 @@
 .\" -*- nroff -*-
-.\" Copyright 1996-2002 Hans Reiser.
+.\" Copyright 1996-2003 Hans Reiser.
 .\" 
-.TH MKREISERFS 8 "January 2002" "Reiserfsprogs-3.6.4"
+.TH MKREISERFS 8 "April 2003" "Reiserfsprogs-3.6.9"
 .SH NAME
 mkreiserfs \- create a Linux ReiserFS file system 
 .SH SYNOPSIS
@@ -12,6 +12,7 @@
 [ \fB-u\fR | \fB--uuid \fIUUID\fR ] 
 [ \fB-l\fR | \fB--label \fILABEL\fR ]
 [ \fB--format \fIFORMAT\fR ]
+[ \fB-q\fR | \fB--quiet\fR ]
 [ \fB-j\fR | \fB--journal-device \fIFILE\fR ]
 [ \fB-s\fR | \fB--journal-size \fIN\fR ]
 [ \fB-o\fR | \fB--journal-offset \fIN\fR ]
@@ -41,7 +42,7 @@
 .TP
 \fB--format \fIFORMAT\fR
 \fIFORMAT\fR specifies a format new filsystem has to be of. Choose one
-of 3.5 and 3.6. If none is specified mkreiserfs will create format 3.6
+of 3.5 and 3.6. If none is specified \fBmkreiserfs\fR will create format 3.6
 if running kernel is 2.4, 3.5 if 2.2 is running, and will refuse
 creation under other kernels.
 .TP
@@ -50,11 +51,15 @@
 \fIUUID\fR (see also \fBuuidgen(8)\fR). The  format  of  the  UUID  is  a 
 series  of  hex  digits  separated  by  hypthens,  like  this:
 "c1b9d5a2-f162-11cf-9ece-0020afc76f16". If the option skipped,
-mkreiserfs generates a new one.
+\fBmkreiserfs\fR generates a new one.
 .TP
 \fB-l\fR | \fB--label \fILABEL\fR
 Set  the  volume  label  of  the filesystem. \fILABEL\fR can be at most 16
-characters long; if it is longer than 16 characters, mkreiserfs will truncate it.
+characters long; if it is longer than 16 characters, \fBmkreiserfs\fR will truncate it.
+.TP
+\fB-q\fR | \fB--quiet \fR
+Make \fBmkreiserfs\fR to work quiet without producing any message, progress and question. 
+It is useful if you run \fBmkreiserfs\fR in a script. For use by end users only.
 .TP
 \fB-j\fR | \fB--journal-device \fIFILE\fR
 \fIFILE\fR is name of block device where the file system is to have
@@ -79,12 +84,12 @@
 adjusted.
 .TP
 \fB-f\fR
-This forces mkreiserfs to continue even if device is either whole
+This forces \fBmkreiserfs\fR to continue even if device is either whole
 disk, or looks mounted or is not a block device. Specified more than
 once allows to avoid asking for confirmation.
 .TP
 \fB-d\fR
-This makes mkreiserfs to print debugging information during mkreiserfs.
+This makes \fBmkreiserfs\fR to print debugging information during \fBmkreiserfs\fR.
 .TP
 \fB-V\fR
 This prints version and exits.
diff --git a/mkreiserfs/mkreiserfs.c b/mkreiserfs/mkreiserfs.c
index 8d15004..aa57d58 100644
--- a/mkreiserfs/mkreiserfs.c
+++ b/mkreiserfs/mkreiserfs.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 1996-2002 Hans Reiser, licensing governed by ../README
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 /* mkreiserfs is very simple. It supports only 4k blocks. It skips
@@ -26,7 +27,6 @@
 #include <errno.h>
 #include <sys/vfs.h>
 #include <time.h>
-#include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <linux/kdev_t.h>
@@ -46,8 +46,7 @@
 static void message( const char * fmt, ... ) 
 	__attribute__ ((format (printf, 1, 2)));
 
-	static void message( const char * fmt, ... ) 
-{
+static void message( const char * fmt, ... ) {
     char *buf;
     va_list args;
 	
@@ -64,34 +63,36 @@
 
 static void print_usage_and_exit(void)
 {
-	fprintf(stderr, "Usage: %s [options] "
-			" device [block-count]\n"
-			"\n"
-			"Options:\n\n"
-			"  -b | --block-size N              size of file-system block, in bytes\n"
-			"  -j | --journal-device FILE       path to separate device to hold journal\n"
-			"  -s | --journal-size N            size of the journal in blocks\n"
-			"  -o | --journal-offset N          offset of the journal from the start of\n"
-			"                                   the separate device, in blocks\n"
-			"  -t | --transaction-max-size N    maximal size of transaction, in blocks\n"
-			"  -h | --hash rupasov|tea|r5       hash function to use by default\n"
-			"  -u | --uuid UUID                 store UUID in the superblock\n"
-			"  -l | --label LABEL               store LABEL in the superblock\n"
-			"  --format 3.5|3.6                 old 3.5 format or newer 3.6\n"
-			"  -f | --force                     specified once, make mkreiserfs the whole\n"
-			"                                   disk, not block device or mounted partition;\n"
-			"                                   specified twice, do not ask for confirmation\n"
-			"  -d | --debug                     print debugging information during mkreiser\n"
-			"  -V                               print version and exit\n",
-			program_name);
-	exit (1);
+    fprintf(stderr, "Usage: %s [options] "
+	" device [block-count]\n"
+	"\n"
+	"Options:\n\n"
+	"  -b | --block-size N              size of file-system block, in bytes\n"
+	"  -j | --journal-device FILE       path to separate device to hold journal\n"
+	"  -s | --journal-size N            size of the journal in blocks\n"
+	"  -o | --journal-offset N          offset of the journal from the start of\n"
+	"                                   the separate device, in blocks\n"
+	"  -t | --transaction-max-size N    maximal size of transaction, in blocks\n"
+	"  -h | --hash rupasov|tea|r5       hash function to use by default\n"
+	"  -u | --uuid UUID                 store UUID in the superblock\n"
+	"  -l | --label LABEL               store LABEL in the superblock\n"
+	"  --format 3.5|3.6                 old 3.5 format or newer 3.6\n"
+	"  -f | --force                     specified once, make mkreiserfs the whole\n"
+	"                                   disk, not block device or mounted partition;\n"
+	"                                   specified twice, do not ask for confirmation\n"
+	"  -q | --quiet                     quiet work without messages, progress and\n"
+	"                                   questions. Useful if run in a script. For use\n" 
+	"                                   by end users only.\n"
+	"  -d | --debug                     print debugging information during mkreiser\n"
+	"  -V                               print version and exit\n",
+	program_name);
+    exit (1);
 }
 
-//			"  -B badblocks-file                list of all bad blocks on the fs\n"
+//	"  -B badblocks-file                list of all bad blocks on the fs\n"
 
 int Create_default_journal = 1;
 int Block_size = 4096;
-int DEBUG_MODE = 0;
 
 /* size of journal + 1 block for journal header */
 unsigned long Journal_size = 0;
@@ -103,21 +104,28 @@
 unsigned char * LABEL = NULL;
 char * badblocks_file;
 
+enum mkfs_mode {
+    DEBUG_MODE = 1 << 0,
+    QUIET_MODE = 1 << 1
+};
+
+int mode;
 
 /* form super block (old one) */
 static void make_super_block (reiserfs_filsys_t * fs)
 {
-    set_sb_umount_state (fs->fs_ondisk_sb, REISERFS_CLEANLY_UMOUNTED);
+    set_sb_umount_state (fs->fs_ondisk_sb, FS_CLEANLY_UMOUNTED);
     set_sb_tree_height (fs->fs_ondisk_sb, 2);
     set_sb_hash_code (fs->fs_ondisk_sb, Hash);
     if (fs->fs_format == REISERFS_FORMAT_3_6) {
         if (!uuid_is_correct (UUID) && generate_random_uuid (UUID))
-	    reiserfs_warning (stdout, "failed to genetate UUID\n");
+	    reiserfs_warning (stderr, "failed to genetate UUID\n");
 
 	memcpy (fs->fs_ondisk_sb->s_uuid, UUID, 16);
 	if (LABEL != NULL) {
 	    if (strlen (LABEL) > 16)
-	        reiserfs_warning (stderr, "\nSpecified LABEL is longer then 16 characters, will be truncated\n\n");
+	        reiserfs_warning (stderr, "\nSpecified LABEL is longer then 16 "
+		"characters, will be truncated\n\n");
 	    strncpy (fs->fs_ondisk_sb->s_label, LABEL, 16);
 	}
 	set_sb_v2_flag (fs->fs_ondisk_sb, reiserfs_attrs_cleared);
@@ -157,20 +165,18 @@
 
 void zero_journal (reiserfs_filsys_t * fs)
 {
-    int i;
+    unsigned long start, len, done;
     struct buffer_head * bh;
-    unsigned long done;
-    unsigned long start, len;
+    unsigned int i;
 
-
-    fprintf (stderr, "Initializing journal - ");
+    fprintf (stdout, "Initializing journal - ");
 
     start = get_jp_journal_1st_block (sb_jp (fs->fs_ondisk_sb));
     len = get_jp_journal_size (sb_jp (fs->fs_ondisk_sb));
 
     done = 0;
     for (i = 0; i < len; i ++) {
-        print_how_far (stderr, &done, len, 1, 1/*be quiet*/);
+        print_how_far (stdout, &done, len, 1, 1/*be quiet*/);
         bh = getblk (fs->fs_journal_dev, start + i, fs->fs_blocksize);
 		if (!bh)
 			die ("zero_journal: getblk failed");
@@ -181,8 +187,8 @@
         brelse (bh);
     }
 
-    fprintf (stderr, "\n");
-    fflush (stderr);
+    fprintf (stdout, "\n");
+    fflush (stdout);
 }
 
 
@@ -191,20 +197,18 @@
 static void make_bitmap (reiserfs_filsys_t * fs)
 {
     struct reiserfs_super_block * sb = fs->fs_ondisk_sb;
-    int i;
+    unsigned int i;
     unsigned long block;
     int marked;
     
-
     marked = 0;
 
     /* mark skipped area and super block */
     for (i = 0; i <= fs->fs_super_bh->b_blocknr; i ++) {
-		reiserfs_bitmap_set_bit (fs->fs_bitmap2, i);
-		marked ++;
+	reiserfs_bitmap_set_bit (fs->fs_bitmap2, i);
+	marked ++;
     }
-
-
+    
     if (fs->fs_badblocks_bm) {
 	for (i = 0; i < get_sb_block_count (sb); i ++) {
 	    if (reiserfs_bitmap_test_bit (fs->fs_badblocks_bm, i)) {
@@ -221,7 +225,8 @@
 		reiserfs_bitmap_set_bit (fs->fs_bitmap2, block);
 		marked ++;
 		if (spread_bitmaps (fs))
-			block = (block / (fs->fs_blocksize * 8) + 1) * (fs->fs_blocksize * 8);
+			block = (block / (fs->fs_blocksize * 8) + 1) * 
+				(fs->fs_blocksize * 8);
 		else
 			block ++;
     }
@@ -233,7 +238,7 @@
 		/* makr journal blocks as used */
 		for (i = 0; i <= get_jp_journal_size (sb_jp (sb)); i ++) {
 			reiserfs_bitmap_set_bit (fs->fs_bitmap2,
-									 i + get_jp_journal_1st_block (sb_jp (sb)));
+			    i + get_jp_journal_1st_block (sb_jp (sb)));
 			marked ++;
 		}
 		block = get_jp_journal_1st_block (sb_jp (sb)) + i;
@@ -244,7 +249,9 @@
         block++;
     }
 
-    while ((block < get_sb_block_count (sb)) && reiserfs_bitmap_test_bit (fs->fs_bitmap2, block)) {
+    while ((block < get_sb_block_count (sb)) && 
+	   reiserfs_bitmap_test_bit (fs->fs_bitmap2, block)) 
+    {
     	block++;
     }
 
@@ -300,7 +307,9 @@
 static void report (reiserfs_filsys_t * fs, char * j_filename)
 {
 //    print_block (stdout, fs, fs->fs_super_bh);
-    struct reiserfs_super_block * sb = (struct reiserfs_super_block *)(fs->fs_super_bh->b_data);
+    struct reiserfs_super_block * sb = 
+	(struct reiserfs_super_block *)(fs->fs_super_bh->b_data);
+
     struct stat st;
     dev_t rdev;
 
@@ -308,12 +317,12 @@
 		return;
 
     if (fstat (fs->fs_super_bh->b_dev, &st) == -1) {
-		/*reiserfs_warning (stderr, "fstat failed: %m\n");*/
+		/*reiserfs_warning (stderr, "fstat failed: %s\n", strerror(errno));*/
 		rdev = 0;
     } else	
 		rdev = st.st_rdev;
 
-    if (DEBUG_MODE) {
+    if (mode & DEBUG_MODE) {
         reiserfs_warning (stdout, "Block %lu (0x%x) contains super block. ",
 						  fs->fs_super_bh->b_blocknr, rdev);
     }
@@ -328,44 +337,48 @@
     if (is_reiserfs_jr_magic_string (sb))
 		reiserfs_warning (stdout, "non-");
     reiserfs_warning (stdout, "standard journal\n");
-    reiserfs_warning (stdout, "Count of blocks on the device: %u\n", get_sb_block_count (sb));
-    reiserfs_warning (stdout, "Number of blocks consumed by mkreiserfs formatting process: %u\n", 
-					  get_sb_block_count (sb) - get_sb_free_blocks (sb));    
-    if (DEBUG_MODE)
+    reiserfs_warning (stdout, "Count of blocks on the device: %u\n", 
+	get_sb_block_count (sb));
+    reiserfs_warning (stdout, "Number of blocks consumed by mkreiserfs "
+	"formatting process: %u\n", get_sb_block_count (sb) - get_sb_free_blocks (sb));
+    if (mode & DEBUG_MODE)
         reiserfs_warning (stdout, "Free blocks: %u\n", get_sb_free_blocks (sb));
     reiserfs_warning (stdout, "Blocksize: %d\n", get_sb_block_size (sb));
     reiserfs_warning (stdout, "Hash function used to sort names: %s\n",
 					  code2name (get_sb_hash_code (sb)));
-    if (DEBUG_MODE) {
+    if (mode & DEBUG_MODE) {
         reiserfs_warning (stdout, "Number of bitmaps: %u\n", get_sb_bmap_nr (sb));
         reiserfs_warning (stdout, "Root block: %u\n", get_sb_root_block (sb));
         reiserfs_warning (stdout, "Tree height: %d\n", get_sb_tree_height (sb));
-        reiserfs_warning (stdout, "Objectid map size %d, max %d\n", get_sb_oid_cursize (sb),
-						  get_sb_oid_maxsize (sb));
+        reiserfs_warning (stdout, "Objectid map size %d, max %d\n", 
+	    get_sb_oid_cursize (sb), get_sb_oid_maxsize (sb));
         reiserfs_warning (stdout, "Journal parameters:\n");
         print_journal_params (stdout, sb_jp (sb));
     } else {
         if (j_filename && strcmp (j_filename, fs->fs_file_name)) 
-            reiserfs_warning (stdout, "Journal Device [0x%x]\n", get_jp_journal_dev (sb_jp (sb)));
+            reiserfs_warning (stdout, "Journal Device [0x%x]\n", 
+		get_jp_journal_dev (sb_jp (sb)));
+	
         reiserfs_warning (stdout, "Journal Size %u blocks (first block %u)\n",
-						  get_jp_journal_size (sb_jp (sb)) + 1,
-						  get_jp_journal_1st_block (sb_jp (sb)));
+	    get_jp_journal_size (sb_jp (sb)) + 1,
+	    get_jp_journal_1st_block (sb_jp (sb)));
         reiserfs_warning (stdout, "Journal Max transaction length %u\n", 
-						  get_jp_journal_max_trans_len (sb_jp (sb)));
+	    get_jp_journal_max_trans_len (sb_jp (sb)));
     }
 
     if (j_filename && strcmp (j_filename, fs->fs_file_name)) {
         reiserfs_warning (stdout, "Space on this device reserved by journal: %u\n", 
-						  get_sb_reserved_for_journal (sb));
+	    get_sb_reserved_for_journal (sb));
     }
     
-    if (DEBUG_MODE) {
-		reiserfs_warning (stdout, "Filesystem state 0x%x\n", get_sb_fs_state (sb));
-		reiserfs_warning (stdout, "sb_version %u\n", get_sb_version (sb));
+    if (mode & DEBUG_MODE) {
+	reiserfs_warning (stdout, "Filesystem state 0x%x\n", get_sb_fs_state (sb));
+	reiserfs_warning (stdout, "sb_version %u\n", get_sb_version (sb));
     }
 
     if (get_reiserfs_format (sb) == REISERFS_FORMAT_3_6) {
-        reiserfs_warning (stdout, "inode generation number: %u\n", get_sb_v2_inode_generation (sb));
+        reiserfs_warning (stdout, "inode generation number: %u\n", 
+	    get_sb_v2_inode_generation (sb));
         reiserfs_warning (stdout, "UUID: %U\n", sb->s_uuid);
         if (strcmp (sb->s_label, ""))
             reiserfs_warning (stdout, "LABEL: %s\n", sb->s_label);
@@ -393,11 +406,11 @@
 static void set_reiserfs_version (char * str)
 {
     if (!strcmp (str, "3.5"))
-		Format = "3.5";
+	Format = "3.5";
     else  {
-		Format = "3.6";
-		if (strcmp (str, "3.6"))
-			message("wrong reiserfs version specified. Using default 3.6 format");
+	Format = "3.6";
+	if (strcmp (str, "3.6"))
+	    message("wrong reiserfs version specified. Using default 3.6 format");
     }
 }
 
@@ -408,7 +421,7 @@
 
     val = (int) strtol (str, &tmp, 0);
     if (*tmp)
-		die ("%s: strtol is unable to make an integer of %s\n", program_name, str);
+	die ("%s: strtol is unable to make an integer of %s\n", program_name, str);
     return val;
 }
 
@@ -418,8 +431,8 @@
     *b_size = str2int (str);
       
     if (!is_blocksize_correct (*b_size))
-        die ("%s: wrong blocksize %s specified, only divisible by 1024 are supported currently",
-        	program_name, str);
+        die ("%s: wrong blocksize %s specified, only power of 2 from 512-8192 "
+	    "interval are supported", program_name, str);
 }
 
 
@@ -451,15 +464,18 @@
 
 static int is_journal_default (char * name, char * jname, int blocksize)
 {
-	if (jname && strcmp (name, jname))
-		return 0;
-	if (Journal_size &&
-	    Journal_size != journal_default_size (REISERFS_DISK_OFFSET_IN_BYTES / blocksize, blocksize) + 1)
-		/* journal size is set and it is not default size */
-		return 0;
-	if (Max_trans_size != JOURNAL_TRANS_MAX)
-		return 0;
-	return 1;
+    if (jname && strcmp (name, jname))
+	return 0;
+    
+    if (Journal_size && Journal_size != 
+	journal_default_size(REISERFS_DISK_OFFSET_IN_BYTES / blocksize, blocksize) + 1)
+	/* journal size is set and it is not default size */
+	return 0;
+    
+    if (Max_trans_size && Max_trans_size != JOURNAL_TRANS_MAX)
+	return 0;
+
+    return 1;
 }
 
 	
@@ -482,14 +498,17 @@
 		return REISERFS_FORMAT_3_6;
 	}
 	
-	message ("Guessing about desired format.. ");
+	reiserfs_warning (stdout, "Guessing about desired format.. ");
 	
 	if (uname (&sysinfo) == -1) {
-		message ("could not get system info: %m");
+		message ("could not get system info: %s", strerror(errno));
 		exit (1);
 	}
 	
-	message ("Kernel %s is running.", sysinfo.release);
+	reiserfs_warning(stdout, "Kernel %s is running.\n", sysinfo.release);
+	if (!strncmp (sysinfo.release, "2.6", 3))
+		return REISERFS_FORMAT_3_6;
+	
 	if (!strncmp (sysinfo.release, "2.5", 3))
 		return REISERFS_FORMAT_3_6;
 	
@@ -497,12 +516,12 @@
 		return REISERFS_FORMAT_3_6;
 
 	if (strncmp (sysinfo.release, "2.2", 3)) {
-		message( "You should run either 2.4 or 2.2 to be able "
-				 "to create reiserfs filesystem or specify desired format with -v");
+		message( "You should run either 2.2 or 2.4 or higher to be able "
+		    "to create reiserfs filesystem or specify desired format with --format");
 		exit (1);
 	}
 
-    message ("Creating filesystem of format 3.5");
+    reiserfs_warning(stdout, "Creating filesystem of format 3.5\n");
     return REISERFS_FORMAT_3_5;
 }
 
@@ -510,28 +529,27 @@
 int main (int argc, char **argv)
 {
     reiserfs_filsys_t * fs;
-    int force;
-    char * device_name;
-    char * jdevice_name;
-    unsigned long fs_size;
+    int force = 0;
+    char * device_name = NULL;
+    char * jdevice_name = NULL;
+    unsigned long fs_size = 0;
     int c;
     static int flag;
 
-
     program_name = strrchr( argv[ 0 ], '/' );
-    program_name = program_name ? ++ program_name : argv[ 0 ];
     
-    print_banner (program_name);
-
-    if (argc < 2)
-		print_usage_and_exit ();
+    if (program_name)
+	program_name++;
+    else
+	program_name = argv[ 0 ];
     
-    force = 0;
-    fs_size = 0;
-    device_name = 0;
-    jdevice_name = 0;
 
+    if (argc < 2) {
+	print_banner (program_name);
 
+	print_usage_and_exit ();
+    }
+    
     while (1) {
 		static struct option options[] = {
 			{"block-size", required_argument, 0, 'b'},
@@ -547,7 +565,7 @@
 		};
 		int option_index;
       
-		c = getopt_long (argc, argv, "b:j:s:t:o:h:u:l:Vfd",
+		c = getopt_long (argc, argv, "b:j:s:t:o:h:u:l:VfdB:q",
 						 options, &option_index);
 		if (c == -1)
 			break;
@@ -596,19 +614,19 @@
 			break;
 
 		case 'V':
-			exit (1);
+			print_usage_and_exit ();
 
 		case 'f':
 			force ++;
 			break;
 
 		case 'd':
-			DEBUG_MODE = 1;
+			mode |= DEBUG_MODE;
 			break;
 		
 		case 'u':
 			if (set_uuid (optarg, UUID)) {
-			    reiserfs_warning(stdout, "wrong UUID specified\n");
+			    reiserfs_warning(stderr, "wrong UUID specified\n");
 			    return 1;
 			}
 			
@@ -617,7 +635,10 @@
 		case 'l':
 			LABEL = optarg;
 			break;
-		
+		case 'q':
+			mode |= QUIET_MODE;
+			fclose(stdout);
+			break;
 		default:
 			print_usage_and_exit();
 		}
@@ -640,28 +661,23 @@
     if (is_journal_default (device_name, jdevice_name, Block_size))
         Create_default_journal = 1;
     
-    if (!Max_trans_size) {
-        /* max transaction size has not been specified,
-           for blocksize >= 4096 - max transaction size is 1024. For block size < 4096
-           - trans max size is decreased proportionally */
-        Max_trans_size = JOURNAL_TRANS_MAX;
-        if (Block_size < 4096)
-            Max_trans_size = JOURNAL_TRANS_MAX / (4096 / Block_size);
-    }
-	
-    if (!can_we_format_it (device_name, force))
+    if (!(mode & QUIET_MODE) && !can_we_format_it (device_name, force))
         return 1;
 	
     if (jdevice_name)
-        if (!can_we_format_it (jdevice_name, force))
+        if (!(mode & QUIET_MODE) && !can_we_format_it (jdevice_name, force))
             return 1;
 
-    fs = reiserfs_create (device_name, select_format (), fs_size, Block_size, Create_default_journal, 1);
+    fs = reiserfs_create (device_name, select_format(), fs_size, Block_size, 
+	Create_default_journal, 1);
+    
     if (!fs) {
         return 1;
     }
 		
-    if (!reiserfs_create_journal (fs, jdevice_name, Offset, Journal_size, Max_trans_size)) {
+    if (!reiserfs_create_journal (fs, jdevice_name, Offset, Journal_size, 
+	Max_trans_size)) 
+    {
         return 1;
     }
 
@@ -672,7 +688,7 @@
     /* these fill buffers (super block, first bitmap, root block) with
        reiserfs structures */
     if (uuid_is_correct (UUID) && fs->fs_format != REISERFS_FORMAT_3_6) {
-	reiserfs_warning(stdout, "UUID can be specified only with 3.6 format\n");
+	reiserfs_warning(stderr, "UUID can be specified only with 3.6 format\n");
 	return 1;
     }
 
@@ -683,11 +699,11 @@
     make_super_block (fs);
     make_bitmap (fs);
     make_root_block (fs);
-    add_badblock_list (fs, 1);
+//    add_badblock_list (fs, 1);
   
     report (fs, jdevice_name);
 
-    if (!force) {
+    if (!force && !(mode & QUIET_MODE)) {
         fprintf (stderr, "ATTENTION: YOU SHOULD REBOOT AFTER FDISK!\n"
                 "\tALL DATA WILL BE LOST ON '%s'", device_name);
         if (jdevice_name && strcmp (jdevice_name, device_name))
@@ -709,32 +725,15 @@
     sync ();
     printf ("ok\n");
  
-	if (DEBUG_MODE)
-		return 0;
-	printf ("\nThe Defense Advanced Research Projects Agency (DARPA) is the primary sponsor of"
-			"\nReiser4. DARPA does not endorse this project; it merely sponsors it."
-			"\n"
-			"\nContinuing core development of version 3 is mostly paid for by Hans Reiser from"
-			"\nmoney made selling licenses in addition to the GPL to companies who don't want"
-			"\nit known that they use ReiserFS as a foundation for their proprietary product."
-			"\nAnd my lawyer asked 'People pay you money for this?'.  Yup.  Hee Hee.  Life is"
-			"\ngood.  If you buy ReiserFS, you can focus on your value add rather than"
-			"\nreinventing an entire FS.  You should buy some free software too...."
-			"\n"
-			"\nSuSE pays for continuing work on journaling for version 3, and paid for much of"
-			"\nthe previous version 3 work.  Reiserfs integration in their distro is"
-			"\nconsistently solid."
-			"\n"
-			"\nMP3.com paid for initial journaling development."
-			"\n"
-			"\nBigstorage.com contributes to our general fund every month, and has done so for"
-			"\nquite a long time."
-			"\n"
-			"\nThanks to all of those sponsors, including the secret ones.  Without you, Hans"
-			"\nwould still have that day job, and the merry band of hackers would be missing"
-			"\nquite a few...."
-			"\n"
-			"\nHave fun.\n"); 
+    if (mode & DEBUG_MODE)
+	return 0;
+    
+    misc_print_credit(stdout);
+    printf("\nTell your friends to use the kernel based on 2.4.18 or later "
+	"when you use\nreiserFS. Have fun.\n\n");
+        
+    printf("ReiserFS is successfully created on %s.\n", device_name);
+
     return 0;
 }
 
diff --git a/reiserfscore/Makefile.in b/reiserfscore/Makefile.in
index 2306ebc..0bcfbca 100644
--- a/reiserfscore/Makefile.in
+++ b/reiserfscore/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,282 +12,367 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 noinst_LIBRARIES = libcore.a
 
-libcore_a_SOURCES = do_balan.c fix_node.c hashes.c ibalance.c lbalance.c prints.c stree.c node_formats.c reiserfslib.c bitmap.c journal.c includes.h
+libcore_a_SOURCES = do_balan.c fix_node.c hashes.c ibalance.c lbalance.c prints.c \
+stree.c node_formats.c reiserfslib.c bitmap.c journal.c includes.h
 
+subdir = reiserfscore
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../include/config.h
-CONFIG_CLEAN_FILES = 
-LIBRARIES =  $(noinst_LIBRARIES)
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
 
+libcore_a_AR = $(AR) cru
+libcore_a_LIBADD =
+am_libcore_a_OBJECTS = do_balan.$(OBJEXT) fix_node.$(OBJEXT) \
+	hashes.$(OBJEXT) ibalance.$(OBJEXT) lbalance.$(OBJEXT) \
+	prints.$(OBJEXT) stree.$(OBJEXT) node_formats.$(OBJEXT) \
+	reiserfslib.$(OBJEXT) bitmap.$(OBJEXT) journal.$(OBJEXT)
+libcore_a_OBJECTS = $(am_libcore_a_OBJECTS)
 
-DEFS = @DEFS@ -I. -I$(srcdir) -I../include
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-libcore_a_LIBADD = 
-libcore_a_OBJECTS =  do_balan.o fix_node.o hashes.o ibalance.o \
-lbalance.o prints.o stree.o node_formats.o reiserfslib.o bitmap.o \
-journal.o
-AR = ar
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/bitmap.Po ./$(DEPDIR)/do_balan.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/fix_node.Po ./$(DEPDIR)/hashes.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/ibalance.Po ./$(DEPDIR)/journal.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/lbalance.Po ./$(DEPDIR)/node_formats.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/prints.Po ./$(DEPDIR)/reiserfslib.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/stree.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(libcore_a_SOURCES)
+DIST_COMMON = Makefile.am Makefile.in
 SOURCES = $(libcore_a_SOURCES)
-OBJECTS = $(libcore_a_OBJECTS)
 
-all: all-redirect
+all: all-am
+
 .SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps reiserfscore/Makefile
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  reiserfscore/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-noinstLIBRARIES:
+AR = ar
 
 clean-noinstLIBRARIES:
 	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
-
-distclean-noinstLIBRARIES:
-
-maintainer-clean-noinstLIBRARIES:
-
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
+libcore.a: $(libcore_a_OBJECTS) $(libcore_a_DEPENDENCIES) 
+	-rm -f libcore.a
+	$(libcore_a_AR) libcore.a $(libcore_a_OBJECTS) $(libcore_a_LIBADD)
+	$(RANLIB) libcore.a
 
 mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
+	-rm -f *.$(OBJEXT) core *.core
 
 distclean-compile:
 	-rm -f *.tab.c
 
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/do_balan.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fix_node.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hashes.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ibalance.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/journal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lbalance.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node_formats.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prints.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reiserfslib.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stree.Po@am__quote@
 
-libcore.a: $(libcore_a_OBJECTS) $(libcore_a_DEPENDENCIES)
-	-rm -f libcore.a
-	$(AR) cru libcore.a $(libcore_a_OBJECTS) $(libcore_a_LIBADD)
-	$(RANLIB) libcore.a
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
+
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = reiserfscore
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-bitmap.o: bitmap.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-do_balan.o: do_balan.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-fix_node.o: fix_node.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-hashes.o: hashes.c
-ibalance.o: ibalance.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-journal.o: journal.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-lbalance.o: lbalance.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-node_formats.o: node_formats.c includes.h ../include/io.h \
-	../include/misc.h ../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-prints.o: prints.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-reiserfslib.o: reiserfslib.c includes.h ../include/io.h \
-	../include/misc.h ../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-stree.o: stree.c includes.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
+all-am: Makefile $(LIBRARIES)
 
-install-data-am:
+installdirs:
+
+install: install-am
+install-exec: install-exec-am
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile $(LIBRARIES)
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-noinstLIBRARIES mostlyclean-compile \
-		mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
-		mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-noinstLIBRARIES distclean-compile \
-		distclean-tags distclean-generic clean-am
+clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-noinstLIBRARIES \
-		maintainer-clean-compile maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
-clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-noinstLIBRARIES ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-info-am
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/reiserfscore/bitmap.c b/reiserfscore/bitmap.c
index 8c08725..5901e9f 100644
--- a/reiserfscore/bitmap.c
+++ b/reiserfscore/bitmap.c
@@ -1,7 +1,8 @@
 /* 
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
-  
+
 /*
  * 2000/10/26 - Initial version.
  */
@@ -47,6 +48,9 @@
     bm->bm_map = new_map;
     bm->bm_byte_size = byte_count;
     bm->bm_bit_size = bit_count;
+
+    bm->bm_dirty = 1;
+
     return 0;
 }
 
@@ -56,6 +60,8 @@
 
     bm->bm_byte_size = (bit_count + 7) / 8;
     bm->bm_bit_size = bit_count;
+
+    bm->bm_dirty = 1;
 }
 
 /* bitmap destructor */
@@ -80,8 +86,8 @@
 
 int reiserfs_bitmap_compare (reiserfs_bitmap_t * bm1, reiserfs_bitmap_t * bm2)
 {
-    int bytes, bits;
-    long unsigned i, diff;
+    unsigned long i, diff;
+    unsigned long int bytes, bits;
 
     assert (bm1->bm_byte_size == bm2->bm_byte_size &&
 	    bm1->bm_bit_size == bm2->bm_bit_size);
@@ -119,16 +125,17 @@
     Y - `from` bitmap. 
     Save result in the `to` bitmap.
 */
-void reiserfs_bitmap_disjunction (reiserfs_bitmap_t * to, reiserfs_bitmap_t * from)
+void reiserfs_bitmap_disjunction (reiserfs_bitmap_t * to, 
+    reiserfs_bitmap_t * from) 
 {
-    int i;
+    unsigned int i;
 
     assert (to->bm_byte_size == from->bm_byte_size &&
 	    to->bm_bit_size == from->bm_bit_size);
 
     for (i = 0; i < to->bm_bit_size; i++) {
-	if (test_bit(i, from->bm_map) && !test_bit(i, to->bm_map)) {
-	    set_bit(i, to->bm_map);
+	if (misc_test_bit(i, from->bm_map) && !misc_test_bit(i, to->bm_map)) {
+	    misc_set_bit(i, to->bm_map);
 	    to->bm_set_bits ++;
 	    to->bm_dirty = 1;	
 	}
@@ -142,14 +149,14 @@
     Save result in the `base` bitmap.
 */
 void reiserfs_bitmap_delta (reiserfs_bitmap_t * base, reiserfs_bitmap_t * exclude) {
-   int i;
+   unsigned int i;
 
     assert (base->bm_byte_size == exclude->bm_byte_size &&
 	    base->bm_bit_size == exclude->bm_bit_size);
 
     for (i = 0; i < base->bm_bit_size; i++) {
-	if (test_bit(i, exclude->bm_map) && test_bit(i, base->bm_map)) {
-	    clear_bit(i, base->bm_map);
+	if (misc_test_bit(i, exclude->bm_map) && misc_test_bit(i, base->bm_map)) {
+	    misc_clear_bit(i, base->bm_map);
 	    base->bm_set_bits --;
 	    base->bm_dirty = 1;
 	}
@@ -159,9 +166,9 @@
 void reiserfs_bitmap_set_bit (reiserfs_bitmap_t * bm, unsigned int bit_number)
 {
     assert(bit_number < bm->bm_bit_size);
-    if (test_bit (bit_number, bm->bm_map))
+    if (misc_test_bit (bit_number, bm->bm_map))
 	return;
-    set_bit(bit_number, bm->bm_map);
+    misc_set_bit(bit_number, bm->bm_map);
     bm->bm_set_bits ++;
     bm->bm_dirty = 1;
 }
@@ -170,9 +177,9 @@
 void reiserfs_bitmap_clear_bit (reiserfs_bitmap_t * bm, unsigned int bit_number)
 {
     assert(bit_number < bm->bm_bit_size);
-    if (!test_bit (bit_number, bm->bm_map))
+    if (!misc_test_bit (bit_number, bm->bm_map))
 	return;
-    clear_bit (bit_number, bm->bm_map);
+    misc_clear_bit (bit_number, bm->bm_map);
     bm->bm_set_bits --;
     bm->bm_dirty = 1;
 }
@@ -183,34 +190,32 @@
     if (bit_number >= bm->bm_bit_size)
 	printf ("bit %u, bitsize %lu\n", bit_number, bm->bm_bit_size);
     assert(bit_number < bm->bm_bit_size);
-    return test_bit(bit_number, bm->bm_map);
+    return misc_test_bit(bit_number, bm->bm_map);
 }
 
 
-int reiserfs_bitmap_zeros (reiserfs_bitmap_t * bm)
-{
+unsigned int reiserfs_bitmap_zeros (reiserfs_bitmap_t * bm) {
     return bm->bm_bit_size - bm->bm_set_bits;
 }
 
 
-int reiserfs_bitmap_ones (reiserfs_bitmap_t * bm)
-{
+unsigned int reiserfs_bitmap_ones (reiserfs_bitmap_t * bm) {
     return bm->bm_set_bits;
 }
 
 
-int reiserfs_bitmap_find_zero_bit (reiserfs_bitmap_t * bm, unsigned long * start)
+int reiserfs_bitmap_find_zero_bit (reiserfs_bitmap_t * bm, unsigned long * first)
 {
-    unsigned int  bit_nr = *start;
-    assert(*start < bm->bm_bit_size);
+    unsigned long bit_nr = *first;
+    assert(*first < bm->bm_bit_size);
 
-    bit_nr = find_next_zero_bit(bm->bm_map, bm->bm_bit_size, *start);
+    bit_nr = misc_find_next_zero_bit(bm->bm_map, bm->bm_bit_size, *first);
 
     if (bit_nr >= bm->bm_bit_size) { /* search failed */	
 	return 1;
     }
 
-    *start = bit_nr;
+    *first = bit_nr;
     return 0;
 }
 
@@ -218,14 +223,13 @@
 /* read every bitmap block and copy their content into bitmap 'bm' */
 static int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t * fs)
 {
-    unsigned long to_copy;
-    int copied;
-    int i;
-    char * p;
-    int last_byte_unused_bits;
-    unsigned long block;
+    unsigned int last_byte_unused_bits;
+    unsigned long block, to_copy;
     struct buffer_head * bh;
-
+    unsigned int i;
+    int copied;
+    int ret = 0;
+    char * p;
 
     to_copy = (get_sb_block_count (fs->fs_ondisk_sb) + 7) / 8;
 
@@ -248,8 +252,16 @@
 	    mark_buffer_uptodate (bh, 1);
 	}
 
-	if (to_copy < fs->fs_blocksize)
+	if (to_copy < fs->fs_blocksize) {
+	    for (i = to_copy; i < fs->fs_blocksize; i++) {
+		if (bh->b_data[i] != (char)0xff) {
+		    ret = 1;
+		    break;
+		}
+	    }
+	    
 	    copied = to_copy;
+	}
 	memcpy (p, bh->b_data, copied); 
 	brelse (bh);
 	p += copied;
@@ -265,8 +277,13 @@
     /* on disk bitmap has bits out of SB_BLOCK_COUNT set to 1, where as
        reiserfs_bitmap_t has those bits set to 0 */
     last_byte_unused_bits = bm->bm_byte_size * 8 - bm->bm_bit_size;
-    for (i = 0; i < last_byte_unused_bits; i ++)
-	clear_bit (bm->bm_bit_size + i, bm->bm_map);
+
+    for (i = 0; i < last_byte_unused_bits; i ++) {
+	if (misc_test_bit (bm->bm_bit_size + i, bm->bm_map) == 0)
+	    ret = 1;
+	else	    
+	    misc_clear_bit (bm->bm_bit_size + i, bm->bm_map);
+    }
 
     bm->bm_set_bits = 0;
     /* FIXME: optimize that */
@@ -275,7 +292,8 @@
 	    bm->bm_set_bits ++;
     
     bm->bm_dirty = 0;
-    return 0;
+
+    return ret;
 }
 
 
@@ -283,14 +301,10 @@
    changed and return 1. Otherwise - return 0 */
 int reiserfs_flush_to_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t * fs)
 {
-    unsigned long to_copy;
-    int copied;
-    int i;
-    char * p;
-    int last_byte_unused_bits;
-    unsigned long block;
+    unsigned int last_byte_unused_bits, i;
+    unsigned long to_copy, copied, block;
     struct buffer_head * bh;
-
+    char * p;
 
     /* make sure that the device is big enough */
     bh = bread (fs->fs_dev, bm->bm_bit_size - 1, fs->fs_blocksize);
@@ -331,8 +345,9 @@
 	if (copied == to_copy) {
 	    /* set unused bits of last byte of a bitmap to 1 */
 	    last_byte_unused_bits = bm->bm_byte_size * 8 - bm->bm_bit_size;
+
 	    for (i = 0; i < last_byte_unused_bits; i ++)
-		set_bit ((bm->bm_bit_size % (fs->fs_blocksize * 8)) + i, bh->b_data);
+		misc_set_bit ((bm->bm_bit_size % (fs->fs_blocksize * 8)) + i, bh->b_data);
 	}
 	mark_buffer_dirty (bh);
 	brelse (bh);
@@ -403,14 +418,14 @@
     __u32 v;
     int zeros;
     int count;
-    int i;
+    unsigned int i;
     int extents;
     long position;
 
   /*  fp = fopen (filename, "w+");
     if (!fp) {
-	reiserfs_warning (stderr, "reiserfs_bitmap_save: could not save bitmap in %s: %m",
-			  filename);
+	reiserfs_warning (stderr, "reiserfs_bitmap_save: could not save bitmap in %s: %s",
+			  filename, strerror(errno));
 	return;
     }*/
 
@@ -430,7 +445,7 @@
     position = ftell(fp);
 
     if (fseek (fp, 4, SEEK_CUR)) {
-	reiserfs_warning (stderr, "reiserfs_bitmap_save: fseek failed: %m\n");
+	reiserfs_warning (stderr, "reiserfs_bitmap_save: fseek failed: %s\n", strerror(errno));
 //	fclose (fp);
 	return;
     }
@@ -481,14 +496,14 @@
     fwrite (&v, 4, 1, fp);
 
     if (fseek (fp, position, SEEK_SET)) {
-	reiserfs_warning (stderr, "reiserfs_bitmap_save: fseek failed: %m");
+	reiserfs_warning (stderr, "reiserfs_bitmap_save: fseek failed: %s", strerror(errno));
 	return;
     }
 
     fwrite (&extents, 4, 1, fp);
 
     if (fseek (fp, 0, SEEK_END)) {
-	reiserfs_warning (stderr, "reiserfs_bitmap_save: fseek failed: %m");
+	reiserfs_warning (stderr, "reiserfs_bitmap_save: fseek failed: %s", strerror(errno));
 	return;
     }
 }
@@ -528,7 +543,8 @@
     __u32 v;
 
     if (fseek (fp, -4, SEEK_END)) {
-	reiserfs_warning (stderr, "is_stage_magic_correct: fseek failed: %m\n");
+	reiserfs_warning (stderr, "is_stage_magic_correct: fseek failed: %s\n", 
+	    strerror(errno));
 	return -1;
     }
 
@@ -539,7 +555,8 @@
     }
 
     if (fseek (fp, 0, SEEK_SET)) {
-	reiserfs_warning (stderr, "is_stage_magic_correct: fseek failed: %m\n");
+	reiserfs_warning (stderr, "is_stage_magic_correct: fseek failed: %s\n", 
+	    strerror(errno));
 	return -1;
     }
 
@@ -571,7 +588,7 @@
     
 /*    fp = fopen (filename, "r");
     if (!fp) {
-	reiserfs_warning (stderr, "reiserfs_bitmap_load: fopen failed: %m\n");
+	reiserfs_warning (stderr, "reiserfs_bitmap_load: fopen failed: %s\n", strerror(errno));
 	return 0;
     }*/
 
@@ -633,7 +650,7 @@
 
 void reiserfs_bitmap_invert (reiserfs_bitmap_t * bm)
 {
-    int i;
+    unsigned int i;
 
     /*reiserfs_warning (stderr, "Bitmap inverting..");fflush (stderr);*/
     for (i = 0; i < bm->bm_bit_size; i ++) {
@@ -659,33 +676,22 @@
 /* read bitmap blocks */
 int reiserfs_open_ondisk_bitmap (reiserfs_filsys_t * fs)
 {
-    struct buffer_head * bh;
-
     if (fs->fs_bitmap2)
 	reiserfs_panic ("%s: bitmap is initiaized already", __FUNCTION__);
     fs->fs_bitmap2 = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
     if (!fs->fs_bitmap2)
-	return 0;
+	return -1;
 
-    if ( (get_sb_block_count (fs->fs_ondisk_sb) + fs->fs_blocksize * 8 - 1) / (fs->fs_blocksize * 8) !=
-    	get_sb_bmap_nr (fs->fs_ondisk_sb)) {
+    if ((get_sb_block_count (fs->fs_ondisk_sb) + fs->fs_blocksize * 8 - 1) / 
+	(fs->fs_blocksize * 8) != get_sb_bmap_nr (fs->fs_ondisk_sb)) 
+    {
 	reiserfs_warning (stderr, "%s: wrong either bitmaps number,\n", __FUNCTION__);
-	reiserfs_warning (stderr, "count of blocks or blocksize, run with --rebuild-sb to fix it\n");
-	return 0;
+	reiserfs_warning (stderr, "count of blocks or blocksize, run with --rebuild-sb "
+	    "to fix it\n");
+	return -1;
     }    	
 
-    bh = bread (fs->fs_dev, fs->fs_bitmap2->bm_bit_size - 1, fs->fs_blocksize);
-    if (!bh) {
-	reiserfs_warning (stderr, "%s: bread failed for block %lu\n", __FUNCTION__,  fs->fs_bitmap2->bm_bit_size - 1);
-	reiserfs_warning (stderr, "\tYour partition is not big enough. Enlarge your partition or\n");
-	reiserfs_warning (stderr, "\trun reiserfsck with --rebuild-sb to fix super block.\n");
-	return 0;
-    }	
-
-    brelse (bh);
-    	
-    reiserfs_fetch_ondisk_bitmap (fs->fs_bitmap2, fs);
-    return 1;
+    return reiserfs_fetch_ondisk_bitmap (fs->fs_bitmap2, fs);
 }
 
 int reiserfs_create_ondisk_bitmap (reiserfs_filsys_t * fs)
diff --git a/reiserfscore/do_balan.c b/reiserfscore/do_balan.c
index 10e0734..fb9387b 100644
--- a/reiserfscore/do_balan.c
+++ b/reiserfscore/do_balan.c
@@ -1,6 +1,6 @@
 /*
- * Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Hans Reiser, see
- * reiserfs/README for licensing and copyright details
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 /* Now we have all buffers that must be used in balancing of the tree 	*/
@@ -344,8 +344,8 @@
 			    /* 0-th item in S0 can be only of DIRECT type when l_n != 0*/
 			    //B_N_PKEY (tbS0, 0)->k_offset += l_n;z
 			    key = B_N_PKEY (tbS0, 0);
-                            temp_n = (is_indirect_ih(B_N_PITEM_HEAD (tb->L[0], n + item_pos - ret_val))) ?
-                                 (l_n  / UNFM_P_SIZE) * tb->tb_fs->fs_blocksize : l_n;
+                            temp_n = is_indirect_ih(B_N_PITEM_HEAD (tb->L[0], n + item_pos - ret_val)) ?
+                                 (int)((l_n / UNFM_P_SIZE) * tb->tb_fs->fs_blocksize) : l_n;
 
 			    set_offset (key_format (key), key, get_offset (key) + temp_n);
 
@@ -848,10 +848,9 @@
 		else
 		    /* item falls wholly into S_new[i] */
 		{
-		    int ret_val;
 		    struct item_head * pasted;
 		
-		    ret_val = leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i], S_new[i]);
+		    leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i], S_new[i]);
 		    /* paste into item */
 		    bi.bi_bh = S_new[i];
 		    bi.bi_parent = 0;
@@ -983,7 +982,7 @@
     bi.bi_parent = 0;
     bi.bi_position = 0;
     make_empty_node (&bi);
-    set_bit(BH_Uptodate, &first_b->b_state);
+    misc_set_bit(BH_Uptodate, &first_b->b_state);
 
     tb->FEB[i] = 0;
     tb->used[i] = first_b;
@@ -1012,7 +1011,7 @@
 void reiserfs_invalidate_buffer (struct tree_balance * tb, struct buffer_head * bh, int do_free_block)
 {
     set_blkh_level (B_BLK_HEAD (bh), FREE_LEVEL);
-    clear_bit(BH_Dirty, &bh->b_state);
+    misc_clear_bit(BH_Dirty, &bh->b_state);
 
     if (do_free_block) {
 	struct buffer_head * to_be_forgotten;
diff --git a/reiserfscore/fix_node.c b/reiserfscore/fix_node.c
index 7e004b9..c2f996d 100644
--- a/reiserfscore/fix_node.c
+++ b/reiserfscore/fix_node.c
@@ -1,6 +1,6 @@
 /*
- * Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Hans Reiser, see
- * reiserfs/README for licensing and copyright details
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 /**
@@ -138,12 +138,8 @@
     int new_num;
     struct buffer_head * Sh;	/* this comes from tb->S[h] */
 
-    struct item_head * temp_ih;
-
     Sh = PATH_H_PBUFFER (tb->tb_path, h);
 
-    temp_ih = B_N_PITEM_HEAD (PATH_PLAST_BUFFER (tb->tb_path), B_NR_ITEMS (PATH_PLAST_BUFFER (tb->tb_path)) - 1);
-
     /* size of changed node */
     vn->vn_size = MAX_CHILD_SIZE (Sh->b_size) - get_blkh_free_space (B_BLK_HEAD (Sh)) + tb->insert_size[h];
 
@@ -1030,7 +1026,7 @@
     
     }
 
-    if (MAX_CHILD_SIZE (S0->b_size) + vn->vn_size <= rfree + lfree + ih_size) {
+    if ((int)MAX_CHILD_SIZE(S0->b_size) + vn->vn_size <= rfree + lfree + ih_size) {
 	set_parameters (tb, 0, -1, -1, -1, NULL, -1, -1);
 	return 1;  
     }
@@ -1422,19 +1418,16 @@
 {
     struct buffer_head * Sh = PATH_H_PBUFFER (tb->tb_path, h);
     int levbytes = tb->insert_size[h];
-    struct item_head * ih;
     struct item_head * r_ih = NULL;
   
-    ih = B_N_PITEM_HEAD (Sh, 0);
     if ( tb->CFR[h] )
 	r_ih = (struct item_head *)B_N_PDELIM_KEY(tb->CFR[h],tb->rkey[h]);
   
-    if (
-	lfree + rfree + sfree < MAX_CHILD_SIZE(Sh->b_size) + levbytes
+    if (lfree + rfree + sfree < (int)(MAX_CHILD_SIZE(Sh->b_size) + levbytes
 	/* shifting may merge items which might save space */
 	- (( ! h && is_left_mergeable (tb->tb_fs, tb->tb_path) == 1 ) ? IH_SIZE : 0)
 	- (( ! h && r_ih && is_right_mergeable (tb->tb_fs, tb->tb_path) == 1 ) ? IH_SIZE : 0)
-	+ (( h ) ? KEY_SIZE : 0))
+	+ (( h ) ? KEY_SIZE : 0)))
     {
 	/* node can not be removed */
 	if (sfree >= levbytes ) /* new item fits into node S[h] without any shifting */
@@ -1777,15 +1770,12 @@
   /* Sh is the node whose balance is currently being checked,
      and Fh is its father.  */
     struct buffer_head * Sh, * Fh;
-    int maxsize,
-	n_ret_value;
+    int n_ret_value;
     int lfree, rfree /* free space in L and R */;
 
     Sh = PATH_H_PBUFFER (tb->tb_path, h); 
     Fh = PATH_H_PPARENT (tb->tb_path, h); 
 
-    maxsize = MAX_CHILD_SIZE(Sh->b_size); 
-
     /* using tb->insert_size[h], which is negative in this case,
        create_virtual_node calculates: new_nr_item = number of items node
        would have if operation is performed without balancing (new_nr_item); */
@@ -1934,20 +1924,15 @@
        bytes. */
     int levbytes;
     /* the maximal item size */
-    int maxsize,
-	n_ret_value;
-    /* S0 is the node whose balance is currently being checked, and F0 is its
-       father.  */
-    struct buffer_head * S0, * F0;
+    int n_ret_value;
+    /* F0 is the parent of the node whose balance is currently being checked */
+    struct buffer_head * F0;
     int lfree, rfree /* free space in L and R */;
     
-    S0 = PATH_H_PBUFFER (tb->tb_path, 0);
     F0 = PATH_H_PPARENT (tb->tb_path, 0);
 
     levbytes = tb->insert_size[h];
 
-    maxsize = MAX_CHILD_SIZE(S0->b_size); 	/* maximal possible size of an item */
-
     if ( ! F0 ) {
 	/* S[0] is the root now. */
 	set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
diff --git a/reiserfscore/hashes.c b/reiserfscore/hashes.c
index 041ad55..607472b 100644
--- a/reiserfscore/hashes.c
+++ b/reiserfscore/hashes.c
@@ -1,6 +1,6 @@
 /*
- * Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Hans Reiser, see
- * reiserfs/README for licensing and copyright details
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 /*
diff --git a/reiserfscore/ibalance.c b/reiserfscore/ibalance.c
index 53c68fc..ff0a2c6 100644
--- a/reiserfscore/ibalance.c
+++ b/reiserfscore/ibalance.c
@@ -1,6 +1,6 @@
 /*
- * Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Hans Reiser, see
- * reiserfs/README for licensing and copyright details
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "includes.h"
diff --git a/reiserfscore/includes.h b/reiserfscore/includes.h
index f501cc6..15178d4 100644
--- a/reiserfscore/includes.h
+++ b/reiserfscore/includes.h
@@ -1,7 +1,8 @@
 /*
- * Copyright 2000, 2001, 2002 by Hans Reiser, licensing governed by
- * reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <string.h>
@@ -18,3 +19,5 @@
 #include "io.h"
 #include "misc.h"
 #include "reiserfs_lib.h"
+#include "swab.h"
+
diff --git a/reiserfscore/journal.c b/reiserfscore/journal.c
index 97250cb..c3fe777 100644
--- a/reiserfscore/journal.c
+++ b/reiserfscore/journal.c
@@ -1,5 +1,6 @@
 /*
- * Copyright 2002 Hans Reiser
+ * Copyright 2002-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "includes.h"
@@ -53,12 +54,57 @@
 	((offset + get_desc_trans_len (d_bh) + 2) % get_jp_journal_size (sb_jp));
 }
 
+/* common checks for validness of a transaction */
+int transaction_check_content (reiserfs_filsys_t * fs, reiserfs_trans_t * trans) {
+    struct buffer_head *d_bh, *c_bh;
+    struct reiserfs_journal_desc * desc;
+    struct reiserfs_journal_commit * commit;
+    unsigned long block;
+    unsigned int trans_half, i;
 
-/**/
-int is_valid_transaction (reiserfs_filsys_t * fs, struct buffer_head * d_bh)
-{
-    struct buffer_head * c_bh;
+    d_bh = bread (fs->fs_journal_dev, trans->desc_blocknr, fs->fs_blocksize);
+
+    if (!d_bh || who_is_this (d_bh->b_data, d_bh->b_size) != THE_JDESC)
+	goto error_desc_brelse;
+
+    /* read expected commit block and compare with descriptor block */
+    c_bh = bread (fs->fs_journal_dev, commit_expected (fs, d_bh), fs->fs_blocksize);
+    if (!c_bh)
+	goto error_desc_brelse;
+ 
+    if (!does_desc_match_commit (d_bh, c_bh)) 
+	goto error_commit_brelse;
+
+    /* Check that all target blocks are journalable */
+    desc = (struct reiserfs_journal_desc *)(d_bh->b_data);
+    commit = (struct reiserfs_journal_commit *)(c_bh->b_data);
+
+    trans_half = journal_trans_half (d_bh->b_size);
+    for (i = 0; i < get_desc_trans_len(d_bh); i++) {
+	if (i < trans_half)
+	    block = le32_to_cpu (desc->j2_realblock[i]);
+	else
+	    block = le32_to_cpu (commit->j3_realblock[i - trans_half]);
+
+	if (not_journalable(fs, block)) 
+	    goto error_commit_brelse;
+    }
     
+    brelse (d_bh);
+    brelse (c_bh);
+    return 1;
+    
+error_commit_brelse:
+    brelse (c_bh);
+error_desc_brelse:
+    brelse(d_bh);
+    return 0;
+}
+
+/* common checks for validness of a transaction */
+int transaction_check_desc(reiserfs_filsys_t * fs, struct buffer_head * d_bh) {
+    struct buffer_head * c_bh;
+    int ret = 1;
 
     if (!d_bh || who_is_this (d_bh->b_data, d_bh->b_size) != THE_JDESC)
 	return 0;
@@ -67,13 +113,12 @@
     c_bh = bread (fs->fs_journal_dev, commit_expected (fs, d_bh), fs->fs_blocksize);
     if (!c_bh)
 	return 0;
-    
-    if (does_desc_match_commit (d_bh, c_bh)) {
-	brelse (c_bh);
-	return 1;
-    }
+ 
+    if (!does_desc_match_commit (d_bh, c_bh)) 
+	ret = 0;
+
     brelse (c_bh);
-    return 0;
+    return ret;
 }
 
 
@@ -102,7 +147,7 @@
     trans_nr = 0;
     for (j_cur = 0; j_cur < j_size; j_cur ++) {
 	d_bh = bread (fs->fs_journal_dev, j_start + j_cur, fs->fs_blocksize);
-	if (!is_valid_transaction (fs, d_bh)) {
+	if (!transaction_check_desc (fs, d_bh)) {
 	    brelse (d_bh);
 	    continue;
 	}
@@ -158,9 +203,12 @@
 
     found = TRANS_NOT_FOUND;
 
+    if (trans->trans_id == break_trans.trans_id)
+	return found;
+	
     /* make sure that 'trans' is a valid transaction */
     d_bh = bread (fs->fs_journal_dev, trans->desc_blocknr, fs->fs_blocksize);
-    if (!is_valid_transaction (fs, d_bh))
+    if (!transaction_check_desc (fs, d_bh))
 	die ("next_transaction: valid transaction is expected");
 
     block = next_desc_expected (fs, d_bh);
@@ -168,7 +216,7 @@
 
     while (1) {
 	next_d_bh = bread (fs->fs_journal_dev, block, fs->fs_blocksize);
-	if (is_valid_transaction (fs, next_d_bh))
+	if (transaction_check_desc (fs, next_d_bh))
 	    break;
 
 	brelse (next_d_bh);
@@ -196,7 +244,7 @@
     return found;
 }
 
-static void read_journal_write_in_place (reiserfs_filsys_t * fs, reiserfs_trans_t * trans, int index, 
+static void read_journal_write_in_place (reiserfs_filsys_t * fs, reiserfs_trans_t * trans, unsigned int index, 
                                          unsigned long in_journal, unsigned long in_place)
 {
     struct buffer_head * j_bh, * bh;
@@ -234,11 +282,9 @@
     struct reiserfs_journal_desc * desc;
     struct reiserfs_journal_commit * commit;
     unsigned long j_start, j_offset, j_size;
-    int i;
+    unsigned int i, trans_half;
     unsigned long block;
-    int trans_half;
-
-    
+ 
     d_bh = bread (fs->fs_journal_dev, trans->desc_blocknr, fs->fs_blocksize);
     if (!d_bh) {
 	reiserfs_warning (stdout, "reading descriptor block %lu failed\n", trans->desc_blocknr);
@@ -295,31 +341,16 @@
 
     while (1) {
 	action (fs, &oldest);	
-	if ((ret == TRANS_LAST) || ((ret = next_transaction (fs, &oldest, newest)) == TRANS_NOT_FOUND) )
+	if (ret == TRANS_LAST)
+	    break;
+	ret = next_transaction (fs, &oldest, newest);	
+	if (ret == TRANS_NOT_FOUND)
 	    break;
     }
 }
 
-
-/* user is allowed to specify journal size and ratio between journal size and
-   max trans len. Max batch is calculated as 9/10 of max trans len. Max commit
-   and trans ages are not tunable so far */
-static __u32 advise_journal_length (reiserfs_filsys_t * fs, __u32 desired)
-{
-    if (!desired)
-        return journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize);
-
-    if (desired < JOURNAL_MIN_SIZE + 1) {
-		reiserfs_warning (stderr, "WARNING: Journal length is too small %u, resetting to minimal possible %u\n",
-						  desired, JOURNAL_MIN_SIZE + 1);
-        return JOURNAL_MIN_SIZE;
-    }
-
-    return desired;
-}
-
-
-unsigned long get_size_of_journal_or_reserved_area (struct reiserfs_super_block * sb)
+unsigned long get_size_of_journal_or_reserved_area(
+    struct reiserfs_super_block * sb)
 {
 	if (is_reiserfs_jr_magic_string (sb))
 		return get_sb_reserved_for_journal (sb);
@@ -329,13 +360,14 @@
 }
 
 
-__u32 advise_journal_max_trans_len (__u32 desired, __u32 journal_size, int blocksize)
+__u32 advise_journal_max_trans_len (__u32 desired, __u32 journal_size /* no j_header */, 
+    int blocksize, int verbose)
 {
     __u32 saved;
-	__u32 ratio = 1;
+    __u32 ratio = 1;
 
-	if (blocksize < 4096)
-		ratio = 4096/blocksize;
+    if (blocksize < 4096)
+	ratio = 4096/blocksize;
 	
     saved = desired;
     if (!desired)
@@ -350,10 +382,13 @@
     if (desired < JOURNAL_TRANS_MIN/ratio)
 		desired = JOURNAL_TRANS_MIN/ratio;
 
-    if (saved && saved != desired)
+    if (verbose) {
+	if (saved && saved != desired)
 		reiserfs_warning (stderr,
-						  "WARNING: wrong transaction "
-						  "max size (%u). Changed to %u\n", saved, desired);
+		    "WARNING: wrong transaction max size (%u). Changed to %u\n", 
+		    saved, desired);
+    }
+
     return desired;
 }
 #if 0
@@ -391,21 +426,64 @@
 }
 
 
+int reiserfs_journal_params_check (reiserfs_filsys_t * fs) {
+    struct reiserfs_journal_header * j_head;
+    struct reiserfs_super_block * sb = fs->fs_ondisk_sb;
+    
+    j_head = (struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data);
+	
+    /* Check the superblock's journal parameters. */
+    if (!is_reiserfs_jr_magic_string (sb)) {    
+	if (get_jp_journal_dev (sb_jp(sb)) != 0 || 
+	    get_jp_journal_1st_block (sb_jp(sb)) != get_journal_start_must (fs) || 
+	    get_jp_journal_size (sb_jp(sb)) != 
+	    journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
+	{
+	    reiserfs_warning (stderr, 
+		"\nreiserfs_open_journal: wrong journal parameters found in the "
+		"super block. \nYou should run reiserfsck with --rebuild-sb to "
+		"check your superblock consistency.\n\n");
+		
+	    return 1;
+	}
+    }
+	
+    if (memcmp(&j_head->jh_journal, sb_jp (sb), sizeof(struct journal_params))) {
+	if (!is_reiserfs_jr_magic_string (sb)) {
+	    reiserfs_warning (stderr, 
+		"\nreiserfs_open_journal: journal parameters from the superblock "
+		"does not match \nto the journal headers ones. It looks like that "
+		"you created your fs with old\nreiserfsprogs. Journal header is "
+		"fixed.\n\n", fs->fs_j_file_name);
+		
+	    memcpy(&j_head->jh_journal, sb_jp(sb), sizeof(struct journal_params));
+	    mark_buffer_dirty(fs->fs_jh_bh);
+	    bwrite(fs->fs_jh_bh);
+	} else {
+	    reiserfs_warning (stderr,
+		"\nreiserfs_open_journal: journal parameters from the super block "
+		"does not match \nto journal parameters from the journal. You should "
+		"run  reiserfsck with --rebuild-sb to check your superblock consistency.\n\n");
+		
+	    return 1;	
+	}
+    }
+    
+    return 0;
+}
+
 /* read journal header and make sure that it matches with the filesystem
    opened */
-int reiserfs_open_journal (reiserfs_filsys_t * fs, char * j_filename, int flags)
-{
-    struct buffer_head * bh;
-    struct reiserfs_journal_header * j_head;
+int reiserfs_open_journal (reiserfs_filsys_t * fs, char * j_filename, int flags) {
     struct reiserfs_super_block * sb;
-
-
+    __u64 count;
+    
     sb = fs->fs_ondisk_sb;
 
     if (!j_filename) {
         if (is_reiserfs_jr_magic_string (sb)) {
             /* create a special file to access journal */
-            return 0;   
+            return 1;
         } 
 	
 	j_filename = fs->fs_file_name;
@@ -414,58 +492,55 @@
 	if (strcmp (j_filename, fs->fs_file_name)) {
 	    reiserfs_warning (stderr, "Filesystem with standard journal found, "
 		"wrong name of specified journal device %s \n", j_filename);
-	    return 0;
+	    return 1;
 	}
     }
 
     fs->fs_journal_dev = open (j_filename, flags | O_LARGEFILE);
     if (fs->fs_journal_dev == -1) 
-        return 0;
-	
+        return -1;
+    
     asprintf (&fs->fs_j_file_name, "%s", j_filename);
-	
-    /* read journal header */
-    bh = bread (fs->fs_journal_dev, get_jp_journal_1st_block (sb_jp (sb)) +
-        get_jp_journal_size (sb_jp (sb)), fs->fs_blocksize);
-    if (!bh) {
-	reiserfs_warning (stderr, "reiserfs_open_journal: bread failed reading "
-		  "journal  header\n");
-	return 0;
+    
+    if (get_jp_journal_size(sb_jp(sb)) < JOURNAL_MIN_SIZE) {
+	reiserfs_warning (stderr, "Journal of (%lu) block size found on specified journal "
+	    "device %s.\nMust be not less than (%lu).\nRun --rebuild-sb to rebuild journal "
+	    "parameters.\n", get_jp_journal_size (sb_jp (sb)) + 1, j_filename, 
+	    JOURNAL_MIN_SIZE + 1);
+	return 1;
     }
-	
-    j_head = (struct reiserfs_journal_header *)(bh->b_data);
-	
-    if (is_reiserfs_jr_magic_string (sb)) {
-        if (get_jp_journal_1st_block (&j_head->jh_journal) != get_jp_journal_1st_block (sb_jp (sb)) || 
-            get_jp_journal_dev (&j_head->jh_journal) != get_jp_journal_dev (sb_jp (sb)) || 
-            get_jp_journal_size (&j_head->jh_journal) != get_jp_journal_size (sb_jp (sb))) 
-	{
-	    reiserfs_warning (stderr, "reiserfs_open_journal: no journal found on %s\n", j_filename);
-            brelse (bh);
-            return 0;
-        }
-    } else {
-	if (get_jp_journal_dev (sb_jp(sb)) != 0 || 
-	    get_jp_journal_1st_block (sb_jp(sb)) != get_journal_start_must (fs) || 
-	    get_jp_journal_size (sb_jp(sb)) != journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
-	{
-	    reiserfs_warning (stderr, "reiserfs_open_journal: wrong journal parameters found in the super block.\n");
-            brelse (bh);
-            return 0;
-	}
-	    
+    
+    count = count_blocks (j_filename, fs->fs_blocksize);
+    if (get_jp_journal_1st_block (sb_jp (sb)) + get_jp_journal_size (sb_jp (sb)) + 1 > count) {
+	reiserfs_warning (stderr, "Detected journal on specified device %s does not fit to "
+	    "the device.\nStart block (%lu) + size (%lu) less than device size (%lu).\n"
+	    "Run --rebuild-sb to rebuild journal parameters.\n", 
+	    get_jp_journal_1st_block(sb_jp (sb)), get_jp_journal_size(sb_jp (sb)) + 1,
+	    count);
+	return 1;
+    }
+    
+    /* read journal header */
+    fs->fs_jh_bh = bread (fs->fs_journal_dev, get_jp_journal_1st_block (sb_jp (sb)) 
+	+ get_jp_journal_size (sb_jp (sb)), fs->fs_blocksize);
+
+    if (!fs->fs_jh_bh) {
+	reiserfs_warning (stderr, "reiserfs_open_journal: bread failed reading "
+	    "journal  header.\n");
+	return -1;
     }
 
-    fs->fs_jh_bh = bh;
-    return 1;
+    return 0;
 }
 
-/* initialize super block's journal related fields and journal header fields. If
-   len is 0 - make journal of default size */
-int reiserfs_create_journal (reiserfs_filsys_t * fs, char * j_filename,
-							 unsigned long offset, 
-							 unsigned long len, /* journal size including journal header */
-							 int transaction_max_size)
+/* initialize super block's journal related fields and journal header fields. 
+ * If len is 0 - make journal of default size */
+int reiserfs_create_journal(
+    reiserfs_filsys_t * fs, 
+    char * j_device,		/* journal device name */
+    unsigned long offset,	/* journal offset on the j_device */
+    unsigned long len,		/* including journal header */
+    int transaction_max_size)
 {
     struct stat st;
     struct buffer_head * bh;
@@ -473,113 +548,126 @@
     struct reiserfs_super_block * sb;
     unsigned long blocks;
 
-    
     sb = fs->fs_ondisk_sb;
-
-
-    if (!j_filename || !strcmp (j_filename, fs->fs_file_name)) {
-	/* journal is to be on a host device, make sure that there is enough
-	   space for it */
-	if (!len)
-		len = journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1;
-			
-	if (!is_block_count_correct (
-		fs->fs_super_bh->b_blocknr, fs->fs_blocksize, get_sb_block_count (sb), len - 1)) {
-//	if (get_sb_block_count (sb) < min_block_amount (fs->fs_blocksize, len))	{
-		/* host device does not contain enough blocks */
-		reiserfs_warning (stderr, "reiserfs_create_journal: "
-					  "cannot create filesystem on %d blocks\n",
-					  get_sb_block_count (sb));
+    
+    if (!j_device || !strcmp (j_device, fs->fs_file_name)) {
+	/* Journal is to be on the host device, check the amount space for the 
+	 * journal on it. */
+	len = len ? len : journal_default_size(fs->fs_super_bh->b_blocknr, 
+	    fs->fs_blocksize) + 1;
+		
+	offset = offset ? offset : get_journal_start_must(fs);
+	
+	if (offset < get_journal_start_must(fs)) {
+	    reiserfs_warning (stderr, "reiserfs_create_journal: offset is "
+		"%lu, but it cannot be less then %llu on the device %s\n", 
+		offset, get_journal_start_must(fs), j_device);
+	    return 0;
+	}
+	
+	if (!is_block_count_correct(offset, fs->fs_blocksize, 
+	    get_sb_block_count(sb), len)) 
+	{
+	    /* host device does not contain enough blocks */
+	    reiserfs_warning (stderr, "reiserfs_create_journal: cannot create "
+		"a journal of %lu blocks with %lu offset on %d blocks\n", 
+		len, offset, get_sb_block_count(sb));
 		return 0;
 	}
-
-	j_filename = fs->fs_file_name;
-
-	/* journal is not on a separate device starts after super block and first
-           bitmap. offset is ignored */
-	offset = get_journal_start_must (fs);
+	
+	j_device = fs->fs_file_name;
+	
+	
 	st.st_rdev = 0;
     } else {
 	/* journal is to be on separate device */
-	blocks = count_blocks (j_filename, fs->fs_blocksize);
+	blocks = count_blocks (j_device, fs->fs_blocksize);
 	if (!len) {
-		/* default size of a journal on a separate device is whole device */
-		if (blocks < offset) {
-			reiserfs_warning (stderr,
-				  "reiserfs_create_journal: "
-				  "offset is %lu, blocks on device %lu\n",
-				  offset, blocks);
-			return 0;
-		}
-		len = blocks - offset;
+	    /* default size of a journal on a separate device is whole device */
+	    if (blocks < offset) {
+		reiserfs_warning (stderr, "reiserfs_create_journal: offset is "
+		    "%lu, blocks on device %lu\n", offset, blocks);
+		return 0;
+	    }
+	    len = blocks - offset;
 	}
 
-	if (len > journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1)
-		reiserfs_warning (stderr,
-			  "NOTE: journal new size %lu is greater than default size %lu:\n"
-			  "this may slow down journal initializing and mounting. Hope it is ok.\n\n",
-			  len, journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1);
+	if (len > journal_default_size (fs->fs_super_bh->b_blocknr, 
+	    fs->fs_blocksize) + 1) 
+	{
+	    fflush(stderr);
+	    
+	    reiserfs_warning (stdout, "NOTE: journal new size %lu is greater "
+		"than default size %lu:\nthis may slow down initializing and "
+		"mounting of the journal. Hope it is ok.\n\n", len, 
+		journal_default_size(fs->fs_super_bh->b_blocknr, 
+		fs->fs_blocksize) + 1);
+	}
 
 	if (blocks < offset + len) {
-		reiserfs_warning (stderr,
-			  "reiserfs_create_journal: "
-			  "no enough blocks on device %lu, needed %lu\n",
-			  blocks, offset + len);
-		return 0;
+	    reiserfs_warning (stderr, "reiserfs_create_journal: no enough "
+		"blocks on device %lu, needed %lu\n", blocks, offset + len);
+	    return 0;
 	}
-	if (stat (j_filename, &st) == -1) {
-		reiserfs_warning (stderr, "reiserfs_create_journal: "
-					  "stat %s failed: %m\n", j_filename);
-		return 0;
+	
+	if (stat (j_device, &st) == -1) {
+	    reiserfs_warning (stderr, "reiserfs_create_journal: stat %s failed"
+		": %s\n", j_device, strerror(errno));
+	    return 0;
 	}
+/*
 	if (!S_ISBLK (st.st_mode)) {
 		reiserfs_warning (stderr, "reiserfs_create_journal: "
-					  "%s is not a block device (%x)\n", j_filename, st.st_rdev);
+		"%s is not a block device (%x)\n", j_device, st.st_rdev);
 		return 0;
 	}
+*/
     }
 
-    fs->fs_journal_dev = open (j_filename, O_RDWR | O_LARGEFILE);
+    fs->fs_journal_dev = open (j_device, O_RDWR | O_LARGEFILE);
     if (fs->fs_journal_dev == -1) {
-	reiserfs_warning (stderr, "reiserfs_create_journal: could not open %s: %m\n",
-			  j_filename);
+	reiserfs_warning (stderr, "reiserfs_create_journal: could not open "
+	    "%s: %s\n", j_device, strerror(errno));
 	return 0;
     }
 
-    asprintf (&fs->fs_j_file_name, "%s", j_filename);
+    asprintf (&fs->fs_j_file_name, "%s", j_device);
 
-    len = advise_journal_length (fs, len - 1) + 1;
-
+    if (len < JOURNAL_MIN_SIZE) {
+	reiserfs_warning (stderr, "WARNING: Journal size (%u) is less, than "
+	    "minimal supported journal size (%u).", len, JOURNAL_MIN_SIZE + 1);
+        return 0;
+    }
     /* get journal header */
     bh = getblk (fs->fs_journal_dev, offset + len - 1, fs->fs_blocksize);
     if (!bh) {
-	reiserfs_warning (stderr, "reiserfs_create_journal: "
-				  "getblk failed\n");
+	reiserfs_warning (stderr, "reiserfs_create_journal: getblk failed\n");
 	return 0;
     }
 
     /* fill journal header */
     jh = (struct reiserfs_journal_header *)bh->b_data;
-    set_jp_journal_1st_block (&jh->jh_journal, offset);
-    set_jp_journal_dev (&jh->jh_journal, st.st_rdev);
-    set_jp_journal_magic (&jh->jh_journal, get_random ());
+    set_jp_journal_1st_block(&jh->jh_journal, offset);
+    set_jp_journal_dev(&jh->jh_journal, st.st_rdev);
+    set_jp_journal_magic(&jh->jh_journal, get_random());
 
-    set_jp_journal_size (&jh->jh_journal, len - 1);
-    set_jp_journal_max_trans_len (&jh->jh_journal,
-    	advise_journal_max_trans_len(transaction_max_size, len - 1, fs->fs_blocksize));
-    set_jp_journal_max_batch (&jh->jh_journal,
-    	advise_journal_max_batch (get_jp_journal_max_trans_len (&jh->jh_journal) ));
-    set_jp_journal_max_commit_age (&jh->jh_journal, advise_journal_max_commit_age ());
-    set_jp_journal_max_trans_age (&jh->jh_journal, advise_journal_max_trans_age ());
+    set_jp_journal_size(&jh->jh_journal, len - 1);
+    set_jp_journal_max_trans_len(&jh->jh_journal, advise_journal_max_trans_len(
+	transaction_max_size, len - 1, fs->fs_blocksize, 1));
+    set_jp_journal_max_batch(&jh->jh_journal, advise_journal_max_batch(
+	get_jp_journal_max_trans_len(&jh->jh_journal)));
+    set_jp_journal_max_commit_age(&jh->jh_journal, 
+	advise_journal_max_commit_age());
+    set_jp_journal_max_trans_age(&jh->jh_journal, 
+	advise_journal_max_trans_age ());
 
     mark_buffer_uptodate (bh, 1);
     mark_buffer_dirty (bh);
-
+    
     fs->fs_jh_bh = bh;
-
+    
     /* make a copy of journal header in the super block */
     memcpy (sb_jp (sb), &jh->jh_journal, sizeof (struct journal_params));
-
     mark_buffer_dirty (fs->fs_super_bh);
 
     return 1;
@@ -601,7 +689,7 @@
     flush_buffers (fs->fs_journal_dev);
     invalidate_buffers (fs->fs_journal_dev);
     if (close (fs->fs_journal_dev))
-	die ("reiserfs_reopen_journal: closed failed: %m");
+	die ("reiserfs_reopen_journal: closed failed: %s", strerror(errno));
 
     fs->fs_journal_dev = open (fs->fs_j_file_name, flag | O_LARGEFILE);
     if (fs->fs_journal_dev == -1)
@@ -665,7 +753,7 @@
     struct buffer_head * bh;
     struct reiserfs_journal_header * j_head;
     reiserfs_trans_t cur, newest, control;
-    int replayed, ret = 0;
+    int replayed, ret;
 
     if (!reiserfs_journal_opened (fs))
         reiserfs_panic ("replay_journal: journal is not opened");
@@ -686,29 +774,53 @@
 	return 0;
     }
 
-    if (control.mount_id != newest.mount_id) {
-	reiserfs_warning (stderr, "Journal header's mountid: %lu\n"
-	  "latest transaction found is of mountid %lu\n", control.mount_id, newest.mount_id);
-        if (user_confirmed (stderr, "Should those transactions be replayed?(Y/n)[n]", "Y\n")) {
-            control.mount_id = newest.mount_id;
-//            control.trans_id = 0;
-        }
-    }
-	
+    /*  Smth strange with journal header or journal. We cannot say for sure what was the last 
+	replaied transaction, but relying on JH data is preferable. */
+
     replayed = 0;
-    while (1) {
-	if (cur.mount_id == control.mount_id && cur.trans_id > control.trans_id) {
-            reiserfs_warning (stderr, "trans replayed: mountid %lu, transid %lu, desc %lu, "
-                "len %lu, commit %lu, next trans offset %lu\n",
-		cur.mount_id, cur.trans_id, cur.desc_blocknr, cur.trans_len,
-		cur.commit_blocknr, cur.next_trans_offset);
-	    replay_one_transaction (fs, &cur);
-	    update_journal_header (bh, cur);
-            replayed ++;
-	}
-	if ((ret == TRANS_LAST) || ((ret = next_transaction (fs, &cur, newest)) == TRANS_NOT_FOUND) )
+    ret = TRANS_FOUND;
+    
+    while (cur.mount_id != control.mount_id || cur.trans_id != control.trans_id) {
+	if (control.mount_id == cur.mount_id && control.trans_id == 0 && 
+	    control.desc_blocknr == 0)
+	    break;
+	
+	ret = next_transaction (fs, &cur, newest);
+	
+	if (ret != TRANS_FOUND)
 	    break;
     }
+
+    while (ret == TRANS_FOUND) {
+	if (control.mount_id != cur.mount_id || control.trans_id != 0 || 
+	    control.desc_blocknr != 0) 
+	{
+	    ret = next_transaction (fs, &cur, newest);
+	    
+	    if (ret == TRANS_NOT_FOUND)
+		break;
+	    
+	    if (cur.mount_id != control.mount_id || cur.trans_id != control.trans_id + 1)
+		break;	    
+	}
+	
+	if (!transaction_check_content(fs, &cur)) {
+	    reiserfs_warning (stderr, "Trans broken: mountid %lu, transid %lu, desc %lu, "
+		"len %lu, commit %lu, next trans offset %lu\n", cur.mount_id, cur.trans_id, 
+		cur.desc_blocknr, cur.trans_len, cur.commit_blocknr, cur.next_trans_offset);
+	    break;
+	}
+
+        reiserfs_warning (stderr, "Trans replayed: mountid %lu, transid %lu, desc %lu, "
+            "len %lu, commit %lu, next trans offset %lu\n",
+	    cur.mount_id, cur.trans_id, cur.desc_blocknr, cur.trans_len,
+	    cur.commit_blocknr, cur.next_trans_offset);
+	replay_one_transaction (fs, &cur);
+	update_journal_header (bh, cur);
+	control = cur;
+        replayed ++;
+    }
+
     reiserfs_warning (stderr, "%d transactions replayed\n", replayed);
 	
     mark_buffer_dirty (fs->fs_super_bh);
diff --git a/reiserfscore/lbalance.c b/reiserfscore/lbalance.c
index c2645dc..2a21ee0 100644
--- a/reiserfscore/lbalance.c
+++ b/reiserfscore/lbalance.c
@@ -1,6 +1,6 @@
 /*
- * Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Hans Reiser, see
- * reiserfs/README for licensing and copyright details
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "includes.h"
@@ -704,9 +704,8 @@
 	mark_buffer_dirty(bi->bi_parent) ;
     }
 
-    if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF)
-	reiserfs_panic ("leaf_insert_into_buf: bad leaf %lu: %b",
-			bh->b_blocknr, bh);
+    if (is_a_leaf(bh->b_data, bh->b_size) != THE_LEAF)
+	reiserfs_panic ("leaf_insert_into_buf: bad leaf %lu: %b", bh->b_blocknr, bh);
 }
 
 
@@ -784,9 +783,8 @@
 	set_dc_child_size (dc, get_dc_child_size (dc) + paste_size);
 	mark_buffer_dirty(bi->bi_parent);
     }
-    if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF)
-	reiserfs_panic ("leaf_paste_in_buffer: bad leaf %lu: %b",
-			bh->b_blocknr, bh);
+    if (is_a_leaf(bh->b_data, bh->b_size) != THE_LEAF)
+	reiserfs_panic ("leaf_paste_in_buffer: bad leaf %lu: %b", bh->b_blocknr, bh);
 }
 
 
@@ -951,7 +949,7 @@
 	set_dc_child_size (dc, get_dc_child_size (dc) - cut_size);
 	mark_buffer_dirty(bi->bi_parent);
     }
-    if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF)
+    if (is_a_leaf(bh->b_data, bh->b_size) != THE_LEAF)
 	reiserfs_panic ("leaf_cut_from_buffer: bad leaf %lu: %b",
 			bh->b_blocknr, bh);
 }
@@ -1013,12 +1011,12 @@
 	struct disk_child * dc;
 
 	dc = B_N_CHILD (bi->bi_parent, bi->bi_position);
-	set_dc_child_size (dc, get_dc_child_size (dc) - (j - last_removed_loc + IH_SIZE * del_num));
+	set_dc_child_size (dc, get_dc_child_size (dc) - 
+	    (j - last_removed_loc + IH_SIZE * del_num));
 	mark_buffer_dirty(bi->bi_parent);
     }
-    if (who_is_this (bh->b_data, bh->b_size) != THE_LEAF)
-	reiserfs_panic ("leaf_delete_items_entirely: bad leaf %lu: %b",
-			bh->b_blocknr, bh);
+    if (is_a_leaf(bh->b_data, bh->b_size) != THE_LEAF)
+	reiserfs_panic ("leaf_delete_items_entirely: bad leaf %lu: %b", bh->b_blocknr, bh);
 }
 
 
@@ -1075,7 +1073,6 @@
     memmove ((char *)(deh + new_entry_count), deh, insert_point - (char *)deh);
 
     /* copy new entry heads */
-    deh = (struct reiserfs_de_head *)((char *)deh);
     memcpy (deh, new_dehs, DEH_SIZE * new_entry_count);
 
     /* set locations of new records */
diff --git a/reiserfscore/node_formats.c b/reiserfscore/node_formats.c
index 119e099..cc404bc 100644
--- a/reiserfscore/node_formats.c
+++ b/reiserfscore/node_formats.c
@@ -1,23 +1,94 @@
 /*
- *  Copyright 2000, 2001, 2002 by Hans Reiser, licensing governed by
- *  reiserfs/README
+ *  Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ *  reiserfsprogs/README
  */
 
-
 #include "includes.h"
 
-int correct_direct_item_offset (__u64 offset, int format) {
-    if (format == KEY_FORMAT_2) {
-        return (offset && ((offset - 1) % 8 == 0));
-    } else {
-	return (offset);
+int leaf_count_ih(char * buf, int blocksize) {
+    struct item_head * ih;
+    int prev_location;
+    int nr;
+
+    /* look at the table of item head */
+    prev_location = blocksize;
+    ih = (struct item_head *)(buf + BLKH_SIZE);
+    nr = 0;
+    while (1) {
+	if (get_ih_location (ih) + get_ih_item_len (ih) != prev_location)
+	    break;
+	if (get_ih_location (ih) < IH_SIZE * (nr + 1) + BLKH_SIZE)
+	    break;
+	if (get_ih_item_len (ih) > MAX_ITEM_LEN (blocksize))
+	    break;
+	prev_location = get_ih_location (ih);
+	ih ++;
+	nr ++;
     }
-    return 0;
+    
+    return nr;
 }
 
+int leaf_free_space_estimate(char * buf, int blocksize) {
+    struct block_head * blkh;
+    struct item_head * ih;
+    int nr;
+    
+    blkh = (struct block_head *)buf;
+    nr = get_blkh_nr_items(blkh);    
+    ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1;
+    
+    return (nr ? get_ih_location (ih) : blocksize) - BLKH_SIZE - IH_SIZE * nr;
+}
+
+static int leaf_blkh_correct(char * buf, int blocksize) {
+    struct block_head * blkh;
+    unsigned int nr;
+
+    blkh = (struct block_head *)buf;
+    if (!is_leaf_block_head (buf))
+	return 0;
+
+    nr = get_blkh_nr_items(blkh);
+    if (nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN)))
+	/* item number is too big or too small */
+	return 0;
+
+    return leaf_free_space_estimate(buf, blocksize) == get_blkh_free_space (blkh);
+}
+
+int is_a_leaf(char * buf, int blocksize) {
+    struct block_head * blkh;
+    int counted;
+    
+    blkh = (struct block_head *)buf;
+    if (!is_leaf_block_head (buf))
+	return 0;
+
+    counted = leaf_count_ih(buf, blocksize);
+    
+    /* if leaf block header is ok, check item count also. */
+    if (leaf_blkh_correct(buf, blocksize))
+	return counted >= get_blkh_nr_items (blkh) ? THE_LEAF : HAS_IH_ARRAY;
+    
+    /* leaf block header is corrupted, it is ih_array if some items were detected.*/
+    return counted ? HAS_IH_ARRAY : 0;
+}
+
+int leaf_item_number_estimate(struct buffer_head * bh) {
+    struct block_head * blkh;
+    int nr;
+    
+    nr = leaf_count_ih(bh->b_data, bh->b_size);
+    blkh = (struct block_head *)bh->b_data;
+
+    return nr >= get_blkh_nr_items (blkh) ? get_blkh_nr_items (blkh) : nr;
+}
+
+#if 0
 /* this only checks block header and item head array (ih_location-s
    and ih_item_len-s). Item internals are not checked */
-static int does_node_look_like_a_leaf (char * buf, int blocksize)
+int does_node_look_like_a_leaf (char * buf, int blocksize)
 {
     struct block_head * blkh;
     struct item_head * ih;
@@ -37,6 +108,7 @@
 
     ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1;
     used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - (nr ? get_ih_location (ih) : blocksize));
+
     if (used_space != blocksize - get_blkh_free_space (blkh))
 	/* free space does not match to calculated amount of use space */
 	return 0;
@@ -63,10 +135,9 @@
     return 1;
 }
 
-
 /* check ih_item_len and ih_location. Should be useful when block head is
    corrupted */
-int does_node_have_ih_array (char * buf, int blocksize)
+static int does_node_have_ih_array (char * buf, int blocksize)
 {
     struct item_head * ih;
     int prev_location;
@@ -88,13 +159,13 @@
 	return 0;
     return nr;
 }
-
+#endif
 
 /* returns 1 if buf looks like an internal node, 0 otherwise */
 static int is_correct_internal (char * buf, int blocksize)
 {
     struct block_head * blkh;
-    int nr;
+    unsigned int nr;
     int used_space;
 
     blkh = (struct block_head *)buf;
@@ -123,7 +194,7 @@
     if (B_LEVEL (bh) != level)
 	return 0;
     if (is_leaf_node (bh))
-	return does_node_look_like_a_leaf (bh->b_data, bh->b_size);
+	return is_a_leaf(bh->b_data, bh->b_size);
 
     return is_correct_internal (bh->b_data, bh->b_size);
 }
@@ -203,30 +274,6 @@
     return 0;
 }
 
-
-
-#if 0
-/* returns code of             0 -  here means 3.5 format,
-                               2 - either pure 3.6 or converted 3.5
-                               3 - journal-relocated 3.6*/
-int magic_2_version (struct reiserfs_super_block * rs)
-{
-    int ret;
-
-    ret = 0;
-    if (is_reiser2fs_magic_string (rs)) 
-	ret = REISERFS_VERSION_2 ;
-    else if (is_reiser2fs_jr_magic_string (rs))
-	ret = REISERFS_VERSION_3;
-    else if (is_reiserfs_magic_string (rs))
-	ret = REISERFS_VERSION_1;
-    else
-	reiserfs_panic ("magic_2_version: unknown magic string found");
-    return ret;
-}
-#endif
-
-
 /* this one had signature in different place of the super_block
    structure */
 int is_prejournaled_reiserfs (struct reiserfs_super_block * rs)
@@ -251,19 +298,17 @@
    block, journal descriptor), unformatted */
 int who_is_this (char * buf, int blocksize)
 {
+    int res;
+    
     /* super block? */
     if (does_look_like_super_block ((void *)buf))
 	return THE_SUPER;
 
-    if (does_node_look_like_a_leaf (buf, blocksize))
-	/* block head and item head array seem matching (node level, free
-           space, item number, item locations and length) */
-	return THE_LEAF;
-
-    if (does_node_have_ih_array (buf, blocksize)) {
-	/* item header array found */
-	return HAS_IH_ARRAY;
-    }
+    if ((res = is_a_leaf(buf, blocksize)))
+	/* if block head and item head array seem matching (node level, free
+           space, item number, item locations and length), then it is THE_LEAF,
+	  otherwise, it is HAS_IH_ARRAY */
+	return res;
 
     if (is_correct_internal (buf, blocksize))
 	return THE_INTERNAL;
@@ -282,7 +327,7 @@
 char * which_block (int code)
 {
     static char * leaf = "leaf";
-    static char * broken_leaf = "leaf w/o block head";
+    static char * broken_leaf = "broken leaf";
     static char * internal = "internal";
     static char * other = "unknown";
 
@@ -299,8 +344,7 @@
 
 
 /** */
-int block_of_journal (reiserfs_filsys_t * fs, unsigned long block)
-{
+int block_of_journal (reiserfs_filsys_t * fs, unsigned long block) {
     if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb)) {
 	/* standard journal */
 	if (block >= get_journal_start_must (fs) &&
@@ -328,9 +372,7 @@
 	return (block == (REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize + 1)) ;
     } else {
 	/* bitmap in */
-	if (block > 2 && block < 3 + get_sb_bmap_nr (fs->fs_ondisk_sb))
-	    return 1;
-	return 0;
+	return (block > 2ul && block < 3ul + get_sb_bmap_nr(fs->fs_ondisk_sb)) ? 1 : 0;
     }
     return 0;
 }
@@ -343,9 +385,6 @@
 	/* it is one of bitmap blocks */
 	return 1;
 
-    if (block > 32768)
-	return 0;
-
     if (block_of_journal (fs, block))
 	/* block of journal area */
 	return 1;
@@ -377,26 +416,24 @@
 
 // in reiserfs version 0 (undistributed bitmap)
 // FIXME: what if number of bitmaps is 15?
-int get_journal_old_start_must (reiserfs_filsys_t * fs)
-{
-    return (REISERFS_OLD_DISK_OFFSET_IN_BYTES / fs->fs_blocksize) + 1 + get_sb_bmap_nr (fs->fs_ondisk_sb);
+unsigned int get_journal_old_start_must (reiserfs_filsys_t * fs) {
+    return (REISERFS_OLD_DISK_OFFSET_IN_BYTES / fs->fs_blocksize) + 1 + 
+	get_sb_bmap_nr (fs->fs_ondisk_sb);
 }
 
-int get_journal_new_start_must (reiserfs_filsys_t * fs)
+unsigned int get_journal_new_start_must (reiserfs_filsys_t * fs)
 {
     return (REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize) + 2;
 }
 
-int get_journal_start_must (reiserfs_filsys_t * fs) {
-//    if (fs->fs_super_bh->b_size == 4096 && fs->fs_super_bh->b_blocknr == 2)
-    if (is_old_sb_location (fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
+unsigned int get_journal_start_must(reiserfs_filsys_t * fs) {
+    if (is_old_sb_location(fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
     	return get_journal_old_start_must (fs);
 
-    return get_journal_new_start_must (fs);
+    return get_journal_new_start_must(fs);
 }
 
-__u64 get_bytes_number (struct item_head * ih, int blocksize)
-{
+__u32 get_bytes_number (struct item_head * ih, int blocksize) {
     switch (get_type (&ih->ih_key)) {
     case TYPE_DIRECT:
 	return get_ih_item_len (ih);
@@ -413,79 +450,6 @@
 
 int check_item_f (reiserfs_filsys_t * fs, struct item_head * ih, char * item);
 
-#if 0
-/* look at the 16 byte and try to find: does it look like a reiserfs
-   key. Returns 0 if something looks broken in the key, 1 otherwise */
-static int does_key_look_correct (reiserfs_filsys_t * fs, struct key * key)
-{
-    int type;
-
-    if (key->k_dir_id == key->k_objectid ||
-	!key->k_dir_id || key->k_objectid < 2)
-	/* k_dir_id and k_objectid must be different, and > 0 */
-	return 0;
-
-    if (key->u.k_offset_v1.k_offset == 0 &&
-	key->u.k_offset_v1.k_uniqueness == 0)
-	/* looks like a stat data */
-	return 1;
-
-    if (!key->u.k_offset_v1.k_offset ||
-	!key->u.k_offset_v1.k_uniqueness)
-	/* these should be either both 0 or both !0 */
-	return 0;
-
-    type = key->u.k_offset_v2.k_type;
-
-    if (key->u.k_offset_v1.k_uniqueness == 500)
-	/* looks like a key of directory entry */
-	return (type == 0) ? 1 : 0;
-
-    if (type == 15) {
-	/* looks like old key of */
-	if (key->u.k_offset_v1.k_uniqueness == 0xffffffff) {
-	    /* direct item. Check offset */
-	    if (key->u.k_offset_v1.k_offset >= fs->s_blocksize * 4 + 1)
-		/* fixme: this could be more accurate */
-		return 0;
-	    return 1;
-	}
-
-	if (key->u.k_offset_v1.k_uniqueness == 0xfffffffe) {
-	    /* indirect item. Check offset */
-	    if (key->u.k_offset_v1.k_offset % fs->s_blocksize != 1)
-		return 0;
-	    return 1;
-	}
-
-	return 0;
-    }
-
-    /* there should be a new key of indirect or direct item */
-
-    if (type == TYPE_DIRECT) {
-	/* check offset */
-	if (key->u.k_offset_v2.k_offset >= fs->s_blocksize * 4 + 1) /* fixme*/
-	    /* fixme: this could be more accurate */
-	    return 0;
-
-	if ((key->u.k_offset_v2.k_offset - 1) % 8 != 0)
-	    /* "new" direct items get split on the boundary of 8 byte */
-	    return 0;
-	
-	return 1;
-    }
-
-    if (type == TYPE_INDIRECT) {
-	/* check offset */
-	if ((key->u.k_offset_v2.k_offset % fs->s_blocksize) != 1)
-	    return 0;
-	return 1;
-    }
-
-    return 0;
-}
-#endif
 /* ih_key, ih_location and ih_item_len seem correct, check other fields */
 static int does_ih_look_correct (struct item_head * ih)
 {
@@ -522,7 +486,7 @@
 static int is_bad_indirect (reiserfs_filsys_t * fs, struct item_head * ih, char * item,
 			    check_unfm_func_t check_unfm_func)
 {
-    int i;
+    unsigned int i;
     __u32 * ind = (__u32 *)item;
 
     if (get_ih_item_len (ih) % UNFM_P_SIZE)
@@ -571,7 +535,7 @@
 int is_properly_hashed (reiserfs_filsys_t * fs,
 			char * name, int namelen, __u32 offset)
 {
-    int i;
+    unsigned int i;
 
     if (namelen == 1 && name[0] == '.') {
 	if (offset == DOT_OFFSET)
@@ -610,30 +574,14 @@
 
     if (good_name (reiserfs_hash(fs), name, namelen, offset))
 	return 1;
-#if 0
-    fprintf (stderr, "is_properly_hashed: namelen %d, name \"%s\", offset %u, hash %u\n",
-	    namelen, name_from_entry (name, namelen), GET_HASH_VALUE (offset),
-	    GET_HASH_VALUE (reiserfs_hash(fs) (name, namelen)));
 
-    /* we could also check whether more than one hash function match on the
-       name */
-    for (i = 1; i < sizeof (hashes) / sizeof (hashes [0]); i ++) {
-	if (i == g_real_hash)
-	    continue;
-	if (good_name (hashes[i], name, namelen, deh_offset)) {
-	    die ("bad_hash: at least two hashes got screwed up with this name: \"%s\"",
-		 bad_name (name, namelen));
-	}
-    }
-#endif
     return 0;
 }
 
 
-int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, int code_to_try_first)
+int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, unsigned int code_to_try_first)
 {
-    int i;
-
+    unsigned int i;
 
     if (!namelen || !name[0])
 	return UNSET_HASH;
@@ -642,6 +590,7 @@
 	if (hash_value_masked == GET_HASH_VALUE (hashes [code_to_try_first].func (name, namelen)))
 	    return code_to_try_first;
     }
+    
     for (i = 1; i < HASH_AMOUNT; i ++) {
 	if (i == code_to_try_first)
 	    continue;
@@ -654,8 +603,7 @@
 }
 
 
-char * code2name (int code)
-{
+char * code2name(unsigned int code) {
     if (code >= HASH_AMOUNT || code < 0)
         return 0;
     return hashes [code].name;
@@ -664,7 +612,7 @@
 
 int func2code (hashf_t func)
 {
-    int i;
+    unsigned int i;
     
     for (i = 0; i < HASH_AMOUNT; i ++)
 	if (func == hashes [i].func)
@@ -675,8 +623,7 @@
 }
 
 
-hashf_t code2func (int code)
-{
+hashf_t code2func(unsigned int code) {
     if (code >= HASH_AMOUNT) {
 	reiserfs_warning (stderr, "code2func: wrong hash code %d.\n"
 			  "Using default %s hash function\n", code,
@@ -687,9 +634,8 @@
 }
 
 
-hashf_t name2func (char * hash)
-{
-    int i;
+hashf_t name2func (char * hash) {
+    unsigned int i;
  
     for (i = 0; i < HASH_AMOUNT; i ++)
 	if (!strcmp (hash, hashes [i].name))
@@ -730,9 +676,9 @@
 	prev_location = get_deh_location (deh);
 	    
 	namelen = name_in_entry_length (ih, deh, i);
-	if (namelen > REISERFS_MAX_NAME_LEN (fs->fs_blocksize)) {
+	if (namelen > (int)REISERFS_MAX_NAME_LEN(fs->fs_blocksize))
 	    return 1;
-	}
+	
 	if (get_deh_offset (deh) <= prev_offset)
 	    return 1;
 	prev_offset = get_deh_offset (deh);
@@ -980,8 +926,7 @@
 }
 
 
-loff_t get_offset (const struct key * key)
-{
+unsigned long long get_offset (const struct key * key) {
     if (key_format (key) == KEY_FORMAT_1)
 	return get_key_offset_v1 (key);
 
@@ -1352,8 +1297,9 @@
 }
 
 
-int is_blocksize_correct (int blocksize)
+int is_blocksize_correct (unsigned int blocksize)
 {
-    return ((blocksize == 0) || (blocksize % 1024) ? 0 : 1);
+    return ((blocksize == 0) || (((blocksize & -blocksize) == blocksize) 
+	&& (blocksize >=512) && (blocksize <= 8192)));
 }
 
diff --git a/reiserfscore/prints.c b/reiserfscore/prints.c
index f43b5bd..e6597bc 100644
--- a/reiserfscore/prints.c
+++ b/reiserfscore/prints.c
@@ -1,6 +1,6 @@
 /*
- * Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Hans Reiser, see
- * reiserfs/README for licensing and copyright details
+ * Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "includes.h"
@@ -376,7 +376,7 @@
 void print_indirect_item (FILE * fp, struct buffer_head * bh, int item_num)
 {
     struct item_head * ih;
-    int j;
+    unsigned int j;
     __u32 * unp, prev = INT_MAX;
     int num;
 
@@ -403,7 +403,7 @@
 
 char * timestamp (time_t t)
 {
-    strftime (timebuf, 256, "%m/%d/%Y %T", localtime (&t));
+    strftime (timebuf, 256, "%d/%Y %T", localtime (&t));
     return timebuf;
 }
 
@@ -517,8 +517,8 @@
 
     blkh = B_BLK_HEAD (bh);
     ih = B_N_PITEM_HEAD (bh,0);
-    nr = get_blkh_nr_items (blkh);
-
+    nr = leaf_count_ih(bh->b_data, bh->b_size);
+    
     reiserfs_warning (fp,
 		      "\n===================================================================\n");
     reiserfs_warning (fp, "LEAF NODE (%ld) contains %b (real items %d)\n",
@@ -526,7 +526,7 @@
 
     if (!(print_mode & PRINT_TREE_DETAILS)) {
 	reiserfs_warning (fp, "FIRST ITEM_KEY: %k, LAST ITEM KEY: %k\n",
-			   &(ih->ih_key), &((ih + get_blkh_nr_items (blkh) - 1)->ih_key));
+			   &(ih->ih_key), &((ih + nr - 1)->ih_key));
 	return 0;
     }
 
@@ -607,6 +607,7 @@
     struct reiserfs_super_block * sb = (struct reiserfs_super_block *)(bh->b_data);
     dev_t rdev;
     int format = 0;
+    __u16 state;
 
     if (!does_look_like_super_block (sb))
 	return 1;
@@ -643,7 +644,7 @@
 	reiserfs_warning (fp, "Root block: %u\n", get_sb_root_block (sb));
     }
     reiserfs_warning (fp, "Filesystem is %scleanly umounted\n",
-		      (get_sb_umount_state (sb) == REISERFS_CLEANLY_UMOUNTED) ? "" : "NOT ");
+		      (get_sb_umount_state (sb) == FS_CLEANLY_UMOUNTED) ? "" : "NOT ");
 
     if (short_print)
     	return 0;
@@ -656,14 +657,23 @@
     print_journal_params (fp, sb_jp (sb));
     reiserfs_warning (fp, "Blocks reserved by journal: %u\n",
 		      get_sb_reserved_for_journal (sb));
-    reiserfs_warning (fp, "Fs state field: 0x%x\n", get_sb_fs_state (sb));
+    state = get_sb_fs_state (sb);
+    reiserfs_warning (fp, "Fs state field: 0x%x:\n", state);
+    if ((state & FS_FATAL) == FS_FATAL)
+	reiserfs_warning (fp, "\tFATAL corruptions exist.\n");
+    if ((state & FS_ERROR) == FS_ERROR)
+	reiserfs_warning (fp, "\t some corruptions exist.\n");
+    if ((state & IO_ERROR) == IO_ERROR)
+	reiserfs_warning (fp, "\tI/O corruptions exist.\n");
+
     reiserfs_warning (fp, "sb_version: %u\n", get_sb_version (sb));
     if (format == 2) {
         reiserfs_warning (fp, "inode generation number: %u\n", get_sb_v2_inode_generation (sb));
         reiserfs_warning (fp, "UUID: %U\n", sb->s_uuid);
         reiserfs_warning (fp, "LABEL: %.16s\n", sb->s_label);
         reiserfs_warning (fp, "Set flags in SB:\n");
-        reiserfs_warning (fp, "\t%s\n", ((get_sb_v2_flag (sb, reiserfs_attrs_cleared)) ? "ATTRIBUTES CLEAN" : ""));
+	if ((get_sb_v2_flag (sb, reiserfs_attrs_cleared)))
+	    reiserfs_warning (fp, "\tATTRIBUTES CLEAN\n");
     }
 
     return 0;
@@ -722,8 +732,7 @@
 
 void print_tb (int mode, int item_pos, int pos_in_item, struct tree_balance * tb, char * mes)
 {
-  int h = 0;
-  int i;
+  unsigned int h = 0;
   struct buffer_head * tbSh, * tbFh;
 
 
@@ -753,19 +762,19 @@
       tbSh = 0;
       tbFh = 0;
     }
-    printf ("* %d * %3ld(%2d) * %3ld(%2d) * %3ld(%2d) * %5ld * %5ld * %5ld * %5ld * %5ld *\n",
+    printf ("* %u * %3lu(%2lu) * %3lu(%2lu) * %3lu(%2lu) * %5ld * %5ld * %5ld * %5ld * %5ld *\n",
 	    h, 
-	    (tbSh) ? (tbSh->b_blocknr):(-1),
-	    (tbSh) ? tbSh->b_count : -1,
-	    (tb->L[h]) ? (tb->L[h]->b_blocknr):(-1),
-	    (tb->L[h]) ? tb->L[h]->b_count : -1,
-	    (tb->R[h]) ? (tb->R[h]->b_blocknr):(-1),
-	    (tb->R[h]) ? tb->R[h]->b_count : -1,
-	    (tbFh) ? (tbFh->b_blocknr):(-1),
-	    (tb->FL[h]) ? (tb->FL[h]->b_blocknr):(-1),
-	    (tb->FR[h]) ? (tb->FR[h]->b_blocknr):(-1),
-	    (tb->CFL[h]) ? (tb->CFL[h]->b_blocknr):(-1),
-	    (tb->CFR[h]) ? (tb->CFR[h]->b_blocknr):(-1));
+	    tbSh ? tbSh->b_blocknr : ~0ul,
+	    tbSh ? tbSh->b_count : ~0ul,
+	    tb->L[h] ? tb->L[h]->b_blocknr : ~0ul,
+	    tb->L[h] ? tb->L[h]->b_count : ~0ul,
+	    tb->R[h] ? tb->R[h]->b_blocknr : ~0ul,
+	    tb->R[h] ? tb->R[h]->b_count : ~0ul,
+	    tbFh ? tbFh->b_blocknr : ~0ul,
+	    tb->FL[h] ? tb->FL[h]->b_blocknr : ~0ul,
+	    tb->FR[h] ? tb->FR[h]->b_blocknr : ~0ul,
+	    tb->CFL[h] ? tb->CFL[h]->b_blocknr : ~0ul,
+	    tb->CFR[h] ? tb->CFR[h]->b_blocknr : ~0ul);
   }
 
   printf ("*********************************************************************\n");
@@ -790,14 +799,12 @@
 
 
   /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */
-  h = 0;
-  for (i = 0; i < sizeof (tb->FEB) / sizeof (tb->FEB[0]); i ++)
-    printf ("%s%p (%lu %d)", i == 0 ? "FEB list: " : ", ", tb->FEB[i], tb->FEB[i] ? tb->FEB[i]->b_blocknr : 0,
-	    tb->FEB[i] ? tb->FEB[i]->b_count : 0);
+  for (h = 0; h < sizeof (tb->FEB) / sizeof (tb->FEB[0]); h++)
+    printf("%s%p (%lu %d)", h == 0 ? "FEB list: " : ", ", tb->FEB[h], tb->FEB[h] ? tb->FEB[h]->b_blocknr : 0,
+	    tb->FEB[h] ? tb->FEB[h]->b_count : 0);
   printf ("\n");
 
   printf ("********************** END OF PRINT_TB *******************\n\n");
-
 }
 
 
@@ -812,13 +819,13 @@
 
     blocks = blocksize * 8;
 
-    if (test_bit (0, map)) {
+    if (misc_test_bit (0, map)) {
 	/* first block addressed by this bitmap block is used */
 	ones ++;
 	if (!silent)
 	    reiserfs_warning (fp, "Busy (%d-", i * bits);
 	for (j = 1; j < blocks; j ++) {
-	    while (test_bit (j, map)) {
+	    while (misc_test_bit (j, map)) {
 		ones ++;
 		if (j == blocks - 1) {
 		    if (!silent)
@@ -830,7 +837,7 @@
 	    if (!silent)
 		reiserfs_warning (fp, "%d) Free(%d-", j - 1 + i * bits, j + i * bits);
 
-	    while (!test_bit (j, map)) {
+	    while (!misc_test_bit (j, map)) {
 		zeros ++;
 		if (j == blocks - 1) {
 		    if (!silent)
@@ -844,6 +851,7 @@
 
 	    j --;
 	end:
+	    /* to make gcc 3.2 do not sware here */;
 	}
     } else {
 	/* first block addressed by this bitmap is free */
@@ -852,7 +860,7 @@
 	    reiserfs_warning (fp, "Free (%d-", i * bits);
 	for (j = 1; j < blocks; j ++) {
 	    k = 0;
-	    while (!test_bit (j, map)) {
+	    while (!misc_test_bit (j, map)) {
 		k ++;
 		if (j == blocks - 1) {
 		    if (!silent)
@@ -867,7 +875,7 @@
 		reiserfs_warning (fp, "%d) Busy(%d-", j - 1 + i * bits, j + i * bits);
 	    
 	    k = 0;
-	    while (test_bit (j, map)) {
+	    while (misc_test_bit (j, map)) {
 		ones ++;
 		if (j == blocks - 1) {
 		    if (!silent)
@@ -883,6 +891,7 @@
 	
 	    j --;
 	end2:
+	    /* to make gcc 3.2 do not sware here */;
 	}
     }
 
@@ -952,13 +961,14 @@
 		      (char *)omap - (char *)sb);
       
     for (i = 0; i < get_sb_oid_cursize (sb); i ++) {
-	if (i % 2 == 0)
-	    reiserfs_warning (fp, "busy(%u-%u) ", le32_to_cpu (omap[i]),
-			      le32_to_cpu (omap[i+1]) - 1); 
-	else
-	    reiserfs_warning (fp, "free(%u-%u) ", 
-			      le32_to_cpu (omap[i]),
-			      ((i+1) == get_sb_oid_cursize (sb)) ? -1 : (le32_to_cpu (omap[i+1]) - 1));
+	if (i % 2 == 0) {
+	    reiserfs_warning(fp, "busy(%u-%u) ", le32_to_cpu (omap[i]),
+			     le32_to_cpu (omap[i+1]) - 1); 
+	} else {
+	    reiserfs_warning(fp, "free(%u-%u) ", le32_to_cpu (omap[i]),
+			    ((i+1) == get_sb_oid_cursize (sb)) ? 
+			    ~0ul : (le32_to_cpu (omap[i+1]) - 1));
+	}
     }
 
     reiserfs_warning (fp, "\nObject id array has size %d (max %d):", 
@@ -990,7 +1000,8 @@
 
 
 static void print_trans_element (reiserfs_filsys_t * fs, reiserfs_trans_t * trans,
-				 int index, unsigned long in_journal, unsigned long in_place)
+				 unsigned int index, unsigned long in_journal, 
+				 unsigned long in_place)
 {
     if (index % 8 == 0)
 	reiserfs_warning (stdout, "#%d\t", index);
diff --git a/reiserfscore/reiserfslib.c b/reiserfscore/reiserfslib.c
index 454a593..f916868 100644
--- a/reiserfscore/reiserfslib.c
+++ b/reiserfscore/reiserfslib.c
@@ -1,5 +1,6 @@
 /*
- *  Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ *  Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ *  reiserfsprogs/README
  */
 
 #include "includes.h"
@@ -26,13 +27,13 @@
 /* reiserfs needs at least: enough blocks for journal, 64 k at the beginning,
    one block for super block, bitmap block and root block. Note that first
    bitmap block must point to all of them */
-int is_block_count_correct (unsigned long block_of_super_block, int block_size,
-	unsigned long block_count, unsigned long journal_size)
+int is_block_count_correct (unsigned long journal_offset, unsigned int block_size,
+    unsigned long block_count, unsigned long journal_size)
 {
     unsigned long blocks;
 
-    /* RESERVED, MD RAID SBs, super block, bitmap, root, journal size w/ journal header */
-    blocks = block_of_super_block + 1 + 1 + 1 + journal_size;
+    /* RESERVED, MD RAID SBs, super block, bitmap, root, journal size with journal header */
+    blocks = journal_offset + journal_size;
 
     /* we have a limit: skipped area, super block, journal and root block
     all have to be addressed by one first bitmap */
@@ -46,15 +47,15 @@
 }
 
 /* read super block. fixme: only 4k blocks, pre-journaled format
-   is refused. Journal and bitmap are to be opened separately */
-reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int *error, void * vp)
+   is refused. Journal and bitmap are to be opened separately.
+   skip_check is set to 1 if checks of openned SB should be omitted.*/
+reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int *error, void * vp, int check)
 {
     reiserfs_filsys_t * fs;
     struct buffer_head * bh;
     struct reiserfs_super_block * sb;
     int fd, i;
 
-
     /* convert root dir key and parent root dir key to little endian format */
     make_const_keys ();
 
@@ -80,7 +81,7 @@
 	} else {
 	    sb = (struct reiserfs_super_block *)bh->b_data;
 	    
-	    if (does_look_like_super_block (sb))
+	    if (is_any_reiserfs_magic_string(sb))
 		goto found;
 
 	    /* reiserfs signature is not found at the i-th 4k block */
@@ -88,9 +89,9 @@
 	}
     }
 
-    reiserfs_warning (stderr, "reiserfs_open: neither new nor old reiserfs format "
-		      "found on %s\n", filename);
-
+    reiserfs_warning(stderr, 
+	"\nreiserfs_open: the reiserfs superblock cannot be found on %s.\n", filename);
+    
     if (error)
 	*error = 0;
     freemem (fs);
@@ -99,6 +100,35 @@
     return fs;
 
  found:
+
+    if (check) {
+	/* A few checks of found super block. */
+	struct buffer_head *tmp_bh;
+	
+	if (!is_blocksize_correct(get_sb_block_size(sb))) {
+	    reiserfs_warning(stderr, "reiserfs_open: a superblock with wrong parameters "
+		"was found in the block (%d).\n", i);
+	    freemem (fs);
+	    close (fd);
+	    brelse(bh);
+	    return NULL;
+	}
+    
+	tmp_bh = bread (fd, get_sb_block_count(sb) - 1, get_sb_block_size(sb));
+	
+	if (!tmp_bh) {
+	    reiserfs_warning (stderr, "\n%s: Your partition is not big enough to contain the \n"
+		    "filesystem of (%lu) blocks as was specified in the found super block.\n", 
+		    __FUNCTION__,  get_sb_block_count(sb) - 1);
+	    
+	    freemem (fs);
+	    close (fd);
+	    brelse(bh);
+	    return NULL;
+	}
+	
+	brelse(tmp_bh);
+    }
    
     fs->fs_blocksize = get_sb_block_size (sb);
     
@@ -137,7 +167,10 @@
    constant for given size and version of a filesystem */
 reiserfs_filsys_t * reiserfs_create (char * filename,
 				     int version,
-				     unsigned long block_count, int block_size, int default_journal, int new_format)
+				     unsigned long block_count, 
+				     int block_size, 
+				     int default_journal, 
+				     int new_format)
 {
     reiserfs_filsys_t * fs;
 
@@ -151,11 +184,11 @@
 	return 0;
     }
 
-    if (!is_block_count_correct (REISERFS_DISK_OFFSET_IN_BYTES / block_size, block_size, block_count, 0)) {
-//    if (block_count < min_block_amount (block_size, 0)) {
-	reiserfs_warning (stderr, "reiserfs_create: "
-			  "can not create that small (%d blocks) filesystem\n",
-			  block_count);
+    if (!is_block_count_correct (REISERFS_DISK_OFFSET_IN_BYTES / block_size, 
+	block_size, block_count, 0)) 
+    {
+	reiserfs_warning (stderr, "reiserfs_create: can not create that small "
+	    "(%d blocks) filesystem\n", block_count);
 	return 0;
     }
 
@@ -167,8 +200,8 @@
 
     fs->fs_dev = open (filename, O_RDWR | O_LARGEFILE);
     if (fs->fs_dev == -1) {
-	reiserfs_warning (stderr, "reiserfs_create: could not open %s: %m\n",
-			  filename);
+	reiserfs_warning (stderr, "reiserfs_create: could not open %s: %s\n",
+			  filename, strerror(errno));
 	freemem (fs);
 	return 0;
     }
@@ -178,9 +211,11 @@
     fs->fs_format = version;
 
     if (new_format)
-        fs->fs_super_bh = getblk (fs->fs_dev, REISERFS_DISK_OFFSET_IN_BYTES / block_size, block_size);
+        fs->fs_super_bh = getblk (fs->fs_dev, 
+	    REISERFS_DISK_OFFSET_IN_BYTES / block_size, block_size);
     else 
-        fs->fs_super_bh = getblk (fs->fs_dev, REISERFS_OLD_DISK_OFFSET_IN_BYTES / block_size, block_size);
+        fs->fs_super_bh = getblk (fs->fs_dev, 
+	    REISERFS_OLD_DISK_OFFSET_IN_BYTES / block_size, block_size);
     
     if (!fs->fs_super_bh) {
 	reiserfs_warning (stderr, "reiserfs_create: getblk failed\n");
@@ -207,7 +242,8 @@
     set_sb_block_size (fs->fs_ondisk_sb, block_size);
     switch (version) {
     case REISERFS_FORMAT_3_5:
-	set_sb_oid_maxsize (fs->fs_ondisk_sb, (block_size - SB_SIZE_V1) / sizeof(__u32) / 2 * 2);
+	set_sb_oid_maxsize (fs->fs_ondisk_sb, 
+	    (block_size - SB_SIZE_V1) / sizeof(__u32) / 2 * 2);
 	/* sb_oid_cursize */
 	/* sb_state */
 	memcpy (fs->fs_ondisk_sb->s_v1.s_magic, REISERFS_3_5_SUPER_MAGIC_STRING,
@@ -215,7 +251,8 @@
 	break;
 
     case REISERFS_FORMAT_3_6:
-	set_sb_oid_maxsize (fs->fs_ondisk_sb, (block_size - SB_SIZE) / sizeof(__u32) / 2 * 2);
+	set_sb_oid_maxsize (fs->fs_ondisk_sb, 
+	    (block_size - SB_SIZE) / sizeof(__u32) / 2 * 2);
 	/* sb_oid_cursize */
 	/* sb_state */
         memcpy (fs->fs_ondisk_sb->s_v1.s_magic, REISERFS_3_6_SUPER_MAGIC_STRING,
@@ -262,24 +299,15 @@
 /* 0 means: do not guarantee that fs is consistent */
 int reiserfs_is_fs_consistent (reiserfs_filsys_t * fs)
 {
-    if (get_sb_umount_state (fs->fs_ondisk_sb) == REISERFS_CLEANLY_UMOUNTED &&
-	get_sb_fs_state (fs->fs_ondisk_sb) == REISERFS_CONSISTENT)
+    if (get_sb_umount_state (fs->fs_ondisk_sb) == FS_CLEANLY_UMOUNTED &&
+	get_sb_fs_state (fs->fs_ondisk_sb) == FS_CONSISTENT)
 	return 1;
     return 0;
 }
 
-
-void reiserfs_reopen (reiserfs_filsys_t * fs, int flag)
-{
-    reiserfs_only_reopen (fs, flag);
-    reiserfs_reopen_journal (fs, flag);
-
-}
-
-
 /* flush bitmap, brelse super block, flush all dirty buffers, close and open
    again the device, read super block */
-void reiserfs_only_reopen (reiserfs_filsys_t * fs, int flag)
+static void reiserfs_only_reopen (reiserfs_filsys_t * fs, int flag)
 {
     unsigned long super_block;
 
@@ -291,11 +319,11 @@
     
     invalidate_buffers (fs->fs_dev);
     if (close (fs->fs_dev))
-	die ("reiserfs_reopen: closed failed: %m");
+	die ("reiserfs_reopen: closed failed: %s", strerror(errno));
     
     fs->fs_dev = open (fs->fs_file_name, flag | O_LARGEFILE);
     if (fs->fs_dev == -1)
-	die ("reiserfs_reopen: could not reopen device: %m");
+	die ("reiserfs_reopen: could not reopen device: %s", strerror(errno));
 
     fs->fs_super_bh = bread (fs->fs_dev, super_block, fs->fs_blocksize);
     if (!fs->fs_super_bh)
@@ -309,6 +337,11 @@
 	fs->fs_dirt = 0;
 }
 
+void reiserfs_reopen (reiserfs_filsys_t * fs, int flag)
+{
+    reiserfs_only_reopen (fs, flag);
+    reiserfs_reopen_journal (fs, flag);
+}
 
 int is_opened_rw (reiserfs_filsys_t * fs)
 {
@@ -858,7 +891,7 @@
 	    }
 
 	    /* the name in directory has the same hash as the given name */
-	    if ((name_in_entry_length (ih, deh, i) == strlen (name)) &&
+	    if ((name_in_entry_length (ih, deh, i) == (int)strlen (name)) &&
 		!memcmp (name_in_entry (deh, i), name, strlen (name))) {
 		path->pos_in_item = i;
 		return 1;
@@ -900,7 +933,7 @@
    generation counter in 'min_gen_counter'. dies if found object is not a
    directory. */
 int reiserfs_find_entry (reiserfs_filsys_t * fs, struct key * dir, char * name, 
-			 int * min_gen_counter, struct key * key)
+			 unsigned int * min_gen_counter, struct key * key)
 {
     struct key entry_key;
     int retval;
@@ -938,7 +971,7 @@
 	    if (GET_GENERATION_NUMBER (get_deh_offset (deh)) == *min_gen_counter)
 		(*min_gen_counter) ++;
 			
-	    if ((name_in_entry_length (ih, deh, i) == strlen (name)) &&
+	    if ((name_in_entry_length (ih, deh, i) == (int)strlen (name)) &&
 	        (!memcmp (name_in_entry (deh, i), name, strlen (name)))) {
 		/* entry found in the directory */
 		if (key) {
@@ -1009,13 +1042,13 @@
 /* add new name into a directory. If it exists in a directory - do
    nothing */
 int reiserfs_add_entry (reiserfs_filsys_t * fs, struct key * dir, char * name, int name_len,
-			struct key * key, int fsck_need)
+			struct key * key, __u16 fsck_need)
 {
     struct item_head entry_ih = {{0,}, };
     char * entry;
     int retval;
     INITIALIZE_PATH(path);
-    int gen_counter;
+    unsigned int gen_counter;
     int item_len;
     __u32 hash;
 
@@ -1217,7 +1250,8 @@
 	if (blocknr < get_sb_block_count (fs->fs_ondisk_sb) && !not_data_block (fs, blocknr)) {
 	    reiserfs_bitmap_set_bit (fs->fs_badblocks_bm, blocknr);
 	} else {
-	    fprintf (stderr, "%s: bad block number %u in badblocks file\n", __FUNCTION__, blocknr);
+	    fprintf (stderr, "%s: block number %u belongs to internal reiserfs structures.\n", 
+		__FUNCTION__, blocknr);
 	}
     }
 
diff --git a/reiserfscore/stree.c b/reiserfscore/stree.c
index 9c53928..227b6cf 100644
--- a/reiserfscore/stree.c
+++ b/reiserfscore/stree.c
@@ -1,5 +1,6 @@
 /*
- *  Copyright 1996-2002 Hans Reiser, see reiserfs/README for licensing and copyright details
+ *  Copyright 1996-2003 by Hans Reiser, licensing governed by 
+ *  reiserfsprogs/README
  */
 
 /*
diff --git a/reiserfsprogs.spec b/reiserfsprogs.spec
index 8dfd901..bd3cdb9 100644
--- a/reiserfsprogs.spec
+++ b/reiserfsprogs.spec
@@ -1,10 +1,10 @@
-%define reiserfsprogsversion 3.6.4 
+%define reiserfsprogsversion 3.6.9 
 
 Vendor:       Hans Reiser
 Distribution: Hans Reiser
 Name:         reiserfsprogs
 Release:      1
-Copyright:    2002 Hans Reiser
+Copyright:    2003 Hans Reiser
 Group:        Unsorted
 
 Packager:     anthon@mnt.org
@@ -22,7 +22,7 @@
 Authors:
 --------
 Hans Reiser <reiser@namesys.com>
-Vitaly Fertman <vetalf@inbox.ru>
+Vitaly Fertman <vitaly@namesys.com>
 Alexander Zarochentcev <zam@namesys.com>
 Vladimir Saveliev <monstr@namesys.com>
 
@@ -81,4 +81,5 @@
 %clean
   %{__rm} -rf $RPM_BUILD_ROOT
 %files -f %{buildroot}/rpm-filelist
+%defattr(-,root,root)
 %doc README
diff --git a/resize_reiserfs/Makefile.in b/resize_reiserfs/Makefile.in
index ab2de68..06d7bd4 100644
--- a/resize_reiserfs/Makefile.in
+++ b/resize_reiserfs/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,60 +12,98 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 sbin_PROGRAMS = resize_reiserfs
 
 resize_reiserfs_SOURCES = fe.c resize_reiserfs.c do_shrink.c resize.h
@@ -71,102 +111,117 @@
 EXTRA_DIST = $(man_MANS)
 
 LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+subdir = resize_reiserfs
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../include/config.h
-CONFIG_CLEAN_FILES = 
-PROGRAMS =  $(sbin_PROGRAMS)
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+sbin_PROGRAMS = resize_reiserfs$(EXEEXT)
+PROGRAMS = $(sbin_PROGRAMS)
 
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I../include
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-resize_reiserfs_OBJECTS =  fe.o resize_reiserfs.o do_shrink.o
+am_resize_reiserfs_OBJECTS = fe.$(OBJEXT) resize_reiserfs.$(OBJEXT) \
+	do_shrink.$(OBJEXT)
+resize_reiserfs_OBJECTS = $(am_resize_reiserfs_OBJECTS)
 resize_reiserfs_LDADD = $(LDADD)
-resize_reiserfs_DEPENDENCIES =  $(top_srcdir)/lib/libmisc.a \
-$(top_srcdir)/reiserfscore/libcore.a
-resize_reiserfs_LDFLAGS = 
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+resize_reiserfs_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
+	$(top_srcdir)/reiserfscore/libcore.a
+resize_reiserfs_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/do_shrink.Po ./$(DEPDIR)/fe.Po \
+@AMDEP_TRUE@	./$(DEPDIR)/resize_reiserfs.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-man8dir = $(mandir)/man8
-MANS = $(man_MANS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(resize_reiserfs_SOURCES)
 
 NROFF = nroff
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
+MANS = $(man_MANS)
+DIST_COMMON = Makefile.am Makefile.in
 SOURCES = $(resize_reiserfs_SOURCES)
-OBJECTS = $(resize_reiserfs_OBJECTS)
 
-all: all-redirect
+all: all-am
+
 .SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps resize_reiserfs/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-sbinPROGRAMS:
-
-clean-sbinPROGRAMS:
-	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
-
-distclean-sbinPROGRAMS:
-
-maintainer-clean-sbinPROGRAMS:
-
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  resize_reiserfs/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(sbindir)
 	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  if test -f $$p; then \
-	    echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
-	     $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \
 	  else :; fi; \
 	done
 
 uninstall-sbinPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
+	  rm -f $(DESTDIR)$(sbindir)/$$f; \
 	done
 
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+resize_reiserfs$(EXEEXT): $(resize_reiserfs_OBJECTS) $(resize_reiserfs_DEPENDENCIES) 
+	@rm -f resize_reiserfs$(EXEEXT)
+	$(LINK) $(resize_reiserfs_LDFLAGS) $(resize_reiserfs_OBJECTS) $(resize_reiserfs_LDADD) $(LIBS)
 
 mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
+	-rm -f *.$(OBJEXT) core *.core
 
 distclean-compile:
 	-rm -f *.tab.c
 
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/do_shrink.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resize_reiserfs.Po@am__quote@
 
-resize_reiserfs: $(resize_reiserfs_OBJECTS) $(resize_reiserfs_DEPENDENCIES)
-	@rm -f resize_reiserfs
-	$(LINK) $(resize_reiserfs_LDFLAGS) $(resize_reiserfs_OBJECTS) $(resize_reiserfs_LDADD) $(LIBS)
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
 
-install-man8:
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+man8dir = $(mandir)/man8
+install-man8: $(man8_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(man8dir)
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
@@ -175,158 +230,212 @@
 	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
 	  else file=$$i; fi; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \
 	  $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \
 	done
-
 uninstall-man8:
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@$(NORMAL_UNINSTALL)
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
 	done; \
 	for i in $$list; do \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \
 	  rm -f $(DESTDIR)$(man8dir)/$$inst; \
 	done
-install-man: $(MANS)
-	@$(NORMAL_INSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) install-man8
-uninstall-man:
-	@$(NORMAL_UNINSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) uninstall-man8
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = resize_reiserfs
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-do_shrink.o: do_shrink.c resize.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-fe.o: fe.c resize.h ../include/io.h ../include/misc.h ../include/swab.h \
-	../include/reiserfs_lib.h ../include/reiserfs_fs.h \
-	../include/config.h ../version.h
-resize_reiserfs.o: resize_reiserfs.c resize.h ../include/io.h \
-	../include/misc.h ../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am: install-sbinPROGRAMS
-install-exec: install-exec-am
+all-am: Makefile $(PROGRAMS) $(MANS)
 
-install-data-am: install-man
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir)
+
+install: install-am
+install-exec: install-exec-am
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-sbinPROGRAMS uninstall-man
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS) $(MANS)
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-	$(mkinstalldirs)  $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-sbinPROGRAMS mostlyclean-compile \
-		mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-sbinPROGRAMS clean-compile clean-tags clean-generic \
-		mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-sbinPROGRAMS distclean-compile distclean-tags \
-		distclean-generic clean-am
+clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-sbinPROGRAMS \
-		maintainer-clean-compile maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-exec-am: install-sbinPROGRAMS
+
+install-info: install-info-am
+
+install-man: install-man8
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
-clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
-install-sbinPROGRAMS mostlyclean-compile distclean-compile \
-clean-compile maintainer-clean-compile install-man8 uninstall-man8 \
-install-man uninstall-man tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-man uninstall-sbinPROGRAMS
+
+uninstall-man: uninstall-man8
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-sbinPROGRAMS ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-man8 install-sbinPROGRAMS \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-info-am uninstall-man \
+	uninstall-man8 uninstall-sbinPROGRAMS
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/resize_reiserfs/do_shrink.c b/resize_reiserfs/do_shrink.c
index b4530f2..2b4bdc4 100644
--- a/resize_reiserfs/do_shrink.c
+++ b/resize_reiserfs/do_shrink.c
@@ -1,10 +1,11 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "resize.h"
 #include <time.h>
 
-
 static unsigned long int_node_cnt   = 0, int_moved_cnt   = 0;
 static unsigned long leaf_node_cnt  = 0, leaf_moved_cnt  = 0;
 static unsigned long unfm_node_cnt  = 0, unfm_moved_cnt  = 0;
@@ -55,6 +56,9 @@
 	/* move wrong block */ 
 	bh = bread(fs->fs_dev, block, fs->fs_blocksize);
 
+	if (!bh)
+	    reiserfs_panic ("move_generic_block: bread failed.\n");
+
 	reiserfs_bitmap_find_zero_bit(bmp, &unused_block);
 	if (unused_block == 0 || unused_block >= bnd) {
 		fputs ("resize_reiserfs: can\'t find free block\n", stderr);
@@ -95,7 +99,7 @@
 	struct item_head *ih;
 	unsigned long new_blocknr = 0;
 	int node_is_internal = 0;
-	int i, j;
+	unsigned int i, j;
 	
 	bh = bread(fs->fs_dev, block, fs->fs_blocksize);
 	if (!bh)
@@ -105,7 +109,7 @@
 		
 		leaf_node_cnt++;
 		
-		for (i=0; i < B_NR_ITEMS(bh); i++) {
+		for (i = 0; i < B_NR_ITEMS(bh); i++) {
 			ih = B_N_PITEM_HEAD(bh, i);
 			if (is_indirect_ih(ih)) {
 				__u32 * indirect;
@@ -172,11 +176,11 @@
 		int c;
 
 		printf(
-			"You are running BETA version of reiserfs shrinker.\n"
-			"This version is only for testing or VERY CAREFUL use.\n"
-			"Backup of you data is recommended.\n\n"
-			"Do you want to continue? [y/N]:"
-			);
+		    "You are running BETA version of reiserfs shrinker.\n"
+		    "This version is only for testing or VERY CAREFUL use.\n"
+		    "Backup of you data is recommended.\n\n"
+		    "Do you want to continue? [y/N]:"
+		);
 		fflush(stdout);
 		c = getchar();
 		if (c != 'y' && c != 'Y')
@@ -186,18 +190,22 @@
 	bmap_nr_new = (blocks - 1) / (8 * fs->fs_blocksize) + 1;
 
 	/* is shrinking possible ? */
-	if (get_sb_block_count(ondisk_sb) - blocks > get_sb_free_blocks(ondisk_sb) + get_sb_bmap_nr(ondisk_sb) - bmap_nr_new) {
-	    fprintf(stderr, "resize_reiserfs: can\'t shrink fs; too many blocks already allocated\n");
+	if (get_sb_block_count(ondisk_sb) - blocks > 
+	    get_sb_free_blocks(ondisk_sb) + get_sb_bmap_nr(ondisk_sb) - 
+	    bmap_nr_new) 
+	{
+	    fprintf(stderr, "resize_reiserfs: can\'t shrink fs; too many "
+		"blocks already allocated\n");
 	    return -1;
 	}
 
 	reiserfs_reopen(fs, O_RDWR);
-	if (!reiserfs_open_ondisk_bitmap (fs))
+	if (reiserfs_open_ondisk_bitmap (fs))
 	    DIE("cannot open ondisk bitmap");
 	bmp = fs->fs_bitmap2;
 	ondisk_sb = fs->fs_ondisk_sb;
 
-	set_sb_fs_state (fs->fs_ondisk_sb, REISERFS_CORRUPTED);
+	set_sb_fs_state (fs->fs_ondisk_sb, FS_ERROR);
 	mark_buffer_uptodate(fs->fs_super_bh, 1);
 	mark_buffer_dirty(fs->fs_super_bh);
 	bwrite(fs->fs_super_bh);
@@ -218,10 +226,11 @@
 		fflush(stdout);
 	}
 
-	n_root_block = move_formatted_block(fs, get_sb_root_block(ondisk_sb), blocks, 0);
-	if (n_root_block) {
-		set_sb_root_block (ondisk_sb, n_root_block);
-	}
+	n_root_block = move_formatted_block(fs, get_sb_root_block(ondisk_sb), 
+	    blocks, 0);
+	
+	if (n_root_block)
+	    set_sb_root_block (ondisk_sb, n_root_block);
 
 	if (opt_verbose)
 	    printf ("\n\nnodes processed (moved):\n"
diff --git a/resize_reiserfs/fe.c b/resize_reiserfs/fe.c
index 81ac5af..f405975 100644
--- a/resize_reiserfs/fe.c
+++ b/resize_reiserfs/fe.c
@@ -1,10 +1,10 @@
 /*
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
 
 #include "resize.h"
 
-
 /* the front-end for kernel on-line resizer */
 int resize_fs_online(char * devname, unsigned long blocks)
 {
diff --git a/resize_reiserfs/resize.h b/resize_reiserfs/resize.h
index 06da5ce..fb37b5e 100644
--- a/resize_reiserfs/resize.h
+++ b/resize_reiserfs/resize.h
@@ -1,6 +1,8 @@
 /* 
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #define _GNU_SOURCE
 
 #include <sys/types.h>
diff --git a/resize_reiserfs/resize_reiserfs.8 b/resize_reiserfs/resize_reiserfs.8
index f03034d..b74a99a 100644
--- a/resize_reiserfs/resize_reiserfs.8
+++ b/resize_reiserfs/resize_reiserfs.8
@@ -1,7 +1,7 @@
 .\" -*- nroff -*-
-.\" Copyright 1996-2002 Hans Reiser.
+.\" Copyright 1996-2003 Hans Reiser.
 .\" 
-.TH RESIZE_REISERFS 8 "January 2002" "Reiserfsprogs-3.6.4"
+.TH RESIZE_REISERFS 8 "April 2003" "Reiserfsprogs-3.6.9"
 .SH NAME
 resize_reiserfs \- Reiserfs filesystem resizer
 .SH SYNOPSIS
diff --git a/resize_reiserfs/resize_reiserfs.c b/resize_reiserfs/resize_reiserfs.c
index 09a2e4e..76009c1 100644
--- a/resize_reiserfs/resize_reiserfs.c
+++ b/resize_reiserfs/resize_reiserfs.c
@@ -1,7 +1,8 @@
 /* 
- * Copyright 2000-2002 by Hans Reiser, licensing governed by reiserfs/README
+ * Copyright 2000-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
- 
+
 /*  
  * Written by Alexander Zarochentcev.
  * 
@@ -83,17 +84,17 @@
 /* the first one of the most important functions */
 static int expand_fs (reiserfs_filsys_t * fs, unsigned long block_count_new) {
     unsigned int bmap_nr_new, bmap_nr_old;
-    int i;
     struct reiserfs_super_block * sb;
+    unsigned int i;
 
 
     reiserfs_reopen(fs, O_RDWR);
-    if (!reiserfs_open_ondisk_bitmap (fs))
+    if (reiserfs_open_ondisk_bitmap (fs))
 	DIE("cannot open ondisk bitmap");
 
     sb = fs->fs_ondisk_sb;
 
-    set_sb_fs_state (fs->fs_ondisk_sb, REISERFS_CORRUPTED);
+    set_sb_fs_state (fs->fs_ondisk_sb, FS_ERROR);
 
     bwrite_cond(fs->fs_super_bh);
 
@@ -187,12 +188,18 @@
 	print_usage_and_exit();
     devname = argv[optind];
 
-    fs = reiserfs_open(devname, O_RDONLY, &error, 0);
+    fs = reiserfs_open(devname, O_RDONLY, &error, 0, 1);
     if (!fs)
 	DIE ("cannot open '%s': %s", devname, strerror(error));
-    if (!reiserfs_open_journal (fs, jdevice_name, O_RDONLY)) {
+
+    if (reiserfs_open_journal (fs, jdevice_name, O_RDWR | O_LARGEFILE))
+	DIE ("Failed to open the journal device (%s).", jdevice_name);
+    
+    if (reiserfs_journal_params_check(fs)) {
 	if (!opt_skipj)
-	    DIE ("can not open journal of '%s'", devname);
+	    DIE ("Wrong journal parameters detected on (%s)", jdevice_name);
+	else
+	    reiserfs_close_journal(fs);
     }
 
     /* forced to continue without journal available/specified */
@@ -205,61 +212,78 @@
     }
 
     sb = fs->fs_ondisk_sb;
-	
+    
     if(bytes_count_str) {	/* new fs size is specified by user */
-	block_count_new = calc_new_fs_size(get_sb_block_count(sb), fs->fs_blocksize, bytes_count_str);
+	block_count_new = calc_new_fs_size(get_sb_block_count(sb), 
+	    fs->fs_blocksize, bytes_count_str);
     } else {		/* use whole device */
 	block_count_new = count_blocks(devname, fs->fs_blocksize);
     }
 
     if (is_mounted (devname)) {
 	reiserfs_close(fs);
-	return resize_fs_online(devname, block_count_new);
+	if ((error = resize_fs_online(devname, block_count_new)))
+	    reiserfs_warning(stderr, "\n\nresize_reiserfs: On-line resizing "
+		"failed.\n\n ");
+	else
+	    reiserfs_warning(stderr, "\n\nresize_reiserfs: On-line resizing "
+		"finished successfully.\n\n ");
+	return error;
     }
 
     if (!reiserfs_is_fs_consistent (fs)) {
-	reiserfs_warning (stderr, "\n\nresize_reiserfs: run reiserfsck --check first\n\n");
+	reiserfs_warning (stderr, "\n\nresize_reiserfs: run reiserfsck --check "
+	    "first\n\n");
 	reiserfs_close (fs);
 	return 1;
     }
 
-    if (get_sb_umount_state(sb) != REISERFS_CLEANLY_UMOUNTED)
+    if (get_sb_umount_state(sb) != FS_CLEANLY_UMOUNTED)
 	/* fixme: shouldn't we check for something like: fsck guarantees: fs is ok */
 	DIE ("the file system isn't in valid state.");
 		
     if (block_count_new >= get_sb_block_count(sb)) {
 	if (block_count_new == get_sb_block_count(sb)) {
-	    reiserfs_warning (stderr, "%s already is of the needed size. Nothing to be done\n\n", devname);
+	    reiserfs_warning (stderr, "%s already is of the needed size. "
+		"Nothing to be done\n\n", devname);
 	    exit (1);
 	}
 	
-	if(!valid_offset(fs->fs_dev, (loff_t) block_count_new * fs->fs_blocksize - 1)) {
-	    reiserfs_warning (stderr, "%s is of %lu blocks size only with reiserfs of %d blocks\nsize on it. "\
-		"You are trying to expant reiserfs up to %lu blocks size.\nYou probably forgot to expand your "\
-		"partition size.\n\n", devname, count_blocks (devname, fs->fs_blocksize),
+	if(!valid_offset(fs->fs_dev, 
+	    (loff_t)block_count_new * fs->fs_blocksize - 1)) 
+	{
+	    reiserfs_warning (stderr, "%s is of %lu blocks size only with "
+		"reiserfs of %d blocks\nsize on it. You are trying to expand "
+		"reiserfs up to %lu blocks size.\nYou probably forgot to "
+		"expand your partition size.\n\n", devname, 
+		count_blocks(devname, fs->fs_blocksize),
 		get_sb_block_count(sb), block_count_new);
 	    exit (1);
 	}
     }
 
-
-    sb_old = 0;		/* Needed to keep idiot compiler from issuing false warning */
+    /* Needed to keep idiot compiler from issuing false warning */
+    sb_old = 0;		
+    
     /* save SB for reporting */
     if(opt_verbose) {
 	sb_old = getmem(SB_SIZE);
 	memcpy(sb_old, fs->fs_ondisk_sb, SB_SIZE);
     }
 
-    error = (block_count_new > get_sb_block_count(fs->fs_ondisk_sb)) ? expand_fs(fs, block_count_new) : shrink_fs(fs, block_count_new);
-    if (error)
+    error = (block_count_new > get_sb_block_count(fs->fs_ondisk_sb)) ? 
+	expand_fs(fs, block_count_new) : shrink_fs(fs, block_count_new);
+    if (error) {
+	reiserfs_warning(stderr, "\n\nresize_reiserfs: Resizing failed.\n\n ");
 	return error;
+    }
 
     if(opt_verbose) {
 	sb_report(fs->fs_ondisk_sb, sb_old);
 	freemem(sb_old);
     }
 
-    set_sb_fs_state (fs->fs_ondisk_sb, REISERFS_CONSISTENT);
+    set_sb_fs_state (fs->fs_ondisk_sb, FS_CONSISTENT);
     bwrite_cond(fs->fs_super_bh);
 	
     if (opt_verbose) {
@@ -270,5 +294,8 @@
     if (opt_verbose)
 	printf("done\n");
 	
+    reiserfs_warning(stderr, "\n\nresize_reiserfs: Resizing finished "
+	"successfully.\n\n ");
+    
     return 0;
 }
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..f57a5a9
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,4 @@
+SUBDIRS = PROGS
+
+sbin_PROGRAMS = 
+
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..f058c5b
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,418 @@
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+SUBDIRS = PROGS
+
+sbin_PROGRAMS = 
+subdir = tests
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+sbin_PROGRAMS =
+PROGRAMS = $(sbin_PROGRAMS)
+
+DIST_SOURCES =
+
+RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
+	ps-recursive install-info-recursive uninstall-info-recursive \
+	all-recursive install-data-recursive install-exec-recursive \
+	installdirs-recursive install-recursive uninstall-recursive \
+	check-recursive installcheck-recursive
+DIST_COMMON = Makefile.am Makefile.in
+DIST_SUBDIRS = $(SUBDIRS)
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  tests/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	$(mkinstalldirs) $(DESTDIR)$(sbindir)
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-sbinPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
+	  rm -f $(DESTDIR)$(sbindir)/$$f; \
+	done
+
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+uninstall-info-am:
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
+
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d $(distdir)/$$subdir \
+	    || mkdir $(distdir)/$$subdir \
+	    || exit 1; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$(top_distdir)" \
+	        distdir=../$(distdir)/$$subdir \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(PROGRAMS)
+installdirs: installdirs-recursive
+installdirs-am:
+	$(mkinstalldirs) $(DESTDIR)$(sbindir)
+
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
+
+distclean: distclean-recursive
+
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-sbinPROGRAMS
+
+install-info: install-info-recursive
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-sbinPROGRAMS
+
+uninstall-info: uninstall-info-recursive
+
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
+	clean-generic clean-recursive clean-sbinPROGRAMS ctags \
+	ctags-recursive distclean distclean-generic distclean-recursive \
+	distclean-tags distdir dvi dvi-am dvi-recursive info info-am \
+	info-recursive install install-am install-data install-data-am \
+	install-data-recursive install-exec install-exec-am \
+	install-exec-recursive install-info install-info-am \
+	install-info-recursive install-man install-recursive \
+	install-sbinPROGRAMS install-strip installcheck installcheck-am \
+	installdirs installdirs-am installdirs-recursive \
+	maintainer-clean maintainer-clean-generic \
+	maintainer-clean-recursive mostlyclean mostlyclean-generic \
+	mostlyclean-recursive pdf pdf-am pdf-recursive ps ps-am \
+	ps-recursive tags tags-recursive uninstall uninstall-am \
+	uninstall-info-am uninstall-info-recursive uninstall-recursive \
+	uninstall-sbinPROGRAMS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/PROGS/Makefile.am b/tests/PROGS/Makefile.am
new file mode 100644
index 0000000..f553f7d
--- /dev/null
+++ b/tests/PROGS/Makefile.am
@@ -0,0 +1,5 @@
+sbin_PROGRAMS = reiserfs_corrupter
+
+SOURCES = corrupter.c 
+LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+
diff --git a/tests/PROGS/Makefile.in b/tests/PROGS/Makefile.in
new file mode 100644
index 0000000..5b69df6
--- /dev/null
+++ b/tests/PROGS/Makefile.in
@@ -0,0 +1,382 @@
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../..
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+sbin_PROGRAMS = reiserfs_corrupter
+
+SOURCES = corrupter.c 
+LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+subdir = tests/PROGS
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+sbin_PROGRAMS = reiserfs_corrupter$(EXEEXT)
+PROGRAMS = $(sbin_PROGRAMS)
+
+reiserfs_corrupter_SOURCES = reiserfs_corrupter.c
+reiserfs_corrupter_OBJECTS = reiserfs_corrupter.$(OBJEXT)
+reiserfs_corrupter_LDADD = $(LDADD)
+reiserfs_corrupter_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
+	$(top_srcdir)/reiserfscore/libcore.a
+reiserfs_corrupter_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/reiserfs_corrupter.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = reiserfs_corrupter.c
+DIST_COMMON = Makefile.am Makefile.in
+SOURCES = corrupter.c 
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  tests/PROGS/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+install-sbinPROGRAMS: $(sbin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	$(mkinstalldirs) $(DESTDIR)$(sbindir)
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-sbinPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
+	  rm -f $(DESTDIR)$(sbindir)/$$f; \
+	done
+
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+reiserfs_corrupter$(EXEEXT): $(reiserfs_corrupter_OBJECTS) $(reiserfs_corrupter_DEPENDENCIES) 
+	@rm -f reiserfs_corrupter$(EXEEXT)
+	$(LINK) $(reiserfs_corrupter_LDFLAGS) $(reiserfs_corrupter_OBJECTS) $(reiserfs_corrupter_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reiserfs_corrupter.Po@am__quote@
+
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
+
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
+
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ../..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(sbindir)
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-sbinPROGRAMS
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-sbinPROGRAMS
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-sbinPROGRAMS ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-sbinPROGRAMS install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-info-am uninstall-sbinPROGRAMS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/PROGS/reiserfs_corrupter.c b/tests/PROGS/reiserfs_corrupter.c
new file mode 100644
index 0000000..3dc24d0
--- /dev/null
+++ b/tests/PROGS/reiserfs_corrupter.c
@@ -0,0 +1,198 @@
+#define _GNU_SOURCE
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <asm/types.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
+#include <sys/vfs.h>
+
+#include "io.h"
+#include "misc.h"
+#include "reiserfs_lib.h"
+
+enum {
+	USED_BLOCKS,
+	ALL_BLOCKS,
+	EXTERN_BITMAP
+};
+
+typedef struct corrupter_options {
+    int bitmap_kind;
+    char * bm_name;
+    reiserfs_bitmap_t * bm;
+    int block_size;
+    int offset;
+} corrupter_options_t;
+
+#define print_usage_and_exit() {\
+printf ("\nUsage: %s [options] device\n"\
+"Options:\n"\
+"  -b bitmap\t\tscan blocks marked in bitmap\n"\
+"  -S\t\t\tscan-whole-partition\n"\
+"  -s blocksize\t\tfs blocksize\n"\
+"  -o bitmap\t\tskip offset blocks\n\n"\
+  , argv[0]);\
+  exit (16);\
+}
+
+static char * parse_options (corrupter_options_t * options, int argc, char * argv [])
+{
+    int c;
+    options->bitmap_kind = USED_BLOCKS;
+    options->block_size = 4096;
+    options->offset = 0;
+    options->bm_name = NULL;
+    options->bm = NULL;
+
+    while (1) {
+	int option_index;
+
+	c = getopt_long (argc, argv, "Sb:s:o:",
+			 NULL, &option_index);
+	if (c == -1)
+	    break;
+	
+	switch (c) {
+	case 0:
+	    /* long-only options */
+	
+	    break;
+
+	case 'b': /* --scan-marked-in-bitmap */
+	    options->bitmap_kind = EXTERN_BITMAP;
+	    options->bm_name = optarg;
+	    break;
+
+	case 'S': /* --scan-whole-partition */
+	    options->bitmap_kind = ALL_BLOCKS;
+	    break;
+
+	case 'o': /* --scan-marked-in-bitmap */
+	    options->offset = atoi (optarg);
+	    break;
+	
+	case 's': /* --scan-marked-in-bitmap */
+	    options->block_size = atoi (optarg);
+	    break;
+	
+	default:
+	    print_usage_and_exit();
+	}
+    }
+
+    if (optind != argc - 1)
+	print_usage_and_exit();
+
+    return argv[optind];
+}
+
+void load_bitmap_from_file (corrupter_options_t * options) {
+    FILE * fd;
+
+    fd = fopen (options->bm_name, "r");
+	
+    if (!fd)
+	reiserfs_panic ("%s: could not load bitmap: %s\n", __FUNCTION__, strerror(errno));
+
+    options->bm = reiserfs_bitmap_load (fd);
+	
+    if (!options->bm)
+        reiserfs_panic ("could not load fitmap from \"%s\"", options->bm_name);
+
+    fclose (fd);
+}
+
+void warn_what_will_be_done (corrupter_options_t * options, char * file_name, int bl_count) {
+    printf ("====================\n");
+    printf ("\tprogram will corrupt %s\n", file_name);
+    printf ("\tblock size is %d\n", options->block_size);
+    printf ("\toffset is %d blocks\n", options->offset);
+
+    if (options->bitmap_kind == ALL_BLOCKS) {
+	printf ("\tall formatted blocks, bitmap and journal blocks will be corrupted\n");
+    } else if (options->bitmap_kind == USED_BLOCKS) {
+	printf ("\tall formatted blocks, bitmap and journal blocks which are used in fs bitmap will be corrupted\n");
+    } else if (options->bitmap_kind == EXTERN_BITMAP) {
+	printf ("\tall formatted blocks, bitmap and journal blocks from bitmap %s will be corrupted\n", options->bm_name);
+    }
+
+    printf ("\tblocks count %d\n", bl_count);
+    printf ("====================\n");
+}
+
+int main (int argc, char * argv []) {
+    corrupter_options_t options;
+    char * file_name;
+    unsigned int block_count, i;
+    reiserfs_filsys_t * fs;
+
+    file_name = parse_options (&options, argc, argv);
+
+    fs = reiserfs_open (file_name, O_RDONLY, 0, &options, 1);
+	
+    if (no_reiserfs_found (fs))
+        die ("could not open filesystem on \"%s\"", file_name);
+
+    /* keep SB to separate memory */
+    fs->fs_ondisk_sb = getmem(fs->fs_blocksize);
+    memcpy (fs->fs_ondisk_sb, fs->fs_super_bh->b_data, fs->fs_blocksize);
+
+    block_count = get_sb_block_count (fs->fs_ondisk_sb);
+
+    if (options.bm_name) {
+    	load_bitmap_from_file (&options);
+    } else {
+	if (reiserfs_open_ondisk_bitmap (fs))
+    	    die ("could not open bitmap\n");
+	
+	options.bm = reiserfs_create_bitmap (fs->fs_bitmap2->bm_bit_size);
+	reiserfs_bitmap_copy (options.bm, fs->fs_bitmap2);
+    }
+
+    if (options.bm && block_count > options.bm->bm_bit_size) {
+        printf ("fs is larger (%d blocks) then bitmap (%ld blocks), work with %ld blocks only\n",
+	block_count, options.bm->bm_bit_size, options.bm->bm_bit_size);
+	block_count = options.bm->bm_bit_size;
+    }
+
+    warn_what_will_be_done (&options, file_name, block_count);
+
+    for (i = options.offset; i < block_count; i++) {
+        int who;
+        struct buffer_head * bh;
+        /* read every block and corrupt all formatted blocks */
+        	if (!reiserfs_bitmap_test_bit (options.bm, i))
+	    continue;
+        	
+	bh = bread (fs->fs_dev, i, fs->fs_blocksize);
+	
+	who = who_is_this (bh->b_data, bh->b_size);
+	
+	/*	
+	if (block of bitmap || block of journal || leaf || internal)
+	take N random bytes and write them into N random place
+	within the block		
+	*/
+	if (who != THE_SUPER && who != THE_LEAF && who != THE_INTERNAL && who != THE_JDESC &&
+	    !block_of_bitmap (fs, i) && !block_of_journal (fs, i))
+	    continue;
+	
+	printf ("\ncorrupt %d ", i);		
+    }
+
+    freemem(fs->fs_ondisk_sb);
+
+    reiserfs_close (fs);
+    printf ("\nDone\n");
+    return 0;
+}
diff --git a/tune/Makefile.in b/tune/Makefile.in
index 6e5eac8..fb4d8d1 100644
--- a/tune/Makefile.in
+++ b/tune/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,60 +12,98 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-
-SHELL = @SHELL@
+@SET_MAKE@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
 
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
 sbindir = @sbindir@
-
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 sbin_PROGRAMS = reiserfstune
 
 reiserfstune_SOURCES = tune.c tune.h
@@ -72,102 +112,113 @@
 EXTRA_DIST = $(man_MANS)
 
 LDADD = $(top_srcdir)/lib/libmisc.a $(top_srcdir)/reiserfscore/libcore.a
+subdir = tune
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../include/config.h
-CONFIG_CLEAN_FILES = 
-PROGRAMS =  $(sbin_PROGRAMS)
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+sbin_PROGRAMS = reiserfstune$(EXEEXT)
+PROGRAMS = $(sbin_PROGRAMS)
 
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I../include
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-reiserfstune_OBJECTS =  tune.o
+am_reiserfstune_OBJECTS = tune.$(OBJEXT)
+reiserfstune_OBJECTS = $(am_reiserfstune_OBJECTS)
 reiserfstune_LDADD = $(LDADD)
-reiserfstune_DEPENDENCIES =  $(top_srcdir)/lib/libmisc.a \
-$(top_srcdir)/reiserfscore/libcore.a
-reiserfstune_LDFLAGS = 
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+reiserfstune_DEPENDENCIES = $(top_srcdir)/lib/libmisc.a \
+	$(top_srcdir)/reiserfscore/libcore.a
+reiserfstune_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/tune.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-man8dir = $(mandir)/man8
-MANS = $(man_MANS)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(reiserfstune_SOURCES)
 
 NROFF = nroff
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
+MANS = $(man_MANS)
+DIST_COMMON = Makefile.am Makefile.in
 SOURCES = $(reiserfstune_SOURCES)
-OBJECTS = $(reiserfstune_OBJECTS)
 
-all: all-redirect
+all: all-am
+
 .SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps tune/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-sbinPROGRAMS:
-
-clean-sbinPROGRAMS:
-	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
-
-distclean-sbinPROGRAMS:
-
-maintainer-clean-sbinPROGRAMS:
-
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  tune/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 install-sbinPROGRAMS: $(sbin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(sbindir)
 	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  if test -f $$p; then \
-	    echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
-	     $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
+	   $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f || exit 1; \
 	  else :; fi; \
 	done
 
 uninstall-sbinPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	list='$(sbin_PROGRAMS)'; for p in $$list; do \
-	  rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+	@list='$(sbin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
+	  rm -f $(DESTDIR)$(sbindir)/$$f; \
 	done
 
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
+clean-sbinPROGRAMS:
+	-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
+reiserfstune$(EXEEXT): $(reiserfstune_OBJECTS) $(reiserfstune_DEPENDENCIES) 
+	@rm -f reiserfstune$(EXEEXT)
+	$(LINK) $(reiserfstune_LDFLAGS) $(reiserfstune_OBJECTS) $(reiserfstune_LDADD) $(LIBS)
 
 mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
+	-rm -f *.$(OBJEXT) core *.core
 
 distclean-compile:
 	-rm -f *.tab.c
 
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tune.Po@am__quote@
 
-reiserfstune: $(reiserfstune_OBJECTS) $(reiserfstune_DEPENDENCIES)
-	@rm -f reiserfstune
-	$(LINK) $(reiserfstune_LDFLAGS) $(reiserfstune_OBJECTS) $(reiserfstune_LDADD) $(LIBS)
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
 
-install-man8:
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+@am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+@am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+@am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+@am__fastdepCC_TRUE@	fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+man8dir = $(mandir)/man8
+install-man8: $(man8_MANS) $(man_MANS)
+	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(man8dir)
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
@@ -176,152 +227,212 @@
 	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
 	  else file=$$i; fi; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \
 	  $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \
 	done
-
 uninstall-man8:
-	@list='$(man8_MANS)'; \
-	l2='$(man_MANS)'; for i in $$l2; do \
+	@$(NORMAL_UNINSTALL)
+	@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
+	l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+	for i in $$l2; do \
 	  case "$$i" in \
 	    *.8*) list="$$list $$i" ;; \
 	  esac; \
 	done; \
 	for i in $$list; do \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+	  case "$$ext" in \
+	    8*) ;; \
+	    *) ext='8' ;; \
+	  esac; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+	  inst=`echo $$inst | sed -e 's/^.*\///'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
 	  echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \
 	  rm -f $(DESTDIR)$(man8dir)/$$inst; \
 	done
-install-man: $(MANS)
-	@$(NORMAL_INSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) install-man8
-uninstall-man:
-	@$(NORMAL_UNINSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) uninstall-man8
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
 
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
+	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-clean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = tune
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-tune.o: tune.c tune.h ../include/io.h ../include/misc.h \
-	../include/swab.h ../include/reiserfs_lib.h \
-	../include/reiserfs_fs.h ../include/config.h ../version.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am: install-sbinPROGRAMS
-install-exec: install-exec-am
+all-am: Makefile $(PROGRAMS) $(MANS)
 
-install-data-am: install-man
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir)
+
+install: install-am
+install-exec: install-exec-am
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-sbinPROGRAMS uninstall-man
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS) $(MANS)
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-	$(mkinstalldirs)  $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man8
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
 	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-sbinPROGRAMS mostlyclean-compile \
-		mostlyclean-tags mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-sbinPROGRAMS clean-compile clean-tags clean-generic \
-		mostlyclean-am
-
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-distclean-am:  distclean-sbinPROGRAMS distclean-compile distclean-tags \
-		distclean-generic clean-am
+clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
 
 distclean: distclean-am
 
-maintainer-clean-am:  maintainer-clean-sbinPROGRAMS \
-		maintainer-clean-compile maintainer-clean-tags \
-		maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-exec-am: install-sbinPROGRAMS
+
+install-info: install-info-am
+
+install-man: install-man8
+
+installcheck-am:
 
 maintainer-clean: maintainer-clean-am
 
-.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
-clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
-install-sbinPROGRAMS mostlyclean-compile distclean-compile \
-clean-compile maintainer-clean-compile install-man8 uninstall-man8 \
-install-man uninstall-man tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-man uninstall-sbinPROGRAMS
+
+uninstall-man: uninstall-man8
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-sbinPROGRAMS ctags distclean distclean-compile \
+	distclean-depend distclean-generic distclean-tags distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-man8 install-sbinPROGRAMS \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-info-am uninstall-man \
+	uninstall-man8 uninstall-sbinPROGRAMS
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/tune/reiserfstune.8 b/tune/reiserfstune.8
index b9dd728..03d97e9 100644
--- a/tune/reiserfstune.8
+++ b/tune/reiserfstune.8
@@ -1,7 +1,7 @@
 .\" -*- nroff -*-
-.\" Copyright 1996-2002 Hans Reiser.
+.\" Copyright 1996-2003 Hans Reiser.
 .\" 
-.TH REISERFSTUNE 8 "January 2002" "Reiserfsprogs-3.6.4"
+.TH REISERFSTUNE 8 "April 2003" "Reiserfsprogs-3.6.9"
 .SH NAME
 reiserfstune 
 .SH SYNOPSIS
@@ -9,7 +9,7 @@
 [ \fB-f\fR ]
 [ \fB-j\fR | \fB--journal-device\fR \fIFILE\fR ]
 [ \fB--no-journal-available\fR ]
-[ \fB--journal-new-device\fR \fIFILE\fR ]
+[ \fB--journal-new-device\fR \fIFILE\fR ] [ \fB--make-journal-standard\fR ]
 [ \fB-s\fR | \fB--journal-new-size\fR \fIN\fR ]
 [ \fB-o\fR | \fB--journal-new-offset\fR \fIN\fR ]
 [ \fB-t\fR | \fB--max-transaction-size\fR \fIN\fR ]
diff --git a/tune/tune.c b/tune/tune.c
index cc551ef..44c6b6c 100644
--- a/tune/tune.c
+++ b/tune/tune.c
@@ -1,6 +1,8 @@
 /*
- * Copyright 2002  Hans Reiser
+ * Copyright 2002-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #include "tune.h"
 
 char *program_name;
@@ -47,6 +49,11 @@
     exit (1);
 }
 
+/*
+    Undocumented options:
+    -B badblock_file
+*/
+
 unsigned long Journal_size = 0;
 int Max_trans_size = JOURNAL_TRANS_MAX;
 int Offset = 0;
@@ -54,62 +61,52 @@
 int Force = 0;
 char * LABEL;
 unsigned char UUID[16];
+char * badblocks_file;
 
-static int should_make_journal_non_standard (int force)
-{
-    message ("ATTENTION! Filesystem with standard journal found. ");
-    check_forcing_ask_confirmation (force);
-    return 1;
-}
-
+/* If specified paramenters defines the standard journal, make it standard. */
 static int should_make_journal_standard (reiserfs_filsys_t * fs, char * j_new_dev_name)
 {
     if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb))
 	return 0;
-    
+/*    
     if (!user_confirmed (stderr, "ATTENTION! Filesystem with non-standard journal "
 			 "found. Continue? (y/n):", "y\n")) {
 	exit(1);
     }
+*/  
     /* make sure journal is on main device, it has default size
      and the file system has non-standard magic */
-
+ 
     if (j_new_dev_name) {
 	/* new journal was specified - check if it is available */
-	if (strcmp (j_new_dev_name, fs->fs_file_name)) {
-	    message ("Can not create standard journal on separated device %s",
-		     j_new_dev_name);
+	if (strcmp (j_new_dev_name, fs->fs_file_name))
 	    return 0;
-	}
-	if (Journal_size && (Journal_size != journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize))) {
-	    message ("Can not create standard journal of the size %lu",
-		     Journal_size);
+	
+	if (Journal_size && Journal_size != 
+	    journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1) 
 	    return 0;
-	}
-	if (Max_trans_size && (Max_trans_size != JOURNAL_TRANS_MAX)) {
-		message ("Can not create standard journal with the transaction "
-			 "max size %u", Max_trans_size);
-		return 0;
-	}
-    }
-    else {
+	
+	if (Max_trans_size && (Max_trans_size != JOURNAL_TRANS_MAX))
+		return 0;	
+    } else {
 	/* new journal was not specified - check ondisk journal params */
-	if (get_jp_journal_dev(sb_jp(fs->fs_ondisk_sb))) {
-	    message ("Can not create standard journal on separated device [0x%x]",
-		    get_jp_journal_dev(sb_jp(fs->fs_ondisk_sb)));
-	    return 0;
-	}
-	if(get_jp_journal_size(sb_jp(fs->fs_ondisk_sb))!= journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize)){
-	    message ("Can not create standard journal of the size %u",
-		     get_jp_journal_size(sb_jp(fs->fs_ondisk_sb)));
+	
+	if (get_sb_reserved_for_journal(fs->fs_ondisk_sb) < 
+	    journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1)
+	{
+	    message ("Can not create standard journal of the size %llu",
+		     journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1);
 	    return 0;
 	}
     }
+
     return 1;
 }
 
 static int set_standard_journal_params (reiserfs_filsys_t * fs)
 {
+    struct buffer_head * bh;
+
     /* ondisk superblock update */
 
     if (get_sb_version(fs->fs_ondisk_sb) == 0)
@@ -123,6 +120,11 @@
 		 " try reiserfsck first", get_sb_version(fs->fs_ondisk_sb));
 	return 0;
     }
+    
+    set_jp_journal_1st_block (sb_jp(fs->fs_ondisk_sb), get_journal_start_must (fs));
+    set_jp_journal_dev (sb_jp(fs->fs_ondisk_sb), 0);
+    set_jp_journal_size (sb_jp(fs->fs_ondisk_sb), journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
+
     if (get_jp_journal_max_trans_len(sb_jp(fs->fs_ondisk_sb)) != JOURNAL_TRANS_MAX)
 	set_jp_journal_max_trans_len(sb_jp(fs->fs_ondisk_sb), JOURNAL_TRANS_MAX);
     if (get_jp_journal_max_batch(sb_jp(fs->fs_ondisk_sb)) != JOURNAL_MAX_BATCH)
@@ -134,15 +136,26 @@
     set_sb_reserved_for_journal (fs->fs_ondisk_sb, 0);
     
     /* journal_header update */
+    bh = getblk(fs->fs_journal_dev, 
+	    get_jp_journal_1st_block(sb_jp(fs->fs_ondisk_sb)) + 
+	    get_jp_journal_size(sb_jp(fs->fs_ondisk_sb)), fs->fs_blocksize);
     
-    ((struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data)) -> jh_journal =
-	*(sb_jp(fs->fs_ondisk_sb));
+    if (!bh) {
+	message ("Cannot get the journal header block. getblk failed.\n");
+	return 0;
+    }
+    ((struct reiserfs_journal_header *)(bh->b_data))->jh_journal = *(sb_jp(fs->fs_ondisk_sb));
+    mark_buffer_uptodate (bh, 1);
+    mark_buffer_dirty (bh);
+    bwrite(bh);
+    brelse(bh);
+
     return 1;
 }
 
 void zero_journal (reiserfs_filsys_t * fs)
 {
-    int i;
+    unsigned int i;
     struct buffer_head * bh;
     unsigned long done;
     unsigned long start, len;
@@ -214,7 +227,11 @@
     int Is_journal_or_maxtrans_size_specified = 0;
 
     program_name = strrchr( argv[ 0 ], '/' );
-    program_name = program_name ? ++ program_name : argv[ 0 ];
+
+    if (program_name)
+	program_name++;
+    else 
+	program_name = argv[ 0 ];
     
     print_banner (program_name);
 
@@ -243,7 +260,7 @@
 	};
 	int option_index;
       
-	c = getopt_long (argc, argv, "j:s:t:o:fu:l:",
+	c = getopt_long (argc, argv, "j:s:t:o:fu:l:B:",
 			 options, &option_index);
 	if (c == -1)
 	    break;
@@ -289,6 +306,9 @@
 	       confirmation */
 	    Force ++;
 	    break;
+	case 'B': /* --badblock-list */
+	    asprintf (&badblocks_file, "%s", optarg);			
+	    break;
 	case 'u':
 	    /* UUID */
 	    if (!strcmp(optarg, "random")) {
@@ -331,50 +351,108 @@
     /* device to be formatted */
     device_name = argv [optind];
 
-    if (!jdevice_name && !(Options & OPT_SKIP_J))
-        jdevice_name = device_name;
-
-    if (jdevice_name && (Options & OPT_SKIP_J)) {
-	    message ("either specify journal device, "
-		     "or choose the option --no-journal-awailable");
-	    return 1;
-    }
-    fs = reiserfs_open (device_name, O_RDONLY, 0, NULL);
+    fs = reiserfs_open (device_name, O_RDONLY, 0, NULL, 1);
     if (no_reiserfs_found(fs)) {
 	message ("Cannot open reiserfs on %s", device_name);
         return 1;
     }
 
-    /* now we try to open journal, it makes sence if there is no the flag
-       NEED_TUNE  in ondisk superblock */
-    if (get_jp_journal_magic(sb_jp(fs->fs_ondisk_sb)) != NEED_TUNE) {
-      if (!reiserfs_open_journal (fs, jdevice_name, O_RDONLY)) {
-	if (!(Options & OPT_SKIP_J)) {
-	    message ("Unable to open old journal.");
-	    reiserfs_close (fs);
-	    return 1;
-	}
-	else
-	  if (!reiserfs_is_fs_consistent (fs)) {
-	    message ("Check filesystem consistency first");
-	    reiserfs_close (fs);
-	    return 1;
-	  }
-	/* forced to continue without journal available/specifed */
-      }
-    }
-
     /* journal was opened or it wasn't opened but the option
        --no-journal-available has been specified by user */
 
     /* make sure filesystem is not mounted */
     if (is_mounted (fs->fs_file_name)) {
 	/* fixme: it can not be mounted, btw */
-        message ("can not rebuild journal of mounted filesystem");
+        message ("Reiserfstune is not allowed to be run on mounted filesystem.");
 	reiserfs_close (fs);
         return 1;
     }
+    
+    if (!reiserfs_is_fs_consistent (fs)) {
+	message ("Filesystem looks not cleanly umounted, check the consistency first.\n");
+	reiserfs_close (fs);
+	return 1;
+    }
 
+    reiserfs_reopen (fs, O_RDWR);
+    
+    if (badblocks_file) {
+	unsigned long i, marked = 0;
+	
+	if (reiserfs_open_ondisk_bitmap (fs) < 0) {
+	    message("Failed to open reiserfs ondisk bitmap.\n");
+	    reiserfs_close(fs);
+	    exit(1);
+	}
+	
+	if (create_badblock_bitmap (fs, badblocks_file)) {
+	    message("Failed to initialize the bad block bitmap.\n");
+	    reiserfs_close(fs);
+	    exit(1);
+	}
+	    
+	for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
+	    if (reiserfs_bitmap_test_bit (fs->fs_badblocks_bm, i)) {
+		if (!reiserfs_bitmap_test_bit (fs->fs_bitmap2, i)) {
+		    reiserfs_bitmap_set_bit (fs->fs_bitmap2, i);
+		    marked++;
+		} else {
+		    /* Check that this is a block  */
+		    if (not_data_block(fs, i)) {
+			message("Block %lu belongs to the internal reiserfs area "
+			    "and cannot be reloacted.\n", i);
+
+			exit(1);
+		    } else {
+			message("Block %lu is used already in reiserfs tree.\n", i);
+		    }
+		}
+	    }
+	}
+	
+	message("%lu bad blocks were marked as used.\n", marked);
+	
+	reiserfs_close(fs);
+	exit(0);
+    }
+    
+    if (!jdevice_name && !(Options & OPT_SKIP_J)) {
+	message ("Journal device has not been specified. Assuming journal is on the main "
+	    "device (%s).\n", device_name);
+        jdevice_name = device_name;
+    }
+
+    if (jdevice_name && (Options & OPT_SKIP_J)) {
+	message ("Either specify journal device, "
+		 "or choose the option --no-journal-available");
+	return 1;
+    }
+    
+    if (j_new_device_name && (Options & OPT_STANDARD)) {
+	/* New device was specified and --make-journal-standard was also. */
+	message ("Either specify new journal device, "
+		 "or choose the option --make-journal-standard");
+	return 1;
+    }
+    
+    /* now we try to open journal, it makes sence if there is no the flag
+       NEED_TUNE  in ondisk superblock and --no-journal available is not 
+       specified. */
+    if (get_jp_journal_magic(sb_jp(fs->fs_ondisk_sb)) != NEED_TUNE && 
+	!(Options & OPT_SKIP_J)) 
+    {
+	if (reiserfs_open_journal (fs, jdevice_name, O_RDWR | O_LARGEFILE)) {
+	    message ("Failed to open the journal device (%s).", jdevice_name);
+	    return 1;
+	}
+
+	if (reiserfs_journal_params_check(fs)) {
+	    message ("Unable to open old journal. Wrong journal parameters.");
+	    reiserfs_close (fs);
+	    return 1;
+	}
+    }
+    
     /* in spite of journal was opened, the file system can be non-consistent or
        there are non-replayed transaction in journal, 
        make sure it isn't (if there is no the flag NEED_TUNE in ondisk superblock */
@@ -398,13 +476,12 @@
 	} 
     }
 
-    reiserfs_reopen (fs, O_RDWR);
-
     /* set UUID and LABEL if specified */
     if (fs->fs_format == REISERFS_FORMAT_3_6) {
         if (uuid_is_correct (UUID)) {
 	    memcpy (fs->fs_ondisk_sb->s_uuid, UUID, 16);
 	    mark_buffer_dirty (fs->fs_super_bh);
+	    fs->fs_dirt = 1;
 	}
 	
 	if (LABEL != NULL) {
@@ -412,8 +489,8 @@
 	        message ("Specified LABEL is longer then 16 characters, will be truncated\n");
 	    strncpy (fs->fs_ondisk_sb->s_label, LABEL, 16);
 	    mark_buffer_dirty (fs->fs_super_bh);
+	    fs->fs_dirt = 1;
 	}
-	fs->fs_dirt = 1;
     } else {
         if (uuid_is_correct (UUID))
             reiserfs_panic ("UUID cannot be specified for 3.5 format\n");
@@ -422,15 +499,22 @@
     }
 
     if (!j_new_device_name) {
-	/* new journal device hasn't been specify */
+	
+	/* new journal device hasn't been specified */
 	printf ("Current parameters:\n");
 	print_filesystem_state (stdout, fs);
 	print_block (stdout, fs, fs->fs_super_bh);
-	printf ("Current journal parameters:\n");
-	print_journal_params (stdout, sb_jp (fs->fs_ondisk_sb));
 
 	if ((Options & OPT_STANDARD)
-	    && should_make_journal_standard(fs, j_new_device_name)) {
+	    && should_make_journal_standard(fs, j_new_device_name)) 
+	{
+	    if (!user_confirmed (stderr, "ATTENTION! Filesystem with "
+		"non-standard journal found. Continue? (y/n):", "y\n")) 
+	    {
+		exit(1);
+	    }
+
+	    fs->fs_journal_dev = fs->fs_dev;
 	    if (set_standard_journal_params (fs)) {
 		printf ("\nNew parameters:\n");
 		print_filesystem_state (stdout, fs);
@@ -439,8 +523,6 @@
 		print_journal_params (stdout, sb_jp (fs->fs_ondisk_sb));
 		mark_buffer_dirty (fs->fs_super_bh);
 		mark_buffer_uptodate (fs->fs_super_bh, 1);
-		mark_buffer_dirty (fs->fs_jh_bh);
-		mark_buffer_uptodate (fs->fs_jh_bh, 1);
 		reiserfs_close (fs);
 		printf ("Syncing.."); fflush (stdout);
 		sync ();
@@ -448,12 +530,18 @@
 		return 0;
 	    }
 	}
-	if (Is_journal_or_maxtrans_size_specified)
+	
+	if (Is_journal_or_maxtrans_size_specified) {
 	    /* new journal device hasn't been specified, but
 	       journal size or max transaction size have been, so we suppose
 	       that journal device remains the same */
+	    if (!reiserfs_journal_opened (fs)) {
+		message("Cannot set up new paramenters for not specified journal.");
+		return 1;
+	    }
+	
 	    j_new_device_name = jdevice_name;
-	else {	
+	} else {	
 	    /* the only parameter has been specified is device_name, so
 	       there is nothing to do */
 	    reiserfs_close (fs);
@@ -479,17 +567,23 @@
 	else
 	    /* non-standard journal */
 	    reserved = get_sb_reserved_for_journal (fs->fs_ondisk_sb);
+		
+	journal_size = Journal_size;
 	
-	journal_size = (Journal_size ? Journal_size : journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
+	if (!journal_size) {
+	    journal_size = journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1;
+	    message("Journal size has not been specified. Assuming it is the default size (%lu)", 
+		journal_size);
+	}
 	
 /*	journal_size = (Journal_size ? Journal_size : // specified
 			(fs->fs_blocksize == 1024 ? (fs->fs_blocksize) * 8 - 3 -
 			 REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize :
 			 JOURNAL_DEFAULT_SIZE + 1));	// default
 */
-	if (journal_size > reserved) {
+	if (journal_size + Offset > get_journal_start_must (fs) + reserved) {
 		message ("There is no enough space reserved for journal on main "
-			 "device (journal_size=%lu, reserved=%lu\n", journal_size,
+			 "device (journal_size=%lu, reserved=%lu)\n", journal_size,
 			 reserved);
 	    reiserfs_close (fs);
 	    return 1;
@@ -502,11 +596,14 @@
     if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb)) {
 	/* we have standard journal, so check if we can convert it
 	   to non-standard one */
+	
+	/*
 	if (!should_make_journal_non_standard (Force)) {
 	    reiserfs_close (fs);
 	    return 1;
 	}
-
+	*/
+	
         if (is_reiserfs_3_6_magic_string (fs->fs_ondisk_sb))
 	    set_sb_version (fs->fs_ondisk_sb, REISERFS_FORMAT_3_6);
         else if (is_reiserfs_3_5_magic_string (fs->fs_ondisk_sb))
@@ -520,7 +617,7 @@
 	memcpy (fs->fs_ondisk_sb->s_v1.s_magic, REISERFS_JR_SUPER_MAGIC_STRING,
 		strlen (REISERFS_JR_SUPER_MAGIC_STRING));
 	set_sb_reserved_for_journal (fs->fs_ondisk_sb,
-				     get_jp_journal_size (sb_jp(fs->fs_ondisk_sb)) + 1);
+		get_jp_journal_size (sb_jp(fs->fs_ondisk_sb)) + 1);
     }
 
     /* now we are going to close old journal and to create a new one */
@@ -533,10 +630,9 @@
         return 1;
     }
 
-    if (Options & OPT_STANDARD) 
-	if (should_make_journal_standard (fs, j_new_device_name))
-	    set_standard_journal_params (fs);
-    
+    if (should_make_journal_standard (fs, j_new_device_name))
+	set_standard_journal_params (fs);
+
     message ("New journal parameters:");
     print_journal_params (stdout, sb_jp (fs->fs_ondisk_sb));
 
diff --git a/tune/tune.h b/tune/tune.h
index 529ac4c..fb3cec2 100644
--- a/tune/tune.h
+++ b/tune/tune.h
@@ -1,6 +1,8 @@
 /*
- * Copyright 2002 Hans Reiser, licensing governed by ../README
+ * Copyright 2002-2003 by Hans Reiser, licensing governed by 
+ * reiserfsprogs/README
  */
+
 #define _GNU_SOURCE
 
 #include <stdio.h>
diff --git a/version.h b/version.h
index c62ca84..86ec530 100644
--- a/version.h
+++ b/version.h
@@ -1,7 +1,7 @@
 /*
- * Copyright 2002 Hans Reiser
+ * Copyright 2002-2003 Hans Reiser, licensing governed by reiserfsprogs/README
  */
 
 #define print_banner(prog) \
-fprintf (stderr, "\n<-------------%s, 2002------------->\nreiserfsprogs %s\n\n", \
+fprintf (stderr, "\n<-------------%s, 2003------------->\nreiserfsprogs %s\n\n", \
 prog, VERSION)