Imported reiserfsprogs-3.6.21

This commit is contained in:
Jeff Mahoney committed 2012-10-11 11:32:39 -04:00
1 parent dac518d099
commit 149a82e2e9
193 files changed
+32708 -44216

No files matched your search

+8 -4
View File
@@ -38,18 +38,18 @@ 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
Edward Shishkin 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 worked on libreiser4 and userspace plugins; developped librepair, userspace
plugins repair code, fsck & debugfs for V4.
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 & debugfs.
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
@@ -79,6 +79,10 @@ 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 Europe (www.lycos-europe.com) had a support contract with us that
consistently came in just when we would otherwise have missed payroll, and that
they kept 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.
+23
View File
@@ -1,3 +1,26 @@
2009-01-09
3.6.21 release.
2009-01-09
Patches from Jeff Mahoney:
- reiserfsprogs-mkreiserfs-quiet.diff
- reiserfsprogs-large-block-warning.diff
- reiserfsprogs-fsck-mapid.diff
- reiserfsprogs-external-journal-changes.diff
- reiserfsprogs-remove-stupid-fsck_sleep.diff
- reiserfsprogs-mkfs-use-o_excl.diff
- reiserfsprogs-enforce-block-limit.diff
- reiserfsprogs-large-fs.diff
- reiserfsprogs-better-fsck-a-behavior.diff
- reiserfsprogs-remove-dependency-on-asm_unaligned.h.diff
- reiserfsprogs-progress.diff
- reiserfsprogs-reorder-libs.diff
Patches from Ludwig Nussel:
- mkreiserfs-set-the-owner-of-the-root-directory-to-the-calling-user.diff
Patches from Edward Shishkin:
- reiserfsprogs-disable-small-block.diff
- reiserfsprogs-new-version.diff
2004-10-13
3.6.19 release.
2004-09-22
+1 -1
View File
@@ -85,7 +85,7 @@ Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/sbin', `/usr/local/man', etc. You can specify an
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
+5 -15
View File
@@ -1,18 +1,8 @@
SUBDIRS = include libmisc libreiserfs libutil utils
SUBDIRS = include lib reiserfscore fsck debugreiserfs resize_reiserfs mkreiserfs tune
EXTRA_DIST = AUTHORS COPYING NEWS README CREDITS \
reiserfsprogs.spec reiserfsprogs.spec.in depcomp
# libreiserfs.m4
noinst_DATA = reiserfsprogs.spec
aclocaldir = $(datadir)/aclocal
#aclocal_DATA = libreiserfs.m4
EXTRA_DIST = CREDITS version.h
define all-sources
( find ./ -name '*.[ch]' | grep -v SCCS | grep -v "Attic" | grep -v "reiserfsprogs" )
endef
TAGS:
$(all-sources) | etags -
tags:
$(all-sources) | xargs -- ctags -w -o TAGS
dist-hook:
cp -f reiserfsprogs.spec $(distdir)
+125 -107
View File
@@ -1,8 +1,8 @@
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006 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.
@@ -13,15 +13,12 @@
# 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
@@ -35,29 +32,32 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/reiserfsprogs.spec.in $(top_srcdir)/configure \
AUTHORS COPYING ChangeLog INSTALL NEWS compile config.guess \
config.sub depcomp install-sh missing mkinstalldirs
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \
ChangeLog INSTALL NEWS config.guess config.sub depcomp \
install-sh missing mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
configure.lineno config.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = reiserfsprogs.spec
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
DATA = $(noinst_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
@@ -73,8 +73,6 @@ GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -93,6 +91,8 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -103,9 +103,8 @@ LIBS = @LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -114,18 +113,17 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PROGS_LDFLAGS = @PROGS_LDFLAGS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
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__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -137,36 +135,43 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = include libmisc libreiserfs libutil utils
EXTRA_DIST = AUTHORS COPYING NEWS README CREDITS \
reiserfsprogs.spec reiserfsprogs.spec.in depcomp
# libreiserfs.m4
aclocaldir = $(datadir)/aclocal
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = include lib reiserfscore fsck debugreiserfs resize_reiserfs mkreiserfs tune
noinst_DATA = reiserfsprogs.spec
EXTRA_DIST = CREDITS version.h
all: all-recursive
.SUFFIXES:
am--refresh:
@@ -203,26 +208,6 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
reiserfsprogs.spec: $(top_builddir)/config.status $(srcdir)/reiserfsprogs.spec.in
cd $(top_builddir) && $(SHELL) ./config.status $@
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,
@@ -254,8 +239,7 @@ $(RECURSIVE_TARGETS):
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
$(RECURSIVE_CLEAN_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
@@ -302,12 +286,42 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$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; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
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 | \
@@ -327,24 +341,22 @@ distclean-tags:
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
$(mkdir_p) $(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; \
test -d $(distdir) || mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
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"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
@@ -358,7 +370,7 @@ distdir: $(DISTFILES)
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(mkdir_p) "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
@@ -366,14 +378,19 @@ distdir: $(DISTFILES)
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
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 {} {} \; \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
@@ -448,7 +465,7 @@ distcheck: dist
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
@@ -469,7 +486,7 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile config.h
all-am: Makefile $(DATA)
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
@@ -503,7 +520,7 @@ clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
@@ -517,12 +534,20 @@ info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-exec-am:
install-html: install-html-recursive
install-info: install-info-recursive
install-man:
install-pdf: install-pdf-recursive
install-ps: install-ps-recursive
installcheck-am:
maintainer-clean: maintainer-clean-recursive
@@ -543,36 +568,29 @@ ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-am:
uninstall-info: uninstall-info-recursive
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
install-strip
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \
check-am clean clean-generic clean-recursive ctags \
ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-shar \
dist-tarZ dist-zip distcheck distclean distclean-generic \
distclean-hdr distclean-recursive distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am html \
html-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 installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-recursive pdf \
pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-info-am
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \
ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
dist-hook dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-generic distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
tags-recursive uninstall uninstall-am
#aclocal_DATA = libreiserfs.m4
define all-sources
( find ./ -name '*.[ch]' | grep -v SCCS | grep -v "Attic" | grep -v "reiserfsprogs" )
endef
TAGS:
$(all-sources) | etags -
tags:
$(all-sources) | xargs -- ctags -w -o TAGS
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:
Vendored
+92 -6111
View File
File diff suppressed because it is too large. Load diff
-142
View File
@@ -1,142 +0,0 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
scriptversion=2005-02-03.08
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# 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.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
esac
ofile=
cfile=
eat=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we strip `-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
+41 -93
View File
@@ -1,9 +1,9 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2005-02-10'
timestamp='2003-07-02'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@@ -207,21 +207,15 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit 0 ;;
amd64:OpenBSD:*:*)
echo x86_64-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
cats:OpenBSD:*:*)
echo arm-unknown-openbsd${UNAME_RELEASE}
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
luna88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
@@ -237,33 +231,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
mvmeppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mips64-unknown-openbsd${UNAME_RELEASE}
echo mipseb-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sun3:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:ekkoBSD:*:*)
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
exit 0 ;;
macppc:MirBSD:*:*)
echo powerppc-unknown-mirbsd${UNAME_RELEASE}
exit 0 ;;
*:MirBSD:*:*)
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
exit 0 ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
fi
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
@@ -301,12 +287,14 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit 0 ;;
Alpha*:OpenVMS:*:*)
echo alpha-hp-vms
exit 0 ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
@@ -329,12 +317,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:OS/390:*:*)
echo i370-ibm-openedition
exit 0 ;;
*:z/VM:*:*)
echo s390-ibm-zvmoe
exit 0 ;;
*:OS400:*:*)
echo powerpc-ibm-os400
exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
@@ -355,7 +337,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit 0 ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
DRS?6000:UNIX_SV:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7 && exit 0 ;;
esac ;;
@@ -427,9 +409,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
@@ -765,7 +744,7 @@ EOF
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
*:UNICOS/mp:*:*)
echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
@@ -773,11 +752,6 @@ EOF
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
@@ -787,8 +761,22 @@ EOF
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
*:FreeBSD:*:*|*:GNU/FreeBSD:*:*)
# Determine whether the default compiler uses glibc.
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#if __GLIBC__ >= 2
LIBC=gnu
#else
LIBC=
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
# GNU/FreeBSD systems have a "k" prefix to indicate we are using
# FreeBSD's kernel, but not the complete OS.
case ${LIBC} in gnu) kernel_only='k' ;; esac
echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -814,9 +802,6 @@ EOF
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
exit 0 ;;
amd64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit 0 ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit 0 ;;
@@ -824,13 +809,8 @@ EOF
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
exit 0 ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit 0 ;;
@@ -840,18 +820,9 @@ EOF
cris:Linux:*:*)
echo cris-axis-linux
exit 0 ;;
crisv32:Linux:*:*)
echo crisv32-axis-linux
exit 0 ;;
frv:Linux:*:*)
echo frv-${VENDOR}-linux
exit 0 ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-${VENDOR}-linux
exit 0 ;;
@@ -987,9 +958,6 @@ EOF
LIBC=gnuaout
#endif
#endif
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}" | sed 's/linux-gnu/linux/' && exit 0
@@ -1020,9 +988,6 @@ EOF
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit 0 ;;
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
@@ -1092,9 +1057,9 @@ EOF
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit 0 ;;
M68*:*:R3V[5678]*:*)
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -1192,10 +1157,9 @@ EOF
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
case `uname -p` in
*86) UNAME_PROCESSOR=i686 ;;
unknown) UNAME_PROCESSOR=powerpc ;;
powerpc) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit 0 ;;
@@ -1210,10 +1174,7 @@ EOF
*:QNX:*:4*)
echo i386-pc-qnx
exit 0 ;;
NSE-?:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
NSR-?:NONSTOP_KERNEL:*:*)
NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
*:NonStop-UX:*:*)
@@ -1257,19 +1218,6 @@ EOF
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
exit 0 ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms && exit 0 ;;
I*) echo ia64-dec-vms && exit 0 ;;
V*) echo vax-dec-vms && exit 0 ;;
esac ;;
*:XENIX:*:SysV)
echo i386-pc-xenix
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
Vendored
+30 -92
View File
@@ -1,9 +1,9 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2005-02-10'
timestamp='2003-07-04'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -70,7 +70,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@@ -118,8 +118,7 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
nto-qnx* | linux-gnu* | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -145,7 +144,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray)
-apple | -axis)
os=
basic_machine=$1
;;
@@ -229,15 +228,14 @@ case $basic_machine in
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
| ip2k \
| m32r | m68000 | m68k | m88k | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@@ -249,7 +247,6 @@ case $basic_machine in
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
@@ -262,12 +259,12 @@ case $basic_machine in
| pyramid \
| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
| x86 | xscale | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
@@ -300,17 +297,17 @@ case $basic_machine in
| avr-* \
| bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | craynv-* | cydra-* \
| clipper-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| m32r-* | m32rle-* \
| ip2k-* \
| m32r-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* \
| m88110-* | m88k-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@@ -322,13 +319,11 @@ case $basic_machine in
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| msp430-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
@@ -337,14 +332,14 @@ case $basic_machine in
| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
| xtensa-* \
| ymp-* \
| z8k-*)
;;
@@ -364,9 +359,6 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
@@ -384,9 +376,6 @@ case $basic_machine in
amd64)
basic_machine=x86_64-pc
;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
@@ -446,27 +435,12 @@ case $basic_machine in
basic_machine=j90-cray
os=-unicos
;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16c)
basic_machine=cr16c-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
@@ -489,10 +463,6 @@ case $basic_machine in
basic_machine=m88k-motorola
os=-sysv3
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
@@ -671,6 +641,10 @@ case $basic_machine in
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
mmix*)
basic_machine=mmix-knuth
os=-mmixware
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
@@ -751,6 +725,10 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
nv1)
basic_machine=nv1-cray
os=-unicosmp
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@@ -762,10 +740,6 @@ case $basic_machine in
basic_machine=or32-unknown
os=-coff
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
@@ -986,10 +960,6 @@ case $basic_machine in
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
@@ -1033,10 +1003,6 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
@@ -1067,9 +1033,6 @@ case $basic_machine in
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
rs6000)
basic_machine=rs6000-ibm
;;
@@ -1092,7 +1055,7 @@ case $basic_machine in
sh64)
basic_machine=sh64-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b)
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
cydra)
@@ -1165,20 +1128,19 @@ case $os in
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
| -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
| -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1202,9 +1164,6 @@ case $os in
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
@@ -1214,9 +1173,6 @@ case $os in
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
@@ -1238,9 +1194,6 @@ case $os in
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
@@ -1263,9 +1216,6 @@ case $os in
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
@@ -1302,9 +1252,6 @@ case $os in
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
-none)
;;
*)
@@ -1385,9 +1332,6 @@ case $basic_machine in
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
@@ -1520,15 +1464,9 @@ case $basic_machine in
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
Vendored
+3837 -4309
View File
File diff suppressed because it is too large. Load diff
+28 -85
View File
@@ -1,87 +1,41 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(include/reiserfs/libreiserfs.h)
AC_INIT(version.h)
AC_CANONICAL_HOST
AC_PREREQ(2.50)
AH_TEMPLATE([PACKAGE], [Define this to be the name of the package.])
AH_TEMPLATE([VERSION], [Define to the version of the package.])
AH_TEMPLATE([HAVE_LIBUUID], [Define for enable libuuid using.])
AH_TEMPLATE([ENABLE_DEBUG], [Define for enable debug info.])
dnl AH_TEMPLATE([LIBREISERFS_MAX_INTERFACE_VERSION], [Define to the max interface version.])
dnl AH_TEMPLATE([LIBREISERFS_MIN_INTERFACE_VERSION], [Define to the min interface version.])
LIBREISERFS_MAJOR_VERSION=3
LIBREISERFS_MINOR_VERSION=6
LIBREISERFS_MICRO_VERSION=20
LIBREISERFS_VERSION=$LIBREISERFS_MAJOR_VERSION.$LIBREISERFS_MINOR_VERSION.$LIBREISERFS_MICRO_VERSION
dnl LIBREISERFS_INTERFACE_AGE=0
dnl LIBREISERFS_BINARY_AGE=0
dnl LT_RELEASE=$LIBREISERFS_MAJOR_VERSION.$LIBREISERFS_MINOR_VERSION
dnl LT_CURRENT=`expr $LIBREISERFS_MICRO_VERSION - $LIBREISERFS_INTERFACE_AGE`
dnl LT_REVISION=$LIBREISERFS_INTERFACE_AGE
dnl LT_AGE=`expr $LIBREISERFS_BINARY_AGE - $LIBREISERFS_INTERFACE_AGE`
PACKAGE=reiserfsprogs
VERSION=$LIBREISERFS_VERSION
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(reiserfsprogs, 3.6.21)
AM_MAINTAINER_MODE
dnl AC_DEFINE_UNQUOTED(LIBREISERFS_MAX_INTERFACE_VERSION, $LIBREISERFS_BINARY_AGE)
dnl AC_DEFINE_UNQUOTED(LIBREISERFS_MIN_INTERFACE_VERSION, $LIBREISERFS_INTERFACE_AGE)
AC_ARG_ENABLE(debug,
[ --enable-debug enable extra checks], ,
enable_debug=no
)
PROGS_LDFLAGS=""
AC_ARG_ENABLE(static,
[ --enable-static build all static], ,
enable_static=no
)
if test x$enable_static = xyes; then
PROGS_LDFLAGS=-static
fi
dnl We install in /sbin, the utils are to be available on boot
dnl AC_PREFIX(/)
AM_CONFIG_HEADER(include/config.h)
AC_SUBST(sbindir)
PRESET_CFLAGS=$CFLAGS
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AM_ENABLE_SHARED
dnl AM_PROG_LIBTOOL
dnl Checks for libraries.
# Check for LIBUUID
LIBS=""
AC_CHECK_LIB(uuid, uuid_generate, , AC_MSG_WARN(libuuid could not be found))
UUID_LIBS="$LIBS"
AC_SUBST(UUID_LIBS)
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_CHECK_HEADERS(print.h errno.h fcntl.h limits.h malloc.h sys/ioctl.h unistd.h uuid/uuid.h)
AC_CHECK_HEADERS([asm/unaligned.h])
AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h unistd.h uuid/uuid.h)
AC_HEADER_MAJOR
dnl Checks for typedefs, structures, and compiler characteristics.
@@ -89,7 +43,11 @@ AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_STRUCT_ST_RDEV
AC_C_BIGENDIAN
AC_ARG_ENABLE(debug, [ --enable-debug enable extra checks],
enable_debug=yes,
enable_debug=no
)
dnl Check for the compiler pic option.
AC_CACHE_CHECK([whether -fPIC works], [pic], [
@@ -124,7 +82,7 @@ AC_CACHE_CHECK([whether -Wredundant-decls works], [redundant_decls], [
# Check for large file
AC_SYS_LARGEFILE
if test x${ac_cv_sys_file_offset_bits} = xno; then
if test -z "${ac_cv_sys_file_offset_bits}"; then
AC_MSG_WARN(Can't detect right _FILE_OFFSET_BITS. Will be forced to 64bit.)
ac_cv_sys_file_offset_bits=64
fi
@@ -143,12 +101,11 @@ AC_CHECK_SIZEOF(blkcnt_t, 64, [
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_STAT
AC_FUNC_MEMCMP
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(strerror strstr strtol register_printf_function statfs getmntent\
hasmntopt memset time uname)
hasmntopt memset time uname strptime ctime_r)
dnl Never enable this. It is for debugging only
@@ -160,7 +117,7 @@ AC_ARG_ENABLE(io-failure-emulation,
fi
])
credits="$srcdir/CREDITS"
credits="./CREDITS"
AC_MSG_CHECKING(for $credits)
if test -r $credits ; then
AC_MSG_RESULT(yes)
@@ -193,7 +150,7 @@ BEGIN {in_header = 1; start = 2; count = 0}
}
}
END { print "\n};\n#define CREDITS_COUNT " count }
'] $credits > "$srcdir/include/util/credits.h"
'] $credits > include/credits.h
if test x$enable_debug = xyes; then
if test "x" = "x$PRESET_CFLAGS"; then
@@ -213,11 +170,11 @@ if test x$enable_debug = xyes; then
if test x$uninitialized = xyes; then
CFLAGS="$CFLAGS -Wuninitialized -O1"
else
CFLAGS="$CFLAGS -O0"
CFLAGS="$CFLAGS -O2"
fi
else
if test "x" = "x$PRESET_CFLAGS"; then
CFLAGS="-Wall -O2"
CFLAGS="-g -Wall -O2"
fi
fi
@@ -225,30 +182,16 @@ if test x$pic = xyes; then
CFLAGS="$CFLAGS -fPIC -DPIC"
fi
dnl AC_SUBST(LT_RELEASE)
dnl AC_SUBST(LT_CURRENT)
dnl AC_SUBST(LT_REVISION)
dnl AC_SUBST(LT_AGE)
AC_SUBST(UUID_LIBS)
AC_SUBST(PROGS_LDFLAGS)
AC_OUTPUT(
Makefile
include/Makefile
include/misc/Makefile
include/reiserfs/Makefile
include/util/Makefile
libmisc/Makefile
libreiserfs/Makefile
libutil/Makefile
utils/Makefile
utils/mkfs/Makefile
utils/resizer/Makefile
utils/fsck/Makefile
utils/debugfs/Makefile
utils/tune/Makefile
reiserfsprogs.spec)
mkreiserfs/Makefile
resize_reiserfs/Makefile
fsck/Makefile
lib/Makefile
Makefile
reiserfscore/Makefile
debugreiserfs/Makefile
tune/Makefile)
echo
echo Type \'make\' to compile reiserfsprogs and \'make install\' to install it.
echo Type \'make\' to compile reiserfsprogs
+7
View File
@@ -0,0 +1,7 @@
sbin_PROGRAMS = debugreiserfs
debugreiserfs_SOURCES = debugreiserfs.c pack.c unpack.c stat.c corruption.c scan.c recover.c debugreiserfs.h
man_MANS = debugreiserfs.8
EXTRA_DIST = $(man_MANS)
LDADD = $(top_srcdir)/reiserfscore/libcore.a $(top_srcdir)/lib/libmisc.a
@@ -1,8 +1,8 @@
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006 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.
@@ -14,17 +14,11 @@
@SET_MAKE@
SOURCES = $(mkfs_reiserfs_SOURCES)
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
@@ -38,34 +32,35 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
sbin_PROGRAMS = mkfs.reiserfs$(EXEEXT)
subdir = utils/mkfs
sbin_PROGRAMS = debugreiserfs$(EXEEXT)
subdir = debugreiserfs
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"
sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(sbin_PROGRAMS)
am_mkfs_reiserfs_OBJECTS = mkfs_reiserfs-mkreiserfs.$(OBJEXT)
mkfs_reiserfs_OBJECTS = $(am_mkfs_reiserfs_OBJECTS)
mkfs_reiserfs_DEPENDENCIES = \
$(top_builddir)/libreiserfs/libreiserfs-static.a \
$(top_builddir)/libutil/libutil-static.a \
$(top_builddir)/libmisc/libmisc-static.a
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
am_debugreiserfs_OBJECTS = debugreiserfs.$(OBJEXT) pack.$(OBJEXT) \
unpack.$(OBJEXT) stat.$(OBJEXT) corruption.$(OBJEXT) \
scan.$(OBJEXT) recover.$(OBJEXT)
debugreiserfs_OBJECTS = $(am_debugreiserfs_OBJECTS)
debugreiserfs_LDADD = $(LDADD)
debugreiserfs_DEPENDENCIES = $(top_srcdir)/reiserfscore/libcore.a \
$(top_srcdir)/lib/libmisc.a
DEFAULT_INCLUDES = -I. -I$(top_builddir)/include@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(mkfs_reiserfs_SOURCES)
DIST_SOURCES = $(mkfs_reiserfs_SOURCES)
SOURCES = $(debugreiserfs_SOURCES)
DIST_SOURCES = $(debugreiserfs_SOURCES)
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
@@ -73,8 +68,6 @@ ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -93,6 +86,8 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -103,9 +98,8 @@ LIBS = @LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -114,18 +108,17 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PROGS_LDFLAGS = @PROGS_LDFLAGS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
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__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -137,38 +130,43 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
man_MANS = mkfs.reiserfs.8
EXTRA_DIST = mkfs.reiserfs.8
mkfs_reiserfs_SOURCES = mkreiserfs.c
mkfs_reiserfs_LDADD = $(top_builddir)/libreiserfs/libreiserfs-static.a \
$(top_builddir)/libutil/libutil-static.a \
$(top_builddir)/libmisc/libmisc-static.a
mkfs_reiserfs_LDFLAGS = @PROGS_LDFLAGS@
mkfs_reiserfs_CFLAGS = @CFLAGS@
INCLUDES = -I$(top_srcdir)/include
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
debugreiserfs_SOURCES = debugreiserfs.c pack.c unpack.c stat.c corruption.c scan.c recover.c debugreiserfs.h
man_MANS = debugreiserfs.8
EXTRA_DIST = $(man_MANS)
LDADD = $(top_srcdir)/reiserfscore/libcore.a $(top_srcdir)/lib/libmisc.a
all: all-am
.SUFFIXES:
@@ -182,9 +180,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu utils/mkfs/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu debugreiserfs/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu utils/mkfs/Makefile
$(AUTOMAKE) --gnu debugreiserfs/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -204,7 +202,7 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(sbindir)" || $(mkdir_p) "$(DESTDIR)$(sbindir)"
test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
@list='$(sbin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
@@ -225,9 +223,9 @@ uninstall-sbinPROGRAMS:
clean-sbinPROGRAMS:
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
mkfs.reiserfs$(EXEEXT): $(mkfs_reiserfs_OBJECTS) $(mkfs_reiserfs_DEPENDENCIES)
@rm -f mkfs.reiserfs$(EXEEXT)
$(LINK) $(mkfs_reiserfs_LDFLAGS) $(mkfs_reiserfs_OBJECTS) $(mkfs_reiserfs_LDADD) $(LIBS)
debugreiserfs$(EXEEXT): $(debugreiserfs_OBJECTS) $(debugreiserfs_DEPENDENCIES)
@rm -f debugreiserfs$(EXEEXT)
$(LINK) $(debugreiserfs_OBJECTS) $(debugreiserfs_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -235,39 +233,30 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Po@am__quote@
@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@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
mkfs_reiserfs-mkreiserfs.o: mkreiserfs.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mkfs_reiserfs_CFLAGS) $(CFLAGS) -MT mkfs_reiserfs-mkreiserfs.o -MD -MP -MF "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Tpo" -c -o mkfs_reiserfs-mkreiserfs.o `test -f 'mkreiserfs.c' || echo '$(srcdir)/'`mkreiserfs.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Tpo" "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Po"; else rm -f "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mkreiserfs.c' object='mkfs_reiserfs-mkreiserfs.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mkfs_reiserfs_CFLAGS) $(CFLAGS) -c -o mkfs_reiserfs-mkreiserfs.o `test -f 'mkreiserfs.c' || echo '$(srcdir)/'`mkreiserfs.c
mkfs_reiserfs-mkreiserfs.obj: mkreiserfs.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mkfs_reiserfs_CFLAGS) $(CFLAGS) -MT mkfs_reiserfs-mkreiserfs.obj -MD -MP -MF "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Tpo" -c -o mkfs_reiserfs-mkreiserfs.obj `if test -f 'mkreiserfs.c'; then $(CYGPATH_W) 'mkreiserfs.c'; else $(CYGPATH_W) '$(srcdir)/mkreiserfs.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Tpo" "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Po"; else rm -f "$(DEPDIR)/mkfs_reiserfs-mkreiserfs.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mkreiserfs.c' object='mkfs_reiserfs-mkreiserfs.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mkfs_reiserfs_CFLAGS) $(CFLAGS) -c -o mkfs_reiserfs-mkreiserfs.obj `if test -f 'mkreiserfs.c'; then $(CYGPATH_W) 'mkreiserfs.c'; else $(CYGPATH_W) '$(srcdir)/mkreiserfs.c'; fi`
uninstall-info-am:
install-man8: $(man8_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man8dir)" || $(mkdir_p) "$(DESTDIR)$(man8dir)"
test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)"
@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
@@ -360,22 +349,21 @@ distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
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; \
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
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"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
@@ -391,7 +379,7 @@ check: check-am
all-am: Makefile $(PROGRAMS) $(MANS)
installdirs:
for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
@@ -437,14 +425,22 @@ info: info-am
info-am:
install-data-am: install-data-local install-man
install-data-am: install-man
install-dvi: install-dvi-am
install-exec-am: install-sbinPROGRAMS
install-html: install-html-am
install-info: install-info-am
install-man: install-man8
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
@@ -464,38 +460,26 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-local uninstall-man \
uninstall-sbinPROGRAMS
uninstall-am: uninstall-man uninstall-sbinPROGRAMS
uninstall-man: uninstall-man8
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-sbinPROGRAMS ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-data-local 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-local uninstall-man \
uninstall-man8 uninstall-sbinPROGRAMS
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-man8 install-pdf \
install-pdf-am install-ps install-ps-am 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-man uninstall-man8 \
uninstall-sbinPROGRAMS
uninstall-mkreiserfs:
if test -f $(DESTDIR)$(sbindir)/mkreiserfs; then \
rm -f $(DESTDIR)$(sbindir)/mkreiserfs; \
fi;
install-mkreiserfs:
if test -f $(DESTDIR)$(sbindir)/mkfs.reiserfs; then \
rm -f $(DESTDIR)$(sbindir)/mkreiserfs; \
ln $(DESTDIR)$(sbindir)/mkfs.reiserfs $(DESTDIR)$(sbindir)/mkreiserfs; \
fi;
install-data-local: install-mkreiserfs
uninstall-local: uninstall-mkreiserfs
# 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:
File diff suppressed because it is too large. Load diff
@@ -1,11 +1,11 @@
.\" -*- nroff -*-
.\" Copyright 1996-2004 Hans Reiser.
.\"
.TH debugfs.reiserfs 8 "February 2004" "Reiserfsprogs 3.6.19"
.TH DEBUGREISERFS 8 "January 2009" "Reiserfsprogs 3.6.21"
.SH NAME
debugfs.reiserfs \- The debugging tool for the ReiserFS filesystem.
debugreiserfs \- The debugging tool for the ReiserFS filesystem.
.SH SYNOPSIS
.B debugfs.reiserfs
.B debugreiserfs
[
.B -dDJmoqpuSV
] [
@@ -21,7 +21,7 @@ debugfs.reiserfs \- The debugging tool for the ReiserFS filesystem.
.\" ] [
.I device
.SH DESCRIPTION
\fBdebugfs.reiserfs\fR sometimes helps to solve problems with reiserfs filesystems.
\fBdebugreiserfs\fR sometimes helps to solve problems with reiserfs filesystems.
When run without options it prints the super block of the ReiserFS filesystem found
on the \fIdevice\fR.
.TP
@@ -61,37 +61,37 @@ prints the specified block of the filesystem.
.\" formatted nodes found. Can be used to find specific key in the filesystem.
.\" .TP
.B -p
extracts the filesystem's metadata with \fBdebugfs.reiserfs\fR -p /dev/xxx | gzip -c >
extracts the filesystem's metadata with \fBdebugreiserfs\fR -p /dev/xxx | gzip -c >
xxx.gz. None of your data are packed unless a filesystem corruption presents when
the whole block having this corruption is packed. You send us the output, and we use
it to create a filesystem with the same strucure as yours using \fBdebugfs.reiserfs -u\fR.
it to create a filesystem with the same strucure as yours using \fBdebugreiserfs -u\fR.
When the data file is not too large, this usually allows us to quickly reproduce
and debug the problem.
.TP
.B -u
builds the ReiserFS filesystem image with gunzip -c xxx.gz | \fBdebugfs.reiserfs\fR
-u /dev/image of the previously packed metadata with \fBdebugfs.reiserfs -p\fR. The
builds the ReiserFS filesystem image with gunzip -c xxx.gz | \fBdebugreiserfs\fR
-u /dev/image of the previously packed metadata with \fBdebugreiserfs -p\fR. The
result image is not the same as the original filesystem, because mostly only metadata
were packed with \fBdebugfs.reiserfs -p\fR, but the filesystem structure is completely
were packed with \fBdebugreiserfs -p\fR, but the filesystem structure is completely
recreated.
.TP
.B -S
When -S is not specified -p
.\" and -s
deals with blocks marked used in the filesystem bitmap only. With this option
set \fBdebugfs.reiserfs\fR will work with the entire device.
set \fBdebugreiserfs\fR will work with the entire device.
.TP
.B -q
When
.\" -s or
-p is in use, suppress showing the speed of progress.
.SH AUTHOR
This version of \fBdebugfs.reiserfs\fR has been written by Vitaly Fertman
This version of \fBdebugreiserfs\fR has been written by Vitaly Fertman
<vitaly@namesys.com>.
.SH BUGS
Please report bugs to the ReiserFS developers <reiserfs-dev@namesys.com>, providing
as much information as possible--your hardware, kernel, patches, settings, all printed
messages; check the syslog file for any related information.
.SH SEE ALSO
.BR fsck.reiserfs (8),
.BR mkfs.reiserfs (8)
.BR reiserfsck (8),
.BR mkreiserfs (8)
@@ -3,19 +3,7 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "debugreiserfs.h"
#include "misc/unaligned.h"
#include "misc/malloc.h"
#include "util/misc.h"
#include "util/print.h"
#include <getopt.h>
#include <errno.h>
#include <fcntl.h>
reiserfs_filsys_t * fs;
@@ -81,51 +69,52 @@ struct reiserfs_fsstat {
static void print_disk_tree (reiserfs_filsys_t * fs, unsigned long block_nr)
{
reiserfs_bh_t * bh;
struct buffer_head * bh;
int i, j, count;
static int level = -1;
if (level == -1)
level = reiserfs_sb_get_height (fs->fs_ondisk_sb);
level = get_sb_tree_height (fs->fs_ondisk_sb);
bh = reiserfs_buffer_read (fs->fs_dev, block_nr, fs->fs_blocksize);
bh = bread (fs->fs_dev, block_nr, fs->fs_blocksize);
if (!bh) {
misc_die ("Could not read block %lu\n", block_nr);
die ("Could not read block %lu\n", block_nr);
}
level --;
if (level < 1)
misc_die ("level too small");
die ("level too small");
if (level != reiserfs_nh_get_level (NODE_HEAD (bh))) {
if (level != get_blkh_level (B_BLK_HEAD (bh))) {
printf ("%d expected, %d found in %lu\n", level,
reiserfs_nh_get_level (NODE_HEAD (bh)), bh->b_blocknr);
get_blkh_level (B_BLK_HEAD (bh)), bh->b_blocknr);
}
if (reiserfs_int_head (bh)) {
reiserfs_dc_t * dc;
if (is_internal_node (bh)) {
struct disk_child * dc;
g_stat_info.nr_internals ++;
reiserfs_node_print (stdout, fs, bh, data(fs)->options, -1, -1);
print_block (stdout, fs, bh,
data(fs)->options & PRINT_TREE_DETAILS, -1, -1);
dc = reiserfs_int_at (bh, 0);
count = reiserfs_node_items(bh);
dc = B_N_CHILD (bh, 0);
count = B_NR_ITEMS(bh);
for (i = 0; i <= count; i++, dc++)
print_disk_tree (fs, reiserfs_dc_get_nr (dc));
} else if (reiserfs_leaf_head (bh)) {
reiserfs_ih_t *ih;
print_disk_tree (fs, get_dc_child_blocknr (dc));
} else if (is_leaf_node (bh)) {
struct item_head *ih;
g_stat_info.nr_leaves ++;
reiserfs_node_print (stdout, fs, bh, data(fs)->options, -1, -1);
print_block (stdout, fs, bh,
data (fs)->options & PRINT_TREE_DETAILS, -1, -1);
ih = reiserfs_ih_at (bh, 0);
count = reiserfs_leaf_estimate_items(bh);
ih = B_N_PITEM_HEAD (bh, 0);
count = leaf_item_number_estimate(bh);
for (i = 0; i < count; i++, ih++) {
if (reiserfs_ih_ext(ih)) {
__u32 * ind_item =
(__u32 *)reiserfs_item_by_ih (bh, ih);
if (is_indirect_ih(ih)) {
__u32 * ind_item = (__u32 *)B_I_PITEM (bh, ih);
for (j = 0; j < (int)reiserfs_ext_count (ih); j ++) {
for (j = 0; j < (int)I_UNFM_NUM (ih); j ++) {
if (d32_get (ind_item, j)) {
g_stat_info.nr_unformatted += 1;
}
@@ -133,12 +122,13 @@ static void print_disk_tree (reiserfs_filsys_t * fs, unsigned long block_nr)
}
}
} else {
reiserfs_node_print (stdout, fs, bh, data(fs)->options, -1, -1);
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);
}
reiserfs_buffer_close (bh);
brelse (bh);
level ++;
}
@@ -146,38 +136,37 @@ static void print_disk_blocks (reiserfs_filsys_t * fs)
{
int type;
unsigned long done = 0, total;
reiserfs_bh_t * bh;
struct buffer_head * bh;
unsigned int j;
total = reiserfs_bitmap_ones (input_bitmap(fs));
for (j = 0; j < reiserfs_sb_get_blocks (fs->fs_ondisk_sb); j ++) {
if (!reiserfs_bitmap_test_bit (input_bitmap (fs), j))
continue;
if (!misc_test_bit(PRINT_QUIET, &data(fs)->options))
util_misc_progress (stderr, &done, total, 1, 0);
for (j = 0; j < get_sb_block_count (fs->fs_ondisk_sb); j ++) {
if (!reiserfs_bitmap_test_bit (input_bitmap (fs), j))
continue;
bh = reiserfs_buffer_read (fs->fs_dev, j, fs->fs_blocksize);
if (!bh) {
reiserfs_warning (stderr, "could not read block %lu\n", j);
continue;
}
type = reiserfs_node_type (bh);
if (type != NT_UNKNOWN) {
reiserfs_node_print (stdout, fs, bh,
(1 << LP_LEAF_DETAILS) | (1 << LP_DIRECT_ITEMS), -1, -1);
}
print_how_far (stderr, &done, total, 1, be_quiet (fs));
if (type == NT_INTERNAL)
g_stat_info.nr_internals ++;
else if (type == NT_LEAF || type == NT_IH_ARRAY)
g_stat_info.nr_leaves ++;
reiserfs_buffer_close (bh);
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);
}
fprintf (stderr, "\n");
}
@@ -185,13 +174,13 @@ static void print_disk_blocks (reiserfs_filsys_t * fs)
void pack_one_block (reiserfs_filsys_t * fs, unsigned long block);
static void print_one_block (reiserfs_filsys_t * fs, unsigned long block)
{
reiserfs_bh_t * bh;
struct buffer_head * bh;
if (!fs->fs_bitmap2) {
reiserfs_bh_t * bm_bh;
struct buffer_head * bm_bh;
unsigned long bm_block;
if (reiserfs_bitmap_spread (fs))
if (spread_bitmaps (fs))
bm_block =
( block / (fs->fs_blocksize * 8) ) ?
(block / (fs->fs_blocksize * 8)) *
@@ -201,7 +190,7 @@ static void print_one_block (reiserfs_filsys_t * fs, unsigned long block)
bm_block = fs->fs_super_bh->b_blocknr + 1 +
(block / (fs->fs_blocksize * 8));
bm_bh = reiserfs_buffer_read (fs->fs_dev, bm_block, fs->fs_blocksize);
bm_bh = bread (fs->fs_dev, bm_block, fs->fs_blocksize);
if (bm_bh) {
if (misc_test_bit((block % (fs->fs_blocksize * 8)),
bm_bh->b_data))
@@ -213,7 +202,7 @@ static void print_one_block (reiserfs_filsys_t * fs, unsigned long block)
"ondisk bitmap\n", block);
}
reiserfs_buffer_close (bm_bh);
brelse (bm_bh);
}
} else {
if (reiserfs_bitmap_test_bit (fs->fs_bitmap2, block))
@@ -222,23 +211,23 @@ static void print_one_block (reiserfs_filsys_t * fs, unsigned long block)
fprintf (stderr, "%lu is free in ondisk bitmap\n", block);
}
bh = reiserfs_buffer_read (fs->fs_dev, block, fs->fs_blocksize);
bh = bread (fs->fs_dev, block, fs->fs_blocksize);
if (!bh) {
printf ("print_one_block: reiserfs_buffer_read failed\n");
printf ("print_one_block: bread failed\n");
return;
}
if (debug_mode (fs) == DO_PACK) {
pack_one_block (fs, bh->b_blocknr);
reiserfs_buffer_close (bh);
brelse (bh);
return;
}
if (reiserfs_node_type (bh) != NT_UNKNOWN)
reiserfs_node_print (stdout, fs, bh, (1 << LP_LEAF_DETAILS), -1, -1);
if (who_is_this (bh->b_data, bh->b_size) != THE_UNKNOWN)
print_block (stdout, fs, bh, PRINT_TREE_DETAILS, -1, -1);
else
printf ("Looks like unformatted\n");
reiserfs_buffer_close (bh);
brelse (bh);
return;
}
@@ -274,13 +263,13 @@ static char * parse_options (struct debugreiserfs_data * data,
{
switch (c) {
case 'a': /* -r will read this, -n and -N will write to it */
strncpy(data->map_file, optarg, sizeof(data->map_file));
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 -k */
data->input_bitmap = optarg;
asprintf (&data->input_bitmap, "%s", optarg);
data->scan_area = EXTERN_BITMAP;
break;
@@ -297,20 +286,22 @@ static char * parse_options (struct debugreiserfs_data * data,
case '1': /* print a single node */
data->block = strtol (optarg, &tmp, 0);
if (*tmp)
misc_die ("parse_options: bad block number");
die ("parse_options: bad block number");
break;
case 'C':
data->mode = DO_CORRUPT_ONE;
data->block = strtol (optarg, &tmp, 0);
if (*tmp) {
misc_die ("parse_options: bad block number");
die ("parse_options: bad block number");
}
break;
case 'F':
data->mode = DO_CORRUPT_FILE;
corruption_list_file = optarg;
if (asprintf (&corruption_list_file, "%s", optarg) == -1 ) {
die ("parse_options: bad list corruption file");
}
break;
case 'p':
@@ -334,6 +325,7 @@ static char * parse_options (struct debugreiserfs_data * data,
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 */
@@ -345,38 +337,38 @@ static char * parse_options (struct debugreiserfs_data * data,
break;
case 'r':
data->recovery_file = optarg;
asprintf (&data->recovery_file, "%s", optarg);
data->mode = DO_RECOVER;
break;
case 'd':
/* print leaf details from internal tree */
misc_set_bit(LP_LEAF_DETAILS, &data->options);
data->options |= PRINT_TREE_DETAILS;
break;
case 'D':
/* print leaf details accordingly the bitmap - can be used
with -S */
misc_set_bit(PRINT_DETAILS, &data->options);
data->options |= PRINT_DETAILS;
break;
case 'o':
/* print objectid map */
misc_set_bit(PRINT_OBJECTID_MAP, &data->options);
data->options |= PRINT_OBJECTID_MAP;
break;
case 'm': /* print a block map */
case 'M': /* print a block map with details */
misc_set_bit(PRINT_BITMAP, &data->options);
data->options |= PRINT_BITMAP;
break;
case 'j': /* -j must have a parameter */
misc_set_bit(PRINT_JOURNAL, &data->options);
data->options |= PRINT_JOURNAL;
data->journal_device_name = optarg;
break;
case 'J':
misc_set_bit(PRINT_JOURNAL_HEADER, &data->options);
data->options |= PRINT_JOURNAL_HEADER;
break;
case 'R': /* read block numbers from stdin and look for them in the
@@ -386,12 +378,12 @@ static char * parse_options (struct debugreiserfs_data * data,
break;
case 'B': /*disabled for a while*/
badblocks_file = optarg;
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 */
misc_set_bit(PRINT_QUIET, &data->options);
data->options |= BE_QUIET;
break;
case 'Z':
data->mode = DO_ZERO;
@@ -413,13 +405,13 @@ static char * parse_options (struct debugreiserfs_data * data,
data->mode = DO_NOTHING;
break;
case 'v':
misc_set_bit(PRINT_VERBOSE, &data->options);
data->options |= BE_VERBOSE;
break;
}
}
if (data->mode == DO_NOTHING) {
util_print_banner(program_name);
print_banner(program_name);
exit(0);
}
@@ -427,7 +419,7 @@ static char * parse_options (struct debugreiserfs_data * data,
/* only one non-option argument is permitted */
print_usage_and_exit();
util_print_banner(program_name);
print_banner(program_name);
data->device_name = argv[optind];
return argv[optind];
@@ -463,28 +455,29 @@ static void init_bitmap (reiserfs_filsys_t * fs)
FILE * fp;
unsigned long block_count;
if (reiserfs_bitmap_open (fs) < 0)
if (reiserfs_open_ondisk_bitmap (fs) < 0)
reiserfs_exit (1, "Could not open ondisk bitmap");
block_count = reiserfs_sb_get_blocks (fs->fs_ondisk_sb);
block_count = get_sb_block_count (fs->fs_ondisk_sb);
switch (scan_area (fs)) {
case ALL_BLOCKS:
input_bitmap (fs) = reiserfs_bitmap_create (block_count);
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_bitmap_create (block_count);
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_bitmap_create (block_count);
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",
@@ -518,11 +511,11 @@ static void do_dump_tree (reiserfs_filsys_t * fs)
return;
}
if ((misc_test_bit(PRINT_JOURNAL, &data(fs)->options) ||
misc_test_bit(PRINT_JOURNAL_HEADER, &data(fs)->options)) &&
if (((data (fs)->options & PRINT_JOURNAL) ||
(data (fs)->options & PRINT_JOURNAL_HEADER)) &&
!reiserfs_journal_opened (fs))
{
if (reiserfs_journal_open (fs, data(fs)->journal_device_name,
if (reiserfs_open_journal (fs, data(fs)->journal_device_name,
O_RDONLY))
{
printf ("Could not open journal\n");
@@ -530,34 +523,33 @@ static void do_dump_tree (reiserfs_filsys_t * fs)
}
}
reiserfs_super_print_state (stdout, fs);
reiserfs_node_print (stdout, fs, fs->fs_super_bh);
print_filesystem_state (stdout, fs);
print_block (stdout, fs, fs->fs_super_bh);
if (misc_test_bit(PRINT_JOURNAL, &data(fs)->options))
reiserfs_journal_print (fs);
if (data (fs)->options & PRINT_JOURNAL)
print_journal (fs);
if (misc_test_bit(PRINT_JOURNAL_HEADER, &data(fs)->options))
reiserfs_journal_print_header (fs);
if (data (fs)->options & PRINT_JOURNAL_HEADER)
print_journal_header (fs);
if (misc_test_bit(PRINT_OBJECTID_MAP, &data(fs)->options))
reiserfs_objmap_print (stdout, fs);
if (data (fs)->options & PRINT_OBJECTID_MAP)
print_objectid_map (stdout, fs);
if (misc_test_bit(PRINT_BITMAP, &data(fs)->options))
reiserfs_bitmap_print (stdout, fs, 0);
if (data (fs)->options & PRINT_BITMAP)
print_bmap (stdout, fs, 0/*opt_print_block_map == 1 ? 1 : 0*/);
if (misc_test_bit(PRINT_DETAILS, &data(fs)->options))
if (data (fs)->options & PRINT_DETAILS)
init_bitmap (fs);
if (misc_test_bit(PRINT_DETAILS, &data(fs)->options) ||
misc_test_bit(LP_LEAF_DETAILS, &data(fs)->options))
if (data (fs)->options & PRINT_DETAILS ||
data (fs)->options & PRINT_TREE_DETAILS)
{
if (misc_test_bit(PRINT_DETAILS, &data(fs)->options)) {
if (data (fs)->options & PRINT_DETAILS) {
print_disk_blocks (fs);
printf("The '%s' device with reiserfs has:\n",
fs->fs_file_name);
} else {
/* DEBUGGING */
print_disk_tree (fs, reiserfs_sb_get_root(fs->fs_ondisk_sb));
print_disk_tree (fs, get_sb_root_block(fs->fs_ondisk_sb));
printf("The internal reiserfs tree has:\n");
}
@@ -571,24 +563,24 @@ static void do_dump_tree (reiserfs_filsys_t * fs)
}
static void callback_badblock_print(reiserfs_filsys_t *fs,
reiserfs_path_t *badblock_path,
struct path *badblock_path,
void *data)
{
reiserfs_ih_t *tmp_ih;
struct item_head *tmp_ih;
FILE *fd = (FILE *)data;
__u32 *ind_item;
__u32 i;
tmp_ih = REISERFS_PATH_IH(badblock_path);
ind_item = (__u32 *)REISERFS_PATH_ITEM(badblock_path);
tmp_ih = get_ih(badblock_path);
ind_item = (__u32 *)get_item(badblock_path);
for (i = 0; i < reiserfs_ext_count(tmp_ih); i++)
for (i = 0; i < I_UNFM_NUM(tmp_ih); i++)
fprintf (fd, "%u\n", d32_get (ind_item, i));
reiserfs_tree_pathrelse (badblock_path);
pathrelse (badblock_path);
}
void debug_badblock_print () {
void extract_badblock_list () {
FILE *fd;
if (!(fd = fopen (badblocks_file, "w"))) {
@@ -596,7 +588,7 @@ void debug_badblock_print () {
badblocks_file);
}
reiserfs_badblock_traverse(fs, callback_badblock_print, fd);
badblock_list(fs, callback_badblock_print, fd);
fclose (fd);
}
@@ -615,7 +607,7 @@ static int str2int (char * str, int * res)
void do_corrupt_blocks (reiserfs_filsys_t * fs)
{
char line[256];
char * line;
FILE * fd;
size_t n = 0;
int numblock;
@@ -627,11 +619,9 @@ void do_corrupt_blocks (reiserfs_filsys_t * fs)
}
while (1) {
line[0] = '\0';
line = NULL;
n = 0;
if (fgets(line, sizeof(line), fd) == NULL ||
strlen(line) <= 1)
{
if (getline (&line, &n, fd) == -1) {
break;
}
@@ -644,42 +634,40 @@ void do_corrupt_blocks (reiserfs_filsys_t * fs)
do_corrupt_one_block(fs, line);
}
printf ("before free line : %s\n", line);
free (line);
printf ("after free\n");
reiserfs_fs_reopen (fs, O_RDWR);
reiserfs_reopen (fs, O_RDWR);
}
fclose (fd);
return;
}
void debugreiserfs_zero_reiserfs(reiserfs_filsys_t * fs) {
unsigned long done, total, i;
reiserfs_bh_t * bh;
struct buffer_head * bh;
reiserfs_fs_reopen (fs, O_RDWR);
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 = reiserfs_buffer_open(fs->fs_dev, i, fs->fs_blocksize);
if (!bh)
misc_die("Could not get block %lu\n", i);
memset(bh->b_data, 0, fs->fs_blocksize);
reiserfs_buffer_mkdirty(bh);
reiserfs_buffer_mkuptodate(bh, 0);
reiserfs_buffer_write(bh);
reiserfs_buffer_close (bh);
if (!misc_test_bit(PRINT_QUIET, &data(fs)->options))
util_misc_progress (stderr, &done, total, 1, 0);
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");
@@ -694,25 +682,25 @@ int main (int argc, char * argv[])
int error;
struct debugreiserfs_data * data;
data = misc_getmem (sizeof (struct debugreiserfs_data));
data = getmem (sizeof (struct debugreiserfs_data));
file_name = parse_options (data, argc, argv);
if (data->mode == DO_UNPACK) {
do_unpack(file_name, data->journal_device_name, data->input_bitmap,
misc_test_bit(PRINT_VERBOSE, &data->options));
do_unpack(file_name, data->journal_device_name,
data->input_bitmap, data->options & BE_VERBOSE);
return 0;
}
fs = reiserfs_fs_open (file_name, O_RDONLY, &error, data, 0);
fs = reiserfs_open (file_name, O_RDONLY, &error, data, 0);
if (fs == NULL) {
if (no_reiserfs_found (fs)) {
reiserfs_exit (1, "\n\ndebugreiserfs: can not open reiserfs on "
"\"%s\": %s\n\n", file_name, error ? strerror(error)
: "no filesystem found");
exit(1) ;
}
if (reiserfs_journal_open (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");
}
@@ -728,16 +716,16 @@ int main (int argc, char * argv[])
break;
case DO_CORRUPT_ONE:
reiserfs_fs_reopen (fs, O_RDWR);
reiserfs_reopen (fs, O_RDWR);
do_corrupt_one_block (fs, (char *)NULL);
break;
case DO_CORRUPT_FILE:
reiserfs_fs_reopen (fs, O_RDWR);
reiserfs_reopen (fs, O_RDWR);
do_corrupt_blocks (fs);
break;
case DO_RANDOM_CORRUPTION:
reiserfs_fs_reopen (fs, O_RDWR);
reiserfs_reopen (fs, O_RDWR);
/*
do_leaves_corruption (fs);
do_bitmap_corruption (fs);
@@ -773,7 +761,7 @@ int main (int argc, char * argv[])
reiserfs_warning (stderr, "Will try to extract list of bad blocks "
"and save it to '%s' file\n", badblocks_file);
debug_badblock_print ();
extract_badblock_list ();
reiserfs_warning (stderr, "Done\n\n");
break;
case DO_ZERO:
@@ -782,9 +770,10 @@ int main (int argc, char * argv[])
break;
}
if (data(fs)->log)
reiserfs_close (fs);
if (data(fs)->log) {
fclose (data(fs)->log);
reiserfs_fs_close (fs);
}
return 0;
}
@@ -2,12 +2,12 @@
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "reiserfs/libreiserfs.h"
#if 0
#define _GNU_SOURCE
#ifndef HAVE_CONFIG_H
# include "config.h"
#endif
#include "io.h"
#include "misc.h"
#include "reiserfs_lib.h"
@@ -16,12 +16,9 @@
#include <string.h>
#include <errno.h>
#endif
extern reiserfs_filsys_t * fs;
/* print all items from bitmap */
#define PRINT_DETAILS LP_LAST
/*
* modes
@@ -47,18 +44,18 @@ extern reiserfs_filsys_t * fs;
/*first bits are in reiserfs_fs.b*/
enum debug_print {
PRINT_JOURNAL = LP_LAST,
PRINT_JOURNAL_HEADER = LP_LAST + 1,
PRINT_BITMAP = LP_LAST + 2,
PRINT_OBJECTID_MAP = LP_LAST + 3,
PRINT_QUIET = LP_LAST + 4,
PRINT_VERBOSE = LP_LAST + 5,
PRINT_DEBUG_LAST
};
#define PRINT_JOURNAL 0x10
#define PRINT_JOURNAL_HEADER 0x20
#define PRINT_BITMAP 0x40
#define PRINT_OBJECTID_MAP 0x80
#define BE_QUIET 0x100
#define BE_VERBOSE 0x200
#define debug_option(options, bit) (options & (1 << (bit)))
#define debug_setoption(options, bit) (options |= (1 << (bit)))
/* these moved to reiserfs_fs.h */
//#define PRINT_TREE_DETAILS
//#define PRINT_DETAILS
//#define PRINT_ITEM_DETAILS
//#define PRINT_DIRECT_ITEMS
// the leaf is stored in compact form:
@@ -104,8 +101,8 @@ enum debug_print {
#define WITH_SD_FIRST_DIRECT_BYTE 0x80 /* 8. for old stat data first_direct_byte is stored */
#define NLINK_BITS_32 0x0100 /* 9. nlinks stored in 32 bits */
#define SIZE_BITS_64 0x0200 /* 10. size has to be stored in 64 bit */
#define WHOLE_EXTENT 0x0400 /* 11. extent item is stored with compression */
#define SAFE_LINK 0x0800 /* 11. extent item is stored with compression */
#define WHOLE_INDIRECT 0x0400 /* 11. indirect item is stored with compression */
#define SAFE_LINK 0x0800 /* 11. indirect item is stored with compression */
#define TYPE_MASK 0x3 /* two lowest bits are used to store item type */
@@ -227,7 +224,7 @@ struct debugreiserfs_data {
char * pattern; /* for -n */
char * device_name;
char * journal_device_name; /* for -j */
char map_file[4096]; /* for -n, -N and -f */
char * map_file; /* for -n, -N and -f */
char * recovery_file; /* for -r */
unsigned long options; /* -q only yet*/
@@ -251,6 +248,8 @@ struct debugreiserfs_data {
#define map_file(fs) (data(fs)->map_file)
#define recovery_file(fs) (data(fs)->recovery_file)
#define be_quiet(fs) (data(fs)->options & BE_QUIET)
/* stat.c */
void do_stat (reiserfs_filsys_t * fs);
@@ -275,7 +274,7 @@ extern int do_unpack(char *host, char *j_filename, char *filename, int verbose);
void print_map(reiserfs_filsys_t * fs);
struct saved_item {
reiserfs_ih_t si_ih;
struct item_head si_ih;
unsigned long si_block;
int si_item_num, si_entry_pos;
struct saved_item *si_next; /* list of items having the same key */
+125 -149
View File
@@ -3,14 +3,9 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "debugreiserfs.h"
#include "misc/unaligned.h"
#include "util/print.h"
#include "util/misc.h"
/* counters for each kind of blocks */
int packed,
@@ -31,41 +26,41 @@ unsigned long had_to_be_sent; /* how many bytes were to be sent */
inline void set_pi_type( struct packed_item *pi, __u32 val )
{
misc_set_bitfield_XX (32, pi, val, 0, 2);
set_bit_field_XX (32, pi, val, 0, 2);
}
inline __u32 get_pi_type( const struct packed_item *pi )
{
return misc_get_bitfield_XX (32, pi, 0, 2);
get_bit_field_XX (32, pi, 0, 2);
}
inline void set_pi_mask( struct packed_item *pi, __u32 val )
{
misc_set_bitfield_XX (32, pi, val, 2, 18);
set_bit_field_XX (32, pi, val, 2, 18);
}
__u32 get_pi_mask( const struct packed_item *pi )
{
return misc_get_bitfield_XX (32, pi, 2, 18);
get_bit_field_XX (32, pi, 2, 18);
}
inline void set_pi_item_len( struct packed_item *pi, __u32 val )
{
misc_set_bitfield_XX (32, pi, val, 20, 12);
set_bit_field_XX (32, pi, val, 20, 12);
}
inline __u32 get_pi_item_len( const struct packed_item *pi )
{
return misc_get_bitfield_XX (32, pi, 20, 12);
get_bit_field_XX (32, pi, 20, 12);
}
static void pack_ih (struct packed_item * pi, reiserfs_ih_t * ih)
static void pack_ih (struct packed_item * pi, struct item_head * ih)
{
__u32 v32;
__u16 v16;
@@ -76,31 +71,31 @@ static void pack_ih (struct packed_item * pi, reiserfs_ih_t * ih)
/* sen key components which are to be sent */
if (get_pi_mask(pi) & DIR_ID) {
v32 = reiserfs_key_get_did (&ih->ih_key);
v32 = get_key_dirid (&ih->ih_key);
fwrite_le32 (&v32);
}
if (get_pi_mask(pi) & OBJECT_ID) {
v32 = reiserfs_key_get_oid (&ih->ih_key);
v32 = get_key_objectid (&ih->ih_key);
fwrite_le32 (&v32);
}
if (get_pi_mask(pi) & OFFSET_BITS_64) {
__u64 offset;
offset = reiserfs_key_get_off (&ih->ih_key);
offset = get_offset (&ih->ih_key);
fwrite_le64 (&offset);
}
if (get_pi_mask(pi) & OFFSET_BITS_32) {
__u32 offset;
offset = reiserfs_key_get_off (&ih->ih_key);
offset = get_offset (&ih->ih_key);
fwrite_le32 (&offset);
}
if (get_pi_mask(pi) & IH_FREE_SPACE) {
v16 = reiserfs_ih_get_entries (ih);
v16 = get_ih_entry_count (ih);
fwrite_le16 (&v16);
}
@@ -111,16 +106,15 @@ static void pack_ih (struct packed_item * pi, reiserfs_ih_t * ih)
}
static void pack_direct (struct packed_item * pi, reiserfs_bh_t * bh,
reiserfs_ih_t * ih)
static void pack_direct (struct packed_item * pi, struct buffer_head * bh,
struct item_head * ih)
{
if (reiserfs_ih_get_free (ih) != 0xffff)
if (get_ih_free_space (ih) != 0xffff)
/* ih_free_space has unexpected value */
set_pi_mask (pi, get_pi_mask (pi) | IH_FREE_SPACE);
if (get_pi_mask(pi) & SAFE_LINK)
reiserfs_key_set_did(&ih->ih_key,
d32_get((__u32 *)reiserfs_item_by_ih (bh, ih), 0) );
set_key_dirid(&ih->ih_key, d32_get((__u32 *)B_I_PITEM (bh, ih), 0) );
/* send key components which are to be sent */
pack_ih (pi, ih);
@@ -128,7 +122,7 @@ static void pack_direct (struct packed_item * pi, reiserfs_bh_t * bh,
/* if there is at least one extent longer than 2 - it is worth packing */
static int should_pack_extent (__u32 * ind_item, int unfm_num)
static int should_pack_indirect (__u32 * ind_item, int unfm_num)
{
int i, len;
@@ -148,42 +142,42 @@ static int should_pack_extent (__u32 * ind_item, int unfm_num)
}
/* extent item can be either packed using "extents" (when it is
/* indirect item can be either packed using "extents" (when it is
worth doing) or be stored as is. Size of item in packed form is not
stored. Unpacking will stop when full item length is reached */
static void pack_extent (struct packed_item * pi, reiserfs_bh_t * bh,
reiserfs_ih_t * ih)
static void pack_indirect (struct packed_item * pi, struct buffer_head * bh,
struct item_head * ih)
{
unsigned int i;
__u32 * ind_item;
__u16 len;
if (reiserfs_ih_get_entries (ih))
if (get_ih_entry_count (ih))
set_pi_mask (pi, get_pi_mask (pi) | IH_FREE_SPACE);
ind_item = (__u32 *)reiserfs_item_by_ih (bh, ih);
if (!should_pack_extent (ind_item, reiserfs_ext_count (ih)))
set_pi_mask (pi, get_pi_mask (pi) | WHOLE_EXTENT);
ind_item = (__u32 *)B_I_PITEM (bh, ih);
if (!should_pack_indirect (ind_item, I_UNFM_NUM (ih)))
set_pi_mask (pi, get_pi_mask (pi) | WHOLE_INDIRECT);
if (get_pi_mask(pi) & SAFE_LINK)
reiserfs_key_set_did(&ih->ih_key, d32_get(ind_item, 0));
set_key_dirid(&ih->ih_key, d32_get(ind_item, 0));
pack_ih (pi, ih);
if (get_pi_mask(pi) & SAFE_LINK)
return;
if (get_pi_mask(pi) & WHOLE_EXTENT) {
fwrite (ind_item, reiserfs_ih_get_len (ih), 1, stdout);
sent_bytes += reiserfs_ih_get_len (ih);
if (get_pi_mask(pi) & WHOLE_INDIRECT) {
fwrite (ind_item, get_ih_item_len (ih), 1, stdout);
sent_bytes += get_ih_item_len (ih);
return;
}
fwrite32 (&ind_item [0]);
for (i = 1, len = 1; i < reiserfs_ext_count (ih); i ++) {
for (i = 1, len = 1; i < I_UNFM_NUM (ih); i ++) {
if ((d32_get(ind_item, i) == 0 && d32_get(ind_item, i - 1) == 0) ||
d32_get(ind_item, i) == d32_get(ind_item, i - 1) + 1)
{
@@ -212,11 +206,11 @@ static void pack_extent (struct packed_item * pi, reiserfs_bh_t * bh,
maybe deh_state (16)
*/
static void pack_direntry (reiserfs_filsys_t * fs, struct packed_item * pi,
reiserfs_bh_t * bh,
reiserfs_ih_t * ih)
struct buffer_head * bh,
struct item_head * ih)
{
int i;
reiserfs_deh_t * deh;
struct reiserfs_de_head * deh;
struct packed_dir_entry pe;
__u16 entry_count, gen_counter;
@@ -227,28 +221,28 @@ static void pack_direntry (reiserfs_filsys_t * fs, struct packed_item * pi,
pack_ih (pi, ih);
/* entry count is sent unconditionally */
entry_count = reiserfs_ih_get_entries (ih);
entry_count = get_ih_entry_count (ih);
deh = reiserfs_deh (bh, ih);
deh = B_I_DEH (bh, ih);
for (i = 0; i < entry_count; i ++, deh ++) {
pe.entrylen = reiserfs_direntry_entry_len (ih, deh, i);
pe.entrylen = entry_length (ih, deh, i);
pe.mask = 0;
if (reiserfs_deh_get_did (deh) != reiserfs_key_get_oid (&ih->ih_key))
if (get_deh_dirid (deh) != get_key_objectid (&ih->ih_key))
/* entry points to name of another directory, store deh_dir_id */
pe.mask |= HAS_DIR_ID;
gen_counter = OFFSET_GEN (reiserfs_deh_get_off (deh));
gen_counter = GET_GENERATION_NUMBER (get_deh_offset (deh));
if (gen_counter != 0)
/* store generation counter if it is != 0 */
pe.mask |= HAS_GEN_COUNTER;
if (reiserfs_deh_get_state (deh) != 4)
if (get_deh_state (deh) != 4)
/* something unusual in deh_state. Store it */
pe.mask |= HAS_STATE;
fwrite8 (&pe.mask);
fwrite_le16 (&pe.entrylen);
fwrite (reiserfs_deh_name (deh, i), pe.entrylen, 1, stdout);
fwrite (name_in_entry (deh, i), pe.entrylen, 1, stdout);
sent_bytes += pe.entrylen;
fwrite32 (&(deh->deh2_objectid));
@@ -264,14 +258,14 @@ static void pack_direntry (reiserfs_filsys_t * fs, struct packed_item * pi,
}
static void pack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
reiserfs_ih_t * ih)
static void pack_stat_data (struct packed_item * pi, struct buffer_head * bh,
struct item_head * ih)
{
if (reiserfs_ih_get_free (ih) != 0xffff)
if (get_ih_free_space (ih) != 0xffff)
/* ih_free_space has unexpected value */
set_pi_mask (pi, get_pi_mask (pi) | IH_FREE_SPACE);
if (reiserfs_ih_format_v1 (ih)) {
if (stat_data_v1 (ih)) {
/* for old stat data: we take
mode - 16 bits
nlink - 16 bits
@@ -279,10 +273,10 @@ static void pack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
blocks/rdev - 32 bits
maybe first_direct byte 32 bits
*/
reiserfs_sd_v1_t * sd_v1;
struct stat_data_v1 * sd_v1;
sd_v1 = (reiserfs_sd_v1_t *)reiserfs_item_by_ih (bh, ih);
if (sd_v1->sd_fdb != 0xffffffff) /* ok if -1 */
sd_v1 = (struct stat_data_v1 *)B_I_PITEM (bh, ih);
if (sd_v1->sd_first_direct_byte != 0xffffffff) /* ok if -1 */
set_pi_mask (pi, get_pi_mask (pi) | WITH_SD_FIRST_DIRECT_BYTE);
@@ -294,7 +288,7 @@ static void pack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
fwrite32 (&sd_v1->u.sd_blocks);
if (get_pi_mask(pi) & WITH_SD_FIRST_DIRECT_BYTE)
fwrite32 (&sd_v1->sd_fdb);
fwrite32 (&sd_v1->sd_first_direct_byte);
} else {
/* for new stat data
mode - 16 bits
@@ -302,26 +296,26 @@ static void pack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
size in either 32 or 64 bits
blocks - 32 bits
*/
reiserfs_sd_t * sd;
struct stat_data * sd;
/* these will maintain disk-order values */
__u16 nlink16;
__u32 nlink32, size32;
__u64 size64;
sd = (reiserfs_sd_t *)reiserfs_item_by_ih (bh, ih);
if (reiserfs_sd_v2_nlink (sd) > 0xffff) {
sd = (struct stat_data *)B_I_PITEM (bh, ih);
if (sd_v2_nlink (sd) > 0xffff) {
set_pi_mask (pi, get_pi_mask (pi) | NLINK_BITS_32);
nlink32 = sd->sd_nlink;
} else {
/* This is required to deal with big endian systems */
nlink16 = cpu_to_le16 ((__u16)reiserfs_sd_v2_nlink (sd));
nlink16 = cpu_to_le16 ((__u16)sd_v2_nlink (sd));
}
if (reiserfs_sd_v2_size (sd) > 0xffffffff) {
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 with big endian systems */
size32 = cpu_to_le32 ((__u32)reiserfs_sd_v2_size (sd));
size32 = cpu_to_le32 ((__u32)sd_v2_size (sd));
}
@@ -346,7 +340,7 @@ static void pack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
}
static void pack_full_block (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
static void pack_full_block (reiserfs_filsys_t * fs, struct buffer_head * bh)
{
__u16 magic;
__u32 block;
@@ -376,7 +370,7 @@ static int check_unfm_ptr (reiserfs_filsys_t * fs, __u32 block)
if (block >= SB_BLOCK_COUNT (fs))
return 1;
if (reiserfs_fs_block(fs, block) != BT_UNKNOWN)
if (not_data_block (fs, block))
return 1;
return 0;
@@ -384,31 +378,27 @@ static int check_unfm_ptr (reiserfs_filsys_t * fs, __u32 block)
#endif
/* we only pack leaves which do not have any corruptions */
static int can_pack_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
static int can_pack_leaf (reiserfs_filsys_t * fs, struct buffer_head * bh)
{
int i;
reiserfs_ih_t * ih;
struct item_head * ih;
ih = reiserfs_ih_at (bh, 0);
for (i = 0; i < reiserfs_nh_get_items (NODE_HEAD (bh)); i ++, ih ++) {
if (reiserfs_leaf_correct_at (fs, ih, reiserfs_item_by_ih (bh, ih),
0/*check_unfm_ptr*/, 1/*bad dir*/))
{
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
if (is_it_bad_item (fs, ih, B_I_PITEM (bh, ih), 0/*check_unfm_ptr*/, 1/*bad dir*/))
return 0;
}
}
return 1;
}
/* pack leaf only if all its items are correct: keys are correct,
direntries are hashed properly and hash function is defined,
extent items are correct, stat data ?, */
static void pack_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
indirect items are correct, stat data ?, */
static void pack_leaf (reiserfs_filsys_t * fs, struct buffer_head * bh)
{
int i;
reiserfs_ih_t * ih;
struct item_head * ih;
struct packed_item pi;
__u16 v16;
@@ -420,17 +410,17 @@ static void pack_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
}
/* start magic in low 8 bits, hash code in high 8 bits */
v16 = (LEAF_START_MAGIC | (reiserfs_hash_code(fs->hash) << 8));
v16 = (LEAF_START_MAGIC | (func2code (fs->fs_hash_function) << 8));
fwrite_le16 (&v16);
/* block number */
fwrite_le32 (&bh->b_blocknr);
/* item number */
v16 = reiserfs_nh_get_items (NODE_HEAD (bh));
v16 = get_blkh_nr_items (B_BLK_HEAD (bh));
fwrite_le16 (&v16);
ih = reiserfs_ih_at (bh, 0);
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < v16; i ++, ih ++) {
#if 0
@@ -439,46 +429,41 @@ static void pack_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
#endif
set_pi_mask (&pi, 0);
set_pi_item_len (&pi, reiserfs_ih_get_len (ih));
set_pi_type (&pi, reiserfs_key_get_type (&ih->ih_key));
set_pi_item_len (&pi, get_ih_item_len (ih));
set_pi_type (&pi, get_type (&ih->ih_key));
// format
if (reiserfs_ih_get_format (ih) == KEY_FORMAT_2)
if (get_ih_key_format (ih) == KEY_FORMAT_2)
set_pi_mask( &pi, get_pi_mask(&pi) | NEW_FORMAT );
// k_dir_id
if (!i || (i && reiserfs_key_get_did (&ih->ih_key) != reiserfs_key_get_did (&(ih - 1)->ih_key))) {
if (!i || (i && get_key_dirid (&ih->ih_key) != get_key_dirid (&(ih - 1)->ih_key))) {
/* if item is first in the leaf or if previous item has different
k_dir_id - store it */
set_pi_mask (&pi, get_pi_mask (&pi) | DIR_ID);
}
// k_object_id
if (!i || (i && reiserfs_key_get_oid (&ih->ih_key) != reiserfs_key_get_oid (&(ih - 1)->ih_key))) {
if (!i || (i && get_key_objectid (&ih->ih_key) != get_key_objectid (&(ih - 1)->ih_key))) {
/* if item is first in the leaf or if previous item has different
k_objectid - store it */
set_pi_mask (&pi, get_pi_mask (&pi) | OBJECT_ID);
}
/* store offset if it is != 0 in 32 or 64 bits */
if (reiserfs_key_get_off (&ih->ih_key)) {
if (get_offset (&ih->ih_key)) {
int send_offset = 1;
if ((get_pi_mask (&pi) & DIR_ID) == 0 && (get_pi_mask (&pi) & OBJECT_ID) == 0) {
/* previous item is of the same object, so try to avoid
sending k_offset */
if ((reiserfs_ih_stat (ih - 1) &&
reiserfs_key_get_off (&ih->ih_key) == 1) ||
(reiserfs_ih_ext (ih - 1) && reiserfs_ih_direct (ih) &&
reiserfs_key_get_off (&(ih - 1)->ih_key) +
reiserfs_leaf_ibytes (ih - 1, fs->fs_blocksize) ==
reiserfs_key_get_off (&ih->ih_key)))
{
if ((is_stat_data_ih (ih - 1) && get_offset (&ih->ih_key) == 1) ||
(is_indirect_ih (ih - 1) && is_direct_ih (ih) &&
get_offset (&(ih - 1)->ih_key) + get_bytes_number (ih - 1, fs->fs_blocksize) == get_offset (&ih->ih_key)))
/* unpack can calculate offset itself */
send_offset = 0;
}
}
if (send_offset) {
if (reiserfs_key_get_off (&ih->ih_key) > 0xffffffffULL)
if (get_offset (&ih->ih_key) > 0xffffffffULL)
set_pi_mask (&pi, get_pi_mask (&pi) | OFFSET_BITS_64);
else
set_pi_mask (&pi, get_pi_mask (&pi) | OFFSET_BITS_32);
@@ -486,22 +471,22 @@ static void pack_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
}
/* ih key format is correct, check fsck_need field */
if (reiserfs_ih_get_flags (ih))
if (get_ih_flags (ih))
set_pi_mask (&pi, get_pi_mask (&pi) | IH_FORMAT);
if ((reiserfs_key_get_did (&ih->ih_key) == (__u32)-1) && (reiserfs_ih_get_len (ih) == 4))
if ((get_key_dirid (&ih->ih_key) == (__u32)-1) && (get_ih_item_len (ih) == 4))
set_pi_mask (&pi, get_pi_mask (&pi) | SAFE_LINK);
if (reiserfs_ih_direct (ih)) {
if (is_direct_ih (ih)) {
pack_direct (&pi, bh, ih);
} else if (reiserfs_ih_ext (ih))
pack_extent (&pi, bh, ih);
else if (reiserfs_ih_dir (ih))
} else if (is_indirect_ih (ih))
pack_indirect (&pi, bh, ih);
else if (is_direntry_ih (ih))
pack_direntry (fs, &pi, bh, ih);
else if (reiserfs_ih_stat (ih))
else if (is_stat_data_ih (ih))
pack_stat_data (&pi, bh, ih);
else
misc_die ("pack_leaf: unknown item found");
die ("pack_leaf: unknown item found");
#if 0
v32 = ITEM_END_MAGIC;
fwrite32 (&v32);
@@ -519,14 +504,14 @@ static void pack_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
}
static int can_pack_internal (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
static int can_pack_internal (reiserfs_filsys_t * fs, struct buffer_head * bh)
{
return 0;
}
/* pack internal node as a full block */
static void pack_internal (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
static void pack_internal (reiserfs_filsys_t * fs, struct buffer_head * bh)
{
internals ++;
if (!can_pack_internal (fs, bh)) {
@@ -539,24 +524,24 @@ static void pack_internal (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
/* packed blocks are marked free in the bitmap*/
static void send_block (reiserfs_filsys_t * fs, reiserfs_bh_t * bh, int send_unknown)
static void send_block (reiserfs_filsys_t * fs, struct buffer_head * bh, int send_unknown)
{
int type;
packed ++;
type = reiserfs_node_type (bh);
type = who_is_this (bh->b_data, bh->b_size);
switch (type) {
case NT_LEAF:
case THE_LEAF:
pack_leaf (fs, bh);
break;
case NT_IH_ARRAY:
case HAS_IH_ARRAY:
having_ih_array ++;
// fprintf (stderr, "BROKEN BLOCK HEAD %lu\n", bh->b_blocknr);
pack_full_block (fs, bh);
break;
case NT_INTERNAL:
case THE_INTERNAL:
pack_internal (fs, bh);
break;
@@ -577,58 +562,51 @@ static void send_block (reiserfs_filsys_t * fs, reiserfs_bh_t * bh, int send_unk
/* super block, journal, bitmaps */
static void pack_frozen_data (reiserfs_filsys_t * fs)
{
reiserfs_bh_t * bh;
struct buffer_head * bh;
unsigned long block;
__u16 magic16;
int sent_journal_start_magic = 0;
unsigned int i, bmap_nr;
unsigned int i;
if (reiserfs_super_jr_magic(fs->fs_ondisk_sb) &&
reiserfs_jp_get_dev(reiserfs_sb_jp(fs->fs_ondisk_sb)) &&
if (is_reiserfs_jr_magic_string(fs->fs_ondisk_sb) &&
get_jp_journal_dev(sb_jp(fs->fs_ondisk_sb)) &&
!journal_device_name(fs)) {
if (!util_user_confirmed (stderr,"\n File system has non-standard "
"journal that hasn't been specified.\n"
"Continue packing without journal? [N/Yes] "
"(note need to type Yes):", "Yes\n"))
{
if (!user_confirmed (stderr,
"\n File system has non-standard journal "
"that hasn't been specified.\n"
"Continue packing without journal? [N/Yes] (note need to type Yes):", "Yes\n"))
exit (0);
}
}
/* super block */
reiserfs_warning (stderr, "super block..");fflush (stderr);
send_block (fs, fs->fs_super_bh,
1/*send block even if its format is not determined */);
bmap_nr = reiserfs_bmap_nr(reiserfs_sb_get_blocks (fs->fs_ondisk_sb),
fs->fs_blocksize);
reiserfs_warning (stderr, "ok\nbitmaps..(%d).. ", bmap_nr);
send_block (fs, fs->fs_super_bh, 1/*send block even if its format is not determined */);
reiserfs_warning (stderr, "ok\nbitmaps..(%d).. ", reiserfs_fs_bmap_nr(fs));
fflush (stderr);
/* bitmaps */
block = fs->fs_super_bh->b_blocknr + 1;
for (i = 0; i < bmap_nr; i ++) {
bh = reiserfs_buffer_read (fs->fs_dev, block, fs->fs_blocksize);
for (i = 0; i < reiserfs_fs_bmap_nr(fs); i ++) {
bh = bread (fs->fs_dev, block, fs->fs_blocksize);
if (!bh) {
fprintf (stderr, "pack_frozen_data: reiserfs_buffer_read failed: %lu\n", block);
fprintf (stderr, "pack_frozen_data: bread failed: %lu\n", block);
continue;
}
send_block (fs, bh, 1);
if (reiserfs_bitmap_spread (fs))
if (spread_bitmaps (fs))
block = (block / (fs->fs_blocksize * 8) + 1) * (fs->fs_blocksize * 8);
else
block ++;
reiserfs_buffer_close (bh);
brelse (bh);
}
/* journal */
if (reiserfs_jp_get_dev (reiserfs_sb_jp (fs->fs_ondisk_sb))) {
if (get_jp_journal_dev (sb_jp (fs->fs_ondisk_sb))) {
/* non-standard journal is on a separate device */
if (journal_device_name (fs) && !reiserfs_journal_opened (fs))
misc_die ("Specified journal is not available. Specify it correctly or "
die ("Specified journal is not available. Specify it correctly or "
"don't specify at all");
else if (!journal_device_name(fs))
/* non-standard journal was not specified (that confirmed by user) -
@@ -640,19 +618,19 @@ static void pack_frozen_data (reiserfs_filsys_t * fs)
sent_journal_start_magic = 1;
}
}
block = reiserfs_jp_get_start (reiserfs_sb_jp (fs->fs_ondisk_sb));
block = get_jp_journal_1st_block (sb_jp (fs->fs_ondisk_sb));
reiserfs_warning (stderr, "ok\njournal (from %lu to %lu)..",
block, block + reiserfs_jp_get_size (reiserfs_sb_jp (fs->fs_ondisk_sb)));
block, block + get_jp_journal_size (sb_jp (fs->fs_ondisk_sb)));
fflush (stderr);
for (i = 0; i <= reiserfs_jp_get_size (reiserfs_sb_jp (fs->fs_ondisk_sb)); i ++) {
bh = reiserfs_buffer_read (fs->fs_journal_dev, block + i, fs->fs_blocksize);
for (i = 0; i <= get_jp_journal_size (sb_jp (fs->fs_ondisk_sb)); i ++) {
bh = bread (fs->fs_journal_dev, block + i, fs->fs_blocksize);
if (!bh) {
reiserfs_warning (stderr, "could not read %lu, skipped\n", i);
continue;
}
send_block (fs, bh, 1);
reiserfs_buffer_close (bh);
brelse (bh);
}
if (sent_journal_start_magic) {
magic16 = SEPARATED_JOURNAL_END_MAGIC;
@@ -668,7 +646,7 @@ static void pack_frozen_data (reiserfs_filsys_t * fs)
/* pack all "not data blocks" and correct leaf */
void pack_partition (reiserfs_filsys_t * fs)
{
reiserfs_bh_t * bh;
struct buffer_head * bh;
__u32 magic32;
__u16 blocksize;
__u16 magic16;
@@ -696,22 +674,20 @@ void pack_partition (reiserfs_filsys_t * fs)
total = reiserfs_bitmap_ones (what_to_pack);
for (i = 0; i < reiserfs_sb_get_blocks (fs->fs_ondisk_sb); i ++) {
for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
if (!reiserfs_bitmap_test_bit (what_to_pack, i))
continue;
print_how_far (stderr, &done, total, 1, be_quiet (fs));
if (!misc_test_bit(PRINT_QUIET, &data(fs)->options)) {
util_misc_progress (stderr, &done, total, 1, 0);
}
bh = reiserfs_buffer_read (fs->fs_dev, i, blocksize);
bh = bread (fs->fs_dev, i, blocksize);
if (!bh) {
reiserfs_warning (stderr, "could not read block %lu\n", i);
continue;
}
send_block (fs, bh, 0/*do not send block of not determined format */);
reiserfs_buffer_close (bh);
brelse (bh);
}
magic16 = END_MAGIC;
@@ -737,7 +713,7 @@ void pack_one_block (reiserfs_filsys_t * fs, unsigned long block)
{
__u32 magic32;
__u16 magic16;
reiserfs_bh_t * bh;
struct buffer_head * bh;
// reiserfs magic
magic32 = REISERFS_SUPER_MAGIC;
@@ -746,17 +722,17 @@ void pack_one_block (reiserfs_filsys_t * fs, unsigned long block)
// blocksize
fwrite_le16 (&fs->fs_blocksize);
bh = reiserfs_buffer_read (fs->fs_dev, block, fs->fs_blocksize);
bh = bread (fs->fs_dev, block, fs->fs_blocksize);
if (!bh)
return;
if (reiserfs_node_type (bh) == NT_LEAF)
if (who_is_this (bh->b_data, bh->b_size) == THE_LEAF)
pack_leaf (fs, bh);
else
pack_full_block (fs, bh);
reiserfs_buffer_close (bh);
brelse (bh);
// end magic
magic16 = END_MAGIC;
@@ -3,14 +3,8 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "debugreiserfs.h"
#include "misc/unaligned.h"
#include <errno.h>
#if 0
@@ -28,17 +22,17 @@ void do_recover (reiserfs_filsys_t fs)
char * line = 0;
int n = 0;
int fd;
reiserfs_key_t key = {0, 0, };
reiserfs_bh_t * bh;
reiserfs_ih_t * ih;
struct key key = {0, 0, };
struct buffer_head * bh;
struct item_head * ih;
unsigned long block;
char code;
long long int recovered = 0;
loff_t recovered = 0;
int i, j;
reiserfs_bitmap_t bitmap;
int used, not_used;
bitmap = reiserfs_bitmap_create (SB_BLOCK_COUNT (fs));
bitmap = reiserfs_create_bitmap (SB_BLOCK_COUNT (fs));
reiserfs_fetch_disk_bitmap (bitmap, fs);
/* we check how many blocks recoverd items point to are free or used */
used = 0;
@@ -52,7 +46,7 @@ void do_recover (reiserfs_filsys_t fs)
case 'K':
/* get a key of file which is to be recovered */
if (sscanf (line, "%c %u %u\n", &code, &key.k_dir_id, &key.k_objectid) != 3) {
misc_die ("recover_file: wrong input K format");
die ("recover_file: wrong input K format");
}
printf ("Recovering file (%u, %u)\n", key.k_dir_id, key.k_objectid);
break;
@@ -61,22 +55,22 @@ void do_recover (reiserfs_filsys_t fs)
/* get a file name */
recovered = 0;
if (sscanf (line, "%c %s\n", &code, name) != 2) {
misc_die ("recover_file: wrong input N format");
die ("recover_file: wrong input N format");
}
fd = open (name, O_RDWR | O_CREAT | O_EXCL, 0644);
if (fd == -1)
misc_die ("recover_file: could not create file %s: %s",
die ("recover_file: could not create file %s: %s",
name,strerror (errno));
printf ("Recovering file %s..\n", name);
break;
case 'B':
if (!fd)
misc_die ("recover_file: file name is not specified");
die ("recover_file: file name is not specified");
if (sscanf (line, "%c %lu\n", &code, &block) != 2) {
misc_die ("recover_file: wrong input B format");
die ("recover_file: wrong input B format");
}
bh = reiserfs_buffer_read (fs->s_dev, block, fs->s_blocksize);
bh = bread (fs->s_dev, block, fs->s_blocksize);
if (!bh) {
printf ("reading block %lu failed\n", block);
continue;
@@ -84,29 +78,29 @@ void do_recover (reiserfs_filsys_t fs)
printf ("working with block %lu..\n", block);
ih = reiserfs_ih_at (bh, 0);
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < node_item_number (bh); i ++, ih ++) {
__u32 * extent;
reiserfs_bh_t * tmp_bh;
__u32 * indirect;
struct buffer_head * tmp_bh;
if (!reiserfs_ih_ext (ih) || key.k_dir_id != ih->ih_key.k_dir_id ||
if (!is_indirect_ih (ih) || key.k_dir_id != ih->ih_key.k_dir_id ||
key.k_objectid != ih->ih_key.k_objectid)
continue;
extent = (__u32 *)reiserfs_item_by_ih (bh, ih);
for (j = 0; j < reiserfs_ext_count (ih); j ++) {
block = le32_to_cpu (extent [j]);
indirect = (__u32 *)B_I_PITEM (bh, ih);
for (j = 0; j < I_UNFM_NUM (ih); j ++) {
block = le32_to_cpu (indirect [j]);
if (!block)
continue;
tmp_bh = reiserfs_buffer_read (fs->s_dev, block, fs->s_blocksize);
tmp_bh = bread (fs->s_dev, block, fs->s_blocksize);
if (!tmp_bh) {
printf ("reading block %Lu failed\n", (long long int)block * fs->s_blocksize);
printf ("reading block %Lu failed\n", (loff_t)block * fs->s_blocksize);
continue;
}
if (lseek64 (fd, reiserfs_key_get_off (&ih->ih_key) + j * fs->s_blocksize - 1,
SEEK_SET) == (off_t)-1) {
printf ("llseek failed to pos %Ld\n", (long long int)block * fs->s_blocksize);
reiserfs_buffer_close (tmp_bh);
if (lseek64 (fd, get_offset (&ih->ih_key) + j * fs->s_blocksize - 1,
SEEK_SET) == (loff_t)-1) {
printf ("llseek failed to pos %Ld\n", (loff_t)block * fs->s_blocksize);
brelse (tmp_bh);
continue;
}
if (reiserfs_bitmap_test_bit (bitmap, block))
@@ -114,17 +108,17 @@ void do_recover (reiserfs_filsys_t fs)
else
not_used ++;
/*printf ("block of file %Ld gets block %lu\n",
(reiserfs_key_get_off (&ih->ih_key) - 1) / fs->s_blocksize + j, block);*/
(get_offset (&ih->ih_key) - 1) / fs->s_blocksize + j, block);*/
if (write (fd, tmp_bh->b_data, tmp_bh->b_size) != tmp_bh->b_size) {
printf ("write failed to pos %Ld\n", (long long int)block * fs->s_blocksize);
reiserfs_buffer_close (tmp_bh);
printf ("write failed to pos %Ld\n", (loff_t)block * fs->s_blocksize);
brelse (tmp_bh);
continue;
}
recovered += fs->s_blocksize;
reiserfs_buffer_close (tmp_bh);
brelse (tmp_bh);
}
}
reiserfs_buffer_close (bh);
brelse (bh);
break;
}
}
@@ -175,7 +169,7 @@ static void read_map (FILE * fp)
&ids[0], buf, &ids[2]);
//do_recover = util_user_confirmed (stdout, "recover? (Y):", "Y\n");
//do_recover = user_confirmed (stdout, "recover? (Y):", "Y\n");
//if (do_recover)
// reiserfs_warning (stderr, "recovering not ready\n");
@@ -226,7 +220,7 @@ void do_recover (reiserfs_filsys_t * fs)
{
FILE * fp;
if (map_file (fs) [0] != '\0') {
if (map_file (fs)) {
fp = fopen (map_file (fs), "r");
if (fp == 0) {
reiserfs_warning (stderr, "do_recover: fopen failed: %m");
@@ -249,28 +243,24 @@ void do_recover (reiserfs_filsys_t * fs)
#include <limits.h>
static long int get_answer(long int max) {
char answer[256], *tmp;
char *answer, *tmp;
size_t n = 0;
long int result = 0;
do {
printf("Which should be left?: ");
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
result = strtol (answer, &tmp, 0);
if ((errno != ERANGE) &&
(result < max) &&
(result >= 0) &&
if ((errno != ERANGE) && (result < max) && (result >= 0) &&
(answer != tmp))
{
break;
}
} while (1);
return result;
}
static void recover_items(FILE *fp, reiserfs_filsys_t * fs, FILE *target_file) {
reiserfs_bh_t *bh, *bh_pointed;
reiserfs_ih_t *ih;
struct buffer_head *bh, *bh_pointed;
struct item_head *ih;
struct saved_item item, *cur;
int size = sizeof(struct saved_item) - sizeof(struct saved_item *);
struct saved_item *map = NULL;
@@ -287,56 +277,42 @@ static void recover_items(FILE *fp, reiserfs_filsys_t * fs, FILE *target_file) {
memcpy((void *)map + map_size - sizeof(struct saved_item), &item, size);
}
for (i = 1, cur = map + 1;
i <= map_size / sizeof(struct saved_item);
i++, cur++)
{
bh = reiserfs_buffer_read (fs->fs_dev, (cur - 1)->si_block,
fs->fs_blocksize);
for (i = 1, cur = map + 1; i <= map_size / sizeof(struct saved_item); i++, cur++) {
bh = bread (fs->fs_dev, (cur - 1)->si_block, fs->fs_blocksize);
if (!bh) {
reiserfs_warning (fp, "reiserfs_buffer_read failed\n");
reiserfs_warning (fp, "bread failed\n");
continue;
}
if (i == map_size / sizeof(struct saved_item)) {
if (start != -1) {
reiserfs_leaf_print(stdout, fs, bh, 0,
(cur - 1)->si_item_num,
(cur - 1)->si_item_num + 1);
reiserfs_print_item(stdout, bh, B_N_PITEM_HEAD (bh, (cur - 1)->si_item_num));
result = get_answer(i - start) + start;
} else {
result = i - 1;
}
start = -1;
} else if (reiserfs_ih_dir(&(cur - 1)->si_ih) ||
reiserfs_ih_stat(&(cur - 1)->si_ih))
{
reiserfs_buffer_close(bh);
} else if (is_direntry_ih(&(cur - 1)->si_ih) || is_stat_data_ih(&(cur - 1)->si_ih)) {
brelse(bh);
continue;
} else {
length = reiserfs_leaf_ibytes(&(cur - 1)->si_ih, fs->fs_blocksize);
if (offset < reiserfs_key_get_off(&(cur - 1)->si_ih.ih_key) +
reiserfs_leaf_ibytes(&(cur - 1)->si_ih, fs->fs_blocksize))
offset = reiserfs_key_get_off(&(cur - 1)->si_ih.ih_key) +
(length ? length - 1 : 0);
length = get_bytes_number(&(cur - 1)->si_ih, fs->fs_blocksize);
if (offset < get_offset(&(cur - 1)->si_ih.ih_key) +
get_bytes_number(&(cur - 1)->si_ih, fs->fs_blocksize))
offset = get_offset(&(cur - 1)->si_ih.ih_key) + (length ? length - 1 : 0);
if (offset >= reiserfs_key_get_off(&cur->si_ih.ih_key)) {
if (offset >= get_offset(&cur->si_ih.ih_key)) {
/* Problem interval */
if (start == -1)
start = i - 1;
printf("Problem item %d:\n", i - start - 1);
reiserfs_leaf_print(stdout, fs, bh, 0,
(cur - 1)->si_item_num,
(cur - 1)->si_item_num + 1);
reiserfs_print_item(stdout, bh, B_N_PITEM_HEAD (bh, (cur - 1)->si_item_num));
} else if (start != -1) {
/* problem interval finished */
printf("Problem item %d:\n", i - start - 1);
reiserfs_leaf_print(stdout, fs, bh, 0,
(cur - 1)->si_item_num,
(cur - 1)->si_item_num + 1);
reiserfs_print_item(stdout, bh, B_N_PITEM_HEAD (bh, (cur - 1)->si_item_num));
result = get_answer((long int)i - start) + start;
start = -1;
@@ -344,48 +320,40 @@ static void recover_items(FILE *fp, reiserfs_filsys_t * fs, FILE *target_file) {
result = i - 1;
}
}
reiserfs_buffer_close(bh);
brelse(bh);
if (start != -1)
continue;
bh = reiserfs_buffer_read (fs->fs_dev, (map + result)->si_block,
fs->fs_blocksize);
printf("write %ld\n", result);
bh = bread (fs->fs_dev, (map + result)->si_block, fs->fs_blocksize);
if (!bh) {
reiserfs_warning (fp, "reiserfs_buffer_read failed\n");
reiserfs_warning (fp, "bread failed\n");
continue;
}
fseek(target_file,
reiserfs_key_get_off(&(map + result)->si_ih.ih_key) - 1,
SEEK_SET);
ih = reiserfs_ih_at (bh, (map + result)->si_item_num);
if (reiserfs_ih_direct(ih)) {
fwrite(reiserfs_item_by_ih(bh, ih),
(map + result)->si_ih.ih2_item_len, 1, target_file);
} else if (reiserfs_ih_ext(ih)) {
for (j = 0; j < reiserfs_ext_count (ih); j ++) {
unfm_ptr = d32_get((__u32 *)reiserfs_item_by_ih(bh, ih), j);
fseek(target_file, get_offset(&(map + result)->si_ih.ih_key) - 1, SEEK_SET);
ih = B_N_PITEM_HEAD (bh, (map + result)->si_item_num);
if (is_direct_ih(ih)) {
fwrite(B_I_PITEM(bh, ih), (map + result)->si_ih.ih2_item_len, 1, target_file);
} else if (is_indirect_ih(ih)) {
for (j = 0; j < I_UNFM_NUM (ih); j ++) {
unfm_ptr = d32_get((__u32 *)B_I_PITEM(bh, ih), j);
if (!unfm_ptr) {
fseek(target_file, fs->fs_blocksize, SEEK_CUR);
continue;
}
bh_pointed = reiserfs_buffer_read (fs->fs_dev, unfm_ptr,
fs->fs_blocksize);
bh_pointed = bread (fs->fs_dev, unfm_ptr, fs->fs_blocksize);
if (!bh_pointed) {
reiserfs_warning (fp, "reiserfs_buffer_read failed\n");
reiserfs_warning (fp, "bread failed\n");
continue;
}
fwrite(bh_pointed->b_data,
fs->fs_blocksize, 1, target_file);
reiserfs_buffer_close(bh_pointed);
fwrite(bh_pointed->b_data, fs->fs_blocksize, 1, target_file);
brelse(bh_pointed);
}
}
reiserfs_buffer_close(bh);
brelse(bh);
}
free(map);
@@ -394,7 +362,7 @@ static void recover_items(FILE *fp, reiserfs_filsys_t * fs, FILE *target_file) {
void do_recover(reiserfs_filsys_t * fs) {
FILE *fp, *recovery;
if (map_file (fs)[0] != '\0') {
if (map_file (fs)) {
fp = fopen (map_file (fs), "r");
if (fp == 0) {
reiserfs_warning (stderr, "fopen failed: %m\n");
+212 -224
View File
@@ -3,13 +3,7 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "debugreiserfs.h"
#include "util/misc.h"
#include <regex.h>
#include <obstack.h>
#include <search.h>
@@ -56,8 +50,8 @@ struct saved_name {
/* attach item to every name in the list */
static void store_item (struct saved_name * name, reiserfs_bh_t * bh,
reiserfs_ih_t * ih, int pos)
static void store_item (struct saved_name * name, struct buffer_head * bh,
struct item_head * ih, int pos)
{
struct saved_item * new;
void * vp;
@@ -66,11 +60,11 @@ static void store_item (struct saved_name * name, reiserfs_bh_t * bh,
new = obstack_alloc (&item_store, sizeof (struct saved_item));
new->si_ih = *ih;
new->si_block = bh->b_blocknr;
new->si_item_num = ih - reiserfs_ih_at (bh, 0);
new->si_item_num = ih - B_N_PITEM_HEAD (bh, 0);
new->si_next = 0;
new->si_entry_pos = pos;
vp = tfind (new, &name->items, reiserfs_key_comp);
vp = tfind (new, &name->items, comp_keys);
if (vp) {
item_in = *(void **)vp;
/* add item to the end of list of items having this key */
@@ -82,7 +76,7 @@ static void store_item (struct saved_name * name, reiserfs_bh_t * bh,
item_in = item_in->si_next;
}
} else
tsearch (new, &name->items, reiserfs_key_comp);
tsearch (new, &name->items, comp_keys);
saved_items ++;
}
@@ -106,7 +100,7 @@ static int comp_pointed (const void * p1, const void * p2)
name1 = (struct saved_name *)p1;
name2 = (struct saved_name *)p2;
return reiserfs_key_comp2 (&name1->dirid, &name2->dirid);
return comp_short_keys (&name1->dirid, &name2->dirid);
}
@@ -128,8 +122,8 @@ static int name_found (struct saved_name * name, struct saved_name ** name_in)
/* check every name in the list */
cur = *name_in;
while (cur) {
if (!reiserfs_key_comp2 (&name->dirid, &cur->dirid) &&
!reiserfs_key_comp2 (&name->parent_dirid, &cur->parent_dirid))
if (!not_of_one_file (&name->dirid, &cur->dirid) &&
!not_of_one_file (&name->parent_dirid, &cur->parent_dirid))
{
cur->count ++;
*name_in = cur;
@@ -177,11 +171,11 @@ static void add_name (struct saved_name * name, struct saved_name * name_in)
/* take each name matching to a given pattern, */
static void scan_for_name (reiserfs_bh_t * bh)
static void scan_for_name (struct buffer_head * bh)
{
int i, j, i_num;
reiserfs_ih_t * ih;
reiserfs_deh_t * deh;
struct item_head * ih;
struct reiserfs_de_head * deh;
int namelen;
char * name;
struct saved_name * new, *name_in;
@@ -190,28 +184,25 @@ static void scan_for_name (reiserfs_bh_t * bh)
int min_entry_size = 1;
int ih_entry_count = 0;
ih = reiserfs_ih_at (bh, 0);
i_num = reiserfs_leaf_estimate_items(bh);
ih = B_N_PITEM_HEAD (bh, 0);
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i ++, ih ++) {
if (!reiserfs_ih_dir (ih))
if (!is_direntry_ih (ih))
continue;
if (reiserfs_leaf_correct_at (fs, ih, reiserfs_item_by_ih (bh, ih),
0, 1))
{
if (is_it_bad_item (fs, ih, B_I_PITEM (bh, ih), 0, 1))
continue;
}
deh = reiserfs_deh (bh, ih);
deh = B_I_DEH (bh, ih);
if ( (reiserfs_ih_get_entries (ih) > (reiserfs_ih_get_len(ih) / (REISERFS_DEH_SIZE + min_entry_size))) ||
(reiserfs_ih_get_entries (ih) == 0))
ih_entry_count = reiserfs_ih_get_len(ih) / (REISERFS_DEH_SIZE + min_entry_size);
if ( (get_ih_entry_count (ih) > (get_ih_item_len(ih) / (DEH_SIZE + min_entry_size))) ||
(get_ih_entry_count (ih) == 0))
ih_entry_count = get_ih_item_len(ih) / (DEH_SIZE + min_entry_size);
else
ih_entry_count = reiserfs_ih_get_entries (ih);
ih_entry_count = get_ih_entry_count (ih);
for (j = 0; j < ih_entry_count; j ++, deh ++) {
name = reiserfs_deh_name (deh, j);
namelen = reiserfs_direntry_name_len (ih, deh, j);
name = name_in_entry (deh, j);
namelen = name_in_entry_length (ih, deh, j);
ch = name[namelen];
name[namelen] = 0;
retval = regexec (&pattern, name, 0, NULL, 0);
@@ -224,15 +215,15 @@ static void scan_for_name (reiserfs_bh_t * bh)
new = obstack_alloc (&name_store, sizeof (struct saved_name) + namelen);
/* pointed object */
new->dirid = reiserfs_deh_get_did (deh);
new->objectid = reiserfs_deh_get_obid (deh);
new->dirid = get_deh_dirid (deh);
new->objectid = get_deh_objectid (deh);
/* pointer to first name which points the same key */
new->first_name = 0;
/* where this name is from */
new->parent_dirid = reiserfs_key_get_did (&ih->ih_key);
new->parent_objectid = reiserfs_key_get_oid (&ih->ih_key);
new->parent_dirid = get_key_dirid (&ih->ih_key);
new->parent_objectid = get_key_objectid (&ih->ih_key);
new->block = bh->b_blocknr;
new->count = 1;
@@ -263,16 +254,16 @@ static void scan_for_name (reiserfs_bh_t * bh)
return;
}
static struct saved_name *scan_for_key(reiserfs_key_t *key) {
static struct saved_name *scan_for_key(struct key *key) {
char *name;
struct saved_name * new, *name_in;
char name[REISERFS_NAME_MAX];
sprintf(name, "%u_%u", reiserfs_key_get_did (key), reiserfs_key_get_oid (key));
asprintf (&name, "%u_%u", get_key_dirid (key), get_key_objectid (key));
new = obstack_alloc (&name_store, sizeof (struct saved_name) + strlen(name));
/* pointed object */
new->dirid = reiserfs_key_get_did (key);
new->objectid = reiserfs_key_get_oid (key);
new->dirid = get_key_dirid (key);
new->objectid = get_key_objectid (key);
/* pointer to first name which points the same key */
new->first_name = 0;
@@ -291,6 +282,8 @@ static struct saved_name *scan_for_key(reiserfs_key_t *key) {
new->name [new->name_len] = 0;
new->name_next = 0;
free(name);
if (name_found (new, &name_in)) {
/* there was already exactly this name */
obstack_free (&name_store, new);
@@ -303,32 +296,32 @@ static struct saved_name *scan_for_key(reiserfs_key_t *key) {
return new;
}
static int comp_token_key(reiserfs_bh_t *bh, reiserfs_ih_t *ih, reiserfs_key_t *key) {
reiserfs_deh_t * deh;
static int comp_token_key(struct buffer_head *bh, struct item_head *ih, struct key *key) {
struct reiserfs_de_head * deh;
int j, ih_entry_count = 0;
int min_entry_size = 1;
if ((reiserfs_key_get_did(&ih->ih_key) == reiserfs_key_get_did(key) ||
reiserfs_key_get_did(key) == ~(__u32)0) &&
(reiserfs_key_get_oid(&ih->ih_key) == reiserfs_key_get_oid(key) ||
reiserfs_key_get_oid(key) == ~(__u32)0))
if ((get_key_dirid(&ih->ih_key) == get_key_dirid(key) ||
get_key_dirid(key) == ~(__u32)0) &&
(get_key_objectid(&ih->ih_key) == get_key_objectid(key) ||
get_key_objectid(key) == ~(__u32)0))
return -1;
if (!reiserfs_ih_dir (ih))
if (!is_direntry_ih (ih))
return 0;
deh = reiserfs_deh (bh, ih);
deh = B_I_DEH (bh, ih);
if ( (reiserfs_ih_get_entries (ih) > (reiserfs_ih_get_len(ih) / (REISERFS_DEH_SIZE + min_entry_size))) ||
(reiserfs_ih_get_entries (ih) == 0))
ih_entry_count = reiserfs_ih_get_len(ih) / (REISERFS_DEH_SIZE + min_entry_size);
if ( (get_ih_entry_count (ih) > (get_ih_item_len(ih) / (DEH_SIZE + min_entry_size))) ||
(get_ih_entry_count (ih) == 0))
ih_entry_count = get_ih_item_len(ih) / (DEH_SIZE + min_entry_size);
else
ih_entry_count = reiserfs_ih_get_entries (ih);
ih_entry_count = get_ih_entry_count (ih);
for (j = 0; j < ih_entry_count; j ++, deh ++) {
if ((reiserfs_deh_get_did (deh) == reiserfs_key_get_did (key) || (int)reiserfs_key_get_did (key) == -1) &&
(reiserfs_deh_get_obid (deh) == reiserfs_key_get_oid (key) || (int)reiserfs_key_get_oid (key) == -1))
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))
{
return j;
}
@@ -339,15 +332,15 @@ static int comp_token_key(reiserfs_bh_t *bh, reiserfs_ih_t *ih, reiserfs_key_t *
/* take every item, look for its key in the key index, if it is found - store
item in the sorted list of items of a file */
static void scan_items (reiserfs_bh_t * bh, reiserfs_key_t *key) {
static void scan_items (struct buffer_head * bh, struct key *key) {
int i, i_num, pos;
reiserfs_ih_t * ih;
struct item_head * ih;
struct saved_name * name_in_store;
void * res;
ih = reiserfs_ih_at (bh, 0);
i_num = reiserfs_leaf_estimate_items(bh);
ih = B_N_PITEM_HEAD (bh, 0);
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i ++, ih ++) {
if (key) {
if (!(pos = comp_token_key(bh, ih, key)))
@@ -370,7 +363,7 @@ static void scan_items (reiserfs_bh_t * bh, reiserfs_key_t *key) {
/* FIXME: does not work for long files */
struct version {
int flag; /* direct or extent */
int flag; /* direct or indirect */
int len;
__u32 from;
int count;
@@ -400,15 +393,15 @@ struct file_map {
struct file_map map;
static int have_to_append (reiserfs_ih_t * ih)
static int have_to_append (struct item_head * ih)
{
unsigned long long off = reiserfs_key_get_off (&ih->ih_key);
loff_t off = get_offset (&ih->ih_key);
if (reiserfs_ih_ext (ih)) {
if (is_indirect_ih (ih)) {
if (map.head_len * fs->fs_blocksize + 1 <= off)
return 1;
return 0;
} else if (reiserfs_ih_direct (ih)) {
} else if (is_direct_ih (ih)) {
int i;
__u32 tail_start;
@@ -429,24 +422,24 @@ static int have_to_append (reiserfs_ih_t * ih)
}
static void do_append (reiserfs_ih_t * ih, void * data)
static void do_append (struct item_head * ih, void * data)
{
int i;
int padd;
unsigned long long off = reiserfs_key_get_off (&ih->ih_key);
unsigned long long off = get_offset (&ih->ih_key);
if (reiserfs_ih_ext (ih)) {
if (is_indirect_ih (ih)) {
padd = (off - 1) / fs->fs_blocksize - map.head_len;
map.head = realloc (map.head, (map.head_len + padd + reiserfs_ext_count (ih)) * 4);
map.head = realloc (map.head, (map.head_len + padd + I_UNFM_NUM (ih)) * 4);
if (!map.head)
reiserfs_panic ("realloc failed");
memset ((char *)map.head + map.head_len * 4, 0, padd * 4);
memcpy ((char *)map.head + (map.head_len + padd) * 4, data,
reiserfs_ih_get_len (ih));
map.head_len += (padd + reiserfs_ext_count (ih));
get_ih_item_len (ih));
map.head_len += (padd + I_UNFM_NUM (ih));
} else if (reiserfs_ih_direct (ih)) {
} else if (is_direct_ih (ih)) {
unsigned int tail_start, skip;
// find correct tail first
@@ -455,13 +448,13 @@ static void do_append (reiserfs_ih_t * ih, void * data)
for (i = 0; i < map.tail_nr; i ++) {
if (map.tails[i].offset == tail_start) {
map.tails[i].data = realloc (map.tails[i].data,
off - tail_start + reiserfs_ih_get_len (ih));
off - tail_start + get_ih_item_len (ih));
if (!map.tails[i].data)
reiserfs_panic ("realloc failed");
padd = skip - map.tails[i].len;
memset (map.tails[i].data + map.tails[i].len, 0, padd);
memcpy (map.tails[i].data + map.tails[i].len + padd, data, reiserfs_ih_get_len (ih));
map.tails[i].len += (padd + reiserfs_ih_get_len (ih));
memcpy (map.tails[i].data + map.tails[i].len + padd, data, get_ih_item_len (ih));
map.tails[i].len += (padd + get_ih_item_len (ih));
return;
}
}
@@ -471,48 +464,45 @@ static void do_append (reiserfs_ih_t * ih, void * data)
reiserfs_panic ("realloc failed");
map.tails[map.tail_nr].offset = off;
map.tails[map.tail_nr].len = skip + reiserfs_ih_get_len (ih);
map.tails[map.tail_nr].len = skip + get_ih_item_len (ih);
map.tails[map.tail_nr].data = malloc (map.tails[map.tail_nr].len);
memset (map.tails[map.tail_nr].data, 0, skip);
memcpy (map.tails[map.tail_nr].data + skip, data, reiserfs_ih_get_len (ih));
memcpy (map.tails[map.tail_nr].data + skip, data, get_ih_item_len (ih));
map.tail_nr ++;
}
}
// map contains
static void do_overwrite (reiserfs_ih_t * ih, void * data)
static void do_overwrite (struct item_head * ih, void * data)
{
unsigned long long off, skip;
int to_compare, to_append;
reiserfs_ih_t tmp_ih;
struct item_head tmp_ih;
char * p;
off = reiserfs_key_get_off (&ih->ih_key);
off = get_offset (&ih->ih_key);
if (reiserfs_ih_ext (ih)) {
if (is_indirect_ih (ih)) {
skip = (off - 1) / fs->fs_blocksize;
to_compare = (map.head_len - skip > reiserfs_ext_count (ih)) ?
reiserfs_ext_count (ih) : (map.head_len - skip);
to_append = reiserfs_ext_count (ih) - to_compare;
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;
if (memcmp (p, data, to_compare * 4))
reiserfs_warning (stderr, "overwrite (extent): %H contains different data\n", ih);
reiserfs_warning (stderr, "overwrite (indirect): %H contains different data\n", ih);
if (to_append) {
tmp_ih = *ih;
reiserfs_ih_set_len (&tmp_ih, reiserfs_ih_get_len (ih) - to_compare * 4);
reiserfs_key_set_off (reiserfs_key_format (&ih->ih_key),
&tmp_ih.ih_key, off + to_compare *
fs->fs_blocksize);
set_ih_item_len (&tmp_ih, get_ih_item_len (ih) - to_compare * 4);
set_offset (key_format (&ih->ih_key), &tmp_ih.ih_key, off + to_compare * fs->fs_blocksize);
do_append (&tmp_ih, (char *)data + to_compare * 4);
}
} else if (reiserfs_ih_direct (ih)) {
} else if (is_direct_ih (ih)) {
unsigned int tail_start;
int i;
@@ -522,25 +512,21 @@ static void do_overwrite (reiserfs_ih_t * ih, void * data)
if (map.tails[i].offset == tail_start) {
// ih is a part of this tail
skip = (off - 1) & (fs->fs_blocksize - 1);
to_compare = (map.tails[i].len - skip > reiserfs_ih_get_len (ih) ? reiserfs_ih_get_len (ih) :
to_compare = (map.tails[i].len - skip > get_ih_item_len (ih) ? get_ih_item_len (ih) :
map.tails[i].len - skip);
to_append = reiserfs_ih_get_len (ih) - to_compare;
to_append = get_ih_item_len (ih) - to_compare;
p = (char *)map.tails[i].data + skip;
if (memcmp (p, data, to_compare))
reiserfs_warning (stderr, "overwrite (direct): %H contains "
"different data\n", ih);
reiserfs_warning (stderr, "overwrite (direct): %H contains different data\n", ih);
if (to_append) {
tmp_ih = *ih;
reiserfs_ih_set_len (&tmp_ih, reiserfs_ih_get_len (ih) - to_compare);
reiserfs_key_set_off (reiserfs_key_format (&ih->ih_key),
&tmp_ih.ih_key, off + to_compare);
set_ih_item_len (&tmp_ih, get_ih_item_len (ih) - to_compare);
set_offset (key_format (&ih->ih_key), &tmp_ih.ih_key, off + to_compare);
do_append (&tmp_ih, (char *)data + to_compare);
}
return;
}
}
@@ -551,19 +537,19 @@ static void do_overwrite (reiserfs_ih_t * ih, void * data)
static void map_one_item (struct saved_item * item)
{
reiserfs_bh_t * bh;
reiserfs_ih_t * ih;
struct buffer_head * bh;
struct item_head * ih;
void * data;
// read the block containing the item
bh = reiserfs_buffer_read (fs->fs_dev, item->si_block, fs->fs_blocksize);
bh = bread (fs->fs_dev, item->si_block, fs->fs_blocksize);
if (!bh) {
reiserfs_warning (stderr, "reiserfs_buffer_read failed\n");
reiserfs_warning (stderr, "bread failed\n");
return;
}
ih = reiserfs_ih_at (bh, item->si_item_num);
data = reiserfs_item_by_ih (bh, ih);
ih = B_N_PITEM_HEAD (bh, item->si_item_num);
data = B_I_PITEM (bh, ih);
if (memcmp (&item->si_ih, ih, sizeof (*ih)))
reiserfs_panic ("wrong item");
@@ -572,22 +558,22 @@ static void map_one_item (struct saved_item * item)
} else
do_overwrite (ih, data);
reiserfs_buffer_close (bh);
brelse (bh);
}
// flush map which is in variable map
static void flush_map (reiserfs_filsys_t * fs,
reiserfs_key_t * dir,
struct key * dir,
char * name,
reiserfs_key_t * key)
struct key * key)
{
int i;
FILE * fp;
__u32 v32;
if (map_file (fs) == '\0')
sprintf(map_file (fs), ".map");
if (!map_file (fs))
asprintf (&map_file (fs), "%s", ".map");
//reiserfs_warning (stderr, "Saving maps into %s\n", map_file (fs));
fp = fopen (map_file (fs), "a");
@@ -610,10 +596,10 @@ static void flush_map (reiserfs_filsys_t * fs,
fwrite (name, v32, 1, fp);
// short key of a directory
fwrite (dir, REISERFS_KEY_SHSIZE, 1, fp);
fwrite (dir, SHORT_KEY_SIZE, 1, fp);
// short key of file
fwrite (key, REISERFS_KEY_SHSIZE, 1, fp);
fwrite (key, SHORT_KEY_SIZE, 1, fp);
// list of data block pointers
fwrite (&map.head_len, sizeof (map.head_len), 1, fp);
@@ -656,11 +642,11 @@ static void map_item_list (const void *nodep, VISIT value, int level)
item = *(struct saved_item **)nodep;
// 1. find the longest item
max_bytes = reiserfs_leaf_ibytes (&item->si_ih, fs->fs_blocksize);
max_bytes = get_bytes_number (&item->si_ih, fs->fs_blocksize);
longest = item;
while (item->si_next) {
item = item->si_next;
bytes = reiserfs_leaf_ibytes (&item->si_ih, fs->fs_blocksize);
bytes = get_bytes_number (&item->si_ih, fs->fs_blocksize);
if (bytes > max_bytes) {
longest = item;
max_bytes = bytes;
@@ -698,8 +684,8 @@ static void make_file_map (const void *nodep, VISIT value, int level)
twalk (name->items, map_item_list);
// write map to a file
flush_map (fs, (reiserfs_key_t *)&name->parent_dirid, name->name,
(reiserfs_key_t *)&name->dirid);
flush_map (fs, (struct key *)&name->parent_dirid, name->name,
(struct key *)&name->dirid);
} else if (name->first_name)
reiserfs_warning (stdout, "[%K]:\"%s\" has item list\n",
@@ -717,27 +703,27 @@ static void make_file_map (const void *nodep, VISIT value, int level)
*/
static void print_items(FILE *fp, reiserfs_filsys_t * fs) {
reiserfs_bh_t *bh;
struct buffer_head *bh;
struct item_head *ih;
struct saved_item item;
int size = sizeof(struct saved_item) - sizeof(struct saved_item *);
while (fread(&item, size, 1, fp) == 1) {
bh = reiserfs_buffer_read (fs->fs_dev, item.si_block, fs->fs_blocksize);
bh = bread (fs->fs_dev, item.si_block, fs->fs_blocksize);
if (!bh) {
reiserfs_warning (fp, "reiserfs_buffer_read failed\n");
reiserfs_warning (fp, "bread failed\n");
continue;
}
reiserfs_leaf_print(stdout, fs, bh, 0,
item.si_item_num,
item.si_item_num + 1);
reiserfs_buffer_close(bh);
ih = B_N_PITEM_HEAD (bh, item.si_item_num);
reiserfs_print_item(stdout, bh, ih);
brelse(bh);
}
}
void print_map(reiserfs_filsys_t * fs) {
FILE * fp;
if (map_file (fs) [0] != '\0') {
if (map_file (fs)) {
fp = fopen (map_file (fs), "r");
if (fp == 0) {
reiserfs_warning (stderr, "fopen failed: %m\n");
@@ -774,7 +760,7 @@ static void save_items(const void *nodep, VISIT value, int level) {
if (fp) {
fwrite(item, sizeof(struct saved_item) - sizeof(struct saved_item *), 1, fp);
} else {
if (reiserfs_ih_dir (&item->si_ih) && item->si_entry_pos != -1) {
if (is_direntry_ih (&item->si_ih) && item->si_entry_pos != -1) {
reiserfs_warning(log_to, "block %lu, item %d (%H): entry %d\n",
item->si_block, item->si_item_num,
&item->si_ih, item->si_entry_pos);
@@ -792,15 +778,15 @@ static void save_items(const void *nodep, VISIT value, int level) {
static void make_map(const void *nodep, VISIT value, int level) {
struct saved_name * name;
char file_name[4096];
char *file_name = 0;
static int nr = 0;
name = *(struct saved_name **)nodep;
if (value == leaf || value == postorder) {
while (name) {
if (map_file(fs)[0] != '\0') {
sprintf(file_name, "%s.%d", map_file(fs), ++nr);
if (map_file(fs)) {
asprintf(&file_name, "%s.%d", map_file(fs), ++nr);
reiserfs_warning (log_to, "%d - (%d): [%K]:\"%s\": stored in the %s\n",
nr, name->count, &name->parent_dirid, name->name, file_name);
@@ -819,143 +805,148 @@ static void make_map(const void *nodep, VISIT value, int level) {
if (fp) {
fclose(fp);
fp = NULL;
free(file_name);
}
}
}
}
/* store map if it is a regular file */
static void locate_file (reiserfs_filsys_t * fs, reiserfs_key_t * key)
static void locate_file (reiserfs_filsys_t * fs, struct key * key)
{
REISERFS_PATH_INIT (path);
const reiserfs_key_t * next_key;
INITIALIZE_PATH (path);
struct key * next_key;
int retval;
do {
retval = reiserfs_tree_search_item (fs, key, &path);
retval = reiserfs_search_by_key_4 (fs, key, &path);
if (retval != ITEM_FOUND)
break;
if (!reiserfs_key_stat (key) && !reiserfs_key_dir (key)) {
if (!is_stat_data_key (key) && !is_direntry_key (key)) {
struct saved_item si;
si.si_block = REISERFS_PATH_LEAF (&path)->b_blocknr;
si.si_item_num = REISERFS_PATH_LEAF_POS (&path);
si.si_ih = *REISERFS_PATH_IH (&path);
si.si_block = get_bh (&path)->b_blocknr;
si.si_item_num = get_item_pos (&path);
si.si_ih = *get_ih (&path);
map_one_item (&si);
}
next_key = reiserfs_tree_next_key (&path, fs);
if (!next_key || reiserfs_key_comp2 (next_key, key))
/*reiserfs_warning (stdout, "\t");
reiserfs_print_item (stdout, get_bh (&path), get_ih (&path));*/
next_key = reiserfs_next_key (&path);
if (!next_key || not_of_one_file (next_key, key))
break;
*key = *next_key;
reiserfs_tree_pathrelse (&path);
pathrelse (&path);
} while (1);
reiserfs_tree_pathrelse (&path);
pathrelse (&path);
}
/* read stdin and look for specified name in the specified directory */
static void look_for_name (reiserfs_filsys_t * fs)
{
char buf[256], *p;
unsigned long dirid, objectid;
REISERFS_PATH_INIT (path);
reiserfs_key_t key = {0, };
INITIALIZE_PATH (path);
char * name, * objectid, * dirid;
size_t n;
struct key key = {0, };
reiserfs_warning (stderr, "Enter dirid objectid "
"\"name\" or press ^D to quit\n");
reiserfs_warning (stderr,
"Enter dirid objectid \"name\" or press ^D to quit\n");
while (1) {
reiserfs_warning (stderr, ">");
fgets(buf, sizeof(buf), stdin);
if ((p = (char *)strtok(buf, " \t\n")) == NULL)
continue;
if (sscanf(p, "%lu ", &dirid) <= 0)
continue;
if ((p = (char *)strtok(NULL, " \t\n")) == NULL)
continue;
if (sscanf(p, "%lu ", &objectid) <= 0)
continue;
if ((p = (char *)strtok(NULL, " \t\n")) == NULL)
continue;
reiserfs_key_set_did (&key, dirid);
reiserfs_key_set_oid (&key, objectid);
n = 0; dirid = 0;
if (getdelim (&dirid, &n, ' ', stdin) == -1)
break;
if (!strcmp (dirid, "\n"))
break;
set_key_dirid (&key, atol (dirid));
p [strlen(p) - 1] = '\0';
n = 0; objectid = 0;
if (getdelim (&objectid, &n, ' ', stdin) == -1)
break;
set_key_objectid (&key, atol (objectid));
n = 0; name = 0;
if (getdelim (&name, &n, '\n', stdin) == -1)
break;
name [strlen (name) - 1] = 0;
reiserfs_warning (stdout, "looking for file \"%s\" in (%K) - ",
p, &key);
name, &key);
if (reiserfs_tree_scan_name (fs, &key, p, &path)) {
reiserfs_key_t fkey = {0, };
reiserfs_deh_t * deh;
if (reiserfs_locate_entry (fs, &key, name, &path)) {
struct key fkey = {0, };
struct reiserfs_de_head * deh;
reiserfs_warning (stdout, "name is found in block %lu (item %d, entry %d)\n",
REISERFS_PATH_LEAF (&path)->b_blocknr, REISERFS_PATH_LEAF_POS (&path),
get_bh (&path)->b_blocknr, get_item_pos (&path),
path.pos_in_item);
deh = reiserfs_deh (REISERFS_PATH_LEAF (&path), REISERFS_PATH_IH (&path)) + path.pos_in_item;
reiserfs_key_set_did (&fkey, reiserfs_deh_get_did (deh));
reiserfs_key_set_oid (&fkey, reiserfs_deh_get_obid (deh));
deh = B_I_DEH (get_bh (&path), get_ih (&path)) + path.pos_in_item;
set_key_dirid (&fkey, get_deh_dirid (deh));
set_key_objectid (&fkey, get_deh_objectid (deh));
reiserfs_tree_pathrelse (&path);
pathrelse (&path);
/* look for file and print its layout */
memset (&map, 0, sizeof (struct file_map));
locate_file (fs, &fkey);
flush_map (fs, &key, p, &fkey);
flush_map (fs, &key, name, &fkey);
} else {
reiserfs_warning (stdout, "name not found\n");
}
free (dirid);
free (objectid);
free (name);
}
}
#if 0
static void scan_for_key (reiserfs_bh_t * bh, reiserfs_key_t * key)
static void scan_for_key (struct buffer_head * bh, struct key * key)
{
int i, j, i_num;
reiserfs_ih_t * ih;
reiserfs_deh_t * deh;
struct item_head * ih;
struct reiserfs_de_head * deh;
int min_entry_size = 1;
int ih_entry_count = 0;
ih = reiserfs_ih_at (bh, 0);
i_num = reiserfs_leaf_estimate_items(bh);
ih = B_N_PITEM_HEAD (bh, 0);
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i ++, ih ++) {
if ((reiserfs_key_get_did(&ih->ih_key) == reiserfs_key_get_did(key) ||
reiserfs_key_get_did(key) == ~(__u32)0) &&
(reiserfs_key_get_oid(&ih->ih_key) == reiserfs_key_get_oid(key) ||
reiserfs_key_get_oid(key) == ~(__u32)0))
if ((get_key_dirid(&ih->ih_key) == get_key_dirid(key) ||
get_key_dirid(key) == ~(__u32)0) &&
(get_key_objectid(&ih->ih_key) == get_key_objectid(key) ||
get_key_objectid(key) == ~(__u32)0))
{
reiserfs_warning(log_to, "%d-th item of block %lu is item of file %K: %H\n",
i, bh->b_blocknr, key, ih);
}
if (!reiserfs_ih_dir (ih))
if (!is_direntry_ih (ih))
continue;
deh = reiserfs_deh (bh, ih);
deh = B_I_DEH (bh, ih);
if ( (reiserfs_ih_get_entries (ih) > (reiserfs_ih_get_len(ih) / (REISERFS_DEH_SIZE + min_entry_size))) ||
(reiserfs_ih_get_entries (ih) == 0))
ih_entry_count = reiserfs_ih_get_len(ih) / (REISERFS_DEH_SIZE + min_entry_size);
if ( (get_ih_entry_count (ih) > (get_ih_item_len(ih) / (DEH_SIZE + min_entry_size))) ||
(get_ih_entry_count (ih) == 0))
ih_entry_count = get_ih_item_len(ih) / (DEH_SIZE + min_entry_size);
else
ih_entry_count = reiserfs_ih_get_entries (ih);
ih_entry_count = get_ih_entry_count (ih);
for (j = 0; j < ih_entry_count; j ++, deh ++) {
if ((reiserfs_deh_get_did (deh) == reiserfs_key_get_did (key) || (int)reiserfs_key_get_did (key) == -1) &&
(reiserfs_deh_get_obid (deh) == reiserfs_key_get_oid (key) || (int)reiserfs_key_get_oid (key) == -1)) {
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_to, "dir item %d (%H) of block %lu has "
"entry (%d-th) %.*s pointing to %K\n",
i, ih, bh->b_blocknr, j,
reiserfs_direntry_name_len (ih, deh, j), reiserfs_deh_name (deh, j), key);
name_in_entry_length (ih, deh, j), name_in_entry (deh, j), key);
}
}
}
@@ -966,10 +957,11 @@ static void scan_for_key (reiserfs_bh_t * bh, reiserfs_key_t * key)
void do_scan (reiserfs_filsys_t * fs)
{
unsigned long i;
reiserfs_bh_t * bh;
struct buffer_head * bh;
int type;
char answer[256];
reiserfs_key_t key = {0, 0, };
char * answer = 0;
size_t n = 0;
struct key key = {0, 0, };
unsigned long done, total;
if (debug_mode (fs) == DO_LOOK_FOR_NAME) {
@@ -998,37 +990,35 @@ void do_scan (reiserfs_filsys_t * fs)
}
printf ("Looking for names matching %s\n", name_pattern (fs));
reiserfs_key_set_did (&key, 1);
set_key_dirid (&key, 1);
} else {
printf ("What key do you want to find: dirid?");
fgets(answer, sizeof(answer), stdin);
reiserfs_key_set_did (&key, atoi (answer));
getline (&answer, &n, stdin);
set_key_dirid (&key, atoi (answer));
printf ("objectid?");
fgets(answer, sizeof(answer), stdin);
reiserfs_key_set_oid (&key, atoi (answer));
getline (&answer, &n, stdin);
set_key_objectid (&key, atoi (answer));
reiserfs_warning (stderr, "looking for (%K)\n", &key);
}
if (debug_mode (fs) == DO_SCAN_FOR_NAME) {
done = 0;
for (i = 0; i < reiserfs_sb_get_blocks (fs->fs_ondisk_sb); i ++) {
for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
if (!reiserfs_bitmap_test_bit (input_bitmap (fs), i))
continue;
bh = reiserfs_buffer_read (fs->fs_dev, i, fs->fs_blocksize);
bh = bread (fs->fs_dev, i, fs->fs_blocksize);
if (!bh) {
printf ("could not read block %lu\n", i);
continue;
}
type = reiserfs_node_type (bh);
if (type == NT_LEAF || type == NT_IH_ARRAY)
type = who_is_this (bh->b_data, bh->b_size);
if (type == THE_LEAF || type == HAS_IH_ARRAY)
scan_for_name (bh);
else
reiserfs_bitmap_clear_bit (input_bitmap (fs), i);
reiserfs_buffer_close (bh);
if (!misc_test_bit(PRINT_QUIET, &data(fs)->options))
util_misc_progress (stderr, &done, total, 1, 0);
brelse (bh);
print_how_far (stderr, &done, total, 1, be_quiet (fs));
}
}
@@ -1043,42 +1033,40 @@ void do_scan (reiserfs_filsys_t * fs)
done = 0;
total = reiserfs_bitmap_ones (input_bitmap (fs));
printf ("%ld bits set in bitmap\n", total);
for (i = 0; i < reiserfs_sb_get_blocks (fs->fs_ondisk_sb); i ++) {
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 = reiserfs_buffer_read (fs->fs_dev, i, fs->fs_blocksize);
bh = bread (fs->fs_dev, i, fs->fs_blocksize);
if (!bh) {
printf ("could not read block %lu\n", i);
continue;
}
type = reiserfs_node_type (bh);
type = who_is_this (bh->b_data, bh->b_size);
switch (type) {
case NT_JDESC:
if (!reiserfs_key_get_did (&key))
case THE_JDESC:
if (!get_key_dirid (&key))
printf ("block %lu is journal descriptor\n", i);
break;
case NT_SUPER:
if (!reiserfs_key_get_did (&key))
case THE_SUPER:
if (!get_key_dirid (&key))
printf ("block %lu is reiserfs super block\n", i);
break;
case NT_INTERNAL:
if (!reiserfs_key_get_did (&key))
case THE_INTERNAL:
if (!get_key_dirid (&key))
printf ("block %lu is reiserfs internal node\n", i);
break;
case NT_LEAF:
case NT_IH_ARRAY:
case THE_LEAF:
case HAS_IH_ARRAY:
scan_items (bh, (debug_mode (fs) == DO_SCAN_FOR_NAME ? NULL : &key));
break;
default:
break;
}
reiserfs_buffer_close (bh);
if (!misc_test_bit(PRINT_QUIET, &data(fs)->options))
util_misc_progress (stderr, &done, total, 1, 0);
brelse (bh);
print_how_far (stderr, &done, total, 1, be_quiet (fs));
}
fprintf (stderr, "\nThere were %d items saved\n", saved_items);
+35 -43
View File
@@ -3,13 +3,7 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "debugreiserfs.h"
#include "util/misc.h"
#include <search.h>
#include <obstack.h>
@@ -45,7 +39,7 @@ void * items_tree;
static int comp_items_1 (const void * p1, const void * p2)
{
int retval;
reiserfs_ih_t * ih1, * ih2;
struct item_head * ih1, * ih2;
/*
if (*(int *)p1 != *(int *)p2)
@@ -53,22 +47,22 @@ static int comp_items_1 (const void * p1, const void * p2)
else
retval = 0;
*/
retval = reiserfs_key_comp (p1, p2);
/*retval = reiserfs_key_comp2 (p1, p2);*/
retval = comp_keys (p1, p2);
/*retval = comp_short_keys (p1, p2);*/
if (retval)
return retval;
ih1 = (reiserfs_ih_t *)p1;
ih2 = (reiserfs_ih_t *)p2;
ih1 = (struct item_head *)p1;
ih2 = (struct item_head *)p2;
if (reiserfs_ih_get_len (ih1) < reiserfs_ih_get_len (ih2))
if (get_ih_item_len (ih1) < get_ih_item_len (ih2))
return -1;
if (reiserfs_ih_get_len (ih1) > reiserfs_ih_get_len (ih2))
if (get_ih_item_len (ih1) > get_ih_item_len (ih2))
return 1;
if (reiserfs_ih_get_entries (ih1) < reiserfs_ih_get_entries (ih2))
if (get_ih_entry_count (ih1) < get_ih_entry_count (ih2))
return -1;
if (reiserfs_ih_get_entries (ih1) > reiserfs_ih_get_entries (ih2))
if (get_ih_entry_count (ih1) > get_ih_entry_count (ih2))
return 1;
return 0;
@@ -83,13 +77,13 @@ static void print_node (const void *nodep, VISIT value, int level)
if (value == leaf) {
for (i = 0; i < level; i ++)
reiserfs_warning (stdout, "\t");
reiserfs_warning (stdout, "%H\n", *(reiserfs_ih_t **)nodep);
reiserfs_warning (stdout, "%H\n", *(struct item_head **)nodep);
return;
}
if (value == postorder) {
for (i = 0; i < level; i ++)
reiserfs_warning (stdout, "\t");
reiserfs_warning (stdout, "%H\n", *(reiserfs_ih_t **)nodep);
reiserfs_warning (stdout, "%H\n", *(struct item_head **)nodep);
}
}
*/
@@ -100,7 +94,7 @@ static int is_unique_item (struct obstack * ostack, void ** tree, void * ih)
void * res;
void * key1;
key1 = obstack_copy (ostack, ih, REISERFS_IH_SIZE);
key1 = obstack_copy (ostack, ih, IH_SIZE);
res = tsearch (key1, tree, comp_items_1);
if (!res)
reiserfs_panic ("Too many keys found");
@@ -119,16 +113,16 @@ static int is_unique_item (struct obstack * ostack, void ** tree, void * ih)
}
static void stat1_the_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
static void stat1_the_leaf (reiserfs_filsys_t * fs, struct buffer_head * bh)
{
int i, i_num;
reiserfs_ih_t * ih;
struct item_head * ih;
int is_there_unique_item;
ih = reiserfs_ih_at (bh, 0);
ih = B_N_PITEM_HEAD (bh, 0);
is_there_unique_item = 0;
i_num = reiserfs_leaf_estimate_items(bh);
i_num = leaf_item_number_estimate(bh);
for (i = 0; i < i_num; i ++, ih ++) {
/* count all items */
fs_stat.all ++;
@@ -146,21 +140,21 @@ static void stat1_the_leaf (reiserfs_filsys_t * fs, reiserfs_bh_t * bh)
fs_stat.blocks_to_skip ++;
reiserfs_bitmap_clear_bit (input_bitmap (fs), bh->b_blocknr);
} else {
ih = reiserfs_ih_at (bh, 0);
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 < i_num; i ++, ih ++) {
fs_stat.items [reiserfs_key_get_type (&ih->ih_key)] ++;
fs_stat.items [get_type (&ih->ih_key)] ++;
}
}
}
/*
static void stat2_the_leaf (reiserfs_bh_t * bh)
static void stat2_the_leaf (struct buffer_head * bh)
{
int i;
reiserfs_ih_t * ih;
struct item_head * ih;
ih = reiserfs_ih_at (bh, 0);
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < node_item_number (bh); i ++, ih ++) {
}
@@ -171,7 +165,7 @@ void do_stat (reiserfs_filsys_t * fs)
{
unsigned long i;
unsigned long done, total;
reiserfs_bh_t * bh;
struct buffer_head * bh;
int type;
FILE * fp;
@@ -180,7 +174,7 @@ void do_stat (reiserfs_filsys_t * fs)
items_tree = 0;
/*
bh = reiserfs_buffer_read (fs->s_dev, 8211, fs->s_blocksize);
bh = bread (fs->s_dev, 8211, fs->s_blocksize);
stat1_the_leaf (fs, bh);
return;
@@ -189,27 +183,26 @@ void do_stat (reiserfs_filsys_t * fs)
/* pass 0 of stating */
total = reiserfs_bitmap_ones (input_bitmap (fs));
done = 0;
for (i = 0; i < reiserfs_sb_get_blocks (fs->fs_ondisk_sb); i ++) {
for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
if (!reiserfs_bitmap_test_bit (input_bitmap (fs), i))
continue;
if (!misc_test_bit(PRINT_QUIET, &data(fs)->options))
util_misc_progress (stderr, &done, total, 1, 0);
print_how_far (stderr, &done, total, 1, be_quiet (fs));
bh = reiserfs_buffer_read (fs->fs_dev, i, fs->fs_blocksize);
bh = bread (fs->fs_dev, i, fs->fs_blocksize);
if (!bh) {
printf ("could not read block %lu\n", i);
continue;
}
type = reiserfs_node_type (bh);
if (type != NT_LEAF && type != NT_IH_ARRAY) {
type = who_is_this (bh->b_data, bh->b_size);
if (type != THE_LEAF && type != HAS_IH_ARRAY) {
reiserfs_bitmap_clear_bit (input_bitmap (fs), i);
reiserfs_buffer_close (bh);
brelse (bh);
continue;
}
fs_stat.leaves ++;
stat1_the_leaf (fs, bh);
reiserfs_buffer_close (bh);
brelse (bh);
}
reiserfs_warning (stderr, "\nThere were found on the '%s' device:\n"
@@ -218,7 +211,7 @@ void do_stat (reiserfs_filsys_t * fs)
"\tblocks containing at least one unique item %lu\n"
"\tblocks which can be skipped %lu\n"
"\t\tstat data %lu\n"
"\t\textent %lu\n"
"\t\tindirect %lu\n"
"\t\tdirect %lu\n"
"\t\tdirectory items %lu\n"
"\tunique items %lu\n",
@@ -234,7 +227,7 @@ void do_stat (reiserfs_filsys_t * fs)
fs_stat.leaves - fs_stat.blocks_to_skip,
fs_stat.blocks_to_skip,
fs_stat.items [TYPE_STAT_DATA],
fs_stat.items [TYPE_EXTENT],
fs_stat.items [TYPE_INDIRECT],
fs_stat.items [TYPE_DIRECT],
fs_stat.items [TYPE_DIRENTRY],
fs_stat.unique_items);
@@ -264,14 +257,13 @@ void do_stat (reiserfs_filsys_t * fs)
reiserfs_warning (stderr, "Looking for blocks containing only keys not pointed by any of entries\n");
total = reiserfs_bitmap_ones (input_bitmap (fs));
done = 0;
for (i = 0; i < reiserfs_sb_get_blocks (fs->fs_ondisk_sb); i ++) {
for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
if (!reiserfs_bitmap_test_bit (input_bitmap (fs), i))
continue;
if (!misc_test_bit(PRINT_QUIET, &data(fs)->options))
util_misc_progress (stderr, &done, total, 1, 0);
print_how_far (stderr, &done, total, 1, be_quiet (fs));
bh = reiserfs_buffer_read (fs->fs_dev, i, fs->fs_blocksize);
bh = bread (fs->fs_dev, i, fs->fs_blocksize);
if (!bh) {
printf ("could not read block %lu\n", i);
continue;
+127 -148
View File
@@ -2,21 +2,12 @@
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "debugreiserfs.h"
#include "misc/unaligned.h"
#include "util/device.h"
#include "util/misc.h"
#include <sys/resource.h>
#include <fcntl.h>
#include <unistd.h>
#define print_usage_and_exit() misc_die ("Usage: %s [-v] [-b filename] device\n\
#define print_usage_and_exit() die ("Usage: %s [-v] [-b filename] device\n\
-v prints blocks number of every block unpacked\n\
-b filename saves bitmap of blocks unpacked to filename\n\
-j filename stores journal in the filename\n", argv[0]);
@@ -33,16 +24,16 @@ int verbose = 0;
int Default_journal = 1;
static void unpack_offset (struct packed_item * pi, reiserfs_ih_t * ih, int blocksize)
static void unpack_offset (struct packed_item * pi, struct item_head * ih, int blocksize)
{
if (get_pi_mask(pi) & OFFSET_BITS_64) {
__u64 v64;
if (reiserfs_ih_get_format (ih) != KEY_FORMAT_2)
misc_die ("unpack_offset: key format is not set or wrong");
if (get_ih_key_format (ih) != KEY_FORMAT_2)
die ("unpack_offset: key format is not set or wrong");
fread_le64 (&v64);
reiserfs_key_set_off (KEY_FORMAT_2, &ih->ih_key, v64);
set_offset (KEY_FORMAT_2, &ih->ih_key, v64);
return;
}
@@ -50,19 +41,18 @@ static void unpack_offset (struct packed_item * pi, reiserfs_ih_t * ih, int bloc
__u32 v32;
fread_le32 (&v32);
reiserfs_key_set_off (reiserfs_ih_get_format (ih), &ih->ih_key, v32);
set_offset (get_ih_key_format (ih), &ih->ih_key, v32);
return;
}
if ((get_pi_mask(pi) & DIR_ID) == 0 && (get_pi_mask(pi) & OBJECT_ID) == 0) {
/* offset was not sent, as it can be calculated looking at the
previous item */
if (reiserfs_ih_stat (ih - 1))
reiserfs_key_set_off (reiserfs_ih_get_format (ih), &ih->ih_key, 1);
if (reiserfs_ih_ext (ih - 1))
reiserfs_key_set_off(reiserfs_ih_get_format (ih), &ih->ih_key,
reiserfs_key_get_off (&(ih - 1)->ih_key)
+ reiserfs_leaf_ibytes (ih - 1, blocksize));
if (is_stat_data_ih (ih - 1))
set_offset (get_ih_key_format (ih), &ih->ih_key, 1);
if (is_indirect_ih (ih - 1))
set_offset (get_ih_key_format (ih), &ih->ih_key,
get_offset (&(ih - 1)->ih_key) + get_bytes_number (ih - 1, blocksize));
}
// offset is 0
@@ -70,10 +60,10 @@ static void unpack_offset (struct packed_item * pi, reiserfs_ih_t * ih, int bloc
}
static void unpack_type (struct packed_item * pi, reiserfs_ih_t * ih)
static void unpack_type (struct packed_item * pi, struct item_head * ih)
{
reiserfs_key_set_type (reiserfs_ih_get_format (ih), &ih->ih_key, get_pi_type(pi));
if (reiserfs_key_unkn (&ih->ih_key))
set_type (get_ih_key_format (ih), &ih->ih_key, get_pi_type(pi));
if (type_unknown (&ih->ih_key))
reiserfs_panic ("unpack_type: unknown type %d unpacked for %H\n",
get_pi_type(pi), ih);
}
@@ -89,69 +79,65 @@ static void unpack_type (struct packed_item * pi, reiserfs_ih_t * ih)
maybe gencounter (16)
maybe deh_state (16)
*/
static void unpack_direntry (struct packed_item * pi, reiserfs_bh_t * bh,
reiserfs_ih_t * ih, hashf_t hash_func)
static void unpack_direntry (struct packed_item * pi, struct buffer_head * bh,
struct item_head * ih, hashf_t hash_func)
{
__u16 entry_count, namelen, gen_counter, entry_len;
__u8 mask;
int i;
reiserfs_deh_t * deh;
struct reiserfs_de_head * deh;
int location;
char * item;
/* if (!hash_func)
misc_die ("unpack_direntry: hash function is not set");*/
die ("unpack_direntry: hash function is not set");*/
if (!(get_pi_mask(pi) & IH_FREE_SPACE))
misc_die ("ih_entry_count must be packed for directory items");
die ("ih_entry_count must be packed for directory items");
entry_count = reiserfs_ih_get_entries (ih);
entry_count = get_ih_entry_count (ih);
/* if (!entry_count)
reiserfs_panic ("unpack_direntry: entry count should be set already");*/
item = bh->b_data + reiserfs_ih_get_loc (ih);
deh = (reiserfs_deh_t *)item;
item = bh->b_data + get_ih_location (ih);
deh = (struct reiserfs_de_head *)item;
location = get_pi_item_len(pi);
for (i = 0; i < entry_count; i ++, deh ++) {
fread8 (&mask);
fread_le16 (&entry_len);
location -= entry_len;
reiserfs_deh_set_loc (deh, location);
set_deh_location (deh, location);
fread (item + location, entry_len, 1, stdin);
/* find name length */
namelen = strlen (item + location);
if (namelen > entry_len)
if (*(item + location + entry_len - 1))
namelen = entry_len;
else
namelen = strlen (item + location);
fread32 (&deh->deh2_objectid);
if (mask & HAS_DIR_ID)
fread32 (&deh->deh2_dir_id);
else
reiserfs_deh_set_did (deh, reiserfs_key_get_oid (&ih->ih_key));
set_deh_dirid (deh, get_key_objectid (&ih->ih_key));
if (*(item + location) == '.' && namelen == 1) {
if (*(item + location) == '.' && namelen == 1)
/* old or new "." */
reiserfs_deh_set_off (deh, OFFSET_DOT);
} else if (*(item + location) == '.' &&
*(item + location + 1) == '.' && namelen == 2)
{
set_deh_offset (deh, DOT_OFFSET);
else if (*(item + location) == '.' && *(item + location + 1) == '.' && namelen == 2)
/* old or new ".." */
reiserfs_deh_set_off (deh, OFFSET_DOT_DOT);
} else if (hash_func) {
reiserfs_deh_set_off (deh, reiserfs_hash_value(hash_func,
item + location, namelen));
}
set_deh_offset (deh, DOT_DOT_OFFSET);
else if (hash_func)
set_deh_offset (deh, hash_value(hash_func, item + location, namelen));
if (mask & HAS_GEN_COUNTER) {
fread_le16 (&gen_counter);
reiserfs_deh_set_off (deh, reiserfs_deh_get_off (deh) | gen_counter);
set_deh_offset (deh, get_deh_offset (deh) | gen_counter);
}
if (mask & HAS_STATE)
fread16 (&deh->deh2_state);
else
reiserfs_deh_set_state (deh, (1 << DEH_Visible2));
set_deh_state (deh, (1 << DEH_Visible2));
}
return;
@@ -159,15 +145,15 @@ static void unpack_direntry (struct packed_item * pi, reiserfs_bh_t * bh,
/* struct packed_item is already unpacked */
static void unpack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
reiserfs_ih_t * ih)
static void unpack_stat_data (struct packed_item * pi, struct buffer_head * bh,
struct item_head * ih)
{
if (!(get_pi_mask(pi) & IH_FREE_SPACE)) {
/* ih_free_space was not packed - set default */
reiserfs_ih_set_entries (ih, 0xffff);
set_ih_entry_count (ih, 0xffff);
}
if (reiserfs_ih_get_format (ih) == KEY_FORMAT_1) {
if (get_ih_key_format (ih) == KEY_FORMAT_1) {
/* stat data comes in the following format:
if this is old stat data:
mode - 16 bits
@@ -176,9 +162,9 @@ static void unpack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
blocks/rdev - 32 bits
maybe first_direct byte 32 bits
*/
reiserfs_sd_v1_t * sd;
struct stat_data_v1 * sd;
sd = (reiserfs_sd_v1_t *)reiserfs_item_by_ih (bh, ih);
sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih);
memset (sd, 0, sizeof (sd));
fread16 (&sd->sd_mode);
@@ -187,9 +173,9 @@ static void unpack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
fread32 (&sd->u.sd_blocks);
if (get_pi_mask(pi) & WITH_SD_FIRST_DIRECT_BYTE) {
fread32 (&sd->sd_fdb);
fread32 (&sd->sd_first_direct_byte);
} else {
sd->sd_fdb = 0xffffffff;
sd->sd_first_direct_byte = 0xffffffff;
}
} else {
/* for new stat data
@@ -198,9 +184,9 @@ static void unpack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
size in either 32 or 64 bits
blocks - 32 bits
*/
reiserfs_sd_t * sd;
struct stat_data * sd;
sd = (reiserfs_sd_t *)reiserfs_item_by_ih (bh, ih);
sd = (struct stat_data *)B_I_PITEM (bh, ih);
memset (sd, 0, sizeof (sd));
fread16 (&sd->sd_mode);
@@ -211,7 +197,7 @@ static void unpack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
__u16 nlink16;
fread16 (&nlink16);
reiserfs_set_sd_v2_nlink (sd, le16_to_cpu(nlink16));
set_sd_v2_nlink (sd, le16_to_cpu(nlink16));
}
if (get_pi_mask(pi) & SIZE_BITS_64) {
@@ -221,7 +207,7 @@ static void unpack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
/* We need the endian conversions since sd->sd_size is 64 bit */
fread_le32 (&size32);
reiserfs_set_sd_v2_size (sd, size32 );
set_sd_v2_size (sd, size32 );
}
fread32 (&sd->sd_blocks);
@@ -231,10 +217,10 @@ static void unpack_stat_data (struct packed_item * pi, reiserfs_bh_t * bh,
}
/* extent item comes either in packed form or as is. ih_free_space
/* indirect item comes either in packed form or as is. ih_free_space
can go first */
static void unpack_extent (struct packed_item * pi, reiserfs_bh_t * bh,
reiserfs_ih_t * ih)
static void unpack_indirect (struct packed_item * pi, struct buffer_head * bh,
struct item_head * ih)
{
__u32 * ind_item, * end;
int i;
@@ -242,23 +228,23 @@ static void unpack_extent (struct packed_item * pi, reiserfs_bh_t * bh,
if (!(get_pi_mask(pi) & IH_FREE_SPACE)) {
/* ih_free_space was not packed - set default */
reiserfs_ih_set_entries (ih, 0);
set_ih_entry_count (ih, 0);
}
ind_item = (__u32 *)reiserfs_item_by_ih (bh, ih);
ind_item = (__u32 *)B_I_PITEM (bh, ih);
if (get_pi_mask(pi) & SAFE_LINK) {
d32_put(ind_item, 0, reiserfs_key_get_did(&ih->ih_key));
reiserfs_key_set_did(&ih->ih_key, (__u32)-1);
d32_put(ind_item, 0, get_key_dirid(&ih->ih_key));
set_key_dirid(&ih->ih_key, (__u32)-1);
return;
}
if (get_pi_mask(pi) & WHOLE_EXTENT) {
if (get_pi_mask(pi) & WHOLE_INDIRECT) {
fread (ind_item, get_pi_item_len(pi), 1, stdin);
return;
}
end = ind_item + reiserfs_ext_count (ih);
end = ind_item + I_UNFM_NUM (ih);
while (ind_item < end) {
__u32 base;
fread32 (ind_item);
@@ -277,18 +263,18 @@ static void unpack_extent (struct packed_item * pi, reiserfs_bh_t * bh,
// FIXME: we have no way to preserve symlinks
static void unpack_direct (struct packed_item * pi, reiserfs_bh_t * bh,
reiserfs_ih_t * ih)
static void unpack_direct (struct packed_item * pi, struct buffer_head * bh,
struct item_head * ih)
{
__u32 * d_item = (__u32 *)reiserfs_item_by_ih (bh, ih);
__u32 * d_item = (__u32 *)B_I_PITEM (bh, ih);
if (!(get_pi_mask(pi) & IH_FREE_SPACE))
/* ih_free_space was not packed - set default */
reiserfs_ih_set_entries (ih, 0xffff);
set_ih_entry_count (ih, 0xffff);
if (get_pi_mask(pi) & SAFE_LINK) {
d32_put(d_item, 0, reiserfs_key_get_did(&ih->ih_key));
reiserfs_key_set_did(&ih->ih_key, (__u32)-1);
d32_put(d_item, 0, get_key_dirid(&ih->ih_key));
set_key_dirid(&ih->ih_key, (__u32)-1);
} else {
memset (d_item, 'a', get_pi_item_len(pi));
}
@@ -299,9 +285,9 @@ static void unpack_direct (struct packed_item * pi, reiserfs_bh_t * bh,
static void unpack_leaf (int dev, hashf_t hash_func, __u16 blocksize)
{
static int unpacked_leaves = 0;
reiserfs_bh_t * bh;
struct buffer_head * bh;
struct packed_item pi;
reiserfs_ih_t * ih;
struct item_head * ih;
int i;
__u16 v16;
__u32 v32;
@@ -316,20 +302,21 @@ static void unpack_leaf (int dev, hashf_t hash_func, __u16 blocksize)
if (verbose)
reiserfs_warning (stderr, "leaf %d: %d items\n", v32, v16);
bh = reiserfs_buffer_open (dev, v32, blocksize);
bh = getblk (dev, v32, blocksize);
if (!bh)
misc_die ("unpack_leaf: reiserfs_buffer_open failed");
die ("unpack_leaf: getblk failed");
reiserfs_nh_set_items (NODE_HEAD (bh), v16);
reiserfs_nh_set_level (NODE_HEAD (bh), LEAF_LEVEL);
reiserfs_nh_set_free (NODE_HEAD (bh), REISERFS_NODE_SPACE (bh->b_size));
set_blkh_nr_items (B_BLK_HEAD (bh), v16);
set_blkh_level (B_BLK_HEAD (bh), DISK_LEAF_NODE_LEVEL);
set_blkh_free_space (B_BLK_HEAD (bh), MAX_FREE_SPACE (bh->b_size));
ih = reiserfs_ih_at (bh, 0);
for (i = 0; i < reiserfs_nh_get_items (NODE_HEAD (bh)); i ++, ih ++) {
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < get_blkh_nr_items (B_BLK_HEAD (bh)); i ++, ih ++) {
#if 0
fread32 (&v32);
if (v32 != ITEM_START_MAGIC)
misc_die ("unpack_leaf: no start item magic found: block %lu, item %i",
die ("unpack_leaf: no start item magic found: block %lu, item %i",
bh->b_blocknr, i);
#endif
@@ -338,25 +325,25 @@ static void unpack_leaf (int dev, hashf_t hash_func, __u16 blocksize)
/* dir_id - if it is there */
if (get_pi_mask(&pi) & DIR_ID) {
fread32 (&v32);
reiserfs_key_set_did (&ih->ih_key, le32_to_cpu(v32));
set_key_dirid (&ih->ih_key, le32_to_cpu(v32));
} else {
if (!i)
misc_die ("unpack_leaf: dir_id is not set");
reiserfs_key_set_did (&ih->ih_key, reiserfs_key_get_did (&(ih - 1)->ih_key));
die ("unpack_leaf: dir_id is not set");
set_key_dirid (&ih->ih_key, get_key_dirid (&(ih - 1)->ih_key));
}
/* object_id - if it is there */
if (get_pi_mask(&pi) & OBJECT_ID) {
fread32 (&v32);
reiserfs_key_set_oid (&ih->ih_key, le32_to_cpu(v32));
set_key_objectid (&ih->ih_key, le32_to_cpu(v32));
} else {
if (!i)
misc_die ("unpack_leaf: object_id is not set");
reiserfs_key_set_oid (&ih->ih_key, reiserfs_key_get_oid (&(ih - 1)->ih_key));
die ("unpack_leaf: object_id is not set");
set_key_objectid (&ih->ih_key, get_key_objectid (&(ih - 1)->ih_key));
}
// we need to set item format before offset unpacking
reiserfs_ih_set_format (ih, (get_pi_mask(&pi) & NEW_FORMAT) ? KEY_FORMAT_2 : KEY_FORMAT_1);
set_ih_key_format (ih, (get_pi_mask(&pi) & NEW_FORMAT) ? KEY_FORMAT_2 : KEY_FORMAT_1);
// offset
unpack_offset (&pi, ih, bh->b_size);
@@ -367,33 +354,33 @@ static void unpack_leaf (int dev, hashf_t hash_func, __u16 blocksize)
/* ih_free_space and ih_format */
if (get_pi_mask(&pi) & IH_FREE_SPACE) {
fread16 (&v16);
reiserfs_ih_set_entries (ih, le16_to_cpu(v16));
set_ih_entry_count (ih, le16_to_cpu(v16));
}
if (get_pi_mask(&pi) & IH_FORMAT)
fread16 (&ih->ih_format);
/* item length and item location */
reiserfs_ih_set_len (ih, get_pi_item_len(&pi));
reiserfs_ih_set_loc (ih, (i ? reiserfs_ih_get_loc (ih - 1) : bh->b_size) - get_pi_item_len(&pi));
set_ih_item_len (ih, get_pi_item_len(&pi));
set_ih_location (ih, (i ? get_ih_location (ih - 1) : bh->b_size) - get_pi_item_len(&pi));
// item itself
if (reiserfs_ih_direct (ih)) {
if (is_direct_ih (ih)) {
unpack_direct (&pi, bh, ih);
} else if (reiserfs_ih_ext (ih)) {
unpack_extent (&pi, bh, ih);
} else if (reiserfs_ih_dir (ih)) {
} else if (is_indirect_ih (ih)) {
unpack_indirect (&pi, bh, ih);
} else if (is_direntry_ih (ih)) {
unpack_direntry (&pi, bh, ih, hash_func);
} else if (reiserfs_ih_stat (ih)) {
} else if (is_stat_data_ih (ih)) {
unpack_stat_data (&pi, bh, ih);
}
reiserfs_nh_set_free (NODE_HEAD (bh), reiserfs_nh_get_free (NODE_HEAD (bh)) -
(REISERFS_IH_SIZE + reiserfs_ih_get_len (ih)));
set_blkh_free_space (B_BLK_HEAD (bh), get_blkh_free_space (B_BLK_HEAD (bh)) -
(IH_SIZE + get_ih_item_len (ih)));
#if 0
fread32 (&v32);
if (v32 != ITEM_END_MAGIC)
misc_die ("unpack_leaf: no end item magic found: block %lu, item %i",
die ("unpack_leaf: no end item magic found: block %lu, item %i",
bh->b_blocknr, i);
if (verbose)
reiserfs_warning (stderr, "%d: %H\n", i, ih);
@@ -402,17 +389,17 @@ static void unpack_leaf (int dev, hashf_t hash_func, __u16 blocksize)
fread_le16 (&v16);
if (v16 != LEAF_END_MAGIC)
misc_die ("unpack_leaf: wrong end signature found - %x, block %lu",
die ("unpack_leaf: wrong end signature found - %x, block %lu",
v16, bh->b_blocknr);
reiserfs_buffer_mkuptodate (bh, 1);
reiserfs_buffer_mkdirty (bh);
reiserfs_buffer_write (bh);
mark_buffer_uptodate (bh, 1);
mark_buffer_dirty (bh);
bwrite (bh);
/*
if (reiserfs_fs_block(fs, bh->b_blocknr) == BT_UNKNOWN)
if (!not_data_block (bh->b_blocknr))
data_blocks_unpacked ++;
*/
reiserfs_buffer_close (bh);
brelse (bh);
if (what_unpacked)
reiserfs_bitmap_set_bit (what_unpacked, bh->b_blocknr);
@@ -427,43 +414,43 @@ static void unpack_full_block (int dev, int blocksize)
{
static int full_blocks_unpacked = 0;
__u32 block;
reiserfs_bh_t * bh;
struct buffer_head * bh;
fread_le32 (&block);
if (verbose)
fprintf (stderr, "full #%d\n", block);
bh = reiserfs_buffer_open (dev, block, blocksize);
bh = getblk (dev, block, blocksize);
if (!bh)
misc_die ("unpack_full_block: reiserfs_buffer_open failed");
die ("unpack_full_block: getblk failed");
fread (bh->b_data, bh->b_size, 1, stdin);
if (reiserfs_node_type (bh) == NT_SUPER && !what_unpacked) {
if (who_is_this (bh->b_data, bh->b_size) == THE_SUPER && !what_unpacked) {
unsigned long blocks;
reiserfs_bh_t * tmp;
struct buffer_head * tmp;
blocks = reiserfs_sb_get_blocks ((reiserfs_sb_t *)(bh->b_data));
blocks = get_sb_block_count ((struct reiserfs_super_block *)(bh->b_data));
fprintf (stderr, "There were %lu blocks on the device\n", blocks);
what_unpacked = reiserfs_bitmap_create (blocks);
what_unpacked = reiserfs_create_bitmap (blocks);
/* make file as long as filesystem is */
tmp = reiserfs_buffer_open (dev, blocks - 1, blocksize);
reiserfs_buffer_mkdirty (tmp);
reiserfs_buffer_mkuptodate (tmp, 0);
reiserfs_buffer_write (tmp);
reiserfs_buffer_close (tmp);
tmp = getblk (dev, blocks - 1, blocksize);
mark_buffer_dirty (tmp);
mark_buffer_uptodate (tmp, 0);
bwrite (tmp);
brelse (tmp);
}
reiserfs_buffer_mkuptodate (bh, 1);
reiserfs_buffer_mkdirty (bh);
reiserfs_buffer_write (bh);
mark_buffer_uptodate (bh, 1);
mark_buffer_dirty (bh);
bwrite (bh);
/*
if (reiserfs_fs_block(fs, bh->b_blocknr) == BT_UNKNOWN)
if (!not_data_block (bh->b_blocknr))
data_blocks_unpacked ++;
*/
reiserfs_buffer_close (bh);
brelse (bh);
if (what_unpacked)
reiserfs_bitmap_set_bit (what_unpacked, block);
@@ -509,7 +496,7 @@ void unpack_partition (int fd, int jfd)
fread_le32 (&magic32);
if (magic32 != REISERFS_SUPER_MAGIC)
misc_die ("unpack_partition: reiserfs magic number (0x%x) not found - %x\n",
die ("unpack_partition: reiserfs magic number (0x%x) not found - %x\n",
REISERFS_SUPER_MAGIC, magic32);
fread_le16 (&blocksize);
@@ -538,7 +525,7 @@ void unpack_partition (int fd, int jfd)
fread (c + 1, 1, 1, stdin); /* read % */
if (c[0] != '0' || c[1] != '%')
misc_die ("0%% expected\n");
die ("0%% expected\n");
if (verbose)
fprintf (stderr, "0%% skipped\n");
@@ -552,12 +539,12 @@ void unpack_partition (int fd, int jfd)
switch (magic16 & 0xff) {
case LEAF_START_MAGIC:
leaves ++;
unpack_leaf (dev, reiserfs_hash_func (magic16 >> 8), blocksize);
unpack_leaf (dev, code2func (magic16 >> 8), blocksize);
break;
case SEPARATED_JOURNAL_START_MAGIC:
if (Default_journal)
misc_die ("file name for separated journal has to be specified");
die ("file name for separated journal has to be specified");
dev = jfd;
break;
@@ -581,9 +568,9 @@ void unpack_partition (int fd, int jfd)
default:
position = ftell(stdin);
if (position == ~(long)0)
misc_die ("unpack_partition: bad magic found - %x", magic16 & 0xff);
die ("unpack_partition: bad magic found - %x", magic16 & 0xff);
else
misc_die ("unpack_partition: bad magic found - %x, position %lu",
die ("unpack_partition: bad magic found - %x, position %lu",
magic16 & 0xff, ftell(stdin));
}
}
@@ -610,27 +597,19 @@ int do_unpack(char *host, char *j_filename, char *filename, int verbose) {
fprintf (stderr, "sertlimit failed: %m\n");
}
if (util_device_mounted(host) > 0) {
if (misc_device_mounted(host) > 0) {
fprintf(stderr, "%s seems mounted, umount it first\n", host);
return 0;
}
fd = open (host, O_RDWR
#ifdef O_LARGEFILE
| O_LARGEFILE
#endif
);
fd = open (host, O_RDWR | O_LARGEFILE);
if (fd == -1) {
perror ("open failed");
return 0;
}
if (!Default_journal) {
fdj = open (j_filename, O_RDWR
#ifdef O_LARGEFILE
| O_LARGEFILE
#endif
);
fdj = open (j_filename, O_RDWR | O_LARGEFILE);
if (fdj == -1) {
perror ("open failed");
return 0;
@@ -640,9 +619,9 @@ int do_unpack(char *host, char *j_filename, char *filename, int verbose) {
unpack_partition (fd, fdj);
if (what_unpacked && filename) {
FILE * file = util_file_open(filename, "w+");
FILE * file = open_file(filename, "w+");
reiserfs_bitmap_save (file, what_unpacked);
fclose (file);
close_file(file);
}
close (fd);
+34 -91
View File
@@ -1,9 +1,7 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2005-02-09.22
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# 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
@@ -27,45 +25,22 @@ scriptversion=2005-02-09.22
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
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
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
@@ -197,25 +172,19 @@ sgi)
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, 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.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
# 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 -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
@@ -223,7 +192,6 @@ aix)
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# 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:'.
@@ -287,47 +255,31 @@ tru64)
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mecanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
tmpdepfile1="$dir.libs/$base.lo.d"
tmpdepfile2="$dir.libs/$base.d"
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
tmpdepfile1="$dir$base.o.d"
tmpdepfile2="$dir$base.d"
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
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 tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$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
@@ -340,7 +292,7 @@ tru64)
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
# always write the proprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
@@ -436,7 +388,7 @@ makedepend)
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
# always write the proprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
@@ -478,7 +430,7 @@ cpp)
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
@@ -518,12 +470,3 @@ none)
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
+11
View File
@@ -0,0 +1,11 @@
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
man_MANS = reiserfsck.8
EXTRA_DIST = $(man_MANS)
reiserfsck_LDADD = $(top_srcdir)/reiserfscore/libcore.a $(top_srcdir)/lib/libmisc.a
+102 -137
View File
@@ -1,8 +1,8 @@
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006 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.
@@ -14,17 +14,11 @@
@SET_MAKE@
SOURCES = $(resizefs_reiserfs_SOURCES)
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
@@ -38,36 +32,37 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
sbin_PROGRAMS = resizefs.reiserfs$(EXEEXT)
subdir = utils/resizer
sbin_PROGRAMS = reiserfsck$(EXEEXT)
subdir = fsck
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"
sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(sbin_PROGRAMS)
am_resizefs_reiserfs_OBJECTS = resizefs_reiserfs-fe.$(OBJEXT) \
resizefs_reiserfs-resize_reiserfs.$(OBJEXT) \
resizefs_reiserfs-do_shrink.$(OBJEXT)
resizefs_reiserfs_OBJECTS = $(am_resizefs_reiserfs_OBJECTS)
resizefs_reiserfs_DEPENDENCIES = \
$(top_builddir)/libreiserfs/libreiserfs-static.a \
$(top_builddir)/libutil/libutil-static.a \
$(top_builddir)/libmisc/libmisc-static.a
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
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_DEPENDENCIES = $(top_srcdir)/reiserfscore/libcore.a \
$(top_srcdir)/lib/libmisc.a
DEFAULT_INCLUDES = -I. -I$(top_builddir)/include@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(resizefs_reiserfs_SOURCES)
DIST_SOURCES = $(resizefs_reiserfs_SOURCES)
SOURCES = $(reiserfsck_SOURCES)
DIST_SOURCES = $(reiserfsck_SOURCES)
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
@@ -75,8 +70,6 @@ ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -95,6 +88,8 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -105,9 +100,8 @@ LIBS = @LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -116,18 +110,17 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PROGS_LDFLAGS = @PROGS_LDFLAGS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
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__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -139,38 +132,46 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
man_MANS = resizefs.reiserfs.8
EXTRA_DIST = resizefs.reiserfs.8
resizefs_reiserfs_SOURCES = fe.c resize_reiserfs.c do_shrink.c resize.h
resizefs_reiserfs_LDADD = $(top_builddir)/libreiserfs/libreiserfs-static.a \
$(top_builddir)/libutil/libutil-static.a \
$(top_builddir)/libmisc/libmisc-static.a
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
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
resizefs_reiserfs_LDFLAGS = @PROGS_LDFLAGS@
resizefs_reiserfs_CFLAGS = @CFLAGS@
INCLUDES = -I$(top_srcdir)/include
man_MANS = reiserfsck.8
EXTRA_DIST = $(man_MANS)
reiserfsck_LDADD = $(top_srcdir)/reiserfscore/libcore.a $(top_srcdir)/lib/libmisc.a
all: all-am
.SUFFIXES:
@@ -184,9 +185,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu utils/resizer/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu fsck/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu utils/resizer/Makefile
$(AUTOMAKE) --gnu fsck/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -206,7 +207,7 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(sbindir)" || $(mkdir_p) "$(DESTDIR)$(sbindir)"
test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
@list='$(sbin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
@@ -227,9 +228,9 @@ uninstall-sbinPROGRAMS:
clean-sbinPROGRAMS:
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
resizefs.reiserfs$(EXEEXT): $(resizefs_reiserfs_OBJECTS) $(resizefs_reiserfs_DEPENDENCIES)
@rm -f resizefs.reiserfs$(EXEEXT)
$(LINK) $(resizefs_reiserfs_LDFLAGS) $(resizefs_reiserfs_OBJECTS) $(resizefs_reiserfs_LDADD) $(LIBS)
reiserfsck$(EXEEXT): $(reiserfsck_OBJECTS) $(reiserfsck_DEPENDENCIES)
@rm -f reiserfsck$(EXEEXT)
$(LINK) $(reiserfsck_OBJECTS) $(reiserfsck_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -237,69 +238,38 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resizefs_reiserfs-do_shrink.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resizefs_reiserfs-fe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Po@am__quote@
@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@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
resizefs_reiserfs-fe.o: fe.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -MT resizefs_reiserfs-fe.o -MD -MP -MF "$(DEPDIR)/resizefs_reiserfs-fe.Tpo" -c -o resizefs_reiserfs-fe.o `test -f 'fe.c' || echo '$(srcdir)/'`fe.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/resizefs_reiserfs-fe.Tpo" "$(DEPDIR)/resizefs_reiserfs-fe.Po"; else rm -f "$(DEPDIR)/resizefs_reiserfs-fe.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fe.c' object='resizefs_reiserfs-fe.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -c -o resizefs_reiserfs-fe.o `test -f 'fe.c' || echo '$(srcdir)/'`fe.c
resizefs_reiserfs-fe.obj: fe.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -MT resizefs_reiserfs-fe.obj -MD -MP -MF "$(DEPDIR)/resizefs_reiserfs-fe.Tpo" -c -o resizefs_reiserfs-fe.obj `if test -f 'fe.c'; then $(CYGPATH_W) 'fe.c'; else $(CYGPATH_W) '$(srcdir)/fe.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/resizefs_reiserfs-fe.Tpo" "$(DEPDIR)/resizefs_reiserfs-fe.Po"; else rm -f "$(DEPDIR)/resizefs_reiserfs-fe.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fe.c' object='resizefs_reiserfs-fe.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -c -o resizefs_reiserfs-fe.obj `if test -f 'fe.c'; then $(CYGPATH_W) 'fe.c'; else $(CYGPATH_W) '$(srcdir)/fe.c'; fi`
resizefs_reiserfs-resize_reiserfs.o: resize_reiserfs.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -MT resizefs_reiserfs-resize_reiserfs.o -MD -MP -MF "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Tpo" -c -o resizefs_reiserfs-resize_reiserfs.o `test -f 'resize_reiserfs.c' || echo '$(srcdir)/'`resize_reiserfs.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Tpo" "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Po"; else rm -f "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='resize_reiserfs.c' object='resizefs_reiserfs-resize_reiserfs.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -c -o resizefs_reiserfs-resize_reiserfs.o `test -f 'resize_reiserfs.c' || echo '$(srcdir)/'`resize_reiserfs.c
resizefs_reiserfs-resize_reiserfs.obj: resize_reiserfs.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -MT resizefs_reiserfs-resize_reiserfs.obj -MD -MP -MF "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Tpo" -c -o resizefs_reiserfs-resize_reiserfs.obj `if test -f 'resize_reiserfs.c'; then $(CYGPATH_W) 'resize_reiserfs.c'; else $(CYGPATH_W) '$(srcdir)/resize_reiserfs.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Tpo" "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Po"; else rm -f "$(DEPDIR)/resizefs_reiserfs-resize_reiserfs.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='resize_reiserfs.c' object='resizefs_reiserfs-resize_reiserfs.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -c -o resizefs_reiserfs-resize_reiserfs.obj `if test -f 'resize_reiserfs.c'; then $(CYGPATH_W) 'resize_reiserfs.c'; else $(CYGPATH_W) '$(srcdir)/resize_reiserfs.c'; fi`
resizefs_reiserfs-do_shrink.o: do_shrink.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -MT resizefs_reiserfs-do_shrink.o -MD -MP -MF "$(DEPDIR)/resizefs_reiserfs-do_shrink.Tpo" -c -o resizefs_reiserfs-do_shrink.o `test -f 'do_shrink.c' || echo '$(srcdir)/'`do_shrink.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/resizefs_reiserfs-do_shrink.Tpo" "$(DEPDIR)/resizefs_reiserfs-do_shrink.Po"; else rm -f "$(DEPDIR)/resizefs_reiserfs-do_shrink.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='do_shrink.c' object='resizefs_reiserfs-do_shrink.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -c -o resizefs_reiserfs-do_shrink.o `test -f 'do_shrink.c' || echo '$(srcdir)/'`do_shrink.c
resizefs_reiserfs-do_shrink.obj: do_shrink.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -MT resizefs_reiserfs-do_shrink.obj -MD -MP -MF "$(DEPDIR)/resizefs_reiserfs-do_shrink.Tpo" -c -o resizefs_reiserfs-do_shrink.obj `if test -f 'do_shrink.c'; then $(CYGPATH_W) 'do_shrink.c'; else $(CYGPATH_W) '$(srcdir)/do_shrink.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/resizefs_reiserfs-do_shrink.Tpo" "$(DEPDIR)/resizefs_reiserfs-do_shrink.Po"; else rm -f "$(DEPDIR)/resizefs_reiserfs-do_shrink.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='do_shrink.c' object='resizefs_reiserfs-do_shrink.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(resizefs_reiserfs_CFLAGS) $(CFLAGS) -c -o resizefs_reiserfs-do_shrink.obj `if test -f 'do_shrink.c'; then $(CYGPATH_W) 'do_shrink.c'; else $(CYGPATH_W) '$(srcdir)/do_shrink.c'; fi`
uninstall-info-am:
install-man8: $(man8_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man8dir)" || $(mkdir_p) "$(DESTDIR)$(man8dir)"
test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)"
@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
@@ -392,22 +362,21 @@ distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
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; \
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
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"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
@@ -423,7 +392,7 @@ check: check-am
all-am: Makefile $(PROGRAMS) $(MANS)
installdirs:
for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
@@ -469,14 +438,22 @@ info: info-am
info-am:
install-data-am: install-data-local install-man
install-data-am: install-man
install-dvi: install-dvi-am
install-exec-am: install-sbinPROGRAMS
install-html: install-html-am
install-info: install-info-am
install-man: install-man8
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
@@ -496,38 +473,26 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-local uninstall-man \
uninstall-sbinPROGRAMS
uninstall-am: uninstall-man uninstall-sbinPROGRAMS
uninstall-man: uninstall-man8
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-sbinPROGRAMS ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-data-local 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-local uninstall-man \
uninstall-man8 uninstall-sbinPROGRAMS
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-man8 install-pdf \
install-pdf-am install-ps install-ps-am 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-man uninstall-man8 \
uninstall-sbinPROGRAMS
uninstall-resize_reiserfs:
if test -f $(DESTDIR)$(sbindir)/resize_reiserfs; then \
rm -f $(DESTDIR)$(sbindir)/resize_reiserfs; \
fi;
install-resize_reiserfs:
if test -f $(DESTDIR)$(sbindir)/resizefs.reiserfs; then \
rm -f $(DESTDIR)$(sbindir)/resize_reiserfs; \
ln $(DESTDIR)$(sbindir)/resizefs.reiserfs $(DESTDIR)$(sbindir)/resize_reiserfs; \
fi;
install-data-local: install-resize_reiserfs
uninstall-local: uninstall-resize_reiserfs
# 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:
+1178
View File
File diff suppressed because it is too large. Load diff
+204 -249
View File
@@ -3,10 +3,11 @@
* reiserfsprogs/README
*/
#include "reiserfs/libreiserfs.h"
#include <stdio.h>
#define _GNU_SOURCE
#if 0
#ifndef HAVE_CONFIG_H
# include "config.h"
#endif
#include "io.h"
#include "misc.h"
@@ -18,10 +19,10 @@
#include <assert.h>
#include "../version.h"
#endif
/* main.c */
extern reiserfs_filsys_t * fs;
int main (int argc, char * argv []);
/* Exit codes. */
#define EXIT_OK 0
@@ -61,104 +62,93 @@ extern reiserfs_filsys_t * fs;
#define OPT_SAVE_PASSES_DUMP 1 << 7
#define OPT_SAVE_ROLLBACK 1 << 8
#define OPT_YES 1 << 9
#define BADBLOCKS_FILE 1 << 10
#define BADBLOCKS_FILE 1 << 10
#define OPT_FORCE 1 << 11
/* set by fsck when pass-by-pass (-d), FS_FATAL flag included */
enum fsck_state_flags {
PASS_0_DONE = 0xfa02,
PASS_1_DONE = 0xfb02,
TREE_IS_BUILT = 0xfc02,
SEMANTIC_DONE = 0xfd02,
LOST_FOUND_DONE = 0xfe02
};
/* Stage.c */
extern void fsck_stage_start_put (FILE * file, unsigned long stage);
extern void fsck_stage_end_put (FILE * file);
extern int fsck_stage_magic_check (FILE * fp);
/* pass0.c */
extern int pass0_block_isbad_unfm(unsigned long block);
extern int pass0_block_isgood_unfm(unsigned long block);
extern int pass0_block_isleaf(unsigned long block);
extern void pass0_block_clleaf(unsigned long block);
extern void fsck_pass0 (reiserfs_filsys_t *);
extern void fsck_pass0_load_result (FILE *, reiserfs_filsys_t *);
extern void make_allocable (unsigned long block);
extern int fsck_leaf_check(reiserfs_bh_t * bh);
extern unsigned long alloc_block (void);
extern void fsck_pass0_aux_fini ();
extern int fsck_leaf_item_check (reiserfs_bh_t * bh, reiserfs_ih_t *, char *);
extern int are_there_allocable_blocks (unsigned int amout_needed);
extern int fsck_leaf_check_header(reiserfs_filsys_t * fs, reiserfs_bh_t * bh);
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 (unsigned int amout_needed);
unsigned long alloc_block (void);
void make_allocable (unsigned long block);
void register_uninsertable (unsigned long block);
void register_saved_item (void);
int still_bad_unfm_ptr_1 (unsigned long block);
int still_bad_unfm_ptr_2 (unsigned long block);
void make_alloc_bitmap (reiserfs_filsys_t *);
void delete_aux_bitmaps ();
void set_aux_bitmaps(reiserfs_bitmap_t * leaves, reiserfs_bitmap_t * good, reiserfs_bitmap_t * bad);
#define __is_marked(name,block) reiserfs_bitmap_test_bit (name##_bitmap, block)
#define __mark(name,block) reiserfs_bitmap_set_bit (name##_bitmap, block)
#define __unmark(name,block) reiserfs_bitmap_clear_bit (name##_bitmap, block)
/* unformatted in tree */
extern reiserfs_bitmap_t * bad_unfm_in_tree_once_bitmap;
#define is_bad_unfm_in_tree_once(block) __is_marked (bad_unfm_in_tree_once, block)
#define mark_bad_unfm_in_tree_once(block) __mark (bad_unfm_in_tree_once, block)
/* pass1.c */
#define fsck_item_reach(ih) (reiserfs_ih_isreach (ih) ? 1 : 0)
#define fsck_item_mkunreach(ih) \
({ \
reiserfs_ih_clflags (ih); \
reiserfs_ih_mkunreach (ih); \
\
if (reiserfs_ih_ext (ih)) \
reiserfs_ih_set_free (ih, 0); \
})
void pass_1 (reiserfs_filsys_t *);
void load_pass_1_result (FILE *, reiserfs_filsys_t *);
struct buffer_head * make_buffer (int dev, unsigned long blocknr, int size, char * data);
void build_the_tree (void);
extern int g_unaccessed_items;
int is_item_reachable (struct item_head * ih);
void mark_item_reachable (struct item_head * ih, struct buffer_head * bh);
void mark_item_unreachable (struct item_head * ih);
#define fsck_item_mkreach(ih, bh) \
({ \
reiserfs_ih_clunreach (ih); \
reiserfs_buffer_mkdirty (bh); \
})
struct si * remove_saved_item (struct si * si);
int tree_is_empty (void);
void make_single_leaf_tree (struct buffer_head * bh);
extern void fsck_pass1 (reiserfs_filsys_t *);
extern void fsck_pass1_load_result (FILE *, reiserfs_filsys_t *);
extern void fsck_pass2 (reiserfs_filsys_t *);
extern void fsck_info_checkmem(void);
/* pass2.c */
typedef struct saveitem saveitem_t;
struct saveitem {
reiserfs_ih_t si_ih;
void pass_2 (reiserfs_filsys_t *);
void load_pass_2_result (reiserfs_filsys_t *);
void insert_item_separately (struct item_head * ih, char * item, int was_in_tree);
void save_item (struct si ** head, struct item_head * ih, char * item, __u32 blocknr);
struct si * save_and_delete_file_item (struct si * si, struct path * path);
void take_bad_blocks_put_into_tree (void);
void rewrite_object (struct item_head * ih, int do_remap);
void pass_2_take_bad_blocks_put_into_tree (void);
/*int is_remapped (struct item_head * ih);*/
void link_relocated_files (void);
int should_relocate (struct item_head * ih);
void relocate_dir (struct item_head * ih, int change_ih);
extern __u32 objectid_for_relocation (struct key * key);
extern void linked_already(struct key *new_key);
/* file.c */
struct si {
struct item_head si_ih;
char * si_dnm_data;
saveitem_t * si_next;
struct si * si_next;
__u32 si_blocknr;
// changed by XB;
saveitem_t * last_known;
struct si * last_known;
};
void put_saved_items_into_tree (struct si *);
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);
extern void fsck_pass2_load_result (reiserfs_filsys_t *);
extern void fsck_item_save(reiserfs_path_t * path,
saveitem_t ** head);
extern saveitem_t * fsck_item_free(saveitem_t * si);
extern void fsck_tree_insert_item (reiserfs_ih_t * ih,
char * item, int was_in_tree);
extern void fsck_tree_merge(reiserfs_path_t *path);
extern long long int must_there_be_a_hole (const reiserfs_ih_t *ih,
const reiserfs_key_t *key);
extern int fsck_tree_insert_zero_ptr (reiserfs_filsys_t *fs,
reiserfs_key_t *key,
long long int p_count,
__u16 flags);
extern void fsck_tree_rewrite(reiserfs_filsys_t *fs,
const reiserfs_key_t *start_key,
__u64 end, __u16 flags);
typedef int (*tree_modify_t) (reiserfs_path_t *path, void *data);
/* relocate.c */
extern void fsck_relocate_mklinked(reiserfs_key_t *new_key);
extern __u32 fsck_relocate_get_oid (reiserfs_key_t * key);
extern __u32 fsck_relocate_oid(reiserfs_key_t * key);
extern void fsck_relocate_link_all (void);
extern __u32 fsck_relocate_check (reiserfs_ih_t * ih, int isdir);
/* semantic.c */
@@ -169,141 +159,116 @@ extern __u32 fsck_relocate_check (reiserfs_ih_t * ih, int isdir);
#define RELOCATED -3
#define LOOP_FOUND -4
extern void fsck_semantic (reiserfs_filsys_t *);
extern void fsck_semantic_load_result (FILE *, reiserfs_filsys_t *);
extern void fsck_semantic_check (void);
extern int is_dot_dot (char * name, int namelen);
extern int is_dot (char * name, int namelen);
extern int not_a_directory (void * sd);
extern int not_a_regfile (void * sd);
extern void zero_nlink (reiserfs_ih_t * ih, void * sd);
extern int fix_obviously_wrong_sd_mode (reiserfs_path_t * path);
extern int wrong_st_blocks(const reiserfs_key_t * key,
__u32 * blocks,
__u32 sd_blocks,
__u16 mode,
int new_format);
extern int wrong_st_size (const reiserfs_key_t * key,
unsigned long long max_file_size,
int blocksize,
__u64 * size,
__u64 sd_size,
int type);
void load_semantic_result (FILE *, reiserfs_filsys_t *);
void pass_3_semantic (reiserfs_filsys_t *);
void semantic_check (void);
int check_semantic_tree (struct key * key, struct key * parent, int is_dot_dot, int lost_found, struct item_head * new_ih);
void zero_nlink (struct item_head * ih, void * sd);
int not_a_directory (void * sd);
int not_a_regfile (void * sd);
int fix_obviously_wrong_sd_mode (struct path * path);
int is_dot_dot (char * name, int namelen);
int is_dot (char * name, int namelen);
/*void create_dir_sd (reiserfs_filsys_t * fs,
struct path * path, struct key * key);*/
int rebuild_check_regular_file (struct path * path, void * sd,
struct item_head * new_ih);
int rebuild_semantic_pass (struct key * key, struct key * parent, int is_dot_dot,
struct item_head * new_ih);
extern int rebuild_semantic_pass (reiserfs_key_t * key,
const reiserfs_key_t * parent,
int is_dot_dot,
reiserfs_ih_t * new_ih);
extern void relocate_dir (reiserfs_ih_t * ih);
extern int rebuild_check_regular_file (reiserfs_path_t * path,
void * sd,
reiserfs_ih_t * new_ih);
/* lost+found.c */
extern void fsck_lost (reiserfs_filsys_t *);
extern void fsck_lost_load_result (reiserfs_filsys_t *);
void pass_3a_look_for_lost (reiserfs_filsys_t *);
void load_lost_found_result (reiserfs_filsys_t *);
/* pass4.c */
void pass_4_check_unaccessed_items (void);
/* check.c */
int is_leaf_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);
/*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);
//extern int bad_block_number (struct super_block * s, blocknr_t block);
/* check_tree.c */
void check_fs_tree (reiserfs_filsys_t *);
void do_clean_attributes (reiserfs_filsys_t * fs);
int bad_pair (reiserfs_filsys_t *, struct buffer_head * bh, int i);
int bad_leaf_2 (reiserfs_filsys_t *, struct buffer_head * bh);
#if 0
extern int should_be_relocated (struct key * key);
extern void to_be_relocated (struct key * key);
extern void clear_relocated_list(void);
#endif
/* ustree.c */
void reiserfsck_paste_into_item (struct path * path, const char * body, int size);
void reiserfsck_insert_item (struct path * path, struct item_head * ih, const char * body);
void reiserfsck_delete_item (struct path * path, int temporary);
void reiserfsck_cut_from_item (struct path * path, int cut_size);
/*typedef int (comp3_function_t)(void * key1, void * key2, int version);*/
/*typedef int (comp_function_t)(struct key * key1, struct key * key2);*/
/*int ubin_search_id(__u32 * id, __u32 * base, __u32 number, __u32 * pos);*/
/*int usearch_by_key (struct super_block * s, struct key * key, struct path * path);*/
/*int usearch_by_key_3 (struct super_block * s, struct key * key, struct path * path, int * repeat, int stop_level,
comp3_function_t comp_func, int version);
int usearch_by_entry_key (struct super_block * s, struct key * key, struct path * path);*/
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, int depth);
/* bitmap.c */
int reiserfsck_reiserfs_new_blocknrs (reiserfs_filsys_t * fs,
unsigned long * pblocknrs,
unsigned long start_from,
int amount_needed);
int reiserfsck_reiserfs_free_block (reiserfs_filsys_t * fs, unsigned long block);
struct buffer_head * reiserfsck_get_new_buffer (unsigned long start);
int is_block_used (unsigned long block);
void mark_block_used (unsigned long block, int check_hardware);
void mark_block_uninsertable (unsigned long block);
int is_block_uninsertable (unsigned long block);
/* objectid.c */
int comp_ids(const void *p1, const void *p2);
typedef struct id_map {
void **index;
__u32 count, last_used;
} id_map_t;
extern void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs);
extern void id_map_free(id_map_t *);
extern int id_map_mark(id_map_t *map, __u32 id);
extern id_map_t *id_map_init();
extern __u32 id_map_alloc(id_map_t *map);
extern int id_map_test(id_map_t *map, __u32 id);
extern void fetch_objectid_map (struct id_map * map,
reiserfs_filsys_t * fs);
extern void reiserfs_objectid_map_save (FILE * fp, struct id_map * id_map);
extern struct id_map * reiserfs_objectid_map_load (FILE * fp);
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);
/* rollback.c */
extern void fsck_rollback_fini ();
void reiserfs_objectid_map_save (FILE * fp, struct id_map * id_map);
struct id_map * reiserfs_objectid_map_load (FILE * fp);
*/
extern void fsck_rollback_init (char * rollback_file,
unsigned int *bloksize, FILE * log);
void mark_formatted_pointed_by_indirect (__u32);
int is_formatted_pointed_by_indirect (__u32);
extern int fsck_rollback_prep (char * rollback_file, FILE * log);
extern void fsck_rollback (int fd_device,
int fd_journal_device,
FILE * log);
/* pass4.c */
extern void fsck_cleanup (void);
/* check_tree.c */
extern void check_fs_tree (reiserfs_filsys_t *);
extern void fsck_tree_clean_attr (reiserfs_filsys_t * fs);
extern int fsck_leaf_check_neigh (reiserfs_filsys_t *fs,
reiserfs_bh_t * bh,
int i);
extern int fsck_tree_delete(reiserfs_key_t * start_key,
saveitem_t ** save_here,
int skip_dir_items,
tree_modify_t func,
void *data);
/* ubitmap.c */
extern int is_block_used (unsigned long block);
extern void mark_block_used (unsigned long block, int check_hardware);
extern void fsck_bitmap_mkuninsert (unsigned long block);
extern int fsck_bitmap_isuninsert (unsigned long block);
extern void fsck_bitmap_cluninsert (unsigned long block);
extern int reiserfsck_new_blocknrs (reiserfs_filsys_t * fs,
unsigned long * pblocknrs,
unsigned long start_from,
int amount_needed);
extern int reiserfsck_free_block (reiserfs_filsys_t * fs,
unsigned long block);
extern reiserfs_bh_t * reiserfsck_get_new_buffer (unsigned long start);
/* ufile.c */
#define FSCK_MAX_GAP(bs) \
(100 * REISERFS_ITEM_MAX(bs) / REISERFS_EXT_SIZE * bs)
extern void fsck_file_relocate (reiserfs_key_t *key,
int update_key);
extern int reiserfsck_file_write (reiserfs_ih_t * ih,
char * item,
int was_in_tree);
extern int are_file_items_correct (reiserfs_ih_t * sd_ih,
void * sd,
__u64 * size,
__u32 * blocks,
int mark_passed_items,
int * symlink);
/* ustree.c*/
typedef int (*path_func_t) (reiserfs_filsys_t *,
reiserfs_path_t *);
extern void fsck_tree_trav (reiserfs_filsys_t *,
path_func_t,
path_func_t,
int depth);
enum fsck_stage {
FS_CHECK = 0x0,
FS_PASS0 = 0x1,
FS_PASS1 = 0x2,
FS_PASS2 = 0x3,
FS_SEMANTIC = 0x4,
FS_LOST = 0x5,
FS_CLEANUP = 0x6,
FS_LAST
};
#define MAP_NOT_PACKED 0
#define MAP_PACKED 1
struct pass0_stat {
unsigned long dealt_with; /* number of blocks read during pass 0 */
@@ -313,24 +278,22 @@ struct pass0_stat {
unsigned long too_old_leaves; /* these are leaves which contains
direntries with different hash from the
one specified with -h */
unsigned long wrong_pointers; /* pointers in extent items pointing to
unsigned long wrong_pointers; /* pointers in indirect items pointing to
wrong area */
unsigned long pointed; /* pointers blocks of device pointed by all
extent items */
/* number of removed items. */
unsigned long long removed;
indirect items */
};
struct pass1_stat {
unsigned long leaves; /* leaves found in pass0 to build tree off */
unsigned long inserted_leaves; /* number of leaves inserted by pointers */
unsigned long pointed_leaves; /* pointers in extent items which pointed
unsigned long pointed_leaves; /* pointers in indirect items which pointed
to leaves (zeroed) */
unsigned long uninsertable_leaves;
unsigned long non_unique_pointers; /* pointers to already pointed unformatted nodes */
unsigned long correct_pointers;
unsigned long saved_items; /* items saved on pass1: should be 0 */
unsigned long allocable_blocks; /* allocable blocks before pass 1 starts */
};
@@ -345,6 +308,7 @@ struct pass2_stat {
struct semantic_stat {
unsigned long oid_sharing_files_relocated;
unsigned long regular_files;
unsigned long directories;
unsigned long symlinks;
@@ -353,26 +317,36 @@ struct semantic_stat {
unsigned long fixed_sizes;
unsigned long oid_sharing;
unsigned long oid_sharing_dirs_relocated;
unsigned long oid_sharing_files_relocated;
unsigned long deleted_entries;
unsigned long added_sd;
};
struct lost_found_stat {
unsigned long dir_recovered;
unsigned long empty_lost_dirs;
unsigned long lost_found;
unsigned long lost_found_files;
unsigned long lost_found_dirs;
unsigned long oid_sharing;
unsigned long oid_sharing_dirs_relocated;
unsigned long oid_sharing_files_relocated;
};
struct pass_4_stat {
unsigned long deleted_items;
};
struct rebuild_info {
struct {
union {
struct pass0_stat pass0;
struct pass1_stat pass1;
struct pass2_stat pass2;
struct semantic_stat semantic;
struct {
struct semantic_stat semantic;
struct lost_found_stat lost_found;
} tree;
struct pass_4_stat pass4;
} pass_u;
@@ -445,7 +419,7 @@ struct fsck_data {
/* objectid maps */
id_map_t * proper_id_map;
id_map_t * semantic_id_map; /* this objectid map is used to
cure objectid sharing problem */
cure objectid sharing problem */
};
@@ -453,7 +427,8 @@ struct fsck_data {
#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 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))
@@ -500,20 +475,16 @@ struct fsck_data {
/* name of file where we store rollback data */
#define state_rollback_file(fs) fsck_data(fs)->rebuild.rollback_file
int fsck_info_ask (reiserfs_filsys_t * fs,
char * q, char * a,
int default_answer);
int fsck_user_confirmed (reiserfs_filsys_t * fs, char * q, char * a, int default_answer);
void stage_report (int, reiserfs_filsys_t *);
void fsck_stage_report (int, reiserfs_filsys_t *);
/* journal.c */
int replay_journal (reiserfs_filsys_t *);
/*pass1: rebuild super block*/
void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * data);
/* special type for symlink not conflicting to any of item types. */
#define TYPE_SYMLINK 4
#define fsck_log(fmt, list...) \
{\
if (!fsck_silent (fs))\
@@ -529,32 +500,16 @@ fflush (fsck_progress_file(fs));\
#define FATAL 1
#define FIXABLE 2
enum entry_type {
ET_NAME = 0x0,
ET_DOT = 0x1,
ET_DOT_DOT = 0x2,
ET_LOST_FOUND = 0x3,
ET_LAST
};
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 (EXIT_USER);\
}
#define one_more_corruption(fs,kind) \
({ \
if (kind == FATAL) \
fsck_check_stat (fs)->fatal_corruptions++; \
else if (kind == FIXABLE) \
fsck_check_stat (fs)->fixable_corruptions++; \
})
#define one_less_corruption(fs,kind) \
({ \
if (kind == FATAL) \
fsck_check_stat (fs)->fatal_corruptions--; \
else if (kind == FIXABLE) \
fsck_check_stat (fs)->fixable_corruptions--; \
})
+176
View File
@@ -0,0 +1,176 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "fsck.h"
int fsck_user_confirmed (reiserfs_filsys_t * fs, char * q, char * a, int default_answer)
{
if (!fsck_interactive (fs))
return default_answer;
return user_confirmed (fsck_progress_file (fs), q, a);
}
void stage_report (int pass, reiserfs_filsys_t * fs)
{
switch (pass) {
case 0:
{
struct pass0_stat * stat;
/* what has been done on pass 0 */
stat = pass_0_stat (fs);
fsck_progress ("\tRead blocks (but not data blocks) %lu\n", stat->dealt_with);
fsck_progress ("\t\tLeaves among those %lu\n", stat->leaves);
if (stat->leaves_corrected)
fsck_progress ("\t\t\t- corrected leaves %lu\n", stat->leaves_corrected);
if (stat->all_contents_removed)
fsck_progress ("\t\t\t- leaves all contents of which could not be saved and deleted %lu\n",
stat->all_contents_removed);
if (stat->too_old_leaves)
fsck_progress ("\t\t\t- too old leaves %lu (skipped)\n", stat->too_old_leaves);
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)->count);
}
break;
case 1:
{
struct pass1_stat * stat;
/* what has been done on pass 1 */
stat = pass_1_stat (fs);
fsck_progress ("\t%lu leaves read\n", stat->leaves);
fsck_progress ("\t\t%lu inserted\n", stat->inserted_leaves);
if (stat->pointed_leaves)
fsck_progress ("\t\t\t- pointers in indirect items pointing to metadata %lu (zeroed)\n",
stat->pointed_leaves);
if (stat->saved_items)
fsck_progress ("\tSaved %lu items\n", stat->saved_items);
if (stat->uninsertable_leaves)
fsck_progress ("\t\t%lu not inserted\n", stat->uninsertable_leaves);
if (stat->non_unique_pointers)
fsck_progress ("\tnon-unique pointers in indirect items (zeroed) %lu\n",
stat->non_unique_pointers);
}
break;
case 2:
{
struct pass2_stat * stat;
/* what has been done on pass 2 */
stat = pass_2_stat (fs);
if (stat->leaves)
fsck_progress ("\tLeaves inserted item by item %lu\n", stat->leaves);
if (stat->safe_non_unique_pointers)
fsck_progress ("\t%lu \n",
stat->safe_non_unique_pointers);
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 with a directory %lu\n",
stat->relocated);
if (stat->rewritten)
fsck_progress ("\tFiles rewritten %lu\n", stat->rewritten);
}
break;
case 3: /* semantic */
{
struct semantic_stat * stat;
/* what has been done on the semantic pass */
stat = sem_pass_stat (fs);
fsck_progress ("\tFiles found: %ld\n", stat->regular_files);
fsck_progress ("\tDirectories found: %ld\n", stat->directories);
if (stat->symlinks)
fsck_progress ("\tSymlinks found: %ld\n", stat->symlinks);
if (stat->others)
fsck_progress ("\tOthers: %ld\n", stat->others);
if (stat->broken_files)
fsck_progress ("\tBroken (of files/symlinks/others): %ld\n", stat->broken_files);
if (stat->fixed_sizes)
fsck_progress ("\tFiles with fixed size: %ld\n", stat->fixed_sizes);
if (stat->deleted_entries)
fsck_progress ("\tNames pointing to nowhere (removed): %ld\n", stat->deleted_entries);
if (stat->oid_sharing)
fsck_progress ("\tObjects having used objectids: %lu\n", stat->oid_sharing);
if (stat->oid_sharing_files_relocated)
fsck_progress ("\t\tfiles fixed %lu\n", stat->oid_sharing_files_relocated);
if (stat->oid_sharing_dirs_relocated)
fsck_progress ("\t\tdirs fixed %lu\n", stat->oid_sharing_dirs_relocated);
}
break;
case 0x3a: /* lost+found pass */
{
struct lost_found_stat * stat;
/* what has been done on the semantic pass */
stat = lost_found_pass_stat (fs);
if (stat->lost_found)
fsck_progress ("\tObjects without names %lu\n",
stat->lost_found);
if (stat->empty_lost_dirs)
fsck_progress ("\tEmpty lost dirs removed %lu\n",
stat->empty_lost_dirs);
if (stat->lost_found_dirs)
fsck_progress ("\tDirs linked to /lost+found: %lu\n",
stat->lost_found_dirs);
if (stat->dir_recovered)
fsck_progress ("\t\tDirs without stat data found %lu\n",
stat->dir_recovered);
if (stat->lost_found_files)
fsck_progress ("\tFiles linked to /lost+found %lu\n",
stat->lost_found_files);
if (stat->oid_sharing)
fsck_progress ("\tObjects having used objectids: %lu\n", stat->oid_sharing);
if (stat->oid_sharing_files_relocated)
fsck_progress ("\t\tfiles fixed %lu\n", stat->oid_sharing_files_relocated);
if (stat->oid_sharing_dirs_relocated)
fsck_progress ("\t\tdirs fixed %lu\n", stat->oid_sharing_dirs_relocated);
}
break;
case 4: /* removing of unreachable */
{
struct pass_4_stat * stat;
/* what has been done on the semantic pass */
stat = pass_4_stat (fs);
if (stat->deleted_items)
fsck_progress ("\tDeleted unreachable items %lu\n",
stat->deleted_items);
}
break;
case 5:
fsck_progress ("There are on the filesystem:\n"
"\tLeaves %lu\n\tInternal nodes %lu\n"
"\tDirectories %lu\n\tOther files %lu\n"
"\tData block pointers %lu (%lu of them are zero)\n"
"\tSafe links %lu\n",
fsck_check_stat (fs)->leaves,
fsck_check_stat (fs)->internals,
fsck_check_stat (fs)->dirs,
fsck_check_stat (fs)->files,
fsck_check_stat (fs)->unfm_pointers,
fsck_check_stat (fs)->zero_unfm_pointers,
fsck_check_stat (fs)->safe);
} /* switch */
memset (&fsck_data (fs)->rebuild.pass_u, 0, sizeof (fsck_data (fs)->rebuild.pass_u));
}
+372
View File
@@ -0,0 +1,372 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "fsck.h"
void erase_name (int len);
void print_name (char * name, int len);
void modify_item (struct item_head * ih, void * item);
/* fixme: search_by_key is not needed after any add_entry */
static __u64 _look_for_lost (reiserfs_filsys_t * fs, int link_lost_dirs)
{
struct key key, prev_key, * rdkey;
INITIALIZE_PATH (path);
int item_pos;
struct buffer_head * bh;
struct item_head * ih;
unsigned long leaves;
int is_it_dir;
static int lost_files = 0; /* looking for lost dirs we calculate amount of
lost files, so that when we will look for
lost files we will be able to stop when
there are no lost files anymore */
int retval;
__u64 size;
key = root_dir_key;
if (!link_lost_dirs && !lost_files) {
/* we have to look for lost files but we know already that there are
no any */
return 0;
}
fsck_progress ("Looking for lost %s:\n", link_lost_dirs ? "directories" : "files");
leaves = 0;
/* total size of added entries */
size = 0;
while (1) {
retval = reiserfs_search_by_key_4 (fs, &key, &path);
/* fixme: we assume path ends up with a leaf */
bh = get_bh (&path);
item_pos = get_item_pos (&path);
if (retval != ITEM_FOUND) {
if (item_pos == get_blkh_nr_items (B_BLK_HEAD (bh))) {
rdkey = uget_rkey (&path);
if (!rdkey) {
pathrelse (&path);
break;
}
key = *rdkey;
pathrelse (&path);
continue;
}
/* we are on the item in the buffer */
}
/* print ~ how many leaves were scanned and how fast it was */
if (!fsck_quiet (fs))
print_how_fast (leaves++, 0, 50, 0);
for (ih = get_ih (&path); item_pos < get_blkh_nr_items (B_BLK_HEAD (bh)); item_pos ++, ih ++, PATH_LAST_POSITION(&path)++) {
if (is_item_reachable (ih))
continue;
/* found item which can not be reached */
if (!is_direntry_ih (ih) && !is_stat_data_ih (ih)) {
continue;
}
if (is_direntry_ih (ih)) {
/* if this directory has no stat data - try to recover it */
struct key sd;
struct path tmp;
sd = ih->ih_key;
set_type_and_offset (KEY_FORMAT_1, &sd, SD_OFFSET, TYPE_STAT_DATA);
if (reiserfs_search_by_key_4 (fs, &sd, &tmp) == ITEM_FOUND) {
/* should not happen - because if there were a stat data -
we would have done with the whole directory */
pathrelse (&tmp);
continue;
}
lost_found_pass_stat (fs)->dir_recovered ++;
create_dir_sd (fs, &tmp, &sd, modify_item);
id_map_mark(proper_id_map (fs), get_key_objectid (&sd));
key = sd;
pathrelse (&path);
goto cont;
}
/* stat data marked "not having name" found */
if (is_stat_data_ih (get_ih(&path)))
fix_obviously_wrong_sd_mode (&path);
is_it_dir = ((not_a_directory (B_I_PITEM (bh,ih))) ? 0 : 1);
if (is_it_dir) {
struct key tmp_key;
INITIALIZE_PATH (tmp_path);
struct item_head * tmp_ih;
/* there is no need to link empty lost directories into /lost+found */
tmp_key = ih->ih_key;
set_type_and_offset (KEY_FORMAT_1, &tmp_key, 0xffffffff, TYPE_DIRENTRY);
reiserfs_search_by_key_4 (fs, &tmp_key, &tmp_path);
tmp_ih = get_ih (&tmp_path);
tmp_ih --;
if (not_of_one_file (&tmp_key, tmp_ih))
reiserfs_panic ("not directory found");
if (!is_direntry_ih (tmp_ih) ||
(get_deh_offset (B_I_DEH (get_bh (&tmp_path), tmp_ih) +
get_ih_entry_count (tmp_ih) - 1) == DOT_DOT_OFFSET)) {
/* last directory item is either stat data or empty
directory item - do not link this dir into lost+found */
lost_found_pass_stat (fs)->empty_lost_dirs ++;
pathrelse (&tmp_path);
continue;
}
pathrelse (&tmp_path);
}
if (link_lost_dirs && !is_it_dir) {
/* we are looking for directories and it is not a dir */
lost_files ++;
continue;
}
lost_found_pass_stat (fs)->lost_found ++;
{
struct key obj_key = {0, 0, {{0, 0},}};
char * lost_name;
struct item_head tmp_ih;
/* key to continue */
key = ih->ih_key;
set_key_objectid (&key, get_key_objectid (&key) + 1);
tmp_ih = *ih;
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 (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)
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),
get_key_objectid (&tmp_ih.ih_key));
/* entry in lost+found directory will point to this key */
set_key_dirid (&obj_key, get_key_dirid (&tmp_ih.ih_key));
set_key_objectid (&obj_key, get_key_objectid (&tmp_ih.ih_key));
pathrelse (&path);
/* 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
lost_found things */
print_name (lost_name, strlen (lost_name));
/*fsck_progress ("\tChecking lost dir \"%s\":", lost_name);*/
rebuild_semantic_pass (&obj_key, &lost_found_dir_key, /*dot_dot*/0, /*reloc_ih*/0);
erase_name (strlen (lost_name));
/*fsck_progress ("finished\n");*/
lost_found_pass_stat (fs)->lost_found_dirs ++;
} else {
if (reiserfs_search_by_key_4 (fs, &obj_key, &path) != ITEM_FOUND)
reiserfs_panic ("look_for_lost: lost file stat data %K not found",
&obj_key);
/* check_regular_file does not mark stat data reachable */
mark_item_reachable (get_ih (&path), get_bh (&path));
rebuild_check_regular_file (&path, get_item (&path), 0/*reloc_ih*/);
pathrelse (&path);
lost_found_pass_stat (fs)->lost_found_files ++;
lost_files --;
}
free (lost_name);
goto cont;
}
} /* for */
prev_key = key;
PATH_LAST_POSITION(&path) = item_pos - 1;
rdkey = reiserfs_next_key (&path);
if (rdkey)
key = *rdkey;
else
break;
if (comp_keys (&prev_key, &key) != -1)
reiserfs_panic ("pass_3a: key must grow 2: prev=%k next=%k",
&prev_key, &key);
pathrelse (&path);
cont:
if (!link_lost_dirs && !lost_files) {
break;
}
}
pathrelse (&path);
#if 0
/* check names added we just have added to/lost+found. Those names are
marked DEH_Lost_found flag */
fsck_progress ("Checking lost+found directory.."); fflush (stdout);
check_semantic_tree (&lost_found_dir_key, &root_dir_key, 0, 1/* lost+found*/);
fsck_progress ("finished\n");
#endif
return size;
}
static void save_lost_found_result (reiserfs_filsys_t * fs)
{
FILE * file;
int retval;
/* save bitmaps with which we will be able start reiserfs from
pass 1 */
file = open_file ("temp_fsck_file.deleteme", "w+");
if (!file)
return;
reiserfs_begin_stage_info_save (file, LOST_FOUND_DONE);
reiserfs_end_stage_info_save (file);
close_file (file);
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",
state_dump_file (fs));
}
/* we have nothing to load from a state file, but we have to fetch
on-disk bitmap, copy it to allocable bitmap, and fetch objectid
map */
void load_lost_found_result (reiserfs_filsys_t * fs)
{
fsck_new_bitmap (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
reiserfs_bitmap_copy (fsck_new_bitmap (fs), fs->fs_bitmap2);
fsck_allocable_bitmap (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
reiserfs_bitmap_copy (fsck_allocable_bitmap (fs), fs->fs_bitmap2);
fs->block_allocator = reiserfsck_reiserfs_new_blocknrs;
fs->block_deallocator = reiserfsck_reiserfs_free_block;
/* we need objectid map on semantic pass to be able to relocate files */
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)
{
/* update super block: objectid map, fsck state */
set_sb_fs_state (fs->fs_ondisk_sb, LOST_FOUND_DONE);
mark_buffer_dirty (fs->fs_super_bh);
/* write all dirty blocks */
fsck_progress ("Flushing..");
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);
fsck_progress ("finished\n");
stage_report (0x3a, fs);
if (!fsck_run_one_step (fs)) {
if (fsck_user_confirmed (fs, "Continue? (Yes):", "Yes\n", 1))
/* reiserfsck continues */
return;
}
save_lost_found_result (fs);
id_map_free(proper_id_map (fs));
proper_id_map (fs) = 0;
fs->fs_dirt = 1;
reiserfs_close (fs);
exit(EXIT_OK);
}
void pass_3a_look_for_lost (reiserfs_filsys_t * fs)
{
INITIALIZE_PATH (path);
struct item_head * ih;
void * sd;
__u64 size, sd_size;
__u32 blocks;
__u16 mode;
__u32 objectid;
unsigned int gen_counter;
fsck_progress ("Pass 3a (looking for lost dir/files):\n");
/* 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");
/* look for lost dirs first */
size = _look_for_lost (fs, 1);
/* link files which are still lost */
size += _look_for_lost (fs, 0);
/* update /lost+found sd_size and sd_blocks (nlink is correct already) */
objectid = reiserfs_find_entry (fs, &root_dir_key, "lost+found",
&gen_counter, &lost_found_dir_key);
if (!objectid) {
reiserfs_panic ("look_for_lost: The entry 'lost+found' could not be found in the root directory.");
}
if (reiserfs_search_by_key_4 (fs, &lost_found_dir_key, &path) != ITEM_FOUND)
reiserfs_panic ("look_for_lost: The StatData of the 'lost+found' directory %K could not be found",
&lost_found_dir_key);
ih = get_ih (&path);
sd = get_item (&path);
get_sd_size (ih, sd, &sd_size);
size += sd_size;
blocks = dir_size2st_blocks (size);
set_sd_size (ih, sd, &size);
set_sd_blocks (ih, sd, &blocks);
/* make lost+found to be drwx------ */
mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;
set_sd_mode (ih, sd, &mode);
mark_buffer_dirty (get_bh (&path));
pathrelse (&path);
after_lost_found (fs);
}
File diff suppressed because it is too large. Load diff
+1999
View File
File diff suppressed because it is too large. Load diff
+821
View File
@@ -0,0 +1,821 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "fsck.h"
reiserfs_bitmap_t * bad_unfm_in_tree_once_bitmap;
//int step = 0; // 0 - find stat_data or any item ; 1 - find item ; 2 - already found
/* allocates buffer head and copy buffer content */
struct buffer_head * make_buffer (int dev, unsigned long blocknr, int size, char * data)
{
struct buffer_head * bh;
bh = getblk (dev, blocknr, size);
if (buffer_uptodate (bh))
return bh;
// die ("make_buffer: uptodate buffer found");
memcpy (bh->b_data, data, size);
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) != ~(__u32)0) &&
(get_key_objectid (to_find) != get_key_objectid (key)))
return 1;
if ((get_key_dirid (to_find) != ~(__u32)0) &&
(get_key_dirid (to_find) != get_key_dirid (key)))
return 1;
return 0;
}
int is_item_reachable (struct item_head * ih)
{
return ih_reachable (ih) ? 1 : 0;
}
void mark_item_unreachable (struct item_head * ih)
{
clean_ih_flags (ih);
mark_ih_unreachable (ih);
if (is_indirect_ih (ih))
set_ih_free_space (ih, 0);
}
void mark_item_reachable (struct item_head * ih, struct buffer_head * bh)
{
mark_ih_reachable (ih);
mark_buffer_dirty (bh);
}
static void stat_data_in_tree (struct buffer_head *bh,
struct item_head * ih)
{
#if 0
__u32 objectid;
objectid = get_key_objectid (&ih->ih_key);
if (mark_objectid_really_used (proper_id_map (fs), objectid)) {
stat_shared_objectid_found (fs);
mark_objectid_really_used (shared_id_map (fs), objectid);
}
#endif
zero_nlink (ih, B_I_PITEM (bh, ih));
}
static char *still_bad_unfm_ptr_to_string (int val) {
switch (val) {
case 1:
return "a leaf";
case 2:
return "shared between a few files";
case 3:
return "not a data block";
case 4:
return "not used in on-disk bitmap";
case 5:
return "out of partition boundary";
}
return "";
}
/* this just marks blocks pointed by an indirect item as used in the
new bitmap */
static void indirect_in_tree (struct buffer_head * bh,
struct item_head * ih)
{
unsigned int i;
__u32 * unp;
__u32 unfm_ptr;
int ret;
unp = (__u32 *)B_I_PITEM (bh, ih);
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
unfm_ptr = d32_get (unp, i);
if (unfm_ptr == 0)
continue;
if ((ret = still_bad_unfm_ptr_1 (unfm_ptr)))
reiserfs_panic ("%s: block %lu: The file %k points to the block (%u) which is %s",
__FUNCTION__, bh->b_blocknr, &ih->ih_key, unfm_ptr, still_bad_unfm_ptr_to_string(ret));
mark_block_used (unfm_ptr, 1);
}
}
static void leaf_is_in_tree_now (struct buffer_head * bh)
{
item_action_t actions[] = {stat_data_in_tree, indirect_in_tree, 0, 0};
mark_block_used ((bh)->b_blocknr, 1);
for_every_item (bh, mark_item_unreachable, actions);
pass_1_stat (fs)->inserted_leaves ++;
mark_buffer_dirty (bh);
}
static void insert_pointer (struct buffer_head * bh, struct path * path)
{
struct item_head * ih;
char * body;
int retval;
struct tree_balance tb;
init_tb_struct (&tb, fs, path, 0x7fff);
/* fix_nodes & do_balance must work for internal nodes only */
ih = 0;
retval = fix_nodes (/*tb.transaction_handle,*/ M_INTERNAL, &tb, ih);
if (retval != CARRY_ON)
die ("insert_pointer: fix_nodes failed with retval == %d", retval);
/* child_pos: we insert after position child_pos: this feature of the insert_child */
/* there is special case: we insert pointer after
(-1)-st key (before 0-th key) in the parent */
if (PATH_LAST_POSITION (path) == 0 && path->pos_in_item == 0)
PATH_H_B_ITEM_ORDER (path, 0) = -1;
else {
if (PATH_H_PPARENT (path, 0) == 0)
PATH_H_B_ITEM_ORDER (path, 0) = 0;
/* PATH_H_B_ITEM_ORDER (path, 0) = PATH_H_PPARENT (path, 0) ? PATH_H_B_ITEM_ORDER (path, 0) : 0;*/
}
ih = 0;
body = (char *)bh;
//memmode = 0;
do_balance (&tb, ih, body, M_INTERNAL, 0);
leaf_is_in_tree_now (bh);
}
/* return 1 if left and right can be joined. 0 otherwise */
int balance_condition_fails (struct buffer_head * left, struct buffer_head * right)
{
if (B_FREE_SPACE (left) >= B_CHILD_SIZE (right) -
(are_items_mergeable (B_N_PITEM_HEAD (left, B_NR_ITEMS (left) - 1), B_N_PITEM_HEAD (right, 0), left->b_size) ? IH_SIZE : 0))
return 1;
return 0;
}
/* return 1 if new can be joined with last node on the path or with
its right neighbor, 0 otherwise */
int balance_condition_2_fails (struct buffer_head * new, struct path * path)
{
struct buffer_head * bh;
struct key * right_dkey;
int pos, used_space;
bh = PATH_PLAST_BUFFER (path);
if (balance_condition_fails (bh, new))
/* new node can be joined with last buffer on the path */
return 1;
/* new node can not be joined with its left neighbor */
right_dkey = uget_rkey (path);
if (right_dkey == 0)
/* there is no right neighbor */
return 0;
pos = PATH_H_POSITION (path, 1);
if (pos == B_NR_ITEMS (bh = PATH_H_PBUFFER (path, 1))) {
/* we have to read parent of right neighbor. For simplicity we
call search_by_key, which will read right neighbor as well */
INITIALIZE_PATH(path_to_right_neighbor);
if (reiserfs_search_by_key_4 (fs, right_dkey, &path_to_right_neighbor) != ITEM_FOUND)
reiserfs_panic ("%s: block %lu, pointer %d: The left delimiting key %k of the block (%lu) is wrong,"
"the item cannot be found", __FUNCTION__, PATH_H_PBUFFER(path, 1)->b_blocknr, pos,
right_dkey, get_dc_child_blocknr(B_N_CHILD (bh, pos + 1)));
used_space = B_CHILD_SIZE (PATH_PLAST_BUFFER (&path_to_right_neighbor));
pathrelse (&path_to_right_neighbor);
}
else
used_space = get_dc_child_size (B_N_CHILD (bh, pos + 1));
if (B_FREE_SPACE (new) >= used_space -
(are_items_mergeable (B_N_PITEM_HEAD (new, B_NR_ITEMS (new) - 1), (struct item_head *)right_dkey, new->b_size) ? IH_SIZE : 0))
return 1;
return 0;
}
static void get_max_buffer_key (struct buffer_head * bh, struct key * key)
{
struct item_head * ih;
ih = B_N_PITEM_HEAD (bh, B_NR_ITEMS (bh) - 1);
copy_key (key, &(ih->ih_key));
if (is_direntry_key (key)) {
/* copy deh_offset 3-rd and 4-th key components of the last entry */
set_offset (KEY_FORMAT_1, key,
get_deh_offset (B_I_DEH (bh, ih) + get_ih_entry_count (ih) - 1));
} else if (!is_stat_data_key (key))
/* get key of the last byte, which is contained in the item */
set_offset (key_format (key), key, get_offset (key) + get_bytes_number (ih, bh->b_size) - 1);
}
int tree_is_empty (void)
{
return (get_sb_root_block (fs->fs_ondisk_sb) == ~(__u32)0 ||
get_sb_root_block (fs->fs_ondisk_sb) == 0) ? 1 : 0;
}
void make_single_leaf_tree (struct buffer_head * bh)
{
/* tree is empty, make tree root */
set_sb_root_block (fs->fs_ondisk_sb, bh->b_blocknr);
set_sb_tree_height (fs->fs_ondisk_sb, 2);
mark_buffer_dirty (fs->fs_super_bh);
leaf_is_in_tree_now (bh);
}
/* inserts pointer to leaf into tree if possible. If not, marks node as
uninsertable in special bitmap */
static void try_to_insert_pointer_to_leaf (struct buffer_head * new_bh)
{
INITIALIZE_PATH (path);
struct buffer_head * bh; /* last path buffer */
struct key * first_bh_key, last_bh_key; /* first and last keys of new buffer */
struct key last_path_buffer_last_key, * right_dkey;
int ret_value;
if (tree_is_empty () == 1) {
make_single_leaf_tree (new_bh);
return;
}
first_bh_key = B_N_PKEY (new_bh, 0);
/* try to find place in the tree for the first key of the coming node */
ret_value = reiserfs_search_by_key_4 (fs, first_bh_key, &path);
if (ret_value == ITEM_FOUND)
goto cannot_insert;
/* get max key in the new node */
get_max_buffer_key (new_bh, &last_bh_key);
bh = PATH_PLAST_BUFFER (&path);
if (comp_keys (B_N_PKEY (bh, 0), &last_bh_key) == 1/* first is greater*/) {
/* new buffer falls before the leftmost leaf */
if (balance_condition_fails (new_bh, bh))
goto cannot_insert;
if (uget_lkey (&path) != 0 || PATH_LAST_POSITION (&path) != 0)
die ("try_to_insert_pointer_to_leaf: bad search result");
path.pos_in_item = 0;
goto insert;
}
/* get max key of buffer, that is in tree */
get_max_buffer_key (bh, &last_path_buffer_last_key);
if (comp_keys (&last_path_buffer_last_key, first_bh_key) != -1/* second is greater */)
/* first key of new buffer falls in the middle of node that is in tree */
goto cannot_insert;
right_dkey = uget_rkey (&path);
if (right_dkey && comp_keys (right_dkey, &last_bh_key) != 1 /* first is greater */)
goto cannot_insert;
if (balance_condition_2_fails (new_bh, &path))
goto cannot_insert;
insert:
insert_pointer (new_bh, &path);
goto out;
cannot_insert:
/* statistic */
mark_block_uninsertable (new_bh->b_blocknr);
out:
pathrelse (&path);
return;
}
/* everything should be correct already in the leaf but contents of indirect
items. So we only
1. zero slots pointing to a leaf
2. zero pointers to blocks which are pointed already
3. what we should do with directory entries hashed by another hash?
they are deleted for now
*/
static void pass1_correct_leaf (reiserfs_filsys_t * fs,
struct buffer_head * bh)
{
unsigned int i, j;
struct item_head * ih;
__u32 * ind_item;
__u32 unfm_ptr;
int dirty = 0;
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < B_NR_ITEMS (bh); i ++, ih ++) {
if (is_direntry_ih (ih)) {
struct reiserfs_de_head * deh;
__u32 offset;
char * name;
int name_len;
unsigned int hash_code;
deh = B_I_DEH (bh, ih);
offset = 0;
for (j = 0; j < get_ih_entry_count (ih); j ++) {
name = name_in_entry (deh + j, j);
name_len = name_in_entry_length (ih, deh + j, j);
if ((j == 0 && is_dot (name, name_len)) ||
(j == 1 && is_dot_dot (name, name_len))) {
continue;
}
hash_code = find_hash_in_use (name, name_len, get_deh_offset (deh + j),
get_sb_hash_code (fs->fs_ondisk_sb));
if (hash_code != get_sb_hash_code (fs->fs_ondisk_sb)) {
fsck_log ("pass1: block %lu, item %d, entry %d: The entry \"%.*s\" of the %k is hashed with %s "
"whereas proper hash is %s", bh->b_blocknr, i, j, name_len, name, &ih->ih_key,
code2name (hash_code), code2name (get_sb_hash_code (fs->fs_ondisk_sb)));
if (get_ih_entry_count (ih) == 1) {
delete_item (fs, bh, i);
fsck_log(" - the only entry - item was deleted\n");
i --;
ih --;
break;
} else {
cut_entry (fs, bh, i, j, 1);
fsck_log(" - deleted\n");
j --;
deh = B_I_DEH (bh, ih);
continue;
}
}
if (j && offset >= get_deh_offset (deh + j)) {
fsck_log ("pass1: block %lu, item %d, entry %d: The entry "
"\"%.*s\" of the %k has hash offset %lu not "
"larger smaller than the previous one %lu. The "
"entry is deleted.\n", bh->b_blocknr,
i, j, name_len, name, &ih->ih_key,
get_deh_offset(deh + j), offset);
cut_entry (fs, bh, i, j, 1);
j --;
deh = B_I_DEH (bh, ih);
continue;
}
offset = get_deh_offset (deh + j);
}
continue;
}
if (!is_indirect_ih (ih))
continue;
/* correct indirect items */
ind_item = (__u32 *)B_I_PITEM (bh, ih);
for (j = 0; j < I_UNFM_NUM (ih); j ++) {
unfm_ptr = d32_get (ind_item, j);
if (!unfm_ptr)
continue;
/* this corruption of indirect item had to be fixed in pass0 */
if (not_data_block (fs, unfm_ptr) || unfm_ptr >= get_sb_block_count (fs->fs_ondisk_sb))
/*!was_block_used (unfm_ptr))*/
reiserfs_panic ("%s: block %lu, item %d, pointer %d: The wrong pointer (%u) in the file %K. "
"Must be fixed on pass0.", __FUNCTION__, bh->b_blocknr, i, j, unfm_ptr, &ih->ih_key);
/* 1. zero slots pointing to a leaf */
if (is_used_leaf (unfm_ptr)) {
dirty ++;
d32_put (ind_item, j, 0);
pass_1_stat (fs)->pointed_leaves ++;
continue;
}
/* 2. zero pointers to blocks which are pointed already */
if (is_bad_unformatted (unfm_ptr)) {
/* this unformatted pointed more than once. Did we see it already? */
if (!is_bad_unfm_in_tree_once (unfm_ptr))
/* keep first reference to it and mark about that in
special bitmap */
mark_bad_unfm_in_tree_once (unfm_ptr);
else {
/* Yes, we have seen this pointer already, zero other pointers to it. */
dirty ++;
d32_put (ind_item, j, 0);
pass_1_stat (fs)->non_unique_pointers ++;
continue;
}
} else
pass_1_stat (fs)->correct_pointers ++;
}
}
if (dirty)
mark_buffer_dirty (bh);
}
struct si * remove_saved_item (struct si * si)
{
struct si * tmp = si->si_next;
freemem (si->si_dnm_data);
freemem (si);
return tmp;
}
/* fsck starts creating of this bitmap on pass 1. It will then become
on-disk bitmap */
static void init_new_bitmap (reiserfs_filsys_t * fs)
{
unsigned int i;
unsigned long block;
unsigned long reserved;
fsck_new_bitmap (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
/* mark_block_used skips 0, set the bit explicitly */
reiserfs_bitmap_set_bit (fsck_new_bitmap (fs), 0);
/* mark other skipped blocks and super block used */
for (i = 1; i <= fs->fs_super_bh->b_blocknr; i ++)
mark_block_used (i, 1);
/* mark bitmap blocks as used */
block = fs->fs_super_bh->b_blocknr + 1;
for (i = 0; i < reiserfs_fs_bmap_nr(fs); i ++) {
mark_block_used (block, 1);
if (spread_bitmaps (fs))
block = (block / (fs->fs_blocksize * 8) + 1) * (fs->fs_blocksize * 8);
else
block ++;
}
reserved = get_size_of_journal_or_reserved_area (fs->fs_ondisk_sb);
/* where does journal area (or reserved journal area) start from */
if (!is_new_sb_location (fs->fs_super_bh->b_blocknr, fs->fs_blocksize) &&
!is_old_sb_location (fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
die ("init_new_bitmap: Wrong super block location, you must run --rebuild-sb.");
block = get_journal_start_must (fs);
for (i = block; i < reserved + block; i ++)
mark_block_used (i, 1);
if (fs->fs_badblocks_bm)
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 (fsck_new_bitmap (fs), i))
reiserfs_panic ("%s: The block pointer to not data area, must be fixed on the pass0.\n",
__FUNCTION__);
reiserfs_bitmap_set_bit (fsck_new_bitmap (fs), i);
}
}
#if 0
/* mark journal area as used if journal is standard or it is non standard
and initialy has been created on a main device */
reserved = 0;
if (!is_reiserfs_jr_magic_string (fs->fs_ondisk_sb))
reserved = get_jp_journal_size (sb_jp (fs->fs_ondisk_sb));
if (get_sb_reserved_for_journal (fs->fs_ondisk_sb))
reserved = get_sb_reserved_for_journal (fs->fs_ondisk_sb);
if (reserved) {
for (i = 0; i <= reserved; i ++)
mark_block_used (i + get_jp_journal_1st_block (sb_jp
(fs->fs_ondisk_sb)));
}
#endif
}
/* this makes a map of blocks which can be allocated when fsck will
continue */
static void find_allocable_blocks (reiserfs_filsys_t * fs)
{
unsigned long i;
fsck_progress ("Looking for allocable blocks .. ");
fsck_allocable_bitmap (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
reiserfs_bitmap_fill (fsck_allocable_bitmap (fs));
/* find how many leaves are not pointed by any indirect items */
for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
if (not_data_block (fs, i))
/* journal (or reserved for it area), bitmaps, super block and
blocks before it */
continue;
if (is_good_unformatted (i) && is_bad_unformatted (i))
die ("find_allocable_blocks: The block (%lu) is masr as good and as bad at once.", i);
if (is_good_unformatted (i) || is_bad_unformatted (i)) {
/* blocks which were pointed once or more thn onec from indirect
items - they will not be allocated */
continue;
}
/* make allocable not leaves, not bad blocks */
if (!is_used_leaf (i) && (!fs->fs_badblocks_bm ||
!reiserfs_bitmap_test_bit (fs->fs_badblocks_bm, i)))
{
/* this is not leaf and it is not pointed by found indirect items,
so it does not contains anything valuable */
make_allocable (i);
pass_1_stat (fs)->allocable_blocks ++;
}
}
fsck_progress ("finished\n");
fs->block_allocator = reiserfsck_reiserfs_new_blocknrs;
fs->block_deallocator = reiserfsck_reiserfs_free_block;
}
static void before_pass_1 (reiserfs_filsys_t * fs)
{
/* this will become an on-disk bitmap */
init_new_bitmap (fs);
/* bitmap of leaves which could not be inserted on pass 1. FIXME:
no need to have 1 bit per block */
fsck_uninsertables (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
reiserfs_bitmap_fill (fsck_uninsertables (fs));
/* find blocks which can be allocated */
find_allocable_blocks (fs);
/* bitmap of bad unformatted nodes which are in the tree already */
bad_unfm_in_tree_once_bitmap = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
/* pass 1 does not deal with objectid */
}
static void save_pass_1_result (reiserfs_filsys_t * fs)
{
FILE * file;
int retval;
file = open_file("temp_fsck_file.deleteme", "w+");
if (!file)
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 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);
/* to be able to restart with pass 2 we need bitmap of
uninsertable blocks and bitmap of alocable blocks */
reiserfs_begin_stage_info_save(file, PASS_1_DONE);
reiserfs_bitmap_save (file, fsck_uninsertables (fs));
reiserfs_bitmap_save (file, fsck_allocable_bitmap(fs));
reiserfs_end_stage_info_save (file);
close_file (file);
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",
state_dump_file (fs));
}
void load_pass_1_result (FILE * fp, reiserfs_filsys_t * fs)
{
fsck_new_bitmap (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
reiserfs_bitmap_copy (fsck_new_bitmap (fs), fs->fs_bitmap2);
fsck_uninsertables (fs) = reiserfs_bitmap_load (fp);
fsck_allocable_bitmap (fs) = reiserfs_bitmap_load (fp);
fs->block_allocator = reiserfsck_reiserfs_new_blocknrs;
fs->block_deallocator = reiserfsck_reiserfs_free_block;
if (!fsck_new_bitmap (fs) || !fsck_allocable_bitmap (fs) ||
!fsck_allocable_bitmap (fs))
fsck_exit ("State dump file seems corrupted. Run without -d");
/* we need objectid map on pass 2 to be able to relocate files */
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",
reiserfs_bitmap_ones (fsck_new_bitmap (fs)),
reiserfs_bitmap_zeros (fsck_allocable_bitmap (fs)),
reiserfs_bitmap_zeros (fsck_uninsertables (fs)));
}
extern reiserfs_bitmap_t * leaves_bitmap;
/* reads blocks marked in leaves_bitmap and tries to insert them into
tree */
static void do_pass_1 (reiserfs_filsys_t * fs)
{
struct buffer_head * bh;
unsigned long i;
int what_node;
unsigned long done = 0, total;
/* on pass0 we have found that amount of leaves */
total = reiserfs_bitmap_ones (leaves_bitmap);
/* read all leaves found on the pass 0 */
for (i = 0; i < get_sb_block_count (fs->fs_ondisk_sb); i ++) {
if (!is_used_leaf (i))
continue;
print_how_far (fsck_progress_file (fs), &done, total, 1, fsck_quiet (fs));
/* at least one of nr_to_read blocks is to be checked */
bh = bread (fs->fs_dev, i, fs->fs_blocksize);
if (!bh) {
/* we were reading one block at time, and failed, so mark
block bad */
fsck_progress ("pass1: Reading of the block %lu failed\n", i);
continue;
}
what_node = who_is_this (bh->b_data, bh->b_size);
if ( what_node != THE_LEAF ) {
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) &&
fsck_data(fs)->rebuild.use_journal_area))
/* block is in new tree already */
die ("build_the_tree: The leaf (%lu) is in the tree already\n", i);
/* fprintf (block_list, "leaf %d\n", i + j);*/
pass_1_stat (fs)->leaves ++;
/* the leaf may still contain indirect items with wrong
slots. Fix that */
pass1_correct_leaf (fs, bh);
if (get_blkh_nr_items (B_BLK_HEAD (bh)) == 0) {
/* all items were deleted on pass 0 or pass 1 */
mark_buffer_clean (bh);
brelse (bh);
continue;
}
if (is_leaf_bad (bh)) {
/* FIXME: will die */
fsck_log ("is_leaf_bad: WARNING: The leaf (%lu) is formatted badly. Will be handled on the the pass2.\n",
bh->b_blocknr);
mark_block_uninsertable (bh->b_blocknr);
brelse (bh);
continue;
}
if (block_of_journal (fs, i) && fsck_data(fs)->rebuild.use_journal_area) {
/* FIXME: temporary thing */
if (tree_is_empty ()) {
/* we insert inot tree only first leaf of journal */
unsigned long block;
struct buffer_head * new_bh;
block = alloc_block ();
if (!block)
die ("could not allocate block");
new_bh = getblk (bh->b_dev, block, bh->b_size);
memcpy (new_bh->b_data, bh->b_data, bh->b_size);
mark_buffer_uptodate (new_bh, 1);
mark_buffer_dirty (new_bh);
make_single_leaf_tree (new_bh);
brelse (new_bh);
brelse (bh);
continue;
}
/* other blocks of journal will be inserted in pass 2 */
mark_block_uninsertable (bh->b_blocknr);
brelse (bh);
continue;
}
try_to_insert_pointer_to_leaf (bh);
brelse (bh);
}
fsck_progress ("\n");
}
static void after_pass_1 (reiserfs_filsys_t * fs)
{
time_t t;
/* update fsck_state */
/* we should not flush bitmaps on disk after pass1, because
new_bitmap contains only those blocks which are good leaves or
just allocated internal blocks. */
set_sb_fs_state (fs->fs_ondisk_sb, PASS_1_DONE);
mark_buffer_dirty (fs->fs_super_bh);
/* write all dirty blocks */
fsck_progress ("Flushing..");
fs->fs_dirt = 1;
reiserfs_flush (fs);
fsck_progress ("finished\n");
stage_report (1, fs);
/* we do not need this anymore */
delete_aux_bitmaps ();
reiserfs_delete_bitmap (bad_unfm_in_tree_once_bitmap);
if (!fsck_run_one_step (fs)) {
if (fsck_user_confirmed (fs, "Continue? (Yes):", "Yes\n", 1))
/* reiserfsck continues */
return;
} else
save_pass_1_result (fs);
if (proper_id_map (fs)) {
/* when we run pass 1 only - we do not have proper_id_map */
id_map_free(proper_id_map (fs));
proper_id_map (fs) = 0;
}
time (&t);
fsck_progress ("###########\n"
"reiserfsck finished pass 1 at %s"
"###########\n", ctime (&t));
fs->fs_dirt = 1;
reiserfs_close (fs);
exit(0);
}
void pass_1 (reiserfs_filsys_t * fs)
{
fsck_progress ("\nPass 1 (will try to insert %lu leaves):\n",
reiserfs_bitmap_ones (fsck_source_bitmap (fs)));
if (fsck_log_file (fs) != stderr)
fsck_log ("####### Pass 1 #######\n");
before_pass_1 (fs);
/* try to insert leaves found during pass 0 */
do_pass_1 (fs);
after_pass_1 (fs);
}
+641
View File
@@ -0,0 +1,641 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "fsck.h"
/* on pass2 we take leaves which could not be inserted into tree
during pass1 and insert each item separately. It is possible that
items of different objects with the same key can be found. We treat
that in the following way: we put it into tree with new key and
link it into /lost+found directory with name made of dir,oid. When
coming item is a directory - we delete object from the tree, put it
back with different key, link it to /lost+found directory and
insert directory as it is */
/* relocation rules: we have an item (it is taken from "non-insertable"
leaf). It has original key yet. We check to see if object with this
key is remapped. Object can be only remapped if it is not a piece
of directory */
/* 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;
struct relocated * next;
};
/* all relocated files will be linked into lost+found directory at the
beginning of semantic pass */
static struct relocated * relocated_list = NULL;
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) &&
cur->old_objectid == get_key_objectid (key))
/* object is relocated already */
return cur->new_objectid;
cur = cur->next;
}
return 0;
}
/* return objectid the object has to be remapped with */
__u32 objectid_for_relocation (struct key * key)
{
struct relocated * cur;
__u32 cur_id;
if ((cur_id = get_relocated_objectid_from_list (key)) != 0)
return cur_id;
cur = getmem (sizeof (struct relocated));
cur->old_dir_id = get_key_dirid (key);
cur->old_objectid = get_key_objectid (key);
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",
key, get_key_dirid (key), cur->new_objectid);*/
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 */
void save_item (struct si ** head, struct item_head * ih, char * item, __u32 blocknr)
{
struct si * si, * cur;
si = getmem (sizeof (*si));
si->si_dnm_data = getmem (get_ih_item_len(ih));
/*si->si_blocknr = blocknr;*/
memcpy (&(si->si_ih), ih, IH_SIZE);
memcpy (si->si_dnm_data, item, get_ih_item_len(ih));
if (*head == 0)
*head = si;
else {
cur = *head;
while (cur->si_next)
cur = cur->si_next;
cur->si_next = si;
}
return;
}
struct si * save_and_delete_file_item (struct si * si, struct path * path)
{
struct buffer_head * bh = PATH_PLAST_BUFFER (path);
struct item_head * ih = PATH_PITEM_HEAD (path);
save_item (&si, ih, B_I_PITEM (bh, ih), bh->b_blocknr);
/* delete item temporary - do not free unformatted nodes */
reiserfsck_delete_item (path, 1/*temporary*/);
return si;
}
/* check whether there are any directory items with this key */
int should_relocate (struct item_head * ih)
{
struct key key;
struct key * rkey;
struct path path;
struct item_head * path_ih;
/* starting with the leftmost item with this key */
key = ih->ih_key;
set_type_and_offset (KEY_FORMAT_1, &key, SD_OFFSET, TYPE_STAT_DATA);
while (1) {
reiserfs_search_by_key_4 (fs, &key, &path);
if (get_item_pos (&path) == B_NR_ITEMS (get_bh (&path))) {
rkey = uget_rkey (&path);
if (rkey && !not_of_one_file (&key, rkey)) {
/* file continues in the right neighbor */
key = *rkey;
pathrelse (&path);
continue;
}
/* there is no more items with this key */
pathrelse (&path);
break;
}
path_ih = get_ih (&path);
if (not_of_one_file (&key, &(path_ih->ih_key))) {
/* there are no more item with this key */
pathrelse (&path);
break;
}
if (is_stat_data_ih (path_ih)) {
fix_obviously_wrong_sd_mode (&path);
if (ih_checked (path_ih)) {
/* we have checked it already */
pathrelse (&path);
if (get_relocated_objectid_from_list (&path_ih->ih_key))
return 1; /* it was relocated */
break;
} else {
mark_ih_checked (path_ih);
mark_buffer_dirty (get_bh(&path));
}
}
/* ok, item found, but make sure that it is not a directory one */
if ((is_stat_data_ih (path_ih) && !not_a_directory (get_item (&path))) ||
(is_direntry_ih (path_ih))) {
/* item of directory found. so, we have to relocate the file */
pathrelse (&path);
return 1;
}
key = path_ih->ih_key;
set_offset (KEY_FORMAT_1, &key, get_offset (&key) + 1);
pathrelse (&path);
}
return 0;
}
/* this works for both new and old stat data */
#define st_mode(sd) le16_to_cpu(((struct stat_data *)(sd))->sd_mode)
#define st_mtime_v1(sd) le32_to_cpu(((struct stat_data_v1 *)(sd))->sd_mtime)
#define st_mtime_v2(sd) le32_to_cpu(((struct stat_data *)(sd))->sd_mtime)
/* either both sd-s are new of both are old */
static void overwrite_stat_data (struct item_head * new_ih,
void * new_item, struct path * path)
{
__u16 new_mode, old_mode;
get_sd_mode (new_ih, new_item, &new_mode);
get_sd_mode (get_ih (path), get_item (path), &old_mode);
if (S_ISREG (new_mode) && !S_ISREG (old_mode)) {
/* in tree we have not regular file - overwrite its stat data
with stat data of regular file */
memcpy (get_item (path), new_item, get_ih_item_len (get_ih (path)));
mark_buffer_dirty (get_bh (path));
return;
}
if (S_ISREG (old_mode) && !S_ISREG (new_mode)) {
/* new stat data is not a stat data of regular file, keep
regular file stat data in tree */
return;
}
/* if coming stat data has newer mtime - use that */
if (stat_data_v1 (new_ih)) {
if (st_mtime_v1 (new_item) > st_mtime_v1 (get_item (path))) {
memcpy (get_item (path), new_item, SD_V1_SIZE);
mark_buffer_dirty (get_bh (path));
}
} else {
if (st_mtime_v2 (new_item) > st_mtime_v2 (get_item (path))) {
memcpy (get_item (path), new_item, SD_SIZE);
mark_buffer_dirty (get_bh (path));
}
}
return;
}
/* insert sd item if it does not exist, overwrite it otherwise */
static void put_sd_into_tree (struct item_head * new_ih, char * new_item)
{
struct path path;
if (!not_a_directory (new_item)) {
/* new item is a stat data of a directory. So we have to
relocate all items which have the same short key and are of
not a directory */
rewrite_file (new_ih, 1, 0/*do not change new_ih*/);
} else {
/* new item is a stat data of something else but directory. If
there are items of directory - we have to relocate the file */
if (should_relocate (new_ih))
rewrite_file (new_ih, 1, 1/*change new_ih*/);
}
/* if we will have to insert item into tree - it is ready */
zero_nlink (new_ih, new_item);
mark_item_unreachable (new_ih);
/* we are sure now that if we are inserting stat data of a
directory - there are no items with the same key which are not
items of a directory, and that if we are inserting stat data is
of not a directory - it either has new key already or there are
no items with this key which are items of a directory */
if (reiserfs_search_by_key_4 (fs, &(new_ih->ih_key), &path) == ITEM_FOUND) {
/* this stat data is found */
if (get_ih_key_format (get_ih(&path)) != get_ih_key_format (new_ih)) {
/* in tree stat data and a new one are of different
formats */
fsck_log ("put_sd_into_tree: Inserting the StatData %K, mode (%M)...",
&(new_ih->ih_key), st_mode (new_item));
if (stat_data_v1 (new_ih)) {
/* sd to be inserted is of V1, where as sd in the tree
is of V2 */
fsck_log ("found newer in the tree, mode (%M), insersion was skipped.\n",
st_mode (get_item (&path)));
pathrelse (&path);
} else {
/* the stat data in the tree is sd_v1 */
fsck_log ("older sd, mode (%M), is replaced with it.\n",
st_mode (get_item (&path)));
reiserfsck_delete_item (&path, 0/*not temporary*/);
reiserfs_search_by_key_4 (fs, &new_ih->ih_key, &path);
reiserfsck_insert_item (&path, new_ih, new_item);
}
} else {
/* both stat data are of the same version */
overwrite_stat_data (new_ih, new_item, &path);
pathrelse (&path);
}
return;
}
/* item not found, insert a new one */
reiserfsck_insert_item (&path, new_ih, new_item);
}
/* this tries to put each item entry to the tree, if there is no items
of the directory, insert item containing 1 entry */
static void put_directory_item_into_tree (struct item_head * comingih, char * item)
{
struct reiserfs_de_head * deh;
int i;
char * buf;
char * name;
int namelen;
/* if there are anything with this key but a directory - move it
somewhere else */
rewrite_file (comingih, 1, 0/* do not change ih */);
deh = (struct reiserfs_de_head *)item;
for (i = 0; i < get_ih_entry_count (comingih); i ++, deh ++) {
name = name_in_entry (deh, i);
namelen = name_in_entry_length (comingih, deh, i);
if (!is_properly_hashed (fs, name, namelen, get_deh_offset (deh)))
reiserfs_panic ("put_directory_item_into_tree: The entry (%d) \"%.*s\" of the directory %k has"
" badly hashed entry", i, namelen, name, &comingih->ih_key);
asprintf (&buf, "%.*s", namelen, name);
/* 1 for fsck is important: if there is no any items of this
directory in the tree yet - new item will be inserted
marked not reached */
reiserfs_add_entry (fs, &(comingih->ih_key), buf, entry_length (comingih, deh, i),
(struct key *)&(deh->deh2_dir_id), 1 << IH_Unreachable);
free (buf);
}
}
void insert_item_separately (struct item_head * ih,
char * item, int was_in_tree)
{
if (get_key_dirid (&ih->ih_key) == get_key_objectid (&ih->ih_key))
reiserfs_panic ("insert_item_separately: The item being inserted has the bad key %H", ih);
if (is_stat_data_ih (ih)) {
put_sd_into_tree (ih, item);
} else if (is_direntry_ih (ih)) {
put_directory_item_into_tree (ih, item);
} else {
reiserfsck_file_write (ih, item, was_in_tree);
}
}
static void put_stat_data_items (struct buffer_head * bh)
{
int i;
struct item_head * ih;
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < B_NR_ITEMS (bh); i ++, ih ++) {
/* this check instead of saved_items */
if (!is_stat_data_ih (ih) || is_bad_item (bh, ih, B_I_PITEM (bh, ih))) {
continue;
}
insert_item_separately (ih, B_I_PITEM (bh, ih), 0/*was in tree*/);
}
}
static void put_not_stat_data_items (struct buffer_head * bh)
{
int i;
struct item_head * ih;
ih = B_N_PITEM_HEAD (bh, 0);
for (i = 0; i < B_NR_ITEMS (bh); i ++, ih ++) {
if (is_stat_data_ih (ih) || is_bad_item (bh, ih, B_I_PITEM (bh, ih))) {
continue;
}
insert_item_separately (ih, B_I_PITEM (bh, ih), 0/*was in tree*/);
}
}
static void before_pass_2 (reiserfs_filsys_t * fs)
{
/* anything specific for pass 2 ? */
}
static void save_pass_2_result (reiserfs_filsys_t * fs)
{
FILE * file;
int retval;
file = open_file("temp_fsck_file.deleteme", "w+");
if (!file)
return;
/* to be able to restart from semantic we do not need to save
anything here, but two magic values */
reiserfs_begin_stage_info_save(file, TREE_IS_BUILT);
reiserfs_end_stage_info_save (file);
close_file (file);
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",
__FUNCTION__, state_dump_file (fs));
}
/* we have nothing to load from a state file, but we have to fetch
on-disk bitmap, copy it to allocable bitmap, and fetch objectid
map */
void load_pass_2_result (reiserfs_filsys_t * fs)
{
fsck_new_bitmap (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
reiserfs_bitmap_copy (fsck_new_bitmap (fs), fs->fs_bitmap2);
fsck_allocable_bitmap (fs) = reiserfs_create_bitmap (get_sb_block_count (fs->fs_ondisk_sb));
reiserfs_bitmap_copy (fsck_allocable_bitmap (fs), fs->fs_bitmap2);
fs->block_allocator = reiserfsck_reiserfs_new_blocknrs;
fs->block_deallocator = reiserfsck_reiserfs_free_block;
/* we need objectid map on semantic pass to be able to relocate files */
proper_id_map (fs) = id_map_init();
/* Not implemented yet.
fetch_objectid_map (proper_id_map (fs), fs);
*/
}
/* uninsertable blocks are marked by 0s in uninsertable_leaf_bitmap
during the pass 1. They must be not in the tree */
static void do_pass_2 (reiserfs_filsys_t * fs) {
struct buffer_head * bh;
unsigned long j;
int i, what_node;
unsigned long done = 0, total;
total = reiserfs_bitmap_zeros(fsck_uninsertables(fs)) * 2;
if (!total)
return;
fsck_progress ("\nPass 2:\n");
for (i = 0; i < 2; i++) {
j = 0;
while ((j < fsck_uninsertables(fs)->bm_bit_size) &&
reiserfs_bitmap_find_zero_bit(fsck_uninsertables(fs), &j) == 0)
{
bh = bread (fs->fs_dev, j, fs->fs_blocksize);
if (bh == 0) {
fsck_log ("pass_2: Reading of the block (%lu) failed on the device 0x%x\n",
j, fs->fs_dev);
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",
__FUNCTION__, bh->b_blocknr);
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 cont;
}
/*
fsck_log ("block %lu is being inserted\n", bh->b_blocknr);
check_buffers_mem(fsck_log_file (fs));
fflush(fsck_log_file (fs));
*/
if (i) {
/* insert all not SD items */
put_not_stat_data_items (bh);
pass_2_stat (fs)->leaves ++;
make_allocable (j);
} else
/* insert SD items only */
put_stat_data_items (bh);
print_how_far (fsck_progress_file (fs), &done, total, 1, fsck_quiet (fs));
cont:
brelse (bh);
j ++;
}
}
fsck_progress ("\n");
}
static void after_pass_2 (reiserfs_filsys_t * fs)
{
time_t t;
/* we can now flush new_bitmap on disk as tree is built and
contains all data, which were found on dik at start in
used bitmaps */
reiserfs_bitmap_copy (fs->fs_bitmap2, fsck_new_bitmap (fs));
/* we should copy new_bitmap to allocable bitmap, becuase evth what is used
for now (marked as used in new_bitmap) should not be allocablel;
and what is not in tree for now should be allocable.
these bitmaps differ because on pass2 we skip those blocks, whose SD's
are not in the tree, and therefore indirect items of such bad leaves points
to not used and not allocable blocks.
*/
/* DEBUG only */
/* if (reiserfs_bitmap_compare (fsck_allocable_bitmap (fs), fsck_new_bitmap(fs))) {
fsck_log ("Allocable bitmap differs from the new bitmap after pass2\n");
reiserfs_bitmap_copy (fsck_allocable_bitmap(fs), fsck_new_bitmap (fs));
}
*/
/* update super block: objectid map, fsck state */
set_sb_fs_state (fs->fs_ondisk_sb, TREE_IS_BUILT);
mark_buffer_dirty (fs->fs_super_bh);
/* write all dirty blocks */
fsck_progress ("Flushing..");
id_map_flush(proper_id_map (fs), fs);
fs->fs_dirt = 1;
reiserfs_flush_to_ondisk_bitmap (fs->fs_bitmap2, fs);
reiserfs_flush (fs);
fsck_progress ("finished\n");
/* fixme: should be optional */
/* fsck_progress ("Tree is built. Checking it - ");
reiserfsck_check_pass1 ();
fsck_progress ("finished\n");*/
stage_report (2, fs);
/* free what we do not need anymore */
reiserfs_delete_bitmap (fsck_uninsertables (fs));
if (!fsck_run_one_step (fs)) {
if (fsck_user_confirmed (fs, "Continue? (Yes):", "Yes\n", 1))
/* reiserfsck continues */
return;
} else
save_pass_2_result (fs);
id_map_free(proper_id_map (fs));
proper_id_map (fs) = 0;
reiserfs_delete_bitmap (fsck_new_bitmap (fs));
reiserfs_delete_bitmap (fsck_allocable_bitmap (fs));
time (&t);
fsck_progress ("###########\n"
"reiserfsck finished pass 2 at %s"
"###########\n", ctime (&t));
fs->fs_dirt = 1;
reiserfs_close (fs);
exit(0);
}
void pass_2 (reiserfs_filsys_t * fs)
{
if (fsck_log_file (fs) != stderr)
fsck_log ("####### Pass 2 #######\n");
before_pass_2 (fs);
/* take blocks which were not inserted into tree yet and put each
item separately */
do_pass_2 (fs);
after_pass_2 (fs);
if (get_sb_root_block (fs->fs_ondisk_sb) == ~(__u32)0 ||
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");
}
+90
View File
@@ -0,0 +1,90 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "fsck.h"
void pass_4_check_unaccessed_items (void)
{
struct key key;
struct path path;
int i;
struct buffer_head * bh;
struct item_head * ih;
unsigned long items;
struct key * rdkey;
path.path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
key = root_dir_key;
fsck_progress ("Pass 4 - ");
items = 0;
while (reiserfs_search_by_key_4 (fs, &key, &path) == ITEM_FOUND) {
bh = PATH_PLAST_BUFFER (&path);
/* print ~ how many leaves were scanned and how fast it was */
if (!fsck_quiet (fs))
print_how_fast (items++, 0, 50, 0);
for (i = get_item_pos (&path), ih = get_ih (&path); i < B_NR_ITEMS (bh); i ++, ih ++) {
if (!is_item_reachable (ih)) {
PATH_LAST_POSITION (&path) = i;
rdkey = reiserfs_next_key(&path);
if (rdkey)
key = *rdkey;
else
memset (&key, 0xff, KEY_SIZE);
pass_4_stat (fs)->deleted_items ++;
reiserfsck_delete_item (&path, 0);
goto cont;
}
if (get_ih_flags(ih) != 0) {
clean_ih_flags(ih);
mark_buffer_dirty(bh);
}
}
PATH_LAST_POSITION(&path) = i - 1;
rdkey = reiserfs_next_key (&path);
if (rdkey)
key = *rdkey;
else
memset (&key, 0xff, KEY_SIZE);
pathrelse (&path);
cont:
/* to make gcc 3.2 do not sware here */;
}
pathrelse (&path);
fsck_progress ("finished\n");
stage_report (4, fs);
/* after pass 4 */
/* put bitmap on place */
reiserfs_bitmap_copy (fs->fs_bitmap2, fsck_new_bitmap (fs));
/* update super block */
set_sb_free_blocks (fs->fs_ondisk_sb, reiserfs_bitmap_zeros (fsck_new_bitmap (fs)));
mark_buffer_dirty (fs->fs_super_bh);
/* write all dirty blocks */
fsck_progress ("Flushing..");
fs->fs_dirt = 1;
id_map_flush(proper_id_map (fs), fs);
reiserfs_flush_to_ondisk_bitmap (fs->fs_bitmap2, fs);
reiserfs_flush (fs);
fsck_progress ("finished\n");
return;
}
@@ -1,12 +1,12 @@
.\" -*- nroff -*-
.\" Copyright 1996-2004 Hans Reiser.
.\"
.TH fsck.reiserfs 8 "February 2004" "Reiserfsprogs-3.6.19"
.TH REISERFSCK 8 "January 2009" "Reiserfsprogs-3.6.21"
.SH NAME
fsck.reiserfs \- The checking tool for the ReiserFS filesystem.
reiserfsck \- The checking tool for the ReiserFS filesystem.
.SH SYNOPSIS
.B fsck.reiserfs
[ \fB-afprVy\fR ]
.B reiserfsck
[ \fB-aprVy\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 ]
@@ -17,6 +17,7 @@ fsck.reiserfs \- The checking tool for the ReiserFS filesystem.
[ \fB-l\fR | \fB--logfile \fIfile\fR ]
[ \fB-q\fR | \fB--quiet\fR ]
[ \fB-y\fR | \fB--yes\fR ]
[ \fB-f\fR | \fB--force\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 ]
@@ -24,7 +25,7 @@ fsck.reiserfs \- The checking tool for the ReiserFS filesystem.
[ \fB--no-journal-available\fR ]
.I device
.SH DESCRIPTION
\fBfsck.reiserfs\fR searches for a Reiserfs filesystem on a device, replays
\fBReiserfsck\fR searches for a Reiserfs filesystem on a device, replays
any necessary transactions, and either checks or repairs the file system.
.TP
.I device
@@ -58,10 +59,10 @@ for directories, and deleting invalid directory entries.
.B --rebuild-tree
This option rebuilds the entire filesystem tree using leaf nodes
found on the device. Normally you only need this option if the
\fBfsck.reiserfs --check\fR reports "Running with \fB--rebuild-tree\fR
\fBreiserfsck --check\fR reports "Running with \fB--rebuild-tree\fR
is required". You are strongly encouraged to make a backup copy
of the whole partition before attempting the \fB--rebuild-tree\fR
option. Once \fBfsck.reiserfs --rebuild-tree\fR is started it must
option. Once \fBreiserfsck --rebuild-tree\fR is started it must
finish its work (and you should not interrupt it), otherwise the
filesystem will be left in the unmountable state to avoid subsequent
data corruptions.
@@ -81,10 +82,10 @@ from the main data device (although it can be avoided with the expert
option \fB--no-journal-available\fR).
.TP
.\" .B --interactive, -i
.\" This makes \fBfsck.reiserfs\fR to stop after each pass completed.
.\" This makes \fBreiserfsck\fR to stop after each pass completed.
.\" .TP
.B --adjust-size, -z
This option causes \fBfsck.reiserfs\fR to correct file sizes that
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
@@ -94,79 +95,82 @@ byte are corrected by \fB--fix-fixable\fR.
This option sets the badblock list to be the list of blocks specified in
the given `file`. The filesystem badblock list is cleared before the new
list is added. It can be used with \fB--fix-fixable\fR to fix the list of
badblocks (see \fBdebugfs.reiserfs -B\fR). If the device has bad blocks, every
badblocks (see \fBdebugreiserfs -B\fR). If the device has bad blocks, every
time it must be given with the \fB--rebuild-tree\fR option.
.TP
\fB--logfile \fIfile\fR, \fB-l \fI file\fR
This option causes \fBfsck.reiserfs\fR to report any corruption it finds
This option causes \fBreiserfsck\fR to report any corruption it finds
to the specified log file rather than to stderr.
.TP
.B --nolog, -n
This option prevents \fBfsck.reiserfs\fR from reporting any kinds of corruption.
This option prevents \fBreiserfsck\fR from reporting any kinds of corruption.
.TP
.B --quiet, -q
This option prevents \fBfsck.reiserfs\fR from reporting its rate of progress.
This option prevents \fBreiserfsck\fR from reporting its rate of progress.
.TP
.B --yes, -y
This option inhibits \fBfsck.reiserfs\fR from asking you for confirmation after
This option inhibits \fBreiserfsck\fR from asking you for confirmation after
telling you what it is going to do. It will assuem you confirm. For safety,
it does not work with the \fB--rebuild-tree\fR option.
.TP
\fB-a\fR, \fB-p\fR
These options are usually passed by fsck -A during the automatic checking
of those partitions listed in /etc/fstab. These options cause \fBfsck.reiserfs\fR
of those partitions listed in /etc/fstab. These options cause \fBreiserfsck\fR
to print some information about the specified filesystem, to check if error
flags in the superblock are set and to 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 \fBfsck.reiserfs\fR switches
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 \fBfsck.reiserfs\fR finishes with an error.
set in the superblock, then \fBreiserfsck\fR finishes with an error.
.TP
.B --force, -f
Force checking even if the file system seems clean.
.TP
.B -V
This option prints the reiserfsprogs version and then exit.
.TP
\fB-r\fR, \fB-f\fR
These options are not yet operational and therefore are ignored.
\fB-r\fR This option does nothing at all; it is provided only for
backwards compatibility.
.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
OPTIONS.
.TP
.B \fB\--no-journal-available\fR
This option allows \fBfsck.reiserfs\fR to proceed when the journal device is
This option allows \fBreiserfsck\fR to proceed when the journal device is
not available. This option has no effect when the journal is located on
the main data device. NOTE: after this operation you must use \fBtunefs.reiserfs\fR
the main data device. NOTE: after this operation you must use \fBreiserfstune\fR
to specify a new journal device.
.TP
.B --scan-whole-partition, -S
This option causes \fB--rebuild-tree\fR to scan the whole partition but not only
the used space on the partition.
.SH AN EXAMPLE OF USING fsck.reiserfs
.SH AN EXAMPLE OF USING reiserfsck
1. You think something may be wrong with a reiserfs partition on /dev/hda1
or you would just like to perform a periodic disk check.
2. Run \fBfsck.reiserfs --check --logfile check.log /dev/hda1\fR. If \fBfsck.reiserfs
2. Run \fBreiserfsck --check --logfile check.log /dev/hda1\fR. If \fBreiserfsck
--check\fR exits with status 0 it means no errors were discovered.
3. If \fBfsck.reiserfs --check\fR exits with status 1 (and reports about fixable
corruptions) it means that you should run \fBfsck.reiserfs --fix-fixable --logfile
3. If \fBreiserfsck --check\fR exits with status 1 (and reports about fixable
corruptions) it means that you should run \fBreiserfsck --fix-fixable --logfile
fixable.log /dev/hda1\fR.
4. If \fBfsck.reiserfs --check\fR exits with status 2 (and reports about fatal
corruptions) it means that you need to run \fBfsck.reiserfs --rebuild-tree\fR.
If \fBfsck.reiserfs --check\fR fails in some way you should also run \fBfsck.reiserfs
4. If \fBreiserfsck --check\fR exits with status 2 (and reports about fatal
corruptions) it means that you need to run \fBreiserfsck --rebuild-tree\fR.
If \fBreiserfsck --check\fR fails in some way you should also run \fBreiserfsck
--rebuild-tree\fR, but we also encourage you to submit this as a bug report.
5. Before running \fBfsck.reiserfs --rebuild-tree\fR, please make a backup of
the whole partition before proceeding. Then run \fBfsck.reiserfs --rebuild-tree
5. Before running \fBreiserfsck --rebuild-tree\fR, please make a backup of
the whole partition before proceeding. Then run \fBreiserfsck --rebuild-tree
--logfile rebuild.log /dev/hda1\fR.
6. If the \fBfsck.reiserfs --rebuild-tree\fR step fails or does not recover what
6. If the \fBreiserfsck --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 including your platform and Linux kernel version. We
will try to help solve the problem.
.SH EXIT CODES
\fBfsck.reiserfs\fR uses the following exit codes:
\fBreiserfsck\fR uses the following exit codes:
.br
\ \fI0\fR \-\ No errors.
.br
@@ -176,18 +180,18 @@ will try to help solve the problem.
.br
\ \fI4\fR \-\ File system fatal errors left uncorrected,
.br
\ \fBfsck.reiserfs --rebuild-tree\fR needs to be launched.
\ \fBreiserfsck --rebuild-tree\fR needs to be launched.
.br
\ \fI6\fR \-\ File system fixable errors left uncorrected,
.br
\ \fBfsck.reiserfs --fix-fixable\fR needs to be launched.
\ \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 \fBfsck.reiserfs\fR has been written by Vitaly Fertman <vitaly@namesys.com>.
This version of \fBreiserfsck\fR has been written by Vitaly Fertman <vitaly@namesys.com>.
.SH BUGS
Please report bugs to the ReiserFS developers <reiserfs-dev@namesys.com>, providing
as much information as possible--your hardware, kernel, patches, settings, all printed
@@ -195,7 +199,7 @@ messages, the logfile; check the syslog file for any related information.
.SH TODO
Faster recovering, signal handling.
.SH SEE ALSO
.BR mkfs.reiserfs (8),
.BR tunefs.reiserfs (8)
.BR resizefs.reiserfs (8),
.BR debugfs.reiserfs (8),
.BR mkreiserfs (8),
.BR reiserfstune (8)
.BR resize_reiserfs (8),
.BR debugreiserfs (8),
+816
View File
@@ -0,0 +1,816 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by reiserfsprogs/README
*/
#include "fsck.h"
static struct key *trunc_links = NULL;
static __u32 links_num = 0;
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, 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,
struct key * entry_key, struct item_head * ih);
void print_name (char * name, int len);
void erase_name (int len);
struct path_key
{
struct short_key
{
__u32 k_dir_id;
__u32 k_objectid;
} key;
struct path_key * next, * prev;
};
struct path_key * head_key = NULL;
struct path_key * tail_key = NULL;
static int check_path_key(struct key * key)
{
struct path_key * cur = head_key;
while(cur != NULL)
{
if (!comp_short_keys(&cur->key, key)) {
fsck_log("\nsemantic check: The directory %k has 2 names.", key);
return LOOP_FOUND;
}
cur = cur->next;
}
return 0;
}
static int add_path_key(struct key * key)
{
if (check_path_key(key))
return LOOP_FOUND;
if (tail_key == NULL)
{
tail_key = getmem(sizeof(struct path_key));
head_key = tail_key;
tail_key->prev = NULL;
}else{
tail_key->next = getmem(sizeof(struct path_key));
tail_key->next->prev = tail_key;
tail_key = tail_key->next;
}
copy_short_key (&tail_key->key, key);
tail_key->next = NULL;
return 0;
}
void del_path_key()
{
if (tail_key == NULL)
die("Wrong path_key structure");
if (tail_key->prev == NULL)
{
freemem(tail_key);
tail_key = head_key = NULL;
}else{
tail_key = tail_key->prev;
freemem(tail_key->next);
tail_key->next = NULL;
}
}
/* path is path to stat data. If file will be relocated - new_ih will contain
a key file was relocated with */
static int check_check_regular_file (struct path * path, void * sd,
struct item_head * new_ih)
{
int is_new_file;
// struct key key, sd_key;
__u16 mode;
__u32 nlink;
__u64 real_size, sd_size;
__u32 blocks, sd_blocks; /* proper values and value in stat data */
__u32 first_direct_byte, sd_first_direct_byte;
struct item_head * ih, sd_ih;
int fix_sd;
int symlnk = 0;
int retval = OK;
__u32 tmp_position;
ih = get_ih (path);
if (new_ih) {
/* this objectid is used already */
*new_ih = *ih;
pathrelse (path);
rewrite_file (new_ih, 1, 1);
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)
reiserfs_panic ("check_check_regular_file: Could not find a StatData of "
"the relocated file %K", &new_ih->ih_key);
/* stat data is marked unreachable again due to relocation, fix that */
ih = get_ih (path);
sd = get_item (path);
}
if (get_ih_item_len (ih) == SD_SIZE)
is_new_file = 1;
else
is_new_file = 0;
get_sd_nlink (ih, sd, &nlink);
get_sd_mode (ih, sd, &mode);
get_sd_size (ih, sd, &sd_size);
get_sd_blocks (ih, sd, &sd_blocks);
/*
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
// check and set nlink first
nlink ++;
set_sd_nlink (ih, sd, &nlink);
mark_buffer_dirty (bh);
if (nlink > 1)
return OK;
}
*/
if (!is_new_file)
get_sd_first_direct_byte (ih, sd, &sd_first_direct_byte);
if (S_ISLNK (mode))
symlnk = 1;
sd_ih = *ih;
// sd_key = sd_ih.ih_key;
pathrelse (path);
if (are_file_items_correct (&sd_ih, sd, &real_size, &blocks, 0/* do not mark reachable */,
&symlnk) != 1)
{
one_more_corruption (fs, FATAL);
fsck_log ("check_regular_file: The file %K with the corrupted structure found\n",
&sd_ih.ih_key);
} else {
fix_sd = 0;
fix_sd += wrong_mode (&sd_ih.ih_key, &mode, real_size, symlnk);
if (!is_new_file)
fix_sd += wrong_first_direct_byte (&sd_ih.ih_key, fs->fs_blocksize,
&first_direct_byte, sd_first_direct_byte, real_size);
if (reiserfs_bin_search(&sd_ih.ih_key, trunc_links, links_num, sizeof(sd_ih.ih_key),
&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,
symlnk ? TYPE_SYMLINK : 0);
} else {
real_size = sd_size;
}
fix_sd += wrong_st_blocks (&sd_ih.ih_key, &blocks, sd_blocks, mode, is_new_file);
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);
return STAT_DATA_NOT_FOUND;
}
bh = get_bh (path);
ih = get_ih (path);
sd = get_item (path);
set_sd_size (ih, sd, &real_size);
set_sd_blocks (ih, sd, &blocks);
set_sd_mode (ih, sd, &mode);
if (!is_new_file)
set_sd_first_direct_byte (ih, sd, &first_direct_byte);
mark_buffer_dirty (bh);
} else {
fsck_check_stat (fs)->fixable_corruptions += fix_sd;
}
}
}
return retval;
}
/* returns buffer, containing found directory item.*/
static char * get_next_directory_item (
struct key * key, /* on return this will contain key of next item in the tree */
struct key * parent, struct item_head * ih, __u32 * pos_in_item, int dir_format)
{
INITIALIZE_PATH (path);
char * dir_item;
struct key * rdkey;
struct buffer_head * bh;
struct reiserfs_de_head * deh;
int i;
int retval;
start_again:
retval = reiserfs_search_by_entry_key (fs, key, &path);
if (retval != POSITION_FOUND && get_offset (key) != DOT_OFFSET)
reiserfs_panic ("get_next_directory_item: The current directory %k cannot be found",
key);
/* leaf containing directory item */
bh = PATH_PLAST_BUFFER (&path);
*pos_in_item = path.pos_in_item;
*ih = *get_ih (&path);
deh = B_I_DEH (bh, ih);
/* position was not found for '.' or there is no '..' */
if (retval != POSITION_FOUND || ((get_offset (key) == DOT_OFFSET) &&
(get_ih_entry_count (ih) < 2 || name_in_entry_length (ih, deh + 1, 1) != 2 ||
strncmp (name_in_entry (deh + 1, 1), "..", 2)))) {
fsck_log ("get_next_directory_item: The %s %k cannot be found in %k",
(retval == POSITION_NOT_FOUND) ? "entry" : "directory", key, &ih->ih_key);
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
/* add "." and ".." exist */
pathrelse (&path);
reiserfs_add_entry (fs, key, ".", name_length (".", dir_format), key, 0);
reiserfs_add_entry (fs, key, "..", name_length ("..", dir_format), parent, 0);
fsck_log (" - entry was added\n");
goto start_again;
} else {
one_more_corruption (fs, FIXABLE);
fsck_log ("\n");
if (retval == DIRECTORY_NOT_FOUND)
return 0;
}
}
/* make sure, that ".." exists as well */
/*
if (get_offset (key) == DOT_OFFSET) {
if (get_ih_entry_count (ih) < 2 ||
name_in_entry_length (ih, deh + 1, 1) != 2 ||
strncmp (name_in_entry (deh + 1, 1), "..", 2))
{
fsck_log ("get_next_directory_item: \"..\" not found in %H\n", ih);
pathrelse (&path);
return 0;
}
}
*/
/* 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;
char * name;
name = name_in_entry (deh, i);
namelen = name_in_entry_length (ih, deh, i);
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);
*/
if (get_deh_offset (deh) == DOT_OFFSET) {
if (not_of_one_file (&(deh->deh2_dir_id), key)) {
/* "." must point to the directory it is in */
//deh->deh_objectid != REISERFS_ROOT_PARENT_OBJECTID)/*????*/ {
fsck_log ("get_next_directory_item: The entry \".\" of the directory %K "
"pointes to %K, instead of %K", key, (struct key *)(&(deh->deh2_dir_id)),
key);
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
set_deh_dirid (deh, get_key_dirid (key));
set_deh_objectid (deh, get_key_objectid (key));
mark_buffer_dirty (bh);
fsck_log (" - corrected\n");
} else {
one_more_corruption (fs, FIXABLE);
fsck_log ("\n");
}
}
}
if (get_deh_offset (deh) == DOT_DOT_OFFSET) {
/* set ".." so that it points to the correct parent directory */
if (comp_short_keys (&(deh->deh2_dir_id), parent)) {
fsck_log ("get_next_directory_item: The entry \"..\" of the directory %K "
"pointes to %K, instead of %K", key, (struct key *)(&(deh->deh2_dir_id)));
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
set_deh_dirid (deh, get_key_dirid (parent));
set_deh_objectid (deh, get_key_objectid (parent));
mark_buffer_dirty (bh);
fsck_log (" - corrected\n");
} else {
one_more_corruption (fs, FIXABLE);
fsck_log ("\n");
}
}
}
}
/* copy directory item to the temporary buffer */
dir_item = getmem (get_ih_item_len (ih));
memcpy (dir_item, B_I_PITEM (bh, ih), get_ih_item_len (ih));
/* next item key */
if (PATH_LAST_POSITION (&path) == (B_NR_ITEMS (bh) - 1) &&
(rdkey = uget_rkey (&path)))
copy_key (key, rdkey);
else {
set_key_dirid (key, 0);
set_key_objectid (key, 0);
}
if (fsck_mode (fs) == FSCK_REBUILD)
mark_item_reachable (get_ih (&path), bh);
pathrelse (&path);
return dir_item;
}
/* semantic pass of --check */
static int check_semantic_pass (struct key * key, struct key * parent, int dot_dot,
struct item_head * new_ih)
{
struct path path;
void * sd;
__u32 nlink;
int is_new_dir;
struct buffer_head * bh;
struct item_head * ih;
int retval;
char * dir_item;
__u32 pos_in_item;
struct item_head tmp_ih;
struct key next_item_key, entry_key, object_key;
__u64 dir_size = 0;
__u32 blocks;
__u64 sd_size;
__u32 sd_blocks;
int fix_sd;
/*int relocate;*/
int dir_format = 0;
__u16 mode;
retval = OK;
/* 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);
return STAT_DATA_NOT_FOUND;
}
/* look for stat data of an object */
if (reiserfs_search_by_key_4 (fs, key, &path) == ITEM_NOT_FOUND) {
pathrelse (&path);
return STAT_DATA_NOT_FOUND;
}
/* stat data has been found */
ih = get_ih (&path);
sd = get_item(&path);
get_sd_nlink (ih, sd, &nlink);
/* 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 0
if ((/* relocate = */ should_be_relocated(&ih->ih_key))) {
/*
if (fsck_mode(fs) == FSCK_CHECK)
relocate = 0;
*/
one_more_corruption(fs, FATAL);
}
#endif
if (fix_obviously_wrong_sd_mode (&path)) {
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);
}
if (not_a_directory (sd)) {
fsck_check_stat (fs)->files ++;
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 "
"%K", &ih->ih_key);
*new_ih = *ih;
pathrelse (&path);
sem_pass_stat (fs)->oid_sharing_dirs_relocated ++;
relocate_dir (new_ih, 1);
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) {
// it looks like stat data of a directory found
if (nlink) {
// we saw this directory already
if (!dot_dot) {
// this name is not ".." - and hard links are not allowed on directories
pathrelse (&path);
return STAT_DATA_NOT_FOUND;
} else {
// ".." found
nlink ++;
set_sd_nlink (ih, sd, &nlink);
mark_buffer_dirty (get_bh (&path));
pathrelse (&path);
return OK;
}
} // do not run it for dot_dot on check at all
nlink = 2;
if (get_key_objectid (key) == REISERFS_ROOT_OBJECTID)
nlink ++;
set_sd_nlink (ih, sd, &nlink);
mark_buffer_dirty (get_bh (&path));
}
*/
/* directory stat data found */
if (get_ih_item_len (ih) == SD_SIZE)
is_new_dir = 1;
else
is_new_dir = 0;
/* save stat data's size and st_blocks */
get_sd_size (ih, sd, &sd_size);
get_sd_blocks (ih, sd, &sd_blocks);
get_sd_mode (ih, sd, &mode);
dir_format = (get_ih_item_len (get_ih (&path)) == SD_SIZE) ? KEY_FORMAT_2 : KEY_FORMAT_1;
/* release path pointing to stat data */
pathrelse (&path);
fsck_check_stat (fs)->dirs ++;
set_key_dirid (&next_item_key, get_key_dirid (key));
set_key_objectid (&next_item_key, get_key_objectid (key));
set_key_offset_v1 (&next_item_key, DOT_OFFSET);
set_key_uniqueness (&next_item_key, DIRENTRY_UNIQUENESS);
dir_size = 0;
while ((dir_item = get_next_directory_item (&next_item_key, parent, &tmp_ih,
&pos_in_item, dir_format)) != 0)
{
/* dir_item is copy of the item in separately allocated memory,
item_key is a key of next item in the tree */
int i;
char * name = 0;
int namelen, entry_len;
struct reiserfs_de_head * deh = (struct reiserfs_de_head *)dir_item + pos_in_item;
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);
name = 0;
}
namelen = name_in_entry_length (&tmp_ih, deh, i);
asprintf (&name, "%.*s", namelen, name_in_entry (deh, i));
entry_len = entry_length (&tmp_ih, deh, i);
get_object_key (deh, &object_key, &entry_key, &tmp_ih);
if ((dir_format == KEY_FORMAT_2) && (entry_len % 8 != 0)) {
/* not alighed directory of new format - delete it */
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
fsck_log ("Entry %K (\"%.*s\") in the directory %K is not formated "
"properly - deleted\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);
reiserfs_add_entry (fs, key, name, entry_len,
(struct key *)&(deh->deh2_dir_id), 0);
} else {
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);
}
}
print_name (name, namelen);
if (!is_properly_hashed (fs, name, namelen, get_deh_offset (deh))) {
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 ".." */
ret = OK;
} else {
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 ();
}
}
erase_name (namelen);
/* check what check_semantic_tree returned */
switch (ret) {
case OK:
dir_size += DEH_SIZE + entry_len;
break;
case STAT_DATA_NOT_FOUND:
fsck_log ("check_semantic_pass: Name \"%.*s\" in directory %K points to "
"nowhere\n", namelen, name, &tmp_ih.ih_key);
case LOOP_FOUND:
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
reiserfs_remove_entry (fs, &entry_key);
fsck_log (" - removed");
} else {
one_more_corruption (fs, FIXABLE);
}
fsck_log ("\n");
break;
case DIRECTORY_HAS_NO_ITEMS:
fsck_log ("check_semantic_pass: Name \"%.*s\" in directory %K points a "
"directory without body\n", namelen, name, &tmp_ih.ih_key);
/* fixme: stat data should be deleted as well */
/*
if (fsck_fix_fixable (fs)) {
reiserfs_remove_entry (fs, &entry_key);
fsck_data(fs)->deleted_entries ++;
fsck_log (" - removed");
}
fsck_log ("\n");*/
break;
case RELOCATED:
/* file was relocated, update key in corresponding directory entry */
if (reiserfs_search_by_entry_key (fs, &entry_key, &path) != POSITION_FOUND) {
fsck_log("Cannot find a name of the relocated file %K in the directory "
"%K\n", &entry_key, &tmp_ih.ih_key);
} else {
/* update key dir entry points to */
struct reiserfs_de_head * tmp_deh;
tmp_deh = B_I_DEH (get_bh (&path), get_ih (&path)) + path.pos_in_item;
fsck_log ("The directory %K pointing to %K (\"%.*s\") updated to point "
"to ", &tmp_ih.ih_key, &tmp_deh->deh2_dir_id, namelen, name);
set_deh_dirid (tmp_deh, get_key_dirid (&relocated_ih.ih_key));
set_deh_objectid (tmp_deh, get_key_objectid (&relocated_ih.ih_key));
fsck_log ("%K (\"%.*s\")\n", &tmp_deh->deh2_dir_id, namelen, name);
mark_buffer_dirty (get_bh (&path));
}
dir_size += DEH_SIZE + entry_len;
pathrelse (&path);
break;
}
} /* for */
freemem (dir_item);
free (name);
name = 0;
if (not_of_one_file (&next_item_key, key))
/* next key is not of this directory */
break;
} /* while (dir_item) */
if (dir_size == 0)
/* FIXME: is it possible? */
return DIRECTORY_HAS_NO_ITEMS;
/* calc correct value of sd_blocks field of stat data */
blocks = dir_size2st_blocks (dir_size);
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, TYPE_DIRENTRY);
if (fix_sd) {
if (fsck_mode (fs) == FSCK_FIX_FIXABLE) {
/* we have to fix either sd_size or sd_blocks, so look for stat data again */
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);
return STAT_DATA_NOT_FOUND;
}
bh = get_bh (&path);
ih = get_ih (&path);
sd = get_item (&path);
set_sd_size (ih, sd, &dir_size);
set_sd_blocks (ih, sd, &blocks);
mark_buffer_dirty (bh);
pathrelse (&path);
} else {
fsck_check_stat (fs)->fixable_corruptions += fix_sd;
}
}
return retval;
}
int check_safe_links ()
{
struct path safe_link_path, path;
struct key safe_link_key = {-1, 0, {{0, 0}}};
struct key key = {0, 0, {{0, 0}}};
struct key * rkey;
struct item_head * tmp_ih;
while (1) {
if (get_key_dirid (&safe_link_key) == 0)
break;
reiserfs_search_by_key_4 (fs, &safe_link_key, &safe_link_path);
if (get_blkh_nr_items ( B_BLK_HEAD (get_bh(&safe_link_path))) <=
PATH_LAST_POSITION (&safe_link_path))
{
pathrelse (&safe_link_path);
break;
}
tmp_ih = get_ih(&safe_link_path);
if (get_key_dirid(&tmp_ih->ih_key) != (__u32)-1 ||
get_key_objectid(&tmp_ih->ih_key) == (__u32)-1) {
pathrelse (&safe_link_path);
break;
}
if (get_ih_item_len (tmp_ih) != 4)
reiserfs_panic ("Safe Link %k cannot be of the size %d",
&tmp_ih->ih_key, get_ih_item_len (tmp_ih));
set_key_dirid(&key, d32_get((__u32 *)get_item(&safe_link_path), 0));
set_key_objectid(&key, get_key_objectid(&tmp_ih->ih_key));
if ((rkey = reiserfs_next_key(&safe_link_path)) == NULL)
set_key_dirid (&safe_link_key, 0);
else
safe_link_key = *rkey;
if (reiserfs_search_by_key_4 (fs, &key, &path) == ITEM_NOT_FOUND) {
/*sware on check, delete on fix-fixable*/
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);
} 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);
d32_put((__u32 *)get_item(&safe_link_path), 0, 0);
pathrelse (&path);
reiserfsck_delete_item (&safe_link_path, 0);
continue;
}
} else if (get_offset(&tmp_ih->ih_key) == 0x1) {
/* Truncate */
if (!not_a_directory (get_item(&path))) {
/*truncate on directory should not happen*/
/*sware on check, delete on fix-fixable*/
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);
} 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);
d32_put((__u32 *)get_item(&safe_link_path), 0, 0);
pathrelse (&path);
reiserfsck_delete_item (&safe_link_path, 0);
continue;
}
} else {
/* save 'safe truncate links' to avoid swaring on wrong sizes. */
__u32 position;
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,
sizeof(key), &position);
}
}
}
pathrelse (&path);
pathrelse (&safe_link_path);
}
return OK;
}
void release_safe_links () {
freemem(trunc_links);
}
/* called when --check is given */
void semantic_check (void)
{
if (fsck_data (fs)->check.bad_nodes) {
fsck_progress ("Bad nodes were found, Semantic pass skipped\n");
goto clean;
}
if (fsck_data (fs)->check.fatal_corruptions) {
fsck_progress ("Fatal corruptions were found, Semantic pass skipped\n");
goto clean;
}
fsck_progress ("Checking Semantic tree:\n");
if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
/*create new_bitmap, and initialize new_bitmap & allocable bitmap*/
fsck_new_bitmap (fs) = reiserfs_create_bitmap(get_sb_block_count(fs->fs_ondisk_sb));
reiserfs_bitmap_copy (fsck_new_bitmap (fs), fs->fs_bitmap2);
fsck_allocable_bitmap (fs) = reiserfs_create_bitmap(get_sb_block_count
(fs->fs_ondisk_sb));
reiserfs_bitmap_copy (fsck_allocable_bitmap (fs), fs->fs_bitmap2);
fs->block_allocator = reiserfsck_reiserfs_new_blocknrs;
fs->block_deallocator = reiserfsck_reiserfs_free_block;
}
check_safe_links ();
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);
}
release_safe_links ();
if (fsck_mode(fs) == FSCK_FIX_FIXABLE) {
reiserfs_delete_bitmap (fs->fs_bitmap2);
reiserfs_bitmap_delta (fsck_new_bitmap (fs), fsck_deallocate_bitmap (fs));
fs->fs_bitmap2 = fsck_new_bitmap (fs);
reiserfs_delete_bitmap (fsck_allocable_bitmap (fs));
fsck_allocable_bitmap (fs) = NULL;
set_sb_free_blocks (fs->fs_ondisk_sb, reiserfs_bitmap_zeros (fs->fs_bitmap2));
mark_buffer_dirty (fs->fs_super_bh);
add_badblock_list(fs, 1);
}
fsck_progress ("finished\n");
clean:
if (fsck_deallocate_bitmap (fs))
reiserfs_delete_bitmap (fsck_deallocate_bitmap (fs));
}
File diff suppressed because it is too large. Load diff
+254 -285
View File
@@ -3,19 +3,7 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "fsck.h"
#include "misc/malloc.h"
#include "misc/device.h"
#include "util/print.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
# include <uuid/uuid.h>
@@ -28,7 +16,8 @@
int what_fs_version ()
{
char answer[256];
size_t n = 0;
char * answer = 0;
int version;
printf("\nwhat the version of ReiserFS do you use[1-4]\n"
"\t(1) 3.6.x\n"
@@ -36,10 +25,10 @@ int what_fs_version ()
"\t(3) < 3.5.9 converted to new format (don't choose if unsure)\n"
"\t(4) < 3.5.9 (this is very old format, don't choose if unsure)\n"
"\t(X) exit\n");
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
version = atoi (answer);
if (version < 1 || version > 4)
misc_die ("rebuild_sb: wrong version");
die ("rebuild_sb: wrong version");
return version;
}
@@ -52,14 +41,14 @@ int what_fs_version ()
int check_sb (reiserfs_filsys_t * fs) {
int magic = 0, version = 0;
if (!reiserfs_fs_blksize_check (fs->fs_blocksize))
if (!is_blocksize_correct (fs->fs_blocksize))
super_error(-1, "Wrong blocksize found in the super block\n");
if (reiserfs_super_36_magic (sb))
if (is_reiserfs_3_6_magic_string (sb))
magic = 2;
else if (reiserfs_super_35_magic (sb))
else if (is_reiserfs_3_5_magic_string (sb))
magic = 1;
else if (reiserfs_super_jr_magic (sb))
else if (is_reiserfs_jr_magic_string (sb))
magic = 3;
else
super_error(-1, "Invalid magic found in the super block.\n");
@@ -78,59 +67,59 @@ int check_sb (reiserfs_filsys_t * fs) {
standard_journal = 0;
}
if (reiserfs_sb_get_version (sb) != REISERFS_FORMAT_3_6 && reiserfs_sb_get_version (sb) != REISERFS_FORMAT_3_5)
if (get_sb_version (sb) != REISERFS_FORMAT_3_6 && get_sb_version (sb) != REISERFS_FORMAT_3_5)
super_error(-1, "Invalid format found in the super block.\n");
if (reiserfs_new_location(fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
if (is_new_sb_location(fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
{
if (magic == 3)
version = reiserfs_sb_get_version (sb) == REISERFS_FORMAT_3_6 ? 1 : 2;
version = get_sb_version (sb) == REISERFS_FORMAT_3_6 ? 1 : 2;
else
version = magic == 2 ? 1 : 2;
} else if (reiserfs_old_location(fs->fs_super_bh->b_blocknr, fs->fs_blocksize)) {
} else if (is_old_sb_location(fs->fs_super_bh->b_blocknr, fs->fs_blocksize)) {
if (magic == 3)
version = reiserfs_sb_get_version (sb) == REISERFS_FORMAT_3_6 ? 3 : 4;
version = get_sb_version (sb) == REISERFS_FORMAT_3_6 ? 3 : 4;
else
version = magic == 2 ? 3 : 4;
} else
misc_die("Super block in the wong block(%d).\n", fs->fs_super_bh->b_blocknr);
die("Super block in the wong block(%d).\n", fs->fs_super_bh->b_blocknr);
if (version == 0)
misc_die ("FS format must be figured out here.\n");
die ("FS format must be figured out here.\n");
if (reiserfs_sb_get_blocks (sb) > misc_device_count_blocks (filename, fs->fs_blocksize))
if (get_sb_block_count (sb) > count_blocks (filename, fs->fs_blocksize))
super_error(-1, "Invalid block count found in the super block.\n");
if (reiserfs_sb_get_blksize (sb) != fs->fs_blocksize)
if (get_sb_block_size (sb) != fs->fs_blocksize)
super_error(-1, "Invalid block size found in the super block (%lu).\n",
reiserfs_sb_get_blksize (sb));
get_sb_block_size (sb));
//Non needed from here
p_oid_maxsize = (fs->fs_blocksize - reiserfs_super_size (sb)) / sizeof(__u32) / 2 * 2;
if (reiserfs_sb_get_mapmax (sb) != p_oid_maxsize)
p_oid_maxsize = (fs->fs_blocksize - reiserfs_super_block_size (sb)) / sizeof(__u32) / 2 * 2;
if (get_sb_oid_maxsize (sb) != p_oid_maxsize)
super_error(-1, "Invalid objectid map max size found in the super block (%lu).\n",
reiserfs_sb_get_mapmax (sb));
get_sb_oid_maxsize (sb));
if (reiserfs_sb_get_mapcur (sb) == 1 || reiserfs_sb_get_mapcur (sb) > reiserfs_sb_get_mapmax (sb))
if (get_sb_oid_cursize (sb) == 1 || get_sb_oid_cursize (sb) > get_sb_oid_maxsize (sb))
super_error(-1, "Invalid objectid map found in the super block (%lu).\n",
reiserfs_sb_get_mapcur (sb));
get_sb_oid_cursize (sb));
if (reiserfs_sb_get_root (sb) > block_count && reiserfs_sb_get_root (sb) != ~0)
if (get_sb_root_block (sb) > block_count && get_sb_root_block (sb) != ~0)
fsck_log("Invalid root block found in the super block (%lu).\n",
reiserfs_sb_get_root (sb));
get_sb_root_block (sb));
if (reiserfs_sb_get_free (sb) > block_count)
if (get_sb_free_blocks (sb) > block_count)
fsck_log ("Invalid free block count found in the super block (%lu).\n",
reiserfs_sb_get_free (sb));
get_sb_free_blocks (sb));
if (reiserfs_sb_get_height (sb) && ((reiserfs_sb_get_height (sb) < LEAF_LEVEL + 1) ||
(reiserfs_sb_get_height (sb) > REISERFS_TREE_HEIGHT_MAX) && (reiserfs_sb_get_height (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) && (get_sb_tree_height (sb) != ~0)))
super_error(-1, "Invalid tree height found in the super block (%lu).\n",
reiserfs_sb_get_height (sb));
get_sb_tree_height (sb));
if (reiserfs_sb_get_hash (sb) && reiserfs_hash_name (reiserfs_sb_get_hash (sb)) == 0)
if (get_sb_hash_code (sb) && code2name (get_sb_hash_code (sb)) == 0)
super_error(-1, "Invalid hash found in the super block (%lu).\n",
reiserfs_sb_get_hash (sb));
get_sb_hash_code (sb));
if (version == 1 || version == 3) {
if (!uuid_is_correct(sb->s_uuid))
@@ -143,36 +132,36 @@ int check_sb (reiserfs_filsys_t * fs) {
//Not needed till here.
p_bmap_nr = (block_count + (fs->fs_blocksize * 8 - 1)) / (fs->fs_blocksize * 8);
if (reiserfs_sb_get_bmaps (sb) != p_bmap_nr)
if (get_sb_bmap_nr (sb) != p_bmap_nr)
super_error(-1, "Invalid bitmap number found in the super block (%lu).\n",
reiserfs_sb_get_bmaps (sb));
get_sb_bmap_nr (sb));
if (!fsck_skip_journal (fs) && standard_journal == 1) {
if (reiserfs_jp_get_dev (reiserfs_sb_jp(sb)) != 0)
super_error(-1, "Invalid journal device found (%lu).\n", reiserfs_jp_get_dev (reiserfs_sb_jp(sb)));
if (get_jp_journal_dev (sb_jp(sb)) != 0)
super_error(-1, "Invalid journal device found (%lu).\n", get_jp_journal_dev (sb_jp(sb)));
if (reiserfs_jp_get_start (reiserfs_sb_jp(sb)) != reiserfs_journal_start_must (fs))
super_error(-1, "Invalid journal first block found (%lu).\n", reiserfs_jp_get_start (reiserfs_sb_jp(sb)));
if (get_jp_journal_1st_block (sb_jp(sb)) != get_journal_start_must (fs))
super_error(-1, "Invalid journal first block found (%lu).\n", get_jp_journal_1st_block (sb_jp(sb)));
if (reiserfs_jp_get_size (reiserfs_sb_jp(sb)) != reiserfs_journal_default(fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
super_error(-1, "Invalid journal size found (%lu).\n", reiserfs_jp_get_size (reiserfs_sb_jp(sb)) + 1);
if (get_jp_journal_size (sb_jp(sb)) != journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize))
super_error(-1, "Invalid journal size found (%lu).\n", get_jp_journal_size (sb_jp(sb)) + 1);
if (reiserfs_jp_get_max_batch (reiserfs_sb_jp(sb)) != reiserfs_journal_batch(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb)))) {
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",
reiserfs_jp_get_max_batch (reiserfs_sb_jp(sb)), reiserfs_journal_batch(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb))));
reiserfs_jp_set_max_batch (reiserfs_sb_jp(sb), reiserfs_journal_batch(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb))));
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 (reiserfs_jp_get_commit_age (reiserfs_sb_jp(sb)) != reiserfs_journal_commit_age()) {
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",
reiserfs_jp_get_commit_age (reiserfs_sb_jp(sb)), reiserfs_journal_commit_age());
reiserfs_jp_set_commit_age (reiserfs_sb_jp(sb), reiserfs_journal_commit_age());
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 (reiserfs_jp_get_trans_age (reiserfs_sb_jp(sb)) != reiserfs_journal_trans_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",
reiserfs_jp_get_trans_age (reiserfs_sb_jp(sb)), reiserfs_journal_trans_age());
reiserfs_jp_set_trans_age (reiserfs_sb_jp(sb), reiserfs_journal_trans_age());
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());
}
@@ -181,23 +170,26 @@ int check_sb (reiserfs_filsys_t * fs) {
void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * data)
{
struct reiserfs_journal_header *j_head;
__u32 p_jp_journal_1st_block = 0;
int retval, exit_code = EXIT_OK;
reiserfs_sb_t * ondisk_sb = 0;
unsigned long block_count = 0;
char * journal_dev_name = 0;
int standard_journal = -1;
int magic_was_found = 0;
__u32 p_jp_dev_size = 0;
reiserfs_sb_t * sb = 0;
struct stat stat_buf;
__u16 p_oid_maxsize;
char answer[256];
__u32 p_bmap_nr;
int version = 0;
int sb_size;
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;
__u16 p_oid_maxsize;
unsigned int bmap_nr;
__u32 p_jp_journal_1st_block = 0;
__u32 p_jp_dev_size = 0;
int standard_journal = -1;
char * journal_dev_name = 0;
char * tmp;
int sb_size;
char * answer = 0;
size_t n = 0;
struct stat stat_buf;
int retval, exit_code = EXIT_OK;
#if defined(HAVE_LIBUUID) && defined(HAVE_UUID_UUID_H)
char uuid[37];
@@ -205,25 +197,21 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
uuid[36] = '\0';
#endif
if (fs != NULL) {
sb = misc_getmem (sizeof (*sb));
if (!reiserfs_fs_rw (fs)) {
if (!no_reiserfs_found (fs)) {
sb = getmem (sizeof (*sb));
if (!is_opened_rw (fs)) {
close (fs->fs_dev);
fs->fs_dev = open (fs->fs_file_name, O_RDWR
#ifdef O_LARGEFILE
| O_LARGEFILE
#endif
);
fs->fs_dev = open (fs->fs_file_name, O_RDWR | O_LARGEFILE);
}
if (!reiserfs_fs_blksize_check (fs->fs_blocksize)) {
if (!is_blocksize_correct (fs->fs_blocksize)) {
printf("\nCannot find a proper blocksize, enter block size [4096]: \n");
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
if (strcmp(answer, "\n")) {
retval = (int) strtol (answer, &tmp, 0);
if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified\n");
if (!reiserfs_fs_blksize_check (retval))
if (!is_blocksize_correct (retval))
reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified, "
"only power of 2 from 512-8192 interval are supported.\n");
} else
@@ -232,7 +220,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
fs->fs_blocksize = retval;
}
if (!(block_count = misc_device_count_blocks (filename, fs->fs_blocksize)))
if (!(block_count = count_blocks (filename, fs->fs_blocksize)))
exit(EXIT_OPER);
/* save ondisk_sb somewhere and work in temp area */
@@ -240,7 +228,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
memcpy (sb, fs->fs_ondisk_sb, sizeof (*sb));
fs->fs_ondisk_sb = sb;
if (reiserfs_super_36_magic (sb)) {
if (is_reiserfs_3_6_magic_string (sb)) {
/* 3_6 magic */
if (fsck_data (fs)->journal_dev_name)
/* journal dev must not be specified with standard journal */
@@ -255,7 +243,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
version = 3;
magic_was_found = 2;
} else if (reiserfs_super_35_magic (sb)) {
} 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 (EXIT_USER, "ReiserFS with default journal "
@@ -270,8 +258,13 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
version = 4;
magic_was_found = 1;
} else if (reiserfs_super_jr_magic (sb)) {
if (reiserfs_sb_get_version (sb) == REISERFS_FORMAT_3_6) {
} else if (is_reiserfs_jr_magic_string (sb)) {
if (!fsck_data (fs)->journal_dev_name && !fsck_skip_journal(fs))
/* journal dev must be specified with non standard journal */
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 (fs->fs_super_bh->b_blocknr ==
REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
@@ -281,7 +274,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
version = 3;
magic_was_found = 3;
} else if (reiserfs_sb_get_version (sb) == REISERFS_FORMAT_3_5) {
} else if (get_sb_version (sb) == REISERFS_FORMAT_3_5) {
/* non-standard magic + sb_format == 3_5 */
if (fs->fs_super_bh->b_blocknr ==
REISERFS_DISK_OFFSET_IN_BYTES / fs->fs_blocksize)
@@ -308,44 +301,40 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
if (version == 0)
version = what_fs_version ();
if (reiserfs_sb_get_blocks (sb) != block_count) {
if (get_sb_block_count (sb) != block_count) {
do {
printf("\nDid you use resizer(y/n)[n]: ");
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
} while(strcmp ("y\n", answer) &&
strcmp ("n\n", answer) &&
strcmp ("\n", answer));
if (!strcmp ("y\n", answer)) {
printf("\nEnter partition size [%lu]: ", block_count);
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
if (strcmp ("\n", answer))
block_count = atoi (answer);
} else {
fsck_conditional_log (magic_was_found, "rebuild-sb: wrong block count "
"occured (%lu), fixed (%lu)\n", reiserfs_sb_get_blocks(sb), block_count);
"occured (%lu), fixed (%lu)\n", get_sb_block_count(sb), block_count);
}
reiserfs_sb_set_blocks (sb, block_count);
set_sb_block_count (sb, block_count);
}
if (reiserfs_sb_get_blksize (sb) != fs->fs_blocksize) {
if (get_sb_block_size (sb) != fs->fs_blocksize) {
fsck_log("rebuild-sb: wrong block size occured (%lu), fixed (%lu)\n",
reiserfs_sb_get_blksize (sb), fs->fs_blocksize);
reiserfs_sb_set_blksize (sb, fs->fs_blocksize);
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 (fs == NULL) {
if (no_reiserfs_found (fs)) {
int fd;
fd = open (filename, O_RDWR
#ifdef O_LARGEFILE
| O_LARGEFILE
#endif
);
fd = open (filename, O_RDWR | O_LARGEFILE);
if (fd == -1) {
reiserfs_exit (EXIT_OPER, "rebuils_sb: cannot open device %s",
@@ -358,37 +347,33 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
retval = 4096;
} else {
printf("\nEnter block size [4096]: \n");
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
if (strcmp(answer, "\n")) {
retval = (int) strtol (answer, &tmp, 0);
if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified\n");
if (!reiserfs_fs_blksize_check (retval))
if (!is_blocksize_correct (retval))
reiserfs_exit (EXIT_USER, "rebuild_sb: wrong block size specified, "
"only divisible by 1024 are supported currently\n");
} else
retval = 4096;
}
if (!(block_count = misc_device_count_blocks (filename, retval)))
if (!(block_count = count_blocks (filename, retval)))
exit(EXIT_OPER);
switch(version){
case 1:
fs = reiserfs_fs_create (filename, REISERFS_FORMAT_3_6,
block_count, retval, 1, 1);
fs = reiserfs_create (filename, REISERFS_FORMAT_3_6, block_count, retval, 1, 1);
break;
case 2:
fs = reiserfs_fs_create (filename, REISERFS_FORMAT_3_5,
block_count, retval, 1, 1);
fs = reiserfs_create (filename, REISERFS_FORMAT_3_5, block_count, retval, 1, 1);
break;
case 3:
fs = reiserfs_fs_create (filename, REISERFS_FORMAT_3_6,
block_count, retval, 1, 0);
fs = reiserfs_create (filename, REISERFS_FORMAT_3_6, block_count, retval, 1, 0);
break;
case 4:
fs = reiserfs_fs_create (filename, REISERFS_FORMAT_3_5,
block_count, retval, 1, 0);
fs = reiserfs_create (filename, REISERFS_FORMAT_3_5, block_count, retval, 1, 0);
break;
}
@@ -405,7 +390,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
"available, re-run with --no-journal-available option specified).\n"
"Is journal default? (y/n)[y]: ");
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
} while(strcmp ("y\n", answer) &&
strcmp ("n\n", answer) &&
strcmp ("\n", answer));
@@ -424,100 +409,98 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
do {
printf("\nDid you use resizer(y/n)[n]: ");
fgets(answer, sizeof(answer), stdin);
} while (strcmp ("y\n", answer) &&
strcmp ("n\n", answer) &&
strcmp ("\n", answer));
getline (&answer, &n, stdin);
} while (strcmp ("y\n", answer) && strcmp ("n\n", answer) && strcmp ("\n", answer));
if (!strcmp ("y\n", answer)) {
printf("\nEnter partition size [%lu]: ", block_count);
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
if (strcmp ("\n", answer))
block_count = atoi (answer);
reiserfs_sb_set_blocks (sb, block_count);
set_sb_block_count (sb, block_count);
}
reiserfs_sb_set_state (sb, FS_ERROR);
set_sb_fs_state (sb, FS_ERROR);
}
if (version == 1 || version == 3) {
if (reiserfs_super_format (sb) != REISERFS_FORMAT_3_6) {
if (get_reiserfs_format (sb) != REISERFS_FORMAT_3_6) {
fsck_log("rebuild-sb: wrong reiserfs version occured (%lu), fixed (%lu)\n",
reiserfs_super_format (sb), REISERFS_FORMAT_3_6);
reiserfs_sb_set_version (sb, REISERFS_FORMAT_3_6);
get_reiserfs_format (sb), REISERFS_FORMAT_3_6);
set_sb_version (sb, REISERFS_FORMAT_3_6);
}
} else if (version == 2 || version == 4) {
if (reiserfs_super_format (sb) != REISERFS_FORMAT_3_5) {
if (get_reiserfs_format (sb) != REISERFS_FORMAT_3_5) {
fsck_log("rebuild-sb: wrong reiserfs version occured (%lu), fixed (%lu)\n",
reiserfs_super_format (sb), REISERFS_FORMAT_3_5);
reiserfs_sb_set_version (sb, REISERFS_FORMAT_3_5);
get_reiserfs_format (sb), REISERFS_FORMAT_3_5);
set_sb_version (sb, REISERFS_FORMAT_3_5);
}
}
p_oid_maxsize = (fs->fs_blocksize - reiserfs_super_size (sb)) /
p_oid_maxsize = (fs->fs_blocksize - reiserfs_super_block_size (sb)) /
sizeof(__u32) / 2 * 2;
if (reiserfs_sb_get_mapmax (sb) != p_oid_maxsize) {
if (get_sb_oid_maxsize (sb) != p_oid_maxsize) {
fsck_log("rebuild-sb: wrong objectid map max size occured (%lu), fixed (%lu)\n",
reiserfs_sb_get_mapmax (sb), p_oid_maxsize);
reiserfs_sb_set_mapmax (sb, p_oid_maxsize);
get_sb_oid_maxsize (sb), p_oid_maxsize);
set_sb_oid_maxsize (sb, p_oid_maxsize);
}
p_bmap_nr = reiserfs_bmap_nr(block_count, fs->fs_blocksize);
p_bmap_nr = reiserfs_bmap_over(p_bmap_nr) ? 0 : p_bmap_nr;
if (reiserfs_sb_get_bmaps (sb) != p_bmap_nr) {
fsck_log("rebuild-sb: wrong bitmap number occured (%lu), fixed (%lu)\n",
reiserfs_sb_get_bmaps (sb), p_bmap_nr);
reiserfs_sb_set_bmaps (sb, (__u16)p_bmap_nr);
bmap_nr = reiserfs_fs_bmap_nr(fs);
if (reiserfs_bmap_over(bmap_nr) && get_sb_bmap_nr(sb) != 0) {
fsck_log("rebuild-sb: wrong bitmap number occured (%u), fixed (0) "
"(really %u)\n", get_sb_bmap_nr (sb), bmap_nr);
set_sb_bmap_nr (sb, 0);
} else if (get_sb_bmap_nr(sb) != bmap_nr) {
fsck_log("rebuild-sb: wrong bitmap number occured (%u), "
"fixed (%u)\n", get_sb_bmap_nr (sb), bmap_nr);
set_sb_bmap_nr (sb, bmap_nr);
}
if (reiserfs_sb_get_root (sb) > block_count) {
if (get_sb_root_block (sb) > block_count) {
fsck_log("rebuild-sb: wrong root block occured (%lu), zeroed\n",
reiserfs_sb_get_root (sb));
reiserfs_sb_set_root (sb, 0);
get_sb_root_block (sb));
set_sb_root_block (sb, 0);
}
if (reiserfs_sb_get_free (sb) > block_count) {
if (get_sb_free_blocks (sb) > block_count) {
fsck_log ("rebuild-sb: wrong free block count occured (%lu), zeroed\n",
reiserfs_sb_get_free (sb));
reiserfs_sb_set_free (sb, 0);
get_sb_free_blocks (sb));
set_sb_free_blocks (sb, 0);
}
if (reiserfs_sb_get_umount (sb) != FS_CLEANLY_UMOUNTED &&
reiserfs_sb_get_umount (sb) != FS_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", reiserfs_sb_get_umount (sb));
reiserfs_sb_set_umount (sb, FS_NOT_CLEANLY_UMOUNTED);
"fixed to (FS_NOT_CLEANLY_UMOUNTED)\n", get_sb_umount_state (sb));
set_sb_umount_state (sb, FS_NOT_CLEANLY_UMOUNTED);
}
if (reiserfs_sb_get_mapcur (sb) == 1 ||
reiserfs_sb_get_mapcur (sb) > reiserfs_sb_get_mapmax (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",
reiserfs_sb_get_mapcur (sb));
get_sb_oid_cursize (sb));
reiserfs_sb_set_mapcur (sb, 0);
set_sb_oid_cursize (sb, 0);
}
if ( reiserfs_sb_get_height (sb) &&
((reiserfs_sb_get_height (sb) < LEAF_LEVEL + 1) ||
(reiserfs_sb_get_height (sb) > REISERFS_TREE_HEIGHT_MAX)) ) {
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 (%u), zeroed\n",
reiserfs_sb_get_height (sb));
get_sb_tree_height (sb));
reiserfs_sb_set_height (sb, 0);
set_sb_tree_height (sb, 0);
}
if (reiserfs_sb_get_hash (sb) &&
reiserfs_hash_name (reiserfs_sb_get_hash (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",
reiserfs_sb_get_hash (sb));
get_sb_hash_code (sb));
reiserfs_sb_set_hash (sb, 0);
set_sb_hash_code (sb, 0);
}
if (version == 1 || version == 3) {
@@ -540,8 +523,8 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
if we have a standard journal
reserved = 0
dev - same
size = reiserfs_journal_default(fs->fs_super_bh->b_blocknr, fs)
offset = reiserfs_journal_default(fs)
size = journal_default_size(fs->fs_super_bh->b_blocknr, fs)
offset = journal_default_size(fs)
if we have a non standard journal
if we found magic string
try to find a jhead and comare dev, size, offset there
@@ -553,44 +536,39 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
*/
p_jp_journal_1st_block = reiserfs_journal_start_must (fs);
p_jp_journal_1st_block = get_journal_start_must (fs);
if (standard_journal == 1) {
if (reiserfs_jp_get_dev (reiserfs_sb_jp(sb)) != 0) {
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", reiserfs_jp_get_dev (reiserfs_sb_jp(sb)));
reiserfs_jp_set_dev (reiserfs_sb_jp(sb), 0);
"occured (%lu), fixed (0)\n", get_jp_journal_dev (sb_jp(sb)));
set_jp_journal_dev (sb_jp(sb), 0);
}
if (reiserfs_sb_get_reserved (sb) != 0) {
if (get_sb_reserved_for_journal (sb) != 0) {
fsck_log ("rebuild-sb: wrong size reserved for default journal occured "
"(%lu), fixed (0)\n", reiserfs_sb_get_reserved (sb));
reiserfs_sb_set_reserved (sb, 0);
"(%lu), fixed (0)\n", get_sb_reserved_for_journal (sb));
set_sb_reserved_for_journal (sb, 0);
}
if (reiserfs_jp_get_start (reiserfs_sb_jp(sb)) != p_jp_journal_1st_block) {
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", reiserfs_jp_get_start (reiserfs_sb_jp(sb)),
"block occured (%lu), fixed (%lu)\n", get_jp_journal_1st_block (sb_jp(sb)),
p_jp_journal_1st_block);
reiserfs_jp_set_start (reiserfs_sb_jp(sb) , p_jp_journal_1st_block);
set_jp_journal_1st_block (sb_jp(sb) , p_jp_journal_1st_block);
}
if (reiserfs_jp_get_size (reiserfs_sb_jp(sb)) !=
reiserfs_journal_default(fs->fs_super_bh->b_blocknr, 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 size "
"occured (%lu), fixed (%lu)\n", reiserfs_jp_get_size (reiserfs_sb_jp(sb)) + 1,
reiserfs_journal_default (fs->fs_super_bh->b_blocknr,
"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);
reiserfs_jp_set_size (reiserfs_sb_jp(sb),
reiserfs_journal_default (fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
set_jp_journal_size (sb_jp(sb),
journal_default_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize));
}
if ((retval = reiserfs_journal_open(fs, filename, O_RDWR
#ifdef O_LARGEFILE
| O_LARGEFILE
#endif
)))
{
if ((retval = reiserfs_open_journal(fs, filename, O_RDWR | O_LARGEFILE))) {
fsck_log("\nrebuild-sb: Failed to open the journal device (%s).\n",
filename);
@@ -600,36 +578,37 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
/* Check that specified non-standard journal device exists. */
journal_dev_name = fsck_data (fs)->journal_dev_name;
retval = stat(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_journal_open(fs, journal_dev_name, O_RDWR
#ifdef O_LARGEFILE
| O_LARGEFILE
#endif
);
retval = reiserfs_open_journal(fs, journal_dev_name,
O_RDWR | O_LARGEFILE);
if (retval == 0) {
journal_dev_name = fs->fs_j_file_name;
j_head = (struct reiserfs_journal_header *)(fs->fs_jh_bh->b_data);
retval = memcmp(&j_head->jh_journal, reiserfs_sb_jp(sb),
sizeof(reiserfs_journal_param_t));
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_journal_close(fs);
reiserfs_close_journal(fs);
}
}
if (!reiserfs_journal_opened(fs)) {
fsck_log ("Journal cannot be opened, assuming the "
"journal device %s is correct\n", journal_dev_name);
fsck_log ("Journal cannot be opened, assuming specified "
"journal device is correct\n");
}
}
@@ -641,27 +620,27 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
default_value = (!strcmp(fs->fs_file_name, journal_dev_name)) ?
p_jp_journal_1st_block : 0;
else
default_value = reiserfs_jp_get_start (reiserfs_sb_jp(sb));
default_value = get_jp_journal_1st_block (sb_jp(sb));
printf("\nEnter journal offset on %s in blocks [%Lu]: \n",
journal_dev_name, (unsigned long long)default_value);
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
if (strcmp(answer, "\n")) {
retval = (int) strtol (answer, &tmp, 0);
if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
reiserfs_exit(EXIT_USER, "rebuild_sb: wrong offset specified\n");
reiserfs_jp_set_start (reiserfs_sb_jp(sb), retval);
set_jp_journal_1st_block (sb_jp(sb), retval);
} else
reiserfs_jp_set_start (reiserfs_sb_jp(sb), default_value);
set_jp_journal_1st_block (sb_jp(sb), default_value);
if (!(p_jp_dev_size = misc_device_count_blocks (journal_dev_name, fs->fs_blocksize)))
if (!(p_jp_dev_size = count_blocks (journal_dev_name, fs->fs_blocksize)))
exit(EXIT_OPER);
/* some checks for journal offset */
if (strcmp(fs->fs_file_name, journal_dev_name) != 0) {
if (p_jp_dev_size < reiserfs_jp_get_start (reiserfs_sb_jp(sb)) + 1)
if (p_jp_dev_size < get_jp_journal_1st_block (sb_jp(sb)) + 1)
reiserfs_exit(EXIT_USER, "rebuild_sb: offset is much than device size\n");
}
@@ -670,44 +649,41 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
header */
if (magic_was_found == 0)
default_value = (!strcmp(fs->fs_file_name, journal_dev_name)) ?
reiserfs_journal_default (fs->fs_super_bh->b_blocknr,
journal_default_size (fs->fs_super_bh->b_blocknr,
fs->fs_blocksize) + 1 :
p_jp_dev_size - reiserfs_jp_get_start (reiserfs_sb_jp(sb));
p_jp_dev_size - get_jp_journal_1st_block (sb_jp(sb));
else
default_value = reiserfs_jp_get_size (reiserfs_sb_jp(sb)) + 1;
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);
fgets(answer, sizeof(answer), stdin);
getline (&answer, &n, stdin);
if (strcmp(answer, "\n")) {
retval = (int) strtol (answer, &tmp, 0);
if ((*tmp && strcmp(tmp, "\n")) || retval < 0)
reiserfs_exit(EXIT_USER, "rebuild_sb: wrong offset specified\n");
reiserfs_jp_set_size (reiserfs_sb_jp(sb), retval - 1);
set_jp_journal_size (sb_jp(sb), retval - 1);
} else {
reiserfs_jp_set_size (reiserfs_sb_jp(sb), default_value - 1);
set_jp_journal_size (sb_jp(sb), default_value - 1);
}
/* some checks for journal size */
if (reiserfs_jp_get_size (reiserfs_sb_jp(sb)) +
reiserfs_jp_get_start (reiserfs_sb_jp(sb)) + 1 > p_jp_dev_size)
if (get_jp_journal_size (sb_jp(sb)) +
get_jp_journal_1st_block (sb_jp(sb)) + 1 > p_jp_dev_size)
reiserfs_exit(EXIT_USER, "rebuild_sb: journal offset + journal size is "
"greater than device size\n");
/* some checks for journal size */
if (reiserfs_jp_get_size (reiserfs_sb_jp(sb)) < JOURNAL_MIN_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 ((retval = reiserfs_journal_open(fs, journal_dev_name, O_RDWR
#ifdef O_LARGEFILE
| O_LARGEFILE
#endif
)))
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);
@@ -720,94 +696,87 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
magic_was_found = 0;
}
retval = stat(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));
if (strcmp (fs->fs_file_name, journal_dev_name))
reiserfs_jp_set_dev (reiserfs_sb_jp(sb), stat_buf.st_rdev);
set_jp_journal_dev (sb_jp(sb), stat_buf.st_rdev);
else
reiserfs_jp_set_dev (reiserfs_sb_jp(sb), 0);
set_jp_journal_dev (sb_jp(sb), 0);
} else {
fsck_log ("\nJournal was specified as not available. reiserfstune is "
"needed.\n\n");
reiserfs_jp_set_magic (reiserfs_sb_jp(sb), NEED_TUNE);
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 (reiserfs_jp_get_tlen (reiserfs_sb_jp(sb)) !=
reiserfs_journal_tlen(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb)),
reiserfs_jp_get_size (reiserfs_sb_jp(sb)),
fs->fs_blocksize, 0))
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",
reiserfs_jp_get_tlen (reiserfs_sb_jp(sb)),
reiserfs_journal_tlen(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb)),
reiserfs_jp_get_size (reiserfs_sb_jp(sb)),
fs->fs_blocksize, 0));
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));
reiserfs_jp_set_tlen (reiserfs_sb_jp(sb),
reiserfs_journal_tlen(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb)),
reiserfs_jp_get_size (reiserfs_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 (reiserfs_jp_get_max_batch (reiserfs_sb_jp(sb)) !=
reiserfs_journal_batch(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb))))
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",
reiserfs_jp_get_max_batch (reiserfs_sb_jp(sb)),
reiserfs_journal_batch(reiserfs_jp_get_tlen (reiserfs_sb_jp(sb))));
get_jp_journal_max_batch (sb_jp(sb)),
advise_journal_max_batch(get_jp_journal_max_trans_len (sb_jp(sb))));
reiserfs_jp_set_max_batch (reiserfs_sb_jp(sb),
reiserfs_journal_batch(reiserfs_jp_get_tlen (reiserfs_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 (reiserfs_jp_get_commit_age (reiserfs_sb_jp(sb)) !=
reiserfs_journal_commit_age())
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",
reiserfs_jp_get_commit_age (reiserfs_sb_jp(sb)), reiserfs_journal_commit_age());
get_jp_journal_max_commit_age (sb_jp(sb)), advise_journal_max_commit_age());
reiserfs_jp_set_commit_age (reiserfs_sb_jp(sb), reiserfs_journal_commit_age());
set_jp_journal_max_commit_age (sb_jp(sb), advise_journal_max_commit_age());
}
if (reiserfs_jp_get_trans_age (reiserfs_sb_jp(sb)) != reiserfs_journal_trans_age()) {
fsck_log ("rebuild-sb: wrong journal transaction age occured (%u), "
"fixed (%u)\n", reiserfs_jp_get_trans_age (reiserfs_sb_jp(sb)),
reiserfs_journal_trans_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());
reiserfs_jp_set_trans_age (reiserfs_sb_jp(sb), reiserfs_journal_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 (reiserfs_jp_get_magic (reiserfs_sb_jp(sb)) == 0 ||
reiserfs_jp_get_magic (reiserfs_sb_jp(sb)) == NEED_TUNE)
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);
reiserfs_jp_set_magic (reiserfs_sb_jp(sb), magic);
reiserfs_jp_set_magic (&j_head->jh_journal, magic);
set_jp_journal_magic (sb_jp(sb), magic);
set_jp_journal_magic (&j_head->jh_journal, magic);
}
}
retval = memcmp(&j_head->jh_journal, reiserfs_sb_jp(sb), sizeof(reiserfs_journal_param_t));
retval = memcmp(&j_head->jh_journal, sb_jp(sb), sizeof(struct journal_params));
if (retval) {
if (standard_journal == 1) {
@@ -826,7 +795,7 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
}
if (standard_journal || !magic_was_found) {
if (!util_user_confirmed (stdout, "Do you want to rebuild the journal header? "
if (!user_confirmed (stdout, "Do you want to rebuild the journal header? "
"(y/n)[n]: ", "y\n"))
{
exit(EXIT_USER);
@@ -834,9 +803,9 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
exit_code = EXIT_FIXED;
}
memcpy(&j_head->jh_journal, reiserfs_sb_jp(sb), sizeof(reiserfs_journal_param_t));
reiserfs_buffer_mkdirty(fs->fs_jh_bh);
reiserfs_buffer_write (fs->fs_jh_bh);
memcpy(&j_head->jh_journal, sb_jp(sb), sizeof(struct journal_params));
mark_buffer_dirty(fs->fs_jh_bh);
bwrite (fs->fs_jh_bh);
}
}
@@ -844,41 +813,41 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
checked in open_journal */
if (version == 1 || version == 3)
sb_size = REISERFS_SB_SIZE;
sb_size = SB_SIZE;
else
sb_size = REISERFS_SB_SIZE_V1;
sb_size = SB_SIZE_V1;
if (ondisk_sb == NULL ||
memcmp(ondisk_sb, sb, sb_size - ((sb_size == REISERFS_SB_SIZE) ?
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 */
reiserfs_sb_set_state (sb, reiserfs_sb_get_state (sb) | FS_ERROR);
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 */
fs->fs_ondisk_sb = ondisk_sb;
memcpy (ondisk_sb, sb, sb_size);
misc_freemem(sb);
freemem(sb);
}
fflush(stdout);
reiserfs_node_print (stderr, fs, fs->fs_super_bh);
print_block (stderr, fs, fs->fs_super_bh);
if (util_user_confirmed (stderr, "Is this ok ? (y/n)[n]: ", "y\n")) {
reiserfs_buffer_mkuptodate (fs->fs_super_bh, 1);
reiserfs_buffer_mkdirty (fs->fs_super_bh);
reiserfs_buffer_write (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 ("The fs may still be unconsistent. Run reiserfsck --check.\n\n");
exit_code = EXIT_FIXED;
} else {
reiserfs_buffer_mkclean (fs->fs_super_bh);
mark_buffer_clean (fs->fs_super_bh);
fsck_progress ("Super block was not written\n");
}
} else {
reiserfs_node_print (stderr, fs, fs->fs_super_bh);
print_block (stderr, fs, fs->fs_super_bh);
reiserfs_buffer_mkclean (fs->fs_super_bh);
mark_buffer_clean (fs->fs_super_bh);
fsck_progress ("\nSuper block seems to be correct\n\n");
}
@@ -886,8 +855,8 @@ void rebuild_sb (reiserfs_filsys_t * fs, char * filename, struct fsck_data * dat
}
/* if (version == 0) {
reiserfs_buffer_close (fs->fs_super_bh);
misc_freemem (fs);
brelse (fs->fs_super_bh);
freemem (fs);
close (fs->fs_dev);
fs = NULL;
}
+81 -68
View File
@@ -3,14 +3,7 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "fsck.h"
#include "misc/malloc.h"
#include <assert.h>
/* g_disk_bitmap initially contains copy of disk bitmaps
(cautious version of it);
@@ -25,7 +18,7 @@
If block contains internal node, put 0 in g_disk_bitmap if block is
not used in new tree yet.
If block contains leaf and is used already (by an extent item
If block contains leaf and is used already (by an indirect item
handled already to this time) save all items. They will be inserted
into tree after pass 1.
@@ -37,8 +30,8 @@
found block containing the internal nodes we mark it in
g_disk_bitmap as free (reiserfs_free_internal_block). When block
gets into new tree it is marked in g_new_bitmap (mark_block_used)
When collecting resources for reiserfs_tb_balance, we mark new blocks with
mark_block_used. After reiserfs_tb_balance we unmark unused new blocks in
When collecting resources for do_balance, we mark new blocks with
mark_block_used. After do_balance we unmark unused new blocks in
g_new_bitmap (bitmap.c:/reiserfs_free_block)
Allocating of new blocks: look for 0 bit in g_disk_bitmap
@@ -51,66 +44,65 @@
/* is blocks used (marked by 1 in new bitmap) in the tree which is being built
(as leaf, internal, bitmap, or unformatted node) */
int is_block_used (unsigned long block) {
int is_block_used (unsigned long block)
{
return reiserfs_bitmap_test_bit (fsck_new_bitmap (fs), block);
}
void mark_block_used (unsigned long block, int check_hardware) {
void mark_block_used (unsigned long block, int check_hardware)
{
if (!block)
return;
if (is_block_used (block)) {
if (check_hardware)
fsck_info_checkmem();
misc_die ("mark_block_used: (%lu) used already", block);
check_memory_msg();
die ("mark_block_used: (%lu) used already", block);
}
reiserfs_bitmap_set_bit (fsck_new_bitmap (fs), block);
}
void mark_block_free (unsigned long block) {
void mark_block_free (unsigned long block)
{
if (!is_block_used (block))
misc_die ("mark_block_free: (%lu) is free already", block);
die ("mark_block_free: (%lu) is free already", block);
reiserfs_bitmap_clear_bit (fsck_new_bitmap (fs), block);
}
int fsck_bitmap_isuninsert (unsigned long block) {
int is_block_uninsertable (unsigned long block)
{
return !reiserfs_bitmap_test_bit (fsck_uninsertables (fs), block);
}
void fsck_bitmap_cluninsert (unsigned long block) {
reiserfs_bitmap_set_bit (fsck_uninsertables (fs), block);
pass_1_stat (fs)->uninsertable_leaves --;
}
/* uninsertable block is marked by bit clearing */
void fsck_bitmap_mkuninsert (unsigned long block) {
if (fsck_bitmap_isuninsert (block))
misc_die ("%s: (%lu) is uninsertable already",
__FUNCTION__, block);
void mark_block_uninsertable (unsigned long block)
{
if (is_block_uninsertable (block))
die ("mark_block_uninsertable: (%lu) is uninsertable already", block);
reiserfs_bitmap_clear_bit (fsck_uninsertables (fs), block);
/* we do not need thsi actually */
pass_1_stat (fs)->uninsertable_leaves ++;
}
/* FIXME: should be able to work around no disk space */
int reiserfsck_new_blocknrs (reiserfs_filsys_t * fs,
unsigned long * free_blocknrs,
unsigned long start,
int amount_needed)
int reiserfsck_reiserfs_new_blocknrs (reiserfs_filsys_t * fs,
unsigned long * free_blocknrs,
unsigned long start, int amount_needed)
{
int i;
if (!are_there_allocable_blocks (amount_needed))
misc_die ("out of disk space");
die ("out of disk space");
for (i = 0; i < amount_needed; i ++) {
free_blocknrs[i] = alloc_block ();
if (!free_blocknrs[i])
misc_die ("reiserfsck_new_blocknrs: 0 is allocated");
die ("reiserfs_new_blocknrs: 0 is allocated");
mark_block_used (free_blocknrs[i], 0);
}
return CARRY_ON;
@@ -122,20 +114,20 @@ int reiserfsck_new_blocknrs (reiserfs_filsys_t * fs,
// allocation in future you should have bad block counter in a super
// block. Another minor issue: users of _get_new_buffer expect buffer
// to be filled with 0s
reiserfs_bh_t * reiserfsck_get_new_buffer (unsigned long start) {
struct buffer_head * reiserfsck_get_new_buffer (unsigned long start)
{
unsigned long blocknr = 0;
reiserfs_bh_t * bh = NULL;
struct buffer_head * bh = NULL;
assert(fs->block_allocator != NULL);
fs->block_allocator(fs, &blocknr, start, 1);
bh = reiserfs_buffer_open (fs->fs_dev, blocknr, fs->fs_blocksize);
reiserfs_new_blocknrs (fs, &blocknr, start, 1);
bh = getblk (fs->fs_dev, blocknr, fs->fs_blocksize);
return bh;
}
/* free block in new bitmap */
int reiserfsck_free_block (reiserfs_filsys_t * fs, unsigned long block) {
int reiserfsck_reiserfs_free_block (reiserfs_filsys_t * fs, unsigned long block)
{
mark_block_free (block);
/* put it back to pool of blocks for allocation */
@@ -143,35 +135,56 @@ int reiserfsck_free_block (reiserfs_filsys_t * fs, unsigned long block) {
return 0;
}
/* these are used to allocate blocks for tree building */
int are_there_allocable_blocks (unsigned int amout_needed) {
if (reiserfs_bitmap_zeros (fsck_allocable_bitmap (fs)) < amout_needed) {
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 ++) {
if (!reiserfs_bitmap_test_bit (fsck_allocable_bitmap (fs), i))
zeros ++;
}
fsck_progress ("there are %u allocable blocks, btw\n", zeros);
return 0;
}
return 1;
}
void make_allocable (unsigned long block) {
reiserfs_bitmap_clear_bit (fsck_allocable_bitmap (fs), block);
}
unsigned long alloc_block (void) {
unsigned long block = 0; /* FIXME: start point could be used */
if (reiserfs_bitmap_find_zero_bit (fsck_allocable_bitmap (fs), &block)) {
misc_die ("alloc_block: Allocable blocks counter is wrong");
return 0;
}
reiserfs_bitmap_set_bit (fsck_allocable_bitmap (fs), block);
return block;
}
+1222
View File
File diff suppressed because it is too large. Load diff
+89 -130
View File
@@ -3,12 +3,7 @@
* reiserfsprogs/README
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "fsck.h"
#include "misc/malloc.h"
/* when --check fsck builds a map of objectids of files it finds in the tree
@@ -20,7 +15,7 @@
/* 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 INDEX_COUNT ((MAX_ID / BM_INTERVAL) + 1)
#define id_map_interval(map, id) (map->index + (id / BM_INTERVAL))
@@ -37,8 +32,8 @@ id_map_t *id_map_init() {
id_map_t *map;
__u32 i;
map = misc_getmem(sizeof(id_map_t));
map->index = misc_malloc(INDEX_COUNT * sizeof(void *));
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)
@@ -59,11 +54,11 @@ void id_map_free(id_map_t *map) {
for (i = 0; i < INDEX_COUNT; i++) {
if (map->index[i] != (void *)0 && map->index[i] != (void *)1)
misc_freemem(map->index[i]);
freemem(map->index[i]);
}
misc_freemem(map->index);
misc_freemem(map);
freemem(map->index);
freemem(map);
}
int id_map_test(id_map_t *map, __u32 id) {
@@ -82,7 +77,7 @@ int id_map_mark(id_map_t *map, __u32 id) {
void **interval = id_map_interval(map, id);
if (*interval == (void *)0)
*interval = misc_getmem(ALLOC_SIZE);
*interval = getmem(ALLOC_SIZE);
if (*interval == (void *)1)
return 1;
@@ -97,7 +92,7 @@ int id_map_mark(id_map_t *map, __u32 id) {
if ((*(__u16 *)id_map_local_count(*interval)) == BM_INTERVAL) {
/* Dealloc fully used bitmap */
misc_freemem(*interval);
freemem(*interval);
*interval = (void *)1;
}
@@ -125,7 +120,7 @@ __u32 id_map_alloc(id_map_t *map) {
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)
misc_die ("Id is out of interval size, interval looks corrupted.");
die ("Id is out of interval size, interval looks corrupted.");
id += i * BM_INTERVAL;
} else if (first != ~(__u32)0) {
@@ -133,7 +128,7 @@ __u32 id_map_alloc(id_map_t *map) {
if (id == 0)
id = 2;
} else
misc_die ("%s: No more free objectid is available.", __FUNCTION__);
die ("%s: No more free objectid is available.", __FUNCTION__);
id_map_mark(map, id);
@@ -150,25 +145,23 @@ static void sb_id_map_pack(sb_id_map_t *map) {
static __u32 id_map_next_bound(id_map_t *map, __u32 start) {
__u32 index = start / BM_INTERVAL;
__u32 offset = 0;
__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 {
offset = start % BM_INTERVAL;
else
look_for = !misc_test_bit(offset, map->index[index]);
offset++;
}
offset++;
start_again:
if (look_for) {
while (index < INDEX_COUNT && map->index[index] == (void *)0) {
while (index < INDEX_COUNT && map->index[index] == (void *)0)
index++;
}
if (index == INDEX_COUNT)
return 0;
@@ -176,14 +169,15 @@ start_again:
if (map->index[index] == (void *)1)
return index * BM_INTERVAL;
offset = misc_find_next_set_bit(map->index[index],
BM_INTERVAL, offset);
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++;
@@ -194,17 +188,16 @@ start_again:
if (map->index[index] == (void *)0)
return index * BM_INTERVAL;
offset = misc_find_next_zero_bit(map->index[index],
BM_INTERVAL, offset);
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;
}
return index * BM_INTERVAL + offset;
}
void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
@@ -212,40 +205,33 @@ void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
__u32 id, prev_id;
__u32 * sb_objectid_map;
size = reiserfs_super_size (fs->fs_ondisk_sb);
size = reiserfs_super_block_size (fs->fs_ondisk_sb);
sb_objectid_map = (__u32 *)((char *)(fs->fs_ondisk_sb) + size);
max = ((fs->fs_blocksize - size) >> 3 << 1);
reiserfs_sb_set_mapmax (fs->fs_ondisk_sb, max);
set_sb_oid_maxsize (fs->fs_ondisk_sb, max);
id = 1;
sb_objectid_map[0] = cpu_to_le32(0);
sb_objectid_map[0] = cpu_to_le32(1);
for (i = 1; i < max - 1; i++) {
id = id_map_next_bound(map, id);
sb_objectid_map[i] = cpu_to_le32(id);
if (id == 0) {
if (i % 2) {
misc_die ("%s: Used interval is not closed "
"on flushing.", __FUNCTION__);
}
if (i % 2)
die ("%s: Used interval is not closed on flushing.", __FUNCTION__);
break;
}
}
if (map->index[map->last_used] == (void *)0) {
misc_die ("Object id map looks corrupted - last "
"used interval cannot be zeroed.");
}
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) {
misc_die ("Objectid interval does not contain "
"any set bit what is expected.");
}
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;
@@ -266,130 +252,103 @@ void id_map_flush(struct id_map * map, reiserfs_filsys_t * fs) {
prev_id = id;
}
if (prev_id == ~(__u32)0) {
misc_die ("Objectid interval does not contain "
"any set bit what is expected.");
}
if (prev_id == ~(__u32)0)
die ("Objectid interval does not contain any set bit what is expected.");
prev_id++;
}
sb_objectid_map[max - 1] =
cpu_to_le32(prev_id + map->last_used * BM_INTERVAL);
} else {
sb_objectid_map[max - 1] = cpu_to_le32(prev_id + map->last_used * BM_INTERVAL);
} else {
i--;
memset(sb_objectid_map + i, 0, (max - i) * sizeof (__u32));
}
reiserfs_sb_set_mapcur (fs->fs_ondisk_sb, i);
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)
void fetch_objectid_map (struct id_map * map, reiserfs_filsys_t * fs)
{
__u32 i, j, sb_size;
int sb_size;
__u32 * sb_objectid_map;
sb_size = reiserfs_super_size (fs->fs_ondisk_sb);
sb_size = reiserfs_super_block_size (fs->fs_ondisk_sb);
sb_objectid_map = (__u32 *)((char *)(fs->fs_ondisk_sb) + sb_size);
if (map == NULL)
misc_die ("Not map given");
if (map->m_page_count != 1)
die ("fetch_objectid_map: can not fetch long map");
for (i = 0; i < reiserfs_sb_get_mapcur(fs->fs_ondisk_sb); i+=2) {
for (j = sb_objectid_map[i]; j < sb_objectid_map[i + 1]; j++) {
id_map_mark(map, j);
if (j == 0)
map->count--;
}
}
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_slot_count = get_sb_oid_cursize (fs->fs_ondisk_sb);
}
#define OBJMAP_START_MAGIC 375331
#define OBJMAP_END_MAGIC 7700472
void reiserfs_objectid_map_save (FILE * fp, struct id_map * id_map) {
__u32 v, count;
void reiserfs_objectid_map_save (FILE * fp, struct id_map * id_map)
{
__u32 v;
int i;
v = OBJMAP_START_MAGIC;
fwrite (&v, 4, 1, fp);
v = 0;
count = 0;
/* Write 0. */
v = id_map->m_used_slot_count;
fwrite (&v, 4, 1, fp);
count++;
while ((v = id_map_next_bound(id_map, v))) {
fwrite (&v, 4, 1, fp);
count++;
for (i = 0; i < id_map->m_page_count - 1; i++) {
fwrite ((char *)id_map->m_begin + MAP_SIZE * i, 4, 1, fp);
}
fwrite (&count, 4, 1, fp);
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);
}
v = OBJMAP_END_MAGIC;
fwrite (&v, 4, 1, fp);
}
struct id_map * reiserfs_objectid_map_load (FILE * fp) {
__u32 v, count, i, prev, next;
struct id_map * reiserfs_objectid_map_load (FILE * fp)
{
__u32 v;
int i;
struct id_map * id_map;
int skip, odd;
id_map = id_map_init();
fread (&v, 4, 1, fp);
if (v != OBJMAP_START_MAGIC) {
reiserfs_warning (stderr, "reiserfs_objectid_map_load: no "
"objectid map begin magic found");
goto error;
reiserfs_warning (stderr, "reiserfs_objectid_map_load: no objectid map begin magic found");
return 0;
}
// read bit size of objectid map
fread (&v, 4, 1, fp);
id_map = init_id_map (MAP_NOT_PACKED);
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);
for (i = 0; i < id_map->m_page_count - 1; i++) {
fread ((char *)id_map->m_begin + MAP_SIZE * i, 4, 1, fp);
}
count = 0;
skip = 0;
odd = 0;
prev = 0;
while (1) {
if (skip) {
skip = 0;
v = next;
} else if (fread(&v, 4, 1, fp) != 1) {
reiserfs_warning (stderr, "%s: failed to read the given",
__FUNCTION__);
goto error;
}
if (v == count) {
/* Check if the magic goes after. */
if (fread(&next, 4, 1, fp) != 1) {
reiserfs_warning (stderr, "%s: failed to read the given",
__FUNCTION__);
goto error;
}
if (next != OBJMAP_END_MAGIC)
skip = 1;
else break;
}
if (odd) {
for (i = prev; i < v; i++) {
id_map_mark(id_map, i);
if (i == 0)
id_map->count--;
}
}
prev = v;
odd = odd ? 0 : 1;
count++;
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);
}
return id_map;
error:
fread (&v, 4, 1, fp);
if (v != OBJMAP_END_MAGIC) {
reiserfs_warning (stderr, "reiserfs_objectid_map_load: no objectid map end magic found");
return 0;
}
fflush (stderr);
id_map_free(id_map);
return NULL;
return id_map;
}
*/
+289
View File
@@ -0,0 +1,289 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "fsck.h"
#include "progbar.h"
struct tree_balance * cur_tb = 0;
void reiserfsck_paste_into_item (struct path * path, const char * body, int size)
{
struct tree_balance tb;
init_tb_struct (&tb, fs, path, size);
if (fix_nodes (/*tb.transaction_handle,*/ M_PASTE, &tb, 0/*ih*/) != CARRY_ON)
//fix_nodes(options, tree_balance, ih_to_option, body_to_option)
die ("reiserfsck_paste_into_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, 0, body, M_PASTE, 0/*zero num*/);
}
void reiserfsck_insert_item (struct path * path, struct item_head * ih, const char * body)
{
struct tree_balance tb;
init_tb_struct (&tb, fs, path, IH_SIZE + get_ih_item_len(ih));
if (fix_nodes (/*tb.transaction_handle,*/ M_INSERT, &tb, ih/*, body*/) != CARRY_ON)
die ("reiserfsck_insert_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, ih, body, M_INSERT, 0/*zero num*/);
}
static void free_unformatted_nodes (struct item_head * ih, struct buffer_head * bh)
{
__u32 * punfm = (__u32 *)B_I_PITEM (bh, ih);
unsigned int i;
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
__u32 unfm = d32_get (punfm, i);
if (unfm != 0) {
struct buffer_head * to_be_forgotten;
to_be_forgotten = find_buffer (fs->fs_dev, unfm, fs->fs_blocksize);
if (to_be_forgotten) {
//atomic_inc(&to_be_forgotten->b_count);
to_be_forgotten->b_count ++;
bforget (to_be_forgotten);
}
reiserfs_free_block (fs, unfm);
}
}
}
void reiserfsck_delete_item (struct path * path, int temporary)
{
struct tree_balance tb;
struct item_head * ih = PATH_PITEM_HEAD (path);
if (is_indirect_ih (ih) && !temporary)
free_unformatted_nodes (ih, PATH_PLAST_BUFFER (path));
init_tb_struct (&tb, fs, path, -(IH_SIZE + get_ih_item_len(ih)));
if (fix_nodes (/*tb.transaction_handle,*/ M_DELETE, &tb, 0/*ih*/) != CARRY_ON)
die ("reiserfsck_delete_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, 0, 0, M_DELETE, 0/*zero num*/);
}
void reiserfsck_cut_from_item (struct path * path, int cut_size)
{
struct tree_balance tb;
struct item_head * ih;
if (cut_size >= 0)
die ("reiserfsck_cut_from_item: cut size == %d", cut_size);
if (is_indirect_ih (ih = PATH_PITEM_HEAD (path))) {
struct buffer_head *bh = PATH_PLAST_BUFFER (path);
__u32 unfm_ptr = d32_get ((__u32 *)B_I_PITEM(bh, ih), I_UNFM_NUM (ih) - 1);
if (unfm_ptr != 0) {
struct buffer_head * to_be_forgotten;
to_be_forgotten = find_buffer (fs->fs_dev, unfm_ptr, fs->fs_blocksize);
if (to_be_forgotten) {
//atomic_inc(&to_be_forgotten->b_count);
to_be_forgotten->b_count ++;
bforget (to_be_forgotten);
}
reiserfs_free_block (fs, unfm_ptr);
}
}
init_tb_struct (&tb, fs, path, cut_size);
if (fix_nodes (/*tb.transaction_handle,*/ M_CUT, &tb, 0) != CARRY_ON)
die ("reiserfsck_cut_from_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, 0, 0, M_CUT, 0/*zero num*/);
}
/* uget_rkey is utils clone of stree.c/get_rkey */
/*
struct key * uget_rkey (struct path * path)
{
int pos, offset = path->path_length;
struct buffer_head * bh;
if (offset < FIRST_PATH_ELEMENT_OFFSET)
die ("uget_rkey: illegal offset in the path (%d)", offset);
while (offset-- > FIRST_PATH_ELEMENT_OFFSET) {
if (! buffer_uptodate (PATH_OFFSET_PBUFFER (path, offset)))
die ("uget_rkey: parent is not uptodate");
// Parent at the path is not in the tree now.
if (! B_IS_IN_TREE (bh = PATH_OFFSET_PBUFFER (path, offset)))
die ("uget_rkey: buffer on the path is not in tree");
// Check whether position in the parrent is correct.
if ((pos = PATH_OFFSET_POSITION (path, offset)) > B_NR_ITEMS (bh))
die ("uget_rkey: invalid position (%d) in the path", pos);
// Check whether parent at the path really points to the child.
if (get_dc_child_blocknr (B_N_CHILD (bh, pos)) != PATH_OFFSET_PBUFFER (path, offset + 1)->b_blocknr)
die ("uget_rkey: invalid block number (%d). Must be %ld",
get_dc_child_blocknr (B_N_CHILD (bh, pos)), PATH_OFFSET_PBUFFER (path, offset + 1)->b_blocknr);
// Return delimiting key if position in the parent is not the last one.
if (pos != B_NR_ITEMS (bh))
return B_N_PDELIM_KEY(bh, pos);
}
// there is no right delimiting key
return 0;
}
*/
static unsigned long first_child (struct buffer_head * bh)
{
return get_dc_child_blocknr (B_N_CHILD (bh, 0));
}
#if 0
static unsigned long last_child (struct buffer_head * bh)
{
return child_block_number (bh, node_item_number (bh));
}
#endif
static unsigned long get_child (int pos, struct buffer_head * parent)
{
if (pos == -1)
return -1;
if (pos > B_NR_ITEMS (parent))
die ("get_child: no child found, should not happen: %d of %d", pos, B_NR_ITEMS (parent));
return get_dc_child_blocknr (B_N_CHILD (parent, pos));
}
static void print (int cur, int total)
{
if (fsck_quiet (fs))
return;
printf ("/%3d (of %3d)", cur, total);fflush (stdout);
}
/* erase /XXX(of XXX) */
static void erase (void)
{
if (fsck_quiet (fs))
return;
printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b");
printf (" ");
printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush (stdout);
}
void pass_through_tree (reiserfs_filsys_t * fs, do_after_read_t action1,
do_on_full_path_t action2, int depth)
{
struct buffer_head * path[MAX_HEIGHT] = {0,};
int total[MAX_HEIGHT] = {0,};
int cur[MAX_HEIGHT] = {0,};
int h = 0;
unsigned long block = get_sb_root_block (fs->fs_ondisk_sb);
int problem;
struct spinner spinner;
spinner_init(&spinner, fsck_progress_file(fs));
if (block >= get_sb_block_count (fs->fs_ondisk_sb) || not_data_block (fs, block)) {
die ("\nBad root block %lu. (--rebuild-tree did not complete)\n", block);
}
while ( 1 ) {
problem = 0;
if (path[h])
die ("pass_through_tree: empty slot expected");
if (h)
print (cur[h - 1], total[h - 1]);
if (fs->fs_badblocks_bm && reiserfs_bitmap_test_bit (fs->fs_badblocks_bm, block)) {
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);
if (h == 0) {
brelse (path[h]);
path[h] = 0;
break;
}
problem = 1;
} else {
spinner_touch(&spinner);
path[h] = bread (fs->fs_dev, block, fs->fs_blocksize);
if (path[h] == 0)
/* FIXME: handle case when read failed */
die ("pass_through_tree: unable to read %lu block on device 0x%x\n",
block, fs->fs_dev);
if (action1)
if ((problem = action1 (fs, path, h))) {
fsck_log (" the problem in the internal node occured (%lu), whole subtree is skipped\n",
path[h]->b_blocknr);
fsck_data (fs)->check.bad_nodes++;
if (h == 0) {
brelse (path[h]);
path[h] = 0;
break;
}
}
}
/* Time to stop. */
if (h == depth)
problem ++;
if (problem || is_leaf_node (path[h])) {
if (!problem && action2)
action2 (fs, path, h);
brelse (path[h]);
if (h)
erase ();
while (h && (cur[h-1] == total[h-1] || problem)) {
problem = 0;
path[h] = 0;
h --;
brelse (path[h]);
if (h)
erase ();
}
if (h == 0) {
path[h] = 0;
break;
}
block = get_child (cur[h - 1], path[h-1]);
cur[h - 1] ++;
path[h] = 0;
continue;
}
total[h] = B_NR_ITEMS (path[h]) + 1;
cur[h] = 1;
block = first_child (path[h]);
h ++;
}
spinner_clear(&spinner);
}
+1 -1
View File
@@ -1 +1 @@
SUBDIRS = misc reiserfs util
noinst_HEADERS = io.h misc.h reiserfs_fs.h reiserfs_lib.h swab.h parse_time.h progbar.h
+98 -173
View File
@@ -1,8 +1,8 @@
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006 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.
@@ -13,15 +13,12 @@
# 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
@@ -36,29 +33,22 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = include
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -77,6 +67,8 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -87,9 +79,8 @@ LIBS = @LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -98,18 +89,17 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PROGS_LDFLAGS = @PROGS_LDFLAGS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
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__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -121,30 +111,42 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = misc reiserfs util
all: all-recursive
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_HEADERS = io.h misc.h reiserfs_fs.h reiserfs_lib.h swab.h parse_time.h progbar.h
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@@ -176,78 +178,23 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
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):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
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) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
else :; fi
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
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) \
|| eval $$failcom; \
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
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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -259,24 +206,11 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
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 | \
@@ -288,11 +222,11 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
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 | \
@@ -311,22 +245,21 @@ distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
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; \
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
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"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
@@ -337,35 +270,19 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(mkdir_p) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(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
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
check: check-am
all-am: Makefile $(HEADERS) config.h
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
installcheck: installcheck-recursive
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@@ -381,65 +298,73 @@ distclean-generic:
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: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
dvi: dvi-recursive
dvi: dvi-am
dvi-am:
html: html-recursive
html: html-am
info: info-recursive
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am:
install-info: install-info-recursive
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-recursive
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf: pdf-am
pdf-am:
ps: ps-recursive
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
uninstall-am:
uninstall-info: uninstall-info-recursive
.MAKE: install-am install-strip
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-recursive ctags ctags-recursive \
distclean distclean-generic distclean-recursive distclean-tags \
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
ctags distclean distclean-generic distclean-hdr distclean-tags \
distdir dvi dvi-am html html-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-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
maintainer-clean-recursive mostlyclean mostlyclean-generic \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-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.
+9 -39
View File
@@ -1,21 +1,14 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* include/config.h.in. Generated from configure.in by autoheader. */
/* Define for enable debug info. */
#undef ENABLE_DEBUG
/* Define to 1 if you have the <asm/unaligned.h> header file. */
#undef HAVE_ASM_UNALIGNED_H
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you have the `ctime_r' function. */
#undef HAVE_CTIME_R
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
@@ -43,22 +36,12 @@
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define to 1 if you have the <print.h> header file. */
#undef HAVE_PRINT_H
/* Define to 1 if you have the `register_printf_function' function. */
#undef HAVE_REGISTER_PRINTF_FUNCTION
/* Define to 1 if you have the `statfs' function. */
#undef HAVE_STATFS
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -77,6 +60,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strptime' function. */
#undef HAVE_STRPTIME
/* Define to 1 if you have the `strstr' function. */
#undef HAVE_STRSTR
@@ -90,17 +76,9 @@
`HAVE_STRUCT_STAT_ST_RDEV' instead. */
#undef HAVE_ST_RDEV
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
@@ -125,10 +103,6 @@
/* gets set when configure --enable-io-failure-emulation */
#undef IO_FAILURE_EMULATION
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
*/
#undef MAJOR_IN_MKDEV
@@ -155,10 +129,10 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of a `blkcnt_t', as computed by sizeof. */
/* The size of `blkcnt_t', as computed by sizeof. */
#undef SIZEOF_BLKCNT_T
/* The size of a `off_t', as computed by sizeof. */
/* The size of `off_t', as computed by sizeof. */
#undef SIZEOF_OFF_T
/* Define to 1 if you have the ANSI C header files. */
@@ -167,10 +141,6 @@
/* Version number of package */
#undef VERSION
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
@@ -186,5 +156,5 @@
#undef inline
#endif
/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
+84
View File
@@ -0,0 +1,84 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFSPROGS_IO_H
#define REISERFSPROGS_IO_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "misc.h"
struct buffer_head {
unsigned long b_blocknr;
int b_dev;
unsigned long b_size;
char * b_data;
unsigned long b_state;
unsigned int b_count;
unsigned int b_list ;
void (*b_start_io) (unsigned long);
void (*b_end_io)(struct buffer_head *bh, int uptodate);
struct buffer_head * b_next;
struct buffer_head * b_prev;
struct buffer_head * b_hash_next;
struct buffer_head * b_hash_prev;
};
#define BH_Uptodate 0
#define BH_Dirty 1
#define BH_Lock 2
#define BH_Do_not_flush 3
#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",
__FILE__, __FUNCTION__, __LINE__,
__builtin_return_address (0),
__builtin_return_address (1),
__builtin_return_address (2));
*/
void __wait_on_buffer (struct buffer_head * bh);
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, 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);
int bwrite (struct buffer_head * bh);
void brelse (struct buffer_head * bh);
void bforget (struct buffer_head * bh);
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 (int);
void free_buffers (void);
void invalidate_buffers (int);
#endif
+189
View File
@@ -0,0 +1,189 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
/* nothing abount reiserfs here */
#ifndef REISERFSPROGS_MISC_H
#define REISERFSPROGS_MISC_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <linux/major.h>
#if MAJOR_IN_MKDEV
# include <sys/mkdev.h>
#elif MAJOR_IN_SYSMACROS
# include <sys/sysmacros.h>
#endif
#include "swab.h"
#define POSITION_FOUND 8
#define POSITION_NOT_FOUND 9
#define INVAL_PTR (void *)-1
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);
unsigned int get_mem_size (char * p);
void check_and_free_mem (void);
char * kdevname (int dev);
typedef enum mount_flags {
MF_NOT_MOUNTED = 0x0,
MF_RO = 0x1,
MF_RW = 0x2
} mount_flags_t;
typedef struct mount_hint {
char *point; /* Mount point. */
__u32 psize; /* Mount point buffer size. */
__u32 flags; /* Mount flags. */
} mount_hint_t;
struct mntent *misc_mntent(char *device);
int misc_device_mounted(char *device);
void misc_print_credit(FILE *out);
typedef struct dma_info {
int fd;
struct stat st;
int support_type;
int dma;
__u64 speed;
} dma_info_t;
int prepare_dma_check(dma_info_t *dma_info);
int get_dma_info(dma_info_t *dma_info);
void clean_after_dma_check(int fd, dma_info_t *dma_info);
int valid_offset( int fd, loff_t offset);
unsigned long count_blocks (char * filename, int blocksize);
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);
int user_confirmed (FILE * fp, char * q, char * yes);
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);
#define STAT_FIELD_H(Field, Type) \
inline Type misc_device_##Field(char *device);
STAT_FIELD_H(mode, mode_t);
STAT_FIELD_H(rdev, dev_t);
STAT_FIELD_H(size, off_t);
STAT_FIELD_H(blocks, blkcnt_t);
__u16 mask16 (int from, int count);
__u32 mask32 (int from, int count);
__u64 mask64 (int from, int count);
int reiserfs_bin_search (void * key, void * base, __u32 num, int width,
__u32 *ppos, __compar_fn_t comp_func);
struct block_handler {
__u32 blocknr;
dev_t device;
};
int blocklist__is_block_saved (struct block_handler ** base, __u32 * count, __u32 blocknr,
dev_t device, __u32 * position);
void blocklist__insert_in_position (void * block_h, void ** base, __u32 * count,
int elem_size, __u32 * position);
int blockdev_list_compare (const void * block1, const void * block2);
#define set_bit_field_XX(XX,vp,val,from,count) \
{\
__u##XX * p, tmp;\
\
/* make sure that given value can be put in 'count' bits */\
if (val > (1 << count))\
die ("set_bit_field: val %d is too big for %d bits", val, count);\
\
p = (__u##XX *)vp;\
tmp = le##XX##_to_cpu (*p);\
\
/* clear 'count' bits starting from 'from'-th one */\
tmp &= ~mask##XX (from, count);\
\
/* put given value in proper bits */\
tmp |= (val << from);\
\
*p = cpu_to_le##XX (tmp);\
}
#define get_bit_field_XX(XX,vp,from,count) \
\
__u##XX * p, tmp;\
\
p = (__u##XX *)vp;\
tmp = le##XX##_to_cpu (*p);\
\
/* clear all bits but 'count' bits starting from 'from'-th one */\
tmp &= mask##XX (from, count);\
\
/* get value written in specified bits */\
tmp >>= from;\
return tmp;
#ifndef major
#define major(rdev) ((rdev)>>8)
#define minor(rdev) ((rdev) & 0xff)
#endif /* major */
#ifndef SCSI_DISK_MAJOR
#define SCSI_DISK_MAJOR(maj) ((maj) == SCSI_DISK0_MAJOR || \
((maj) >= SCSI_DISK1_MAJOR && (maj) <= SCSI_DISK7_MAJOR))
#endif /* SCSI_DISK_MAJOR */
#ifndef SCSI_BLK_MAJOR
#define SCSI_BLK_MAJOR(maj) (SCSI_DISK_MAJOR(maj) || (maj) == SCSI_CDROM_MAJOR)
#endif /* SCSI_BLK_MAJOR */
#ifndef IDE_DISK_MAJOR
#ifdef IDE9_MAJOR
#define IDE_DISK_MAJOR(maj) ((maj) == IDE0_MAJOR || (maj) == IDE1_MAJOR || \
(maj) == IDE2_MAJOR || (maj) == IDE3_MAJOR || \
(maj) == IDE4_MAJOR || (maj) == IDE5_MAJOR || \
(maj) == IDE6_MAJOR || (maj) == IDE7_MAJOR || \
(maj) == IDE8_MAJOR || (maj) == IDE9_MAJOR)
#else
#define IDE_DISK_MAJOR(maj) ((maj) == IDE0_MAJOR || (maj) == IDE1_MAJOR || \
(maj) == IDE2_MAJOR || (maj) == IDE3_MAJOR || \
(maj) == IDE4_MAJOR || (maj) == IDE5_MAJOR)
#endif /* IDE9_MAJOR */
#endif /* IDE_DISK_MAJOR */
#endif /* REISERFS_MISC_H */
-1
View File
@@ -1 +0,0 @@
noinst_HEADERS = types.h bitops.h malloc.h swab.h device.h misc.h unaligned.h
-337
View File
@@ -1,337 +0,0 @@
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 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 = :
build_triplet = @build@
host_triplet = @host@
subdir = include/misc
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
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@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
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@
PROGS_LDFLAGS = @PROGS_LDFLAGS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
UUID_LIBS = @UUID_LIBS@
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__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
noinst_HEADERS = types.h bitops.h malloc.h swab.h device.h misc.h unaligned.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/misc/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu include/misc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
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
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; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
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
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"; \
$(mkdir_p) "$(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 $(HEADERS)
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
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(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 mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
dvi-am:
html: html-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
-rm -f Makefile
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-tags distdir dvi \
dvi-am html html-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.
.NOEXPORT:
-79
View File
@@ -1,79 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef MISC_BITOPS_H
#define MISC_BITOPS_H
#include "misc/types.h"
#include "misc/misc.h"
extern __u16 mask16 (int from, int count);
extern __u32 mask32 (int from, int count);
extern __u64 mask64 (int from, int count);
#define misc_set_bitfield_XX(XX,vp,val,from,count) \
({ \
__u##XX * p, tmp; \
\
/* make sure that given value can be put in 'count' bits */ \
if (val > (1 << count)) \
misc_die ("misc_set_bitfield: val %d is too big for %d bits", val, count); \
\
p = (__u##XX *)vp; \
tmp = le##XX##_to_cpu (*p); \
\
/* clear 'count' bits starting from 'from'-th one */ \
tmp &= ~mask##XX (from, count); \
\
/* put given value in proper bits */ \
tmp |= (val << from); \
\
*p = cpu_to_le##XX (tmp); \
})
#define misc_get_bitfield_XX(XX,vp,from,count) \
({ \
__u##XX * p, tmp; \
\
p = (__u##XX *)vp; \
tmp = le##XX##_to_cpu (*p); \
\
/* clear all bits but 'count' bits starting from 'from'-th one */ \
tmp &= mask##XX (from, count); \
\
/* get value written in specified bits */ \
tmp >>= from; \
tmp; \
})
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);
#endif
-24
View File
@@ -1,24 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef MISC_DEVICE_H
#define MISC_DEVICE_H
#include <sys/types.h>
extern int misc_device_valid_offset(int fd, long long int offset);
extern unsigned long misc_device_count_blocks (char * filename,
int blocksize);
extern char misc_device_typec (unsigned short mode);
#define STAT_FIELD_H(Field, Type) \
Type misc_device_##Field(char *device);
STAT_FIELD_H(mode, mode_t);
STAT_FIELD_H(rdev, dev_t);
#endif
-21
View File
@@ -1,21 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef MISC_MALLOC_H
#define MISC_MALLOC_H
extern void *misc_getmem (int size);
extern void *misc_malloc(int size);
extern void misc_freemem (void * p);
extern void misc_checkmem (char * p, int size);
extern void *misc_expandmem (void * p, int size, int by);
extern unsigned int misc_memsize (char * p);
#endif
-41
View File
@@ -1,41 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
/* nothing abount reiserfs here */
#ifndef MISC_H
#define MISC_H
#include "misc/types.h"
/* n must be power of 2 */
#define MISC_UP(x,n) (((x)+(n)-1u) / (n) * (n))
#define MISC_DOWN(x,n) ((x) / (n) * (n))
/* to be ok for alpha etc we have to align structures to 8 byte boundary. */
#define MISC_ROUND_UP(x) MISC_UP(x,8LL)
extern void misc_die (char * fmt, ...) __attribute__ ((format (printf, 1, 2)));
typedef int (*dir_walk_func_t) (char *path, void *data);
extern int misc_dir_walk(char *path, dir_walk_func_t func, void *data);
extern __u32 misc_random (void);
typedef int (*misc_comp_func_t) (const void *, const void *);
extern int misc_device_rdev_match(char *path, void *data);
extern int misc_bin_search (const void * key, void * base,
__u32 num, int width, int *ppos,
misc_comp_func_t comp_func);
extern void blocklist__insert_in_position (void * block_h, void ** base,
__u32 * count, int elem_size,
int * position);
extern int blockdev_list_compare (const void * block1, const void * block2);
#endif
-21
View File
@@ -1,21 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef MISC_TYPES_H
#define MISC_TYPES_H
#include <string.h>
typedef unsigned char __u8;
typedef unsigned short int __u16;
typedef unsigned int __u32;
typedef unsigned long long int __u64;
#define INVAL_PTR (void *)-1
#define MAX_INT 2147483647
#define LONG_LONG_MAX 9223372036854775807LL
#define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
#endif
-40
View File
@@ -1,40 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef MISC_UNALIGNED_H
#define MISC_UNALIGNED_H
#ifdef HAVE_ASM_UNALIGNED_H
# include <asm/unaligned.h>
#endif
#ifndef get_unaligned
#define get_unaligned(ptr) \
({ \
__typeof__(*(ptr)) __tmp; \
memcpy(&__tmp, (ptr), sizeof(*(ptr))); \
__tmp; \
})
#endif
#ifndef put_unaligned
#define put_unaligned(val, ptr) \
({ \
__typeof__(*(ptr)) __tmp = (val); \
memcpy((ptr), &__tmp, sizeof(*(ptr))); \
(void)0; \
})
#endif
/* these operate on extent items, where you've got an array of ints
** at a possibly unaligned location. These are a noop on ia32
**
** p is the array of __u32, i is the index into the array, v is the value
** to store there.
*/
#define d32_get(p, i) le32_to_cpu(get_unaligned((__u32 *)(p) + (i)))
#define d32_put(p, i, v) put_unaligned(cpu_to_le32(v), (__u32 *)(p) + (i))
#endif
+15
View File
@@ -0,0 +1,15 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
/* nothing abount reiserfs here */
#ifndef TIME_H
#define TIME_H
#include <time.h>
time_t parse_time(char *str);
#endif /* TIME_H */
+32
View File
@@ -0,0 +1,32 @@
#ifndef _PROGBAR_H_
#define _PROGBAR_H_
enum {
E2F_FLAG_PROG_SUPPRESS = 1,
E2F_FLAG_PROG_BAR = 2,
};
struct progbar {
char units[16];
int progress_pos;
int progress_last_percent;
time_t progress_last_time;
int flags;
FILE *file;
};
struct spinner {
int count;
FILE *file;
};
void progbar_init(struct progbar *ctx, const char *units, FILE *fp);
void progbar_clear(struct progbar * ctx);
int progbar_update(struct progbar * ctx, const char *label, int curr, int max,
unsigned int dpynum);
void spinner_init(struct spinner *spinner, FILE *fp);
void spinner_touch(struct spinner *spinner);
void spinner_clear(struct spinner *spinner);
#endif /* _PROGBAR_H_ */
-6
View File
@@ -1,6 +0,0 @@
noinst_HEADERS = badblock.h bitmap.h buffer.h direntry.h extent.h \
filesystem.h fix_node.h hash.h internal.h \
internal_balance.h journal.h key.h leaf.h \
leaf_balance.h node.h objmap.h policy.h print.h \
stat.h super.h tree.h tree_balance.h libreiserfs.h \
types.h
-29
View File
@@ -1,29 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_BADBLOCK_H
#define REISERFS_BADBLOCK_H
#include "reiserfs/types.h"
#define REISERFS_BAD_DID 1
#define REISERFS_BAD_OID (__u32)-1
typedef void (*badblock_func_t) (reiserfs_filsys_t *fs,
reiserfs_path_t *badblock_path,
void *data);
extern void reiserfs_badblock_extract(reiserfs_filsys_t *fs,
reiserfs_path_t *badblock_path,
void *data);
extern void reiserfs_badblock_flush (reiserfs_filsys_t * fs,
int no_badblock_in_tree_yet);
extern void reiserfs_badblock_traverse(reiserfs_filsys_t * fs,
badblock_func_t action,
void *data);
#endif
-89
View File
@@ -1,89 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_BITMAP_H
#define REISERFS_BITMAP_H
#include "reiserfs/types.h"
#include <stdio.h>
#define reiserfs_bmap_nr(count, blk_size) \
((count - 1) / (blk_size * 8) + 1)
#define reiserfs_bmap_over(nr) (nr > ((1ll << 16) - 1))
extern reiserfs_bitmap_t *reiserfs_bitmap_create (unsigned int bit_count);
extern int reiserfs_bitmap_open(reiserfs_filsys_t *);
extern void reiserfs_bitmap_delete (reiserfs_bitmap_t * bm);
extern void reiserfs_bitmap_free (reiserfs_filsys_t *);
extern void reiserfs_bitmap_close (reiserfs_filsys_t *);
extern int reiserfs_bitmap_flush (reiserfs_bitmap_t * bm,
reiserfs_filsys_t * fs);
extern int reiserfs_bitmap_expand (reiserfs_bitmap_t * bm,
unsigned int bit_count);
extern void reiserfs_bitmap_shrink (reiserfs_bitmap_t * bm,
unsigned int bit_count);
extern void reiserfs_bitmap_copy (reiserfs_bitmap_t * to,
reiserfs_bitmap_t * from);
extern int reiserfs_bitmap_compare (reiserfs_bitmap_t * bm1,
reiserfs_bitmap_t * bm2);
extern void reiserfs_bitmap_disjunction (reiserfs_bitmap_t * disk,
reiserfs_bitmap_t * cont);
extern void reiserfs_bitmap_delta (reiserfs_bitmap_t * base,
reiserfs_bitmap_t * exclude);
extern void reiserfs_bitmap_set_bit (reiserfs_bitmap_t * bm,
unsigned int bit_number);
extern void reiserfs_bitmap_clear_bit (reiserfs_bitmap_t * bm,
unsigned int bit_number);
extern int reiserfs_bitmap_test_bit (reiserfs_bitmap_t * bm,
unsigned int bit_number);
extern int reiserfs_bitmap_find_zero_bit (reiserfs_bitmap_t * bm,
unsigned long * start);
extern void reiserfs_bitmap_zero (reiserfs_bitmap_t * bm);
extern void reiserfs_bitmap_fill (reiserfs_bitmap_t * bm);
extern void reiserfs_bitmap_invert (reiserfs_bitmap_t * bm);
extern unsigned int reiserfs_bitmap_ones (reiserfs_bitmap_t * bm);
extern unsigned int reiserfs_bitmap_zeros (reiserfs_bitmap_t * bm);
extern int reiserfs_bitmap_spread (reiserfs_filsys_t *);
extern int reiserfs_bitmap_block (reiserfs_filsys_t *,
unsigned long block);
/* Backup copies. */
extern void reiserfs_bitmap_save (FILE * fp,
reiserfs_bitmap_t *bm);
extern reiserfs_bitmap_t * reiserfs_bitmap_load (FILE * fp);
extern void reiserfs_bitmap_print (FILE * fp, reiserfs_filsys_t * fs,
int silent);
extern void reiserfs_print_bmap_block (FILE * fp, int i,
unsigned long block,
char * map, int blocks,
int silent, int blocksize);
#endif
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_BUFFER_H
#define REISERFS_BUFFER_H
#include "reiserfs/types.h"
#define BH_Uptodate 0
#define BH_Dirty 1
#define BH_Lock 2
#define BH_Do_not_flush 3
#define reiserfs_buffer_uptodate(bh) misc_test_bit(BH_Uptodate, &(bh)->b_state)
#define reiserfs_buffer_mkuptodate(bh,i) misc_set_bit(BH_Uptodate, &(bh)->b_state)
#define reiserfs_buffer_isdirty(bh) misc_test_bit(BH_Dirty, &(bh)->b_state)
#define reiserfs_buffer_isclean(bh) !misc_test_bit(BH_Dirty, &(bh)->b_state)
#define reiserfs_buffer_mkdirty(bh) misc_set_bit(BH_Dirty, &(bh)->b_state)
#define reiserfs_buffer_mkclean(bh) misc_clear_bit(BH_Dirty, &(bh)->b_state)
#define reiserfs_buffer_noflush(bh) misc_test_bit(BH_Do_not_flush, &(bh)->b_state)
#define reiserfs_buffer_mknoflush(bh) misc_set_bit(BH_Do_not_flush, &(bh)->b_state)
#define reiserfs_buffer_clnoflush(bh) misc_clear_bit(BH_Do_not_flush, &(bh)->b_state)
extern reiserfs_bh_t * reiserfs_buffer_open (int, unsigned long, unsigned long);
extern reiserfs_bh_t * reiserfs_buffer_find (int, unsigned long, unsigned long);
extern reiserfs_bh_t * reiserfs_buffer_read (int, unsigned long, unsigned long);
extern int reiserfs_buffer_write (reiserfs_bh_t *);
extern void reiserfs_buffer_close (reiserfs_bh_t *);
extern void reiserfs_buffer_forget (reiserfs_bh_t *);
extern void reiserfs_buffer_flush_all(int);
extern void reiserfs_buffer_free_all (void);
extern void reiserfs_buffer_invalidate_all (int);
#endif
-158
View File
@@ -1,158 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_DIRENTRY_H
#define REISERFS_DIRENTRY_H
#include "reiserfs/types.h"
/***************************************************************************/
/* DIRECTORY STRUCTURE */
/***************************************************************************/
/*
Picture represents the structure of directory items
________________________________________________
| Array of | | | | | |
| directory |N-1| N-2 | .... | 1st |0th|
| entry headers | | | | | |
|_______________|___|_____|________|_______|___|
<---- directory entries ------>
First directory item has k_offset component 1. We store "." and ".."
in one item, always, we never split "." and ".." into differing
items. This makes, among other things, the code for removing
directories simpler. */
/* Each directory entry has its header. This header has deh_dir_id and
deh_objectid fields, those are key of object, entry points to */
/* NOT IMPLEMENTED:
Directory will someday contain stat data of object */
struct reiserfs_de_head
{
__u32 deh2_offset; /* third component of the directory entry key */
__u32 deh2_dir_id; /* objectid of the parent directory of the object,
that is referenced by directory entry */
__u32 deh2_objectid;/* objectid of the object, that is referenced by
directory entry */
__u16 deh2_location;/* offset of name in the whole item */
__u16 deh2_state; /* whether 1) entry contains stat data (for future),
and 2) whether entry is hidden (unlinked) */
} __attribute__ ((__packed__));
typedef struct reiserfs_de_head reiserfs_deh_t;
#define REISERFS_DEH_SIZE sizeof(reiserfs_deh_t)
/* set/get fields of dir entry head these defines */
#define reiserfs_deh_get_off(deh) get_le32 (deh, deh2_offset)
#define reiserfs_deh_set_off(deh,val) set_le32 (deh, deh2_offset, val)
#define reiserfs_deh_get_did(deh) get_le32 (deh, deh2_dir_id)
#define reiserfs_deh_set_did(deh,val) set_le32 (deh, deh2_dir_id, val)
#define reiserfs_deh_get_obid(deh) get_le32 (deh, deh2_objectid)
#define reiserfs_deh_set_obid(deh,val) set_le32 (deh, deh2_objectid, val)
#define reiserfs_deh_get_loc(deh) get_le16 (deh, deh2_location)
#define reiserfs_deh_set_loc(deh,val) set_le16 (deh, deh2_location, val)
#define reiserfs_deh_get_state(deh) get_le16 (deh, deh2_state)
#define reiserfs_deh_set_state(deh,val) set_le16 (deh, deh2_state, val)
#define reiserfs_deh_name(deh, pos) \
((char *)(deh - pos) + reiserfs_deh_get_loc(deh))
/* empty directory contains two entries "." and ".." and their headers */
#define REISERFS_DIR_MIN \
(REISERFS_DEH_SIZE * 2 + \
MISC_ROUND_UP (strlen (".")) + \
MISC_ROUND_UP (strlen ("..")))
/* old format directories have this size when empty */
#define REISERFS_DIR_MIN_V1 (REISERFS_DEH_SIZE * 2 + 3)
#define DEH_Statdata 0 /* not used now */
#define DEH_Visible2 2
#define DEH_Bad_offset 4 /* fsck marks entries to be deleted with this flag */
#define DEH_Bad_location 5
#define reiserfs_deh_state_bit(deh,bit) \
(reiserfs_deh_get_state (deh) & (1 << bit))
#define reiserfs_deh_state_set_bit(deh,bit) \
{ \
__u16 state; \
state = reiserfs_deh_get_state (deh); \
state |= (1 << bit); \
reiserfs_deh_set_state(deh, state); \
}
#define reiserfs_deh_state_clear_bit(deh,bit) \
{ \
__u16 state; \
state = reiserfs_deh_get_state (deh); \
state &= ~(1 << bit); \
reiserfs_deh_set_state(deh, state); \
}
/* Bad means "hashed unproperly or/and invalid location" */
#define reiserfs_deh_locbad(deh) \
reiserfs_deh_state_bit (deh, DEH_Bad_location)
#define reiserfs_deh_set_locbad(deh) \
reiserfs_deh_state_set_bit (deh, DEH_Bad_location)
#define reiserfs_deh_set_locok(deh) \
reiserfs_deh_state_clear_bit (deh, DEH_Bad_location)
#define reiserfs_deh_offbad(deh) \
reiserfs_deh_state_bit (deh, DEH_Bad_offset)
#define reiserfs_deh_set_offbad(deh) \
reiserfs_deh_state_set_bit (deh, DEH_Bad_offset)
#define reiserfs_deh_bad(deh) \
(reiserfs_deh_locbad(deh) || reiserfs_deh_offbad(deh))
/* for directories st_blocks is number of 512 byte units which fit into dir
size round up to blocksize */
#define REISERFS_DIR_BLOCKS(size) ((size + 511) / 512)
/* array of the entry headers */
#define reiserfs_deh(bh,ih) ((reiserfs_deh_t *)(reiserfs_item_by_ih(bh,ih)))
#define REISERFS_NAME_MAX 256
/* #define REISERFS_NAME_MAX(block_size) \
(block_size - REISERFS_NODEH_SIZE - \
REISERFS_IH_SIZE - REISERFS_DEH_SIZE)
*/
/* -REISERFS_SD_SIZE when entry will contain stat data */
extern int reiserfs_direntry_loc_check (reiserfs_deh_t * deh,
reiserfs_ih_t * ih,
int first);
extern int reiserfs_direntry_entry_len (reiserfs_ih_t * ih,
reiserfs_deh_t * deh,
int pos_in_item);
extern int reiserfs_direntry_name_len (reiserfs_ih_t * ih,
reiserfs_deh_t * deh,
int pos_in_item);
extern int reiserfs_direntry_entry_estimate (char * name,
int key_format);
extern int reiserfs_direntry_check (reiserfs_filsys_t * fs,
reiserfs_ih_t * ih,
char * item,
int bad_dir);
extern void reiserfs_direntry_print (FILE * fp,
reiserfs_filsys_t * fs,
reiserfs_bh_t * bh,
reiserfs_ih_t * ih);
#endif
-26
View File
@@ -1,26 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_EXTENT_H
#define REISERFS_EXTENT_H
#include "reiserfs/types.h"
/* Size of pointer to the unformatted node. */
#define REISERFS_EXT_SIZE (sizeof(__u32))
/* number of blocks pointed to by the extent item */
#define reiserfs_ext_count(p_s_ih) \
(reiserfs_ih_get_len(p_s_ih) / REISERFS_EXT_SIZE)
extern int reiserfs_ext_check (reiserfs_filsys_t * fs,
reiserfs_ih_t * ih, char * item,
unfm_func_t func);
extern void reiserfs_ext_print(FILE * fp,
reiserfs_bh_t * bh,
int item_num);
#endif
-73
View File
@@ -1,73 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_FS_H
#define REISERFS_FS_H
#include <reiserfs/types.h>
/* ReiserFS leaves the first 64k unused, so that partition labels have enough
space. If someone wants to write a fancy bootloader that needs more than
64k, let us know, and this will be increased in size. This number must be
larger than than the largest block size on any platform, or code will
break. -Hans */
#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
/*#define MD_RAID_SUPERBLOCKS_IN_BYTES (128 * 1024)*/
/* the spot for the super in versions 3.5 - 3.5.11 (inclusive) */
#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)
#define reiserfs_ondisk_offset(block_of_super_block, block_size) \
(block_of_super_block * block_size)
#define reiserfs_new_location(block_of_super_block, block_size) \
((reiserfs_ondisk_offset(block_of_super_block, block_size) == \
REISERFS_DISK_OFFSET_IN_BYTES) ? 1 : 0)
/*only 4k blocks for old location*/
#define reiserfs_old_location(block_of_super_block, block_size) \
((reiserfs_ondisk_offset(block_of_super_block, 4096) == \
REISERFS_OLD_DISK_OFFSET_IN_BYTES) ? 1 : 0)
enum reiserfs_blktype {
BT_INVAL = 0x1,
BT_SUPER = 0x2,
BT_JOURNAL = 0x3,
BT_BITMAP = 0x4,
BT_UNKNOWN
};
typedef enum reiserfs_blktype reiserfs_blktype_t;
extern reiserfs_filsys_t * reiserfs_fs_open (char * filename,
int flags,
int * error,
void * vp,
int skip_check);
extern reiserfs_filsys_t * reiserfs_fs_create (char * filename,
int version,
unsigned long block_count,
int block_size,
int default_journal,
int new_format);
extern void reiserfs_fs_flush (reiserfs_filsys_t *);
extern void reiserfs_fs_free (reiserfs_filsys_t *);
extern void reiserfs_fs_close (reiserfs_filsys_t *);
extern void reiserfs_fs_reopen (reiserfs_filsys_t *, int flags);
extern int reiserfs_fs_rw (reiserfs_filsys_t * fs);
extern int reiserfs_fs_blksize_check (unsigned int blocksize);
extern reiserfs_blktype_t reiserfs_fs_block(reiserfs_filsys_t *fs,
unsigned long block);
#endif
-76
View File
@@ -1,76 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_FIX_NODE_H
#define REISERFS_FIX_NODE_H
#include <reiserfs/types.h>
#include <reiserfs/tree_balance.h>
/* maximum number of FEB blocknrs on a single level */
#define FN_AMOUNT_MAX 2
/* To make any changes in the tree we always first find node, that contains
item to be changed/deleted or place to insert a new item. We call this node
S. To do balancing we need to decide what we will shift to left/right
neighbor, or to a new node, where new item will be etc. To make this
analysis simpler we build virtual node. Virtual node is an array of items,
that will replace items of node S. (For instance if we are going to delete
an item, virtual node does not contain it). Virtual node keeps information
about item sizes and types, mergeability of first and last items, sizes of
all entries in directory item. We use this array of items when calculating
what we can shift to neighbors and how many nodes we have to have if we do
not any shiftings, if we shift to left/right neighbor or to both. */
struct reiserfs_virtual_item
{
/* item type, mergeability */
unsigned short vi_type;
/* length of item that it will have after balancing */
unsigned short vi_item_len;
/* offset of item that it have before balancing */
__u64 vi_item_offset;
/* number of entries in directory item (including the new one if any,
or excluding entry if it must be cut) */
short vi_entry_count;
/* array of entry lengths for directory item */
unsigned short * vi_entry_sizes;
};
struct reiserfs_virtual_node
{
/* this is a pointer to the free space in the buffer */
char * vn_free_ptr;
/* number of items in virtual node */
unsigned short vn_nr_item;
/* size of node , that node would have if it has unlimited size and no
balancing is performed */
short vn_size;
/* mode of balancing (paste, insert, delete, cut) */
short vn_mode;
short vn_affected_item_num;
short vn_pos_in_item;
/* item header of inserted item, 0 for other modes */
reiserfs_ih_t * vn_ins_ih;
/* array of items (including a new one, excluding item to be deleted) */
struct reiserfs_virtual_item * vn_vi;
};
extern int reiserfs_fix_nodes (int n_op_mode,
reiserfs_tb_t * p_s_tb,
reiserfs_ih_t * p_s_ins_ih);
extern void reiserfs_unfix_nodes (reiserfs_tb_t *);
/* FIXME: move these 2 into tree.h when get rid of search_by_key */
extern reiserfs_bh_t * reiserfs_tree_right_neighbor (reiserfs_filsys_t * s,
reiserfs_path_t * path);
extern reiserfs_bh_t * reiserfs_tree_left_neighbor (reiserfs_filsys_t * s,
reiserfs_path_t * path);
extern void reiserfs_fix_node_print(struct reiserfs_virtual_node * vn);
#endif
-52
View File
@@ -1,52 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_HASH_H
#define REISERFS_HASH_H
#include "misc/types.h"
#define UNSET_HASH 0 // read_super will guess about, what hash names
// in directories were sorted with
enum {
REISERFS_HASH_TEA = 0x1,
REISERFS_HASH_YURA = 0x2,
REISERFS_HASH_R5 = 0x3,
REISERFS_HASH_LAST
};
#define DEFAULT_HASH REISERFS_HASH_R5
/* hashes.c */
extern __u32 reiserfs_hash_keyed (const char *msg, int len);
extern __u32 reiserfs_hash_yura (const char *msg, int len);
extern __u32 reiserfs_hash_r5 (const char *msg, int len);
extern int reiserfs_hash_count (void);
extern int reiserfs_hash_correct (hashf_t *func,
char * name,
int namelen,
__u32 offset);
extern int reiserfs_hash_find (char * name,
int namelen,
__u32 deh_offset,
unsigned int code_to_try_first);
extern char *reiserfs_hash_name (unsigned int code);
extern int reiserfs_hash_code (hashf_t func);
extern hashf_t reiserfs_hash_func (unsigned int code);
extern hashf_t reiserfs_hash_get (char * hash);
extern __u32 reiserfs_hash_value (hashf_t func, char * name, int namelen);
#endif
-78
View File
@@ -1,78 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_INTERNAL_H
#define REISERFS_INTERNAL_H
/*
* Picture represents an internal node of the reiserfs tree
* ______________________________________________________
* | | Array of | Array of | Free |
* |block | keys | pointers | space |
* | head | N | N+1 | |
* |______|_______________|___________________|___________|
*/
/* Disk child pointer: The pointer from an internal node of the tree
to a node that is on disk. */
struct reiserfs_dc {
__u32 dc2_block_number; /* Disk child's block number. */
__u16 dc2_size; /* Disk child's used space. */
__u16 dc2_reserved;
} __attribute__ ((__packed__));
typedef struct reiserfs_dc reiserfs_dc_t;
#define REISERFS_DC_SIZE (sizeof(reiserfs_dc_t))
/* set/get fields of disk_child with these defines */
#define reiserfs_dc_get_nr(dc) get_le32 (dc, dc2_block_number)
#define reiserfs_dc_set_nr(dc,val) set_le32 (dc, dc2_block_number, val)
#define reiserfs_dc_get_size(dc) get_le16 (dc, dc2_size)
#define reiserfs_dc_set_size(dc,val) set_le16 (dc, dc2_size, val)
#define reiserfs_dc_init(dc, size, blocknr) \
({ \
reiserfs_dc_set_nr(dc, blocknr); \
reiserfs_dc_set_size(dc, size); \
set_le16(dc, dc2_reserved, 0); \
})
/* max and min number of keys in internal node */
#define REISERFS_INT_MAX(bh) \
((REISERFS_NODE_SPACE(bh->b_size) - REISERFS_DC_SIZE) / \
(REISERFS_KEY_SIZE+REISERFS_DC_SIZE))
#define REISERFS_INT_MIN(bh) (REISERFS_INT_MAX(bh) / 2)
/* get key */
#define reiserfs_int_key_at(bh,item_num) \
((reiserfs_key_t * )((bh)->b_data + REISERFS_NODEH_SIZE) + \
(item_num) )
/* Get disk child by buffer header and position in the tree node. */
#define reiserfs_int_at(p_s_bh,n_pos) \
((reiserfs_dc_t *) ((p_s_bh)->b_data + REISERFS_NODEH_SIZE + \
reiserfs_node_items(p_s_bh) * REISERFS_KEY_SIZE +\
REISERFS_DC_SIZE * (n_pos)))
#define reiserfs_int_head(bh) \
((reiserfs_nh_get_level (((reiserfs_node_head_t *)((bh)->b_data))) > \
LEAF_LEVEL) && \
(reiserfs_nh_get_level (((reiserfs_node_head_t *)((bh)->b_data))) <= \
REISERFS_TREE_HEIGHT_MAX))
extern int reiserfs_internal_correct (reiserfs_bh_t *bh);
extern int reiserfs_internal_print (FILE * fp,
reiserfs_bh_t * bh,
int first, int last);
extern int reiserfs_internal_get_pos (reiserfs_bh_t * bh,
unsigned long block);
#endif
-14
View File
@@ -1,14 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_IB_H
#define REISERFS_IB_H
extern int reiserfs_ib_balance (reiserfs_tb_t * tb,
int h, int child_pos,
reiserfs_ih_t * insert_key,
reiserfs_bh_t ** insert_ptr);
#endif
-211
View File
@@ -1,211 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_JOURNAL_H
#define REISERFS_JOURNAL_H
#define reiserfs_jp_get_start(jp) get_le32(jp, jp_start)
#define reiserfs_jp_set_start(jp,val) set_le32(jp, jp_start, val)
#define reiserfs_jp_get_dev(jp) get_le32 (jp, jp_dev)
#define reiserfs_jp_set_dev(jp,val) set_le32 (jp, jp_dev, val)
#define reiserfs_jp_get_size(jp) get_le32 (jp, jp_size)
#define reiserfs_jp_set_size(jp,val) set_le32 (jp, jp_size, val)
#define reiserfs_jp_get_tlen(jp) get_le32 (jp, jp_tlen)
#define reiserfs_jp_set_tlen(jp,val) set_le32 (jp, jp_tlen, val)
#define reiserfs_jp_get_magic(jp) get_le32 (jp, jp_magic)
#define reiserfs_jp_set_magic(jp,val) set_le32 (jp, jp_magic, val)
#define NEED_TUNE 0xffffffff
#define reiserfs_jp_get_max_batch(jp) get_le32 (jp, jp_max_batch)
#define reiserfs_jp_set_max_batch(jp,val) set_le32 (jp, jp_max_batch, val)
#define reiserfs_jp_get_commit_age(jp) get_le32 (jp, jp_commit_age)
#define reiserfs_jp_set_commit_age(jp,val) set_le32 (jp, jp_commit_age, val)
#define reiserfs_jp_get_trans_age(jp) get_le32 (jp, jp_trans_age)
#define reiserfs_jp_set_trans_age(jp,val) set_le32 (jp, jp_trans_age, val)
/* must be correct to keep the desc and commit structs at 4k */
/* first block written in a commit. BUG, not 64bit safe */
struct reiserfs_journal_desc {
/* id of commit */
__u32 j2_trans_id ;
/* length of commit. len +1 is the commit block */
__u32 j2_len ;
/* mount id of this trans*/
__u32 j2_mount_id ;
/* real locations for each block */
__u32 j2_realblock[1] ;
};
#define reiserfs_jd_magic(bh) (bh->b_data + bh->b_size - 12)
#define reiserfs_jd_head(bh) ((struct reiserfs_journal_desc *)bh->b_data)
#define reiserfs_jd_get_trans(bh) get_le32 (reiserfs_jd_head (bh), j2_trans_id)
#define reiserfs_jd_set_trans(bh,val) set_le32 (reiserfs_jd_head (bh), j2_trans_id, val)
#define reiserfs_jd_get_len(bh) get_le32 (reiserfs_jd_head (bh), j2_len)
#define reiserfs_jd_set_len(bh,val) set_le32 (reiserfs_jd_head (bh), j2_len, val)
#define reiserfs_jd_get_mount(bh) get_le32 (reiserfs_jd_head (bh), j2_mount_id)
#define reiserfs_jd_set_mount(bh,val) set_le32 (reiserfs_jd_head (bh), j2_mount_id, val)
/* last block written in a commit BUG, not 64bit safe */
struct reiserfs_journal_commit {
__u32 j3_trans_id ; /* must match j_trans_id from the desc block */
__u32 j3_len ; /* ditto */
__u32 j3_realblock[1] ; /* real locations for each block */
} ;
#define reiserfs_jc_head(bh) ((struct reiserfs_journal_commit *)bh->b_data)
#define reiserfs_jc_get_trans(bh) get_le32 (reiserfs_jc_head(bh), j3_trans_id)
#define reiserfs_jc_set_trans(bh,val) set_le32 (reiserfs_jc_head(bh), j3_trans_id, val)
#define reiserfs_jc_get_len(bh) get_le32 (reiserfs_jc_head(bh), j3_len)
#define reiserfs_jc_set_len(bh,val) set_le32 (reiserfs_jc_head(bh), j3_len, val)
/* set/get fields of journal header with these defines */
#define reiserfs_jh_get_mount(jh) get_le32 (jh, jh_mount_id)
#define reiserfs_jh_set_mount(jh,val) set_le32 (jh, jh_mount_id, val)
#define reiserfs_jh_get_flushed(jh) get_le32 (jh, jh_last_flush_trans_id)
#define reiserfs_jh_set_flushed(jh,val) set_le32 (jh, jh_last_flush_trans_id, val)
#define reiserfs_jh_get_start(jh) get_le32 (jh, jh_flush_offset)
#define reiserfs_jh_set_start(jh,val) set_le32 (jh, jh_flush_offset, val)
/* Journal Transaction Half */
#define reiserfs_jt_half(blocksize) \
((blocksize - sizeof (struct reiserfs_journal_desc) + \
sizeof (__u32) - 12) / sizeof (__u32))
/* journal default settings */
#define JOURNAL_MIN_SIZE 512
/* biggest possible single transaction, don't change for now (8/3/99) */
#define JOURNAL_TRANS_MAX 1024
/* need to check whether it works */
#define JOURNAL_TRANS_MIN 256
/* default journal size / max trans length */
#define JOURNAL_DEFAULT_RATIO 8
#define JOURNAL_MIN_RATIO 2
/* max blocks to batch into one transaction, don't make this
any bigger than 900 */
#define JOURNAL_MAX_BATCH 900
#define JOURNAL_MAX_COMMIT_AGE 30
#define JOURNAL_MAX_TRANS_AGE 30
/* journal max size is a maximum number of blocks pointed by first bitmap -
REISERFS_DISK_OFFSET - superblock - first bitmap - journal herader */
#define reiserfs_journal_max(sb_nr,blocksize) \
blocksize * 8 - (sb_nr + 1 + 1 + 1)
#define reiserfs_journal_default(sb_nr,blocksize) \
(unsigned long long) \
((8192 > reiserfs_journal_max (sb_nr,blocksize)) ? \
reiserfs_journal_max (sb_nr,blocksize) : 8192)
struct reiserfs_trans {
unsigned long mount_id;
unsigned long trans_id;
unsigned long desc_blocknr;
unsigned long trans_len;
unsigned long commit_blocknr;
unsigned long next_trans_offset;
};
typedef struct reiserfs_trans reiserfs_trans_t;
extern unsigned long reiserfs_journal_hostsize (reiserfs_sb_t *sb);
extern int reiserfs_journal_block (reiserfs_filsys_t *,
unsigned long block);
extern int reiserfs_journal_desc_valid (reiserfs_bh_t *);
extern int reiserfs_journal_get_transactions (reiserfs_filsys_t *,
reiserfs_trans_t *,
reiserfs_trans_t *);
typedef void (*action_on_trans_t) (reiserfs_filsys_t *,
reiserfs_trans_t *);
extern void reiserfs_journal_by_transaction (reiserfs_filsys_t *,
action_on_trans_t);
typedef void (*action_on_block_t) (reiserfs_filsys_t *,
reiserfs_trans_t *,
unsigned int index,
unsigned long in_journal,
unsigned long in_place);
extern void reiserfs_journal_foreach (reiserfs_filsys_t * fs,
reiserfs_trans_t * trans,
action_on_block_t action);
extern int reiserfs_journal_open (reiserfs_filsys_t *,
char *, int flags);
extern int reiserfs_journal_params_check(reiserfs_filsys_t *fs);
extern int reiserfs_journal_create (reiserfs_filsys_t * fs,
char * j_filename,
unsigned long offset,
unsigned long len,
int transaction_max_size);
extern int reiserfs_journal_opened (reiserfs_filsys_t *);
extern void reiserfs_journal_flush (reiserfs_filsys_t * fs);
extern void reiserfs_journal_free (reiserfs_filsys_t * fs);
extern void reiserfs_journal_close (reiserfs_filsys_t *);
extern void reiserfs_journal_reopen (reiserfs_filsys_t * fs, int flag);
extern int reiserfs_journal_replay (reiserfs_filsys_t * fs);
extern __u32 reiserfs_journal_trans_age (void);
extern __u32 reiserfs_journal_commit_age (void);
extern __u32 reiserfs_journal_batch (unsigned long journal_trans_max);
extern __u32 reiserfs_journal_tlen (__u32 desired,
__u32 journal_size,
int blocksize,
int verbose);
extern unsigned int reiserfs_journal_start_must (reiserfs_filsys_t * fs);
extern int reiserfs_journal_fits (unsigned long sb_nr,
unsigned int block_size,
unsigned long block_count,
unsigned long journal_size);
extern void reiserfs_journal_print_params (FILE * fp,
reiserfs_journal_param_t * jp);
extern void reiserfs_journal_print_header (reiserfs_filsys_t * fs);
extern void reiserfs_journal_print (reiserfs_filsys_t *);
extern int reiserfs_print_jdesc (FILE * fp, reiserfs_bh_t * bh);
#endif
-126
View File
@@ -1,126 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_KEY_H
#define REISERFS_KEY_H
/* set/get fields of keys on disk with these defines */
#define reiserfs_key_get_did(k) get_le32 (k, k2_dir_id)
#define reiserfs_key_set_did(k,val) set_le32 (k, k2_dir_id, val)
#define reiserfs_key_get_oid(k) get_le32 (k, k2_objectid)
#define reiserfs_key_set_oid(k,val) set_le32 (k, k2_objectid, val)
#define reiserfs_key_get_off1(k) get_le32 (k, u.k2_offset_v1.k_offset)
#define reiserfs_key_set_off1(k,val) set_le32 (k, u.k2_offset_v1.k_offset, val)
#define reiserfs_key_get_uni(k) get_le32 (k, u.k2_offset_v1.k_uniqueness)
#define reiserfs_key_set_uni(k,val) set_le32 (k, u.k2_offset_v1.k_uniqueness, val)
#define REISERFS_KEY_SIZE (sizeof(reiserfs_key_t))
#define REISERFS_KEY_SHSIZE 8
// values for k_uniqueness field of the reiserfs_key_t
#define UNI_SD 0
#define UNI_DE 500
#define UNI_DE 500
#define UNI_DIRECT 0xffffffff
#define UNI_EXT 0xfffffffe
#define UNI_UNKN 555
/* values for k_type field of the reiserfs_key_t */
#define TYPE_STAT_DATA 0x0
#define TYPE_EXTENT 0x1
#define TYPE_DIRECT 0X2
#define TYPE_DIRENTRY 0X3
#define TYPE_LAST 0x4
#define TYPE_UNKNOWN 0xf
#define KEY_FORMAT_1 0
#define KEY_FORMAT_2 1
#define KEY_FORMAT_UNDEFINED 15
/* Our function for comparing keys can compare keys of different lengths.
It takes as a parameter the length of the keys it is to compare. These
defines are used in determining what is to be passed to it as that
parameter. */
#define REISERFS_KEY_LEN 4
#define REISERFS_KEY_SHORT_LEN 2
/* there are 4 types of items: stat data, directory item, extent, direct.
FIXME: This table does not describe new key format
+-------------------+------------+--------------+------------+
| | k_offset | k_uniqueness | mergeable? |
+-------------------+------------+--------------+------------+
| stat data | 0 | 0 | no |
+-------------------+------------+--------------+------------+
| 1st directory item| OFFSET_DOT |DIRENTRY_UNIQU| no |
| non 1st directory | hash value | | yes |
| item | | | |
+-------------------+------------+--------------+------------+
| extent item | offset + 1 |TYPE_EXTENT | if not the first object EXT item
+-------------------+------------+--------------+------------+
| direct item | offset + 1 |TYPE_DIRECT | if not the first object direct item
+-------------------+------------+--------------+------------+
*/
#define reiserfs_key_stat(p_s_key) \
(reiserfs_key_get_type (p_s_key) == TYPE_STAT_DATA )
#define reiserfs_key_dir(p_s_key) \
(reiserfs_key_get_type (p_s_key) == TYPE_DIRENTRY )
#define reiserfs_key_direct(p_s_key) \
(reiserfs_key_get_type (p_s_key) == TYPE_DIRECT )
#define reiserfs_key_ext(p_s_key) \
(reiserfs_key_get_type (p_s_key) == TYPE_EXTENT )
#define reiserfs_key_unkn(p_s_key) \
(reiserfs_key_get_type (p_s_key) >= TYPE_LAST)
#define MAX_KEY1_OFFSET 0xffffffff
#define MAX_KEY2_OFFSET 0xfffffffffffffffLL
/* hash value occupies 24 bits starting from 7 up to 30 */
#define OFFSET_HASH(offset) ((offset) & 0x7fffff80)
/* generation number occupies 7 bits starting from 0 up to 6 */
#define OFFSET_GEN(offset) ((offset) & 0x0000007f)
#define OFFSET_SD 0
#define OFFSET_DOT 1
#define OFFSET_DOT_DOT 2
extern const reiserfs_key_t MIN_KEY;
extern const reiserfs_key_t MAX_KEY;
extern const reiserfs_key_t root_dir_key;
extern const reiserfs_key_t parent_root_dir_key;
extern reiserfs_key_t lost_found_dir_key;
extern void reiserfs_key_copy (reiserfs_key_t * to, const reiserfs_key_t * from);
extern void reiserfs_key_copy2 (reiserfs_key_t * to, const reiserfs_key_t * from);
extern int reiserfs_key_comp (const void * k1, const void * k2);
extern int reiserfs_key_comp3 (const void * k1, const void * k2);
extern int reiserfs_key_comp2 (const void * p_s_key1, const void * p_s_key2);
extern int reiserfs_key_format (const reiserfs_key_t * key);
extern unsigned long long reiserfs_key_get_off (const reiserfs_key_t * key);
extern int reiserfs_key_get_type (const reiserfs_key_t * key);
extern char * reiserfs_key_name (const reiserfs_key_t * key);
extern void reiserfs_key_set_type (int format,
reiserfs_key_t * key,
int type);
extern void reiserfs_key_set_off (int format,
reiserfs_key_t * key,
unsigned long long offset);
extern void reiserfs_key_set_sec (int format,
reiserfs_key_t * key,
unsigned long long offset,
int type);
#endif
-197
View File
@@ -1,197 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*
* Leaf balancing method declarations.
*
*/
#ifndef REISERFS_LEAF_H
#define REISERFS_LEAF_H
#include <reiserfs/types.h>
#include <misc/bitops.h>
/* size of item header */
#define REISERFS_IH_SIZE (sizeof(reiserfs_ih_t))
/* set/get fields of item head on disk with these defines */
#define reiserfs_ih_get_entries(ih) get_le16 (ih, u.ih2_entry_count)
#define reiserfs_ih_set_entries(ih,val) set_le16 (ih, u.ih2_entry_count, val)
#define reiserfs_ih_get_free(ih) get_le16 (ih, u.ih2_free_space)
#define reiserfs_ih_set_free(ih,val) set_le16 (ih, u.ih2_free_space, 0)
#define reiserfs_ih_get_len(ih) get_le16 (ih, ih2_item_len)
#define reiserfs_ih_set_len(ih,val) set_le16 (ih, ih2_item_len, val)
#define reiserfs_ih_get_loc(ih) get_le16 (ih, ih2_item_location)
#define reiserfs_ih_set_loc(ih,val) set_le16 (ih, ih2_item_location, val)
#define reiserfs_ih_format_v1(ih) (reiserfs_ih_get_format (ih) == KEY_FORMAT_1)
#define IH_Unreachable 0
#define IH_Was_Tail 1
#define IH_Checked 2
#define IH_Writable 3
/* Unreachable bit is set on tree rebuilding and is cleared in semantic pass */
#define reiserfs_ih_clflags(ih) reiserfs_ih_set_flags (ih, 0)
#define reiserfs_ih_isreach(ih) \
(!(reiserfs_ih_get_flags (ih) & (1 << IH_Unreachable)))
#define reiserfs_ih_clunreach(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) & ~(1 << IH_Unreachable))
#define reiserfs_ih_mkunreach(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) | (1 << IH_Unreachable))
#define reiserfs_ih_wastail(ih) \
(reiserfs_ih_get_flags (ih) & (1 << IH_Was_Tail))
#define reiserfs_ih_mktail(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) | (1 << IH_Was_Tail))
#define reiserfs_ih_cltail(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) & ~(1 << IH_Was_Tail))
#define reiserfs_ih_ischeck(ih) \
(reiserfs_ih_get_flags (ih) & (1 << IH_Checked))
#define reiserfs_ih_mkcheck(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) | (1 << IH_Checked))
#define reiserfs_ih_clcheck(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) & ~(1 << IH_Checked))
#define reiserfs_ih_iswrite(ih) \
(reiserfs_ih_get_flags (ih) & (1 << IH_Writable))
#define reiserfs_ih_mkwrite(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) | (1 << IH_Writable))
#define reiserfs_ih_clwrite(ih) reiserfs_ih_set_flags (ih, \
reiserfs_ih_get_flags (ih) & ~(1 << IH_Writable))
#define reiserfs_ih_stat(p_s_ih) reiserfs_key_stat(&((p_s_ih)->ih_key))
#define reiserfs_ih_dir(p_s_ih) reiserfs_key_dir(&((p_s_ih)->ih_key))
#define reiserfs_ih_direct(p_s_ih) reiserfs_key_direct(&((p_s_ih)->ih_key))
#define reiserfs_ih_ext(p_s_ih) reiserfs_key_ext(&((p_s_ih)->ih_key))
/* maximal length of item */
#define REISERFS_ITEM_MAX(block_size) \
(block_size - REISERFS_NODEH_SIZE - REISERFS_IH_SIZE)
#define REISERFS_ITEM_MIN 1
#define REISERFS_DIRECT_MAX(size) \
((size) - REISERFS_NODEH_SIZE - 2 * REISERFS_IH_SIZE - \
REISERFS_SD_SIZE - REISERFS_EXT_SIZE)
/* get the item header */
#define reiserfs_ih_at(bh,item_num) \
((reiserfs_ih_t * )((bh)->b_data + REISERFS_NODEH_SIZE) + (item_num))
/* get the key */
#define reiserfs_ih_key_at(bh,item_num) \
(&(reiserfs_ih_at(bh,item_num)->ih_key))
/* get item body */
#define reiserfs_item_at(bh,item_num) \
( (bh)->b_data + reiserfs_ih_get_loc (reiserfs_ih_at((bh),(item_num))))
/* following defines use reiserfs buffer header and item header */
/* get item body */
#define reiserfs_item_by_ih(bh,ih) ((bh)->b_data + reiserfs_ih_get_loc(ih))
#define reiserfs_leaf_head(bh) \
(reiserfs_nh_get_level ((reiserfs_node_head_t *)((bh)->b_data)) \
== LEAF_LEVEL)
/* check whether byte number 'offset' is in this item */
#define reiserfs_item_has_off(p_s_ih, n_offset, n_blocksize) \
(reiserfs_key_get_off(&(p_s_ih)->ih_key) <= (n_offset) && \
reiserfs_key_get_off(&(p_s_ih)->ih_key) + \
reiserfs_leaf_ibytes(p_s_ih,n_blocksize) > (n_offset) )
#define reiserfs_item_has_key(p_s_ih, p_s_key, n_blocksize) \
(!reiserfs_key_comp2(p_s_ih, p_s_key) && \
reiserfs_item_has_off(p_s_ih, reiserfs_key_get_off (p_s_key), \
n_blocksize))
#define reiserfs_item_off_at(ih, pos, bs) \
(reiserfs_key_get_off (&(ih)->ih_key) + \
(pos) * (reiserfs_ih_direct(ih) ? 1 : (bs)))
#define reiserfs_dir(ih, item) \
((reiserfs_ih_stat(ih) && !not_a_directory(item)) || \
reiserfs_ih_dir(ih))
#define reiserfs_item_count(ih) \
(reiserfs_ih_ext(ih) ? reiserfs_ext_count(ih) : \
reiserfs_ih_direct(ih) ? reiserfs_ih_get_len(ih) : \
reiserfs_ih_dir(ih) ? reiserfs_ih_get_entries(ih) : \
reiserfs_ih_stat(ih) ? 1 : 0)
extern void reiserfs_leaf_mkempty (reiserfs_bh_t *bh);
extern int reiserfs_leaf_mergeable (reiserfs_ih_t *left,
reiserfs_ih_t *right,
int bsize);
extern int reiserfs_leaf_count_items(reiserfs_bh_t *bh);
extern int reiserfs_leaf_free_count(reiserfs_bh_t *bh);
extern int reiserfs_leaf_estimate_items(reiserfs_bh_t * bh);
extern int reiserfs_leaf_valid(reiserfs_bh_t *bh);
typedef void (*ih_func_t) (reiserfs_ih_t * ih);
typedef void (*item_func_t) (reiserfs_bh_t * bh,
reiserfs_ih_t * ih);
extern void reiserfs_leaf_traverse(reiserfs_bh_t * bh,
ih_func_t action,
item_func_t * actions);
extern void reiserfs_leaf_delete_item (reiserfs_filsys_t *,
reiserfs_bh_t * bh,
int item_num);
extern void reiserfs_leaf_delete_entry (reiserfs_filsys_t *,
reiserfs_bh_t * bh,
int item_num,
int entry_num,
int del_count);
extern int reiserfs_leaf_correct_at (reiserfs_filsys_t *,
reiserfs_ih_t *, char *,
unfm_func_t, int);
extern __u32 reiserfs_leaf_ibytes (const reiserfs_ih_t * ih,
int blocksize);
extern int reiserfs_leaf_print(FILE * fp,
reiserfs_filsys_t * fs,
reiserfs_bh_t * bh,
int print_mode,
int first,
int last);
/* key format is stored in 12 bits starting from 0-th of item_head's ih2_format*/
extern __u16 reiserfs_ih_get_format(const reiserfs_ih_t *ih);
extern void reiserfs_ih_set_format(reiserfs_ih_t *ih, __u16 val);
extern __u16 reiserfs_ih_get_flags(const reiserfs_ih_t *ih);
extern void reiserfs_ih_set_flags(reiserfs_ih_t *ih, __u16 val);
enum leaf_print {
LP_LEAF_DETAILS = 0x1,
LP_DIRECT_ITEMS = 0x2,
LP_LAST
};
#endif
-42
View File
@@ -1,42 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_LB_H
#define REISERFS_LB_H
extern void reiserfs_lb_delete_item (reiserfs_filsys_t * fs,
reiserfs_bufinfo_t * bi,
int first,
int del_num);
extern void reiserfs_lb_delete_unit (reiserfs_filsys_t * fs,
reiserfs_bufinfo_t * bi,
int cut_item_num,
int pos_in_item,
int cut_size);
extern void reiserfs_lb_delete (reiserfs_filsys_t * fs,
reiserfs_bufinfo_t * cur_bi,
int last_first,
int first,
int del_num,
int del_bytes);
extern int reiserfs_lb_balance (reiserfs_tb_t * tb,
reiserfs_ih_t * ih,
const char * body,
int flag,
int zeros_number,
reiserfs_ih_t * insert_key,
reiserfs_bh_t ** insert_ptr);
extern int reiserfs_lb_copy (reiserfs_filsys_t * fs,
reiserfs_bufinfo_t * dest_bi,
reiserfs_bh_t * src,
int last_first,
int cpy_num,
int cpy_bytes);
#endif
-46
View File
@@ -1,46 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_LIBREISER4_H
#define REISERFS_LIBREISER4_H
#ifdef __cplusplus
extern "C" {
#endif
#include <reiserfs/types.h>
#include <reiserfs/bitmap.h>
#include <reiserfs/buffer.h>
#include <reiserfs/filesystem.h>
#include <reiserfs/journal.h>
#include <reiserfs/super.h>
#include <reiserfs/tree.h>
#include <reiserfs/key.h>
#include <reiserfs/node.h>
#include <reiserfs/leaf.h>
#include <reiserfs/direntry.h>
#include <reiserfs/internal.h>
#include <reiserfs/extent.h>
#include <reiserfs/stat.h>
#include <reiserfs/fix_node.h>
#include <reiserfs/tree_balance.h>
#include <reiserfs/internal_balance.h>
#include <reiserfs/leaf_balance.h>
#include <reiserfs/badblock.h>
#include <reiserfs/objmap.h>
#include <reiserfs/policy.h>
#include <reiserfs/print.h>
#include <reiserfs/hash.h>
#ifdef LIBREISERFS_READY
extern const char *libreiserfs_version(void);
extern int libreiserfs_max_interface_version(void);
extern int libreiserfs_min_interface_version(void);
#endif
#ifdef __cplusplus
}
#endif
#endif
-92
View File
@@ -1,92 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_NODE_H
#define REISERFS_NODE_H
/*
* Picture represents a leaf of internal tree
* ______________________________________________________
* | | Array of | | |
* |Block | Object-Item | F r e e | Objects- |
* | head | Headers | S p a c e | Items |
* |______|_______________|___________________|___________|
*/
/* Header of a disk block. More precisely, header of a formatted leaf
or internal node, and not the header of an unformatted node. */
struct reiserfs_node_head {
__u16 blk2_level; /* Level of a block in the tree. */
__u16 blk2_nr_item; /* Number of keys/items in a block. */
__u16 blk2_free_space; /* Block free space in bytes. */
__u16 blk_reserved;
__u32 reserved [4];
};
typedef struct reiserfs_node_head reiserfs_node_head_t;
#define REISERFS_NODEH_SIZE (sizeof(reiserfs_node_head_t))
/* set/get fields of block head on disk with these defines */
#define reiserfs_nh_get_level(blkh) get_le16 (blkh, blk2_level)
#define reiserfs_nh_set_level(blkh,val) set_le16 (blkh, blk2_level, val)
#define reiserfs_nh_get_items(blkh) get_le16 (blkh, blk2_nr_item)
#define reiserfs_nh_set_items(blkh,val) set_le16 (blkh, blk2_nr_item, val)
#define reiserfs_nh_get_free(blkh) get_le16 (blkh, blk2_free_space)
#define reiserfs_nh_set_free(blkh,val) set_le16 (blkh, blk2_free_space, val)
/*
* values for blk_type field
*/
#define FREE_LEVEL 0 /* Node of this level is out of the tree. */
#define LEAF_LEVEL 1 /* Leaf node level. */
/* Given the buffer head of a formatted node, resolve to the block head of that node. */
#define NODE_HEAD(p_s_bh) ((reiserfs_node_head_t *)((p_s_bh)->b_data))
#define reiserfs_node_items(bh) reiserfs_nh_get_items (NODE_HEAD(bh))
#define reiserfs_node_level(bh) reiserfs_nh_get_level (NODE_HEAD(bh))
#define reiserfs_node_free(bh) reiserfs_nh_get_free (NODE_HEAD(bh))
/* Does the buffer contain a disk block which is in the tree. */
#define REISERFS_NODE_INTREE(p_s_bh) \
(reiserfs_nh_get_level(NODE_HEAD (p_s_bh)) != FREE_LEVEL)
#define REISERFS_NODE_SPACE(blocksize) ((blocksize) - REISERFS_NODEH_SIZE)
/* amount of used space in buffer (not including block head) */
#define reiserfs_node_used(cur) (REISERFS_NODE_SPACE(cur->b_size) - \
(reiserfs_node_free(cur)))
enum node_type {
NT_LEAF = 0x1,
NT_INTERNAL = 0x2,
NT_SUPER = 0x3,
NT_JDESC = 0x4,
NT_IH_ARRAY = 0x5,
NT_UNKNOWN
};
typedef enum node_type node_type_t;
extern void reiserfs_node_replace_key (reiserfs_bh_t * dest, int n_dest,
reiserfs_bh_t * src, int n_src);
extern void reiserfs_node_forget(reiserfs_filsys_t *fs,
unsigned long blk);
extern int reiserfs_node_formatted (reiserfs_bh_t * bh, int level);
extern int reiserfs_node_type (reiserfs_bh_t *bh);
extern char *reiserfs_node_type_name(int code);
extern void reiserfs_node_print (FILE * fp,
reiserfs_filsys_t *,
reiserfs_bh_t * bh, ...);
#endif
-19
View File
@@ -1,19 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_OBJMAP_H
#define REISERFS_OBJMAP_H
/* object identifier for root dir */
#define REISERFS_ROOT_OBJECTID 2
#define REISERFS_ROOT_PARENT_OBJECTID 1
extern int reiserfs_objmap_test (reiserfs_filsys_t * fs, __u32 objectid);
extern void reiserfs_objmap_set (reiserfs_filsys_t * fs, __u32 objectid);
extern void reiserfs_objmap_print (FILE * fp, reiserfs_filsys_t * fs);
#endif
-25
View File
@@ -1,25 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_POLICY_H
#define REISERFS_POLICY_H
/* this is aggressive tail suppression policy taken from the kernel */
/* It should be REISERFS_DIRECT_MAX used here, but sometimes it is not enough,
* and items got deleted. */
#define reiserfs_policy_ext(n_file_size,n_tail_size,n_block_size) \
( \
(!(n_tail_size)) || \
(((n_tail_size) > REISERFS_ITEM_MAX(n_block_size)) || \
( (n_file_size) >= (n_block_size) * 4 ) || \
( ( (n_file_size) >= (n_block_size) * 3 ) && \
( (n_tail_size) >= (REISERFS_ITEM_MAX(n_block_size))/4) ) || \
( ( (n_file_size) >= (n_block_size) * 2 ) && \
( (n_tail_size) >= (REISERFS_ITEM_MAX(n_block_size))/2) ) || \
( ( (n_file_size) >= (n_block_size) ) && \
( (n_tail_size) >= (REISERFS_ITEM_MAX(n_block_size) * 3)/4) ) ) \
)
#endif
-29
View File
@@ -1,29 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_PRINT_H
#define REISERFS_PRINT_H
#include <stdlib.h>
extern void reiserfs_warning (FILE * fp, const char * fmt, ...);
#define reiserfs_panic(fmt, list...) \
{\
fflush (stdout);\
fprintf (stderr, "%s %d %s\n", __FILE__, __LINE__, __FUNCTION__);\
reiserfs_warning (stderr, (const char *)fmt, ## list);\
reiserfs_warning (stderr, "\n" );\
abort ();\
}
#define reiserfs_exit(val, fmt, list...) \
{\
fflush (stdout);\
reiserfs_warning (stderr, (const char *)fmt, ## list);\
reiserfs_warning (stderr, "\n" );\
exit (val);\
}
#endif
-192
View File
@@ -1,192 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_STAT_H
#define REISERFS_STAT_H
/* Stat Data on disk (reiserfs version of UFS disk inode minus the address blocks) */
/* The sense of adding union to stat data is to keep a value of real number of
blocks used by file. The necessity of adding such information is caused by
existing of files with holes. Reiserfs should keep number of used blocks
for file, but not calculate it from file size (that is not correct for
holed files). Thus we have to add additional information to stat data.
When we have a device special file, there is no need to get number of used
blocks for them, and, accordingly, we doesn't need to keep major and minor
numbers for regular files, which might have holes. So this field is being
overloaded. */
struct reiserfs_sd_v1 {
__u16 sd_mode; /* file type, permissions */
__u16 sd_nlink; /* number of hard links */
__u16 sd_uid; /* owner */
__u16 sd_gid; /* group */
__u32 sd_size; /* file size */
__u32 sd_atime; /* time of last access */
__u32 sd_mtime; /* time file was last modified */
__u32 sd_ctime; /* time inode (stat data) was last changed (except
changes to sd_atime and sd_mtime) */
union {
__u32 sd_rdev;
__u32 sd_blocks; /* number of blocks file uses */
} __attribute__ ((__packed__)) u;
__u32 sd_fdb; /* first byte of file which is stored
in a direct item: except that if it
equals 1 it is a symlink and if it
equals MAX_KEY_OFFSET there is no
direct item. The existence of this
field really grates on me. Let's
replace it with a macro based on
sd_size and our tail suppression
policy. Someday. -Hans */
} __attribute__ ((__packed__));
typedef struct reiserfs_sd_v1 reiserfs_sd_v1_t;
#define REISERFS_SD_SIZE_V1 (sizeof(reiserfs_sd_v1_t))
/* this is used to check sd_size of stat data v1 */
#define REISERFS_SD_SIZE_MAX_V1 0x7fffffff
// sd_fdb is set to this when there are no direct items in a file
#define REISERFS_SD_NODIRECT 0xffffffff
/* Stat Data on disk (reiserfs version of UFS disk inode minus the
address blocks) */
struct reiserfs_sd {
__u16 sd_mode; /* file type, permissions */
__u16 sd_attrs;
__u32 sd_nlink; /* 32 bit nlink! */
__u64 sd_size; /* 64 bit size!*/
__u32 sd_uid; /* 32 bit uid! */
__u32 sd_gid; /* 32 bit gid! */
__u32 sd_atime; /* time of last access */
__u32 sd_mtime; /* time file was last modified */
__u32 sd_ctime; /* time inode (stat data) was last changed (except
changes to sd_atime and sd_mtime) */
__u32 sd_blocks;
union {
__u32 sd_rdev;
__u32 sd_generation;
//__u32 sd_fdb;
/* first byte of file which is stored in a direct item: except that if
it equals 1 it is a symlink and if it equals ~(__u32)0 there is no
direct item. The existence of this field really grates on me. Let's
replace it with a macro based on sd_size and our tail suppression
policy? */
} __attribute__ ((__packed__)) u;
} __attribute__ ((__packed__));
//
// this is 44 bytes long
//
typedef struct reiserfs_sd reiserfs_sd_t;
#define REISERFS_SD_SIZE (sizeof(reiserfs_sd_t))
/* this is used to check sd_size of stat data v2: max offset which can
be reached with a key of format 2 is 60 bits */
#define REISERFS_SD_SIZE_MAX_V2 0xfffffffffffffffLL
/* reiserfs_sd_v1_t* access macros */
#define reiserfs_sd_v1_mode(sd) (le16_to_cpu((sd)->sd_mode))
#define reiserfs_set_sd_v1_mode(sd,n) ((sd)->sd_mode = cpu_to_le16((n)))
#define reiserfs_sd_v1_nlink(sd) (le16_to_cpu((sd)->sd_nlink))
#define reiserfs_set_sd_v1_nlink(sd,n) ((sd)->sd_nlink = cpu_to_le16((n)))
#define reiserfs_sd_v1_uid(sd) (le16_to_cpu((sd)->sd_uid))
#define reiserfs_set_sd_v1_uid(sd,n) ((sd)->sd_uid = cpu_to_le16((n)))
#define reiserfs_sd_v1_gid(sd) (le16_to_cpu((sd)->sd_gid))
#define reiserfs_set_sd_v1_gid(sd,n) ((sd)->sd_gid = cpu_to_le16((n)))
#define reiserfs_sd_v1_size(sd) (le32_to_cpu((sd)->sd_size))
#define reiserfs_set_sd_v1_size(sd,n) ((sd)->sd_size = cpu_to_le32((n)))
#define reiserfs_sd_v1_atime(sd) (le32_to_cpu((sd)->sd_atime))
#define reiserfs_set_sd_v1_atime(sd,n) ((sd)->sd_atime = cpu_to_le32((n)))
#define reiserfs_sd_v1_mtime(sd) (le32_to_cpu((sd)->sd_mtime))
#define reiserfs_set_sd_v1_mtime(sd,n) ((sd)->sd_mtime = cpu_to_le32((n)))
#define reiserfs_sd_v1_ctime(sd) (le32_to_cpu((sd)->sd_ctime))
#define reiserfs_set_sd_v1_ctime(sd,n) ((sd)->sd_ctime = cpu_to_le32((n)))
#define reiserfs_sd_v1_blocks(sd) (le32_to_cpu((sd)->u.sd_blocks))
#define reiserfs_set_sd_v1_blocks(sd,n) ((sd)->u.sd_blocks = cpu_to_le32((n)))
#define reiserfs_sd_v1_rdev(sd) (le32_to_cpu((sd)->u.sd_rdev))
#define reiserfs_set_sd_v1_rdev(sd,n) ((sd)->u.sd_rdev = cpu_to_le32((n)))
#define reiserfs_sd_v1_fdb(sd) (le32_to_cpu((sd)->sd_fdb))
#define reiserfs_set_sd_v1_fdb(sd,n) ((sd)->sd_fdb = cpu_to_le32((n)))
/* reiserfs_sd_t */
#define reiserfs_sd_v2_mode(sd) (le16_to_cpu((sd)->sd_mode))
#define reiserfs_set_sd_v2_mode(sd,n) ((sd)->sd_mode = cpu_to_le16((n)))
#define reiserfs_sd_v2_attrs(sd) (le16_to_cpu((sd)->sd_attrs))
#define reiserfs_set_sd_v2_attrs(sd,n) ((sd)->sd_attrs = cpu_to_le16((n)))
#define reiserfs_sd_v2_nlink(sd) (le32_to_cpu((sd)->sd_nlink))
#define reiserfs_set_sd_v2_nlink(sd,n) ((sd)->sd_nlink = cpu_to_le32((n)))
#define reiserfs_sd_v2_size(sd) (le64_to_cpu((sd)->sd_size))
#define reiserfs_set_sd_v2_size(sd,n) ((sd)->sd_size = cpu_to_le64((n)))
#define reiserfs_sd_v2_uid(sd) (le32_to_cpu((sd)->sd_uid))
#define reiserfs_set_sd_v2_uid(sd,n) ((sd)->sd_uid = cpu_to_le32((n)))
#define reiserfs_sd_v2_gid(sd) (le32_to_cpu((sd)->sd_gid))
#define reiserfs_set_sd_v2_gid(sd,n) ((sd)->sd_gid = cpu_to_le32((n)))
#define reiserfs_sd_v2_atime(sd) (le32_to_cpu((sd)->sd_atime))
#define reiserfs_set_sd_v2_atime(sd,n) ((sd)->sd_atime = cpu_to_le32((n)))
#define reiserfs_sd_v2_mtime(sd) (le32_to_cpu((sd)->sd_mtime))
#define reiserfs_set_sd_v2_mtime(sd,n) ((sd)->sd_mtime = cpu_to_le32((n)))
#define reiserfs_sd_v2_ctime(sd) (le32_to_cpu((sd)->sd_ctime))
#define reiserfs_set_sd_v2_ctime(sd,n) ((sd)->sd_ctime = cpu_to_le32((n)))
#define reiserfs_sd_v2_blocks(sd) (le32_to_cpu((sd)->sd_blocks))
#define reiserfs_set_sd_v2_blocks(sd,n) ((sd)->sd_blocks = cpu_to_le32((n)))
#define reiserfs_sd_v2_rdev(sd) (le32_to_cpu((sd)->u.sd_rdev))
#define reiserfs_set_sd_v2_rdev(sd,n) ((sd)->u.sd_rdev = cpu_to_le32((n)))
extern void reiserfs_stat_init (int blocksize, int key_format,
__u32 dirid, __u32 objectid,
reiserfs_ih_t * ih, void * sd);
extern void reiserfs_stat_set (int field, reiserfs_ih_t * ih,
void * sd, void * value);
extern void reiserfs_stat_get (int field, reiserfs_ih_t * ih,
void * sd, void * value);
/* access to stat data fields */
#define STAT_MODE 0
#define STAT_SIZE 1
#define STAT_NLINK 2
#define STAT_BLOCKS 3
#define STAT_FDB 4
#define reiserfs_stat_get_mode(ih, sd, pmode) \
reiserfs_stat_get(STAT_MODE, ih, sd, pmode)
#define reiserfs_stat_set_mode(ih, sd, pmode) \
reiserfs_stat_set(STAT_MODE, ih, sd, pmode)
#define reiserfs_stat_get_size(ih, sd, psize) \
reiserfs_stat_get(STAT_SIZE, ih, sd, psize)
#define reiserfs_stat_set_size(ih, sd, psize) \
reiserfs_stat_set(STAT_SIZE, ih, sd, psize)
#define reiserfs_stat_get_blocks(ih, sd, pblocks) \
reiserfs_stat_get(STAT_BLOCKS, ih, sd, pblocks)
#define reiserfs_stat_set_blocks(ih, sd, pblocks) \
reiserfs_stat_set(STAT_BLOCKS, ih, sd, pblocks)
#define reiserfs_stat_get_nlink(ih, sd, pnlink) \
reiserfs_stat_get(STAT_NLINK, ih, sd, pnlink)
#define reiserfs_stat_set_nlink(ih, sd, pnlink) \
reiserfs_stat_set(STAT_NLINK, ih, sd, pnlink)
#define reiserfs_stat_get_fdb(ih, sd, pfdb) \
reiserfs_stat_get(STAT_FDB, ih, sd, pfdb)
#define reiserfs_stat_set_fdb(ih, sd, pfdb) \
reiserfs_stat_set(STAT_FDB, ih, sd, pfdb)
extern int reiserfs_print_stat_data (FILE * fp,
reiserfs_bh_t * bh,
reiserfs_ih_t * ih,
int alltimes);
#endif
-156
View File
@@ -1,156 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_SUPER_H
#define REISERFS_SUPER_H
#define REISERFS_SB_SIZE_V1 (sizeof(reiserfs_sb_v1_t)) /* 76 bytes */
#define reiserfs_sb_jp(sb) (&((sb)->s_v1.sb_journal))
/* values for sb_version field of struct reiserfs_super_block. sb_version is
only reliable on filesystem with non-standard journal */
#define REISERFS_FORMAT_3_5 0
#define REISERFS_FORMAT_3_6 2
#define REISERFS_FORMAT_UNKNOWN -1
/* values for sb_mount_state field */
#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 */
typedef enum {
reiserfs_attrs_cleared = 0x00000001,
} reiserfs_super_block_flags;
#define REISERFS_SB_SIZE (sizeof(reiserfs_sb_t)) /* 204 bytes */
/* set/get fields of super block with these defines */
#define reiserfs_sb_get_blocks(sb) get_le32 (sb, s_v1.sb_block_count)
#define reiserfs_sb_set_blocks(sb,val) set_le32 (sb, s_v1.sb_block_count, val)
#define reiserfs_sb_get_free(sb) get_le32 (sb, s_v1.sb_free_blocks)
#define reiserfs_sb_set_free(sb,val) set_le32 (sb, s_v1.sb_free_blocks, val)
#define reiserfs_sb_get_root(sb) get_le32 (sb,s_v1.sb_root_block)
#define reiserfs_sb_set_root(sb,val) set_le32 (sb, s_v1.sb_root_block, val)
#if 0
#define get_sb_mount_id(sb) get_le32 (sb,s_v1.sb_mountid)
#define set_sb_mount_id(sb,val) set_le32 (sb, s_v1.sb_mountid, val)
#define get_sb_journal_magic(sb) get_le32 (sb, s_v1.sb_journal_magic)
#define set_sb_journal_magic(sb,val) set_le32 (sb, s_v1.sb_journal_magic, val)
#endif
#define reiserfs_sb_get_blksize(sb) get_le16 (sb, s_v1.sb_blocksize)
#define reiserfs_sb_set_blksize(sb,val) set_le16 (sb, s_v1.sb_blocksize, val)
#define reiserfs_sb_get_mapmax(sb) get_le16 (sb, s_v1.sb_oid_maxsize)
#define reiserfs_sb_set_mapmax(sb,val) set_le16 (sb, s_v1.sb_oid_maxsize, val)
#define reiserfs_sb_get_mapcur(sb) get_le16 (sb, s_v1.sb_oid_cursize)
#define reiserfs_sb_set_mapcur(sb,val) set_le16 (sb, s_v1.sb_oid_cursize, val)
#define reiserfs_sb_get_umount(sb) get_le16 (sb, s_v1.sb_umount_state)
#define reiserfs_sb_set_umount(sb,val) set_le16 (sb, s_v1.sb_umount_state, val)
#define reiserfs_sb_get_state(sb) get_le16 (sb, s_v1.sb_fs_state)
#define reiserfs_sb_set_state(sb,flag) set_le16 (sb, s_v1.sb_fs_state, flag)
#define reiserfs_sb_get_hash(sb) get_le32 (sb, s_v1.sb_hash_function_code)
#define reiserfs_sb_set_hash(sb,val) set_le32 (sb, s_v1.sb_hash_function_code, val)
#define reiserfs_sb_get_height(sb) get_le16 (sb, s_v1.sb_tree_height)
#define reiserfs_sb_set_height(sb,val) set_le16 (sb, s_v1.sb_tree_height, val)
#define reiserfs_sb_get_bmaps(sb) get_le16 (sb, s_v1.sb_bmap_nr)
#define reiserfs_sb_set_bmaps(sb,val) set_le16 (sb, s_v1.sb_bmap_nr, val)
#define reiserfs_sb_get_version(sb) get_le16 (sb, s_v1.sb_version)
#define reiserfs_sb_set_version(sb,val) set_le16 (sb, s_v1.sb_version, val)
#define reiserfs_sb_get_reserved(sb) \
get_le16 (sb, s_v1.sb_reserved_for_journal)
#define reiserfs_sb_set_reserved(sb,val) \
set_le16 (sb, s_v1.sb_reserved_for_journal, val)
#define reiserfs_sb_get_gen(sb) get_le32 (sb, sb_inode_generation)
#define reiserfs_sb_set_gen(sb,val) set_le32 (sb, sb_inode_generation, val)
#define reiserfs_sb_get_flags(sb) get_le32 (sb, s_flags)
#define reiserfs_sb_set_flags(sb, val) set_le32 (sb, s_flags, val)
#define reiserfs_sb_isflag(sb, flag) \
(get_le32 (sb, s_flags) & flag)
#define reiserfs_sb_mkflag(sb, flag) \
set_le32 (sb, s_flags, get_le32 (sb, s_flags) | flag)
#define reiserfs_sb_clflag(sb, flag) \
set_le32 (sb, s_flags, get_le32 (sb, s_flags) & ~(flag))
/* 0 does not guarantee that fs is consistent */
#define reiserfs_sb_state_ok(fs) \
((reiserfs_sb_get_umount (fs->fs_ondisk_sb) == FS_CLEANLY_UMOUNTED) && \
(reiserfs_sb_get_state (fs->fs_ondisk_sb) == FS_CONSISTENT))
/* prejournalled reiserfs had signature in the other place in super block */
#define REISERFS_SUPER_MAGIC_STRING_OFFSET_NJ 20
/* f_type of struct statfs will be set at this value by statfs(2) */
#define REISERFS_SUPER_MAGIC 0x52654973
/* various reiserfs signatures. We have 3 so far. ReIsErFs for 3.5 format with
standard journal, ReIsEr2Fs for 3.6 (or converted 3.5) and ReIsEr3Fs for
filesystem with non-standard journal (formats are distinguished by
sb_version in that case). Those signatures should be looked for at the
64-th and at the 8-th 1k block of the device */
#define REISERFS_3_5_SUPER_MAGIC_STRING "ReIsErFs"
#define REISERFS_3_6_SUPER_MAGIC_STRING "ReIsEr2Fs"
#define REISERFS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" /* JR stands for Journal
Relocation */
/* these are possible values for sb_fs_state */
enum reiserfs_state_flags {
/* this is set by mkreiserfs and by reiserfsck */
FS_CONSISTENT = 0x0,
/* this is set by the kernel when fsck is wanted. */
FS_ERROR = 0x1,
/* this is set by fsck when fatal corruption is found */
FS_FATAL = 0x2,
/* this is set by kernel when io error occures */
/* IO_ERROR = 0x4, */
FS_STATE_LAST = 0x5
};
extern int reiserfs_super_35_magic (reiserfs_sb_t * rs);
extern int reiserfs_super_36_magic (reiserfs_sb_t * rs);
extern int reiserfs_super_jr_magic (reiserfs_sb_t * rs);
extern int reiserfs_super_magic (reiserfs_sb_t * rs);
extern int reiserfs_super_format (reiserfs_sb_t * sb);
extern int reiserfs_super_size (reiserfs_sb_t * rs);
extern int reiserfs_super_prejournaled (reiserfs_sb_t * rs);
extern void reiserfs_super_print_state (FILE * fp,
reiserfs_filsys_t * fs);
extern int reiserfs_super_print (FILE * fp,
reiserfs_filsys_t *,
char * file_name,
reiserfs_bh_t * bh,
int short_print);
extern int reiserfs_super_valid(reiserfs_bh_t *bh);
#endif
-160
View File
@@ -1,160 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_TREE_H
#define REISERFS_TREE_H
#include <reiserfs/types.h>
/* Search_by_key fills up the path from the root to the leaf as it
descends the tree looking for the key. It uses reiserfs_buffer_read to
try to find buffers in the cache given their block number. If it
does not find them in the cache it reads them from disk. For each
node reiserfs_tree_search_item finds using reiserfs_buffer_read it then uses
bin_search to look through that node. bin_search will find the
position of the block_number of the next node if it is looking
through an internal node. If it is looking through a leaf node
bin_search will find the position of the item which has key either
equal to given key, or which is the maximal key less than the given
key. */
#define REISERFS_PATH_INIT(var) \
reiserfs_path_t var = {REISERFS_PATH_OFFILL, }
/* Get path element by path and path position. */
#define REISERFS_PATH_ELEM(p_s_path,nr_elem) \
((p_s_path)->path_elements + (nr_elem))
/* Get buffer header at the path by path and path position. */
#define REISERFS_PATH_BUFFER(p_s_path,nr_elem) \
(REISERFS_PATH_ELEM(p_s_path, nr_elem)->pe_buffer)
/* Get position in the element at the path by path and path position. */
#define REISERFS_PATH_POS(p_s_path,nr_elem) \
(REISERFS_PATH_ELEM(p_s_path, nr_elem)->pe_position)
#define REISERFS_PATH_LEAF(p_s_path) \
(REISERFS_PATH_BUFFER((p_s_path), (p_s_path)->path_length))
#define REISERFS_PATH_LEAF_POS(p_s_path) \
(REISERFS_PATH_POS((p_s_path), (p_s_path)->path_length))
#define REISERFS_PATH_IH(p_s_path) \
reiserfs_ih_at(REISERFS_PATH_LEAF(p_s_path), \
REISERFS_PATH_LEAF_POS(p_s_path))
/* in reiserfs_tb_balance leaf has h == 0 in contrast with path structure,
where root has level == 0. That is why we need these defines */
#define REISERFS_PATH_UPBUFFER(p_s_path, h) \
(REISERFS_PATH_BUFFER (p_s_path, p_s_path->path_length - (h)))
/* tb->F[h] or tb->S[0]->b_parent */
#define REISERFS_PATH_UPPARENT(path, h) \
REISERFS_PATH_UPBUFFER (path, (h) + 1)
#define REISERFS_PATH_UPPOS(path, h) \
REISERFS_PATH_POS (path, path->path_length - (h))
/* tb->S[h]->b_item_order */
#define REISERFS_PATH_UPPARENT_POS(path, h) \
REISERFS_PATH_UPPOS(path, h + 1)
#define REISERFS_PATH_LEVEL(p_s_path, n_h) \
((p_s_path)->path_length - (n_h))
#define REISERFS_PATH_ITEM(path) \
((void *) reiserfs_item_at(REISERFS_PATH_LEAF(path), \
REISERFS_PATH_LEAF_POS (path)))
extern int reiserfs_tree_search_entry (reiserfs_filsys_t *fs,
const reiserfs_key_t * key,
reiserfs_path_t * path);
extern int reiserfs_tree_search_position (reiserfs_filsys_t *fs,
const reiserfs_key_t * key,
reiserfs_path_t * path);
extern const reiserfs_key_t * reiserfs_tree_lkey (reiserfs_path_t * path,
reiserfs_filsys_t *fs);
extern const reiserfs_key_t * reiserfs_tree_rkey (reiserfs_path_t * path,
reiserfs_filsys_t *fs);
extern const reiserfs_key_t *reiserfs_tree_next_key (reiserfs_path_t * path,
reiserfs_filsys_t *fs);
extern int reiserfs_tree_delete_entry (reiserfs_filsys_t *,
reiserfs_key_t *);
extern void reiserfs_tree_delete (reiserfs_filsys_t *,
reiserfs_path_t *, int);
extern void reiserfs_tree_delete_unit (reiserfs_filsys_t *,
reiserfs_path_t *, int);
extern void reiserfs_tree_insert_unit (reiserfs_filsys_t *,
reiserfs_path_t * path,
const void * body,
int size);
extern void reiserfs_tree_insert (reiserfs_filsys_t *,
reiserfs_path_t * ,
reiserfs_ih_t *,
const void *);
extern int reiserfs_tree_search_name (reiserfs_filsys_t *,
const reiserfs_key_t * dir,
char * name,
unsigned int * min_gen_counter,
reiserfs_key_t * key);
extern int reiserfs_tree_search_body (reiserfs_filsys_t * fs,
const reiserfs_key_t * key,
reiserfs_path_t * path);
extern int reiserfs_tree_search_item (reiserfs_filsys_t * fs,
const reiserfs_key_t * key,
reiserfs_path_t * path);
extern int reiserfs_tree_scan_name (reiserfs_filsys_t *,
reiserfs_key_t * dir,
char * name,
reiserfs_path_t * path);
extern int reiserfs_tree_insert_entry (reiserfs_filsys_t *,
const reiserfs_key_t * dir,
char * name,
int name_len,
const reiserfs_key_t * key,
__u16 fsck_need);
typedef void (*item_modify_t) (reiserfs_ih_t *, void *item);
extern __u16 reiserfs_tree_root (reiserfs_filsys_t * fs,
item_modify_t modify,
__u16 ih_flags);
extern int reiserfs_tree_create_stat (reiserfs_filsys_t * fs,
reiserfs_path_t * path,
const reiserfs_key_t * key,
item_modify_t modify);
extern void reiserfs_tree_pathrelse (reiserfs_path_t * p_s_search_path);
extern int reiserfs_tree_left_mergeable (reiserfs_filsys_t * s,
reiserfs_path_t * path);
extern int reiserfs_tree_right_mergeable (reiserfs_filsys_t * s,
reiserfs_path_t * path);
extern int reiserfs_tree_node_mergeable (reiserfs_bh_t *left,
reiserfs_bh_t *right);
extern int reiserfs_tree_merge(reiserfs_filsys_t *fs,
reiserfs_path_t *dst_path,
reiserfs_path_t *src_path);
#endif
-202
View File
@@ -1,202 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_TB_H
#define REISERFS_TB_H
/* This temporary structure is used in tree balance algorithms, and
constructed as we go to the extent that its various parts are needed. It
contains arrays of nodes that can potentially be involved in the balancing
of node S, and parameters that define how each of the nodes must be
balanced. Note that in these algorithms for balancing the worst case is to
need to balance the current node S and the left and right neighbors and all
of their parents plus create a new node. We implement S1 balancing for the
leaf nodes and S0 balancing for the internal nodes (S1 and S0 are defined
in our papers.)*/
/* size of the array of buffers to free at end of reiserfs_tb_balance */
#define TB_2FREE_MAX 7
#define TB_FEB_MAX (REISERFS_TREE_HEIGHT_MAX + 1)
/* someday somebody will prefix every field in this struct with tb_ */
struct reiserfs_tb {
reiserfs_filsys_t * tb_fs;
reiserfs_path_t * tb_path;
/* array of left neighbors of nodes in the path */
reiserfs_bh_t * L[REISERFS_TREE_HEIGHT_MAX];
/* array of right neighbors of nodes in the path*/
reiserfs_bh_t * R[REISERFS_TREE_HEIGHT_MAX];
/* array of fathers of the left neighbors */
reiserfs_bh_t * FL[REISERFS_TREE_HEIGHT_MAX];
/* array of fathers of the right neighbors */
reiserfs_bh_t * FR[REISERFS_TREE_HEIGHT_MAX];
/* array of common parents of center node and its left neighbor */
reiserfs_bh_t * CFL[REISERFS_TREE_HEIGHT_MAX];
/* array of common parents of center node and its right neighbor */
reiserfs_bh_t * CFR[REISERFS_TREE_HEIGHT_MAX];
/* array of blocknr's that are free and are the nearest to the left
node that are usable for writing dirty formatted leaves, using
the write_next_to algorithm. */
/*unsigned long free_and_near[MAX_DIRTIABLE];*/
/* array of empty buffers. Number of buffers in array equals cur_blknum. */
reiserfs_bh_t * FEB[TB_FEB_MAX];
reiserfs_bh_t * used[TB_FEB_MAX];
/* array of number of items which must be shifted to the left in order to
balance the current node; for leaves includes item that will be partially
shifted; for internal nodes, it is the number of child pointers rather
than items. It includes the new item being created. For preserve_shifted
purposes the code sometimes subtracts one from this number to get the
number of currently existing items being shifted, and even more often
for leaves it subtracts one to get the number of wholly shifted items
for other purposes. */
short int lnum[REISERFS_TREE_HEIGHT_MAX];
/* substitute right for left in comment above */
short int rnum[REISERFS_TREE_HEIGHT_MAX];
/* array indexed by height h mapping the key delimiting L[h] and
S[h] to its item number within the node CFL[h] */
short int lkey[REISERFS_TREE_HEIGHT_MAX];
/* substitute r for l in comment above */
short int rkey[REISERFS_TREE_HEIGHT_MAX];
/* the number of bytes by we are trying to add or remove from S[h].
A negative value means removing. */
short int insert_size[REISERFS_TREE_HEIGHT_MAX];
/* number of nodes that will replace node S[h] after balancing on the level
h of the tree. If 0 then S is being deleted, if 1 then S is remaining
and no new nodes are being created, if 2 or 3 then 1 or 2 new nodes is
being created */
short int blknum[REISERFS_TREE_HEIGHT_MAX];
/* fields that are used only for balancing leaves of the tree */
/* number of empty blocks having been already allocated */
short int cur_blknum;
/* number of items that fall into left most node when S[0] splits */
short int s0num;
/* number of items that fall into first new node when S[0] splits */
short int s1num;
/* number of items that fall into second new node when S[0] splits */
short int s2num;
/* number of bytes which can flow to the left neighbor from the left */
short int lbytes;
/* most liquid item that cannot be shifted from S[0] entirely
if -1 then nothing will be partially shifted */
/* number of bytes which will flow to the right neighbor from the right */
short int rbytes;
/* number of bytes which flow to the first new node when S[0] splits
note: if S[0] splits into 3 nodes, then items do not need to be cut */
short int s1bytes;
short int s2bytes;
/* buffers which are to be freed after reiserfs_tb_balance finishes
by reiserfs_unfix_nodes */
reiserfs_bh_t * buf_to_free[TB_2FREE_MAX];
/* kmalloced memory. Used to create virtual node and keep map of dirtied
bitmap blocks */
char * vn_buf;
/* size of the vn_buf */
int vn_buf_size;
/* VN starts after bitmap of bitmap blocks */
struct reiserfs_virtual_node * tb_vn;
};
typedef struct reiserfs_tb reiserfs_tb_t;
enum tb_return {
CARRY_ON = 0x0,
NO_DISK_SPACE = 0x3,
IO_ERROR = 0x4,
NO_BALANCING_NEEDED = 0x5,
ITEM_FOUND = 0x6,
ITEM_NOT_FOUND = 0x7,
POSITION_FOUND = 0x8,
POSITION_NOT_FOUND = 0x9,
GOTO_PREVIOUS_ITEM = 0xa,
POSITION_FOUND_INVISIBLE= 0xb,
FILE_NOT_FOUND = 0xc,
DIRECTORY_NOT_FOUND = 0xd,
DIRECTORY_FOUND = 0xf,
LAST_SEARCH
};
/* These are modes of balancing */
/* When inserting an item. */
#define M_INSERT 'i'
/* When inserting into (directories only) or appending onto an already
existant item. */
#define M_PASTE 'p'
/* When deleting an item. */
#define M_DELETE 'd'
/* When truncating an item or removing an entry from a (directory) item. */
#define M_CUT 'c'
/* used when balancing on leaf level skipped (in reiserfsck) */
#define M_INTERNAL 'n'
#define FIRST_TO_LAST 0
#define LAST_TO_FIRST 1
/* used in reiserfs_tb_balance for passing parent of node information that
has been gotten from tb struct */
struct reiserfs_bufinfo {
reiserfs_bh_t * bi_bh;
reiserfs_bh_t * bi_parent;
int bi_position;
};
typedef struct reiserfs_bufinfo reiserfs_bufinfo_t;
extern void reiserfs_tb_attach_new (reiserfs_bufinfo_t * bi);
extern reiserfs_bh_t * reiserfs_tb_FEB (reiserfs_tb_t *tb);
extern int reiserfs_tb_lpos (reiserfs_tb_t * tb, int h);
extern int reiserfs_tb_rpos (reiserfs_tb_t * tb, int h);
extern void reiserfs_tb_balance (reiserfs_tb_t * tb,
reiserfs_ih_t * ih,
const char * body,
int flag,
int zeros_num);
extern void reiserfs_tb_init (reiserfs_tb_t * tb,
reiserfs_filsys_t *,
reiserfs_path_t * path,
int size);
extern void reiserfs_tb_print_path (reiserfs_tb_t * tb,
reiserfs_path_t * path);
#endif
-297
View File
@@ -1,297 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFS_TYPES_H
#define REISERFS_TYPES_H
#include "misc/types.h"
#include "misc/swab.h"
struct reiserfs_bitmap {
unsigned long bm_byte_size;
unsigned long bm_bit_size;
char * bm_map;
unsigned long bm_set_bits;
int bm_dirty; /* used for fetched bitmap */
unsigned long bm_first_zero;
};
typedef struct reiserfs_bitmap reiserfs_bitmap_t;
typedef struct reiserfs_bh reiserfs_bh_t;
struct reiserfs_bh {
unsigned long b_blocknr;
int b_dev;
unsigned long b_size;
char * b_data;
unsigned long b_state;
unsigned int b_count;
unsigned int b_list ;
void (*b_start_io) (unsigned long);
void (*b_end_io)(reiserfs_bh_t *bh, int uptodate);
reiserfs_bh_t * b_next;
reiserfs_bh_t * b_prev;
reiserfs_bh_t * b_hash_next;
reiserfs_bh_t * b_hash_prev;
};
/* magic string to find desc blocks in the journal */
#define JOURNAL_DESC_MAGIC "ReIsErLB"
struct reiserfs_journal_param {
/* where does journal start from on its device */
__u32 jp_start;
/* journal device st_rdev */
__u32 jp_dev;
/* size of the journal on FS creation. used to make sure
they don't overflow it */
__u32 jp_size;
/* max number of blocks in a transaction. */
__u32 jp_tlen;
/* random value made on fs creation (this was sb_journal_block_count) */
__u32 jp_magic;
/* max number of blocks to batch into a trans */
__u32 jp_max_batch;
/* in seconds, how old can an async commit be */
__u32 jp_commit_age;
/* in seconds, how old can a transaction be */
__u32 jp_trans_age;
};
typedef struct reiserfs_journal_param reiserfs_journal_param_t;
/* this header block gets written whenever a transaction is considered fully
** flushed, and is more recent than the last fully flushed transaction. fully
** flushed means all the log blocks and all the real blocks are on disk, and
** this transaction does not need to be replayed. */
struct reiserfs_journal_header {
/* id of last fully flushed transaction */
__u32 jh_last_flush_trans_id ;
/* offset in the log of where to start replay after a crash */
__u32 jh_flush_offset ;
__u32 jh_mount_id ;
reiserfs_journal_param_t jh_journal;
/* the mount id of the fs during the last reiserfsck --check. */
__u32 jh_last_check_mount_id;
};
/* this is the super from 3.5.X */
struct reiserfs_super_block_v1
{
__u32 sb_block_count; /* 0 number of block on data device */
__u32 sb_free_blocks; /* 4 free blocks count */
__u32 sb_root_block; /* 8 root of the tree */
reiserfs_journal_param_t sb_journal; /* 12 */
__u16 sb_blocksize; /* 44 */
__u16 sb_oid_maxsize; /* 46 max size of object id array, see
get_objectid() commentary */
__u16 sb_oid_cursize; /* 48 current size of object id array */
__u16 sb_umount_state; /* 50 this is set to 1 when filesystem was
umounted, to 2 - when not */
char s_magic[10]; /* 52 reiserfs magic string indicates that
file system is reiserfs: "ReIsErFs" or
"ReIsEr2Fs" or "ReIsEr3Fs" */
__u16 sb_fs_state; /* 62 it is set to used by fsck to mark which phase of
rebuilding is done (used for fsck debugging) */
__u32 sb_hash_function_code;/* 64 code of fuction which was/is/will be
used to sort names in a directory. See
codes in above */
__u16 sb_tree_height; /* 68 height of filesytem tree. Tree
consisting of only one root block has 2
here */
__u16 sb_bmap_nr; /* 70 amount of bitmap blocks needed to
address each block of file system */
__u16 sb_version; /* 72 this field is only reliable on
filesystem with non-standard journal */
__u16 sb_reserved_for_journal; /* 74 size in blocks of journal area on
main device, we need to keep after
non-standard journal relocation */
};
typedef struct reiserfs_super_block_v1 reiserfs_sb_v1_t;
/* Structure of super block on disk */
struct reiserfs_super_block {
/* 0 */ reiserfs_sb_v1_t s_v1;
/* 76 */ __u32 sb_inode_generation;
/* Right now used only by inode-attributes, if enabled */
/* 80 */ __u32 s_flags;
/* filesystem unique identifier */
/* 84 */ unsigned char s_uuid[16];
/* filesystem volume label */
/*100 */ unsigned char s_label[16];
/* zero filled by mkreiserfs and reiserfs_convert_objectid_map_v1()
* so any additions must be updated there as well. */
/*116 */ char s_unused[88];
/*204*/
} __attribute__ ((__packed__));;
typedef struct reiserfs_super_block reiserfs_sb_t;
typedef __u32 (*hashf_t) (const char *, int);
typedef struct reiserfs_filsys reiserfs_filsys_t;
struct reiserfs_filsys {
unsigned int fs_blocksize;
int fs_format; /* on-disk format version */
hashf_t hash; /* pointer to function which is used to sort
names in directory. It is set by
reiserfs_fs_open if it is set in the super
block, otherwise it is set by first
reiserfs_hash_correct */
char fs_file_name[4096]; /* file name of underlying device */
int fs_dev; /* descriptor of opened block device file */
reiserfs_bh_t * fs_super_bh; /* buffer containing super block */
reiserfs_sb_t * fs_ondisk_sb; /* pointer to its b_data */
reiserfs_bitmap_t * fs_bitmap2; /* ondisk bitmap after
reiserfs_bitmap_open */
/* opened journal fields */
char fs_j_file_name[4096]; /* file name of relocated journal device */
int fs_journal_dev; /* descriptor of opened journal device */
reiserfs_bh_t * fs_jh_bh; /* buffer containing journal header */
/* badblocks */
reiserfs_bitmap_t * fs_badblocks_bm;
int fs_dirt;
int fs_flags;
void * fs_vp;
int (*block_allocator) (reiserfs_filsys_t * fs,
unsigned long * free_blocknrs,
unsigned long start, int amount_needed);
int (*block_deallocator) (reiserfs_filsys_t * fs, unsigned long block);
__u16 lost_format;
};
#define REISERFS_TREE_HEIGHT_MAX 6
#define REISERFS_PATH_OFFINIT 2
#define REISERFS_PATH_OFFILL 1
#define REISERFS_PATH_MAX (REISERFS_TREE_HEIGHT_MAX + \
REISERFS_PATH_OFFINIT)
struct reiserfs_path_element {
/* Pointer to the buffer at the path in the tree. */
reiserfs_bh_t * pe_buffer;
/* Position in the tree node which is placed in the buffer above. */
int pe_position;
};
typedef struct reiserfs_path_element reiserfs_path_element_t;
/* We need to keep track of who the ancestors of nodes are. When we
perform a search we record which nodes were visited while
descending the tree looking for the node we searched for. This list
of nodes is called the path. This information is used while
performing balancing. Note that this path information may become
invalid, and this means we must check it when using it to see if it
is still valid. You'll need to read reiserfs_tree_search_item and the
comments in it, especially about decrement_counters_in_path(),
to understand this structure. */
struct reiserfs_path {
/* Length of the array above. */
unsigned int path_length;
/* Array of the path elements. */
reiserfs_path_element_t path_elements[REISERFS_PATH_MAX];
int pos_in_item;
};
typedef struct reiserfs_path reiserfs_path_t;
struct reiserfs_koff_v1 {
__u32 k_offset;
__u32 k_uniqueness;
} __attribute__ ((__packed__));
struct reiserfs_koff_v2 {
#if __BYTE_ORDER == __LITTLE_ENDIAN
__u64 k_offset:60;
__u64 k_type: 4;
#elif __BYTE_ORDER == __BIG_ENDIAN
__u64 k_type: 4;
__u64 k_offset:60;
#else
# error "nuxi/pdp-endian archs are not supported"
#endif
} __attribute__ ((__packed__));
/* Key of the object determines object's location in the tree,
composed of 4 components */
struct reiserfs_key {
/* packing locality: by default parent directory object id */
__u32 k2_dir_id;
/* object identifier */
__u32 k2_objectid;
union {
struct reiserfs_koff_v1 k2_offset_v1;
struct reiserfs_koff_v2 k2_offset_v2;
} __attribute__ ((__packed__)) u;
} __attribute__ ((__packed__));
typedef struct reiserfs_key reiserfs_key_t;
/* Everything in the filesystem is stored as a set of items. The item head
contains the key of the item, its free space (for extent items) and
specifies the location of the item itself within the block. */
struct reiserfs_ih {
reiserfs_key_t ih_key; /* Everything in the tree is found by searching for it
based on its key.*/
union {
__u16 ih2_free_space; /* The free space in the last unformatted node
of an extent item if this is an extent
item. This equals 0xFFFF iff this is a direct
item or stat data item. Note that the key, not
this field, is used to determine the item
type, and thus which field this union
contains. */
__u16 ih2_entry_count; /* Iff this is a directory item, this field
equals the number of directory entries in
the directory item. */
} __attribute__ ((__packed__)) u;
__u16 ih2_item_len; /* total size of the item body */
__u16 ih2_item_location; /* an offset to the item body within the
block */
__u16 ih_format; /* key format is stored in bits 0-11 of this item
flags are stored in bits 12-15 */
#if 0
struct {
__u16 key_format : 12; /* KEY_FORMAT_1 or KEY_FORMAT_2. This is not
necessary, but we have space, let use it */
__u16 flags : 4; /* fsck set here its flag (reachable/unreachable) */
} __attribute__ ((__packed__)) ih2_format;
#endif
} __attribute__ ((__packed__));
typedef struct reiserfs_ih reiserfs_ih_t;
typedef int (*unfm_func_t) (reiserfs_filsys_t *, __u32);
#endif
File diff suppressed because it is too large. Load diff
+412
View File
@@ -0,0 +1,412 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef REISERFSPROGS_LIB_H
#define REISERFSPROGS_LIB_H
#define BADBLOCK_DIRID 1
#define BADBLOCK_OBJID (__u32)-1
typedef struct reiserfs_filsys reiserfs_filsys_t;
#include "reiserfs_fs.h"
struct _bitmap {
unsigned long bm_byte_size;
unsigned long bm_bit_size;
char * bm_map;
unsigned long bm_set_bits;
int bm_dirty; /* used for fetched bitmap */
};
typedef struct _bitmap reiserfs_bitmap_t;
typedef __u32 (*hashf_t) (const char *, int);
struct reiserfs_filsys {
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
reiserfs_open if it is set in the super
block, otherwise it is set by first
is_properly_hashed */
char * fs_file_name; /* file name of underlying device */
int fs_dev; /* descriptor of opened block device file */
struct buffer_head * fs_super_bh; /* buffer containing super block */
struct reiserfs_super_block * fs_ondisk_sb; /* pointer to its b_data */
reiserfs_bitmap_t * fs_bitmap2; /* ondisk bitmap after
reiserfs_open_ondisk_bitmap */
/* opened journal fields */
char * fs_j_file_name; /* file name of relocated journal device */
int fs_journal_dev; /* descriptor of opened journal device */
struct buffer_head * fs_jh_bh; /* buffer containing journal header */
/* badblocks */
reiserfs_bitmap_t * fs_badblocks_bm;
int fs_dirt;
int fs_flags;
void * fs_vp;
int (*block_allocator) (reiserfs_filsys_t * fs,
unsigned long * free_blocknrs,
unsigned long start, int amount_needed);
int (*block_deallocator) (reiserfs_filsys_t * fs, unsigned long block);
};
struct _transaction {
unsigned long mount_id;
unsigned long trans_id;
unsigned long desc_blocknr;
unsigned long trans_len;
unsigned long commit_blocknr;
unsigned long next_trans_offset;
};
typedef struct _transaction reiserfs_trans_t;
/* reiserfslib.c */
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, 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 *);
void reiserfs_free (reiserfs_filsys_t *);
void reiserfs_close (reiserfs_filsys_t *);
void reiserfs_reopen (reiserfs_filsys_t *, int flags);
int is_opened_rw (reiserfs_filsys_t * fs);
/*
void reiserfs_read_bitmap_blocks (reiserfs_filsys_t *);
void reiserfs_free_bitmap_blocks (reiserfs_filsys_t *);
*/
int no_reiserfs_found (reiserfs_filsys_t *);
int block_size_ok(int blocksize, int force);
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);
int reiserfs_new_blocknrs (reiserfs_filsys_t *,
unsigned long * free_blocknrs, unsigned long start,
int amount_needed);
int reiserfs_free_block (reiserfs_filsys_t *, unsigned long block);
int spread_bitmaps (reiserfs_filsys_t *);
int filesystem_dirty (reiserfs_filsys_t *);
void mark_filesystem_dirty (reiserfs_filsys_t *);
void reiserfs_paste_into_item (reiserfs_filsys_t *, struct path * path,
const void * body, int size);
void reiserfs_insert_item (reiserfs_filsys_t *, struct path * path,
struct item_head * ih, const void * body);
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,
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, __u16 fsck_need);
struct key * uget_lkey (struct path * path);
struct key * uget_rkey (struct path * path);
int reiserfs_search_by_key_3 (reiserfs_filsys_t *, struct key * key,
struct path * path);
int reiserfs_search_by_key_4 (reiserfs_filsys_t *, struct key * key,
struct path * path);
int reiserfs_search_by_entry_key (reiserfs_filsys_t *, struct key * key,
struct path * path);
int usearch_by_position (reiserfs_filsys_t *, struct key * key, int version, struct path * path);
struct key * reiserfs_next_key (struct path * path);
void copy_key (void * to, void * from);
void copy_short_key (void * to, void * from);
void copy_item_head(void * p_v_to, void * p_v_from);
int comp_keys (const void * k1, const void * k2);
int comp_keys_3 (const void * k1, const void * k2);
int comp_short_keys (const void * p_s_key1, const void * p_s_key2);
int comp_items (struct item_head * p_s_ih, struct path * p_s_path);
__u32 hash_value (hashf_t func, char * name, int namelen);
int create_dir_sd (reiserfs_filsys_t * fs,
struct path * path, struct key * key,
void (*modify_item)(struct item_head *, void *));
void make_sure_root_dir_exists (reiserfs_filsys_t * fs,
void (*modyfy_item)(struct item_head *, void *),
int ih_flags);
typedef void (*badblock_func_t) (reiserfs_filsys_t *fs,
struct path *badblock_path,
void *data);
void mark_badblock(reiserfs_filsys_t *fs, struct path *badblock_path, void *data);
int create_badblock_bitmap (reiserfs_filsys_t * fs, char * badblocks_file);
void add_badblock_list (reiserfs_filsys_t * fs, int no_badblock_in_tree_yet);
void badblock_list(reiserfs_filsys_t * fs, badblock_func_t action, void *data);
#define reiserfs_fs_bmap_nr(fs) reiserfs_bmap_nr(get_sb_block_count(fs->fs_ondisk_sb), fs->fs_blocksize)
#define reiserfs_bmap_nr(count, blk_size) ((count - 1) / (blk_size * 8) + 1)
#define reiserfs_bmap_over(nr) (nr > ((1LL << 16) - 1))
extern struct key root_dir_key;
extern struct key parent_root_dir_key;
extern struct key lost_found_dir_key;
extern __u16 root_dir_format;
extern __u16 lost_found_dir_format;
/* bitmap.c */
int reiserfs_open_ondisk_bitmap (reiserfs_filsys_t *);
int reiserfs_create_ondisk_bitmap (reiserfs_filsys_t *);
void reiserfs_free_ondisk_bitmap (reiserfs_filsys_t *);
void reiserfs_close_ondisk_bitmap (reiserfs_filsys_t *);
int reiserfs_flush_to_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t * fs);
unsigned int reiserfs_calc_bmap_nr(reiserfs_filsys_t *fs, unsigned int blocks);
reiserfs_bitmap_t * reiserfs_create_bitmap (unsigned int bit_count);
int reiserfs_expand_bitmap (reiserfs_bitmap_t * bm, unsigned int bit_count);
void reiserfs_shrink_bitmap (reiserfs_bitmap_t * bm, unsigned int bit_count);
void reiserfs_delete_bitmap (reiserfs_bitmap_t * bm);
void reiserfs_bitmap_copy (reiserfs_bitmap_t * to, reiserfs_bitmap_t * from);
int reiserfs_bitmap_compare (reiserfs_bitmap_t * bm1, reiserfs_bitmap_t * bm2);
void reiserfs_bitmap_disjunction (reiserfs_bitmap_t * disk, reiserfs_bitmap_t * cont);
void reiserfs_bitmap_delta (reiserfs_bitmap_t * base, reiserfs_bitmap_t * exclude);
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);
int reiserfs_bitmap_test_bit (reiserfs_bitmap_t * bm, unsigned int bit_number);
int reiserfs_bitmap_find_zero_bit (reiserfs_bitmap_t * bm, unsigned long * start);
/*int reiserfs_fetch_ondisk_bitmap (reiserfs_bitmap_t * bm, reiserfs_filsys_t *);*/
/*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);
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);
void reiserfs_bitmap_save (FILE * fp, reiserfs_bitmap_t * bm);
/* this probably should be in fsck */
void reiserfs_begin_stage_info_save(FILE * file, unsigned long stage);
void reiserfs_end_stage_info_save(FILE * file);
int is_stage_magic_correct (FILE * fp);
//void reiserfs_stage_info_save(struct fsck_data *, FILE * file);
reiserfs_bitmap_t * reiserfs_bitmap_load (FILE * fp);
void reiserfs_bitmap_invert (reiserfs_bitmap_t * bm);
int reiserfs_remove_entry (reiserfs_filsys_t *, struct key * key);
/* node_formats.c */
#define THE_LEAF 1
#define THE_INTERNAL 2
#define THE_SUPER 3
#define THE_JDESC 4
#define HAS_IH_ARRAY 5
#define THE_UNKNOWN 6
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);
int does_look_like_super_block (struct reiserfs_super_block * rs);
int is_any_reiserfs_magic_string (struct reiserfs_super_block * rs);
int get_reiserfs_format (struct reiserfs_super_block * sb);
int reiserfs_super_block_size (struct reiserfs_super_block * rs);
/*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);
int not_journalable (reiserfs_filsys_t *, unsigned long block);
int block_of_bitmap (reiserfs_filsys_t *, unsigned long block);
int block_of_journal (reiserfs_filsys_t *, unsigned long block);
int is_tree_node (struct buffer_head * bh, int level);
int is_properly_hashed (reiserfs_filsys_t *,
char * name, int namelen, __u32 offset);
int dir_entry_bad_location (struct reiserfs_de_head * deh,
struct item_head * ih, int first);
void make_dir_stat_data (int blocksize, int key_format,
__u32 dirid, __u32 objectid,
struct item_head * ih, void * sd);
void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid,
__u32 par_dirid, __u32 par_objid);
void make_empty_dir_item (char * body, __u32 dirid, __u32 objid,
__u32 par_dirid, __u32 par_objid);
int reiserfs_is_fs_consistent (reiserfs_filsys_t * fs);
typedef void (*item_action_t) (struct buffer_head * bh, struct item_head * ih);
typedef void (*item_head_action_t) (struct item_head * ih);
void for_every_item (struct buffer_head * bh, item_head_action_t action,
item_action_t * actions);
int key_format (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);
char * key_of_what (const struct key * key);
int type_unknown (struct key * key);
void set_type (int format, struct key * key, int type);
void set_offset (int format, struct key * key, loff_t offset);
void set_type_and_offset (int format, struct key * key, loff_t offset, int type);
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);
#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 (unsigned int code);
int func2code (hashf_t func);
hashf_t code2func (unsigned int code);
hashf_t name2func (char * hash);
int find_hash_in_use (char * name, int namelen, __u32 deh_offset, unsigned int code_to_try_first);
int entry_length (struct item_head * ih, struct reiserfs_de_head * deh,
int pos_in_item);
char * name_in_entry (struct reiserfs_de_head * deh, int pos_in_item);
int name_in_entry_length (struct item_head * ih,
struct reiserfs_de_head * deh, int pos_in_item);
int name_length (char * name, int key_format);
/* access to stat data fields */
void get_set_sd_field (int field, struct item_head * ih, void * sd,
void * value, int set);
#define GET_SD_MODE 0
#define GET_SD_SIZE 1
#define GET_SD_NLINK 2
#define GET_SD_BLOCKS 3
#define GET_SD_FIRST_DIRECT_BYTE 4
#define get_sd_mode(ih,sd,pmode) get_set_sd_field (GET_SD_MODE, ih, sd, pmode, 0/*get*/)
#define set_sd_mode(ih,sd,pmode) get_set_sd_field (GET_SD_MODE, ih, sd, pmode, 1/*set*/)
#define get_sd_size(ih,sd,psize) get_set_sd_field (GET_SD_SIZE, ih, sd, psize, 0/*get*/)
#define set_sd_size(ih,sd,psize) get_set_sd_field (GET_SD_SIZE, ih, sd, psize, 1/*set*/)
#define get_sd_blocks(ih,sd,pblocks) get_set_sd_field (GET_SD_BLOCKS, ih, sd, pblocks, 0/*get*/)
#define set_sd_blocks(ih,sd,pblocks) get_set_sd_field (GET_SD_BLOCKS, ih, sd, pblocks, 1/*set*/)
//#define get_sd_rdev(ih,sd,pblocks) get_set_sd_field (GET_SD_RDEV, ih, sd, pblocks, 0/*get*/)
//#define set_sd_rdev(ih,sd,pblocks) get_set_sd_field (GET_SD_RDEV, ih, sd, pblocks, 1/*set*/)
//#define get_sd_generation(ih,sd,pblocks) get_set_sd_field (GET_SD_GENER, ih, sd, pblocks, 0/*get*/)
//#define set_sd_generation(ih,sd,pblocks) get_set_sd_field (GET_SD_GENER, ih, sd, pblocks, 1/*set*/)
#define get_sd_nlink(ih,sd,pnlink) get_set_sd_field (GET_SD_NLINK, ih, sd, pnlink, 0/*get*/)
#define set_sd_nlink(ih,sd,pnlink) get_set_sd_field (GET_SD_NLINK, ih, sd, pnlink, 1/*set*/)
#define get_sd_first_direct_byte(ih,sd,pfdb) get_set_sd_field (GET_SD_FIRST_DIRECT_BYTE, ih, sd, pfdb, 0/*get*/)
#define set_sd_first_direct_byte(ih,sd,pfdb) get_set_sd_field (GET_SD_FIRST_DIRECT_BYTE, ih, sd, pfdb, 1/*set*/)
int is_objectid_used (reiserfs_filsys_t * fs, __u32 objectid);
void mark_objectid_used (reiserfs_filsys_t * fs, __u32 objectid);
/* journal.c */
int get_boundary_transactions (reiserfs_filsys_t *, reiserfs_trans_t *,
reiserfs_trans_t *);
int next_transaction (reiserfs_filsys_t *, reiserfs_trans_t *, reiserfs_trans_t);
int replay_one_transaction (reiserfs_filsys_t *, reiserfs_trans_t *);
typedef void (*action_on_trans_t) (reiserfs_filsys_t *, reiserfs_trans_t *);
void for_each_transaction (reiserfs_filsys_t *, action_on_trans_t);
typedef void (*action_on_block_t) (reiserfs_filsys_t *, reiserfs_trans_t *,
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);
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, int force);
int reiserfs_journal_opened (reiserfs_filsys_t *);
void reiserfs_flush_journal (reiserfs_filsys_t * fs);
void reiserfs_free_journal (reiserfs_filsys_t * fs);
void reiserfs_close_journal (reiserfs_filsys_t *);
void reiserfs_reopen_journal (reiserfs_filsys_t * fs, int flag);
__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, int verbose);
/* prints.c */
void print_indirect_item (FILE * fp, struct buffer_head * bh, int item_num);
void print_block (FILE * fp, reiserfs_filsys_t *, struct buffer_head * bh, ...);//int print_mode, int first, int last);
int print_super_block (FILE * fp, reiserfs_filsys_t *, char * file_name, struct buffer_head * bh, int short_print);
void print_journal (reiserfs_filsys_t *);
void print_journal_header (reiserfs_filsys_t * fs);
void reiserfs_warning (FILE * fp, const char * fmt, ...);
char ftypelet (mode_t mode);
void reiserfs_print_item (FILE * fp, struct buffer_head * bh,
struct item_head * ih);
void print_filesystem_state (FILE * fp, reiserfs_filsys_t * fs);
void print_one_transaction (reiserfs_filsys_t * fs, reiserfs_trans_t * trans);
void print_journal_params (FILE * fp, struct journal_params * jp);
char * get_reiserfs_version (__u16 version);
int can_we_format_it (char * device_name, int force);
#define reiserfs_panic(fmt, list...) \
{\
fflush (stdout);\
fprintf (stderr, "%s %d %s\n", __FILE__, __LINE__, __FUNCTION__);\
reiserfs_warning (stderr, (const char *)fmt, ## list);\
reiserfs_warning (stderr, "\n" );\
abort ();\
}
#define reiserfs_exit(val, fmt, list...) \
{\
fflush (stdout);\
reiserfs_warning (stderr, (const char *)fmt, ## list);\
reiserfs_warning (stderr, "\n" );\
exit (val);\
}
#define check_forcing_ask_confirmation(force) \
if (force < 1) {\
/* avoid formatting it without being forced */\
reiserfs_warning (stderr, "Use -f to force over\n");\
return 0;\
}\
if (force < 2) {\
if (!user_confirmed (stderr, "Continue (y/n):", "y\n"))\
return 0;\
}\
#endif /* REISERFSPROGS_LIB_H */
+8 -17
View File
@@ -3,8 +3,11 @@
* reiserfsprogs/README
*/
#ifndef MISC_SWAB_H
#define MISC_SWAB_H
#ifndef REISERFSPROGS_SWAB_H
#define REISERFSPROGS_SWAB_H
#include <endian.h>
#include <asm/types.h>
#define __swab16(x) \
({ \
@@ -39,7 +42,7 @@
})
#ifndef WORDS_BIGENDIAN
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define cpu_to_le16(val) (val)
# define le16_to_cpu(val) (val)
@@ -48,7 +51,7 @@
# define cpu_to_le64(val) (val)
# define le64_to_cpu(val) (val)
#elif defined(WORDS_BIGENDIAN)
#elif __BYTE_ORDER == __BIG_ENDIAN
# define cpu_to_le16(val) __swab16(val)
# define le16_to_cpu(val) __swab16(val)
@@ -61,16 +64,4 @@
# error "nuxi/pdp-endian archs are not supported"
#endif
#define get_leXX(xx,p,field) (le##xx##_to_cpu ((p)->field))
#define set_leXX(xx,p,field,val) do { (p)->field = cpu_to_le##xx(val); } while (0)
#define get_le16(p,field) get_leXX (16, p, field)
#define set_le16(p,field,val) set_leXX (16, p, field, val)
#define get_le32(p,field) get_leXX (32, p, field)
#define set_le32(p,field,val) set_leXX (32, p, field, val)
#define get_le64(p,field) get_leXX (64, p, field)
#define set_le64(p,field,val) set_leXX (64, p, field, val)
#endif /* MISC_SWAB_H */
#endif /* REISERFS_SWAB_H */
-1
View File
@@ -1 +0,0 @@
noinst_HEADERS = badblock.h misc.h print.h device.h mntent.h
-14
View File
@@ -1,14 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef UTIL_BADBLOCK_H
#define UTIL_BADBLOCK_H
#include "reiserfs/libreiserfs.h"
extern int util_badblock_load (reiserfs_filsys_t * fs,
char * badblocks_file);
#endif
-72
View File
@@ -1,72 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef UTIL_DEVICE_H
#define UTIL_DEVICE_H
#include "misc/types.h"
#include <linux/major.h>
#include <sys/types.h>
#include <stdio.h>
#ifndef major
#define major(rdev) ((rdev)>>8)
#define minor(rdev) ((rdev) & 0xff)
#endif /* major */
#ifndef SCSI_DISK_MAJOR
#define SCSI_DISK_MAJOR(maj) ((maj) == SCSI_DISK0_MAJOR || \
((maj) >= SCSI_DISK1_MAJOR && (maj) <= SCSI_DISK7_MAJOR))
#endif /* SCSI_DISK_MAJOR */
#ifndef SCSI_BLK_MAJOR
#define SCSI_BLK_MAJOR(maj) (SCSI_DISK_MAJOR(maj) || (maj) == SCSI_CDROM_MAJOR)
#endif /* SCSI_BLK_MAJOR */
#ifndef IDE_DISK_MAJOR
#ifdef IDE9_MAJOR
#define IDE_DISK_MAJOR(maj) ((maj) == IDE0_MAJOR || (maj) == IDE1_MAJOR || \
(maj) == IDE2_MAJOR || (maj) == IDE3_MAJOR || \
(maj) == IDE4_MAJOR || (maj) == IDE5_MAJOR || \
(maj) == IDE6_MAJOR || (maj) == IDE7_MAJOR || \
(maj) == IDE8_MAJOR || (maj) == IDE9_MAJOR)
#else
#define IDE_DISK_MAJOR(maj) ((maj) == IDE0_MAJOR || (maj) == IDE1_MAJOR || \
(maj) == IDE2_MAJOR || (maj) == IDE3_MAJOR || \
(maj) == IDE4_MAJOR || (maj) == IDE5_MAJOR)
#endif /* IDE9_MAJOR */
#endif /* IDE_DISK_MAJOR */
typedef enum mount_flags {
MF_NOT_MOUNTED = 0x0,
MF_RO = 0x1,
MF_RW = 0x2
} mount_flags_t;
extern FILE * util_file_open (char * filename, char * option);
typedef struct util_device_dma {
int fd;
int support_type;
int dma;
__u64 speed;
dev_t st_rdev;
} util_device_dma_t;
extern int util_device_dma_prep(util_device_dma_t *dma_info);
extern int util_device_get_dma(util_device_dma_t *dma_info);
extern void util_device_dma_fini(int fd, util_device_dma_t *dma_info);
extern int util_device_formatable (char * device_name, int force);
extern int util_root_mounted(char *device);
extern int util_device_mounted(char *device);
extern int util_file_ro(char *file);
#endif
-30
View File
@@ -1,30 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef UTIL_MISC_H
#define UTIL_MISC_H
#include <stdio.h>
extern void util_misc_progress (FILE * fp,
unsigned long *passed,
unsigned long total,
unsigned int inc,
int forward);
extern void util_misc_speed (FILE *fp,
unsigned long total,
unsigned long passed,
int cursor_pos,
int reset_time);
extern void util_misc_print_name (FILE * fp, char * name, int len);
extern void util_misc_erase_name (FILE * fp, int len);
extern void util_misc_fini_name (FILE *fp);
#endif
-11
View File
@@ -1,11 +0,0 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef UTIL_MNTENT_H
#define UTIL_MNTENT_H
extern struct mntent *util_mntent(char *device);
#endif
-15
View File
@@ -1,15 +0,0 @@
/*
* Copyright 2000-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#ifndef UTIL_PRINT_H
#define UTIL_PRINT_H
#include <stdio.h>
extern int util_user_confirmed(FILE * fp, char * q, char * yes);
extern void util_print_banner(char *name);
#endif
+191 -263
View File
@@ -1,38 +1,19 @@
#!/bin/sh
#
# install - install a program, script, or datafile
scriptversion=2005-02-02.21
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright (C) 1994 X Consortium
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
@@ -42,11 +23,13 @@ scriptversion=2005-02-02.21
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
@@ -58,266 +41,211 @@ stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
src=""
dst=""
dir_arg=""
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
-d) dir_arg=true
shift
continue;;
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-d) dir_arg=true
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
--help) echo "$usage"; exit $?;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
if test -n "$dir_arg"; then
dst=$src
src=
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
shift
IFS=$oIFS
pathcomp=''
pathcomp=
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit 1; }
pathcomp="${pathcomp}/"
done
fi
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit 0
}
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
+5
View File
@@ -0,0 +1,5 @@
noinst_LIBRARIES = libmisc.a
libmisc_a_SOURCES = io.c misc.c parse_time.c progbar.c
##reiserfs.c
+119 -58
View File
@@ -1,8 +1,8 @@
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# Makefile.in generated by automake 1.10 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006 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.
@@ -14,15 +14,11 @@
@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
@@ -36,25 +32,36 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = include/reiserfs
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
subdir = lib
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
HEADERS = $(noinst_HEADERS)
LIBRARIES = $(noinst_LIBRARIES)
AR = ar
ARFLAGS = cru
libmisc_a_AR = $(AR) $(ARFLAGS)
libmisc_a_LIBADD =
am_libmisc_a_OBJECTS = io.$(OBJEXT) misc.$(OBJEXT) \
parse_time.$(OBJEXT) progbar.$(OBJEXT)
libmisc_a_OBJECTS = $(am_libmisc_a_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(top_builddir)/include@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libmisc_a_SOURCES)
DIST_SOURCES = $(libmisc_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -73,6 +80,8 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -83,9 +92,8 @@ LIBS = @LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -94,18 +102,17 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PROGS_LDFLAGS = @PROGS_LDFLAGS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
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__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -117,38 +124,45 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
noinst_HEADERS = badblock.h bitmap.h buffer.h direntry.h extent.h \
filesystem.h fix_node.h hash.h internal.h \
internal_balance.h journal.h key.h leaf.h \
leaf_balance.h node.h objmap.h policy.h print.h \
stat.h super.h tree.h tree_balance.h libreiserfs.h \
types.h
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LIBRARIES = libmisc.a
libmisc_a_SOURCES = io.c misc.c parse_time.c progbar.c
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -158,9 +172,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/reiserfs/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu include/reiserfs/Makefile
$(AUTOMAKE) --gnu lib/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -178,7 +192,38 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
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 *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_time.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/progbar.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -229,22 +274,21 @@ distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
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; \
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
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"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
@@ -257,7 +301,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -285,11 +329,13 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
@@ -303,21 +349,30 @@ info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
@@ -327,16 +382,22 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
ctags distclean distclean-generic distclean-tags distdir dvi \
dvi-am html html-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
clean-noinstLIBRARIES ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am 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
# 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.
+960
View File
@@ -0,0 +1,960 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#include "io.h"
#include <string.h>
#include <errno.h>
#include <asm/types.h>
void check_memory_msg (void) {
fprintf(stderr,
"\nThe problem has occurred looks like a hardware problem (perhaps\n"
"memory). Send us the bug report only if the second run dies at\n"
"the same place with the same block number.\n");
}
void check_hd_msg (void) {
fprintf(stderr,
"\nThe problem has occurred looks like a hardware problem. If you have\n"
"bad blocks, we advise you to get a new hard drive, because once you\n"
"get one bad block that the disk drive internals cannot hide from\n"
"your sight,the chances of getting more are generally said to become\n"
"much higher (precise statistics are unknown to us), and this disk\n"
"drive is probably not expensive enough for you to you to risk your\n"
"time and data on it. If you don't want to follow that follow that\n"
"advice 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 means\n"
"it takes a block it has in reserve and allocates it for use for\n"
"of that block number). If it cannot remap the block, use badblock\n"
"option (-B) with reiserfs utils to handle this block correctly.\n");
}
static int is_bad_block (unsigned long block)
{
#ifdef IO_FAILURE_EMULATION
/* this array similates bad blocks on the device */
unsigned long bad_blocks [] =
{
8208, 8209, 8210
/*, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19*/
};
int i;
for (i = 0; i < sizeof (bad_blocks) / sizeof (bad_blocks[0]); i ++)
if (bad_blocks [i] == block)
return 1;
#endif
return 0;
}
/* All buffers are in double linked cycled list. If getblk found buffer with
wanted block number in hash queue it moves buffer to the end of list. */
static int g_nr_buffers;
static unsigned long buffers_memory;
/* create buffers until we spend this fraction of system memory, this
** is a hard limit on the amount of buffer ram used
*/
#define BUFFER_MEMORY_FRACTION 10
/* number of bytes in local buffer cache before we start forcing syncs
** of dirty data and reusing unused buffers instead of allocating new
** ones. If a flush doesn't find reusable buffers, new ones are
** still allocated up to the BUFFER_MEMORY_FRACTION percentage
**
*/
#define BUFFER_SOFT_LIMIT (500 * 1024)
static unsigned long buffer_soft_limit = BUFFER_SOFT_LIMIT;
#define NR_HASH_QUEUES 4096
static struct buffer_head * g_a_hash_queues [NR_HASH_QUEUES];
static struct buffer_head * Buffer_list_head;
static struct buffer_head * g_free_buffers = NULL ;
static struct buffer_head * g_buffer_heads;
static int buffer_hits = 0 ;
static int buffer_misses = 0 ;
static int buffer_reads = 0 ;
static int buffer_writes = 0 ;
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 */
int free = 0;
struct buffer_head * next;
next = *list;
if (!next)
return ;
for (;;) {
if (next->b_dev == dev && next->b_size == size) {
all ++;
if (next->b_count != 0) {
in_use ++;
}
if (buffer_dirty (next)) {
dirty ++;
}
if (buffer_clean (next) && next->b_count == 0) {
free ++;
}
}
next = next->b_next;
if (next == *list)
break;
}
printf("show_buffers (dev %d, size %lu): free %d, count != 0 %d, dirty %d, "
"all %d\n", dev, size, free, in_use, dirty, all);
}
static void show_buffers (int dev, int size)
{
_show_buffers(&Buffer_list_head, dev, size) ;
_show_buffers(&g_free_buffers, dev, size) ;
}
static void insert_into_hash_queue (struct buffer_head * bh)
{
int index = bh->b_blocknr % NR_HASH_QUEUES;
if (bh->b_hash_prev || bh->b_hash_next)
die ("insert_into_hash_queue: hash queue corrupted");
if (g_a_hash_queues[index]) {
g_a_hash_queues[index]->b_hash_prev = bh;
bh->b_hash_next = g_a_hash_queues[index];
}
g_a_hash_queues[index] = bh;
}
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 == -1) ? */
return;
if (bh == g_a_hash_queues[bh->b_blocknr % NR_HASH_QUEUES]) {
if (bh->b_hash_prev != 0)
die ("remove_from_hash_queue: hash queue corrupted");
g_a_hash_queues[bh->b_blocknr % NR_HASH_QUEUES] = bh->b_hash_next;
}
if (bh->b_hash_next)
bh->b_hash_next->b_hash_prev = bh->b_hash_prev;
if (bh->b_hash_prev)
bh->b_hash_prev->b_hash_next = bh->b_hash_next;
bh->b_hash_prev = bh->b_hash_next = 0;
}
static void put_buffer_list_end (struct buffer_head **list,
struct buffer_head * bh)
{
struct buffer_head * last = 0;
if (bh->b_prev || bh->b_next)
die ("put_buffer_list_end: buffer list corrupted");
if (*list == 0) {
bh->b_next = bh;
bh->b_prev = bh;
*list = bh;
} else {
last = (*list)->b_prev;
bh->b_next = last->b_next;
bh->b_prev = last;
last->b_next->b_prev = bh;
last->b_next = bh;
}
}
static void remove_from_buffer_list (struct buffer_head **list,
struct buffer_head * bh)
{
if (bh == bh->b_next) {
*list = 0;
} else {
bh->b_prev->b_next = bh->b_next;
bh->b_next->b_prev = bh->b_prev;
if (bh == *list)
*list = bh->b_next;
}
bh->b_next = bh->b_prev = 0;
}
static void put_buffer_list_head (struct buffer_head **list,
struct buffer_head * bh)
{
put_buffer_list_end (list, bh);
*list = bh;
}
/*
#include <sys/mman.h>
static size_t estimate_memory_amount (void)
{
size_t len = 1;
size_t max = 0;
void * addr;
while (len > 0) {
addr = mmap (0, len, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (addr == MAP_FAILED) {
if (errno != ENOMEM)
die ("mmap failed: %s\n", strerror(errno));
break;
}
if (mlock (addr, len) != 0) {
if (errno == EPERM)
die ("No permission to run mlock");
break;
}
munlock (addr, len);
munmap (addr, len);
max = len;
len *= 2;
}
// * If we've looped, we don't want to return 0, we want to return the
// * last successful len before we looped. In the event that mmap/mlock
// * failed for len = 1, max will still be 0, so we don't get an invalid
// * result
return max;
}
*/
#define GROW_BUFFERS__NEW_BUFERS_PER_CALL 10
/* creates number of new buffers and insert them into head of buffer list */
static int grow_buffers (int size)
{
int i;
struct buffer_head * bh, * tmp;
/* get memory for array of buffer heads */
bh = (struct buffer_head *)getmem (GROW_BUFFERS__NEW_BUFERS_PER_CALL *
sizeof (struct buffer_head) + sizeof (struct buffer_head *));
if (g_buffer_heads == 0)
g_buffer_heads = bh;
else {
/* link new array to the end of array list */
tmp = g_buffer_heads;
while (*(struct buffer_head **)(tmp + GROW_BUFFERS__NEW_BUFERS_PER_CALL) != 0)
tmp = *(struct buffer_head **)(tmp + GROW_BUFFERS__NEW_BUFERS_PER_CALL);
*(struct buffer_head **)(tmp + GROW_BUFFERS__NEW_BUFERS_PER_CALL) = bh;
}
for (i = 0; i < GROW_BUFFERS__NEW_BUFERS_PER_CALL; i ++) {
tmp = bh + i;
memset (tmp, 0, sizeof (struct buffer_head));
tmp->b_data = getmem (size);
if (tmp->b_data == 0)
die ("grow_buffers: no memory for new buffer data");
tmp->b_dev = -1;
tmp->b_size = size;
put_buffer_list_head (&g_free_buffers, tmp);
}
buffers_memory += GROW_BUFFERS__NEW_BUFERS_PER_CALL * size;
g_nr_buffers += GROW_BUFFERS__NEW_BUFERS_PER_CALL;
return GROW_BUFFERS__NEW_BUFERS_PER_CALL;
}
struct buffer_head *find_buffer(int dev, unsigned long block, unsigned long size)
{
struct buffer_head * next;
next = g_a_hash_queues[block % NR_HASH_QUEUES];
for (;;) {
struct buffer_head *tmp = next;
if (!next)
break;
next = tmp->b_hash_next;
if (tmp->b_blocknr != block || tmp->b_size != size || tmp->b_dev != dev)
continue;
next = tmp;
break;
}
return next;
}
static struct buffer_head * get_free_buffer (struct buffer_head **list,
unsigned long size)
{
struct buffer_head * next;
next = *list;
if (!next)
return 0;
for (;;) {
if (!next)
die ("get_free_buffer: buffer list is corrupted");
if (next->b_count == 0 && buffer_clean (next) && next->b_size == size) {
remove_from_hash_queue (next);
remove_from_buffer_list (list, next);
return next;
}
next = next->b_next;
if (next == *list)
break;
}
return 0;
}
/* 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, int dev, int to_write) {
struct buffer_head * next;
int written = 0;
restart:
next = *list;
if (!next)
return 0;
for (;;) {
if (!next)
die ("sync_buffers: buffer list is corrupted");
if (next->b_dev == dev && buffer_dirty (next) && buffer_uptodate (next)) {
if ((to_write == 0 || next->b_count == 0) && !buffer_do_not_flush (next)) {
bwrite (next);
}
}
/* if this buffer is reusable, put it onto the end of the free list */
if (next->b_count == 0 && buffer_clean(next)) {
remove_from_hash_queue (next);
remove_from_buffer_list (list, next);
put_buffer_list_end (&g_free_buffers, next);
written++ ;
if (written == to_write)
return written;
goto restart;
}
if (to_write && written >= to_write)
return written;
next = next->b_next;
if (next == *list)
break;
}
return written;
}
void flush_buffers (int dev)
{
if (dev == -1)
die ("flush_buffers: device is not specified");
sync_buffers (&Buffer_list_head, dev, 0/*all*/);
buffer_soft_limit = BUFFER_SOFT_LIMIT;
}
struct buffer_head * getblk (int dev, unsigned long block, int size)
{
struct buffer_head * bh;
bh = find_buffer (dev, block, size);
if (bh) {
/* move the buffer to the end of list */
/*checkmem (bh->b_data, bh->b_size);*/
remove_from_buffer_list (&Buffer_list_head, bh);
put_buffer_list_end (&Buffer_list_head, bh);
bh->b_count ++;
buffer_hits++ ;
return bh;
}
buffer_misses++ ;
bh = get_free_buffer (&g_free_buffers, size);
if (bh == NULL) {
if (buffers_memory >= buffer_soft_limit) {
if (sync_buffers (&Buffer_list_head, dev, 32) == 0) {
grow_buffers(size);
buffer_soft_limit = buffers_memory +
GROW_BUFFERS__NEW_BUFERS_PER_CALL * size;
}
} else {
if (grow_buffers(size) == 0)
sync_buffers (&Buffer_list_head, dev, 32);
}
bh = get_free_buffer (&g_free_buffers, size);
if (bh == NULL) {
show_buffers (dev, size);
die ("getblk: no free buffers after grow_buffers "
"and refill (%d)", g_nr_buffers);
}
}
bh->b_count = 1;
bh->b_dev = dev;
bh->b_size = size;
bh->b_blocknr = block;
bh->b_end_io = NULL ;
memset (bh->b_data, 0, size);
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);
/*checkmem (bh->b_data, bh->b_size);*/
return bh;
}
void brelse (struct buffer_head * bh)
{
if (bh == 0)
return;
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));*/
bh->b_count --;
}
void bforget (struct buffer_head * bh)
{
if (bh) {
bh->b_state = 0;
brelse (bh);
remove_from_hash_queue (bh);
remove_from_buffer_list(&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)
{
unsigned long long offset;
ssize_t bytes;
buffer_reads++ ;
offset = (unsigned long long)bh->b_size * bh->b_blocknr;
if (lseek (bh->b_dev, offset, SEEK_SET) < 0)
return -1;
bytes = read (bh->b_dev, bh->b_data, bh->b_size);
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;
bh = getblk (dev, block, size);
/*checkmem (bh->b_data, get_mem_size(bh->b_data));*/
if (buffer_uptodate (bh))
return bh;
ret = f_read(bh);
if (ret > 0) {
die ("%s: End of file, cannot read the block (%lu).\n",
__FUNCTION__, block);
} 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__, block, strerror(errno));
} else {
fprintf (stderr, "%s: Cannot read the block (%lu): (%s).\n",
__FUNCTION__, block, strerror(errno));
return NULL;
}
}
mark_buffer_uptodate (bh, 0);
return bh;
}
#define ROLLBACK_FILE_START_MAGIC "_RollBackFileForReiserfsFSCK"
static struct block_handler * rollback_blocks_array;
static __u32 rollback_blocks_number = 0;
static FILE * s_rollback_file = 0;
static FILE * log_file;
static int do_rollback = 0;
static char * rollback_data;
static int rollback_blocksize;
void init_rollback_file (char * rollback_file, int *blocksize, FILE * log) {
char * string;
struct stat buf;
if (rollback_file == NULL)
return;
stat(rollback_file, &buf);
s_rollback_file = fopen (rollback_file, "w+");
if (s_rollback_file == NULL) {
fprintf (stderr, "Cannot create file %s, work without a rollback file\n", rollback_file);
return;
}
rollback_blocksize = *blocksize;
string = ROLLBACK_FILE_START_MAGIC;
fwrite (string, 28, 1, s_rollback_file);
fwrite (&rollback_blocksize, sizeof (rollback_blocksize), 1, s_rollback_file);
fwrite (&rollback_blocks_number, sizeof (rollback_blocks_number), 1, s_rollback_file);
fflush(s_rollback_file);
rollback_data = getmem(rollback_blocksize);
// printf("\ncheckmem1");
// fflush (stdout);
// checkmem (rollback_data, get_mem_size((char *)rollback_data));
// printf(" OK");
log_file = log;
if (log_file)
fprintf (log_file, "rollback: file (%s) initialize\n", rollback_file);
do_rollback = 0;
}
#if 0
static void erase_rollback_file (char * rollback_file) {
close_rollback_file ();
unlink (rollback_file);
}
#endif
int open_rollback_file (char * rollback_file, FILE * log) {
char string [28];
struct stat buf;
if (rollback_file == NULL)
return -1;
if (stat(rollback_file, &buf)) {
fprintf (stderr, "Cannot stat rollback file (%s)\n", rollback_file);
return -1;
}
s_rollback_file = fopen (rollback_file, "r+");
if (s_rollback_file == NULL) {
fprintf (stderr, "Cannot open file (%s)\n", rollback_file);
return -1;
}
fread (string, 28, 1, s_rollback_file);
if (!strcmp (string, ROLLBACK_FILE_START_MAGIC)) {
fprintf (stderr, "Specified file (%s) does not look like a rollback file\n", rollback_file);
fclose (s_rollback_file);
s_rollback_file = 0;
return -1;
}
fread (&rollback_blocksize, sizeof (rollback_blocksize), 1, s_rollback_file);
if (rollback_blocksize <= 0) {
fprintf(stderr, "rollback: wrong rollback blocksize, exit\n");
return -1;
}
log_file = log;
if (log_file)
fprintf (log_file, "rollback: file (%s) opened\n", rollback_file);
do_rollback = 1;
return 0;
}
void close_rollback_file () {
if (s_rollback_file == 0)
return;
if (!do_rollback) {
if (fseek (s_rollback_file, 28 + sizeof(int), SEEK_SET) == (loff_t)-1)
return;
fwrite (&rollback_blocks_number, sizeof (rollback_blocksize), 1, s_rollback_file);
if (log_file != 0)
fprintf (log_file, "rollback: %d blocks backed up\n", rollback_blocks_number);
}
fclose (s_rollback_file);
freemem (rollback_data);
freemem (rollback_blocks_array);
// fprintf (stdout, "rollback: (%u) blocks saved, \n", rollback_blocks_number);
/* for (i = 0; i < rollback_blocks_number; i++)
fprintf(stdout, "device (%Lu), block number (%u)\n",
rollback_blocks_array [i].device,
rollback_blocks_array [i].blocknr);
fprintf(stdout, "\n");
*/
}
void do_fsck_rollback (int fd_device, int fd_journal_device, FILE * progress) {
long long int offset;
struct stat buf;
int descriptor;
ssize_t retval;
int count_failed = 0;
int count_rollbacked = 0;
int b_dev;
int n_dev = 0;
int n_journal_dev = 0;
unsigned long total, done = 0;
if (fd_device == 0) {
fprintf(stderr, "rollback: unspecified device, exit\n");
return;
}
if (fd_journal_device) {
if (!fstat (fd_journal_device, &buf)) {
n_journal_dev = buf.st_rdev;
} else {
fprintf(stderr, "rollback: specified journal device cannot be stated\n");
}
}
if (!fstat (fd_device, &buf)) {
n_dev = buf.st_rdev;
} else {
fprintf(stderr, "rollback: specified device cannot be stated, exit\n");
return;
}
rollback_data = getmem (rollback_blocksize);
// printf("\ncheckmem2");
// fflush (stdout);
// checkmem (rollback_data, get_mem_size((char *)rollback_data));
// printf(" OK");
fread (&rollback_blocks_number, sizeof (rollback_blocks_number), 1, s_rollback_file);
total = rollback_blocks_number;
while (1) {
print_how_far (progress, &done, rollback_blocks_number, 1, 0/*not quiet*/);
descriptor = 0;
if ((retval = fread (&b_dev, sizeof (b_dev), 1, s_rollback_file)) <= 0) {
if (retval)
fprintf (stderr, "rollback: fread: %s\n", strerror (errno));
break;
}
if ((retval = fread (&offset, sizeof (offset), 1, s_rollback_file)) <= 0) {
if (retval)
fprintf (stderr, "rollback: fread: %s\n", strerror (errno));
break;
}
if ((retval = fread (rollback_data, rollback_blocksize, 1, s_rollback_file)) <= 0) {
if (retval)
fprintf (stderr, "rollback: fread: %s\n", strerror (errno));
break;
}
if (n_dev == b_dev)
descriptor = fd_device;
if ((n_journal_dev) && (n_journal_dev == b_dev))
descriptor = fd_journal_device;
if (descriptor == 0) {
fprintf(stderr, "rollback: block from unknown device, skip block\n");
count_failed ++;
continue;
}
if (lseek (descriptor, offset, SEEK_SET) == (loff_t)-1) {
fprintf(stderr, "device cannot be lseeked, skip block\n");
count_failed ++;
continue;
}
if (write (descriptor, rollback_data, rollback_blocksize) == -1) {
fprintf (stderr, "rollback: write %d bytes returned error "
"(block=%lld, dev=%d): %s\n", rollback_blocksize,
offset/rollback_blocksize, b_dev, strerror (errno));
count_failed ++;
} else {
count_rollbacked ++;
/*if you want to know what gets rollbacked, uncomment it*/
/* if (log_file != 0 && log_file != stdout)
fprintf (log_file, "rollback: block %Lu of device %Lu was restored\n",
(loff_t)offset/rollback_blocksize, b_dev);
*/
// fprintf (stdout, "rollback: block (%Ld) written\n", (loff_t)offset/rollback_blocksize);
}
}
printf ("\n");
if (log_file != 0)
fprintf (log_file, "rollback: (%u) blocks restored\n", count_rollbacked);
}
/*
static void rollback__mark_block_saved (struct block_handler * rb_e) {
if (rollback_blocks_array == NULL)
rollback_blocks_array = getmem (ROLLBACK__INCREASE_BLOCK_NUMBER * sizeof (*rb_e));
if (rollback_blocks_number == get_mem_size ((void *)rollback_blocks_array) / sizeof (*rb_e))
rollback_blocks_array = expandmem (rollback_blocks_array, get_mem_size((void *)rollback_blocks_array),
ROLLBACK__INCREASE_BLOCK_NUMBER * sizeof (*rb_e));
// checkmem ((char *)rollback_blocks_array, get_mem_size((char *)rollback_blocks_array));
rollback_blocks_array[rollback_blocks_number] = *rb_e;
rollback_blocks_number ++;
qsort (rollback_blocks_array, rollback_blocks_number, sizeof (*rb_e), rollback_compare);
// printf("\ncheckmem3");
// fflush (stdout);
// checkmem ((char *)rollback_blocks_array, get_mem_size((char *)rollback_blocks_array));
// printf(" OK");
}
*/
/* for now - just make sure that bad blocks did not get here */
int bwrite (struct buffer_head * bh)
{
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",
bh->b_blocknr);
exit(8);
}
if (!buffer_dirty (bh) || !buffer_uptodate (bh))
return 0;
buffer_writes++ ;
if (bh->b_start_io)
/* this is used by undo feature of reiserfsck */
bh->b_start_io (bh->b_blocknr);
size = bh->b_size;
offset = (loff_t)size * (loff_t)bh->b_blocknr;
if (lseek (bh->b_dev, offset, SEEK_SET) == (loff_t)-1){
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 == (unsigned long)rollback_blocksize) {
struct stat buf;
__u32 position;
struct block_handler block_h;
/*log previous content into the log*/
if (!fstat (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)
{
/*read initial data from the disk*/
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),
&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);
}
*/
} else {
fprintf (stderr, "bwrite: read (block=%lu, dev=%d): %s\n",
bh->b_blocknr, bh->b_dev, strerror (errno));
exit(8);
}
if (lseek (bh->b_dev, offset, SEEK_SET) == (loff_t)-1) {
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));
}
} 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);
}
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);
}
mark_buffer_clean (bh);
if (bh->b_end_io) {
bh->b_end_io(bh, 1) ;
}
return 0;
}
static int _check_and_free_buffer_list(struct buffer_head *list) {
struct buffer_head *next = list ;
int count = 0 ;
if (!list)
return 0 ;
for(;;) {
if (next->b_count != 0)
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 "
"(%d %lu) found\n", next->b_dev, next->b_blocknr);
freemem (next->b_data);
count++;
next = next->b_next;
if (next == list)
break;
}
return count;
}
static void check_and_free_buffer_mem (void)
{
int count = 0;
struct buffer_head * next ;
// printf("check and free buffer mem, hits %d misses %d reads %d writes %d\n",
// buffer_hits, buffer_misses, buffer_reads, buffer_writes) ;
/*sync_buffers (0, 0);*/
count = _check_and_free_buffer_list(Buffer_list_head);
count += _check_and_free_buffer_list(g_free_buffers);
if (count != g_nr_buffers)
die ("check_and_free_buffer_mem: found %d buffers, must be %d",
count, g_nr_buffers);
/* free buffer heads */
while ((next = g_buffer_heads)) {
g_buffer_heads = *(struct buffer_head **)
(next + GROW_BUFFERS__NEW_BUFERS_PER_CALL);
freemem (next);
}
return;
}
/* */
void free_buffers (void)
{
check_and_free_buffer_mem ();
}
static void _invalidate_buffer_list(struct buffer_head *list, int dev)
{
struct buffer_head * next;
if (!list)
return;
next = list;
for (;;) {
if (next->b_dev == dev) {
if (buffer_dirty (next) || next->b_count)
fprintf (stderr, "invalidate_buffers: dirty buffer or used buffer (%d %lu) found\n",
next->b_count, next->b_blocknr);
next->b_state = 0;
remove_from_hash_queue (next);
}
next = next->b_next;
if (next == list)
break;
}
}
/* forget all buffers of the given device */
void invalidate_buffers (int dev)
{
_invalidate_buffer_list(Buffer_list_head, dev) ;
_invalidate_buffer_list(g_free_buffers, dev) ;
}
+986
View File
@@ -0,0 +1,986 @@
/*
* Copyright 1996-2004 by Hans Reiser, licensing governed by
* reiserfsprogs/README
*/
#define _GNU_SOURCE
#include "misc.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <time.h>
#include <utime.h>
#include <ctype.h>
#include <linux/hdreg.h>
#include <dirent.h>
#include <assert.h>
#include <sys/ioctl.h>
#include <signal.h>
/* Debian modifications by Ed Boraas <ed@debian.org> */
#include <sys/mount.h>
/* End Debian mods */
#define STAT_FIELD(Field, Type) \
inline Type misc_device_##Field(char *device) { \
struct stat st; \
\
if (stat(device, &st) == 0) \
return st.st_##Field; \
\
fprintf(stderr, "Stat of the device '%s' failed.", device); \
exit(8); \
}
STAT_FIELD(mode, mode_t);
STAT_FIELD(rdev, dev_t);
STAT_FIELD(size, off_t);
STAT_FIELD(blocks, blkcnt_t);
void die (char * fmt, ...)
{
static char buf[1024];
va_list args;
va_start (args, fmt);
vsprintf (buf, fmt, args);
va_end (args);
fprintf (stderr, "\n%s\n", buf);
abort ();
}
#define MEM_BEGIN "_mem_begin_"
#define MEM_END "mem_end"
#define MEM_FREED "__free_"
#define CONTROL_SIZE (strlen (MEM_BEGIN) + 1 + sizeof (int) + strlen (MEM_END) + 1)
unsigned int get_mem_size(char *p) {
char *begin;
begin = p - strlen (MEM_BEGIN) - 1 - sizeof(int);
return *(int *)(begin + strlen (MEM_BEGIN) + 1);
}
void checkmem (char * p, int size)
{
char * begin;
char * end;
begin = p - strlen (MEM_BEGIN) - 1 - sizeof (int);
if (strcmp (begin, MEM_BEGIN))
die ("checkmem: memory corrupted - invalid head sign");
if (*(int *)(begin + strlen (MEM_BEGIN) + 1) != size)
die ("checkmem: memory corrupted - invalid size");
end = begin + size + CONTROL_SIZE - strlen (MEM_END) - 1;
if (strcmp (end, MEM_END))
die ("checkmem: memory corrupted - invalid end sign");
}
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;
p = (char *)malloc (CONTROL_SIZE + size);
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;
p += size;
strcpy (p, MEM_END);
return mem;
}
void * expandmem (void * vp, int size, int by)
{
int allocated;
char * mem, * p = vp;
int expand_by = by;
if (p) {
checkmem (p, size);
allocated = CONTROL_SIZE + size;
p -= (strlen (MEM_BEGIN) + 1 + sizeof (int));
} else {
allocated = 0;
/* add control bytes to the new allocated area */
expand_by += CONTROL_SIZE;
}
p = realloc (p, allocated + expand_by);
if (!p)
die ("expandmem: no more memory (%d)", size);
if (!vp) {
strcpy (p, MEM_BEGIN);
}
mem = p + strlen (MEM_BEGIN) + 1 + sizeof (int);
*(int *)(p + strlen (MEM_BEGIN) + 1) = size + by;
/* fill new allocated area by 0s */
if(by > 0)
memset (mem + size, 0, by);
strcpy (mem + size + by, MEM_END);
// checkmem (mem, size + by);
return mem;
}
void freemem (void * vp)
{
char * p = vp;
int size;
if (!p)
return;
size = get_mem_size (vp);
checkmem (p, size);
p -= (strlen (MEM_BEGIN) + 1 + sizeof (int));
strcpy (p, MEM_FREED);
strcpy (p + size + CONTROL_SIZE - strlen (MEM_END) - 1, MEM_FREED);
free (p);
}
typedef int (*func_t) (char *);
/* Lookup the @file in the @mntfile. @file is mntent.mnt_fsname if @fsname
is set; mntent.mnt_dir otherwise. Return the mnt entry from the @mntfile.
Warning: if the root fs is mounted RO, the content of /etc/mtab may be
not correct. */
static struct mntent *misc_mntent_lookup(char *mntfile,
char *file,
int path)
{
struct mntent *mnt;
int name_match = 0;
struct stat st;
dev_t rdev = 0;
dev_t dev = 0;
ino_t ino = 0;
char *name;
FILE *fp;
assert(mntfile != NULL);
assert(file != NULL);
if (stat(file, &st) == 0) {
/* Devices is stated. */
if (S_ISBLK(st.st_mode)) {
rdev = st.st_rdev;
} else {
dev = st.st_dev;
ino = st.st_ino;
}
}
if ((fp = setmntent(mntfile, "r")) == NULL)
return INVAL_PTR;
while ((mnt = getmntent(fp)) != NULL) {
/* Check if names match. */
name = path ? mnt->mnt_dir : mnt->mnt_fsname;
if (strcmp(file, name) == 0)
name_match = 1;
if (stat(name, &st))
continue;
/* If names do not match, check if stats match. */
if (!name_match) {
if (rdev && S_ISBLK(st.st_mode)) {
if (rdev != st.st_rdev)
continue;
} else if (dev && !S_ISBLK(st.st_mode)) {
if (dev != st.st_dev ||
ino != st.st_ino)
continue;
} else {
continue;
}
}
/* If not path and not block device do not check anything more. */
if (!path && !rdev)
break;
if (path) {
/* Either names or stats match. Make sure the st_dev of
the path is same as @mnt_fsname device rdev. */
if (stat(mnt->mnt_fsname, &st) == 0 &&
dev == st.st_rdev)
break;
} else {
/* Either names or stats match. Make sure the st_dev of
the mount entry is same as the given device rdev. */
if (stat(mnt->mnt_dir, &st) == 0 &&
rdev == st.st_dev)
break;
}
}
endmntent (fp);
return mnt;
}
static int misc_root_mounted(char *device) {
struct stat rootst, devst;
assert(device != NULL);
if (stat("/", &rootst) != 0)
return -1;
if (stat(device, &devst) != 0)
return -1;
if (!S_ISBLK(devst.st_mode) ||
devst.st_rdev != rootst.st_dev)
return 0;
return 1;
}
static int misc_file_ro(char *file) {
if (utime(file, 0) == -1) {
if (errno == EROFS)
return 1;
}
return 0;
}
struct mntent *misc_mntent(char *device) {
int proc = 0, path = 0, root = 0;
struct mntent *mnt;
struct statfs stfs;
assert(device != NULL);
/* Check if the root. */
if (misc_root_mounted(device) == 1)
root = 1;
#ifdef __linux__
/* Check if /proc is procfs. */
if (statfs("/proc", &stfs) == 0 && stfs.f_type == 0x9fa0) {
proc = 1;
if (root) {
/* Lookup the "/" entry in /proc/mounts. Special
case as root entry can present as:
rootfs / rootfs rw 0 0
Look up the mount point in this case. */
mnt = misc_mntent_lookup("/proc/mounts", "/", 1);
} else {
/* Lookup the @device /proc/mounts */
mnt = misc_mntent_lookup("/proc/mounts", device, 0);
}
if (mnt == INVAL_PTR)
proc = 0;
else if (mnt)
return mnt;
}
#endif /* __linux__ */
#if defined(MOUNTED) || defined(_PATH_MOUNTED)
#ifndef MOUNTED
#define MOUNTED _PATH_MOUNTED
#endif
/* Check in MOUNTED (/etc/mtab) if RW. */
if (!misc_file_ro(MOUNTED)) {
path = 1;
if (root) {
mnt = misc_mntent_lookup(MOUNTED, "/", 1);
} else {
mnt = misc_mntent_lookup(MOUNTED, device, 0);
}
if (mnt == INVAL_PTR)
path = 0;
else if (mnt)
return mnt;
}
#endif /* defined(MOUNTED) || defined(_PATH_MOUNTED) */
/* If has not been checked in neither /proc/mounts nor /etc/mtab (or
errors have occured), return INVAL_PTR, NULL otherwise. */
return (!proc && !path) ? INVAL_PTR : NULL;
}
int misc_device_mounted(char *device) {
struct mntent *mnt;
/* Check for the "/" first to avoid any possible problem with
reflecting the root fs info in mtab files. */
if (misc_root_mounted(device) == 1) {
return misc_file_ro("/") ? MF_RO : MF_RW;
}
/* Lookup the mount entry. */
if ((mnt = misc_mntent(device)) == NULL) {
return MF_NOT_MOUNTED;
} else if (mnt == INVAL_PTR) {
return 0;
}
return hasmntopt(mnt, MNTOPT_RO) ? MF_RO : MF_RW;
}
char buf1 [100];
char buf2 [100];
void print_how_fast (unsigned long passed, unsigned long total,
int cursor_pos, int reset_time)
{
static time_t t0 = 0, t1 = 0, t2 = 0;
int speed;
int indent;
if (reset_time)
time (&t0);
time (&t1);
if (t1 != t0) {
speed = passed / (t1 - t0);
if (total - passed) {
if (t1 - t2 < 1)
return;
t2 = t1;
}
} else
speed = 0;
/* what has to be written */
if (total)
sprintf (buf1, "left %lu, %d /sec", total - passed, speed);
else {
/*(*passed) ++;*/
sprintf (buf1, "done %lu, %d /sec", passed, speed);
}
/* make indent */
indent = 79 - cursor_pos - strlen (buf1);
memset (buf2, ' ', indent);
buf2[indent] = 0;
fprintf (stderr, "%s%s", buf2, buf1);
memset (buf2, '\b', indent + strlen (buf1));
buf2 [indent + strlen (buf1)] = 0;
fprintf (stderr, "%s", buf2);
fflush (stderr);
}
static char * strs[] =
{"0%",".",".",".",".","20%",".",".",".",".","40%",".",".",".",".","60%",".",".",".",".","80%",".",".",".",".","100%"};
static char progress_to_be[1024];
static char current_progress[1024];
static void str_to_be (char * buf, int prosents)
{
int i;
prosents -= prosents % 4;
buf[0] = 0;
for (i = 0; i <= prosents / 4; i ++)
strcat (buf, strs[i]);
}
void print_how_far (FILE * fp,
unsigned long * passed, unsigned long total,
unsigned int inc, int quiet)
{
int percent;
if (*passed == 0)
current_progress[0] = 0;
(*passed) += inc;
if (*passed > total) {
/* fprintf (fp, "\nprint_how_far: total %lu has been reached already. cur=%lu\n",
total, *passed);*/
return;
}
percent = ((*passed) * 100) / total;
str_to_be (progress_to_be, percent);
if (strlen (current_progress) != strlen (progress_to_be)) {
fprintf (fp, "%s", progress_to_be + strlen (current_progress));
}
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);
}
fflush (fp);
}
#if defined(__linux__) && defined(_IOR) && !defined(BLKGETSIZE64)
/* Note! Despite this call being called with *64, it must be encoded to
* return only sizeof(size_t), since in earlier kernel versions it was
* declared _IOR(0x12, 114, sizeof(u64)), making it use sizeof(sizeof(u64)).
*
* However, the call itself does always return 64bit!
*/
# define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#endif
/* To not have problem with last sectors on the block device when switching
to smaller one. */
#define MAX_BS (64 * 1024)
int valid_offset( int fd, loff_t offset) {
char ch;
loff_t res;
/*res = reiserfs_llseek (fd, offset, 0);*/
res = lseek (fd, offset, SEEK_SET);
if (res < 0)
return 0;
/* if (read (fd, &ch, 1) < 0) does not wirk on files */
if (read (fd, &ch, 1) < 1)
return 0;
return 1;
}
/* calculates number of blocks in a file. Returns 0 for "sparse"
regular files and files other than regular files and block devices */
unsigned long count_blocks (char * filename, int blocksize)
{
loff_t high, low;
unsigned long sz;
__u64 size;
int fd;
if (!S_ISBLK(misc_device_mode(filename)) &&
!S_ISREG(misc_device_mode(filename)))
return 0;
fd = open (filename, O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Failed to open '%s': %s.\n", filename, strerror(errno));
return 0;
}
#ifdef BLKGETSIZE64
{
if (ioctl (fd, BLKGETSIZE64, &size) >= 0) {
size = (size / MAX_BS) * MAX_BS / blocksize;
sz = size;
if ((__u64)sz != size)
die ("count_blocks: block device too large");
close(fd);
return sz;
}
}
#endif
#ifdef BLKGETSIZE
{
if (ioctl (fd, BLKGETSIZE, &sz) >= 0) {
size = sz;
close(fd);
return (size * 512 / MAX_BS) * MAX_BS / blocksize;
}
}
#endif
low = 0;
for( high = 1; valid_offset (fd, high); high *= 2 )
low = high;
while (low < high - 1) {
const loff_t mid = ( low + high ) / 2;
if (valid_offset (fd, mid))
low = mid;
else
high = mid;
}
valid_offset (fd, 0);
close (fd);
return (low + 1) * MAX_BS / MAX_BS / blocksize;
}
/* there are masks for certain bits */
__u16 mask16 (int from, int count)
{
__u16 mask;
mask = (0xffff >> from);
mask <<= from;
mask <<= (16 - from - count);
mask >>= (16 - from - count);
return mask;
}
__u32 mask32 (int from, int count)
{
__u32 mask;
mask = (0xffffffff >> from);
mask <<= from;
mask <<= (32 - from - count);
mask >>= (32 - from - count);
return mask;
}
__u64 mask64 (int from, int count)
{
__u64 mask;
mask = (0xffffffffffffffffLL >> from);
mask <<= from;
mask <<= (64 - from - count);
mask >>= (64 - from - count);
return mask;
}
__u32 get_random (void)
{
srandom (time (0));
return random ();
}
/* this implements binary search in the array 'base' among 'num' elements each
of those is 'width' bytes long. 'comp_func' is used to compare keys */
int reiserfs_bin_search (void * key, void * base, __u32 num, int width,
__u32 * ppos, comparison_fn_t comp_func)
{
__u32 rbound, lbound, j;
int ret;
if (num == 0 || base == NULL) {
/* objectid map may be 0 elements long */
*ppos = 0;
return POSITION_NOT_FOUND;
}
lbound = 0;
rbound = num - 1;
for (j = (rbound + lbound) / 2; lbound <= rbound; j = (rbound + lbound) / 2) {
ret = comp_func ((void *)((char *)base + j * width), key ) ;
if (ret < 0) { /* second is greater */
lbound = j + 1;
continue;
} else if (ret > 0) { /* first is greater */
if (j == 0)
break;
rbound = j - 1;
continue;
} else { /* equal */
*ppos = j;
return POSITION_FOUND;
}
}
*ppos = lbound;
return POSITION_NOT_FOUND;
}
#define BLOCKLIST__ELEMENT_NUMBER 10
/*element is block number and device*/
int blockdev_list_compare (const void * block1, const void * block2) {
if (*(__u32 *)block1 < *(__u32 *)block2)
return -1;
if (*(__u32 *)block1 > *(__u32 *)block2)
return 1;
if (*((__u32 *)block1 + 1) < *((__u32 *)block2 + 1))
return -1;
if (*((__u32 *)block1 + 1) > *((__u32 *)block2 + 1))
return 1;
return 0;
}
void blocklist__insert_in_position (void *elem, void **base, __u32 *count,
int elem_size, __u32 *position)
{
if (elem_size == 0)
return;
if (*base == NULL)
*base = getmem (BLOCKLIST__ELEMENT_NUMBER * elem_size);
if (*count == get_mem_size((void *)*base) / elem_size)
*base = expandmem (*base, get_mem_size((void *)*base),
BLOCKLIST__ELEMENT_NUMBER * elem_size);
if (*position < *count) {
memmove (*base + (*position + 1),
*base + (*position),
(*count - *position) * elem_size);
}
memcpy (*base + (char) *position * elem_size, elem, elem_size);
*count+=1;
}
/* 0 - dma is not supported, scsi or regular file */
/* 1 - xt drive */
/* 2 - ide drive */
static void get_dma_support(dma_info_t *dma_info){
if (S_ISREG(dma_info->st.st_mode))
dma_info->st.st_rdev = dma_info->st.st_dev;
if (IDE_DISK_MAJOR(major(dma_info->st.st_rdev))) {
dma_info->support_type = 2;
return;
}
#ifdef XT_DISK_MAJOR
if (major(dma_info->st.st_rdev) == XT_DISK_MAJOR) {
dma_info->support_type = 1;
return;
}
#endif
dma_info->support_type = 0;
}
/*
* Return values:
* 0 - ok;
* 1 - preparation cannot be done
* -1 - preparation failed
*/
int prepare_dma_check(dma_info_t *dma_info) {
DIR *dir;
struct dirent *dirent;
struct stat st;
dev_t rdev;
int rem;
char buf[256];
#ifndef HDIO_GET_DMA
return -1;
#endif
if (fstat(dma_info->fd, &dma_info->st))
die("stat on device failed\n");
get_dma_support(dma_info);
/* dma should be supported */
if (dma_info->support_type == 0)
return 1;
if (dma_info->support_type == 2) {
rdev = dma_info->st.st_rdev;
if ((rem = (minor(rdev) % 64)) != 0) {
rdev -= rem;
if(!(dir = opendir("/dev/"))) {
dma_info->support_type = 1;
return 0;
}
while ((dirent = readdir(dir)) != NULL) {
if (strncmp(dirent->d_name, ".", 1) == 0 || strncmp(dirent->d_name, "..", 2) == 0)
continue;
memset(buf, 0, 256);
strncat(buf, "/dev/", 5);
strncat(buf, dirent->d_name, strlen(dirent->d_name));
if (stat(buf, &st))
break;
if (S_ISBLK(st.st_mode) && st.st_rdev == rdev)
{
dma_info->st = st;
dma_info->fd = open(buf, O_RDONLY
#if defined(O_LARGEFILE)
| O_LARGEFILE
#endif
);
closedir(dir);
return 0;
}
}
closedir(dir);
dma_info->support_type = 1;
return 1;
}
}
return 0;
}
static int is_dma_on (int fd) {
#ifdef HDIO_GET_DMA
static long parm;
if (ioctl(fd, HDIO_GET_DMA, &parm))
return -1;
else
return parm;
#endif
return 0;
}
static __u64 dma_speed(int fd, int support_type) {
static struct hd_driveid id;
__u64 speed = 0;
if (support_type != 2)
return 0;
#ifdef HDIO_OBSOLETE_IDENTITY
if (!ioctl(fd, HDIO_GET_IDENTITY, &id) ||
!ioctl(fd, HDIO_OBSOLETE_IDENTITY)) {
#else
if (!ioctl(fd, HDIO_GET_IDENTITY, &id)) {
#endif
speed |= (__u64)id.dma_1word & ~(__u64)0xff;
speed |= ((__u64)id.dma_mword & ~(__u64)0xff) << 16;
speed |= ((__u64)id.dma_ultra & ~(__u64)0xff) << 32;
} else if (errno == -ENOMSG)
return -1;
else
return -1;
return speed;
}
int get_dma_info(dma_info_t *dma_info) {
if ((dma_info->dma = is_dma_on(dma_info->fd)) == -1)
return -1;
if ((dma_info->speed = dma_speed(dma_info->fd, dma_info->support_type)) == (__u64)-1)
return -1;
return 0;
}
void clean_after_dma_check(int fd, dma_info_t *dma_info) {
signal(SIGALRM, SIG_IGN);
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;
__u32 num1, num2;
fprintf(out, "A pair of credits:\n");
srandom (time (0));
num1 = random() % CREDITS_COUNT;
line = credits[num1];
fprintf(out, "%s\n", line);
while ((num1 == (num2 = random() % CREDITS_COUNT))) {}
line = credits[num2];
fprintf(out, "%s\n", line);
}
int user_confirmed (FILE * fp, char * q, char * yes) {
char * answer = 0;
size_t n = 0;
fprintf (fp, "%s", q);
if (getline (&answer, &n, stdin) != (ssize_t)strlen (yes) || strcmp (yes, answer))
return 0;
return 1;
}
+37
View File
@@ -0,0 +1,37 @@
#define _XOPEN_SOURCE
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "misc.h"
#include "reiserfs_lib.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
time_t parse_time(char *str)
{
struct tm ts;
if (strcmp(str, "now") == 0) {
return (time(0));
}
memset(&ts, 0, sizeof (ts));
#ifdef HAVE_STRPTIME
strptime(str, "%Y%m%d%H%M%S", &ts);
#else
sscanf(str, "%4d%2d%2d%2d%2d%2d", &ts.tm_year, &ts.tm_mon,
&ts.tm_mday, &ts.tm_hour, &ts.tm_min, &ts.tm_sec);
ts.tm_year -= 1900;
ts.tm_mon -= 1;
if (ts.tm_year < 0 || ts.tm_mon < 0 || ts.tm_mon > 11 ||
ts.tm_mday < 0 || ts.tm_mday > 31 || ts.tm_hour > 23 ||
ts.tm_min > 59 || ts.tm_sec > 61)
ts.tm_mday = 0;
#endif
if (ts.tm_mday == 0)
reiserfs_warning(stderr, "Couldn't parse date/time "
"specifier: %s", str);
return (mktime(&ts));
}
+117
View File
@@ -0,0 +1,117 @@
#include <stdio.h>
#include <sys/time.h>
#include <string.h>
#include "progbar.h"
static char bar[128], spaces[128];
static const char spinner[] = "\\|/-";
void progbar_init(struct progbar *ctx, const char *units, FILE *fp)
{
memset(ctx, 0, sizeof (*ctx));
if (!bar[0])
memset(bar, '=', sizeof(bar)-1);
if (!spaces[0])
memset(spaces, ' ', sizeof(spaces)-1);
strncpy(ctx->units, units, sizeof(ctx->units));
ctx->file = fp;
}
void progbar_clear(struct progbar * ctx)
{
if (!(ctx->flags & E2F_FLAG_PROG_BAR))
return;
fprintf(ctx->file, "\r%*s\r", 80, " ");
fflush(ctx->file);
ctx->flags &= ~E2F_FLAG_PROG_BAR;
}
int progbar_update(struct progbar * ctx, const char *label, int curr, int max,
unsigned int dpynum)
{
int i;
unsigned int tick;
struct timeval tv;
int dpywidth;
int fixed_percent;
float percent = ((float) curr) / ((float) max) * 100;
if (ctx->flags & E2F_FLAG_PROG_SUPPRESS)
return 0;
/*
* Calculate the new progress position. If the
* percentage hasn't changed, then we skip out right
* away.
*/
fixed_percent = (int) ((10 * percent) + 0.5);
if (ctx->progress_last_percent == fixed_percent)
return 0;
ctx->progress_last_percent = fixed_percent;
/*
* If we've already updated the spinner once within
* the last 1/8th of a second, no point doing it
* again.
*/
gettimeofday(&tv, NULL);
tick = (tv.tv_sec << 3) + (tv.tv_usec / (1000000 / 8));
if ((tick == ctx->progress_last_time) &&
(fixed_percent != 0) && (fixed_percent != 1000))
return 0;
ctx->progress_last_time = tick;
/*
* Advance the spinner, and note that the progress bar
* will be on the screen
*/
ctx->progress_pos = (ctx->progress_pos+1) & 3;
ctx->flags |= E2F_FLAG_PROG_BAR;
dpywidth = 66 - strlen(label);
dpywidth = 8 * (dpywidth / 8);
if (dpynum)
dpywidth -= 8;
i = ((percent * dpywidth) + 50) / 100;
fprintf(ctx->file, "\r%s: |%s%s", label,
bar + (sizeof(bar) - (i+1)),
spaces + (sizeof(spaces) - (dpywidth - i + 1)));
if (fixed_percent == 1000)
fputc('|', ctx->file);
else
fputc(spinner[ctx->progress_pos & 3], ctx->file);
fprintf(ctx->file, " %4.1f%% ", percent);
if (dpynum)
fprintf(ctx->file, "%u%s\r", dpynum, ctx->units);
else
fputs(" \r", ctx->file);
if (fixed_percent == 1000)
progbar_clear(ctx);
fflush(ctx->file);
return 0;
}
void
spinner_init(struct spinner *ctx, FILE *fp)
{
memset(ctx, 0, sizeof (*ctx));
ctx->file = fp;
}
void
spinner_touch(struct spinner *ctx)
{
fprintf(ctx->file, "%c", spinner[ctx->count++ % 4]);
}
void
spinner_clear(struct spinner *ctx)
{
fputs("", ctx->file);
}
-6
View File
@@ -1,6 +0,0 @@
noinst_LIBRARIES = libmisc-static.a
libmisc_static_a_SOURCES = bitops.c device.c malloc.c misc.c
libmisc_static_a_CFLAGS = @CFLAGS@
INCLUDES = -I$(top_srcdir)/include
-451
View File
@@ -1,451 +0,0 @@
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 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@
SOURCES = $(libmisc_static_a_SOURCES)
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 = :
build_triplet = @build@
host_triplet = @host@
subdir = libmisc
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
AR = ar
ARFLAGS = cru
libmisc_static_a_AR = $(AR) $(ARFLAGS)
libmisc_static_a_LIBADD =
am_libmisc_static_a_OBJECTS = libmisc_static_a-bitops.$(OBJEXT) \
libmisc_static_a-device.$(OBJEXT) \
libmisc_static_a-malloc.$(OBJEXT) \
libmisc_static_a-misc.$(OBJEXT)
libmisc_static_a_OBJECTS = $(am_libmisc_static_a_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libmisc_static_a_SOURCES)
DIST_SOURCES = $(libmisc_static_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
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@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
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@
PROGS_LDFLAGS = @PROGS_LDFLAGS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
UUID_LIBS = @UUID_LIBS@
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__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
noinst_LIBRARIES = libmisc-static.a
libmisc_static_a_SOURCES = bitops.c device.c malloc.c misc.c
libmisc_static_a_CFLAGS = @CFLAGS@
INCLUDES = -I$(top_srcdir)/include
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libmisc/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu libmisc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libmisc-static.a: $(libmisc_static_a_OBJECTS) $(libmisc_static_a_DEPENDENCIES)
-rm -f libmisc-static.a
$(libmisc_static_a_AR) libmisc-static.a $(libmisc_static_a_OBJECTS) $(libmisc_static_a_LIBADD)
$(RANLIB) libmisc-static.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmisc_static_a-bitops.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmisc_static_a-device.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmisc_static_a-malloc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmisc_static_a-misc.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
libmisc_static_a-bitops.o: bitops.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-bitops.o -MD -MP -MF "$(DEPDIR)/libmisc_static_a-bitops.Tpo" -c -o libmisc_static_a-bitops.o `test -f 'bitops.c' || echo '$(srcdir)/'`bitops.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-bitops.Tpo" "$(DEPDIR)/libmisc_static_a-bitops.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-bitops.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bitops.c' object='libmisc_static_a-bitops.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-bitops.o `test -f 'bitops.c' || echo '$(srcdir)/'`bitops.c
libmisc_static_a-bitops.obj: bitops.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-bitops.obj -MD -MP -MF "$(DEPDIR)/libmisc_static_a-bitops.Tpo" -c -o libmisc_static_a-bitops.obj `if test -f 'bitops.c'; then $(CYGPATH_W) 'bitops.c'; else $(CYGPATH_W) '$(srcdir)/bitops.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-bitops.Tpo" "$(DEPDIR)/libmisc_static_a-bitops.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-bitops.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bitops.c' object='libmisc_static_a-bitops.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-bitops.obj `if test -f 'bitops.c'; then $(CYGPATH_W) 'bitops.c'; else $(CYGPATH_W) '$(srcdir)/bitops.c'; fi`
libmisc_static_a-device.o: device.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-device.o -MD -MP -MF "$(DEPDIR)/libmisc_static_a-device.Tpo" -c -o libmisc_static_a-device.o `test -f 'device.c' || echo '$(srcdir)/'`device.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-device.Tpo" "$(DEPDIR)/libmisc_static_a-device.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-device.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='device.c' object='libmisc_static_a-device.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-device.o `test -f 'device.c' || echo '$(srcdir)/'`device.c
libmisc_static_a-device.obj: device.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-device.obj -MD -MP -MF "$(DEPDIR)/libmisc_static_a-device.Tpo" -c -o libmisc_static_a-device.obj `if test -f 'device.c'; then $(CYGPATH_W) 'device.c'; else $(CYGPATH_W) '$(srcdir)/device.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-device.Tpo" "$(DEPDIR)/libmisc_static_a-device.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-device.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='device.c' object='libmisc_static_a-device.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-device.obj `if test -f 'device.c'; then $(CYGPATH_W) 'device.c'; else $(CYGPATH_W) '$(srcdir)/device.c'; fi`
libmisc_static_a-malloc.o: malloc.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-malloc.o -MD -MP -MF "$(DEPDIR)/libmisc_static_a-malloc.Tpo" -c -o libmisc_static_a-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-malloc.Tpo" "$(DEPDIR)/libmisc_static_a-malloc.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-malloc.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='malloc.c' object='libmisc_static_a-malloc.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c
libmisc_static_a-malloc.obj: malloc.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-malloc.obj -MD -MP -MF "$(DEPDIR)/libmisc_static_a-malloc.Tpo" -c -o libmisc_static_a-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-malloc.Tpo" "$(DEPDIR)/libmisc_static_a-malloc.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-malloc.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='malloc.c' object='libmisc_static_a-malloc.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi`
libmisc_static_a-misc.o: misc.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-misc.o -MD -MP -MF "$(DEPDIR)/libmisc_static_a-misc.Tpo" -c -o libmisc_static_a-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-misc.Tpo" "$(DEPDIR)/libmisc_static_a-misc.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-misc.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libmisc_static_a-misc.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
libmisc_static_a-misc.obj: misc.c
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -MT libmisc_static_a-misc.obj -MD -MP -MF "$(DEPDIR)/libmisc_static_a-misc.Tpo" -c -o libmisc_static_a-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libmisc_static_a-misc.Tpo" "$(DEPDIR)/libmisc_static_a-misc.Po"; else rm -f "$(DEPDIR)/libmisc_static_a-misc.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libmisc_static_a-misc.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmisc_static_a_CFLAGS) $(CFLAGS) -c -o libmisc_static_a-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi`
uninstall-info-am:
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
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; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
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
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"; \
$(mkdir_p) "$(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 $(LIBRARIES)
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
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(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-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-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
-rm -rf ./$(DEPDIR)
-rm -f Makefile
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-generic distclean-tags distdir dvi dvi-am html \
html-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.
.NOEXPORT:
Loaded 100 of 193 files, more files were not shown because too many files have changed in this diff. Show more