Imported reiserfsprogs-3.6.9

This commit is contained in:
Jeff Mahoney committed 2012-10-11 11:29:29 -04:00
1 parent 99c89460c3
commit cccefa4d84
86 files changed
+13393 -6954

No files matched your search

+277 -190
View File
@@ -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.
+79 -73
View File
@@ -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 @@ int reiserfs_expand_bitmap (reiserfs_bitmap_t * bm, unsigned int bit_count)
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 @@ void reiserfs_shrink_bitmap (reiserfs_bitmap_t * bm, unsigned int bit_count)
bm->bm_byte_size = (bit_count + 7) / 8;
bm->bm_bit_size = bit_count;
bm->bm_dirty = 1;
}
/* bitmap destructor */
@@ -80,8 +86,8 @@ void reiserfs_bitmap_copy (reiserfs_bitmap_t * to, reiserfs_bitmap_t * from)
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 @@ int reiserfs_bitmap_compare (reiserfs_bitmap_t * bm1, reiserfs_bitmap_t * bm2)
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 @@ void reiserfs_bitmap_disjunction (reiserfs_bitmap_t * to, reiserfs_bitmap_t * fr
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_delta (reiserfs_bitmap_t * base, reiserfs_bitmap_t * exclud
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_set_bit (reiserfs_bitmap_t * bm, unsigned int bit_number)
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 @@ int reiserfs_bitmap_test_bit (reiserfs_bitmap_t * bm, unsigned int bit_number)
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 @@ int reiserfs_bitmap_find_zero_bit (reiserfs_bitmap_t * bm, unsigned long * start
/* 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 @@ static int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys
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 @@ static int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys
/* 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 @@ static int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys
bm->bm_set_bits ++;
bm->bm_dirty = 0;
return 0;
return ret;
}
@@ -283,14 +301,10 @@ static int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys
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 @@ int reiserfs_flush_to_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t *
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 @@ void reiserfs_bitmap_save (FILE * fp, reiserfs_bitmap_t * bm)
__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 @@ void reiserfs_bitmap_save (FILE * fp, reiserfs_bitmap_t * bm)
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 @@ void reiserfs_bitmap_save (FILE * fp, reiserfs_bitmap_t * bm)
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 @@ int is_stage_magic_correct (FILE * fp)
__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 @@ int is_stage_magic_correct (FILE * fp)
}
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 @@ reiserfs_bitmap_t * reiserfs_bitmap_load (FILE * fp)
/* 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 @@ reiserfs_bitmap_t * reiserfs_bitmap_load (FILE * fp)
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 @@ void reiserfs_free_ondisk_bitmap (reiserfs_filsys_t * fs)
/* 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)
+7 -8
View File
@@ -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 @@ static int balance_leaf(/*struct reiserfs_transaction_handle *th, */
/* 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 @@ static int balance_leaf(/*struct reiserfs_transaction_handle *th, */
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 @@ struct buffer_head * get_FEB (struct tree_balance * tb)
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 replace_key (reiserfs_filsys_t * fs,
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;
+9 -24
View File
@@ -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 @@ static void create_virtual_node (struct tree_balance * tb, int h)
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 @@ static int are_leaves_removable (struct tree_balance * tb, int lfree, int rfree)
}
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 @@ static inline int can_node_be_removed (int mode, int lfree, int sfree, int rfree
{
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 @@ static int dc_check_balance_internal (struct tree_balance * tb, int h)
/* 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 @@ static int dc_check_balance_leaf (struct tree_balance * tb, int h)
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);
+2 -2
View File
@@ -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
*/
/*
+2 -2
View File
@@ -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"
+5 -2
View File
@@ -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"
+297 -185
View File
@@ -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 @@ unsigned long next_desc_expected (reiserfs_filsys_t * fs, struct buffer_head * d
((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 @@ int is_valid_transaction (reiserfs_filsys_t * fs, struct buffer_head * d_bh)
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 @@ int get_boundary_transactions (reiserfs_filsys_t * fs,
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 @@ int next_transaction (reiserfs_filsys_t * fs, reiserfs_trans_t * trans, reiserfs
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 @@ int next_transaction (reiserfs_filsys_t * fs, reiserfs_trans_t * trans, reiserfs
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 @@ int next_transaction (reiserfs_filsys_t * fs, reiserfs_trans_t * trans, reiserfs
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 @@ void for_each_block (reiserfs_filsys_t * fs, reiserfs_trans_t * trans,
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 @@ void for_each_transaction (reiserfs_filsys_t * fs, action_on_trans_t action)
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 @@ unsigned long get_size_of_journal_or_reserved_area (struct reiserfs_super_block
}
__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 @@ __u32 advise_journal_max_trans_len (__u32 desired, __u32 journal_size, int block
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 @@ __u32 advise_journal_max_trans_age (void)
}
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 @@ int reiserfs_open_journal (reiserfs_filsys_t * fs, char * j_filename, int flags)
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 @@ int reiserfs_create_journal (reiserfs_filsys_t * fs, char * j_filename,
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);
len = advise_journal_length (fs, len - 1) + 1;
asprintf (&fs->fs_j_file_name, "%s", j_device);
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 @@ void reiserfs_reopen_journal (reiserfs_filsys_t * fs, int flag)
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 @@ int replay_journal (reiserfs_filsys_t * fs)
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 @@ int replay_journal (reiserfs_filsys_t * fs)
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);
+11 -14
View File
@@ -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 @@ void leaf_insert_into_buf (reiserfs_filsys_t * s,
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 @@ void leaf_paste_in_buffer (reiserfs_filsys_t * fs,
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 @@ void leaf_cut_from_buffer (reiserfs_filsys_t * fs,
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 @@ static void leaf_delete_items_entirely (reiserfs_filsys_t * fs,
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 @@ void leaf_paste_entries (struct buffer_head * bh,
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 */
+120 -174
View File
@@ -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 @@ static int does_node_look_like_a_leaf (char * buf, int blocksize)
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 @@ static int does_node_look_like_a_leaf (char * buf, int blocksize)
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 @@ int does_node_have_ih_array (char * buf, int blocksize)
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 @@ int is_tree_node (struct buffer_head * bh, int level)
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 @@ int reiserfs_super_block_size (struct reiserfs_super_block * sb)
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 @@ int does_look_like_super_block (struct reiserfs_super_block * sb) {
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 @@ int who_is_this (char * buf, int blocksize)
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 @@ char * which_block (int code)
/** */
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 @@ int block_of_bitmap (reiserfs_filsys_t * fs, unsigned long block)
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 @@ int not_data_block (reiserfs_filsys_t * fs, unsigned long block)
/* 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 @@ int not_journalable (reiserfs_filsys_t * fs, unsigned long block)
// 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 @@ __u64 get_bytes_number (struct item_head * ih, int blocksize)
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 does_ih_look_correct (struct item_head * ih)
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 known_hashes (void)
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 @@ int is_properly_hashed (reiserfs_filsys_t * fs,
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 @@ int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, int cod
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 @@ int find_hash_in_use (char * name, int namelen, __u32 hash_value_masked, int cod
}
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 @@ char * code2name (int code)
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 @@ int func2code (hashf_t func)
}
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 code2func (int code)
}
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 @@ static int is_bad_directory (reiserfs_filsys_t * fs, struct item_head * ih, char
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 @@ int key_format (const struct key * key)
}
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 @@ void mark_objectid_used (reiserfs_filsys_t * fs, __u32 objectid)
}
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)));
}
+53 -42
View File
@@ -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 @@ static void print_sequence (FILE * fp, __u32 start, int len)
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 timebuf[256];
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 @@ static int print_leaf (FILE * fp, reiserfs_filsys_t * fs, struct buffer_head * b
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 @@ static int print_leaf (FILE * fp, reiserfs_filsys_t * fs, struct buffer_head * b
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 @@ int print_super_block (FILE * fp, reiserfs_filsys_t * fs, char * file_name,
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 @@ int print_super_block (FILE * fp, reiserfs_filsys_t * fs, char * file_name,
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 @@ int print_super_block (FILE * fp, reiserfs_filsys_t * fs, char * file_name,
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_block (FILE * fp, reiserfs_filsys_t * fs,
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 @@ void print_tb (int mode, int item_pos, int pos_in_item, struct tree_balance * tb
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 @@ void print_tb (int mode, int item_pos, int pos_in_item, struct tree_balance * tb
/* 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 @@ static void print_bmap_block (FILE * fp, int i, unsigned long block, char * map,
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 @@ static void print_bmap_block (FILE * fp, int i, unsigned long block, char * map,
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 @@ static void print_bmap_block (FILE * fp, int i, unsigned long block, char * map,
j --;
end:
/* to make gcc 3.2 do not sware here */;
}
} else {
/* first block addressed by this bitmap is free */
@@ -852,7 +860,7 @@ static void print_bmap_block (FILE * fp, int i, unsigned long block, char * map,
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 @@ static void print_bmap_block (FILE * fp, int i, unsigned long block, char * map,
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 @@ static void print_bmap_block (FILE * fp, int i, unsigned long block, char * map,
j --;
end2:
/* to make gcc 3.2 do not sware here */;
}
}
@@ -952,13 +961,14 @@ void print_objectid_map (FILE * fp, reiserfs_filsys_t * fs)
(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 @@ void print_journal_header (reiserfs_filsys_t * fs)
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);
+78 -44
View File
@@ -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 @@ static void make_const_keys (void)
/* 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 @@ int is_block_count_correct (unsigned long block_of_super_block, int block_size,
}
/* 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 @@ reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int *error, void
} 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_filsys_t * reiserfs_open (char * filename, int flags, int *error, void
}
}
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 @@ reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int *error, void
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 @@ reiserfs_filsys_t * reiserfs_open (char * filename, int flags, int *error, void
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 @@ reiserfs_filsys_t * reiserfs_create (char * filename,
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 @@ reiserfs_filsys_t * reiserfs_create (char * filename,
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 @@ reiserfs_filsys_t * reiserfs_create (char * filename,
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 @@ reiserfs_filsys_t * reiserfs_create (char * filename,
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 @@ reiserfs_filsys_t * reiserfs_create (char * filename,
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 @@ int spread_bitmaps (reiserfs_filsys_t * fs)
/* 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 @@ void reiserfs_only_reopen (reiserfs_filsys_t * fs, int flag)
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 @@ void reiserfs_only_reopen (reiserfs_filsys_t * fs, int flag)
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 @@ int reiserfs_locate_entry (reiserfs_filsys_t * fs, struct key * dir, char * name
}
/* 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 @@ int reiserfs_locate_entry (reiserfs_filsys_t * fs, struct key * dir, char * name
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 @@ int reiserfs_find_entry (reiserfs_filsys_t * fs, struct key * dir, char * name,
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 @@ char * make_entry (char * entry, char * name, struct key * key, __u32 offset)
/* 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 @@ int create_badblock_bitmap (reiserfs_filsys_t * fs, char * badblocks_file) {
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);
}
}
+2 -1
View File
@@ -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
*/
/*