summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/Makefile9
-rw-r--r--doc/introduction.xml9
-rw-r--r--doc/manual.xml33
-rw-r--r--doc/outline.txt172
-rw-r--r--doc/release-notes.xml25
-rw-r--r--pkgs/applications/audio/abcde/default.nix60
-rw-r--r--pkgs/applications/audio/abcde/install.patch21
-rw-r--r--pkgs/applications/audio/audacious/plugins.nix3
-rw-r--r--pkgs/applications/audio/cd-discid/default.nix31
-rw-r--r--pkgs/applications/audio/cd-discid/install.patch14
-rw-r--r--pkgs/applications/audio/snd/default.nix2
-rw-r--r--pkgs/applications/editors/eclipse/default.nix10
-rw-r--r--pkgs/applications/editors/eclipse/eclipse_classic.nix7
-rw-r--r--pkgs/applications/editors/ed/default.nix28
-rw-r--r--pkgs/applications/editors/emacs-modes/quack/builder.sh7
-rw-r--r--pkgs/applications/editors/emacs-modes/quack/default.nix22
-rw-r--r--pkgs/applications/editors/emacs-modes/remember/default.nix45
-rw-r--r--pkgs/applications/editors/emacs-unicode/builder.sh10
-rw-r--r--pkgs/applications/editors/jedit/default.nix (renamed from pkgs/applications/jedit/default.nix)0
-rw-r--r--pkgs/applications/editors/jedit/wrapper.nix (renamed from pkgs/applications/jedit/wrapper.nix)0
-rw-r--r--pkgs/applications/editors/kile/default.nix12
-rw-r--r--pkgs/applications/graphics/ImageMagick/6.3.8-5.nix26
-rw-r--r--pkgs/applications/graphics/ImageMagick/6.3.9-0.nix26
-rw-r--r--pkgs/applications/graphics/ImageMagick/default.nix35
-rw-r--r--pkgs/applications/graphics/gimp/default.nix6
-rw-r--r--pkgs/applications/graphics/pqiv/default.nix24
-rw-r--r--pkgs/applications/misc/acrobat-reader/default.nix7
-rw-r--r--pkgs/applications/misc/blender/default.nix8
-rw-r--r--pkgs/applications/misc/gv/default.nix14
-rw-r--r--pkgs/applications/misc/kiwixbuilder/default.nix28
-rw-r--r--pkgs/applications/misc/lyx/default.nix14
-rw-r--r--pkgs/applications/misc/synergy/default.nix7
-rw-r--r--pkgs/applications/misc/taskjuggler/default.nix69
-rw-r--r--pkgs/applications/misc/xchm/default.nix4
-rw-r--r--pkgs/applications/misc/xmobar/default.nix12
-rw-r--r--pkgs/applications/misc/xneur/default.nix21
-rw-r--r--pkgs/applications/networking/browsers/firefox-3/default.nix7
-rw-r--r--pkgs/applications/networking/browsers/firefox/default.nix6
-rw-r--r--pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/bitlbee/default.nix4
-rw-r--r--pkgs/applications/networking/instant-messengers/funpidgin/2.4.1.nix29
-rw-r--r--pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/default.nix7
-rw-r--r--pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix42
-rw-r--r--pkgs/applications/networking/instant-messengers/pidgin/default.nix11
-rw-r--r--pkgs/applications/networking/instant-messengers/psi/0.11.nix20
-rw-r--r--pkgs/applications/networking/irc/konversation/default.nix16
-rw-r--r--pkgs/applications/networking/mailreaders/mutt/default.nix12
-rw-r--r--pkgs/applications/networking/mailreaders/thunderbird-2.x/default.nix6
-rw-r--r--pkgs/applications/networking/p2p/ldcpp/1.0.1.nix31
-rw-r--r--pkgs/applications/networking/skype/default.nix34
-rw-r--r--pkgs/applications/networking/sniffers/wireshark/default.nix10
-rw-r--r--pkgs/applications/networking/sync/rsync/default.nix6
-rw-r--r--pkgs/applications/networking/sync/unison/default.nix12
-rw-r--r--pkgs/applications/office/abiword/builder.sh9
-rw-r--r--pkgs/applications/office/abiword/default.nix12
-rw-r--r--pkgs/applications/science/biology/clustalw2/default.nix21
-rw-r--r--pkgs/applications/science/biology/emboss/default.nix30
-rw-r--r--pkgs/applications/science/biology/mrbayes/builder.sh9
-rw-r--r--pkgs/applications/science/biology/mrbayes/default.nix20
-rw-r--r--pkgs/applications/science/biology/ncbi-tools/default.nix22
-rw-r--r--pkgs/applications/science/biology/paml/default.nix32
-rw-r--r--pkgs/applications/science/logic/coq/default.nix23
-rw-r--r--pkgs/applications/taxes/aangifte-2007/builder.sh21
-rw-r--r--pkgs/applications/taxes/aangifte-2007/default.nix21
-rw-r--r--pkgs/applications/version-management/bazaar/default.nix11
-rw-r--r--pkgs/applications/version-management/bazaar/tools.nix23
-rw-r--r--pkgs/applications/version-management/codeville/0.8.0.nix23
-rw-r--r--pkgs/applications/version-management/cvs/default.nix7
-rw-r--r--pkgs/applications/version-management/cvsps/01_ignoretrunk.dpatch23
-rw-r--r--pkgs/applications/version-management/cvsps/02_dynamicbufferalloc.dpatch125
-rw-r--r--pkgs/applications/version-management/cvsps/03_diffoptstypo.dpatch19
-rw-r--r--pkgs/applications/version-management/cvsps/default.nix28
-rw-r--r--pkgs/applications/version-management/darcs/darcs-2.nix (renamed from pkgs/applications/version-management/darcs_2_pre.nix)6
-rw-r--r--pkgs/applications/version-management/git/default.nix83
-rw-r--r--pkgs/applications/version-management/git/docbook2texi.patch36
-rw-r--r--pkgs/applications/version-management/git/pwd.patch22
-rw-r--r--pkgs/applications/version-management/monotone-viz/1.0.1.nix19
-rw-r--r--pkgs/applications/version-management/monotone/default.nix6
-rw-r--r--pkgs/applications/version-management/subversion-1.4.x/default.nix14
-rw-r--r--pkgs/applications/version-management/subversion-1.4.x/svnmerge.nix22
-rw-r--r--pkgs/applications/version-management/tailor/0.9.31.nix19
-rw-r--r--pkgs/applications/version-management/viewmtn/0.10.nix45
-rw-r--r--pkgs/applications/video/MPlayer/default.nix22
-rw-r--r--pkgs/applications/video/MPlayer/rp9codecs/builder.sh11
-rw-r--r--pkgs/applications/video/MPlayer/rp9codecs/default.nix8
-rw-r--r--pkgs/applications/video/gnash/builder.sh4
-rw-r--r--pkgs/applications/video/gnash/default.nix47
-rw-r--r--pkgs/applications/virtualization/qemu/0.9.0.nix28
-rw-r--r--pkgs/applications/virtualization/qemu/0.9.1.nix44
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/bcop/0.7.4.nix34
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/ccsm-simple/0.7.4.nix29
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/ccsm/0.7.4.nix29
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/compizconfig-python/0.7.4.nix23
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/config-backend/0.7.4.nix24
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/default.nix1
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/extra/0.7.4.nix34
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/libcompizconfig/0.7.4.nix23
-rw-r--r--pkgs/applications/window-managers/compiz-fusion/main/0.7.4.nix29
-rw-r--r--pkgs/applications/window-managers/compiz/0.7.4.nix51
-rw-r--r--pkgs/applications/window-managers/jwm/default.nix22
-rw-r--r--pkgs/applications/window-managers/wmii/default.nix17
-rw-r--r--pkgs/applications/window-managers/wmii31/default.nix2
-rw-r--r--pkgs/applications/window-managers/xmonad/default.nix43
-rw-r--r--pkgs/applications/window-managers/xmonad/xmonad-contrib.nix12
-rw-r--r--pkgs/build-support/checker/default.nix4
-rw-r--r--pkgs/build-support/fetchdarcs/builder.sh4
-rw-r--r--pkgs/build-support/fetchdarcs/default.nix3
-rw-r--r--pkgs/build-support/fetchsvnssh/builder.sh15
-rw-r--r--pkgs/build-support/fetchsvnssh/default.nix16
-rwxr-xr-xpkgs/build-support/fetchsvnssh/sshsubversion.exp22
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix34
-rw-r--r--pkgs/build-support/kernel/make-initrd.nix31
-rw-r--r--pkgs/build-support/kernel/make-initrd.sh39
-rw-r--r--pkgs/build-support/kernel/modules-closure.nix14
-rw-r--r--pkgs/build-support/kernel/modules-closure.sh36
-rw-r--r--pkgs/build-support/kernel/paths-from-graph.pl68
-rw-r--r--pkgs/build-support/vm/deb/deb-closure.pl162
-rw-r--r--pkgs/build-support/vm/default.nix823
-rw-r--r--pkgs/build-support/vm/rpm/redhat-9-i386.list92
-rw-r--r--pkgs/build-support/vm/rpm/redhat-9-i386.nix93
-rw-r--r--pkgs/build-support/vm/rpm/rpm-closure.pl114
-rwxr-xr-xpkgs/build-support/vm/rpm/rpm-list-to-nix.pl51
-rw-r--r--pkgs/build-support/vm/rpm/suse-9-i386.list90
-rw-r--r--pkgs/build-support/vm/rpm/suse-9-i386.nix90
-rw-r--r--pkgs/build-support/vm/test.nix70
-rw-r--r--pkgs/data/documentation/rnrs/builder.sh12
-rw-r--r--pkgs/data/documentation/rnrs/common.nix29
-rw-r--r--pkgs/data/documentation/rnrs/r3rs.nix6
-rw-r--r--pkgs/data/documentation/rnrs/r4rs.nix6
-rw-r--r--pkgs/data/documentation/rnrs/r5rs.nix6
-rw-r--r--pkgs/data/fonts/freefont-ttf/default.nix22
-rw-r--r--pkgs/data/fonts/libertine/2.7.bin.nix17
-rw-r--r--pkgs/data/fonts/libertine/2.7.nix23
-rw-r--r--pkgs/data/fonts/lmodern/0.92.nix32
-rw-r--r--pkgs/data/fonts/lmodern/1.010.nix27
-rw-r--r--pkgs/data/fonts/redhat-liberation-fonts/default.nix2
-rw-r--r--pkgs/data/fonts/unifont/default.nix4
-rw-r--r--pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix10
-rw-r--r--pkgs/data/sgml+xml/stylesheets/xslt/docbook5/default.nix6
-rw-r--r--pkgs/desktops/kde/kdebase/default.nix11
-rw-r--r--pkgs/desktops/kde/kdelibs/default.nix10
-rw-r--r--pkgs/development/compilers/bigloo/default.nix168
-rw-r--r--pkgs/development/compilers/ehc/default.nix65
-rw-r--r--pkgs/development/compilers/flapjax/default.nix25
-rw-r--r--pkgs/development/compilers/fpc/default.nix4
-rw-r--r--pkgs/development/compilers/fpc/lazarus.nix39
-rw-r--r--pkgs/development/compilers/gcc-4.2/fortran.nix73
-rw-r--r--pkgs/development/compilers/gcc-4.2/fortran.sh86
-rw-r--r--pkgs/development/compilers/ghc-6.6.1/setup-hook.sh2
-rw-r--r--pkgs/development/compilers/ghc-6.6/setup-hook.sh2
-rw-r--r--pkgs/development/compilers/ghc-6.8/default.nix5
-rw-r--r--pkgs/development/compilers/ghc-6.8/setup-hook.sh4
-rw-r--r--pkgs/development/compilers/ghc-6.8/snapshot.nix41
-rw-r--r--pkgs/development/compilers/ghc-6.8/x86_64-linux_patch24
-rw-r--r--pkgs/development/compilers/ghc/createGhcWrapper/default.nix38
-rw-r--r--pkgs/development/compilers/ghc/ghc-wrapper/default.nix51
-rw-r--r--pkgs/development/compilers/ghc/ghc-wrapper/ghc-cabal-executable-fun.nix17
-rw-r--r--pkgs/development/compilers/ghcs/default.nix117
-rw-r--r--pkgs/development/compilers/ghcs/patch55
-rw-r--r--pkgs/development/compilers/ikarus/0.0.3.nix21
-rw-r--r--pkgs/development/compilers/jdk/default.nix5
-rw-r--r--pkgs/development/compilers/jdk/jdk5-sun-linux.nix11
-rw-r--r--pkgs/development/compilers/jdk/jdk6-linux.nix19
-rw-r--r--pkgs/development/compilers/llvm/builder.sh86
-rw-r--r--pkgs/development/compilers/llvm/default.nix11
-rw-r--r--pkgs/development/compilers/llvm/llvm-gcc.nix67
-rw-r--r--pkgs/development/compilers/llvm/no-sys-dirs.patch139
-rw-r--r--pkgs/development/compilers/ocaml/3.10.0.nix47
-rw-r--r--pkgs/development/compilers/roadsend/default.nix7
-rw-r--r--pkgs/development/compilers/scala/default.nix22
-rw-r--r--pkgs/development/compilers/stalin/default.nix42
-rw-r--r--pkgs/development/compilers/swi-prolog/5.6.51.nix4
-rw-r--r--pkgs/development/compilers/swi-prolog/default.nix16
-rw-r--r--pkgs/development/compilers/webdsl/default.nix6
-rw-r--r--pkgs/development/compilers/yap/default.nix17
-rw-r--r--pkgs/development/eclipse/jdt-sdk/default.nix13
-rw-r--r--pkgs/development/guile-modules/guile-lib/default.nix18
-rw-r--r--pkgs/development/interpreters/clisp/default.nix6
-rw-r--r--pkgs/development/interpreters/guile/default.nix25
-rw-r--r--pkgs/development/interpreters/guile/popen-zombie.patch45
-rw-r--r--pkgs/development/interpreters/guile/setup-hook.sh4
-rw-r--r--pkgs/development/interpreters/php_configurable/default.nix539
-rw-r--r--pkgs/development/interpreters/pyrex/0.9.5.nix26
-rw-r--r--pkgs/development/interpreters/pyrex/0.9.6.nix44
-rw-r--r--pkgs/development/interpreters/python/2.4/default.nix (renamed from pkgs/development/interpreters/python/2.4.nix)0
-rw-r--r--pkgs/development/interpreters/python/2.4/search-path.patch (renamed from pkgs/development/interpreters/python/search-path.patch)0
-rw-r--r--pkgs/development/interpreters/python/2.4/setup-hook.sh (renamed from pkgs/development/interpreters/python/setup-hook.sh)0
-rw-r--r--pkgs/development/interpreters/python/2.5/default.nix27
-rw-r--r--pkgs/development/interpreters/python/default.nix6
-rw-r--r--pkgs/development/interpreters/r-lang/default.nix18
-rw-r--r--pkgs/development/interpreters/ruby/default.nix11
-rw-r--r--pkgs/development/interpreters/ruby/gems.nix24
-rw-r--r--pkgs/development/libraries/agg/default.nix9
-rw-r--r--pkgs/development/libraries/avahi/common.nix21
-rw-r--r--pkgs/development/libraries/babl/default.nix17
-rw-r--r--pkgs/development/libraries/dbus/default.nix15
-rw-r--r--pkgs/development/libraries/gdbm/default.nix17
-rw-r--r--pkgs/development/libraries/gdbm/install.patch29
-rw-r--r--pkgs/development/libraries/gegl/default.nix19
-rw-r--r--pkgs/development/libraries/glib/default.nix11
-rw-r--r--pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch14
-rw-r--r--pkgs/development/libraries/glibc-2.7/glibc-pwd.patch74
-rw-r--r--pkgs/development/libraries/gmm/default.nix17
-rw-r--r--pkgs/development/libraries/gnutls/default.nix32
-rw-r--r--pkgs/development/libraries/gnutls/tmpdir.patch28
-rw-r--r--pkgs/development/libraries/gtk-libs/2.12/glibmm/default.nix7
-rw-r--r--pkgs/development/libraries/gtk-libs/2.12/gtkmm/default.nix7
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/atk/default.nix13
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/default.nix23
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/glib/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix21
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.6/pango/default.nix14
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/atk/default.nix13
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/default.nix26
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/glib/default.nix13
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix22
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix12
-rw-r--r--pkgs/development/libraries/gtk-libs/2.8/pango/default.nix13
-rw-r--r--pkgs/development/libraries/haskell/X11/default.nix4
-rw-r--r--pkgs/development/libraries/java/hsqldb/default.nix6
-rw-r--r--pkgs/development/libraries/lablgtk/default.nix4
-rw-r--r--pkgs/development/libraries/lib3ds/default.nix18
-rw-r--r--pkgs/development/libraries/libcaca/default.nix11
-rw-r--r--pkgs/development/libraries/libcdio/default.nix15
-rw-r--r--pkgs/development/libraries/libffi/default.nix34
-rw-r--r--pkgs/development/libraries/libixp/libixp-0.3.nix12
-rw-r--r--pkgs/development/libraries/libixp_for_wmii/default.nix12
-rw-r--r--pkgs/development/libraries/libmicrohttpd/default.nix12
-rw-r--r--pkgs/development/libraries/liboil/0.3.13.nix (renamed from pkgs/development/libraries/liboil/0.3.12.nix)4
-rw-r--r--pkgs/development/libraries/libqglviewer/default.nix23
-rw-r--r--pkgs/development/libraries/libxml2/setup-hook.sh12
-rw-r--r--pkgs/development/libraries/mpfr/default.nix7
-rw-r--r--pkgs/development/libraries/mysql-connector-odbc/builder.sh7
-rw-r--r--pkgs/development/libraries/mysql-connector-odbc/default.nix13
-rw-r--r--pkgs/development/libraries/openssl/default.nix6
-rw-r--r--pkgs/development/libraries/qt-4/default.nix64
-rw-r--r--pkgs/development/libraries/schroedinger/default.nix11
-rw-r--r--pkgs/development/libraries/unixODBC/default.nix2
-rw-r--r--pkgs/development/libraries/unixODBCDrivers/default.nix103
-rw-r--r--pkgs/development/libraries/x264/default.nix18
-rw-r--r--pkgs/development/libraries/xine-lib/default.nix4
-rw-r--r--pkgs/development/misc/bleeding-edge-repos/default.nix55
-rw-r--r--pkgs/development/misc/bleeding_edge_repos/default.nix16
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/filtered-requirements.sh18
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/full-requirements.sh21
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/grab-url.sh20
-rw-r--r--pkgs/development/perl-modules/expression-generator/lib-cache.sh19
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/make-clean-dir.sh5
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/requirements.sh17
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/retrieve-file-link.sh14
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/retrieve-meta-yaml.sh16
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/retrieve-modulepage.sh5
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/source-download-link.sh17
-rw-r--r--pkgs/development/perl-modules/expression-generator/usage.txt10
-rwxr-xr-xpkgs/development/perl-modules/expression-generator/write-nix-expression.sh34
-rw-r--r--pkgs/development/python-modules/flup/r2311.nix18
-rw-r--r--pkgs/development/python-modules/pygtk/default.nix7
-rw-r--r--pkgs/development/python-modules/pyqt/3.17.4.nix20
-rw-r--r--pkgs/development/python-modules/pyqt/4.3.3.nix20
-rw-r--r--pkgs/development/python-modules/python-sip/4.7.4.nix18
-rw-r--r--pkgs/development/python-modules/pyx/default.nix40
-rw-r--r--pkgs/development/python-modules/setuptools/0.6c8.nix19
-rw-r--r--pkgs/development/tools/analysis/lcov/builder.sh12
-rw-r--r--pkgs/development/tools/analysis/lcov/default.nix35
-rw-r--r--pkgs/development/tools/analysis/lcov/lcov.patch169
-rw-r--r--pkgs/development/tools/analysis/lcov/string.patch10
-rw-r--r--pkgs/development/tools/analysis/valgrind/callgrind_annotate.patch8
-rw-r--r--pkgs/development/tools/analysis/valgrind/default.nix27
-rw-r--r--pkgs/development/tools/build-managers/apache-ant/ant-contrib.nix17
-rw-r--r--pkgs/development/tools/build-managers/apache-ant/builder.sh44
-rw-r--r--pkgs/development/tools/build-managers/apache-ant/default.nix17
-rw-r--r--pkgs/development/tools/build-managers/cmake/default.nix7
-rw-r--r--pkgs/development/tools/guile/g-wrap/default.nix36
-rw-r--r--pkgs/development/tools/guile/guile-lint/default.nix2
-rw-r--r--pkgs/development/tools/haskell/uuagc/default.nix4
-rw-r--r--pkgs/development/tools/misc/cproto/cproto_patch11
-rw-r--r--pkgs/development/tools/misc/cproto/default.nix20
-rw-r--r--pkgs/development/tools/misc/ctags/default.nix25
-rw-r--r--pkgs/development/tools/misc/dejagnu/default.nix37
-rw-r--r--pkgs/development/tools/misc/hasktags/default.nix2
-rw-r--r--pkgs/development/tools/misc/hsc2hs/default.nix26
-rw-r--r--pkgs/development/tools/misc/pmccabe/default.nix36
-rw-r--r--pkgs/development/tools/misc/xxdiff/3.2.nix37
-rw-r--r--pkgs/development/tools/parsing/flex/flex-2.5.35.nix19
-rw-r--r--pkgs/development/tools/profiling/oprofile/default.nix41
-rw-r--r--pkgs/development/tools/profiling/oprofile/opcontrol.patch16
-rw-r--r--pkgs/development/tools/profiling/sysprof/configure.patch17
-rw-r--r--pkgs/development/tools/profiling/sysprof/default.nix47
-rw-r--r--pkgs/games/openttd/default.nix22
-rw-r--r--pkgs/games/wesnoth/default.nix4
-rw-r--r--pkgs/lib/annotatedDerivations.nix56
-rw-r--r--pkgs/lib/default.nix34
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/cabal.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/getOptions.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/ghc_lambdavm.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/happs_data.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/happs_ixset.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/happs_plugins.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/happs_server.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/happs_state.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/happs_util.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/haskellnet.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/hsc2hs.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/hsjava.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/hsql.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/hsutils.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/http.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/hypertable.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/mkcabal.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/nix_repository_manager.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/syb_with_class.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/synergy.nix3
-rw-r--r--pkgs/misc/bleeding-edge-fetch-info/takusen.nix3
-rw-r--r--pkgs/misc/emulators/wine/default.nix8
-rw-r--r--pkgs/misc/freestyle/default.nix50
-rw-r--r--pkgs/misc/freestyle/patch182
-rw-r--r--pkgs/misc/ghc68executables/default.nix137
-rw-r--r--pkgs/misc/ghc68extraLibs/WASHNGo_Patch_ghc68256
-rw-r--r--pkgs/misc/ghc68extraLibs/default.nix436
-rw-r--r--pkgs/misc/ghc68extraLibs/haskellnetPatch66
-rw-r--r--pkgs/misc/ghc68extraLibs/hdbc_postgresql_patch10
-rw-r--r--pkgs/misc/ghc68extraLibs/hsql-mysql-patch73
-rw-r--r--pkgs/misc/ghc68extraLibs/takusen_setup_patch51
-rw-r--r--pkgs/misc/my_env/default.nix35
-rw-r--r--pkgs/misc/ntfs-3g/default.nix18
-rw-r--r--pkgs/misc/screensavers/xlockmore/default.nix2
-rw-r--r--pkgs/misc/tex/auctex/default.nix25
-rw-r--r--pkgs/misc/tex/nix/default.nix61
-rw-r--r--pkgs/misc/tex/nix/run-latex.sh15
-rw-r--r--pkgs/misc/tex/tetex/builder.sh2
-rw-r--r--pkgs/misc/tex/texlive/aggregate.nix58
-rw-r--r--pkgs/misc/tex/texlive/beamer.nix20
-rw-r--r--pkgs/misc/tex/texlive/cm-super.nix27
-rw-r--r--pkgs/misc/tex/texlive/context.nix21
-rw-r--r--pkgs/misc/tex/texlive/default.nix87
-rw-r--r--pkgs/misc/tex/texlive/extra.nix19
-rw-r--r--pkgs/misc/tex/texlive/pgf.nix20
-rw-r--r--pkgs/misc/tex/texlive/setup-hook.sh7
-rw-r--r--pkgs/misc/tex/texlive/xcolor.nix34
-rw-r--r--pkgs/misc/xosd/default.nix18
-rw-r--r--pkgs/os-specific/linux/atheros/0.9.4.nix30
-rw-r--r--pkgs/os-specific/linux/atheros/r3574.nix30
-rw-r--r--pkgs/os-specific/linux/atheros/r3693.nix43
-rw-r--r--pkgs/os-specific/linux/aufs/default.nix16
-rw-r--r--pkgs/os-specific/linux/blcr/0.6.5.nix27
-rw-r--r--pkgs/os-specific/linux/dietlibc/builder.sh5
-rw-r--r--pkgs/os-specific/linux/e2fsprogs/default.nix12
-rw-r--r--pkgs/os-specific/linux/e2fsprogs/e2fsprogs-1.39_etc.patch27
-rw-r--r--pkgs/os-specific/linux/e3cfsprogs/default.nix4
-rw-r--r--pkgs/os-specific/linux/ext3cow-tools/default.nix2
-rw-r--r--pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix10
-rw-r--r--pkgs/os-specific/linux/gw6c/5.1.nix39
-rw-r--r--pkgs/os-specific/linux/gw6c/default.nix30
-rw-r--r--pkgs/os-specific/linux/hal/default.nix8
-rw-r--r--pkgs/os-specific/linux/hdparm/default.nix11
-rw-r--r--pkgs/os-specific/linux/hibernate/default.nix44
-rw-r--r--pkgs/os-specific/linux/hibernate/gen-manpages.patch11
-rw-r--r--pkgs/os-specific/linux/hibernate/hibernate.patch37
-rw-r--r--pkgs/os-specific/linux/hibernate/install.patch11
-rw-r--r--pkgs/os-specific/linux/iwlwifi/default.nix6
-rw-r--r--pkgs/os-specific/linux/jfsrec/svn-7.nix22
-rw-r--r--pkgs/os-specific/linux/jfsutils/1.1.12.nix18
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.6.25.4.nix26
-rw-r--r--pkgs/os-specific/linux/kernel-headers/2.6.26-rc5.nix26
-rw-r--r--pkgs/os-specific/linux/kernel/builder-custom.sh127
-rw-r--r--pkgs/os-specific/linux/kernel/builder.sh17
-rw-r--r--pkgs/os-specific/linux/kernel/config-2.6.25-i686-smp4043
-rw-r--r--pkgs/os-specific/linux/kernel/config-2.6.25-uml684
-rw-r--r--pkgs/os-specific/linux/kernel/config-2.6.25-x86_64-smp3766
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch560
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.20.nix3
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch18462
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.23.nix7
-rw-r--r--pkgs/os-specific/linux/kernel/linux-2.6.25.nix95
-rw-r--r--pkgs/os-specific/linux/kernel/linux.nix97
-rw-r--r--pkgs/os-specific/linux/kernel/sec_perm-2.6.24.patch16
-rwxr-xr-xpkgs/os-specific/linux/kernelscripts/builder.sh34
-rw-r--r--pkgs/os-specific/linux/kernelscripts/default.nix8
-rw-r--r--pkgs/os-specific/linux/klibc/shrunk.nix24
-rw-r--r--pkgs/os-specific/linux/kqemu/1.3.0pre11.nix49
-rw-r--r--pkgs/os-specific/linux/kvm/57.nix12
-rw-r--r--pkgs/os-specific/linux/kvm/69.nix38
-rw-r--r--pkgs/os-specific/linux/kvm/readonly-kernel.patch14
-rw-r--r--pkgs/os-specific/linux/kvm/smbd-path.patch26
-rw-r--r--pkgs/os-specific/linux/libcap/default.nix2
-rw-r--r--pkgs/os-specific/linux/libvolume_id/default.nix6
-rw-r--r--pkgs/os-specific/linux/module-init-tools/aggregator.nix63
-rw-r--r--pkgs/os-specific/linux/nfs-utils/default.nix34
-rw-r--r--pkgs/os-specific/linux/nfs-utils/sbindir.patch11
-rw-r--r--pkgs/os-specific/linux/nss_ldap/default.nix2
-rw-r--r--pkgs/os-specific/linux/numactl/default.nix26
-rw-r--r--pkgs/os-specific/linux/nvidia/default.nix18
-rw-r--r--pkgs/os-specific/linux/opengl/xorg-sys/builder.sh3
-rw-r--r--pkgs/os-specific/linux/splashutils/1.3.nix (renamed from pkgs/os-specific/linux/splashutils/default.nix)6
-rw-r--r--pkgs/os-specific/linux/splashutils/1.5.nix32
-rw-r--r--pkgs/os-specific/linux/tcp-wrapper/builder.sh37
-rw-r--r--pkgs/os-specific/linux/tcp-wrapper/default.nix20
-rw-r--r--pkgs/os-specific/linux/uml-utilities/builder.sh4
-rw-r--r--pkgs/os-specific/linux/wis-go7007/default.nix2
-rw-r--r--pkgs/os-specific/linux/wpa_supplicant/default.nix7
-rw-r--r--pkgs/os-specific/linux/xfsprogs/2.9.7-1.nix25
-rw-r--r--pkgs/servers/dict/1.9.15.nix24
-rw-r--r--pkgs/servers/dict/dictd-db-collector.nix80
-rw-r--r--pkgs/servers/dict/dictd-db.nix94
-rw-r--r--pkgs/servers/dict/freedict.nix4
-rw-r--r--pkgs/servers/dns/bind/9.5.0.nix19
-rw-r--r--pkgs/servers/gpm/1.20.3pre6.nix22
-rw-r--r--pkgs/servers/gpm/1.99.6.nix23
-rw-r--r--pkgs/servers/http/apache-httpd/default.nix2
-rw-r--r--pkgs/servers/mail/postfix/default.nix21
-rw-r--r--pkgs/servers/monitoring/zabbix/default.nix34
-rw-r--r--pkgs/servers/network-script/builder.sh11
-rw-r--r--pkgs/servers/network-script/default.nix10
-rwxr-xr-xpkgs/servers/network-script/network66
-rw-r--r--pkgs/servers/portmap/default.nix42
-rw-r--r--pkgs/servers/samba/default.nix35
-rw-r--r--pkgs/servers/samba/smb.conf271
-rw-r--r--pkgs/servers/server-scripts/generic/builder.sh11
-rw-r--r--pkgs/servers/server-scripts/generic/default.nix11
-rw-r--r--pkgs/servers/server-scripts/generic/functions117
-rw-r--r--pkgs/servers/squid/3.head.nix24
-rw-r--r--pkgs/servers/squid/default.nix8
-rw-r--r--pkgs/servers/ssh-script/builder.sh13
-rw-r--r--pkgs/servers/ssh-script/default.nix12
-rwxr-xr-xpkgs/servers/ssh-script/sshd163
-rw-r--r--pkgs/servers/syslog-script/builder.sh11
-rw-r--r--pkgs/servers/syslog-script/default.nix10
-rwxr-xr-xpkgs/servers/syslog-script/syslog64
-rw-r--r--pkgs/servers/x11/xorg/default.nix10
-rw-r--r--pkgs/servers/xmpp/openfire/3.4.5.nix8
-rw-r--r--pkgs/stdenv/cygwin/default.nix3
-rw-r--r--pkgs/stdenv/freebsd/default.nix3
-rw-r--r--pkgs/stdenv/generic/default.nix3
-rw-r--r--pkgs/stdenv/linux/default.nix20
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix4
-rw-r--r--pkgs/stdenv/nix/default.nix5
-rw-r--r--pkgs/stdenv/powerpc-darwin/default.nix3
-rw-r--r--pkgs/tools/X11/keynav/default.nix2
-rw-r--r--pkgs/tools/X11/x2vnc/1.7.2.nix28
-rw-r--r--pkgs/tools/X11/xpra/default.nix39
-rw-r--r--pkgs/tools/backup/rsnapshot/default.nix23
-rw-r--r--pkgs/tools/graphics/ploticus/builder.sh25
-rw-r--r--pkgs/tools/graphics/ploticus/default.nix21
-rw-r--r--pkgs/tools/graphics/ploticus/ploticus-install.patch17
-rw-r--r--pkgs/tools/misc/eProver/default.nix6
-rw-r--r--pkgs/tools/misc/expect/default.nix4
-rw-r--r--pkgs/tools/misc/fontforge/default.nix32
-rw-r--r--pkgs/tools/misc/grub/default.nix9
-rw-r--r--pkgs/tools/misc/hddtemp/default.nix (renamed from pkgs/tools/hddtemp/default.nix)0
-rw-r--r--pkgs/tools/misc/idutils/default.nix41
-rw-r--r--pkgs/tools/misc/keychain/default.nix24
-rw-r--r--pkgs/tools/misc/mdbtools/0.6-pre1.nix22
-rw-r--r--pkgs/tools/misc/minicom/2.3.nix18
-rw-r--r--pkgs/tools/misc/mysql2pgsql/default.nix27
-rw-r--r--pkgs/tools/misc/pinentry/default.nix17
-rw-r--r--pkgs/tools/misc/relfs/cvs.2007.12.01.nix6
-rw-r--r--pkgs/tools/misc/relfs/cvs.2008.03.05.nix53
-rw-r--r--pkgs/tools/misc/uucp/1.07.nix18
-rw-r--r--pkgs/tools/networking/curl/default.nix10
-rw-r--r--pkgs/tools/networking/dhcp/builder.sh4
-rw-r--r--pkgs/tools/networking/dhcp/default.nix29
-rw-r--r--pkgs/tools/networking/dhcp/no-mkdir-var-run.patch22
-rw-r--r--pkgs/tools/networking/iodine/default.nix1
-rw-r--r--pkgs/tools/networking/iodine/iodine-0.4.1.nix21
-rw-r--r--pkgs/tools/networking/lsh/default.nix6
-rw-r--r--pkgs/tools/networking/nss-mdns/default.nix37
-rw-r--r--pkgs/tools/networking/socat/1.6.0.0.nix35
-rw-r--r--pkgs/tools/networking/socat/1.6.0.1.nix25
-rw-r--r--pkgs/tools/networking/socat/2.0.0-b1.nix33
-rw-r--r--pkgs/tools/networking/vpnc/builder.sh9
-rw-r--r--pkgs/tools/networking/vpnc/default.nix12
-rw-r--r--pkgs/tools/package-management/dpkg/default.nix35
-rw-r--r--pkgs/tools/package-management/nix/custom.nix17
-rw-r--r--pkgs/tools/package-management/nix/unstable.nix6
-rw-r--r--pkgs/tools/package-management/nixRepositoryManager/default.nix47
-rw-r--r--pkgs/tools/security/gnupg2/default.nix4
-rw-r--r--pkgs/tools/security/metasploit/3.1.nix31
-rw-r--r--pkgs/tools/security/nmap/default.nix20
-rw-r--r--pkgs/tools/system/at/default.nix31
-rw-r--r--pkgs/tools/system/at/install.patch55
-rw-r--r--pkgs/tools/system/ddrescue/1.8.nix20
-rw-r--r--pkgs/tools/text/cheetah-template/2.0.1.nix18
-rw-r--r--pkgs/tools/text/diffstat/default.nix17
-rw-r--r--pkgs/tools/text/ed/default.nix7
-rw-r--r--pkgs/tools/text/highlight/2.6.10.nix20
-rw-r--r--pkgs/tools/text/mpage/default.nix28
-rw-r--r--pkgs/tools/typesetting/asciidoc/default.nix53
-rw-r--r--pkgs/tools/typesetting/docbook2x/db2x_texixml-to-stdout.patch15
-rw-r--r--pkgs/tools/typesetting/docbook2x/default.nix53
-rw-r--r--pkgs/tools/typesetting/lhs2tex/builder.sh14
-rw-r--r--pkgs/tools/typesetting/lhs2tex/default.nix14
-rw-r--r--pkgs/tools/typesetting/xmlto/default.nix43
-rw-r--r--pkgs/top-level/all-packages.nix2399
-rw-r--r--pkgs/top-level/build-for-release.nix21
-rw-r--r--pkgs/top-level/builder-defs.nix133
-rw-r--r--pkgs/top-level/template-composing+config.nix4
-rw-r--r--pkgs/top-level/template-composing-builder.nix31
-rw-r--r--pkgs/top-level/template-debian.nix4
501 files changed, 21912 insertions, 22427 deletions
diff --git a/doc/Makefile b/doc/Makefile
index c21825e0dc1..d81fd55c2c8 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -16,7 +16,7 @@ NEWS_OPTS = \
  --stringparam section.autolabel.max.depth 0 \
  --stringparam header.rule 0
 
-all: NEWS.html NEWS.txt
+all: NEWS.html NEWS.txt manual.html
 
 NEWS.html: release-notes.xml
 	$(XSLTPROC) --nonet --xinclude --output $@ $(NEWS_OPTS) \
@@ -28,3 +28,10 @@ NEWS.txt: release-notes.xml
 	  $(docbookxsl)/html/docbook.xsl -
 	LANG=en_US w3m -dump $@.tmp.html > $@
 	rm $@.tmp.html
+
+manual.html: *.xml
+	$(XSLTPROC) --nonet --xinclude --output manual.html \
+	  $(docbookxsl)/html/docbook.xsl manual.xml
+
+manual.pdf: *.xml
+	dblatex manual.xml
diff --git a/doc/introduction.xml b/doc/introduction.xml
new file mode 100644
index 00000000000..f1f15995909
--- /dev/null
+++ b/doc/introduction.xml
@@ -0,0 +1,9 @@
+<chapter xmlns="http://docbook.org/ns/docbook"
+         xmlns:xlink="http://www.w3.org/1999/xlink"
+         xml:id="chap-introduction">
+
+<title>Introduction</title>
+
+<para>Bla</para>
+
+</chapter>
\ No newline at end of file
diff --git a/doc/manual.xml b/doc/manual.xml
new file mode 100644
index 00000000000..c38e0835e5f
--- /dev/null
+++ b/doc/manual.xml
@@ -0,0 +1,33 @@
+<book xmlns="http://docbook.org/ns/docbook"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+
+  <info>
+
+    <title>Nixpkgs Manual</title>
+
+    <subtitle>Draft (Version <xi:include href="../VERSION"
+    parse="text" />)</subtitle>
+
+    <author>
+      <personname>
+        <firstname>Eelco</firstname>
+        <surname>Dolstra</surname>
+      </personname>
+      <affiliation>
+        <orgname>Delft University of Technology</orgname>
+        <orgdiv>Department of Software Technology</orgdiv>
+      </affiliation>
+    </author>
+
+    <copyright>
+      <year>2008</year>
+      <holder>Eelco Dolstra</holder>
+    </copyright>
+
+    <date>June 2008</date>
+    
+  </info>
+
+  <xi:include href="introduction.xml" />
+  
+</book>
\ No newline at end of file
diff --git a/doc/outline.txt b/doc/outline.txt
new file mode 100644
index 00000000000..060592a99ab
--- /dev/null
+++ b/doc/outline.txt
@@ -0,0 +1,172 @@
+- Intro
+
+  - Goal of this manual
+
+
+- Quick start to adding a package
+
+  (Some of this can be copied/moved from the Nix manual)
+
+  - Hello example
+    - Nix expr
+    - Update all-packages.nix
+    - How to test
+    - How to debug failing builds    
+
+  - Subversion example
+
+  - Some X example?
+
+
+- The standard environment
+
+  (Some of this can be moved from the Nix manual)
+
+  - Special attributes
+
+  - Generic builder
+
+  - Helper functions
+
+  - GCC / ld wrapper (+ env vars)
+
+  - Phases (+ how to add phases) and hooks
+
+  - Override functions for stdenv
+
+    - Overriding GCC
+
+    - Overriding the setup script
+
+    - Predefined override functions in all-packages.nix: static binary
+      stdenv, dietlibc stdenv
+
+  - Stdenv bootstrap; how to update the Linux bootstrap binaries
+
+
+- Support for specific languages
+
+  - Perl
+
+    - Generic Perl builder
+
+  - Python
+
+    - Wrapper generation
+
+  - Haskell
+
+    - TODO
+
+  - Java
+
+    - TODO; Java needs lots of improvement
+
+  - TeX/LaTeX
+
+    - Special support for building TeX documents
+  
+
+- Special kinds of applications
+
+  - OpenGL apps
+
+  - Binary-only apps
+
+  - Linux kernel modules
+
+  - Mozilla plugins/extensions
+
+  - X apps
+
+  - KDE apps
+
+  - GConf-based apps
+
+  - Programs that need wrappers
+
+    - makeWrapper etc.
+
+  - Initial ramdisks
+
+
+- Library functions
+
+  - i.e. in lib/default.nix
+
+
+- Specific package notes
+
+  - Linux kernel; how to update; feature tests
+
+  - X.org; how to update
+
+  - Gnome; how to update
+
+  - GCC?
+
+  - GHC?
+
+  - ...
+
+
+- Meta attributes
+
+  - License attr; possible values
+
+
+- Virtual machine support (for the build farm)
+
+  - vmtools
+
+  - KVM notes
+
+  - Performing a build in a VM
+
+    - In the host FS
+
+    - In a disk image
+
+  - RPM builds
+
+    - RPM image creation
+
+  - Deb builds
+
+    - Deb image creation
+
+  - Debugging VM builds
+  
+
+- Guidelines for Nixpkgs contributions
+
+  - File naming conventions
+
+    - Versioning of packages
+
+  - Tree organisation
+
+  - Variable naming
+
+  - Layout / indentations style
+
+  - Output FS hierarchy (e.g. $out/share/man instead of $out/man)
+
+  
+- Misc
+
+  - Building outside of the Nixpkgs tree
+
+  - Config options
+
+  - Downloading stuff
+
+    - fetchurl
+
+      - mirror:// scheme
+
+    - fetchsvn
+
+    - fetchcvs
+
+    - fetchdarcs
diff --git a/doc/release-notes.xml b/doc/release-notes.xml
index 8ed87faa2ee..f04a674e96b 100644
--- a/doc/release-notes.xml
+++ b/doc/release-notes.xml
@@ -7,7 +7,30 @@
 
 <section><title>Release 0.12 (TBA)</title>
 
-<para>…</para>
+<para>This release has the following improvements:
+
+<itemizedlist>
+
+  <listitem><para>TODO: simplified and expanded stdenv hook
+  handling.</para></listitem>
+
+  <listitem><para>Important updates:
+
+    <itemizedlist>
+
+      <listitem><para>Glibc 2.7.</para></listitem>
+      
+      <listitem><para>GCC 4.2.4.</para></listitem>
+
+      <listitem><para>Linux 2.6.25.</para></listitem>
+
+    </itemizedlist>
+
+  </para></listitem>
+
+</itemizedlist>
+
+</para>
 
 </section>
   
diff --git a/pkgs/applications/audio/abcde/default.nix b/pkgs/applications/audio/abcde/default.nix
new file mode 100644
index 00000000000..5cfa72158ba
--- /dev/null
+++ b/pkgs/applications/audio/abcde/default.nix
@@ -0,0 +1,60 @@
+{ stdenv, fetchurl, libcdio, cddiscid, wget, bash, vorbisTools
+, makeWrapper }:
+
+let version = "2.3.99.6";
+in
+  stdenv.mkDerivation {
+    name = "abcde-${version}";
+    src = fetchurl {
+      url = "mirror://debian/pool/a/abcde/abcde_${version}.orig.tar.gz";
+      sha256 = "1wl4ygj1cf1d6g05gwwygsd5g83l039fzi011r30ma5lnm763lyb";
+    };
+
+    # FIXME: This package does not support MP3 encoding (only Ogg),
+    # nor `distmp3', `eject', etc.
+
+    patches = [ ./install.patch ];
+
+    configurePhase = ''
+      sed -i "s|^[[:blank:]]*prefix *=.*$|prefix = $out|g ;
+              s|^[[:blank:]]*etcdir *=.*$|etcdir = $out/etc|g ;
+	      s|^[[:blank:]]*INSTALL *=.*$|INSTALL = install -c|g" \
+	  "Makefile";
+
+      # We use `cd-paranoia' from GNU libcdio, which contains a hyphen
+      # in its name, unlike Xiph's cdparanoia.
+      sed -i "s|^[[:blank:]]*CDPARANOIA=.*$|CDPARANOIA=cd-paranoia|g" \
+           "abcde"
+
+      substituteInPlace "abcde"					\
+	--replace "/etc/abcde.conf" "$out/etc/abcde.conf"
+    '';
+
+    buildInputs = [ makeWrapper ];
+
+    postInstall = ''
+      substituteInPlace "$out/bin/cddb-tool" \
+         --replace '#!/bin/sh' '#!${bash}/bin/sh'
+      substituteInPlace "$out/bin/abcde" \
+         --replace '#!/bin/bash' '#!${bash}/bin/bash'
+
+      wrapProgram "$out/bin/abcde" --prefix PATH ":" \
+        "$out/bin:${libcdio}/bin:${cddiscid}/bin:${wget}/bin:${vorbisTools}/bin"
+
+      wrapProgram "$out/bin/cddb-tool" --prefix PATH ":" \
+        "${wget}/bin"
+    '';
+
+    meta = {
+      homepage = http://www.hispalinux.es/~data/abcde.php;
+      licence = "GPLv2+";
+      description = "A Better CD Encoder (ABCDE)";
+
+      longDescription = ''
+        abcde is a front-end command-line utility (actually, a shell
+        script) that grabs tracks off a CD, encodes them to
+        Ogg/Vorbis, MP3, FLAC, Ogg/Speex and/or MPP/MP+ (Musepack)
+        format, and tags them, all in one go.
+      '';
+    };
+  }
\ No newline at end of file
diff --git a/pkgs/applications/audio/abcde/install.patch b/pkgs/applications/audio/abcde/install.patch
new file mode 100644
index 00000000000..f5ab75f4bb9
--- /dev/null
+++ b/pkgs/applications/audio/abcde/install.patch
@@ -0,0 +1,21 @@
+--- abcde-2.3.3/Makefile~	2005-08-26 00:43:27.000000000 +0200
++++ abcde-2.3.3/Makefile	2008-05-26 22:20:17.000000000 +0200
+@@ -14,13 +14,13 @@ clean:
+ 
+ install:
+ 	$(INSTALL) -d -m 755 $(bindir)
+-	$(INSTALL) -m 755 -o 0 abcde $(bindir)
+-	$(INSTALL) -m 755 -o 0 cddb-tool $(bindir)
++	$(INSTALL) -m 755 abcde $(bindir)
++	$(INSTALL) -m 755 cddb-tool $(bindir)
+ 	$(INSTALL) -d -m 755 $(mandir)
+-	$(INSTALL) -m 644 -o 0 abcde.1 $(mandir)
+-	$(INSTALL) -m 644 -o 0 cddb-tool.1 $(mandir)
++	$(INSTALL) -m 644 abcde.1 $(mandir)
++	$(INSTALL) -m 644 cddb-tool.1 $(mandir)
+ 	$(INSTALL) -d -m 755 $(etcdir)
+-	$(INSTALL) -m 644 -o 0 abcde.conf $(etcdir)
++	$(INSTALL) -m 644 abcde.conf $(etcdir)
+ 
+ tarball:
+ 	@cd .. && tar czvf abcde_$(VERSION).orig.tar.gz \
diff --git a/pkgs/applications/audio/audacious/plugins.nix b/pkgs/applications/audio/audacious/plugins.nix
index 1abcacaf959..4d870fdd94d 100644
--- a/pkgs/applications/audio/audacious/plugins.nix
+++ b/pkgs/applications/audio/audacious/plugins.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchurl, pkgconfig, audacious, dbus_glib, gettext
 , libmad, xlibs, alsaLib, taglib, libmpcdec, libogg, libvorbis
+, libcdio, libcddb
 }:
 
 stdenv.mkDerivation {
@@ -13,7 +14,7 @@ stdenv.mkDerivation {
   buildInputs = [
     pkgconfig audacious dbus_glib gettext libmad
     xlibs.libXcomposite alsaLib taglib libmpcdec
-    libogg libvorbis
+    libogg libvorbis libcdio libcddb
   ];
 
   preBuild = ''
diff --git a/pkgs/applications/audio/cd-discid/default.nix b/pkgs/applications/audio/cd-discid/default.nix
new file mode 100644
index 00000000000..24e0be5eac0
--- /dev/null
+++ b/pkgs/applications/audio/cd-discid/default.nix
@@ -0,0 +1,31 @@
+{ fetchurl, stdenv }:
+
+let version = "0.9";
+in
+  stdenv.mkDerivation {
+    name = "cd-discid-${version}";
+    src = fetchurl {
+      url = "mirror://debian/pool/main/c/cd-discid/cd-discid_${version}.orig.tar.gz";
+      sha256 = "1fx2ky1pb07l1r0bldpw16wdsfzw7a0093ib9v66kmilwy2sq5s9";
+    };
+
+    patches = [ ./install.patch ];
+
+    configurePhase = ''
+      sed -i "s|^[[:blank:]]*prefix *=.*$|prefix = $out|g ;
+	      s|^[[:blank:]]*INSTALL *=.*$|INSTALL = install -c|g"  \
+	  "Makefile";
+    '';
+
+    meta = {
+      homepage = http://lly.org/~rcw/cd-discid/;
+      licence = "GPLv2+";
+      description = "cd-discid, a command-line utility to retrieve a disc's CDDB ID";
+
+      longDescription = ''
+        cd-discid is a backend utility to get CDDB discid information
+        from a CD-ROM disc.  It was originally designed for cdgrab (now
+        abcde), but can be used for any purpose requiring CDDB data.
+      '';
+    };
+  }
\ No newline at end of file
diff --git a/pkgs/applications/audio/cd-discid/install.patch b/pkgs/applications/audio/cd-discid/install.patch
new file mode 100644
index 00000000000..4f0256813ff
--- /dev/null
+++ b/pkgs/applications/audio/cd-discid/install.patch
@@ -0,0 +1,14 @@
+--- cd-discid-0.9/Makefile	2003-01-05 21:18:07.000000000 +0100
++++ cd-discid-0.9/Makefile	2008-05-26 22:14:56.000000000 +0200
+@@ -32,9 +32,9 @@ clean:
+ 
+ install: cd-discid
+ 	$(INSTALL) -d -m 755 $(bindir)
+-	$(INSTALL) -s -m 755 -o 0 cd-discid $(bindir)
++	$(INSTALL) -s -m 755 cd-discid $(bindir)
+ 	$(INSTALL) -d -m 755 $(mandir)
+-	$(INSTALL) -m 644 -o 0 cd-discid.1 $(mandir)
++	$(INSTALL) -m 644 cd-discid.1 $(mandir)
+ 
+ tarball:
+ 	@cd .. && tar czvf cd-discid_$(VERSION).orig.tar.gz \
diff --git a/pkgs/applications/audio/snd/default.nix b/pkgs/applications/audio/snd/default.nix
index 42a235a4cb8..3b5bff294c3 100644
--- a/pkgs/applications/audio/snd/default.nix
+++ b/pkgs/applications/audio/snd/default.nix
@@ -2,7 +2,7 @@ args : with args;
 	let localDefs = builderDefs {
 		src = 
 	fetchurl {
-		url = ftp://ccrma-ftp.stanford.edu/pub/Lisp/snd-9.4.tar.gz;
+		url = http://downloads.sourceforge.net/snd/snd-9.4.tar.gz;
 		sha256 = "0zqgfnkvkqxby1k74mwba1r4pb520glcsz5jjmpzm9m41nqnghmm";
 	};
 
diff --git a/pkgs/applications/editors/eclipse/default.nix b/pkgs/applications/editors/eclipse/default.nix
index 23199bdcc12..17fbd51cb57 100644
--- a/pkgs/applications/editors/eclipse/default.nix
+++ b/pkgs/applications/editors/eclipse/default.nix
@@ -3,7 +3,7 @@
 let {
   body =
     stdenv.mkDerivation {
-      name = "eclipse-sdk-3.3.3.1";
+      name = "eclipse-sdk-3.3.2";
       builder = ./builder.sh;
       src = bindist;
       buildInputs = [makeWrapper];
@@ -13,10 +13,10 @@ let {
 
   bindist = 
     if (stdenv.system == "x86_64-linux") then fetchurl {
-      url = "http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/eclipse/downloads/drops/R-3.3.1.1-200710231652/eclipse-SDK-3.3.1.1-linux-gtk-x86_64.tar.gz";
-      sha256 = "3fec49e95c45b56ad77b2bd15616af9d1fa6c3b338d4c70b497ecdc974c0b030";
+      url = http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/eclipse/downloads/drops/R-3.3.2-200802211800/eclipse-SDK-3.3.2-linux-gtk-x86_64.tar.gz;
+      sha256 = "fa7ff6fd17d053a53f743fa3d79493aa2e359402563cc736db9709a87826af21";
     } else fetchurl {
-      url = http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/eclipse/downloads/drops/R-3.3.1.1-200710231652/eclipse-SDK-3.3.1.1-linux-gtk.tar.gz;
-      sha256 = "409e47745c92ff8ea8b2037104ec90c2f8ce3edb3563fdb312d55e1bbd2ada01";
+      url = http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/eclipse/downloads/drops/R-3.3.2-200802211800/eclipse-SDK-3.3.2-linux-gtk.tar.gz;
+      sha256 = "624460c87f763b855fcddca86d969f2e4c730e654fe1a0dd69624afe576b13c8";
     };
 }
diff --git a/pkgs/applications/editors/eclipse/eclipse_classic.nix b/pkgs/applications/editors/eclipse/eclipse_classic.nix
index 9dba9e6a791..2d3b22e476e 100644
--- a/pkgs/applications/editors/eclipse/eclipse_classic.nix
+++ b/pkgs/applications/editors/eclipse/eclipse_classic.nix
@@ -1,3 +1,7 @@
+# Note, if you want to install plugins using the update manager you should
+# copy the store path to a local directory and chown -R $USER yourcopy
+# Then start your local copy
+
 args: with args;
 let arch = if stdenv.system == "x86_64-linux" then "x86_64"
             else if stdenv.system == "i686-linux" then "x86"
@@ -38,7 +42,10 @@ args.stdenv.mkDerivation rec {
     makeWrapper \$out/eclipse/eclipse \$out/bin/eclipse \\
         --prefix PATH \":\" \"\$jdk/bin\" \\
         --prefix LD_LIBRARY_PATH \":\" \"\$rpath\"
+    sed -e 's=exec.*=exec \$(dirname $0)/../eclipse/eclipse $@=' -i \$out/bin/eclipse
   ";
+  # using dirname so that eclipse still runs after copying the whole store
+  # directory somewhere else (so that you can use the update manager
 
   src = args.fetchurl {
     #url = http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/eclipse/downloads/drops/S-3.4M5-200802071530/eclipse-sourceBuild-srcIncluded-3.4M5.zip;
diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix
new file mode 100644
index 00000000000..e40143c409e
--- /dev/null
+++ b/pkgs/applications/editors/ed/default.nix
@@ -0,0 +1,28 @@
+{ fetchurl, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "ed-0.9";
+  src = fetchurl {
+    url = "mirror://gnu/ed/${name}.tar.bz2";
+    sha256 = "1xy746g7ai9gmv6iq2x1ll8x6wy4fi9anfh7gj5ifsdnaiahgyi2";
+  };
+
+  meta = {
+    description = "GNU ed, an implementation of the standard Unix editor";
+
+    longDescription = ''
+      GNU ed is a line-oriented text editor.  It is used to create,
+      display, modify and otherwise manipulate text files, both
+      interactively and via shell scripts.  A restricted version of ed,
+      red, can only edit files in the current directory and cannot
+      execute shell commands.  Ed is the "standard" text editor in the
+      sense that it is the original editor for Unix, and thus widely
+      available.  For most purposes, however, it is superseded by
+      full-screen editors such as GNU Emacs or GNU Moe.
+    '';
+
+    license = "GPLv3+";
+
+    homepage = http://www.gnu.org/software/ed/;
+  };
+}
diff --git a/pkgs/applications/editors/emacs-modes/quack/builder.sh b/pkgs/applications/editors/emacs-modes/quack/builder.sh
new file mode 100644
index 00000000000..a3b1bcfd805
--- /dev/null
+++ b/pkgs/applications/editors/emacs-modes/quack/builder.sh
@@ -0,0 +1,7 @@
+source "$stdenv/setup" || exit 1
+
+emacsDir="$out/share/emacs/site-lisp"
+
+ensureDir "$emacsDir" &&					\
+cp "$src" "$emacsDir/quack.el" &&				\
+emacs --batch -f batch-byte-compile "$emacsDir/quack.el"
diff --git a/pkgs/applications/editors/emacs-modes/quack/default.nix b/pkgs/applications/editors/emacs-modes/quack/default.nix
new file mode 100644
index 00000000000..d95e1109539
--- /dev/null
+++ b/pkgs/applications/editors/emacs-modes/quack/default.nix
@@ -0,0 +1,22 @@
+{ fetchurl, stdenv, emacs }:
+
+stdenv.mkDerivation {
+  name = "quack-0.30";
+
+  src = fetchurl {
+    # XXX: Upstream URL is not versioned, which might eventually break this.
+    url = "http://www.neilvandyke.org/quack/quack.el";
+    sha256 = "1j68azxbc54hdk3cw9q95qpz99wgj9xxgrzzwmydxh3zafy5faqs";
+  };
+
+  buildInputs = [ emacs ];
+
+  builder = ./builder.sh;
+
+  meta = {
+    description = ''Quack: Enhanced Emacs Support for Editing and
+                    Running Scheme Code'';
+    homepage = http://www.neilvandyke.org/quack/;
+    license = "GPLv2+";
+  };
+}
diff --git a/pkgs/applications/editors/emacs-modes/remember/default.nix b/pkgs/applications/editors/emacs-modes/remember/default.nix
new file mode 100644
index 00000000000..ea17a9b792a
--- /dev/null
+++ b/pkgs/applications/editors/emacs-modes/remember/default.nix
@@ -0,0 +1,45 @@
+{ fetchurl, stdenv, texinfo, emacs, bbdb }:
+
+stdenv.mkDerivation rec {
+  # Note: Remember is part of GNU Emacs 23.
+  name = "remember-2.0";
+
+  src = fetchurl {
+    url = "http://download.gna.org/remember-el/${name}.tar.gz";
+    sha256 = "04bp071xjbb6mbspjpwcza0krgx2827v6rfxbsdcpn0qcjgad9wm";
+  };
+
+  # FIXME: It also has a (soft) dependency on Planner and Bibl-mode.
+  buildInputs = [ emacs bbdb texinfo ];
+
+  patchPhase = ''
+    sed -i "Makefile.defs" \
+         -e"s|^ *PREFIX *=.*$|PREFIX = $out|g ;
+	    s|^ *ELISPDIR *=.*$|ELISPDIR = $out/share/emacs/site-lisp|g ;
+	    s|^ *EMACS *=.*$|EMACS = emacs -L \"${bbdb}/share/emacs/site-lisp\"|g"
+  '';
+
+  meta = {
+    description = "Remember, an Emacs mode for quickly remembering data";
+
+    longDescription = ''
+      Remember is an Emacs mode for quickly remembering data.  It uses
+      whatever back-end is appropriate to record and correlate the
+      data, but its main intention is to allow you to express as
+      little structure as possible up front.
+
+      When you enter data, either by typing it into a buffer, or using
+      the contents of the selected region, Remember will store that
+      data -- unindexed, uninterpreted -- in a data pool.  It will
+      also try to remember as much context information as possible
+      (any text properties that were set, where you copied it from,
+      when, how, etc).  Later, you can walk through your accumulated
+      set of data (both organized, and unorganized) and easily begin
+      moving things around, and making annotations that will express
+      the full meaning of that data, as far as you know it.
+    '';
+
+    homepage = http://gna.org/projects/remember-el/;
+    license = "GPLv2+";
+  };
+}
diff --git a/pkgs/applications/editors/emacs-unicode/builder.sh b/pkgs/applications/editors/emacs-unicode/builder.sh
index 8b53ade4f97..03dc2ac70be 100644
--- a/pkgs/applications/editors/emacs-unicode/builder.sh
+++ b/pkgs/applications/editors/emacs-unicode/builder.sh
@@ -5,10 +5,12 @@ preConfigure() {
     libc=$(cat ${NIX_GCC}/nix-support/orig-libc)
     echo "libc: $libc"
 
-    substituteInPlace src/s/gnu-linux.h \
-        --replace /usr/lib/crt1.o $libc/lib/crt1.o \
-        --replace /usr/lib/crti.o $libc/lib/crti.o \
-        --replace /usr/lib/crtn.o $libc/lib/crtn.o
+    for i in src/s/*.h src/m/*.h; do
+        substituteInPlace $i \
+            --replace /usr/lib/crt1.o $libc/lib/crt1.o \
+            --replace /usr/lib/crti.o $libc/lib/crti.o \
+            --replace /usr/lib/crtn.o $libc/lib/crtn.o
+    done
     
     for i in Makefile.in ./src/Makefile.in ./lib-src/Makefile.in ./leim/Makefile.in ./admin/unidata/Makefile; do
         substituteInPlace $i --replace /bin/pwd pwd
diff --git a/pkgs/applications/jedit/default.nix b/pkgs/applications/editors/jedit/default.nix
index c43b7f86914..c43b7f86914 100644
--- a/pkgs/applications/jedit/default.nix
+++ b/pkgs/applications/editors/jedit/default.nix
diff --git a/pkgs/applications/jedit/wrapper.nix b/pkgs/applications/editors/jedit/wrapper.nix
index 8af3d96918d..8af3d96918d 100644
--- a/pkgs/applications/jedit/wrapper.nix
+++ b/pkgs/applications/editors/jedit/wrapper.nix
diff --git a/pkgs/applications/editors/kile/default.nix b/pkgs/applications/editors/kile/default.nix
new file mode 100644
index 00000000000..385f1c7dce4
--- /dev/null
+++ b/pkgs/applications/editors/kile/default.nix
@@ -0,0 +1,12 @@
+{stdenv, fetchurl, perl, arts, qt, kdelibs, libX11, libXt, libXext, zlib, libpng, libjpeg, freetype, expat }:
+
+stdenv.mkDerivation {
+  name = "kile-2.0";
+
+  src = fetchurl {
+    url = http://heanet.dl.sourceforge.net/sourceforge/kile/kile-2.0.tar.bz2;
+    sha256 = "14a7e4605a3ee486b9a7c11e9bd3236bdbd34955d5522eac5da1e511dea6c7e2";
+  };
+
+  buildInputs = [ perl arts qt kdelibs libX11 libXt libXext zlib libpng libjpeg freetype expat ];
+}
diff --git a/pkgs/applications/graphics/ImageMagick/6.3.8-5.nix b/pkgs/applications/graphics/ImageMagick/6.3.8-5.nix
deleted file mode 100644
index 83c7075f8e5..00000000000
--- a/pkgs/applications/graphics/ImageMagick/6.3.8-5.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-args: with args;
-stdenv.mkDerivation (rec {
-  name = "ImageMagick-6.3.8-5";
-
-  src = fetchurl {
-    url = "ftp://ftp.imagemagick.org/pub/ImageMagick/${name}.tar.bz2";
-    sha256 = "0lsvi2z5b5zam6yvjzsyjpa36rg1c0kczifz73k9b4v8zz9a9vfl";
-  };
-
-  configureFlags = " --with-dots --with-gs-font-dir="+ ghostscript +
-		"/share/ghostscript/fonts --with-gslib " +(
-		if args ? tetex then " --with-frozenpaths " else ""
-		);
-
-  buildInputs = [bzip2 freetype ghostscript graphviz libjpeg libpng 
-		libtiff libX11 libxml2 zlib libtool] ++ (if args ? tetex then [args.tetex] else [])
-		 ++ (if args ? librsvg then [args.librsvg] else []);
-
-  meta = {
-    homepage = http://www.imagemagick.org;
-  };
-} // (if args ? tetex then {
-	preConfigure = "
-		export DVIDecodeDelegate=${args.tetex}/bin/dvips
-	";
-} else {}))
diff --git a/pkgs/applications/graphics/ImageMagick/6.3.9-0.nix b/pkgs/applications/graphics/ImageMagick/6.3.9-0.nix
deleted file mode 100644
index 17632f3c46a..00000000000
--- a/pkgs/applications/graphics/ImageMagick/6.3.9-0.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-args: with args;
-stdenv.mkDerivation (rec {
-  name = "ImageMagick-${version}";
-
-  src = fetchurl {
-    url = "ftp://ftp.imagemagick.org/pub/ImageMagick/${name}.tar.bz2";
-    sha256 = "0ynn8gxixjb16xhg60hp2sbfymh03y5qxxgffwlchciiylw9dlvd";
-  };
-
-  configureFlags = " --with-dots --with-gs-font-dir="+ ghostscript +
-		"/share/ghostscript/fonts --with-gslib " +(
-		if args ? tetex then " --with-frozenpaths " else ""
-		);
-
-  buildInputs = [bzip2 freetype ghostscript graphviz libjpeg libpng 
-		libtiff libX11 libxml2 zlib libtool] ++ (if args ? tetex then [args.tetex] else [])
-		 ++ (if args ? librsvg then [args.librsvg] else []);
-
-  meta = {
-    homepage = http://www.imagemagick.org;
-  };
-} // (if args ? tetex then {
-	preConfigure = "
-		export DVIDecodeDelegate=${args.tetex}/bin/dvips
-	";
-} else {}))
diff --git a/pkgs/applications/graphics/ImageMagick/default.nix b/pkgs/applications/graphics/ImageMagick/default.nix
new file mode 100644
index 00000000000..1050332cc28
--- /dev/null
+++ b/pkgs/applications/graphics/ImageMagick/default.nix
@@ -0,0 +1,35 @@
+args: with args;
+
+let version = "6.4.1-1"; in
+
+stdenv.mkDerivation (rec {
+  name = "ImageMagick-${version}";
+
+  src = fetchurl {
+    url = "mirror://imagemagick/${name}.tar.bz2";
+    sha256 = "0a8defbfa867bb5e969f898d9a3b65a8c4f6952cb71411b40f005dd0a183644e";
+  };
+
+  configureFlags = ''
+    --with-dots
+    --with-gs-font-dir=${ghostscript}/share/ghostscript/fonts
+    --with-gslib
+    ${if args ? tetex then "--with-frozenpaths" else ""}
+  '';
+
+  buildInputs =
+    [ bzip2 freetype ghostscript graphviz libjpeg libpng
+      libtiff libX11 libxml2 zlib libtool
+    ]
+    ++ stdenv.lib.optional (args ? tetex) args.tetex
+    ++ stdenv.lib.optional (args ? librsvg) args.librsvg;
+
+  preConfigure = if args ? tetex then
+    ''
+      export DVIDecodeDelegate=${args.tetex}/bin/dvips
+    '' else "";
+
+  meta = {
+    homepage = http://www.imagemagick.org;
+  };
+})
diff --git a/pkgs/applications/graphics/gimp/default.nix b/pkgs/applications/graphics/gimp/default.nix
index ffd32c49e11..aa5e28d42e0 100644
--- a/pkgs/applications/graphics/gimp/default.nix
+++ b/pkgs/applications/graphics/gimp/default.nix
@@ -4,10 +4,10 @@
 }:
 
 stdenv.mkDerivation {
-  name = "gimp-2.4.5";
+  name = "gimp-2.4.6";
   src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/gimp/v2.4/gimp-2.4.5.tar.bz2;
-    sha256 = "1bnm92n874vg9pva374an79g6gizkjb4ifdxy5r5a905wv117pys";
+    url = ftp://ftp.gtk.org/pub/gimp/v2.4/gimp-2.4.6.tar.bz2;
+    sha256 = "1shbrrncx99pbn66xpya0a55cv18g4lvl9spc3ry906z1vkzkblr";
   };
   
   buildInputs = [
diff --git a/pkgs/applications/graphics/pqiv/default.nix b/pkgs/applications/graphics/pqiv/default.nix
new file mode 100644
index 00000000000..72f338dcfeb
--- /dev/null
+++ b/pkgs/applications/graphics/pqiv/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, getopt, which, pkgconfig, gtk } :
+
+stdenv.mkDerivation (rec {
+  name = "pqiv-0.7.1";
+
+  src = fetchurl {
+    url = "http://www.pberndt.com/raw//Programme/Linux/pqiv/_download/pqiv-0.7.1.tbz";
+    sha256 = "659c5d1d12c080dff5152325a2391e01a2c9a6ea225d1f755a98e8766f318eef";
+  };
+
+  buildInputs = [ getopt which pkgconfig gtk ];
+
+  unpackCmd="bzip2 -d < $src | tar xvf - || fail";
+
+  preConfigure=''
+    substituteInPlace configure --replace /bin/bash "$shell"
+    sed -i -e 's|$(tempfile -s.*)|temp.c|' -e 's|tempfile|mktemp|' configure
+  '';
+
+  meta = {
+    description = "Rewrite of qiv (quick image viewer)";
+    homepage = http://www.pberndt.com/Programme/Linux/pqiv;
+  };
+})
diff --git a/pkgs/applications/misc/acrobat-reader/default.nix b/pkgs/applications/misc/acrobat-reader/default.nix
index 3c2e5bafeb2..bc14b0cb45d 100644
--- a/pkgs/applications/misc/acrobat-reader/default.nix
+++ b/pkgs/applications/misc/acrobat-reader/default.nix
@@ -8,18 +8,23 @@ assert stdenv.system == "i686-linux";
 
 stdenv.mkDerivation {
   name = "acrobat-reader-7.0.9";
+  
   builder = ./builder.sh;
+  
   src = fetchurl {
     url = http://ardownload.adobe.com/pub/adobe/reader/unix/7x/7.0.9/enu/AdobeReader_enu-7.0.9-1.i386.tar.gz;
     sha256 = "0qs8v57gamkk243f44yqxic93izf0bn2d9l4wwbqqy1jv5s125hy";
   };
+  
   libPath = [
     libXt libXp libXext libX11 glib pango atk gtk libstdcpp5 zlib
     (if xineramaSupport then libXinerama else null)
   ];
+  
   inherit fastStart;
-
+  
   meta = {
+    description = "Adobe Reader, a viewer for PDF documents";
     homepage = http://www.adobe.com/products/reader;
   };
 }
diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix
index aa50f67719c..81042e548c6 100644
--- a/pkgs/applications/misc/blender/default.nix
+++ b/pkgs/applications/misc/blender/default.nix
@@ -18,6 +18,14 @@ stdenv.mkDerivation {
   # or openEXR is broken. I think OpenEXR should use include "" isntead of <> to
   # include files beeing in the same directory
   buildPhase = "
+cat >> user-config.py << EOF
+WITH_BF_OPENAL = 'true'
+WITH_BF_GAMEENGINE='true'
+WITH_BF_BULLET = 'true'
+WITH_BF_INTERNATIONAL = 'true'
+WITH_BF_OPENEXR = 'true'
+EOF
+
     sed -i -e \"s=##### END SETUP ##########=env['CPPFLAGS'].append(os.getenv('CPPFLAGS').split(':'))\\n##### END SETUP ##########=\" SConstruct\n"
     + " CPPFLAGS=-I$openexr/include/OpenEXR"
     + " scons PREFIX=\$out/nix-support"
diff --git a/pkgs/applications/misc/gv/default.nix b/pkgs/applications/misc/gv/default.nix
index 4566761e690..160ebe33083 100644
--- a/pkgs/applications/misc/gv/default.nix
+++ b/pkgs/applications/misc/gv/default.nix
@@ -1,20 +1,22 @@
 { stdenv, fetchurl, Xaw3d, ghostscriptX }:
 
-stdenv.mkDerivation {
-  name = "gv-3.6.1";
+stdenv.mkDerivation rec {
+  name = "gv-3.6.4";
 
   src = fetchurl {
-    url = http://ftp.gnu.org/gnu/gv/gv-3.6.3.tar.gz;
-    sha256 = "9486c25675719e986cbd77b48204025e825c46258b6750deeb64b3940685a033";
+    url = "mirror://gnu/gv/${name}.tar.gz";
+    sha256 = "09v87h0fmpg7wid6b7wwcbl28x9m1wmn465hvpxs95wmn7nw98c2";
   };
 
   buildInputs = [ Xaw3d ghostscriptX ];
   
   postConfigure = [ "sed 's|\\<gs\\>|${ghostscriptX}/bin/gs|g' -i src/*.am src/*.ad" ];
 
-  inherit ghostscriptX;
+  doCheck = true;
 
   meta = {
-    homepage = http://wwwthep.physik.uni-mainz.de/~plass/gv;
+    homepage = http://www.gnu.org/software/gv/;
+    description = "GNU gv, a PostScript/PDF document viewer";
+    license = "GPLv2+";
   };
 }
diff --git a/pkgs/applications/misc/kiwixbuilder/default.nix b/pkgs/applications/misc/kiwixbuilder/default.nix
new file mode 100644
index 00000000000..cf10ca58c4b
--- /dev/null
+++ b/pkgs/applications/misc/kiwixbuilder/default.nix
@@ -0,0 +1,28 @@
+args : with args; with builderDefs {src="";} null;
+	let localDefs = builderDefs (rec {
+		src = /* put a fetchurl here */
+		fetchurl {
+			url = http://downloads.sourceforge.net/kiwix/kiwixbuilder.tgz;
+			sha256 = "0qb97smw4675i3hh328a7f65payw1w71bn4d32ycdkmqk56zl4ds";
+		};
+		buildInputs = [glib zlib];
+		configureFlags = [" --prefix=$out "];
+		preConfigure = FullDepEntry (''
+			export NIX_CFLAGS_COMPILE=$NIX_CFLAGS_COMPILE' -I${glib}/include/glib-2.0/ -I${glib}/lib/glib-2.0/include/ '
+			export NIX_LDFLAGS=$NIX_LDFLAGS' -lglib-2.0 '
+			sed -e 's@/usr/local/lib/libz\.a@${zlib}/lib/libz.a@' -i configure
+		'') ["minInit" "doUnpack"];
+	}) args null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "kiwix";
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs 
+			[preConfigure doConfigure doMakeInstall doForceShare doPropagate]);
+	meta = {
+		description = "
+		Offline Wikipedia viewer builder.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/misc/lyx/default.nix b/pkgs/applications/misc/lyx/default.nix
index 246b8caa3ca..a53b4a382a0 100644
--- a/pkgs/applications/misc/lyx/default.nix
+++ b/pkgs/applications/misc/lyx/default.nix
@@ -1,14 +1,14 @@
 # I haven't put much effort into this expressions .. so some optional depencencies may be missing - Marc
-args:
-args.stdenv.mkDerivation {
-  name = "lyx-1.5.3";
+args: with args;
+stdenv.mkDerivation {
+  name = "lyx-1.5.4";
 
-  src = args.fetchurl {
-    url = http://lyx.cybermirror.org/stable/lyx-1.5.3.tar.bz2;
-    sha256 = "1q0xlhrvj87iw9rk9z2vfka4jw5pw7n5fsmmiyzram9y4hghavav";
+  src = fetchurl {
+    url = http://lyx.cybermirror.org/stable/lyx-1.5.4.tar.bz2;
+    sha256 = "6c8b9aafc287ee683b68ebb08166e660e27af9942a30291f14c18de39aca8f2b";
   };
 
-  buildInputs =(with args; [tetex qt python]);
+  buildInputs = [texLive qt python];
 
   meta = { 
       description = "WYSIWYM frontend for LaTeX, DocBook, etc.";
diff --git a/pkgs/applications/misc/synergy/default.nix b/pkgs/applications/misc/synergy/default.nix
index 71bd7a80ee7..1912ef0dfe8 100644
--- a/pkgs/applications/misc/synergy/default.nix
+++ b/pkgs/applications/misc/synergy/default.nix
@@ -2,12 +2,15 @@ args: with args;
 stdenv.mkDerivation {
   name = "synergy-cvs";
 
-  src = fetchcvs {
+  src = bleedingEdgeRepos.sourceByName "synergy";
+  /*
+  fetchcvs {
     cvsRoot = ":pserver:anonymous@synergy2.cvs.sourceforge.net:/cvsroot/synergy2";
     module = "synergy";
     date = "NOW";
-    sha256 = "ef8e2ebfda6e43240051a7af9417092b2af50ece8b5c6c3fbd908ba91c4fe068";
+    sha256 = "0a52b3adaae5f41cf16c5911c9037c5f2ee704a27bcaa9f874e3a4ff58d773c1";
   };
+  */
 
   buildInputs = [x11 xextproto libXtst inputproto];
 
diff --git a/pkgs/applications/misc/taskjuggler/default.nix b/pkgs/applications/misc/taskjuggler/default.nix
new file mode 100644
index 00000000000..3812f7edd97
--- /dev/null
+++ b/pkgs/applications/misc/taskjuggler/default.nix
@@ -0,0 +1,69 @@
+{stdenv, fetchurl,
+zlib, libpng, perl, expat, qt,
+libX11, libXext, libSM, libICE,
+withKde, kdelibs, kdebase
+}:
+
+stdenv.mkDerivation rec {
+  name = "taskjuggler-2.4.1";
+  src = fetchurl {
+    url = "http://www.taskjuggler.org/download/${name}.tar.bz2";
+    md5 = "18e0cec8b2ec69220ae7c9a790c16819";
+  };
+
+  buildInputs =
+    [zlib libpng libX11 libXext libSM libICE perl expat]
+    ++ (if withKde then [kdelibs] else [])
+    ;
+
+  preConfigure = ''
+    for i in $(grep -R "/bin/bash" .  | sed 's/:.*//'); do
+      substituteInPlace $i --replace /bin/bash $(type -Pp bash)
+    done
+    for i in $(grep -R "/usr/bin/perl" .  | sed 's/:.*//'); do
+      substituteInPlace $i --replace /usr/bin/perl ${perl}/bin/perl
+    done
+
+    # Fix install
+    for i in docs/en/Makefile.in Examples/BigProject/Common/Makefile.in Examples/BigProject/Makefile.in Examples/BigProject/Project1/Makefile.in Examples/BigProject/Project2/Makefile.in Examples/FirstProject/Makefile.in Examples/ShiftSchedule/Makefile.in; do
+      # Do not use variable substitution because there is some text after the last '@'
+      substituteInPlace $i --replace 'docprefix = @PACKAGES_DIR@' 'docprefix = $(docdir)/'
+    done
+
+    # Comment because the ical export need the KDE support.
+    for i in Examples/FirstProject/AccountingSoftware.tjp; do
+      substituteInPlace $i --replace "icalreport" "# icalreport"
+    done
+  '';
+
+  configureFlags = "
+    --without-arts --disable-docs
+    --x-includes=${libX11}/include
+    --x-libraries=${libX11}/lib
+    --with-qt-dir=${qt}
+    --with-kde-support=${if withKde then "yes" else "no"}
+  ";
+
+  preInstall = ''
+    mkdir -p $out/share/emacs/site-lisp/
+    cp Contrib/emacs/taskjug.el $out/share/emacs/site-lisp/
+  '';
+
+  installFlags =
+    # kde_locale is not defined when installing without kde.
+    if withKde then "" else "kde_locale=\${out}/share/locale";
+
+  meta = {
+    homepage = "http://www.taskjuggler.org";
+    license = "GPLv2";
+    description = "Project management tool.";
+    longDescription = ''
+      TaskJuggler is a modern and powerful, Open Source project management
+      tool. Its new approach to project planing and tracking is more
+      flexible and superior to the commonly used Gantt chart editing
+      tools. It has already been successfully used in many projects and
+      scales easily to projects with hundreds of resources and thousands of
+      tasks.
+    '';
+  };
+}
diff --git a/pkgs/applications/misc/xchm/default.nix b/pkgs/applications/misc/xchm/default.nix
index d9ffe8515db..f67482ae5f0 100644
--- a/pkgs/applications/misc/xchm/default.nix
+++ b/pkgs/applications/misc/xchm/default.nix
@@ -3,8 +3,8 @@
 stdenv.mkDerivation {
   name = "xchm-1.9";
   src = fetchurl {
-    url = mirror://sourceforge/xchm/xchm-1.9.tar.gz;
-    md5 = "12e1faf49447c743c5c936636cd8a172";
+    url = mirror://sourceforge/xchm/xchm-1.14.tar.gz;
+    sha256 = "0gx8h8iabfrawx86f3im36favwl18afwx6z7w9gkjamihcm1an1w";
   };
   buildInputs = [wxGTK chmlib];
 
diff --git a/pkgs/applications/misc/xmobar/default.nix b/pkgs/applications/misc/xmobar/default.nix
new file mode 100644
index 00000000000..4e767177e29
--- /dev/null
+++ b/pkgs/applications/misc/xmobar/default.nix
@@ -0,0 +1,12 @@
+{cabal, X11}:
+
+cabal.mkDerivation (self : {
+  pname = "xmobar";
+  name = "${self.fname}";
+  version = "0.8";
+  sha256 = "88aa5bc0715e2592282e5897bc7938f16580804f56757bc71ed3762bf86c9415";
+  extraBuildInputs = [X11];
+  meta = {
+    description = "xmobar is a minimalistic text based status bar";
+  };
+})
diff --git a/pkgs/applications/misc/xneur/default.nix b/pkgs/applications/misc/xneur/default.nix
new file mode 100644
index 00000000000..79da06d5083
--- /dev/null
+++ b/pkgs/applications/misc/xneur/default.nix
@@ -0,0 +1,21 @@
+args: with args;
+
+stdenv.mkDerivation {
+  name="xneur";
+  src = fetchurl {
+    url = "http://dists.xneur.ru/release-0.8.0/tgz/xneur-0.8.0.tar.bz2";
+    sha256 = "1f05bm4vqdrlm8rxwgqv89k5lhc236xg841aw4snw514g0hi2sl8";
+  };
+
+  buildInputs = [libX11 pkgconfig pcre GStreamer glib libxml2 aspell];
+
+  preConfigure = "sed -e 's/-Werror//' -i configure";
+
+  meta = {
+    description = "xneur is the keyboard layout switcher.";
+  };
+
+}
+
+
+
diff --git a/pkgs/applications/networking/browsers/firefox-3/default.nix b/pkgs/applications/networking/browsers/firefox-3/default.nix
index 88315aa0c31..7f8f0eed65a 100644
--- a/pkgs/applications/networking/browsers/firefox-3/default.nix
+++ b/pkgs/applications/networking/browsers/firefox-3/default.nix
@@ -4,8 +4,10 @@ stdenv.mkDerivation {
   name = "firefox-3.0-beta-3";
 
   src = fetchurl {
-    url = ftp://ftp.mozilla.org/pub/firefox/releases/3.0b3/source/firefox-3.0b3-source.tar.bz2;
-    sha1 = "142f28a41077e77d61423a5ca6585a45737ff999";
+    url = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.0rc2/source/firefox-3.0rc2-source.tar.bz2;
+    #url = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.0b5/source/firefox-3.0b5-source.tar.bz2;
+    #url = ftp://ftp.mozilla.org/pub/firefox/releases/3.0b4/source/firefox-3.0b5-source.tar.bz2;
+    sha256 = "13g1ipnjxq4ssfj6f6pdp9rjdadb5sydfsgx6a5pqvxhzch5nq6i";
   };
 
   buildInputs = [
@@ -62,3 +64,4 @@ stdenv.mkDerivation {
   passthru = {inherit gtk;};
 }
 
+
diff --git a/pkgs/applications/networking/browsers/firefox/default.nix b/pkgs/applications/networking/browsers/firefox/default.nix
index 81545bc5bd1..e7c8b5095e8 100644
--- a/pkgs/applications/networking/browsers/firefox/default.nix
+++ b/pkgs/applications/networking/browsers/firefox/default.nix
@@ -10,12 +10,12 @@
 }:
 
 stdenv.mkDerivation {
-  name = "firefox-2.0.0.12";
+  name = "firefox-2.0.0.14";
 
   builder = ./builder.sh;
   src = fetchurl {
-    url = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.12/source/firefox-2.0.0.12-source.tar.bz2;
-    sha1 = "766f3e945145d9e4d36d5eb3e551b5eb44a1d862";
+    url = http://releases.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.14/source/firefox-2.0.0.14-source.tar.bz2;
+    sha256 = "af045b58ab560bb6535e5f63a1027dccab98ca123a1b161ddd4cc52fa505a901";
   };
 
   buildInputs = [
diff --git a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/default.nix b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/default.nix
index e14cfe2bea7..f039d86e4e5 100644
--- a/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/default.nix
+++ b/pkgs/applications/networking/browsers/mozilla-plugins/flashplayer-9/default.nix
@@ -3,12 +3,12 @@
 assert stdenv.system == "i686-linux";
 
 stdenv.mkDerivation {
-  name = "flashplayer-9.0.115.0";
+  name = "flashplayer-9.0.124.0";
 
   builder = ./builder.sh;
   src = fetchurl {
     url = http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_9_linux.tar.gz;
-    sha256 = "0yr2n7barlbvqxxzbvgp0pmbwwf7bvjksravqa47yra689jvynr7";
+    sha256 = "16p98jf3y9041p8fk6cq7dqj7s4l4m7g9nhvc3dmhmld0075qagl";
   };
 
   inherit zlib alsaLib;
diff --git a/pkgs/applications/networking/instant-messengers/bitlbee/default.nix b/pkgs/applications/networking/instant-messengers/bitlbee/default.nix
index ed36ca779b6..e7128d5ae71 100644
--- a/pkgs/applications/networking/instant-messengers/bitlbee/default.nix
+++ b/pkgs/applications/networking/instant-messengers/bitlbee/default.nix
@@ -1,10 +1,10 @@
 args: with args;
 
 stdenv.mkDerivation rec {
-  name = "bitlbee-1.0.4";
+  name = "bitlbee-1.2";
   src = fetchurl {
     url = "mirror://bitlbee/src/" + name + ".tar.gz";
-    sha256 = "072vdpz4z3bmskm04crrkj946hj0gnnd6w0vqrb7xmj1lrzg68vg";
+    sha256 = "ff69fa43445c833a34ea64c23178383e3abe98f2ec7e791ea0cf3913e4090bb8";
   };
 
   buildInputs = [ gnutls glib pkgconfig ];
diff --git a/pkgs/applications/networking/instant-messengers/funpidgin/2.4.1.nix b/pkgs/applications/networking/instant-messengers/funpidgin/2.4.1.nix
new file mode 100644
index 00000000000..8db711c2f6d
--- /dev/null
+++ b/pkgs/applications/networking/instant-messengers/funpidgin/2.4.1.nix
@@ -0,0 +1,29 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/funpidgin/funpidgin-2.4.1.tar.bz2;
+    sha256 = "1slzvgwaxl19fdyg7k12nqsvvbjaqv6ivfzwkbvm09596ag5r3mn";
+  };
+
+  buildInputs = [gtkspell aspell
+    GStreamer startupnotification
+    libxml2 openssl nss
+    libXScrnSaver ncurses scrnsaverproto 
+    libX11 xproto kbproto];
+
+  propagatedBuildInputs = [
+    pkgconfig gtk perl perlXMLParser gettext
+  ];
+
+  configureFlags="--with-nspr-includes=${nss}/include/nspr --with-nspr-libs=${nss}/lib --with-nss-includes=${nss}/include/nss --with-nss-libs=${nss}/lib --with-ncurses-headers=${ncurses}/include --enable-screensaver";
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "funpidgin-" + version;
+  meta = {
+    description = "Funpidgin - PidginIM fork with user-friendly development model";
+    homepage = http://funpidgin.sf.net; 
+  };
+}
+
diff --git a/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/default.nix b/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/default.nix
index 95664d0fbeb..930e2d108be 100644
--- a/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/default.nix
+++ b/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/default.nix
@@ -1,5 +1,5 @@
 {stdenv, fetchurl, pidgin, imagemagick, ghostscript,
-	pkgconfig, glib, gtk, tetex}:
+	pkgconfig, glib, gtk, texLive}:
 stdenv.mkDerivation {
   name = "pidgin-latex";
 
@@ -11,11 +11,12 @@ stdenv.mkDerivation {
 
   preBuild = "
   	sed -e '/^PREFIX/d' -i Makefile ; 
-	sed -e 's@/usr/bin/latex@${tetex}/bin/pdflatex@g' -i pidgin-latex.h
+	sed -e 's@/usr/bin/latex@${texLive}/bin/pdflatex@g' -i pidgin-latex.h
 	sed -e 's@/usr/bin/convert@${imagemagick}/bin/convert@g' -i pidgin-latex.h
 	sed -e 's@.*convert_path.*@const gchar *convert = CONVERT_PATH;@'
 	sed -e 's@.*latex_path.*@const gchar *convert = LATEX_PATH;@'
 	sed -e 's/%s.dvi/%s.pdf/' -i pidgin-latex.c
+	sed -e 's/latex_system\(.*\)FALSE/latex_system\1TRUE/' -i pidgin-latex.c
   ";
 
   makeFlags="PREFIX=\$(out)";
@@ -25,7 +26,7 @@ stdenv.mkDerivation {
   postInstall = "mkdir -p \${out}/share/pidgin-latex; 
 	ln -s \${out}/lib/pidgin/pidgin-latex.so \${out}/share/pidgin-latex/";
 
-  buildInputs = [pidgin imagemagick ghostscript pkgconfig glib gtk tetex];
+  buildInputs = [pidgin imagemagick ghostscript pkgconfig glib gtk texLive];
 
   meta = {
     description = "
diff --git a/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix b/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix
new file mode 100644
index 00000000000..aebede6301f
--- /dev/null
+++ b/pkgs/applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix
@@ -0,0 +1,42 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://mesh.dl.sourceforge.net/sourceforge/pidgin-latex/pidgin-latex-1.2.1.tar.bz2;
+    sha256 = "19h76fwsx5y30l5wda2930k10r385aipngfljz5bdi7b9y52lii7";
+  };
+
+  buildInputs = [texLive pkgconfig gtk imagemagick glib pidgin which];
+  configureFlags = [];
+  installFlags = [
+    "PREFIX=$out"
+  ];
+
+  preBuild = FullDepEntry (''
+    ensureDir $out/bin
+    ln -s $(which convert) $out/bin
+    ln -s $(which xelatex) $out/bin
+    ln -s $(which dvips) $out/bin
+
+    sed -e 's/-Wl,-soname//' -i Makefile
+    sed -e 's/\(PATH("\)latex/\1xelatex/' -i LaTeX.c
+    sed -e 's/|| execute(cmddvips, dvipsopts, 10) //' -i LaTeX.c
+    sed -e 's/  strcat([*]file_ps, "[.]ps");/  strcat(*file_ps, ".pdf");/' -i LaTeX.c
+    sed -e 's/\([*]convertopts\[5\]=[{]"\)\(\\"",\)/\1 -trim \2/' -i LaTeX.c
+    sed -e 's/\(#define HEADER ".*\)12pt\(.*\)"/\116pt\2\\\\usepackage{fontspec}\\\\usepackage{xunicode}"/' -i LaTeX.h
+  '') ["minInit" "addInputs" "defEnsureDir" "doUnpack"];
+
+  postInstall = FullDepEntry (''
+    ensureDir $out/lib
+    ensureDir $out/share/pidgin-latex
+    ln -s ../../lib/pidgin/LaTeX.so  $out/share/pidgin-latex 
+  '') ["minInit" "defEnsureDir" "doMakeInstall"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = [ "preBuild" "doMakeInstall" "postInstall"];
+      
+  name = "pidgin-latex-1.2.1";
+  meta = {
+    description = "LaTeX rendering plugin for Pidgin IM";
+    priority = "10";
+  };
+}
diff --git a/pkgs/applications/networking/instant-messengers/pidgin/default.nix b/pkgs/applications/networking/instant-messengers/pidgin/default.nix
index badf19f1994..12eb70e91f9 100644
--- a/pkgs/applications/networking/instant-messengers/pidgin/default.nix
+++ b/pkgs/applications/networking/instant-messengers/pidgin/default.nix
@@ -13,14 +13,14 @@
 { stdenv, fetchurl, pkgconfig, gtk, gtkspell, aspell,
   GStreamer, startupnotification, gettext,
   perl, perlXMLParser, libxml2, openssl, nss,
-  libXScrnSaver, ncurses
+  libXScrnSaver, ncurses, avahi, dbus, dbus_glib
 } :
 
 stdenv.mkDerivation {
-  name = "pidgin-2.4.0";
+  name = "pidgin-2.4.2";
   src = fetchurl {
-    url = mirror://sourceforge/pidgin/pidgin-2.4.0.tar.bz2;
-    sha256 = "1h8ydf5mg9swc78sf6fqd0vw5liw474jkjj7lfw7z9d2p9mfwdbf";
+    url = mirror://sourceforge/pidgin/pidgin-2.4.2.tar.bz2;
+    sha256 = "0pyih0kxa85imxjjjd15lchc7gfqazn72hvpwy1h1666hf48f29z";
   };
 
   inherit nss ncurses;
@@ -29,13 +29,14 @@ stdenv.mkDerivation {
     GStreamer startupnotification
     libxml2 openssl nss
     libXScrnSaver ncurses
+    avahi dbus dbus_glib
   ];
 
   propagatedBuildInputs = [
     pkgconfig gtk perl perlXMLParser gettext
   ];
 
-  configureFlags="--with-nspr-includes=${nss}/include/nspr --with-nspr-libs=${nss}/lib --with-nss-includes=${nss}/include/nss --with-nss-libs=${nss}/lib --with-ncurses-headers=${ncurses}/include";
+  configureFlags="--with-nspr-includes=${nss}/include/nspr --with-nspr-libs=${nss}/lib --with-nss-includes=${nss}/include/nss --with-nss-libs=${nss}/lib --with-ncurses-headers=${ncurses}/include --disable-meanwhile --disable-nm --disable-tcl";
   meta = {
     description = "Pidgin IM - XMPP(Jabber), AIM/ICQ, IRC, SIP etc client.";
     homepage = http://pidgin.im;
diff --git a/pkgs/applications/networking/instant-messengers/psi/0.11.nix b/pkgs/applications/networking/instant-messengers/psi/0.11.nix
new file mode 100644
index 00000000000..2f9d9e3b3b7
--- /dev/null
+++ b/pkgs/applications/networking/instant-messengers/psi/0.11.nix
@@ -0,0 +1,20 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = ftp://ftp.ru.debian.org/debian/pool/main/p/psi/psi_0.11.orig.tar.gz;
+    sha256 = "1rgjahngari4pwhi0zz9mricaaqxkk8ry8w6s1vgsq3zwa2l5x57";
+  };
+
+  buildInputs = [aspell qt zlib sox openssl libX11 xproto 
+    libSM libICE];
+  configureFlags = [" --with-zlib-inc=${zlib}/include "
+    " --with-openssl-inc=${openssl}/include "
+  ];
+
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "psi-" + version;
+  meta = {
+    description = "Psi, an XMPP (Jabber) client";
+  };
+}
diff --git a/pkgs/applications/networking/irc/konversation/default.nix b/pkgs/applications/networking/irc/konversation/default.nix
new file mode 100644
index 00000000000..0e200482834
--- /dev/null
+++ b/pkgs/applications/networking/irc/konversation/default.nix
@@ -0,0 +1,16 @@
+{stdenv, fetchurl, libX11, libXt, libXext, arts, qt, kdelibs, zlib, libpng, libjpeg, perl, expat}:
+
+stdenv.mkDerivation {
+  name = "konversation-1.0.1";
+  src = fetchurl {
+    url = http://download.berlios.de/konversation/konversation-1.0.1.tar.bz2;
+    sha256 = "8be736289c52c21fe5ada7dd153767abd5155424a510ab9781b9d2f585cc00fd";
+  };
+  buildInputs = [arts qt kdelibs libX11 libXt libXext zlib libpng libjpeg perl expat];
+  postConfigure = '' for i in `find . -name Makefile`; do echo $i; sed -i -e "s|-L/usr/lib||g" -e "s|\-R \$(x_libraries)||g" $i; done '';
+
+  meta = {
+    homepage = http://www.konversation.org;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/applications/networking/mailreaders/mutt/default.nix b/pkgs/applications/networking/mailreaders/mutt/default.nix
index c3b4fe54d02..1191441d1b2 100644
--- a/pkgs/applications/networking/mailreaders/mutt/default.nix
+++ b/pkgs/applications/networking/mailreaders/mutt/default.nix
@@ -1,23 +1,28 @@
 { stdenv, fetchurl, ncurses, which
 , sslSupport ? true
 , imapSupport ? true
+, headerCache ? true
+, gdbm ? null
 , openssl ? null
 }:
 
+assert headerCache -> gdbm != null;
 assert sslSupport -> openssl != null;
 
 stdenv.mkDerivation {
-  name = "mutt-1.5.15";
+  name = "mutt-1.5.16";
   src = fetchurl {
-    url = ftp://ftp.mutt.org/mutt/devel/mutt-1.5.15.tar.gz;
-    sha256 = "03fa1f45d4743cd395b634d19aebbc2c1918cf6b683e0af51076ccc79f643a9a";
+    url = ftp://ftp.mutt.org/mutt/devel/mutt-1.5.16.tar.gz;
+    sha256 = "825e920b394db6f56fa8deb45977c061331f59d953944e27ff595625bbad3e83";
   };
   buildInputs = [
     ncurses which
+    (if headerCache then gdbm else null)
     (if sslSupport then openssl else null)
   ];
   configureFlags = [
     "--with-mailpath="
+    (if headerCache then "--enable-hcache" else "--disable-hcache")
     (if sslSupport then "--with-ssl" else "--without-ssl")
     (if imapSupport then "--enable-imap" else "--disable-imap")
   ];
@@ -26,3 +31,4 @@ stdenv.mkDerivation {
     homepage = http://www.mutt.org;
   };
 }
+
diff --git a/pkgs/applications/networking/mailreaders/thunderbird-2.x/default.nix b/pkgs/applications/networking/mailreaders/thunderbird-2.x/default.nix
index 7032333b888..bd8c36bd83a 100644
--- a/pkgs/applications/networking/mailreaders/thunderbird-2.x/default.nix
+++ b/pkgs/applications/networking/mailreaders/thunderbird-2.x/default.nix
@@ -11,12 +11,12 @@
 }:
 
 stdenv.mkDerivation {
-  name = "thunderbird-2.0.0.12";
+  name = "thunderbird-2.0.0.14";
 
   builder = ./builder.sh;
   src = fetchurl {
-    url = http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/2.0.0.12/source/thunderbird-2.0.0.12-source.tar.bz2;
-    sha1 = "36ea64353d32a9f138ef658250cfdcf8f9e862f2";
+    url = ftp://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/2.0.0.14/source/thunderbird-2.0.0.14-source.tar.bz2;
+    sha256 = "0c4pg2fl83916923xvzn1nyhc1iz4nfn7034vnjchd27pq03zbny";
   };
 
   buildInputs = [
diff --git a/pkgs/applications/networking/p2p/ldcpp/1.0.1.nix b/pkgs/applications/networking/p2p/ldcpp/1.0.1.nix
new file mode 100644
index 00000000000..ea1f6b1b84b
--- /dev/null
+++ b/pkgs/applications/networking/p2p/ldcpp/1.0.1.nix
@@ -0,0 +1,31 @@
+args : with args; with builderDefs {src="";} null;
+	let localDefs = builderDefs (rec {
+		src = /* put a fetchurl here */
+		fetchurl {
+			url = http://download2.berlios.de/linuxdcpp/linuxdcpp-1.0.1.tar.bz2;
+			sha256 = "0f0vvsa3x3nirqnf2lagpmbbj3pgdcp6wa2gvadj294b3va4hx34";
+		};
+
+		buildInputs = [scons pkgconfig gtk bzip2 pkgconfig libglade
+			openssl libX11];
+		configureFlags = [];
+		doScons = FullDepEntry (''
+			ensureDir $out
+			export NIX_LDFLAGS="$NIX_LDFLAGS -lX11";
+			scons PREFIX=$out 
+			scons PREFIX=$out install
+		'') ["minInit" "doUnpack" "addInputs" "defEnsureDir"];
+	}) args null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "ldcpp-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs 
+			[doScons doForceShare doPropagate]);
+	meta = {
+		description = "
+		Linux DC++ - Direct Connect client
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/networking/skype/default.nix b/pkgs/applications/networking/skype/default.nix
index 285cba82a3f..25ab4f77d84 100644
--- a/pkgs/applications/networking/skype/default.nix
+++ b/pkgs/applications/networking/skype/default.nix
@@ -1,18 +1,36 @@
 args: with args;
-stdenv.mkDerivation {
+stdenv.mkDerivation ( rec {
+  pname = "skype";
+  version = "1.4.0.118";
   name = "skype-1.4";
 
   src = fetchurl {
     url = http://www.skype.com/go/getskype-linux-static;
-    sha256 = "0k71byzaipmw8lb92aad4qyh9rk0fnn3za74v1h268h09gkkd8mz";
-    name = "skype_static-1.4.0.99.tar.bz2";
+    sha256 = "1293f54811a36b2a1b83c56a4ad2844e58c753fe39b61422fac66b001d0f9e0c";
+    name = "${pname}_static-${version}.tar.bz2";
   };
 
-  buildInputs = [alsaLib glibc libSM libICE libXi libXrender libXrandr libXfixes 
-      libXcursor libXinerama freetype fontconfig libXext libX11 
-    fontconfig libXinerama libsigcxx gcc41.gcc ];
+  buildInputs = [
+    alsaLib 
+    glibc 
+    gcc.gcc
+    libSM 
+    libICE 
+    libXi 
+    libXrender 
+    libXrandr 
+    libXfixes 
+    libXcursor 
+    libXinerama 
+    freetype 
+    fontconfig 
+    libXext 
+    libX11 
+    fontconfig 
+    libsigcxx 
+  ];
 
-  phases = "installPhase";
+  phases = "unpackPhase installPhase";
   installPhase ="
 
     ensureDir \$out/{opt/skype/,bin};
@@ -41,4 +59,4 @@ done
       homepage = http://www.skype.com;
       license = "skype-eula";
   };
-}
+})
diff --git a/pkgs/applications/networking/sniffers/wireshark/default.nix b/pkgs/applications/networking/sniffers/wireshark/default.nix
index 67318531371..d3876db24c5 100644
--- a/pkgs/applications/networking/sniffers/wireshark/default.nix
+++ b/pkgs/applications/networking/sniffers/wireshark/default.nix
@@ -1,10 +1,10 @@
-{stdenv, fetchurl, perl, pkgconfig, gtk, libpcap}:
+{stdenv, fetchurl, perl, pkgconfig, gtk, libpcap, flex, bison}:
 
 stdenv.mkDerivation {
-  name = "wireshark-0.99.7";
+  name = "wireshark-1.0.0";
   src = fetchurl {
-    url = http://www.wireshark.org/download/src/wireshark-0.99.7.tar.bz2;
-    sha256 = "10pb2mn6p40gsq2nbnqdzihrpa078jdgxqh8l4zs33bxa1h37frc";
+    url = http://www.wireshark.org/download/src/all-versions/wireshark-1.0.0.tar.bz2;
+    sha256 = "1l4zrmxf3i2i8a5f953pbbpy1c44d1q3r79hbzq7q9x78vhi6ixm";
   };
-  buildInputs = [perl pkgconfig gtk libpcap];
+  buildInputs = [perl pkgconfig gtk libpcap flex bison];
 }
diff --git a/pkgs/applications/networking/sync/rsync/default.nix b/pkgs/applications/networking/sync/rsync/default.nix
index 8393ed5df2f..494d3506a64 100644
--- a/pkgs/applications/networking/sync/rsync/default.nix
+++ b/pkgs/applications/networking/sync/rsync/default.nix
@@ -1,9 +1,9 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "rsync-2.6.9";
+  name = "rsync-3.0.0";
   src = fetchurl {
-    url = http://rsync.samba.org/ftp/rsync/rsync-2.6.9.tar.gz;
-    sha256 = "1y9kwsyxfgcv2kzlh6bnm95mdwcz30wrmihb61rhx2fdpq0p6hya";
+    url = http://rsync.samba.org/ftp/rsync/src/rsync-3.0.0.tar.gz;
+    sha256 = "0sd11rb5cpa5a2dl3h7cn1q4nmdkc07hf9vr3yvrkqwxpfspss8p";
   };
 }
diff --git a/pkgs/applications/networking/sync/unison/default.nix b/pkgs/applications/networking/sync/unison/default.nix
index 0883c236d01..7c735b8954c 100644
--- a/pkgs/applications/networking/sync/unison/default.nix
+++ b/pkgs/applications/networking/sync/unison/default.nix
@@ -1,15 +1,18 @@
 {stdenv, fetchurl, ocaml, lablgtk, fontschumachermisc, xset, makeWrapper}:
 
-stdenv.mkDerivation {
+stdenv.mkDerivation (rec {
+
   name = "unison-2.13.16";
   src = fetchurl {
-    url = http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.13.16.tar.gz;
+    url = "http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/${name}.tar.gz";
     sha256 = "808400a933aeb67654edc770822cd186d1b2adc92e7cb5836996c71c69ffe656";
   };
 
   buildInputs = [ocaml makeWrapper];
 
-  preBuild = "sed -i \"s|\\(OCAMLOPT=.*\\)$|\\1 -I ${lablgtk}/lib/ocaml/lablgtk2|\" Makefile.OCaml";
+  preBuild = ''
+    sed -i "s|\(OCAMLOPT=.*\)$|\1 -I ${lablgtk}/lib/ocaml/lablgtk2|" Makefile.OCaml
+  '';
   makeFlags = "UISTYLE=gtk2 INSTALLDIR=$(out)/bin/";
   preInstall = "ensureDir $out/bin";
   postInstall = ''
@@ -18,4 +21,5 @@ stdenv.mkDerivation {
         --run "${xset}/bin/xset q | grep -q \"${fontschumachermisc}\" || ${xset}/bin/xset +fp \"${fontschumachermisc}/lib/X11/fonts/misc\""
     done
   '';
-}
+
+})
diff --git a/pkgs/applications/office/abiword/builder.sh b/pkgs/applications/office/abiword/builder.sh
deleted file mode 100644
index aa9955d6e37..00000000000
--- a/pkgs/applications/office/abiword/builder.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-source $stdenv/setup
-
-preConfigure() {
-  cd abi
-}
-
-preConfigure=preConfigure
-
-genericBuild
diff --git a/pkgs/applications/office/abiword/default.nix b/pkgs/applications/office/abiword/default.nix
index 76ae26b8b36..fca38eff225 100644
--- a/pkgs/applications/office/abiword/default.nix
+++ b/pkgs/applications/office/abiword/default.nix
@@ -1,16 +1,16 @@
 {stdenv, fetchurl, pkgconfig, gtk, libglade, libgnomeprint,
-libgnomeprintui, libgnomecanvas, fribidi, libpng, popt
+libgnomeprintui, libgnomecanvas, fribidi, libpng, popt, libgsf,
+enchant, wv
 }:
 
 stdenv.mkDerivation {
-  name = "abiword-2.4.6";
-  builder = ./builder.sh;
+  name = "abiword-2.6.3";
   src = fetchurl {
-    url = http://www.abisource.com/downloads/abiword/2.4.6/source/abiword-2.4.6.tar.gz;
-    sha256 = "1lzyl9nd545jga1hh5c67kdqajp60i5xc67wvg6jcgzkn41my44q";
+    url = http://www.abisource.com/downloads/abiword/2.6.3/source/abiword-2.6.3.tar.gz;
+    sha256 = "1v4hvnlf5x9q4w3w4yvv712hsajmhv8dpndbni623ag24g2frzz5";
   };
 
   buildInputs = [pkgconfig gtk libglade libgnomeprint libgnomeprintui
-                 libgnomecanvas fribidi libpng popt
+                 libgnomecanvas fribidi libpng popt libgsf enchant wv
                 ];
 }
diff --git a/pkgs/applications/science/biology/clustalw2/default.nix b/pkgs/applications/science/biology/clustalw2/default.nix
new file mode 100644
index 00000000000..6c21f3cafda
--- /dev/null
+++ b/pkgs/applications/science/biology/clustalw2/default.nix
@@ -0,0 +1,21 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "clustalw2-2.0.5";
+  src = fetchurl {
+    url = ftp://ftp.ebi.ac.uk/pub/software/clustalw2/clustalw-2.0.5-src.tar.gz;
+    sha256 = "0sh40ni53jdnb0pbnlhrfcan8dfsgqi9zsas2z24bhcw71yvn8ba";
+  };
+
+  meta = {
+    description     = "General purpose multiple sequence alignment program for DNA or proteins";
+    longDescription = ''ClustalW2 is a general purpose multiple sequence
+    alignment program for DNA or proteins. It produces biologically meaningful
+    multiple sequence alignments of divergent sequences. It calculates the best
+    match for the selected sequences, and lines them up so that the identities,
+    similarities and differences can be seen.  Evolutionary relationships can
+    be seen via viewing Cladograms or Phylograms.'';
+    license     = "non-commercial";
+    homepage    = http://www.ebi.ac.uk/Tools/clustalw2/;
+  };
+}
diff --git a/pkgs/applications/science/biology/emboss/default.nix b/pkgs/applications/science/biology/emboss/default.nix
new file mode 100644
index 00000000000..427eb0a432e
--- /dev/null
+++ b/pkgs/applications/science/biology/emboss/default.nix
@@ -0,0 +1,30 @@
+{stdenv, fetchurl, readline, perl, libX11, libpng, libXt, zlib}:
+
+stdenv.mkDerivation {
+  name = "emboss-5.0.0-9";
+  src = fetchurl {
+    url = ftp://emboss.open-bio.org/pub/EMBOSS/EMBOSS-5.0.0.tar.gz;
+    sha256 = "1bj0bxfj97cgnk3w3123cqn5sq5xsbvzs8bzvqkgy6d7hadz1rk4";
+  };
+  patch = fetchurl {
+    url = ftp://emboss.open-bio.org/pub/EMBOSS/fixes/patches/patch-1-9.gz;
+    sha256 = "1pfn5zdxrr71c3kwpdkzmmsqvdwkmynkvcr707vqh73h9cjhk3c1";
+  };
+
+  buildInputs = [readline perl libpng libX11 libXt zlib];
+
+  preConfigure = ''
+    gzip -d $patch | patch -p1
+  '';
+
+  meta = {
+    description     = "EMBOSS is 'The European Molecular Biology Open Software Suite'";
+    longDescription = ''EMBOSS is a free Open Source software analysis package
+    specially developed for the needs of the molecular biology (e.g. EMBnet)
+    user community. The software automatically copes with data in a variety of
+    formats and even allows transparent retrieval of sequence data from the
+    web.'';
+    license     = "GPL2";
+    homepage    = http://emboss.sourceforge.net/;
+  };
+}
diff --git a/pkgs/applications/science/biology/mrbayes/builder.sh b/pkgs/applications/science/biology/mrbayes/builder.sh
new file mode 100644
index 00000000000..5b3a54946fc
--- /dev/null
+++ b/pkgs/applications/science/biology/mrbayes/builder.sh
@@ -0,0 +1,9 @@
+# builder for mrbayes - note: only builds on Unix
+
+source $stdenv/setup
+
+tar xvfz $src
+cd mrbayes-*
+make
+mkdir -p $out/bin
+cp -v mb $out/bin
diff --git a/pkgs/applications/science/biology/mrbayes/default.nix b/pkgs/applications/science/biology/mrbayes/default.nix
new file mode 100644
index 00000000000..78295faf69a
--- /dev/null
+++ b/pkgs/applications/science/biology/mrbayes/default.nix
@@ -0,0 +1,20 @@
+{stdenv, fetchurl, readline}:
+
+stdenv.mkDerivation rec {
+  # FIXME: replace Makefile so we can build MPI & MAC support
+
+  name = "mrbayes-3.1.2";
+  src = fetchurl {
+    url = "mirror://sourceforge/mrbayes/${name}.tar.gz";
+    sha256 = "1x7j8ca5wjrqrxmcpvd375ydm3s2pbkzykv8xfhg1jc037g560n6";
+  };
+  builder = ./builder.sh;
+  buildInputs = [readline];
+
+  meta = {
+    description     = "Bayesian Inference of Phylogeny";
+    longDescription = ''Bayesian inference of phylogeny is based upon a quantity called the posterior probability distribution of trees, which is the probability of a tree conditioned on the observations. The conditioning is accomplished using Bayes's theorem. The posterior probability distribution of trees is impossible to calculate analytically; instead, MrBayes uses a simulation technique called Markov chain Monte Carlo (or MCMC) to approximate the posterior probabilities of trees.'';
+    license     = "GPL2";
+    homepage    = http://mrbayes.csit.fsu.edu/;
+  };
+}
diff --git a/pkgs/applications/science/biology/ncbi-tools/default.nix b/pkgs/applications/science/biology/ncbi-tools/default.nix
new file mode 100644
index 00000000000..43dc25d13fb
--- /dev/null
+++ b/pkgs/applications/science/biology/ncbi-tools/default.nix
@@ -0,0 +1,22 @@
+{stdenv, fetchurl, cpio}:
+
+# Note: may need the C-libs at ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools++/2008/Mar_17_2008/NCBI_C_Toolkit/ncbi_c--Mar_17_2008.tar.gz (or split out?)
+
+stdenv.mkDerivation rec {
+  name = "ncbi_cxx";
+  ncbi_version = "Mar_17_2008";
+  src = fetchurl {
+    url = "ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools++/2008/${ncbi_version}/ncbi_cxx--${ncbi_version}.tar.gz";
+    sha256 = "0mxbmz6gndallz8l5jdslq6illa3hgf31xi2yb984mqm9in485as";
+  };
+
+  configureFlags = "--without-debug --with-bin-release --with-dll --without-static";
+  buildInputs = [cpio];
+
+  meta = {
+    description = ''NCBI Bioinformatics toolbox (incl. blast)'';
+    longDescription = ''The NCBI Bioinformatics toolsbox, including command-line utilties, libraries and include files. No X11 support (at this point).'';
+    homepage = http://www.ncbi.nlm.nih.gov/IEB/ToolBox/; 
+    license = "GPL";
+  };
+}
diff --git a/pkgs/applications/science/biology/paml/default.nix b/pkgs/applications/science/biology/paml/default.nix
new file mode 100644
index 00000000000..8e900d7ad3d
--- /dev/null
+++ b/pkgs/applications/science/biology/paml/default.nix
@@ -0,0 +1,32 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "paml";
+  src = fetchurl {
+    url = http://abacus.gene.ucl.ac.uk/software/paml4b.tar.gz;
+    sha256 = "0jm9smbkwycwchv6a98yh5xmfw7167p59zpzi5sjz0ka4y7vp3ib";
+  };
+
+  preBuild = ''
+    cd ./src/
+  '';
+  installPhase = ''
+    mkdir -pv $out/bin
+    cp -v codeml $out/bin 
+    cp -v baseml $out/bin
+    cp -v basemlg $out/bin
+    cp -v chi2 $out/bin
+    cp -v codeml $out/bin
+    cp -v evolver $out/bin
+    cp -v mcmctree $out/bin
+    cp -v pamp $out/bin
+    cp -v yn00 $out/bin
+  '';
+
+  meta = {
+    description     = "Phylogenetic Analysis by Maximum Likelihood (PAML)";
+    longDescription = ''PAML is a package of programs for phylogenetic analyses of DNA or protein sequences using maximum likelihood. It is maintained and distributed for academic use free of charge by Ziheng Yang. ANSI C source codes are distributed for UNIX/Linux/Mac OSX, and executables are provided for MS Windows. PAML is not good for tree making. It may be used to estimate parameters and test hypotheses to study the evolutionary process, when you have reconstructed trees using other programs such as PAUP*, PHYLIP, MOLPHY, PhyML, RaxML, etc.'';
+    license     = "non-commercial";
+    homepage    = http://abacus.gene.ucl.ac.uk/software/paml.html; 
+  };
+}
diff --git a/pkgs/applications/science/logic/coq/default.nix b/pkgs/applications/science/logic/coq/default.nix
new file mode 100644
index 00000000000..475c68f7b9c
--- /dev/null
+++ b/pkgs/applications/science/logic/coq/default.nix
@@ -0,0 +1,23 @@
+{stdenv, fetchurl, ocaml, ncurses}:
+
+stdenv.mkDerivation (rec {
+
+  name = "coq-8.1pl3";
+  src = fetchurl {
+    url = "http://coq.inria.fr/V8.1pl3/files/coq-8.1pl3.tar.gz";
+    sha256 = "7f8f45594adff2625312c5ecb144cb00d39c99201dac309c9286b34d01a36bb6";
+  };
+
+  buildInputs = [ocaml ncurses];
+
+  prefixKey = "-prefix ";
+  patchPhase = ''
+    UNAME=$(type -tp uname)
+    MV=$(type -tp mv)
+    RM=$(type -tp cp)
+    substituteInPlace ./configure --replace "/bin/uname" "$UNAME"
+    substituteInPlace Makefile --replace "/bin/mv" "$MV" \
+                               --replace "/bin/rm" "$RM"
+  '';
+
+})
diff --git a/pkgs/applications/taxes/aangifte-2007/builder.sh b/pkgs/applications/taxes/aangifte-2007/builder.sh
new file mode 100644
index 00000000000..e2d2658024a
--- /dev/null
+++ b/pkgs/applications/taxes/aangifte-2007/builder.sh
@@ -0,0 +1,21 @@
+source $stdenv/setup
+
+echo $NIX_GCC
+
+buildPhase=buildPhase
+buildPhase() {
+    for i in bin/*; do
+        patchelf \
+            --set-interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
+            --set-rpath $libX11/lib:$libXext/lib:$libSM/lib:$(cat $NIX_GCC/nix-support/orig-gcc)/lib \
+            $i
+    done
+}
+
+installPhase=installPhase
+installPhase() {
+    ensureDir $out
+    cp -prvd * $out/
+}
+
+genericBuild
\ No newline at end of file
diff --git a/pkgs/applications/taxes/aangifte-2007/default.nix b/pkgs/applications/taxes/aangifte-2007/default.nix
new file mode 100644
index 00000000000..3cd472b51c2
--- /dev/null
+++ b/pkgs/applications/taxes/aangifte-2007/default.nix
@@ -0,0 +1,21 @@
+{stdenv, fetchurl, libX11, libXext, libSM}:
+
+stdenv.mkDerivation {
+  name = "aangifte2007-1";
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = http://download.belastingdienst.nl/belastingdienst/apps/linux/ib2007_linux.tar.gz;
+    sha256 = "13p3gv086jn95wvmfygdmk9qjn0qxqdv7pp0v5pmw6i5hp8rmjxf";
+  };
+
+  inherit libX11 libXext libSM;
+
+  dontStrip = true;
+  dontPatchELF = true;
+
+  meta = {
+    description = "Elektronische aangifte IB 2007";
+    url = "http://www.belastingdienst.nl/download/1341.html";
+  };
+}
diff --git a/pkgs/applications/version-management/bazaar/default.nix b/pkgs/applications/version-management/bazaar/default.nix
index 71134c0841a..c2b5306b2e2 100644
--- a/pkgs/applications/version-management/bazaar/default.nix
+++ b/pkgs/applications/version-management/bazaar/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, python, makeWrapper}:
 
 stdenv.mkDerivation {
-  name = "bazaar-1.1";
+  name = "bazaar-1.5";
 
   src = fetchurl {
-    url = https://launchpad.net/bzr/1.1/1.1/+download/bzr-1.1.tar.gz;
-    sha256 = "1qpkw580r22yxybdghx2ha0kyk22brbhd1kg9wwjh209dqy2gqzc";
+    url = http://launchpad.net/bzr/1.5/1.5/+download/bzr-1.5.tar.gz;
+    sha256 = "0wacjmnil5pivkcqz3jcqfqh258yrwv33fg2p8vf45pbmr7yw0bv";
   };
 
   buildInputs = [python makeWrapper];
@@ -15,6 +15,11 @@ stdenv.mkDerivation {
     wrapProgram $out/bin/bzr --prefix PYTHONPATH : "$(toPythonPath $out)"
   '';
 
+  passthru = {
+    # If someone wants to assert python features..
+    inherit python;
+  };
+
   meta = {
     homepage = http://bazaar-vcs.org/;
     description = "A distributed version control system that Just Works";
diff --git a/pkgs/applications/version-management/bazaar/tools.nix b/pkgs/applications/version-management/bazaar/tools.nix
new file mode 100644
index 00000000000..c36ac2d63dc
--- /dev/null
+++ b/pkgs/applications/version-management/bazaar/tools.nix
@@ -0,0 +1,23 @@
+args : with args; 
+
+if ! bazaar.python.readlineSupport then 
+  throw "Bazaar Tools require readline support in python."
+else
+
+rec {
+  src = fetchurl {
+    url = http://launchpad.net/bzrtools/stable/1.5.0/+download/bzrtools-1.5.0.tar.gz;
+    sha256 = "0lm4qhsjy3k8zp9hcahlf37v69w6lhhz2x3hjskgm3rk6b0bngjz";
+  };
+
+  buildInputs = [];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = [(simplyShare "bzrtools")];
+      
+  name = "bzr-tools-1.5";
+  meta = {
+    description = "Bazaar plugins.";
+  };
+}
diff --git a/pkgs/applications/version-management/codeville/0.8.0.nix b/pkgs/applications/version-management/codeville/0.8.0.nix
new file mode 100644
index 00000000000..57552bac2fc
--- /dev/null
+++ b/pkgs/applications/version-management/codeville/0.8.0.nix
@@ -0,0 +1,23 @@
+args : with args; 
+
+if (! python ? db4Support) || (! python.db4Support) then 
+  throw ''Python DB4 support is required for codeville.'' 
+else
+
+rec {
+  src = fetchurl {
+    url = http://codeville.org/download/Codeville-0.8.0.tar.gz;
+    sha256 = "1p8zc4ijwcwf5bxl34n8d44mlxk1zhbpca68r93ywxqkqm2aqz37";
+  };
+
+  buildInputs = [python makeWrapper];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["installPythonPackage" (makeManyWrappers ''$out/bin/*'' ''--prefix PYTHONPATH : $(toPythonPath $out)'')];
+      
+  name = "codeville-" + version;
+  meta = {
+    description = "Codeville - RCS with powerful merge.";
+  };
+}
diff --git a/pkgs/applications/version-management/cvs/default.nix b/pkgs/applications/version-management/cvs/default.nix
index cb6a4dbf6f8..80b27b8376a 100644
--- a/pkgs/applications/version-management/cvs/default.nix
+++ b/pkgs/applications/version-management/cvs/default.nix
@@ -1,11 +1,12 @@
-{stdenv, fetchurl, vim}:
+{ stdenv, fetchurl, nano }:
 
 stdenv.mkDerivation {
   name = "cvs-1.12.13";
 
   src = fetchurl {
     url = http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2;
-    md5 = "956ab476ce276c2d19d583e227dbdbea";
+    sha256 = "0pjir8cwn0087mxszzbsi1gyfc6373vif96cw4q3m1x6p49kd1bq";
   };
-  buildInputs = [vim];
+
+  buildInputs = [ nano ];
 }
diff --git a/pkgs/applications/version-management/cvsps/01_ignoretrunk.dpatch b/pkgs/applications/version-management/cvsps/01_ignoretrunk.dpatch
new file mode 100644
index 00000000000..39185ae2bfa
--- /dev/null
+++ b/pkgs/applications/version-management/cvsps/01_ignoretrunk.dpatch
@@ -0,0 +1,23 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 01_ignoretrunk.dpatch by  <crafterm@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Ignore TRUNK branch name patch
+
+@DPATCH@
+
+diff -urN cvsps-2.1.orig/cvsps.c cvsps-2.1/cvsps.c
+--- cvsps-2.1.orig/cvsps.c	2005-05-25 22:39:40.000000000 -0500
++++ cvsps-2.1/cvsps.c	2005-06-19 23:07:20.000000000 -0500
+@@ -2104,6 +2109,11 @@
+     
+     if (!get_branch_ext(rev, eot, &leaf))
+     {
++	if (strcmp(tag, "TRUNK") == 0)
++	{
++	    debug(DEBUG_STATUS, "ignoring the TRUNK branch/tag");
++	    return;
++	}
+ 	debug(DEBUG_APPERROR, "malformed revision");
+ 	exit(1);
+     }
diff --git a/pkgs/applications/version-management/cvsps/02_dynamicbufferalloc.dpatch b/pkgs/applications/version-management/cvsps/02_dynamicbufferalloc.dpatch
new file mode 100644
index 00000000000..70ffb02a21a
--- /dev/null
+++ b/pkgs/applications/version-management/cvsps/02_dynamicbufferalloc.dpatch
@@ -0,0 +1,125 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 02_dynamicbufferalloc.dpatch by  <crafterm@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Dynamic buffer allocation
+
+@DPATCH@
+
+diff -urN cvsps-2.1-orig/cache.c cvsps-2.1/cache.c
+--- cvsps-2.1-orig/cache.c	2005-05-25 22:39:40.000000000 -0500
++++ cvsps-2.1/cache.c	2005-07-26 15:21:29.716569500 -0500
+@@ -108,10 +108,19 @@
+     int tag_flags = 0;
+     char branchbuff[LOG_STR_MAX] = "";
+     int branch_add = 0;
+-    char logbuff[LOG_STR_MAX] = "";
++    int logbufflen = LOG_STR_MAX + 1;
++    char * logbuff = malloc(logbufflen);
+     time_t cache_date = -1;
+     int read_version;
+ 
++    if (logbuff == NULL)
++    {
++	debug(DEBUG_SYSERROR, "could not malloc %d bytes for logbuff in read_cache", logbufflen);
++	exit(1);
++    }
++
++    logbuff[0] = 0;
++
+     if (!(fp = cache_open("r")))
+ 	goto out;
+ 
+@@ -299,8 +308,19 @@
+ 	    else
+ 	    {
+ 		/* Make sure we have enough in the buffer */
+-		if (strlen(logbuff)+strlen(buff)<LOG_STR_MAX)
+-		    strcat(logbuff, buff);
++		int len = strlen(buff);
++		if (strlen(logbuff) + len >= LOG_STR_MAX)
++		{
++		    logbufflen += (len >= LOG_STR_MAX ? (len+1) : LOG_STR_MAX);
++		    char * newlogbuff = realloc(logbuff, logbufflen);
++		    if (newlogbuff == NULL)
++		    {
++			debug(DEBUG_SYSERROR, "could not realloc %d bytes for logbuff in read_cache", logbufflen);
++			exit(1);
++		    }
++		    logbuff = newlogbuff;
++		}
++		strcat(logbuff, buff);
+ 	    }
+ 	    break;
+ 	case CACHE_NEED_PS_MEMBERS:
+@@ -332,6 +352,7 @@
+  out_close:
+     fclose(fp);
+  out:
++    free(logbuff);
+     return cache_date;
+ }
+ 
+diff -urN cvsps-2.1-orig/cvsps.c cvsps-2.1/cvsps.c
+--- cvsps-2.1-orig/cvsps.c	2005-05-25 22:39:40.000000000 -0500
++++ cvsps-2.1/cvsps.c	2005-07-26 15:22:02.558230700 -0500
+@@ -265,7 +265,8 @@
+     PatchSetMember * psm = NULL;
+     char datebuff[20];
+     char authbuff[AUTH_STR_MAX];
+-    char logbuff[LOG_STR_MAX + 1];
++    int logbufflen = LOG_STR_MAX + 1;
++    char * logbuff = malloc(logbufflen);
+     int loglen = 0;
+     int have_log = 0;
+     char cmd[BUFSIZ];
+@@ -273,6 +274,12 @@
+     char use_rep_buff[PATH_MAX];
+     char * ltype;
+ 
++    if (logbuff == NULL)
++    {
++	debug(DEBUG_SYSERROR, "could not malloc %d bytes for logbuff in load_from_cvs", logbufflen);
++	exit(1);
++    }
++
+     if (!no_rlog && !test_log_file && cvs_check_cap(CAP_HAVE_RLOG))
+     {
+ 	ltype = "rlog";
+@@ -480,24 +487,22 @@
+ 		 */
+ 		if (have_log || !is_revision_metadata(buff))
+ 		{
+-		    /* if the log buffer is full, that's it.  
+-		     * 
+-		     * Also, read lines (fgets) always have \n in them
+-		     * which we count on.  So if truncation happens,
+-		     * be careful to put a \n on.
+-		     * 
+-		     * Buffer has LOG_STR_MAX + 1 for room for \0 if
+-		     * necessary
+-		     */
+-		    if (loglen < LOG_STR_MAX)
++		    /* If the log buffer is full, try to reallocate more. */
++		    if (loglen < logbufflen)
+ 		    {
+ 			int len = strlen(buff);
+ 			
+-			if (len >= LOG_STR_MAX - loglen)
++			if (len >= logbufflen - loglen)
+ 			{
+-			    debug(DEBUG_APPMSG1, "WARNING: maximum log length exceeded, truncating log");
+-			    len = LOG_STR_MAX - loglen;
+-			    buff[len - 1] = '\n';
++			    debug(DEBUG_STATUS, "reallocating logbufflen to %d bytes for file %s", logbufflen, file->filename);
++			    logbufflen += (len >= LOG_STR_MAX ? (len+1) : LOG_STR_MAX);
++			    char * newlogbuff = realloc(logbuff, logbufflen);
++			    if (newlogbuff == NULL)
++			    {
++				debug(DEBUG_SYSERROR, "could not realloc %d bytes for logbuff in load_from_cvs", logbufflen);
++				exit(1);
++			    }
++			    logbuff = newlogbuff;
+ 			}
+ 
+ 			debug(DEBUG_STATUS, "appending %s to log", buff);
diff --git a/pkgs/applications/version-management/cvsps/03_diffoptstypo.dpatch b/pkgs/applications/version-management/cvsps/03_diffoptstypo.dpatch
new file mode 100644
index 00000000000..eb3818ed97e
--- /dev/null
+++ b/pkgs/applications/version-management/cvsps/03_diffoptstypo.dpatch
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 03_diffoptstypo.dpatch by  <crafterm@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Diff opts typo fix
+
+@DPATCH@
+
+--- cvsps-2.1-orig/cvsps.1	2005-05-26 05:39:40.000000000 +0200
++++ cvsps-2.1/cvsps.1	2005-07-28 15:17:48.885112048 +0200
+@@ -83,7 +83,7 @@
+ disable the use of rlog internally.  Note: rlog is
+ required for stable PatchSet numbering.  Use with care.
+ .TP
+-.B \-\-diffs\-opts <option string>
++.B \-\-diff\-opts <option string>
+ send a custom set of options to diff, for example to increase
+ the number of context lines, or change the diff format.
+ .TP
diff --git a/pkgs/applications/version-management/cvsps/default.nix b/pkgs/applications/version-management/cvsps/default.nix
new file mode 100644
index 00000000000..bea43f77d06
--- /dev/null
+++ b/pkgs/applications/version-management/cvsps/default.nix
@@ -0,0 +1,28 @@
+{ fetchurl, stdenv, cvs, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "cvsps-2.1";
+  src = fetchurl {
+    url = "http://www.cobite.com/cvsps/${name}.tar.gz";
+    sha256 = "0nh7q7zcmagx0i63h6fqqkkq9i55k77myvb8h6jn2f266f5iklwi";
+  };
+
+  # Patches from Debian's `cvsps-2.1-4'.
+  patches = [ ./01_ignoretrunk.dpatch
+              ./02_dynamicbufferalloc.dpatch
+	      ./03_diffoptstypo.dpatch ];
+
+  buildInputs = [ cvs zlib ];
+
+  installPhase = "make install prefix=$out";
+
+  meta = {
+    description = ''CVSps is a program for generating `patchset' information
+                    from a CVS repository.  A patchset in this case is
+		    defined as a set of changes made to a collection of
+		    files, and all committed at the same time (using a single
+		    "cvs commit" command).'';
+    homepage = http://www.cobite.com/cvsps/;
+    license = "GPLv2";
+  };
+}
diff --git a/pkgs/applications/version-management/darcs_2_pre.nix b/pkgs/applications/version-management/darcs/darcs-2.nix
index a8bd48aa336..ed21e0231cb 100644
--- a/pkgs/applications/version-management/darcs_2_pre.nix
+++ b/pkgs/applications/version-management/darcs/darcs-2.nix
@@ -1,10 +1,10 @@
 {stdenv, fetchurl, ghc, zlib, ncurses, curl}:
 
 stdenv.mkDerivation {
-  name = "darcs-2.0.0pre3";
+  name = "darcs-2.0.0";
   src = fetchurl {
-    url = http://darcs.net/darcs-2.0.0pre3.tar.gz;
-    sha256 = "";
+    url = http://darcs.net/darcs-2.0.0.tar.gz;
+    sha256 = "1admaglbf7i15x9pihncqj5iraqzcw801pf76f0pd2hbc2k0yx7x";
   };
   buildInputs = [ghc zlib ncurses curl];
 
diff --git a/pkgs/applications/version-management/git/default.nix b/pkgs/applications/version-management/git/default.nix
index db0df695f2b..3e6a838b499 100644
--- a/pkgs/applications/version-management/git/default.nix
+++ b/pkgs/applications/version-management/git/default.nix
@@ -1,35 +1,82 @@
-args: with args;
+{ fetchurl, stdenv, curl, openssl, zlib, expat, perl, gettext, cpio
+, asciidoc, texinfo, xmlto, docbook2x, docbook_xsl, docbook_xml_dtd_42
+, libxslt, tcl, tk, makeWrapper
+, svnSupport, subversion, perlLibs
+, guiSupport
+}:
+
+# `git-svn' support requires Subversion and various Perl libraries.
+# FIXME: We should make sure Subversion comes with its Perl bindings.
+assert svnSupport -> (subversion != null && perlLibs != []);
+
 
 stdenv.mkDerivation rec {
-  name = "git-1.5.4.2";
+  name = "git-1.5.5";
 
   src = fetchurl {
     url = "mirror://kernel/software/scm/git/${name}.tar.bz2";
-    sha256 = "089n3da06k19gzhacsqgaamgx5hy5r50r2b4a626s87w44mj78sn";
+    sha256 = "0pp6hfxkcwzb415wkkn713pqsv7cv06y90s53dyhsicqqn83hj17";
   };
 
-  buildInputs = [curl openssl zlib expat gettext]
-    ++ (if emacs != null then [emacs] else []);
+  patches = [ ./pwd.patch ./docbook2texi.patch ];
 
-  makeFlags="prefix=\${out} PERL_PATH=${perl}/bin/perl SHELL_PATH=${stdenv.shell}";
+  buildInputs = [curl openssl zlib expat gettext cpio makeWrapper]
+    ++ # documentation tools
+       [ asciidoc texinfo xmlto docbook2x
+         docbook_xsl docbook_xml_dtd_42 libxslt ]
+    ++ stdenv.lib.optionals guiSupport [tcl tk];
+
+  makeFlags = "prefix=\${out} PERL_PATH=${perl}/bin/perl SHELL_PATH=${stdenv.shell}";
 
   postInstall =
-    if emacs != null then
-	 ''# Install Emacs mode.
-	   echo "installing Emacs mode..."
-	   make install -C contrib/emacs prefix="$out"
+    ''
+      # Install Emacs mode.
+      echo "installing Emacs mode..."
+      ensureDir $out/share/emacs/site-lisp
+      cp -p contrib/emacs/*.el $out/share/emacs/site-lisp
+    '' # */
+    
+   + (if svnSupport then
+
+      ''# wrap git-svn
+        gitperllib=$out/lib/site_perl
+        for i in ${builtins.toString perlLibs}; do
+          gitperllib=$gitperllib:$i/lib/site_perl
+        done
+        wrapProgram "$out/bin/git-svn"                  \
+                     --set GITPERLLIB "$gitperllib"     \
+                     --prefix PATH : "${subversion}/bin" ''
+       else ''
+       echo "NOT installing \`git-svn' since \`svnSupport' is false."
+       rm $out/bin/git-svn '')
 
-	   # XXX: There are other things under `contrib' that people might want to
-	   # install. ''
-       else
-         ''echo "NOT installing Emacs mode.  Set \`git.useEmacs' to \`true' in your"
-	   echo "\`~/.nixpkgs/config.nix' file to change it."'';
+   + ''# Install man pages and Info manual
+       make PERL_PATH="${perl}/bin/perl" cmd-list.made install install-info \
+         -C Documentation ''
+
+   + (if guiSupport then ''
+       # Wrap Tcl/Tk programs
+       for prog in gitk git-gui git-citool
+       do
+         wrapProgram "$out/bin/$prog"                   \
+                     --set TK_LIBRARY "${tk}/lib/tk8.4" \
+                     --prefix PATH : "${tk}/bin"
+       done
+     '' else "")
+
+   + ''# Wrap `git-clone'
+       wrapProgram $out/bin/git-clone                   \
+                   --prefix PATH : "${cpio}/bin" '';
 
   meta = {
     license = "GPLv2";
     homepage = http://git.or.cz;
-    description = ''Git, a popular distributed version control system
-                    designed to handle very large projects with speed
-		    and efficiency.'';
+    description = "Git, a popular distributed version control system";
+
+    longDescription = ''
+      Git, a popular distributed version control system designed to
+      handle very large projects with speed and efficiency.
+    '';
+
   };
 }
diff --git a/pkgs/applications/version-management/git/docbook2texi.patch b/pkgs/applications/version-management/git/docbook2texi.patch
new file mode 100644
index 00000000000..4c26a10a72d
--- /dev/null
+++ b/pkgs/applications/version-management/git/docbook2texi.patch
@@ -0,0 +1,36 @@
+This patch does two things: (1) use the right name for `docbook2texi',
+and (2) make sure `gitman.info' isn't produced since it's broken (duplicate
+node names).
+
+--- git-1.5.4.4/Documentation/Makefile~	2008-03-09 11:18:13.000000000 +0100
++++ git-1.5.4.4/Documentation/Makefile	2008-03-12 16:04:05.000000000 +0100
+@@ -53,7 +53,7 @@ DOC_REF = origin/man
+ infodir?=$(prefix)/share/info
+ MAKEINFO=makeinfo
+ INSTALL_INFO=install-info
+-DOCBOOK2X_TEXI=docbook2x-texi
++DOCBOOK2X_TEXI=docbook2texi
+ ifndef PERL_PATH
+ 	PERL_PATH = /usr/bin/perl
+ endif
+@@ -89,7 +89,7 @@ man1: $(DOC_MAN1)
+ man5: $(DOC_MAN5)
+ man7: $(DOC_MAN7)
+ 
+-info: git.info gitman.info
++info: git.info
+ 
+ install: man
+ 	$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
+@@ -101,10 +101,9 @@ install: man
+ 
+ install-info: info
+ 	$(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
+-	$(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
++	$(INSTALL) -m 644 git.info $(DESTDIR)$(infodir)
+ 	if test -r $(DESTDIR)$(infodir)/dir; then \
+ 	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
+-	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
+ 	else \
+ 	  echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
+ 	fi
diff --git a/pkgs/applications/version-management/git/pwd.patch b/pkgs/applications/version-management/git/pwd.patch
new file mode 100644
index 00000000000..78c67043913
--- /dev/null
+++ b/pkgs/applications/version-management/git/pwd.patch
@@ -0,0 +1,22 @@
+--- git-1.5.4.4/git-clone.sh	2008-03-09 11:18:13.000000000 +0100
++++ git-1.5.4.4/git-clone.sh	2008-03-30 23:43:35.000000000 +0200
+@@ -40,7 +40,7 @@ eval "$(echo "$OPTIONS_SPEC" | git rev-p
+ 
+ get_repo_base() {
+ 	(
+-		cd "`/bin/pwd`" &&
++		cd "`pwd`" &&
+ 		cd "$1" || cd "$1.git" &&
+ 		{
+ 			cd .git
+--- git-1.5.4.4/git-submodule.sh	2008-03-09 11:18:13.000000000 +0100
++++ git-1.5.4.4/git-submodule.sh	2008-03-31 00:01:03.000000000 +0200
+@@ -28,7 +28,7 @@ say()
+ # NEEDSWORK: identical function exists in get_repo_base in clone.sh
+ get_repo_base() {
+ 	(
+-		cd "`/bin/pwd`" &&
++		cd "`pwd`" &&
+ 		cd "$1" || cd "$1.git" &&
+ 		{
+ 			cd .git
diff --git a/pkgs/applications/version-management/monotone-viz/1.0.1.nix b/pkgs/applications/version-management/monotone-viz/1.0.1.nix
new file mode 100644
index 00000000000..7f0b4e72724
--- /dev/null
+++ b/pkgs/applications/version-management/monotone-viz/1.0.1.nix
@@ -0,0 +1,19 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://oandrieu.nerim.net/monotone-viz/monotone-viz-1.0.1-nolablgtk.tar.gz;
+    sha256 = "0aqz65mlqplj5ccr8czcr6hvliclf9y1xi1rrs2z2s3fvahasxnp";
+  };
+
+  buildInputs = [ocaml lablgtk libgnomecanvas gtk graphviz glib pkgconfig];
+  configureFlags = ["--with-lablgtk-dir=${lablgtk}/lib/ocaml/lablgtk2"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "monotone-viz-" + version;
+  meta = {
+    description = "Monotone commit tree visualizer";
+  };
+}
+
diff --git a/pkgs/applications/version-management/monotone/default.nix b/pkgs/applications/version-management/monotone/default.nix
index fc2339af6a5..e148b8b5612 100644
--- a/pkgs/applications/version-management/monotone/default.nix
+++ b/pkgs/applications/version-management/monotone/default.nix
@@ -1,10 +1,10 @@
 {stdenv, fetchurl, boost, zlib}:
 
 stdenv.mkDerivation {
-  name = "monotone-0.38";
+  name = "monotone-0.40";
   src = fetchurl {
-    url = http://monotone.ca/downloads/0.38/monotone-0.38.tar.gz;
-    md5 = "c1a0d2619f451a664289b042c104860d";
+    url = http://monotone.ca/downloads/0.40/monotone-0.40.tar.gz;
+    sha256 = "0zs1zxvdn0m27w1830qbbh5vqk948hkpdkxwnlghszcbzz49151h";
   };
   buildInputs = [boost zlib];
 }
diff --git a/pkgs/applications/version-management/subversion-1.4.x/default.nix b/pkgs/applications/version-management/subversion-1.4.x/default.nix
index d09176302b8..3170fca9f20 100644
--- a/pkgs/applications/version-management/subversion-1.4.x/default.nix
+++ b/pkgs/applications/version-management/subversion-1.4.x/default.nix
@@ -16,8 +16,11 @@ assert javahlBindings -> jdk != null;
 assert sslSupport -> neon.sslSupport;
 assert compressionSupport -> neon.compressionSupport;
 
-stdenv.mkDerivation {
-  name = "subversion-1.4.6";
+stdenv.mkDerivation rec {
+
+  version = "1.4.6"; # attribute version is used within svnmerge as well
+
+  name = "subversion-${version}";
 
   builder = ./builder.sh;
   src = fetchurl {
@@ -48,6 +51,13 @@ stdenv.mkDerivation {
   inherit httpServer pythonBindings javahlBindings perlBindings;
   patches = [ ./subversion-respect_CPPFLAGS_in_perl_bindings.patch ];
 
+  passthru = {
+    inherit perlBindings pythonBindings;
+    python = if ( swig != null ) && (swig ? python) then 
+        swig.python 
+      else null;
+  };
+
   meta = {
     description = "A version control system intended to be a compelling replacement for CVS in the open source community";
     homepage = http://subversion.tigris.org/;
diff --git a/pkgs/applications/version-management/subversion-1.4.x/svnmerge.nix b/pkgs/applications/version-management/subversion-1.4.x/svnmerge.nix
new file mode 100644
index 00000000000..9c8b0349f4a
--- /dev/null
+++ b/pkgs/applications/version-management/subversion-1.4.x/svnmerge.nix
@@ -0,0 +1,22 @@
+{subversion, stdenv, python, shebangfix }:
+stdenv.mkDerivation {
+  name = "svnmerge-${subversion.version}";
+
+  src = subversion.src;
+
+  phases = "unpackPhase buildPhase";
+
+  buildInputs = [ shebangfix python ];
+
+  buildPhase = "
+    ensureDir \$out/bin
+    t=\$out/bin/svnmerge.py
+    cp contrib/client-side/svnmerge.py \$t
+    chmod +x \$t
+    shebangfix  \$t
+  ";
+
+  meta = subversion.meta // { 
+      description = "installs the contrib tool svnmerge.py";
+  };
+}
diff --git a/pkgs/applications/version-management/tailor/0.9.31.nix b/pkgs/applications/version-management/tailor/0.9.31.nix
new file mode 100644
index 00000000000..bd4dced8265
--- /dev/null
+++ b/pkgs/applications/version-management/tailor/0.9.31.nix
@@ -0,0 +1,19 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://darcs.arstecnica.it/tailor-0.9.31.tar.gz;
+    sha256 = "1apzd6mfmhgmxffzgzwsr17gnyqj6bycn783l9105cihsfcv9v3j";
+  };
+
+  buildInputs = [python makeWrapper];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["installPythonPackage" "wrapBinContentsPython"];
+      
+  name = "tailor-" + version;
+  meta = {
+    description = "Version control tools integration tool";
+  };
+}
+ 
diff --git a/pkgs/applications/version-management/viewmtn/0.10.nix b/pkgs/applications/version-management/viewmtn/0.10.nix
new file mode 100644
index 00000000000..82b841f964a
--- /dev/null
+++ b/pkgs/applications/version-management/viewmtn/0.10.nix
@@ -0,0 +1,45 @@
+
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://grahame.angrygoats.net/source/viewmtn/viewmtn-0.10.tgz;
+    sha256 = "1c6y708xaf6pds1r6l00q7vpgfagfbnf95kqj168vw3xr3l8a4yx";
+  };
+
+  buildInputs = [python flup highlight monotone 
+    cheetahTemplate makeWrapper graphviz which];
+  configureFlags = [];
+  makeFlags = ["PREFIX=$out"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doInstall" 
+    (doPatchShebangs "$out/bin")
+    (makeManyWrappers "$out/bin/*" 
+      (pythonWrapperArguments + preservePathWrapperArguments)) 
+  ];
+      
+  doInstall = FullDepEntry (''
+    for i in dot mtn highlight; do 
+        sed -e "s@/usr/bin/$i@$(which $i)@" -i config.py.example
+    done
+    sed -e "s@'templates/'@'$out/share/viewmtn/templates/'@" -i config.py.example
+
+    fullOut=$(toPythonPath $out)
+    
+    ensureDir $fullOut
+    ensureDir $out/bin
+    ensureDir $out/share/viewmtn
+    
+    cp -r * $fullOut
+    cp $fullOut/viewmtn.py $out/bin
+    
+    ln -s $fullOut/{AUTHORS,ChangeLog,INSTALL,LICENSE,README,TODO,config.py.example} $out/share/viewmtn
+    ln -s $fullOut/templates $out/share/viewmtn/
+    ln -s $fullOut/static $out/share/viewmtn/
+  '') ["minInit" "defEnsureDir" "addInputs" "doUnpack"];
+
+  name = "viewmtn-" + version;
+  meta = {
+    description = "Monotone web interface";
+  };
+}
diff --git a/pkgs/applications/video/MPlayer/default.nix b/pkgs/applications/video/MPlayer/default.nix
index 9b3065ad08a..170c2ca4f7e 100644
--- a/pkgs/applications/video/MPlayer/default.nix
+++ b/pkgs/applications/video/MPlayer/default.nix
@@ -3,6 +3,9 @@
 , stdenv, fetchurl, x11, freetype, freefont_ttf, zlib
 , alsa ? null, libX11, libXv ? null, libtheora ? null, libcaca ? null
 , libXinerama ? null, libXrandr ? null, libdvdnav ? null
+, cdparanoia ? null, cddaSupport ? true
+, extraBuildInputs ? []
+, extraConfigureFlags ? ""
 }:
 
 assert alsaSupport -> alsa != null;
@@ -12,6 +15,7 @@ assert cacaSupport -> libcaca != null;
 assert xineramaSupport -> libXinerama != null;
 assert randrSupport -> libXrandr != null;
 assert dvdnavSupport -> libdvdnav != null;
+assert cddaSupport -> cdparanoia != null;
 
 let
 
@@ -19,6 +23,10 @@ let
     inherit stdenv fetchurl;
   };
 
+  rp9codecs = (import ./rp9codecs) {
+    inherit stdenv fetchurl;
+  };
+
 in
 
 stdenv.mkDerivation {
@@ -38,17 +46,22 @@ stdenv.mkDerivation {
     (if xineramaSupport then libXinerama else null)
     (if randrSupport then libXrandr else null)
     (if dvdnavSupport then libdvdnav else null)
-  ];
+    (if cddaSupport then cdparanoia else null)
+  ]
+  ++ extraBuildInputs
+  ;
 
   configureFlags = "
     ${if cacaSupport then "--enable-caca" else "--disable-caca"}
     ${if dvdnavSupport then "--enable-dvdnav" else ""}
     --win32codecsdir=${win32codecs}
-    --realcodecsdir=${win32codecs}
+    --realcodecsdir=${rp9codecs}
     --enable-runtime-cpudetection
     --enable-x11 --with-extraincdir=${libX11}/include
     --disable-xanim
-  ";
+  "
+  + extraConfigureFlags
+  ;
 
   NIX_LDFLAGS = "-lX11 -lXext "  # !!! hack, necessary to get libX11/Xext in the RPATH
     + (if dvdnavSupport then "-ldvdnav" else "");
@@ -66,6 +79,7 @@ stdenv.mkDerivation {
 
   meta = {
     description = "A movie player that supports many video formats";
-    homepage = "GPL";
+    homepage = "http://mplayerhq.hu";
+    license = "GPL";
   };
 }
diff --git a/pkgs/applications/video/MPlayer/rp9codecs/builder.sh b/pkgs/applications/video/MPlayer/rp9codecs/builder.sh
new file mode 100644
index 00000000000..b8dfd5ce6b8
--- /dev/null
+++ b/pkgs/applications/video/MPlayer/rp9codecs/builder.sh
@@ -0,0 +1,11 @@
+source $stdenv/setup
+
+buildPhase=true
+
+installPhase() {
+    mkdir $out
+    cp -prv * $out
+}
+installPhase=installPhase
+
+genericBuild
diff --git a/pkgs/applications/video/MPlayer/rp9codecs/default.nix b/pkgs/applications/video/MPlayer/rp9codecs/default.nix
new file mode 100644
index 00000000000..27d95f21604
--- /dev/null
+++ b/pkgs/applications/video/MPlayer/rp9codecs/default.nix
@@ -0,0 +1,8 @@
+{stdenv, fetchurl}: stdenv.mkDerivation {
+  name = "MPlayer-rp9codecs-20050115";
+  builder = ./builder.sh;
+  src = fetchurl {
+    url = http://www2.mplayerhq.hu/MPlayer/releases/codecs/rp9codecs-20050115.tar.bz2;
+    sha256 = "353c22e2c992a1c730bdd5fade66a94e1a058e38063d2ce064a6510b70c39677";
+  };
+}
diff --git a/pkgs/applications/video/gnash/builder.sh b/pkgs/applications/video/gnash/builder.sh
index b90cec98429..519007fa55e 100644
--- a/pkgs/applications/video/gnash/builder.sh
+++ b/pkgs/applications/video/gnash/builder.sh
@@ -1,5 +1,5 @@
-source $stdenv/setup
+source "$stdenv/setup" || exit 1
 
-configureFlags="--with-sdl-mixer-incl=$SDL_mixer/include/SDL --with-sdl-incl=$SDL/include/SDL --with-plugindir=$out/plugins"
+configureFlags="--with-sdl-mixer-incl=$SDL_mixer/include/SDL --with-sdl-incl=$SDL/include/SDL --with-npapi-plugindir=$out/plugins --enable-gui=gtk"
 
 genericBuild
diff --git a/pkgs/applications/video/gnash/default.nix b/pkgs/applications/video/gnash/default.nix
index f23027158a4..0aa847f4382 100644
--- a/pkgs/applications/video/gnash/default.nix
+++ b/pkgs/applications/video/gnash/default.nix
@@ -1,17 +1,46 @@
-{stdenv, fetchurl, libX11, libXext, libXi, libXmu
+{ stdenv, fetchurl
 , SDL, SDL_mixer, GStreamer
-, libogg, libxml2, libjpeg, mesa, libpng}:
+, libogg, libxml2, libjpeg, mesa, libpng
+, boost, freetype, agg, dbus, curl, pkgconfig
+, glib, gtk, x11
+, lib}:
 
-stdenv.mkDerivation {
-  name = "gnash-0.7.2";
+stdenv.mkDerivation rec {
+  name = "gnash-0.8.2";
 
-  builder = ./builder.sh;
   src = fetchurl {
-    url = mirror://gnu/gnash/0.7.2/gnash-0.7.2.tar.bz2;
-    md5 = "ccef0f45be01a4c2992b46c2363a514f";
+    url = http://getgnash.org/packages/releases/gnash-0.8.3.tar.bz2;
+    sha256 = "16n32774sd5q4nkd95v2m8r2yfa9fk30jnq1iicarq3j8i2xh7xg";
   };
 
-  buildInputs = [libX11 libXext libXi libXmu SDL SDL_mixer GStreamer
-                 libogg libxml2 libjpeg mesa libpng];
+  builder = ./builder.sh;
+
+  patchPhase = ''
+    # Add all libs to `macros/libslist', a list of library search paths.
+    for lib in ${lib.concatStringsSep " "
+                                      (map (lib: "\"${lib}\"/lib")
+                                           (buildInputs ++ [stdenv.glibc]))}
+    do
+      echo -n "$lib " >> macros/libslist
+    done
+  '';
+
+
+  # XXX: KDE is supported as well so we could make it available optionally.
+  buildInputs = [x11 SDL SDL_mixer GStreamer
+                 libogg libxml2 libjpeg mesa libpng boost freetype agg
+		 dbus curl pkgconfig glib gtk];
   inherit SDL_mixer SDL;
+
+  # Make sure `gtk-gnash' gets `libXext' in its `RPATH'.
+  NIX_LDFLAGS="-lX11 -lXext";
+
+  preInstall = ''ensureDir $out/plugins'';
+  postInstall = ''make install-plugins'';
+
+  meta = {
+    homepage = http://www.gnu.org/software/gnash/;
+    description = ''Gnash is the GNU Flash movie player.'';
+    license = "GPLv3+";
+  };
 } // {mozillaPlugin = "/plugins";}
diff --git a/pkgs/applications/virtualization/qemu/0.9.0.nix b/pkgs/applications/virtualization/qemu/0.9.0.nix
deleted file mode 100644
index db49632f904..00000000000
--- a/pkgs/applications/virtualization/qemu/0.9.0.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-args : with args;
-	let localDefs = builderDefs {
-		src = /* put a fetchurl here */
-		fetchurl {
-			url = http://fabrice.bellard.free.fr/qemu/qemu-0.9.0.tar.gz;
-			sha256 = "1h85njd8xvn472yhcm92rjyzqjr719ab73rxwmz9cm2n6gwsq7s9";
-		};
-
-		buildInputs = [ SDL zlib which ];
-		configureFlags = [];
-	} null; /* null is a terminator for sumArgs */
-	in with localDefs;
-let 
-preConfigure = FullDepEntry ("
-  gcc --version
-") [minInit];
-in
-stdenv.mkDerivation rec {
-	name = "qemu-"+version;
-	builder = writeScript (name + "-builder")
-		(textClosure localDefs [ preConfigure doConfigure doMakeInstall doForceShare doPropagate]);
-	meta = {
-		description = "
-		QEmu processor emulator.
-";
-		inherit src;
-	};
-}
diff --git a/pkgs/applications/virtualization/qemu/0.9.1.nix b/pkgs/applications/virtualization/qemu/0.9.1.nix
index 1d1774a5c7b..bb5ad173c0a 100644
--- a/pkgs/applications/virtualization/qemu/0.9.1.nix
+++ b/pkgs/applications/virtualization/qemu/0.9.1.nix
@@ -1,28 +1,20 @@
-args : with args;
-	let localDefs = builderDefs {
-		src = /* put a fetchurl here */
-		fetchurl {
-			url = http://fabrice.bellard.free.fr/qemu/qemu-0.9.1.tar.gz;
-			sha256 = "199mb12w141yh2afzznh539jsip4h79kfsxwaj1xhzfwljsd0mj7";
-		};
+{stdenv, fetchurl, SDL, zlib, which}:
 
-		buildInputs = [ SDL zlib which ];
-		configureFlags = [ ];
-	} null; /* null is a terminator for sumArgs */
-	in with localDefs;
-let 
-preConfigure = FullDepEntry ("
-  gcc --version
-") [minInit];
-in
-stdenv.mkDerivation rec {
-	name = "qemu-"+version;
-	builder = writeScript (name + "-builder")
-		(textClosure localDefs [ preConfigure doConfigure doMakeInstall doForceShare doPropagate]);
-	meta = {
-		description = "
-		QEmu processor emulator.
-";
-		inherit src;
-	};
+stdenv.mkDerivation {
+  name = "qemu-0.9.1";
+
+  src = fetchurl {
+    url = http://bellard.org/qemu/qemu-0.9.1.tar.gz;
+    sha256 = "199mb12w141yh2afzznh539jsip4h79kfsxwaj1xhzfwljsd0mj7";
+  };
+
+  patches = [../../../os-specific/linux/kvm/smbd-path.patch];
+
+  patchFlags = "-p2";
+  
+  buildInputs = [SDL zlib which];
+  
+  meta = {
+    description = "QEmu processor emulator";
+  };
 }
diff --git a/pkgs/applications/window-managers/compiz-fusion/bcop/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/bcop/0.7.4.nix
new file mode 100644
index 00000000000..c9c8c5c731a
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/bcop/0.7.4.nix
@@ -0,0 +1,34 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/compiz-bcop-0.7.4.tar.bz2;
+		sha256 = "1dfkwac45p6bl64gn58jnj5h99w81mlqkzfn7jni96kgspvnipjf";
+	};
+		buildInputs = (import ../general-dependencies.nix args);
+		propagatedBuildInputs = [getopt libxslt];
+		configureFlags = [];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let 
+	fixPkgconfig = FullDepEntry ("
+		ensureDir \$out/lib
+		ln -fs \$out/share/pkgconfig \$out/lib/pkgconfig
+	") [minInit doMakeInstall defEnsureDir];
+	fixInterpreter = FullDepEntry ("
+		sed -e 's@^#!/bin/bash@#! ${stdenv.bash}/bin/bash@' -i \$out/bin/bcop
+	") [minInit doMakeInstall];
+in
+stdenv.mkDerivation rec {
+	name = "compiz-bcop-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doAutotools doConfigure doMakeInstall fixPkgconfig fixInterpreter doForceShare 
+			doPropagate]);
+	inherit propagatedBuildInputs;
+	meta = {
+		description = "
+	Compiz BCOP.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz-fusion/ccsm-simple/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/ccsm-simple/0.7.4.nix
new file mode 100644
index 00000000000..5bed74bb2af
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/ccsm-simple/0.7.4.nix
@@ -0,0 +1,29 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/simple-ccsm-0.7.4.tar.bz2;
+		sha256 = "1clb0ag73dylslqvg7f4rsk5d3iv4aj5lvhfq7wb99m6k9bksh5y";
+	};
+		buildInputs = (import ../general-dependencies.nix args) ++
+			[libcompizconfig bcop compizConfigPython python gettext pygtk 
+			pycairo configBackendGConf];
+		configureFlags = [];
+		wrappedEnv = [
+			"PYTHONPATH" "$(toPythonPath \$out)"
+			"PYTHONPATH" "\$PYTHONPATH"
+			"PYTHONPATH" "$(toPythonPath ${pygtk})/gtk-2.0"
+		];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "compizconfig-settings-"+args.version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [installPythonPackage (doWrap "\$out/bin/simple-ccsm")]);
+	meta = {
+		description = "
+	Compiz Settings Manager (simplified)
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz-fusion/ccsm/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/ccsm/0.7.4.nix
new file mode 100644
index 00000000000..a09e3df353b
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/ccsm/0.7.4.nix
@@ -0,0 +1,29 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/ccsm-0.7.4.tar.bz2;
+		sha256 = "0267xvz2j476r1awiwkfhfahjh8p1al6ip0qjzlw1lidmd9fdbxv";
+	};
+		buildInputs = (import ../general-dependencies.nix args) ++
+			[libcompizconfig bcop compizConfigPython python gettext pygtk 
+			pycairo configBackendGConf];
+		configureFlags = [];
+		wrappedEnv = [
+			"PYTHONPATH" "$(toPythonPath \$out)"
+			"PYTHONPATH" "\$PYTHONPATH"
+			"PYTHONPATH" "$(toPythonPath ${pygtk})/gtk-2.0"
+		];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "compizconfig-settings-"+args.version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [installPythonPackage (doWrap "\$out/bin/ccsm")]);
+	meta = {
+		description = "
+	Compiz Settings Manager
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz-fusion/compizconfig-python/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/compizconfig-python/0.7.4.nix
new file mode 100644
index 00000000000..c77d332f890
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/compizconfig-python/0.7.4.nix
@@ -0,0 +1,23 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/compizconfig-python-0.7.4.tar.bz2;
+		sha256 = "0y9r1cp0f5c3x7ysbdkil6156nhy4a7aqhmxqdg3hjwwgkfsgi9d";
+	};
+		buildInputs = (import ../general-dependencies.nix args) ++
+			[libcompizconfig bcop python pyrex configBackendGConf];
+		configureFlags = [];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "compizconfig-python-"+args.version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doAutotools doConfigure doMakeInstall doForceShare]);
+	meta = {
+		description = "
+	Compiz configuration - Python part.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz-fusion/config-backend/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/config-backend/0.7.4.nix
new file mode 100644
index 00000000000..5136db338df
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/config-backend/0.7.4.nix
@@ -0,0 +1,24 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/compizconfig-backend-gconf-0.7.4.tar.bz2;
+		sha256 = "0gvb81zlp0wciq0cp7g1wnldm5p1n21i6zfwjm26ialphi4m47ly";
+	};
+		buildInputs = (import ../general-dependencies.nix args) ++
+			[bcop libcompizconfig];
+		configureFlags = [];
+		forceShare = ["man" "doc" "info" "lib/compizconfig"];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "compizconfig-backend-GConf-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doAutotools doConfigure doMakeInstall doForceShare doPropagate]);
+	meta = {
+		description = "
+	Compiz configuration backend (GConf).
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz-fusion/default.nix b/pkgs/applications/window-managers/compiz-fusion/default.nix
index 589b77d0f23..334af5eb012 100644
--- a/pkgs/applications/window-managers/compiz-fusion/default.nix
+++ b/pkgs/applications/window-managers/compiz-fusion/default.nix
@@ -11,4 +11,5 @@ rec
 	pluginsMain = selectVersion ./main (args //{inherit bcop ;});
 	pluginsExtra = selectVersion ./extra (args //{inherit bcop pluginsMain;});
 	compizManager = selectVersion ./compiz-manager (args // {inherit bcop ccsm;});
+	ccsmSimple = selectVersion ./ccsm-simple (args // {inherit libcompizconfig bcop compizConfigPython configBackendGConf;});
 }
diff --git a/pkgs/applications/window-managers/compiz-fusion/extra/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/extra/0.7.4.nix
new file mode 100644
index 00000000000..4ea554a6e7f
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/extra/0.7.4.nix
@@ -0,0 +1,34 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/compiz-fusion-plugins-extra-0.7.4.tar.bz2;
+		sha256 = "0zncmzccnw8avvj20h1xfh8s5f1xgwwry0fkhw444phx7pwcds3w";
+	};
+		buildInputs = (import ../general-dependencies.nix args)++
+		[bcop libjpeg gettext pluginsMain];
+		configureFlags = [];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let
+	sharePlugins = FullDepEntry ("
+		ensureDir \$out/share/compiz-plugins
+		ln -vsf \$out/lib/compiz \$out/share/compiz-plugins
+	") [minInit doMakeInstall defEnsureDir];
+	fixIncludes = FullDepEntry ("
+sed -e 's@#include <compiz-text.h>@#include <compiz/compiz-text.h>@' -i src/group/group-internal.h;
+sed -e 's@#include <compiz-text.h>@#include <compiz/compiz-text.h>@' -i src/scalefilter/scalefilter.c;
+sed -e 's@#include <compiz-mousepoll.h>@#include <compiz/compiz-mousepoll.h>@' -i src/showmouse/showmouse.c;
+	") [minInit doUnpack];
+in
+stdenv.mkDerivation rec {
+	name = "compiz-fusion-plugins-extra-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [fixIncludes doConfigure doMakeInstall sharePlugins doForceShare]);
+	meta = {
+		description = "
+	Extra Compiz Fusion plugins.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz-fusion/libcompizconfig/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/libcompizconfig/0.7.4.nix
new file mode 100644
index 00000000000..d052a7d3c72
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/libcompizconfig/0.7.4.nix
@@ -0,0 +1,23 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/libcompizconfig-0.7.4.tar.bz2;
+		sha256 = "0y5hfah30giszilg8v0v10vg45rnc9gdjbsqawdjn2q6bh3xzmr3";
+	};
+		buildInputs = (import ../general-dependencies.nix args)++
+			[bcop];
+		configureFlags = [];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "libcompizconfig-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doAutotools doConfigure doMakeInstall doForceShare]);
+	meta = {
+		description = "
+	Compiz configuration backend library.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz-fusion/main/0.7.4.nix b/pkgs/applications/window-managers/compiz-fusion/main/0.7.4.nix
new file mode 100644
index 00000000000..0fdb6ec5fa0
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz-fusion/main/0.7.4.nix
@@ -0,0 +1,29 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/compiz-fusion-plugins-main-0.7.4.tar.bz2;
+		sha256 = "1dk8gb0ysij9ny51x9xgz595zbh6cm37hfbn1y738s471cjh7mp3";
+	};
+		buildInputs = (import ../general-dependencies.nix args)++
+		[bcop libjpeg gettext];
+		configureFlags = [];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let
+	sharePlugins = FullDepEntry ("
+		ensureDir \$out/share/compiz-plugins
+		ln -vsf \$out/lib/compiz \$out/share/compiz-plugins
+	") [minInit doMakeInstall defEnsureDir];
+in
+stdenv.mkDerivation rec {
+	name = "compiz-fusion-plugins-main-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doConfigure doMakeInstall sharePlugins doForceShare]);
+	meta = {
+		description = "
+	Main Compiz Fusion plugins.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/applications/window-managers/compiz/0.7.4.nix b/pkgs/applications/window-managers/compiz/0.7.4.nix
new file mode 100644
index 00000000000..8e95a903155
--- /dev/null
+++ b/pkgs/applications/window-managers/compiz/0.7.4.nix
@@ -0,0 +1,51 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+	fetchurl {
+		url = http://releases.compiz-fusion.org/0.7.4/compiz/compiz-0.7.4.tar.bz2;
+		sha256 = "1ik2wlrc469l0l9j7yhfapcmwkshhva5b5sh5h4czg3bj5iivaf7";
+	};
+		buildInputs = [
+			    pkgconfig gtk libwnck GConf libgnome 
+			    libgnomeui metacity gnomegtk glib pango libglade libgtkhtml 
+			    gtkhtml libgnomecanvas libgnomeprint libgnomeprintui gnomepanel 
+			    librsvg fuse 
+		];
+		  propagatedBuildInputs = [
+		    libpng libXcomposite libXfixes libXdamage libXrandr libXinerama
+		    libICE libSM startupnotification mesa GConf perl perlXMLParser libxslt
+		    dbus.libs dbus_glib compositeproto fixesproto damageproto randrproto
+		    xineramaproto renderproto kbproto xextproto libXrender xproto libX11
+		    libxcb
+		  ];
+		configureFlags = ["--enable-gtk" "--enable-fuse" 
+			"--enable-annotate" "--enable-librsvg"] ++ 
+			(if args ? extraConfigureFlags then args.extraConfigureFlags else []);
+		patches = [ ./glx-patch-0.6.2.patch ];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let
+	postAll = FullDepEntry ("
+    for i in $out/bin/*; do
+     patchelf --set-rpath /var/run/opengl-driver/lib:$(patchelf --print-rpath $i) $i
+    done
+    ensureDir \$out/share/compiz-plugins/
+    ln -sfv \$out/lib/compiz \$out/share/compiz-plugins/
+  ") [minInit doMakeInstall defEnsureDir];
+in
+
+stdenv.mkDerivation 
+rec {
+	name = "compiz-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doPatch doConfigure doMakeInstall doPropagate 
+			doForceShare postAll]);
+	inherit propagatedBuildInputs;
+	meta = {
+		description = "
+	Compiz window manager
+";
+		inherit src;
+	};
+}
+
diff --git a/pkgs/applications/window-managers/jwm/default.nix b/pkgs/applications/window-managers/jwm/default.nix
new file mode 100644
index 00000000000..3f0f550123a
--- /dev/null
+++ b/pkgs/applications/window-managers/jwm/default.nix
@@ -0,0 +1,22 @@
+args: with args;
+
+stdenv.mkDerivation {
+  name="jwm-2.0.1";
+  src = fetchurl {
+     url = http://24.254.249.181:8080/joewing.net/programs/jwm/releases/jwm-2.0.1.tar.bz2;
+     sha256 = "1ix5y00cmg3cyazl0adzgv49140zxaf2dpngyg1dyy4ma6ysdmnw";
+  };
+
+  buildInputs = [libX11 libXext libXinerama libXpm libXft];
+
+
+  postInstall = ''
+    sed -i -e s/rxvt/xterm/g $out/etc/system.jwmrc
+    sed -i -e "s/.*Swallow.*\|.*xload.*//" $out/etc/system.jwmrc'';
+
+
+  meta = {
+  description = "JWM is a window manager for X11 window system. It is written in C and uses only Xlib at a minimum.";
+  };
+
+}
diff --git a/pkgs/applications/window-managers/wmii/default.nix b/pkgs/applications/window-managers/wmii/default.nix
index a7a4d2973c0..396f69181b6 100644
--- a/pkgs/applications/window-managers/wmii/default.nix
+++ b/pkgs/applications/window-managers/wmii/default.nix
@@ -2,25 +2,30 @@ args: with args; stdenv.mkDerivation {
   name = "wmii-20070516";
 
   src = fetchurl {
-    url = http://www.suckless.org/snaps/wmii-snap20070304.tgz;
-    sha256 = "01ba1qk48n6wgpnavdwakgwmv895jvqvi75sm2wsvd6bqmc2xp86";
+    url = http://www.suckless.org/download/wmii-3.6.tar.gz;
+    sha256 = "05mj651yv02rvkpqqkgwp8307nrrqpcwfv5k8186kx2yiiw9pws6";
   };
 
-  buildInputs = [ libX11 libixp ];
+  buildInputs = [ libX11 libixp xextproto libXt libXext ];
   inherit libixp;
 
-  phases = (if args.includeUnpack then "unpackPhase " else "")+"installPhase";
+  phases = "unpackPhase installPhase";
 
   installPhase = "
+     for i in libfmt libutf libregexp libbio; do
+       cd $i; make; cd ..
+     done
+     mkdir -p \$out/lib
+     cp ${libixp}/lib/libixp.a \$out/lib
      export CFLAGS=\$NIX_CFLAGS_COMPILE
      export LDFLAGS\=$(echo \$NIX_LDFLAGS | sed -e 's/-rpath/-L/g')
      sed -i -e \"s%^PREFIX.*%PREFIX=\$out%\" \\
             -e \"s%^\\(INCS.*\\)%\\1 \$NIX_CFLAGS_COMPILE%\" \\
             -e \"s%^\\(LIBS.*\\)%\\1 \$LDFLAGS%\" \\
-	    -e 's%^\\(AWKPATH = \\).*%\\1${gawk}/bin/gawk%' \\
+            -e 's%^\\(AWKPATH = \\).*%\\1${gawk}/bin/gawk%' \\
             config.mk
      # don't use the default one installed by nixos!
-     sed -i -e \"s%ixpc%\$libixp/bin/ixpc%\" wmiir
+     #sed -i -e \"s%ixpc%\$libixp/bin/ixpc%\" wmiir
      make install
   ";
   meta = { homepage = "www.suckless.org";
diff --git a/pkgs/applications/window-managers/wmii31/default.nix b/pkgs/applications/window-managers/wmii31/default.nix
index ff83b78c37b..1602f1ece39 100644
--- a/pkgs/applications/window-managers/wmii31/default.nix
+++ b/pkgs/applications/window-managers/wmii31/default.nix
@@ -9,7 +9,7 @@ args: with args; stdenv.mkDerivation {
   buildInputs = [ libX11 libixp ];
   inherit libixp;
  
-  phases = (if args.includeUnpack then "unpackPhase " else "")+"installPhase";
+  phases = "unpackPhase installPhase";
 
   installPhase = "
      export CFLAGS=\$NIX_CFLAGS_COMPILE
diff --git a/pkgs/applications/window-managers/xmonad/default.nix b/pkgs/applications/window-managers/xmonad/default.nix
index ccd2dc05adb..ed01ddd3e33 100644
--- a/pkgs/applications/window-managers/xmonad/default.nix
+++ b/pkgs/applications/window-managers/xmonad/default.nix
@@ -1,42 +1,17 @@
-{stdenv, fetchurl, ghc, X11, xmessage}:
-
-stdenv.mkDerivation (rec {
+{cabal, X11, xmessage}:
 
+cabal.mkDerivation (self : {
   pname = "xmonad";
-  version = "0.5";
-
-  name = "${pname}-${version}";
-
-  src = fetchurl {
-    url = "http://hackage.haskell.org/packages/archive/${pname}/${version}/${name}.tar.gz";
-    sha256 = "cfcc4501b000fa740ed35a5be87dc01216e036219551630dcf71d9c3cf57e4c4";
-  };
-
-  buildInputs = [ghc X11];
-
+  name = "${self.fname}";
+  version = "0.7";
+  sha256 = "d5ee338eb6d0680082e20eaafa0b23b32358fffe69e2ec4ad7bdf6e03c751d67";
+  extraBuildInputs = [X11];
   meta = {
     description = "xmonad is a tiling window manager for X";
   };
 
-  configurePhase = '' 
-    sed -i 's|"xmessage"|"${xmessage}/bin/xmessage"|' XMonad/Core.hs
-    ghc --make Setup.lhs
-    ./Setup configure --prefix="$out"
+  preConfigure = '' 
+    substituteInPlace XMonad/Core.hs --replace \
+      '"xmessage"' '"${xmessage}/bin/xmessage"'
   '';
-
-  buildPhase = ''
-    ./Setup build
-  '';
-
-  installPhase = ''
-    ./Setup copy
-    ./Setup register --gen-script
-    mkdir $out/nix-support
-    sed -i 's/|.*\(ghc-pkg update\)/| \1/' register.sh
-    cp register.sh $out/nix-support/register-ghclib.sh
-    sed -i 's/\(ghc-pkg update\)/\1 --user/' register.sh
-    mkdir -p $out/bin
-    cp register.sh $out/bin/register-ghclib-${name}.sh
-  '';
-
 })
diff --git a/pkgs/applications/window-managers/xmonad/xmonad-contrib.nix b/pkgs/applications/window-managers/xmonad/xmonad-contrib.nix
new file mode 100644
index 00000000000..2c0e250470f
--- /dev/null
+++ b/pkgs/applications/window-managers/xmonad/xmonad-contrib.nix
@@ -0,0 +1,12 @@
+{cabal, xmonad, X11}:
+
+cabal.mkDerivation (self : {
+  pname = "xmonad-contrib";
+  name = "${self.fname}";
+  version = "0.7";
+  sha256 = "4034d0c8ce092fc9b4e9d9ecf89bc9c16c4ac28aad190f074edc9e4201db0697";
+  extraBuildInputs = [X11 xmonad];
+  meta = {
+    description = "a huge extension library for xmonad";
+  };
+})
diff --git a/pkgs/build-support/checker/default.nix b/pkgs/build-support/checker/default.nix
index ebf977d4755..ae25493c77c 100644
--- a/pkgs/build-support/checker/default.nix
+++ b/pkgs/build-support/checker/default.nix
@@ -18,7 +18,9 @@ let
 	if (! isAttrs b) then s else
 	if (lib.getAttr ["_type"] "" b) == "option" then "" else
 	findInList (x : x != "") 
-		(map (x: checkAttrInclusion 
+		( map (x: if (x == "servicesProposal") # this attr will be checked at another place ( -> upstart-jobs/default.nix )
+                       then ""
+                       else checkAttrInclusion 
 			(s + "." + x) 
 			(__getAttr x a)
 			(lib.getAttr [x] null b)) 
diff --git a/pkgs/build-support/fetchdarcs/builder.sh b/pkgs/build-support/fetchdarcs/builder.sh
index 6edad270765..7214eda4266 100644
--- a/pkgs/build-support/fetchdarcs/builder.sh
+++ b/pkgs/build-support/fetchdarcs/builder.sh
@@ -7,9 +7,9 @@ if test -n "$tag"; then
     tagflags="--tag=$tag"
 fi
 
-header "getting $url ${tagtext}into $out"
+header "getting $url $partial ${tagtext} into $out"
 
-darcs get --no-pristine-tree --partial $tagflags "$url" "$out"
+darcs get --no-pristine-tree $partial $tagflags "$url" "$out"
 # remove metadata, because it can change
 rm -rf "$out/_darcs"
 
diff --git a/pkgs/build-support/fetchdarcs/default.nix b/pkgs/build-support/fetchdarcs/default.nix
index efb37bea522..b8dde18aa3e 100644
--- a/pkgs/build-support/fetchdarcs/default.nix
+++ b/pkgs/build-support/fetchdarcs/default.nix
@@ -1,9 +1,10 @@
-{stdenv, darcs, nix}: {url, tag ? null, md5}:
+{stdenv, darcs, nix}: {url, tag ? null, md5, partial ? true}:
 
 stdenv.mkDerivation {
   name = "fetchdarcs";
   builder = ./builder.sh;
   buildInputs = [darcs nix];
+  partial = if partial then "--partial" else "";
 
   # Nix <= 0.7 compatibility.
   id = md5;
diff --git a/pkgs/build-support/fetchsvnssh/builder.sh b/pkgs/build-support/fetchsvnssh/builder.sh
new file mode 100644
index 00000000000..d9c6dc7da31
--- /dev/null
+++ b/pkgs/build-support/fetchsvnssh/builder.sh
@@ -0,0 +1,15 @@
+source $stdenv/setup
+
+header "exporting $url (r$rev) into $out"
+
+if test "$sshSupport"; then
+    export SVN_SSH="$openssh/bin/ssh"
+fi
+
+# Pipe the "p" character into Subversion to force it to accept the
+# server's certificate.  This is perfectly safe: we don't care
+# whether the server is being spoofed --- only the cryptographic
+# hash of the output matters.
+expect -f $sshSubversion "$username" "$password" "$rev" "$url" $out
+
+stopNest
diff --git a/pkgs/build-support/fetchsvnssh/default.nix b/pkgs/build-support/fetchsvnssh/default.nix
new file mode 100644
index 00000000000..6c6c03d6873
--- /dev/null
+++ b/pkgs/build-support/fetchsvnssh/default.nix
@@ -0,0 +1,16 @@
+{stdenv, subversion, sshSupport ? false, openssh ? null, expect}: 
+{username, password, url, rev ? "HEAD", md5 ? "", sha256 ? ""}:
+
+stdenv.mkDerivation {
+  name = "svn-export-ssh";
+  builder = ./builder.sh;
+  buildInputs = [subversion expect];
+
+  outputHashAlgo = if sha256 == "" then "md5" else "sha256";
+  outputHashMode = "recursive";
+  outputHash = if sha256 == "" then md5 else sha256;
+  
+  sshSubversion = ./sshsubversion.exp;
+  
+  inherit username password url rev sshSupport openssh;
+}
diff --git a/pkgs/build-support/fetchsvnssh/sshsubversion.exp b/pkgs/build-support/fetchsvnssh/sshsubversion.exp
new file mode 100755
index 00000000000..c00f39714e5
--- /dev/null
+++ b/pkgs/build-support/fetchsvnssh/sshsubversion.exp
@@ -0,0 +1,22 @@
+#!/nix/var/nix/profiles/default/bin/expect -f
+
+# Set variables
+set username [lindex $argv 0]
+set password [lindex $argv 1]
+set rev [lindex $argv 2]
+set url [lindex $argv 3]
+set out [lindex $argv 4]
+set timeout -1
+
+spawn svn export -r$rev svn+ssh://$username@$url $out
+match_max 100000
+
+expect "*continue connecting*" { send -- "yes\r"; expect "*?assword:*"; send -- "$password\r" } \
+       "*?assword:*" { send -- "$password\r" }
+
+expect "*?assword:*"
+send -- "$password\r"
+
+# Send blank line
+send -- "\r"
+expect eof
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
index 70cc0c41973..69dbdbc57a8 100644
--- a/pkgs/build-support/fetchurl/mirrors.nix
+++ b/pkgs/build-support/fetchurl/mirrors.nix
@@ -24,7 +24,7 @@ rec {
 
   # GNU.
   gnu = [
-    ftp://ftp.nluug.nl/pub/gnu/
+    http://ftp.nluug.nl/pub/gnu/
     http://mirrors.kernel.org/gnu/
     http://ftp.gnu.org/pub/gnu/
   ];
@@ -89,7 +89,7 @@ rec {
     ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/
     ftp://ftp.u-aizu.ac.jp/pub/graphics/image/ImageMagick/imagemagick.org
     ftp://zoffy.asahi-net.or.jp/pub/graphics/ImageMagick
-    ftp://ftp.nluug.nl/pub/ImageMagick
+    http://ftp.nluug.nl/pub/ImageMagick
     http://ftp.surfnet.nl/pub/ImageMagick/
     ftp://sunsite.icm.edu.pl/packages/ImageMagick/
     ftp://ftp.chg.ru/packages/ImageMagick
@@ -115,10 +115,32 @@ rec {
 
   # Debian.
   debian = [
-    ftp://ftp.de.debian.org/debian/pool/
-    ftp://ftp.nl.debian.org/debian/pool/
-    ftp://ftp.ru.debian.org/debian/pool/
-    ftp://ftp.debian.org/debian/pool/
+    ftp://ftp.de.debian.org/debian/
+    ftp://ftp.nl.debian.org/debian/
+    ftp://ftp.ru.debian.org/debian/
+    ftp://ftp.debian.org/debian/
+  ];
+
+  # Ubuntu.
+  ubuntu = [
+    http://nl.archive.ubuntu.com/ubuntu/
+    http://de.archive.ubuntu.com/ubuntu/
+    http://archive.ubuntu.com/ubuntu/
+  ];
+
+  # Fedora (please only add full mirrors that carry old Fedora distributions as well).
+  fedora = [
+    http://ftp.nluug.nl/pub/os/Linux/distr/fedora/
+    http://ftp.funet.fi/pub/mirrors/ftp.redhat.com/pub/fedora/
+    http://download.fedora.redhat.com/pub/fedora/
+  ];
+
+  # openSUSE.
+  opensuse = [
+    http://opensuse.hro.nl/opensuse/
+    http://ftp.funet.fi/pub/linux/mirrors/opensuse/
+    http://ftp5.gwdg.de/pub/opensuse/
+    http://ftp.opensuse.org/pub/opensuse/
   ];
 
   # Gnome (see http://ftp.gnome.org/pub/GNOME/MIRRORS).
diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix
new file mode 100644
index 00000000000..b62ed984045
--- /dev/null
+++ b/pkgs/build-support/kernel/make-initrd.nix
@@ -0,0 +1,31 @@
+# Create an initial ramdisk containing the closure of the specified
+# file system objects.  An initial ramdisk is used during the initial
+# stages of booting a Linux system.  It is loaded by the boot loader
+# along with the kernel image.  It's supposed to contain everything
+# (such as kernel modules) necessary to allow us to mount the root
+# file system.  Once the root file system is mounted, the `real' boot
+# script can be called.
+#
+# An initrd is really just a gzipped cpio archive.
+#
+# Symlinks are created for each top-level file system object.  E.g.,
+# `contents = {object = ...; symlink = /init;}' is a typical
+# argument.
+
+{stdenv, perl, cpio, contents}:
+
+stdenv.mkDerivation {
+  name = "initrd";
+  builder = ./make-initrd.sh;
+  buildInputs = [perl cpio];
+
+  # !!! should use XML.
+  objects = map (x: x.object) contents;
+  symlinks = map (x: x.symlink) contents;
+  suffices = map (x: if x ? suffix then x.suffix else "none") contents;
+  
+  # For obtaining the closure of `contents'.
+  exportReferencesGraph =
+    map (x: [("closure-" + baseNameOf x.symlink) x.object]) contents;
+  pathsFromGraph = ./paths-from-graph.pl;
+}
diff --git a/pkgs/build-support/kernel/make-initrd.sh b/pkgs/build-support/kernel/make-initrd.sh
new file mode 100644
index 00000000000..d930e51a03f
--- /dev/null
+++ b/pkgs/build-support/kernel/make-initrd.sh
@@ -0,0 +1,39 @@
+source $stdenv/setup
+
+set -o pipefail
+
+objects=($objects)
+symlinks=($symlinks)
+suffices=($suffices)
+
+mkdir root
+
+# Needed for splash_helper, which gets run before init.
+mkdir root/dev
+mkdir root/sys
+mkdir root/proc
+
+
+for ((n = 0; n < ${#objects[*]}; n++)); do
+    object=${objects[$n]}
+    symlink=${symlinks[$n]}
+    suffix=${suffices[$n]}
+    if test "$suffix" = none; then suffix=; fi
+
+    mkdir -p $(dirname root/$symlink)
+    ln -s $object$suffix root/$symlink
+done
+
+
+# Get the paths in the closure of `object'.
+storePaths=$(perl $pathsFromGraph closure-*)
+
+
+# Paths in cpio archives *must* be relative, otherwise the kernel
+# won't unpack 'em.
+(cd root && cp -prd --parents $storePaths .)
+
+
+# Put the closure in a gzipped cpio archive.
+ensureDir $out
+(cd root && find * -print0 | cpio -ov -H newc --null | gzip -9 > $out/initrd)
diff --git a/pkgs/build-support/kernel/modules-closure.nix b/pkgs/build-support/kernel/modules-closure.nix
new file mode 100644
index 00000000000..55377859b24
--- /dev/null
+++ b/pkgs/build-support/kernel/modules-closure.nix
@@ -0,0 +1,14 @@
+# Given a kernel build (with modules in $kernel/lib/modules/VERSION),
+# produce a module tree in $out/lib/modules/VERSION that contains only
+# the modules identified by `rootModules', plus their dependencies.
+# Also generate an appropriate modules.dep.
+
+{stdenv, kernel, rootModules, module_init_tools, allowMissing ? false}:
+
+stdenv.mkDerivation {
+  name = kernel.name + "-shrunk";
+  builder = ./modules-closure.sh;
+  inherit kernel rootModules module_init_tools;
+  allowedReferences = ["out"];
+  allowMissing = if allowMissing then "true" else "";
+}
diff --git a/pkgs/build-support/kernel/modules-closure.sh b/pkgs/build-support/kernel/modules-closure.sh
new file mode 100644
index 00000000000..44e816c4208
--- /dev/null
+++ b/pkgs/build-support/kernel/modules-closure.sh
@@ -0,0 +1,36 @@
+source $stdenv/setup
+
+set -o pipefail
+
+PATH=$module_init_tools/sbin:$PATH
+
+version=$(cd $kernel/lib/modules && ls -d *)
+
+echo "kernel version is $version"
+
+export MODULE_DIR=$kernel/lib/modules/
+
+# Determine the dependencies of each root module.
+closure=
+for module in $rootModules; do
+    echo "root module: $module"
+    deps=$(modprobe --config /dev/null --set-version "$version" --show-depends "$module" \
+    | sed 's/^insmod //') || if test -z "allowMissing"; then exit 1; fi
+    #for i in $deps; do echo $i; done
+    closure="$closure $deps"
+done
+
+echo "closure:"
+ensureDir $out
+for module in $closure; do
+    target=$(echo $module | sed "s^$kernel^$out^")
+    if test -e "$target"; then continue; fi
+    echo $module
+    mkdir -p $(dirname $target)
+    cp $module $target
+    grep "^$module" $kernel/lib/modules/$version/modules.dep \
+        | sed "s^$kernel^$out^g" \
+        >> $out/lib/modules/$version/modules.dep
+    echo $target >> $out/insmod-list
+done
+
diff --git a/pkgs/build-support/kernel/paths-from-graph.pl b/pkgs/build-support/kernel/paths-from-graph.pl
new file mode 100644
index 00000000000..43ce4e68db4
--- /dev/null
+++ b/pkgs/build-support/kernel/paths-from-graph.pl
@@ -0,0 +1,68 @@
+use strict;
+use File::Basename;
+
+my %storePaths;
+my %refs;
+
+foreach my $graph (@ARGV) {
+    open GRAPH, "<$graph" or die;
+
+    while (<GRAPH>) {
+        chomp;
+        my $storePath = "$_";
+        $storePaths{$storePath} = 1;
+
+        my $deriver = <GRAPH>; chomp $deriver;
+        my $count = <GRAPH>; chomp $count;
+
+        my @refs = ();
+        for (my $i = 0; $i < $count; ++$i) {
+            my $ref = <GRAPH>; chomp $ref;
+            push @refs, $ref;
+        }
+        $refs{$storePath} = \@refs;
+        
+    }
+    
+    close GRAPH;
+}
+
+
+if ($ENV{"printManifest"} eq "1") {
+    print "version {\n";
+    print "  ManifestVersion: 3\n";
+    print "}\n";
+
+    foreach my $storePath (sort (keys %storePaths)) {
+        my $base = basename $storePath;
+        print "localPath {\n";
+        print "  StorePath: $storePath\n";
+        print "  CopyFrom: /tmp/inst-store/$base\n";
+        print "  References: ";
+        foreach my $ref (@{$refs{$storePath}}) {
+            print "$ref ";
+        }
+        print "\n";
+        print "}\n";
+    }
+}
+
+elsif ($ENV{"printRegistration"} eq "1") {
+    # This is the format used by `nix-store --register-validity
+    # --hash-given' / `nix-store --load-db'.
+    foreach my $storePath (sort (keys %storePaths)) {
+        print "$storePath\n";
+        print "0000000000000000000000000000000000000000000000000000000000000000\n"; # !!! fix
+        print "\n"; # don't care about preserving the deriver
+        print scalar(@{$refs{$storePath}}), "\n";
+        foreach my $ref (@{$refs{$storePath}}) {
+            print "$ref\n";
+        }
+    }
+}
+
+else {
+    foreach my $storePath (sort (keys %storePaths)) {
+        print "$storePath\n";
+    }
+}
diff --git a/pkgs/build-support/vm/deb/deb-closure.pl b/pkgs/build-support/vm/deb/deb-closure.pl
new file mode 100644
index 00000000000..f35af6ca2da
--- /dev/null
+++ b/pkgs/build-support/vm/deb/deb-closure.pl
@@ -0,0 +1,162 @@
+use strict;
+use Dpkg::Cdata;
+use Dpkg::Deps;
+
+my $packagesFile = shift @ARGV;
+my $urlPrefix = shift @ARGV;
+my @toplevelPkgs = @ARGV;
+
+my %packages;
+
+
+# Parse the Packages file.
+open PACKAGES, "<$packagesFile" or die;
+
+while (1) {
+    my $cdata = parsecdata(\*PACKAGES, $packagesFile);
+    last unless defined $cdata;
+    #print $cdata->{Package}, "\n";
+    die unless defined $cdata->{Package};
+    $packages{$cdata->{Package}} = $cdata;
+}
+
+close PACKAGES;
+
+
+# Flatten a Dpkg::Deps dependency value into a list of package names.
+sub getDeps {
+    my $deps = shift;
+    #print "$deps\n";
+    if ($deps->isa('Dpkg::Deps::AND')) {
+        my @res = ();
+        foreach my $dep ($deps->get_deps()) {
+            push @res, getDeps($dep);
+        }
+        return @res;
+    } elsif ($deps->isa('Dpkg::Deps::OR')) {
+        # Arbitrarily pick the first alternative.
+        return getDeps(($deps->get_deps())[0]);
+    } elsif ($deps->isa('Dpkg::Deps::Simple')) {
+        return ($deps->{package});
+    } else {
+        die "unknown dep type";
+    }
+}
+
+
+# Process the "Provides" fields to be able to resolve virtual dependencies.
+my %provides;
+
+foreach my $cdata (values %packages) {
+    next unless defined $cdata->{Provides};
+    my @provides = getDeps(Dpkg::Deps::parse($cdata->{Provides}));
+    foreach my $name (@provides) {
+        #die "conflicting provide: $name\n" if defined $provides{$name};
+        $provides{$name} = $cdata->{Package};
+    }
+}
+
+
+# Determine the closure of a package.
+my %donePkgs;
+my %depsUsed;
+my @order = ();
+
+sub closePackage {
+    my $pkgName = shift;
+    print STDERR ">>> $pkgName\n";
+    my $cdata = $packages{$pkgName};
+    
+    if (!defined $cdata) {
+        die "unknown (virtual) package $pkgName"
+            unless defined $provides{$pkgName};
+        print STDERR "virtual $pkgName: using $provides{$pkgName}\n";
+        $pkgName = $provides{$pkgName};
+        $cdata = $packages{$pkgName};
+    }
+    
+    die "unknown package $pkgName" unless defined $cdata;
+    return if defined $donePkgs{$pkgName};
+    $donePkgs{$pkgName} = 1;
+
+    if (defined $cdata->{Provides}) {
+        foreach my $name (getDeps(Dpkg::Deps::parse($cdata->{Provides}))) {
+            $provides{$name} = $cdata->{Package};
+        }
+    }
+    
+    my @depNames = ();
+    
+    if (defined $cdata->{Depends}) {
+        print STDERR "    $pkgName: $cdata->{Depends}\n";
+        my $deps = Dpkg::Deps::parse($cdata->{Depends});
+        die unless defined $deps;
+        push @depNames, getDeps($deps);
+    }
+
+    if (defined $cdata->{'Pre-Depends'}) {
+        print STDERR "    $pkgName: $cdata->{'Pre-Depends'}\n";
+        my $deps = Dpkg::Deps::parse($cdata->{'Pre-Depends'});
+        die unless defined $deps;
+        push @depNames, getDeps($deps);
+    }
+
+    foreach my $depName (@depNames) {
+        closePackage($depName);
+    }
+
+    push @order, $pkgName;
+    $depsUsed{$pkgName} = \@depNames;
+}
+
+foreach my $pkgName (@toplevelPkgs) {
+    closePackage $pkgName;
+}
+
+
+# Generate the output Nix expression.
+print "# This is a generated file.  Do not modify!\n";
+print "# Following are the Debian packages constituting the closure of: @toplevelPkgs\n\n";
+print "{fetchurl}:\n\n";
+print "[\n\n";
+
+# Output the packages in strongly connected components.
+my %done;
+my %forward;
+my $newComponent = 1;
+foreach my $pkgName (@order) {
+    $done{$pkgName} = 1;
+    my $cdata = $packages{$pkgName};
+    my @deps = @{$depsUsed{$pkgName}};
+    foreach my $dep (@deps) {
+        $dep = $provides{$dep} if defined $provides{$dep};
+        $forward{$dep} = 1 unless defined $done{$dep};
+    }
+    delete $forward{$pkgName};
+
+    print "  [\n\n" if $newComponent;
+    $newComponent = 0;
+    
+    print "    (fetchurl {\n";
+    print "      url = $urlPrefix/$cdata->{Filename};\n";
+    print "      sha256 = \"$cdata->{SHA256}\";\n";
+    print "    })\n";
+    print "\n";
+
+    if (keys %forward == 0) {
+        print "  ]\n\n";
+        $newComponent = 1;
+    }
+}
+
+foreach my $pkgName (@order) {
+    my $cdata = $packages{$pkgName};
+}
+
+print "]\n";
+
+if ($newComponent != 1) {
+    print STDERR "argh: ", keys %forward, "\n";
+    exit 1;
+}
+    
diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix
new file mode 100644
index 00000000000..ab6b3911457
--- /dev/null
+++ b/pkgs/build-support/vm/default.nix
@@ -0,0 +1,823 @@
+{pkgs}:
+
+with pkgs;
+
+rec {
+
+
+  inherit (kernelPackages) kernel klibcShrunk;
+
+
+  modulesClosure = makeModulesClosure {
+    inherit kernel;
+    rootModules = ["cifs" "ne2k_pci" "nls_utf8" "ata_piix" "sd_mod"];
+  };
+
+  
+  mountCifs = (makeStaticBinaries stdenv).mkDerivation {
+    name = "mount.cifs";
+    src = fetchurl {
+      name = "mount.cifs.c";
+      url = "http://websvn.samba.org/cgi-bin/viewcvs.cgi/*checkout*/branches/SAMBA_3_0/source/client/mount.cifs.c?rev=6103";
+      sha256 = "19205gd3pv8g519hlbjaw559wqgf0h2vkln9xgqaqip2h446qarp";
+    };
+    buildInputs = [nukeReferences];
+    buildCommand = ''
+      ensureDir $out/bin
+      gcc -Wall $src -o $out/bin/mount.cifs
+      strip $out/bin/mount.cifs
+      nuke-refs $out/bin/mount.cifs
+    '';
+    allowedReferences = []; # prevent accidents like glibc being included in the initrd
+  };
+
+  
+  stage1Init = writeScript "vm-run-stage1" ''
+    #! ${klibcShrunk}/bin/sh.shared -e
+    echo START
+
+    export PATH=${klibcShrunk}/bin:${mountCifs}/bin
+
+    mkdir /etc
+    echo -n > /etc/fstab
+
+    mount -t proc none /proc
+
+    for o in $(cat /proc/cmdline); do
+      case $o in
+        mountDisk=1)
+          mountDisk=1
+          ;;
+        command=*)
+          set -- $(IFS==; echo $o)
+          command=$2
+          ;;
+        tmpDir=*)
+          set -- $(IFS==; echo $o)
+          export tmpDir=$2
+          ;;
+        out=*)
+          set -- $(IFS==; echo $o)
+          export out=$2
+          ;;
+      esac
+    done
+
+    for i in $(cat ${modulesClosure}/insmod-list); do
+      args=
+      case $i in
+        */cifs.ko)
+          args="CIFSMaxBufSize=4194304"
+          ;;
+      esac
+      echo "loading module $i with args $args"
+      insmod $i $args
+    done
+
+    mount -t tmpfs none /dev
+    mknod /dev/null c 1 3
+    mknod /dev/zero c 1 5
+    mknod /dev/tty  c 5 0
+    mknod /dev/sda  b 8 0
+    mknod /dev/hda  b 3 0
+    
+    ipconfig 10.0.2.15:::::eth0:none
+
+    mkdir /fs
+
+    if test -z "$mountDisk"; then
+      mount -t tmpfs none /fs
+    else
+      mount -t ext2 /dev/sda /fs
+    fi
+    
+    mkdir -p /fs/hostfs
+    
+    mkdir -p /fs/dev
+    mount -o bind /dev /fs/dev
+
+    mount.cifs //10.0.2.4/qemu /fs/hostfs -o guest,username=nobody
+
+    mkdir -p /fs/nix/store
+    mount -o bind /fs/hostfs/nix/store /fs/nix/store
+    
+    mkdir -p /fs/tmp
+    mount -t tmpfs -o "mode=755" none /fs/tmp
+
+    mkdir -p /fs/proc
+    mount -t proc none /fs/proc
+
+    mkdir -p /fs/etc
+    ln -sf /proc/mounts /fs/etc/mtab
+    
+    echo "Now running: $command"
+    test -n "$command"
+
+    set +e
+    chroot /fs $command /tmp $out /hostfs/$tmpDir
+    echo $? > /fs/hostfs/$tmpDir/in-vm-exit
+
+    mount -o remount,ro dummy /fs
+
+    echo DONE
+    reboot
+  '';
+
+  
+  initrd = makeInitrd {
+    contents = [
+      { object = stage1Init;
+        symlink = "/init";
+      }
+    ];
+  };
+
+  
+  stage2Init = writeScript "vm-run-stage2" ''
+    #! ${bash}/bin/sh
+    source $3/saved-env
+    
+    export NIX_STORE=/nix/store
+    export NIX_BUILD_TOP="$1"
+    export TMPDIR="$1"
+    export PATH=/empty
+    out="$2"
+    export ORIG_TMPDIR="$3"
+    cd "$NIX_BUILD_TOP"
+
+    if ! test -e /bin/sh; then
+      ${coreutils}/bin/mkdir -p /bin
+      ${coreutils}/bin/ln -s ${bash}/bin/sh /bin/sh
+    fi
+
+    # For debugging: if this is the second time this image is run,
+    # then don't start the build again, but instead drop the user into
+    # an interactive shell.
+    if test -n "$origBuilder" -a ! -e /.debug; then
+      ${coreutils}/bin/touch /.debug
+      exec $origBuilder $origArgs
+    else
+      export PATH=/bin:/usr/bin:${coreutils}/bin
+      echo "Starting interactive shell..."
+      echo "(To run the original builder: \$origBuilder \$origArgs)"
+      exec ${bash}/bin/sh
+    fi
+  '';
+
+
+  qemuCommandLinux = ''
+    QEMU_SMBD_COMMAND=${samba}/sbin/smbd qemu-system-x86_64 \
+      -nographic -no-reboot \
+      -smb / -hda $diskImage \
+      -kernel ${kernel}/vmlinuz \
+      -initrd ${initrd}/initrd \
+      -append "console=ttyS0 panic=1 command=${stage2Init} tmpDir=$TMPDIR out=$out mountDisk=$mountDisk" \
+      $QEMU_OPTS
+  '';
+
+  
+  vmRunCommand = qemuCommand: writeText "vm-run" ''
+    export > saved-env
+
+    PATH=${coreutils}/bin:${kvm}/bin
+
+    diskImage=''${diskImage:-/dev/null}
+
+    eval "$preVM"
+
+    # Write the command to start the VM to a file so that the user can
+    # debug inside the VM if the build fails (when Nix is called with
+    # the -K option to preserve the temporary build directory).
+    cat > ./run-vm <<EOF
+    #! ${bash}/bin/sh
+    diskImage=$diskImage
+    TMPDIR=$TMPDIR
+    ${qemuCommand}
+    EOF
+
+    chmod +x ./run-vm
+    source ./run-vm
+    
+    if ! test -e in-vm-exit; then
+      echo "Virtual machine didn't produce an exit code."
+      exit 1
+    fi
+    
+    eval "$postVM"
+
+    exit $(cat in-vm-exit)
+  '';
+
+
+  createEmptyImage = {size, fullName}: ''
+    mkdir $out
+    diskImage=$out/image
+    qemu-img create -f qcow $diskImage "${toString size}M"
+
+    mkdir $out/nix-support
+    echo "${fullName}" > $out/nix-support/full-name
+  '';
+
+
+  createRootFS = ''
+    mkdir /mnt
+    ${e2fsprogs}/sbin/mke2fs -F /dev/sda
+    ${klibcShrunk}/bin/mount -t ext2 /dev/sda /mnt
+
+    if test -e /mnt/.debug; then
+      exec ${bash}/bin/sh
+    fi
+    touch /mnt/.debug
+
+    mkdir /mnt/proc /mnt/dev /mnt/sys /mnt/bin
+  '';
+
+
+  /* Run a derivation in a Linux virtual machine (using Qemu/KVM).  By
+     default, there is no disk image; the root filesystem is a tmpfs,
+     and /nix/store is shared with the host (via the CIFS protocol to
+     a Samba instance automatically started by Qemu).  Thus, any pure
+     Nix derivation should run unmodified, e.g. the call
+
+       runInLinuxVM patchelf
+
+     will build the derivation `patchelf' inside a VM.  The attribute
+     `preVM' can optionally contain a shell command to be evaluated
+     *before* the VM is started (i.e., on the host).  The attribute
+     `memSize' specifies the memory size of the VM in megabytes,
+     defaulting to 256.  The attribute `diskImage' can optionally
+     specify a file system image to be attached to /dev/sda.  (Note
+     that currently we expect the image to contain a filesystem, not a
+     full disk image with a partition table etc.)
+
+     If the build fails and Nix is run with the `-K' option, a script
+     `run-vm' will be left behind in the temporary build directory
+     that allows you to boot into the VM and debug it interactively. */
+     
+  runInLinuxVM = attrs: derivation (removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"] // {
+    builder = "${bash}/bin/sh";
+    args = ["-e" (vmRunCommand qemuCommandLinux)];
+    origArgs = attrs.args;
+    origBuilder = attrs.builder;
+    QEMU_OPTS = "-m ${toString (if attrs ? memSize then attrs.memSize else 256)}";
+  });
+
+
+  qemuCommandGeneric = ''
+    QEMU_SMBD_COMMAND=${samba}/sbin/smbd qemu-system-x86_64 \
+      -nographic -no-reboot \
+      -smb $(pwd) -hda $diskImage \
+      $QEMU_OPTS
+  '';
+
+  
+  /* Run a command in a x86 virtual machine image containing an
+     arbitrary OS.  The VM should be configured to do the following:
+
+     - Write log output to the serial port.
+
+     - Mount //10.0.2.4/qemu via SMB.
+
+     - Execute the command "cmd" on the SMB share.  It can access the
+       original derivation attributes in "saved-env" on the share.
+
+     - Produce output under "out" on the SMB share.
+
+     - Write an exit code to "in-vm-exit" on the SMB share ("0"
+       meaning success).
+
+     - Reboot to shutdown the machine (because Qemu doesn't seem
+       capable of a APM/ACPI VM shutdown).
+  */
+  runInGenericVM = attrs: derivation (removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"] // {
+    system = "i686-linux";
+    builder = "${bash}/bin/sh";
+    args = ["-e" (vmRunCommand qemuCommandGeneric)];
+    QEMU_OPTS = "-m ${toString (if attrs ? memSize then attrs.memSize else 256)}";
+
+    preVM = ''
+      diskImage=$(pwd)/image
+      origImage=${attrs.diskImage}
+      if test -d "$origImage"; then origImage="$origImage/image"; fi
+      qemu-img create -b "$origImage" -f qcow $diskImage
+
+      echo "$buildCommand" > cmd
+
+      eval "$postPreVM"
+    '';
+
+    postVM = ''
+      cp -prvd out $out
+    '';
+  });
+
+
+  /* Like runInLinuxVM, but run the build not using the stdenv from
+     the Nix store, but using the tools provided by /bin, /usr/bin
+     etc. from the specified filesystem image, which typically is a
+     filesystem containing a non-NixOS Linux distribution. */
+     
+  runInLinuxImage = attrs: runInLinuxVM (attrs // {
+    mountDisk = true;
+
+    /* Mount `image' as the root FS, but use a temporary copy-on-write
+       image since we don't want to (and can't) write to `image'. */
+    preVM = ''
+      diskImage=$(pwd)/image
+      origImage=${attrs.diskImage}
+      if test -d "$origImage"; then origImage="$origImage/image"; fi
+      qemu-img create -b "$origImage" -f qcow $diskImage
+    '';
+
+    /* Inside the VM, run the stdenv setup script normally, but at the
+       very end set $PATH and $SHELL to the `native' paths for the
+       distribution inside the VM. */
+    postHook = ''
+      PATH=/usr/bin:/bin:/usr/sbin:/sbin
+      SHELL=/bin/sh
+      eval "$origPostHook"
+    '';
+
+    origPostHook = if attrs ? postHook then attrs.postHook else "";
+
+    /* Don't run Nix-specific build steps like patchelf. */
+    fixupPhase = "true";
+  });
+
+
+  /* Create a filesystem image of the specified size and fill it with
+     a set of RPM packages. */
+    
+  fillDiskWithRPMs =
+    {size ? 1024, rpms, name, fullName, preInstall ? "", postInstall ? "", runScripts ? true}:
+    
+    runInLinuxVM (stdenv.mkDerivation {
+      inherit name preInstall postInstall rpms;
+
+      preVM = createEmptyImage {inherit size fullName;};
+
+      buildCommand = ''
+        ${createRootFS}
+
+        chroot=$(type -tP chroot)
+        
+        echo "unpacking RPMs..."
+        for i in $rpms; do
+            echo "$i..."
+            ${rpm}/bin/rpm2cpio "$i" | (cd /mnt && ${cpio}/bin/cpio -i --make-directories)
+        done
+
+        eval "$preInstall"
+
+        echo "initialising RPM DB..."
+        PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
+          ldconfig -v || true
+        PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
+          rpm --initdb
+
+        # Make the Nix store available in /mnt, because that's where the RPMs live.
+        mkdir -p /mnt/nix/store
+        ${klibcShrunk}/bin/mount -o bind /nix/store /mnt/nix/store
+        
+        echo "installing RPMs..."
+        PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
+          rpm -iv ${if runScripts then "" else "--noscripts"} $rpms
+
+        echo "running post-install script..."
+        eval "$postInstall"
+        
+        rm /mnt/.debug
+        
+        ${klibcShrunk}/bin/umount /mnt/nix/store
+        ${klibcShrunk}/bin/umount /mnt
+      '';
+    });
+
+
+  /* Generate a script that can be used to run an interactive session
+     in the given image. */
+     
+  makeImageTestScript = image: writeScript "image-test" ''
+    #! ${bash}/bin/sh
+    if test -z "$1"; then
+      echo "Syntax: $0 <copy-on-write-temp-file>"
+      exit 1
+    fi
+    diskImage="$1"
+    if ! test -e "$diskImage"; then
+      qemu-img create -b ${image}/image -f qcow "$diskImage"
+    fi
+    export TMPDIR=$(mktemp -d)
+    export out=/dummy
+    export origBuilder=
+    export origArgs=
+    export > $TMPDIR/saved-env
+    mountDisk=1
+    ${qemuCommandLinux}
+  '';
+
+
+  /* Build RPM packages from the tarball `src' in the Linux
+     distribution installed in the filesystem `diskImage'.  The
+     tarball must contain an RPM specfile. */
+  
+  buildRPM = attrs: runInLinuxImage (stdenv.mkDerivation ({
+    phases = "prepareImagePhase sysInfoPhase buildPhase installPhase";
+
+    outDir = "rpms/${attrs.diskImage.name}";
+
+    prepareImagePhase = ''
+      if test -n "$extraRPMs"; then
+        rpm -iv $extraRPMs
+      fi
+    '';
+  
+    sysInfoPhase = ''
+      if test -e /etc/fedora-release; then echo "Fedora release: $(cat /etc/fedora-release)"; fi
+      if test -e /etc/SuSE-release; then echo "SUSE release: $(cat /etc/SuSE-release)"; fi
+      header "installed RPM packages"
+      rpm -qa --qf "%{Name}-%{Version}-%{Release} (%{Arch}; %{Distribution}; %{Vendor})\n"
+      stopNest
+    '';
+    
+    buildPhase = ''
+      eval "$preBuild"
+
+      # Hacky: RPM looks for <basename>.spec inside the tarball, so
+      # strip off the hash.
+      stripHash "$src"
+      srcName="$strippedName"
+      cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
+
+      rpmbuild -vv -ta "$srcName" || fail
+
+      eval "$postBuild"
+    '';
+
+    installPhase = ''
+      ensureDir $out/$outDir
+      find /usr/src -name "*.rpm" -exec cp {} $out/$outDir \;
+
+      for i in $out/$outDir/*.rpm; do
+        header "Generated RPM/SRPM: $i"
+        rpm -qip $i
+        stopNest
+      done
+    ''; # */
+  } // attrs));
+
+
+  /* Create a filesystem image of the specified size and fill it with
+     a set of Debian packages.  `debs' must be a list of list of
+     .deb files, namely, the Debian packages grouped together into
+     strongly connected components.  See deb/deb-closure.nix. */
+
+  fillDiskWithDebs =
+    {size ? 1024, debs, name, fullName, postInstall ? null}:
+    
+    runInLinuxVM (stdenv.mkDerivation {
+      inherit name postInstall;
+
+      debs = (lib.intersperse "|" debs);
+
+      preVM = createEmptyImage {inherit size fullName;};
+
+      buildCommand = ''
+        ${createRootFS}
+
+        echo "initialising Debian DB..."
+        PATH=$PATH:${dpkg}/bin:${dpkg}/sbin:${glibc}/sbin
+
+        # Unpack the .debs.  We do this to prevent pre-install scripts
+        # (which have lots of circular dependencies) from barfing.
+        echo "unpacking Debs..."
+        
+        for deb in $debs; do
+          if test "$deb" != "|"; then
+            echo "$deb..."
+            dpkg-deb --extract "$deb" /mnt
+          fi
+        done
+
+        # Make the Nix store available in /mnt, because that's where the .debs live.
+        mkdir -p /mnt/inst/nix/store
+        ${klibcShrunk}/bin/mount -o bind /nix/store /mnt/inst/nix/store
+
+        ${klibcShrunk}/bin/mount -o bind /dev /mnt/dev
+        
+        # Misc. files/directories assumed by various packages.
+        touch /mnt/etc/shells
+        touch /mnt/var/lib/dpkg/status
+        touch /mnt/var/lib/dpkg/available
+        touch /mnt/var/lib/dpkg/diversions
+
+        # Now install the .debs.  This is basically just to register
+        # them with dpkg and to make their pre/post-install scripts
+        # run.
+        echo "installing Debs..."
+
+        export DEBIAN_FRONTEND=noninteractive
+        
+        oldIFS="$IFS"
+        IFS="|"
+        for component in $debs; do
+          IFS="$oldIFS"
+          echo
+          echo ">>> INSTALLING COMPONENT: $component"
+          debs=
+          for i in $component; do
+            debs="$debs /inst/$i";
+          done
+          chroot=$(type -tP chroot)
+          PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
+            /usr/bin/dpkg --install --force-all $debs < /dev/null
+        done
+        
+        echo "running post-install script..."
+        eval "$postInstall"
+        
+        rm /mnt/.debug
+        
+        ${klibcShrunk}/bin/umount /mnt/inst/nix/store
+        ${klibcShrunk}/bin/umount /mnt/dev
+        ${klibcShrunk}/bin/umount /mnt
+      '';
+    });
+
+
+  /* Generate a Nix expression containing fetchurl calls for the
+     closure of a set of top-level RPM packages from the
+     `primary.xml.gz' file of a Fedora or openSUSE distribution. */
+     
+  rpmClosureGenerator =
+    {name, packagesList, urlPrefix, packages, archs ? []}:
+    
+    runCommand "${name}.nix" {buildInputs = [perl perlXMLSimple]; inherit archs;} ''
+      gunzip < ${packagesList} > ./packages.xml
+      perl -w ${rpm/rpm-closure.pl} \
+        ./packages.xml ${urlPrefix} ${toString packages} > $out
+    '';
+
+
+  /* Helper function that combines rpmClosureGenerator and
+     fillDiskWithRPMs to generate a disk image from a set of package
+     names. */
+     
+  makeImageFromRPMDist =
+    { name, fullName, size ? 1024, urlPrefix, packagesList, packages
+    , postInstall ? "", archs ? ["noarch" "i386"], runScripts ? true}:
+
+    fillDiskWithRPMs {
+      inherit name fullName size postInstall runScripts;
+      rpms = import (rpmClosureGenerator {
+        inherit name packagesList urlPrefix packages archs;
+      }) {inherit fetchurl;};
+    };
+
+
+  /* Like `rpmClosureGenerator', but now for Debian/Ubuntu releases
+     (i.e. generate a closure from a Packages.bz2 file). */
+
+  debClosureGenerator =
+    {name, packagesList, urlPrefix, packages}:
+    
+    runCommand "${name}.nix" {} ''
+      bunzip2 < ${packagesList} > ./Packages
+      ${perl}/bin/perl -I${dpkg} -w ${deb/deb-closure.pl} \
+        ./Packages ${urlPrefix} ${toString packages} > $out
+    '';
+  
+
+  /* Helper function that combines debClosureGenerator and
+     fillDiskWithDebs to generate a disk image from a set of package
+     names. */
+     
+  makeImageFromDebDist =
+    {name, fullName, size ? 1024, urlPrefix, packagesList, packages, postInstall ? ""}:
+
+    fillDiskWithDebs {
+      inherit name fullName size postInstall;
+      debs = import (debClosureGenerator {
+        inherit name packagesList urlPrefix packages;
+      }) {inherit fetchurl;};
+    };
+
+
+  /* A bunch of functions that build disk images of various Linux
+     distributions, given a set of top-level package names to be
+     installed in the image. */
+
+  diskImageFuns = {
+
+    fedora2i386 = args: makeImageFromRPMDist ({
+      name = "fedora-core-2-i386";
+      fullName = "Fedora Core 2 (i386)";
+      packagesList = fetchurl {
+        url = mirror://fedora/linux/core/2/i386/os/repodata/primary.xml.gz;
+        sha256 = "1nq1k2k0nzkii737cka301f0vbd2ix2wsfvi6bblpi748q6h2w4k";
+      };
+      urlPrefix = mirror://fedora/linux/core/2/i386/os;
+      runScripts = false;
+    } // args);
+    
+    fedora3i386 = args: makeImageFromRPMDist ({
+      name = "fedora-core-3-i386";
+      fullName = "Fedora Core 3 (i386)";
+      packagesList = fetchurl {
+        url = mirror://fedora/linux/core/3/i386/os/repodata/primary.xml.gz;
+        sha256 = "13znspn4g1bkjkk47393k9chswgzl6nx1n0q6h2wrw52c7d9nw9i";
+      };
+      urlPrefix = mirror://fedora/linux/core/3/i386/os;
+      archs = ["noarch" "i386" "i586"];
+      runScripts = false;
+    } // args);
+    
+    fedora5i386 = args: makeImageFromRPMDist ({
+      name = "fedora-core-5-i386";
+      fullName = "Fedora Core 5 (i386)";
+      packagesList = fetchurl {
+        url = mirror://fedora/linux/core/5/i386/os/repodata/primary.xml.gz;
+        sha256 = "0lfk4mzrpiyls8h7k9ckc3vgywbmg05zsr4ag6qakgnv9gljijig";
+      };
+      urlPrefix = mirror://fedora/linux/core/5/i386/os;
+    } // args);
+    
+    fedora7i386 = args: makeImageFromRPMDist ({
+      name = "fedora-7-i386";
+      fullName = "Fedora 7 (i386)";
+      packagesList = fetchurl {
+        url = mirror://fedora/linux/releases/7/Fedora/i386/os/repodata/primary.xml.gz;
+        sha256 = "0zq7ifirj45wry7b2qkm12qhzzazal3hn610h5kwbrfr2xavs882";
+      };
+      urlPrefix = mirror://fedora/linux/releases/7/Fedora/i386/os;
+    } // args);
+    
+    fedora8i386 = args: makeImageFromRPMDist ({
+      name = "fedora-8-i386";
+      fullName = "Fedora 8 (i386)";
+      packagesList = fetchurl {
+        url = mirror://fedora/linux/releases/8/Fedora/i386/os/repodata/primary.xml.gz;
+        sha256 = "0vr9345rrk0vhs4pc9cjp8npdkqz0xqyirv84vhyfn533m9ws36f";
+      };
+      urlPrefix = mirror://fedora/linux/releases/8/Fedora/i386/os;
+    } // args);
+
+    fedora9i386 = args: makeImageFromRPMDist ({
+      name = "fedora-9-i386";
+      fullName = "Fedora 9 (i386)";
+      packagesList = fetchurl {
+        url = mirror://fedora/linux/releases/9/Fedora/i386/os/repodata/primary.xml.gz;
+        sha256 = "18780xgyag5acx79warcpvzlfkm0mni8xawl6jjvgxg9n3lp6zg0";
+      };
+      urlPrefix = mirror://fedora/linux/releases/9/Fedora/i386/os;
+    } // args);
+
+    opensuse103i386 = args: makeImageFromRPMDist ({
+      name = "opensuse-10.3-i586";
+      fullName = "openSUSE 10.3 (i586)";
+      packagesList = fetchurl {
+        url = mirror://opensuse/distribution/10.3/repo/oss/suse/repodata/primary.xml.gz;
+        sha256 = "0zb5kxsb755nqq9i8jdclmanacyf551ncx6a011v9jqphsvyfvd7";
+      };
+      urlPrefix = mirror://opensuse/distribution/10.3/repo/oss/suse/;
+      archs = ["noarch" "i586"];
+    } // args);
+
+    ubuntu710i386 = args: makeImageFromDebDist ({
+      name = "ubuntu-7.10-gutsy-i386";
+      fullName = "Ubuntu 7.10 Gutsy (i386)";
+      packagesList = fetchurl {
+        url = mirror://ubuntu/dists/gutsy/main/binary-i386/Packages.bz2;
+        sha1 = "8b52ee3d417700e2b2ee951517fa25a8792cabfd";
+      };
+      urlPrefix = mirror://ubuntu;
+    } // args);
+        
+    debian40r3i386 = args: makeImageFromDebDist ({
+      name = "debian-4.0r3-etch-i386";
+      fullName = "Debian 4.0r3 Etch (i386)";
+      packagesList = fetchurl {
+        url = mirror://debian/dists/etch/main/binary-i386/Packages.bz2;
+        sha256 = "7a8f2777315d71fd7321d1076b3bf5f76afe179fe66c2ce8e1ff4baed6424340";
+      };
+      urlPrefix = mirror://debian;
+    } // args);
+        
+  };
+
+
+  /* Common packages for Fedora images. */
+  commonFedoraPackages = [
+    "autoconf"
+    "automake"
+    "basesystem"
+    "bzip2"
+    "curl"
+    "diffutils"
+    "fedora-release"
+    "findutils"
+    "gawk"
+    "gcc-c++"
+    "gzip"
+    "make"
+    "patch"
+    "perl"
+    "pkgconfig"
+    "rpm"
+    "rpm-build"
+    "tar"
+    "unzip"
+  ];
+
+
+  /* Common packages for openSUSE images. */
+  commonOpenSUSEPackages = [
+    "aaa_base"
+    "autoconf"
+    "automake"
+    "bzip2"
+    "curl"
+    "devs"
+    "diffutils"
+    "findutils"
+    "gawk"
+    "gcc-c++"
+    "gzip"
+    "make"
+    "patch"
+    "perl"
+    "pkg-config"
+    "rpm"
+    "tar"
+    "unzip"
+    "util-linux"
+  ];
+
+
+  /* Common packages for Debian/Ubuntu images. */
+  commonDebianPackages = [
+    "base-passwd"
+    "dpkg"
+    "libc6-dev"
+    "perl"
+    "sysvinit"
+    "bash"
+    "gzip"
+    "bzip2"
+    "tar"
+    "grep"
+    "findutils"
+    "g++"
+    "make"
+    "curl"
+    "patch"
+    "diff"
+  ];
+
+
+  /* A bunch of disk images. */
+
+  diskImages = {
+
+    redhat9i386 = fillDiskWithRPMs {
+      name = "redhat-9-i386";
+      fullName = "Red Hat Linux 9 (i386)";
+      size = 1024;
+      rpms = import ./rpm/redhat-9-i386.nix {inherit fetchurl;};
+    };
+    
+    suse90i386 = fillDiskWithRPMs {
+      name = "suse-9.0-i386";
+      fullName = "SUSE Linux 9.0 (i386)";
+      size = 1024;
+      rpms = import ./rpm/suse-9-i386.nix {inherit fetchurl;};
+      # Urgh.  The /etc/group entries are installed by aaa_base (or
+      # something) but due to dependency ordering, that package isn't
+      # installed yet by the time some other packages refer to these
+      # entries.
+      preInstall = ''
+        echo 'bin:x:1:daemon' >> /mnt/etc/group
+        echo 'tty:x:5:' >> /mnt/etc/group
+        echo 'disk:x:6:' >> /mnt/etc/group
+        echo 'lp:x:7:' >> /mnt/etc/group
+        echo 'uucp:x:14:' >> /mnt/etc/group
+        echo 'audio:x:17:' >> /mnt/etc/group
+        echo 'video:x:33:' >> /mnt/etc/group
+      '';
+    };
+    
+    fedora2i386 = diskImageFuns.fedora2i386 { packages = commonFedoraPackages; };
+    fedora3i386 = diskImageFuns.fedora3i386 { packages = commonFedoraPackages; };
+    fedora5i386 = diskImageFuns.fedora5i386 { packages = commonFedoraPackages; };
+    fedora7i386 = diskImageFuns.fedora7i386 { packages = commonFedoraPackages; };
+    fedora8i386 = diskImageFuns.fedora8i386 { packages = commonFedoraPackages; };
+    fedora9i386 = diskImageFuns.fedora9i386 { packages = commonFedoraPackages; };
+    opensuse103i386 = diskImageFuns.opensuse103i386 { packages = commonOpenSUSEPackages; };
+    
+    ubuntu710i386 = diskImageFuns.ubuntu710i386 { packages = commonDebianPackages; };
+    debian40r3i386 = diskImageFuns.debian40r3i386 { packages = commonDebianPackages; };
+
+  };
+
+
+}
diff --git a/pkgs/build-support/vm/rpm/redhat-9-i386.list b/pkgs/build-support/vm/rpm/redhat-9-i386.list
new file mode 100644
index 00000000000..4f46f66cfac
--- /dev/null
+++ b/pkgs/build-support/vm/rpm/redhat-9-i386.list
@@ -0,0 +1,92 @@
+baseURL ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS
+autoconf-2.57-3.noarch.rpm cea6ded7bd395468a41e9b6380cf5c46
+automake-1.6.3-5.noarch.rpm 9a518459499504faa786b63bd88374d1
+basesystem-8.0-2.noarch.rpm 64bc91a544ed3b175e617df2b6683eec
+bash-2.05b-20.i386.rpm db4db03fc2d33e3519d72b8f54d483ef
+binutils-2.13.90.0.18-9.i386.rpm cd09dfb42d1f9cbd70eba37430762bb6
+bzip2-1.0.2-8.i386.rpm ca663b78121235bdaafeced854e8e966
+bzip2-devel-1.0.2-8.i386.rpm 1e69cd15c6288d41bf989afa579b2585
+bzip2-libs-1.0.2-8.i386.rpm 996ac1deed904c7d75960b31dfe61b01
+chkconfig-1.3.8-1.i386.rpm 8ab54c42c15b3f649174e6bfa764adde
+coreutils-4.5.3-19.i386.rpm 972cd0ff8f3e784c2bc5666e80cf354a
+cpp-3.2.2-5.i386.rpm 49d8c65dfa401b96b8018b5f6946c985
+cracklib-2.7-21.i386.rpm 31326ff8fb099f10b5d857dc10a33fa3
+cracklib-dicts-2.7-21.i386.rpm d39c8baf399b348db40f3137e93dae03
+curl-7.9.8-5.i386.rpm 4899792440ce948316546a6a85e1a2ef
+db4-4.0.14-20.i386.rpm 5fec52fddea8e7cd88cfaa34839cc4b3
+dev-3.3.2-5.i386.rpm a8a45208c6e18cac1bf897d5eb0ac07e
+diffutils-2.8.1-6.i386.rpm 772331d623e47069d464760fa68fd0d9
+e2fsprogs-1.32-6.i386.rpm 0b728dbe2d88c87951a921158a80184a
+elfutils-libelf-0.76-3.i386.rpm 1f4a143c12634884ce2a36eef141e6b3
+expat-1.95.5-2.i386.rpm 76aa046090620b8c51107a94a3e80d7c
+file-3.39-9.i386.rpm b0560e1725f28fe375f9885a7a6be684
+filesystem-2.2.1-3.i386.rpm 897e20be2729051cae7a5bc32efb6b3f
+findutils-4.1.7-9.i386.rpm be0e80cec36c3eabf172d5003dd79466
+fontconfig-2.1-9.i386.rpm 86e827ffaa502266116047e840f8eb8f
+freetype-2.1.3-6.i386.rpm 64597ef3568d30982be5c0779f062ff2
+gawk-3.1.1-9.i386.rpm 72da64dc330d5945ae80c1779390ac2e
+gcc-3.2.2-5.i386.rpm aa544de315b6ba5478d3f6e0c15d0208
+gcc-c++-3.2.2-5.i386.rpm a287f9ac6f8e2efc4965186366989684
+gdbm-1.8.0-20.i386.rpm 819986ab928712c2c3c9324d74b360b8
+glib-1.2.10-10.i386.rpm 24d900aaab3ca9561f7ff2d7e3a206bb
+glibc-2.3.2-11.9.i386.rpm d923d7a9a5ac6c25cb51517b23843f78
+glibc-common-2.3.2-11.9.i386.rpm f63000e72fc1adc2c23d4de3ba9ca2a0
+glibc-debug-2.3.2-11.9.i386.rpm ae4aa98a669c3edc7b3c97b1ef409c43
+glibc-devel-2.3.2-11.9.i386.rpm 569afc17dd5f1208407b3742a3849b1c
+glibc-kernheaders-2.4-8.10.i386.rpm 17f4befda9601ac4e3d312245affee2b
+grep-2.5.1-7.i386.rpm 0606cd6f5516817fe56d6bcc8afe179a
+gzip-1.3.3-9.i386.rpm b47a6dfbf36d55a93e3d3920e936a2a7
+info-4.3-5.i386.rpm 8ce01d5cf0287d8cb012bce443679658
+initscripts-7.14-1.i386.rpm 12258ed059d3de4d7a6abef4d4d14222
+iproute-2.4.7-7.i386.rpm b363643aa70272a146ca92c4577ebced
+iputils-20020927-2.i386.rpm 83da3128b0da1fdcfd59786451c9d5eb
+krb5-libs-1.2.7-10.i386.rpm 9865f9f50631007ecdd409a53626502c
+less-378-7.i386.rpm 608656bbe868016ea464d965e07a026c
+libgcc-3.2.2-5.i386.rpm 91cae96d5ac2f19b20cb0c07906aed06
+libjpeg-6b-26.i386.rpm 3c350fc137a973249a85671083ed508b
+libpng-1.2.2-16.i386.rpm b7d5a39ec3d2c73e0f944d0f525ce79c
+libstdc++-3.2.2-5.i386.rpm 09ffb26f39e27232d3c385f5fbc1ef1d
+libstdc++-devel-3.2.2-5.i386.rpm 31768c560244755d32185db6022a4b75
+libtermcap-2.0.8-35.i386.rpm 26883bbee99b436059bd8db85426f3d4
+libtiff-3.5.7-11.i386.rpm e29006e58367d587c0632fb77113841f
+libtool-libs-1.4.3-5.i386.rpm 5fbbdfb5e1cf43ee03fc4f8a2bc4eaba
+m4-1.4.1-13.i386.rpm 38c55c667d34492f24c5946a3374650d
+make-3.79.1-17.i386.rpm 5144104c693ee61250e8fd7d75bab866
+mingetty-1.01-1.i386.rpm d3e42b0faebc682fb3c31216786e0702
+mktemp-1.5-18.i386.rpm 28f1bf48c65ce9a5fd18a53fc71675b0
+modutils-2.4.22-8.i386.rpm db39bb8d565162e3f8608190eb7a19fa
+mount-2.11y-9.i386.rpm 280a81dfd645785fd2af9fe312788256
+ncurses-5.3-4.i386.rpm e941b37d22dc9ac4a8c37960c5fa337f
+ncurses-devel-5.3-4.i386.rpm 5b3d837bba70045ccb6fccb63ec35dc1
+net-tools-1.60-12.i386.rpm 20c2bca22ba3f63c43190b63ebd78be5
+openssl-0.9.7a-2.i386.rpm 39105ce3607fac29a5e0d227e69fea38
+pam-0.75-48.i386.rpm fe77ccc841c5fbb830c81867e8e0f164
+patch-2.5.4-16.i386.rpm 351d225da983e5684fa4c5c8d5ead90f
+pcre-3.9-10.i386.rpm b545fff04823c776e37142764e31613c
+perl-5.8.0-88.i386.rpm c00258c140d4ac1650dcaab4abbda253
+perl-Filter-1.29-3.i386.rpm 27a82686fe46c220683a447d73c42375
+pkgconfig-0.14.0-3.i386.rpm 1502d26e4fdec84cce1eee6fb329f4e7
+popt-1.8-0.69.i386.rpm 8d827ac879feb6bd5a4055a9338d86a1
+procps-2.0.11-6.i386.rpm 1068278922d4cf486d1f5d9b8109fb81
+psmisc-21.2-4.i386.rpm 457a78fac813a2779f43ee3f5f02aaec
+readline-4.3-5.i386.rpm c7b7159668d3272083585737a93628eb
+readline-devel-4.3-5.i386.rpm 79b237ff8225dd73646c347e00ca7732
+redhat-release-9-3.i386.rpm 4002643ba2e2077ccc22ef616d69c9fe
+rpm-4.2-0.69.i386.rpm 521141f6fe9a3443d7f89627a6f8c71e
+rpm-build-4.2-0.69.i386.rpm 6c8b7c4acf2562f2d12378966223856b
+sed-4.0.5-1.i386.rpm 34711aa4e9dc199ba1f617a75b68fd1f
+setup-2.5.25-1.noarch.rpm 0adc91fc02ea439db469bd27ee6609de
+shadow-utils-4.0.3-6.i386.rpm 45fd133d921a37cd36150fab9350baec
+sysklogd-1.4.1-12.i386.rpm caeb14d785b721d045e846effe7f3928
+SysVinit-2.84-13.i386.rpm 4e4a1b1fd557aa8daa4a560b4f59fe0f
+tar-1.13.25-11.i386.rpm abea2f1a14cbd9fecddf55b3f57da4c6
+termcap-11.0.1-16.noarch.rpm 2392055e8d44522ac95a050b6c30079b
+unzip-5.50-7.i386.rpm e0bba7266dba6aafd03bb362ac6424fe
+util-linux-2.11y-9.i386.rpm 4a0bc1bb3aa8eedd8ef6f4cd753dab3c
+which-2.14-5.i386.rpm cb0f37e1c1b59f6e9503844c0839314a
+words-2-21.noarch.rpm 901c74e5f71314c81d326991298f860f
+XFree86-libs-4.3.0-2.i386.rpm c1f7264692685aacba2bc05226c0eb1a
+XFree86-libs-data-4.3.0-2.i386.rpm 33030ba631e865db552d795c3490df8e
+XFree86-Mesa-libGL-4.3.0-2.i386.rpm e9f579759648cdb0492982f4ccaedc4b
+zlib-1.1.4-8.i386.rpm c8e2f95e60e75fcfe51dba704c5a6f11
+zlib-devel-1.1.4-8.i386.rpm 6e891309a0dd19b00cc8dfb9018692fd
diff --git a/pkgs/build-support/vm/rpm/redhat-9-i386.nix b/pkgs/build-support/vm/rpm/redhat-9-i386.nix
new file mode 100644
index 00000000000..1d9a3142bf8
--- /dev/null
+++ b/pkgs/build-support/vm/rpm/redhat-9-i386.nix
@@ -0,0 +1,93 @@
+{fetchurl}: [
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/autoconf-2.57-3.noarch.rpm; md5="cea6ded7bd395468a41e9b6380cf5c46";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/automake-1.6.3-5.noarch.rpm; md5="9a518459499504faa786b63bd88374d1";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/basesystem-8.0-2.noarch.rpm; md5="64bc91a544ed3b175e617df2b6683eec";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/bash-2.05b-20.i386.rpm; md5="db4db03fc2d33e3519d72b8f54d483ef";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/binutils-2.13.90.0.18-9.i386.rpm; md5="cd09dfb42d1f9cbd70eba37430762bb6";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/bzip2-1.0.2-8.i386.rpm; md5="ca663b78121235bdaafeced854e8e966";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/bzip2-devel-1.0.2-8.i386.rpm; md5="1e69cd15c6288d41bf989afa579b2585";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/bzip2-libs-1.0.2-8.i386.rpm; md5="996ac1deed904c7d75960b31dfe61b01";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/chkconfig-1.3.8-1.i386.rpm; md5="8ab54c42c15b3f649174e6bfa764adde";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/coreutils-4.5.3-19.i386.rpm; md5="972cd0ff8f3e784c2bc5666e80cf354a";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/cpp-3.2.2-5.i386.rpm; md5="49d8c65dfa401b96b8018b5f6946c985";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/cracklib-2.7-21.i386.rpm; md5="31326ff8fb099f10b5d857dc10a33fa3";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/cracklib-dicts-2.7-21.i386.rpm; md5="d39c8baf399b348db40f3137e93dae03";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/curl-7.9.8-5.i386.rpm; md5="4899792440ce948316546a6a85e1a2ef";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/db4-4.0.14-20.i386.rpm; md5="5fec52fddea8e7cd88cfaa34839cc4b3";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/dev-3.3.2-5.i386.rpm; md5="a8a45208c6e18cac1bf897d5eb0ac07e";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/diffutils-2.8.1-6.i386.rpm; md5="772331d623e47069d464760fa68fd0d9";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/e2fsprogs-1.32-6.i386.rpm; md5="0b728dbe2d88c87951a921158a80184a";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/elfutils-libelf-0.76-3.i386.rpm; md5="1f4a143c12634884ce2a36eef141e6b3";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/expat-1.95.5-2.i386.rpm; md5="76aa046090620b8c51107a94a3e80d7c";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/file-3.39-9.i386.rpm; md5="b0560e1725f28fe375f9885a7a6be684";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/filesystem-2.2.1-3.i386.rpm; md5="897e20be2729051cae7a5bc32efb6b3f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/findutils-4.1.7-9.i386.rpm; md5="be0e80cec36c3eabf172d5003dd79466";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/fontconfig-2.1-9.i386.rpm; md5="86e827ffaa502266116047e840f8eb8f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/freetype-2.1.3-6.i386.rpm; md5="64597ef3568d30982be5c0779f062ff2";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/gawk-3.1.1-9.i386.rpm; md5="72da64dc330d5945ae80c1779390ac2e";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/gcc-3.2.2-5.i386.rpm; md5="aa544de315b6ba5478d3f6e0c15d0208";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/gcc-c++-3.2.2-5.i386.rpm; md5="a287f9ac6f8e2efc4965186366989684";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/gdbm-1.8.0-20.i386.rpm; md5="819986ab928712c2c3c9324d74b360b8";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/glib-1.2.10-10.i386.rpm; md5="24d900aaab3ca9561f7ff2d7e3a206bb";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/glibc-2.3.2-11.9.i386.rpm; md5="d923d7a9a5ac6c25cb51517b23843f78";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/glibc-common-2.3.2-11.9.i386.rpm; md5="f63000e72fc1adc2c23d4de3ba9ca2a0";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/glibc-debug-2.3.2-11.9.i386.rpm; md5="ae4aa98a669c3edc7b3c97b1ef409c43";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/glibc-devel-2.3.2-11.9.i386.rpm; md5="569afc17dd5f1208407b3742a3849b1c";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/glibc-kernheaders-2.4-8.10.i386.rpm; md5="17f4befda9601ac4e3d312245affee2b";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/grep-2.5.1-7.i386.rpm; md5="0606cd6f5516817fe56d6bcc8afe179a";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/gzip-1.3.3-9.i386.rpm; md5="b47a6dfbf36d55a93e3d3920e936a2a7";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/info-4.3-5.i386.rpm; md5="8ce01d5cf0287d8cb012bce443679658";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/initscripts-7.14-1.i386.rpm; md5="12258ed059d3de4d7a6abef4d4d14222";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/iproute-2.4.7-7.i386.rpm; md5="b363643aa70272a146ca92c4577ebced";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/iputils-20020927-2.i386.rpm; md5="83da3128b0da1fdcfd59786451c9d5eb";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/krb5-libs-1.2.7-10.i386.rpm; md5="9865f9f50631007ecdd409a53626502c";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/less-378-7.i386.rpm; md5="608656bbe868016ea464d965e07a026c";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libgcc-3.2.2-5.i386.rpm; md5="91cae96d5ac2f19b20cb0c07906aed06";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libjpeg-6b-26.i386.rpm; md5="3c350fc137a973249a85671083ed508b";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libpng-1.2.2-16.i386.rpm; md5="b7d5a39ec3d2c73e0f944d0f525ce79c";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libstdc++-3.2.2-5.i386.rpm; md5="09ffb26f39e27232d3c385f5fbc1ef1d";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libstdc++-devel-3.2.2-5.i386.rpm; md5="31768c560244755d32185db6022a4b75";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libtermcap-2.0.8-35.i386.rpm; md5="26883bbee99b436059bd8db85426f3d4";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libtiff-3.5.7-11.i386.rpm; md5="e29006e58367d587c0632fb77113841f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/libtool-libs-1.4.3-5.i386.rpm; md5="5fbbdfb5e1cf43ee03fc4f8a2bc4eaba";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/m4-1.4.1-13.i386.rpm; md5="38c55c667d34492f24c5946a3374650d";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/make-3.79.1-17.i386.rpm; md5="5144104c693ee61250e8fd7d75bab866";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/mingetty-1.01-1.i386.rpm; md5="d3e42b0faebc682fb3c31216786e0702";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/mktemp-1.5-18.i386.rpm; md5="28f1bf48c65ce9a5fd18a53fc71675b0";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/modutils-2.4.22-8.i386.rpm; md5="db39bb8d565162e3f8608190eb7a19fa";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/mount-2.11y-9.i386.rpm; md5="280a81dfd645785fd2af9fe312788256";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/ncurses-5.3-4.i386.rpm; md5="e941b37d22dc9ac4a8c37960c5fa337f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/ncurses-devel-5.3-4.i386.rpm; md5="5b3d837bba70045ccb6fccb63ec35dc1";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/net-tools-1.60-12.i386.rpm; md5="20c2bca22ba3f63c43190b63ebd78be5";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/openssl-0.9.7a-2.i386.rpm; md5="39105ce3607fac29a5e0d227e69fea38";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/pam-0.75-48.i386.rpm; md5="fe77ccc841c5fbb830c81867e8e0f164";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/patch-2.5.4-16.i386.rpm; md5="351d225da983e5684fa4c5c8d5ead90f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/pcre-3.9-10.i386.rpm; md5="b545fff04823c776e37142764e31613c";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/perl-5.8.0-88.i386.rpm; md5="c00258c140d4ac1650dcaab4abbda253";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/perl-Filter-1.29-3.i386.rpm; md5="27a82686fe46c220683a447d73c42375";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/pkgconfig-0.14.0-3.i386.rpm; md5="1502d26e4fdec84cce1eee6fb329f4e7";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/popt-1.8-0.69.i386.rpm; md5="8d827ac879feb6bd5a4055a9338d86a1";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/procps-2.0.11-6.i386.rpm; md5="1068278922d4cf486d1f5d9b8109fb81";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/psmisc-21.2-4.i386.rpm; md5="457a78fac813a2779f43ee3f5f02aaec";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/readline-4.3-5.i386.rpm; md5="c7b7159668d3272083585737a93628eb";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/readline-devel-4.3-5.i386.rpm; md5="79b237ff8225dd73646c347e00ca7732";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/redhat-release-9-3.i386.rpm; md5="4002643ba2e2077ccc22ef616d69c9fe";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/rpm-4.2-0.69.i386.rpm; md5="521141f6fe9a3443d7f89627a6f8c71e";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/rpm-build-4.2-0.69.i386.rpm; md5="6c8b7c4acf2562f2d12378966223856b";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/sed-4.0.5-1.i386.rpm; md5="34711aa4e9dc199ba1f617a75b68fd1f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/setup-2.5.25-1.noarch.rpm; md5="0adc91fc02ea439db469bd27ee6609de";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/shadow-utils-4.0.3-6.i386.rpm; md5="45fd133d921a37cd36150fab9350baec";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/sysklogd-1.4.1-12.i386.rpm; md5="caeb14d785b721d045e846effe7f3928";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/SysVinit-2.84-13.i386.rpm; md5="4e4a1b1fd557aa8daa4a560b4f59fe0f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/tar-1.13.25-11.i386.rpm; md5="abea2f1a14cbd9fecddf55b3f57da4c6";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/termcap-11.0.1-16.noarch.rpm; md5="2392055e8d44522ac95a050b6c30079b";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/unzip-5.50-7.i386.rpm; md5="e0bba7266dba6aafd03bb362ac6424fe";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/util-linux-2.11y-9.i386.rpm; md5="4a0bc1bb3aa8eedd8ef6f4cd753dab3c";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/which-2.14-5.i386.rpm; md5="cb0f37e1c1b59f6e9503844c0839314a";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/words-2-21.noarch.rpm; md5="901c74e5f71314c81d326991298f860f";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/XFree86-libs-4.3.0-2.i386.rpm; md5="c1f7264692685aacba2bc05226c0eb1a";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/XFree86-libs-data-4.3.0-2.i386.rpm; md5="33030ba631e865db552d795c3490df8e";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/XFree86-Mesa-libGL-4.3.0-2.i386.rpm; md5="e9f579759648cdb0492982f4ccaedc4b";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/zlib-1.1.4-8.i386.rpm; md5="c8e2f95e60e75fcfe51dba704c5a6f11";})
+  (fetchurl {url=ftp://fr.rpmfind.net/linux/redhat/9/en/os/i386/RedHat/RPMS/zlib-devel-1.1.4-8.i386.rpm; md5="6e891309a0dd19b00cc8dfb9018692fd";})
+]
diff --git a/pkgs/build-support/vm/rpm/rpm-closure.pl b/pkgs/build-support/vm/rpm/rpm-closure.pl
new file mode 100644
index 00000000000..a29745d9283
--- /dev/null
+++ b/pkgs/build-support/vm/rpm/rpm-closure.pl
@@ -0,0 +1,114 @@
+use strict;
+use XML::Simple;
+
+my $packagesFile = shift @ARGV;
+my $urlPrefix = shift @ARGV;
+my @toplevelPkgs = @ARGV;
+
+my @archs = split ' ', ($ENV{'archs'} or "");
+
+print STDERR "parsing packages...\n";
+
+my $xml = XMLin($packagesFile, ForceArray => ['package', 'rpm:entry', 'file'], KeyAttr => []) or die;
+
+print STDERR "file contains $xml->{packages} packages\n";
+
+
+my %pkgs;
+foreach my $pkg (@{$xml->{'package'}}) {
+    if (scalar @archs > 0) {
+        my $arch = $pkg->{arch};
+        my $found = 0;
+        foreach my $a (@archs) { $found = 1 if $arch eq $a; }
+        next if !$found;
+    }
+    if (defined $pkgs{$pkg->{name}}) {
+        print STDERR "WARNING: duplicate occurrence of package $pkg->{name}\n";
+        next;
+    }
+    $pkgs{$pkg->{name}} = $pkg;
+}
+
+
+my %provides;
+foreach my $pkgName (keys %pkgs) {
+    print STDERR "looking at $pkgName\n";
+    my $pkg = $pkgs{$pkgName};
+    
+    #print STDERR keys %{$pkg->{format}}, "\n";
+
+    #print STDERR $pkg->{format}->{'rpm:provides'}, "\n";
+    
+    my $provides = $pkg->{format}->{'rpm:provides'}->{'rpm:entry'} or die;
+    foreach my $req (@{$provides}) {
+        #print "$req->{name}\n";
+        #print STDERR "  provides $req\n";
+        #die "multiple provides for $req" if defined $provides{$req};
+        $provides{$req->{name}} = $pkgName;
+    }
+
+    if (defined $pkg->{format}->{file}) {
+        foreach my $file (@{$pkg->{format}->{file}}) {
+          #print STDERR "  provides file $file\n";
+          $provides{$file} = $pkgName;
+        }
+    }
+}
+
+
+my %donePkgs;
+my @needed = ();
+
+sub closePackage {
+    my $pkgName = shift;
+
+    return if defined $donePkgs{$pkgName};
+    $donePkgs{$pkgName} = 1;
+    
+    print STDERR ">>> $pkgName\n";
+    
+    my $pkg = $pkgs{$pkgName} or die "package $pkgName doesn't exist";
+
+    my $requires = $pkg->{format}->{'rpm:requires'}->{'rpm:entry'} or die;
+
+    my @deps = ();
+    foreach my $req (@{$requires}) {
+        next if $req->{name} =~ /^rpmlib\(/;
+        print STDERR "  needs $req->{name}\n";
+        my $provider = $provides{$req->{name}};
+        if (!defined $provider) {
+            print STDERR "    WARNING: no provider for $req->{name}\n";
+            next;
+        }
+        print STDERR "    satisfied by $provider\n";
+        push @deps, $provider; 
+    }
+
+    closePackage($_) foreach @deps;
+
+    push @needed, $pkgName;
+}
+
+
+foreach my $pkgName (@toplevelPkgs) {
+    closePackage $pkgName;
+}
+
+
+# Generate the output Nix expression.
+print "# This is a generated file.  Do not modify!\n";
+print "# Following are the RPM packages constituting the closure of: @toplevelPkgs\n\n";
+print "{fetchurl}:\n\n";
+print "[\n\n";
+
+foreach my $pkgName (@needed) {
+    my $pkg = $pkgs{$pkgName};
+    die if $pkg->{checksum}->{type} ne "sha";
+    print "  (fetchurl {\n";
+    print "    url = $urlPrefix/$pkg->{location}->{href};\n";
+    print "    sha1 = \"$pkg->{checksum}->{content}\";\n";
+    print "  })\n";
+    print "\n";
+}
+
+print "]\n";
diff --git a/pkgs/build-support/vm/rpm/rpm-list-to-nix.pl b/pkgs/build-support/vm/rpm/rpm-list-to-nix.pl
new file mode 100755
index 00000000000..bd0e32ac97e
--- /dev/null
+++ b/pkgs/build-support/vm/rpm/rpm-list-to-nix.pl
@@ -0,0 +1,51 @@
+#! /usr/bin/perl -w
+
+use strict;
+
+my $list = shift;
+my $expr = shift;
+
+open LIST, "<$list";
+open NEW, ">$list.tmp";
+open EXPR, ">$expr";
+
+print EXPR "{fetchurl}: [\n";
+
+my $baseURL;
+
+while (<LIST>) {
+
+    if (/^\s*baseURL\s+(\S+)\s*$/) {
+        $baseURL = $1;
+        print NEW "baseURL $baseURL\n";
+    } 
+    
+    elsif (/^\s*(\S+)(\s+([a-z0-9]+))?\s*$/) {
+        my $pkgName = $1;
+        my $url = "$baseURL/$pkgName";
+        my $hash = $3;
+        if (!defined $hash) {
+            $hash = `nix-prefetch-url '$url'`;
+            die "fetch of `$url' failed" if ($? != 0);
+            chomp $hash;
+        }
+        print NEW "$pkgName $hash\n";
+        if (length $hash == 32) {
+            print EXPR "  (fetchurl {url=$url; md5=\"$hash\";})\n";
+        } else {
+            print EXPR "  (fetchurl {url=$url; sha256=\"$hash\";})\n";
+        }
+    }
+
+    else {
+        die "invalid line"
+    }
+}
+
+print EXPR "]\n";
+
+close LIST;
+close NEW;
+close EXPR;
+
+rename "$list\.tmp", "$list" or die "cannot rename";
diff --git a/pkgs/build-support/vm/rpm/suse-9-i386.list b/pkgs/build-support/vm/rpm/suse-9-i386.list
new file mode 100644
index 00000000000..9e3dbdae239
--- /dev/null
+++ b/pkgs/build-support/vm/rpm/suse-9-i386.list
@@ -0,0 +1,90 @@
+baseURL ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586
+glibc-2.3.2-92.i586.rpm d5396400c92d4085e536b708ddce265c
+zlib-1.1.4-232.i586.rpm ba1a8342757071dfd7e52a2c69c86584
+readline-4.3-212.i586.rpm c18b059909f3debca772a8f5b7d3aee7
+ncurses-5.3-115.i586.rpm 48c4f77acdbf2ef9aee807466d0fec88
+aaa_base-9.0-7.i586.rpm 1xj9k6b3s0zrdac52q1mw6l7ms55nzmdkfda1s1jbz9laijijppn
+aaa_skel-2003.9.18-8.i586.rpm 1cp9kyg8ksqk0hixdkzd454jhymqdpln9x2y2izdifzsc9wzbsz3
+sysconfig-0.23.30-39.i586.rpm 1dmn95b9yb7rcbgxscw7nspjrdw67v4gdn7kmy5pqq3jxnpmhzi8
+permissions-2003.9.18-8.i586.rpm 0z0n89jh63lqsa0sg6z7f7mn1n6bh1qnxd1h9s5ypmpkazfdhhib
+ash-0.2-804.i586.rpm 01m2nl5jmy206va26fx7w3p9zvmmvd5jkng19vjdw556a74h9saz
+autoconf-2.57-142.i586.rpm 1e360a37d4db4c87e07d15c88f0c12e2
+automake-1.7.6-44.i586.rpm 2c7f1335e73751008f594a68eb515290
+bash-2.05b-212.i586.rpm 1a0fd51a36144dbe89c16553a71899e0
+binutils-2.14.90.0.5-47.i586.rpm 63d69aeb190304f3ddba2d34fcbb5087
+bzip2-1.0.2-232.i586.rpm d667ffc252d983f27eeb041775503438
+coreutils-5.0-90.i586.rpm 121abfc07a9035329b781fdd46e8b600
+compat-2003.5.12-60.i586.rpm e78e5e2e78a2e29c90c3edbf51c8789e
+cpp-3.3.1-29.i586.rpm 2df0da5848fbc59e322167cf7bf1b2bd
+cracklib-2.7-903.i586.rpm 0c5d1c68796906c035a58cf9e4ce1e64
+curl-7.10.5-42.i586.rpm 17ca3725c110e267127b08bd0a1d59a7
+db-4.1.25-76.i586.rpm 9656c5d737d5d6db5a4a320a98590479
+devs-9.0-5.i586.rpm 81e0daafae9d5c75cf6826518dcb9c0f
+diffutils-2.8.1-207.i586.rpm 7d2aed3fe2d8a3e94076695d32c745fb
+e2fsprogs-1.34-34.i586.rpm 5acb02c211196891382927dd8a197899
+expat-1.95.6-84.i586.rpm 357ceb9a50240da9143ccc8d616f8a34
+file-4.03-45.i586.rpm 7c239f1f0695363c6a0dc2dc5d6e82cf
+filesystem-9.0-7.i586.rpm e4d1ed219ea5c8f39dafa30f3749f900
+fillup-1.42-13.i586.rpm 9d9a32946df392999a0bfd42f7faa7a1
+findutils-4.1.7-748.i586.rpm 10318b40691717786e7092395d63533a
+fontconfig-2.2.1-29.i586.rpm 0113c057d8d658b5301e4ce526820f8b
+freetype2-2.1.4-68.i586.rpm c101e3205fdfa22e912f9dc21cd24d12
+gawk-3.1.3-82.i586.rpm 9181c9078ad77b582b9e77f0323417df
+gcc-3.3.1-29.i586.rpm e32b4b631483ab5d22a12900e070890b
+gcc-c++-3.3.1-29.i586.rpm 7e6ee0a475b23bbf1c0e57087f682e43
+gdbm-1.8.3-124.i586.rpm 414fc63a785ee589e40908763b7fb18d
+glib-1.2.10-488.i586.rpm 018f711f294f1a54f9a5b625748f7b22
+glibc-devel-2.3.2-92.i586.rpm 705d90c6a8a7b7eaab8632c343d4e173
+glibc-i18ndata-2.3.2-92.i586.rpm fc719866325ef22c27ac07e366f8b854
+glibc-locale-2.3.2-92.i586.rpm 657164f38227450e5b0bde2892804f21
+gnome-filesystem-0.1-80.i586.rpm f42a958db0291f04af16a7ab50efedca
+gpm-1.20.1-204.i586.rpm 1mmrydfwl8ivlqhxx9l99w9f6vs0f7gnpc3r7j6qfcszm8ql77w6
+gpg-1.2.2-88.i586.rpm 5734134e5b699eacc227672bcb7fdb62
+grep-2.5.1-302.i586.rpm 553eea58a317a068b2bdbd279066f023
+gzip-1.3.5-51.i586.rpm 011ad84c3d935647e639bba34f9c9726
+info-4.5-92.i586.rpm 0da6ec81011700f2dc0db7f8c62d5436
+insserv-1.00.1-18.i586.rpm 708cee980fe3748f161b64aec372adfb
+iproute2-2.4.7-697.i586.rpm 5b8265f3f5f6a23a212b12700664cc91
+iputils-ss021109-60.i586.rpm b7744924b0d4ee20880cee83965d2c9d
+less-381-32.i586.rpm 2092ca409eeb6c479d345a5a6d19ca3e
+libacl-2.2.15-27.i586.rpm e4e246b6e57e39f68d7eea111daa86c9
+libattr-2.4.8-27.i586.rpm f49e5423a1cd8425f78fe8e2c0846404
+liblcms-1.10-37.i586.rpm 79c8494af052c5032c70ea2a394c7a0e
+libgcc-3.3.1-29.i586.rpm 7ba930b645729570c8b8f768490c7e90
+libjpeg-6.2.0-634.i586.rpm 0a8b28e57514c439a0314c89327b0783
+libpng-1.2.5-97.i586.rpm 09f7bfb235dc205074b2c81a60aaa2bf
+libstdc++-3.3.1-29.i586.rpm fe9e66884f3c6ec73a57c44868c749dd
+libstdc++-devel-3.3.1-29.i586.rpm bb69c86478476fee2fd327a54b5790c9
+libtiff-3.5.7-307.i586.rpm 53152a337d2f540f1b7a61e6b11ae41f
+libtool-1.5-85.i586.rpm dfc1992dc92bef0bcdef7273d2cd70fb
+libxcrypt-2.0-36.i586.rpm 022c44bdfb02c926ad6499506f9e8525
+logrotate-3.6.6-95.i586.rpm 0i8pj3rdnxf4ig1zghsbi63s3ss0mvnv4mvyjjxcnilnmg6qjnqj
+m4-1.4o-512.i586.rpm 141d24f90c907841a8a24ceb8e6cb94d
+make-3.80-101.i586.rpm 4f358bda24d2cefc78c3c744d2bd01da
+mktemp-1.5-637.i586.rpm 3f444e864a5b167472192de89957f47a
+modutils-2.4.25-56.i586.rpm 2d64e9b80a10f945e58a5a70e8859fc9
+ncurses-devel-5.3-115.i586.rpm 747d41d77cfacc3ea3874a6ddebc1862
+net-tools-1.60-448.i586.rpm e92f3a22f4595e97e72d8a6ac2e19959
+openssl-0.9.7b-74.i586.rpm 18e0fa1e8168217f6dea90c1954b5a50
+pam-0.77-129.i586.rpm 7b4e04a641d74fb7f3650100c03b258f
+pam-modules-9.0-6.i586.rpm b93f72a778d19ad9bc42d4c3c1ab5bcb
+patch-2.5.9-56.i586.rpm f9b39a18023a4661dd715e28022ac9d2
+pcre-4.4-24.i586.rpm 9cd20ad696e815b9a93be0015d6373d1
+perl-5.8.1-51.i586.rpm 24c046fc2d03464f61c26c014b715bf2
+perl-Filter-1.29-100.i586.rpm 7674bae9c1a7890a8553854b4933bc50
+pkgconfig-0.15.0-108.i586.rpm 31db551f2fcc901a25da746110584e2d
+popt-1.7-76.i586.rpm 66f310eee498958f83e223845b776746
+readline-devel-4.3-212.i586.rpm c9d0c8cd5ea825beb997c70b6ea95101
+rpm-4.1.1-77.i586.rpm 341f5dfdc85070d91da5fb2774d8c886
+sed-4.0.6-73.i586.rpm c95e7a25899d4d927785cb9cb165fca1
+suse-release-9.0-7.i586.rpm f9965de2e346d02acd56ca963c2ec7ae
+syslogd-1.4.1-424.i586.rpm 3713eb72cc56eef8aed49337efeb3611
+sysvinit-2.82-367.i586.rpm 6dfff9b498c7cb98cff660d0d71f24ec
+tar-1.13.25-204.i586.rpm 4e7808b8b691eb639115db0f88527571
+termcap-2.0.8-781.i586.rpm 755c8d17157be28822a940689ab3c1c7
+unzip-5.50-250.i586.rpm 423d68022a4e5e78aa2a88c1642471a7
+util-linux-2.11z-95.i586.rpm 2174767b2e2e6e4e3cdd8fc569dc3c6e
+XFree86-libs-4.3.0.1-29.i586.rpm 77b0e1d5974703b3fc6621d862b4b038
+zlib-devel-1.1.4-232.i586.rpm 7c60d8432793517236f64b0f79d7f20f
+baseURL ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/noarch
+suse-build-key-1.0-472.noarch.rpm 8e34a1af09d66b66ea353685f4a84dfc
diff --git a/pkgs/build-support/vm/rpm/suse-9-i386.nix b/pkgs/build-support/vm/rpm/suse-9-i386.nix
new file mode 100644
index 00000000000..eef815673d5
--- /dev/null
+++ b/pkgs/build-support/vm/rpm/suse-9-i386.nix
@@ -0,0 +1,90 @@
+{fetchurl}: [
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/glibc-2.3.2-92.i586.rpm; md5="d5396400c92d4085e536b708ddce265c";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/zlib-1.1.4-232.i586.rpm; md5="ba1a8342757071dfd7e52a2c69c86584";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/readline-4.3-212.i586.rpm; md5="c18b059909f3debca772a8f5b7d3aee7";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/ncurses-5.3-115.i586.rpm; md5="48c4f77acdbf2ef9aee807466d0fec88";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/aaa_base-9.0-7.i586.rpm; sha256="1xj9k6b3s0zrdac52q1mw6l7ms55nzmdkfda1s1jbz9laijijppn";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/aaa_skel-2003.9.18-8.i586.rpm; sha256="1cp9kyg8ksqk0hixdkzd454jhymqdpln9x2y2izdifzsc9wzbsz3";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/sysconfig-0.23.30-39.i586.rpm; sha256="1dmn95b9yb7rcbgxscw7nspjrdw67v4gdn7kmy5pqq3jxnpmhzi8";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/permissions-2003.9.18-8.i586.rpm; sha256="0z0n89jh63lqsa0sg6z7f7mn1n6bh1qnxd1h9s5ypmpkazfdhhib";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/ash-0.2-804.i586.rpm; sha256="01m2nl5jmy206va26fx7w3p9zvmmvd5jkng19vjdw556a74h9saz";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/autoconf-2.57-142.i586.rpm; md5="1e360a37d4db4c87e07d15c88f0c12e2";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/automake-1.7.6-44.i586.rpm; md5="2c7f1335e73751008f594a68eb515290";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/bash-2.05b-212.i586.rpm; md5="1a0fd51a36144dbe89c16553a71899e0";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/binutils-2.14.90.0.5-47.i586.rpm; md5="63d69aeb190304f3ddba2d34fcbb5087";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/bzip2-1.0.2-232.i586.rpm; md5="d667ffc252d983f27eeb041775503438";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/coreutils-5.0-90.i586.rpm; md5="121abfc07a9035329b781fdd46e8b600";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/compat-2003.5.12-60.i586.rpm; md5="e78e5e2e78a2e29c90c3edbf51c8789e";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/cpp-3.3.1-29.i586.rpm; md5="2df0da5848fbc59e322167cf7bf1b2bd";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/cracklib-2.7-903.i586.rpm; md5="0c5d1c68796906c035a58cf9e4ce1e64";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/curl-7.10.5-42.i586.rpm; md5="17ca3725c110e267127b08bd0a1d59a7";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/db-4.1.25-76.i586.rpm; md5="9656c5d737d5d6db5a4a320a98590479";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/devs-9.0-5.i586.rpm; md5="81e0daafae9d5c75cf6826518dcb9c0f";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/diffutils-2.8.1-207.i586.rpm; md5="7d2aed3fe2d8a3e94076695d32c745fb";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/e2fsprogs-1.34-34.i586.rpm; md5="5acb02c211196891382927dd8a197899";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/expat-1.95.6-84.i586.rpm; md5="357ceb9a50240da9143ccc8d616f8a34";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/file-4.03-45.i586.rpm; md5="7c239f1f0695363c6a0dc2dc5d6e82cf";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/filesystem-9.0-7.i586.rpm; md5="e4d1ed219ea5c8f39dafa30f3749f900";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/fillup-1.42-13.i586.rpm; md5="9d9a32946df392999a0bfd42f7faa7a1";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/findutils-4.1.7-748.i586.rpm; md5="10318b40691717786e7092395d63533a";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/fontconfig-2.2.1-29.i586.rpm; md5="0113c057d8d658b5301e4ce526820f8b";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/freetype2-2.1.4-68.i586.rpm; md5="c101e3205fdfa22e912f9dc21cd24d12";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gawk-3.1.3-82.i586.rpm; md5="9181c9078ad77b582b9e77f0323417df";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gcc-3.3.1-29.i586.rpm; md5="e32b4b631483ab5d22a12900e070890b";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gcc-c++-3.3.1-29.i586.rpm; md5="7e6ee0a475b23bbf1c0e57087f682e43";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gdbm-1.8.3-124.i586.rpm; md5="414fc63a785ee589e40908763b7fb18d";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/glib-1.2.10-488.i586.rpm; md5="018f711f294f1a54f9a5b625748f7b22";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/glibc-devel-2.3.2-92.i586.rpm; md5="705d90c6a8a7b7eaab8632c343d4e173";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/glibc-i18ndata-2.3.2-92.i586.rpm; md5="fc719866325ef22c27ac07e366f8b854";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/glibc-locale-2.3.2-92.i586.rpm; md5="657164f38227450e5b0bde2892804f21";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gnome-filesystem-0.1-80.i586.rpm; md5="f42a958db0291f04af16a7ab50efedca";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gpm-1.20.1-204.i586.rpm; sha256="1mmrydfwl8ivlqhxx9l99w9f6vs0f7gnpc3r7j6qfcszm8ql77w6";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gpg-1.2.2-88.i586.rpm; md5="5734134e5b699eacc227672bcb7fdb62";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/grep-2.5.1-302.i586.rpm; md5="553eea58a317a068b2bdbd279066f023";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/gzip-1.3.5-51.i586.rpm; md5="011ad84c3d935647e639bba34f9c9726";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/info-4.5-92.i586.rpm; md5="0da6ec81011700f2dc0db7f8c62d5436";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/insserv-1.00.1-18.i586.rpm; md5="708cee980fe3748f161b64aec372adfb";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/iproute2-2.4.7-697.i586.rpm; md5="5b8265f3f5f6a23a212b12700664cc91";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/iputils-ss021109-60.i586.rpm; md5="b7744924b0d4ee20880cee83965d2c9d";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/less-381-32.i586.rpm; md5="2092ca409eeb6c479d345a5a6d19ca3e";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libacl-2.2.15-27.i586.rpm; md5="e4e246b6e57e39f68d7eea111daa86c9";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libattr-2.4.8-27.i586.rpm; md5="f49e5423a1cd8425f78fe8e2c0846404";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/liblcms-1.10-37.i586.rpm; md5="79c8494af052c5032c70ea2a394c7a0e";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libgcc-3.3.1-29.i586.rpm; md5="7ba930b645729570c8b8f768490c7e90";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libjpeg-6.2.0-634.i586.rpm; md5="0a8b28e57514c439a0314c89327b0783";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libpng-1.2.5-97.i586.rpm; md5="09f7bfb235dc205074b2c81a60aaa2bf";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libstdc++-3.3.1-29.i586.rpm; md5="fe9e66884f3c6ec73a57c44868c749dd";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libstdc++-devel-3.3.1-29.i586.rpm; md5="bb69c86478476fee2fd327a54b5790c9";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libtiff-3.5.7-307.i586.rpm; md5="53152a337d2f540f1b7a61e6b11ae41f";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libtool-1.5-85.i586.rpm; md5="dfc1992dc92bef0bcdef7273d2cd70fb";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/libxcrypt-2.0-36.i586.rpm; md5="022c44bdfb02c926ad6499506f9e8525";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/logrotate-3.6.6-95.i586.rpm; sha256="0i8pj3rdnxf4ig1zghsbi63s3ss0mvnv4mvyjjxcnilnmg6qjnqj";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/m4-1.4o-512.i586.rpm; md5="141d24f90c907841a8a24ceb8e6cb94d";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/make-3.80-101.i586.rpm; md5="4f358bda24d2cefc78c3c744d2bd01da";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/mktemp-1.5-637.i586.rpm; md5="3f444e864a5b167472192de89957f47a";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/modutils-2.4.25-56.i586.rpm; md5="2d64e9b80a10f945e58a5a70e8859fc9";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/ncurses-devel-5.3-115.i586.rpm; md5="747d41d77cfacc3ea3874a6ddebc1862";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/net-tools-1.60-448.i586.rpm; md5="e92f3a22f4595e97e72d8a6ac2e19959";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/openssl-0.9.7b-74.i586.rpm; md5="18e0fa1e8168217f6dea90c1954b5a50";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/pam-0.77-129.i586.rpm; md5="7b4e04a641d74fb7f3650100c03b258f";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/pam-modules-9.0-6.i586.rpm; md5="b93f72a778d19ad9bc42d4c3c1ab5bcb";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/patch-2.5.9-56.i586.rpm; md5="f9b39a18023a4661dd715e28022ac9d2";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/pcre-4.4-24.i586.rpm; md5="9cd20ad696e815b9a93be0015d6373d1";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/perl-5.8.1-51.i586.rpm; md5="24c046fc2d03464f61c26c014b715bf2";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/perl-Filter-1.29-100.i586.rpm; md5="7674bae9c1a7890a8553854b4933bc50";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/pkgconfig-0.15.0-108.i586.rpm; md5="31db551f2fcc901a25da746110584e2d";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/popt-1.7-76.i586.rpm; md5="66f310eee498958f83e223845b776746";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/readline-devel-4.3-212.i586.rpm; md5="c9d0c8cd5ea825beb997c70b6ea95101";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/rpm-4.1.1-77.i586.rpm; md5="341f5dfdc85070d91da5fb2774d8c886";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/sed-4.0.6-73.i586.rpm; md5="c95e7a25899d4d927785cb9cb165fca1";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/suse-release-9.0-7.i586.rpm; md5="f9965de2e346d02acd56ca963c2ec7ae";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/syslogd-1.4.1-424.i586.rpm; md5="3713eb72cc56eef8aed49337efeb3611";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/sysvinit-2.82-367.i586.rpm; md5="6dfff9b498c7cb98cff660d0d71f24ec";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/tar-1.13.25-204.i586.rpm; md5="4e7808b8b691eb639115db0f88527571";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/termcap-2.0.8-781.i586.rpm; md5="755c8d17157be28822a940689ab3c1c7";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/unzip-5.50-250.i586.rpm; md5="423d68022a4e5e78aa2a88c1642471a7";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/util-linux-2.11z-95.i586.rpm; md5="2174767b2e2e6e4e3cdd8fc569dc3c6e";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/XFree86-libs-4.3.0.1-29.i586.rpm; md5="77b0e1d5974703b3fc6621d862b4b038";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/i586/zlib-devel-1.1.4-232.i586.rpm; md5="7c60d8432793517236f64b0f79d7f20f";})
+  (fetchurl {url=ftp://ftp.gwdg.de/pub/linux/suse/discontinued/i386/9.0/suse/noarch/suse-build-key-1.0-472.noarch.rpm; md5="8e34a1af09d66b66ea353685f4a84dfc";})
+]
diff --git a/pkgs/build-support/vm/test.nix b/pkgs/build-support/vm/test.nix
new file mode 100644
index 00000000000..2dce01195b7
--- /dev/null
+++ b/pkgs/build-support/vm/test.nix
@@ -0,0 +1,70 @@
+with import ../../.. {};
+with vmTools;
+
+rec {
+
+
+  # Run the PatchELF derivation in a VM.
+  buildPatchelfInVM = runInLinuxVM patchelf;
+
+
+  testRPMImage = makeImageTestScript diskImages.fedora8i386;
+
+
+  buildPatchelfRPM = buildRPM {
+    name = "patchelf-rpm";
+    src = patchelf.src;
+    diskImage = diskImages.fedora5i386;
+  };
+
+  
+  testUbuntuImage = makeImageTestScript diskImages.ubuntu710i386;
+
+  
+  buildInDebian = runInLinuxImage (stdenv.mkDerivation {
+    name = "deb-compile";
+    src = nixUnstable.src;
+    diskImage = diskImages.debian40r3i386;
+    memSize = 512;
+    phases = "sysInfoPhase unpackPhase patchPhase configurePhase buildPhase checkPhase installPhase fixupPhase distPhase";
+    sysInfoPhase = ''
+      dpkg-query --list
+    '';
+  });
+
+
+  testFreeBSD = runInGenericVM {
+    name = "aterm-freebsd";
+    src = aterm242fixes.src;
+    diskImage = "/tmp/freebsd-7.0.qcow";
+
+    postPreVM = ''
+      cp $src aterm.tar.bz2
+    '';
+
+    buildCommand = ''
+      set > /tmp/my-env
+      . /mnt/saved-env
+      . /tmp/my-env
+      unset TEMP
+      unset TEMPDIR
+      unset TMP
+      unset TMPDIR
+
+      set -x
+
+      echo "Hello World!!!"
+      mkdir /mnt/out
+      echo "bar" > /mnt/out/foo
+
+      cd /tmp
+      tar xvf /mnt/aterm.tar.bz2
+      cd aterm-*
+      ./configure --prefix=/mnt/out
+      make
+      make install
+    '';
+  };
+  
+
+}
\ No newline at end of file
diff --git a/pkgs/data/documentation/rnrs/builder.sh b/pkgs/data/documentation/rnrs/builder.sh
new file mode 100644
index 00000000000..096dd2a8ca7
--- /dev/null
+++ b/pkgs/data/documentation/rnrs/builder.sh
@@ -0,0 +1,12 @@
+source "$stdenv/setup" || exit 1
+
+# XXX: Eventually we could consider building the PDF/PS files as well.
+
+echo "source is \`$src', report name is \`$reportName'"
+
+ensureDir "$out/share/info" &&					\
+makeinfo -o "$out/share/info/${reportName}.info" "$src"
+
+# XXX: HTML output is apparently broken.
+#ensureDir "$out/share/doc/${reportName}" &&			\
+#makeinfo -o "$out/share/doc/${reportName}/html" --html --force "$src"
diff --git a/pkgs/data/documentation/rnrs/common.nix b/pkgs/data/documentation/rnrs/common.nix
new file mode 100644
index 00000000000..2775a36f321
--- /dev/null
+++ b/pkgs/data/documentation/rnrs/common.nix
@@ -0,0 +1,29 @@
+{ fetchurl, stdenv, texinfo, revision, sha256 }:
+
+stdenv.mkDerivation rec {
+  name = "r${toString revision}rs";
+  src = fetchurl {
+    url = "http://swiss.csail.mit.edu/ftpdir/scm/${name}.txi";
+    inherit sha256;
+  };
+
+  buildInputs = [ texinfo ];
+
+  # Tell the builder about the name of the report.  
+  reportName = name;
+
+  builder = ./builder.sh;
+
+  meta = {
+    description = ''Revised^${toString revision} Report on the
+                    Algorithmic Language Scheme'';
+
+    longDescription = ''
+      This package contains the GNU Info version of the
+      the ${toString revision}th revision of the Report on the
+      Algorithmic Language Scheme.
+    '';
+
+    homepage = http://swiss.csail.mit.edu/~jaffer/Scheme;
+  };
+}
diff --git a/pkgs/data/documentation/rnrs/r3rs.nix b/pkgs/data/documentation/rnrs/r3rs.nix
new file mode 100644
index 00000000000..adaa03d3a68
--- /dev/null
+++ b/pkgs/data/documentation/rnrs/r3rs.nix
@@ -0,0 +1,6 @@
+args: with args;
+
+((import ./common.nix)
+ (args //
+  { revision = 3;
+    sha256 = "0knrpkr74s8yn4xcqxkqpgxmzdmzrvahh1n1csqc1wwd2rb4vnpr"; }))
diff --git a/pkgs/data/documentation/rnrs/r4rs.nix b/pkgs/data/documentation/rnrs/r4rs.nix
new file mode 100644
index 00000000000..4f444229917
--- /dev/null
+++ b/pkgs/data/documentation/rnrs/r4rs.nix
@@ -0,0 +1,6 @@
+args: with args;
+
+((import ./common.nix)
+ (args //
+  { revision = 4;
+    sha256 = "02jgy0lvi5ymkdxwjasg50zl03zmyj8sgnfxxnjnbmif72c0k4p8"; }))
diff --git a/pkgs/data/documentation/rnrs/r5rs.nix b/pkgs/data/documentation/rnrs/r5rs.nix
new file mode 100644
index 00000000000..b53bbf551b2
--- /dev/null
+++ b/pkgs/data/documentation/rnrs/r5rs.nix
@@ -0,0 +1,6 @@
+args: with args;
+
+((import ./common.nix)
+ (args //
+  { revision = 5;
+    sha256 = "1s2wcslwcgb9j89vjn7qs63qlnsv1481jaw1sgg33fgbgk6a8wrk"; }))
diff --git a/pkgs/data/fonts/freefont-ttf/default.nix b/pkgs/data/fonts/freefont-ttf/default.nix
index e1f8c74ae62..50c4b729354 100644
--- a/pkgs/data/fonts/freefont-ttf/default.nix
+++ b/pkgs/data/fonts/freefont-ttf/default.nix
@@ -1,13 +1,27 @@
 {stdenv, fetchurl}:
 
-stdenv.mkDerivation {
-  name = "freefont-ttf-20060126";
+stdenv.mkDerivation rec {
+  name = "freefont-ttf-20080323";
   src = fetchurl {
-    url = http://download.savannah.gnu.org/releases/freefont/freefont-ttf-20060126.tar.gz;
-    md5 = "822aba4e2ed065d9d3ded6e26e495854";
+    url = "mirror://gnu/freefont/${name}.tar.gz";
+    sha256 = "17wkasp5bgzw8n1dxpfcgj5zawfb743ff3cq24qh4brkyfrf2jkr";
   };
+
   installPhase = ''
     ensureDir $out/share/fonts/truetype
     cp *.ttf $out/share/fonts/truetype
   '';
+
+  meta = {
+    description = "GNU Free UCS Outline Fonts";
+
+    longDescription = ''
+      The GNU Freefont project aims to provide a set of free outline
+      (PostScript Type0, TrueType, OpenType...) fonts covering the ISO
+      10646/Unicode UCS (Universal Character Set).
+    '';
+
+    homepage = http://www.gnu.org/software/freefont/;
+    license = "GPLv2+";
+  };
 }
diff --git a/pkgs/data/fonts/libertine/2.7.bin.nix b/pkgs/data/fonts/libertine/2.7.bin.nix
new file mode 100644
index 00000000000..c88659e4371
--- /dev/null
+++ b/pkgs/data/fonts/libertine/2.7.bin.nix
@@ -0,0 +1,17 @@
+args: with args;
+rec{
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/linuxlibertine/LinLibertineFont-2.7.tgz;
+    sha256 = "06xm3np2xx41fr2yc00q0z2qy9s6p860f18ns1f1f00vi54dm4c5";
+  };
+
+  buildInputs = [];
+  phaseNames = ["doUnpack" "installFonts"];
+
+  name = "linux-libertine-" + version;
+  meta = {
+    description = "Linux Libertine Fonts";
+    homepage = http://linuxlibertine.sf.net;
+  };
+}
+
diff --git a/pkgs/data/fonts/libertine/2.7.nix b/pkgs/data/fonts/libertine/2.7.nix
new file mode 100644
index 00000000000..546a4bdacec
--- /dev/null
+++ b/pkgs/data/fonts/libertine/2.7.nix
@@ -0,0 +1,23 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/linuxlibertine/LinLibertineSRC-2.7.tgz;
+    sha256 = "1czc3pil4zrii6qh6zk0g6hj6axj20gfnpbbdfrzm703wm9w70ic";
+  };
+
+  buildInputs = [fontforge];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doUnpack" "generateFontsFromSFD" "installFonts"];
+      
+  extraFontForgeCommands = ''
+    ScaleToEm(1000);
+  '';
+
+  name = "linux-libertine-" + version;
+  meta = {
+    description = "Linux Libertine Fonts";
+    homepage = http://linuxlibertine.sf.net;
+  };
+}
diff --git a/pkgs/data/fonts/lmodern/0.92.nix b/pkgs/data/fonts/lmodern/0.92.nix
new file mode 100644
index 00000000000..0ac51a0303f
--- /dev/null
+++ b/pkgs/data/fonts/lmodern/0.92.nix
@@ -0,0 +1,32 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftp.de.debian.org/debian/pool/main/l/lmodern/lmodern_0.92.orig.tar.gz;
+    sha256 = "0ak3n7fsi2va94gsn0pfmyby2b4g7wz9h5a0prpbx24ax1xwinls";
+  };
+
+  buildInputs = [];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doCopy"];
+
+  doCopy = FullDepEntry(''
+    ensureDir $out/share/texmf/fonts/enc 
+    ensureDir $out/share/texmf/fonts/map 
+    ensureDir $out/share/texmf/fonts/type1/public/lm 
+    ensureDir $out/share/texmf/dvips/lm 
+    ensureDir $out/share/texmf/dvipdfm/config
+
+    cp -r ./* $out/share/texmf/
+
+    cp dvips/lm/*.enc $out/share/texmf/fonts/enc
+    cp dvips/lm/*.map $out/share/texmf/fonts/map
+    cp dvips/lm/*.map $out/share/texmf/dvipdfm/config
+  '') ["minInit" "defEnsureDir" "doUnpack"];
+
+  name = "lmodern-" + version;
+  meta = {
+    description = "Latin Modern font";
+  };
+}
diff --git a/pkgs/data/fonts/lmodern/1.010.nix b/pkgs/data/fonts/lmodern/1.010.nix
new file mode 100644
index 00000000000..9c82b702824
--- /dev/null
+++ b/pkgs/data/fonts/lmodern/1.010.nix
@@ -0,0 +1,27 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftp.de.debian.org/debian/pool/main/l/lmodern/lmodern_1.010x.orig.tar.gz;
+    sha256 = "0nwxj1ng7rvnp16jxcs25hbc5in65mdk4a3g3rlaq91i5qpq7mxj";
+  };
+
+  buildInputs = [];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doCopy"];
+
+  doCopy = FullDepEntry(''
+    ensureDir $out/share/texmf/
+    ensureDir $out/share/fonts/
+
+    cp -r ./* $out/share/texmf/
+    cp -r fonts/{opentype,type1} $out/share/fonts/
+  '') ["minInit" "defEnsureDir" "doUnpack"];
+
+  name = "lmodern-" + version;
+  meta = {
+    description = "Latin Modern font";
+  };
+}
+
diff --git a/pkgs/data/fonts/redhat-liberation-fonts/default.nix b/pkgs/data/fonts/redhat-liberation-fonts/default.nix
index d88d5ff7b1d..ab8a6ee8579 100644
--- a/pkgs/data/fonts/redhat-liberation-fonts/default.nix
+++ b/pkgs/data/fonts/redhat-liberation-fonts/default.nix
@@ -1,7 +1,7 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "freefont-ttf-20060126";
+  name = "redhat-liberation";
   src = fetchurl {
     url = http://www.redhat.com/f/fonts/liberation-fonts-ttf-3.tar.gz;
     sha256 = "13zzyqyi3mf676aj3fg9122asyykpx94mk689r1p2ab1axyg4k0p";
diff --git a/pkgs/data/fonts/unifont/default.nix b/pkgs/data/fonts/unifont/default.nix
index 3ffc5eabf93..dd525aa3d78 100644
--- a/pkgs/data/fonts/unifont/default.nix
+++ b/pkgs/data/fonts/unifont/default.nix
@@ -1,11 +1,11 @@
 args: with args; with debPackage;
 debBuild ({
   src = fetchurl {
-    url = mirror://debian/main/u/unifont/unifont_1.0.orig.tar.gz;
+    url = mirror://debian/pool/main/u/unifont/unifont_1.0.orig.tar.gz;
     sha256 = "0bg8d6c7w51n5409g0n7vqk3aagbzb5aird5r02vw0yz7w6i729l";
   };
   patch = fetchurl {
-    url = mirror://debian/main/u/unifont/unifont_1.0-4.diff.gz;
+    url = mirror://debian/pool/main/u/unifont/unifont_1.0-4.diff.gz;
     sha256 = "08j0rrf7hc05izchmsx9f9hg7vnyqdvbmba4b9jl8wfhvd1b09fd";
   };
   name = "unifont-1.0-4";
diff --git a/pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix b/pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix
index dff67222e69..1e0103a9305 100644
--- a/pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix
+++ b/pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix
@@ -1,11 +1,13 @@
-{stdenv, fetchurl}:
+{stdenv, fetchurl, unzip}:
 
 stdenv.mkDerivation {
-  name = "docbook5-5.0-pre-cr1";
+  name = "docbook5-5.0";
   builder = ./builder.sh;
 
   src = fetchurl {
-    url = http://www.docbook.org/xml/5.0CR1/docbook-5.0CR1.tar.gz;
-    sha256 = "15bbnydspiry7k7fwl2gdjb53nyw2vg6xwpn3d40f03mcf0bkw11";
+    url = http://www.docbook.org/xml/5.0/docbook-5.0.zip;
+    sha256 = "13i04dkd709f0p5f2413sf2y9321pfi4y85ynf8wih6ryphnbk9x";
   };
+
+  buildInputs = [unzip];
 }
diff --git a/pkgs/data/sgml+xml/stylesheets/xslt/docbook5/default.nix b/pkgs/data/sgml+xml/stylesheets/xslt/docbook5/default.nix
index af9152ac4d2..d3440735801 100644
--- a/pkgs/data/sgml+xml/stylesheets/xslt/docbook5/default.nix
+++ b/pkgs/data/sgml+xml/stylesheets/xslt/docbook5/default.nix
@@ -1,10 +1,10 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "docbook5-xsl-1.73.1";
+  name = "docbook5-xsl-1.74.0";
   builder = ./builder.sh;
   src = fetchurl {
-    url = mirror://sourceforge/docbook/docbook-xsl-ns-1.73.1.tar.bz2;
-    sha256 = "105irc94p04j0fj5vf5fschyxv9azkh2bsa69a796jax5ngpbahn";
+    url = mirror://sourceforge/docbook/docbook-xsl-ns-1.74.0.tar.bz2;
+    sha256 = "0253ymp0k9wb3zsxazz8p9q9fy83rkmp8c67vlk84x7f2i7vf3x9";
   };
 }
diff --git a/pkgs/desktops/kde/kdebase/default.nix b/pkgs/desktops/kde/kdebase/default.nix
index 4ca1a4f2dc2..25ae63e3806 100644
--- a/pkgs/desktops/kde/kdebase/default.nix
+++ b/pkgs/desktops/kde/kdebase/default.nix
@@ -27,6 +27,16 @@ stdenv.mkDerivation {
     --with-extra-includes=${libjpeg}/include
   '';
 
+  # Prevent configure from looking for pkg-config and freetype-config
+  # in the wrong location (it looks in /usr/bin etc. *before* looking
+  # in $PATH).
+  preConfigure = ''
+    substituteInPlace configure \
+      --replace /usr/bin /no-such-path \
+      --replace /usr/local/bin /no-such-path \
+      --replace /opt/local/bin /no-such-path
+  '';
+
   # Quick hack to work around a faulty dependency in
   # konqueror/keditbookmarks/Makefile.am (${includedir} should be
   # ${kdelibs} or so).
@@ -34,5 +44,6 @@ stdenv.mkDerivation {
     ensureDir $out/include
     ln -s ${kdelibs}/include/kbookmarknotifier.h $out/include/
   '';
+  
   postInstall = "rm $out/include/kbookmarknotifier.h";
 }
diff --git a/pkgs/desktops/kde/kdelibs/default.nix b/pkgs/desktops/kde/kdelibs/default.nix
index 3e048aa932d..1e04be5ba16 100644
--- a/pkgs/desktops/kde/kdelibs/default.nix
+++ b/pkgs/desktops/kde/kdelibs/default.nix
@@ -21,6 +21,16 @@ stdenv.mkDerivation {
     libtool freetype bzip2 cups
   ];
 
+  # Prevent configure from looking for pkg-config and freetype-config
+  # in the wrong location (it looks in /usr/bin etc. *before* looking
+  # in $PATH).
+  preConfigure = ''
+    substituteInPlace configure \
+      --replace /usr/bin /no-such-path \
+      --replace /usr/local/bin /no-such-path \
+      --replace /opt/local/bin /no-such-path
+  '';
+
   configureFlags = ''
     --without-arts 
     --with-ssl-dir=${openssl}
diff --git a/pkgs/development/compilers/bigloo/default.nix b/pkgs/development/compilers/bigloo/default.nix
index 2fb0b7c2276..d4c5df5b1be 100644
--- a/pkgs/development/compilers/bigloo/default.nix
+++ b/pkgs/development/compilers/bigloo/default.nix
@@ -1,130 +1,46 @@
-args:
-( args.mkDerivationByConfiguration {
-    flagConfig = {
-    /*
-Bigloo compiler:
-   --native=yes|no [default yes]
-   --jvm=yes|no|force [default no]
-   --dotnet=yes|no|force [default no]
-   --customgc=yes|no [default yes]
-   --bee=partial|full [default partial]
+{ fetchurl, stdenv }:
 
-API:
-   --enable-[calendar|fthread|mail|multimedia|pkgcomp|pkglib|pthread|sqlite|srfi1|ssl|web]
-   --disable-[calendar|fthread|mail|multimedia|pkgcomp|pkglib|pthread|sqlite|srfi1|ssl|web]
+stdenv.mkDerivation rec {
+  name = "bigloo3.0c-4";
 
-Path:
-   --prefix=dir (sets bin, lib, zip, man, info and doc dirs)
-   --bindir=file
-   --libdir=file
-   --gcdir=dir (directory for non custom gc library)
-   --fildir=file
-   --zipdir=file
-   --dlldir=file
-   --mandir=file
-   --infodir=file
-   --docdir=file
-   --tmpdir=file (Bigloo tmp dir)
-   --tmp=file (Installation tmp dir)
-   --lispdir=file
-
-Tools and compilers:
-   --bigloo=comp [default bigloo]
-   --cc=comp [default gcc]
-   --ld=comp [default gcc]
-   --as=asm
-   --cflags=compilation flags
-   --lflags=compiler link flags
-   --coflags=optimization_flags
-   --cpicflags=pic_flags
-   --ldlibs=ld_libs
-   --ldcomplibs=ld_compiler_libs
-   --ldflags=ld_flags
-   --emacs=file
-   --xemacs=file (deprecated, use "--emacs" option)
-   --indent=file
-   --icc (configure for icc)
-
-Host configuration:
-   --arch=[i586|i686|athlon|athlon-tbird|athlon-mp|athlon-xp|k6-2|k6-3|pentium3|pentium4] (configure for specified hardware)
-   --a.out=file
-   --a.bat=file
-   --dirname=file-or-command
-   --force-posixos=operating-system
-   --os-win32
-   --os-macosx (tune for MacOSX)
-   --no-os-macosx (disable MacOSX auto configuration)
-   --cygwin-dos-path=[dos path]
-   --cygwin-dos-jvm=yes|no [default yes]
-   --no-share (disable shared libraries support)
-   --no-ldpreload
-   --sharedbde=yes|no [default no] (link Bde tools against shared libraries)
-   --sharedcompiler=yes|no [default no] (link Bigloo against shared libraries)
-
-JVM configuration:
-   --java=file
-   --javac=file
-   --javaprefix=dir
-   --javashell=shell [should be sh or msdos (default sh)]
-   --native-default-backend
-   --jvm-default-backend
-
-.NET configuration:
-   --pnet (configure for GNU pnet)
-   --mono (configure for Ximian Mono)
-   --dotnetldstyle=style [should be pnet, mono]
-   --dotnetcsccstyle=style [should be pnet, mono]
-   --dotnetclrstyle=style [should be pnet, mono]
-   --dotnetcscc=file
-   --dotnetld=file
-   --dotnetclr=file
-   --dotnetclropt=options
-   --dotnetshell=shell [should be sh or msdos (default sh)]
-   --dotnetasm=asm [optional]
-
-Misc:
-   --finalization=yes|no [default no]
-   --benchmark=yes|no [default no] (must use --arch too)
-   --stack-check=no
-
-Configuration settings:
-   --bigloo.h[=file]
-   --bigloo_gc.h[=file]
-   --bigloo_config.h[=file]
-   --bigloo_config.jvm[=file]
-   --Makefile.config=file
-   --configure.log=file
-   --no-summary
-   --bootconfig
-   --bootdir=dir
-   --configureinfo=yes|no [default no]
-
-   */
-
-    }; 
-
-    extraAttrs = co : rec {
-      name = "bigloo3.0d-alpha05Feb08"; # Thanks to Manuel Serrano for fixing the mv trouble 
-
-      # take care, modifying generated C-Code (altering string and length of string) 
-      preConfigure = 
-        "sed -i -e 's=/bin/rm -f \", 14=rm -f \", 9=' "
-         + " -e 's=/bin/mv \", 11=mv \", 6=' "
-         + "comptime/Cc/cc.c\n"
-      + "sed -i -e 's=/bin/rm=rm=' "
-           + " -e 's=/bin/mv=mv=' "
-         + "configure  gc/install-gc-*";
-
-      src = args.fetchurl {
-        url = "ftp://ftp-sop.inria.fr/mimosa/fp/Bigloo/${name}.tar.gz";
-        sha256 = "03rknb1nl3z2f86k6iazbrapmli2m8lcs21lqrri8ys8s72dm33w";
-      };
+  src = fetchurl {
+    url = "ftp://ftp-sop.inria.fr/mimosa/fp/Bigloo/${name}.tar.gz";
+    sha256 = "0avcdgfw7g4myqrhcdi3k46qv01p0rmvmpqz4qmim9ccdjrvcyq4";
+  };
 
-    meta = { 
-      description = "scheme -> C / Java compiler (.net experimental)";
-      homepage = http://www-sop.inria.fr/mimosa/fp/Bigloo/;
-      # you can choose one of the following licenses: 
-      license = ["GPL"];
-    };
+  patchPhase = ''
+    # Fix absolute paths.
+    sed -e 's=/bin/mv=mv=g' -e 's=/bin/rm=rm=g'			\
+        -e 's=/tmp=$TMPDIR=g' -i configure autoconf/*		\
+	[Mm]akefile*   */[Mm]akefile*   */*/[Mm]akefile*	\
+	*/*/*/[Mm]akefile*   */*/*/*/[Mm]akefile*		\
+	*/*/*/*/*/[Mm]akefile*					\
+	comptime/Cc/cc.scm
+
+    # Make sure we don't change string lengths in the generated
+    # C files.
+    sed -e 's=/bin/rm=     rm=g' -e 's=/bin/mv=     mv=g'	\
+	-i comptime/Cc/cc.c
+  '';
+
+  checkTarget = "test";
+
+  meta = { 
+    description = "Bigloo, an efficient Scheme compiler";
+
+    longDescription = ''
+      Bigloo is a Scheme implementation devoted to one goal: enabling
+      Scheme based programming style where C(++) is usually
+      required.  Bigloo attempts to make Scheme practical by offering
+      features usually presented by traditional programming languages
+      but not offered by Scheme and functional programming.  Bigloo
+      compiles Scheme modules.  It delivers small and fast stand alone
+      binary executables.  Bigloo enables full connections between
+      Scheme and C programs, between Scheme and Java programs, and
+      between Scheme and C# programs.
+    '';
+
+    homepage = http://www-sop.inria.fr/mimosa/fp/Bigloo/;
+    license = "GPLv2+";
   };
-} ) args
+}
diff --git a/pkgs/development/compilers/ehc/default.nix b/pkgs/development/compilers/ehc/default.nix
new file mode 100644
index 00000000000..3590f2ea075
--- /dev/null
+++ b/pkgs/development/compilers/ehc/default.nix
@@ -0,0 +1,65 @@
+{stdenv, coreutils, fetchsvn, m4, libtool, ghc, uulib, uuagc, llvm}:
+
+stdenv.mkDerivation (rec {
+  name = "ehc-svn-1042";
+  homepage = "http://www.cs.uu.nl/wiki/Ehc/WebHome/";
+
+  src = fetchsvn {
+          url = https://svn.cs.uu.nl:12443/repos/EHC/trunk/EHC;
+          rev = "1042";
+          sha256 = "7a9e5d1d57825caa4664686d9a5c0d9b5ebb870095817d77bb7b97869718ed5b";
+  };
+
+  buildInputs = [coreutils m4 ghc libtool uulib uuagc llvm];
+
+  preConfigure = ''
+    find src -name files\*.mk -exec sed -i -- "s/--user//g" '{}' \;
+    sed -i "s|/bin/date|${coreutils}/bin/date|g" mk/dist.mk
+    echo "RTS_GCC_CC_OPTS := -std=gnu99" >> mk/shared.mk.in
+  '';
+
+  buildFlags = "100/ehc 100/ehclib";
+
+  installPhase = ''
+    cd bin
+
+    # install executables
+    echo "installing executables..."
+    mkdir -p $out/bin-ehc
+    for i in *; do
+      if [[ -d $i ]]; then
+        cp $i/ehc $out/bin-ehc/ehc-$i
+      fi;
+    done
+
+    # install runtime support
+    cp -r ../install/* $out
+
+    # install prelude
+    echo "installing prelude..."
+    mkdir -p $out/lib-ehc
+    for i in *; do
+      if [[ -d ../build/$i/ehclib/ehcbase ]]; then
+        mkdir -p $out/lib-ehc/$i
+        cp -r ../build/$i/ehclib/ehcbase $out/lib-ehc/$i
+      fi;
+    done
+
+    # generate wrappers
+    echo "generating wrappers..."
+    mkdir -p $out/bin
+    for i in *; do
+      if [[ -d $i ]]; then
+        echo '#!'"$SHELL" > $out/bin/ehc-$i
+        echo "exec \"$out/bin-ehc/ehc-$i\" --use-inplace=0 -P $out/lib-ehc/$i/ehcbase" '"$@"' >> $out/bin/ehc-$i
+        chmod 751 $out/bin/ehc-$i
+      fi;
+    done
+  '';
+
+  meta = {
+    description = "Essential Haskell Compiler";
+  };
+
+  inherit coreutils;
+})
diff --git a/pkgs/development/compilers/flapjax/default.nix b/pkgs/development/compilers/flapjax/default.nix
new file mode 100644
index 00000000000..69903471899
--- /dev/null
+++ b/pkgs/development/compilers/flapjax/default.nix
@@ -0,0 +1,25 @@
+args:
+args.stdenv.mkDerivation {
+  name = "flapjax-source-20070514";
+
+  src = args.fetchurl {
+    url = http://www.flapjax-lang.org/download/20070514/flapjax-source.tar.gz;
+    sha256 = "188dafpggbfdyciqhrjaq12q0q01z1rp3mpm2iixb0mvrci14flc";
+  };
+
+  phases = "unpackPhase buildPhase";
+
+  buildPhase  = "
+    ensureDir \$out/bin
+    cd compiler;
+    ghc --make Fjc.hs -o \$out/bin/fjc
+  ";
+
+  buildInputs =(with args; [ghc] ++ libs);
+
+  meta = { 
+      description = "programming language designed around the demands of modern, client-based Web applications";
+      homepage = http://www.flapjax-lang.org/;
+      license = "BSD";
+  };
+}
diff --git a/pkgs/development/compilers/fpc/default.nix b/pkgs/development/compilers/fpc/default.nix
index 0d2f1fb525d..463907e0518 100644
--- a/pkgs/development/compilers/fpc/default.nix
+++ b/pkgs/development/compilers/fpc/default.nix
@@ -12,6 +12,10 @@ stdenv.mkDerivation {
 
   buildInputs = [startFPC gawk];
 
+  preConfigure = (if system == "i686-linux" || system == "x86_64-linux" then ''
+  	sed -e "s@'/lib/ld-linux[^']*'@'''@" -i fpcsrc/compiler/systems/t_linux.pas
+  '' else "");
+
   installFlags = "INSTALL_PREFIX=\${out}";
   postInstall = "ln -fs $out/lib/fpc/*/ppc386 $out/bin;
 	mkdir -p $out/lib/fpc/etc/ ;
diff --git a/pkgs/development/compilers/fpc/lazarus.nix b/pkgs/development/compilers/fpc/lazarus.nix
new file mode 100644
index 00000000000..d00e270b67b
--- /dev/null
+++ b/pkgs/development/compilers/fpc/lazarus.nix
@@ -0,0 +1,39 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/lazarus/lazarus-0.9.24-0.tar.gz;
+    sha256 = "0kkj1yycdbyrsw6c34gm5ya7q3256p8ph8j5a23x3qy86gbch827";
+  };
+
+  buildInputs = [fpc gtk glib libXi inputproto 
+    libX11 xproto libXext xextproto gdkpixbuf 
+    stdenv.gcc makeWrapper];
+  configureFlags = [];
+  makeFlags = [
+    "LAZARUS_INSTALL_DIR=$out/lazarus/"
+    "INSTALL_PREFIX=$out/"
+    "FPC=fpc"
+    "PP=fpc"
+  ];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["preBuild" "doMakeInstall" "postInstall"];
+
+  preBuild = FullDepEntry (''
+    export NIX_LDFLAGS='-lXi -lX11 -lglib -lgtk -lgdk -lgdk_pixbuf -lc -lXext'
+    ensureDir $out/share
+    tar xf ${fpc.src} --strip-components=1 -C $out/share
+    sed -e 's@/usr/fpcsrc@'"$out/share/fpcsrc@" -i ide/include/unix/lazbaseconf.inc
+  '') 
+  ["minInit" "defEnsureDir" "doUnpack"];
+
+  postInstall = FullDepEntry (''
+    wrapProgram $out/bin/startlazarus --prefix NIX_LDFLAGS ' ' "'$NIX_LDFLAGS'"
+  '') ["doMakeInstall" "minInit" "defEnsureDir"];
+
+  name = "lazarus-0.9.24-0";
+  meta = {
+    description = "Lazarus graphical IDE for FreePascal language";
+    homepage = http://www.lazarus.freepascal.org ;
+  };
+}
diff --git a/pkgs/development/compilers/gcc-4.2/fortran.nix b/pkgs/development/compilers/gcc-4.2/fortran.nix
new file mode 100644
index 00000000000..240737a21b3
--- /dev/null
+++ b/pkgs/development/compilers/gcc-4.2/fortran.nix
@@ -0,0 +1,73 @@
+{ stdenv, fetchurl, noSysDirs
+, langC ? true, langCC ? true, langF77 ? false
+, profiledCompiler ? false
+, staticCompiler ? false
+, gmp ? null
+, mpfr ? null
+, texinfo ? null
+}:
+
+assert langC || langF77;
+
+with import ../../../lib;
+
+let version = "4.2.3"; in
+
+stdenv.mkDerivation {
+  name = "gcc-${version}";
+  builder = if langF77 then ./fortran.sh else  ./builder.sh;
+  
+  src =
+    optional /*langC*/ true (fetchurl {
+      url = "mirror://gnu/gcc/gcc-${version}/gcc-core-${version}.tar.bz2";
+      sha256 = "04y84s46wzy4h44hpacf7vyla7b5zfc1qvdq3myvrhp82cp0bv4r";
+    }) ++
+    optional langCC (fetchurl {
+      url = "mirror://gnu/gcc/gcc-${version}/gcc-g++-${version}.tar.bz2";
+      sha256 = "0spzz549fifwv02ym33azzwizl0zkq5m1fgy88ccmcyzmwpgyzfq";
+    }) ++
+    optional langF77 (fetchurl {
+      url = "mirror://gnu/gcc/gcc-${version}/gcc-fortran-${version}.tar.bz2";
+      sha256 = "1l3ww6qymrkcfqlssb41a5fdnh6w2hqk0v2ijx56jgjbdnzawyp0";
+    });
+    
+  patches =
+    optional noSysDirs [./no-sys-dirs.patch];
+    
+  inherit noSysDirs profiledCompiler staticCompiler;
+
+  buildInputs = [gmp mpfr texinfo];
+  
+  configureFlags = "
+    --disable-multilib
+    --disable-libstdcxx-pch
+    --with-system-zlib
+    --enable-languages=${
+      concatStrings (intersperse ","
+        (  optional langC   "c"
+        ++ optional langCC  "c++"
+        ++ optional langF77 "fortran"
+        )
+      )
+    }
+    ${if stdenv.isi686 then "--with-arch=i686" else ""}
+    ${if gmp != null then "--with-gmp=${gmp}" else ""}
+    ${if mpfr != null then "--with-mpfr=${mpfr}" else ""}
+  ";
+
+  makeFlags = if staticCompiler then "LDFLAGS=-static" else "";
+
+  passthru = { inherit langC langCC langF77; };
+
+  postInstall = "if test -f $out/bin/gfrotran; then ln -s $out/bin/gfortran $out/bin/g77; fi";
+
+  meta = {
+    homepage = "http://gcc.gnu.org/";
+    license = "GPL/LGPL";
+    description = "GNU Compiler Collection, 4.2.x";
+
+    # Give the real GCC a lower priority than the GCC wrapper so that
+    # both can be installed at the same time.
+    priority = "7";
+  };
+}
diff --git a/pkgs/development/compilers/gcc-4.2/fortran.sh b/pkgs/development/compilers/gcc-4.2/fortran.sh
new file mode 100644
index 00000000000..962e8d37238
--- /dev/null
+++ b/pkgs/development/compilers/gcc-4.2/fortran.sh
@@ -0,0 +1,86 @@
+source $stdenv/setup
+
+
+export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
+mkdir $NIX_FIXINC_DUMMY
+
+export X_CFLAGS="-I${gmp}/include -I${mpfr}/include -L${gmp}/lib -L${mpfr}/lib";
+
+# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
+# Thing.
+export CPP="gcc -E"
+
+
+if test "$noSysDirs" = "1"; then
+
+    if test -e $NIX_GCC/nix-support/orig-libc; then
+
+        # Figure out what extra flags to pass to the gcc compilers
+        # being generated to make sure that they use our glibc.
+        extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
+        extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
+
+        # Use *real* header files, otherwise a limits.h is generated
+        # that does not include Glibc's limits.h (notably missing
+        # SSIZE_MAX, which breaks the build).
+        export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
+        
+    else
+        # Hack: support impure environments.
+        extraCFlags="-isystem /usr/include"
+        extraLDFlags="-L/usr/lib64 -L/usr/lib"
+        export NIX_FIXINC_DUMMY=/usr/include
+    fi
+
+    extraCFlags="-g0 $extraCFlags"
+    extraLDFlags="--strip-debug $extraLDFlags"
+
+    export NIX_EXTRA_CFLAGS=$extraCFlags
+    for i in $extraLDFlags; do
+        export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
+    done
+
+    makeFlagsArray=( \
+        NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        LIMITS_H_TEST=true \
+        X_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
+        LDFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
+        LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
+        )
+fi
+
+
+preConfigure=preConfigure
+preConfigure() {
+    # Perform the build in a different directory.
+    mkdir ../build
+    cd ../build
+    configureScript=../$sourceRoot/configure
+}
+
+
+postInstall=postInstall
+postInstall() {
+    # Remove precompiled headers for now.  They are very big and
+    # probably not very useful yet.
+    find $out/include -name "*.gch" -exec rm -rf {} \; -prune
+
+    # Remove `fixincl' to prevent a retained dependency on the
+    # previous gcc.
+    rm -rf $out/libexec/gcc/*/*/install-tools
+
+    # Get rid of some "fixed" header files
+    rm -rf $out/lib/gcc/*/*/include/root
+}
+
+
+if test -z "$staticCompiler"; then
+    if test -z "$profiledCompiler"; then
+        buildFlags="bootstrap $buildFlags"
+    else    
+        buildFlags="profiledbootstrap $buildFlags"
+    fi
+fi
+
+genericBuild
diff --git a/pkgs/development/compilers/ghc-6.6.1/setup-hook.sh b/pkgs/development/compilers/ghc-6.6.1/setup-hook.sh
index c6f769a0040..03057e82f4a 100644
--- a/pkgs/development/compilers/ghc-6.6.1/setup-hook.sh
+++ b/pkgs/development/compilers/ghc-6.6.1/setup-hook.sh
@@ -13,7 +13,7 @@ makeWrapper() {
   wrapper="$ghc_support/$wrapperName"
   shift #the other arguments are passed to the source app
   echo '#!'"$SHELL" > "$wrapper"
-  echo "exec \"@out@/bin/$wrapperName\" $@" '"$@"' > "$wrapper"
+  echo "exec \"@out@/bin/$wrapperName\" $@" '"$@"' >> "$wrapper"
   chmod +x "$wrapper"
 }
 
diff --git a/pkgs/development/compilers/ghc-6.6/setup-hook.sh b/pkgs/development/compilers/ghc-6.6/setup-hook.sh
index 23da6de0382..b8441abc98a 100644
--- a/pkgs/development/compilers/ghc-6.6/setup-hook.sh
+++ b/pkgs/development/compilers/ghc-6.6/setup-hook.sh
@@ -13,7 +13,7 @@ makeWrapper() {
   wrapper="$ghc_support/$wrapperName"
   shift #the other arguments are passed to the source app
   echo '#!'"$SHELL" > "$wrapper"
-  echo "exec \"$ghc/bin/$wrapperName\" $@" '"$@"' > "$wrapper"
+  echo "exec \"$ghc/bin/$wrapperName\" $@" '"$@"' >> "$wrapper"
   chmod +x "$wrapper"
 }
 
diff --git a/pkgs/development/compilers/ghc-6.8/default.nix b/pkgs/development/compilers/ghc-6.8/default.nix
index e12778f690b..5c7b093e342 100644
--- a/pkgs/development/compilers/ghc-6.8/default.nix
+++ b/pkgs/development/compilers/ghc-6.8/default.nix
@@ -15,6 +15,9 @@ stdenv.mkDerivation (rec {
 
   buildInputs = [ghc readline perl m4 gmp];
 
+  # The setup hook is executed by other packages building with ghc.
+  # It then looks for package configurations that are available and
+  # build a package database on the fly.
   setupHook = ./setup-hook.sh;
 
   meta = {
@@ -23,8 +26,8 @@ stdenv.mkDerivation (rec {
 
   configureFlags=[
     "--with-gmp-libraries=${gmp}/lib"
-    "--with-readline-libraries=${readline}/lib"
     "--with-gmp-includes=${gmp}/include"
+    "--with-readline-libraries=${readline}/lib"
     "--with-gcc=${gcc}/bin/gcc"
   ];
 
diff --git a/pkgs/development/compilers/ghc-6.8/setup-hook.sh b/pkgs/development/compilers/ghc-6.8/setup-hook.sh
index de4bf2192ff..263f46f52d4 100644
--- a/pkgs/development/compilers/ghc-6.8/setup-hook.sh
+++ b/pkgs/development/compilers/ghc-6.8/setup-hook.sh
@@ -1,6 +1,6 @@
 # Support dir for isolating GHC
 ghc_support=$TMPDIR/ghc-6.8-nix-support
-mkdir -p $ghc_support
+ensureDir $ghc_support
 
 # Create isolated package config
 packages_db=$ghc_support/package.conf
@@ -13,7 +13,7 @@ makeWrapper() {
   wrapper="$ghc_support/$wrapperName"
   shift #the other arguments are passed to the source app
   echo '#!'"$SHELL" > "$wrapper"
-  echo "exec \"@out@/bin/$wrapperName\" $@" '"$@"' > "$wrapper"
+  echo "exec \"@out@/bin/$wrapperName\" $@" '"$@"' >> "$wrapper"
   chmod +x "$wrapper"
 }
 
diff --git a/pkgs/development/compilers/ghc-6.8/snapshot.nix b/pkgs/development/compilers/ghc-6.8/snapshot.nix
new file mode 100644
index 00000000000..8258e45e6bb
--- /dev/null
+++ b/pkgs/development/compilers/ghc-6.8/snapshot.nix
@@ -0,0 +1,41 @@
+{stdenv, fetchurl, readline, ghc, perl, m4, gmp, ncurses}:
+
+stdenv.mkDerivation (rec {
+  name = "ghc-6.8.2.20080602";
+  homepage = "http://www.haskell.org/ghc";
+
+  src = map fetchurl [
+    { url    = "${homepage}/dist/stable/dist/${name}-src.tar.bz2";
+      sha256 = "06374d2a65671a21b4ce44a84333cedf4a5f5e0adbb837e8985c6b46b5de4249";
+    }
+    { url    = "${homepage}/dist/stable/dist/${name}-src-extralibs.tar.bz2";
+      sha256 = "0dfea592d6be5838fa7db85a65b7d38b97451b829afe3b03a790350a9591b470";
+    }
+  ];
+
+  buildInputs = [ghc readline perl m4 gmp];
+
+  # The setup hook is executed by other packages building with ghc.
+  # It then looks for package configurations that are available and
+  # build a package database on the fly.
+  setupHook = ./setup-hook.sh;
+
+  meta = {
+    description = "The Glasgow Haskell Compiler";
+  };
+
+  configureFlags=[
+    "--with-gmp-libraries=${gmp}/lib"
+    "--with-gmp-includes=${gmp}/include"
+    "--with-readline-libraries=${readline}/lib"
+    "--with-gcc=${gcc}/bin/gcc"
+  ];
+
+  preConfigure = "
+    # still requires a hack for ncurses
+    sed -i \"s|^\\\(ld-options.*$\\\)|\\\1 -L${ncurses}/lib|\" libraries/readline/readline.buildinfo.in
+  ";
+
+  inherit (stdenv) gcc;
+  inherit readline gmp ncurses;
+})
diff --git a/pkgs/development/compilers/ghc-6.8/x86_64-linux_patch b/pkgs/development/compilers/ghc-6.8/x86_64-linux_patch
deleted file mode 100644
index 26a9cf2781e..00000000000
--- a/pkgs/development/compilers/ghc-6.8/x86_64-linux_patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -ru /tmp/ghc_fresh/ghc-6.9.20071119/compiler/codeGen/CgUtils.hs ./ghc-6.9.20071119/compiler/codeGen/CgUtils.hs
---- /tmp/ghc_fresh/ghc-6.9.20071119/compiler/codeGen/CgUtils.hs 2007-12-05 15:02:30.000000000 +0100
-+++ ./ghc-6.9.20071119/compiler/codeGen/CgUtils.hs      2007-12-05 15:33:16.000000000 +0100
-@@ -51,7 +51,7 @@
-   ) where
- 
- #include "HsVersions.h"
--#include "MachRegs.h"
-+#include "../includes/MachRegs.h"
- 
- import CgMonad
- import TyCon
-diff -ru /tmp/ghc_fresh/ghc-6.9.20071119/compiler/nativeGen/MachRegs.lhs ./ghc-6.9.20071119/compiler/nativeGen/MachRegs.lhs
---- /tmp/ghc_fresh/ghc-6.9.20071119/compiler/nativeGen/MachRegs.lhs     2007-12-05 15:02:30.000000000 +0100
-+++ ./ghc-6.9.20071119/compiler/nativeGen/MachRegs.lhs  2007-12-05 15:32:41.000000000 +0100
-@@ -90,7 +90,7 @@
- -- HACK: go for the max
- #endif
- 
--#include "MachRegs.h"
-+#include "../includes/MachRegs.h"
- 
- import Cmm
- import MachOp          ( MachRep(..) )
diff --git a/pkgs/development/compilers/ghc/createGhcWrapper/default.nix b/pkgs/development/compilers/ghc/createGhcWrapper/default.nix
deleted file mode 100644
index 4d6094f5d72..00000000000
--- a/pkgs/development/compilers/ghc/createGhcWrapper/default.nix
+++ /dev/null
@@ -1,38 +0,0 @@
-args: with args; with lib; with annotatedDerivations;
-
-stdenv.mkDerivation {
-  inherit suffix name ghc ;
-
-  buildInputs = map delAnnotation (libraries ++ [ghcPkgUtil]);
-  #tags = if (installSourceAndTags == true) then
-  #        map sourceWithTagsDerivation ( uniqList { inputList = 
-  #            ( filterAnnotated ( concatLists (map uniqAnnotatedDeps libraries ) ) ) ; } )
-  #        else [];
-  tags = map (x : sourceWithTagsDerivation (x.sourceWithTags)) 
-          (uniqList { inputList=  filter annotatedWithSourceAndTagInfo libraries; } );
-
-  phases="installPhase";
-
-  installPhase="
-    ensureDir \$out/bin
-    if test -n \"\$ghcPackagedLibs\"; then
-       g=:\$(echo \$ghc/lib/ghc-*/package.conf)
-    fi
-
-    for a in ghc ghci ghc-pkg; do
-      app=$(ls -al $ghc/bin/$a | sed -n 's%.*-> \\(.*\\)%\\1%p');
-cat > \"\$out/bin/\$a$suffix\" << EOF
-#!`type -f sh | gawk '{ print $3; }'`
-GHC_PACKAGE_PATH=\${GHC_PACKAGE_PATH}\${g} \$ghc/bin/$app \"\\\$@\"
-EOF
-      chmod +x \"\$out/bin/\$a$suffix\"
-    done
-
-    ensureDir \$out/{src,tags}
-    for i in \$tags; do
-      for path in src tags; do
-        ln -s \$i/\$path/* \$out/\$path
-      done
-    done
-";
-}
diff --git a/pkgs/development/compilers/ghc/ghc-wrapper/default.nix b/pkgs/development/compilers/ghc/ghc-wrapper/default.nix
new file mode 100644
index 00000000000..9cff8095c65
--- /dev/null
+++ b/pkgs/development/compilers/ghc/ghc-wrapper/default.nix
@@ -0,0 +1,51 @@
+args: with args; with lib;
+
+stdenv.mkDerivation {
+  inherit suffix name ghc readline ncurses;
+
+  buildInputs = (libraries ++ [ghcPkgUtil]);
+  tags = if installSourceAndTags then
+          map (x :  sourceWithTagsDerivation (sourceWithTagsFromDerivation x)) 
+          ( uniqList { inputList= filter annotatedWithSourceAndTagInfo libraries; } )
+        else [];
+
+  phases="installPhase";
+
+  installPhase="
+    set -e
+    ensureDir \$out/bin
+    if test -n \"\$ghcPackagedLibs\"; then
+       g=:\$(echo \$ghc/lib/ghc-*/package.conf)
+    fi
+
+    for a in ghc ghci ghc-pkg; do
+      app=$(ls -al $ghc/bin/$a | sed -n 's%.*-> \\(.*\\)%\\1%p');
+cat > \"\$out/bin/\$a$suffix\" << EOF
+#!`type -f sh | gawk '{ print $3; }'`
+export LIBRARY_PATH=\$readline/lib:\$ncurses/lib
+GHC_PACKAGE_PATH=\${GHC_PACKAGE_PATH}\${g} \$ghc/bin/$app \"\\\$@\"
+EOF
+      chmod +x \"\$out/bin/\$a$suffix\"
+    done
+
+    ensureDir \$out/src
+    for i in \$tags; do
+        ln -s \$i/src/* \$out/src
+    done
+
+    ensureDir \$out/bin
+    for i in `echo $GHC_PACKAGE_PATH | sed 's/:/ /g'`; do
+      o=\${i/lib*/}
+      o=\${i/nix-support*/}
+      for j in \$ghc/bin/* `find \${o}bin/ -type f 2>/dev/null` `find \${o}usr/local/bin/ -type f 2>/dev/null`; do
+        b=`basename \$j`
+        if [ \$b == sh ]; then continue; fi
+        if [ \$b == bash ]; then continue; fi
+        if [ \$b == bashbug ]; then continue; fi
+        if [ \$b == bashbug ]; then continue; fi
+        if [ -e \$out/bin/\$b ]; then continue; fi
+        ln -s \$j \$out/bin/;
+      done
+    done
+";
+}
diff --git a/pkgs/development/compilers/ghc/ghc-wrapper/ghc-cabal-executable-fun.nix b/pkgs/development/compilers/ghc/ghc-wrapper/ghc-cabal-executable-fun.nix
new file mode 100644
index 00000000000..1fe0dac7475
--- /dev/null
+++ b/pkgs/development/compilers/ghc/ghc-wrapper/ghc-cabal-executable-fun.nix
@@ -0,0 +1,17 @@
+args: with args;
+{ name, src, meta ? {}, libsFun, pass ? {} } : 
+let buildInputs = libsFun ((ghc68extraLibs ghcsAndLibs.ghc68) // ghcsAndLibs.ghc68.core_libs) 
+                  ++ [ ghcsAndLibs.ghc68.ghc perl ];
+in stdenv.mkDerivation ({
+  inherit name src meta;
+  phases = "unpackPhase patchPhase buildPhase";
+  # TODO The ghc must be the one having compiled the libs.. So make this obvious by not having to pass it
+  buildPhase  = ''
+    ghc --make Setup.*hs -o setup
+    ensureDir \out
+    nix_ghc_pkg_tool join local-pkg-db
+    ./setup configure --prefix=$out --package-db=local-pkg-db
+    ./setup build
+    ./setup install
+    '';
+} // pass // { buildInputs = buildInputs ++  (if pass ? buildInputs then lib.toList pass.buildInputs else []); })
diff --git a/pkgs/development/compilers/ghcs/default.nix b/pkgs/development/compilers/ghcs/default.nix
index 6dd37576524..8865ce78d03 100644
--- a/pkgs/development/compilers/ghcs/default.nix
+++ b/pkgs/development/compilers/ghcs/default.nix
@@ -1,13 +1,12 @@
-{ ghcPkgUtil, gnum4, perl, ghcboot, stdenv, fetchurl, recurseIntoAttrs, gmp, readline, lib, annotatedDerivations, hasktags, ctags } : 
-with annotatedDerivations;
+  { ghcPkgUtil, gnum4, perl, ghcboot, stdenv, fetchurl, recurseIntoAttrs, gmp, readline, lib, hasktags, ctags
+    , sourceByName, autoconf, happy, alex ,automake, getConfig} : 
 rec {
   
   /* What's in here?
      Goal:  really pure GHC. This means put every library into its each package.conf
      and add all together using GHC_PACKAGE_PATH
 
-     First I've tried separating the build of ghc from it's lib. It hase been to painful. I've failed.
-     Now there is nix_ghc_pkg_tool.hs which just takes the installed package.conf
+     First I've tried separating the build of ghc from it's lib. It hase been to painful. I've failed.  Now there is nix_ghc_pkg_tool.hs which just takes the installed package.conf
      and creates a new package db file for each contained package.
 
      The final attribute set looks similar to this:
@@ -35,11 +34,11 @@ rec {
 
   #this only works for ghc-6.8 right now
   ghcAndLibraries = { version, src /* , core_libraries, extra_libraries  */
-                    , extra_src }:
+                    , extra_src, pass ? {} }:
                    recurseIntoAttrs ( rec {
     inherit src extra_src version;
 
-    ghc = stdenv.mkDerivation {
+    ghc = stdenv.mkDerivation ( lib.mergeAttrsNoOverride {} pass {
       name = "ghc-"+version;
       inherit src ghcboot gmp version;
 
@@ -63,6 +62,7 @@ rec {
 
       # now read the main package.conf and create a single package db file for each of them
       # Also create setup hook.
+      makeFlags = getConfig ["ghc" "makeFlags" ] "";
 
       #  note : I don't know yet wether it's a good idea to have RUNGHC.. It's faster
       # but you can't pass packages, can you?
@@ -83,7 +83,7 @@ rec {
         echo \"RUNHGHC=\$RUNHGHC\" >> \$sh
         
       ";
-    };
+    });
 
     core_libs = rec {
         #   name (using lowercase letters everywhere because using installing packages having different capitalization is discouraged) - this way there is not that much to remember?
@@ -111,7 +111,7 @@ rec {
                           deps = [ x.base x.old_locale x.old_time x.filepath ];};
           filepath = { name = "filepath-1.1.0.0"; srcDir = "libraries/filepath";
                           deps = [ x.base ];};
-          ghc = { name = "ghc-${version}"; srcDir = "libraries/Cabal";
+          ghc = { name = "ghc-${version}"; srcDir = "compiler";
                           deps = [ x.base x.old_locale x.old_time x.filepath
                             x.directory x.array x.containers x.hpc x.bytestring
                             x.pretty x.packedstring x.template_haskell x.unix
@@ -142,7 +142,7 @@ rec {
                   name = "rts-1.0"; srcDir = "rts"; # TODO: Doesn't have .hs files so I should use ctags if creating tags at all
                   deps = [];
                   createTagFiles = [
-                      { name = "${name}_haskell_tags";
+                      { name = "${name}_haskell";
                         tagCmd = "${toString ctags}/bin/ctags -R .;mv tags \$TAG_FILE"; }
                     ];
           };
@@ -153,30 +153,24 @@ rec {
         };
 
         toDerivation = attrs : with attrs;
-              rec {
-                inherit name;
-
-                #aDeps = concatLists ( catAttrs ( subsetmap id args [ "buildInputs" "propagatedBuildInputs" ] ) );
-                aDeps = deps;
 
-                # dummy derivation, only creates setup-hook for package database located in the ghc derivation 
-                aDeriv = stdenv.mkDerivation {
-                    inherit name;
+                stdenv.mkDerivation {
+                    inherit (attrs) name;
                     phases = "buildPhase fixupPhase";
                     buildInputs = [ ghcPkgUtil ];
-                    propagatedBuildInputs = [ ghc ] ++ map delAnnotation  attrs.deps;
-                    buildPhase = "setupHookRegisteringPackageDatabase \"${ghc}/lib/ghc-${ghc.version}/${name}.conf\"";
-                };
-
-                sourceWithTags = {
-                  src = ghc.src;
-                  inherit srcDir;
-                  name = name + "-src-with-tags";
-                  createTagFiles = lib.maybeAttr "createTagFiles" [
-                      { name = "${name}_haskell_tags";
-                        tagCmd = "${toString hasktags}/bin/hasktags-modified --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; } 
-                    ] attrs;
-                };
+                    propagatedBuildInputs = [ ghc ] ++ attrs.deps;
+                    buildPhase = "setupHookRegisteringPackageDatabase \"${ghc}/lib/ghc-${ghc.version}/${attrs.name}.conf\"";
+                    meta = {
+                      sourceWithTags = {
+                        src = ghc.src;
+                        inherit srcDir;
+                        name = attrs.name + "-src-with-tags";
+                        createTagFiles = lib.maybeAttr "createTagFiles" [
+                            { name = "${attrs.name}_haskell";
+                              tagCmd = "${toString hasktags}/bin/hasktags-modified --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; } 
+                          ] attrs;
+                      };
+                    };
           };
         derivations = with lib; builtins.listToAttrs (lib.concatLists ( lib.mapRecordFlatten 
                   ( n : attrs : let d = (toDerivation attrs); in [ (nv n d) (nv attrs.name d) ] ) pkgs ) );
@@ -194,6 +188,8 @@ rec {
       #sha256 = "1b1gvi7hc7sc0fkh29qvzzd5lgnlvdv3ayiak4mkfnzkahvmq85s";
     };
 
+    pass = { patches = ./patch; };
+
     extra_src = fetchurl {
       url = "http://www.haskell.org/ghc/dist/stable/dist/ghc-${version}-src-extralibs.tar.bz2";
       sha256 = "044mpbzpkbxcnqhjnrnmjs00mr85057d123rrlz2vch795lxbkcn";
@@ -201,4 +197,65 @@ rec {
       #sha256 = "0py7d9nh3lkhjxr3yb3n9345d0hmzq79bi40al5rcr3sb84rnp9r";
     };
   };
+
+  # this works. commented out because I haven't uploaded all the bleeding edge source dist files.
+  #[> darcs version of ghc which is updated occasionally by Marc Weber 
+  #ghc68darcs = ghcAndLibraries rec {
+  #  version = "6.9";
+
+  #  pass = { buildInputs = [ happy alex]; 
+  #           patches =  ./patch;
+  #           patchPhase = "
+  #             unset patchPhase; patchPhase
+  #             pwd
+  #             sed 's/GhcWithJavaGen=NO/GhcWithJavaGen=YES/g' -i mk/config.mk.in
+  #             ";
+  #  };
+  #  [> each library is usually added using darcs-all get 
+  #  [> so I assemble and prepare the sources here
+  #  src = stdenv.mkDerivation {
+  #    name = "ghc-darcs-src-dist";
+  #    buildInputs = [autoconf automake];
+  #    core_libs = map (x : sourceByName "ghc_core_${x}") ["array" "base" "bytestring" "Cabal" "containers" "directory" "editline" "filepath" "ghc_prim" "haskell98" "hpc" "integer_gmp" "old_locale" "old_time" "packedstring" "pretty" "process" "random" "template_haskell" "unix" "Win32" ];
+  #    ghc = sourceByName "ghc";
+  #    phases = "buildPhase";
+  #    buildPhase = "
+  #      echo unpacking ghc
+  #      tar xfz \$ghc &> /dev/null
+  #      cd nix_repsoitory_manager_tmp_dir/libraries
+  #      for i in \$core_libs; do
+  #        echo 'unpacking core_lib :' \$i
+  #        tar  xfz \$i &> /dev/null
+  #        n=`basename \$i`
+  #        n=\${n/ghc_core_/}
+  #        if [ -f nix_repsoitory_manager_tmp_dir/*.ac ]; then
+  #          cd nix_repsoitory_manager_tmp_dir
+  #          echo   =======================================================
+  #          echo \$n
+  #          autoreconf
+  #          cd ..
+  #        fi
+  #        mv nix_repsoitory_manager_tmp_dir \${n/.tar.gz/}
+  #      done
+  #      mv ghc_prim ghc-prim
+  #      for i in integer-gmp old-locale old-time template-haskell; do
+  #        mv \${i/-/_} $i
+  #      done
+  #      mkdir \$out
+  #      cd ..
+  #      autoreconf
+  #      sh boot
+  #      cd ..
+  #      mv nix*/* \$out/
+  #    ";
+  #  };
+
+  #  [> TODO this is copied.. use dev versions as well here
+  #  extra_src = fetchurl {
+  #    url = "http://www.haskell.org/ghc/dist/stable/dist/ghc-${version}-src-extralibs.tar.bz2";
+  #    sha256 = "044mpbzpkbxcnqhjnrnmjs00mr85057d123rrlz2vch795lxbkcn";
+  #    [>url = http://www.haskell.org/ghc/dist/stable/dist/ghc-6.8.20070912-src-extralibs.tar.bz2;
+  #    [>sha256 = "0py7d9nh3lkhjxr3yb3n9345d0hmzq79bi40al5rcr3sb84rnp9r";
+  #  };
+  #};
 }
diff --git a/pkgs/development/compilers/ghcs/patch b/pkgs/development/compilers/ghcs/patch
new file mode 100644
index 00000000000..e888413c67d
--- /dev/null
+++ b/pkgs/development/compilers/ghcs/patch
@@ -0,0 +1,55 @@
+diff -rN -U3 old-ghc_package_db/compiler/package.conf.in new-ghc_package_db/compiler/package.conf.in
+--- old-ghc_package_db/compiler/package.conf.in	2008-04-24 02:03:28.000000000 +0200
++++ new-ghc_package_db/compiler/package.conf.in	2008-04-24 02:03:28.000000000 +0200
+@@ -10,7 +10,6 @@
+ 	BasicTypes
+ 	BinIface
+ 	Binary
+-	BitSet
+ 	Bitmap
+ 	BuildTyCl
+ 	ByteCodeAsm
+@@ -91,7 +90,6 @@
+         Encoding
+ 	FastString
+ 	FastTypes
+-	FieldLabel
+ 	Finder
+ 	FiniteMap
+ 	FloatIn
+@@ -121,7 +119,6 @@
+ 	IfaceEnv
+ 	IfaceSyn
+ 	IfaceType
+-	IlxGen
+ 	Inst
+ 	InstEnv
+ 	Java
+@@ -179,7 +176,6 @@
+ 	RdrHsSyn
+ 	RdrName
+ 	RegAllocInfo
+-	RegisterAlloc
+ 	RnBinds
+ 	RnEnv
+ 	RnExpr
+diff -rN -U3 old-ghc_package_db/mk/package.mk new-ghc_package_db/mk/package.mk
+--- old-ghc_package_db/mk/package.mk	2008-04-24 02:03:26.000000000 +0200
++++ new-ghc_package_db/mk/package.mk	2008-04-24 02:03:28.000000000 +0200
+@@ -61,6 +61,7 @@
+ 
+ package.conf.inplace   : package.conf.in
+ 	$(CPP) $(RAWCPP_FLAGS) -P \
++		$(if $(subst NO,,$(GhcWithJavaGen)),, -DJava= -D JavaGen= -DPrintJava= ) \
+ 		-DIMPORT_DIR='"$(IMPORT_DIR_INPLACE)"' \
+ 		-DLIB_DIR='"$(LIB_DIR_INPLACE)"' \
+ 		-DINCLUDE_DIR='"$(INCLUDE_DIR_INPLACE)"' \
+@@ -74,6 +75,7 @@
+ 
+ install::
+ 	$(CPP) $(RAWCPP_FLAGS) -P -DINSTALLING \
++		$(if $(subst NO,,$(GhcWithJavaGen)),, -DJava= -D JavaGen= -DPrintJava= ) \
+ 	       -DIMPORT_DIR='"$(IMPORT_DIR_INSTALLED)"' \
+ 	       -DLIB_DIR='"$(LIB_DIR_INSTALLED)"' \
+ 	       -DINCLUDE_DIR='"$(INCLUDE_DIR_INSTALLED)"' \
+
diff --git a/pkgs/development/compilers/ikarus/0.0.3.nix b/pkgs/development/compilers/ikarus/0.0.3.nix
new file mode 100644
index 00000000000..1976df7b742
--- /dev/null
+++ b/pkgs/development/compilers/ikarus/0.0.3.nix
@@ -0,0 +1,21 @@
+
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://www.cs.indiana.edu/~aghuloum/ikarus/ikarus-0.0.3.tar.gz;
+    sha256 = "0d4vqwqfnj39l0gar2di021kcf6bfpkc6g40yapkmxm6sxpdcvjv";
+  };
+
+  buildInputs = [gmp];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "ikarus-" + version;
+  meta = {
+    description = "Ikarus - a Scheme compiler, aiming at R6RS";
+    homepage = http://www.cs.indiana.edu/~aghuloum/ikarus/;
+    license = "GPL3";
+  };
+}
diff --git a/pkgs/development/compilers/jdk/default.nix b/pkgs/development/compilers/jdk/default.nix
index d7921d54002..c27ce4d1640 100644
--- a/pkgs/development/compilers/jdk/default.nix
+++ b/pkgs/development/compilers/jdk/default.nix
@@ -2,9 +2,8 @@ args:
 
 if args.stdenv.system == "i686-linux" || args.stdenv.system == "x86_64-linux" then
   (import ./jdk6-linux.nix) args
-
-else if args.stdenv.system == "powerpc-linux"  then
+else if args.stdenv.system == "powerpc-linux" then
   (import ./jdk5-ibm-powerpc-linux.nix) (removeAttrs args ["libstdcpp5" "pluginSupport" "xlibs" "installjdk"])
-
 else
   abort "the JDK is not supported on this platform"
+
diff --git a/pkgs/development/compilers/jdk/jdk5-sun-linux.nix b/pkgs/development/compilers/jdk/jdk5-sun-linux.nix
index 6a15b1f9ec9..a5d6f8bc516 100644
--- a/pkgs/development/compilers/jdk/jdk5-sun-linux.nix
+++ b/pkgs/development/compilers/jdk/jdk5-sun-linux.nix
@@ -10,13 +10,14 @@
 
 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
 
+let name = "jdk-1_5_0_15"; in
 stdenv.mkDerivation {
-  name = "jdk-1.5.0_14";
-  filename = "jdk-1_5_0_14";
-  dirname = "jdk1.5.0_14";
+  inherit name;
+  filename = "jdk-1_5_0_15";
+  dirname = "jdk1.5.0_15";
   builder = ./builder.sh;
-  pathname = if stdenv.system == "x86_64-linux" then "/tmp/jdk-1_5_0_14-linux-amd64.bin" else "/tmp/jdk-1_5_0_14-linux-i586.bin";
-  md5 = if stdenv.system == "x86_64-linux" then "9dc74d939dd42988280f2c22ab9521bf" else "32df8f2be09c3a0f39da1b3869164b55";
+  pathname = if stdenv.system == "x86_64-linux" then "/tmp/${name}-linux-amd64.bin" else "/tmp/${name}-linux-i586.bin";
+  md5 = if stdenv.system == "x86_64-linux" then "8c560eda470a50926b9e8dab2c806a25" else "6f45ac598a2f6ff73a2429d6a0da2624";
   
   stdenv = stdenv;
   inherit unzip;
diff --git a/pkgs/development/compilers/jdk/jdk6-linux.nix b/pkgs/development/compilers/jdk/jdk6-linux.nix
index 14e0005e38c..4c1bd88c366 100644
--- a/pkgs/development/compilers/jdk/jdk6-linux.nix
+++ b/pkgs/development/compilers/jdk/jdk6-linux.nix
@@ -15,18 +15,18 @@ assert pluginSupport -> libstdcpp5 != null;
 
 (stdenv.mkDerivation ({
   name =
-    if installjdk then "jdk-1.6.0_4" else "jre-1.6.0_4";
+    if installjdk then "jdk-1.6.0_6" else "jre-1.6.0_6";
 
   src =
     if stdenv.system == "i686-linux" then
       fetchurl {
-        url = http://download.java.net/dlj/binaries/jdk-6u4-dlj-linux-i586.bin;
-        sha256 = "955186f497a50106cd1788fcaf032eedc560985826c8a6c3cb7ab43220cad23c";
+        url = http://download.java.net/dlj/binaries/jdk-6u6-dlj-linux-i586.bin;
+        sha256 = "35ad958d88ed2af892c3879c815988bfae7775dd484e920186d1f8ad02a2c076";
       }
     else if stdenv.system == "x86_64-linux" then
       fetchurl {
-        url = http://download.java.net/dlj/binaries/jdk-6u4-dlj-linux-amd64.bin;
-        sha256 = "be0e21402a79c5b6cd6c96d34451bcc365619cd063930f3ca1c1abe2ee5dbf43";
+        url = http://download.java.net/dlj/binaries/jdk-6u6-dlj-linux-amd64.bin;
+        sha256 = "f9e80c53e15d8faf0d3381e2e2540bade4c5f849ff72984a2ed34e3208f0b7ea";
       }
     else
       abort "jdk requires i686-linux or x86_64 linux";
@@ -53,8 +53,13 @@ assert pluginSupport -> libstdcpp5 != null;
       abort "jdk requires i686-linux or x86_64 linux";
 
   buildInputs = [unzip makeWrapper];
+  
+  /**
+   * libXt is only needed on amd64
+   */
   libraries =
-    (if swingSupport then [xlibs.libX11 xlibs.libXext xlibs.libXtst xlibs.libXi] else []);
+    [stdenv.gcc.libc] ++
+    (if swingSupport then [xlibs.libX11 xlibs.libXext xlibs.libXtst xlibs.libXi xlibs.libXp xlibs.libXt] else []);
 
   inherit pluginSupport;
 } // (
@@ -65,7 +70,7 @@ assert pluginSupport -> libstdcpp5 != null;
       inherit libstdcpp5;
     }
   else
-    {}
+    {}  
 ))
 //
   {
diff --git a/pkgs/development/compilers/llvm/builder.sh b/pkgs/development/compilers/llvm/builder.sh
new file mode 100644
index 00000000000..962e8d37238
--- /dev/null
+++ b/pkgs/development/compilers/llvm/builder.sh
@@ -0,0 +1,86 @@
+source $stdenv/setup
+
+
+export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
+mkdir $NIX_FIXINC_DUMMY
+
+export X_CFLAGS="-I${gmp}/include -I${mpfr}/include -L${gmp}/lib -L${mpfr}/lib";
+
+# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
+# Thing.
+export CPP="gcc -E"
+
+
+if test "$noSysDirs" = "1"; then
+
+    if test -e $NIX_GCC/nix-support/orig-libc; then
+
+        # Figure out what extra flags to pass to the gcc compilers
+        # being generated to make sure that they use our glibc.
+        extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
+        extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
+
+        # Use *real* header files, otherwise a limits.h is generated
+        # that does not include Glibc's limits.h (notably missing
+        # SSIZE_MAX, which breaks the build).
+        export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
+        
+    else
+        # Hack: support impure environments.
+        extraCFlags="-isystem /usr/include"
+        extraLDFlags="-L/usr/lib64 -L/usr/lib"
+        export NIX_FIXINC_DUMMY=/usr/include
+    fi
+
+    extraCFlags="-g0 $extraCFlags"
+    extraLDFlags="--strip-debug $extraLDFlags"
+
+    export NIX_EXTRA_CFLAGS=$extraCFlags
+    for i in $extraLDFlags; do
+        export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
+    done
+
+    makeFlagsArray=( \
+        NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        LIMITS_H_TEST=true \
+        X_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
+        LDFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
+        LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
+        )
+fi
+
+
+preConfigure=preConfigure
+preConfigure() {
+    # Perform the build in a different directory.
+    mkdir ../build
+    cd ../build
+    configureScript=../$sourceRoot/configure
+}
+
+
+postInstall=postInstall
+postInstall() {
+    # Remove precompiled headers for now.  They are very big and
+    # probably not very useful yet.
+    find $out/include -name "*.gch" -exec rm -rf {} \; -prune
+
+    # Remove `fixincl' to prevent a retained dependency on the
+    # previous gcc.
+    rm -rf $out/libexec/gcc/*/*/install-tools
+
+    # Get rid of some "fixed" header files
+    rm -rf $out/lib/gcc/*/*/include/root
+}
+
+
+if test -z "$staticCompiler"; then
+    if test -z "$profiledCompiler"; then
+        buildFlags="bootstrap $buildFlags"
+    else    
+        buildFlags="profiledbootstrap $buildFlags"
+    fi
+fi
+
+genericBuild
diff --git a/pkgs/development/compilers/llvm/default.nix b/pkgs/development/compilers/llvm/default.nix
new file mode 100644
index 00000000000..dd13441468c
--- /dev/null
+++ b/pkgs/development/compilers/llvm/default.nix
@@ -0,0 +1,11 @@
+{stdenv, fetchurl, gcc, flex, perl, libtool }:
+
+stdenv.mkDerivation {
+  name = "llvm-2.2";
+  src = fetchurl {
+    url    = http://llvm.org/releases/2.2/llvm-2.2.tar.gz;
+    sha256 = "788d871aec139e0c61d49533d0252b21c4cd030e91405491ee8cb9b2d0311072";
+  };
+
+  buildInputs = [ gcc flex perl libtool ];
+}
diff --git a/pkgs/development/compilers/llvm/llvm-gcc.nix b/pkgs/development/compilers/llvm/llvm-gcc.nix
new file mode 100644
index 00000000000..20090d4b1c6
--- /dev/null
+++ b/pkgs/development/compilers/llvm/llvm-gcc.nix
@@ -0,0 +1,67 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://llvm.org/releases/2.2/llvm-gcc4.2-2.2.source.tar.gz;
+    sha256 = "11vjn8wn76cq63jam7y5ralq1b12r6cdipf22nsnzw90srb49qkp";
+  };
+
+  buildInputs = [llvm bison flex perl libtool];
+  configureFlags = [ " --enable-languages=c,c++ " ];
+  makeFlags = [" -f Makefile "];
+
+  phaseNames = [ "doPatch" "preConfigure" "doConfigure" 
+    "doMakeInstall" "postInstall"];
+
+  patches = [ ./no-sys-dirs.patch ];
+
+  preConfigure = FullDepEntry (''
+
+    sed -e 's,^LLVMSRCDIR.*,LLVMSRCDIR := dummy,' \
+        -e 's,\$(LLVMSRCDIR)/include,${llvm}/include,g' \
+        -e 's,^LLVMOBJDIR.*,LLVMOBJDIR := dummy,' \
+        -e 's,\$(LLVMOBJDIR)/include,${llvm}/include,g' \
+        -e 's,^LLVMBINPATH.*,LLVMBINPATH = ${llvm}/bin,' \
+        -i gcc/Makefile.in 
+
+    cd ..
+    mkdir obj install
+    cd obj
+
+    export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
+    mkdir $NIX_FIXINC_DUMMY
+
+    export CPP="gcc -E"
+
+    # Figure out what extra flags to pass to the gcc compilers
+    # being generated to make sure that they use our glibc.
+    extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
+    extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
+
+    # Use *real* header files, otherwise a limits.h is generated
+    # that does not include Glibc's limits.h (notably missing
+    # SSIZE_MAX, which breaks the build).
+    export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
+
+    extraCFlags="-g0 $extraCFlags"
+    extraLDFlags="--strip-debug $extraLDFlags"
+
+    export NIX_EXTRA_CFLAGS=$extraCFlags
+    for i in $extraLDFlags; do
+        export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
+    done
+
+  '') ["doUnpack" "minInit"];
+  configureCommand = "$(ls ../llvm-gcc*.*.source/configure)";
+
+  postInstall = FullDepEntry (''
+    mv $out/bin/gcc $out/bin/llvm-gcc
+    mv $out/bin/g++ $out/bin/llvm-g++
+  '')["doMakeInstall" "minInit"];
+  
+  name = "llvm-gcc42-2.2";
+  meta = {
+    description = "LLVM GCC frontend";
+  };
+}
+
+  
diff --git a/pkgs/development/compilers/llvm/no-sys-dirs.patch b/pkgs/development/compilers/llvm/no-sys-dirs.patch
new file mode 100644
index 00000000000..3569afe9570
--- /dev/null
+++ b/pkgs/development/compilers/llvm/no-sys-dirs.patch
@@ -0,0 +1,139 @@
+diff -rc gcc-4.2.0-orig/Makefile.in gcc-4.2.0/Makefile.in
+*** gcc-4.2.0-orig/Makefile.in	2006-12-29 18:47:06.000000000 +0100
+--- gcc-4.2.0/Makefile.in	2007-05-20 21:06:42.000000000 +0200
+***************
+*** 364,369 ****
+--- 364,377 ----
+  @host_makefile_frag@
+  ###
+  
++ CFLAGS += $(NIX_EXTRA_CFLAGS)
++ CPPFLAGS_FOR_TARGET += $(NIX_EXTRA_CFLAGS)
++ CXXFLAGS += $(NIX_EXTRA_CFLAGS)
++ LDFLAGS += $(NIX_EXTRA_LDFLAGS)
++ LDFLAGS_FOR_TARGET += $(NIX_EXTRA_LDFLAGS)
++ BOOT_CFLAGS += $(NIX_EXTRA_CFLAGS)
++ BOOT_LDFLAGS += $(NIX_EXTRA_LDFLAGS)
++ 
+  # This is the list of directories that may be needed in RPATH_ENVVAR
+  # so that prorgams built for the target machine work.
+  TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(HOST_LIB_PATH_gcc)
+diff -rc gcc-4.2.0-orig/gcc/Makefile.in gcc-4.2.0/gcc/Makefile.in
+*** gcc-4.2.0-orig/gcc/Makefile.in	2007-03-12 05:40:09.000000000 +0100
+--- gcc-4.2.0/gcc/Makefile.in	2007-05-20 19:35:13.000000000 +0200
+***************
+*** 396,402 ****
+  MD5_H	    = $(srcdir)/../include/md5.h
+  
+  # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
+! NATIVE_SYSTEM_HEADER_DIR = /usr/include
+  # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
+  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
+  
+--- 396,406 ----
+  MD5_H	    = $(srcdir)/../include/md5.h
+  
+  # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
+! # Nix: we override NATIVE_SYSTEM_HEADER_DIR in order to prevent
+! # `fixinc' from fixing header files in /usr/include.  However,
+! # NATIVE_SYSTEM_HEADER_DIR must point to an existing directory, so set
+! # it to some dummy directory.
+! NATIVE_SYSTEM_HEADER_DIR = $(NIX_FIXINC_DUMMY)
+  # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
+  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
+  
+***************
+*** 3066,3072 ****
+    -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+    -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
+    -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+!   -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
+    -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
+    -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+    @TARGET_SYSTEM_ROOT_DEFINE@
+--- 3070,3076 ----
+    -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+    -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
+    -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+!   -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
+    -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
+    -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+    @TARGET_SYSTEM_ROOT_DEFINE@
+diff -rc gcc-4.2.0-orig/gcc/cppdefault.c gcc-4.2.0/gcc/cppdefault.c
+*** gcc-4.2.0-orig/gcc/cppdefault.c	2006-01-20 22:00:03.000000000 +0100
+--- gcc-4.2.0/gcc/cppdefault.c	2007-05-20 17:16:44.000000000 +0200
+***************
+*** 41,46 ****
+--- 41,50 ----
+  # undef CROSS_INCLUDE_DIR
+  #endif
+  
++ #undef LOCAL_INCLUDE_DIR
++ #undef SYSTEM_INCLUDE_DIR
++ #undef STANDARD_INCLUDE_DIR
++ 
+  /* APPLE LOCAL begin mainline 4.3 2006-12-13 CROSS_DIRECTORY_STRUCTURE 4697325 */
+  #if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
+  /* APPLE LOCAL end mainline 4.3 2006-12-13 CROSS_DIRECTORY_STRUCTURE 4697325 */
+diff -rc gcc-4.2.0-orig/gcc/gcc.c gcc-4.2.0/gcc/gcc.c
+*** gcc-4.2.0-orig/gcc/gcc.c	2007-03-05 21:37:05.000000000 +0100
+--- gcc-4.2.0/gcc/gcc.c	2007-05-20 17:49:48.000000000 +0200
+***************
+*** 1449,1458 ****
+  /* Default prefixes to attach to command names.  */
+  
+  #ifndef STANDARD_STARTFILE_PREFIX_1
+! #define STANDARD_STARTFILE_PREFIX_1 "/lib/"
+  #endif
+  #ifndef STANDARD_STARTFILE_PREFIX_2
+! #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
+  #endif
+  
+  #ifdef CROSS_COMPILE  /* Don't use these prefixes for a cross compiler.  */
+--- 1449,1458 ----
+  /* Default prefixes to attach to command names.  */
+  
+  #ifndef STANDARD_STARTFILE_PREFIX_1
+! #define STANDARD_STARTFILE_PREFIX_1 ""
+  #endif
+  #ifndef STANDARD_STARTFILE_PREFIX_2
+! #define STANDARD_STARTFILE_PREFIX_2 ""
+  #endif
+  
+  #ifdef CROSS_COMPILE  /* Don't use these prefixes for a cross compiler.  */
+***************
+*** 1473,1480 ****
+  #endif
+  
+  static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
+! static const char *const standard_exec_prefix_1 = "/usr/libexec/gcc/";
+! static const char *const standard_exec_prefix_2 = "/usr/lib/gcc/";
+  static const char *md_exec_prefix = MD_EXEC_PREFIX;
+  
+  static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
+--- 1473,1480 ----
+  #endif
+  
+  static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
+! static const char *const standard_exec_prefix_1 = "/no-such-path/";
+! static const char *const standard_exec_prefix_2 = "/no-such-path/";
+  static const char *md_exec_prefix = MD_EXEC_PREFIX;
+  
+  static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
+diff -rc gcc-4.2.0-orig/ltconfig gcc-4.2.0/ltconfig
+*** gcc-4.2.0-orig/ltconfig	2007-02-14 18:08:35.000000000 +0100
+--- gcc-4.2.0/ltconfig	2007-05-20 22:16:24.000000000 +0200
+***************
+*** 2322,2327 ****
+--- 2322,2332 ----
+  # A language-specific compiler.
+  CC=$CC
+  
++ # Ugly hack to get libmudflap (and possibly other libraries) to build.
++ # Libtool filters out \`-B' flags when linking (why?), so the \`-B' flag
++ # to Glibc gets lost.  Here we forcibly add it to any invocation.
++ CC="\$CC $NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS"
++ 
+  # Is the compiler the GNU C compiler?
+  with_gcc=$with_gcc
+  
diff --git a/pkgs/development/compilers/ocaml/3.10.0.nix b/pkgs/development/compilers/ocaml/3.10.0.nix
index a26175755b5..8a8ddd7ee97 100644
--- a/pkgs/development/compilers/ocaml/3.10.0.nix
+++ b/pkgs/development/compilers/ocaml/3.10.0.nix
@@ -1,23 +1,28 @@
 args: with args;
-stdenv.mkDerivation rec {
-	name = "ocaml-3.10.0";
-	src = fetchurl {
-		url = "http://caml.inria.fr/pub/distrib/ocaml-3.10/${name}.tar.bz2";
-		sha256 = "1ihmx1civ78s7k2hfc05z1s9vbyx2qw7fg8lnbxnfd6zxkk8878d";
-	};
-	prefixKey = "-prefix ";
-	configureFlags = ["-no-tk" "-x11lib" x11];
-	buildFlags = "world bootstrap world.opt";
-	buildInputs = [x11 ncurses];
-	installTargets = "install installopt"; 
-	patchPhase = "
-	CAT=$(type -tp cat)
-	sed -e \"s@/bin/cat@\${CAT}@\" -i config/auto-aux/sharpbang
-	";
 
-	meta = {
-		homepage = http://caml.inria.fr/ocaml;
-		license = "QPL, LGPL2 (library part)";
-		desctiption = "Most popular variant of the Caml language";
-	};
-}
+stdenv.mkDerivation (rec {
+  
+  name = "ocaml-3.10.0";
+  
+  src = fetchurl {
+    url = "http://caml.inria.fr/pub/distrib/ocaml-3.10/${name}.tar.bz2";
+    sha256 = "1ihmx1civ78s7k2hfc05z1s9vbyx2qw7fg8lnbxnfd6zxkk8878d";
+  };
+
+  prefixKey = "-prefix ";
+  configureFlags = ["-no-tk" "-x11lib" x11];
+  buildFlags = "world bootstrap world.opt";
+  buildInputs = [x11 ncurses];
+  installTargets = "install installopt"; 
+  patchPhase = ''
+    CAT=$(type -tp cat)
+    sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang
+  '';
+
+  meta = {
+    homepage = http://caml.inria.fr/ocaml;
+    license = "QPL, LGPL2 (library part)";
+    desctiption = "Most popular variant of the Caml language";
+  };
+
+})
diff --git a/pkgs/development/compilers/roadsend/default.nix b/pkgs/development/compilers/roadsend/default.nix
index d7c693b6864..c7b04f87109 100644
--- a/pkgs/development/compilers/roadsend/default.nix
+++ b/pkgs/development/compilers/roadsend/default.nix
@@ -4,7 +4,7 @@ let edf = args.lib.enableDisableFeature; in
     flagConfig = {
       mandatory = { buildInputs = ["bigloo" "curl"]; };
     } // edf "pcre" "pcre" { } #support pcre extension [default=check]
-      // edf "fcgi" "fcgi" { } #support FastCGI web backend [default=check]
+      // edf "fcgi" "fcgi" { pass = "fcgi"; } #support FastCGI web backend [default=check]
       // edf "xml" "xml" { pass ="libxml2"; } #support xml extension [default=check]
       // edf "mysql" "mysql" { pass = "mysql"; } #support mysql extension [default=check]
       #// edf "sqlite3=[ARG]" "sqlite3=[ARG]" { } [>use SQLite 3 library [default=yes], optionally
@@ -13,7 +13,7 @@ let edf = args.lib.enableDisableFeature; in
       // edf "gtk" "gtk" { } #support PHP-GTK extension [default=no]
       // edf "gtk2" "gtk2" { }; #support PHP-GTK 2 extension [default=no]
 
-    optionals = [ "libxml2" "gettext" ];
+    optionals = [ "libxml2" "gettext" "fcgi" ];
     extraAttrs = co : {
       name = "roadsend-2.9.3";
 
@@ -22,6 +22,9 @@ let edf = args.lib.enableDisableFeature; in
         sha256 = "0nw7rvrrwkss5cp6ws0m3q63q1mcyy27s8yjhy7kn508db1rgl9x";
       };
 
+    # tell pcc where to find the fastcgi library 
+      postInstall = " sed -e \"s=(ldflags fastcgi.*=(ldflags -l fastcgi -L \$fcgi)=\" -i \$out/etc/pcc.conf ";
+
     meta = { 
       description = "roadsend PHP -> C compiler";
       homepage = http://www.roadsend.com;
diff --git a/pkgs/development/compilers/scala/default.nix b/pkgs/development/compilers/scala/default.nix
new file mode 100644
index 00000000000..6dacef9c1c0
--- /dev/null
+++ b/pkgs/development/compilers/scala/default.nix
@@ -0,0 +1,22 @@
+args: with args;
+
+stdenv.mkDerivation rec {
+  name = "scala-2.7.1";
+
+  src = fetchurl {
+    url = "http://www.scala-lang.org/downloads/distrib/files/${name}.final.tar.gz";
+    sha256 = "3cad113ed7b84f4f009897f6066bee28459e63a1cf1a6d5d56f10f4d1f9819ec";
+  };
+
+  installPhase = ''
+    mkdir -p $out
+    mv * $out
+    rm -f $out/bin/*.bat
+  '';
+
+  phases = "unpackPhase installPhase";
+
+  meta = {
+    description = "Scala is a general purpose programming language";
+  };
+}
diff --git a/pkgs/development/compilers/stalin/default.nix b/pkgs/development/compilers/stalin/default.nix
new file mode 100644
index 00000000000..37b7baa4382
--- /dev/null
+++ b/pkgs/development/compilers/stalin/default.nix
@@ -0,0 +1,42 @@
+{ fetchurl, stdenv, libX11 }:
+
+stdenv.mkDerivation rec {
+  name = "stalin-0.11";
+
+  src = fetchurl {
+    url = "ftp://ftp.ecn.purdue.edu/qobi/stalin.tar.Z";
+    sha256 = "0lz8riccpigdixwf6dswwva6s4kxaz3dzxhkqhcxgwmffy30vw8s";
+  };
+
+  buildInputs = [ libX11 ];
+
+  buildPhase = '' ./build '';
+
+  installPhase = ''
+    ensureDir "$out/bin"
+    cp stalin "$out/bin"
+
+    ensureDir "$out/man/man1"
+    cp stalin.1 "$out/man/man1"
+
+    ensureDir "$out/share/emacs/site-lisp"
+    cp stalin.el "$out/share/emacs/site-lisp"
+
+    ensureDir "$out/doc/${name}"
+    cp README "$out/doc/${name}"
+
+    ensureDir "$out/share/${name}/include"
+    cp include/* "$out/share/${name}/include"
+
+    substituteInPlace "$out/bin/stalin" \
+      --replace "$PWD/include/stalin" "$out/share/${name}/include/stalin"
+    substituteInPlace "$out/bin/stalin" \
+      --replace "$PWD/include" "$out/share/${name}/include"
+  '';
+
+  meta = {
+    homepage = http://www.ece.purdue.edu/~qobi/software.html;
+    license = "GPLv2+";
+    description = "Stalin, an optimizing Scheme compiler";
+  };
+}
diff --git a/pkgs/development/compilers/swi-prolog/5.6.51.nix b/pkgs/development/compilers/swi-prolog/5.6.51.nix
new file mode 100644
index 00000000000..cd640e5f26b
--- /dev/null
+++ b/pkgs/development/compilers/swi-prolog/5.6.51.nix
@@ -0,0 +1,4 @@
+args: import ./default.nix {
+  args = args;
+  sha256 = "d43862606284e659ec3acba9cddea53b772f9afb67d12aa36391d26fe1a05ad8";
+}
diff --git a/pkgs/development/compilers/swi-prolog/default.nix b/pkgs/development/compilers/swi-prolog/default.nix
new file mode 100644
index 00000000000..23682db364f
--- /dev/null
+++ b/pkgs/development/compilers/swi-prolog/default.nix
@@ -0,0 +1,16 @@
+{args, sha256}: with args;
+
+stdenv.mkDerivation {
+  name = "swi-prolog-${version}";
+
+  src = fetchurl {
+    url = "http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/pl-${version}.tar.gz";
+    inherit sha256;
+  };
+
+  meta = {
+    homepage = http://www.swi-prolog.org/;
+    description = "A Prolog compiler and interpreter.";
+    license = "LGPL";
+  };
+}
diff --git a/pkgs/development/compilers/webdsl/default.nix b/pkgs/development/compilers/webdsl/default.nix
index da961cbf2f6..e99456b5d2f 100644
--- a/pkgs/development/compilers/webdsl/default.nix
+++ b/pkgs/development/compilers/webdsl/default.nix
@@ -1,12 +1,12 @@
 {stdenv, fetchurl, aterm, sdf, strategoxt, pkgconfig, javafront}:
 
 stdenv.mkDerivation {
-  name = "webdsl-7.12pre876";
+  name = "webdsl-8.2pre1006";
   builder = ./builder.sh;
 
   src = fetchurl {
-    url = http://buildfarm.st.ewi.tudelft.nl/releases/strategoxt/webdsl-7.12pre876-g60njq3p/webdsl-7.12pre876.tar.gz;
-    md5 = "7cd8709b02e03da74d90f8f8388e8d01";
+    url = http://buildfarm.st.ewi.tudelft.nl/releases/strategoxt/webdsl-8.2pre1006-c8h623yn/webdsl-8.2.tar.gz;
+    md5 = "07c2471c961acc6467c55594e49da7c1";
   };
 
   inherit aterm sdf strategoxt javafront;
diff --git a/pkgs/development/compilers/yap/default.nix b/pkgs/development/compilers/yap/default.nix
new file mode 100644
index 00000000000..27075d1cca6
--- /dev/null
+++ b/pkgs/development/compilers/yap/default.nix
@@ -0,0 +1,17 @@
+args:
+args.stdenv.mkDerivation rec {
+  name = "Yap-5.1.1";
+
+  src = args.fetchurl {
+    url = "http://downloads.sourceforge.net/yap/${name}.tar.gz";
+    sha256 = "0bajxmlla9gay4m4l7y7x6qldxzi0jcq2ykgpjk9liky7g5kbnya";
+  };
+
+  buildInputs =(with args; []);
+
+  meta = { 
+      description = "Yap Prolog System is a ISO-compatible high-performance Prolog compiler";
+      homepage = http://yap.sourceforge.net/;
+      license = "artistic";
+  };
+}
diff --git a/pkgs/development/eclipse/jdt-sdk/default.nix b/pkgs/development/eclipse/jdt-sdk/default.nix
index 4734522b5f4..40d1589f770 100644
--- a/pkgs/development/eclipse/jdt-sdk/default.nix
+++ b/pkgs/development/eclipse/jdt-sdk/default.nix
@@ -1,12 +1,15 @@
 {stdenv, fetchurl, unzip}:
 
-stdenv.mkDerivation {
-  name = "eclipse-jdt-sdk-3.1";
+stdenv.mkDerivation ( rec {
+  pname = "eclipse-JDT-SDK";
+  version = "3.3.2";
+  name = "${pname}-${version}";
+
   builder = ./builder.sh;
   src = fetchurl {
-    url = http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops/R-3.1-200506271435/eclipse-JDT-SDK-3.1.zip;
-    md5 = "665b51beaa718b2fec6b0155ed369f76";
+    url = http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops/R-3.3.2-200802211800/eclipse-JDT-SDK-3.3.2.zip;
+    md5 = "f9e513b7e3b609feef28651c07807b17";
   };
 
   buildInputs = [unzip];
-}
+})
diff --git a/pkgs/development/guile-modules/guile-lib/default.nix b/pkgs/development/guile-modules/guile-lib/default.nix
index cc26c458a06..c96101ed539 100644
--- a/pkgs/development/guile-modules/guile-lib/default.nix
+++ b/pkgs/development/guile-modules/guile-lib/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, guile}:
+{stdenv, fetchurl, guile, texinfo}:
 
 stdenv.mkDerivation rec {
   name = "guile-lib-0.1.6";
@@ -7,7 +7,7 @@ stdenv.mkDerivation rec {
     sha256 = "827744c7954078f1f37e0bf70252ec70b4d60c1482a3542a49bd09723cf65d12";
   };
 
-  buildInputs = [guile];
+  buildInputs = [guile texinfo];
 
   postInstall = ''
     # Remove modules already provided by Guile.
@@ -19,19 +19,13 @@ stdenv.mkDerivation rec {
     then
 	rm -f "$out/share/guile/site/srfi/srfi-35.scm"
     fi
-
-    # Make modules available under `/lib/site-guile' to comply with Guile's
-    # setup-hook.
-    mkdir -p "$out/lib/site-guile"
-    for f in "$out/share/guile/site"/*
-    do
-      ln -s "$f" "$out/lib/site-guile/"
-    done
   '';
 
+  doCheck = true;
+
   meta = {
-    description = ''Guile-Library, a set of various useful
-                    Guile Scheme modules.'';
+    description = ''Guile-Library, a collection of useful Guile
+                    Scheme modules'';
     homepage = http://home.gna.org/guile-lib/;
     license = "GPL";
   };
diff --git a/pkgs/development/interpreters/clisp/default.nix b/pkgs/development/interpreters/clisp/default.nix
index 5095bf985d4..d0dca6b1a16 100644
--- a/pkgs/development/interpreters/clisp/default.nix
+++ b/pkgs/development/interpreters/clisp/default.nix
@@ -11,8 +11,12 @@ stdenv.mkDerivation rec {
   inherit libsigsegv gettext coreutils;
   buildInputs = [libsigsegv gettext ncurses readline libX11 libXau
 	libXt pcre zlib];
-  
+ 
+  # First, replace port 9090 (rather low, can be used)
+  # with 64237 (much higher, IANA private area, not
+  # anything rememberable).
   patchPhase = ''
+  sed -e 's@9090@64237@g' -i tests/socket.tst
   sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
   find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i
   '';
diff --git a/pkgs/development/interpreters/guile/default.nix b/pkgs/development/interpreters/guile/default.nix
index 9aaa796d6b2..0c3aeb07a1e 100644
--- a/pkgs/development/interpreters/guile/default.nix
+++ b/pkgs/development/interpreters/guile/default.nix
@@ -1,12 +1,15 @@
-args: with args; 
+{ fetchurl, stdenv, libtool, readline, gmp
+, gawk, makeWrapper }:
 
 stdenv.mkDerivation rec {
-  name = "guile-1.8.4";
+  name = "guile-1.8.5";
   src = fetchurl {
-    url = "ftp://ftp.gnu.org/gnu/guile/" + name + ".tar.gz";
-    sha256 = "1cz1d4n6vzw0lfsvplsiarwqk675f12j596dzfv0h5r9cljpc0ya";
+    url = "mirror://gnu/guile/" + name + ".tar.gz";
+    sha256 = "12b215bbqqkanapwh4dp3lnkg7k239dqiawfcdrb1zjz8hnkvxp2";
   };
 
+  patches = [ ./popen-zombie.patch ];
+
   buildInputs = [ makeWrapper ];
   propagatedBuildInputs = [readline libtool gmp gawk];
 
@@ -14,13 +17,19 @@ stdenv.mkDerivation rec {
     wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
   '';
 
+  doCheck = true;
+
   setupHook = ./setup-hook.sh;
 
   meta = {
-    description = ''GNU Guile is an interpreter for the Scheme
-                    programming language, packaged as a library that
-		    can be embedded into programs to make them extensible.'';
+    description = "GNU Guile, an embeddable Scheme interpreter";
+    longDescription = ''
+      GNU Guile is an interpreter for the Scheme programming language,
+      packaged as a library that can be embedded into programs to make
+      them extensible.  It supports many SRFIs.
+    '';
+
     homepage = http://www.gnu.org/software/guile/;
-    license = "LGPL";
+    license = "LGPLv2+";
   };
 }
diff --git a/pkgs/development/interpreters/guile/popen-zombie.patch b/pkgs/development/interpreters/guile/popen-zombie.patch
new file mode 100644
index 00000000000..215c87a3a7b
--- /dev/null
+++ b/pkgs/development/interpreters/guile/popen-zombie.patch
@@ -0,0 +1,45 @@
+Index: guile/test-suite/tests/popen.test
+===================================================================
+RCS file: /sources/guile/guile/guile-core/guile/test-suite/tests/popen.test,v
+retrieving revision 1.3.2.2
+diff -u -r1.3.2.2 popen.test
+--- guile/test-suite/tests/popen.test	25 Aug 2006 01:21:39 -0000	1.3.2.2
++++ guile/test-suite/tests/popen.test	18 Mar 2008 20:18:08 -0000
+@@ -1,6 +1,6 @@
+ ;;;; popen.test --- exercise ice-9/popen.scm      -*- scheme -*-
+ ;;;;
+-;;;; Copyright 2003, 2006 Free Software Foundation, Inc.
++;;;; Copyright 2003, 2006, 2008 Free Software Foundation, Inc.
+ ;;;;
+ ;;;; This library is free software; you can redistribute it and/or
+ ;;;; modify it under the terms of the GNU Lesser General Public
+@@ -81,12 +81,15 @@
+     (let* ((pair (pipe))
+ 	   (port (with-error-to-port (cdr pair)
+ 		   (lambda ()
+-		     (open-input-pipe
+-		      "exec 1>/dev/null; echo closed 1>&2; exec 2>/dev/null; sleep 999")))))
++		     (open-input-output-pipe
++		      "exec 1>/dev/null; echo closed 1>&2; exec 2>/dev/null; read")))))
+       (close-port (cdr pair))   ;; write side
+-      (and (char? (read-char (car pair))) ;; wait for child to do its thing
+-	   (char-ready? port)
+-	   (eof-object? (read-char port))))))
++      (let ((result (and (char? (read-char (car pair))) ;; wait for child to do its thing
++			 (char-ready? port)
++			 (eof-object? (read-char port)))))
++	(display "hello!\n" port)
++	(close-pipe port)
++	result))))
+ 
+ ;;
+ ;; open-output-pipe
+@@ -132,7 +135,7 @@
+ 	      (port (with-error-to-port (cdr pair)
+ 		      (lambda ()
+ 			(open-output-pipe
+-			 "exec 0</dev/null; echo closed 1>&2; exec 2>/dev/null; sleep 999")))))
++			 "exec 0</dev/null; echo closed 1>&2; exec 2>/dev/null; read")))))
+ 	 (close-port (cdr pair))   ;; write side
+ 	 (and (char? (read-char (car pair))) ;; wait for child to do its thing
+ 	      (catch 'system-error
diff --git a/pkgs/development/interpreters/guile/setup-hook.sh b/pkgs/development/interpreters/guile/setup-hook.sh
index 114bc4e87cc..87cb5118506 100644
--- a/pkgs/development/interpreters/guile/setup-hook.sh
+++ b/pkgs/development/interpreters/guile/setup-hook.sh
@@ -1,7 +1,7 @@
 addGuileLibPath () {
-    if test -d "$1/lib/site-guile"
+    if test -d "$1/share/guile/site"
     then
-        export GUILE_LOAD_PATH="${GUILE_LOAD_PATH}${GUILE_LOAD_PATH:+:}$1/lib/site-guile"
+        export GUILE_LOAD_PATH="${GUILE_LOAD_PATH}${GUILE_LOAD_PATH:+:}$1/share/guile/site"
     fi
 }
 
diff --git a/pkgs/development/interpreters/php_configurable/default.nix b/pkgs/development/interpreters/php_configurable/default.nix
index d18a2cf2b05..9e80e741d20 100644
--- a/pkgs/development/interpreters/php_configurable/default.nix
+++ b/pkgs/development/interpreters/php_configurable/default.nix
@@ -1,479 +1,113 @@
-/*  TODO check security issues such as :
-+--------------------------------------------------------------------+
-|                        *** WARNING ***                             |
-|                                                                    |
-| You will be compiling the CGI version of PHP without any           |
-| redirection checking.  By putting this cgi binary somewhere in     |
-| your web space, users may be able to circumvent existing .htaccess |
-| security by loading files directly through the parser.  See        |
-| http://www.php.net/manual/security.php for more details.           |
-*/
-
-let version = "5.2.5"; in
+let version = "5.2.6"; in
 
 args:
-( args.mkDerivationByConfiguration {
-    flagConfig = {
-
-    /*
-
-    // The order tries to represent the order given by configure --help 
-       The nix option representation of implemented options is given below
-       only some opitions right now.. They'll grow when I need them
-
-    Configuration:
-      --cache-file=FILE       cache test results in FILE
-      --help                  print this message
-      --no-create             do not create output files
-      --quiet, --silent       do not print `checking...' messages
-      --version               print the version of autoconf that created configure
-
-    Directory and file names:
-      --prefix=PREFIX         install architecture-independent files in PREFIX
-                              [/usr/local]
-      --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                              [same as prefix]
-      --bindir=DIR            user executables in DIR [EPREFIX/bin]
-      --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
-      --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
-      --datadir=DIR           read-only architecture-independent data in DIR
-                              [PREFIX/share]
-      --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
-      --sharedstatedir=DIR    modifiable architecture-independent data in DIR
-                              [PREFIX/com]
-      --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
-      --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
-      --includedir=DIR        C header files in DIR [PREFIX/include]
-      --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
-      --infodir=DIR           info documentation in DIR [PREFIX/info]
-      --mandir=DIR            man documentation in DIR [PREFIX/man]
-      --srcdir=DIR            find the sources in DIR [configure dir or ..]
-      --program-prefix=PREFIX prepend PREFIX to installed program names
-      --program-suffix=SUFFIX append SUFFIX to installed program names
-      --program-transform-name=PROGRAM
-                              run sed PROGRAM on installed program names
-    Host type:
-      --build=BUILD           configure for building on BUILD [BUILD=HOST]
-      --host=HOST             configure for HOST [guessed]
-      --target=TARGET         configure for TARGET [TARGET=HOST]
-    Features and packages:
-      --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-      --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-      --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-      --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-      --x-includes=DIR        X include files are in DIR
-      --x-libraries=DIR       X library files are in DIR
-    --enable and --with options recognized:
-      --with-libdir=NAME      Look for libraries in .../NAME rather than .../lib
-      --disable-rpath         Disable passing additional runtime library
-                              search paths
-
-
 
-    SAPI modules:
+(args.mkDerivationByConfiguration {
 
-      --with-aolserver=DIR    Specify path to the installed AOLserver
-      --with-apxs[=FILE]      Build shared Apache 1.x module. FILE is the optional
-                              pathname to the Apache apxs tool [apxs]
-      --with-apache[=DIR]     Build Apache 1.x module. DIR is the top-level Apache
-                              build directory [/usr/local/apache]
-      --enable-mod-charset      APACHE: Enable transfer tables for mod_charset (Rus Apache)
-      --with-apxs2filter[=FILE]   
-                              EXPERIMENTAL: Build shared Apache 2.0 Filter module. FILE is the optional
-                              pathname to the Apache apxs tool [apxs]
-      --with-apxs2[=FILE]     Build shared Apache 2.0 Handler module. FILE is the optional
-                              pathname to the Apache apxs tool [apxs]
-      --with-apache-hooks[=FILE]      
-                              EXPERIMENTAL: Build shared Apache 1.x module. FILE is the optional
-                              pathname to the Apache apxs tool [apxs]
-      --with-apache-hooks-static[=DIR]
-                              EXPERIMENTAL: Build Apache 1.x module. DIR is the top-level Apache
-                              build directory [/usr/local/apache]
-      --enable-mod-charset      APACHE (hooks): Enable transfer tables for mod_charset (Rus Apache)
-      --with-caudium[=DIR]    Build PHP as a Pike module for use with Caudium.
-                              DIR is the Caudium server dir [/usr/local/caudium/server]
-      --disable-cli           Disable building CLI version of PHP
-                              (this forces --without-pear)
-      --with-continuity=DIR   Build PHP as Continuity Server module. 
-                              DIR is path to the installed Continuity Server root
-      --enable-embed[=TYPE]   EXPERIMENTAL: Enable building of embedded SAPI library
-                              TYPE is either 'shared' or 'static'. [TYPE=shared]
-      --with-isapi[=DIR]      Build PHP as an ISAPI module for use with Zeus
-      --with-milter[=DIR]     Build PHP as Milter application
-      --with-nsapi=DIR        Build PHP as NSAPI module for Netscape/iPlanet/Sun Webserver
-      --with-phttpd=DIR       Build PHP as phttpd module
-      --with-pi3web[=DIR]     Build PHP as Pi3Web module
-      --with-roxen=DIR        Build PHP as a Pike module. DIR is the base Roxen
-                              directory, normally /usr/local/roxen/server
-      --enable-roxen-zts        ROXEN: Build the Roxen module using Zend Thread Safety
-      --with-thttpd=SRCDIR    Build PHP as thttpd module
-      --with-tux=MODULEDIR    Build PHP as a TUX module (Linux only)
-      --with-webjames=SRCDIR  Build PHP as a WebJames module (RISC OS only)
-      --disable-cgi           Disable building CGI version of PHP
-      --enable-fastcgi          CGI: Enable FastCGI support in the CGI binary
-      --enable-force-cgi-redirect
-                                CGI: Enable security check for internal server
-                                redirects. Use this if you run the PHP CGI with Apache
-      --enable-discard-path     CGI: When this is enabled the PHP CGI binary can 
-                                safely be placed outside of the web tree and people
-                                will not be able to circumvent .htaccess security
-      --disable-path-info-check CGI: If this is disabled, paths such as
-                                /info.php/test?a=b will fail to work
+  flagConfig = {
 
+# much left to do here... 
 
-    General settings:
-
-      --enable-gcov           Enable GCOV code coverage (requires LTP) - FOR DEVELOPERS ONLY!!
-      --enable-debug          Compile with debugging symbols
-      --with-layout=TYPE      Set how installed files will be laid out.  Type can
-                              be either PHP or GNU [PHP]
-      --with-config-file-path=PATH
-                              Set the path in which to look for php.ini [PREFIX/lib]
-      --with-config-file-scan-dir=PATH
-                              Set the path where to scan for configuration files
-      --enable-safe-mode      Enable safe mode by default
-      --with-exec-dir[=DIR]   Only allow executables in DIR under safe-mode
-                              [/usr/local/php/bin]
-      --enable-sigchild       Enable PHP's own SIGCHLD handler
-      --enable-magic-quotes   Enable magic quotes by default.
-      --enable-libgcc         Enable explicitly linking against libgcc
-      --disable-short-tags    Disable the short-form <? start tag by default
-      --enable-dmalloc        Enable dmalloc
-      --disable-ipv6          Disable IPv6 support
-      --enable-fd-setsize     Set size of descriptor sets
+    mandatory = { buildInputs = ["flex" "bison"]; };
 
+    # SAPI modules:
+    
+    apxs2 = {
+      cfgOption = "--with-apxs2=\$apacheHttpd/bin/apxs";
+      pass = "apacheHttpd";
+    };
 
-    Extensions:
+    # Extensions 
 
-      --with-EXTENSION=[shared[,PATH]]
+    curl = {
+      cfgOption = "--with-curl=${args.curl} --with-curlwrappers";
+      pass = "curl";
+    };
       
-        NOTE: Not all extensions can be build as 'shared'.
-
-        Example: --with-foobar=shared,/usr/local/foobar/
-
-          o Builds the foobar extension as shared extension.
-          o foobar package install prefix is /usr/local/foobar/
-
-
-     --disable-all   Disable all extensions which are enabled by default
-
-
-      --disable-libxml        Disable LIBXML support
-      --with-libxml-dir[=DIR]   LIBXML: libxml2 install prefix
-      --with-openssl[=DIR]    Include OpenSSL support (requires OpenSSL >= 0.9.6)
-      --with-kerberos[=DIR]     OPENSSL: Include Kerberos support
-      --without-pcre-regex    Do not include Perl Compatible Regular Expressions support.
-                              DIR is the PCRE install prefix [BUNDLED]
-      --with-zlib[=DIR]       Include ZLIB support (requires zlib >= 1.0.9)
-      --with-zlib-dir=<DIR>   Define the location of zlib install directory
-      --enable-bcmath         Enable bc style precision math functions
-      --with-bz2[=DIR]        Include BZip2 support
-      --enable-calendar       Enable support for calendar conversion
-      --disable-ctype         Disable ctype functions
-      --with-curl[=DIR]       Include cURL support
-      --with-curlwrappers     Use cURL for url streams
-      --enable-dba            Build DBA with bundled modules. To build shared DBA
-                              extension use --enable-dba=shared
-      --with-qdbm[=DIR]         DBA: QDBM support
-      --with-gdbm[=DIR]         DBA: GDBM support
-      --with-ndbm[=DIR]         DBA: NDBM support
-      --with-db4[=DIR]          DBA: Berkeley DB4 support
-      --with-db3[=DIR]          DBA: Berkeley DB3 support
-      --with-db2[=DIR]          DBA: Berkeley DB2 support
-      --with-db1[=DIR]          DBA: Berkeley DB1 support/emulation
-      --with-dbm[=DIR]          DBA: DBM support
-      --without-cdb[=DIR]       DBA: CDB support (bundled)
-      --disable-inifile         DBA: INI support (bundled)
-      --disable-flatfile        DBA: FlatFile support (bundled)
-      --enable-dbase          Enable the bundled dbase library
-      --disable-dom           Disable DOM support
-      --with-libxml-dir[=DIR]   DOM: libxml2 install prefix
-      --enable-exif           Enable EXIF (metadata from images) support
-      --with-fbsql[=DIR]      Include FrontBase support. DIR is the FrontBase base directory
-      --with-fdftk[=DIR]      Include FDF support
-      --disable-filter        Disable input filter support
-      --with-pcre-dir           FILTER: pcre install prefix
-      --enable-ftp            Enable FTP support
-      --with-openssl-dir[=DIR]  FTP: openssl install prefix
-      --with-gd[=DIR]         Include GD support.  DIR is the GD library base
-                              install directory [BUNDLED]
-      --with-jpeg-dir[=DIR]     GD: Set the path to libjpeg install prefix
-      --with-png-dir[=DIR]      GD: Set the path to libpng install prefix
-      --with-zlib-dir[=DIR]     GD: Set the path to libz install prefix
-      --with-xpm-dir[=DIR]      GD: Set the path to libXpm install prefix
-      --with-ttf[=DIR]          GD: Include FreeType 1.x support
-      --with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix
-      --with-t1lib[=DIR]        GD: Include T1lib support. T1lib version >= 5.0.0 required
-      --enable-gd-native-ttf    GD: Enable TrueType string function
-      --enable-gd-jis-conv      GD: Enable JIS-mapped Japanese font support
-      */
-      gettext =     { cfgOption = "--with-gettext=\$gettext"; pass={ inherit (args) gettext; }; buildInputs="gettext"; };                    #Include GNU gettext support
-      #gettext =     { cfgOption = "--with-gettext"; buildInputs="gettext"; };                    #Include GNU gettext support
-      /*
-      --with-gmp[=DIR]        Include GNU MP support
-      --disable-hash          Disable hash support
-      --without-iconv[=DIR]   Exclude iconv support
-      --with-imap[=DIR]       Include IMAP support. DIR is the c-client install prefix
-      --with-kerberos[=DIR]     IMAP: Include Kerberos support. DIR is the Kerberos install prefix
-      --with-imap-ssl[=DIR]     IMAP: Include SSL support. DIR is the OpenSSL install prefix
-      --with-interbase[=DIR]  Include InterBase support.  DIR is the InterBase base
-                              install directory [/usr/interbase]
-      --disable-json          Disable JavaScript Object Serialization support
-      --with-ldap[=DIR]       Include LDAP support
-      --with-ldap-sasl[=DIR]    LDAP: Include Cyrus SASL support
-      --enable-mbstring       Enable multibyte string support
-      --disable-mbregex         MBSTRING: Disable multibyte regex support
-      --disable-mbregex-backtrack
-                                MBSTRING: Disable multibyte regex backtrack check
-      --with-libmbfl[=DIR]      MBSTRING: Use external libmbfl.  DIR is the libmbfl base
-                                install directory [BUNDLED]
-      --with-mcrypt[=DIR]     Include mcrypt support
-      --with-mhash[=DIR]      Include mhash support
-
-
-
-      --with-mime-magic[=FILE]  
-                              Include mime_magic support (DEPRECATED!!)
-      --with-ming[=DIR]       Include MING support
-      --with-msql[=DIR]       Include mSQL support.  DIR is the mSQL base
-                              install directory [/usr/local/Hughes]
-      --with-mssql[=DIR]      Include MSSQL-DB support.  DIR is the FreeTDS home
-                              directory [/usr/local/freetds]
-      --with-mysql[=DIR]      Include MySQL support. DIR is the MySQL base directory
-      --with-mysql-sock[=DIR]   MySQL: Location of the MySQL unix socket pointer.
-                                If unspecified, the default locations are searched
-      --with-zlib-dir[=DIR]     MySQL: Set the path to libz install prefix
-      --with-mysqli[=FILE]    Include MySQLi support.  FILE is the optional pathname 
-                              to mysql_config [mysql_config]
-      --enable-embedded-mysqli  MYSQLi: Enable embedded support
-      --with-ncurses[=DIR]    Include ncurses support (CLI/CGI only)
-      --with-oci8[=DIR]       Include Oracle (OCI8) support. DIR defaults to $ORACLE_HOME.
-                              Use --with-oci8=instantclient,/path/to/oic/lib 
-                              for an Oracle Instant Client installation
-      --with-adabas[=DIR]     Include Adabas D support [/usr/local]
-      --with-sapdb[=DIR]      Include SAP DB support [/usr/local]
-      --with-solid[=DIR]      Include Solid support [/usr/local/solid]
-      --with-ibm-db2[=DIR]    Include IBM DB2 support [/home/db2inst1/sqllib]
-      --with-ODBCRouter[=DIR] Include ODBCRouter.com support [/usr]
-      --with-empress[=DIR]    Include Empress support [$EMPRESSPATH]
-                              (Empress Version >= 8.60 required)
-      --with-empress-bcs[=DIR]
-                              Include Empress Local Access support [$EMPRESSPATH]
-                              (Empress Version >= 8.60 required)
-      --with-birdstep[=DIR]   Include Birdstep support [/usr/local/birdstep]
-      --with-custom-odbc[=DIR]
-                              Include user defined ODBC support. DIR is ODBC install base
-                              directory [/usr/local]. Make sure to define CUSTOM_ODBC_LIBS and
-                              have some odbc.h in your include dirs. f.e. you should define 
-                              following for Sybase SQL Anywhere 5.5.00 on QNX, prior to
-                              running this configure script:
-                                  CPPFLAGS="-DODBC_QNX -DSQLANY_BUG"
-                                  LDFLAGS=-lunix
-                                  CUSTOM_ODBC_LIBS="-ldblib -lodbc"
-      --with-iodbc[=DIR]      Include iODBC support [/usr/local]
-      --with-esoob[=DIR]      Include Easysoft OOB support [/usr/local/easysoft/oob/client]
-      --with-unixODBC[=DIR]   Include unixODBC support [/usr/local]
-      --with-dbmaker[=DIR]    Include DBMaker support
-      --enable-pcntl          Enable experimental pcntl support (CLI/CGI only)
-      --disable-pdo           Disable PHP Data Objects support
-      --with-pdo-dblib[=DIR]    PDO: DBLIB-DB support.  DIR is the FreeTDS home
-                                directory
-      --with-pdo-firebird[=DIR] PDO: Firebird support.  DIR is the Firebird base
-                                install directory [/opt/firebird]
-      --with-pdo-mysql[=DIR]    PDO: MySQL support. DIR is the MySQL base directory
-      --with-zlib-dir[=DIR]       PDO_MySQL: Set the path to libz install prefix
-      --with-pdo-oci[=DIR]      PDO: Oracle-OCI support. DIR defaults to $ORACLE_HOME.
-                                Use --with-pdo-oci=instantclient,prefix,version 
-                                for an Oracle Instant Client SDK. 
-                                For Linux with 10.2.0.3 RPMs (for example) use:
-                                --with-pdo-oci=instantclient,/usr,10.2.0.3
-      --with-pdo-odbc=flavour,dir
-                                PDO: Support for 'flavour' ODBC driver.
-                                include and lib dirs are looked for under 'dir'.
-                                
-                                'flavour' can be one of:  ibm-db2, unixODBC, generic
-                                If ',dir' part is omitted, default for the flavour 
-                                you have selected will used. e.g.:
-                                
-                                  --with-pdo-odbc=unixODBC
-                                  
-                                will check for unixODBC under /usr/local. You may attempt 
-                                to use an otherwise unsupported driver using the "generic" 
-                                flavour.  The syntax for generic ODBC support is:
-                                
-                                  --with-pdo-odbc=generic,dir,libname,ldflags,cflags
-
-                                When build as shared the extension filename is always pdo_odbc.so
-      --with-pdo-pgsql[=DIR]    PDO: PostgreSQL support.  DIR is the PostgreSQL base
-                                install directory or the path to pg_config
-      --without-pdo-sqlite[=DIR]
-                                PDO: sqlite 3 support.  DIR is the sqlite base
-                                install directory [BUNDLED]
-      --with-pgsql[=DIR]      Include PostgreSQL support.  DIR is the PostgreSQL
-                              base install directory or the path to pg_config
-      --disable-posix         Disable POSIX-like functions
-      --with-pspell[=DIR]     Include PSPELL support.
-                              GNU Aspell version 0.50.0 or higher required
-
-
-
-      --with-libedit[=DIR]    Include libedit readline replacement (CLI/CGI only)
-      --with-readline[=DIR]   Include readline support (CLI/CGI only)
-      --with-recode[=DIR]     Include recode support
-      --disable-reflection    Disable reflection support
-      --disable-session       Disable session support
-      --with-mm[=DIR]           SESSION: Include mm support for session storage
-      --enable-shmop          Enable shmop support
-      --disable-simplexml     Disable SimpleXML support
-      --with-libxml-dir=DIR     SimpleXML: libxml2 install prefix
-      --with-snmp[=DIR]       Include SNMP support
-      --with-openssl-dir[=DIR]  SNMP: openssl install prefix
-      --enable-ucd-snmp-hack    SNMP: Enable UCD SNMP hack
-      --enable-soap           Enable SOAP support
-      --with-libxml-dir=DIR     SOAP: libxml2 install prefix
-      --enable-sockets        Enable sockets support
-      --disable-spl           Disable Standard PHP Library
-      --without-sqlite        Do not include sqlite support.  DIR is the sqlite base
-                              install directory [BUNDLED]
-      --enable-sqlite-utf8      SQLite: Enable UTF-8 support for SQLite
-      --with-regex=TYPE       regex library type: system, apache, php. [TYPE=php]
-                              WARNING: Do NOT use unless you know what you are doing!
-      --with-sybase[=DIR]     Include Sybase-DB support.  DIR is the Sybase home
-                              directory [/home/sybase]
-      --with-sybase-ct[=DIR]  Include Sybase-CT support.  DIR is the Sybase home
-                              directory [/home/sybase]
-      --enable-sysvmsg        Enable sysvmsg support
-      --enable-sysvsem        Enable System V semaphore support
-      --enable-sysvshm        Enable the System V shared memory support
-      --with-tidy[=DIR]       Include TIDY support
-      --disable-tokenizer     Disable tokenizer support
-      --enable-wddx           Enable WDDX support
-      --with-libxml-dir=DIR     WDDX: libxml2 install prefix
-      --with-libexpat-dir=DIR   WDDX: libexpat dir for XMLRPC-EPI (deprecated)
-      --disable-xml           Disable XML support
-      --with-libxml-dir=DIR     XML: libxml2 install prefix
-      --with-libexpat-dir=DIR   XML: libexpat install prefix (deprecated)
-      --disable-xmlreader     Disable XMLReader support
-      --with-libxml-dir=DIR     XMLReader: libxml2 install prefix
-      --with-xmlrpc[=DIR]     Include XMLRPC-EPI support
-      --with-libxml-dir=DIR     XMLRPC-EPI: libxml2 install prefix
-      --with-libexpat-dir=DIR   XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)
-      --with-iconv-dir=DIR      XMLRPC-EPI: iconv dir for XMLRPC-EPI
-      --disable-xmlwriter     Disable XMLWriter support
-      --with-libxml-dir=DIR     XMLWriter: libxml2 install prefix
-      --with-xsl[=DIR]        Include XSL support.  DIR is the libxslt base
-                              install directory (libxslt >= 1.1.0 required)
-      --enable-zip            Include Zip read/write support
-      --with-zlib-dir[=DIR]     ZIP: Set the path to libz install prefix
-
-    PEAR:
-
-      --with-pear=DIR         Install PEAR in DIR [PREFIX/lib/php]
-      --without-pear          Do not install PEAR
+    zlib = {
+      cfgOption = "--with-zlib=${args.zlib}";
+      pass = "zlib";
+    };
 
-    Zend:
+    libxml2 = {
+      cfgOption = "--with-libxml-dir=\$libxml2";
+      pass = { inherit (args) libxml2; }; 
+    };
+    
+    no_libxml2 = {
+      cfgOption = "--disable-libxml";
+    };
 
-      --with-zend-vm=TYPE     Set virtual machine dispatch method. Type is
-                              one of CALL, SWITCH or GOTO [TYPE=CALL]
-      --enable-maintainer-zts Enable thread safety - for code maintainers only!!
-      --disable-inline-optimization 
-                              If building zend_execute.lo fails, try this switch
-      --enable-zend-multibyte Compile with zend multibyte support
+    postgresql = {
+      cfgOption = "--with-pgsql=\$postgresql";
+      pass = { inherit (args) postgresql; };
+    };
+    
+    mysql = {
+      cfgOption = "--with-mysql=\$mysql";
+      pass = { inherit (args) mysql; };
+    };
 
-    TSRM:
+    mysqli = {
+      cfgOption = "--with-mysqli=\$mysql/bin/mysql_config";
+      pass = { inherit (args) mysql; }; 
+    };
 
-      --with-tsrm-pth[=pth-config]
-                              Use GNU Pth
-      --with-tsrm-st          Use SGI's State Threads
-      --with-tsrm-pthreads    Use POSIX threads (default)
+    mysqli_embedded = {
+      cfgOption = "--enable-embedded-mysqli";
+      depends = "mysqli";
+    };
 
-    Libtool:
+    pdo_mysql = {
+      cfgOption = "--with-pdo-mysql=\$mysql";
+      pass = { inherit (args) mysql; }; 
+    };
+    
+    no_pdo_mysql = { };
 
-      --enable-shared[=PKGS]  build shared libraries [default=yes]
-      --enable-static[=PKGS]  build static libraries [default=yes]
-      --enable-fast-install[=PKGS]  optimize for fast installation [default=yes]
-      --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
-      --disable-libtool-lock  avoid locking (might break parallel builds)
-      --with-pic              try to use only PIC/non-PIC objects [default=use both]
-      --with-tags[=TAGS]      include additional configurations [automatic]
+    bcmath = {
+      cfgOption = "--enable-bcmath";
+    };
 
-      --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+    gd = {
+      cfgOption = "--with-gd=${args.gd}";
+      buildInputs = ["gd"]; # <-- urgh, these strings are ugly
+    };
 
+    /*
+       Building xdebug withing php to be able to add the parameters to the ini file.. Ther should be a better way
+      meta = { 
+              description = "debugging support for PHP";
+              homepage = http://xdebug.org;
+              license = "based on the PHP license - as is";
+              };
     */
-
-# much left to do here... 
-
-          mandatory =  { buildInputs = [ "flex" "bison"]; };
-
-# SAPI modules:
-          apxs2        =      { cfgOption = "--with-apxs2=\$apacheHttpd/bin/apxs";
-                                pass = "apacheHttpd"; };
-
-# Extensions 
-
-          zlib          =     { cfgOption = "--with-zlib=${args.zlib}"; pass = "zlib"; };
-
-          libxml2       =     { cfgOption = "--with-libxml-dir=\$libxml2";
-                                pass = { inherit (args) libxml2; }; 
-                              };
-          no_libxml2    =     { cfgOption =  "--disable-libxml";
-                              };
-
-          postgresql   =      { cfgOption = "--with-pgsql=\$postgresql";
-                                pass = { inherit (args) postgresql;}; };
-          mysql        =      { cfgOption = "--with-mysql=\$mysql";
-                                pass = { inherit (args) mysql;}; };
-
-          mysqli       =      { cfgOption = "--with-mysqli=\$mysql/bin/mysql_config";
-                                pass = { inherit (args) mysql;}; 
-                              };
-
-          mysqli_embedded  =  { cfgOption = "--enable-embedded-mysqli" ; depends = "mysqli"; };
-
-
-          pdo_mysql   =       { cfgOption = "--with-pdo-mysql=\$mysql";
-                                pass = { inherit (args) mysql; }; 
-                              };
-          no_pdo_mysql = { };
-
-          /* default location is enough for now ?
-            --with-mysql-sock[=DIR]   MySQL: Location of the MySQL unix socket pointer.
-                                      If unspecified, the default locations are searched
-          */
-
-          /*
-             Building xdebug withing php to be able to add the parameters to the ini file.. Ther should be a better way
-            meta = { 
-                    description = "debugging support for PHP";
-                    homepage = http://xdebug.org;
-                    license = "based on the PHP license - as is";
-                    };
-          */
-          xdebug = { buildInputs = [ "automake" "autoconf" ];  
-                     pass = { xdebug_src = args.fetchurl {
-                          name = "xdebug-2.0.2.tar.gz";
-                          url = "http://xdebug.org/link.php?url=xdebug202";
-                          sha256 = "1h0bxvf8krr203fmk1k7izrrr81gz537xmd3pqh4vslwdlbhrvic";
-                   };};};
-
-
+    xdebug = {
+      buildInputs = [ "automake" "autoconf" ];
+      pass = {
+        xdebug_src = args.fetchurl {
+          name = "xdebug-2.0.2.tar.gz";
+          url = "http://xdebug.org/link.php?url=xdebug202";
+          sha256 = "1h0bxvf8krr203fmk1k7izrrr81gz537xmd3pqh4vslwdlbhrvic";
+        };
+      };
     };
 
-  defaults = [ "mysql" "mysqli" "pdo_mysql" "libxml2" "apxs2" ];
-  optionals = [ "libxml2" "gettext" "postgresql" "zlib"];
-
-  # Don't konw wether they should be default.. I use them - Marc
+  };
 
+  defaults = [ "mysql" "mysqli" "pdo_mysql" "libxml2" "apxs2" "bcmath" ];
+  
+  optionals = [ "libxml2" "gettext" "postgresql" "zlib"];
 
-  extraAttrs = co : {
+  extraAttrs = co: {
     name = "php_configurable-${version}";
 
-    buildInputs = ( args.lib.getAttr [ "phpIncludes" ] [] args ) ++ co.buildInputs;
+    buildInputs = args.lib.getAttr ["phpIncludes"] [] args ++ co.buildInputs;
 
     configurePhase = ''
       iniFile=$out/etc/$name.ini
       [[ -z "$libxml2" ]] || export PATH=$PATH:$libxml2/bin
-      ./configure --with-config-file-scan-dir=/etc --with-config-file-path=$iniFile --prefix=$out ${co.configureFlags}
+      ./configure --with-config-file-scan-dir=/etc --with-config-file-path=$out/etc --prefix=$out ${co.configureFlags}
       echo configurePhase end
     '';
 
@@ -491,7 +125,7 @@ args:
         ./configure --prefix=$out
         make
         ensureDir $out/lib; cp modules/xdebug.so $out/lib
-        cat >> $iniFile << EOF
+        cat >> $out/etc/php.ini << EOF
           zend_extension="$out/lib/xdebug.so"
           zend_extension_ts="$out/lib/xdebug.so"
           zend_extension_debug="$out/lib/xdebug.so"
@@ -502,22 +136,25 @@ args:
           xdebug.profiler_enable=0
           xdebug.profiler_output_dir="/tmp/xdebug"
           xdebug.remote_mode=req
-        EOF
+          max_execution_time = 300
+          date.timezone = UTC
+    EOF
       fi
     '';
 
     src = args.fetchurl {
       url = "http://nl.php.net/get/php-${version}.tar.bz2/from/this/mirror";
-      sha256 = "18xv961924rkk66gdjcmk1mzbzgp2srbiq5jvbgyn6ahvxq1xb2w";
+      md5 = "7380ffecebd95c6edb317ef861229ebd";
       name = "php-${version}.tar.bz2";
     };
 
     meta = { 
-      description = "The PHP language runtime engine"; # : CLI, CGI and Apache2 SAPIs ? as well TODO 
+      description = "The PHP language runtime engine";
       homepage = http://www.php.net/;
       license = "PHP-3";
     };
 
     patches = [./fix.patch];
   };
+  
 }) args
diff --git a/pkgs/development/interpreters/pyrex/0.9.5.nix b/pkgs/development/interpreters/pyrex/0.9.5.nix
new file mode 100644
index 00000000000..d494b5a1539
--- /dev/null
+++ b/pkgs/development/interpreters/pyrex/0.9.5.nix
@@ -0,0 +1,26 @@
+args: with args;
+
+let
+
+  localDefs = builderDefs {
+
+    src = fetchurl {
+      url = http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/oldtar/Pyrex-0.9.5.1.1.tar.gz;
+      sha256 = "0lxxvn4mjfb83swcbqb5908q4iy53w4ip5i0f9angm2va1jyhd3z";
+    };
+
+    buildInputs = [python];
+
+  } null; /* null is a terminator for sumArgs */
+
+in with localDefs;
+        
+stdenv.mkDerivation rec {
+  name = "pyrex-0.9.5.1.1";
+  builder = writeScript (name + "-builder")
+    (textClosure localDefs [installPythonPackage doForceShare]);
+  meta = {
+    description = "Python package compiler or something like that";
+    inherit src;
+  };
+}
diff --git a/pkgs/development/interpreters/pyrex/0.9.6.nix b/pkgs/development/interpreters/pyrex/0.9.6.nix
index 3747bbed4c3..02c1d532abb 100644
--- a/pkgs/development/interpreters/pyrex/0.9.6.nix
+++ b/pkgs/development/interpreters/pyrex/0.9.6.nix
@@ -1,22 +1,26 @@
-args : with args;
-	let localDefs = builderDefs {
-		src = /* put a fetchurl here */
-	fetchurl {
-		url = http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/oldtar/Pyrex-0.9.6.tar.gz;
-		sha256 = "1i0mrv2a3ihnj5mjf07aic7nlps9qap57j477m8ajwhhwx9vwlxy";
-	};
-		buildInputs = [python];
-		configureFlags = [];
-	} null; /* null is a terminator for sumArgs */
-	in with localDefs;
+args: with args;
+
+let
+
+  localDefs = builderDefs {
+
+    src = fetchurl {
+      url = http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/oldtar/Pyrex-0.9.6.4.tar.gz;
+      sha256 = "18pd9f8al3l6i27cc0ddhgg7hxf28lnfs75x4a8jzscydxgiq5a8";
+    };
+
+    buildInputs = [python];
+
+  } null; /* null is a terminator for sumArgs */
+
+in with localDefs;
+        
 stdenv.mkDerivation rec {
-	name = "Pyrex-"+version;
-	builder = writeScript (name + "-builder")
-		(textClosure localDefs [installPythonPackage doForceShare]);
-	meta = {
-		description = "
-	Python package compiler or something like that.	
-";
-		inherit src;
-	};
+  name = "pyrex-0.9.6.4";
+  builder = writeScript (name + "-builder")
+    (textClosure localDefs [installPythonPackage doForceShare]);
+  meta = {
+    description = "Python package compiler or something like that";
+    inherit src;
+  };
 }
diff --git a/pkgs/development/interpreters/python/2.4.nix b/pkgs/development/interpreters/python/2.4/default.nix
index 726d2ac4aa9..726d2ac4aa9 100644
--- a/pkgs/development/interpreters/python/2.4.nix
+++ b/pkgs/development/interpreters/python/2.4/default.nix
diff --git a/pkgs/development/interpreters/python/search-path.patch b/pkgs/development/interpreters/python/2.4/search-path.patch
index 2e7b7526c0c..2e7b7526c0c 100644
--- a/pkgs/development/interpreters/python/search-path.patch
+++ b/pkgs/development/interpreters/python/2.4/search-path.patch
diff --git a/pkgs/development/interpreters/python/setup-hook.sh b/pkgs/development/interpreters/python/2.4/setup-hook.sh
index 58b8d1cab76..58b8d1cab76 100644
--- a/pkgs/development/interpreters/python/setup-hook.sh
+++ b/pkgs/development/interpreters/python/2.4/setup-hook.sh
diff --git a/pkgs/development/interpreters/python/2.5/default.nix b/pkgs/development/interpreters/python/2.5/default.nix
index 6bbb584841f..bfbc421e115 100644
--- a/pkgs/development/interpreters/python/2.5/default.nix
+++ b/pkgs/development/interpreters/python/2.5/default.nix
@@ -1,6 +1,13 @@
-{stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2}:
+{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2
+, gdbmSupport ? true, gdbm ? null
+, sqlite ? null
+, db4 ? null
+, readline ? null
+, openssl ? null
+}:
 
 assert zlibSupport -> zlib != null;
+assert gdbmSupport -> gdbm != null;
 
 with stdenv.lib;
 
@@ -8,8 +15,14 @@ let
 
   buildInputs =
     optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++
-    [bzip2] ++ 
-    optional zlibSupport zlib;
+    [bzip2]
+    ++ optional zlibSupport zlib
+    ++ optional gdbmSupport gdbm
+    ++ optional (sqlite != null) sqlite
+    ++ optional (db4 != null) db4
+    ++ optional (readline != null) readline
+    ++ optional (openssl != null) openssl
+    ;
 
 in
 
@@ -37,7 +50,9 @@ stdenv.mkDerivation {
     for i in /usr /sw /opt /pkg; do 
       substituteInPlace ./setup.py --replace $i /no-such-path
     done
-  ";
+  " + (if readline != null then ''
+    export NIX_LDFLAGS="$NIX_LDFLAGS -lncurses"
+  '' else "");
   
   postInstall = "
     ensureDir $out/nix-support
@@ -47,6 +62,10 @@ stdenv.mkDerivation {
 
   passthru = {
     inherit zlibSupport;
+    sqliteSupport = sqlite != null;
+    db4Support = db4 != null;
+    readlineSupport = readline != null;
+    opensslSupport = openssl != null;
     libPrefix = "python2.5";
   };
 }
diff --git a/pkgs/development/interpreters/python/default.nix b/pkgs/development/interpreters/python/default.nix
deleted file mode 100644
index af90018870f..00000000000
--- a/pkgs/development/interpreters/python/default.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-args:
-args.stdenv.lib.listOfListsToAttrs [
-	[ "default"  (import ./2.4.nix args) ]
-	[ "2.4"  (import ./2.4.nix args) ]
-	[ "2.5" (import ./2.5 args) ]
-]
diff --git a/pkgs/development/interpreters/r-lang/default.nix b/pkgs/development/interpreters/r-lang/default.nix
new file mode 100644
index 00000000000..a819fbe4616
--- /dev/null
+++ b/pkgs/development/interpreters/r-lang/default.nix
@@ -0,0 +1,18 @@
+{stdenv, fetchurl, readline, perl, g77_42, libX11, libpng, libXt, zlib}:
+
+stdenv.mkDerivation {
+  name = "r-lang-2.7.0";
+  src = fetchurl {
+    url = http://cran.r-project.org/src/base/R-2/R-2.7.0.tar.gz;
+    sha256 = "17ql1j5d9rfpxs04j9v9qyxiysc9nh6yr43lgfdamayzjpia5jqm";
+  };
+
+  buildInputs = [readline perl g77_42 libpng libX11 libXt zlib];
+
+	meta = {
+		description = "R is a language and environment for statistical computing and graphics";
+		longDescription = ''R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language. R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, ...) and graphical techniques, and is highly extensible.'';
+	  license     = "GPL2";
+    homepage    = http://www.r-project.org/;
+  };
+}
diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix
index 9304f0d0b3e..6b437900ca1 100644
--- a/pkgs/development/interpreters/ruby/default.nix
+++ b/pkgs/development/interpreters/ruby/default.nix
@@ -1,4 +1,8 @@
-{stdenv, fetchurl, ncurses, readline}:
+{stdenv, fetchurl, ncurses, readline
+  , lib
+  , zlib ? null
+  , openssl ? null
+}:
 
 stdenv.mkDerivation {
   name = "ruby-1.8.6";
@@ -7,5 +11,8 @@ stdenv.mkDerivation {
     md5 = "23d2494aa94e7ae1ecbbb8c5e1507683";
   };
 
-  buildInputs = [ncurses readline];
+  buildInputs = [ncurses readline]
+    ++(lib.optional (zlib != null) zlib)
+    ++(lib.optional (openssl != null) openssl)
+  ;
 }
diff --git a/pkgs/development/interpreters/ruby/gems.nix b/pkgs/development/interpreters/ruby/gems.nix
new file mode 100644
index 00000000000..49702be7e40
--- /dev/null
+++ b/pkgs/development/interpreters/ruby/gems.nix
@@ -0,0 +1,24 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz;
+    sha256 = "1qb4crmx1dihmk1am93ly437480jvp7lh4pbiwy5ir19hqnfh71b";
+  };
+  version = "1.1.1";
+
+  buildInputs = [ruby makeWrapper];
+  configureFlags = [];
+
+  doInstall = FullDepEntry (''
+    ruby setup.rb --prefix=$out/
+    wrapProgram $out/bin/gem --prefix RUBYLIB : $out/lib:$out/lib
+  '') ["minInit" "addInputs" "doUnpack" "defEnsureDir"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doInstall"];
+      
+  name = "rubygems-" + version;
+  meta = {
+    description = "Ruby package collection";
+  };
+}
diff --git a/pkgs/development/libraries/agg/default.nix b/pkgs/development/libraries/agg/default.nix
index 2c85f401255..bcdf4a644f5 100644
--- a/pkgs/development/libraries/agg/default.nix
+++ b/pkgs/development/libraries/agg/default.nix
@@ -1,11 +1,12 @@
-{stdenv, fetchurl, autoconf, automake, libtool, pkgconfig}:
+{ stdenv, fetchurl, autoconf, automake, libtool, pkgconfig
+, freetype, SDL }:
 
-stdenv.mkDerivation {
+stdenv.mkDerivation rec {
   name = "agg-2.5";
   src = fetchurl {
-    url = http://www.antigrain.com/agg-2.5.tar.gz;
+    url = "http://www.antigrain.com/${name}.tar.gz";
     sha256 = "07wii4i824vy9qsvjsgqxppgqmfdxq0xa87i5yk53fijriadq7mb";
   };
-  buildInputs = [autoconf automake libtool pkgconfig];
+  buildInputs = [autoconf automake libtool pkgconfig freetype SDL];
   preConfigure = "sh autogen.sh";
 }
diff --git a/pkgs/development/libraries/avahi/common.nix b/pkgs/development/libraries/avahi/common.nix
index 1ebadc26e26..a44c2863cc9 100644
--- a/pkgs/development/libraries/avahi/common.nix
+++ b/pkgs/development/libraries/avahi/common.nix
@@ -1,5 +1,7 @@
 sha256: args: with args;
 
+assert qt4Support -> qt4 != null;
+
 stdenv.mkDerivation rec {
   name = "avahi-" + version;
   src = fetchurl {
@@ -7,12 +9,25 @@ stdenv.mkDerivation rec {
     inherit sha256;
   };
 
-  buildInputs = [pkgconfig libdaemon dbus perl perlXMLParser glib qt4];
+  buildInputs = [pkgconfig libdaemon dbus perl perlXMLParser glib expat]
+    ++ lib.optional qt4Support qt4;
 
-  configureFlags = "--disable-qt3 --disable-gdbm --disable-gtk --disable-mono
-    --with-distro=none --enable-shared --disable-static --disable-python";
+  configureFlags = ''
+    --disable-qt3 --disable-gdbm --disable-gtk --disable-mono
+    --${if qt4Support then "enable" else "disable"}-qt4
+    --with-distro=none --enable-shared --disable-static --disable-python
+  '';
 
   meta = {
+    description = "Avahi, an mDNS/DNS-SD implementation";
+    longDescription = ''
+      Avahi is a system which facilitates service discovery on a local
+      network.  It is an implementation of the mDNS (for "Multicast
+      DNS") and DNS-SD (for "DNS-Based Service Discovery")
+      protocols.
+    '';
+
     homepage = http://avahi.org;
+    license = "LGPLv2+";
   };
 }
diff --git a/pkgs/development/libraries/babl/default.nix b/pkgs/development/libraries/babl/default.nix
new file mode 100644
index 00000000000..f1999d62446
--- /dev/null
+++ b/pkgs/development/libraries/babl/default.nix
@@ -0,0 +1,17 @@
+args:
+args.stdenv.mkDerivation {
+  name = "babl-0.0.20";
+
+  src = args.fetchurl {
+    url = ftp://ftp.gtk.org/pub/babl/0.0/babl-0.0.20.tar.bz2;
+    sha256 = "15ilcwszhbfhiyzmjinlxbbpdhmvh9h6nacvqp59z8ai0dbjr54d";
+  };
+
+  buildInputs =(with args; []);
+
+  meta = { 
+      description = "image pixel format coneversion libraray";
+      homepage = http://gegl.org/babl/;
+      license = "GPL3";
+  };
+}
diff --git a/pkgs/development/libraries/dbus/default.nix b/pkgs/development/libraries/dbus/default.nix
index c7bf02788bf..b60705f21f6 100644
--- a/pkgs/development/libraries/dbus/default.nix
+++ b/pkgs/development/libraries/dbus/default.nix
@@ -1,18 +1,12 @@
 args: with args;
-
 let
-
-  version = "1.1.20";
-  
+  version = "1.0.2";
   src = fetchurl {
     url = "http://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.gz";
-    sha256 = "0zhl6cxlwfm9hsl7vm8ycif39805zsa1z8f0qnbfh54jmwccl7vg";
+    sha256 = "1jn652zb81mczsx4rdcwrrzj3lfhx9d107zjfnasc4l5yljl204a";
   };
-  
   configureFlags = "--disable-static --localstatedir=/var --with-session-socket-dir=/tmp";
-  
 in rec {
-
   libs = stdenv.mkDerivation {
     name = "dbus-library-" + version;
     buildInputs = [pkgconfig expat];
@@ -34,16 +28,15 @@ in rec {
     makeFlags = "DBUS_DAEMONDIR=${daemon}/bin";
 
     patchPhase = ''
-      substituteInPlace tools/Makefile.in --replace 'test -z "$(localstatelibdir)"' true
       sed -i 's@ $(top_builddir)/dbus/libdbus-1.la@@' tools/Makefile.in
+      sed -i '/mkdir.*localstate/d' tools/Makefile.in
     '';
   };
 
-  # I'm too lazy to separate daemon and libs now.
+# I'm too lazy to separate daemon and libs now.
   daemon = libs;
   
   # FIXME TODO
   # After merger it will be better to correct upstart-job instead.
   outPath = daemon.outPath;
-  
 }
diff --git a/pkgs/development/libraries/gdbm/default.nix b/pkgs/development/libraries/gdbm/default.nix
new file mode 100644
index 00000000000..d6f1d118f82
--- /dev/null
+++ b/pkgs/development/libraries/gdbm/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "gdbm-1.8.3";
+  src = fetchurl {
+    url = "mirror://gnu/gdbm/${name}.tar.gz";
+    sha256 = "1j8x51xc71di1fx23sl22n5ghlqxl9a57sxri82l12z2l8w06d6c";
+  };
+
+  patches = [ ./install.patch ];
+
+  meta = {
+    description = "GNU DBM key/value database library";
+    homepage = http://www.gnu.org/software/gdbm/;
+    license = "GPLv2+";
+  };
+}
diff --git a/pkgs/development/libraries/gdbm/install.patch b/pkgs/development/libraries/gdbm/install.patch
new file mode 100644
index 00000000000..81afe020b7b
--- /dev/null
+++ b/pkgs/development/libraries/gdbm/install.patch
@@ -0,0 +1,29 @@
+--- gdbm-1.8.3/Makefile.in	2002-10-08 18:09:12.000000000 +0200
++++ gdbm-1.8.3/Makefile.in	2008-04-07 01:15:58.000000000 +0200
+@@ -131,11 +131,11 @@ install: libgdbm.la gdbm.h gdbm.info
+ 		$(INSTALL_ROOT)$(includedir) $(INSTALL_ROOT)$(man3dir) \
+ 		$(INSTALL_ROOT)$(infodir)
+ 	$(LIBTOOL) $(INSTALL) -c libgdbm.la $(INSTALL_ROOT)$(libdir)/libgdbm.la
+-	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) gdbm.h \
++	$(INSTALL_DATA) gdbm.h \
+ 		$(INSTALL_ROOT)$(includedir)/gdbm.h
+-	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/gdbm.3 \
++	$(INSTALL_DATA) $(srcdir)/gdbm.3 \
+ 		$(INSTALL_ROOT)$(man3dir)/gdbm.3
+-	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/gdbm.info \
++	$(INSTALL_DATA) $(srcdir)/gdbm.info \
+ 		$(INSTALL_ROOT)$(infodir)/gdbm.info
+ 
+ install-compat:
+@@ -143,9 +143,9 @@ install-compat:
+ 		$(INSTALL_ROOT)$(includedir)
+ 	$(LIBTOOL) $(INSTALL) -c libgdbm_compat.la \
+ 		$(INSTALL_ROOT)$(libdir)/libgdbm_compat.la
+-	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/dbm.h \
++	$(INSTALL_DATA)) $(srcdir)/dbm.h \
+ 		$(INSTALL_ROOT)$(includedir)/dbm.h
+-	$(INSTALL_DATA) -o $(BINOWN) -g $(BINGRP) $(srcdir)/ndbm.h \
++	$(INSTALL_DATA)) $(srcdir)/ndbm.h \
+ 		$(INSTALL_ROOT)$(includedir)/ndbm.h
+ 
+ #libgdbm.a: $(OBJS) gdbm.h
diff --git a/pkgs/development/libraries/gegl/default.nix b/pkgs/development/libraries/gegl/default.nix
new file mode 100644
index 00000000000..732816a598b
--- /dev/null
+++ b/pkgs/development/libraries/gegl/default.nix
@@ -0,0 +1,19 @@
+args:
+args.stdenv.mkDerivation {
+  name = "gegl-0.0.16";
+
+  src = args.fetchurl {
+    url = ftp://ftp.gimp.org/pub/gegl/0.0/gegl-0.0.16.tar.bz2;
+    sha256 = "0jgbqgpv85x9kc14zi6a6bs6jvsm3hy48nvwrhhygmivayswa3qj";
+  };
+
+  configureFlags = "--disable-docs"; # needs fonts otherwise  don't know how to pass them
+
+  buildInputs =(with args; [pkgconfig glib babl libpng cairo libjpeg librsvg pango ]  );
+
+  meta = { 
+      description = "graph based image processing framework";
+      homepage = http://www.gegl.org;
+      license = "GPL3";
+  };
+}
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix
new file mode 100644
index 00000000000..c4ccf7ec156
--- /dev/null
+++ b/pkgs/development/libraries/glib/default.nix
@@ -0,0 +1,11 @@
+args:
+args.stdenv.mkDerivation {
+  name = "glib-2.14";
+
+  src = args.fetchurl {
+    url = http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.14/glib-2.14.6.tar.bz2;
+    sha256 = "1fi4xb07d7bfnfi65snvbi6i5kzhr3kad8knbwklj47z779vppvq";
+  };
+
+  buildInputs =(with args; [pkgconfig gettext]);
+}
diff --git a/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch b/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch
deleted file mode 100644
index 8543dbbf1d7..00000000000
--- a/pkgs/development/libraries/glibc-2.7/glibc-getcwd-param-MAX.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-2006-06-18  Mike Frysinger  <vapier@gentoo.org>
-
-	* sysdeps/unix/sysv/linux/getcwd.c: Include sys/param.h.
-
---- glibc-old/sysdeps/unix/sysv/linux/getcwd.c
-+++ glibc-new/sysdeps/unix/sysv/linux/getcwd.c
-@@ -24,6 +24,7 @@
- #include <limits.h>
- #include <stdlib.h>
- #include <unistd.h>
-+#include <sys/param.h>
- 
- #include <sysdep.h>
- #include <sys/syscall.h>
diff --git a/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch b/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch
deleted file mode 100644
index 07039718477..00000000000
--- a/pkgs/development/libraries/glibc-2.7/glibc-pwd.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-diff -ruN glibc-20050110/configure glibc-20050110.patched/configure
---- glibc-20050110/configure	2005-01-05 10:39:53.000000000 +0100
-+++ glibc-20050110.patched/configure	2005-01-18 13:33:01.000000000 +0100
-@@ -1393,7 +1393,7 @@
- ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
- 
- 
--if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
-+if test "`cd $srcdir; @PWD@`" = "`@PWD@`"; then
-   { { echo "$as_me:$LINENO: error: you must configure in a separate build directory" >&5
- echo "$as_me: error: you must configure in a separate build directory" >&2;}
-    { (exit 1); exit 1; }; }
-diff -ruN glibc-20050110/io/ftwtest-sh glibc-20050110.patched/io/ftwtest-sh
---- glibc-20050110/io/ftwtest-sh	2004-02-09 21:12:23.000000000 +0100
-+++ glibc-20050110.patched/io/ftwtest-sh	2005-01-18 13:33:15.000000000 +0100
-@@ -120,7 +120,7 @@
-     sort > $testout
- 
- # perhaps $tmp involves some symlinks...
--tmpreal=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
-+tmpreal=`cd $tmp; @PWD@ 2>/dev/null || /usr/bin/pwd`
- 
- cat <<EOF | cmp $testout - || exit 1
- base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
-@@ -138,7 +138,7 @@
- EOF
- rm $testout
- 
--curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
-+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
- cd "$tmp"
- LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d |
-     sort > $testout
-@@ -160,7 +160,7 @@
- EOF
- rm $testout
- 
--curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
-+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
- cd "$tmp"
- LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/. |
-     sort > $testout
-@@ -182,7 +182,7 @@
- EOF
- rm $testout
- 
--curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
-+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
- cd "$tmp"
- LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/foo/lvl1/link@1 |
-     sort > $testout
-diff -ruN glibc-20050110/scripts/rellns-sh glibc-20050110.patched/scripts/rellns-sh
---- glibc-20050110/scripts/rellns-sh	1999-12-19 00:40:25.000000000 +0100
-+++ glibc-20050110.patched/scripts/rellns-sh	2005-01-18 13:35:53.245937423 +0100
-@@ -22,13 +22,13 @@
-   exit 1
- fi
- 
--if test -x /bin/pwd; then
--  pwd=/bin/pwd
--elif test -x /usr/bin/pwd; then
--  pwd=/usr/bin/pwd
--else
-+#if test -x /bin/pwd; then
-+#  pwd=/bin/pwd
-+#elif test -x /usr/bin/pwd; then
-+#  pwd=/usr/bin/pwd
-+#else
-   pwd='pwd'
--fi
-+#fi
- 
- # Make both paths absolute.
- if test -d $1; then
diff --git a/pkgs/development/libraries/gmm/default.nix b/pkgs/development/libraries/gmm/default.nix
new file mode 100644
index 00000000000..56b51d71ca6
--- /dev/null
+++ b/pkgs/development/libraries/gmm/default.nix
@@ -0,0 +1,17 @@
+args:
+args.stdenv.mkDerivation {
+  name = "gmm-3.0";
+
+  src = args.fetchurl {
+    url = http://download.gna.org/getfem/stable/gmm-3.0.tar.gz;
+    sha256 = "1lc34w68s0rhii6caklvq2pyc3jaa4g6kza948ya8ha6rr8d1ypp";
+  };
+
+  buildInputs =(with args; []);
+
+  meta = { 
+      description = "generic C++ template library for sparse, dense and skyline matrices";
+      homepage = http://home.gna.org/getfem/gmm_intro.html;
+      license = "LGLP2.1"; # or later
+  };
+}
diff --git a/pkgs/development/libraries/gnutls/default.nix b/pkgs/development/libraries/gnutls/default.nix
index b7bdf6a4e0c..86b88868e86 100644
--- a/pkgs/development/libraries/gnutls/default.nix
+++ b/pkgs/development/libraries/gnutls/default.nix
@@ -1,15 +1,31 @@
-args: with args;
+{ fetchurl, stdenv, zlib, lzo, libgcrypt
+, guileBindings, guile }:
+
+assert guileBindings -> guile != null;
+
 stdenv.mkDerivation rec {
-	name = "gnutls-2.1.5";
-	src = fetchurl {
-		url = "${meta.homepage}/releases/${name}.tar.bz2";
-		sha256 = "0idkp54d1w1c6l17pl41p2mqabcb1qm2akhfmp4mxwa5mabkiyld";
-	};
-	buildInputs = [zlib lzo libgcrypt];
+
+  name = "gnutls-2.2.5";
+
+  src = fetchurl {
+    url = "mirror://gnu/gnutls/${name}.tar.bz2";
+    sha256 = "0mxf4pwv17lf4c2b3bh70wn35y9f45325am1ywkmw2azbfyqj9ng";
+  };
+
+  patches = [ ./tmpdir.patch ];
+
+  configurePhase = ''
+    ./configure --prefix="$out" --enable-guile --with-guile-site-dir="$out/share/guile/site"
+  '';
+
+  buildInputs = [zlib lzo libgcrypt]
+    ++ stdenv.optional guileBindings guile;
+
+  doCheck = true;
   
   meta = {
     description = "The GNU Transport Layer Security Library";
     homepage = http://www.gnu.org/software/gnutls/;
-    license = "LGPL";
+    license = "LGPLv2.1+";
   };
 }
diff --git a/pkgs/development/libraries/gnutls/tmpdir.patch b/pkgs/development/libraries/gnutls/tmpdir.patch
new file mode 100644
index 00000000000..1cd675dc5e9
--- /dev/null
+++ b/pkgs/development/libraries/gnutls/tmpdir.patch
@@ -0,0 +1,28 @@
+We disable these tests because OpenCDK's `cdk_stream_tmp_from_mem ()'
+stupidly uses `tempfile ()', which does not honor $TMPDIR, leading to
+build failures in chroots.  See also:
+
+  http://thread.gmane.org/gmane.comp.encryption.gpg.gnutls.devel/2693
+
+
+--- gnutls-2.3.4/tests/openpgp/Makefile.in	2008-03-19 13:46:02.000000000 +0100
++++ gnutls-2.3.4/tests/openpgp/Makefile.in	2008-04-08 23:21:34.000000000 +0200
+@@ -52,7 +52,7 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ target_triplet = @target@
+-@ENABLE_OPENPGP_TRUE@TESTS = keyring$(EXEEXT)
++@ENABLE_OPENPGP_TRUE@TESTS =
+ @ENABLE_OPENPGP_TRUE@check_PROGRAMS = keyring$(EXEEXT)
+ subdir = tests/openpgp
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+
+--- gnutls-2.3.4/guile/tests/Makefile.in	2008-03-19 13:46:00.000000000 +0100
++++ gnutls-2.3.4/guile/tests/Makefile.in	2008-04-08 23:30:15.000000000 +0200
+@@ -524,7 +524,6 @@ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ TESTS = anonymous-auth.scm session-record-port.scm		\
+         pkcs-import-export.scm					\
+-	openpgp-keys.scm openpgp-keyring.scm openpgp-auth.scm	\
+         srp-base64.scm errors.scm				\
+ 	x509-certificates.scm x509-auth.scm
diff --git a/pkgs/development/libraries/gtk-libs/2.12/glibmm/default.nix b/pkgs/development/libraries/gtk-libs/2.12/glibmm/default.nix
index bbdde49b75d..2435a80149f 100644
--- a/pkgs/development/libraries/gtk-libs/2.12/glibmm/default.nix
+++ b/pkgs/development/libraries/gtk-libs/2.12/glibmm/default.nix
@@ -1,13 +1,12 @@
 args: with args;
 
 stdenv.mkDerivation {
-  name = "glibmm-2.12.10";
+  name = "glibmm-2.16.2";
   src = fetchurl {
-    url = http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.12/glibmm-2.12.10.tar.bz2;
-    sha256 = "02rjjdh0f6kafa1sn4y5ykvm4f2qn3yh4kr4lngcv7vzasqn1dr1";
+    url = mirror://gnome/GNOME/sources/glibmm/2.16/glibmm-2.16.2.tar.bz2;
+    sha256 = "0a3d4z3kzbr84pg873397nja6wc6810pw233rvn1gz1jkkrzcczh";
   };
 
   buildInputs = [pkgconfig];
   propagatedBuildInputs = [glib libsigcxx];
 }
-
diff --git a/pkgs/development/libraries/gtk-libs/2.12/gtkmm/default.nix b/pkgs/development/libraries/gtk-libs/2.12/gtkmm/default.nix
index 9a44e9a6ba2..8cf6a04295a 100644
--- a/pkgs/development/libraries/gtk-libs/2.12/gtkmm/default.nix
+++ b/pkgs/development/libraries/gtk-libs/2.12/gtkmm/default.nix
@@ -1,13 +1,12 @@
 args: with args;
 
 stdenv.mkDerivation {
-  name = "gtkmm-2.10.11";
+  name = "gtkmm-2.12.7";
   src = fetchurl {
-    url = http://ftp.gnome.org/pub/GNOME/sources/gtkmm/2.10/gtkmm-2.10.11.tar.bz2;
-    sha256 = "1bri9r0k69dmi5xgzrlfllp3adfzhz8dh9zkcvi6sjkgfwi594vx";
+    url = mirror://gnome/sources/gtkmm/2.12/gtkmm-2.12.7.tar.bz2;
+    sha256 = "1syrn4ppjd0an4ly6vmi388q6aav5fakj39wbcvs4nbphanwjn2f";
   };
 
   buildInputs = [pkgconfig];
   propagatedBuildInputs = [glibmm gtk atk cairomm];
 }
-
diff --git a/pkgs/development/libraries/gtk-libs/2.6/atk/default.nix b/pkgs/development/libraries/gtk-libs/2.6/atk/default.nix
deleted file mode 100644
index 66720d4dbeb..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.6/atk/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, pkgconfig, glib, perl}:
-
-assert pkgconfig != null && glib != null && perl != null;
-
-stdenv.mkDerivation {
-  name = "atk-1.9.0";
-  src = fetchurl {
-    url = http://nix.cs.uu.nl/dist/tarballs/atk-1.9.0.tar.bz2;
-    md5 = "7f41bd9c6dcd83c8df391dc1805be653";
-  };
-  buildInputs = [pkgconfig perl];
-  propagatedBuildInputs = [glib];
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/default.nix b/pkgs/development/libraries/gtk-libs/2.6/default.nix
deleted file mode 100644
index dc01a534d81..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.6/default.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, gettext, perl, x11
-, libtiff, libjpeg, libpng}:
-
-rec {
-
-  glib = (import ./glib) {
-    inherit fetchurl stdenv pkgconfig gettext perl;
-  };
-
-  atk = (import ./atk) {
-    inherit fetchurl stdenv pkgconfig glib perl;
-  };
-
-  pango = (import ./pango) {
-    inherit fetchurl stdenv pkgconfig glib x11;
-  };
-
-  gtk = (import ./gtk+) {
-    inherit fetchurl stdenv pkgconfig glib atk pango perl
-            libtiff libjpeg libpng x11;
-  };
-
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/glib/default.nix b/pkgs/development/libraries/gtk-libs/2.6/glib/default.nix
deleted file mode 100644
index 1dc3407a76e..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.6/glib/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{stdenv, fetchurl, pkgconfig, gettext, perl}:
-
-assert pkgconfig != null && gettext != null && perl != null;
-
-stdenv.mkDerivation {
-  name = "glib-2.6.6";
-  src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/gtk/v2.6/glib-2.6.6.tar.bz2;
-    md5 = "6e22b0639d314536f23ee118f29b43de";
-  };
-  buildInputs = [pkgconfig gettext perl];
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix b/pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix
deleted file mode 100644
index 957c596fc7b..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.6/glibmm/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{stdenv, fetchurl, pkgconfig, glib, libsigcxx}:
-
-stdenv.mkDerivation {
-  name = "glibmm-2.6.4";
-  src = fetchurl {
-    url = http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.6/glibmm-2.6.1.tar.bz2;
-    md5 = "e37da352bf581503c5866f0231fd4a74";
-  };
-
-  buildInputs = [pkgconfig glib libsigcxx];
-}
-
diff --git a/pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix b/pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix
deleted file mode 100644
index 06e37f070da..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.6/gtk+/default.nix
+++ /dev/null
@@ -1,21 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, x11, glib, atk
-, pango, perl, libtiff, libjpeg, libpng}:
-
-assert pkgconfig != null && x11 != null && glib != null && atk != null
-  && pango != null && perl != null && perl != null && libtiff != null
-  && libjpeg != null && libpng != null;
-assert x11.buildClientLibs;
-#assert glib == atk.glib;
-#assert glib == pango.glib;
-#assert x11 == pango.x11;
-
-stdenv.mkDerivation {
-  name = "gtk+-2.6.10";
-  src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-2.6.10.tar.bz2;
-    md5 = "520090ef291e35ba93397060e20f5025";
-  };
-  buildInputs = [pkgconfig perl libtiff libjpeg libpng];
-  propagatedBuildInputs = [x11 glib atk pango];
-  inherit libtiff libjpeg libpng;
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix b/pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix
deleted file mode 100644
index ebc1e881c47..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.6/gtkmm/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, gtk, atk, glibmm, libsigcxx}:
-
-stdenv.mkDerivation {
-  name = "gtkmm-2.6.4";
-  src = fetchurl {
-    url = http://ftp.gnome.org/pub/GNOME/sources/gtkmm/2.6/gtkmm-2.6.4.tar.bz2;
-    md5 = "f71d1c4a89c4f9e054400f12a82dec5f";
-  };
-
-  buildInputs = [pkgconfig gtk atk glibmm libsigcxx];
-}
-
diff --git a/pkgs/development/libraries/gtk-libs/2.6/pango/default.nix b/pkgs/development/libraries/gtk-libs/2.6/pango/default.nix
deleted file mode 100644
index 6b9391e0a0b..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.6/pango/default.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-{stdenv, fetchurl, pkgconfig, x11, glib}:
-
-assert pkgconfig != null && x11 != null && glib != null;
-assert x11.buildClientLibs;
-
-stdenv.mkDerivation {
-  name = "pango-1.8.2";
-  src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/gtk/v2.6/pango-1.8.2.tar.bz2;
-    md5 = "f5b5da7a173f0566d8217ec112fde993";
-  };
-  buildInputs = [pkgconfig];
-  propagatedBuildInputs = [x11 glib];
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/atk/default.nix b/pkgs/development/libraries/gtk-libs/2.8/atk/default.nix
deleted file mode 100644
index 07537567520..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.8/atk/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, pkgconfig, glib, perl}:
-
-assert pkgconfig != null && glib != null && perl != null;
-
-stdenv.mkDerivation {
-  name = "atk-1.10.3";
-  src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/gtk/v2.8/atk-1.10.3.tar.bz2;
-    md5 = "c84a01fea567b365c0d44b227fead948";
-  };
-  buildInputs = [pkgconfig perl];
-  propagatedBuildInputs = [glib];
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/default.nix b/pkgs/development/libraries/gtk-libs/2.8/default.nix
deleted file mode 100644
index ee5abd562b1..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.8/default.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ xineramaSupport ? false
-, stdenv, fetchurl, pkgconfig, gettext, perl, x11
-, libtiff, libjpeg, libpng, cairo, libXinerama ? null
-}:
-
-rec {
-
-  glib = (import ./glib) {
-    inherit fetchurl stdenv pkgconfig gettext perl;
-  };
-
-  atk = (import ./atk) {
-    inherit fetchurl stdenv pkgconfig glib perl;
-  };
-
-  pango = (import ./pango) {
-    inherit fetchurl stdenv pkgconfig glib x11 cairo;
-  };
-
-  gtk = (import ./gtk+) {
-    inherit fetchurl stdenv pkgconfig glib atk pango perl
-            libtiff libjpeg libpng x11 cairo libXinerama
-            xineramaSupport;
-  };
-
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/glib/default.nix b/pkgs/development/libraries/gtk-libs/2.8/glib/default.nix
deleted file mode 100644
index f73a1f388f4..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.8/glib/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, pkgconfig, gettext, perl}:
-
-assert pkgconfig != null && gettext != null && perl != null;
-
-stdenv.mkDerivation {
-  name = "glib-2.10.3";
-  src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/glib/2.10/glib-2.10.3.tar.bz2;
-    md5 = "87206e721c12d185d17dd9ecd7e30369";
-  };
-  buildInputs = [pkgconfig perl];
-  propagatedBuildInputs = [gettext];
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix b/pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix
deleted file mode 100644
index 957c596fc7b..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.8/glibmm/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{stdenv, fetchurl, pkgconfig, glib, libsigcxx}:
-
-stdenv.mkDerivation {
-  name = "glibmm-2.6.4";
-  src = fetchurl {
-    url = http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.6/glibmm-2.6.1.tar.bz2;
-    md5 = "e37da352bf581503c5866f0231fd4a74";
-  };
-
-  buildInputs = [pkgconfig glib libsigcxx];
-}
-
diff --git a/pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix b/pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix
deleted file mode 100644
index c5a012d9baa..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.8/gtk+/default.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-{ xineramaSupport ? false
-, stdenv, fetchurl, pkgconfig, x11, glib, atk
-, pango, perl, libtiff, libjpeg, libpng, cairo, libXinerama ? null
-}:
-
-assert x11.buildClientLibs;
-assert xineramaSupport -> libXinerama != null;
-
-
-stdenv.mkDerivation {
-  name = "gtk+-2.8.20";
-  src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/gtk/v2.8/gtk+-2.8.20.tar.bz2;
-    md5 = "74e7ca98194f1fadfe906e66d763d05d";
-  };
-  buildInputs = [
-    pkgconfig perl libtiff libjpeg libpng cairo
-    (if xineramaSupport then libXinerama else null)
-  ];
-  propagatedBuildInputs = [x11 glib atk pango];
-  inherit libtiff libjpeg libpng;
-}
diff --git a/pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix b/pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix
deleted file mode 100644
index ebc1e881c47..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.8/gtkmm/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{ stdenv, fetchurl, pkgconfig, gtk, atk, glibmm, libsigcxx}:
-
-stdenv.mkDerivation {
-  name = "gtkmm-2.6.4";
-  src = fetchurl {
-    url = http://ftp.gnome.org/pub/GNOME/sources/gtkmm/2.6/gtkmm-2.6.4.tar.bz2;
-    md5 = "f71d1c4a89c4f9e054400f12a82dec5f";
-  };
-
-  buildInputs = [pkgconfig gtk atk glibmm libsigcxx];
-}
-
diff --git a/pkgs/development/libraries/gtk-libs/2.8/pango/default.nix b/pkgs/development/libraries/gtk-libs/2.8/pango/default.nix
deleted file mode 100644
index 9e3296e00a1..00000000000
--- a/pkgs/development/libraries/gtk-libs/2.8/pango/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, pkgconfig, x11, glib, cairo}:
-
-assert x11.buildClientLibs;
-
-stdenv.mkDerivation {
-  name = "pango-1.12.4";
-  src = fetchurl {
-    url = ftp://ftp.gtk.org/pub/pango/1.12/pango-1.12.4.tar.bz2;
-    md5 = "8f6749fe961e41dbeed72d1efcd55224";
-  };
-  buildInputs = [pkgconfig];
-  propagatedBuildInputs = [x11 glib cairo];
-}
diff --git a/pkgs/development/libraries/haskell/X11/default.nix b/pkgs/development/libraries/haskell/X11/default.nix
index 39fb5628467..3b6c87bab58 100644
--- a/pkgs/development/libraries/haskell/X11/default.nix
+++ b/pkgs/development/libraries/haskell/X11/default.nix
@@ -4,8 +4,8 @@ assert xineramaSupport -> (libXinerama != null && libXext != null);
 
 cabal.mkDerivation (self : {
   pname = "X11";
-  version = "1.4.1";
-  sha256 = "e51038541415686f0e278ccdbc0b2373cd11f212de99023b7b8f8e776aa09f79";
+  version = "1.4.2";
+  sha256 = "7a37ba1adee9c30a27013ea7058e907c2348ef08eaa79c9895e62e4f0d73d2aa";
   propagatedBuildInputs = [libX11] ++ (if xineramaSupport then [libXinerama libXext] else []);
   meta = {
     description = "A Haskell binding to the X11 graphics library";
diff --git a/pkgs/development/libraries/java/hsqldb/default.nix b/pkgs/development/libraries/java/hsqldb/default.nix
index 9145785a891..695616eca51 100644
--- a/pkgs/development/libraries/java/hsqldb/default.nix
+++ b/pkgs/development/libraries/java/hsqldb/default.nix
@@ -2,12 +2,12 @@
 }:
 
 stdenv.mkDerivation {
-  name = "hsqldb-1.8.0.8";
+  name = "hsqldb-1.8.0.9";
   builder = ./builder.sh;
 
   src = fetchurl {
-    url = mirror://sourceforge/hsqldb/hsqldb_1_8_0_8.zip;
-    sha256 = "1428pkizd19i2p7iiha0nkgypa3hznj4vbw503ayyhnnhbgw4ama";
+    url = mirror://sourceforge/hsqldb/hsqldb_1_8_0_9.zip;
+    sha256 = "e98d1d8bca15059f4ef4f0d3dde2d75778a5e1bbe8bc12abd4ec2cac39d5adec";
   };
 
   buildInputs = [ unzip
diff --git a/pkgs/development/libraries/lablgtk/default.nix b/pkgs/development/libraries/lablgtk/default.nix
index 12728717e82..bd34f6bb93c 100644
--- a/pkgs/development/libraries/lablgtk/default.nix
+++ b/pkgs/development/libraries/lablgtk/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, ocaml, pkgconfig, gtk}:
+{stdenv, fetchurl, ocaml, pkgconfig, gtk, libgnomecanvas}:
 
 stdenv.mkDerivation {
   name = "lablgtk-2.6.0";
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
     sha256 = "3694bc1e288ce0903af6c96a2790d2340ba38fa51b18090062ede75137d97876";
   };
 
-  buildInputs = [ocaml pkgconfig gtk];
+  buildInputs = [ocaml pkgconfig gtk libgnomecanvas];
 
   configureFlags = "--with-libdir=$(out)/lib/ocaml";
   buildFlags = "world";
diff --git a/pkgs/development/libraries/lib3ds/default.nix b/pkgs/development/libraries/lib3ds/default.nix
new file mode 100644
index 00000000000..ec7f4adf031
--- /dev/null
+++ b/pkgs/development/libraries/lib3ds/default.nix
@@ -0,0 +1,18 @@
+args:
+args.stdenv.mkDerivation {
+  name = "lib3ds";
+
+  src = args.fetchurl {
+    url = mirror://sourceforge/lib3ds/lib3ds-1.3.0.zip;
+    sha256 = "1qr9arfdkjf7q11xhvxwzmhxqz3nhcjkyb8zzfjpz9jm54q0rc7m";
+  };
+
+  buildInputs =(with args; [unzip]);
+
+  meta = { 
+      description = "library for managing 3D-Studio Release 3 and 4 \".3DS\" files";
+      homepage = http://lib3ds.sourceforge.net/;
+      license = "LGPL";
+    };
+}
+
diff --git a/pkgs/development/libraries/libcaca/default.nix b/pkgs/development/libraries/libcaca/default.nix
index 95e99710c6e..b7b13f54cc8 100644
--- a/pkgs/development/libraries/libcaca/default.nix
+++ b/pkgs/development/libraries/libcaca/default.nix
@@ -1,11 +1,18 @@
 {stdenv, fetchurl, ncurses}:
 
-stdenv.mkDerivation {
+stdenv.mkDerivation rec {
   name = "libcaca-0.99-beta13b";
   src = fetchurl {
-    url = http://libcaca.zoy.org/files/libcaca-0.99.beta13b.tar.gz;
+	  name = "${name}.tar.gz";
+    url = http://libcaca.zoy.org/attachment/wiki/libcaca/libcaca-0.99.beta13b.tar.gz?format=raw;
     sha256 = "0xy8pcnljnj5la97bzbwwyzyqa7dr3v9cyw8gdjzdfgqywvac1vg";
   };
   configureFlags = "--disable-x11 --disable-imlib2 --disable-doc";
   propagatedBuildInputs = [ncurses];
+
+	meta = {
+	  homepage = http://libcaca.zoy.org/;
+		description = "A graphics library that outputs text instead of pixels.";
+	  license = "WTFPL"; # http://sam.zoy.org/wtfpl/
+	};
 }
diff --git a/pkgs/development/libraries/libcdio/default.nix b/pkgs/development/libraries/libcdio/default.nix
index b9d815be083..7251bf3c3ce 100644
--- a/pkgs/development/libraries/libcdio/default.nix
+++ b/pkgs/development/libraries/libcdio/default.nix
@@ -7,13 +7,18 @@ stdenv.mkDerivation rec {
     sha256 = "1xfizvs0yvgs9ddazalsmccd6whqi5fy4dlm3dhcqj72wvpf7w0v";
   };
 
-  buildInputs = [ libcddb pkgconfig ncurses ];
+  buildInputs = [libcddb pkgconfig ncurses];
+
+  doCheck = true;
 
   meta = {
-    description = ''GNU libcdio is a library for OS-idependent CD-ROM and
-                    CD image access.  It includes a library for working with
-		    ISO-9660 filesystems (libiso9660), as well as utility
-		    programs such as an audio CD player and an extractor.'';
+    description = "A library for OS-idependent CD-ROM and CD image access";
+    longDescription = ''
+      GNU libcdio is a library for OS-idependent CD-ROM and
+      CD image access.  It includes a library for working with
+      ISO-9660 filesystems (libiso9660), as well as utility
+      programs such as an audio CD player and an extractor.
+    '';
     license = "GPLv2+";
     homepage = http://www.gnu.org/software/libcdio/;
   };
diff --git a/pkgs/development/libraries/libffi/default.nix b/pkgs/development/libraries/libffi/default.nix
new file mode 100644
index 00000000000..42e97fb8dfe
--- /dev/null
+++ b/pkgs/development/libraries/libffi/default.nix
@@ -0,0 +1,34 @@
+{ fetchurl, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "libffi-3.0.5";
+  src = fetchurl {
+    url = "ftp://sourceware.org/pub/libffi/${name}.tar.gz";
+    sha256 = "1i0ms6ilhjzz0691nymnvs5a3b5lf95n6p99l65z2zn83rd7pahf";
+  };
+
+  doCheck = true;
+
+  meta = {
+    description = "libffi, a foreign function call interface library";
+
+    longDescription = ''
+      The libffi library provides a portable, high level programming
+      interface to various calling conventions.  This allows a
+      programmer to call any function specified by a call interface
+      description at run-time.
+
+      FFI stands for Foreign Function Interface.  A foreign function
+      interface is the popular name for the interface that allows code
+      written in one language to call code written in another
+      language.  The libffi library really only provides the lowest,
+      machine dependent layer of a fully featured foreign function
+      interface.  A layer must exist above libffi that handles type
+      conversions for values passed between the two languages.
+    '';
+
+    homepage = http://sources.redhat.com/libffi/;
+
+    license = "http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/libffi/LICENSE?rev=1.6&content-type=text/plain&cvsroot=libffi&only_with_tag=MAIN";
+  };
+}
diff --git a/pkgs/development/libraries/libixp/libixp-0.3.nix b/pkgs/development/libraries/libixp/libixp-0.3.nix
deleted file mode 100644
index b56c7d15cca..00000000000
--- a/pkgs/development/libraries/libixp/libixp-0.3.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{stdenv, fetchurl}:
-
-stdenv.mkDerivation {
-  name = "libixp-0.3";
-  description = "libixp is a stand-alone client/server 9P library including ixpc client which behaves like wmiir in the past. Its server api is based heavily on Plan 9's lib9p";
-  builder = ./builder.sh;
-  src = fetchurl {
-    url = http://www.suckless.org/snaps/libixp-0.3.tar.gz;
-    md5 = "d341eb9c8f5d233aba5aa2ea8295ca91";
-  };
-}
-
diff --git a/pkgs/development/libraries/libixp_for_wmii/default.nix b/pkgs/development/libraries/libixp_for_wmii/default.nix
index c26bf7dfc6c..c3fcd0d8100 100644
--- a/pkgs/development/libraries/libixp_for_wmii/default.nix
+++ b/pkgs/development/libraries/libixp_for_wmii/default.nix
@@ -1,18 +1,20 @@
 args: with args;
 stdenv.mkDerivation {
   name = "libixp_for_wmii";
-  phases = (if args.includeUnpack then "unpackPhase " else "")+"installPhase";
+  phases = "unpackPhase installPhase";
   installPhase = "
-
      export LDFLAGS\=$(echo \$NIX_LDFLAGS | sed -e 's/-rpath/-L/g')
      sed -i -e \"s%^PREFIX.*%PREFIX=\$out%\" \\
             -e \"s%^\\(INCLUDE.*\\)%\\1 \$NIX_CFLAGS_COMPILE%\" \\
             -e \"s%^\\(LIBS.*\\)%\\1 \$LDFLAGS%\" \\
             config.mk
-     make install
+     make
+     mkdir -p \$out/include
+     cp -r include/*.h \$out/include
+     cp -r lib \$out
   ";
   src = fetchurl {
-    url = http://www.suckless.org/snaps/libixp-20070220.tar.gz;
-    sha256 = "0bhqgrxp0lnwyf3c9165nldyw300mifyh0mlyfg1i5qr54rk7p79";
+    url = http://www.suckless.org/download/libixp-0.4.tar.gz;
+    sha256 = "0b44p9wvmzxpyf2xd86rxyr49bmfh9cd5hj3d234gkvynvgph60p";
   };
 }
diff --git a/pkgs/development/libraries/libmicrohttpd/default.nix b/pkgs/development/libraries/libmicrohttpd/default.nix
new file mode 100644
index 00000000000..17fdd6bc1d5
--- /dev/null
+++ b/pkgs/development/libraries/libmicrohttpd/default.nix
@@ -0,0 +1,12 @@
+{stdenv, fetchurl, curl}:
+
+stdenv.mkDerivation {
+  name = "libmicrohttpd-0.3.0";
+
+  src = fetchurl {
+    url = ftp://ftp.nluug.nl/pub/gnu/libmicrohttpd/libmicrohttpd-0.3.0.tar.gz;
+    sha256 = "1m3c9akpdx2lg7klqxv5vbwjr9vwfx5k0aqn8zmf6rpdgk5c3bii";
+  };
+
+  buildInputs = [curl];
+}
diff --git a/pkgs/development/libraries/liboil/0.3.12.nix b/pkgs/development/libraries/liboil/0.3.13.nix
index 5a04892d5be..3cb6ad6f992 100644
--- a/pkgs/development/libraries/liboil/0.3.12.nix
+++ b/pkgs/development/libraries/liboil/0.3.13.nix
@@ -5,12 +5,12 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}/download/${name}.tar.gz";
-    sha256 = "0gdmly9sli1918pnb4ds1g38ipxikn651hdss86mp4qlfb8wvqlv";
+    sha256 = "0cndfz98zca40qc1d2waq1dkfx32yscbllbvlnlhjp4cjlkyh9qg";
   };
 
   configureFlags = "--enable-shared --disable-static";
 
-  buildInputs = [pkgconfig];
+  buildInputs = [pkgconfig glib];
 
   meta = {
     homepage = http://liboil.freedesktop.org;
diff --git a/pkgs/development/libraries/libqglviewer/default.nix b/pkgs/development/libraries/libqglviewer/default.nix
new file mode 100644
index 00000000000..6b9d70fb6be
--- /dev/null
+++ b/pkgs/development/libraries/libqglviewer/default.nix
@@ -0,0 +1,23 @@
+args:
+args.stdenv.mkDerivation {
+  name = "libQGLviewer";
+
+  src = args.fetchurl {
+    url = http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer/src/libQGLViewer-2.2.6-3.tar.gz;
+    sha256 = "05vjl7af87dhzrdigm941by9c137g8wyca46h3pvhnmr4pgb0ic9";
+  };
+
+  buildInputs =(with args; [qt4]);
+
+  buildPhase = "
+   cd QGLViewer
+   qmake PREFIX=\$out
+   make
+   ";
+
+  meta = { 
+      description = "trackball-based 3D viewer qt widget including many useful features";
+      homepage = http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer/installUnix.html;
+      license = "GPL2";
+  };
+}
diff --git a/pkgs/development/libraries/libxml2/setup-hook.sh b/pkgs/development/libraries/libxml2/setup-hook.sh
index df1155d1809..d87c226506a 100644
--- a/pkgs/development/libraries/libxml2/setup-hook.sh
+++ b/pkgs/development/libraries/libxml2/setup-hook.sh
@@ -1,9 +1,11 @@
 addXMLCatalogs () {
-    if test -d $1/xml/dtd; then
-        for i in $(find $1/xml/dtd -name catalog.xml); do
-            export XML_CATALOG_FILES="$XML_CATALOG_FILES $i"
-        done
-    fi
+    for kind in dtd xsl; do
+	if test -d $1/xml/$kind; then
+            for i in $(find $1/xml/$kind -name catalog.xml); do
+		export XML_CATALOG_FILES="$XML_CATALOG_FILES $i"
+            done
+	fi
+    done
 }
 
 if test -z "$libxmlHookDone"; then
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index c083238cca0..5063caf9094 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -2,10 +2,9 @@ args: with args;
 stdenv.mkDerivation {
   name = "mpfr-2.3.0";
 
-  src =
-	fetchurl {
-		url = http://www.mpfr.org/mpfr-current/mpfr-2.3.0.tar.bz2;
-		sha256 = "0j1dgpqhw21xc0clm7785jm6k04v9zsssdydvm2z3lcj9ws0v7rm";
+  src = fetchurl {
+	  url = http://www.mpfr.org/mpfr-current/mpfr-2.3.1.tar.bz2;
+	  sha256 = "0c44va4plxfd9zm7aa24173im38svnb15lbxql5hvxbc9bgzjmyq";
 	};
 
   buildInputs =[gmp];
diff --git a/pkgs/development/libraries/mysql-connector-odbc/builder.sh b/pkgs/development/libraries/mysql-connector-odbc/builder.sh
deleted file mode 100644
index 7bf6f996bbc..00000000000
--- a/pkgs/development/libraries/mysql-connector-odbc/builder.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-source $stdenv/setup
-
-configureFlags="$configureFlags \
-  --with-mysql-path=$mysql \
-  --with-unixODBC=$unixODBC"
-
-genericBuild
\ No newline at end of file
diff --git a/pkgs/development/libraries/mysql-connector-odbc/default.nix b/pkgs/development/libraries/mysql-connector-odbc/default.nix
deleted file mode 100644
index 47c14a4d793..00000000000
--- a/pkgs/development/libraries/mysql-connector-odbc/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, mysql, libtool, zlib, unixODBC}:
-
-stdenv.mkDerivation {
-  name = "mysql-connector-odbc-3.51.12";
-  builder = ./builder.sh;
-  src = fetchurl {
-    url = http://ftp.snt.utwente.nl/pub/software/mysql/Downloads/MyODBC3/mysql-connector-odbc-3.51.12.tar.gz;
-    md5 = "a484f590464fb823a8f821b2f1fd7fef";
-  };
-  configureFlags = "--disable-gui";
-  buildInputs = [libtool zlib];
-  inherit mysql unixODBC;
-}
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 9cc46cec85d..709c78db1c7 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl, perl}:
 
 stdenv.mkDerivation {
-  name = "openssl-0.9.8g";
+  name = "openssl-0.9.8h";
   builder = ./builder.sh;
   src = fetchurl {
-    url = ftp://ftp.nluug.nl/pub/security/openssl/openssl-0.9.8g.tar.gz;
-    sha256 = "1w0wj3pgg9ga0hay3jdxs9sl17bfw307b6qvkxn735fy8ml8h9hf";
+    url = ftp://ftp.nluug.nl/pub/security/openssl/openssl-0.9.8h.tar.gz;
+    sha1 = "ced4f2da24a202e01ea22bef30ebc8aee274de86";
   };
   buildInputs = [perl];
 }
diff --git a/pkgs/development/libraries/qt-4/default.nix b/pkgs/development/libraries/qt-4/default.nix
index 046ebde99a1..09427e2f63b 100644
--- a/pkgs/development/libraries/qt-4/default.nix
+++ b/pkgs/development/libraries/qt-4/default.nix
@@ -1,11 +1,42 @@
 args: with args;
-let common =
-rec {
+stdenv.mkDerivation {
+  name = "qt-4.4.0";
+  
+  src = fetchurl {
+    url = ftp://ftp.trolltech.com/qt/source/qt-x11-opensource-src-4.4.0.tar.bz2;
+    sha256 = "871dc71c6c905212f2fea7e6598362114a3b6097c220b0b251f8d159ee7d706e";
+  };
+  
   setupHook = ./setup-hook.sh;  
-  propagatedBuildInputs = [libXft libXrender libXrandr randrproto xextproto
-  libXinerama xineramaproto libXcursor zlib libjpeg mysql libpng which mesa
-  libXmu openssl dbus.libs cups pkgconfig libXext freetype fontconfig inputproto
-  fixesproto libXfixes glib libtiff];
+  propagatedBuildInputs = [
+    libXft 
+    libXrender 
+    libXrandr 
+    randrproto 
+    xextproto
+    libXinerama 
+    xineramaproto 
+    libXcursor 
+    zlib 
+    libjpeg 
+    mysql 
+    libpng 
+    which 
+    mesa
+    libXmu 
+    openssl 
+    dbus.libs 
+    cups 
+    pkgconfig 
+    libXext 
+    freetype 
+    fontconfig 
+    inputproto
+    fixesproto 
+    libXfixes 
+    glib 
+    libtiff
+  ];
   prefixKey = "-prefix ";
   configureFlags = "
     -v -no-separate-debug-info -release
@@ -14,25 +45,6 @@ rec {
     -opengl -xrender -xrandr -xinerama -xcursor -qt-sql-mysql
     -qdbus -cups -glib -xfixes
     -fontconfig -I${freetype}/include/freetype2";
+
   patchPhase = "sed -e 's@/bin/pwd@pwd@' -i configure; sed -e 's@/usr@/FOO@' -i config.tests/*/*.test -i mkspecs/*/*.conf";
-}; in
-rec {
-	trolltech = stdenv.mkDerivation (common // {
-	  name = "qt-4.3.3";
-	  src = fetchurl {
-		url = ftp://ftp.trolltech.com/qt/source/qt-x11-opensource-src-4.3.3.tar.gz;
-		sha256 = "0w0mfm0wwmbj1vnjn27rza1r9wj8k47mn9ril8swprffqnn4p4w9";
-	  };
-	  patchPhase = common.patchPhase;
-	});
-	kde = stdenv.mkDerivation (common // {
-	  name = "qt-kde-4.3svn";
-	  src = fetchsvn {
-		  url = svn://anonsvn.kde.org/home/kde/trunk/qt-copy;
-		  rev = "761061";
-		  sha256 = "0i98kh435dj29ln1lnidxwivcha1m553s4l8c1h2b3yd4950w8x4";
-	  };
-	  patchPhase = "mkdir .svn; bash apply_patches;" + common.patchPhase;
-	});
-	default = kde;
 }
diff --git a/pkgs/development/libraries/schroedinger/default.nix b/pkgs/development/libraries/schroedinger/default.nix
new file mode 100644
index 00000000000..67f026fb482
--- /dev/null
+++ b/pkgs/development/libraries/schroedinger/default.nix
@@ -0,0 +1,11 @@
+{stdenv, fetchurl, liboil, pkgconfig}:
+
+stdenv.mkDerivation {
+  name = "schroedinger-1.0.0";
+  src = fetchurl {
+    url = mirror://sourceforge/schrodinger/schroedinger-1.0.0.tar.gz;
+    sha256 = "0r374wvc73pfzkcpwk0q0sjx6yhp79acyiqbjy3c7sfqdy7sm4x8";
+  };
+
+  buildInputs = [liboil pkgconfig];
+}
diff --git a/pkgs/development/libraries/unixODBC/default.nix b/pkgs/development/libraries/unixODBC/default.nix
index 9049504b7e5..932873ffe94 100644
--- a/pkgs/development/libraries/unixODBC/default.nix
+++ b/pkgs/development/libraries/unixODBC/default.nix
@@ -6,5 +6,5 @@ stdenv.mkDerivation {
     url = mirror://sourceforge/unixodbc/unixODBC-2.2.11.tar.gz;
     md5 = "9ae806396844e38244cf65ad26ba0f23";
   };
-  configureFlags = "--disable-gui";
+  configureFlags = "--disable-gui --sysconfdir=/etc";
 }
diff --git a/pkgs/development/libraries/unixODBCDrivers/default.nix b/pkgs/development/libraries/unixODBCDrivers/default.nix
new file mode 100644
index 00000000000..421843b2737
--- /dev/null
+++ b/pkgs/development/libraries/unixODBCDrivers/default.nix
@@ -0,0 +1,103 @@
+args : with args;
+# each attr contains the name deriv referencing the derivation and ini which
+# evaluates to a string which can be appended to the global unix odbc ini file
+# to register the driver
+# I haven't done any parameter tweaking.. So the defaults provided here might be bad
+{
+# new postgres connector library (doesn't work yet)
+  psqlng = rec {
+    deriv = stdenv.mkDerivation {
+      name = "unix-odbc-pg-odbcng-0.90.101";
+      buildInputs = [ unixODBC glibc libtool postgresql ];
+      # added -ltdl to resolve missing references `dlsym' `dlerror' `dlopen' `dlclose' 
+      preConfigure="
+        export CPPFLAGS=-I${unixODBC}/include
+        export LDFLAGS='-L${unixODBC}/lib -lltdl'
+      ";
+      src = fetchurl {
+        # using my mirror because original url is https
+        # https://projects.commandprompt.com/public/odbcng/attachment/wiki/Downloads/odbcng-0.90.101.tar.gz";
+        url = http://mawercer.de/~publicrepos/odbcng-0.90.101.tar.gz;
+        sha256 = "13z3sify4z2jcil379704w0knkpflg6di4jh6zx1x2gdgzydxa1y";
+      };
+      meta = {
+          description = "unix odbc driver for postgresql";
+          homepage = https://projects.commandprompt.com/public/odbcng;
+          license = "GPL2";
+      };
+    };
+    ini = "";
+  };
+# official postgres connector
+ psql = rec {
+   deriv = stdenv.mkDerivation {
+    name = "psql-odbc-08.03.0200";
+    buildInputs = [ unixODBC libtool postgresql openssl ];
+    preConfigure="
+      export CPPFLAGS=-I${unixODBC}/include
+      export LDFLAGS='-L${unixODBC}/lib -lltdl'
+    ";
+    # added -ltdl to resolve missing references `dlsym' `dlerror' `dlopen' `dlclose' 
+    src = fetchurl {
+      url = http://wwwmaster.postgresql.org/redir?setmir=53&typ=h&url=http://ftp.de.postgresql.org/mirror/postgresql//odbc/versions/src/psqlodbc-08.03.0200.tar.gz;
+      name = "psqlodbc-08.03.0200.tar.gz";
+      sha256 = "1401hgzvs3m2yr2nbbf9gfy2wwijrk4ihwz972arbn0krsiwxya1";
+    };
+    meta = {
+        description = "unix odbc driver for postgresql";
+        homepage =  http://pgfoundry.org/projects/psqlodbc/;
+        license = "LGPL";
+    };
+  };
+  ini = 
+    "[PostgreSQL]\n" +
+    "Description     = official PostgreSQL driver for Linux & Win32\n" +
+    "Driver          = ${deriv}/lib/psqlodbcw.so\n" +
+    "Threading       = 2\n";
+ };
+# mysql connector
+ mysql = rec {
+    libraries = ["lib/libmyodbc3-3.51.12.so"];
+    deriv = stdenv.mkDerivation {
+      name = "mysql-connector-odbc-3.51.12";
+      src = fetchurl {
+        url = http://ftp.snt.utwente.nl/pub/software/mysql/Downloads/MyODBC3/mysql-connector-odbc-3.51.12.tar.gz;
+        md5 = "a484f590464fb823a8f821b2f1fd7fef";
+      };
+      configureFlags = "--disable-gui"
+         +  " --with-mysql-path=${mysql} --with-unixODBC=${unixODBC}";
+      buildInputs = [libtool zlib];
+      inherit mysql unixODBC;
+    };
+    ini =
+      "[MYSQL]\n" +
+      "Description     = MySQL driver\n" +
+      "Driver          = ${deriv}/lib/libmyodbc3-3.51.12.so\n" +
+      "CPTimeout       = \n" +
+      "CPReuse         = \n" +
+      "FileUsage       = 3\n ";
+ };
+ sqlite = rec {
+    deriv = stdenv.mkDerivation {
+      name = "sqlite-connector-odbc-3.51.12";
+      src = fetchurl {
+        url = http://www.ch-werner.de/sqliteodbc/sqliteodbc-0.70.tar.gz;
+        sha256 = "0ysyqdqkxqcqxrxgi15cbrzia9z6yalim5c88faad85bwanx4db8";
+      };
+      configureFlags = "--with-sqlite3=${sqlite} --with-odbc=${unixODBC}";
+      postInstall = ''mkdir lib; mv $out/* lib; mv lib $out'';
+      buildInputs = [libtool zlib sqlite];
+      meta = { 
+        description = "sqlite odbc connector, install using configuration.nix";
+        homepage = http://www.ch-werner.de/sqliteodbc/html/index.html;
+        license = "BSD";
+      };
+    };
+    ini =
+      "[SQLite]\n" +
+      "Description     = SQLite ODBC Driver\n" +
+      "Driver          = ${deriv}/lib/libsqlite3odbc.so\n" +
+      "Setup           = ${deriv}/lib/libsqlite3odbc.so\n" +
+      "Threading       = 2\n";
+ };
+}
diff --git a/pkgs/development/libraries/x264/default.nix b/pkgs/development/libraries/x264/default.nix
new file mode 100644
index 00000000000..9b8cee26868
--- /dev/null
+++ b/pkgs/development/libraries/x264/default.nix
@@ -0,0 +1,18 @@
+args:
+args.stdenv.mkDerivation rec {
+  version = "snapshot-20080521-2245";
+  name = "x264-${version}";
+
+  src = args.fetchurl {
+    url = "ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-${version}.tar.bz2";
+    sha256 = "07khxih1lmhvrzlaksqmaghbi8w2yyjrjcw867gi2y4z1h0ndhks";
+  };
+
+  buildInputs =(with args; []);
+
+  meta = { 
+      description = "library for encoding H264/AVC video streams";
+      homepage = http://www.videolan.org/developers/x264.html;
+      license = "GPL";
+  };
+}
diff --git a/pkgs/development/libraries/xine-lib/default.nix b/pkgs/development/libraries/xine-lib/default.nix
index ba6880d525a..1c8857551c5 100644
--- a/pkgs/development/libraries/xine-lib/default.nix
+++ b/pkgs/development/libraries/xine-lib/default.nix
@@ -1,10 +1,10 @@
 args: with args;
 
 (stdenv.mkDerivation rec {
-  name = "xine-lib-1.1.9.1";
+  name = "xine-lib-1.1.12";
   src = fetchurl {
     url = "mirror://sourceforge/xine/${name}.tar.bz2";
-    sha256 = "1rz4k2a9pny2ksqb5diw1ci8ijihpcm0mi8qxp5p7nasgzgqcj82";
+    sha256 = "49088635c29a38527bd8590139691951783c5c1c7fdb691a8a3a9954097d4dd0";
   };
   buildInputs = [ x11 pkgconfig libXv libXinerama alsaLib mesa aalib SDL
   libvorbis libtheora speex ];
diff --git a/pkgs/development/misc/bleeding-edge-repos/default.nix b/pkgs/development/misc/bleeding-edge-repos/default.nix
new file mode 100644
index 00000000000..dd6903225b2
--- /dev/null
+++ b/pkgs/development/misc/bleeding-edge-repos/default.nix
@@ -0,0 +1,55 @@
+args: 
+  with args;
+  let inherit (builtins) pathExists; in
+  rec {
+  /*
+    tries to get source in this order
+    1) Local .tar.gz in ${HOME}/managed_repos/dist/name.tar.gz (-> see nixRepositoryManager)
+    2) By importing                                           
+        pkgs/misc/bleeding-edge-fetch-info/name.nix
+        (generated by nixRepositoryManager --publish)
+    3) Fall back to fetch_xy given with information given by A) But
+      the sum wil propably be wrong..
+      (not everything is implemented now)
+  */ 
+
+  managedRepoDir = getConfig [ "bleedingEdgeRepos" "managedRepoDir" ] (builtins.getEnv "HOME" + "/managed_repos");
+
+  sourceByName = name : (
+    let localTarGZ = managedRepoDir+"/dist/${name}.tar.gz"; 
+        fetchUrlInfoFile = ../../../misc/bleeding-edge-fetch-info + "/${name}.nix"; in
+    if pathExists localTarGZ
+    then localTarGZ
+    else if pathExists fetchUrlInfoFile
+         then (import fetchUrlInfoFile) { inherit fetchurl; }
+         else builtins.trace "warning, no bleeding edge source info (${fetchUrlInfoFile}) found for ${name}, hash will propably be wrong"
+               (let attr = __getAttr name repos;
+                 in if (attr.type == "darcs")
+                   then fetchdarcs2 { inherit (attr) url md5; }
+                   else throw "TODO") );
+
+  repos = {
+    # each repository has 
+    # a type, url and maybe a tag
+    # you can add groups names to update some repositories at once
+    # see nix_repository_manager expression in all-packages.nix
+
+      nix_repository_manager = { type = "darcs"; url = "http://mawercer.de/~marc/repos/nix-repository-manager"; };
+
+      # darcs repositories haskell 
+      http =  { type= "darcs"; url="http://darcs.haskell.org/http/"; groups="happs"; };
+      syb_with_class =  { type="darcs"; url="http://happs.org/HAppS/syb-with-class"; groups="happs"; };
+      happs_data =  { type="darcs"; url=http://happs.org/repos/HAppS-Data; groups="happs"; };
+      happs_util =  { type="darcs"; url=http://happs.org/repos/HAppS-Util; groups="happs"; };
+      happs_state =  { type="darcs"; url=http://happs.org/repos/HAppS-State; groups="happs"; };
+      happs_plugins =  { type="darcs"; url=http://happs.org/repos/HAppS-Plugins; groups="happs"; };
+      happs_ixset =  { type="darcs"; url=http://happs.org/repos/HAppS-IxSet; groups="happs"; };
+      happs_server =  { type="darcs"; url=http://happs.org/repos/HAppS-Server; groups="happs"; };
+      takusen = { type="darcs"; url=http://darcs.haskell.org/takusen/; };
+      cabal = { type="darcs"; url=http://darcs.haskell.org/cabal; };
+
+
+      # git repositories 
+      hypertable =  { type="git"; url="git://scm.hypertable.org/pub/repos/hypertable.git"; groups=""; };
+    } // getConfig [ "bleedingEdgeRepos" "repos" ] {};
+}
diff --git a/pkgs/development/misc/bleeding_edge_repos/default.nix b/pkgs/development/misc/bleeding_edge_repos/default.nix
deleted file mode 100644
index 80218c8dd6a..00000000000
--- a/pkgs/development/misc/bleeding_edge_repos/default.nix
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-# each repository has 
-# a type, url and maybe a tag
-# you can add group names to update some repositories at once (needs some testing)
-# see nix_repository_manager expression in all-packages.nix
-
-http =  { type= "darcs"; url="http://darcs.haskell.org/http/"; group="happs"; };
-syb_with_class =  { type="darcs"; url="http://happs.org/HAppS/syb-with-class"; group="happs"; };
-happs_data =  { type="darcs"; url=http://happs.org/repos/HAppS-Data; group="happs"; };
-happs_util =  { type="darcs"; url=http://happs.org/repos/HAppS-Util; group="happs"; };
-happs_state =  { type="darcs"; url=http://happs.org/repos/HAppS-State; group="happs"; };
-happs_plugins =  { type="darcs"; url=http://happs.org/repos/HAppS-Plugins; group="happs"; };
-happs_ixset =  { type="darcs"; url=http://happs.org/repos/HAppS-IxSet; group="happs"; };
-happs_server =  { type="darcs"; url=http://happs.org/repos/HAppS-HTTP; group="happs"; };
-cabal = { type="darcs"; url=http://darcs.haskell.org/cabal; };
-}
diff --git a/pkgs/development/perl-modules/expression-generator/filtered-requirements.sh b/pkgs/development/perl-modules/expression-generator/filtered-requirements.sh
new file mode 100755
index 00000000000..98c01508fd5
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/filtered-requirements.sh
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+source lib-cache.sh;
+
+print_reqs() {
+	module_name="$1";
+
+	./requirements.sh "$1"| while read; do
+		if let "$(./source-download-link.sh "${REPLY}" | wc -c)" && [ perl != "$REPLY" ]; then
+			echo "$REPLY";
+		fi;
+	done;
+}
+
+module_name="$1";
+module_basename="${module_name//::/-}";
+
+cached_output print_reqs "$module_basename" "$module_name" "pure.deps";
diff --git a/pkgs/development/perl-modules/expression-generator/full-requirements.sh b/pkgs/development/perl-modules/expression-generator/full-requirements.sh
new file mode 100755
index 00000000000..29ed83668ed
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/full-requirements.sh
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+source lib-cache.sh;
+
+print_requirements () {
+	module_name="$1";
+
+	./requirements.sh "$module_name" | while read; do
+		echo "$REPLY";
+		print_reqs_cache "$REPLY";
+	done | sort | uniq
+};
+
+print_reqs_cache () {
+	module_name="$1";
+	module_basename="${module_name//::/-}";
+	
+	cached_output print_requirements "$module_basename" "$module_name" "full.deps";
+};
+
+print_reqs_cache "$@";
diff --git a/pkgs/development/perl-modules/expression-generator/grab-url.sh b/pkgs/development/perl-modules/expression-generator/grab-url.sh
new file mode 100755
index 00000000000..809cf87fceb
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/grab-url.sh
@@ -0,0 +1,20 @@
+#! /bin/sh
+
+source lib-cache.sh
+
+get_file() {
+	url="$1";
+
+	if [ -n "$url" ]; then 
+		curl "$1";
+	else
+		echo -n;
+	fi;
+}
+
+url="$1";
+name="$2";
+name=${name:-$(basename "$url")}
+
+cached_output get_file "${name%%.*}" "$url" "${name#*.}"
+
diff --git a/pkgs/development/perl-modules/expression-generator/lib-cache.sh b/pkgs/development/perl-modules/expression-generator/lib-cache.sh
new file mode 100644
index 00000000000..7473e2d1c15
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/lib-cache.sh
@@ -0,0 +1,19 @@
+
+# First argument: command to run
+# Second argument: cache name
+# Third argument: argument to command
+# Fourth argument: cache type
+cached_output () {
+	cmd="$1";
+	basename="$2";
+	arg="$3";
+	ext="$4";
+	
+	if ! [ -e "cache-${ext//./-}/${basename}.${ext}" ]; then
+		mkdir -p "cache-${ext//./-}";
+		$cmd $arg > "cache-${ext//./-}/${basename}.${ext}";
+	fi;
+
+	cat "cache-${ext//./-}/${basename}.${ext}";
+}
+
diff --git a/pkgs/development/perl-modules/expression-generator/make-clean-dir.sh b/pkgs/development/perl-modules/expression-generator/make-clean-dir.sh
new file mode 100755
index 00000000000..996cb92e695
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/make-clean-dir.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+rm -rf test;
+mkdir test; 
+for i in *.sh; do ln -s ../$i test; done;
diff --git a/pkgs/development/perl-modules/expression-generator/requirements.sh b/pkgs/development/perl-modules/expression-generator/requirements.sh
new file mode 100755
index 00000000000..60ee68d99ad
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/requirements.sh
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+source lib-cache.sh;
+
+module_name="$1";
+module_basename="${1//::/-}";
+
+print_requirements () {
+	module_name="$1";
+	
+	./retrieve-meta-yaml.sh "$module_name" |
+		sed -re '1,/^requires:/d; /^[a-z]/,$d; s@^\s*@@; s@:\s.*@@';
+	./retrieve-meta-yaml.sh "$module_name" |
+		sed -re '1,/^build_requires:/d; /^[a-z]/,$d; s@^\s*@@; s@:\s.*@@';
+};
+
+cached_output print_requirements "$module_basename" "$module_name" "direct.deps";
diff --git a/pkgs/development/perl-modules/expression-generator/retrieve-file-link.sh b/pkgs/development/perl-modules/expression-generator/retrieve-file-link.sh
new file mode 100755
index 00000000000..a9cf0d94e0d
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/retrieve-file-link.sh
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+module_basename="$1";
+file_name="$2";
+
+version_regexp="${module_basename}(-[0-9.a-z]+){0,1}";
+author_regexp="[A-Z0-9]+";
+
+./retrieve-modulepage.sh "$module_basename" | 
+	egrep "[<]a href=\"[a-z0-9/]*/(${author_regexp}/){0,1}${version_regexp}/${file_name}" |
+	sed -re "s@.*href=\"@@; s@\".*@@" |
+	sed -re 's@^/@http://search.cpan.org/@';
+
+echo "$link_line";
diff --git a/pkgs/development/perl-modules/expression-generator/retrieve-meta-yaml.sh b/pkgs/development/perl-modules/expression-generator/retrieve-meta-yaml.sh
new file mode 100755
index 00000000000..2c85d45691f
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/retrieve-meta-yaml.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+source lib-cache.sh;
+
+print_meta_yaml () {
+	module_name="$1";
+	module_basename="${module_name//::/-}";
+
+	./grab-url.sh "$(./retrieve-file-link.sh "$module_basename" "META.yml")" \
+		"${module_basename}.meta.yml";
+};
+
+module_name="$1";
+module_basename="${module_name//::/-}";
+
+cached_output print_meta_yaml "$module_basename" "$module_name" meta.yaml;
diff --git a/pkgs/development/perl-modules/expression-generator/retrieve-modulepage.sh b/pkgs/development/perl-modules/expression-generator/retrieve-modulepage.sh
new file mode 100755
index 00000000000..866dfa13f94
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/retrieve-modulepage.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+module_basename="$1";
+
+./grab-url.sh "http://search.cpan.org/dist/$module_basename/" "$module_basename".html;
diff --git a/pkgs/development/perl-modules/expression-generator/source-download-link.sh b/pkgs/development/perl-modules/expression-generator/source-download-link.sh
new file mode 100755
index 00000000000..575f47629c2
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/source-download-link.sh
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+source lib-cache.sh;
+
+module_name="$1";
+module_basename="${module_name//::/-}";
+
+write_link() {
+	module_basename="$1";
+
+	./retrieve-modulepage.sh "$module_basename" | 
+		grep -A 2 "This Release" |
+		grep href |
+		sed -re 's/.*href="//; s/".*//; s@^/@http://search.cpan.org/@';
+}
+
+cached_output write_link "$module_basename" "$module_basename" src.link;
diff --git a/pkgs/development/perl-modules/expression-generator/usage.txt b/pkgs/development/perl-modules/expression-generator/usage.txt
new file mode 100644
index 00000000000..1aa0737afdb
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/usage.txt
@@ -0,0 +1,10 @@
+/path/to/write-nix-expression.sh Group::Module::Submodule
+
+It will output Nix assignment formatted for placing into 
+all-packages.nix amongst all the perl packages, like perlAlgorithmDiff.
+Actually it will grab distribution unit Group-Module-Submodule via
+search.cpan.org, and make some effort to write correct dependencies.
+If among requirements there are some that have empty META.yml, or if 
+any of requirements acannot be installed by just getting distribution
+unit whose name can be guessed by replacing :: with -, manual editing
+will be needed. 
diff --git a/pkgs/development/perl-modules/expression-generator/write-nix-expression.sh b/pkgs/development/perl-modules/expression-generator/write-nix-expression.sh
new file mode 100755
index 00000000000..cfe1506640b
--- /dev/null
+++ b/pkgs/development/perl-modules/expression-generator/write-nix-expression.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+
+cd $(dirname $0);
+
+source lib-cache.sh;
+
+print_expression () {
+	module_name="$1";
+	module_basename="${module_name//::/-}";
+	module_compressedname="perl${module_name//::/}";
+	sourcelink="$(./source-download-link.sh "${module_name}")";
+	version_name="${sourcelink%.tar.*}";
+	version_name="${version_name##*/}";
+	dependencies="$(./filtered-requirements.sh "$module_name" | sed -e 's/^/perl/; s/:://g' | xargs)";
+	source_hash=$(nix-prefetch-url "$sourcelink" 2>/dev/null);
+
+	cat <<EOF
+
+  ${module_compressedname} = import ../development/perl-modules/generic perl {
+    name = "${version_name}";
+    src = fetchurl {
+      url = ${sourcelink};
+      sha256 = "$source_hash";
+    };
+    propagatedBuildInputs = [${dependencies}];
+  };
+
+EOF
+};
+
+module_name="$1";
+module_basename="${module_name//::/-}";
+
+cached_output print_expression "$module_basename" "$module_name" "nix";
diff --git a/pkgs/development/python-modules/flup/r2311.nix b/pkgs/development/python-modules/flup/r2311.nix
new file mode 100644
index 00000000000..1334a7e7539
--- /dev/null
+++ b/pkgs/development/python-modules/flup/r2311.nix
@@ -0,0 +1,18 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://www.saddi.com/software/flup/dist/flup-r2311.tar.gz;
+    sha256 = "15wyn6d6wla1ag91yxmlh9b4m0w1i0c2lm8ka4qfv4ijqcqakdx3";
+  };
+
+  buildInputs = [python setuptools];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["addInputs" "createPythonInstallationTarget" (doDump "0") "installPythonPackage"];
+      
+  name = "flup-" + version;
+  meta = {
+    description = "FastCGI Python module set";
+  };
+}
diff --git a/pkgs/development/python-modules/pygtk/default.nix b/pkgs/development/python-modules/pygtk/default.nix
index e8a66817013..9d487db5dd0 100644
--- a/pkgs/development/python-modules/pygtk/default.nix
+++ b/pkgs/development/python-modules/pygtk/default.nix
@@ -2,12 +2,13 @@
 
 stdenv.mkDerivation {
   name = "pygtk-2.10.4";
-#  builder = ./builder.sh;
+
   src = fetchurl {
     url = http://ftp.gnome.org/pub/GNOME/sources/pygtk/2.10/pygtk-2.10.4.tar.bz2;
     sha256 = "1xg8vng42lql29aa5ryva8icc8dwdc7h2y3yn96qjdgl394d96mb";
   };
-  buildInputs = [python pkgconfig glib gtk pycairo];
+  
+  buildInputs = [python pkgconfig glib gtk];
 
-  propagatedBuildInputs = [pygobject];
+  propagatedBuildInputs = [pygobject pycairo];
 }
diff --git a/pkgs/development/python-modules/pyqt/3.17.4.nix b/pkgs/development/python-modules/pyqt/3.17.4.nix
new file mode 100644
index 00000000000..435997a203c
--- /dev/null
+++ b/pkgs/development/python-modules/pyqt/3.17.4.nix
@@ -0,0 +1,20 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftp.de.debian.org/debian/pool/main/p/python-qt3/python-qt3_3.17.4.orig.tar.gz;
+    sha256 = "0p76g64ww9nhg1sahphanwb7nkjmsvxyaqk8k8iaycnlc8040c8r";
+  };
+
+  buildInputs = [qt python pkgconfig pythonSip libX11 libXext glib];
+  configureFlags = [" -q ${qt} "];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doPythonConfigure" "doMakeInstall"];
+  extraPythonConfigureCommand = ''echo yes | \'';
+
+  name = "python-qt-" + version;
+  meta = {
+    description = "Qt bindings for Python";
+    license = "GPL";
+  };
+}
diff --git a/pkgs/development/python-modules/pyqt/4.3.3.nix b/pkgs/development/python-modules/pyqt/4.3.3.nix
new file mode 100644
index 00000000000..23bed9c9c0a
--- /dev/null
+++ b/pkgs/development/python-modules/pyqt/4.3.3.nix
@@ -0,0 +1,20 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = mirror://debian/pool/main/p/python-qt4/python-qt4_4.3.3.orig.tar.gz;
+    sha256 = "0m8yzaz17nb8prm2kmy0mbiq4np515abi2xkadflsgwq1bj86qyk";
+  };
+
+  buildInputs = [qt python pkgconfig pythonSip libX11 libXext glib];
+  configureFlags = [" -p $prefix/share/pyQt4/plugins " '' -e "$prefix/include/python$pythonVersion" ''];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doPythonConfigure" "doMakeInstall"];
+  extraPythonConfigureCommand = ''echo yes | \'';
+
+  name = "python-qt-" + version;
+  meta = {
+    description = "Qt bindings for Python";
+    license = "GPL";
+  };
+}
diff --git a/pkgs/development/python-modules/python-sip/4.7.4.nix b/pkgs/development/python-modules/python-sip/4.7.4.nix
new file mode 100644
index 00000000000..bc4437a2795
--- /dev/null
+++ b/pkgs/development/python-modules/python-sip/4.7.4.nix
@@ -0,0 +1,18 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftp.de.debian.org/debian/pool/main/s/sip4-qt3/sip4-qt3_4.7.4.orig.tar.gz;
+    sha256 = "0g518b26346q9b0lm13rsgdbq14r4nckyjbf209ylakwx6zir4l5";
+  };
+
+  buildInputs = [python];
+  configureFlags = [ '' -e "$prefix/include/python$pythonVersion" ''];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doPythonConfigure" "doMakeInstall"];
+      
+  name = "python-sip-" + version;
+  meta = {
+    description = "Python/C++ bindings generator";
+  };
+}
diff --git a/pkgs/development/python-modules/pyx/default.nix b/pkgs/development/python-modules/pyx/default.nix
new file mode 100644
index 00000000000..374158da810
--- /dev/null
+++ b/pkgs/development/python-modules/pyx/default.nix
@@ -0,0 +1,40 @@
+{stdenv, fetchurl, python, makeWrapper}:
+
+stdenv.mkDerivation rec {
+  name = "PyX-0.10";
+  src = fetchurl {
+    url = "mirror://sourceforge/pyx/${name}.tar.gz";
+    sha256 = "dfaa4a7790661d67d95f80b22044fdd8a9922483631950296ff1d7a9f85c8bba";
+  };
+
+  patchPhase = ''
+    substituteInPlace ./setup.py --replace '"/etc"' '"etc"'
+  '';
+
+  buildInputs = [python makeWrapper];
+  buildPhase = "python ./setup.py build";
+  installPhase = ''
+    python ./setup.py install --prefix="$out" || exit 1
+
+    for i in "$out/bin/"*
+    do
+      # FIXME: We're assuming Python 2.4.
+      wrapProgram "$i" --prefix PYTHONPATH :  \
+       "$out/lib/python2.4/site-packages" ||  \
+        exit 2
+    done
+  '';
+
+  meta = {
+    description = ''Python graphics package'';
+    longDescription = ''
+      PyX is a Python package for the creation of PostScript and PDF
+      files. It combines an abstraction of the PostScript drawing
+      model with a TeX/LaTeX interface. Complex tasks like 2d and 3d
+      plots in publication-ready quality are built out of these
+      primitives.
+    '';
+    license = "GPLv2";
+    homepage = http://pyx.sourceforge.net/;
+  };
+}
diff --git a/pkgs/development/python-modules/setuptools/0.6c8.nix b/pkgs/development/python-modules/setuptools/0.6c8.nix
new file mode 100644
index 00000000000..d8149f5514a
--- /dev/null
+++ b/pkgs/development/python-modules/setuptools/0.6c8.nix
@@ -0,0 +1,19 @@
+
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c8.tar.gz;
+    sha256 = "0dry431lkaqqmgvka0rhnw54ljf1yx0npzh7r81z2ylcrn27lrln";
+  };
+
+  buildInputs = [python];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["createPythonInstallationTarget" "installPythonPackage"];
+      
+  name = "setuptools-" + version;
+  meta = {
+    description = "Installation utilities for Python packages";
+  };
+}
diff --git a/pkgs/development/tools/analysis/lcov/builder.sh b/pkgs/development/tools/analysis/lcov/builder.sh
index 5315cc2835a..b0092e00255 100644
--- a/pkgs/development/tools/analysis/lcov/builder.sh
+++ b/pkgs/development/tools/analysis/lcov/builder.sh
@@ -1,19 +1,7 @@
 source $stdenv/setup
 
-installFlags="PREFIX=$out"
 
-preInstall=preInstall
 preInstall() {
-    substituteInPlace bin/install.sh --replace /bin/bash $shell
-
-    for i in bin/*; do
-        echo "fixing $i..."
-        sed -e "s^@PREFIX@^$out^" \
-            -e "s^@PERL@^$perl/bin/perl^" \
-            < $i > $i.tmp
-        mv $i.tmp $i
-        chmod +x $i
-    done
 }
 
 genericBuild
diff --git a/pkgs/development/tools/analysis/lcov/default.nix b/pkgs/development/tools/analysis/lcov/default.nix
index 4df104d53cb..9834b8a5a2b 100644
--- a/pkgs/development/tools/analysis/lcov/default.nix
+++ b/pkgs/development/tools/analysis/lcov/default.nix
@@ -1,12 +1,35 @@
 {stdenv, fetchurl, perl}:
 
 stdenv.mkDerivation {
-  name = "lcov-1.4pre-cvs-20041021";
-  builder = ./builder.sh;
+  name = "lcov-1.6";
+  
   src = fetchurl {
-    url = http://nix.cs.uu.nl/dist/tarballs/lcov-1.4pre-cvs-20041021.tar.gz;
-    md5 = "5150da759b4047b19d026c6ab1216841";
+    url = mirror://sourceforge/ltp/lcov-1.6.tar.gz;
+    sha256 = "0d6lb0vlj3lvqmm678jic9h25q4dnlkbv37wg5yj311hdr9ls1kx";
   };
-  patches = [./lcov.patch];
-  inherit perl;
+
+  patches = [
+    # http://ltp.cvs.sourceforge.net/ltp/utils/analysis/lcov/bin/geninfo?revision=1.33&view=markup&pathrev=HEAD
+    ./string.patch
+  ];
+
+  preBuild = ''
+    makeFlagsArray=(PREFIX=$out BIN_DIR=$out/bin MAN_DIR=$out/share/man)
+  '';
+
+  preInstall = ''
+    substituteInPlace bin/install.sh --replace /bin/bash $shell
+  '';
+
+  postInstall = ''
+    for i in $out/bin/*; do
+      substituteInPlace $i --replace /usr/bin/perl ${perl}/bin/perl
+    done
+  ''; # */
+
+  meta = {
+    description = "A code coverage tool for Linux";
+    homepage = http://ltp.sourceforge.net/coverage/lcov.php;
+  };
+
 }
diff --git a/pkgs/development/tools/analysis/lcov/lcov.patch b/pkgs/development/tools/analysis/lcov/lcov.patch
deleted file mode 100644
index 5dbe5ddc0fd..00000000000
--- a/pkgs/development/tools/analysis/lcov/lcov.patch
+++ /dev/null
@@ -1,169 +0,0 @@
-diff -rc lcov-orig/bin/gendesc lcov-1.1/bin/gendesc
-*** lcov-orig/bin/gendesc	2004-10-22 16:10:55.000000000 +0200
---- lcov-1.1/bin/gendesc	2004-10-22 16:27:52.000000000 +0200
-***************
-*** 1,4 ****
-! #!/usr/bin/perl -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
---- 1,4 ----
-! #! @PERL@ -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
-diff -rc lcov-orig/bin/genhtml lcov-1.1/bin/genhtml
-*** lcov-orig/bin/genhtml	2004-10-22 16:10:55.000000000 +0200
---- lcov-1.1/bin/genhtml	2004-10-22 16:29:40.000000000 +0200
-***************
-*** 1,4 ****
-! #!/usr/bin/perl -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
---- 1,4 ----
-! #! @PERL@ -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
-***************
-*** 200,208 ****
-  {
-  	$config = read_config($ENV{"HOME"}."/.lcovrc");
-  }
-! elsif (-r "/etc/lcovrc")
-  {
-! 	$config = read_config("/etc/lcovrc");
-  }
-  
-  if ($config)
---- 200,208 ----
-  {
-  	$config = read_config($ENV{"HOME"}."/.lcovrc");
-  }
-! elsif (-r "@PREFIX@/etc/lcovrc")
-  {
-! 	$config = read_config("@PREFIX@/etc/lcovrc");
-  }
-  
-  if ($config)
-diff -rc lcov-orig/bin/geninfo lcov-1.1/bin/geninfo
-*** lcov-orig/bin/geninfo	2004-10-22 16:10:56.000000000 +0200
---- lcov-1.1/bin/geninfo	2004-10-22 16:29:40.000000000 +0200
-***************
-*** 1,4 ****
-! #!/usr/bin/perl -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
---- 1,4 ----
-! #! @PERL@ -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
-***************
-*** 124,132 ****
-  {
-  	$config = read_config($ENV{"HOME"}."/.lcovrc");
-  }
-! elsif (-r "/etc/lcovrc")
-  {
-! 	$config = read_config("/etc/lcovrc");
-  }
-  
-  if ($config)
---- 124,132 ----
-  {
-  	$config = read_config($ENV{"HOME"}."/.lcovrc");
-  }
-! elsif (-r "@PREFIX@/etc/lcovrc")
-  {
-! 	$config = read_config("@PREFIX@/etc/lcovrc");
-  }
-  
-  if ($config)
-diff -rc lcov-orig/bin/genpng lcov-1.1/bin/genpng
-*** lcov-orig/bin/genpng	2004-10-22 16:10:56.000000000 +0200
---- lcov-1.1/bin/genpng	2004-10-22 16:28:14.000000000 +0200
-***************
-*** 1,4 ****
-! #!/usr/bin/perl -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
---- 1,4 ----
-! #! @PERL@ -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
-diff -rc lcov-orig/bin/lcov lcov-1.1/bin/lcov
-*** lcov-orig/bin/lcov	2004-10-22 16:10:56.000000000 +0200
---- lcov-1.1/bin/lcov	2004-10-22 16:29:39.000000000 +0200
-***************
-*** 1,4 ****
-! #!/usr/bin/perl -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
---- 1,4 ----
-! #! @PERL@ -w
-  #
-  #   Copyright (c) International Business Machines  Corp., 2002
-  #
-***************
-*** 166,174 ****
-  {
-  	$config = read_config($ENV{"HOME"}."/.lcovrc");
-  }
-! elsif (-r "/etc/lcovrc")
-  {
-! 	$config = read_config("/etc/lcovrc");
-  }
-  
-  if ($config)
---- 166,174 ----
-  {
-  	$config = read_config($ENV{"HOME"}."/.lcovrc");
-  }
-! elsif (-r "@PREFIX@/etc/lcovrc")
-  {
-! 	$config = read_config("@PREFIX@/etc/lcovrc");
-  }
-  
-  if ($config)
-diff -rc lcov-orig/bin/updateversion.pl lcov-1.1/bin/updateversion.pl
-*** lcov-orig/bin/updateversion.pl	2004-10-22 16:10:55.000000000 +0200
---- lcov-1.1/bin/updateversion.pl	2004-10-22 16:28:39.000000000 +0200
-***************
-*** 1,4 ****
-! #!/usr/bin/perl -w
-  #
-  # Update version and date strings in LCOV files
-  #
---- 1,4 ----
-! #! @PERL@ -w
-  #
-  # Update version and date strings in LCOV files
-  #
-diff -rc lcov-orig/Makefile lcov-1.1/Makefile
-*** lcov-orig/Makefile	2004-10-22 16:10:55.000000000 +0200
---- lcov-1.1/Makefile	2004-10-22 16:26:18.000000000 +0200
-***************
-*** 16,23 ****
-  DATE    := $(shell date +%Y-%m-%d)
-  
-  CFG_DIR := $(PREFIX)/etc
-! BIN_DIR := $(PREFIX)/usr/bin
-! MAN_DIR := $(PREFIX)/usr/share/man
-  TMP_DIR := /tmp/lcov-tmp.$(shell echo $$$$)
-  FILES   := $(wildcard bin/*) $(wildcard man/*) README CHANGES Makefile \
-  	   $(wildcard rpm/*)
---- 16,23 ----
-  DATE    := $(shell date +%Y-%m-%d)
-  
-  CFG_DIR := $(PREFIX)/etc
-! BIN_DIR := $(PREFIX)/bin
-! MAN_DIR := $(PREFIX)/share/man
-  TMP_DIR := /tmp/lcov-tmp.$(shell echo $$$$)
-  FILES   := $(wildcard bin/*) $(wildcard man/*) README CHANGES Makefile \
-  	   $(wildcard rpm/*)
diff --git a/pkgs/development/tools/analysis/lcov/string.patch b/pkgs/development/tools/analysis/lcov/string.patch
new file mode 100644
index 00000000000..db753c5dab2
--- /dev/null
+++ b/pkgs/development/tools/analysis/lcov/string.patch
@@ -0,0 +1,10 @@
+--- a/bin/geninfo	2007/10/04 08:18:07	1.32
++++ b/bin/geninfo	2007/11/01 16:29:39	1.33
+@@ -1478,6 +1478,7 @@
+ 					}
+ 					next;
+ 				}
++				last if ($length == 0);
+ 				($blocks, $string) =
+ 					read_gcno_string(*INPUT, $endianness);
+ 				if (defined($string))
diff --git a/pkgs/development/tools/analysis/valgrind/callgrind_annotate.patch b/pkgs/development/tools/analysis/valgrind/callgrind_annotate.patch
new file mode 100644
index 00000000000..7b09ead4510
--- /dev/null
+++ b/pkgs/development/tools/analysis/valgrind/callgrind_annotate.patch
@@ -0,0 +1,8 @@
+--- valgrind-3.3.0/callgrind/callgrind_annotate.in	2007-12-11 00:18:11.000000000 +0100
++++ valgrind-3.3.0/callgrind/callgrind_annotate.in	2008-06-03 23:12:26.000000000 +0200
+@@ -1,4 +1,4 @@
+-#! /usr/bin/perl -w
++#! @PERL@ -w
+ ##--------------------------------------------------------------------##
+ ##--- The cache simulation framework: instrumentation, recording   ---##
+ ##--- and results printing.                                        ---##
diff --git a/pkgs/development/tools/analysis/valgrind/default.nix b/pkgs/development/tools/analysis/valgrind/default.nix
index 7f46228304b..599e9dbd71e 100644
--- a/pkgs/development/tools/analysis/valgrind/default.nix
+++ b/pkgs/development/tools/analysis/valgrind/default.nix
@@ -1,17 +1,34 @@
-{stdenv, fetchurl}:
+{ stdenv, fetchurl, perl, gdb }:
 
 stdenv.mkDerivation {
-  name = "valgrind-3.3.0";
+  name = "valgrind-3.3.1";
+
   src = fetchurl {
-    url = http://valgrind.org/downloads/valgrind-3.3.0.tar.bz2;
-    sha256 = "0yllx5a2f5bx18gqz74aikr27zxwpblswn65lqvm9rbzswlq5w2s";
+    url = http://valgrind.org/downloads/valgrind-3.3.1.tar.bz2;
+    sha256 = "1ymai2xr3c7132vzkngrshlcsrs1qagfd4vwccr96ixx2pcb9dwm";
   };
 
+  patches = [ ./callgrind_annotate.patch ];
+
+  # Perl is needed for `cg_annotate'.
+  # GDB is needed to provide a sane default for `--db-command'.
+  buildInputs = [ perl gdb ];
+
   configureFlags =
     if stdenv.system == "x86_64-linux" then ["--enable-only64bit"] else [];
 
   meta = {
     homepage = http://www.valgrind.org/;
-    description = "Award-winning suite of tools for debugging and profiling Linux programs";
+    description = "Valgrind, a debugging and profiling tool suite";
+
+    longDescription = ''
+      Valgrind is an award-winning instrumentation framework for
+      building dynamic analysis tools.  There are Valgrind tools that
+      can automatically detect many memory management and threading
+      bugs, and profile your programs in detail.  You can also use
+      Valgrind to build new tools.
+    '';
+
+    license = "GPLv2+";
   };
 }
diff --git a/pkgs/development/tools/build-managers/apache-ant/ant-contrib.nix b/pkgs/development/tools/build-managers/apache-ant/ant-contrib.nix
new file mode 100644
index 00000000000..ca61f43c738
--- /dev/null
+++ b/pkgs/development/tools/build-managers/apache-ant/ant-contrib.nix
@@ -0,0 +1,17 @@
+args: with args;
+
+stdenv.mkDerivation {
+  name = "ant-contrib-1.0b3";
+
+  installPhase = ''
+    mkdir -p $out
+    mv ant-contrib*.jar $out/
+  '';
+
+  phases = "unpackPhase installPhase";
+
+  src = fetchurl {
+    url = mirror://sourceforge/ant-contrib/ant-contrib-1.0b3-bin.tar.bz2;
+    sha256 = "96effcca2581c1ab42a4828c770b48d54852edf9e71cefc9ed2ffd6590571ad1";
+  };
+}
diff --git a/pkgs/development/tools/build-managers/apache-ant/builder.sh b/pkgs/development/tools/build-managers/apache-ant/builder.sh
index 42d5e67d154..068925b4755 100644
--- a/pkgs/development/tools/build-managers/apache-ant/builder.sh
+++ b/pkgs/development/tools/build-managers/apache-ant/builder.sh
@@ -1,21 +1,53 @@
 source $stdenv/setup
 
-mkdir -p $out/bin
+tar jxf $src || exit 1
+mkdir -p $out
+
+mv apache-ant-*/* $out || exit 1
+
+# add ant-contrib
+cp $antContrib/*.jar $out/lib
+
+# remove crap in the root directory
+
+for file in $out/*
+do
+  if test -f $file ; then
+    rm $file
+  fi
+done
+rm -rf $out/docs
+
+# prevent the use of hacky scripts. This will be handled in Nix.
+rm $out/bin/* || exit 1
+
+# add ant script. This script is to be invoked with all
+# appropiate variables and will try to be clever or user-friendly.
 
 cat >> $out/bin/ant <<EOF
 #! /bin/sh
 
 export JAVA_HOME=$jdk
 export JAVACMD=$jdk/bin/java
-export ANT_OPTS=""
-export ANT_ARGS=""
 export LANG="en_US"
 
-$ant/bin/core-ant \$@
+export ANT_HOME=$out
+ 
+if [ -z "\$LOCALCLASSPATH" ] ; then
+    LOCALCLASSPATH=\$ANT_HOME/lib/ant-launcher.jar
+else
+    LOCALCLASSPATH=\$ANT_HOME/lib/ant-launcher.jar:\$LOCALCLASSPATH
+fi
+
+if [ -n "\$JIKESPATH" ]; then
+  exec "\$JAVACMD" \$NIX_ANT_OPTS \$ANT_OPTS -classpath "\$LOCALCLASSPATH" -Dant.home="\${ANT_HOME}" -Djikes.class.path="\$JIKESPATH" org.apache.tools.ant.launch.Launcher \$ANT_ARGS -lib "$CLASSPATH" "\$@"
+else
+  exec "\$JAVACMD" \$NIX_ANT_OPTS \$ANT_OPTS -classpath "\$LOCALCLASSPATH" -Dant.home="\${ANT_HOME}" org.apache.tools.ant.launch.Launcher \$ANT_ARGS -lib "$CLASSPATH" "\$@"
+  fi
+fi
 EOF
 
 chmod a+x $out/bin/ant
 
-ln -s $ant/lib $ant/etc $out/
-
+ln -s $out/bin/ant $out/bin/antRun
 
diff --git a/pkgs/development/tools/build-managers/apache-ant/default.nix b/pkgs/development/tools/build-managers/apache-ant/default.nix
index 2532db69f97..a9e35d5d70b 100644
--- a/pkgs/development/tools/build-managers/apache-ant/default.nix
+++ b/pkgs/development/tools/build-managers/apache-ant/default.nix
@@ -1,16 +1,23 @@
-{stdenv, fetchurl, jdk, name}:
+{fetchurl, stdenv, jdk, name}:
 
 let {
   body =
     stdenv.mkDerivation {
       name = name;
+
       builder = ./builder.sh;
-      buildInputs = [ant jdk];
-      inherit ant jdk;
+      buildInputs = [antContrib jdk];
+
+      inherit antContrib jdk;
+
+      src = fetchurl {
+        url = http://apache.surfnet.nl/ant/binaries/apache-ant-1.6.5-bin.tar.bz2;
+        md5 = "26031ee1a2fd248ad0cc2e7f17c44c39";
+      };
     };
 
-  ant =
-    (import ./core-apache-ant.nix) {
+  antContrib =
+    (import ./ant-contrib.nix) {
       inherit fetchurl stdenv;
     };
 }
diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix
index 45311ee0e3c..8b8e2f976e0 100644
--- a/pkgs/development/tools/build-managers/cmake/default.nix
+++ b/pkgs/development/tools/build-managers/cmake/default.nix
@@ -1,11 +1,10 @@
 args: with args;
 stdenv.mkDerivation {
-  name = "cmake-2.4.7";
+  name = "cmake-2.6.0";
   setupHook = ./setup-hook.sh;
 
-  src = fetchurl {
-    url = http://www.cmake.org/files/v2.4/cmake-2.4.7.tar.gz;
-    sha256 = "0mkx23s7zq48hzzzw3vbzsfzfz3rjsiwgf3i00xawcxrjjrgxm9g";
+  src = fetchurl { url=http://www.cmake.org/files/v2.6/cmake-2.6.0.tar.gz;
+                   sha256 = "09qgk5gk0pnihzf2mmqz5cayd64y5viic8x78x4czrh4982x76a9";
   };
 
   propagatedBuildInputs = [replace];
diff --git a/pkgs/development/tools/guile/g-wrap/default.nix b/pkgs/development/tools/guile/g-wrap/default.nix
new file mode 100644
index 00000000000..01a1dbe72eb
--- /dev/null
+++ b/pkgs/development/tools/guile/g-wrap/default.nix
@@ -0,0 +1,36 @@
+{ fetchurl, stdenv, guile, libffi, pkgconfig, glib
+, guileLib }:
+
+stdenv.mkDerivation rec {
+  name = "g-wrap-1.9.11";
+  src = fetchurl {
+    url = "mirror://savannah/g-wrap/${name}.tar.gz";
+    sha256 = "1j8zchilsr0dziyr21az4x3xxyr4d3jc8nybag9rp6pjj8k49adn";
+  };
+
+  # Note: Glib support is optional, but it's quite useful (e.g., it's
+  # used by Guile-GNOME).  Guile-Library is needed by the test suite.
+  buildInputs = [ guile libffi pkgconfig glib guileLib ];
+
+  # GMP 4.2.2 uses GNU "extern inline".  With GCC 4.2 in C99 mode,
+  # this yields warnings such as:
+  #
+  #  gmp.h:1606: warning: C99 inline functions are not supported; using GNU89
+  #
+  # Since G-Wrap builds in C99 mode and with `-Werror', we need to
+  # pass it `-fgnu89-inline'.
+  CFLAGS = "-fgnu89-inline";
+
+  doCheck = true;
+
+  meta = {
+    description = "G-Wrap, a wrapper generator for Guile";
+    longDescription = ''
+      G-Wrap is a tool (and Guile library) for generating function
+      wrappers for inter-language calls.  It currently only supports
+      generating Guile wrappers for C functions.
+    '';
+    homepage = http://www.nongnu.org/g-wrap/;
+    license = "LGPLv2+";
+  };
+}
diff --git a/pkgs/development/tools/guile/guile-lint/default.nix b/pkgs/development/tools/guile/guile-lint/default.nix
index f9032dd4884..d2e4f7c2510 100644
--- a/pkgs/development/tools/guile/guile-lint/default.nix
+++ b/pkgs/development/tools/guile/guile-lint/default.nix
@@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
     mv ,,tmp guile-lint.in
   '';
 
+  doCheck = true;
+
   meta = {
     description = ''Guile-Lint checks syntax and semantics in a
                     Guile program or module.'';
diff --git a/pkgs/development/tools/haskell/uuagc/default.nix b/pkgs/development/tools/haskell/uuagc/default.nix
index b45db5f2ea6..a5b276f9e1e 100644
--- a/pkgs/development/tools/haskell/uuagc/default.nix
+++ b/pkgs/development/tools/haskell/uuagc/default.nix
@@ -2,9 +2,9 @@
 
 cabal.mkDerivation (self : {
   pname = "uuagc";
-  version = "0.9.5";
+  version = "0.9.6";
   name = self.fname;
-  sha256 = "c5be435efa609f72c09e175dd5cf7835a060bd7eaf6634ec4cde72ea84b99f25";
+  sha256 = "10e148bdf052e9a80e52c54a94314df9d1772e68416e5dfac289c47fd1ba8558";
   extraBuildInputs = [uulib];
   meta = {
     description = "Attribute Grammar System of Universiteit Utrecht";
diff --git a/pkgs/development/tools/misc/cproto/cproto_patch b/pkgs/development/tools/misc/cproto/cproto_patch
new file mode 100644
index 00000000000..3743fef977b
--- /dev/null
+++ b/pkgs/development/tools/misc/cproto/cproto_patch
@@ -0,0 +1,11 @@
+diff -Naur cproto-4.6-old/cproto.h cproto-4.6/cproto.h
+--- cproto-4.6-old/cproto.h	1998-01-18 19:49:16.000000000 -0500
++++ cproto-4.6/cproto.h	2004-03-14 00:02:32.148070032 -0500
+@@ -117,6 +117,7 @@
+     Declarator *declarator;
+     DeclaratorList decl_list;
+ } YYSTYPE;
++#define YYSTYPE_IS_DECLARED 1
+ 
+ /* Prototype styles */
+ #if OPT_LINTLIBRARY
diff --git a/pkgs/development/tools/misc/cproto/default.nix b/pkgs/development/tools/misc/cproto/default.nix
new file mode 100644
index 00000000000..dd2856975bd
--- /dev/null
+++ b/pkgs/development/tools/misc/cproto/default.nix
@@ -0,0 +1,20 @@
+args:
+args.stdenv.mkDerivation {
+  name = "cproto-4.6";
+
+  src = args.fetchurl {
+    url = mirror://sourceforge/cproto/cproto-4.6.tar.gz;
+    sha256 = "0ilhkx9iwc5bh65q47mf68p39iyk07d52fv00z431nl6qcb9hp9j";
+  };
+
+  buildInputs =(with args; [flex bison]);
+
+  # patch made by Joe Khoobyar copied from gentoo bugs
+  patches= ./cproto_patch ;
+
+  meta = { 
+      description = "generate C function prototypes from C source code";
+      homepage = http://cproto.sourceforge.net/;
+      license = "public domain";
+  };
+}
diff --git a/pkgs/development/tools/misc/ctags/default.nix b/pkgs/development/tools/misc/ctags/default.nix
index 2d23436a2ad..bddb55b035d 100644
--- a/pkgs/development/tools/misc/ctags/default.nix
+++ b/pkgs/development/tools/misc/ctags/default.nix
@@ -1,9 +1,26 @@
 {stdenv, fetchurl}:
 
-stdenv.mkDerivation {
-  name = "ctags-5.5.4";
+stdenv.mkDerivation rec {
+  name = "ctags-5.7";
   src = fetchurl {
-    url = mirror://sourceforge/ctags/ctags-5.5.4.tar.gz;
-    md5 = "a84124caadd4103270e0b84596ecfe83";
+    url = "mirror://sourceforge/ctags/${name}.tar.gz";
+    sha256 = "10623bbcc9b0cb60124271ce83111733a1043ab022d51cfcd2c0e0c953bd8b58";
+  };
+
+  meta = {
+    description = "Exuberant Ctags, a tool for fast source code browsing";
+
+    longDescription = ''
+      Ctags generates an index (or tag) file of language objects found
+      in source files that allows these items to be quickly and easily
+      located by a text editor or other utility.  A tag signifies a
+      language object for which an index entry is available (or,
+      alternatively, the index entry created for that object).  Many
+      programming languages are supported.
+    '';
+
+    homepage = http://ctags.sourceforge.net/;
+
+    license = "GPLv2+";
   };
 }
diff --git a/pkgs/development/tools/misc/dejagnu/default.nix b/pkgs/development/tools/misc/dejagnu/default.nix
new file mode 100644
index 00000000000..0c7cad6424a
--- /dev/null
+++ b/pkgs/development/tools/misc/dejagnu/default.nix
@@ -0,0 +1,37 @@
+{ fetchurl, stdenv, expect, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "dejagnu-1.4.4";
+
+  src = fetchurl {
+    url = "mirror://gnu/dejagnu/${name}.tar.gz";
+    sha256 = "13841q6pfwd9d1sdw48yxdyb4xhiccii0mb0ilql627v43pyvyyh";
+  };
+
+  buildInputs = [ expect makeWrapper ];
+
+  doCheck = true;
+
+  postInstall = ''
+    wrapProgram "$out/bin/runtest" \
+                --prefix PATH ":" "${expect}/bin"
+  '';
+
+  meta = {
+    description = "The DejaGNU testing framework";
+    
+    longDescription = ''
+      DejaGnu is a framework for testing other programs.  Its purpose
+      is to provide a single front end for all tests.  Think of it as a
+      custom library of Tcl procedures crafted to support writing a
+      test harness.  A test harness is the testing infrastructure that
+      is created to support a specific program or tool.  Each program
+      can have multiple testsuites, all supported by a single test
+      harness.  DejaGnu is written in Expect, which in turn uses Tcl --
+      Tool command language.
+    '';
+
+    homepage = http://www.gnu.org/software/dejagnu/;
+    license = "GPLv2+";
+  };
+}
diff --git a/pkgs/development/tools/misc/hasktags/default.nix b/pkgs/development/tools/misc/hasktags/default.nix
index 613d028948f..a9cb8cef14b 100644
--- a/pkgs/development/tools/misc/hasktags/default.nix
+++ b/pkgs/development/tools/misc/hasktags/default.nix
@@ -4,7 +4,7 @@ args.stdenv.mkDerivation {
 
   src = args.fetchurl {
     url = http://mawercer.de/hasktags.hs;
-    sha256 = "112k97g6mgvwa0a9zrq840mqxxw55cn422h1c134xb0fl29llig7";
+    sha256 = "1dpf91s8k5gnykdhp6y94gimbh7z58156f5d8y918wxmj08gbb8g";
   };
 
   buildInputs =(with args; [ghc]);
diff --git a/pkgs/development/tools/misc/hsc2hs/default.nix b/pkgs/development/tools/misc/hsc2hs/default.nix
new file mode 100644
index 00000000000..cfa9e3b56f6
--- /dev/null
+++ b/pkgs/development/tools/misc/hsc2hs/default.nix
@@ -0,0 +1,26 @@
+#TODO write a function (abstraction)
+args: with args;
+args.stdenv.mkDerivation {
+  name = "hsc2hs-darcs";
+
+  src = bleedingEdgeRepos.sourceByName "hsc2hs";
+
+  phases = "unpackPhase buildPhase";
+
+  buildPhase  = ''
+    ghc --make Setup.*hs -o setup
+    ensureDir \out
+     nix_ghc_pkg_tool join local-pkg-db
+    ./setup configure --prefix=$out --package-db=local-pkg-db
+    ./setup build
+    ./setup install
+  '';
+
+  buildInputs = (with args; [ghc] ++ libs);
+
+  meta = {
+      description = "automate some parts of the process of writing Haskell bindings to C code";
+      homepage = http://www.flapjax-lang.org/;
+      license = "BSD3";
+  };
+}
diff --git a/pkgs/development/tools/misc/pmccabe/default.nix b/pkgs/development/tools/misc/pmccabe/default.nix
new file mode 100644
index 00000000000..10cf371f13a
--- /dev/null
+++ b/pkgs/development/tools/misc/pmccabe/default.nix
@@ -0,0 +1,36 @@
+{ fetchurl, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "pmccabe-2.4-CVS20070814";
+
+  src = fetchurl {
+    url = "http://cvs.parisc-linux.org/download/${name}.tar.gz";
+    sha256 = "0nqvfdf2cxx516nw0rwr3lhzhiyrnpc2jf45ldfwsdc9rm2nj3r9";
+  };
+
+  configurePhase = ''
+    sed -i "Makefile"							\
+        -"es|^[[:blank:]]*DESTDIR[[:blank:]]*=.*$|DESTDIR = $out|g ;	\
+	   s|^[[:blank:]]*INSTALL[[:blank:]]*=.*$|INSTALL = install|g ;	\
+	   s|/usr/|/|g"
+  '';
+
+  meta = {
+    description = "McCabe-style function complexity and line counting for C and C++";
+    homepage = http://www.parisc-linux.org/~bame/pmccabe/;
+    license = "GPLv2+";
+
+    longDescription = ''
+      pmccabe calculates McCabe-style cyclomatic complexity for C and
+      C++ source code.  Per-function complexity may be used for
+      spotting likely trouble spots and for estimating testing
+      effort.
+
+      pmccabe also includes a non-commented line counter, decomment which
+      only removes comments from source code; codechanges, a program to
+      calculate the amount of change which has occurred between two source
+      trees or files; and vifn, to invoke vi given a function name rather
+      than a file name.
+    '';
+  };
+}
diff --git a/pkgs/development/tools/misc/xxdiff/3.2.nix b/pkgs/development/tools/misc/xxdiff/3.2.nix
new file mode 100644
index 00000000000..63d718b9d9a
--- /dev/null
+++ b/pkgs/development/tools/misc/xxdiff/3.2.nix
@@ -0,0 +1,37 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/xxdiff/xxdiff-3.2.tar.bz2;
+    sha256 = "1f5j9l9n5j2ab0h3iwaz0mnz0y8h7ilc0dbcrfmaibk2njx38mcn";
+  };
+
+  buildInputs = [qt flex bison python pkgconfig makeWrapper 
+    libX11 libXext];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["prepareMainBuild"
+    "deploy"
+    "installPythonPackage" 
+    (makeManyWrappers 
+      ''$out/bin/*'' 
+      ''--prefix PYTHONPATH : $(toPythonPath $out):$PYTHONPATH'')
+  ];
+
+  prepareMainBuild = FullDepEntry (''
+    cd src 
+    export QTDIR=${qt}/
+    make -f Makefile.bootstrap makefile
+  '') ["minInit" "doUnpack"];
+
+  deploy = FullDepEntry (''
+    ensureDir $out/bin/
+    cp ../bin/xxdiff $out/bin
+    cd ..
+  '') ["minInit" "doMake" "defEnsureDir" "addInputs"];
+      
+  name = "xxdiff" + version;
+  meta = {
+    description = "Interactive merge tool";
+  };
+}
diff --git a/pkgs/development/tools/parsing/flex/flex-2.5.35.nix b/pkgs/development/tools/parsing/flex/flex-2.5.35.nix
new file mode 100644
index 00000000000..c200e4e7d2f
--- /dev/null
+++ b/pkgs/development/tools/parsing/flex/flex-2.5.35.nix
@@ -0,0 +1,19 @@
+# This should be moved to default.nix eventually (?)
+
+{stdenv, fetchurl, yacc, m4}:
+
+assert yacc != null && m4 != null;
+
+stdenv.mkDerivation {
+  name = "flex-2.5.35";
+  src = fetchurl {
+    url = mirror://sourceforge/flex/flex-2.5.35.tar.bz2;
+    sha256 = "0ysff249mwhq0053bw3hxh58djc0gy7vjan2z1krrf9n5d5vvv0b";
+  };
+  buildInputs = [yacc];
+  propagatedBuildInputs = [m4];
+
+  meta = {
+    description = "A fast lexical analyser generator";
+  };
+}
diff --git a/pkgs/development/tools/profiling/oprofile/default.nix b/pkgs/development/tools/profiling/oprofile/default.nix
new file mode 100644
index 00000000000..ca44470598f
--- /dev/null
+++ b/pkgs/development/tools/profiling/oprofile/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, binutils, popt
+, makeWrapper, gawk, which, gnugrep }:
+
+stdenv.mkDerivation rec {
+  name = "oprofile-0.9.3";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/oprofile/${name}.tar.gz";
+    sha256 = "1jxj8h11rwaviy5dz2ra7q41qfgdl1psc4470327pk5bblbap1jg";
+  };
+
+  patches = [ ./opcontrol.patch ];
+
+  # FIXME: Add optional Qt support.
+  buildInputs = [ binutils popt makeWrapper gawk which gnugrep ];
+
+  configureFlags = "--with-kernel-support";
+
+  postInstall = ''
+    wrapProgram "$out/bin/opcontrol"					\
+       --prefix PATH : "${gawk}/bin:${which}/bin:${gnugrep}/bin"
+  '';
+
+  meta = {
+    description = "Oprofile, a system-wide profiler for Linux";
+    longDescription = ''
+      OProfile is a system-wide profiler for Linux systems, capable of
+      profiling all running code at low overhead.  It consists of a
+      kernel driver and a daemon for collecting sample data, and
+      several post-profiling tools for turning data into information.
+
+      OProfile leverages the hardware performance counters of the CPU
+      to enable profiling of a wide variety of interesting statistics,
+      which can also be used for basic time-spent profiling. All code
+      is profiled: hardware and software interrupt handlers, kernel
+      modules, the kernel, shared libraries, and applications.
+    '';
+    license = "GPLv2";
+    homepage = http://oprofile.sourceforge.net/;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/development/tools/profiling/oprofile/opcontrol.patch b/pkgs/development/tools/profiling/oprofile/opcontrol.patch
new file mode 100644
index 00000000000..fa072c738ff
--- /dev/null
+++ b/pkgs/development/tools/profiling/oprofile/opcontrol.patch
@@ -0,0 +1,16 @@
+--- oprofile-0.9.3/utils/opcontrol	2007-07-16 20:22:17.000000000 +0200
++++ oprofile-0.9.3/utils/opcontrol	2008-06-04 23:05:20.000000000 +0200
+@@ -1647,12 +1647,10 @@ check_version()
+ 
+ # determine the location of opcontrol and related programs
+ if test -z "$OPDIR"; then
+-	BINDIR="/usr/bin"
+-	OPCONTROL=`$BINDIR/which $0`
+-	OPDIR=`$BINDIR/dirname $OPCONTROL`
++	OPCONTROL=`which $0`
++	OPDIR=`dirname $OPCONTROL`
+ fi
+ 
+-PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
+ 
+ check_options_early $@
diff --git a/pkgs/development/tools/profiling/sysprof/configure.patch b/pkgs/development/tools/profiling/sysprof/configure.patch
new file mode 100644
index 00000000000..212840ee406
--- /dev/null
+++ b/pkgs/development/tools/profiling/sysprof/configure.patch
@@ -0,0 +1,17 @@
+--- sysprof-1.0.10/configure	2008-04-28 01:41:25.000000000 +0200
++++ sysprof-1.0.10/configure	2008-06-07 15:40:07.000000000 +0200
+@@ -3342,14 +3342,6 @@ if test $kernel_module = "yes"; then
+      echo \*
+      exit 1
+   fi
+-
+-  if  ! test -f /lib/modules/`uname -r`/build/Makefile  ; then
+-     echo \*
+-     echo \* Sysprof requires the kernel source code to be installed.
+-     echo \* On a Fedora Core system the relevant package is kernel-devel
+-     echo \*
+-     exit 1
+-  fi
+ fi
+ 
+ # Pkgconfig dependencies
diff --git a/pkgs/development/tools/profiling/sysprof/default.nix b/pkgs/development/tools/profiling/sysprof/default.nix
new file mode 100644
index 00000000000..397a6033d62
--- /dev/null
+++ b/pkgs/development/tools/profiling/sysprof/default.nix
@@ -0,0 +1,47 @@
+{ fetchurl, stdenv, kernel, binutils
+, pkgconfig, gtk, glib, pango, libglade }:
+
+stdenv.mkDerivation rec {
+  name = "sysprof-1.0.10";
+
+  src = fetchurl {
+    url = "http://www.daimi.au.dk/~sandmann/sysprof/${name}.tar.gz";
+    sha256 = "1cdjnymd9nz72vcw6j0bbhb2ka19rjqd3scgx810a4m3qcai7irs";
+  };
+
+  buildInputs = [ binutils pkgconfig gtk glib pango libglade ];
+
+  patches = [ ./configure.patch ];
+
+  preConfigure = ''
+    kernelVersion=$(cd "${kernel}/lib/modules" && echo *)
+    echo "assuming Linux kernel version \`$kernelVersion'"
+
+    sed -i "module/Makefile" \
+        -e"s|^[[:blank:]]*KDIR[[:blank:]]*:=.*$|KDIR := ${kernel}/lib/modules/$kernelVersion/build|g ;
+	   s|\$(KMAKE) modules_install|install sysprof-module.ko $out/share/sysprof/module|g ;
+	   s|\\[ -e /sbin/depmod.*$|true|g"
+
+    # XXX: We won't run `depmod' after installing the module.
+  '';
+
+  configureFlags = "--enable-kernel-module";
+
+  preInstall = ''
+    mkdir -p "$out/share/sysprof/module"
+  '';
+
+  meta = {
+    homepage = http://www.daimi.au.dk/~sandmann/sysprof/;
+    description = "Sysprof, a system-wide profiler for Linux";
+    license = "GPLv2+";
+
+    longDescription = ''
+      Sysprof is a sampling CPU profiler for Linux that uses a kernel
+      module to profile the entire system, not just a single
+      application.  Sysprof handles shared libraries and applications
+      do not need to be recompiled.  In fact they don't even have to
+      be restarted.
+    '';
+  };
+}
\ No newline at end of file
diff --git a/pkgs/games/openttd/default.nix b/pkgs/games/openttd/default.nix
new file mode 100644
index 00000000000..66c296b487a
--- /dev/null
+++ b/pkgs/games/openttd/default.nix
@@ -0,0 +1,22 @@
+{stdenv, fetchurl, SDL, libpng, zlib}:
+
+stdenv.mkDerivation rec {
+  name = "openttd-${version}";
+  version = "0.6.0";
+
+  src = fetchurl {
+    url = "mirror://sf/openttd/${name}-source.tar.bz2";
+    md5 = "dcf63687c73ff56887049fedaf6c6019";
+  };
+
+  buildInputs = [SDL libpng];
+  prefixKey = "--prefix-dir=";
+  configureFlags = "--with-zlib=${zlib}/lib/libz.a";
+  makeFlags = "INSTALL_PERSONAL_DIR=";
+
+  meta = {
+    description = ''OpenTTD is an open source clone of the Microprose game "Transport Tycoon Deluxe".'';
+    homepage = http://www.openttd.org/;
+    license = "GPLv2";
+  };
+}
diff --git a/pkgs/games/wesnoth/default.nix b/pkgs/games/wesnoth/default.nix
index 2e132dd8889..65c6002091e 100644
--- a/pkgs/games/wesnoth/default.nix
+++ b/pkgs/games/wesnoth/default.nix
@@ -1,13 +1,13 @@
 args: with args;
 stdenv.mkDerivation (rec {
   pname = "wesnoth";
-  version = "1.3.18";
+  version = "1.4.1";
 
   name = "${pname}-${version}";
 
   src = fetchurl {
     url = "http://surfnet.dl.sourceforge.net/sourceforge/${pname}/${name}.tar.bz2";
-    sha256 = "ab2ed2cbe1daa134c453927bf0ec5d3a36f3319063b6f18c35819871f386da75";
+    sha256 = "c5b7b478553dc8994d99024e14b48b3f64e2c328631bd5b05904509b499fa68c";
   };
 
   buildInputs = [SDL SDL_image SDL_mixer SDL_net gettext zlib boost freetype];
diff --git a/pkgs/lib/annotatedDerivations.nix b/pkgs/lib/annotatedDerivations.nix
deleted file mode 100644
index eca97747cd8..00000000000
--- a/pkgs/lib/annotatedDerivations.nix
+++ /dev/null
@@ -1,56 +0,0 @@
-{ lib } : with lib; with builtins; rec {
-  /*
-  # traversal proposal (very unstable now )
-  # goal: create tags easily (and install source files along without recompiling)
-
-  rec {
-    # encouraged: using it you can filter based on names later on? Do we ned it?
-    name = 
-
-    # required: the annotated derivation (this attr is used to identify a
-    # annotated derivation)
-    aDeriv =
-
-    # required: extra list of annotated dependencies, so we can traverse the tree
-    aDeps = <annotated deps>
-
-    # your annotation derivations 
-  };
-  */
-
-  isAnnotated = a : (a ? aDeriv); # this function serves documentation purposes 
-
-  delAnnotation = a :
-    if ((__isAttrs a) && (isAnnotated a)) then  a.aDeriv
-    else a; # most probalby a derivation without annotations.
-
-  # returns buildInputs and propagatedBuildInputs from given set after removing annotations
-  delAnnotationsFromInputs = attrs :
-    subsetmap (map delAnnotation) attrs [ "buildInputs" "propagatedBuildInputs" ];
-
-  /* so an annotated drivation function might look like this
-  args: with args;
-    let aDeps = filterDeps args;
-        deps = delAnnotation aDeps;
-    in rec {
-      name = "my-package-0.2";
-      inherit aDeps;
-
-      aDeriv = stdenv.mkDerivation {
-        inherit name;
-        buildInputs = deps;
-      };
-    };
-
-  */
-
-  filterAnnotated = lib.filter isAnnotated;
-
-  # stops when depthCounter = 0 
-  traverseByDepthCounter = depthCounter : aAttrs :
-    if (depthCounter == 0) then []
-    else [ aAttrs ] ++ map (traverseByDepthCounter (__sub depthCounter 1) ) (filterAnnotated aAttrs.aDeps);
-
-  # get all deps recursively
-  uniqAnnotatedDeps = aAttrs : uniqList { inputList = traverseByDepthCounter 10 aAttrs; };
-}
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix
index 1df45f96f37..2c8e29cc04b 100644
--- a/pkgs/lib/default.nix
+++ b/pkgs/lib/default.nix
@@ -23,6 +23,15 @@ rec {
 	else (innerSumArgs f (x // y)));
   sumArgs = f : innerSumArgs f {};
 
+  # Advanced sumArgs version. Hm, twice as slow, I'm afraid.
+  # composedArgs id (x:x//{a="b";}) (x:x//{b=x.a + "c";}) null;
+  # {a="b" ; b="bc";};
+  innerComposedArgs = f : x : y : (if y==null then (f x)
+  	else (if (builtins.isAttrs y) then 
+		(innerComposedArgs f (x//y))
+	else (innerComposedArgs f (y x))));
+  composedArgs = f: innerComposedArgs f {};
+
   # example a = pairMap (x : y : x + y) ["a" "b" "c" "d"];
   # result: ["ab" "cd"]
   innerPairMap = acc: f: l: 
@@ -194,6 +203,7 @@ rec {
   # Return a list or an empty list, dependening on a boolean value.
   optionals = cond: elems: if cond then elems else [];
 
+  optionalString = cond: string: if cond then string else "";
 
   # Return a list of integers from `first' up to and including `last'.
   range = first: last:
@@ -333,6 +343,7 @@ rec {
           if (x ? outPath) then "x is a derivation with name ${x.name}"
           else "x is an attr set with attributes ${builtins.toString (__attrNames x)}"
       else if (__isFunction x) then "x is a function"
+      else if (x == []) then "x is an empty list"
       else if (__isList x) then "x is a list, first item is : ${whatis (__head x)}"
       else if (x == true || x == false) then builtins.toString x
       else "x is probably a string starting, starting characters: ${__substring 0 50 x}..";
@@ -359,6 +370,10 @@ rec {
   # calls a function (f attr value ) for each record item. returns a list
   mapRecordFlatten = f : r : map (attr: f attr (builtins.getAttr attr r) ) (attrNames r);
 
+  # maps a function on each attr value
+  # f = name : attrValue : ..
+  mapAttrs = f : r : listToAttrs ( mapRecordFlatten (n : a : nv n ( f n a ) )  r);
+
   # to be used with listToAttrs (_a_ttribute _v_alue)
   nv = name : value : { inherit name value; };
   # attribute set containing one attribute
@@ -384,6 +399,25 @@ rec {
   # eg { a = 7; } {  a = [ 2 3 ]; } becomes { a = [ 7 2 3 ]; }
   mergeAttrsConcatenateValues = mergeAttrsWithFunc ( a : b : (toList a) ++ (toList b) );
 
+  # merges attributes using //, if a name exisits in both attributes
+  # an error will be triggered unless its listed in mergeLists
+  # so you can mergeAttrsNoOverride { buildInputs = [a]; } { buildInputs = [a]; } {} to get
+  # { buildInputs = [a b]; }
+  # merging buildPhase does'nt really make sense. The cases will be rare where appending /prefixing will fit your needs?
+  # in these cases the first buildPhase will override the second one
+  mergeAttrsNoOverride = { mergeLists ? ["buildInputs" "propagatedBuildInputs"],
+                           overrideSnd ? [ "buildPhase" ]
+                         } : attrs1 : attrs2 :
+    fold (n: set : 
+        setAttr set n ( if (__hasAttr n set) 
+            then # merge 
+              if elem n mergeLists # attribute contains list, merge them by concatenating
+                then (__getAttr n attrs2) ++ (__getAttr n attrs1)
+              else if elem n overrideSnd
+                then __getAttr n attrs1
+              else throw "error mergeAttrsNoOverride, attribute ${n} given in both attributes - no merge func defined"
+            else __getAttr n attrs2 # add attribute not existing in attr1
+           )) attrs1 (__attrNames attrs2);
   # returns atribute values as a list 
   flattenAttrs = set : map ( attr : builtins.getAttr attr set) (attrNames set);
   mapIf = cond : f :  fold ( x : l : if (cond x) then [(f x)] ++ l else l) [];
diff --git a/pkgs/misc/bleeding-edge-fetch-info/cabal.nix b/pkgs/misc/bleeding-edge-fetch-info/cabal.nix
new file mode 100644
index 00000000000..e3d8ad5df33
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/cabal.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/cabal.tar.gz;
+  sha256 = "33bdbe8f0c213dcc28da88a2775f81f72e89209806e26b412699220c3db206ec";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/getOptions.nix b/pkgs/misc/bleeding-edge-fetch-info/getOptions.nix
new file mode 100644
index 00000000000..a4a7c360e9b
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/getOptions.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/getOptions.tar.gz;
+  sha256 = "6475f2e5762cee2b8544d051c2b831ed5bd22a5711eca86fd6e0f0e95ac8b8b0";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/ghc_lambdavm.nix b/pkgs/misc/bleeding-edge-fetch-info/ghc_lambdavm.nix
new file mode 100644
index 00000000000..e7ec6393170
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/ghc_lambdavm.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/ghc_lambdavm.tar.gz;
+  sha256 = "3d10e839b8226987383e870258ff38b56442ff254688f7c50983850676f992cb";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/happs_data.nix b/pkgs/misc/bleeding-edge-fetch-info/happs_data.nix
new file mode 100644
index 00000000000..964e8b4f5b5
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/happs_data.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/happs_data.tar.gz;
+  sha256 = "26aec1571b1c1e69bf5a79fa6b3346e7493e3a4e00efe4c23a57b04e35e8d5a3";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/happs_ixset.nix b/pkgs/misc/bleeding-edge-fetch-info/happs_ixset.nix
new file mode 100644
index 00000000000..5d4a4be4f16
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/happs_ixset.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/happs_ixset.tar.gz;
+  sha256 = "80c857775cccdff49c55f28be069b53e14653b2812808ef9b4456aa500431241";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/happs_plugins.nix b/pkgs/misc/bleeding-edge-fetch-info/happs_plugins.nix
new file mode 100644
index 00000000000..fc285b94b77
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/happs_plugins.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/happs_plugins.tar.gz;
+  sha256 = "ff4ec49f4fcfb835a92ef9ec12ef7d1644d21318ca32a064ba8b72ea083bc103";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/happs_server.nix b/pkgs/misc/bleeding-edge-fetch-info/happs_server.nix
new file mode 100644
index 00000000000..00a98a3ae4a
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/happs_server.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/happs_server.tar.gz;
+  sha256 = "76dbb45796c8795f93df39ea3a87cd9028eb4fcdbea1e3c611596298dbbc0f69";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/happs_state.nix b/pkgs/misc/bleeding-edge-fetch-info/happs_state.nix
new file mode 100644
index 00000000000..188135c14f0
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/happs_state.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/happs_state.tar.gz;
+  sha256 = "d59f13b2cdcfbf412be0ee973c3824c2035b55c613f293ae98894dc8bd9de9f2";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/happs_util.nix b/pkgs/misc/bleeding-edge-fetch-info/happs_util.nix
new file mode 100644
index 00000000000..5ceb76e6db5
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/happs_util.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/happs_util.tar.gz;
+  sha256 = "c5c5b363c79bba39ab7c30a6e7371fec9401e26dea4be82be1e4777acab5b965";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/haskellnet.nix b/pkgs/misc/bleeding-edge-fetch-info/haskellnet.nix
new file mode 100644
index 00000000000..b5102f6d04d
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/haskellnet.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/haskellnet.tar.gz;
+  sha256 = "fde6f79b09d6cfbc6021aed9fa54ed186715a6eaacd4634f07554d4d3777f70d";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/hsc2hs.nix b/pkgs/misc/bleeding-edge-fetch-info/hsc2hs.nix
new file mode 100644
index 00000000000..8d0bdea1a9a
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/hsc2hs.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/hsc2hs.tar.gz;
+  sha256 = "3179eba85e56f30250793dbb612ffb8ad869e37297a185c2e0fb29134afb73af";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/hsjava.nix b/pkgs/misc/bleeding-edge-fetch-info/hsjava.nix
new file mode 100644
index 00000000000..b275c6bc1a1
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/hsjava.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/hsjava.tar.gz;
+  sha256 = "952839e53f63fc43c7c8a760bab97d150c504e148ebdd407be5e642661ed048f";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/hsql.nix b/pkgs/misc/bleeding-edge-fetch-info/hsql.nix
new file mode 100644
index 00000000000..f8f7e494d58
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/hsql.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/hsql.tar.gz;
+  sha256 = "9856e6811a4fc78bf55a1c4bb08091075a343995696b7026a0ef0dae91abc99a";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/hsutils.nix b/pkgs/misc/bleeding-edge-fetch-info/hsutils.nix
new file mode 100644
index 00000000000..7f4d93f97ef
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/hsutils.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/hsutils.tar.gz;
+  sha256 = "6d1cc9881fb2684016e52d3ab8e6666c5396da168eb298c3a549294668f6aa52";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/http.nix b/pkgs/misc/bleeding-edge-fetch-info/http.nix
new file mode 100644
index 00000000000..4ef8410096d
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/http.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/http.tar.gz;
+  sha256 = "3e463fa090c6a7ddb06e88b592b1788a216db7eaf9384850b6d462217ba5be62";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/hypertable.nix b/pkgs/misc/bleeding-edge-fetch-info/hypertable.nix
new file mode 100644
index 00000000000..022c1d87e0a
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/hypertable.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/hypertable.tar.gz;
+  sha256 = "d8a385def778d817415a6dd9d7ce10a60525c3c4a4d4dd8ec3bd8cfd359d2ab4";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/mkcabal.nix b/pkgs/misc/bleeding-edge-fetch-info/mkcabal.nix
new file mode 100644
index 00000000000..16f530dd602
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/mkcabal.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/mkcabal.tar.gz;
+  sha256 = "9f231756c36b46d29516ed327a320837194799a76de4833dc6a5c88e5ccd1658";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/nix_repository_manager.nix b/pkgs/misc/bleeding-edge-fetch-info/nix_repository_manager.nix
new file mode 100644
index 00000000000..d915a5f5edd
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/nix_repository_manager.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/nix_repository_manager.tar.gz;
+  sha256 = "6422ef73ea0efceed6ee8e0c6349826813a921ef6f15f68eacc11a3cf1304b37";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/syb_with_class.nix b/pkgs/misc/bleeding-edge-fetch-info/syb_with_class.nix
new file mode 100644
index 00000000000..97339411ee1
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/syb_with_class.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/syb_with_class.tar.gz;
+  sha256 = "6893a44c6831b3fd10587c275b82903d24b8a51409eead9ec2c530300f2e6542";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/synergy.nix b/pkgs/misc/bleeding-edge-fetch-info/synergy.nix
new file mode 100644
index 00000000000..a585e3bf5be
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/synergy.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/synergy.tar.gz;
+  sha256 = "c86dde2f10e7071d823cff542ea6c98a7e29a45e4909034edbd7605caa775a47";}
diff --git a/pkgs/misc/bleeding-edge-fetch-info/takusen.nix b/pkgs/misc/bleeding-edge-fetch-info/takusen.nix
new file mode 100644
index 00000000000..b2550a44087
--- /dev/null
+++ b/pkgs/misc/bleeding-edge-fetch-info/takusen.nix
@@ -0,0 +1,3 @@
+ args: with args; fetchurl { 
+  url = http://mawercer.de/~nix/repos/takusen.tar.gz;
+  sha256 = "35f3dbededae1a8d3bf648b229cbaf983907ff762b80674a65505f13c44147df";}
diff --git a/pkgs/misc/emulators/wine/default.nix b/pkgs/misc/emulators/wine/default.nix
index 5c44b762c33..b41c1eeeba4 100644
--- a/pkgs/misc/emulators/wine/default.nix
+++ b/pkgs/misc/emulators/wine/default.nix
@@ -8,11 +8,11 @@ assert stdenv.isLinux;
 let lib = import ../../../lib/default.nix; in
 
 stdenv.mkDerivation {
-  name = "wine-0.9.56";
+  name = "wine-1.0-pre-rc2";
 
   src = fetchurl {
-    url = mirror://sourceforge/wine/wine-0.9.56.tar.bz2;
-    sha256 = "d211cffa3d0ca4922b062faff04871fd2744a783686dd6f4d9f87c9e1a2fccd3";
+    url = mirror://sourceforge/wine/wine-1.0-rc2.tar.bz2;
+    sha256 = "1f0qi4qv8scfgq9angikimr8zl65jl9jxqpikmcmxq4gwqc265h6";
   };
 
   buildInputs = [
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
   # Wine locates a lot of libraries dynamically through dlopen().  Add
   # them to the RPATH so that the user doesn't have to set them in
   # LD_LIBRARY_PATH.
-  NIX_LDFLAGS = map (path: "-rpath ${path}/lib") [
+  NIX_LDFLAGS = map (path: "-rpath ${path}/lib ") [
     freetype fontconfig stdenv.gcc.gcc mesa mesa.libdrm
     xlibs.libXinerama xlibs.libXrender xlibs.libXrandr
     xlibs.libXcursor xlibs.libXcomposite
diff --git a/pkgs/misc/freestyle/default.nix b/pkgs/misc/freestyle/default.nix
new file mode 100644
index 00000000000..ad165760f7a
--- /dev/null
+++ b/pkgs/misc/freestyle/default.nix
@@ -0,0 +1,50 @@
+args:
+args.stdenv.mkDerivation {
+  name = "freestyle-2.2.0";
+
+  src = args.fetchurl {
+    url = mirror://sourceforge/freestyle/freestyle.2.2.0-src.tar.bz2;
+    sha256 = "1h4880fijmfy0x6dbl9hfri071rpj3lnwfzkxi1qyqhy7zyxy7ga";
+ };
+
+  buildInputs =(with args; [qt4 libpng lib3ds freeglut libXi libQGLViewer swig]);
+  inherit (args) python freeglut libQGLViewer lib3ds; # if you want to use another adopt patch and Config.pri 
+
+  buildPhase = ''
+    export PYTHON_VERSION=2.5
+    cd src/system && qmake -makefile PREFIX=\$out && cd ..
+    cd rendering && qmake -makefile PREFIX=\$out && cd ..
+    qmake -makefile PREFIX=\$out && make
+    cd swig && make -f Makefile
+    cd ../..
+
+    hide=$out/nix-support/hide
+    moddir=$out/share/freestyle
+    mkdir -p $out/bin $moddir $hide
+    cp -r style_modules $moddir
+    cp build/lib/*.so* $hide
+    cp build/Freestyle $hide
+    cp -r build/linux-g++/debug/lib/python $hide/pylib
+    cat > $out/bin/Freestyle << EOF
+      #!/bin/sh
+      echo use export PYTHONPATH to add your py files to the search path
+      echo the style modules can be loded from directory $moddir
+      echo starting Freestyle know - have fun
+      echo -e "\n\n\n\n"
+      export PYTHONPATH=$PYTHONPATH:$moddir/style_modules:$hide/pylib
+      LD_LIBRARY_PATH=$hide
+      $hide/Freestyle
+    EOF
+    chmod +x $out/bin/Freestyle
+    '';
+
+  patches = ./patch;
+
+  installPhase = ":";
+
+  meta = { 
+      description = "Non-Photorealistic Line Drawing rendering from 3D scenes";
+      homepage = http://freestyle.sourceforge.net;
+      license = "GPL2";
+  };
+}
diff --git a/pkgs/misc/freestyle/patch b/pkgs/misc/freestyle/patch
new file mode 100644
index 00000000000..733f50dbf10
--- /dev/null
+++ b/pkgs/misc/freestyle/patch
@@ -0,0 +1,182 @@
+diff -U3 -r a/src/Config.pri b/src/Config.pri
+--- a/src/Config.pri	2008-06-06 22:08:06.000000000 +0200
++++ b/src/Config.pri	2008-06-08 03:50:16.000000000 +0200
+@@ -80,11 +80,11 @@
+ win32:QMAKE_CXXFLAGS     *= /GR /GX
+ win32:QMAKE_CFLAGS       *= /GR /GX
+ irix-n32:QMAKE_CFLAGS    *= -LANG:std
+-irix-n32:QMAKE_CXXFLAGS  *= -LANG:std
+-linux-g++:QMAKE_CFLAGS   *= -Wno-deprecated
+-linux-g++:QMAKE_CXXFLAGS *= -Wno-deprecated
+-cygwin-g++:QMAKE_CFLAGS   *= -Wno-deprecated
+-cygwin-g++:QMAKE_CXXFLAGS *= -Wno-deprecated -mno-win32
++QMAKE_CXXFLAGS  *= -LANG:std
++QMAKE_CFLAGS   *= -Wno-deprecated -fPIC
++QMAKE_CXXFLAGS *= -Wno-deprecated -fPIC
++QMAKE_CFLAGS   *= -Wno-deprecated -fPIC
++QMAKE_CXXFLAGS *= -Wno-deprecated -fPIC
+ mac:QMAKE_CFLAGS         *= -Wno-deprecated
+ mac:QMAKE_CXXFLAGS       *= -Wno-deprecated
+ 
+diff -U3 -r a/src/geometry/Grid.h b/src/geometry/Grid.h
+--- a/src/geometry/Grid.h	2008-06-06 22:08:06.000000000 +0200
++++ b/src/geometry/Grid.h	2008-06-06 22:05:52.000000000 +0200
+@@ -321,7 +321,7 @@
+           for (OccludersSet::iterator it = occluders.begin();
+               it != occluders.end();
+               it++) {
+-                  if ((unsigned)(*it)->userdata2 != _timestamp) {
++                  if ((unsigned long)(*it)->userdata2 != _timestamp) {
+                       (*it)->userdata2 = (void*)_timestamp;
+                       visitor.examineOccluder(*it);
+                   }
+diff -U3 -r a/src/libconfig.pri b/src/libconfig.pri
+--- a/src/libconfig.pri	2008-06-06 22:08:06.000000000 +0200
++++ b/src/libconfig.pri	2008-06-07 22:23:44.000000000 +0200
+@@ -1,110 +1,32 @@
+ # This file should be viewed as a -*- mode: Makefile -*-
+ 
+-contains( CONFIG, 3ds1.20 ) {
+   message ("Using 3ds 1.2.0 module")
+-  linux-g++:INCLUDEPATH  *= $(HOME)/INCLUDE/LINUX
+-  linux-g++:LIBS         *= -L$(HOME)/LIB/LINUX -l3ds
+-  cygwin-g++:INCLUDEPATH  *= /usr/lib/lib3ds-1.2.0
+-  cygwin-g++:LIBS         *= -L/usr/lib/lib3ds-1.2.0/lib3ds -l3ds
+-  mac:INCLUDEPATH *= /usr/local/include
+-  mac:LIBS         *= -l3ds
+-  mac:QMAKE_LIBDIR *= /usr/local/lib
+-  win32:    INCLUDEPATH  *= C:\include\lib3ds\1.2.0
+-  win32:    QMAKE_LIBDIR *= C:\lib\lib3ds\1.2.0
+-  win32:debug:    LIBS         *= lib3ds-120sd.lib
+-  win32:release:    LIBS         *= lib3ds-120s.lib
+-}
+-
+-contains( CONFIG, 3ds1.30 ) {
+-  message ("Using 3ds 1.3.0 module")
+-  linux-g++:INCLUDEPATH  *= $(HOME)/INCLUDE/LINUX
+-  linux-g++:LIBS         *= -L$(HOME)/LIB/LINUX -l3ds
+-  cygwin-g++:INCLUDEPATH  *= /usr/lib/lib3ds-1.3.0
+-  cygwin-g++:LIBS         *= -L/usr/lib/lib3ds-1.3.0/lib3ds -l3ds
+-  mac:INCLUDEPATH *= /usr/local/include
+-  mac:LIBS         *= -l3ds
+-  mac:QMAKE_LIBDIR *= /usr/local/lib
+-  win32:    INCLUDEPATH  *= C:\include\lib3ds\1.3.0
+-  win32:    QMAKE_LIBDIR *= C:\lib\lib3ds\1.3.0
+-  win32:debug:    LIBS         *= lib3ds-1_3d.lib
+-  win32:release:    LIBS         *= lib3ds-1_3.lib
+-}
++  INCLUDEPATH  *= $(lib3ds)/include
++  LIBS         *= -L$(lib3ds)/lib -l3ds
+ 
+ contains( CONFIG, qglviewer ) {
+   message ("Using QGLViewer module")
+   CONFIG *= qt thread opengl glut
+-  linux-g++:INCLUDEPATH *= $(HOME)/INCLUDE
+-  linux-g++:LIBS        *= -L$(HOME)/LIB/LINUX -lQGLViewer
+-  cygwin-g++:LIBS        *= -lQGLViewer
+-  win32:    INCLUDEPATH  *= $(HOME)\INCLUDE
+-  win32:    QMAKE_LIBDIR *= $(HOME)\LIB
+-  win32:    LIBS        *= QGLViewer.lib
++  INCLUDEPATH *= $(mesa)/include
++  LIBS        *= -L$(mesa)/lib -lQGLViewer
++  LIBS        *= -lQGLViewer
+ }
+ 
+-contains( CONFIG, python2.3) {
+-  message ("Using python 2.3 module")
+-  linux-g++:INCLUDEPATH *= /usr/include/python2.3
+-  linux-g++:LIBS	*= -lpthread -lm -lutil	
+-  linux-g++:LIBS        *= -L/usr/local/lib/ -lpython2.3 -L$(HOME)/LIB/LINUX 
+-  win32:    INCLUDEPATH *= C:\python23\include
+-  win32:    QMAKE_LIBDIR *= C:\python23\libs
+-  win32:    LIBS        *= python23.lib
+-}
+-
+-contains( CONFIG, python2.4) {
+-  message ("Using python 2.4 module")
+-  linux-g++:INCLUDEPATH *= /usr/include/python2.4
+-  linux-g++:LIBS	*= -lpthread -lm -lutil	
+-  linux-g++:LIBS        *= -L/usr/local/lib/ -lpython2.4 -L$(HOME)/LIB/LINUX
+-  cygwin-g++:INCLUDEPATH *= /usr/include/python2.4
+-  cygwin-g++:LIBS	*= -lpthread -lm -lutil	
+-  cygwin-g++:LIBS        *= -L/usr/lib/python2.4/config -lpython2.4 
+-  win32:    INCLUDEPATH *= C:\python24\include
+-  win32:    QMAKE_LIBDIR *= C:\python24\libs
+-  win32:    LIBS        *= python24.lib
+-}
+-
+-contains( CONFIG, python2.5) {
+-  message ("Using python 2.5 module")
+-  linux-g++:INCLUDEPATH *= /usr/include/python2.5
+-  linux-g++:LIBS	*= -lpthread -lm -lutil	
+-  linux-g++:LIBS        *= -L/usr/local/lib/ -lpython2.5 -L$(HOME)/LIB/LINUX
+-  mac:	    INCLUDEPATH *= /usr/include/python2.5
+-  mac:      LIBS        *= -L/usr/lib/python2.5/config -lpython2.5
+-  cygwin-g++:INCLUDEPATH *= /usr/include/python2.5
+-  cygwin-g++:LIBS	*= -lpthread -lm -lutil	
+-  cygwin-g++:LIBS        *= -L/usr/lib/python2.5/config -lpython2.5 
+-  win32:    INCLUDEPATH *= C:\python25\include
+-  win32:    QMAKE_LIBDIR *= C:\python25\libs
+-  win32:    LIBS        *= python25.lib
+-}
++message ("Using python ${PYTHON_VERSION} module")
++INCLUDEPATH *= ${python}/include/python${PYTHON_VERSION}
++LIBS	*= -lpthread -lm -lutil	
++LIBS        *= -L${python}/lib -lpython${PYTHON_VERSION} -L$(HOME)/LIB/LINUX
+ 
+ 
+ contains( CONFIG, glut) {
+   message ("Using glut module")
+-  linux-g++:LIBS *= -lglut -lXi
+-  cygwin-g++:LIBS *= -lglut -lXi
+-  mac: LIBS *= -framework Glut
+-  win32:INCLUDEPATH *= C:\include
+-  win32: QMAKE_LIBDIR *= C:\lib\glut
+-  win32: LIBS *= glut32.lib
++  INCLUDEPATH *= ${freeglut}/include
++  LIBS *= -lglut -lXi -L{freeglut}/lib
+ }
+ 
+ contains( CONFIG, qglviewer2 ) {
+-  message ("Using QGLViewer module")
++  MESSAGE ("Using QGLViewer module")
+   CONFIG *= qt thread opengl glut
+-  linux-g++:INCLUDEPATH *= $(HOME)/INCLUDE
+-  linux-g++:LIBS        *= -L$(HOME)/LIB/LINUX -lQGLViewer
+-  mac: LIBS *= -lQGLViewer
+-  cygwin-g++:LIBS        *= -lQGLViewer2
+-  win32:    INCLUDEPATH  *= C:\include\QGLViewer\2.2.5
+-  win32{
+-    release{
+-      QMAKE_LIBDIR *= C:\lib\QGLViewer\release
+-    }
+-    debug{
+-      QMAKE_LIBDIR *= C:\lib\QGLViewer\debug
+-    }
+-  }
+-  win32:    LIBS        *= QGLViewer2.lib
++  INCLUDEPATH *= $(libQGLViewer)/include
++  LIBS        *= -L$(libQGLViewer)/lib -lQGLViewer
+ }
+diff -U3 -r a/src/swig/Makefile b/src/swig/Makefile
+--- a/src/swig/Makefile	2008-06-06 22:08:06.000000000 +0200
++++ b/src/swig/Makefile	2008-06-08 01:17:31.000000000 +0200
+@@ -19,14 +19,15 @@
+ LIBDIR    = ../../build/${PLATEFORM}/${BUILD}/lib/python
+ IPATH     = -I../geometry -I../image -I../scene_graph -I../stroke \
+             -I../system -I../view_map -I../winged_edge \
+-            -I/usr/include/python${PYTHON_VERSION_MAJ}.${PYTHON_VERSION_MIN}
++            -I${python}/include/python${PYTHON_VERSION}
+ # options to compile with static python : -lpthread -lm -lutil -shared -Xlinker -x -export-dynamic
+ #OPTI      = -lpthread -lm -lutil -shared -Xlinker -x -export-dynamic #-O3 -funroll-loops -fomit-frame-pointer -ffast-math -march=i686
+ DBUG      = #-ggdb #-pg
+ WARN	  = -w #-W -Wall #-pedantic -ansi
+ 
+-CFLAGS    = ${OPTI} ${DBUG} ${WARN} ${IPATH}
+-LDFLAGS   = ${OPTI} ${DBUG} ${WARN} ${LPATH}
++CFLAGS    = ${OPTI} ${DBUG} ${WARN} ${IPATH} -fPIC
++LDFLAGS   = ${OPTI} ${DBUG} ${WARN} ${LPATH} -L${python}/lib
++
+ 
+ SWIG_SRC  = Freestyle.i
+ PY_SRC    = ${SWIG_SRC:.i=.py}
diff --git a/pkgs/misc/ghc68executables/default.nix b/pkgs/misc/ghc68executables/default.nix
new file mode 100644
index 00000000000..bf097e57076
--- /dev/null
+++ b/pkgs/misc/ghc68executables/default.nix
@@ -0,0 +1,137 @@
+args: with args;
+let inherit (bleedingEdgeRepos)  sourceByName;
+# map ghcCabalExecutableFun and add cabal dependency to all 
+executables = lib.mapAttrs ( name_dummy : a : ghcCabalExecutableFun (a // { libsFun = x : (a.libsFun x) ++ [x.cabal_darcs]; } ) )
+({
+  happy = {
+    name = "happy-1.17";
+    libsFun = x : [x.base x.directory x.haskell98 x.mtl];
+    src = fetchurl {
+      url =  "http://hackage.haskell.org/packages/archive/happy/1.17/happy-1.17.tar.gz";
+      sha256 = "0aqaqy27fkkilj3wk03krx2gdgrw5hynn8wnahrkimg52xyy996w";
+    };
+    meta = {
+      executables = ["happy"];
+      description = "A lexical analyser generator for Haskell";
+      homepage = http://www.haskell.org/happy/;
+      license = "BSD3";
+    };
+    pass = {
+      patchPhase = '' sed -e "s/buildVerbose flags/fromFlag (buildVerbosity flags)/g" -e "s/BuildFlags(..)/BuildFlags(..), fromFlag/g" -i Setup.lhs '';
+    };
+  };
+  alex = {
+    name = "alex-2.2";
+    libsFun = x : [x.base x.haskell98];
+    src = fetchurl {
+      url =  "http://hackage.haskell.org/packages/archive/alex/2.2/alex-2.2.tar.gz";
+      sha256 = "1zhzlhwljbd52hwd8dm7fcbinfzjhal5x91rvi8x7cgxdkyd8n79";
+    };
+    meta = {
+      executables = ["alex"];
+      description = "tool generating lexical analysers";
+      homepage = http://www.haskell.org/alex/;
+      license = "BSD3";
+    };
+    pass = {
+      patchPhase = '' sed -e "s/buildVerbose flags/fromFlag (buildVerbosity flags)/g" -e "s/BuildFlags(..)/BuildFlags(..), fromFlag/g" -i Setup.lhs '';
+    };
+  };
+  drift = {
+    name = "DrIFT-2.2.3";
+    libsFun = x : [ x.base x.haskell98 ];
+    src = fetchurl {
+      url = http://hackage.haskell.org/packages/archive/DrIFT/2.2.3/DrIFT-2.2.3.tar.gz;
+      sha256 = "1615ijdz1bcmgnz86yx54ap6r7q08flh309jfyc7xaxxq5cdib0k";
+    };
+    meta = { 
+      description = "DrIFT is a type sensitive preprocessor for Haskell";
+      homepage = http://repetae.net/computer/haskell/DrIFT/;
+      license = "BSD3";
+    };
+  };
+  hxq = { 
+    name="hxq-0.7";
+    libsFun = x: [ x.base x.haskell98 x.template_haskell ];
+    src = fetchurl { url = http://hackage.haskell.org/packages/archive/HXQ/0.7/HXQ-0.7.tar.gz; sha256 = "0zwar8fykks1n86zm0alkdx4yg903hkdr66wffsji6fhhpkzcmrh";};
+  };
+  #leksah = {
+    #name="leksah-darcs";
+    #libsFun = x: [ x.base x.filepath x.parsec x.mtl x.process x.old_time x.containers x.pretty x.directory x.gtk2hs x.binary x.bytestring x.cabal_darcs x.ghc ];
+    #src = sourceByName "leksah";
+  #};
+  #hsffig = 
+  #  let version = "0.1.2-08-29-2007"; in
+  #  rec {
+  #  name = "hsffig-${version}";
+  #  src = fetchurl {
+  #    url = "http://www.golubovsky.org/software/hsffig/nightly/hsffig.${version}.tar.gz";
+  #    sha256 = "0pp27dchp5jshsacc1n15jvabsvc60l6phyfw0x9y6cmcwq72blg";
+  #  };
+  #  pass = { patchPhase = ''
+  #    sed -e "s/ALEX =.*/ALEX=alex/" -e "s/-package text//" -i Makefile 
+  #  '';
+  #    buildPhase = "unset buildPhase; buildPhase"; [> force using default buildPhase 
+  #  };
+  #  libsFun = x : [ x.base x.directory x.process x.cabal_darcs x.finitemap executables.alex executables.happy ];
+  #  meta = { 
+  #      description = "automatically generates C bindings for haskell (needs hsc2hs)";
+  #      homepage = "now sourceforge";
+  #      license = "BSD";
+  #      executables = ["hsffig"];
+  #  };
+  #};
+  flapjax = {
+  name = "flapjax-source-20070514";
+    src = args.fetchurl {
+      url = http://www.flapjax-lang.org/download/20070514/flapjax-source.tar.gz;
+      sha256 = "188dafpggbfdyciqhrjaq12q0q01z1rp3mpm2iixb0mvrci14flc";
+    };
+    pass = { buildPhase  = "
+      ensureDir \$out/bin
+      cd compiler;
+      ghc --make Fjc.hs -o \$out/bin/fjc
+    "; };
+    libsFun = x : [x.mtl x.parsec x.random];
+    meta = { 
+        description = "programming language designed around the demands of modern, client-based Web applications";
+        homepage = http://www.flapjax-lang.org/;
+        license = "BSD";
+        executables = ["fjc"];
+    };
+  };
+  /*
+  xmonad = {
+    name = "xmonad-darcs";
+    libsFun = x : [x.base x.mtl x.unix x.x11 x.x11extras xmessage  ];
+    src = sourceByName "xmonad";
+  };
+  darcs_unstable = {
+    name = "darcs_unstable";
+    libsFun = x : [x.base x.haskell98 x.http_darcs x.regex_compat x.quickcheck x.bytestring x.parsec x.html x.containers];
+    src = sourceByName "pg_darcsone";
+    pass = {
+      buildInputs = [  autoconf zlib ];
+      postUnpack = "cd nix_*; pwd; autoconf; cd ..";
+        NIX_LDFLAGS = "-lz";
+    };
+  };
+
+  */
+  mkcabal = { 
+    name = "mkcabal-0.4.1"; 
+    libsFun = x : [x.base x.readline x.pcreLight x.mtl];
+    src = sourceByName "mkcabal";
+    meta = { 
+      executables = ["mkcabal"]; 
+      description = "mkcabal"; 
+      homepage = "hackage"; 
+      license = "BSD3"; 
+    }; 
+    pass = { 
+      patchPhase = "sed -i s/0.3/0.3.1/g -i mkcabal.cabal";
+      buildInputs = pkgs.readline; # hack - this shouldn't be needed! 
+    }; 
+  }; 
+} // getConfig ["ghc68CustomExecutables"] (x : {} ) pkgs  ); in executables
+
diff --git a/pkgs/misc/ghc68extraLibs/WASHNGo_Patch_ghc682 b/pkgs/misc/ghc68extraLibs/WASHNGo_Patch_ghc682
new file mode 100644
index 00000000000..bc63491df6e
--- /dev/null
+++ b/pkgs/misc/ghc68extraLibs/WASHNGo_Patch_ghc682
@@ -0,0 +1,56 @@
+--- b/Setup.lhs	2007-07-13 16:06:51.000000000 +0000
++++ a/Setup.lhs	2008-05-07 19:20:08.000000000 +0000
+@@ -4,7 +4,10 @@
+ > import Distribution.Simple
+ > import Distribution.Simple.Configure
+ > import Distribution.Simple.LocalBuildInfo
++> import Distribution.Simple.Program
+ > import Distribution.Setup
++> import Distribution.Text
++> import Distribution.Verbosity
+ > import Distribution.PackageDescription
+ > import IO
+ > import System
+@@ -17,23 +20,23 @@
+ >     { instHook = myInstaller
+ >     }
+ > 
+-> myInstaller :: PackageDescription -> LocalBuildInfo -> Maybe UserHooks -> InstallFlags -> IO ()
+-> myInstaller pdesc lbi mhook userFlags =
+->   do instHook defaultUserHooks pdesc lbi mhook userFlags
++> myInstaller :: PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()
++> myInstaller pdesc lbi hook userFlags =
++>   do instHook defaultUserHooks pdesc lbi hook userFlags
+ >      myPostInstaller pdesc userFlags lbi
+ > 
+ > -- | Build and install the shell script to invoke the Haskell compiler with 
+ > -- the correct flags
+ > myPostInstaller :: PackageDescription -> InstallFlags -> LocalBuildInfo -> IO ()
+ > myPostInstaller pdesc instFlags localBuildInfo =
+->   let hc = compiler localBuildInfo
+->	bindir = prefix localBuildInfo ++ "/bin"
++>   let bindir = ((fromPathTemplate . prefix . installDirTemplates) localBuildInfo) ++ "/bin"
+ >	generated = bindir ++ "/washc"
+->	pid = showPackageId (package pdesc)
++>	pid = display (package pdesc)
+ >   in
+ >   do h <- openFile generated WriteMode
++>      compilerPath <- fmap ( programPath . fst) $ requireProgram normal ghcProgram AnyVersion (withPrograms localBuildInfo)
+ >      hPutStrLn h "#!/bin/sh"
+->      hPutStr h (compilerPath hc)
++>      hPutStr h  compilerPath
+ >      hPutStr h " -pgmF "
+ >      hPutStr h bindir
+ >      hPutStr h "/wash2hs"
+--- a/WASH.cabal	2008-05-11 22:35:37.000000000 +0200
++++ b/WASH.cabal	2008-05-11 22:35:51.000000000 +0200
+@@ -8,7 +8,7 @@
+ Category: Web
+ Stability: Beta
+ Synopsis: WASH is a family of embedded domain specific languages (EDSL) for programming Web applications in Haskell.
+-Build-Depends: base, regex-compat, haskell98, parsec
++Build-Depends: base, regex-compat, haskell98, parsec, containers
+ Extensions: ForeignFunctionInterface
+ Exposed-Modules:
+         WASH.CGI.AbstractSelector
+
diff --git a/pkgs/misc/ghc68extraLibs/default.nix b/pkgs/misc/ghc68extraLibs/default.nix
new file mode 100644
index 00000000000..2f7f4f7151f
--- /dev/null
+++ b/pkgs/misc/ghc68extraLibs/default.nix
@@ -0,0 +1,436 @@
+# contains libraries and maybe applications in the future. That's why I'm putting it into misc. Feel free to move it somewhere else
+
+# TODO use nix names (regexCompat instead of regex_compat)
+args : ghc: with args;
+
+rec {
+      #   name (using lowercase letters everywhere because using installing packages having different capitalization is discouraged) - this way there is not that much to remember?
+
+      cabal_darcs_name = "cabal-darcs";
+
+      # introducing p here to speed things up.
+      # It merges derivations (defined below) and additional inputs. I hope that using as few nix functions as possible results in greates speed?
+      # unfortunately with x; won't work because it forces nix to evaluate all attributes of x which would lead to infinite recursion
+      pkgs = let x = ghc.core_libs // derivations;
+                 wxVersion = "0.10.3";
+                 wxSrc = fetchurl { url = "mirror://sourceforge/wxhaskell/wxhaskell-src-${wxVersion}.tar.gz";
+                                   sha256 = "2a9b70b92c96ef1aa3eaa3426e224c0994c24bfdaccbf2b673edef65ba3cffce"; };
+                 inherit (bleedingEdgeRepos) sourceByName;
+             in {
+          # ghc extra packages 
+          mtl     = { name="mtl-1.1.0.0";     srcDir="libraries/mtl";    p_deps=[ x.base ]; src = ghc.extra_src; };
+          parsec  = { name="parsec-2.1.0.0";  srcDir="libraries/parsec"; p_deps=[ x.base ]; src = ghc.extra_src; };
+          network = { name="network-2.1.0.0"; srcDir="libraries/network"; p_deps=[ x.base x.parsec3 x.haskell98 ];       src = ghc.extra_src; };
+          regex_base = { name="regex-base-0.72.0.1"; srcDir="libraries/regex-base"; p_deps=[ x.base x.array x.bytestring x.haskell98 ]; src = ghc.extra_src; };
+          regex_posix = { name="regex-posix-0.72.0.2"; srcDir="libraries/regex-posix"; p_deps=[ x.regex_base x.haskell98 ]; src = ghc.extra_src; };
+          regex_compat = { name="regex-compat-0.71.0.1"; srcDir="libraries/regex-compat"; p_deps=[ x.base x.regex_posix x.regex_base x.haskell98 ]; src = ghc.extra_src; };
+          stm = { name="stm-2.1.1.0"; srcDir="libraries/stm"; p_deps=[ x.base x.array ]; src = ghc.extra_src; };
+          hunit = { name="HUnit-1.2.0.0"; srcDir="libraries/HUnit"; p_deps=[ x.base ]; src = ghc.extra_src; };
+          quickcheck = { name="QuickCheck-1.1.0.0"; srcDir="libraries/QuickCheck"; p_deps=[x.base x.random]; src = ghc.extra_src; };
+          tagsoup = { name = "tagsoup-0.4"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/tagsoup/0.4/tagsoup-0.4.tar.gz; sha256 = "0rdy303qaw63la1fhw1z8h6k8cs33f71955pwlzxyx0n45g58hc7";};  p_deps = [ x.base x.mtl x.network ]; };
+          hxt = { name = "hxt-7.5"; src =fetchurl { url = http://hackage.haskell.org/packages/archive/hxt/7.5/hxt-7.5.tar.gz; sha256 ="00q6m90a4qm4d5cg1x9r6b7f0rszcf2y7ifzs9mvy9kmzfl5ga7n"; };  p_deps = [x.base x.haskell98 x.http_darcs x.hunit x.network x.parsec x.tagsoup ]; };
+          haskellnet = { name = "HaskellNet-0.2"; src = sourceByName "haskellnet"; p_deps = [ x.base x.haskell98 x.network x.crypto x.mtl x.parsec x.time x.haxml x.bytestring x.pretty x.array x.dataenc x.containers x.old_locale x.old_time ]; 
+             pass = { 
+               patchPhase = "
+                 patch -p1 < \$patch
+                 sed -i 's/mtl/mtl, bytestring, pretty, array, dataenc, containers, old-locale, old-time/' *.cabal
+                 "; 
+               patch= ./haskellnetPatch ; 
+             };
+          };
+          dataenc = { name = "dataenc-0.10.2"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/dataenc/0.10.2/dataenc-0.10.2.tar.gz; sha256="1kl087994ajbwy65f24qjnz6wchlhmk5vkdw1506zzfbi5fr6x7r"; }; p_deps = [ x.base ]; };
+          # other pacakges  (hackage etc)
+          polyparse = { name = "polyparse-2.3"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/polyparse/1.1/polyparse-1.1.tar.gz; sha256 = "0mrrk3hhfrn68xn5y4jfg4ba0pa08bj05l007862vrxyyb4bksl7"; }; p_deps = [ x.base x.haskell98 ]; };
+          /*
+bash: HaXml: command not found
+marc@nixos: ~ ]$ nix-prefetch-url http://hackage.haskell.org/packages/archive/hexpat/0.2/hexpat-0.2.tar.gz
+######################################################################## 100.0%
+hash is 05pcrh1czs6s3d7wv3ygiwf40ilmkiiygb86m1as2w2vwk9mqm6q
+path is /nix/store/ikrbg8w0xxnbnggbvld5af2ib1bdpcfn-hexpat-0.2.tar.gz
+05pcrh1czs6s3d7wv3ygiwf40ilmkiiygb86m1as2w2vwk9mqm6q
+
+
+*/
+
+
+          # hint = { name="hint-0.1"; src = fetchurl { url = "http://hackage.haskell.org/packages/archive/hint/0.1/hint-0.1.tar.gz"; sha256 = "1adydl2la4lxxl6zz24lm4vbdrsi4bkpppzxhpkkmzsjhhkpf2f9"; }; p_deps = [ x.base x.ghc x.haskellSrc x.mtl ]; };
+          pcreLight = { name="pcre-light-0.3.1"; src= fetchurl { url = http://hackage.haskell.org/packages/archive/pcre-light/0.3.1/pcre-light-0.3.1.tar.gz; sha256 = "1h0qhfvqjcx59zkqhvsy7vw23l4444czg2z7b2lndy6cmkqc719m"; }; p_deps = [x.base x.bytestring pcre x.haskell98 ]; 
+            pass = { patchPhase = "                      
+                  echo \"    extra-lib-dirs: ${pcre}/lib\" >> pcre-light.cabal
+                  ";
+          }; };
+          hsHaruPDF = { name = "HsHaruPDF-0.0.0"; src = fetchurl{url= "http://hackage.haskell.org/packages/archive/HsHaruPDF/0.0.0/HsHaruPDF-0.0.0.tar.gz"; sha256="1yifhxk1m3z2i7gaxgwlmk6cv2spbpx8fny4sn59ybca8wd9z7ps";}; p_deps = [ x.base x.haskell98 ]; 
+                        pass = { buildInputs = [ mysql zlib libpng ]; 
+                          patchPhase = "
+                            sed 's/include-dirs:.*/include-dirs: haru/'  -i HsHaruPDF.cabal
+                            sed 's=extra-lib-dirs:.*=extra-lib-dirs: ${libpng}/lib ${zlib}/lib=' -i HsHaruPDF.cabal
+                            ";
+                        };
+          };
+          # hint = { name="hint-0.1"; src = fetchurl { url = "http://hackage.haskell.org/packages/archive/hint/0.1/hint-0.1.tar.gz"; sha256 = "1adydl2la4lxxl6zz24lm4vbdrsi4bkpppzxhpkkmzsjhhkpf2f9"; }; p_deps = [ x.base x.ghc x.haskellSrc x.mtl ]; };
+          timeout = { name="timeout-0.1.2"; src = fetchurl{ url = http://hackage.haskell.org/packages/archive/control-timeout/0.1.2/control-timeout-0.1.2.tar.gz; sha256 = "1g1x6c4dafckwcw48v83f3nm2sxv8kynwv8ib236ay913ycgayvg";}; p_deps = [ x.base x.time x.stm ]; };
+          parsec3  = { name="parsec-3.0.0";  p_deps=[ x.base x.mtl x.bytestring ];  src = fetchurl { url = "http://hackage.haskell.org/packages/archive/parsec/3.0.0/parsec-3.0.0.tar.gz"; sha256 = "0fqryy09y8h7z0hlayg5gpavghgwa0g3bldynwl17ks8l87ykj7a"; }; };
+
+          binary = rec { name = "binary-0.4.1"; p_deps = [ x.base x.bytestring x.containers x.array ];
+                           src = fetchurl { url = "http://hackage.haskell.org/packages/archive/binary/0.4.1/binary-0.4.1.tar.gz";
+                                        sha256 = "0jg5i1k5fz0xp1piaaf5bzhagqvfl3i73hlpdmgs4gc40r1q4x5v"; };
+                 };
+          hlist = { name="HList-0.1"; src = fetchurl { url="http://hackage.haskell.org/packages/archive/HList/0.1/HList-0.1.tar.gz"; sha256 = "1gv80qrnf71fzgb2ywaybkfvida0pwkd4a53vhmc0yg214yin4kh"; }; p_deps = [ ]; };
+          # using different name to not clash with postgresql
+          postgresql_bindings = rec { name = "PostgreSQL-0.2"; p_deps = [x.base x.mtl postgresql x.haskell98];
+                          src = fetchurl { url = "http://hackage.haskell.org/packages/archive/PostgreSQL/0.2/PostgreSQL-0.2.tar.gz";
+                                       sha256 = "0p5q3yc8ymgzzlc600h4mb9w86ncrgjdbpqfi49b2jqvkcx5bwrr"; };
+                          pass = {
+                             inherit postgresql;
+                             patchPhase = "echo 'extensions: MultiParamTypeClasses ForeignFunctionInterface EmptyDataDecls GeneralizedNewtypeDeriving FlexibleInstances UndecidableInstances' >> PostgreSQL.cabal
+                                           echo \"extra-lib-dirs: \$postgresql/lib\" >> PostgreSQL.cabal
+                                           echo \"extra-libraries: pq\" >> PostgreSQL.cabal
+                                          ";
+
+                          };
+                };
+          unixCompat ={ name = "unix-compat-0.1.2.1"; src = fetchurl { url=http://hackage.haskell.org/packages/archive/unix-compat/0.1.2.1/unix-compat-0.1.2.1.tar.gz; sha256 = "119fiazjr83xm4nk394v7lmsvhkic5k78pzcvv70j7zp83hjccsm"; }; p_deps = [ x.base x.directory x.old_time x.haskell98 ]; };
+          tar = rec { name = "tar-0.1.1.1"; p_deps = [ x.base x.bytestring x.haskell98 x.binary x.unixCompat ];
+                           src = fetchurl { url = "http://hackage.haskell.org/packages/archive/tar/0.1.1.1/tar-0.1.1.1.tar.gz";
+                                        sha256 = "08ns56xxw6519q0f7fqdznhcwx5dj2rc531mivxdyja6lmmjcfcb"; };
+                    #pass = {
+                      #patchPhase = ''
+                        #echo      "  extra-lib-dirs: ${zlib}/lib" >> zlib.cabal
+                        #echo      "  include-dirs: ${zlib}/include" >> zlib.cabal'';
+               #}; 
+          };
+          zlib = rec { name = "zlib-0.4.0.4"; p_deps = [ x.base x.bytestring x.haskell98 ];
+                           src = fetchurl { url = "http://hackage.haskell.org/packages/archive/zlib/0.4.0.4/zlib-0.4.0.4.tar.gz";
+                                        sha256 = "14hzqpzqs3rcwx6qpgybrcz33yrzb5y4p0bdsilhdgl15594ibad"; };
+                    pass = {
+                      patchPhase = ''
+                        echo      "  extra-lib-dirs: ${zlib}/lib" >> zlib.cabal
+                        echo      "  include-dirs: ${zlib}/include" >> zlib.cabal'';
+               }; };
+          bzlib = rec { name = "bzlib-0.4.0.3"; p_deps = [ x.base x.bytestring x.haskell98 ];
+                           src = fetchurl { url = "http://hackage.haskell.org/packages/archive/bzlib/0.4.0.3/bzlib-0.4.0.3.tar.gz";
+                                        sha256 = "0mdhqds2d4lx75yy39bvbvmvkb81xl1mhgbjwi4299j7isrrgmb4"; };
+                    pass = {
+                      patchPhase = ''
+                        echo   "  extra-lib-dirs: ${bzip2}/lib
+                          include-dirs: ${bzip2}/include" >> bzlib.cabal '';
+               }; };
+          wash = rec { name = "WashNGo-2.12"; p_deps = [x.base x.mtl x.haskell98 x.regex_compat x.parsec x.containers ];
+                         src = fetchurl { url = "http://www.informatik.uni-freiburg.de/~thiemann/WASH/WashNGo-2.12.tgz";
+                                      sha256 = "1dyc2062jpl3xdlm0n7xkz620h060g2i5ghnb32cn95brcj9fgrz"; };
+                      useLocalPkgDB = true;
+                  pass = {
+                    patches = ./WASHNGo_Patch_ghc682;
+                  };
+               };
+
+          #hsql = rec { name = "hsql-1.7"; p_deps = [x.base x.mtl x.haskell98  x.old_time ];
+                        #src = fetchurl { url = "http://hackage.haskell.org/packages/archive/hsql/1.7/hsql-1.7.tar.gz";
+                                     #sha256 = "0j2lkvg5c0x5gf2sy7zmmgrda0c3l73i9d6hyka2f15d5n1rfjc9"; };
+                      #pass = { patchPhase = "
+                                    #sed -e 's=build-depends:.*=build-depends: base, old-locale, old-time=' -i hsql.cabal
+                                    #echo \"extensions: 
+                                    #ForeignFunctionInterface, TypeSynonymInstances, CPP, ExistentialQuantification, GeneralizedNewtypeDeriving, PatternSignatures, ScopedTypeVariables, Rank2Types, DeriveDataTypeable \" >> hsql.cabal
+                                    #"; };
+              #};
+          # supports new time library
+          hsqlDarcs = rec { name = "hsql-darcs"; p_deps = [x.base x.mtl x.haskell98  x.old_time x.old_locale x.time ];
+                        src = sourceByName "hsql";
+                      pass = {  srcDir = "HSQL"; };
+              };
+          hsqlMysqlDarcs = { name = "hsql-mysql-darcs"; srcDir = "MySQL"; src = sourceByName "hsql"; p_deps = [ x.base x.hsqlDarcs x.old_time ];
+                        pass = { buildInputs = [ mysql zlib ];
+                                 patchPhase = "echo      \"  extra-lib-dirs: ${zlib}/lib\" >> MySQL/hsql-mysql.cabal
+                                           sed -e \"s=configVerbose=configVerbosity=\" -e \"s=sqlite_path=\$sqlite=\" -i MySQL/Setup.lhs
+                                             ";
+                               };
+                      };
+          #hsql_postgresql = rec { name = "hsql-postgresql-1.7"; p_deps = [ x.base x.mtl x.haskell98  x.old_time x.hsql postgresql ];
+          #              src = fetchurl { url = "";
+          #                           sha256 = "180c8acp4p9hsl5h8ryhhli9mlqcmcfjqaxzr7sa074gpzq29vfc"; };
+          #            pass = { patchPhase = "
+          #                          sed -e 's=build-depends:.*=build-depends: base, old-locale, old-time=' -i hsql.cabal
+          #                          echo \"extensions: 
+          #                          ForeignFunctionInterface, TypeSynonymInstances, CPP, ExistentialQuantification, GeneralizedNewtypeDeriving, PatternSignatures, ScopedTypeVariables, Rank2Types, DeriveDataTypeable \" >> hsql.cabal
+          #                          "; };
+          #    };
+          # I'm getting a glibc error when compiling - where does it come from ?
+          takusen = rec { name = "takusen-0.8"; p_deps = [ x.base x.mtl x.haskell98 x.time postgresql sqlite ];
+                          src =  sourceByName "takusen";
+                          pass = {
+                             inherit postgresql sqlite;
+                             patch = ./takusen_setup_patch;
+                            # no ODBC, Oracle support in nix
+                             patchPhase = "patch -p1 Setup.hs < \$patch
+                                           sed -e '/ODBC/d' -i Takusen.cabal
+                                           sed -e '/Oracle/d' -i Takusen.cabal
+                                           sed -e \"s=pg_path=\$postgresql=\" -e \"s=sqlite_path=\$sqlite=\" -i Setup.hs
+                                           sed -e \"s=configVerbose=configVerbosity=\" -e \"s=sqlite_path=\$sqlite=\" -i Setup.hs
+                                           sed -e \"s=regVerbose=regVerbosity=\" -e \"s=sqlite_path=\$sqlite=\" -i Setup.hs
+                                           ";
+                          };
+                };
+          hdbc = rec { name = "hdbc-1.1.4.0"; p_deps = [ x.base x.mtl x.haskell98 x.time x.bytestring postgresql sqlite ];
+                          src = fetchurl {
+                            url = http://software.complete.org/hdbc/static/download_area/1.1.4.0/hdbc_1.1.4.0.tar.gz;
+
+                            sha256 = "677e789094e3790be2462331b6c0f97b4ac1d65c8eb98cf7d8b83d5f3f9fbd39";
+                          };
+                          pass = {
+                             inherit postgresql sqlite;
+                             #patch = ./takusen_setup_patch;
+                            # no ODBC, Oracle support in nix
+                             #patchPhase = "patch -p1 Setup.hs < \$patch
+                             #              sed -e '/ODBC/d' -i Takusen.cabal
+                             #              sed -e '/Oracle/d' -i Takusen.cabal
+                             #              sed -e \"s=pg_path=\$postgresql=\" -e \"s=sqlite_path=\$sqlite=\" -i Setup.hs
+                             #              ";
+                          };
+                };
+          hdbc_postgresql = { name = "hdbc-postgresql"; p_deps = [ x.hdbc x.parsec3 postgresql ];
+                              src = fetchurl {
+                                url = http://hackage.haskell.org/packages/archive/HDBC-postgresql/1.1.4.0/HDBC-postgresql-1.1.4.0.tar.gz;
+                                sha256 = "1b9lxj55jvvq76ll8dr4kfb6aj7r0baj4gh8wkhgwc1kd41sx7h3"; };
+                              pass = {
+                                  patches = [ ./hdbc_postgresql_patch ];
+                                  patchPhase = "unset patchPhase; patchPhase;
+                                                sed -e '/Cabal-Ver/d' -i HDBC-postgresql.cabal";
+                              };
+          };
+
+          gtk2hs = rec { name = "gtk2hs-0.9.12.1"; p_deps = [ x.haskell98 x.mtl x.bytestring pkgconfig ] ++ (with gtkLibs; [ glib pango gtk gnome.glib gnome.gtksourceview]); 
+                          src = fetchurl {
+                            url = "http://downloads.sourceforge.net/gtk2hs/${name}.tar.gz";
+                            sha256 = "110z6v9gzhg6nzlz5gs8aafmipbva6rc50b8z1jgq0k2g25hfy22"; };
+                          pass = {
+                            buildPhase = "
+                              createEmptyPackageDatabaseAndSetupHook
+                              export GHC_PACKAGE_PATH
+                              ./configure --prefix=\$out --with-user-pkgconf=local-pkg-db --with-pkgconf=\$PACKAGE_DB
+                              make
+                              ensureDir \$out
+                              make install
+                              ";
+                          };
+                        };
+          hspread = { name = "hspread-0.3"; p_deps = [ x.base x.bytestring x.network x.binary ];
+                          src = fetchurl {
+                            url = http://hackage.haskell.org/packages/archive/hspread/0.3/hspread-0.3.tar.gz;
+                            sha256 = "0lwq7v7p6akykcsz6inkg99h3z7ab1gs5nkjjlgsbyqbwvimmf5n"; };
+                          pass = {
+                          };
+          };
+
+          wxcore = rec {
+                         
+                        name = "wxhaskel-${wxVersion}"; p_deps = [ x.haskell98 x.mtl x.bytestring x.parsec3 pkgconfig wxGTK  ] ++ (with gtkLibs; [ glib pango gtk gnome.glib]);
+                        src = wxSrc;
+                        pass = {
+                          profiling = if getConfig [ "ghc68" "profiling" ] false then "--hcprof" else "";
+                          buildInputs = [ unzip ];
+                          buildPhase = "
+                            createEmptyPackageDatabaseAndSetupHook
+                            export GHC_PACKAGE_PATH
+                            sed -e 's/which/type -p/g' configure
+                            ./configure --prefix=\$out --package-conf=\$PACKAGE_DB \$profiling
+                            make
+                            ensureDir \$out
+                            make install
+                            ";
+                        };
+                      };
+
+          wx = { name="wx-${wxVersion}"; src =wxSrc; srcDir="wx"; p_deps = [ x.haskell98 x.mtl x.bytestring x.parsec3 x.wxcore pkgconfig wxGTK  ] ++ (with gtkLibs; [ glib pango gtk gnome.glib]);
+                #  TODO rempove pwd
+                pass = { patchPhase = "pwd; cp {,wx/}license.txt"; };
+            };
+                  
+          typecompose = { name="TypeCompose-0.4"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/TypeCompose/0.5/TypeCompose-0.5.tar.gz; sha256 = "0mzjvwjixkp0jxfzxjw1pq8k1sm61sb5y96fk07xm91nn4sgpaqj"; }; p_deps = [ x.base ]; };
+          reactive = { name="reactive-0.5"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/reactive/0.5/reactive-0.5.tar.gz; sha256 = "1giv5p2nks4rw683bkmnjmdanpx8mgqi6dzj099cjbk93jag9581"; }; p_deps = [ x.base x.typecompose ]; };
+          phooey = { name="phooey-2.0"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/phooey/2.0/phooey-2.0.tar.gz; sha256 = "1bb6cn2vk7b57gaxh863ymidb4l7ldiwcnpif790rd4bq44fwfvf"; }; p_deps = [ x.base x.typecompose x.reactive x.wx x.wxcore ]; };
+
+          # depreceated (This is the deprecated Data.FiniteMap library, often useful to get old code to build when you are too lazy to update it.)
+          finitemap = { name="finitemap-0.1"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/FiniteMap/0.1/FiniteMap-0.1.tar.gz; sha256 = "1kf638h5gsc8fklhaw2jiad1r0ssgj8zkfmzywp85lrx5z529gky"; }; p_deps = [ x.base x.haskell98 ]; };
+
+          parallel = { name = "parallel-1.0.0.0"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/parallel/1.0.0.0/parallel-1.0.0.0.tar.gz; sha256 = "0f6g724zpdqhjcfv064yknrdx4rjaaj71bfx57c8ywizifcwxp4h"; }; p_deps = [x.base]; };
+
+          httpSimple = { name = "HTTP-Simple-0.1"; src = fetchurl { url =  http://hackage.haskell.org/packages/archive/HTTP-Simple/0.1/HTTP-Simple-0.1.tar.gz; sha256 = "0mbszgx8x02wry2h8jhdc51ryi7dwbi396y5h4k6p0bva8yp5bd0"; }; p_deps = [x.base x.network x.http_darcs]; };
+
+          deeparrow = { name = "DeepArrow-0.2"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/DeepArrow/0.2/DeepArrow-0.2.tar.gz; sha256 = "1rm55nryg2z4r5919da2cc3nq08cg0g9gf59qfzl50lfccq8x2wd"; }; p_deps = [ x.base x.mtl x.typecompose x.haskellSrc ]; };
+          tv = { name = "TV-0.4"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/TV/0.4/TV-0.4.tar.gz; sha256 = "0hracvx6pydmqfkx9n906k0463b0qaxskis91kir63ivf91zwndp"; }; p_deps = [ x.base  x.typecompose x.deeparrow]; };
+          guitv = { name = "GuiTV-0.4"; src = fetchurl { url = http://darcs.haskell.org/packages/GuiTV/dist/GuiTV-0.4.tar.gz; sha256 = "15mndbxm83q0d8ci3vj51zwrmzl0f5i5yqv0caw05vlzfsr4ib5i";}; p_deps = [ x.base x.deeparrow x.typecompose x.phooey x.tv ]; }; 
+
+          haskellSrc = { name = "haskell-src-1.0.1.1"; src = fetchurl { url = "http://hackage.haskell.org/packages/archive/haskell-src/1.0.1.1/haskell-src-1.0.1.1.tar.gz"; sha256 = "06kilrf7y5h6dxj57kwymr20zvdsq6zhchwn4wky12mrmzjxyj01"; }; p_deps = [ x.haskell98 x.base x.pretty x.array ]; 
+                      pass = { buildInputs = (with executables; [ happy alex ] ); };
+                      };
+          haskellSrcExt = { name = "haskell-src-exts-0.3.3.tar.gz"; src = fetchurl  { url = "http://hackage.haskell.org/packages/archive/haskell-src-exts/0.3.3/haskell-src-exts-0.3.3.tar.gz"; sha256 = "0g9ibjj1k5k3mqfx5mp8pqr0zx53pp9dkf52r8cdv18bl8xhzbpx"; }; p_deps = [ x.base x.base x.array x.pretty ]; 
+                      pass = { buildInputs = (with executables; [ happy alex ] ); };
+                    };
+
+          # haskelldb 
+          haskelldb = { name = "haskelldb-0.10"; src = fetchurl  { url = "http://hackage.haskell.org/packages/archive/haskelldb/0.10/haskelldb-0.10.tar.gz"; sha256 = "1i4kgsgajr9cijg0a2c04rn1zqwiasfvdbvs8c5qm49vkbdzm7l5"; }; p_deps = [ x.base x.haskell98 x.mtl x.pretty x.old_time x.directory x.old_locale]; 
+                    pass = { patchPhase = "sed -i 's/mtl/mtl, pretty, old-time, directory, old-locale/' haskelldb.cabal
+                                            echo 'ghc-options: -O2 -fglasgow-exts -fallow-undecidable-instances' >> haskelldb.cabal"; };
+          };
+            #hsql drivers
+
+          haskelldbHsql = { name= "haskelldb-hsql--0.10"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/haskelldb-hsql/0.10/haskelldb-hsql-0.10.tar.gz; sha256 = "0s3bjm080hzw23zjxr4412m81v408ll9y6gqb2yyw30n886ixzgh"; }; p_deps = [ x.base x.haskell98 x.mtl x.hsqlDarcs x.haskelldb x.old_time x.old_locale ]; 
+                    pass = { patchPhase = "sed -i 's/mtl/mtl, pretty, old-time, directory, old-locale/' haskelldb-hsql.cabal
+                                            echo 'ghc-options: -O2 -fglasgow-exts -fallow-undecidable-instances' >> haskelldb-hsql.cabal"; };
+                    };
+          haskelldbHsqlMysql = { name= "haskelldb-hsql-mysql-0.10"; src = fetchurl { url = http://hackage.haskell.org/packages/archive/haskelldb-hsql-mysql/0.10/haskelldb-hsql-mysql-0.10.tar.gz; sha256 = "0nfgq0xn45rhwxr8jvawviqfhgvhqr56l7ki1d72605y34dfx7rw"; }; p_deps = [ x.base x.haskell98 x.mtl x.hsqlDarcs x.haskelldbHsql x.hsqlMysqlDarcs x.haskelldb ]; 
+          };
+
+
+          /*
+
+          haskelldb-hsql-postgresql-0.10.tar.gz
+          ######################################################################## 100.0%
+          hash is 00nva5hhaknm5via4c1p2wj7ibyn6q874f0c3izjb9dk7rivfvgv
+          path is /nix/store/9n86rzpn0c4zyb7wpilpfcpkfnq68fch-haskelldb-hsql-postgresql-0.10.tar.gz
+          00nva5hhaknm5via4c1p2wj7ibyn6q874f0c3izjb9dk7rivfvgv
+          */
+
+
+          getOptions = rec { name = "GetOptions"; p_deps = [ x.haskell98 x.base x.mtl ];
+                       src = sourceByName "getOptions";
+                 };
+
+          # 1.13 is stable. There are more recent non stable versions
+          haxml = rec { name = "HaXml-1.13.3"; p_deps = [ x.base x.rts x.directory x.process x.pretty x.containers x.filepath x.haskell98 ];
+                       src = fetchurl { url = "http://www.haskell.org/HaXml/${name}.tar.gz";
+                                        sha256 = "08d9wy0rg9m66dd10x0zvkl74l25vxdakz7xp3j88s2gd31jp1v0"; };
+                 };
+          xhtml = rec { name = "xhtml-3000.0.2.2"; p_deps = [ x.base ];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/xhtml/3000.0.2.2/xhtml-3000.0.2.2.tar.gz";
+                                        sha256 = "112mbq26ksh7r22y09h0xvm347kba3p4ns12vj5498fqqj333878"; };
+                 };
+          html = rec { name = "html-1.0.1.1"; p_deps = [ x.base ];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/html/1.0.1.1/html-1.0.1.1.tar.gz";
+                                        sha256 = "10fayfm18p83zlkr9ikxlqgnzxg1ckdqaqvz6wp1xj95fy3p6yl1"; };
+                 };
+          crypto = rec { name = "crypto-4.1.0"; p_deps = [ x.base x.array x.pretty x.quickcheck x.random x.hunit ];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/Crypto/4.1.0/Crypto-4.1.0.tar.gz";
+                                        sha256 = "13rbpbn6p1da6qa9m6f7dmkzdkmpnx6jiyyndzaz99nzqlrwi109"; };
+                 };
+          hslogger = rec { name = "hslogger-1.0.4"; p_deps = [ x.containers x.directory x.mtl x.network x.process];
+                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/hslogger/1.0.4/hslogger-1.0.4.tar.gz";
+                                        sha256 = "0kmz8xs1q41rg2xwk22fadyhxdg5mizhw0r4d74y43akkjwj96ar"; };
+                 };
+          parsep = { name = "parsep-0.1"; p_deps = [ x.base x.mtl x.bytestring ];
+                         src = fetchurl { url = "http://twan.home.fmf.nl/parsep/parsep-0.1.tar.gz";
+                                        sha256 = "1y5pbs5mzaa21127cixsamahlbvmqzyhzpwh6x0nznsgmg2dpc9q"; };
+                         pass = { patchPhase = "sed -i 's/fps/bytestring/' *.cabal"; };
+                 };
+          time = { name = "time-1.1.2.0"; p_deps = [ x.base x.old_locale ];
+                         src = fetchurl { url = "http://hackage.haskell.org/packages/archive/time/1.1.2.0/time-1.1.2.0.tar.gz";
+                                        sha256 = "0zm4qqczwbqzy2pk7wz5p1virgylwyzd9zxp0406s5zvp35gvl89"; };
+                  };
+          rjson = { name = "RJson-0.3.3"; p_deps = [ x.base x.mtl x.parsec3 x.bytestring x.iconv x.array x.containers x.syb_with_class_darcs ];
+                        src = fetchurl { url = http://hackage.haskell.org/packages/archive/RJson/0.3.3/RJson-0.3.3.tar.gz;
+                                        sha256 = "0va1rbgjb8m3rij02318a31bi9gmy3zwyx5z12164c7iwafnd5v2"; };
+                  };
+          iconv = { name = "iconv-0.4"; p_deps = [ x.base x.bytestring ];
+                        src = fetchurl { url = http://hackage.haskell.org/packages/archive/iconv/0.4/iconv-0.4.tar.gz;
+                                        sha256 = "1snqzz7hi2qa83m5v3098rsldb485kz2jggd335qhvjahcp4bj1p"; };
+                  };
+
+          utf8string = { name = "utf8-string-0.3"; p_deps = [ x.base x.bytestring ];
+                        src = fetchurl { url = http://hackage.haskell.org/packages/archive/utf8-string/0.3/utf8-string-0.3.tar.gz;
+                                        sha256 = "11mln2r0ym4y12zxizn6n40xbgsi6q4n6n810rcg94bv35gqgcby"; };
+                  };
+          x11 = { name = "x11-1.4.1"; p_deps = [ x.base x.haskell98 x.bytestring ] ++ (with xlibs; [ libX11 libXext ]);
+                        src = fetchurl { url = http://hackage.haskell.org/packages/archive/X11/1.4.1/X11-1.4.1.tar.gz;
+                                        sha256 = "0yczl1m7g3lggcxh56fy2br13kbk4c5vrkcc4w76ys0m2ia3h475"; };
+                  };
+          x11extras = { name = "X11-extras-0.4"; p_deps = [ x.base x.bytestring x.x11 xlibs.libXinerama ];
+                        src = fetchurl { url = http://hackage.haskell.org/packages/archive/X11-extras/0.4/X11-extras-0.4.tar.gz;
+                                        sha256 = "1cpjr09gddcjd0wqwvaankv1zj7fyc6hbfdvar63f51g3vvw627a"; };
+                  };
+          /*
+          x11xft = { name = "xft-0.2"; p_deps = [ x.base x.bytestring x.haskell98 x.x11 x.utf8string x.bytestring xlibs.libXft freetype];
+                        src = fetchurl { url = http://hackage.haskell.org/packages/archive/X11-xft/0.2/X11-xft-0.2.tar.gz;
+                                        sha256 = "1ahvpkgh5mr6v8gisv1sc9s4075hqh85cpqcqh1ylr6lkf7dz31w"; };
+                         pass = { 
+                            inherit freetype;
+                            patchPhase = "sed -i \"s=include-dirs:.*=include-dirs: $freetype/include=\" *.cabal"; };
+                  };
+          */
+
+        # HAPPS - Libraries
+          http_darcs = { name="http-darcs"; p_deps = [x.network x.parsec3];
+                  src = sourceByName "http";
+                   #src = fetchdarcs { url = "http://darcs.haskell.org/http/"; md5 = "4475f858cf94f4551b77963d08d7257c"; };
+                 };
+          syb_with_class_darcs = { name="syb-with-class-darcs"; p_deps = [x.template_haskell x.bytestring ];
+                   src =
+                    # fetchdarcs { url = "http://happs.org/HAppS/syb-with-class"; md5 = "b42336907f7bfef8bea73bc36282d6ac"; };
+                     sourceByName "syb_with_class"; # { url = "http://happs.org/HAppS/syb-with-class"; md5 = "b42336907f7bfef8bea73bc36282d6ac"; };
+                 };
+
+        happs_data_darcs = { name="HAppS-Data-darcs"; p_deps=[ x.base x.mtl x.template_haskell x.syb_with_class_darcs x.haxml x.happs_util_darcs x.regex_compat x.bytestring x.pretty x.binary ];
+                    src = sourceByName "happs_data"; # fetchdarcs { url = "http://happs.org/repos/HAppS-Data"; md5 = "10c505dd687e9dc999cb187090af9ba7"; };
+                    };
+        happs_util_darcs = { name="HAppS-Util-darcs"; p_deps=[ x.base x.mtl x.hslogger x.template_haskell x.array x.bytestring x.old_time x.process x.directory ];
+                    src = sourceByName "happs_util"; # fetchdarcs { url = "http://happs.org/repos/HAppS-Util"; md5 = "693cb79017e522031c307ee5e59fc250"; };
+                    };
+      
+        happs_state_darcs = { name="HAppS-State-darcs"; p_deps=[ x.base x.haxml
+                      x.mtl x.network x.stm x.template_haskell x.hslogger
+                        x.happs_util_darcs x.happs_data_darcs x.bytestring x.containers
+                        x.random x.old_time x.old_locale x.unix x.directory x.binary x.hspread ];
+                      src = sourceByName "happs_state";
+                      #src = fetchdarcs { url = "http://happs.org/repos/HAppS-State"; 
+                      #                   md5 = "956e5c293b60f4a98148fedc5fa38acc"; 
+                      #                 };
+                    };
+#        happs_plugins_darcs = { name="HAppS-plugins-darcs"; p_deps=[ x.base x.mtl x.hslogger x.happs_util_darcs x.happs_data_darcs x.happs_state_darcs x.containers ];
+#[>src = fetchdarcs { url = "http://happs.org/repos/HAppS-Plugins"; md5 = "693cb79017e522031c307ee5e59fc250"; };
+#                    src = bleedingEdgeRepos.sourceByName "happs_plugins";
+#                    };
+        # there is no .cabal yet 
+        #happs_smtp_darcs = { name="HAppS-smtp-darcs"; p_deps=[];
+                    #src = fetchdarcs { url = "http://happs.org/repos/HAppS-smtp"; md5 = "5316917e271ea1ed8ad261080bcb47db"; };
+                    #};
+
+        happs_ixset_darcs = { name="HAppS-IxSet-darcs"; p_deps=[ x.base x.mtl
+                          x.hslogger x.happs_util_darcs x.happs_state_darcs x.happs_data_darcs
+                          x.template_haskell x.syb_with_class_darcs x.containers ];
+                    src = sourceByName "happs_ixset";
+                    #src = fetchdarcs { url = "http://happs.org/repos/HAppS-IxSet"; 
+                                       #md5 = "fa6b24517f09aa16e972f087430967fd"; 
+                                       #tag = "0.9.2";
+                                        # no tag
+                                       #md5 = "fa6b24517f09aa16e972f087430967fd"; 
+                                     #};
+                    };
+        happs_server_darcs = { name="HAppS-Server-darcs"; p_deps=[x.haxml x.parsec3 x.mtl
+                x.network x.regex_compat x.hslogger x.happs_data_darcs
+                  x.happs_util_darcs x.happs_state_darcs x.happs_ixset_darcs x.http_darcs
+                  x.template_haskell x.xhtml x.html x.bytestring x.random
+                  x.containers x.old_time x.old_locale x.directory x.unix];
+                    #src = fetchdarcs { url = "http://happs.org/repos/HAppS-HTTP"; md5 = "e1bb17eb30a39d30b8c34dffbf80edc2"; };
+                    src = sourceByName "happs_server";
+                    };
+        # using darcs with minimal patch applied to support $GHC_PACKAGE_PATH
+        cabal_darcs = 
+        { name=cabal_darcs_name; p_deps = with ghc.core_libs; [base rts directory process pretty containers filepath];
+                  src = sourceByName "cabal";
+          pass = { dummy = 1; };
+        };
+      } // (getConfig [ "ghc68CustomLibs" ] ( args: x : {} ) ) args x;
+      #srcs_only = let x = pkgs; in map (y : y.src ) [ x.happs_util_darcs x.happs_data_darcs x.syb_with_class_darcs x.http_darcs 
+      #          x.happs_server_darcs x.happs_ixset_darcs x.happs_plugins_darcs x.happs_server_darcs ];
+      toDerivation = attrs : with attrs;
+      # result is { mtl = <deriv>;
+        addHasktagsTaggingInfo (ghcCabalDerivation {
+            inherit (attrs) name src;
+            useLocalPkgDB = attrs ? useLocalPkgDB;
+            propagatedBuildInputs = p_deps ++ (lib.optional (attrs.name != cabal_darcs_name) derivations.cabal_darcs );
+            srcDir = if attrs ? srcDir then attrs.srcDir else ".";
+            # add cabal, take deps either from this list or from ghc.core_libs 
+            pass = if attrs ? pass then attrs.pass else {};
+        });
+      derivations = with lib; builtins.listToAttrs (lib.concatLists ( lib.mapRecordFlatten 
+                ( n : attrs : let d = (toDerivation attrs); in [ (nv n d) (nv attrs.name d) ] ) pkgs ) );
+    }.derivations
diff --git a/pkgs/misc/ghc68extraLibs/haskellnetPatch b/pkgs/misc/ghc68extraLibs/haskellnetPatch
new file mode 100644
index 00000000000..fd7a280683d
--- /dev/null
+++ b/pkgs/misc/ghc68extraLibs/haskellnetPatch
@@ -0,0 +1,66 @@
+diff -rN -U3 old-pg_haskellnet/HaskellNet/Auth.hs new-pg_haskellnet/HaskellNet/Auth.hs
+--- old-pg_haskellnet/HaskellNet/Auth.hs	2008-04-22 19:21:58.000000000 +0200
++++ new-pg_haskellnet/HaskellNet/Auth.hs	2008-04-22 19:21:58.000000000 +0200
+@@ -21,6 +21,7 @@
+ import Data.List
+ import Data.Bits
+ import Data.Array
++import Data.Maybe
+ 
+ type UserName = String
+ type Password = String
+@@ -41,7 +42,7 @@
+ b64Encode = map (toEnum.fromEnum) . B64.encode . map (toEnum.fromEnum)
+ 
+ b64Decode :: String -> String
+-b64Decode = map (toEnum.fromEnum) . B64.decode . map (toEnum.fromEnum)
++b64Decode = map (toEnum.fromEnum) . fromJust . B64.decode . map (toEnum.fromEnum)
+ 
+ showOctet :: [Octet] -> String
+ showOctet = concat . map hexChars
+diff -rN -U3 old-pg_haskellnet/haskellnet.cabal new-pg_haskellnet/haskellnet.cabal
+--- old-pg_haskellnet/haskellnet.cabal	2008-04-22 19:21:58.000000000 +0200
++++ new-pg_haskellnet/haskellnet.cabal	2008-04-22 19:21:58.000000000 +0200
+@@ -3,7 +3,7 @@
+ Author:         Jun Mukai
+ License:        BSD3
+ Category:       Network
+-Build-Depends:  base, haskell98, network, Crypto, mtl, parsec, time, HaXml
++Build-Depends:  base, haskell98, network, Crypto, mtl, parsec, time, HaXml, bytestring, pretty, array, dataenc, containers, old-locale, old-time
+ Synopsis:       network related libraries such as HTTP, POP3, SMTP
+ Exposed-modules:
+    Text.IMAPParsers,
+diff -rN -U3 old-pg_haskellnet/Text/Atom.hs new-pg_haskellnet/Text/Atom.hs
+--- old-pg_haskellnet/Text/Atom.hs	2008-04-22 19:21:58.000000000 +0200
++++ new-pg_haskellnet/Text/Atom.hs	2008-04-22 19:21:58.000000000 +0200
+@@ -38,7 +38,8 @@
+ import Data.Map (findWithDefault, insert, Map)
+ import qualified Data.Map as M
+ import Data.Monoid (Sum(..))
+-import Data.Time.LocalTime (LocalTime(..), TimeOfDay(..), ZonedTime(..), TimeZone(..), formatTime, minutesToTimeZone, utc)
++import Data.Time.Format (formatTime)
++import Data.Time.LocalTime (LocalTime(..), TimeOfDay(..), ZonedTime(..), TimeZone(..), minutesToTimeZone, utc)
+ import System.Locale (defaultTimeLocale)
+ import Data.Time.Calendar
+ import Text.XML.HaXml hiding (version)
+@@ -55,7 +56,7 @@
+ b64Encode :: String -> String
+ b64Encode = map e2e . B64.encode . map e2e
+ b64Decode :: String -> String
+-b64Decode = map e2e . B64.decode . map e2e
++b64Decode = map e2e . fromJust . B64.decode . map e2e
+ 
+ atomEscaper = mkXmlEscaper [('<', "lt"), ('>', "gt"), ('&', "amp"), ('"', "quot")] (`elem` "<>\"")
+ xEscape :: [Content] -> [Content]
+diff -rN -U3 old-pg_haskellnet/Text/RSS.hs new-pg_haskellnet/Text/RSS.hs
+--- old-pg_haskellnet/Text/RSS.hs	2008-04-22 19:21:58.000000000 +0200
++++ new-pg_haskellnet/Text/RSS.hs	2008-04-22 19:21:58.000000000 +0200
+@@ -26,6 +26,7 @@
+ import Data.Record
+ import Data.List (isPrefixOf)
+ import Data.Maybe
++import Data.Time.Format (formatTime)
+ import Data.Time.Calendar (fromGregorian)
+ import Data.Time.LocalTime
+ import System.Locale (defaultTimeLocale)
+
diff --git a/pkgs/misc/ghc68extraLibs/hdbc_postgresql_patch b/pkgs/misc/ghc68extraLibs/hdbc_postgresql_patch
new file mode 100644
index 00000000000..75df73ae94b
--- /dev/null
+++ b/pkgs/misc/ghc68extraLibs/hdbc_postgresql_patch
@@ -0,0 +1,10 @@
+--- a/Setup.lhs   2008-03-12 08:47:46.000000000 +0100
++++ b/Setup.lhs   2008-03-12 08:46:39.000000000 +0100
+@@ -2,7 +2,8 @@
+ 
+ \begin{code}
+ import Distribution.PackageDescription
++import Distribution.PackageDescription.Parse
+ import Distribution.Simple
+ import Distribution.Simple.LocalBuildInfo
+ import Distribution.Simple.Program
diff --git a/pkgs/misc/ghc68extraLibs/hsql-mysql-patch b/pkgs/misc/ghc68extraLibs/hsql-mysql-patch
new file mode 100644
index 00000000000..d15004b0a18
--- /dev/null
+++ b/pkgs/misc/ghc68extraLibs/hsql-mysql-patch
@@ -0,0 +1,73 @@
+--- b/Setup.lhs	2008-04-04 19:21:06.000000000 +0200
++++ a/Setup.lhs	2008-04-04 19:43:42.000000000 +0200
+@@ -1,12 +1,14 @@
++-- packages: process, Cabal, directory, filepath
+ #!/usr/bin/runghc
+ 
+ \begin{code}
+ import Data.Maybe(fromMaybe)
+ import Distribution.PackageDescription
++import Distribution.Verbosity
++import Distribution.PackageDescription.Parse
+ import Distribution.Setup
+ import Distribution.Simple
+ import Distribution.Simple.LocalBuildInfo
+-import Distribution.Simple.Utils(rawSystemVerbose)
+ import System.Info
+ import System.Exit
+ import System.Directory
+@@ -15,19 +17,19 @@
+ import Control.Monad(when)
+ import Control.Exception(try)
+ 
++
+ main = defaultMainWithHooks defaultUserHooks{preConf=preConf, postConf=postConf}
+   where
+     preConf ::  [String] -> ConfigFlags -> IO HookedBuildInfo
+     preConf args flags = do
+       try (removeFile "MySQL.buildinfo")
+       return emptyHookedBuildInfo
+-    postConf :: [String] -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode
++    postConf :: [String] -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
+     postConf args flags _ localbuildinfo = do
+-      mb_bi <- mysqlConfigBuildInfo (configVerbose flags)
++      mb_bi <- mysqlConfigBuildInfo (fromFlag (configVerbose flags))
+       let default_binfo | os == "mingw32" = emptyBuildInfo{extraLibs=["libmySQL"], ccOptions=["-Dmingw32_HOST_OS"]}
+                         | otherwise       = emptyBuildInfo{extraLibs=["mysqlclient"]}
+       writeHookedBuildInfo "MySQL.buildinfo" (Just (fromMaybe default_binfo mb_bi),[])
+-      return ExitSuccess
+ \end{code}
+ 
+ The following code is derived from Distribution.Simple.Configure
+@@ -46,9 +48,9 @@
+   message ("Using " ++ name ++ ": " ++ path)
+   return (Just path)
+ 
+-rawSystemGrabOutput :: Int -> FilePath -> [String] -> IO String
++rawSystemGrabOutput :: Verbosity -> FilePath -> [String] -> IO String
+ rawSystemGrabOutput verbose path args = do
+-  when (verbose > 0) $
++  when (verbose > silent ) $
+         putStrLn (path ++ concatMap (' ':) args)
+   (inp,out,err,pid) <- runInteractiveProcess path args Nothing Nothing
+   exitCode <- waitForProcess pid
+@@ -67,7 +69,7 @@
+ 
+ Populate BuildInfo using pkg-config tool.
+ \begin{code}
+-mysqlConfigBuildInfo :: Int -> IO (Maybe BuildInfo)
++mysqlConfigBuildInfo :: Verbosity -> IO (Maybe BuildInfo)
+ mysqlConfigBuildInfo verbose = do
+   mb_mysql_config_path <- findProgram "mysql_config" Nothing
+   case mb_mysql_config_path of
+--- a/hsql-mysql.cabal	2008-04-07 17:36:32.000000000 +0200
++++ b/hsql-mysql.cabal	2008-04-07 17:34:17.000000000 +0200
+@@ -5,7 +5,7 @@
+ category:	 Database
+ description: 	 MySQL driver for HSQL.
+ exposed-modules: Database.HSQL.MySQL
+-build-depends: 	 base, hsql
++build-depends: 	 base, hsql, old-time
+ extensions:      ForeignFunctionInterface, CPP
+ cc-options: -IDatabase/HSQL
+ extra-source-files: Database/HSQL/HsMySQL.h
diff --git a/pkgs/misc/ghc68extraLibs/takusen_setup_patch b/pkgs/misc/ghc68extraLibs/takusen_setup_patch
new file mode 100644
index 00000000000..baa318de556
--- /dev/null
+++ b/pkgs/misc/ghc68extraLibs/takusen_setup_patch
@@ -0,0 +1,51 @@
+--- orig/Setup.hs	2008-03-11 16:35:54.000000000 +0100
++++ mod/Setup.hs	2008-03-11 16:45:16.000000000 +0100
+@@ -1,3 +1,4 @@
++-- packages:HAppS-Server,mtl,HAppS-Data,HAppS-State,mtl,process,filepath,Cabal,directory

+ -- #!/usr/bin/env runhaskell 

+ 

+ {-# OPTIONS -cpp #-}

+@@ -8,12 +9,13 @@
+ import Control.Exception (bracket)

+ import Control.Monad (when)

+ import Data.List (isPrefixOf, unionBy)

++import Distribution.PackageDescription.Parse (writeHookedBuildInfo)

+ import Distribution.PackageDescription

+   ( PackageDescription(..), Library(..), BuildInfo(..), HookedBuildInfo

+-  , emptyHookedBuildInfo, writeHookedBuildInfo, emptyBuildInfo, hasLibs

++  , emptyHookedBuildInfo, emptyBuildInfo, hasLibs

+   )

+ import Distribution.Simple.Setup -- ( --Flag, fromFlag, toFlag

+-  ( ConfigFlags(..), BuildFlags(..)

++  ( fromFlag, Flag(..),  ConfigFlags(..), BuildFlags(..)

+   , InstallFlags(..), HaddockFlags(..)

+   , CopyFlags(..)

+   , RegisterFlags(..), emptyRegisterFlags

+@@ -78,11 +80,16 @@
+     preConf args flags = do

+       try (removeFile "takusen.buildinfo")

+       return emptyHookedBuildInfo

++    conf libName path = (Just emptyBuildInfo {

++            extraLibs = [libName]

++          , extraLibDirs = [ path ++ "/lib" ]

++          , includeDirs = [ path ++  "/include" ]

++          })

+     postConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()

+     postConf args flags _ localbuildinfo = do

+       let verbose = (configVerbose flags)

+-      sqliteBI <- configSqlite3 verbose

+-      pgBI <- configPG verbose

++      let sqliteBI = conf "sqlite3" "sqlite_path"

++      let pgBI = conf "pq" "pg_path"

+       oraBI <- configOracle verbose

+       odbcBI <- configOdbc verbose

+       let bis = [sqliteBI, pgBI, oraBI, odbcBI]

+@@ -99,7 +106,7 @@
+ defaultInstallHook :: PackageDescription -> LocalBuildInfo

+                    -> UserHooks -> InstallFlags -> IO ()

+ defaultInstallHook pkg_descr localbuildinfo _ (InstallFlags uInstFlag verbosity) = do

+-  install pkg_descr localbuildinfo (CopyFlags NoCopyDest verbosity)

++  install pkg_descr localbuildinfo (CopyFlags (Flag NoCopyDest) verbosity)

+   when (hasLibs pkg_descr) $

+       register pkg_descr localbuildinfo

+            emptyRegisterFlags{ regPackageDB=uInstFlag, regVerbose=verbosity }

diff --git a/pkgs/misc/my_env/default.nix b/pkgs/misc/my_env/default.nix
new file mode 100644
index 00000000000..94c7a591081
--- /dev/null
+++ b/pkgs/misc/my_env/default.nix
@@ -0,0 +1,35 @@
+# idea: provide nix environment for your developement actions
+# experimental
+
+/*
+  # example for nix itself adding glibc tag file to an env var.
+  # experimental
+  env_nix = my_environment rec {
+   buildInputs = [perl curl bzip2 aterm242fixes db4] 
+          ++ map (x : sourceWithTagsDerivation ( (addCTaggingInfo x ).passthru.sourceWithTags ) ) [ glibc ];
+   db4 = db44;
+   aterm = aterm242fixes;
+   name = "env_nix";
+   userCmds = ". ~/.bashrc
+    PS1='\033]2;\h:\u:\w\007\\nenv ${name} \[\033[1;32m\][\u@\h: \w ]$\[\033[0m\] '
+     ";
+  };
+*/
+
+args:  stdenv.mkDerivation ( 
+  { userCmds =""; } // {
+  phases = "buildPhase";
+  buildPhase = "
+    ensureDir \$out/bin
+    name=${args.name}
+    o=\$out/bin/$name
+    echo -e \"#!/bin/sh --login\\n\" >> \$o
+    export | grep -v HOME= | grep -v PATH= >> \$o 
+    echo \"export PATH=\$PATH:\\\$PATH entering $name\" >> \$o
+    echo \"echo entering $name\" >> \$o
+    echo \"$userCmds\" >> \$o
+    echo \"/bin/sh\" >> $o
+    echo \"echo leaving $name\" >> \$o
+    chmod +x $o
+  ";
+} //args);
diff --git a/pkgs/misc/ntfs-3g/default.nix b/pkgs/misc/ntfs-3g/default.nix
index 5f6a0bdbc5f..0d0ec76c252 100644
--- a/pkgs/misc/ntfs-3g/default.nix
+++ b/pkgs/misc/ntfs-3g/default.nix
@@ -1,12 +1,22 @@
 args: with args;
 stdenv.mkDerivation rec {
-  name = "ntfs-3g-1.1104";
+  pname = "ntfs-3g";
+  version = "1.2310";
+  name = "${pname}-${version}";
+
   src = fetchurl {
     url = "${meta.homepage}/${name}.tgz";
-    sha256 = "1m96c3vxm051lpy3kyik9s0m390rj6ngm11xmahfhw61794jzbyp";
+    sha256 = "3394bd1c9d0f3640803dc65ebbb42ee945db47e06f1a2b84ad257bad5e3c10f3";
   };
-  buildInputs = [fuse pkgconfig];
-  preConfigure="sed -e 's:/sbin:@sbindir@:' -i src/Makefile.in";
+
+  buildInputs = [fuse pkgconfig utillinux];
+
+  preConfigure="
+    sed -e 's:/sbin:@sbindir@:' -i src/Makefile.in
+    sed -e 's:/bin/mount:${utillinux}/bin/mount:' -i libfuse-lite/mount_util.c
+    sed -e 's:/bin/umount:${utillinux}/bin/umount:' -i libfuse-lite/mount_util.c
+  ";
+
   configureFlags="--enable-shared --disable-static --disable-ldconfig --exec-prefix=\${prefix}";
 
   meta = {
diff --git a/pkgs/misc/screensavers/xlockmore/default.nix b/pkgs/misc/screensavers/xlockmore/default.nix
index 025a2c044eb..45a18f9fc02 100644
--- a/pkgs/misc/screensavers/xlockmore/default.nix
+++ b/pkgs/misc/screensavers/xlockmore/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation {
   # Don't try to install `xlock' setuid.  Instead, the user should add
   # it to `security.extraSetuidPrograms'.
   configureFlags = 
-    "--disable-setuid " + "--enable-pam " +
+    "--disable-setuid --enable-pam --enable-bad-pam " +
     "--enable-appdefaultdir=$out/lib/X11/app-defaults";
 
   meta = {
diff --git a/pkgs/misc/tex/auctex/default.nix b/pkgs/misc/tex/auctex/default.nix
index 117ccf9e3da..6ca85167aed 100644
--- a/pkgs/misc/tex/auctex/default.nix
+++ b/pkgs/misc/tex/auctex/default.nix
@@ -1,15 +1,24 @@
-{ stdenv, fetchurl, emacs, tetex }:
+{ stdenv, fetchurl, emacs, texLive }:
  
-stdenv.mkDerivation {
-  name = "auctex-11.84";
+stdenv.mkDerivation ( rec {
+  pname = "auctex";
+  version = "11.85";
+  name = "${pname}-${version}";
+
   meta = {
     description = "AUCTeX is an extensible package for writing and formatting TeX files in GNU Emacs and XEmacs.";
     homepage = http://www.gnu.org/software/auctex;
   };
+
   src = fetchurl {
-    url = http://ftp.gnu.org/pub/gnu/auctex/auctex-11.84.tar.gz;
-    md5 = "73970c51221524442c11cde13d0584e9";
+    url = "http://ftp.gnu.org/pub/gnu/${pname}/${name}.tar.gz";
+    sha256 = "aebbea00431f8fd1e6be6519d9cc28e974942000737f956027da2c952a6d304e";
   };
-  configureFlags="--with-lispdir=\${out}/emacs/site-lisp --disable-preview";
-  buildInputs = [ emacs tetex ];
-}
+
+  buildInputs = [ emacs texLive ];
+
+  configureFlags = [
+    "--with-lispdir=\${out}/share/emacs/site-lisp"
+    "--disable-preview"
+  ];
+})
diff --git a/pkgs/misc/tex/nix/default.nix b/pkgs/misc/tex/nix/default.nix
index 54fb512c890..cb416132cf9 100644
--- a/pkgs/misc/tex/nix/default.nix
+++ b/pkgs/misc/tex/nix/default.nix
@@ -11,6 +11,7 @@ rec {
     , compressBlanksInIndex ? true
     , packages ? []
     , searchRelativeTo ? dirOf (toString rootFile) # !!! duplication
+    , copySources ? false
     }:
 
     assert generatePDF -> !generatePS;
@@ -22,7 +23,7 @@ rec {
       copyIncludes = ./copy-includes.pl;
       
       inherit rootFile generatePDF generatePS extraFiles
-        compressBlanksInIndex;
+        compressBlanksInIndex copySources;
 
       includes = import (findLaTeXIncludes {inherit rootFile searchRelativeTo;});
       
@@ -95,15 +96,15 @@ rec {
 
     pkgs.stdenv.mkDerivation {
       inherit name preamble body;
-      buildCommand = "
+      buildCommand = ''
         touch $out
-        echo '\\documentclass{article}' >> $out
-        echo '\\pagestyle{empty}' >> $out
-        if test -n \"$preamble\"; then cat $preamble >> $out; fi
-        echo '\\begin{document}' >> $out
+        echo '\documentclass{article}' >> $out
+        echo '\pagestyle{empty}' >> $out
+        if test -n "$preamble"; then cat $preamble >> $out; fi
+        echo '\begin{document}' >> $out
         cat $body >> $out
-        echo '\\end{document}' >> $out
-      ";
+        echo '\end{document}' >> $out
+      '';
     };
 
 
@@ -116,8 +117,10 @@ rec {
     pkgs.stdenv.mkDerivation {
       name = "png";
       inherit postscript;
+
+      buildInputs = [pkgs.imagemagick pkgs.ghostscript];
       
-      buildCommand = "
+      buildCommand = ''
         if test -d $postscript; then
           input=$(ls $postscript/*.ps)
         else
@@ -125,19 +128,17 @@ rec {
           ln -s $postscript $input
         fi
 
-        # !!! Quick hack: no ImageMagick in Nixpkgs yet!
-        export PATH=/usr/bin:$PATH
         ensureDir $out
-        convert -units PixelsPerInch \\
-          -density 300 \\
-          -trim \\
-          -matte \\
-          -transparent '#ffffff' \\
-          -type PaletteMatte \\
-          +repage \\
-          $input \\
-          \"$out/$(basename $input .ps).png\"
-      ";
+        convert -units PixelsPerInch \
+          -density 600 \
+          -trim \
+          -matte \
+          -transparent '#ffffff' \
+          -type PaletteMatte \
+          +repage \
+          $input \
+          "$out/$(basename $input .ps).png"
+      ''; # */
     };
 
 
@@ -162,5 +163,21 @@ rec {
     };
 
 
-      
+  # Convert a piece of TeX code to a PDF.
+  simpleTeXToPDF =
+    { preamble ? null
+    , body
+    , name ? baseNameOf (toString body)
+    , packages ? []
+    }:
+
+    runLaTeX {
+      rootFile = wrapSimpleTeX {
+        inherit body preamble;
+      };
+      inherit packages;
+      searchRelativeTo = dirOf (toString body);
+    };
+
+
 }
diff --git a/pkgs/misc/tex/nix/run-latex.sh b/pkgs/misc/tex/nix/run-latex.sh
index 13948400489..0b6e29988fe 100644
--- a/pkgs/misc/tex/nix/run-latex.sh
+++ b/pkgs/misc/tex/nix/run-latex.sh
@@ -2,6 +2,9 @@ source $stdenv/setup
 
 ensureDir $out
 
+mkdir root
+cd root
+
 startDir=$(perl $copyIncludes $includes)
 cd $startDir
 
@@ -48,6 +51,11 @@ runLaTeX() {
 echo
 
 
+if test -n "$copySources"; then
+    cp -prd $TMPDIR/root $out/tex-srcs
+fi
+
+
 echo "PASS 1..."
 runLaTeX
 echo
@@ -88,6 +96,13 @@ fi
 
 
 if test "$runNeeded"; then
+    echo "PASS 4..."
+    runLaTeX
+    echo
+fi
+
+
+if test "$runNeeded"; then
     echo "Hm, still not done :-("
     echo
 fi
diff --git a/pkgs/misc/tex/tetex/builder.sh b/pkgs/misc/tex/tetex/builder.sh
index f3fe32fbb70..b43b7ed93ec 100644
--- a/pkgs/misc/tex/tetex/builder.sh
+++ b/pkgs/misc/tex/tetex/builder.sh
@@ -12,6 +12,8 @@ configureFlags="\
   --without-x11 \
   --without-xdvik \
   --without-oxdvik \
+  --without-texinfo \
+  --without-texi2html \
   --with-system-zlib \
   --with-system-pnglib \
   --with-system-ncurses \
diff --git a/pkgs/misc/tex/texlive/aggregate.nix b/pkgs/misc/tex/texlive/aggregate.nix
new file mode 100644
index 00000000000..5a6df800451
--- /dev/null
+++ b/pkgs/misc/tex/texlive/aggregate.nix
@@ -0,0 +1,58 @@
+args : with args;
+rec {
+  phaseNames = ["doAggregate"];
+  name = "TeXLive-linkdir";
+
+  buildInputs = lib.closePropagation paths;
+
+  doAggregate = FullDepEntry (''
+
+    for currentPath in ${lib.concatStringsSep " " buildInputs}; do
+        echo Symlinking "$currentPath"
+        find $currentPath/share ! -type d | while read; do
+            REPLY="''${REPLY#$currentPath}"
+	    ensureDir $out/"$(dirname "$REPLY")"
+	    ln -fs $currentPath/"$REPLY" $out/"$REPLY"
+	    echo
+        done | while read; do head -n 99 >/dev/null; echo -n .; done
+	echo
+
+	cp -Trfp $currentPath/libexec $out/libexec || true
+    done
+
+    rm -r $out/share/texmf-config
+    find $out/share/texmf -type d | while read; do
+      REPLY="''${REPLY#$out/share/texmf}"
+      ensureDir $out/share/texmf-config/"$REPLY"
+    done
+
+    ensureDir $out/bin
+    for i in $out/libexec/*/*; do
+        echo -ne "#! /bin/sh\\n$i \"\$@\"" >$out/bin/$(basename $i)
+        chmod a+x $out/bin/$(basename $i)
+    done
+
+    rm $out/share/texmf*/ls-R
+    for i in web2c texconfig fonts/map; do
+        cp -r $out/share/texmf/$i/* $out/share/texmf-config/$i || true
+    done
+
+    TEXMFCONFIG=$out/share/texmf-config HOME=$PWD PATH=$PATH:$out/bin updmap --syncwithtrees
+    PATH=$PATH:$out/bin mktexlsr $out/share/texmf*
+    TEXMFCONFIG=$out/share/texmf-config HOME=$PWD PATH=$PATH:$out/bin updmap --syncwithtrees
+    PATH=$PATH:$out/bin mktexlsr $out/share/texmf*
+  '') ["minInit" "defEnsureDir" "addInputs"];
+
+  meta = {
+    description = "TeX distribution directory";
+    longDescription = ''
+      Here all the files from different TeX-related 
+      packages are collected in one directory. Of 
+      course, mktexlsr is called. Later placed 
+      directories take precedence. It is supposed that
+      share and libexec are symlinked, and bin is
+      recreated with wrappers for libexec-located 
+      linked binaries.
+    '';
+  };
+}
diff --git a/pkgs/misc/tex/texlive/beamer.nix b/pkgs/misc/tex/texlive/beamer.nix
new file mode 100644
index 00000000000..abeecffb530
--- /dev/null
+++ b/pkgs/misc/tex/texlive/beamer.nix
@@ -0,0 +1,20 @@
+args: with args;
+rec {
+  name = "texlive-beamer-2007";
+  src = fetchurl {
+    url = mirror://debian/pool/main/l/latex-beamer/latex-beamer_3.07.orig.tar.gz;
+    sha256 = "07ldhg5f0hcnhjgzg5g8ailqacn8zhqc8nl2jkxc43c2qxbvswbv";
+  };
+
+  buildInputs = [texLive];
+  propagatedBuildInputs = [texLiveLatexXColor texLivePGF];
+  phaseNames = ["doCopy"];
+  doCopy = FullDepEntry (''
+    ensureDir $out/share/texmf-dist/tex/latex/beamer
+    cp -r * $out/share/texmf-dist/tex/latex/beamer 
+  '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
+
+  meta = {
+    description = "Extra components for TeXLive: beamer class";
+  };
+}
diff --git a/pkgs/misc/tex/texlive/cm-super.nix b/pkgs/misc/tex/texlive/cm-super.nix
new file mode 100644
index 00000000000..19c8b5566b9
--- /dev/null
+++ b/pkgs/misc/tex/texlive/cm-super.nix
@@ -0,0 +1,27 @@
+args: with args;
+rec {
+  name = "texlive-cm-super-2007";
+  src = fetchurl {
+    url = mirror://debian/pool/main/c/cm-super/cm-super_0.3.3.orig.tar.gz;
+    sha256 = "1lxvnhqds2zi6ssz66r1b7s6p855lab7cgp0hdg247zkacbjxcfg";
+  };
+
+  phaseNames = ["doCopy"];
+  doCopy = FullDepEntry (''
+    ensureDir $out/share/texmf/fonts/enc
+    ensureDir $out/share/texmf/fonts/map
+    ensureDir $out/share/texmf/fonts/type1/public/cm-super
+    cp pfb/*.pfb $out/share/texmf/fonts/type1/public/cm-super
+    ensureDir $out/share/texmf/dvips/cm-super
+    cp dvips/*.{map,enc}  $out/share/texmf/dvips/cm-super
+    cp dvips/*.enc  $out/share/texmf/fonts/enc
+    cp dvips/*.map  $out/share/texmf/fonts/map
+    ensureDir $out/share/texmf/dvipdfm/config
+    cp dvipdfm/*.map  $out/share/texmf/dvipdfm/config
+  '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
+  buildInputs = [texLive];
+
+  meta = {
+    description = "Extra components for TeXLive: CM-Super fonts";
+  };
+}
diff --git a/pkgs/misc/tex/texlive/context.nix b/pkgs/misc/tex/texlive/context.nix
new file mode 100644
index 00000000000..11b4d15c097
--- /dev/null
+++ b/pkgs/misc/tex/texlive/context.nix
@@ -0,0 +1,21 @@
+args: with args;
+rec {
+  name = "context-2008.01.28";
+  src = fetchurl {
+    url = http://ftp.de.debian.org/debian/pool/main/c/context/context_2008.01.28.orig.tar.gz;
+    sha256 = "0infkn73v3kwqgg6b7rqnr28i5z5dbdfapy6ppzlcnr19yj4nh9y";
+  };
+
+  buildInputs = [texLive];
+  phaseNames = ["doCopy"];
+  doCopy = FullDepEntry (''
+    ensureDir $out/share/texmf
+    cp -r * $out/share/texmf
+  '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
+
+  meta = {
+    description = "ConTEXt TeX wrapper";
+  };
+
+}
+ 
diff --git a/pkgs/misc/tex/texlive/default.nix b/pkgs/misc/tex/texlive/default.nix
new file mode 100644
index 00000000000..f9528197c80
--- /dev/null
+++ b/pkgs/misc/tex/texlive/default.nix
@@ -0,0 +1,87 @@
+args : with args; 
+rec {
+  src = fetchurl { 
+    url = mirror://debian/pool/main/t/texlive-bin/texlive-bin_2007.dfsg.1.orig.tar.gz;
+    sha256 = "17wdn9vl4pa897046jpzxl6bl2ppr7swwb8x0jafwvbcnmywndag";
+  };
+  
+  texmfSrc = fetchurl { 
+    url = mirror://debian/pool/main/t/texlive-base/texlive-base_2007.orig.tar.gz;
+    sha256 = "16a4dyliidk43qj0m4gpsl9ln7nqsdcdx1lkbk4wrm03xpx87zvh";
+  };
+
+  langTexmfSrc = fetchurl {
+    url = mirror://debian/pool/main/t/texlive-lang/texlive-lang_2007.orig.tar.gz;
+    sha256 = "0cmd9ryd57rzzg7g2gm3qn4ijakkacy810h5zncqd39p3i1yn6nx";
+  };
+
+  setupHook = ./setup-hook.sh;
+
+  doPreConfigure = FullDepEntry (''
+    ensureDir $out
+    ensureDir $out/nix-support 
+    cp ${setupHook} $out/nix-support/setup-hook.sh
+    ensureDir $out/share
+    tar xf ${texmfSrc} -C $out/share --strip-components=1
+    tar xf ${langTexmfSrc} -C $out/share --strip-components=1
+    cp -r texmf* $out/share
+    cd build/source
+    sed -e s@/usr/bin/@@g -i $(grep /usr/bin/ -rl . )
+    sed -e '/ubidi_open/i#include <unicode/urename.h>' -i $(find . -name configure)
+    sed -e s@ncurses/curses.h@curses.h@g -i $(grep ncurses/curses.h -rl . ) 
+
+    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${freetype}/include/freetype2"
+    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${icu}/include/layout";
+  '') ["minInit" "doUnpack" "addInputs" "defEnsureDir"];
+
+  doPostInstall = FullDepEntry(''
+    mv $out/bin $out/libexec
+    ensureDir $out/bin
+    for i in $out/libexec/*/*; do
+        echo -ne "#! /bin/sh\\n$i \"\$@\"" >$out/bin/$(basename $i)
+        chmod a+x $out/bin/$(basename $i)
+    done
+    texmf_var=$(mktemp -d /var/tmp/texmf-varXXXXXXXX)
+    mv $out/share/texmf-var/* $texmf_var/ 
+    chmod -R a+rwX $texmf_var
+    rm -r $out/share/texmf-var || true
+    rm -r /var/tmp/texmf-var || true
+    ln -sfT $texmf_var $out/share/texmf-var
+    ln -sfT $texmf_var /var/tmp/texmf-var
+    ln -s $out/share/texmf $out/share/texmf-config
+    
+    sed -e 's/.*pyhyph.*/=&/' -i $out/share/texmf-config/tex/generic/config/language.dat
+    sed -e 's@^#!env ruby@#! ${ruby}/bin/ruby@' -i $out/libexec/*/*
+    sed -e 's@^#!env perl@#! ${perl}/bin/perl@' -i $out/libexec/*/*
+
+    PATH=$PATH:$out/bin mktexlsr $out/share/texmf*
+
+    HOME=. PATH=$PATH:$out/bin updmap-sys --syncwithtrees
+    
+    PATH=$PATH:$out/bin mktexlsr $out/share/texmf*
+ '') ["minInit" "defEnsureDir" "doUnpack" "doMakeInstall"];
+
+  buildInputs = [
+    zlib bzip2 ncurses libpng flex bison libX11 libICE
+    xproto freetype t1lib gd libXaw icu ghostscript ed 
+    libXt libXpm libXmu libXext xextproto perl libSM 
+    ruby
+  ];
+
+  configureFlags = [ "--with-x11" "--with-system-zlib" 
+    "--with-system-freetype2" "--with-system-t1lib" 
+    "--with-system-pnglib" "--with-system-gd" 
+    "--with-system-icu" "--with-system-ncurses" 
+    "--enable-ipc" "--with-mktexfmt"
+  ];
+
+  phaseNames = ["doPreConfigure" "doConfigure" 
+    "doMakeInstall" "doPostInstall"];
+
+  name = "texlive-core-2007";
+  meta = {
+    description = "A TeX distribution";
+    srcs = [texmfSrc langTexmfSrc];
+  };
+}
+
diff --git a/pkgs/misc/tex/texlive/extra.nix b/pkgs/misc/tex/texlive/extra.nix
new file mode 100644
index 00000000000..296073fa5aa
--- /dev/null
+++ b/pkgs/misc/tex/texlive/extra.nix
@@ -0,0 +1,19 @@
+args: with args;
+rec {
+  name = "texlive-extra-2007";
+  src = fetchurl {
+    url = mirror://debian/pool/main/t/texlive-extra/texlive-extra_2007.dfsg.1.orig.tar.gz;
+    sha256 = "1440495dcsrwhnz1p1prs4rf84ca0v7fjwg7sdw7isnprnpiq7w5";
+  };
+
+  buildInputs = [texLive];
+  phaseNames = ["doCopy"];
+  doCopy = FullDepEntry (''
+    ensureDir $out/share
+    cp -r texmf* $out/share/
+  '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
+
+  meta = {
+    description = "Extra components for TeXLive";
+  };
+}
diff --git a/pkgs/misc/tex/texlive/pgf.nix b/pkgs/misc/tex/texlive/pgf.nix
new file mode 100644
index 00000000000..5e30740f694
--- /dev/null
+++ b/pkgs/misc/tex/texlive/pgf.nix
@@ -0,0 +1,20 @@
+args: with args;
+rec {
+  name = "texlive-pgf-2007";
+  src = fetchurl {
+    url = mirror://debian/pool/main/p/pgf/pgf_1.18.orig.tar.gz;
+    sha256 = "1fk0m3rqsgdrxp2n6mbhh92819g1133w67lbgk66pqgspbrnk6h2";
+  };
+
+  propagatedBuildInputs = [texLiveLatexXColor texLive];
+
+  phaseNames = ["doCopy"];
+  doCopy = FullDepEntry (''
+    ensureDir $out/share/texmf/tex/generic/pgf
+    cp -r * $out/share/texmf/tex/generic/pgf
+  '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
+
+  meta = {
+    description = "Extra components for TeXLive: graphics package";
+  };
+}
diff --git a/pkgs/misc/tex/texlive/setup-hook.sh b/pkgs/misc/tex/texlive/setup-hook.sh
new file mode 100644
index 00000000000..d79c4fae419
--- /dev/null
+++ b/pkgs/misc/tex/texlive/setup-hook.sh
@@ -0,0 +1,7 @@
+addTeXMFPath () {
+    if test -d "$1/share/texmf-nix"; then
+        export TEXINPUTS="${TEXINPUTS}${TEXINPUTS:+:}$1/share/texmf-nix//:"
+    fi
+}
+
+envHooks=(${envHooks[@]} addTeXMFPath)
diff --git a/pkgs/misc/tex/texlive/xcolor.nix b/pkgs/misc/tex/texlive/xcolor.nix
new file mode 100644
index 00000000000..dcbbbcb8af6
--- /dev/null
+++ b/pkgs/misc/tex/texlive/xcolor.nix
@@ -0,0 +1,34 @@
+args: with args;
+rec {
+  name = "texlive-latex-xcolor-2007";
+  src = fetchurl {
+    url = mirror://debian/pool/main/l/latex-xcolor/latex-xcolor_2.11.orig.tar.gz;
+    sha256 = "0z78xfn5iq5ncg82sd6v2qrxs8p9hs3m4agaz90p4db5dvk2w0mn";
+  };
+
+  buildInputs = [texLive];
+  phaseNames = ["doCopy"];
+  doCopy = FullDepEntry (''
+    export HOME=$PWD
+
+    ensureDir $out/share/texmf/tex/latex/xcolor
+    ensureDir $out/share/texmf/dvips/xcolor
+    latex xcolor.ins 
+    cp *.sty *.def $out/share/texmf/tex/latex/xcolor
+    cp *.pro $out/share/texmf/dvips/xcolor
+
+    latex xcolor.dtx
+    latex xcolor.dtx
+    makeindex -s gind.ist xcolor.idx
+    latex xcolor.dtx
+    latex xcolor.dtx
+
+    rm *.sty *.pro *.ins *.def *.dtx
+    ensureDir $out/share/texmf/doc/latex-xcolor
+    cp *  $out/share/texmf/doc/latex-xcolor
+  '') ["minInit" "doUnpack" "defEnsureDir" "addInputs"];
+
+  meta = {
+    description = "Extra components for TeXLive: LaTeX color support";
+  };
+}
diff --git a/pkgs/misc/xosd/default.nix b/pkgs/misc/xosd/default.nix
new file mode 100644
index 00000000000..3996d9b08ef
--- /dev/null
+++ b/pkgs/misc/xosd/default.nix
@@ -0,0 +1,18 @@
+args: with args;
+stdenv.mkDerivation (rec {
+  pname = "xosd";
+  version = "2.2.12";
+
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "http://ignavus.net/${name}.tar.gz";
+    sha256 = "7d4ae8e1a6dbd7743af3b1cdc85144e2de26abe6daec25f4bd74bf311774df08";
+  };
+
+  buildInputs = [libX11 libXext libXt xextproto xproto];
+
+  meta = {
+    description = "XOSD displays text on your screen";
+  };
+})
diff --git a/pkgs/os-specific/linux/atheros/0.9.4.nix b/pkgs/os-specific/linux/atheros/0.9.4.nix
new file mode 100644
index 00000000000..38309d53537
--- /dev/null
+++ b/pkgs/os-specific/linux/atheros/0.9.4.nix
@@ -0,0 +1,30 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+		fetchurl {
+		  url = http://downloads.sourceforge.net/madwifi/madwifi-0.9.4.tar.gz;
+		  sha256 = "06jd5b8rfw7rmiva6jgmrb7n26g5plcg9marbnnmg68gbcqbr3xh";
+		};
+
+		buildInputs = [];
+		configureFlags = [];
+		makeFlags = [''KERNELPATH=${kernel}/lib/modules/*/build'' ''DESTDIR=$out''];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let 
+postInstall = FullDepEntry (''
+	ln -s $out/usr/local/bin $out/bin
+'') [minInit doMakeInstall];
+in
+stdenv.mkDerivation rec {
+	name = "atheros-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doMakeInstall 
+			postInstall doForceShare doPropagate]);
+	meta = {
+		description = "
+		Atheros WiFi driver.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/os-specific/linux/atheros/r3574.nix b/pkgs/os-specific/linux/atheros/r3574.nix
new file mode 100644
index 00000000000..486ae9fe80f
--- /dev/null
+++ b/pkgs/os-specific/linux/atheros/r3574.nix
@@ -0,0 +1,30 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = /* put a fetchurl here */
+		  fetchurl {
+		    url = http://snapshots.madwifi.org/madwifi-trunk/madwifi-trunk-r3574-20080426.tar.gz;
+		    sha256 = "1awr8jxrh6nvrsnyaydafkz7yarax3h4xphjcx6gmwsfbyb2mj7q";
+		  };
+
+		buildInputs = [];
+		configureFlags = [];
+		makeFlags = [''KERNELPATH=${kernel}/lib/modules/*/build'' ''DESTDIR=$out''];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let
+postInstall = FullDepEntry (''
+	ln -s $out/usr/local/bin $out/bin
+'') [minInit doMakeInstall];
+in
+stdenv.mkDerivation rec {
+	name = "atheros-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [doMakeInstall postInstall
+			doForceShare doPropagate]);
+	meta = {
+		description = "
+		Atheros WiFi driver.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/os-specific/linux/atheros/r3693.nix b/pkgs/os-specific/linux/atheros/r3693.nix
new file mode 100644
index 00000000000..159a44cb224
--- /dev/null
+++ b/pkgs/os-specific/linux/atheros/r3693.nix
@@ -0,0 +1,43 @@
+args : with args;
+	let localDefs = builderDefs {
+		src = fetchurl {
+			url = http://snapshots.madwifi.org/madwifi-trunk/madwifi-trunk-r3693-20080602.tar.gz;
+			sha256 = "0r9nnxcq50rgwcm9y93rpk3mqknl3ixkxkd72437b55qlz1f9vs3";
+		};
+
+		buildInputs = [];
+		configureFlags = [];
+		makeFlags = [''KERNELPATH=${kernel}/lib/modules/*/build'' ''DESTDIR=$out''];
+		hal20080528 = fetchurl {
+		  url = http://people.freebsd.org/~sam/ath_hal-20080528.tgz;
+		  sha256 = "1a6glkd8n46876hl48ib08p81qwsvrk4153j4b9xrxgid6f8bar9";
+		};
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let
+preBuild = FullDepEntry (''
+	echo Replacing HAL.
+	tar xvf ${hal20080528}
+	rm -r hal
+	mv ath_hal-* hal
+'') ["minInit" "doUnpack"];
+postInstall = FullDepEntry (''
+	ln -s $out/usr/local/bin $out/bin
+'') [minInit doMakeInstall];
+in
+stdenv.mkDerivation rec {
+	name = "atheros-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs 
+			((lib.optional 
+				(lib.getAttr ["freshHAL"] false args)
+				preBuild)
+			++ [doMakeInstall postInstall
+			doForceShare doPropagate]));
+	meta = {
+		description = "
+		Atheros WiFi driver.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/os-specific/linux/aufs/default.nix b/pkgs/os-specific/linux/aufs/default.nix
index bc874427f2b..e8361a7265d 100644
--- a/pkgs/os-specific/linux/aufs/default.nix
+++ b/pkgs/os-specific/linux/aufs/default.nix
@@ -1,15 +1,21 @@
 {stdenv, fetchurl, kernel}:
 
 stdenv.mkDerivation {
-  name = "aufs-20080128";
-  
+  name = "aufs-20080508-${kernel.version}";
+
   src = fetchurl {
-    url = http://nix.cs.uu.nl/dist/tarballs/aufs-20080128.tar.bz2;
-    sha256 = "0732zp6wfss09x9d6n0a3v65rifn739m9nffi5d3952vglg4va6l";
+    url = http://nixos.org/tarballs/aufs-20080508.tar.bz2;
+    sha256 = "1b7y6klk2fc6hf8w2la4k3yvxdvjibsnhv7d6mb12a7h13msjci6";
   };
 
-  buildPhase = ''
+  patches = [
+    (fetchurl {
+      url = http://www.mail-archive.com/aufs-users@lists.sourceforge.net/msg01091/04_sec_perm.dpatch;
+      sha256 = "0b51dpks4d5qgysrakv2c1v076d9hc8ln2cbh012zi75b45gn4ir";
+    })
+  ];
 
+  buildPhase = ''
     kernelVersion=$(cd ${kernel}/lib/modules && ls)
     kernelBuild=$(echo ${kernel}/lib/modules/$kernelVersion/source)
     tar xvfj ${kernel.src}
diff --git a/pkgs/os-specific/linux/blcr/0.6.5.nix b/pkgs/os-specific/linux/blcr/0.6.5.nix
new file mode 100644
index 00000000000..22be20b28c8
--- /dev/null
+++ b/pkgs/os-specific/linux/blcr/0.6.5.nix
@@ -0,0 +1,27 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftg.lbl.gov/CheckpointRestart/downloads/blcr-0.6.5.tar.gz ;
+    sha256 = "195gwxb38wmhzxr0jr349g6pxlwz6id2y6szv2akprv5ypy9py0g";
+  };
+
+  buildInputs = [perl];
+  configureFlags = [ 
+    "--with-linux=$(ls -d ${kernel}/lib/modules/*/build)" 
+    "--with-kmod-dir=$out/lib/modules/$(cd ${kernel}/lib/modules; ls -d 2.6.*)" 
+    "--with-system-map=${kernel}/System.map"
+  ];
+
+  preConfigure = FullDepEntry (''
+    sed -e 's/FASTCALL//' -i configure configure.ac
+    sed -e 's/int (attach_pid/void (attach_pid/' -i configure configure.ac
+  '')["doUnpack" "minInit"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"];
+      
+  name = "blcr-" + version;
+  meta = {
+    description = "Berkley Labs Checkpointing/Restarting module (save process tree state)";
+  };
+}
diff --git a/pkgs/os-specific/linux/dietlibc/builder.sh b/pkgs/os-specific/linux/dietlibc/builder.sh
index a1948bfabba..50779de8f99 100644
--- a/pkgs/os-specific/linux/dietlibc/builder.sh
+++ b/pkgs/os-specific/linux/dietlibc/builder.sh
@@ -25,6 +25,11 @@ postInstall() {
     # from the dietlibc asm to the kernel-headers asm.
     ln -s $kernelHeaders/include/asm/* $out/include/asm/ || true
 
+    # Make asm-x86_64 etc. available.
+    for i in $kernelHeaders/include/asm-*; do
+        ln -s $i $out/include/
+    done
+
     # Idem for include/linux.
     ln -s $kernelHeaders/include/linux/* $out/include/linux/ || true
 }
diff --git a/pkgs/os-specific/linux/e2fsprogs/default.nix b/pkgs/os-specific/linux/e2fsprogs/default.nix
index 72d9dee4132..1ddd60805be 100644
--- a/pkgs/os-specific/linux/e2fsprogs/default.nix
+++ b/pkgs/os-specific/linux/e2fsprogs/default.nix
@@ -1,17 +1,15 @@
-{stdenv, fetchurl, gettext}:
+{stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "e2fsprogs-1.39";
+  name = "e2fsprogs-1.40.8";
   src = fetchurl {
-    url = mirror://sourceforge/e2fsprogs/e2fsprogs-1.39.tar.gz;
-    md5 = "06f7806782e357797fad1d34b7ced0c6";
+    url = mirror://sourceforge/e2fsprogs/e2fsprogs-1.40.8.tar.gz;
+    sha256 = "1bgfi1b7zl60lbc8b0bcqv9rk886jcwwq091n08in4msnpw71prq";
   };
   configureFlags =
     if stdenv ? isDietLibC
     then ""
-    else "--enable-dynamic-e2fsck --enable-elf-shlibs";
-  buildInputs = [gettext];
-  patches = [./e2fsprogs-1.39_etc.patch];
+    else "--enable-elf-shlibs";
   preInstall = "installFlagsArray=('LN=ln -s')";
   postInstall = "make install-libs";
   NIX_CFLAGS_COMPILE =
diff --git a/pkgs/os-specific/linux/e2fsprogs/e2fsprogs-1.39_etc.patch b/pkgs/os-specific/linux/e2fsprogs/e2fsprogs-1.39_etc.patch
deleted file mode 100644
index 0fc5a90eed3..00000000000
--- a/pkgs/os-specific/linux/e2fsprogs/e2fsprogs-1.39_etc.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-diff -ruN e2fsprogs-1.39/misc/Makefile.in e2fsprogs-1.39.new/misc/Makefile.in
---- e2fsprogs-1.39/misc/Makefile.in	2006-03-27 07:58:10.000000000 +0200
-+++ e2fsprogs-1.39.new/misc/Makefile.in	2006-06-24 17:53:48.000000000 +0200
-@@ -223,12 +223,12 @@
- 	@$(SUBSTITUTE_UPTIME) $(srcdir)/filefrag.8.in filefrag.8
- 
- installdirs:
--	@echo "	MKINSTALLDIRS $(sbindir) $(root_sbindir) $(bindir) $(man1dir) $(man8dir) $(libdir)"
-+	@echo "	MKINSTALLDIRS $(sbindir) $(root_sbindir) $(bindir) $(man1dir) $(man8dir) $(libdir) $(root_sysconfdir)"
- 	@$(MKINSTALLDIRS) $(DESTDIR)$(sbindir) \
- 		$(DESTDIR)$(root_sbindir) $(DESTDIR)$(bindir) \
- 		$(DESTDIR)$(man1dir) $(DESTDIR)$(man8dir) \
- 		$(DESTDIR)$(man1dir) $(DESTDIR)$(man5dir) \
--		$(DESTDIR)$(libdir) $(DESTDIR)/etc
-+		$(DESTDIR)$(libdir) $(DESTDIR)$(root_sysconfdir)/etc
- 
- install: all $(SMANPAGES) $(UMANPAGES) installdirs
- 	@for i in $(SPROGS); do \
-@@ -291,7 +291,7 @@
- 	@if ! test -f $(DESTDIR)/etc/mke2fs.conf; then \
- 		echo "	INSTALL_DATA /etc/mke2fs.conf"; \
- 		$(INSTALL_DATA) $(srcdir)/mke2fs.conf \
--			$(DESTDIR)/etc/mke2fs.conf; \
-+			$(DESTDIR)$(root_sysconfdir)/mke2fs.conf; \
- 	fi
- 
- install-strip: install
diff --git a/pkgs/os-specific/linux/e3cfsprogs/default.nix b/pkgs/os-specific/linux/e3cfsprogs/default.nix
index 8db3317a230..89d5ad5158c 100644
--- a/pkgs/os-specific/linux/e3cfsprogs/default.nix
+++ b/pkgs/os-specific/linux/e3cfsprogs/default.nix
@@ -7,8 +7,8 @@ stdenv.mkDerivation {
   patches = [ ./e3cfsprogs-1.39_bin_links.patch ./e3cfsprogs-1.39_etc.patch ];
 
   src = fetchurl {
-    url = http://www.ext3cow.com/Download_files/e3cfsprogs-1.39.tgz;
-    sha256 = "26f535007a497d91c85d337ac67d62d42e3c8fde2ee02c5cb6b6e3e884a5d58f";
+    url = http://ext3cow.com/e3cfsprogs/e3cfsprogs-1.39.tgz;
+    sha256 = "8dd3de546aeb1ae42fb05409aeb724a145fe9aa1dbe1115441c2297c9d48cf31";
   };
 
   configureFlags =
diff --git a/pkgs/os-specific/linux/ext3cow-tools/default.nix b/pkgs/os-specific/linux/ext3cow-tools/default.nix
index 71f6657bffa..9b776de86ce 100644
--- a/pkgs/os-specific/linux/ext3cow-tools/default.nix
+++ b/pkgs/os-specific/linux/ext3cow-tools/default.nix
@@ -5,7 +5,7 @@ stdenv.mkDerivation {
   builder = ./builder.sh;
 
   src = fetchurl {
-    url = http://www.ext3cow.com/Download_files/ext3cow-tools-1.tgz;
+    url = http://ext3cow.com/tools/ext3cow-tools.tgz;
     sha256 = "78f55b19c8eeaa7b8abde63c7d6547b1ac0421a46d826a8d41c049719a3081f2";
   };
 
diff --git a/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
index 3a87cd164cb..97f00cc31a9 100644
--- a/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
+++ b/pkgs/os-specific/linux/firmware/iwlwifi-4965-ucode/default.nix
@@ -10,7 +10,15 @@ stdenv.mkDerivation rec {
   
   buildPhase = "true";
 
-  installPhase = "ensureDir $out; chmod -x *; cp * $out";
+  installPhase = ''
+    ensureDir "$out"
+    chmod -x *
+    cp * "$out"
+
+    # The driver expects the `-1' in the file name.
+    cd "$out"
+    ln -s iwlwifi-4965.ucode iwlwifi-4965-1.ucode
+  '';
   
   meta = {
     description = "Firmware for the Intel 4965ABG wireless card";
diff --git a/pkgs/os-specific/linux/gw6c/5.1.nix b/pkgs/os-specific/linux/gw6c/5.1.nix
new file mode 100644
index 00000000000..68797e3d26f
--- /dev/null
+++ b/pkgs/os-specific/linux/gw6c/5.1.nix
@@ -0,0 +1,39 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://go6.net/4105/file.asp?file_id=150;
+    sha256 = "07svw71wad1kwip7vnsdwcvlhhknqlx8v8kmdnrw11f6xg76w2ln";
+    name = "gateway6-client-5.1.tar.gz";
+  };
+
+  buildInputs = [nettools openssl procps];
+  configureFlags = [];
+  makeFlags = ["target=linux"];
+  installFlags = ["installdir=$out"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["preBuild" "doMakeInstall"];
+
+  goSrcDir = "cd ../tspc-advanced";
+
+  preBuild = FullDepEntry (''
+    sed -e 's@/dev/net/tun@/dev/tun@' -i platform/linux/tsp_tun.c;
+    sed -e 's@/sbin/ifconfig@${nettools}/sbin/ifconfig@' -i template/linux.sh
+    sed -e 's@/sbin/route@${nettools}/sbin/route@' -i template/linux.sh
+    sed -e 's@/sbin/ip@${iproute}/sbin/ip@' -i template/linux.sh
+    sed -e 's@/sbin/sysctl@${procps}/sbin/sysctl@' -i template/linux.sh
+  '') ["minInit" "addInputs" "doUnpack"];
+      
+  name = "gateway6-client-" + version;
+  meta = {
+    description = "Gateway6 client - provides IPv6 tunnel";
+    longDescription = "
+      This package provides Gateway6 client (gw6c) daemon,
+      which connects to so called tunnel broker via IPv4 
+      network, and tunnels IPv6 packets through broker,
+      thus giving global IPv6 connectivity. You may need 
+      tun, ipv6 and sit modules.
+    ";
+    homepage = http://go6.net ;
+  };
+}
diff --git a/pkgs/os-specific/linux/gw6c/default.nix b/pkgs/os-specific/linux/gw6c/default.nix
deleted file mode 100644
index 6e84bc0a61a..00000000000
--- a/pkgs/os-specific/linux/gw6c/default.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{stdenv, fetchurl, nettools, openssl, procps}:
-stdenv.mkDerivation {
-  name = "Gateway6-Client";
-
-  src = fetchurl {
-    name = "GateWay6-Client.tar.gz";
-    url = http://www.go6.net/4105/file.asp?file_id=142;
-    sha256 = "1578i6j3kq7g5f55gy1nksl4q0lxssdk39ilrgqjc20gb6k5j7j3";
-  };
-
-  setSourceRoot = "sourceRoot=$(echo tspc*/)";
-
-  preBuild = "sed -e 's@/dev/net/tun@/dev/tun@' -i platform/linux/tsp_tun.c;
-	sed -e 's@/sbin/@/var/run/current-system/sw/sbin/@' -i template/linux.sh";
-
-  makeFlags = "target=linux";
-  installFlags = "installdir=\$(out)";
-
-  buildInputs = [nettools openssl procps];
-
-  meta = {
-    description = "
-	Gateway6 client. Provides IPv6 tunnel (by default - using 
-	Freenet6 anonymous server, which means dynamic IPv6 address, 
-	but if you register at any tunnel broker you can easily 
-	enter you data in configuration.nix). You need also to enable
-	service \"gw6c\". And check that tun, ipv6 and sit are modprobed.
-";
-  };
-}
diff --git a/pkgs/os-specific/linux/hal/default.nix b/pkgs/os-specific/linux/hal/default.nix
index ce41a29a9fe..c7cde0e96cf 100644
--- a/pkgs/os-specific/linux/hal/default.nix
+++ b/pkgs/os-specific/linux/hal/default.nix
@@ -1,11 +1,11 @@
 args: with args;
 
 stdenv.mkDerivation {
-  name = "hal-0.5.9";
+  name = "hal-0.5.10";
   
   src = fetchurl {
-    url = http://people.freedesktop.org/~david/dist/hal-0.5.9.tar.gz;
-    sha256 = "178cm30kshwvs0kf5d3l9cn4hyhfv5h6c6q0qnl0jxhynvpgin35";
+    url = http://hal.freedesktop.org/releases/hal-0.5.10.tar.gz;
+    sha256 = "0k6bgavkry7sl1wwpwfpk15r52b75gfql2qgyijaqaxg826a2was";
   };
   
   buildInputs = [
@@ -24,6 +24,8 @@ stdenv.mkDerivation {
     --with-eject=${eject}/bin/eject
   ";
 
+  propagatedBuildInputs = [libusb];
+
   preBuild = "
     substituteInPlace hald/linux/coldplug.c --replace /usr/bin/udevinfo ${udev}/bin/udevinfo
   ";
diff --git a/pkgs/os-specific/linux/hdparm/default.nix b/pkgs/os-specific/linux/hdparm/default.nix
index 0171a5ad36f..bb6874336da 100644
--- a/pkgs/os-specific/linux/hdparm/default.nix
+++ b/pkgs/os-specific/linux/hdparm/default.nix
@@ -1,14 +1,19 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "hdparm-6.9";
+  name = "hdparm-8.7";
 
   src = fetchurl {
-    url = mirror://sourceforge/hdparm/hdparm-6.9.tar.gz;
-    sha256 = "01pyb9jmcv9nl1ig39s1i58fwgijqhjc5q1vxscbw0bd563fvrna";
+    url = mirror://sourceforge/hdparm/hdparm-8.7.tar.gz;
+    sha256 = "1gbyywsam769fdsgcy2clkfik9h2drad78h1xnh55b9c6fjlacmq";
   };
 
   preBuild = "
     makeFlagsArray=(sbindir=$out/sbin manprefix=$out)
   ";
+
+  meta = {
+    description = "A tool to get/set ATA/SATA drive parameters under Linux";
+    homepage = http://sourceforge.net/projects/hdparm/;
+  };
 }
diff --git a/pkgs/os-specific/linux/hibernate/default.nix b/pkgs/os-specific/linux/hibernate/default.nix
new file mode 100644
index 00000000000..91dc9068103
--- /dev/null
+++ b/pkgs/os-specific/linux/hibernate/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl, gawk }:
+
+let version = "1.98.1";
+in
+  stdenv.mkDerivation rec {
+    name = "hibernate-${version}";
+    src = fetchurl {
+      url = "http://www.tuxonice.net/downloads/all/hibernate-script-${version}.tar.gz";
+      sha256 = "1xpc2i16jczc3nhvxlkn6fb044srqrh528gnp92cwy4hxf2nzi1z";
+    };
+
+    patches = [ ./install.patch ./gen-manpages.patch ./hibernate.patch ];
+
+    buildInputs = [ gawk ];
+
+    installPhase = ''
+      # FIXME: Storing config files under `$out/etc' is not very useful.
+
+      substituteInPlace "hibernate.sh" --replace \
+        'SWSUSP_D="/etc/hibernate"' "SWSUSP_D=\"$out/etc/hibernate\""
+
+      # Remove all references to `/bin' and `/sbin'.
+      for i in scriptlets.d/*
+      do
+        substituteInPlace "$i" --replace "/bin/" "" --replace "/sbin/" ""
+      done
+
+      PREFIX="$out" CONFIG_PREFIX="$out" ./install.sh
+
+      ln -s "$out/share/hibernate/scriptlets.d" "$out/etc/hibernate"
+    '';
+
+    meta = {
+      description = "The `hibernate' script for swsusp and Tux-on-Ice";
+      longDescription = ''
+        This package provides the `hibernate' script, a command-line utility
+	that saves the computer's state to disk and switches it off, turning
+	it into "hibernation".  It works both with Linux swsusp and Tux-on-Ice.
+      '';
+
+      license = "GPLv2+";
+      homepage = http://www.tuxonice.net/;
+    };
+  }
diff --git a/pkgs/os-specific/linux/hibernate/gen-manpages.patch b/pkgs/os-specific/linux/hibernate/gen-manpages.patch
new file mode 100644
index 00000000000..cdbacc86baf
--- /dev/null
+++ b/pkgs/os-specific/linux/hibernate/gen-manpages.patch
@@ -0,0 +1,11 @@
+--- hibernate-script-1.98.1/gen-manpages.sh	2008-03-31 09:40:29.000000000 +0200
++++ hibernate-script-1.98.1/gen-manpages.sh	2008-04-01 15:58:11.000000000 +0200
+@@ -254,7 +254,7 @@ BEGIN {
+ }
+ 
+ # Create a copy of hibernate.sh with only the help items
+-TMPF=`mktemp /tmp/tmp.hibernate.XXXXXX`
++TMPF=`mktemp "$TMPDIR/tmp.hibernate.XXXXXX"`
+ awk '{
+     if ((substr($0, 1, 1) != "#") && (match($0, "AddConfigHelp") || match($0, "AddOptionHelp")) && (match($0, "\\(\\)") == 0)) {
+         print $0;
diff --git a/pkgs/os-specific/linux/hibernate/hibernate.patch b/pkgs/os-specific/linux/hibernate/hibernate.patch
new file mode 100644
index 00000000000..24de1637d3c
--- /dev/null
+++ b/pkgs/os-specific/linux/hibernate/hibernate.patch
@@ -0,0 +1,37 @@
+--- hibernate-script-1.98.1/hibernate.sh	2008-03-31 09:40:29.000000000 +0200
++++ hibernate-script-1.98.1/hibernate.sh	2008-04-01 18:24:23.000000000 +0200
+@@ -224,7 +224,7 @@ FindXServer() {
+ 
+ 	    xauth="`get_env_var_of_process $xpid XAUTHORITY`"
+ 	    xhome="`get_env_var_of_process $xpid HOME`"
+-	    xuser=`/bin/ls -ld /proc/$xpid/ | awk '{print $3}'`
++	    xuser=`ls -ld /proc/$xpid/ | awk '{print $3}'`
+ 	    [ -z $xauth ] && [ -n $xhome ] && [ -f $xhome/.Xauthority ] && xauth=$xhome/.Xauthority
+ 
+ 	    [ -z $xauth ] && continue
+@@ -273,14 +273,14 @@ UsingSuspendMethod() {
+ # chain.
+ SortSuspendBits() {
+     # explicit path required to be ash compatible.
+-    /bin/echo -ne "$SUSPEND_BITS" | sort -n
++    echo -ne "$SUSPEND_BITS" | sort -n
+ }
+ 
+ # SortResumeBits: Returns a list of functions registered in the correct order
+ # to call for resuming, prefixed by their position number.
+ SortResumeBits() {
+     # explicit path required to be ash compatible.
+-    /bin/echo -ne "$RESUME_BITS" | sort -rn
++    echo -ne "$RESUME_BITS" | sort -rn
+ }
+ 
+ # WrapHelpText: takes text from stdin, wraps it with an indent of 5 and width
+@@ -557,7 +557,7 @@ LoadScriptlets() {
+     CURRENT_SOURCED_SCRIPTLET=""
+     for scriptlet_dir in $SCRIPTLET_PATH ; do
+ 	[ -d "$scriptlet_dir" ] || continue
+-	[ -z "`/bin/ls -1 $scriptlet_dir`" ] && continue
++	[ -z "`ls -1 $scriptlet_dir`" ] && continue
+ 	for scriptlet in $scriptlet_dir/* ; do
+ 	    # Avoid editor backup files.
+ 	    case "$scriptlet" in *~|*.bak) continue ;; esac
diff --git a/pkgs/os-specific/linux/hibernate/install.patch b/pkgs/os-specific/linux/hibernate/install.patch
new file mode 100644
index 00000000000..ae296b955ac
--- /dev/null
+++ b/pkgs/os-specific/linux/hibernate/install.patch
@@ -0,0 +1,11 @@
+--- hibernate-script-1.98.1/install.sh	2008-03-31 09:40:29.000000000 +0200
++++ hibernate-script-1.98.1/install.sh	2008-04-01 15:50:46.000000000 +0200
+@@ -63,7 +63,7 @@ fi
+ cp -a blacklisted-modules $BLACKLIST
+ 
+ # Test if they have anything in there, and warn them
+-if /bin/ls $OLD_SCRIPTLET_DIR/* > /dev/null 2>&1 ; then
++if ls $OLD_SCRIPTLET_DIR/* > /dev/null 2>&1 ; then
+     echo "  **"
+     echo "  ** You have scriptlets already installed in $OLD_SCRIPTLET_DIR"
+     echo "  ** Since version 0.95, these have moved to $SCRIPTLET_DIR."
diff --git a/pkgs/os-specific/linux/iwlwifi/default.nix b/pkgs/os-specific/linux/iwlwifi/default.nix
index ed551e9bd45..c993886c21d 100644
--- a/pkgs/os-specific/linux/iwlwifi/default.nix
+++ b/pkgs/os-specific/linux/iwlwifi/default.nix
@@ -1,10 +1,12 @@
 {stdenv, fetchurl, kernel}:
 
+let version = "1.2.25"; in
+
 stdenv.mkDerivation rec {
-  name = "iwlwifi-1.2.25";
+  name = "iwlwifi-${version}-${kernel.version}";
 
   src = fetchurl {
-    url = "http://www.intellinuxwireless.org/iwlwifi/downloads/${name}.tgz";
+    url = "http://www.intellinuxwireless.org/iwlwifi/downloads/iwlwifi-${version}.tgz";
     sha256 = "09fjy0swcyd77fdp8x2825wj5cd73hwbzl8mz9sy2ha21p1qwq1d";
   };
 
diff --git a/pkgs/os-specific/linux/jfsrec/svn-7.nix b/pkgs/os-specific/linux/jfsrec/svn-7.nix
new file mode 100644
index 00000000000..bb124bb52e7
--- /dev/null
+++ b/pkgs/os-specific/linux/jfsrec/svn-7.nix
@@ -0,0 +1,22 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/jfsrec/jfsrec-svn-7.tar.gz;
+    sha256 = "163z6ljr05vw2k5mj4fim2nlg4khjyibrii95370pvn474mg28vg";
+  };
+
+  buildInputs = [boost];
+  configureFlags = [];
+
+  doFixBoost = FullDepEntry (''
+    sed -e 's/-lboost_[a-z_]*/&-mt/g' -i src/Makefile.in
+  '') ["minInit" "doUnpack"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doFixBoost" "doConfigure" "doMakeInstall"];
+      
+  name = "jfsrec-" + version;
+  meta = {
+    description = "JFS recovery tool";
+  };
+}
diff --git a/pkgs/os-specific/linux/jfsutils/1.1.12.nix b/pkgs/os-specific/linux/jfsutils/1.1.12.nix
new file mode 100644
index 00000000000..14c9f5152f3
--- /dev/null
+++ b/pkgs/os-specific/linux/jfsutils/1.1.12.nix
@@ -0,0 +1,18 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://jfs.sourceforge.net/project/pub/jfsutils-1.1.12.tar.gz;
+    sha256 = "04vqdlg90j0mk5jkxpfg9fp6ss4gs1g5pappgns6183q3i6j02hd";
+  };
+
+  buildInputs = [e2fsprogs];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "jfsutils-" + version;
+  meta = {
+    description = "IBM JFS utilities";
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel-headers/2.6.25.4.nix b/pkgs/os-specific/linux/kernel-headers/2.6.25.4.nix
new file mode 100644
index 00000000000..c6d1cc409fc
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel-headers/2.6.25.4.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchurl}:
+
+assert stdenv.isLinux;
+
+stdenv.mkDerivation {
+  name = "linux-headers-2.6.25.4";
+  
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v2.6/linux-2.6.25.4.tar.bz2";
+    sha256 = "0hp36pwphw5rs9kwm5ksr7ynfmzgpcd8gi45rigbilvcvmsdnxf3";
+  };
+
+  platform = 
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    if stdenv.system == "powerpc-linux" then "powerpc" else
+    abort "don't know what the kernel include directory is called for this platform";
+
+  # !!! hacky
+  fixupPhase = "ln -s $out/include/asm $out/include/asm-$platform";
+
+  extraIncludeDirs =
+    if stdenv.system == "powerpc-linux" then ["ppc"] else [];
+}
diff --git a/pkgs/os-specific/linux/kernel-headers/2.6.26-rc5.nix b/pkgs/os-specific/linux/kernel-headers/2.6.26-rc5.nix
new file mode 100644
index 00000000000..870b9a4c44c
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel-headers/2.6.26-rc5.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchurl}:
+
+assert stdenv.isLinux;
+
+stdenv.mkDerivation {
+  name = "linux-headers-2.6.26-pre-rc5";
+  
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v2.6/testing/linux-2.6.26-rc5.tar.bz2";
+    sha256 = "0mxhxiivm2dyca2shxnr3689x8f3l2vlmqdl80fm6lmq1b3j7k75";
+  };
+
+  platform = 
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    if stdenv.system == "powerpc-linux" then "powerpc" else
+    abort "don't know what the kernel include directory is called for this platform";
+
+  # !!! hacky
+  fixupPhase = "ln -s $out/include/asm $out/include/asm-$platform";
+
+  extraIncludeDirs =
+    if stdenv.system == "powerpc-linux" then ["ppc"] else [];
+}
diff --git a/pkgs/os-specific/linux/kernel/builder-custom.sh b/pkgs/os-specific/linux/kernel/builder-custom.sh
new file mode 100644
index 00000000000..b4592e74c48
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/builder-custom.sh
@@ -0,0 +1,127 @@
+source $stdenv/setup
+
+configurePhase=configurePhase
+configurePhase() {
+    export INSTALL_PATH=$out
+    export INSTALL_MOD_PATH=$out
+	
+    eval "$preConfigure"
+
+    # Get rid of any "localversion" files installed by patches.
+    if test -z "$allowLocalVersion"; then
+        rm -f localversion*
+    fi
+
+    # Set our own localversion, if specified.
+    if test -n "$localVersion"; then
+        echo "$localVersion" > localversion-nix
+    fi
+
+
+    # Create the config file.
+    cp $config .config
+    chmod u+w .config
+
+    echo --extraConfig--;
+    echo "${extraConfig}";
+
+    echo "$extraConfig" | while read; do
+	optionName=$( echo "$REPLY" | sed -e 's/[^A-Z_]//g' );
+	echo --optionName--;
+	echo "$REPLY";
+	echo ${optionName};
+	if [ -n "${optionName}" ]; then 
+	    sed -e s/.'*'${optionName}.'*'/"$REPLY/" -i .config
+	fi;
+    done;
+
+    echo "$extraConfig" >> .config
+
+    #substituteInPlace scripts/kconfig/lxdialog/check-lxdialog.sh \
+    #    --replace /usr /no-such-path
+
+    # Necessary until NIXPKGS-38 is fixed:
+    echo "#! $SHELL" > scripts/kconfig/lxdialog/check-lxdialog.sh
+    chmod +x scripts/kconfig/lxdialog/check-lxdialog.sh
+    
+    make oldconfig \
+        $makeFlags "${makeFlagsArray[@]}"
+
+    echo --finalConfig--
+    cat .config
+}
+
+
+installPhase=installPhase
+installPhase() {
+
+    ensureDir $out
+
+    # Copy the bzImage and System.map.
+    cp System.map $out
+    if test "$arch" = um; then
+        ensureDir $out/bin
+        cp linux $out/bin
+    else
+        cp arch/$arch/boot/bzImage $out/vmlinuz
+    fi
+
+    # Install the modules in $out/lib/modules with matching paths
+    # in modules.dep (i.e., refererring to $out/lib/modules, not
+    # /lib/modules).  The depmod_opts= is to prevent the kernel
+    # from passing `-b PATH' to depmod.
+    export MODULE_DIR=$out/lib/modules/
+    make modules_install \
+        DEPMOD=$module_init_tools/sbin/depmod depmod_opts= \
+        $makeFlags "${makeFlagsArray[@]}" \
+        $installFlags "${installFlagsArray[@]}"
+
+    # Strip the kernel modules.
+    echo "Stripping kernel modules..."
+    find $out -name "*.ko" -print0 | xargs -0 strip -S
+
+    # move this to install later on
+    # largely copied from early FC3 kernel spec files
+    version=$(cd $out/lib/modules && ls -d *)
+
+    # remove symlinks and create directories
+    rm -f $out/lib/modules/$version/build
+    rm -f $out/lib/modules/$version/source
+    mkdir $out/lib/modules/$version/build
+
+    # copy config
+    cp .config $out/lib/modules/$version/build/.config
+
+    if test "$arch" != um; then
+        # copy all Makefiles and Kconfig files
+        ln -s $out/lib/modules/$version/build $out/lib/modules/$version/source
+        cp --parents `find  -type f -name "Makefile*" -o -name "Kconfig*"` $out/lib/modules/$version/build
+        cp Module.symvers $out/lib/modules/$version/build
+
+        # weed out unneeded stuff
+        rm -rf $out/lib/modules/$version/build/Documentation
+        rm -rf $out/lib/modules/$version/build/scripts
+        rm -rf $out/lib/modules/$version/build/include
+
+        # copy architecture dependent files
+        cp -a arch/$arch/scripts $out/lib/modules/$version/build || true
+        cp -a arch/$arch/*lds $out/lib/modules/$version/build || true
+        cp -a "arch/$arch/Makefile*.cpu" $out/lib/modules/$version/build/arch/$arch || true
+        cp -a --parents arch/$arch/kernel/asm-offsets.s $out/lib/modules/$version/build/arch/$arch/kernel || true
+
+        # copy scripts
+        rm -f scripts/*.o
+        rm -f scripts/*/*.o
+        cp -a scripts $out/lib/modules/$version/build
+
+        # copy include files
+        mkdir -p $out/lib/modules/$version/build/include
+        cd include
+        cp -a acpi config linux math-emu media net pcmcia rxrpc scsi sound video asm asm-generic $out/lib/modules/$version/build/include
+        cp -a `readlink asm` $out/lib/modules/$version/build/include
+        cd ..
+    fi
+}
+
+
+genericBuild
diff --git a/pkgs/os-specific/linux/kernel/builder.sh b/pkgs/os-specific/linux/kernel/builder.sh
index 3512a74c196..c5805d3242e 100644
--- a/pkgs/os-specific/linux/kernel/builder.sh
+++ b/pkgs/os-specific/linux/kernel/builder.sh
@@ -57,13 +57,19 @@ installPhase() {
 
     ensureDir $out
 
+    # New kernel versions have a combined tree for i386 and x86_64.
+    archDir=$arch
+    if test -e arch/x86 -a \( "$arch" = i386 -o "$arch" = x86_64 \); then
+        archDir=x86
+    fi
+
     # Copy the bzImage and System.map.
     cp System.map $out
     if test "$arch" = um; then
         ensureDir $out/bin
         cp linux $out/bin
     else
-        cp arch/$arch/boot/bzImage $out/vmlinuz
+        cp arch/$archDir/boot/bzImage $out/vmlinuz
     fi
 
     # Install the modules in $out/lib/modules with matching paths
@@ -71,6 +77,7 @@ installPhase() {
     # /lib/modules).  The depmod_opts= is to prevent the kernel
     # from passing `-b PATH' to depmod.
     export MODULE_DIR=$out/lib/modules/
+    substituteInPlace Makefile --replace '-b $(INSTALL_MOD_PATH) -r' ''
     make modules_install \
         DEPMOD=$module_init_tools/sbin/depmod depmod_opts= \
         $makeFlags "${makeFlagsArray[@]}" \
@@ -104,10 +111,10 @@ installPhase() {
         rm -rf $out/lib/modules/$version/build/include
 
         # copy architecture dependent files
-        cp -a arch/$arch/scripts $out/lib/modules/$version/build || true
-        cp -a arch/$arch/*lds $out/lib/modules/$version/build || true
-        cp -a arch/$arch/Makefile.cpu $out/lib/modules/$version/build/arch/$arch || true
-        cp -a --parents arch/$arch/kernel/asm-offsets.s $out/lib/modules/$version/build/arch/$arch/kernel || true
+        cp -a arch/$archDir/scripts $out/lib/modules/$version/build/ || true
+        cp -a arch/$archDir/*lds $out/lib/modules/$version/build/ || true
+        cp -a arch/$archDir/Makefile*.cpu $out/lib/modules/$version/build/arch/$archDir/ || true
+        cp -a --parents arch/$archDir/kernel/asm-offsets.s $out/lib/modules/$version/build/arch/$archDir/kernel/ || true
 
         # copy scripts
         rm -f scripts/*.o
diff --git a/pkgs/os-specific/linux/kernel/config-2.6.25-i686-smp b/pkgs/os-specific/linux/kernel/config-2.6.25-i686-smp
new file mode 100644
index 00000000000..73f49281c79
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/config-2.6.25-i686-smp
@@ -0,0 +1,4043 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.25
+# Tue Apr 22 13:23:38 2008
+#
+# CONFIG_64BIT is not set
+CONFIG_X86_32=y
+# CONFIG_X86_64 is not set
+CONFIG_X86=y
+# CONFIG_GENERIC_LOCKBREAK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_CLOCKSOURCE_WATCHDOG=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_SEMAPHORE_SLEEPERS=y
+CONFIG_FAST_CMPXCHG_LOCAL=y
+CONFIG_MMU=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_HWEIGHT=y
+# CONFIG_GENERIC_GPIO is not set
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_DMI=y
+# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+# CONFIG_GENERIC_TIME_VSYSCALL is not set
+CONFIG_ARCH_HAS_CPU_RELAX=y
+# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# CONFIG_ZONE_DMA32 is not set
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+# CONFIG_AUDIT_ARCH is not set
+CONFIG_ARCH_SUPPORTS_AOUT=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_32_SMP=y
+CONFIG_X86_HT=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
+CONFIG_KTIME_SCALAR=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-default"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+# CONFIG_TASKSTATS is not set
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_TREE=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=17
+# CONFIG_CGROUPS is not set
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_IPC_NS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+# CONFIG_MARKERS is not set
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+CONFIG_BLOCK=y
+CONFIG_LBD=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_LSF is not set
+# CONFIG_BLK_DEV_BSG is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_CLASSIC_RCU=y
+
+#
+# Processor type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SMP=y
+CONFIG_X86_PC=y
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_NUMAQ is not set
+# CONFIG_X86_SUMMIT is not set
+# CONFIG_X86_BIGSMP is not set
+# CONFIG_X86_VISWS is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_ES7000 is not set
+# CONFIG_X86_RDC321X is not set
+# CONFIG_X86_VSMP is not set
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
+CONFIG_PARAVIRT_GUEST=y
+# CONFIG_XEN is not set
+CONFIG_VMI=y
+CONFIG_LGUEST_GUEST=y
+CONFIG_PARAVIRT=y
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+CONFIG_M686=y
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+# CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+# CONFIG_GENERIC_CPU is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_XADD=y
+CONFIG_X86_PPRO_FENCE=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_GOOD_APIC=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_USE_PPRO_CHECKSUM=y
+CONFIG_X86_TSC=y
+CONFIG_X86_CMOV=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=4
+CONFIG_X86_DEBUGCTLMSR=y
+CONFIG_HPET_TIMER=y
+CONFIG_HPET_EMULATE_RTC=y
+# CONFIG_IOMMU_HELPER is not set
+CONFIG_NR_CPUS=8
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_MCE=y
+CONFIG_X86_MCE_NONFATAL=y
+CONFIG_X86_MCE_P4THERMAL=y
+CONFIG_VM86=y
+CONFIG_TOSHIBA=m
+CONFIG_I8K=m
+CONFIG_X86_REBOOTFIXUPS=y
+CONFIG_MICROCODE=m
+CONFIG_MICROCODE_OLD_INTERFACE=y
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+# CONFIG_NOHIGHMEM is not set
+CONFIG_HIGHMEM4G=y
+# CONFIG_HIGHMEM64G is not set
+CONFIG_PAGE_OFFSET=0xC0000000
+CONFIG_HIGHMEM=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+CONFIG_ARCH_SELECT_MEMORY_MODEL=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_SPARSEMEM_STATIC=y
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HIGHPTE=y
+# CONFIG_MATH_EMULATION is not set
+CONFIG_MTRR=y
+CONFIG_EFI=y
+CONFIG_IRQBALANCE=y
+CONFIG_SECCOMP=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_KEXEC=y
+# CONFIG_CRASH_DUMP is not set
+CONFIG_PHYSICAL_START=0x100000
+# CONFIG_RELOCATABLE is not set
+CONFIG_PHYSICAL_ALIGN=0x100000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_COMPAT_VDSO=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+
+#
+# Power management options
+#
+CONFIG_PM=y
+CONFIG_PM_LEGACY=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP_SMP=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION=""
+CONFIG_ACPI=y
+CONFIG_ACPI_SLEEP=y
+CONFIG_ACPI_PROCFS=y
+CONFIG_ACPI_PROCFS_POWER=y
+CONFIG_ACPI_SYSFS_POWER=y
+CONFIG_ACPI_PROC_EVENT=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_DOCK=m
+CONFIG_ACPI_BAY=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_WMI=m
+CONFIG_ACPI_ASUS=m
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_CUSTOM_DSDT_FILE=""
+# CONFIG_ACPI_CUSTOM_DSDT is not set
+CONFIG_ACPI_BLACKLIST_YEAR=2001
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_X86_PM_TIMER=y
+CONFIG_ACPI_CONTAINER=m
+# CONFIG_ACPI_SBS is not set
+CONFIG_X86_APM_BOOT=y
+CONFIG_APM=y
+# CONFIG_APM_IGNORE_USER_SUSPEND is not set
+CONFIG_APM_DO_ENABLE=y
+# CONFIG_APM_CPU_IDLE is not set
+CONFIG_APM_DISPLAY_BLANK=y
+CONFIG_APM_ALLOW_INTS=y
+# CONFIG_APM_REAL_MODE_POWER_OFF is not set
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=m
+# CONFIG_CPU_FREQ_DEBUG is not set
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+CONFIG_X86_POWERNOW_K6=m
+CONFIG_X86_POWERNOW_K7=m
+CONFIG_X86_POWERNOW_K7_ACPI=y
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+CONFIG_X86_GX_SUSPMOD=m
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
+CONFIG_X86_SPEEDSTEP_ICH=m
+CONFIG_X86_SPEEDSTEP_SMI=m
+CONFIG_X86_P4_CLOCKMOD=m
+CONFIG_X86_CPUFREQ_NFORCE2=m
+CONFIG_X86_LONGRUN=m
+CONFIG_X86_LONGHAUL=m
+CONFIG_X86_E_POWERSAVER=m
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+CONFIG_X86_SPEEDSTEP_LIB=m
+CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK=y
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_GOV_LADDER=y
+CONFIG_CPU_IDLE_GOV_MENU=y
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+# CONFIG_PCI_GOBIOS is not set
+# CONFIG_PCI_GOMMCONFIG is not set
+# CONFIG_PCI_GODIRECT is not set
+CONFIG_PCI_GOANY=y
+CONFIG_PCI_BIOS=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+CONFIG_PCIEAER=y
+CONFIG_ARCH_SUPPORTS_MSI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_HT_IRQ=y
+CONFIG_ISA_DMA_API=y
+CONFIG_ISA=y
+# CONFIG_EISA is not set
+# CONFIG_MCA is not set
+CONFIG_SCx200=m
+CONFIG_SCx200HR_TIMER=m
+CONFIG_K8_NB=y
+CONFIG_PCCARD=m
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=m
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=m
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+CONFIG_I82092=m
+CONFIG_I82365=m
+CONFIG_TCIC=m
+CONFIG_PCMCIA_PROBE=y
+CONFIG_PCCARD_NONSTATIC=m
+CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_COMPAQ=m
+CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM=y
+CONFIG_HOTPLUG_PCI_IBM=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+CONFIG_HOTPLUG_PCI_CPCI=y
+CONFIG_HOTPLUG_PCI_CPCI_ZT5550=m
+CONFIG_HOTPLUG_PCI_CPCI_GENERIC=m
+CONFIG_HOTPLUG_PCI_SHPC=m
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=m
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_NET_KEY=m
+# CONFIG_NET_KEY_MIGRATE is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=m
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=m
+CONFIG_TCP_CONG_CUBIC=m
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+# CONFIG_TCP_CONG_LP is not set
+# CONFIG_TCP_CONG_VENO is not set
+CONFIG_TCP_CONG_YEAH=m
+CONFIG_TCP_CONG_ILLINOIS=m
+# CONFIG_DEFAULT_BIC is not set
+# CONFIG_DEFAULT_CUBIC is not set
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+CONFIG_DEFAULT_RENO=y
+CONFIG_DEFAULT_TCP_CONG="reno"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+# CONFIG_IPV6_MIP6 is not set
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_TUNNEL=m
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_NETLABEL is not set
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CT_ACCT=y
+CONFIG_NF_CONNTRACK_MARK=y
+# CONFIG_NF_CONNTRACK_SECMARK is not set
+# CONFIG_NF_CONNTRACK_EVENTS is not set
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=m
+CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CONNTRACK_AMANDA=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_NETBIOS_NS=m
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SANE=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_DSCP=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_RATEEST=m
+CONFIG_NETFILTER_XT_TARGET_TRACE=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_DSCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_OWNER=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_RATEEST=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_TIME=m
+CONFIG_NETFILTER_XT_MATCH_U32=m
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV4=m
+CONFIG_NF_CONNTRACK_PROC_COMPAT=y
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_NF_NAT_SNMP_BASIC=m
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_TFTP=m
+CONFIG_NF_NAT_AMANDA=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+# CONFIG_IP_NF_ARPTABLES is not set
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_MH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+
+#
+# DECnet: Netfilter Configuration
+#
+CONFIG_DECNET_NF_GRABULATOR=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+# CONFIG_IP_DCCP is not set
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_TIPC is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+CONFIG_ATM_CLIP_NO_ICMP=y
+CONFIG_ATM_LANE=m
+CONFIG_ATM_MPOA=m
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+CONFIG_DECNET=m
+CONFIG_DECNET_ROUTER=y
+CONFIG_LLC=y
+CONFIG_LLC2=m
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=m
+CONFIG_LTPC=m
+CONFIG_COPS=m
+CONFIG_COPS_DAYNA=y
+CONFIG_COPS_TANGENT=y
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+CONFIG_X25=m
+CONFIG_LAPB=m
+CONFIG_ECONET=m
+# CONFIG_ECONET_AUNUDP is not set
+# CONFIG_ECONET_NATIVE is not set
+CONFIG_WAN_ROUTER=m
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RR=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_CLS_FLOW=m
+# CONFIG_NET_EMATCH is not set
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_NAT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+# CONFIG_NET_CLS_IND is not set
+CONFIG_NET_SCH_FIFO=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+CONFIG_HAMRADIO=y
+
+#
+# Packet Radio protocols
+#
+CONFIG_AX25=m
+CONFIG_AX25_DAMA_SLAVE=y
+CONFIG_NETROM=m
+CONFIG_ROSE=m
+
+#
+# AX.25 network device drivers
+#
+CONFIG_MKISS=m
+CONFIG_6PACK=m
+CONFIG_BPQETHER=m
+CONFIG_SCC=m
+CONFIG_SCC_DELAY=y
+CONFIG_SCC_TRXECHO=y
+CONFIG_BAYCOM_SER_FDX=m
+CONFIG_BAYCOM_SER_HDX=m
+CONFIG_BAYCOM_PAR=m
+CONFIG_BAYCOM_EPP=m
+CONFIG_YAM=m
+# CONFIG_CAN is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+CONFIG_IRDA_ULTRA=y
+
+#
+# IrDA options
+#
+CONFIG_IRDA_CACHE_LAST_LSAP=y
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+CONFIG_DONGLE=y
+CONFIG_ESI_DONGLE=m
+CONFIG_ACTISYS_DONGLE=m
+CONFIG_TEKRAM_DONGLE=m
+# CONFIG_TOIM3232_DONGLE is not set
+CONFIG_LITELINK_DONGLE=m
+CONFIG_MA600_DONGLE=m
+CONFIG_GIRBIL_DONGLE=m
+CONFIG_MCP2120_DONGLE=m
+CONFIG_OLD_BELKIN_DONGLE=m
+CONFIG_ACT200L_DONGLE=m
+CONFIG_KINGSUN_DONGLE=m
+# CONFIG_KSDAZZLE_DONGLE is not set
+# CONFIG_KS959_DONGLE is not set
+
+#
+# FIR device drivers
+#
+CONFIG_USB_IRDA=m
+CONFIG_SIGMATEL_FIR=m
+CONFIG_NSC_FIR=m
+CONFIG_WINBOND_FIR=m
+CONFIG_TOSHIBA_FIR=m
+CONFIG_SMC_IRCC_FIR=m
+CONFIG_ALI_FIR=m
+CONFIG_VLSI_FIR=m
+CONFIG_VIA_FIR=m
+CONFIG_MCS_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIUSB=m
+CONFIG_BT_HCIUSB_SCO=y
+CONFIG_BT_HCIBTSDIO=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_AF_RXRPC=m
+# CONFIG_AF_RXRPC_DEBUG is not set
+CONFIG_RXKAD=m
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_SIMPLE is not set
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_RC_SIMPLE is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_IEEE80211_SOFTMAC=m
+# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
+CONFIG_RFKILL=m
+CONFIG_RFKILL_INPUT=m
+CONFIG_RFKILL_LEDS=y
+CONFIG_NET_9P=m
+CONFIG_NET_9P_FD=m
+# CONFIG_NET_9P_VIRTIO is not set
+# CONFIG_NET_9P_DEBUG is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=m
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=m
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLKDEVS=m
+CONFIG_MTD_BLOCK=m
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+CONFIG_MTD_OOPS=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ABSENT=m
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=m
+CONFIG_MTD_PHYSMAP_START=0x8000000
+CONFIG_MTD_PHYSMAP_LEN=0x4000000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+CONFIG_MTD_SBC_GXX=m
+CONFIG_MTD_SCx200_DOCFLASH=m
+CONFIG_MTD_AMD76XROM=m
+CONFIG_MTD_ICHXROM=m
+CONFIG_MTD_ESB2ROM=m
+CONFIG_MTD_CK804XROM=m
+CONFIG_MTD_SCB2_FLASH=m
+CONFIG_MTD_NETtel=m
+CONFIG_MTD_DILNETPC=m
+CONFIG_MTD_DILNETPC_BOOTSIZE=0x80000
+CONFIG_MTD_L440GX=m
+CONFIG_MTD_PCI=m
+CONFIG_MTD_INTEL_VR_NOR=m
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_PMC551=m
+CONFIG_MTD_PMC551_BUGFIX=y
+# CONFIG_MTD_PMC551_DEBUG is not set
+CONFIG_MTD_DATAFLASH=m
+CONFIG_MTD_M25P80=m
+CONFIG_MTD_SLRAM=m
+CONFIG_MTD_PHRAM=m
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+CONFIG_MTD_DOC2000=m
+CONFIG_MTD_DOC2001=m
+CONFIG_MTD_DOC2001PLUS=m
+CONFIG_MTD_DOCPROBE=m
+CONFIG_MTD_DOCECC=m
+CONFIG_MTD_DOCPROBE_ADVANCED=y
+CONFIG_MTD_DOCPROBE_ADDRESS=0x0000
+CONFIG_MTD_DOCPROBE_HIGH=y
+CONFIG_MTD_DOCPROBE_55AA=y
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
+CONFIG_MTD_NAND_CAFE=m
+# CONFIG_MTD_NAND_CS553X is not set
+CONFIG_MTD_NAND_NANDSIM=m
+CONFIG_MTD_NAND_PLATFORM=m
+CONFIG_MTD_ALAUDA=m
+# CONFIG_MTD_ONENAND is not set
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=m
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+CONFIG_PARPORT_PC_FIFO=y
+CONFIG_PARPORT_PC_SUPERIO=y
+CONFIG_PARPORT_PC_PCMCIA=m
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
+CONFIG_PARPORT_NOT_PC=y
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_ISAPNP=y
+# CONFIG_PNPBIOS is not set
+CONFIG_PNPACPI=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_FD=y
+CONFIG_BLK_DEV_XD=m
+CONFIG_PARIDE=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_BPCK6=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=64000
+# CONFIG_BLK_DEV_XIP is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+CONFIG_ATA_OVER_ETH=m
+CONFIG_VIRTIO_BLK=m
+CONFIG_MISC_DEVICES=y
+CONFIG_IBM_ASM=m
+CONFIG_PHANTOM=m
+CONFIG_EEPROM_93CX6=m
+# CONFIG_SGI_IOC4 is not set
+CONFIG_TIFM_CORE=m
+CONFIG_TIFM_7XX1=m
+CONFIG_ACER_WMI=m
+CONFIG_ASUS_LAPTOP=m
+CONFIG_FUJITSU_LAPTOP=m
+CONFIG_TC1100_WMI=m
+CONFIG_MSI_LAPTOP=m
+CONFIG_SONY_LAPTOP=m
+CONFIG_SONYPI_COMPAT=y
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+CONFIG_INTEL_MENLOW=m
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=m
+CONFIG_BLK_DEV_IDE=m
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=m
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_DELKIN=m
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_BLK_DEV_IDEACPI=y
+# CONFIG_IDE_TASK_IOCTL is not set
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=m
+CONFIG_BLK_DEV_PLATFORM=m
+CONFIG_BLK_DEV_CMD640=m
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=m
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_BLK_DEV_OFFBOARD=y
+CONFIG_BLK_DEV_GENERIC=m
+CONFIG_BLK_DEV_OPTI621=m
+CONFIG_BLK_DEV_RZ1000=m
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_AEC62XX=m
+CONFIG_BLK_DEV_ALI15X3=m
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=m
+CONFIG_BLK_DEV_ATIIXP=m
+CONFIG_BLK_DEV_CMD64X=m
+CONFIG_BLK_DEV_TRIFLEX=m
+CONFIG_BLK_DEV_CY82C693=m
+CONFIG_BLK_DEV_CS5520=m
+CONFIG_BLK_DEV_CS5530=m
+CONFIG_BLK_DEV_CS5535=m
+CONFIG_BLK_DEV_HPT34X=m
+CONFIG_HPT34X_AUTODMA=y
+CONFIG_BLK_DEV_HPT366=m
+CONFIG_BLK_DEV_JMICRON=m
+CONFIG_BLK_DEV_SC1200=m
+CONFIG_BLK_DEV_PIIX=m
+CONFIG_BLK_DEV_IT8213=m
+CONFIG_BLK_DEV_IT821X=m
+CONFIG_BLK_DEV_NS87415=m
+CONFIG_BLK_DEV_PDC202XX_OLD=m
+CONFIG_BLK_DEV_PDC202XX_NEW=m
+CONFIG_BLK_DEV_SVWKS=m
+CONFIG_BLK_DEV_SIIMAGE=m
+CONFIG_BLK_DEV_SIS5513=m
+CONFIG_BLK_DEV_SLC90E66=m
+CONFIG_BLK_DEV_TRM290=m
+CONFIG_BLK_DEV_VIA82CXXX=m
+CONFIG_BLK_DEV_TC86C001=m
+
+#
+# Other IDE chipsets support
+#
+
+#
+# Note: most of these also require special kernel boot parameters
+#
+CONFIG_BLK_DEV_4DRIVES=y
+CONFIG_BLK_DEV_ALI14XX=m
+CONFIG_BLK_DEV_DTC2278=m
+CONFIG_BLK_DEV_HT6560B=m
+CONFIG_BLK_DEV_QD65XX=m
+CONFIG_BLK_DEV_UMC8672=m
+CONFIG_BLK_DEV_IDEDMA=y
+CONFIG_IDE_ARCH_OBSOLETE_INIT=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_ENCLOSURE=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+# CONFIG_SCSI_FC_TGT_ATTRS is not set
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+# CONFIG_SCSI_SAS_ATA is not set
+CONFIG_SCSI_SAS_HOST_SMP=y
+# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ISCSI_TCP=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_7000FASST=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AHA152X=m
+CONFIG_SCSI_AHA1542=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
+CONFIG_AIC7XXX_RESET_DELAY_MS=5000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=32
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+CONFIG_AIC79XX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC94XX=m
+# CONFIG_AIC94XX_DEBUG is not set
+CONFIG_SCSI_DPT_I2O=m
+CONFIG_SCSI_ADVANSYS=m
+CONFIG_SCSI_IN2000=m
+CONFIG_SCSI_ARCMSR=m
+# CONFIG_SCSI_ARCMSR_AER is not set
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+CONFIG_SCSI_BUSLOGIC=m
+# CONFIG_SCSI_OMIT_FLASHPOINT is not set
+CONFIG_SCSI_DMX3191D=m
+CONFIG_SCSI_DTC3280=m
+CONFIG_SCSI_EATA=m
+CONFIG_SCSI_EATA_TAGGED_QUEUE=y
+CONFIG_SCSI_EATA_LINKED_COMMANDS=y
+CONFIG_SCSI_EATA_MAX_TAGS=16
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_GENERIC_NCR5380=m
+CONFIG_SCSI_GENERIC_NCR5380_MMIO=m
+CONFIG_SCSI_GENERIC_NCR53C400=y
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+CONFIG_SCSI_INIA100=m
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_MVSAS=m
+CONFIG_SCSI_NCR53C406A=m
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+CONFIG_SCSI_IPR=m
+# CONFIG_SCSI_IPR_TRACE is not set
+# CONFIG_SCSI_IPR_DUMP is not set
+CONFIG_SCSI_PAS16=m
+CONFIG_SCSI_QLOGIC_FAS=m
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_SYM53C416=m
+CONFIG_SCSI_DC395x=m
+CONFIG_SCSI_DC390T=m
+CONFIG_SCSI_T128=m
+CONFIG_SCSI_U14_34F=m
+CONFIG_SCSI_U14_34F_TAGGED_QUEUE=y
+CONFIG_SCSI_U14_34F_LINKED_COMMANDS=y
+CONFIG_SCSI_U14_34F_MAX_TAGS=8
+CONFIG_SCSI_ULTRASTOR=m
+CONFIG_SCSI_NSP32=m
+CONFIG_SCSI_DEBUG=m
+CONFIG_SCSI_SRP=m
+CONFIG_SCSI_LOWLEVEL_PCMCIA=y
+CONFIG_PCMCIA_AHA152X=m
+CONFIG_PCMCIA_FDOMAIN=m
+CONFIG_PCMCIA_NINJA_SCSI=m
+CONFIG_PCMCIA_QLOGIC=m
+CONFIG_PCMCIA_SYM53C500=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+# CONFIG_SATA_MV is not set
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIL24=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+CONFIG_PATA_ACPI=m
+CONFIG_PATA_ALI=m
+CONFIG_PATA_AMD=m
+CONFIG_PATA_ARTOP=m
+CONFIG_PATA_ATIIXP=m
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_CMD64X is not set
+CONFIG_PATA_CS5520=m
+CONFIG_PATA_CS5530=m
+CONFIG_PATA_CS5535=m
+CONFIG_PATA_CS5536=m
+# CONFIG_PATA_CYPRESS is not set
+CONFIG_PATA_EFAR=m
+CONFIG_ATA_GENERIC=m
+CONFIG_PATA_HPT366=m
+CONFIG_PATA_HPT37X=m
+CONFIG_PATA_HPT3X2N=m
+CONFIG_PATA_HPT3X3=m
+# CONFIG_PATA_HPT3X3_DMA is not set
+# CONFIG_PATA_ISAPNP is not set
+CONFIG_PATA_IT821X=m
+CONFIG_PATA_IT8213=m
+CONFIG_PATA_JMICRON=m
+# CONFIG_PATA_LEGACY is not set
+CONFIG_PATA_TRIFLEX=m
+CONFIG_PATA_MARVELL=m
+CONFIG_PATA_MPIIX=m
+CONFIG_PATA_OLDPIIX=m
+CONFIG_PATA_NETCELL=m
+CONFIG_PATA_NINJA32=m
+CONFIG_PATA_NS87410=m
+CONFIG_PATA_NS87415=m
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_OPTIDMA is not set
+CONFIG_PATA_PCMCIA=m
+# CONFIG_PATA_PDC_OLD is not set
+CONFIG_PATA_QDI=m
+# CONFIG_PATA_RADISYS is not set
+CONFIG_PATA_RZ1000=m
+CONFIG_PATA_SC1200=m
+CONFIG_PATA_SERVERWORKS=m
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+CONFIG_PATA_VIA=m
+CONFIG_PATA_WINBOND=m
+CONFIG_PATA_WINBOND_VLB=m
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+# CONFIG_MD_RAID5_RESHAPE is not set
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_MULTIPATH_EMC=m
+CONFIG_DM_MULTIPATH_RDAC=m
+CONFIG_DM_MULTIPATH_HP=m
+# CONFIG_DM_DELAY is not set
+CONFIG_DM_UEVENT=y
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+# CONFIG_FUSION_LOGGING is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_FIREWIRE is not set
+CONFIG_IEEE1394=m
+
+#
+# Subsystem Options
+#
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+
+#
+# Controllers
+#
+CONFIG_IEEE1394_PCILYNX=m
+CONFIG_IEEE1394_OHCI1394=m
+
+#
+# Protocols
+#
+CONFIG_IEEE1394_VIDEO1394=m
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y
+CONFIG_IEEE1394_ETH1394=m
+CONFIG_IEEE1394_DV1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_I2O=m
+CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+CONFIG_MACINTOSH_DRIVERS=y
+CONFIG_MAC_EMUMOUSEBTN=y
+CONFIG_NETDEVICES=y
+# CONFIG_NETDEVICES_MULTIQUEUE is not set
+# CONFIG_IFB is not set
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+# CONFIG_MACVLAN is not set
+CONFIG_EQUALIZER=m
+CONFIG_TUN=m
+CONFIG_VETH=m
+CONFIG_NET_SB1000=m
+CONFIG_ARCNET=m
+CONFIG_ARCNET_1201=m
+CONFIG_ARCNET_1051=m
+CONFIG_ARCNET_RAW=m
+CONFIG_ARCNET_CAP=m
+CONFIG_ARCNET_COM90xx=m
+CONFIG_ARCNET_COM90xxIO=m
+CONFIG_ARCNET_RIM_I=m
+# CONFIG_ARCNET_COM20020 is not set
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_BROADCOM_PHY=m
+CONFIG_ICPLUS_PHY=m
+CONFIG_REALTEK_PHY=m
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_EL1=m
+CONFIG_EL2=m
+CONFIG_ELPLUS=m
+CONFIG_EL16=m
+CONFIG_EL3=m
+CONFIG_3C515=m
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_LANCE=m
+CONFIG_NET_VENDOR_SMC=y
+CONFIG_WD80x3=m
+CONFIG_ULTRA=m
+CONFIG_SMC9194=m
+CONFIG_ENC28J60=m
+# CONFIG_ENC28J60_WRITEVERIFY is not set
+CONFIG_NET_VENDOR_RACAL=y
+CONFIG_NI52=m
+CONFIG_NI65=m
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+CONFIG_TULIP_NAPI=y
+CONFIG_TULIP_NAPI_HW_MITIGATION=y
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+CONFIG_AT1700=m
+CONFIG_DEPCA=m
+CONFIG_HP100=m
+CONFIG_NET_ISA=y
+CONFIG_E2100=m
+CONFIG_EWRK3=m
+CONFIG_EEXPRESS=m
+CONFIG_EEXPRESS_PRO=m
+CONFIG_HPLAN_PLUS=m
+CONFIG_HPLAN=m
+CONFIG_LP486E=m
+CONFIG_ETH16I=m
+CONFIG_NE2000=m
+CONFIG_ZNET=m
+CONFIG_SEEQ8005=m
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+# CONFIG_PCNET32_NAPI is not set
+CONFIG_AMD8111_ETH=m
+# CONFIG_AMD8111E_NAPI is not set
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_AC3200=m
+CONFIG_APRICOT=m
+CONFIG_B44=m
+CONFIG_B44_PCI_AUTOSELECT=y
+CONFIG_B44_PCICORE_AUTOSELECT=y
+CONFIG_B44_PCI=y
+CONFIG_FORCEDETH=m
+# CONFIG_FORCEDETH_NAPI is not set
+CONFIG_CS89x0=m
+CONFIG_EEPRO100=m
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_R6040=m
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+# CONFIG_VIA_RHINE_MMIO is not set
+# CONFIG_VIA_RHINE_NAPI is not set
+CONFIG_SC92031=m
+CONFIG_NET_POCKET=y
+CONFIG_ATP=m
+CONFIG_DE600=m
+CONFIG_DE620=m
+CONFIG_NETDEV_1000=y
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_E1000E_ENABLED=y
+CONFIG_IP1000=m
+CONFIG_IGB=m
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+# CONFIG_R8169_NAPI is not set
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+# CONFIG_SKGE_DEBUG is not set
+# CONFIG_SKY2 is not set
+CONFIG_SK98LIN=m
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+CONFIG_ATL1=m
+CONFIG_NETDEV_10000=y
+CONFIG_CHELSIO_T1=m
+CONFIG_CHELSIO_T1_1G=y
+CONFIG_CHELSIO_T1_NAPI=y
+CONFIG_CHELSIO_T3=m
+CONFIG_IXGBE=m
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+CONFIG_MYRI10GE=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_MLX4_CORE=m
+CONFIG_MLX4_DEBUG=y
+CONFIG_TEHUTI=m
+CONFIG_BNX2X=m
+CONFIG_TR=y
+CONFIG_IBMTR=m
+CONFIG_IBMOL=m
+CONFIG_IBMLS=m
+CONFIG_3C359=m
+CONFIG_TMS380TR=m
+CONFIG_TMSPCI=m
+CONFIG_SKISA=m
+CONFIG_PROTEON=m
+CONFIG_ABYSS=m
+CONFIG_SMCTR=m
+
+#
+# Wireless LAN
+#
+# CONFIG_WLAN_PRE80211 is not set
+CONFIG_WLAN_80211=y
+CONFIG_PCMCIA_RAYCS=m
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_LIBERTAS=m
+CONFIG_LIBERTAS_USB=m
+CONFIG_LIBERTAS_CS=m
+CONFIG_LIBERTAS_SDIO=m
+# CONFIG_LIBERTAS_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_WL3501=m
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_USB_NET_RNDIS_WLAN=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_ADM8211=m
+CONFIG_P54_COMMON=m
+CONFIG_P54_USB=m
+CONFIG_P54_PCI=m
+CONFIG_ATH5K=m
+CONFIG_IWL4965=m
+CONFIG_IWL4965_QOS=y
+# CONFIG_IWL4965_HT is not set
+# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
+# CONFIG_IWL4965_SENSITIVITY is not set
+# CONFIG_IWL4965_DEBUG is not set
+CONFIG_IWL3945=m
+CONFIG_IWL3945_QOS=y
+# CONFIG_IWL3945_SPECTRUM_MEASUREMENT is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_BCM43XX=m
+CONFIG_BCM43XX_DEBUG=y
+CONFIG_BCM43XX_DMA=y
+CONFIG_BCM43XX_PIO=y
+CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
+# CONFIG_BCM43XX_DMA_MODE is not set
+# CONFIG_BCM43XX_PIO_MODE is not set
+CONFIG_B43=m
+CONFIG_B43_PCI_AUTOSELECT=y
+CONFIG_B43_PCICORE_AUTOSELECT=y
+CONFIG_B43_PCMCIA=y
+CONFIG_B43_LEDS=y
+CONFIG_B43_RFKILL=y
+# CONFIG_B43_DEBUG is not set
+CONFIG_B43LEGACY=m
+CONFIG_B43LEGACY_PCI_AUTOSELECT=y
+CONFIG_B43LEGACY_PCICORE_AUTOSELECT=y
+CONFIG_B43LEGACY_LEDS=y
+CONFIG_B43LEGACY_RFKILL=y
+CONFIG_B43LEGACY_DEBUG=y
+CONFIG_B43LEGACY_DMA=y
+CONFIG_B43LEGACY_PIO=y
+CONFIG_B43LEGACY_DMA_AND_PIO_MODE=y
+# CONFIG_B43LEGACY_DMA_MODE is not set
+# CONFIG_B43LEGACY_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2X00_LIB_RFKILL=y
+CONFIG_RT2400PCI=m
+CONFIG_RT2400PCI_RFKILL=y
+CONFIG_RT2500PCI=m
+CONFIG_RT2500PCI_RFKILL=y
+CONFIG_RT61PCI=m
+CONFIG_RT61PCI_RFKILL=y
+CONFIG_RT2500USB=m
+CONFIG_RT73USB=m
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+# CONFIG_USB_EPSON2888 is not set
+# CONFIG_USB_KC2190 is not set
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_PCMCIA_IBMTR=m
+CONFIG_WAN=y
+CONFIG_HOSTESS_SV11=m
+# CONFIG_COSA is not set
+CONFIG_LANMEDIA=m
+CONFIG_SEALEVEL_4021=m
+CONFIG_HDLC=m
+CONFIG_HDLC_RAW=m
+CONFIG_HDLC_RAW_ETH=m
+CONFIG_HDLC_CISCO=m
+CONFIG_HDLC_FR=m
+CONFIG_HDLC_X25=m
+CONFIG_PCI200SYN=m
+CONFIG_WANXL=m
+# CONFIG_PC300 is not set
+# CONFIG_PC300TOO is not set
+CONFIG_N2=m
+CONFIG_C101=m
+CONFIG_FARSYNC=m
+# CONFIG_DSCC4 is not set
+CONFIG_DLCI=m
+CONFIG_DLCI_MAX=8
+CONFIG_SDLA=m
+# CONFIG_WAN_ROUTER_DRIVERS is not set
+CONFIG_LAPBETHER=m
+CONFIG_X25_ASY=m
+# CONFIG_SBNI is not set
+CONFIG_ATM_DRIVERS=y
+# CONFIG_ATM_DUMMY is not set
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+CONFIG_ATM_ZATM=m
+# CONFIG_ATM_ZATM_DEBUG is not set
+CONFIG_ATM_NICSTAR=m
+CONFIG_ATM_NICSTAR_USE_SUNI=y
+CONFIG_ATM_NICSTAR_USE_IDT77105=y
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+CONFIG_ATM_IDT77252_RCV_ALL=y
+CONFIG_ATM_IDT77252_USE_SUNI=y
+# CONFIG_ATM_AMBASSADOR is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_IA=m
+# CONFIG_ATM_IA_DEBUG is not set
+CONFIG_ATM_FORE200E_MAYBE=m
+CONFIG_ATM_FORE200E_PCA=y
+CONFIG_ATM_FORE200E_PCA_DEFAULT_FW=y
+CONFIG_ATM_FORE200E_USE_TASKLET=y
+CONFIG_ATM_FORE200E_TX_RETRY=16
+CONFIG_ATM_FORE200E_DEBUG=0
+CONFIG_ATM_FORE200E=m
+CONFIG_ATM_HE=m
+CONFIG_ATM_HE_USE_SUNI=y
+CONFIG_FDDI=y
+CONFIG_DEFXX=m
+# CONFIG_DEFXX_MMIO is not set
+CONFIG_SKFP=m
+CONFIG_HIPPI=y
+CONFIG_ROADRUNNER=m
+CONFIG_ROADRUNNER_LARGE_RINGS=y
+CONFIG_PLIP=m
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+# CONFIG_PPPOL2TP is not set
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=m
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_NET_FC=y
+CONFIG_NETCONSOLE=m
+# CONFIG_NETCONSOLE_DYNAMIC is not set
+CONFIG_NETPOLL=y
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
+CONFIG_ISDN=m
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+CONFIG_ISDN_PPP_BSDCOMP=m
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+CONFIG_ISDN_X25=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+# CONFIG_HISAX_NO_SENDCOMPLETE is not set
+# CONFIG_HISAX_NO_LLC is not set
+# CONFIG_HISAX_NO_KEYPAD is not set
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_0=y
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_AVM_A1=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_IX1MICROR2=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_ASUSCOM=y
+CONFIG_HISAX_TELEINT=y
+CONFIG_HISAX_HFCS=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_SPORTSTER=y
+CONFIG_HISAX_MIC=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_ISURF=y
+CONFIG_HISAX_HSTSAPHIR=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+CONFIG_HISAX_DEBUG=y
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+CONFIG_HISAX_HFCUSB=m
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+CONFIG_ISDN_DRV_ICN=m
+CONFIG_ISDN_DRV_PCBIT=m
+CONFIG_ISDN_DRV_SC=m
+CONFIG_ISDN_DRV_ACT2000=m
+# CONFIG_ISDN_DRV_GIGASET is not set
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_CAPI_TRACE=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1ISA=m
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_T1ISA=m
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+CONFIG_CAPI_EICON=y
+CONFIG_ISDN_DIVAS=m
+CONFIG_ISDN_DIVAS_BRIPCI=y
+CONFIG_ISDN_DIVAS_PRIPCI=y
+CONFIG_ISDN_DIVAS_DIVACAPI=m
+CONFIG_ISDN_DIVAS_USERIDI=m
+CONFIG_ISDN_DIVAS_MAINT=m
+CONFIG_PHONE=m
+CONFIG_PHONE_IXJ=m
+CONFIG_PHONE_IXJ_PCMCIA=m
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+CONFIG_INPUT_POLLDEV=m
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+CONFIG_KEYBOARD_SUNKBD=m
+# CONFIG_KEYBOARD_LKKBD is not set
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_KEYBOARD_NEWTON=m
+CONFIG_KEYBOARD_STOWAWAY=m
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_LIFEBOOK=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_APPLETOUCH=m
+CONFIG_MOUSE_INPORT=m
+CONFIG_MOUSE_ATIXL=y
+CONFIG_MOUSE_LOGIBM=m
+CONFIG_MOUSE_PC110PAD=m
+# CONFIG_MOUSE_VSXXXAA is not set
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_USB=y
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_DB9=m
+CONFIG_JOYSTICK_GAMECON=m
+CONFIG_JOYSTICK_TURBOGRAFX=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+CONFIG_INPUT_TABLET=y
+CONFIG_TABLET_USB_ACECAD=m
+CONFIG_TABLET_USB_AIPTEK=m
+CONFIG_TABLET_USB_GTCO=m
+CONFIG_TABLET_USB_KBTAB=m
+CONFIG_TABLET_USB_WACOM=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ADS7846=m
+CONFIG_TOUCHSCREEN_FUJITSU=m
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_TOUCHSCREEN_PENMOUNT=m
+CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
+CONFIG_TOUCHSCREEN_TOUCHWIN=m
+CONFIG_TOUCHSCREEN_UCB1400=m
+CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
+CONFIG_TOUCHSCREEN_USB_EGALAX=y
+CONFIG_TOUCHSCREEN_USB_PANJIT=y
+CONFIG_TOUCHSCREEN_USB_3M=y
+CONFIG_TOUCHSCREEN_USB_ITM=y
+CONFIG_TOUCHSCREEN_USB_ETURBO=y
+CONFIG_TOUCHSCREEN_USB_GUNZE=y
+CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y
+CONFIG_TOUCHSCREEN_USB_IRTOUCH=y
+CONFIG_TOUCHSCREEN_USB_IDEALTEK=y
+CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y
+CONFIG_TOUCHSCREEN_USB_GOTOP=y
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=y
+CONFIG_INPUT_APANEL=m
+CONFIG_INPUT_WISTRON_BTNS=m
+CONFIG_INPUT_ATLAS_BTNS=m
+CONFIG_INPUT_ATI_REMOTE=m
+CONFIG_INPUT_ATI_REMOTE2=m
+CONFIG_INPUT_KEYSPAN_REMOTE=m
+CONFIG_INPUT_POWERMATE=m
+CONFIG_INPUT_YEALINK=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_CT82C710=m
+CONFIG_SERIO_PARKBD=m
+CONFIG_SERIO_PCIPS2=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+CONFIG_ROCKETPORT=m
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+CONFIG_DIGIEPCA=m
+# CONFIG_ESPSERIAL is not set
+# CONFIG_MOXA_INTELLIO is not set
+CONFIG_MOXA_SMARTIO=m
+# CONFIG_ISI is not set
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+CONFIG_RISCOM8=m
+# CONFIG_SPECIALIX is not set
+CONFIG_SX=m
+CONFIG_RIO=m
+CONFIG_RIO_OLDPCI=y
+CONFIG_STALDRV=y
+CONFIG_NOZOMI=m
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_PNP=y
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=8
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_FOURPORT=m
+CONFIG_SERIAL_8250_ACCENT=m
+CONFIG_SERIAL_8250_BOCA=m
+CONFIG_SERIAL_8250_EXAR_ST16C554=m
+CONFIG_SERIAL_8250_HUB6=m
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+CONFIG_PPDEV=m
+CONFIG_HVC_DRIVER=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_HW_RANDOM_GEODE=m
+CONFIG_HW_RANDOM_VIA=m
+CONFIG_NVRAM=m
+CONFIG_RTC=y
+CONFIG_DTLK=m
+CONFIG_R3964=m
+CONFIG_APPLICOM=m
+CONFIG_SONYPI=m
+
+#
+# PCMCIA character devices
+#
+CONFIG_SYNCLINK_CS=m
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+CONFIG_IPWIRELESS=m
+CONFIG_MWAVE=m
+CONFIG_SCx200_GPIO=m
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_CS5535_GPIO=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=4096
+CONFIG_HPET=y
+# CONFIG_HPET_RTC_IRQ is not set
+CONFIG_HPET_MMAP=y
+CONFIG_HANGCHECK_TIMER=m
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
+CONFIG_DEVPORT=y
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_I810=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_NFORCE2=m
+CONFIG_I2C_OCORES=m
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_PROSAVAGE=m
+CONFIG_I2C_SAVAGE4=m
+CONFIG_I2C_SIMTEC=m
+CONFIG_SCx200_I2C=m
+CONFIG_SCx200_I2C_SCL=12
+CONFIG_SCx200_I2C_SDA=13
+CONFIG_SCx200_ACB=m
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_TAOS_EVM=m
+CONFIG_I2C_STUB=m
+CONFIG_I2C_TINY_USB=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+CONFIG_I2C_VOODOO3=m
+CONFIG_I2C_PCA_ISA=m
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_DS1682=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_PCF8575=m
+CONFIG_SENSORS_PCF8591=m
+# CONFIG_TPS65010 is not set
+CONFIG_SENSORS_MAX6875=m
+CONFIG_SENSORS_TSL2550=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=m
+# CONFIG_SPI_BUTTERFLY is not set
+CONFIG_SPI_LM70_LLP=m
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_AT25=m
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_TLE62X0=m
+CONFIG_W1=m
+CONFIG_W1_CON=y
+
+#
+# 1-wire Bus Masters
+#
+CONFIG_W1_MASTER_MATROX=m
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS2482=m
+
+#
+# 1-wire Slaves
+#
+CONFIG_W1_SLAVE_THERM=m
+CONFIG_W1_SLAVE_SMEM=m
+CONFIG_W1_SLAVE_DS2433=m
+# CONFIG_W1_SLAVE_DS2433_CRC is not set
+CONFIG_W1_SLAVE_DS2760=m
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+# CONFIG_PDA_POWER is not set
+# CONFIG_BATTERY_DS2760 is not set
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ABITUGURU3=m
+CONFIG_SENSORS_AD7418=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1029=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ADT7470=m
+CONFIG_SENSORS_ADT7473=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_I5K_AMB=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_F71882FG=m
+CONFIG_SENSORS_F75375S=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_FSCHMD=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_CORETEMP=m
+CONFIG_SENSORS_IBMPEX=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM70=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_MAX6650=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_PC87427=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_DME1737=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_ADS7828=m
+CONFIG_SENSORS_THMC50=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT1211=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83L786NG=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+CONFIG_SENSORS_APPLESMC=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+CONFIG_THERMAL=y
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+CONFIG_ACQUIRE_WDT=m
+CONFIG_ADVANTECH_WDT=m
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+CONFIG_SC520_WDT=m
+CONFIG_EUROTECH_WDT=m
+CONFIG_IB700_WDT=m
+CONFIG_IBMASR=m
+CONFIG_WAFER_WDT=m
+CONFIG_I6300ESB_WDT=m
+CONFIG_ITCO_WDT=m
+CONFIG_ITCO_VENDOR_SUPPORT=y
+CONFIG_IT8712F_WDT=m
+CONFIG_HP_WATCHDOG=m
+CONFIG_SC1200_WDT=m
+CONFIG_SCx200_WDT=m
+CONFIG_PC87413_WDT=m
+CONFIG_60XX_WDT=m
+CONFIG_SBC8360_WDT=m
+CONFIG_SBC7240_WDT=m
+CONFIG_CPU5_WDT=m
+CONFIG_SMSC37B787_WDT=m
+CONFIG_W83627HF_WDT=m
+CONFIG_W83697HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+CONFIG_SBC_EPX_C3_WATCHDOG=m
+
+#
+# ISA-based Watchdog Cards
+#
+CONFIG_PCWATCHDOG=m
+CONFIG_MIXCOMWD=m
+CONFIG_WDT=m
+CONFIG_WDT_501=y
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB_POSSIBLE=y
+CONFIG_SSB=m
+CONFIG_SSB_PCIHOST_POSSIBLE=y
+CONFIG_SSB_PCIHOST=y
+CONFIG_SSB_B43_PCI_BRIDGE=y
+CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
+CONFIG_SSB_PCMCIAHOST=y
+# CONFIG_SSB_DEBUG is not set
+CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
+CONFIG_SSB_DRIVER_PCICORE=y
+
+#
+# Multifunction device drivers
+#
+CONFIG_MFD_SM501=m
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+CONFIG_VIDEO_TVAUDIO=m
+CONFIG_VIDEO_TDA7432=m
+CONFIG_VIDEO_TDA9840=m
+CONFIG_VIDEO_TDA9875=m
+CONFIG_VIDEO_TEA6415C=m
+CONFIG_VIDEO_TEA6420=m
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_M52790=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_VP27SMPX=m
+CONFIG_VIDEO_BT819=m
+CONFIG_VIDEO_BT856=m
+CONFIG_VIDEO_OV7670=m
+CONFIG_VIDEO_SAA7110=m
+CONFIG_VIDEO_SAA7111=m
+CONFIG_VIDEO_SAA7114=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_TVP5150=m
+CONFIG_VIDEO_VPX3220=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_SAA7185=m
+CONFIG_VIDEO_ADV7170=m
+CONFIG_VIDEO_ADV7175=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+CONFIG_VIDEO_VIVI=m
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_BT848_DVB=y
+CONFIG_VIDEO_SAA6588=m
+CONFIG_VIDEO_PMS=m
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+CONFIG_VIDEO_W9966=m
+CONFIG_VIDEO_CPIA=m
+CONFIG_VIDEO_CPIA_PP=m
+CONFIG_VIDEO_CPIA_USB=m
+# CONFIG_VIDEO_CPIA2 is not set
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+CONFIG_TUNER_3036=m
+CONFIG_VIDEO_STRADIS=m
+CONFIG_VIDEO_ZORAN_ZR36060=m
+CONFIG_VIDEO_ZORAN=m
+CONFIG_VIDEO_ZORAN_BUZ=m
+CONFIG_VIDEO_ZORAN_DC10=m
+CONFIG_VIDEO_ZORAN_DC30=m
+CONFIG_VIDEO_ZORAN_LML33=m
+CONFIG_VIDEO_ZORAN_LML33R10=m
+# CONFIG_VIDEO_ZORAN_AVS6EYES is not set
+CONFIG_VIDEO_MEYE=m
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_SAA7134_ALSA=m
+CONFIG_VIDEO_SAA7134_DVB=m
+CONFIG_VIDEO_MXB=m
+CONFIG_VIDEO_DPC=m
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_CX88_ALSA=m
+CONFIG_VIDEO_CX88_BLACKBIRD=m
+CONFIG_VIDEO_CX88_DVB=m
+CONFIG_VIDEO_CX88_VP3054=m
+CONFIG_VIDEO_CX23885=m
+CONFIG_VIDEO_IVTV=m
+CONFIG_VIDEO_FB_IVTV=m
+CONFIG_VIDEO_CAFE_CCIC=m
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_ONAIR_CREATOR=y
+CONFIG_VIDEO_PVRUSB2_ONAIR_USB2=y
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_EM28XX_ALSA=m
+CONFIG_VIDEO_USBVISION=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+CONFIG_USB_ZR364XX=m
+CONFIG_USB_STKWEBCAM=m
+CONFIG_RADIO_ADAPTERS=y
+CONFIG_RADIO_CADET=m
+CONFIG_RADIO_RTRACK=m
+CONFIG_RADIO_RTRACK2=m
+CONFIG_RADIO_AZTECH=m
+CONFIG_RADIO_GEMTEK=m
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+CONFIG_RADIO_SF16FMI=m
+CONFIG_RADIO_SF16FMR2=m
+CONFIG_RADIO_TERRATEC=m
+CONFIG_RADIO_TRUST=m
+CONFIG_RADIO_TYPHOON=m
+CONFIG_RADIO_TYPHOON_PROC_FS=y
+CONFIG_RADIO_ZOLTRIX=m
+CONFIG_USB_DSBR=m
+CONFIG_USB_SI470X=m
+CONFIG_DVB_CORE=m
+CONFIG_DVB_CORE_ATTACH=y
+CONFIG_DVB_CAPTURE_DRIVERS=y
+
+#
+# Supported SAA7146 based PCI Adapters
+#
+CONFIG_TTPCI_EEPROM=m
+CONFIG_DVB_AV7110=m
+# CONFIG_DVB_AV7110_FIRMWARE is not set
+CONFIG_DVB_AV7110_OSD=y
+CONFIG_DVB_BUDGET_CORE=m
+CONFIG_DVB_BUDGET=m
+CONFIG_DVB_BUDGET_CI=m
+CONFIG_DVB_BUDGET_AV=m
+CONFIG_DVB_BUDGET_PATCH=m
+
+#
+# Supported USB Adapters
+#
+CONFIG_DVB_USB=m
+# CONFIG_DVB_USB_DEBUG is not set
+CONFIG_DVB_USB_A800=m
+CONFIG_DVB_USB_DIBUSB_MB=m
+# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
+CONFIG_DVB_USB_DIBUSB_MC=m
+CONFIG_DVB_USB_DIB0700=m
+CONFIG_DVB_USB_UMT_010=m
+CONFIG_DVB_USB_CXUSB=m
+CONFIG_DVB_USB_M920X=m
+CONFIG_DVB_USB_GL861=m
+CONFIG_DVB_USB_AU6610=m
+CONFIG_DVB_USB_DIGITV=m
+CONFIG_DVB_USB_VP7045=m
+CONFIG_DVB_USB_VP702X=m
+CONFIG_DVB_USB_GP8PSK=m
+CONFIG_DVB_USB_NOVA_T_USB2=m
+CONFIG_DVB_USB_TTUSB2=m
+CONFIG_DVB_USB_DTT200U=m
+CONFIG_DVB_USB_OPERA1=m
+CONFIG_DVB_USB_AF9005=m
+CONFIG_DVB_USB_AF9005_REMOTE=m
+CONFIG_DVB_TTUSB_BUDGET=m
+CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_CINERGYT2=m
+# CONFIG_DVB_CINERGYT2_TUNING is not set
+
+#
+# Supported FlexCopII (B2C2) Adapters
+#
+CONFIG_DVB_B2C2_FLEXCOP=m
+CONFIG_DVB_B2C2_FLEXCOP_PCI=m
+CONFIG_DVB_B2C2_FLEXCOP_USB=m
+# CONFIG_DVB_B2C2_FLEXCOP_DEBUG is not set
+
+#
+# Supported BT878 Adapters
+#
+CONFIG_DVB_BT8XX=m
+
+#
+# Supported Pluto2 Adapters
+#
+# CONFIG_DVB_PLUTO2 is not set
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+# CONFIG_DVB_FE_CUSTOMISE is not set
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_CX24123=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_VES1X93=m
+CONFIG_DVB_S5H1420=m
+CONFIG_DVB_TDA10086=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_ZL10353=m
+CONFIG_DVB_DIB3000MB=m
+CONFIG_DVB_DIB3000MC=m
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_TDA10023=m
+CONFIG_DVB_STV0297=m
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+CONFIG_DVB_NXT200X=m
+CONFIG_DVB_OR51211=m
+CONFIG_DVB_OR51132=m
+CONFIG_DVB_BCM3510=m
+CONFIG_DVB_LGDT330X=m
+CONFIG_DVB_S5H1409=m
+
+#
+# Tuners/PLL support
+#
+CONFIG_DVB_PLL=m
+CONFIG_DVB_TDA826X=m
+CONFIG_DVB_TDA827X=m
+CONFIG_DVB_TDA18271=m
+CONFIG_DVB_TUNER_QT1010=m
+CONFIG_DVB_TUNER_MT2060=m
+CONFIG_DVB_TUNER_MT2266=m
+CONFIG_DVB_TUNER_MT2131=m
+CONFIG_DVB_TUNER_DIB0070=m
+CONFIG_DVB_TUNER_XC5000=m
+
+#
+# Miscellaneous devices
+#
+CONFIG_DVB_LNBP21=m
+CONFIG_DVB_ISL6421=m
+CONFIG_DVB_TUA6100=m
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_VIDEO_TUNER=m
+# CONFIG_VIDEO_TUNER_CUSTOMIZE is not set
+CONFIG_TUNER_XC2028=m
+CONFIG_TUNER_MT20XX=m
+CONFIG_TUNER_TDA8290=m
+CONFIG_TUNER_TEA5761=m
+CONFIG_TUNER_TEA5767=m
+CONFIG_TUNER_SIMPLE=m
+CONFIG_TUNER_TDA9887=m
+CONFIG_VIDEOBUF_GEN=m
+CONFIG_VIDEOBUF_DMA_SG=m
+CONFIG_VIDEOBUF_VMALLOC=m
+CONFIG_VIDEOBUF_DVB=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR_I2C=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_DAB=y
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+CONFIG_AGP=m
+CONFIG_AGP_ALI=m
+CONFIG_AGP_ATI=m
+CONFIG_AGP_AMD=m
+CONFIG_AGP_AMD64=m
+CONFIG_AGP_INTEL=m
+CONFIG_AGP_NVIDIA=m
+CONFIG_AGP_SIS=m
+CONFIG_AGP_SWORKS=m
+CONFIG_AGP_VIA=m
+CONFIG_AGP_EFFICEON=m
+CONFIG_DRM=m
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_DRM_VIA=m
+CONFIG_DRM_SAVAGE=m
+CONFIG_VGASTATE=m
+CONFIG_VIDEO_OUTPUT_CONTROL=m
+CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+CONFIG_FB_DDC=m
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+CONFIG_FB_SYS_FILLRECT=m
+CONFIG_FB_SYS_COPYAREA=m
+CONFIG_FB_SYS_IMAGEBLIT=m
+CONFIG_FB_SYS_FOPS=m
+CONFIG_FB_DEFERRED_IO=y
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+CONFIG_FB_CIRRUS=m
+CONFIG_FB_PM2=m
+CONFIG_FB_PM2_FIFO_DISCONNECT=y
+CONFIG_FB_CYBER2000=m
+CONFIG_FB_ARC=m
+# CONFIG_FB_ASILIANT is not set
+CONFIG_FB_IMSTT=y
+CONFIG_FB_VGA16=m
+CONFIG_FB_UVESA=m
+CONFIG_FB_VESA=y
+# CONFIG_FB_EFI is not set
+CONFIG_FB_IMAC=y
+CONFIG_FB_HECUBA=m
+CONFIG_FB_HGA=m
+CONFIG_FB_HGA_ACCEL=y
+CONFIG_FB_S1D13XXX=m
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+# CONFIG_FB_NVIDIA_DEBUG is not set
+CONFIG_FB_NVIDIA_BACKLIGHT=y
+CONFIG_FB_RIVA=m
+CONFIG_FB_RIVA_I2C=y
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_RIVA_BACKLIGHT=y
+CONFIG_FB_I810=m
+CONFIG_FB_I810_GTF=y
+CONFIG_FB_I810_I2C=y
+CONFIG_FB_LE80578=m
+CONFIG_FB_CARILLO_RANCH=m
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+CONFIG_FB_INTEL_I2C=y
+# CONFIG_FB_MATROX is not set
+CONFIG_FB_RADEON=m
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+# CONFIG_FB_RADEON_DEBUG is not set
+# CONFIG_FB_ATY128 is not set
+CONFIG_FB_ATY=m
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+# CONFIG_FB_S3 is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+CONFIG_FB_SIS=m
+CONFIG_FB_SIS_300=y
+CONFIG_FB_SIS_315=y
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+# CONFIG_FB_VT8623 is not set
+CONFIG_FB_CYBLA=m
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+# CONFIG_FB_ARK is not set
+CONFIG_FB_PM3=m
+CONFIG_FB_GEODE=y
+CONFIG_FB_GEODE_LX=m
+CONFIG_FB_GEODE_GX=m
+# CONFIG_FB_GEODE_GX_SET_FBSIZE is not set
+CONFIG_FB_GEODE_GX1=m
+CONFIG_FB_SM501=m
+# CONFIG_FB_VIRTUAL is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_LTV350QV=m
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_CORGI=m
+CONFIG_BACKLIGHT_PROGEAR=m
+CONFIG_BACKLIGHT_CARILLO_RANCH=m
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=m
+
+#
+# Display hardware drivers
+#
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+# CONFIG_VGACON_SOFT_SCROLLBACK is not set
+CONFIG_VIDEO_SELECT=y
+CONFIG_MDA_CONSOLE=m
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+# CONFIG_LOGO is not set
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_RTCTIMER=m
+CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y
+# CONFIG_SND_DYNAMIC_MINORS is not set
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_DEBUG=y
+# CONFIG_SND_DEBUG_DETECT is not set
+# CONFIG_SND_PCM_XRUN_DEBUG is not set
+
+#
+# Generic devices
+#
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_OPL4_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_MTS64=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+CONFIG_SND_PORTMAN2X4=m
+CONFIG_SND_AD1848_LIB=m
+CONFIG_SND_CS4231_LIB=m
+CONFIG_SND_SB_COMMON=m
+CONFIG_SND_SB8_DSP=m
+CONFIG_SND_SB16_DSP=m
+
+#
+# ISA devices
+#
+# CONFIG_SND_ADLIB is not set
+CONFIG_SND_AD1816A=m
+CONFIG_SND_AD1848=m
+CONFIG_SND_ALS100=m
+CONFIG_SND_AZT2320=m
+CONFIG_SND_CMI8330=m
+CONFIG_SND_CS4231=m
+CONFIG_SND_CS4232=m
+CONFIG_SND_CS4236=m
+CONFIG_SND_DT019X=m
+CONFIG_SND_ES968=m
+CONFIG_SND_ES1688=m
+CONFIG_SND_ES18XX=m
+CONFIG_SND_SC6000=m
+CONFIG_SND_GUS_SYNTH=m
+CONFIG_SND_GUSCLASSIC=m
+CONFIG_SND_GUSEXTREME=m
+CONFIG_SND_GUSMAX=m
+CONFIG_SND_INTERWAVE=m
+CONFIG_SND_INTERWAVE_STB=m
+CONFIG_SND_OPL3SA2=m
+CONFIG_SND_OPTI92X_AD1848=m
+CONFIG_SND_OPTI92X_CS4231=m
+CONFIG_SND_OPTI93X=m
+CONFIG_SND_MIRO=m
+CONFIG_SND_SB8=m
+CONFIG_SND_SB16=m
+CONFIG_SND_SBAWE=m
+CONFIG_SND_SB16_CSP=y
+CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL=y
+CONFIG_SND_SGALAXY=m
+CONFIG_SND_SSCAPE=m
+CONFIG_SND_WAVEFRONT=m
+CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL=y
+
+#
+# PCI devices
+#
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_OXYGEN_LIB=m
+CONFIG_SND_OXYGEN=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS5530=m
+CONFIG_SND_CS5535AUDIO=m
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_INTEL=m
+# CONFIG_SND_HDA_HWDEP is not set
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_CODEC_ANALOG=y
+CONFIG_SND_HDA_CODEC_SIGMATEL=y
+CONFIG_SND_HDA_CODEC_VIA=y
+CONFIG_SND_HDA_CODEC_ATIHDMI=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+CONFIG_SND_HDA_CODEC_CMEDIA=y
+CONFIG_SND_HDA_CODEC_SI3054=y
+CONFIG_SND_HDA_GENERIC=y
+# CONFIG_SND_HDA_POWER_SAVE is not set
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_HIFIER=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL=y
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL=y
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SIS7019=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VIRTUOSO=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y
+CONFIG_SND_AC97_POWER_SAVE=y
+CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0
+
+#
+# SPI devices
+#
+
+#
+# USB devices
+#
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+CONFIG_SND_USB_CAIAQ=m
+CONFIG_SND_USB_CAIAQ_INPUT=y
+
+#
+# PCMCIA devices
+#
+CONFIG_SND_VXPOCKET=m
+CONFIG_SND_PDAUDIOCF=m
+
+#
+# System on Chip audio support
+#
+# CONFIG_SND_SOC is not set
+
+#
+# SoC Audio support for SuperH
+#
+
+#
+# ALSA SoC audio for Freescale SOCs
+#
+
+#
+# Open Sound System
+#
+CONFIG_SOUND_PRIME=m
+CONFIG_SOUND_TRIDENT=m
+# CONFIG_SOUND_MSNDCLAS is not set
+# CONFIG_SOUND_MSNDPIN is not set
+CONFIG_SOUND_OSS=m
+CONFIG_SOUND_TRACEINIT=y
+CONFIG_SOUND_DMAP=y
+CONFIG_SOUND_SSCAPE=m
+CONFIG_SOUND_VMIDI=m
+CONFIG_SOUND_TRIX=m
+CONFIG_SOUND_MSS=m
+CONFIG_SOUND_MPU401=m
+CONFIG_SOUND_PAS=m
+CONFIG_SOUND_PSS=m
+CONFIG_PSS_MIXER=y
+# CONFIG_PSS_HAVE_BOOT is not set
+CONFIG_SOUND_SB=m
+CONFIG_SOUND_YM3812=m
+CONFIG_SOUND_UART6850=m
+CONFIG_SOUND_AEDSP16=m
+CONFIG_SC6600=y
+CONFIG_SC6600_JOY=y
+CONFIG_SC6600_CDROM=4
+CONFIG_SC6600_CDROMBASE=0x0
+# CONFIG_AEDSP16_MSS is not set
+# CONFIG_AEDSP16_SBPRO is not set
+CONFIG_SOUND_KAHLUA=m
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+# CONFIG_HID_DEBUG is not set
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=m
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+CONFIG_PANTHERLORD_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_ZEROPLUS_FF=y
+CONFIG_USB_HIDDEV=y
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+CONFIG_USB_DEVICE_CLASS=y
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_PERSIST is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+# CONFIG_USB_EHCI_TT_NEWSCHED is not set
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_OHCI_HCD=m
+CONFIG_USB_OHCI_HCD_SSB=y
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_U132_HCD=m
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+CONFIG_USB_R8A66597_HCD=m
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+# CONFIG_USB_STORAGE_ALAUDA is not set
+CONFIG_USB_STORAGE_KARMA=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+CONFIG_USB_SERIAL=m
+CONFIG_USB_EZUSB=y
+CONFIG_USB_SERIAL_GENERIC=y
+# CONFIG_USB_SERIAL_AIRCABLE is not set
+CONFIG_USB_SERIAL_AIRPRIME=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_CH341=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+# CONFIG_USB_SERIAL_FUNSOFT is not set
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_IUU=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_MOS7720=m
+CONFIG_USB_SERIAL_MOS7840=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_OTI6858=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+# CONFIG_USB_SERIAL_DEBUG is not set
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_ADUTUX=m
+CONFIG_USB_AUERSWALD=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_BERRY_CHARGE=m
+CONFIG_USB_LED=m
+CONFIG_USB_CYPRESS_CY7C63=m
+CONFIG_USB_CYTHERM=m
+CONFIG_USB_PHIDGET=m
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETMOTORCONTROL=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_FTDI_ELAN=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+# CONFIG_USB_SISUSBVGA_CON is not set
+CONFIG_USB_LD=m
+CONFIG_USB_TRANCEVIBRATOR=m
+CONFIG_USB_IOWARRIOR=m
+# CONFIG_USB_TEST is not set
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+# CONFIG_USB_GADGET is not set
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD Card Drivers
+#
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK_BOUNCE=y
+CONFIG_SDIO_UART=m
+
+#
+# MMC/SD Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+CONFIG_MMC_WBSD=m
+CONFIG_MMC_TIFM_SD=m
+CONFIG_MEMSTICK=m
+# CONFIG_MEMSTICK_DEBUG is not set
+
+#
+# MemoryStick drivers
+#
+# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
+CONFIG_MSPRO_BLOCK=m
+
+#
+# MemoryStick Host Controller Drivers
+#
+CONFIG_MEMSTICK_TIFM_MS=m
+CONFIG_MEMSTICK_JMICRON_38X=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=m
+
+#
+# LED drivers
+#
+CONFIG_LEDS_NET48XX=m
+CONFIG_LEDS_WRAP=m
+CONFIG_LEDS_CLEVO_MAIL=m
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_INFINIBAND=m
+CONFIG_INFINIBAND_USER_MAD=m
+CONFIG_INFINIBAND_USER_ACCESS=m
+CONFIG_INFINIBAND_USER_MEM=y
+CONFIG_INFINIBAND_ADDR_TRANS=y
+CONFIG_INFINIBAND_MTHCA=m
+CONFIG_INFINIBAND_MTHCA_DEBUG=y
+CONFIG_INFINIBAND_AMSO1100=m
+# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
+CONFIG_INFINIBAND_CXGB3=m
+# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
+CONFIG_MLX4_INFINIBAND=m
+CONFIG_INFINIBAND_NES=m
+# CONFIG_INFINIBAND_NES_DEBUG is not set
+CONFIG_INFINIBAND_IPOIB=m
+# CONFIG_INFINIBAND_IPOIB_CM is not set
+CONFIG_INFINIBAND_IPOIB_DEBUG=y
+# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
+# CONFIG_INFINIBAND_SRP is not set
+# CONFIG_INFINIBAND_ISER is not set
+# CONFIG_EDAC is not set
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# Conflicting RTC option has been selected, check GEN_RTC and RTC
+#
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_INTF_DEV_UIE_EMUL=y
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1374=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_MAX6900=m
+CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_M41T80=m
+CONFIG_RTC_DRV_M41T80_WDT=y
+CONFIG_RTC_DRV_S35390A=m
+
+#
+# SPI RTC drivers
+#
+CONFIG_RTC_DRV_MAX6902=m
+CONFIG_RTC_DRV_R9701=m
+CONFIG_RTC_DRV_RS5C348=m
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=m
+CONFIG_RTC_DRV_DS1511=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_STK17TA8=m
+CONFIG_RTC_DRV_M48T86=m
+CONFIG_RTC_DRV_M48T59=m
+CONFIG_RTC_DRV_V3020=m
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+CONFIG_DCA=m
+CONFIG_AUXDISPLAY=y
+CONFIG_KS0108=m
+CONFIG_KS0108_PORT=0x378
+CONFIG_KS0108_DELAY=2
+CONFIG_CFAG12864B=m
+CONFIG_CFAG12864B_RATE=20
+
+#
+# Userspace I/O
+#
+CONFIG_UIO=m
+CONFIG_UIO_CIF=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+CONFIG_EFI_VARS=m
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_DMIID=y
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT2_FS_XIP=y
+CONFIG_FS_XIP=y
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=m
+CONFIG_JBD_DEBUG=y
+CONFIG_FS_MBCACHE=y
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+CONFIG_JFS_FS=m
+CONFIG_JFS_POSIX_ACL=y
+CONFIG_JFS_SECURITY=y
+# CONFIG_JFS_DEBUG is not set
+CONFIG_JFS_STATISTICS=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_SECURITY=y
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_XFS_RT=y
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_NOLOCK=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+CONFIG_OCFS2_FS=m
+# CONFIG_OCFS2_DEBUG_MASKLOG is not set
+# CONFIG_OCFS2_DEBUG_FS is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_PRINT_QUOTA_WARNING=y
+CONFIG_QFMT_V1=m
+CONFIG_QFMT_V2=m
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+CONFIG_NTFS_RW=y
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+CONFIG_ADFS_FS=m
+# CONFIG_ADFS_FS_RW is not set
+CONFIG_AFFS_FS=m
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+CONFIG_BEFS_FS=m
+# CONFIG_BEFS_DEBUG is not set
+CONFIG_BFS_FS=m
+CONFIG_EFS_FS=m
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_LZO=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+CONFIG_CRAMFS=m
+CONFIG_VXFS_FS=m
+CONFIG_MINIX_FS=y
+CONFIG_HPFS_FS=m
+CONFIG_QNX4FS_FS=m
+CONFIG_ROMFS_FS=m
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_DIRECTIO=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_SUNRPC_XPRT_RDMA=m
+# CONFIG_SUNRPC_BIND34 is not set
+CONFIG_RPCSEC_GSS_KRB5=y
+CONFIG_RPCSEC_GSS_SPKM3=m
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp850"
+CONFIG_CIFS=m
+CONFIG_CIFS_STATS=y
+# CONFIG_CIFS_STATS2 is not set
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_NCP_FS=m
+CONFIG_NCPFS_PACKET_SIGNING=y
+CONFIG_NCPFS_IOCTL_LOCKING=y
+CONFIG_NCPFS_STRONG=y
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+CONFIG_NCPFS_SMALLDOS=y
+CONFIG_NCPFS_NLS=y
+CONFIG_NCPFS_EXTRAS=y
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+CONFIG_AFS_FS=m
+# CONFIG_AFS_DEBUG is not set
+CONFIG_9P_FS=m
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+# CONFIG_AMIGA_PARTITION is not set
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+# CONFIG_MINIX_SUBPARTITION is not set
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+# CONFIG_LDM_DEBUG is not set
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_SYSV68_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_DLM=m
+CONFIG_DLM_DEBUG=y
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_HIGHMEM is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set
+# CONFIG_SAMPLES is not set
+CONFIG_EARLY_PRINTK=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_DEBUG_RODATA is not set
+# CONFIG_DEBUG_NX_TEST is not set
+# CONFIG_4KSTACKS is not set
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
+CONFIG_DOUBLEFAULT=y
+CONFIG_IO_DELAY_TYPE_0X80=0
+CONFIG_IO_DELAY_TYPE_0XED=1
+CONFIG_IO_DELAY_TYPE_UDELAY=2
+CONFIG_IO_DELAY_TYPE_NONE=3
+CONFIG_IO_DELAY_0X80=y
+# CONFIG_IO_DELAY_0XED is not set
+# CONFIG_IO_DELAY_UDELAY is not set
+# CONFIG_IO_DELAY_NONE is not set
+CONFIG_DEFAULT_IO_DELAY_TYPE=0
+# CONFIG_DEBUG_BOOT_PARAMS is not set
+# CONFIG_CPA_DEBUG is not set
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+# CONFIG_SECURITY_NETWORK_XFRM is not set
+CONFIG_SECURITY_CAPABILITIES=y
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+# CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT is not set
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+CONFIG_XOR_BLOCKS=m
+CONFIG_ASYNC_CORE=m
+CONFIG_ASYNC_MEMCPY=m
+CONFIG_ASYNC_XOR=m
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_XTS=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_TWOFISH_586=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_586=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_SEED=m
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SALSA20_586 is not set
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_DEV_PADLOCK=m
+CONFIG_CRYPTO_DEV_PADLOCK_AES=m
+CONFIG_CRYPTO_DEV_PADLOCK_SHA=m
+CONFIG_CRYPTO_DEV_GEODE=m
+CONFIG_CRYPTO_DEV_HIFN_795X=m
+# CONFIG_CRYPTO_DEV_HIFN_795X_RNG is not set
+CONFIG_HAVE_KVM=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM=m
+CONFIG_KVM_INTEL=m
+CONFIG_KVM_AMD=m
+# CONFIG_LGUEST is not set
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_RING=y
+CONFIG_VIRTIO_PCI=m
+CONFIG_VIRTIO_BALLOON=m
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_AUDIT_GENERIC=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_CHECK_SIGNATURE=y
diff --git a/pkgs/os-specific/linux/kernel/config-2.6.25-uml b/pkgs/os-specific/linux/kernel/config-2.6.25-uml
new file mode 100644
index 00000000000..2d4b2704ee2
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/config-2.6.25-uml
@@ -0,0 +1,684 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.25
+# Tue Apr 22 14:00:22 2008
+#
+CONFIG_DEFCONFIG_LIST="arch/$ARCH/defconfig"
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_UML=y
+CONFIG_MMU=y
+CONFIG_NO_IOMEM=y
+# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set
+CONFIG_LOCKDEP_SUPPORT=y
+# CONFIG_STACKTRACE_SUPPORT is not set
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_IRQ_RELEASE_METHOD=y
+CONFIG_HZ=100
+
+#
+# UML-specific options
+#
+# CONFIG_STATIC_LINK is not set
+
+#
+# Host processor type and features
+#
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+CONFIG_M686=y
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+# CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+# CONFIG_GENERIC_CPU is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_XADD=y
+CONFIG_X86_PPRO_FENCE=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_GOOD_APIC=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_USE_PPRO_CHECKSUM=y
+CONFIG_X86_TSC=y
+CONFIG_X86_CMOV=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=4
+CONFIG_X86_DEBUGCTLMSR=y
+CONFIG_UML_X86=y
+CONFIG_X86_32=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+# CONFIG_64BIT is not set
+CONFIG_SEMAPHORE_SLEEPERS=y
+# CONFIG_3_LEVEL_PGTABLES is not set
+CONFIG_ARCH_HAS_SC_SIGNALS=y
+CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_ARCH_SUPPORTS_AOUT=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_LD_SCRIPT_DYN=y
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_HOSTFS=y
+# CONFIG_HPPFS is not set
+CONFIG_MCONSOLE=y
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_HIGHMEM is not set
+CONFIG_KERNEL_STACK_ORDER=2
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=128
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_CGROUPS is not set
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_RELAY is not set
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_IPC_NS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
+# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+# CONFIG_HAVE_OPROFILE is not set
+# CONFIG_HAVE_KPROBES is not set
+# CONFIG_HAVE_KRETPROBES is not set
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_KMOD=y
+CONFIG_BLOCK=y
+# CONFIG_LBD is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_LSF is not set
+# CONFIG_BLK_DEV_BSG is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+CONFIG_CLASSIC_RCU=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_UBD=y
+# CONFIG_BLK_DEV_UBD_SYNC is not set
+CONFIG_BLK_DEV_COW_COMMON=y
+CONFIG_BLK_DEV_LOOP=m
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=m
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# Character Devices
+#
+CONFIG_STDERR_CONSOLE=y
+CONFIG_STDIO_CONSOLE=y
+CONFIG_SSL=y
+CONFIG_NULL_CHAN=y
+CONFIG_PORT_CHAN=y
+CONFIG_PTY_CHAN=y
+CONFIG_TTY_CHAN=y
+CONFIG_XTERM_CHAN=y
+# CONFIG_NOCONFIG_CHAN is not set
+CONFIG_CON_ZERO_CHAN="fd:0,fd:1"
+CONFIG_CON_CHAN="xterm"
+CONFIG_SSL_CHAN="pty"
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=256
+CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_WATCHDOG is not set
+CONFIG_UML_SOUND=m
+CONFIG_SOUND=m
+CONFIG_HOSTAUDIO=m
+# CONFIG_HW_RANDOM is not set
+CONFIG_UML_RANDOM=y
+# CONFIG_MMAPPER is not set
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_LRO=m
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_AF_RXRPC=m
+# CONFIG_AF_RXRPC_DEBUG is not set
+# CONFIG_RXKAD is not set
+
+#
+# Wireless
+#
+# CONFIG_CFG80211 is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_MAC80211 is not set
+# CONFIG_IEEE80211 is not set
+# CONFIG_RFKILL is not set
+CONFIG_NET_9P=m
+CONFIG_NET_9P_FD=m
+# CONFIG_NET_9P_DEBUG is not set
+
+#
+# UML Network Devices
+#
+CONFIG_UML_NET=y
+CONFIG_UML_NET_ETHERTAP=y
+CONFIG_UML_NET_TUNTAP=y
+CONFIG_UML_NET_SLIP=y
+CONFIG_UML_NET_DAEMON=y
+# CONFIG_UML_NET_VDE is not set
+CONFIG_UML_NET_MCAST=y
+# CONFIG_UML_NET_PCAP is not set
+CONFIG_UML_NET_SLIRP=y
+CONFIG_NETDEVICES=y
+# CONFIG_NETDEVICES_MULTIQUEUE is not set
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+CONFIG_VETH=m
+
+#
+# Wireless LAN
+#
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+# CONFIG_PPP_FILTER is not set
+# CONFIG_PPP_ASYNC is not set
+# CONFIG_PPP_SYNC_TTY is not set
+# CONFIG_PPP_DEFLATE is not set
+# CONFIG_PPP_BSDCOMP is not set
+# CONFIG_PPP_MPPE is not set
+# CONFIG_PPPOE is not set
+# CONFIG_PPPOL2TP is not set
+CONFIG_SLIP=m
+# CONFIG_SLIP_COMPRESSED is not set
+CONFIG_SLHC=m
+# CONFIG_SLIP_SMART is not set
+# CONFIG_SLIP_MODE_SLIP6 is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_CONNECTOR is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=y
+CONFIG_REISERFS_FS=y
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_PRINT_QUOTA_WARNING=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+CONFIG_ECRYPT_FS=m
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+# CONFIG_DLM is not set
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
+# CONFIG_SECURITY is not set
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_ALGAPI=m
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_HMAC=m
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_XTS=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_TWOFISH_586=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_586=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_SEED=m
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SALSA20_586 is not set
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=m
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=m
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=m
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_PLIST=y
+CONFIG_HAS_DMA=y
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+# CONFIG_SCSI_FC_TGT_ATTRS is not set
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_HOST_SMP=y
+# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ISCSI_TCP=m
+CONFIG_SCSI_DEBUG=m
+# CONFIG_MD is not set
+# CONFIG_INPUT is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_FS is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+CONFIG_DEBUG_SLAB=y
+# CONFIG_DEBUG_SLAB_LEAK is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_SAMPLES is not set
+# CONFIG_GPROF is not set
+# CONFIG_GCOV is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
diff --git a/pkgs/os-specific/linux/kernel/config-2.6.25-x86_64-smp b/pkgs/os-specific/linux/kernel/config-2.6.25-x86_64-smp
new file mode 100644
index 00000000000..3c17836085c
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/config-2.6.25-x86_64-smp
@@ -0,0 +1,3766 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.25
+# Tue Apr 22 13:53:17 2008
+#
+CONFIG_64BIT=y
+# CONFIG_X86_32 is not set
+CONFIG_X86_64=y
+CONFIG_X86=y
+# CONFIG_GENERIC_LOCKBREAK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_CLOCKSOURCE_WATCHDOG=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_SEMAPHORE_SLEEPERS=y
+CONFIG_FAST_CMPXCHG_LOCAL=y
+CONFIG_MMU=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_HWEIGHT=y
+# CONFIG_GENERIC_GPIO is not set
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_DMI=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_ARCH_HAS_CPU_RELAX=y
+CONFIG_HAVE_SETUP_PER_CPU_AREA=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ZONE_DMA32=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_AUDIT_ARCH=y
+CONFIG_ARCH_SUPPORTS_AOUT=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_64_SMP=y
+CONFIG_X86_HT=y
+CONFIG_X86_TRAMPOLINE=y
+# CONFIG_KTIME_SCALAR is not set
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-default"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+# CONFIG_TASKSTATS is not set
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_TREE=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=17
+# CONFIG_CGROUPS is not set
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_IPC_NS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+# CONFIG_MARKERS is not set
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+CONFIG_BLOCK=y
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_BLK_DEV_BSG is not set
+CONFIG_BLOCK_COMPAT=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_CLASSIC_RCU=y
+
+#
+# Processor type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SMP=y
+CONFIG_X86_PC=y
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_NUMAQ is not set
+# CONFIG_X86_SUMMIT is not set
+# CONFIG_X86_BIGSMP is not set
+# CONFIG_X86_VISWS is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_ES7000 is not set
+# CONFIG_X86_RDC321X is not set
+# CONFIG_X86_VSMP is not set
+CONFIG_PARAVIRT_GUEST=y
+CONFIG_PARAVIRT=y
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+# CONFIG_M686 is not set
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+# CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+CONFIG_GENERIC_CPU=y
+CONFIG_X86_L1_CACHE_BYTES=128
+CONFIG_X86_INTERNODE_CACHE_BYTES=128
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_GOOD_APIC=y
+CONFIG_X86_TSC=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=64
+CONFIG_X86_DEBUGCTLMSR=y
+CONFIG_HPET_TIMER=y
+CONFIG_HPET_EMULATE_RTC=y
+CONFIG_GART_IOMMU=y
+CONFIG_CALGARY_IOMMU=y
+CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT=y
+CONFIG_IOMMU_HELPER=y
+CONFIG_SWIOTLB=y
+CONFIG_NR_CPUS=8
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_MCE=y
+CONFIG_X86_MCE_INTEL=y
+CONFIG_X86_MCE_AMD=y
+CONFIG_I8K=m
+CONFIG_MICROCODE=m
+CONFIG_MICROCODE_OLD_INTERFACE=y
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+# CONFIG_NUMA is not set
+CONFIG_ARCH_SPARSEMEM_DEFAULT=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+CONFIG_ARCH_SELECT_MEMORY_MODEL=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM=y
+CONFIG_HAVE_MEMORY_PRESENT=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPARSEMEM_EXTREME=y
+CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
+CONFIG_SPARSEMEM_VMEMMAP=y
+
+#
+# Memory hotplug is currently incompatible with Software Suspend
+#
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_RESOURCES_64BIT=y
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_MTRR=y
+CONFIG_EFI=y
+CONFIG_SECCOMP=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_KEXEC=y
+# CONFIG_CRASH_DUMP is not set
+CONFIG_PHYSICAL_START=0x200000
+# CONFIG_RELOCATABLE is not set
+CONFIG_PHYSICAL_ALIGN=0x200000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_COMPAT_VDSO=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+
+#
+# Power management options
+#
+CONFIG_ARCH_HIBERNATION_HEADER=y
+CONFIG_PM=y
+CONFIG_PM_LEGACY=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP_SMP=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION=""
+CONFIG_ACPI=y
+CONFIG_ACPI_SLEEP=y
+CONFIG_ACPI_PROCFS=y
+CONFIG_ACPI_PROCFS_POWER=y
+CONFIG_ACPI_SYSFS_POWER=y
+CONFIG_ACPI_PROC_EVENT=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_DOCK=m
+CONFIG_ACPI_BAY=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_WMI=m
+CONFIG_ACPI_ASUS=m
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_CUSTOM_DSDT_FILE=""
+# CONFIG_ACPI_CUSTOM_DSDT is not set
+CONFIG_ACPI_BLACKLIST_YEAR=0
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_X86_PM_TIMER=y
+CONFIG_ACPI_CONTAINER=m
+# CONFIG_ACPI_SBS is not set
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=m
+# CONFIG_CPU_FREQ_DEBUG is not set
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_P4_CLOCKMOD=m
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+CONFIG_X86_SPEEDSTEP_LIB=m
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_GOV_LADDER=y
+CONFIG_CPU_IDLE_GOV_MENU=y
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_DOMAINS=y
+# CONFIG_DMAR is not set
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+CONFIG_PCIEAER=y
+CONFIG_ARCH_SUPPORTS_MSI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_HT_IRQ=y
+CONFIG_ISA_DMA_API=y
+CONFIG_K8_NB=y
+CONFIG_PCCARD=m
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=m
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=m
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+CONFIG_I82092=m
+CONFIG_PCCARD_NONSTATIC=m
+CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+CONFIG_HOTPLUG_PCI_CPCI=y
+CONFIG_HOTPLUG_PCI_CPCI_ZT5550=m
+CONFIG_HOTPLUG_PCI_CPCI_GENERIC=m
+CONFIG_HOTPLUG_PCI_SHPC=m
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_COMPAT_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=m
+CONFIG_IA32_EMULATION=y
+CONFIG_IA32_AOUT=y
+CONFIG_COMPAT=y
+CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
+CONFIG_SYSVIPC_COMPAT=y
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=m
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_NET_KEY=m
+# CONFIG_NET_KEY_MIGRATE is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=m
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=m
+CONFIG_TCP_CONG_CUBIC=m
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+# CONFIG_TCP_CONG_LP is not set
+# CONFIG_TCP_CONG_VENO is not set
+CONFIG_TCP_CONG_YEAH=m
+CONFIG_TCP_CONG_ILLINOIS=m
+# CONFIG_DEFAULT_BIC is not set
+# CONFIG_DEFAULT_CUBIC is not set
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+CONFIG_DEFAULT_RENO=y
+CONFIG_DEFAULT_TCP_CONG="reno"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+# CONFIG_IPV6_MIP6 is not set
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_TUNNEL=m
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_NETLABEL is not set
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CT_ACCT=y
+CONFIG_NF_CONNTRACK_MARK=y
+# CONFIG_NF_CONNTRACK_SECMARK is not set
+# CONFIG_NF_CONNTRACK_EVENTS is not set
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=m
+CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CONNTRACK_AMANDA=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_NETBIOS_NS=m
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SANE=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_DSCP=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_RATEEST=m
+CONFIG_NETFILTER_XT_TARGET_TRACE=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_DSCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_OWNER=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_RATEEST=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_TIME=m
+CONFIG_NETFILTER_XT_MATCH_U32=m
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV4=m
+CONFIG_NF_CONNTRACK_PROC_COMPAT=y
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_NF_NAT_SNMP_BASIC=m
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_TFTP=m
+CONFIG_NF_NAT_AMANDA=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+# CONFIG_IP_NF_ARPTABLES is not set
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_MH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+
+#
+# DECnet: Netfilter Configuration
+#
+CONFIG_DECNET_NF_GRABULATOR=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+# CONFIG_IP_DCCP is not set
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_TIPC is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+CONFIG_ATM_CLIP_NO_ICMP=y
+CONFIG_ATM_LANE=m
+CONFIG_ATM_MPOA=m
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+CONFIG_DECNET=m
+CONFIG_DECNET_ROUTER=y
+CONFIG_LLC=y
+CONFIG_LLC2=m
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=m
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+CONFIG_X25=m
+CONFIG_LAPB=m
+CONFIG_ECONET=m
+# CONFIG_ECONET_AUNUDP is not set
+# CONFIG_ECONET_NATIVE is not set
+CONFIG_WAN_ROUTER=m
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RR=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_CLS_FLOW=m
+# CONFIG_NET_EMATCH is not set
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_NAT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+# CONFIG_NET_CLS_IND is not set
+CONFIG_NET_SCH_FIFO=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+CONFIG_HAMRADIO=y
+
+#
+# Packet Radio protocols
+#
+CONFIG_AX25=m
+CONFIG_AX25_DAMA_SLAVE=y
+CONFIG_NETROM=m
+CONFIG_ROSE=m
+
+#
+# AX.25 network device drivers
+#
+CONFIG_MKISS=m
+CONFIG_6PACK=m
+CONFIG_BPQETHER=m
+CONFIG_BAYCOM_SER_FDX=m
+CONFIG_BAYCOM_SER_HDX=m
+CONFIG_BAYCOM_PAR=m
+CONFIG_YAM=m
+# CONFIG_CAN is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+CONFIG_IRDA_ULTRA=y
+
+#
+# IrDA options
+#
+CONFIG_IRDA_CACHE_LAST_LSAP=y
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+CONFIG_DONGLE=y
+CONFIG_ESI_DONGLE=m
+CONFIG_ACTISYS_DONGLE=m
+CONFIG_TEKRAM_DONGLE=m
+# CONFIG_TOIM3232_DONGLE is not set
+CONFIG_LITELINK_DONGLE=m
+CONFIG_MA600_DONGLE=m
+CONFIG_GIRBIL_DONGLE=m
+CONFIG_MCP2120_DONGLE=m
+CONFIG_OLD_BELKIN_DONGLE=m
+CONFIG_ACT200L_DONGLE=m
+CONFIG_KINGSUN_DONGLE=m
+# CONFIG_KSDAZZLE_DONGLE is not set
+# CONFIG_KS959_DONGLE is not set
+
+#
+# FIR device drivers
+#
+CONFIG_USB_IRDA=m
+CONFIG_SIGMATEL_FIR=m
+CONFIG_NSC_FIR=m
+CONFIG_WINBOND_FIR=m
+CONFIG_SMC_IRCC_FIR=m
+CONFIG_ALI_FIR=m
+CONFIG_VLSI_FIR=m
+CONFIG_VIA_FIR=m
+CONFIG_MCS_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIUSB=m
+CONFIG_BT_HCIUSB_SCO=y
+CONFIG_BT_HCIBTSDIO=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_AF_RXRPC=m
+# CONFIG_AF_RXRPC_DEBUG is not set
+CONFIG_RXKAD=m
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_SIMPLE is not set
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_RC_SIMPLE is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_IEEE80211_SOFTMAC=m
+# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
+CONFIG_RFKILL=m
+CONFIG_RFKILL_INPUT=m
+CONFIG_RFKILL_LEDS=y
+CONFIG_NET_9P=m
+CONFIG_NET_9P_FD=m
+# CONFIG_NET_9P_VIRTIO is not set
+# CONFIG_NET_9P_DEBUG is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=m
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=m
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLKDEVS=m
+CONFIG_MTD_BLOCK=m
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+CONFIG_MTD_OOPS=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ABSENT=m
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=m
+CONFIG_MTD_PHYSMAP_START=0x8000000
+CONFIG_MTD_PHYSMAP_LEN=0x4000000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+CONFIG_MTD_SBC_GXX=m
+CONFIG_MTD_AMD76XROM=m
+CONFIG_MTD_ICHXROM=m
+CONFIG_MTD_ESB2ROM=m
+CONFIG_MTD_CK804XROM=m
+CONFIG_MTD_SCB2_FLASH=m
+CONFIG_MTD_NETtel=m
+CONFIG_MTD_DILNETPC=m
+CONFIG_MTD_DILNETPC_BOOTSIZE=0x80000
+CONFIG_MTD_L440GX=m
+CONFIG_MTD_PCI=m
+CONFIG_MTD_INTEL_VR_NOR=m
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_PMC551=m
+CONFIG_MTD_PMC551_BUGFIX=y
+# CONFIG_MTD_PMC551_DEBUG is not set
+CONFIG_MTD_DATAFLASH=m
+CONFIG_MTD_M25P80=m
+CONFIG_MTD_SLRAM=m
+CONFIG_MTD_PHRAM=m
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+CONFIG_MTD_DOC2000=m
+CONFIG_MTD_DOC2001=m
+CONFIG_MTD_DOC2001PLUS=m
+CONFIG_MTD_DOCPROBE=m
+CONFIG_MTD_DOCECC=m
+CONFIG_MTD_DOCPROBE_ADVANCED=y
+CONFIG_MTD_DOCPROBE_ADDRESS=0x0000
+CONFIG_MTD_DOCPROBE_HIGH=y
+CONFIG_MTD_DOCPROBE_55AA=y
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
+CONFIG_MTD_NAND_CAFE=m
+CONFIG_MTD_NAND_NANDSIM=m
+CONFIG_MTD_NAND_PLATFORM=m
+CONFIG_MTD_ALAUDA=m
+# CONFIG_MTD_ONENAND is not set
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=m
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+CONFIG_PARPORT_PC_FIFO=y
+CONFIG_PARPORT_PC_SUPERIO=y
+CONFIG_PARPORT_PC_PCMCIA=m
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
+CONFIG_PARPORT_NOT_PC=y
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_PNPACPI=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_FD=y
+CONFIG_PARIDE=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=64000
+# CONFIG_BLK_DEV_XIP is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+CONFIG_ATA_OVER_ETH=m
+CONFIG_VIRTIO_BLK=m
+CONFIG_MISC_DEVICES=y
+CONFIG_IBM_ASM=m
+CONFIG_PHANTOM=m
+CONFIG_EEPROM_93CX6=m
+# CONFIG_SGI_IOC4 is not set
+CONFIG_TIFM_CORE=m
+CONFIG_TIFM_7XX1=m
+CONFIG_ACER_WMI=m
+CONFIG_ASUS_LAPTOP=m
+CONFIG_FUJITSU_LAPTOP=m
+CONFIG_MSI_LAPTOP=m
+CONFIG_SONY_LAPTOP=m
+CONFIG_SONYPI_COMPAT=y
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+CONFIG_INTEL_MENLOW=m
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=m
+CONFIG_BLK_DEV_IDE=m
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=m
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_DELKIN=m
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_BLK_DEV_IDEACPI=y
+# CONFIG_IDE_TASK_IOCTL is not set
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=m
+CONFIG_BLK_DEV_PLATFORM=m
+CONFIG_BLK_DEV_CMD640=m
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=m
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_BLK_DEV_OFFBOARD=y
+CONFIG_BLK_DEV_GENERIC=m
+CONFIG_BLK_DEV_OPTI621=m
+CONFIG_BLK_DEV_RZ1000=m
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_AEC62XX=m
+CONFIG_BLK_DEV_ALI15X3=m
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=m
+CONFIG_BLK_DEV_ATIIXP=m
+CONFIG_BLK_DEV_CMD64X=m
+CONFIG_BLK_DEV_TRIFLEX=m
+CONFIG_BLK_DEV_CY82C693=m
+CONFIG_BLK_DEV_CS5520=m
+CONFIG_BLK_DEV_CS5530=m
+CONFIG_BLK_DEV_HPT34X=m
+CONFIG_HPT34X_AUTODMA=y
+CONFIG_BLK_DEV_HPT366=m
+CONFIG_BLK_DEV_JMICRON=m
+CONFIG_BLK_DEV_SC1200=m
+CONFIG_BLK_DEV_PIIX=m
+CONFIG_BLK_DEV_IT8213=m
+CONFIG_BLK_DEV_IT821X=m
+CONFIG_BLK_DEV_NS87415=m
+CONFIG_BLK_DEV_PDC202XX_OLD=m
+CONFIG_BLK_DEV_PDC202XX_NEW=m
+CONFIG_BLK_DEV_SVWKS=m
+CONFIG_BLK_DEV_SIIMAGE=m
+CONFIG_BLK_DEV_SIS5513=m
+CONFIG_BLK_DEV_SLC90E66=m
+CONFIG_BLK_DEV_TRM290=m
+CONFIG_BLK_DEV_VIA82CXXX=m
+CONFIG_BLK_DEV_TC86C001=m
+CONFIG_BLK_DEV_IDEDMA=y
+CONFIG_IDE_ARCH_OBSOLETE_INIT=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_ENCLOSURE=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+# CONFIG_SCSI_FC_TGT_ATTRS is not set
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+# CONFIG_SCSI_SAS_ATA is not set
+CONFIG_SCSI_SAS_HOST_SMP=y
+# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ISCSI_TCP=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
+CONFIG_AIC7XXX_RESET_DELAY_MS=5000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=32
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+CONFIG_AIC79XX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC94XX=m
+# CONFIG_AIC94XX_DEBUG is not set
+CONFIG_SCSI_ADVANSYS=m
+CONFIG_SCSI_ARCMSR=m
+# CONFIG_SCSI_ARCMSR_AER is not set
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+CONFIG_SCSI_BUSLOGIC=m
+# CONFIG_SCSI_OMIT_FLASHPOINT is not set
+CONFIG_SCSI_DMX3191D=m
+CONFIG_SCSI_EATA=m
+CONFIG_SCSI_EATA_TAGGED_QUEUE=y
+CONFIG_SCSI_EATA_LINKED_COMMANDS=y
+CONFIG_SCSI_EATA_MAX_TAGS=16
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+CONFIG_SCSI_INIA100=m
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_MVSAS=m
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+CONFIG_SCSI_IPR=m
+# CONFIG_SCSI_IPR_TRACE is not set
+# CONFIG_SCSI_IPR_DUMP is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_DC395x=m
+CONFIG_SCSI_DC390T=m
+CONFIG_SCSI_DEBUG=m
+CONFIG_SCSI_SRP=m
+CONFIG_SCSI_LOWLEVEL_PCMCIA=y
+CONFIG_PCMCIA_FDOMAIN=m
+CONFIG_PCMCIA_QLOGIC=m
+CONFIG_PCMCIA_SYM53C500=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+# CONFIG_SATA_MV is not set
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIL24=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+CONFIG_PATA_ACPI=m
+CONFIG_PATA_ALI=m
+CONFIG_PATA_AMD=m
+CONFIG_PATA_ARTOP=m
+CONFIG_PATA_ATIIXP=m
+CONFIG_PATA_CMD640_PCI=m
+# CONFIG_PATA_CMD64X is not set
+CONFIG_PATA_CS5520=m
+CONFIG_PATA_CS5530=m
+# CONFIG_PATA_CYPRESS is not set
+CONFIG_PATA_EFAR=m
+CONFIG_ATA_GENERIC=m
+CONFIG_PATA_HPT366=m
+CONFIG_PATA_HPT37X=m
+CONFIG_PATA_HPT3X2N=m
+CONFIG_PATA_HPT3X3=m
+# CONFIG_PATA_HPT3X3_DMA is not set
+CONFIG_PATA_IT821X=m
+CONFIG_PATA_IT8213=m
+CONFIG_PATA_JMICRON=m
+CONFIG_PATA_TRIFLEX=m
+CONFIG_PATA_MARVELL=m
+CONFIG_PATA_MPIIX=m
+CONFIG_PATA_OLDPIIX=m
+CONFIG_PATA_NETCELL=m
+CONFIG_PATA_NINJA32=m
+CONFIG_PATA_NS87410=m
+CONFIG_PATA_NS87415=m
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_OPTIDMA is not set
+CONFIG_PATA_PCMCIA=m
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_RADISYS is not set
+CONFIG_PATA_RZ1000=m
+CONFIG_PATA_SC1200=m
+CONFIG_PATA_SERVERWORKS=m
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+CONFIG_PATA_VIA=m
+CONFIG_PATA_WINBOND=m
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+# CONFIG_MD_RAID5_RESHAPE is not set
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_MULTIPATH_EMC=m
+CONFIG_DM_MULTIPATH_RDAC=m
+CONFIG_DM_MULTIPATH_HP=m
+# CONFIG_DM_DELAY is not set
+CONFIG_DM_UEVENT=y
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+# CONFIG_FUSION_LOGGING is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_FIREWIRE is not set
+CONFIG_IEEE1394=m
+
+#
+# Subsystem Options
+#
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+
+#
+# Controllers
+#
+CONFIG_IEEE1394_PCILYNX=m
+CONFIG_IEEE1394_OHCI1394=m
+
+#
+# Protocols
+#
+CONFIG_IEEE1394_VIDEO1394=m
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y
+CONFIG_IEEE1394_ETH1394=m
+CONFIG_IEEE1394_DV1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_I2O=m
+CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_EXT_ADAPTEC_DMA64=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+CONFIG_MACINTOSH_DRIVERS=y
+CONFIG_MAC_EMUMOUSEBTN=y
+CONFIG_NETDEVICES=y
+# CONFIG_NETDEVICES_MULTIQUEUE is not set
+# CONFIG_IFB is not set
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+# CONFIG_MACVLAN is not set
+CONFIG_EQUALIZER=m
+CONFIG_TUN=m
+CONFIG_VETH=m
+CONFIG_NET_SB1000=m
+CONFIG_ARCNET=m
+CONFIG_ARCNET_1201=m
+CONFIG_ARCNET_1051=m
+CONFIG_ARCNET_RAW=m
+CONFIG_ARCNET_CAP=m
+CONFIG_ARCNET_COM90xx=m
+CONFIG_ARCNET_COM90xxIO=m
+CONFIG_ARCNET_RIM_I=m
+# CONFIG_ARCNET_COM20020 is not set
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_BROADCOM_PHY=m
+CONFIG_ICPLUS_PHY=m
+CONFIG_REALTEK_PHY=m
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_ENC28J60=m
+# CONFIG_ENC28J60_WRITEVERIFY is not set
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+CONFIG_TULIP_NAPI=y
+CONFIG_TULIP_NAPI_HW_MITIGATION=y
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+CONFIG_HP100=m
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+# CONFIG_PCNET32_NAPI is not set
+CONFIG_AMD8111_ETH=m
+# CONFIG_AMD8111E_NAPI is not set
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_B44=m
+CONFIG_B44_PCI_AUTOSELECT=y
+CONFIG_B44_PCICORE_AUTOSELECT=y
+CONFIG_B44_PCI=y
+CONFIG_FORCEDETH=m
+# CONFIG_FORCEDETH_NAPI is not set
+CONFIG_EEPRO100=m
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_R6040=m
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_VIA_RHINE=m
+# CONFIG_VIA_RHINE_MMIO is not set
+# CONFIG_VIA_RHINE_NAPI is not set
+CONFIG_SC92031=m
+CONFIG_NET_POCKET=y
+CONFIG_ATP=m
+CONFIG_DE600=m
+CONFIG_DE620=m
+CONFIG_NETDEV_1000=y
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_E1000E_ENABLED=y
+CONFIG_IP1000=m
+CONFIG_IGB=m
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+# CONFIG_R8169_NAPI is not set
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+# CONFIG_SKGE_DEBUG is not set
+# CONFIG_SKY2 is not set
+CONFIG_SK98LIN=m
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+CONFIG_ATL1=m
+CONFIG_NETDEV_10000=y
+CONFIG_CHELSIO_T1=m
+CONFIG_CHELSIO_T1_1G=y
+CONFIG_CHELSIO_T1_NAPI=y
+CONFIG_CHELSIO_T3=m
+CONFIG_IXGBE=m
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+CONFIG_MYRI10GE=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_MLX4_CORE=m
+CONFIG_MLX4_DEBUG=y
+CONFIG_TEHUTI=m
+CONFIG_BNX2X=m
+CONFIG_TR=y
+CONFIG_IBMOL=m
+CONFIG_3C359=m
+CONFIG_TMS380TR=m
+CONFIG_TMSPCI=m
+CONFIG_ABYSS=m
+
+#
+# Wireless LAN
+#
+# CONFIG_WLAN_PRE80211 is not set
+CONFIG_WLAN_80211=y
+CONFIG_PCMCIA_RAYCS=m
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_LIBERTAS=m
+CONFIG_LIBERTAS_USB=m
+CONFIG_LIBERTAS_CS=m
+CONFIG_LIBERTAS_SDIO=m
+# CONFIG_LIBERTAS_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_WL3501=m
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_USB_NET_RNDIS_WLAN=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_ADM8211=m
+CONFIG_P54_COMMON=m
+CONFIG_P54_USB=m
+CONFIG_P54_PCI=m
+CONFIG_ATH5K=m
+CONFIG_IWL4965=m
+CONFIG_IWL4965_QOS=y
+# CONFIG_IWL4965_HT is not set
+# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
+# CONFIG_IWL4965_SENSITIVITY is not set
+# CONFIG_IWL4965_DEBUG is not set
+CONFIG_IWL3945=m
+CONFIG_IWL3945_QOS=y
+# CONFIG_IWL3945_SPECTRUM_MEASUREMENT is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_BCM43XX=m
+CONFIG_BCM43XX_DEBUG=y
+CONFIG_BCM43XX_DMA=y
+CONFIG_BCM43XX_PIO=y
+CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
+# CONFIG_BCM43XX_DMA_MODE is not set
+# CONFIG_BCM43XX_PIO_MODE is not set
+CONFIG_B43=m
+CONFIG_B43_PCI_AUTOSELECT=y
+CONFIG_B43_PCICORE_AUTOSELECT=y
+CONFIG_B43_PCMCIA=y
+CONFIG_B43_LEDS=y
+CONFIG_B43_RFKILL=y
+# CONFIG_B43_DEBUG is not set
+CONFIG_B43LEGACY=m
+CONFIG_B43LEGACY_PCI_AUTOSELECT=y
+CONFIG_B43LEGACY_PCICORE_AUTOSELECT=y
+CONFIG_B43LEGACY_LEDS=y
+CONFIG_B43LEGACY_RFKILL=y
+CONFIG_B43LEGACY_DEBUG=y
+CONFIG_B43LEGACY_DMA=y
+CONFIG_B43LEGACY_PIO=y
+CONFIG_B43LEGACY_DMA_AND_PIO_MODE=y
+# CONFIG_B43LEGACY_DMA_MODE is not set
+# CONFIG_B43LEGACY_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2X00_LIB_RFKILL=y
+CONFIG_RT2400PCI=m
+CONFIG_RT2400PCI_RFKILL=y
+CONFIG_RT2500PCI=m
+CONFIG_RT2500PCI_RFKILL=y
+CONFIG_RT61PCI=m
+CONFIG_RT61PCI_RFKILL=y
+CONFIG_RT2500USB=m
+CONFIG_RT73USB=m
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+# CONFIG_USB_EPSON2888 is not set
+# CONFIG_USB_KC2190 is not set
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_WAN=y
+CONFIG_LANMEDIA=m
+CONFIG_HDLC=m
+CONFIG_HDLC_RAW=m
+CONFIG_HDLC_RAW_ETH=m
+CONFIG_HDLC_CISCO=m
+CONFIG_HDLC_FR=m
+CONFIG_HDLC_X25=m
+CONFIG_PCI200SYN=m
+CONFIG_WANXL=m
+# CONFIG_PC300 is not set
+# CONFIG_PC300TOO is not set
+CONFIG_FARSYNC=m
+# CONFIG_DSCC4 is not set
+CONFIG_DLCI=m
+CONFIG_DLCI_MAX=8
+# CONFIG_WAN_ROUTER_DRIVERS is not set
+CONFIG_LAPBETHER=m
+CONFIG_X25_ASY=m
+# CONFIG_SBNI is not set
+CONFIG_ATM_DRIVERS=y
+# CONFIG_ATM_DUMMY is not set
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+CONFIG_ATM_ZATM=m
+# CONFIG_ATM_ZATM_DEBUG is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+CONFIG_ATM_IDT77252_RCV_ALL=y
+CONFIG_ATM_IDT77252_USE_SUNI=y
+# CONFIG_ATM_AMBASSADOR is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_FORE200E_MAYBE=m
+CONFIG_ATM_FORE200E_PCA=y
+CONFIG_ATM_FORE200E_PCA_DEFAULT_FW=y
+CONFIG_ATM_FORE200E_USE_TASKLET=y
+CONFIG_ATM_FORE200E_TX_RETRY=16
+CONFIG_ATM_FORE200E_DEBUG=0
+CONFIG_ATM_FORE200E=m
+CONFIG_ATM_HE=m
+CONFIG_ATM_HE_USE_SUNI=y
+CONFIG_FDDI=y
+CONFIG_DEFXX=m
+# CONFIG_DEFXX_MMIO is not set
+CONFIG_SKFP=m
+CONFIG_HIPPI=y
+CONFIG_ROADRUNNER=m
+CONFIG_ROADRUNNER_LARGE_RINGS=y
+CONFIG_PLIP=m
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+# CONFIG_PPPOL2TP is not set
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=m
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_NET_FC=y
+CONFIG_NETCONSOLE=m
+# CONFIG_NETCONSOLE_DYNAMIC is not set
+CONFIG_NETPOLL=y
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
+CONFIG_ISDN=m
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+CONFIG_ISDN_PPP_BSDCOMP=m
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+CONFIG_ISDN_X25=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+# CONFIG_HISAX_NO_SENDCOMPLETE is not set
+# CONFIG_HISAX_NO_LLC is not set
+# CONFIG_HISAX_NO_KEYPAD is not set
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+CONFIG_HISAX_DEBUG=y
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+CONFIG_HISAX_HFCUSB=m
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+# CONFIG_ISDN_DRV_GIGASET is not set
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_CAPI_TRACE=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+CONFIG_CAPI_EICON=y
+CONFIG_ISDN_DIVAS=m
+CONFIG_ISDN_DIVAS_BRIPCI=y
+CONFIG_ISDN_DIVAS_PRIPCI=y
+CONFIG_ISDN_DIVAS_DIVACAPI=m
+CONFIG_ISDN_DIVAS_USERIDI=m
+CONFIG_ISDN_DIVAS_MAINT=m
+CONFIG_PHONE=m
+CONFIG_PHONE_IXJ=m
+CONFIG_PHONE_IXJ_PCMCIA=m
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+CONFIG_INPUT_POLLDEV=m
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+CONFIG_KEYBOARD_SUNKBD=m
+# CONFIG_KEYBOARD_LKKBD is not set
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_KEYBOARD_NEWTON=m
+CONFIG_KEYBOARD_STOWAWAY=m
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_LIFEBOOK=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_APPLETOUCH=m
+# CONFIG_MOUSE_VSXXXAA is not set
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_USB=y
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_DB9=m
+CONFIG_JOYSTICK_GAMECON=m
+CONFIG_JOYSTICK_TURBOGRAFX=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+CONFIG_INPUT_TABLET=y
+CONFIG_TABLET_USB_ACECAD=m
+CONFIG_TABLET_USB_AIPTEK=m
+CONFIG_TABLET_USB_GTCO=m
+CONFIG_TABLET_USB_KBTAB=m
+CONFIG_TABLET_USB_WACOM=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ADS7846=m
+CONFIG_TOUCHSCREEN_FUJITSU=m
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_TOUCHSCREEN_PENMOUNT=m
+CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
+CONFIG_TOUCHSCREEN_TOUCHWIN=m
+CONFIG_TOUCHSCREEN_UCB1400=m
+CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
+CONFIG_TOUCHSCREEN_USB_EGALAX=y
+CONFIG_TOUCHSCREEN_USB_PANJIT=y
+CONFIG_TOUCHSCREEN_USB_3M=y
+CONFIG_TOUCHSCREEN_USB_ITM=y
+CONFIG_TOUCHSCREEN_USB_ETURBO=y
+CONFIG_TOUCHSCREEN_USB_GUNZE=y
+CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y
+CONFIG_TOUCHSCREEN_USB_IRTOUCH=y
+CONFIG_TOUCHSCREEN_USB_IDEALTEK=y
+CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y
+CONFIG_TOUCHSCREEN_USB_GOTOP=y
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=y
+CONFIG_INPUT_APANEL=m
+CONFIG_INPUT_ATLAS_BTNS=m
+CONFIG_INPUT_ATI_REMOTE=m
+CONFIG_INPUT_ATI_REMOTE2=m
+CONFIG_INPUT_KEYSPAN_REMOTE=m
+CONFIG_INPUT_POWERMATE=m
+CONFIG_INPUT_YEALINK=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_CT82C710=m
+CONFIG_SERIO_PARKBD=m
+CONFIG_SERIO_PCIPS2=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+CONFIG_ROCKETPORT=m
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+CONFIG_DIGIEPCA=m
+# CONFIG_MOXA_INTELLIO is not set
+CONFIG_MOXA_SMARTIO=m
+# CONFIG_ISI is not set
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+CONFIG_RISCOM8=m
+# CONFIG_SPECIALIX is not set
+CONFIG_SX=m
+CONFIG_RIO=m
+CONFIG_RIO_OLDPCI=y
+CONFIG_STALDRV=y
+CONFIG_NOZOMI=m
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_PNP=y
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=8
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+CONFIG_PPDEV=m
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_NVRAM=m
+CONFIG_RTC=y
+CONFIG_R3964=m
+CONFIG_APPLICOM=m
+
+#
+# PCMCIA character devices
+#
+CONFIG_SYNCLINK_CS=m
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+CONFIG_IPWIRELESS=m
+CONFIG_MWAVE=m
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=4096
+CONFIG_HPET=y
+# CONFIG_HPET_RTC_IRQ is not set
+CONFIG_HPET_MMAP=y
+CONFIG_HANGCHECK_TIMER=m
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
+CONFIG_DEVPORT=y
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_I810=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_NFORCE2=m
+CONFIG_I2C_OCORES=m
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_PROSAVAGE=m
+CONFIG_I2C_SAVAGE4=m
+CONFIG_I2C_SIMTEC=m
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_TAOS_EVM=m
+CONFIG_I2C_STUB=m
+CONFIG_I2C_TINY_USB=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+CONFIG_I2C_VOODOO3=m
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_DS1682=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_PCF8575=m
+CONFIG_SENSORS_PCF8591=m
+CONFIG_TPS65010=m
+CONFIG_SENSORS_MAX6875=m
+CONFIG_SENSORS_TSL2550=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=m
+# CONFIG_SPI_BUTTERFLY is not set
+CONFIG_SPI_LM70_LLP=m
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_AT25=m
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_TLE62X0=m
+CONFIG_W1=m
+CONFIG_W1_CON=y
+
+#
+# 1-wire Bus Masters
+#
+CONFIG_W1_MASTER_MATROX=m
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS2482=m
+
+#
+# 1-wire Slaves
+#
+CONFIG_W1_SLAVE_THERM=m
+CONFIG_W1_SLAVE_SMEM=m
+CONFIG_W1_SLAVE_DS2433=m
+# CONFIG_W1_SLAVE_DS2433_CRC is not set
+CONFIG_W1_SLAVE_DS2760=m
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+# CONFIG_PDA_POWER is not set
+# CONFIG_BATTERY_DS2760 is not set
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ABITUGURU3=m
+CONFIG_SENSORS_AD7418=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1029=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ADT7470=m
+CONFIG_SENSORS_ADT7473=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_I5K_AMB=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_F71882FG=m
+CONFIG_SENSORS_F75375S=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_FSCHMD=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_CORETEMP=m
+CONFIG_SENSORS_IBMPEX=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM70=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_MAX6650=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_PC87427=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_DME1737=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_ADS7828=m
+CONFIG_SENSORS_THMC50=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT1211=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83L786NG=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+CONFIG_SENSORS_APPLESMC=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+CONFIG_THERMAL=y
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+CONFIG_ACQUIRE_WDT=m
+CONFIG_ADVANTECH_WDT=m
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+CONFIG_SC520_WDT=m
+CONFIG_EUROTECH_WDT=m
+CONFIG_IB700_WDT=m
+CONFIG_IBMASR=m
+CONFIG_WAFER_WDT=m
+CONFIG_I6300ESB_WDT=m
+CONFIG_ITCO_WDT=m
+CONFIG_ITCO_VENDOR_SUPPORT=y
+CONFIG_IT8712F_WDT=m
+CONFIG_HP_WATCHDOG=m
+CONFIG_SC1200_WDT=m
+CONFIG_PC87413_WDT=m
+CONFIG_60XX_WDT=m
+CONFIG_SBC8360_WDT=m
+CONFIG_CPU5_WDT=m
+CONFIG_SMSC37B787_WDT=m
+CONFIG_W83627HF_WDT=m
+CONFIG_W83697HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+CONFIG_SBC_EPX_C3_WATCHDOG=m
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB_POSSIBLE=y
+CONFIG_SSB=m
+CONFIG_SSB_PCIHOST_POSSIBLE=y
+CONFIG_SSB_PCIHOST=y
+CONFIG_SSB_B43_PCI_BRIDGE=y
+CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
+CONFIG_SSB_PCMCIAHOST=y
+# CONFIG_SSB_DEBUG is not set
+CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
+CONFIG_SSB_DRIVER_PCICORE=y
+
+#
+# Multifunction device drivers
+#
+CONFIG_MFD_SM501=m
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+CONFIG_VIDEO_TVAUDIO=m
+CONFIG_VIDEO_TDA7432=m
+CONFIG_VIDEO_TDA9840=m
+CONFIG_VIDEO_TDA9875=m
+CONFIG_VIDEO_TEA6415C=m
+CONFIG_VIDEO_TEA6420=m
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_M52790=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_VP27SMPX=m
+CONFIG_VIDEO_BT819=m
+CONFIG_VIDEO_BT856=m
+CONFIG_VIDEO_OV7670=m
+CONFIG_VIDEO_SAA7110=m
+CONFIG_VIDEO_SAA7111=m
+CONFIG_VIDEO_SAA7114=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_TVP5150=m
+CONFIG_VIDEO_VPX3220=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_SAA7185=m
+CONFIG_VIDEO_ADV7170=m
+CONFIG_VIDEO_ADV7175=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+CONFIG_VIDEO_VIVI=m
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_BT848_DVB=y
+CONFIG_VIDEO_SAA6588=m
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+CONFIG_VIDEO_W9966=m
+CONFIG_VIDEO_CPIA=m
+CONFIG_VIDEO_CPIA_PP=m
+CONFIG_VIDEO_CPIA_USB=m
+# CONFIG_VIDEO_CPIA2 is not set
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+CONFIG_TUNER_3036=m
+CONFIG_VIDEO_STRADIS=m
+CONFIG_VIDEO_ZORAN_ZR36060=m
+CONFIG_VIDEO_ZORAN=m
+CONFIG_VIDEO_ZORAN_BUZ=m
+CONFIG_VIDEO_ZORAN_DC10=m
+CONFIG_VIDEO_ZORAN_DC30=m
+CONFIG_VIDEO_ZORAN_LML33=m
+CONFIG_VIDEO_ZORAN_LML33R10=m
+# CONFIG_VIDEO_ZORAN_AVS6EYES is not set
+CONFIG_VIDEO_MEYE=m
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_SAA7134_ALSA=m
+CONFIG_VIDEO_SAA7134_DVB=m
+CONFIG_VIDEO_MXB=m
+CONFIG_VIDEO_DPC=m
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_CX88_ALSA=m
+CONFIG_VIDEO_CX88_BLACKBIRD=m
+CONFIG_VIDEO_CX88_DVB=m
+CONFIG_VIDEO_CX88_VP3054=m
+CONFIG_VIDEO_CX23885=m
+CONFIG_VIDEO_IVTV=m
+CONFIG_VIDEO_FB_IVTV=m
+CONFIG_VIDEO_CAFE_CCIC=m
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_ONAIR_CREATOR=y
+CONFIG_VIDEO_PVRUSB2_ONAIR_USB2=y
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_EM28XX_ALSA=m
+CONFIG_VIDEO_USBVISION=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+CONFIG_USB_ZR364XX=m
+CONFIG_USB_STKWEBCAM=m
+CONFIG_RADIO_ADAPTERS=y
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+CONFIG_USB_DSBR=m
+CONFIG_USB_SI470X=m
+CONFIG_DVB_CORE=m
+CONFIG_DVB_CORE_ATTACH=y
+CONFIG_DVB_CAPTURE_DRIVERS=y
+
+#
+# Supported SAA7146 based PCI Adapters
+#
+CONFIG_TTPCI_EEPROM=m
+CONFIG_DVB_AV7110=m
+# CONFIG_DVB_AV7110_FIRMWARE is not set
+CONFIG_DVB_AV7110_OSD=y
+CONFIG_DVB_BUDGET_CORE=m
+CONFIG_DVB_BUDGET=m
+CONFIG_DVB_BUDGET_CI=m
+CONFIG_DVB_BUDGET_AV=m
+CONFIG_DVB_BUDGET_PATCH=m
+
+#
+# Supported USB Adapters
+#
+CONFIG_DVB_USB=m
+# CONFIG_DVB_USB_DEBUG is not set
+CONFIG_DVB_USB_A800=m
+CONFIG_DVB_USB_DIBUSB_MB=m
+# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
+CONFIG_DVB_USB_DIBUSB_MC=m
+CONFIG_DVB_USB_DIB0700=m
+CONFIG_DVB_USB_UMT_010=m
+CONFIG_DVB_USB_CXUSB=m
+CONFIG_DVB_USB_M920X=m
+CONFIG_DVB_USB_GL861=m
+CONFIG_DVB_USB_AU6610=m
+CONFIG_DVB_USB_DIGITV=m
+CONFIG_DVB_USB_VP7045=m
+CONFIG_DVB_USB_VP702X=m
+CONFIG_DVB_USB_GP8PSK=m
+CONFIG_DVB_USB_NOVA_T_USB2=m
+CONFIG_DVB_USB_TTUSB2=m
+CONFIG_DVB_USB_DTT200U=m
+CONFIG_DVB_USB_OPERA1=m
+CONFIG_DVB_USB_AF9005=m
+CONFIG_DVB_USB_AF9005_REMOTE=m
+CONFIG_DVB_TTUSB_BUDGET=m
+CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_CINERGYT2=m
+# CONFIG_DVB_CINERGYT2_TUNING is not set
+
+#
+# Supported FlexCopII (B2C2) Adapters
+#
+CONFIG_DVB_B2C2_FLEXCOP=m
+CONFIG_DVB_B2C2_FLEXCOP_PCI=m
+CONFIG_DVB_B2C2_FLEXCOP_USB=m
+# CONFIG_DVB_B2C2_FLEXCOP_DEBUG is not set
+
+#
+# Supported BT878 Adapters
+#
+CONFIG_DVB_BT8XX=m
+
+#
+# Supported Pluto2 Adapters
+#
+# CONFIG_DVB_PLUTO2 is not set
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+# CONFIG_DVB_FE_CUSTOMISE is not set
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_CX24123=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_VES1X93=m
+CONFIG_DVB_S5H1420=m
+CONFIG_DVB_TDA10086=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_ZL10353=m
+CONFIG_DVB_DIB3000MB=m
+CONFIG_DVB_DIB3000MC=m
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_TDA10023=m
+CONFIG_DVB_STV0297=m
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+CONFIG_DVB_NXT200X=m
+CONFIG_DVB_OR51211=m
+CONFIG_DVB_OR51132=m
+CONFIG_DVB_BCM3510=m
+CONFIG_DVB_LGDT330X=m
+CONFIG_DVB_S5H1409=m
+
+#
+# Tuners/PLL support
+#
+CONFIG_DVB_PLL=m
+CONFIG_DVB_TDA826X=m
+CONFIG_DVB_TDA827X=m
+CONFIG_DVB_TDA18271=m
+CONFIG_DVB_TUNER_QT1010=m
+CONFIG_DVB_TUNER_MT2060=m
+CONFIG_DVB_TUNER_MT2266=m
+CONFIG_DVB_TUNER_MT2131=m
+CONFIG_DVB_TUNER_DIB0070=m
+CONFIG_DVB_TUNER_XC5000=m
+
+#
+# Miscellaneous devices
+#
+CONFIG_DVB_LNBP21=m
+CONFIG_DVB_ISL6421=m
+CONFIG_DVB_TUA6100=m
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_VIDEO_TUNER=m
+# CONFIG_VIDEO_TUNER_CUSTOMIZE is not set
+CONFIG_TUNER_XC2028=m
+CONFIG_TUNER_MT20XX=m
+CONFIG_TUNER_TDA8290=m
+CONFIG_TUNER_TEA5761=m
+CONFIG_TUNER_TEA5767=m
+CONFIG_TUNER_SIMPLE=m
+CONFIG_TUNER_TDA9887=m
+CONFIG_VIDEOBUF_GEN=m
+CONFIG_VIDEOBUF_DMA_SG=m
+CONFIG_VIDEOBUF_VMALLOC=m
+CONFIG_VIDEOBUF_DVB=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR_I2C=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_DAB=y
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+CONFIG_AGP=y
+CONFIG_AGP_AMD64=y
+CONFIG_AGP_INTEL=m
+CONFIG_AGP_SIS=m
+CONFIG_AGP_VIA=m
+CONFIG_DRM=m
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_DRM_VIA=m
+CONFIG_DRM_SAVAGE=m
+CONFIG_VGASTATE=m
+CONFIG_VIDEO_OUTPUT_CONTROL=m
+CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+CONFIG_FB_DDC=m
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+CONFIG_FB_SYS_FILLRECT=m
+CONFIG_FB_SYS_COPYAREA=m
+CONFIG_FB_SYS_IMAGEBLIT=m
+CONFIG_FB_SYS_FOPS=m
+CONFIG_FB_DEFERRED_IO=y
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+CONFIG_FB_CIRRUS=m
+CONFIG_FB_PM2=m
+CONFIG_FB_PM2_FIFO_DISCONNECT=y
+CONFIG_FB_CYBER2000=m
+CONFIG_FB_ARC=m
+# CONFIG_FB_ASILIANT is not set
+CONFIG_FB_IMSTT=y
+CONFIG_FB_VGA16=m
+CONFIG_FB_UVESA=m
+CONFIG_FB_VESA=y
+# CONFIG_FB_EFI is not set
+CONFIG_FB_IMAC=y
+CONFIG_FB_HECUBA=m
+CONFIG_FB_HGA=m
+CONFIG_FB_HGA_ACCEL=y
+CONFIG_FB_S1D13XXX=m
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+# CONFIG_FB_NVIDIA_DEBUG is not set
+CONFIG_FB_NVIDIA_BACKLIGHT=y
+CONFIG_FB_RIVA=m
+CONFIG_FB_RIVA_I2C=y
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_RIVA_BACKLIGHT=y
+CONFIG_FB_LE80578=m
+CONFIG_FB_CARILLO_RANCH=m
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+CONFIG_FB_INTEL_I2C=y
+# CONFIG_FB_MATROX is not set
+CONFIG_FB_RADEON=m
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+# CONFIG_FB_RADEON_DEBUG is not set
+# CONFIG_FB_ATY128 is not set
+CONFIG_FB_ATY=m
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+# CONFIG_FB_S3 is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+CONFIG_FB_SIS=m
+CONFIG_FB_SIS_300=y
+CONFIG_FB_SIS_315=y
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+# CONFIG_FB_VT8623 is not set
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+# CONFIG_FB_ARK is not set
+CONFIG_FB_PM3=m
+CONFIG_FB_GEODE=y
+CONFIG_FB_GEODE_LX=m
+CONFIG_FB_GEODE_GX=m
+# CONFIG_FB_GEODE_GX_SET_FBSIZE is not set
+CONFIG_FB_GEODE_GX1=m
+CONFIG_FB_SM501=m
+# CONFIG_FB_VIRTUAL is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_LTV350QV=m
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_CORGI=m
+CONFIG_BACKLIGHT_PROGEAR=m
+CONFIG_BACKLIGHT_CARILLO_RANCH=m
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=m
+
+#
+# Display hardware drivers
+#
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+# CONFIG_VGACON_SOFT_SCROLLBACK is not set
+CONFIG_VIDEO_SELECT=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+# CONFIG_LOGO is not set
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_RTCTIMER=m
+CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y
+# CONFIG_SND_DYNAMIC_MINORS is not set
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_DEBUG=y
+# CONFIG_SND_DEBUG_DETECT is not set
+# CONFIG_SND_PCM_XRUN_DEBUG is not set
+
+#
+# Generic devices
+#
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_MTS64=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+CONFIG_SND_PORTMAN2X4=m
+CONFIG_SND_SB_COMMON=m
+CONFIG_SND_SB16_DSP=m
+
+#
+# PCI devices
+#
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_OXYGEN_LIB=m
+CONFIG_SND_OXYGEN=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS5530=m
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_INTEL=m
+# CONFIG_SND_HDA_HWDEP is not set
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_CODEC_ANALOG=y
+CONFIG_SND_HDA_CODEC_SIGMATEL=y
+CONFIG_SND_HDA_CODEC_VIA=y
+CONFIG_SND_HDA_CODEC_ATIHDMI=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+CONFIG_SND_HDA_CODEC_CMEDIA=y
+CONFIG_SND_HDA_CODEC_SI3054=y
+CONFIG_SND_HDA_GENERIC=y
+# CONFIG_SND_HDA_POWER_SAVE is not set
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_HIFIER=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL=y
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL=y
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VIRTUOSO=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y
+CONFIG_SND_AC97_POWER_SAVE=y
+CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0
+
+#
+# SPI devices
+#
+
+#
+# USB devices
+#
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+CONFIG_SND_USB_CAIAQ=m
+CONFIG_SND_USB_CAIAQ_INPUT=y
+
+#
+# PCMCIA devices
+#
+CONFIG_SND_VXPOCKET=m
+CONFIG_SND_PDAUDIOCF=m
+
+#
+# System on Chip audio support
+#
+# CONFIG_SND_SOC is not set
+
+#
+# SoC Audio support for SuperH
+#
+
+#
+# ALSA SoC audio for Freescale SOCs
+#
+
+#
+# Open Sound System
+#
+CONFIG_SOUND_PRIME=m
+CONFIG_SOUND_TRIDENT=m
+# CONFIG_SOUND_MSNDCLAS is not set
+# CONFIG_SOUND_MSNDPIN is not set
+CONFIG_SOUND_OSS=m
+CONFIG_SOUND_TRACEINIT=y
+CONFIG_SOUND_DMAP=y
+CONFIG_SOUND_SSCAPE=m
+CONFIG_SOUND_VMIDI=m
+CONFIG_SOUND_TRIX=m
+CONFIG_SOUND_MSS=m
+CONFIG_SOUND_MPU401=m
+CONFIG_SOUND_PAS=m
+CONFIG_SOUND_PSS=m
+CONFIG_PSS_MIXER=y
+# CONFIG_PSS_HAVE_BOOT is not set
+CONFIG_SOUND_SB=m
+CONFIG_SOUND_YM3812=m
+CONFIG_SOUND_UART6850=m
+CONFIG_SOUND_AEDSP16=m
+CONFIG_SC6600=y
+CONFIG_SC6600_JOY=y
+CONFIG_SC6600_CDROM=4
+CONFIG_SC6600_CDROMBASE=0x0
+# CONFIG_AEDSP16_MSS is not set
+# CONFIG_AEDSP16_SBPRO is not set
+CONFIG_SOUND_KAHLUA=m
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+# CONFIG_HID_DEBUG is not set
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=m
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+CONFIG_PANTHERLORD_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_ZEROPLUS_FF=y
+CONFIG_USB_HIDDEV=y
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+CONFIG_USB_DEVICE_CLASS=y
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_PERSIST is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+# CONFIG_USB_EHCI_TT_NEWSCHED is not set
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_OHCI_HCD=m
+CONFIG_USB_OHCI_HCD_SSB=y
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_U132_HCD=m
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+CONFIG_USB_R8A66597_HCD=m
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+# CONFIG_USB_STORAGE_ALAUDA is not set
+CONFIG_USB_STORAGE_KARMA=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+CONFIG_USB_SERIAL=m
+CONFIG_USB_EZUSB=y
+CONFIG_USB_SERIAL_GENERIC=y
+# CONFIG_USB_SERIAL_AIRCABLE is not set
+CONFIG_USB_SERIAL_AIRPRIME=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_CH341=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+# CONFIG_USB_SERIAL_FUNSOFT is not set
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_IUU=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_MOS7720=m
+CONFIG_USB_SERIAL_MOS7840=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_OTI6858=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+# CONFIG_USB_SERIAL_DEBUG is not set
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_ADUTUX=m
+CONFIG_USB_AUERSWALD=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_BERRY_CHARGE=m
+CONFIG_USB_LED=m
+CONFIG_USB_CYPRESS_CY7C63=m
+CONFIG_USB_CYTHERM=m
+CONFIG_USB_PHIDGET=m
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETMOTORCONTROL=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_FTDI_ELAN=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+# CONFIG_USB_SISUSBVGA_CON is not set
+CONFIG_USB_LD=m
+CONFIG_USB_TRANCEVIBRATOR=m
+CONFIG_USB_IOWARRIOR=m
+# CONFIG_USB_TEST is not set
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+# CONFIG_USB_GADGET is not set
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD Card Drivers
+#
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK_BOUNCE=y
+CONFIG_SDIO_UART=m
+
+#
+# MMC/SD Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+CONFIG_MMC_WBSD=m
+CONFIG_MMC_TIFM_SD=m
+# CONFIG_MMC_SPI is not set
+CONFIG_MEMSTICK=m
+# CONFIG_MEMSTICK_DEBUG is not set
+
+#
+# MemoryStick drivers
+#
+# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
+CONFIG_MSPRO_BLOCK=m
+
+#
+# MemoryStick Host Controller Drivers
+#
+CONFIG_MEMSTICK_TIFM_MS=m
+CONFIG_MEMSTICK_JMICRON_38X=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=m
+
+#
+# LED drivers
+#
+CONFIG_LEDS_CLEVO_MAIL=m
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_INFINIBAND=m
+CONFIG_INFINIBAND_USER_MAD=m
+CONFIG_INFINIBAND_USER_ACCESS=m
+CONFIG_INFINIBAND_USER_MEM=y
+CONFIG_INFINIBAND_ADDR_TRANS=y
+CONFIG_INFINIBAND_MTHCA=m
+CONFIG_INFINIBAND_MTHCA_DEBUG=y
+CONFIG_INFINIBAND_IPATH=m
+CONFIG_INFINIBAND_AMSO1100=m
+# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
+CONFIG_INFINIBAND_CXGB3=m
+# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
+CONFIG_MLX4_INFINIBAND=m
+CONFIG_INFINIBAND_NES=m
+# CONFIG_INFINIBAND_NES_DEBUG is not set
+CONFIG_INFINIBAND_IPOIB=m
+# CONFIG_INFINIBAND_IPOIB_CM is not set
+CONFIG_INFINIBAND_IPOIB_DEBUG=y
+# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
+# CONFIG_INFINIBAND_SRP is not set
+# CONFIG_INFINIBAND_ISER is not set
+# CONFIG_EDAC is not set
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# Conflicting RTC option has been selected, check GEN_RTC and RTC
+#
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_INTF_DEV_UIE_EMUL=y
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1374=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_MAX6900=m
+CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_M41T80=m
+CONFIG_RTC_DRV_M41T80_WDT=y
+CONFIG_RTC_DRV_S35390A=m
+
+#
+# SPI RTC drivers
+#
+CONFIG_RTC_DRV_MAX6902=m
+CONFIG_RTC_DRV_R9701=m
+CONFIG_RTC_DRV_RS5C348=m
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=m
+CONFIG_RTC_DRV_DS1511=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_STK17TA8=m
+CONFIG_RTC_DRV_M48T86=m
+CONFIG_RTC_DRV_M48T59=m
+CONFIG_RTC_DRV_V3020=m
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+CONFIG_DCA=m
+CONFIG_AUXDISPLAY=y
+CONFIG_KS0108=m
+CONFIG_KS0108_PORT=0x378
+CONFIG_KS0108_DELAY=2
+# CONFIG_CFAG12864B is not set
+
+#
+# Userspace I/O
+#
+CONFIG_UIO=m
+CONFIG_UIO_CIF=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+CONFIG_EFI_VARS=m
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_DMIID=y
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT2_FS_XIP=y
+CONFIG_FS_XIP=y
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+# CONFIG_EXT4DEV_FS is not set
+CONFIG_JBD=m
+CONFIG_JBD_DEBUG=y
+CONFIG_FS_MBCACHE=y
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+CONFIG_JFS_FS=m
+CONFIG_JFS_POSIX_ACL=y
+CONFIG_JFS_SECURITY=y
+# CONFIG_JFS_DEBUG is not set
+CONFIG_JFS_STATISTICS=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_SECURITY=y
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_XFS_RT=y
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_NOLOCK=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+CONFIG_OCFS2_FS=m
+# CONFIG_OCFS2_DEBUG_MASKLOG is not set
+# CONFIG_OCFS2_DEBUG_FS is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_PRINT_QUOTA_WARNING=y
+CONFIG_QFMT_V1=m
+CONFIG_QFMT_V2=m
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+CONFIG_NTFS_RW=y
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+CONFIG_ADFS_FS=m
+# CONFIG_ADFS_FS_RW is not set
+CONFIG_AFFS_FS=m
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+CONFIG_BEFS_FS=m
+# CONFIG_BEFS_DEBUG is not set
+CONFIG_BFS_FS=m
+CONFIG_EFS_FS=m
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_LZO=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+CONFIG_CRAMFS=m
+CONFIG_VXFS_FS=m
+CONFIG_MINIX_FS=y
+CONFIG_HPFS_FS=m
+CONFIG_QNX4FS_FS=m
+CONFIG_ROMFS_FS=m
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_DIRECTIO=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+CONFIG_SUNRPC_GSS=y
+CONFIG_SUNRPC_XPRT_RDMA=m
+# CONFIG_SUNRPC_BIND34 is not set
+CONFIG_RPCSEC_GSS_KRB5=y
+CONFIG_RPCSEC_GSS_SPKM3=m
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp850"
+CONFIG_CIFS=m
+CONFIG_CIFS_STATS=y
+# CONFIG_CIFS_STATS2 is not set
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_NCP_FS=m
+CONFIG_NCPFS_PACKET_SIGNING=y
+CONFIG_NCPFS_IOCTL_LOCKING=y
+CONFIG_NCPFS_STRONG=y
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+CONFIG_NCPFS_SMALLDOS=y
+CONFIG_NCPFS_NLS=y
+CONFIG_NCPFS_EXTRAS=y
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+CONFIG_AFS_FS=m
+# CONFIG_AFS_DEBUG is not set
+CONFIG_9P_FS=m
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+# CONFIG_AMIGA_PARTITION is not set
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+# CONFIG_MINIX_SUBPARTITION is not set
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+# CONFIG_LDM_DEBUG is not set
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_SYSV68_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_DLM=m
+CONFIG_DLM_DEBUG=y
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set
+# CONFIG_SAMPLES is not set
+CONFIG_EARLY_PRINTK=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_DEBUG_PER_CPU_MAPS is not set
+# CONFIG_DEBUG_RODATA is not set
+# CONFIG_DEBUG_NX_TEST is not set
+CONFIG_X86_MPPARSE=y
+# CONFIG_IOMMU_DEBUG is not set
+CONFIG_IO_DELAY_TYPE_0X80=0
+CONFIG_IO_DELAY_TYPE_0XED=1
+CONFIG_IO_DELAY_TYPE_UDELAY=2
+CONFIG_IO_DELAY_TYPE_NONE=3
+CONFIG_IO_DELAY_0X80=y
+# CONFIG_IO_DELAY_0XED is not set
+# CONFIG_IO_DELAY_UDELAY is not set
+# CONFIG_IO_DELAY_NONE is not set
+CONFIG_DEFAULT_IO_DELAY_TYPE=0
+# CONFIG_DEBUG_BOOT_PARAMS is not set
+# CONFIG_CPA_DEBUG is not set
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+# CONFIG_SECURITY_NETWORK_XFRM is not set
+CONFIG_SECURITY_CAPABILITIES=y
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+# CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT is not set
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+CONFIG_XOR_BLOCKS=m
+CONFIG_ASYNC_CORE=m
+CONFIG_ASYNC_MEMCPY=m
+CONFIG_ASYNC_XOR=m
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_XTS=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_DES=y
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_TWOFISH_X86_64=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_X86_64=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_SEED=m
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SALSA20_X86_64 is not set
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_DEV_HIFN_795X=m
+# CONFIG_CRYPTO_DEV_HIFN_795X_RNG is not set
+CONFIG_HAVE_KVM=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM=m
+CONFIG_KVM_INTEL=m
+CONFIG_KVM_AMD=m
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
+CONFIG_VIRTIO_BALLOON=m
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_CHECK_SIGNATURE=y
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch b/pkgs/os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch
index 5ce03fa0434..22704f1a1db 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch
@@ -1,159 +1,6 @@
-diff -ruN linux-2.6.20.3/fs/Kconfig linux-2.6.20.3-ext3cow/fs/Kconfig
---- linux-2.6.20.3/fs/Kconfig	2007-03-13 14:27:08.000000000 -0400
-+++ linux-2.6.20.3-ext3cow/fs/Kconfig	2007-04-07 14:23:46.000000000 -0400
-@@ -136,6 +136,77 @@
- 	  If you are not using a security module that requires using
- 	  extended attributes for file security labels, say N.
- 
-+
-+
-+config EXT3COW_FS
-+	tristate "Ext3cow journalling and versioning file system support"
-+	select JBD
-+	help
-+	  This is the journalling version of the Second extended file system
-+	  (often called ext3), the de facto standard Linux file system
-+	  (method to organize files on a storage device) for hard disks.
-+
-+	  The journalling code included in this driver means you do not have
-+	  to run e2fsck (file system checker) on your file systems after a
-+	  crash.  The journal keeps track of any changes that were being made
-+	  at the time the system crashed, and can ensure that your file system
-+	  is consistent without the need for a lengthy check.
-+
-+	  Other than adding the journal to the file system, the on-disk format
-+	  of ext3 is identical to ext2.  It is possible to freely switch
-+	  between using the ext3 driver and the ext2 driver, as long as the
-+	  file system has been cleanly unmounted, or e2fsck is run on the file
-+	  system.
-+
-+	  To add a journal on an existing ext2 file system or change the
-+	  behavior of ext3 file systems, you can use the tune2fs utility ("man
-+	  tune2fs").  To modify attributes of files and directories on ext3
-+	  file systems, use chattr ("man chattr").  You need to be using
-+	  e2fsprogs version 1.20 or later in order to create ext3 journals
-+	  (available at <http://sourceforge.net/projects/e2fsprogs/>).
-+
-+	  To compile this file system support as a module, choose M here: the
-+	  module will be called ext3.
-+
-+config EXT3COW_FS_XATTR
-+	bool "Ext3cow extended attributes"
-+	depends on EXT3COW_FS
-+	default y
-+	help
-+	  Extended attributes are name:value pairs associated with inodes by
-+	  the kernel or by users (see the attr(5) manual page, or visit
-+	  <http://acl.bestbits.at/> for details).
-+
-+	  If unsure, say N.
-+
-+	  You need this for POSIX ACL support on ext3cow.
-+
-+config EXT3COW_FS_POSIX_ACL
-+	bool "Ext3cow POSIX Access Control Lists"
-+	depends on EXT3COW_FS_XATTR
-+	select FS_POSIX_ACL
-+	help
-+	  Posix Access Control Lists (ACLs) support permissions for users and
-+	  groups beyond the owner/group/world scheme.
-+
-+	  To learn more about Access Control Lists, visit the Posix ACLs for
-+	  Linux website <http://acl.bestbits.at/>.
-+
-+	  If you don't know what Access Control Lists are, say N
-+
-+config EXT3COW_FS_SECURITY
-+	bool "Ext3cow Security Labels"
-+	depends on EXT3COW_FS_XATTR
-+	help
-+	  Security labels support alternative access control models
-+	  implemented by security modules like SELinux.  This option
-+	  enables an extended attribute handler for file security
-+	  labels in the ext3cow filesystem.
-+
-+	  If you are not using a security module that requires using
-+	  extended attributes for file security labels, say N.
-+
-+
- config EXT4DEV_FS
- 	tristate "Ext4dev/ext4 extended fs support development (EXPERIMENTAL)"
- 	depends on EXPERIMENTAL
-@@ -205,23 +276,23 @@
- 	tristate
- 	help
- 	  This is a generic journalling layer for block devices.  It is
--	  currently used by the ext3 and OCFS2 file systems, but it could
-+	  currently used by the ext3, ext3cow and OCFS2 file systems, but it could
- 	  also be used to add journal support to other file systems or block
- 	  devices such as RAID or LVM.
- 
--	  If you are using the ext3 or OCFS2 file systems, you need to
-+	  If you are using the ext3, ext3cow or OCFS2 file systems, you need to
- 	  say Y here. If you are not using ext3 OCFS2 then you will probably
- 	  want to say N.
- 
- 	  To compile this device as a module, choose M here: the module will be
--	  called jbd.  If you are compiling ext3 or OCFS2 into the kernel,
-+	  called jbd.  If you are compiling ext3, ext3cow or OCFS2 into the kernel,
- 	  you cannot compile this code as a module.
- 
- config JBD_DEBUG
- 	bool "JBD (ext3) debugging support"
- 	depends on JBD
- 	help
--	  If you are using the ext3 journaled file system (or potentially any
-+	  If you are using the ext3 or ext3cow journaled file system (or potentially any
- 	  other file system/device using JBD), this option allows you to
- 	  enable debugging output while the system is running, in order to
- 	  help track down any problems you are having.  By default the
-@@ -266,11 +337,12 @@
- 	  "echo 0 > /proc/sys/fs/jbd2-debug".
- 
- config FS_MBCACHE
--# Meta block cache for Extended Attributes (ext2/ext3/ext4)
-+# Meta block cache for Extended Attributes (ext2/ext3(cow)/ext4)
- 	tristate
--	depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT4DEV_FS_XATTR
--	default y if EXT2_FS=y || EXT3_FS=y || EXT4DEV_FS=y
--	default m if EXT2_FS=m || EXT3_FS=m || EXT4DEV_FS=m
-+	depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT3COW_FS_XATTR || EXT4DEV_FS_XATTR
-+	default y if EXT2_FS=y || EXT3_FS=y || EXT3COW_FS=y || EXT4DEV_FS=y
-+	default m if EXT2_FS=m || EXT3_FS=m || EXT3COW_FS=m || EXT4DEV_FS=m
-+
- 
- config REISERFS_FS
- 	tristate "Reiserfs support"
-diff -ruN linux-2.6.20.3/fs/Makefile linux-2.6.20.3-ext3cow/fs/Makefile
---- linux-2.6.20.3/fs/Makefile	2007-03-13 14:27:08.000000000 -0400
-+++ linux-2.6.20.3-ext3cow/fs/Makefile	2007-04-07 14:23:46.000000000 -0400
-@@ -63,6 +63,7 @@
- # Do not add any filesystems before this line
- obj-$(CONFIG_REISERFS_FS)	+= reiserfs/
- obj-$(CONFIG_EXT3_FS)		+= ext3/ # Before ext2 so root fs can be ext3
-+obj-$(CONFIG_EXT3COW_FS)		+= ext3cow/ # Before ext2 so root fs can be ext3
- obj-$(CONFIG_EXT4DEV_FS)	+= ext4/ # Before ext2 so root fs can be ext4dev
- obj-$(CONFIG_JBD)		+= jbd/
- obj-$(CONFIG_JBD2)		+= jbd2/
-diff -ruN linux-2.6.20.3/fs/ext3cow/Makefile linux-2.6.20.3-ext3cow/fs/ext3cow/Makefile
---- linux-2.6.20.3/fs/ext3cow/Makefile	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/Makefile	2007-04-07 14:23:50.000000000 -0400
-@@ -0,0 +1,12 @@
-+#
-+# Makefile for the linux ext3cow-filesystem routines.
-+#
-+
-+obj-$(CONFIG_EXT3COW_FS) += ext3cow.o
-+
-+ext3cow-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
-+	   ioctl.o namei.o super.o symlink.o hash.o resize.o ext3cow_jbd.o
-+
-+ext3cow-$(CONFIG_EXT3COW_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
-+ext3cow-$(CONFIG_EXT3COW_FS_POSIX_ACL) += acl.o
-+ext3cow-$(CONFIG_EXT3COW_FS_SECURITY)	 += xattr_security.o
 diff -ruN linux-2.6.20.3/fs/ext3cow/acl.c linux-2.6.20.3-ext3cow/fs/ext3cow/acl.c
 --- linux-2.6.20.3/fs/ext3cow/acl.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/acl.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/acl.c	2008-03-09 11:14:49.000000000 -0400
 @@ -0,0 +1,551 @@
 +/*
 + * linux/fs/ext3cow/acl.c
@@ -708,7 +555,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/acl.c linux-2.6.20.3-ext3cow/fs/ext3cow/acl.
 +};
 diff -ruN linux-2.6.20.3/fs/ext3cow/acl.h linux-2.6.20.3-ext3cow/fs/ext3cow/acl.h
 --- linux-2.6.20.3/fs/ext3cow/acl.h	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/acl.h	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/acl.h	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,81 @@
 +/*
 +  File: fs/ext3cow/acl.h
@@ -793,7 +640,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/acl.h linux-2.6.20.3-ext3cow/fs/ext3cow/acl.
 +
 diff -ruN linux-2.6.20.3/fs/ext3cow/balloc.c linux-2.6.20.3-ext3cow/fs/ext3cow/balloc.c
 --- linux-2.6.20.3/fs/ext3cow/balloc.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/balloc.c	2007-04-14 11:40:48.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/balloc.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,1823 @@
 +/*
 + *  linux/fs/ext3cow/balloc.c
@@ -2620,7 +2467,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/balloc.c linux-2.6.20.3-ext3cow/fs/ext3cow/b
 +}
 diff -ruN linux-2.6.20.3/fs/ext3cow/bitmap.c linux-2.6.20.3-ext3cow/fs/ext3cow/bitmap.c
 --- linux-2.6.20.3/fs/ext3cow/bitmap.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/bitmap.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/bitmap.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,32 @@
 +/*
 + *  linux/fs/ext3/bitmap.c
@@ -2654,9 +2501,26 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/bitmap.c linux-2.6.20.3-ext3cow/fs/ext3cow/b
 +
 +#endif  /*  EXT3COWFS_DEBUG  */
 +
+diff -ruN linux-2.6.20.3/fs/ext3cow/CHANGELOG linux-2.6.20.3-ext3cow/fs/ext3cow/CHANGELOG
+--- linux-2.6.20.3/fs/ext3cow/CHANGELOG	1969-12-31 19:00:00.000000000 -0500
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/CHANGELOG	2008-03-09 11:27:12.000000000 -0400
+@@ -0,0 +1,12 @@
++3-9-08
++- Fixed a bug that resulted in the first block in a newly allocated indirect block to be allocated over and over again.
++- Fixed a bug that resulted in COW bitmaps not to be reset after truncate.
++- Bug e2fsprogs that caused aborting journal fixed.
++
++6-20-97
++- Finished the rollback code for inode chains in case of error.
++
++6-18-07
++- Added support for 32-bit uid's and gid's back in again
++- Took out support for block fragmentation
++- Hopefully fixed the non-sticking uid/gid bug.
+\ No newline at end of file
 diff -ruN linux-2.6.20.3/fs/ext3cow/dir.c linux-2.6.20.3-ext3cow/fs/ext3cow/dir.c
 --- linux-2.6.20.3/fs/ext3cow/dir.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/dir.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/dir.c	2008-03-09 11:14:49.000000000 -0400
 @@ -0,0 +1,732 @@
 +/*
 + *  linux/fs/ext3cow/dir.c
@@ -2769,7 +2633,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/dir.c linux-2.6.20.3-ext3cow/fs/ext3cow/dir.
 +		 * of recovering data when there's a bad sector
 +		 */
 +    if (!bh) {
-+      ext3cow_error (sb, "ext3cow_readdir",
++      ext3cow_error (sb, "ext3cow_versions",
 +                     "directory #%lu contains a hole at offset %lu",
 +                     dir->i_ino, (unsigned long)filp->f_pos);
 +      /* corrupt size?  Maybe no more blocks to read */
@@ -2808,7 +2672,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/dir.c linux-2.6.20.3-ext3cow/fs/ext3cow/dir.
 +    while (!error && filp->f_pos < dir->i_size 
 +           && offset < sb->s_blocksize) {
 +      de = (struct ext3cow_dir_entry_2 *) (bh->b_data + offset);
-+      if (!ext3cow_check_dir_entry ("ext3cow_readdir", dir, de,
++      if (!ext3cow_check_dir_entry ("ext3cow_readversions", dir, de,
 +                                    bh, offset)) {
 +				/* On error, skip the f_pos to the
 +           next block. */
@@ -3392,7 +3256,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/dir.c linux-2.6.20.3-ext3cow/fs/ext3cow/dir.
 +#endif
 diff -ruN linux-2.6.20.3/fs/ext3cow/ext3cow_jbd.c linux-2.6.20.3-ext3cow/fs/ext3cow/ext3cow_jbd.c
 --- linux-2.6.20.3/fs/ext3cow/ext3cow_jbd.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/ext3cow_jbd.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/ext3cow_jbd.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,59 @@
 +/*
 + * Interface between ext3cow and JBD
@@ -3455,7 +3319,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/ext3cow_jbd.c linux-2.6.20.3-ext3cow/fs/ext3
 +}
 diff -ruN linux-2.6.20.3/fs/ext3cow/file.c linux-2.6.20.3-ext3cow/fs/ext3cow/file.c
 --- linux-2.6.20.3/fs/ext3cow/file.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/file.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/file.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,147 @@
 +/*
 + *  linux/fs/ext3cow/file.c
@@ -3606,7 +3470,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/file.c linux-2.6.20.3-ext3cow/fs/ext3cow/fil
 +
 diff -ruN linux-2.6.20.3/fs/ext3cow/fsync.c linux-2.6.20.3-ext3cow/fs/ext3cow/fsync.c
 --- linux-2.6.20.3/fs/ext3cow/fsync.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/fsync.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/fsync.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,88 @@
 +/*
 + *  linux/fs/ext3cow/fsync.c
@@ -3698,7 +3562,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/fsync.c linux-2.6.20.3-ext3cow/fs/ext3cow/fs
 +}
 diff -ruN linux-2.6.20.3/fs/ext3cow/hash.c linux-2.6.20.3-ext3cow/fs/ext3cow/hash.c
 --- linux-2.6.20.3/fs/ext3cow/hash.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/hash.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/hash.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,152 @@
 +/*
 + *  linux/fs/ext3cow/hash.c
@@ -3854,8 +3718,8 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/hash.c linux-2.6.20.3-ext3cow/fs/ext3cow/has
 +}
 diff -ruN linux-2.6.20.3/fs/ext3cow/ialloc.c linux-2.6.20.3-ext3cow/fs/ext3cow/ialloc.c
 --- linux-2.6.20.3/fs/ext3cow/ialloc.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/ialloc.c	2007-04-07 14:23:50.000000000 -0400
-@@ -0,0 +1,763 @@
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/ialloc.c	2008-03-09 11:14:48.000000000 -0400
+@@ -0,0 +1,764 @@
 +/*
 + *  linux/fs/ext3cow/ialloc.c
 + *
@@ -4436,9 +4300,10 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/ialloc.c linux-2.6.20.3-ext3cow/fs/ext3cow/i
 +	if (!S_ISDIR(mode))
 +		ei->i_flags &= ~EXT3COW_DIRSYNC_FL;
 +#ifdef EXT3COW_FRAGMENTS
-+	ei->i_faddr = 0;
-+	ei->i_frag_no = 0;
-+	ei->i_frag_size = 0;
++  /* Taken out for versioning -znjp */
++	//ei->i_faddr = 0;
++	//ei->i_frag_no = 0;
++	//ei->i_frag_size = 0;
 +#endif
 +	ei->i_file_acl = 0;
 +	ei->i_dir_acl = 0;
@@ -4621,8 +4486,8 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/ialloc.c linux-2.6.20.3-ext3cow/fs/ext3cow/i
 +
 diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/inode.c
 --- linux-2.6.20.3/fs/ext3cow/inode.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/inode.c	2007-04-17 11:34:02.000000000 -0400
-@@ -0,0 +1,3474 @@
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/inode.c	2008-03-09 11:14:48.000000000 -0400
+@@ -0,0 +1,3502 @@
 +/*
 + *  linux/fs/ext3cow/inode.c
 + *
@@ -5012,25 +4877,28 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +{
 +	struct super_block *sb = inode->i_sb;
 +	Indirect *p = chain;
-+	struct buffer_head *bh;
-+  u32* bitmap_w;
++	struct buffer_head *bh = NULL;
++  u32 *bitmap_w = NULL;
 +  int ptrs = EXT3COW_ADDR_PER_BLOCK(inode->i_sb);
 +  int nbitsperword = (sizeof(u32) * 8);
 +
 +	*err = 0;
 +  *cow = 0;
++
++
 +	/* i_data is not going away, no lock needed */
 +	add_chain (chain, NULL, EXT3COW_I(inode)->i_data + *offsets);
 +	if (!p->key){
 +    /* Set the bitmap on allocation - znjp */
-+    if(create)
++    if(create){
 +      EXT3COW_I(inode)->i_cow_bitmap |= (1UL << *offsets);
++    }
 +		goto no_block;
 +  }
 +
-+  /* Are we COWing any direct blocks? -znjp */
++  /* Are we writing and COWing any direct blocks? -znjp */
 +  if(create && !(EXT3COW_I(inode)->i_cow_bitmap & (1UL << *offsets))){    
-+    printk(KERN_INFO "COWing direct block\n");
++    //printk(KERN_INFO "COWing direct block\n");
 +    *(p->p) = 0;
 +    p->key = 0;
 +    /* Set the bitamp when COWing -znjp */
@@ -5040,6 +4908,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +  }
 +
 +	while (--depth) {
++
 +		bh = sb_bread(sb, le32_to_cpu(p->key));
 +		if (!bh)
 +			goto failure;
@@ -5049,23 +4918,23 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +			goto changed;
 +		add_chain(++p, bh, (__le32*)bh->b_data + *++offsets);
 +		/* Reader: end */
-+    /* Find correct bitamp word */
++    /* Find correct bitmap word */
 +    bitmap_w = (u32*)bh->b_data + ptrs + (*offsets/nbitsperword);
 +		if (!p->key){
 +      /* Set the bitmap when allocating -znjp */
-+      if(create)
-+       *bitmap_w = (u32)*bitmap_w | (u32)(1UL << (int)(*offsets%nbitsperword));
++      if(create){
++       *bitmap_w |= (u32)(1UL << (int)(*offsets%nbitsperword));
++      }
 +			goto no_block;
 +    }
 +
 +    /* Are we COWing any indirect blocks? -znjp */
-+    if(create && !((1UL << (int)(*offsets%nbitsperword)) & 
-+         le32_to_cpu((u32)*bitmap_w))){
-+      printk(KERN_INFO "COWing indirect block\n");
++    if(create && !(*bitmap_w & (1UL << (int)(*offsets%nbitsperword)))){
++      //printk(KERN_INFO "COWing indirect block\n");
 +      *(p->p) = 0;
 +      p->key = 0;
 +      /* Set the bitmap -znjp */
-+      *bitmap_w = (u32)*bitmap_w | (u32)(1UL << (int)(*offsets%nbitsperword));
++      *bitmap_w |= (u32)(1UL << (int)(*offsets%nbitsperword));
 +      *cow = 1;
 +      goto no_block;
 +    }
@@ -5297,6 +5166,10 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +	ext3cow_fsblk_t new_blocks[4];
 +	ext3cow_fsblk_t current_block;
 +
++  u32 *bitmap_w = NULL;
++  int ptrs = EXT3COW_ADDR_PER_BLOCK(inode->i_sb);
++  int nbitsperword = (sizeof(u32) * 8);
++
 +	num = ext3cow_alloc_blocks(handle, inode, goal, indirect_blks,
 +				*blks, new_blocks, &err);
 +	if (err)
@@ -5306,6 +5179,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +	/*
 +	 * metadata blocks and data blocks are allocated.
 +	 */
++
 +	for (n = 1; n <= indirect_blks;  n++) {
 +		/*
 +		 * Get buffer_head for parent block, zero it out
@@ -5324,6 +5198,13 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +		}
 +
 +		memset(bh->b_data, 0, blocksize);
++    /* Mark the cow bitmap for each new indirect block allocated.
++     * We had to put this here, because get_branch was insufficient
++     * when allocating an indirect block. -znjp
++     */
++    bitmap_w = (u32*)bh->b_data + ptrs + (offsets[n]/nbitsperword);
++    *bitmap_w |= (u32)(1UL << (int)(offsets[n]%nbitsperword));
++
 +		branch[n].p = (__le32 *) bh->b_data + offsets[n];
 +		branch[n].key = cpu_to_le32(new_blocks[n]);
 +		*branch[n].p = branch[n].key;
@@ -6902,6 +6783,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +				continue;
 +			}
 +      /* Only free the branches that have been newly allocated - znjp */
++      /* Also, set the bits back to 0 in the bitmap -znjp */
 +      cur = 0;
 +      count = 0;
 +      bitmap_word = (u32*)bh->b_data + addr_per_block;
@@ -6924,6 +6806,8 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +              first_block = (u32*)bh->b_data + cur;
 +              count = 1;
 +            }
++            /* Set the bit in the bitmap back to 0 */
++            *bitmap_word ^= (1UL << i);
 +          }
 +        }
 +        (u32*)bitmap_word++;
@@ -7135,6 +7019,9 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +
 +    /* We only want to remove blocks that were allocated in this
 +     * epoch, i.e., have 1 bit in the bitmap. -znjp */
++    /* If we're going to truncate a block, we should its
++     * corresponding bit in the bitmap back to 0, meaning,
++     * it needs to be allocated - znjp */ 
 +    for(b = offsets[0]; b < EXT3COW_NDIR_BLOCKS; b++){
 +      if(EXT3COW_I(inode)->i_cow_bitmap & (1UL << b)){
 +        if(count == 0){
@@ -7148,6 +7035,8 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +          block_to_free = b;
 +          count = 1;
 +        }
++        /* Turn off the bit in the bitmap */
++        EXT3COW_I(inode)->i_cow_bitmap ^= (1UL << b);
 +      }
 +    }
 +    if(count > 0)
@@ -7198,6 +7087,8 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +       ext3cow_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
 +       i_data[EXT3COW_IND_BLOCK] = 0;
 +     }
++     /* And set bitmap back to 0 */
++     EXT3COW_I(inode)->i_cow_bitmap ^= (1UL << EXT3COW_IND_BLOCK);
 +   }
 +	case EXT3COW_IND_BLOCK:
 +   if(EXT3COW_I(inode)->i_cow_bitmap & (1UL << EXT3COW_DIND_BLOCK)){
@@ -7206,6 +7097,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +       ext3cow_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
 +       i_data[EXT3COW_DIND_BLOCK] = 0;
 +     }
++     EXT3COW_I(inode)->i_cow_bitmap ^= (1UL << EXT3COW_DIND_BLOCK);
 +   }
 +	case EXT3COW_DIND_BLOCK:
 +   if(EXT3COW_I(inode)->i_cow_bitmap & (1UL << EXT3COW_TIND_BLOCK)){
@@ -7214,6 +7106,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +       ext3cow_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
 +       i_data[EXT3COW_TIND_BLOCK] = 0;
 +     }
++     EXT3COW_I(inode)->i_cow_bitmap ^= (1UL << EXT3COW_TIND_BLOCK);
 +   }
 +	case EXT3COW_TIND_BLOCK:
 +		;
@@ -7450,12 +7343,10 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +	inode->i_mode = le16_to_cpu(raw_inode->i_mode);
 +	inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
 +	inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
-+  /* Taken out for versioning -znjp
 +	if(!(test_opt (inode->i_sb, NO_UID32))) {
 +		inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
 +		inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
 +	}
-+  */
 +	inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
 +	inode->i_size = le32_to_cpu(raw_inode->i_size);
 +	inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime);
@@ -7491,9 +7382,10 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +  ei->i_next_inode   = le32_to_cpu(raw_inode->i_nxt_inode);
 +  
 +#ifdef EXT3COW_FRAGMENTS
-+	ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
-+	ei->i_frag_no = raw_inode->i_frag;
-+	ei->i_frag_size = raw_inode->i_fsize;
++  /* Taken out for versioning -znjp */
++	//ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
++	//ei->i_frag_no = raw_inode->i_frag;
++	//ei->i_frag_size = raw_inode->i_fsize;
 +#endif
 +	ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl);
 +	if (!S_ISREG(inode->i_mode)) {
@@ -7593,15 +7485,15 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +
 +	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
 +
-+  /* Taken out for versioning  -znjp
++
 +	if(!(test_opt(inode->i_sb, NO_UID32))) {
 +		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
 +		raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
-+*
-+ * Fix up interoperability with old kernels. Otherwise, old inodes get
-+ * re-used with the upper 16 bits of the uid/gid intact
-+ *
-+
++    
++    /* Fix up interoperability with old kernels. Otherwise, old inodes get
++     * re-used with the upper 16 bits of the uid/gid intact
++     */
++    
 +		if(!ei->i_dtime) {
 +			raw_inode->i_uid_high =
 +				cpu_to_le16(high_16_bits(inode->i_uid));
@@ -7620,7 +7512,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +		raw_inode->i_uid_high = 0;
 +		raw_inode->i_gid_high = 0;
 +	}
-+  */
++ 
 +	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
 +	raw_inode->i_size = cpu_to_le32(ei->i_disksize);
 +	raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
@@ -7635,9 +7527,10 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +  raw_inode->i_nxt_inode   = cpu_to_le32(EXT3COW_I(inode)->i_next_inode);
 +
 +#ifdef EXT3COW_FRAGMENTS
-+	raw_inode->i_faddr = cpu_to_le32(ei->i_faddr);
-+	raw_inode->i_frag = ei->i_frag_no;
-+	raw_inode->i_fsize = ei->i_frag_size;
++  /* Taken out for versioning -znjp */
++	//raw_inode->i_faddr = cpu_to_le32(ei->i_faddr);
++	//raw_inode->i_frag = ei->i_frag_no;
++	//raw_inode->i_fsize = ei->i_frag_size;
 +#endif
 +	raw_inode->i_file_acl = cpu_to_le32(ei->i_file_acl);
 +	if (!S_ISREG(inode->i_mode)) {
@@ -8099,7 +7992,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/inode.c linux-2.6.20.3-ext3cow/fs/ext3cow/in
 +}
 diff -ruN linux-2.6.20.3/fs/ext3cow/ioctl.c linux-2.6.20.3-ext3cow/fs/ext3cow/ioctl.c
 --- linux-2.6.20.3/fs/ext3cow/ioctl.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/ioctl.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/ioctl.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,312 @@
 +/*
 + * linux/fs/ext3cow/ioctl.c
@@ -8413,10 +8306,26 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/ioctl.c linux-2.6.20.3-ext3cow/fs/ext3cow/io
 +	return ret;
 +}
 +#endif
+diff -ruN linux-2.6.20.3/fs/ext3cow/Makefile linux-2.6.20.3-ext3cow/fs/ext3cow/Makefile
+--- linux-2.6.20.3/fs/ext3cow/Makefile	1969-12-31 19:00:00.000000000 -0500
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/Makefile	2008-03-09 11:14:49.000000000 -0400
+@@ -0,0 +1,12 @@
++#
++# Makefile for the linux ext3cow-filesystem routines.
++#
++
++obj-$(CONFIG_EXT3COW_FS) += ext3cow.o
++
++ext3cow-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
++	   ioctl.o namei.o super.o symlink.o hash.o resize.o ext3cow_jbd.o
++
++ext3cow-$(CONFIG_EXT3COW_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
++ext3cow-$(CONFIG_EXT3COW_FS_POSIX_ACL) += acl.o
++ext3cow-$(CONFIG_EXT3COW_FS_SECURITY)	 += xattr_security.o
 diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/namei.c
 --- linux-2.6.20.3/fs/ext3cow/namei.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/namei.c	2007-04-16 22:44:05.000000000 -0400
-@@ -0,0 +1,2960 @@
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/namei.c	2008-03-09 11:14:48.000000000 -0400
+@@ -0,0 +1,2979 @@
 +/*
 + *  linux/fs/ext3cow/namei.c
 + *
@@ -9988,7 +9897,6 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +
 +  if(EXT3COW_S_EPOCHNUMBER(sb) > EXT3COW_I_EPOCHNUMBER(dir)){   
 +    if(ext3cow_dup_inode(dentry->d_parent->d_parent->d_inode, dir))
-+      //if(ext3cow_dup_inode(NULL, dir))
 +      return -1;
 +  }
 +
@@ -10197,7 +10105,6 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +      
 +      if(EXT3COW_S_EPOCHNUMBER(dir->i_sb) > EXT3COW_I_EPOCHNUMBER(dir)){
 +        if(ext3cow_dup_inode(dentry->d_parent->d_parent->d_inode, dir))
-+          //if(ext3cow_dup_inode(NULL, dir))
 +          return -1;
 +      }
 +
@@ -11074,11 +10981,6 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +    fake_inode->i_uid  = inode->i_uid;
 +    fake_inode->i_gid  = inode->i_gid;
 +
-+    /* uid_high and gid_high code would go here -znjp 
-+       fake_inode->i_uid_high = inode->i_uid_high;
-+       fake_inode->i_gid_high = inode->i_gid_high;
-+    */
-+
 +    atomic_set(&fake_inode->i_count, 1);
 +
 +    fake_inode->i_nlink         = inode->i_nlink;
@@ -11097,9 +10999,10 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +    fake_inode->i_blocks  = inode->i_blocks;
 +    fake_ini->i_flags     = ini->i_flags;
 +#ifdef EXT3COW_FRAGMENTS
-+    fake_ini->i_faddr     = ini->i_faddr;
-+    fake_ini->i_frag_no   = ini->i_frag_no;
-+    fake_ini->i_frag_size = ini->i_frag_size;
++    /* Taken out for versioning -znjp */
++    //fake_ini->i_faddr     = ini->i_faddr;
++    //fake_ini->i_frag_no   = ini->i_frag_no;
++    //fake_ini->i_frag_size = ini->i_frag_size;
 +#endif
 +    fake_ini->i_file_acl = ini->i_file_acl;
 +    if (!S_ISREG(fake_inode->i_mode)) {
@@ -11229,11 +11132,6 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +    cow_inode->i_mode = inode->i_mode;
 +    cow_inode->i_uid  = inode->i_uid;
 +    cow_inode->i_gid  = inode->i_gid;
-+    
-+    /* uid_high and gid_high code would go here -znjp 
-+       cow_inode->i_uid_high = inode->i_uid_high;
-+       cow_inode->i_gid_high = inode->i_gid_high;
-+    */
 +
 +    cow_inode->i_nlink         = inode->i_nlink;
 +    cow_inode->i_size          = inode->i_size;
@@ -11251,9 +11149,10 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +    cow_inode->i_blocks  = inode->i_blocks;
 +    cow_ini->i_flags     = ini->i_flags;
 +#ifdef EXT3COW_FRAGMENTS
-+    cow_ini->i_faddr     = ini->i_faddr;
-+    cow_ini->i_frag_no   = ini->i_frag_no;
-+    cow_ini->i_frag_size = ini->i_frag_size;
++    /* Taken out for versioning -znjp */
++    //cow_ini->i_faddr     = ini->i_faddr;
++    //cow_ini->i_frag_no   = ini->i_frag_no;
++    //cow_ini->i_frag_size = ini->i_frag_size;
 +#endif
 +    cow_ini->i_file_acl = ini->i_file_acl;
 +    if (!S_ISREG(cow_inode->i_mode)) {
@@ -11334,14 +11233,43 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 + * be used for removing versions.  */
 +int ext3cow_reclaim_dup_inode(struct inode *dir, struct inode *inode)
 +{
-+  //  handle_t *handle = NULL;
++  handle_t *handle = NULL;
++  int err = 0;
++  struct inode *old_inode = NULL;
++  struct inode *parent = dir;
++
++  if(!parent)
++    parent = inode;
 +
 +  if(is_bad_inode(inode))
-+    goto no_delete;
++    return -1;
++  
++  handle = ext3cow_journal_start(parent, 
++                                 EXT3COW_DELETE_TRANS_BLOCKS(parent->i_sb));
++  if(IS_ERR(handle))
++    return PTR_ERR(handle);
++
++  if(IS_DIRSYNC(parent))
++    handle->h_sync = 1;
++
++  old_inode = iget(parent->i_sb, EXT3COW_I_NEXT_INODE(inode));
++  err = PTR_ERR(old_inode);
++  if (!IS_ERR(old_inode)){
 +
++    EXT3COW_I(inode)->i_epoch_number = EXT3COW_I_EPOCHNUMBER(old_inode);
++    EXT3COW_I(inode)->i_cow_bitmap   = EXT3COW_I(old_inode)->i_cow_bitmap;
++    EXT3COW_I(inode)->i_next_inode   = EXT3COW_I(old_inode)->i_next_inode;
++    old_inode->i_nlink = 0;
++
++    iput(old_inode);
++    ext3cow_mark_inode_dirty(handle, inode);
++  }else
++    ext3cow_error(inode->i_sb, "ext3cow_reclaim_dup_inode", 
++                  "Couldn't remove dup'd inode.");
++  
++  ext3cow_journal_stop(handle);
++  
 +  return 0;
-+ no_delete:
-+  return -1;
 +}
 +
 +/*
@@ -11379,7 +11307,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.c linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +};
 diff -ruN linux-2.6.20.3/fs/ext3cow/namei.h linux-2.6.20.3-ext3cow/fs/ext3cow/namei.h
 --- linux-2.6.20.3/fs/ext3cow/namei.h	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/namei.h	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/namei.h	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,8 @@
 +/*  linux/fs/ext3cow/namei.h
 + *
@@ -11391,7 +11319,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/namei.h linux-2.6.20.3-ext3cow/fs/ext3cow/na
 +extern struct dentry *ext3cow_get_parent(struct dentry *child);
 diff -ruN linux-2.6.20.3/fs/ext3cow/resize.c linux-2.6.20.3-ext3cow/fs/ext3cow/resize.c
 --- linux-2.6.20.3/fs/ext3cow/resize.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/resize.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/resize.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,1042 @@
 +/*
 + *  linux/fs/ext3cow/resize.c
@@ -12437,7 +12365,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/resize.c linux-2.6.20.3-ext3cow/fs/ext3cow/r
 +} /* ext3cow_group_extend */
 diff -ruN linux-2.6.20.3/fs/ext3cow/super.c linux-2.6.20.3-ext3cow/fs/ext3cow/super.c
 --- linux-2.6.20.3/fs/ext3cow/super.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/super.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/super.c	2008-03-09 11:14:49.000000000 -0400
 @@ -0,0 +1,2808 @@
 +/*
 + *  linux/fs/ext3cow/super.c
@@ -15249,7 +15177,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/super.c linux-2.6.20.3-ext3cow/fs/ext3cow/su
 +module_exit(exit_ext3cow_fs)
 diff -ruN linux-2.6.20.3/fs/ext3cow/symlink.c linux-2.6.20.3-ext3cow/fs/ext3cow/symlink.c
 --- linux-2.6.20.3/fs/ext3cow/symlink.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/symlink.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/symlink.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,54 @@
 +/*
 + *  linux/fs/ext3cow/symlink.c
@@ -15307,7 +15235,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/symlink.c linux-2.6.20.3-ext3cow/fs/ext3cow/
 +};
 diff -ruN linux-2.6.20.3/fs/ext3cow/xattr.c linux-2.6.20.3-ext3cow/fs/ext3cow/xattr.c
 --- linux-2.6.20.3/fs/ext3cow/xattr.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr.c	2008-03-09 11:14:49.000000000 -0400
 @@ -0,0 +1,1314 @@
 +/*
 + * linux/fs/ext3cow/xattr.c
@@ -16625,7 +16553,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/xattr.c linux-2.6.20.3-ext3cow/fs/ext3cow/xa
 +}
 diff -ruN linux-2.6.20.3/fs/ext3cow/xattr.h linux-2.6.20.3-ext3cow/fs/ext3cow/xattr.h
 --- linux-2.6.20.3/fs/ext3cow/xattr.h	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr.h	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr.h	2008-03-09 11:14:49.000000000 -0400
 @@ -0,0 +1,145 @@
 +/*
 +  File: fs/ext3cow/xattr.h
@@ -16774,7 +16702,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/xattr.h linux-2.6.20.3-ext3cow/fs/ext3cow/xa
 +#endif
 diff -ruN linux-2.6.20.3/fs/ext3cow/xattr_security.c linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_security.c
 --- linux-2.6.20.3/fs/ext3cow/xattr_security.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_security.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_security.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,77 @@
 +/*
 + * linux/fs/ext3cow/xattr_security.c
@@ -16855,7 +16783,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/xattr_security.c linux-2.6.20.3-ext3cow/fs/e
 +};
 diff -ruN linux-2.6.20.3/fs/ext3cow/xattr_trusted.c linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_trusted.c
 --- linux-2.6.20.3/fs/ext3cow/xattr_trusted.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_trusted.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_trusted.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,62 @@
 +/*
 + * linux/fs/ext3cow/xattr_trusted.c
@@ -16921,7 +16849,7 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/xattr_trusted.c linux-2.6.20.3-ext3cow/fs/ex
 +};
 diff -ruN linux-2.6.20.3/fs/ext3cow/xattr_user.c linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_user.c
 --- linux-2.6.20.3/fs/ext3cow/xattr_user.c	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_user.c	2007-04-07 14:23:50.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/ext3cow/xattr_user.c	2008-03-09 11:14:48.000000000 -0400
 @@ -0,0 +1,64 @@
 +/*
 + * linux/fs/ext3cow/xattr_user.c
@@ -16987,10 +16915,147 @@ diff -ruN linux-2.6.20.3/fs/ext3cow/xattr_user.c linux-2.6.20.3-ext3cow/fs/ext3c
 +	.get	= ext3cow_xattr_user_get,
 +	.set	= ext3cow_xattr_user_set,
 +};
+diff -ruN linux-2.6.20.3/fs/Kconfig linux-2.6.20.3-ext3cow/fs/Kconfig
+--- linux-2.6.20.3/fs/Kconfig	2007-03-13 14:27:08.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/Kconfig	2008-03-09 11:14:25.000000000 -0400
+@@ -136,6 +136,77 @@
+ 	  If you are not using a security module that requires using
+ 	  extended attributes for file security labels, say N.
+ 
++
++
++config EXT3COW_FS
++	tristate "Ext3cow journalling and versioning file system support"
++	select JBD
++	help
++	  This is the journalling version of the Second extended file system
++	  (often called ext3), the de facto standard Linux file system
++	  (method to organize files on a storage device) for hard disks.
++
++	  The journalling code included in this driver means you do not have
++	  to run e2fsck (file system checker) on your file systems after a
++	  crash.  The journal keeps track of any changes that were being made
++	  at the time the system crashed, and can ensure that your file system
++	  is consistent without the need for a lengthy check.
++
++	  Other than adding the journal to the file system, the on-disk format
++	  of ext3 is identical to ext2.  It is possible to freely switch
++	  between using the ext3 driver and the ext2 driver, as long as the
++	  file system has been cleanly unmounted, or e2fsck is run on the file
++	  system.
++
++	  To add a journal on an existing ext2 file system or change the
++	  behavior of ext3 file systems, you can use the tune2fs utility ("man
++	  tune2fs").  To modify attributes of files and directories on ext3
++	  file systems, use chattr ("man chattr").  You need to be using
++	  e2fsprogs version 1.20 or later in order to create ext3 journals
++	  (available at <http://sourceforge.net/projects/e2fsprogs/>).
++
++	  To compile this file system support as a module, choose M here: the
++	  module will be called ext3.
++
++config EXT3COW_FS_XATTR
++	bool "Ext3cow extended attributes"
++	depends on EXT3COW_FS
++	default y
++	help
++	  Extended attributes are name:value pairs associated with inodes by
++	  the kernel or by users (see the attr(5) manual page, or visit
++	  <http://acl.bestbits.at/> for details).
++
++	  If unsure, say N.
++
++	  You need this for POSIX ACL support on ext3cow.
++
++config EXT3COW_FS_POSIX_ACL
++	bool "Ext3cow POSIX Access Control Lists"
++	depends on EXT3COW_FS_XATTR
++	select FS_POSIX_ACL
++	help
++	  Posix Access Control Lists (ACLs) support permissions for users and
++	  groups beyond the owner/group/world scheme.
++
++	  To learn more about Access Control Lists, visit the Posix ACLs for
++	  Linux website <http://acl.bestbits.at/>.
++
++	  If you don't know what Access Control Lists are, say N
++
++config EXT3COW_FS_SECURITY
++	bool "Ext3cow Security Labels"
++	depends on EXT3COW_FS_XATTR
++	help
++	  Security labels support alternative access control models
++	  implemented by security modules like SELinux.  This option
++	  enables an extended attribute handler for file security
++	  labels in the ext3cow filesystem.
++
++	  If you are not using a security module that requires using
++	  extended attributes for file security labels, say N.
++
++
+ config EXT4DEV_FS
+ 	tristate "Ext4dev/ext4 extended fs support development (EXPERIMENTAL)"
+ 	depends on EXPERIMENTAL
+@@ -205,23 +276,23 @@
+ 	tristate
+ 	help
+ 	  This is a generic journalling layer for block devices.  It is
+-	  currently used by the ext3 and OCFS2 file systems, but it could
++	  currently used by the ext3, ext3cow and OCFS2 file systems, but it could
+ 	  also be used to add journal support to other file systems or block
+ 	  devices such as RAID or LVM.
+ 
+-	  If you are using the ext3 or OCFS2 file systems, you need to
++	  If you are using the ext3, ext3cow or OCFS2 file systems, you need to
+ 	  say Y here. If you are not using ext3 OCFS2 then you will probably
+ 	  want to say N.
+ 
+ 	  To compile this device as a module, choose M here: the module will be
+-	  called jbd.  If you are compiling ext3 or OCFS2 into the kernel,
++	  called jbd.  If you are compiling ext3, ext3cow or OCFS2 into the kernel,
+ 	  you cannot compile this code as a module.
+ 
+ config JBD_DEBUG
+ 	bool "JBD (ext3) debugging support"
+ 	depends on JBD
+ 	help
+-	  If you are using the ext3 journaled file system (or potentially any
++	  If you are using the ext3 or ext3cow journaled file system (or potentially any
+ 	  other file system/device using JBD), this option allows you to
+ 	  enable debugging output while the system is running, in order to
+ 	  help track down any problems you are having.  By default the
+@@ -266,11 +337,12 @@
+ 	  "echo 0 > /proc/sys/fs/jbd2-debug".
+ 
+ config FS_MBCACHE
+-# Meta block cache for Extended Attributes (ext2/ext3/ext4)
++# Meta block cache for Extended Attributes (ext2/ext3(cow)/ext4)
+ 	tristate
+-	depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT4DEV_FS_XATTR
+-	default y if EXT2_FS=y || EXT3_FS=y || EXT4DEV_FS=y
+-	default m if EXT2_FS=m || EXT3_FS=m || EXT4DEV_FS=m
++	depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT3COW_FS_XATTR || EXT4DEV_FS_XATTR
++	default y if EXT2_FS=y || EXT3_FS=y || EXT3COW_FS=y || EXT4DEV_FS=y
++	default m if EXT2_FS=m || EXT3_FS=m || EXT3COW_FS=m || EXT4DEV_FS=m
++
+ 
+ config REISERFS_FS
+ 	tristate "Reiserfs support"
+diff -ruN linux-2.6.20.3/fs/Makefile linux-2.6.20.3-ext3cow/fs/Makefile
+--- linux-2.6.20.3/fs/Makefile	2007-03-13 14:27:08.000000000 -0400
++++ linux-2.6.20.3-ext3cow/fs/Makefile	2008-03-09 11:14:54.000000000 -0400
+@@ -63,6 +63,7 @@
+ # Do not add any filesystems before this line
+ obj-$(CONFIG_REISERFS_FS)	+= reiserfs/
+ obj-$(CONFIG_EXT3_FS)		+= ext3/ # Before ext2 so root fs can be ext3
++obj-$(CONFIG_EXT3COW_FS)		+= ext3cow/ # Before ext2 so root fs can be ext3
+ obj-$(CONFIG_EXT4DEV_FS)	+= ext4/ # Before ext2 so root fs can be ext4dev
+ obj-$(CONFIG_JBD)		+= jbd/
+ obj-$(CONFIG_JBD2)		+= jbd2/
 diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs.h linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs.h
 --- linux-2.6.20.3/include/linux/ext3cow_fs.h	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs.h	2007-04-07 15:30:04.000000000 -0400
-@@ -0,0 +1,947 @@
++++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs.h	2008-03-09 11:10:57.000000000 -0400
+@@ -0,0 +1,948 @@
 +/*
 + *  linux/include/linux/ext3cow_fs.h
 + *
@@ -17021,6 +17086,7 @@ diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs.h linux-2.6.20.3-ext3cow/inclu
 + */
 +#undef EXT3COWFS_DEBUG
 +
++
 +/*
 + * Define EXT3COW_RESERVATION to reserve data blocks for expanding files
 + */
@@ -17314,11 +17380,11 @@ diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs.h linux-2.6.20.3-ext3cow/inclu
 +	__le32	i_faddr;	/* Fragment address */
 +	union {
 +		struct {
-+			__u8	l_i_frag;	/* Fragment number */
-+			__u8	l_i_fsize;	/* Fragment size */
-+			__u16	i_pad1;
-+			//__le16	l_i_uid_high;	/* these 2 fields    */
-+			//__le16	l_i_gid_high;	/* were reserved2[0] */
++			//__u8	l_i_frag;	/* Fragment number */
++			//__u8	l_i_fsize;	/* Fragment size */
++			//__u16	i_pad1;
++			__le16	l_i_uid_high;	/* these 2 fields    */
++			__le16	l_i_gid_high;	/* were reserved2[0] */
 +			//__u32	l_i_reserved2;
 +      /* Epoch number for versioning -znjp */
 +      __le32 l_i_epoch_number;
@@ -17349,13 +17415,13 @@ diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs.h linux-2.6.20.3-ext3cow/inclu
 +/* For versioning -znjp */
 +//#define i_reserved1	osd1.linux1.l_i_reserved1
 +#define i_cowbitmap osd1.linux1.l_i_direct_cow_bitmap
-+#define i_frag		osd2.linux2.l_i_frag
-+#define i_fsize		osd2.linux2.l_i_fsize
++//#define i_frag		osd2.linux2.l_i_frag
++//#define i_fsize		osd2.linux2.l_i_fsize
 +#define i_uid_low	i_uid
 +#define i_gid_low	i_gid
 +/* For versioning -znjp */
-+//#define i_uid_high	osd2.linux2.l_i_uid_high
-+//#define i_gid_high	osd2.linux2.l_i_gid_high
++#define i_uid_high	osd2.linux2.l_i_uid_high
++#define i_gid_high	osd2.linux2.l_i_gid_high
 +//#define i_reserved2	osd2.linux2.l_i_reserved2
 +#define i_epch_number osd2.linux2.l_i_epoch_number
 +#define i_nxt_inode osd2.linux2.l_i_next_inode
@@ -17940,7 +18006,7 @@ diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs.h linux-2.6.20.3-ext3cow/inclu
 +#endif	/* _LINUX_EXT3COW_FS_H */
 diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs_i.h linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs_i.h
 --- linux-2.6.20.3/include/linux/ext3cow_fs_i.h	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs_i.h	2007-03-24 15:22:06.000000000 -0400
++++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs_i.h	2008-03-09 11:10:55.000000000 -0400
 @@ -0,0 +1,152 @@
 +/*
 + *  linux/include/linux/ext3cow_fs_i.h
@@ -18096,7 +18162,7 @@ diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs_i.h linux-2.6.20.3-ext3cow/inc
 +#endif	/* _LINUX_EXT3COW_FS_I */
 diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs_sb.h linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs_sb.h
 --- linux-2.6.20.3/include/linux/ext3cow_fs_sb.h	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs_sb.h	2007-03-24 15:22:35.000000000 -0400
++++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_fs_sb.h	2008-03-09 11:10:57.000000000 -0400
 @@ -0,0 +1,86 @@
 +/*
 + *  linux/include/linux/ext3cow_fs_sb.h
@@ -18186,7 +18252,7 @@ diff -ruN linux-2.6.20.3/include/linux/ext3cow_fs_sb.h linux-2.6.20.3-ext3cow/in
 +#endif	/* _LINUX_EXT3COW_FS_SB */
 diff -ruN linux-2.6.20.3/include/linux/ext3cow_jbd.h linux-2.6.20.3-ext3cow/include/linux/ext3cow_jbd.h
 --- linux-2.6.20.3/include/linux/ext3cow_jbd.h	1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_jbd.h	2007-03-24 13:58:07.000000000 -0400
++++ linux-2.6.20.3-ext3cow/include/linux/ext3cow_jbd.h	2008-03-09 11:10:56.000000000 -0400
 @@ -0,0 +1,226 @@
 +/*
 + * linux/include/linux/ext3cow_jbd.h
@@ -18416,7 +18482,7 @@ diff -ruN linux-2.6.20.3/include/linux/ext3cow_jbd.h linux-2.6.20.3-ext3cow/incl
 +#endif	/* _LINUX_EXT3COW_JBD_H */
 diff -ruN linux-2.6.20.3/include/linux/magic.h linux-2.6.20.3-ext3cow/include/linux/magic.h
 --- linux-2.6.20.3/include/linux/magic.h	2007-03-13 14:27:08.000000000 -0400
-+++ linux-2.6.20.3-ext3cow/include/linux/magic.h	2007-03-24 14:06:39.000000000 -0400
++++ linux-2.6.20.3-ext3cow/include/linux/magic.h	2008-03-09 11:10:57.000000000 -0400
 @@ -9,6 +9,7 @@
  #define EFS_SUPER_MAGIC		0x414A53
  #define EXT2_SUPER_MAGIC	0xEF53
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.20.nix b/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
index 3299ba5a3cb..365453e5872 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.20.nix
@@ -38,6 +38,7 @@ stdenv.mkDerivation {
   };
   
   patches = map (p: p.patch) kernelPatches;
+  
   extraConfig = lib.concatStrings (map (p: "\n" + (if p ? extraConfig then p.extraConfig else "") + "\n") kernelPatches);
 
   config =
@@ -55,7 +56,7 @@ stdenv.mkDerivation {
     if stdenv.system == "x86_64-linux" then "x86_64" else
     abort "Platform ${stdenv.system} is not supported.";
 
-  makeFlags = if userModeLinux then "ARCH=um SHELL=bash" else "";
+  makeFlags = if userModeLinux then "ARCH=um SHELL=bash HAVE_AIO_ABI=" else "";
 
   inherit module_init_tools;
 
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch b/pkgs/os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch
deleted file mode 100644
index 583597158ad..00000000000
--- a/pkgs/os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch
+++ /dev/null
@@ -1,18462 +0,0 @@
-diff -Naur linux-2.6.21.7/fs/ext3cow/acl.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/acl.c
---- linux-2.6.21.7/fs/ext3cow/acl.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/acl.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,551 @@
-+/*
-+ * linux/fs/ext3cow/acl.c
-+ *
-+ * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
-+ */
-+
-+#include <linux/init.h>
-+#include <linux/sched.h>
-+#include <linux/slab.h>
-+#include <linux/capability.h>
-+#include <linux/fs.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include "xattr.h"
-+#include "acl.h"
-+
-+/*
-+ * Convert from filesystem to in-memory representation.
-+ */
-+static struct posix_acl *
-+ext3cow_acl_from_disk(const void *value, size_t size)
-+{
-+	const char *end = (char *)value + size;
-+	int n, count;
-+	struct posix_acl *acl;
-+
-+	if (!value)
-+		return NULL;
-+	if (size < sizeof(ext3cow_acl_header))
-+		 return ERR_PTR(-EINVAL);
-+	if (((ext3cow_acl_header *)value)->a_version !=
-+	    cpu_to_le32(EXT3COW_ACL_VERSION))
-+		return ERR_PTR(-EINVAL);
-+	value = (char *)value + sizeof(ext3cow_acl_header);
-+	count = ext3cow_acl_count(size);
-+	if (count < 0)
-+		return ERR_PTR(-EINVAL);
-+	if (count == 0)
-+		return NULL;
-+	acl = posix_acl_alloc(count, GFP_KERNEL);
-+	if (!acl)
-+		return ERR_PTR(-ENOMEM);
-+	for (n=0; n < count; n++) {
-+		ext3cow_acl_entry *entry =
-+			(ext3cow_acl_entry *)value;
-+		if ((char *)value + sizeof(ext3cow_acl_entry_short) > end)
-+			goto fail;
-+		acl->a_entries[n].e_tag  = le16_to_cpu(entry->e_tag);
-+		acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
-+		switch(acl->a_entries[n].e_tag) {
-+			case ACL_USER_OBJ:
-+			case ACL_GROUP_OBJ:
-+			case ACL_MASK:
-+			case ACL_OTHER:
-+				value = (char *)value +
-+					sizeof(ext3cow_acl_entry_short);
-+				acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
-+				break;
-+
-+			case ACL_USER:
-+			case ACL_GROUP:
-+				value = (char *)value + sizeof(ext3cow_acl_entry);
-+				if ((char *)value > end)
-+					goto fail;
-+				acl->a_entries[n].e_id =
-+					le32_to_cpu(entry->e_id);
-+				break;
-+
-+			default:
-+				goto fail;
-+		}
-+	}
-+	if (value != end)
-+		goto fail;
-+	return acl;
-+
-+fail:
-+	posix_acl_release(acl);
-+	return ERR_PTR(-EINVAL);
-+}
-+
-+/*
-+ * Convert from in-memory to filesystem representation.
-+ */
-+static void *
-+ext3cow_acl_to_disk(const struct posix_acl *acl, size_t *size)
-+{
-+	ext3cow_acl_header *ext_acl;
-+	char *e;
-+	size_t n;
-+
-+	*size = ext3cow_acl_size(acl->a_count);
-+	ext_acl = kmalloc(sizeof(ext3cow_acl_header) + acl->a_count *
-+			sizeof(ext3cow_acl_entry), GFP_KERNEL);
-+	if (!ext_acl)
-+		return ERR_PTR(-ENOMEM);
-+	ext_acl->a_version = cpu_to_le32(EXT3COW_ACL_VERSION);
-+	e = (char *)ext_acl + sizeof(ext3cow_acl_header);
-+	for (n=0; n < acl->a_count; n++) {
-+		ext3cow_acl_entry *entry = (ext3cow_acl_entry *)e;
-+		entry->e_tag  = cpu_to_le16(acl->a_entries[n].e_tag);
-+		entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
-+		switch(acl->a_entries[n].e_tag) {
-+			case ACL_USER:
-+			case ACL_GROUP:
-+				entry->e_id =
-+					cpu_to_le32(acl->a_entries[n].e_id);
-+				e += sizeof(ext3cow_acl_entry);
-+				break;
-+
-+			case ACL_USER_OBJ:
-+			case ACL_GROUP_OBJ:
-+			case ACL_MASK:
-+			case ACL_OTHER:
-+				e += sizeof(ext3cow_acl_entry_short);
-+				break;
-+
-+			default:
-+				goto fail;
-+		}
-+	}
-+	return (char *)ext_acl;
-+
-+fail:
-+	kfree(ext_acl);
-+	return ERR_PTR(-EINVAL);
-+}
-+
-+static inline struct posix_acl *
-+ext3cow_iget_acl(struct inode *inode, struct posix_acl **i_acl)
-+{
-+	struct posix_acl *acl = EXT3COW_ACL_NOT_CACHED;
-+
-+	spin_lock(&inode->i_lock);
-+	if (*i_acl != EXT3COW_ACL_NOT_CACHED)
-+		acl = posix_acl_dup(*i_acl);
-+	spin_unlock(&inode->i_lock);
-+
-+	return acl;
-+}
-+
-+static inline void
-+ext3cow_iset_acl(struct inode *inode, struct posix_acl **i_acl,
-+                  struct posix_acl *acl)
-+{
-+	spin_lock(&inode->i_lock);
-+	if (*i_acl != EXT3COW_ACL_NOT_CACHED)
-+		posix_acl_release(*i_acl);
-+	*i_acl = posix_acl_dup(acl);
-+	spin_unlock(&inode->i_lock);
-+}
-+
-+/*
-+ * Inode operation get_posix_acl().
-+ *
-+ * inode->i_mutex: don't care
-+ */
-+static struct posix_acl *
-+ext3cow_get_acl(struct inode *inode, int type)
-+{
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	int name_index;
-+	char *value = NULL;
-+	struct posix_acl *acl;
-+	int retval;
-+
-+	if (!test_opt(inode->i_sb, POSIX_ACL))
-+		return NULL;
-+
-+	switch(type) {
-+		case ACL_TYPE_ACCESS:
-+			acl = ext3cow_iget_acl(inode, &ei->i_acl);
-+			if (acl != EXT3COW_ACL_NOT_CACHED)
-+				return acl;
-+			name_index = EXT3COW_XATTR_INDEX_POSIX_ACL_ACCESS;
-+			break;
-+
-+		case ACL_TYPE_DEFAULT:
-+			acl = ext3cow_iget_acl(inode, &ei->i_default_acl);
-+			if (acl != EXT3COW_ACL_NOT_CACHED)
-+				return acl;
-+			name_index = EXT3COW_XATTR_INDEX_POSIX_ACL_DEFAULT;
-+			break;
-+
-+		default:
-+			return ERR_PTR(-EINVAL);
-+	}
-+	retval = ext3cow_xattr_get(inode, name_index, "", NULL, 0);
-+	if (retval > 0) {
-+		value = kmalloc(retval, GFP_KERNEL);
-+		if (!value)
-+			return ERR_PTR(-ENOMEM);
-+		retval = ext3cow_xattr_get(inode, name_index, "", value, retval);
-+	}
-+	if (retval > 0)
-+		acl = ext3cow_acl_from_disk(value, retval);
-+	else if (retval == -ENODATA || retval == -ENOSYS)
-+		acl = NULL;
-+	else
-+		acl = ERR_PTR(retval);
-+	kfree(value);
-+
-+	if (!IS_ERR(acl)) {
-+		switch(type) {
-+			case ACL_TYPE_ACCESS:
-+				ext3cow_iset_acl(inode, &ei->i_acl, acl);
-+				break;
-+
-+			case ACL_TYPE_DEFAULT:
-+				ext3cow_iset_acl(inode, &ei->i_default_acl, acl);
-+				break;
-+		}
-+	}
-+	return acl;
-+}
-+
-+/*
-+ * Set the access or default ACL of an inode.
-+ *
-+ * inode->i_mutex: down unless called from ext3cow_new_inode
-+ */
-+static int
-+ext3cow_set_acl(handle_t *handle, struct inode *inode, int type,
-+	     struct posix_acl *acl)
-+{
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	int name_index;
-+	void *value = NULL;
-+	size_t size = 0;
-+	int error;
-+
-+	if (S_ISLNK(inode->i_mode))
-+		return -EOPNOTSUPP;
-+
-+	switch(type) {
-+		case ACL_TYPE_ACCESS:
-+			name_index = EXT3COW_XATTR_INDEX_POSIX_ACL_ACCESS;
-+			if (acl) {
-+				mode_t mode = inode->i_mode;
-+				error = posix_acl_equiv_mode(acl, &mode);
-+				if (error < 0)
-+					return error;
-+				else {
-+					inode->i_mode = mode;
-+					ext3cow_mark_inode_dirty(handle, inode);
-+					if (error == 0)
-+						acl = NULL;
-+				}
-+			}
-+			break;
-+
-+		case ACL_TYPE_DEFAULT:
-+			name_index = EXT3COW_XATTR_INDEX_POSIX_ACL_DEFAULT;
-+			if (!S_ISDIR(inode->i_mode))
-+				return acl ? -EACCES : 0;
-+			break;
-+
-+		default:
-+			return -EINVAL;
-+	}
-+	if (acl) {
-+		value = ext3cow_acl_to_disk(acl, &size);
-+		if (IS_ERR(value))
-+			return (int)PTR_ERR(value);
-+	}
-+
-+	error = ext3cow_xattr_set_handle(handle, inode, name_index, "",
-+				      value, size, 0);
-+
-+	kfree(value);
-+	if (!error) {
-+		switch(type) {
-+			case ACL_TYPE_ACCESS:
-+				ext3cow_iset_acl(inode, &ei->i_acl, acl);
-+				break;
-+
-+			case ACL_TYPE_DEFAULT:
-+				ext3cow_iset_acl(inode, &ei->i_default_acl, acl);
-+				break;
-+		}
-+	}
-+	return error;
-+}
-+
-+static int
-+ext3cow_check_acl(struct inode *inode, int mask)
-+{
-+	struct posix_acl *acl = ext3cow_get_acl(inode, ACL_TYPE_ACCESS);
-+
-+	if (IS_ERR(acl))
-+		return PTR_ERR(acl);
-+	if (acl) {
-+		int error = posix_acl_permission(inode, acl, mask);
-+		posix_acl_release(acl);
-+		return error;
-+	}
-+
-+	return -EAGAIN;
-+}
-+
-+int
-+ext3cow_permission(struct inode *inode, int mask, struct nameidata *nd)
-+{
-+	return generic_permission(inode, mask, ext3cow_check_acl);
-+}
-+
-+/*
-+ * Initialize the ACLs of a new inode. Called from ext3cow_new_inode.
-+ *
-+ * dir->i_mutex: down
-+ * inode->i_mutex: up (access to inode is still exclusive)
-+ */
-+int
-+ext3cow_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
-+{
-+	struct posix_acl *acl = NULL;
-+	int error = 0;
-+
-+	if (!S_ISLNK(inode->i_mode)) {
-+		if (test_opt(dir->i_sb, POSIX_ACL)) {
-+			acl = ext3cow_get_acl(dir, ACL_TYPE_DEFAULT);
-+			if (IS_ERR(acl))
-+				return PTR_ERR(acl);
-+		}
-+		if (!acl)
-+			inode->i_mode &= ~current->fs->umask;
-+	}
-+	if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
-+		struct posix_acl *clone;
-+		mode_t mode;
-+
-+		if (S_ISDIR(inode->i_mode)) {
-+			error = ext3cow_set_acl(handle, inode,
-+					     ACL_TYPE_DEFAULT, acl);
-+			if (error)
-+				goto cleanup;
-+		}
-+		clone = posix_acl_clone(acl, GFP_KERNEL);
-+		error = -ENOMEM;
-+		if (!clone)
-+			goto cleanup;
-+
-+		mode = inode->i_mode;
-+		error = posix_acl_create_masq(clone, &mode);
-+		if (error >= 0) {
-+			inode->i_mode = mode;
-+			if (error > 0) {
-+				/* This is an extended ACL */
-+				error = ext3cow_set_acl(handle, inode,
-+						     ACL_TYPE_ACCESS, clone);
-+			}
-+		}
-+		posix_acl_release(clone);
-+	}
-+cleanup:
-+	posix_acl_release(acl);
-+	return error;
-+}
-+
-+/*
-+ * Does chmod for an inode that may have an Access Control List. The
-+ * inode->i_mode field must be updated to the desired value by the caller
-+ * before calling this function.
-+ * Returns 0 on success, or a negative error number.
-+ *
-+ * We change the ACL rather than storing some ACL entries in the file
-+ * mode permission bits (which would be more efficient), because that
-+ * would break once additional permissions (like  ACL_APPEND, ACL_DELETE
-+ * for directories) are added. There are no more bits available in the
-+ * file mode.
-+ *
-+ * inode->i_mutex: down
-+ */
-+int
-+ext3cow_acl_chmod(struct inode *inode)
-+{
-+	struct posix_acl *acl, *clone;
-+        int error;
-+
-+	if (S_ISLNK(inode->i_mode))
-+		return -EOPNOTSUPP;
-+	if (!test_opt(inode->i_sb, POSIX_ACL))
-+		return 0;
-+	acl = ext3cow_get_acl(inode, ACL_TYPE_ACCESS);
-+	if (IS_ERR(acl) || !acl)
-+		return PTR_ERR(acl);
-+	clone = posix_acl_clone(acl, GFP_KERNEL);
-+	posix_acl_release(acl);
-+	if (!clone)
-+		return -ENOMEM;
-+	error = posix_acl_chmod_masq(clone, inode->i_mode);
-+	if (!error) {
-+		handle_t *handle;
-+		int retries = 0;
-+
-+	retry:
-+		handle = ext3cow_journal_start(inode,
-+				EXT3COW_DATA_TRANS_BLOCKS(inode->i_sb));
-+		if (IS_ERR(handle)) {
-+			error = PTR_ERR(handle);
-+			ext3cow_std_error(inode->i_sb, error);
-+			goto out;
-+		}
-+		error = ext3cow_set_acl(handle, inode, ACL_TYPE_ACCESS, clone);
-+		ext3cow_journal_stop(handle);
-+		if (error == -ENOSPC &&
-+		    ext3cow_should_retry_alloc(inode->i_sb, &retries))
-+			goto retry;
-+	}
-+out:
-+	posix_acl_release(clone);
-+	return error;
-+}
-+
-+/*
-+ * Extended attribute handlers
-+ */
-+static size_t
-+ext3cow_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
-+			   const char *name, size_t name_len)
-+{
-+	const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
-+
-+	if (!test_opt(inode->i_sb, POSIX_ACL))
-+		return 0;
-+	if (list && size <= list_len)
-+		memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
-+	return size;
-+}
-+
-+static size_t
-+ext3cow_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
-+			    const char *name, size_t name_len)
-+{
-+	const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
-+
-+	if (!test_opt(inode->i_sb, POSIX_ACL))
-+		return 0;
-+	if (list && size <= list_len)
-+		memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
-+	return size;
-+}
-+
-+static int
-+ext3cow_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
-+{
-+	struct posix_acl *acl;
-+	int error;
-+
-+	if (!test_opt(inode->i_sb, POSIX_ACL))
-+		return -EOPNOTSUPP;
-+
-+	acl = ext3cow_get_acl(inode, type);
-+	if (IS_ERR(acl))
-+		return PTR_ERR(acl);
-+	if (acl == NULL)
-+		return -ENODATA;
-+	error = posix_acl_to_xattr(acl, buffer, size);
-+	posix_acl_release(acl);
-+
-+	return error;
-+}
-+
-+static int
-+ext3cow_xattr_get_acl_access(struct inode *inode, const char *name,
-+			  void *buffer, size_t size)
-+{
-+	if (strcmp(name, "") != 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
-+}
-+
-+static int
-+ext3cow_xattr_get_acl_default(struct inode *inode, const char *name,
-+			   void *buffer, size_t size)
-+{
-+	if (strcmp(name, "") != 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
-+}
-+
-+static int
-+ext3cow_xattr_set_acl(struct inode *inode, int type, const void *value,
-+		   size_t size)
-+{
-+	handle_t *handle;
-+	struct posix_acl *acl;
-+	int error, retries = 0;
-+
-+	if (!test_opt(inode->i_sb, POSIX_ACL))
-+		return -EOPNOTSUPP;
-+	if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-+		return -EPERM;
-+
-+	if (value) {
-+		acl = posix_acl_from_xattr(value, size);
-+		if (IS_ERR(acl))
-+			return PTR_ERR(acl);
-+		else if (acl) {
-+			error = posix_acl_valid(acl);
-+			if (error)
-+				goto release_and_out;
-+		}
-+	} else
-+		acl = NULL;
-+
-+retry:
-+	handle = ext3cow_journal_start(inode, EXT3COW_DATA_TRANS_BLOCKS(inode->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+	error = ext3cow_set_acl(handle, inode, type, acl);
-+	ext3cow_journal_stop(handle);
-+	if (error == -ENOSPC && ext3cow_should_retry_alloc(inode->i_sb, &retries))
-+		goto retry;
-+
-+release_and_out:
-+	posix_acl_release(acl);
-+	return error;
-+}
-+
-+static int
-+ext3cow_xattr_set_acl_access(struct inode *inode, const char *name,
-+			  const void *value, size_t size, int flags)
-+{
-+	if (strcmp(name, "") != 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
-+}
-+
-+static int
-+ext3cow_xattr_set_acl_default(struct inode *inode, const char *name,
-+			   const void *value, size_t size, int flags)
-+{
-+	if (strcmp(name, "") != 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
-+}
-+
-+struct xattr_handler ext3cow_xattr_acl_access_handler = {
-+	.prefix	= POSIX_ACL_XATTR_ACCESS,
-+	.list	= ext3cow_xattr_list_acl_access,
-+	.get	= ext3cow_xattr_get_acl_access,
-+	.set	= ext3cow_xattr_set_acl_access,
-+};
-+
-+struct xattr_handler ext3cow_xattr_acl_default_handler = {
-+	.prefix	= POSIX_ACL_XATTR_DEFAULT,
-+	.list	= ext3cow_xattr_list_acl_default,
-+	.get	= ext3cow_xattr_get_acl_default,
-+	.set	= ext3cow_xattr_set_acl_default,
-+};
-diff -Naur linux-2.6.21.7/fs/ext3cow/acl.h linux-2.6.21.7_ext3cowPatched/fs/ext3cow/acl.h
---- linux-2.6.21.7/fs/ext3cow/acl.h	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/acl.h	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,81 @@
-+/*
-+  File: fs/ext3cow/acl.h
-+
-+  (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
-+*/
-+
-+#include <linux/posix_acl_xattr.h>
-+
-+#define EXT3COW_ACL_VERSION	0x0001
-+
-+typedef struct {
-+	__le16		e_tag;
-+	__le16		e_perm;
-+	__le32		e_id;
-+} ext3cow_acl_entry;
-+
-+typedef struct {
-+	__le16		e_tag;
-+	__le16		e_perm;
-+} ext3cow_acl_entry_short;
-+
-+typedef struct {
-+	__le32		a_version;
-+} ext3cow_acl_header;
-+
-+static inline size_t ext3cow_acl_size(int count)
-+{
-+	if (count <= 4) {
-+		return sizeof(ext3cow_acl_header) +
-+		       count * sizeof(ext3cow_acl_entry_short);
-+	} else {
-+		return sizeof(ext3cow_acl_header) +
-+		       4 * sizeof(ext3cow_acl_entry_short) +
-+		       (count - 4) * sizeof(ext3cow_acl_entry);
-+	}
-+}
-+
-+static inline int ext3cow_acl_count(size_t size)
-+{
-+	ssize_t s;
-+	size -= sizeof(ext3cow_acl_header);
-+	s = size - 4 * sizeof(ext3cow_acl_entry_short);
-+	if (s < 0) {
-+		if (size % sizeof(ext3cow_acl_entry_short))
-+			return -1;
-+		return size / sizeof(ext3cow_acl_entry_short);
-+	} else {
-+		if (s % sizeof(ext3cow_acl_entry))
-+			return -1;
-+		return s / sizeof(ext3cow_acl_entry) + 4;
-+	}
-+}
-+
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+
-+/* Value for inode->u.ext3cow_i.i_acl and inode->u.ext3cow_i.i_default_acl
-+   if the ACL has not been cached */
-+#define EXT3COW_ACL_NOT_CACHED ((void *)-1)
-+
-+/* acl.c */
-+extern int ext3cow_permission (struct inode *, int, struct nameidata *);
-+extern int ext3cow_acl_chmod (struct inode *);
-+extern int ext3cow_init_acl (handle_t *, struct inode *, struct inode *);
-+
-+#else  /* CONFIG_EXT3COW_FS_POSIX_ACL */
-+#include <linux/sched.h>
-+#define ext3cow_permission NULL
-+
-+static inline int
-+ext3cow_acl_chmod(struct inode *inode)
-+{
-+	return 0;
-+}
-+
-+static inline int
-+ext3cow_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
-+{
-+	return 0;
-+}
-+#endif  /* CONFIG_EXT3COW_FS_POSIX_ACL */
-+
-diff -Naur linux-2.6.21.7/fs/ext3cow/balloc.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/balloc.c
---- linux-2.6.21.7/fs/ext3cow/balloc.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/balloc.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,1823 @@
-+/*
-+ *  linux/fs/ext3cow/balloc.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  Enhanced block allocation by Stephen Tweedie (sct@redhat.com), 1993
-+ *  Big-endian to little-endian byte-swapping/bitmaps by
-+ *        David S. Miller (davem@caip.rutgers.edu), 1995
-+ */
-+
-+#include <linux/time.h>
-+#include <linux/capability.h>
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/quotaops.h>
-+#include <linux/buffer_head.h>
-+
-+/*
-+ * balloc.c contains the blocks allocation and deallocation routines
-+ */
-+
-+/*
-+ * The free blocks are managed by bitmaps.  A file system contains several
-+ * blocks groups.  Each group contains 1 bitmap block for blocks, 1 bitmap
-+ * block for inodes, N blocks for the inode table and data blocks.
-+ *
-+ * The file system contains group descriptors which are located after the
-+ * super block.  Each descriptor contains the number of the bitmap block and
-+ * the free blocks count in the block.  The descriptors are loaded in memory
-+ * when a file system is mounted (see ext3cow_read_super).
-+ */
-+
-+
-+#define in_range(b, first, len)	((b) >= (first) && (b) <= (first) + (len) - 1)
-+
-+/**
-+ * ext3cow_get_group_desc() -- load group descriptor from disk
-+ * @sb:			super block
-+ * @block_group:	given block group
-+ * @bh:			pointer to the buffer head to store the block
-+ *			group descriptor
-+ */
-+struct ext3cow_group_desc * ext3cow_get_group_desc(struct super_block * sb,
-+					     unsigned int block_group,
-+					     struct buffer_head ** bh)
-+{
-+	unsigned long group_desc;
-+	unsigned long offset;
-+	struct ext3cow_group_desc * desc;
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+
-+	if (block_group >= sbi->s_groups_count) {
-+		ext3cow_error (sb, "ext3cow_get_group_desc",
-+			    "block_group >= groups_count - "
-+			    "block_group = %d, groups_count = %lu",
-+			    block_group, sbi->s_groups_count);
-+
-+		return NULL;
-+	}
-+	smp_rmb();
-+
-+	group_desc = block_group >> EXT3COW_DESC_PER_BLOCK_BITS(sb);
-+	offset = block_group & (EXT3COW_DESC_PER_BLOCK(sb) - 1);
-+	if (!sbi->s_group_desc[group_desc]) {
-+		ext3cow_error (sb, "ext3cow_get_group_desc",
-+			    "Group descriptor not loaded - "
-+			    "block_group = %d, group_desc = %lu, desc = %lu",
-+			     block_group, group_desc, offset);
-+		return NULL;
-+	}
-+
-+	desc = (struct ext3cow_group_desc *) sbi->s_group_desc[group_desc]->b_data;
-+	if (bh)
-+		*bh = sbi->s_group_desc[group_desc];
-+	return desc + offset;
-+}
-+
-+/**
-+ * read_block_bitmap()
-+ * @sb:			super block
-+ * @block_group:	given block group
-+ *
-+ * Read the bitmap for a given block_group, reading into the specified
-+ * slot in the superblock's bitmap cache.
-+ *
-+ * Return buffer_head on success or NULL in case of failure.
-+ */
-+static struct buffer_head *
-+read_block_bitmap(struct super_block *sb, unsigned int block_group)
-+{
-+	struct ext3cow_group_desc * desc;
-+	struct buffer_head * bh = NULL;
-+
-+	desc = ext3cow_get_group_desc (sb, block_group, NULL);
-+	if (!desc)
-+		goto error_out;
-+	bh = sb_bread(sb, le32_to_cpu(desc->bg_block_bitmap));
-+	if (!bh)
-+		ext3cow_error (sb, "read_block_bitmap",
-+			    "Cannot read block bitmap - "
-+			    "block_group = %d, block_bitmap = %u",
-+			    block_group, le32_to_cpu(desc->bg_block_bitmap));
-+error_out:
-+	return bh;
-+}
-+/*
-+ * The reservation window structure operations
-+ * --------------------------------------------
-+ * Operations include:
-+ * dump, find, add, remove, is_empty, find_next_reservable_window, etc.
-+ *
-+ * We use a red-black tree to represent per-filesystem reservation
-+ * windows.
-+ *
-+ */
-+
-+/**
-+ * __rsv_window_dump() -- Dump the filesystem block allocation reservation map
-+ * @rb_root:		root of per-filesystem reservation rb tree
-+ * @verbose:		verbose mode
-+ * @fn:			function which wishes to dump the reservation map
-+ *
-+ * If verbose is turned on, it will print the whole block reservation
-+ * windows(start, end).	Otherwise, it will only print out the "bad" windows,
-+ * those windows that overlap with their immediate neighbors.
-+ */
-+#if 1
-+static void __rsv_window_dump(struct rb_root *root, int verbose,
-+			      const char *fn)
-+{
-+	struct rb_node *n;
-+	struct ext3cow_reserve_window_node *rsv, *prev;
-+	int bad;
-+
-+restart:
-+	n = rb_first(root);
-+	bad = 0;
-+	prev = NULL;
-+
-+	printk("Block Allocation Reservation Windows Map (%s):\n", fn);
-+	while (n) {
-+		rsv = rb_entry(n, struct ext3cow_reserve_window_node, rsv_node);
-+		if (verbose)
-+			printk("reservation window 0x%p "
-+			       "start:  %lu, end:  %lu\n",
-+			       rsv, rsv->rsv_start, rsv->rsv_end);
-+		if (rsv->rsv_start && rsv->rsv_start >= rsv->rsv_end) {
-+			printk("Bad reservation %p (start >= end)\n",
-+			       rsv);
-+			bad = 1;
-+		}
-+		if (prev && prev->rsv_end >= rsv->rsv_start) {
-+			printk("Bad reservation %p (prev->end >= start)\n",
-+			       rsv);
-+			bad = 1;
-+		}
-+		if (bad) {
-+			if (!verbose) {
-+				printk("Restarting reservation walk in verbose mode\n");
-+				verbose = 1;
-+				goto restart;
-+			}
-+		}
-+		n = rb_next(n);
-+		prev = rsv;
-+	}
-+	printk("Window map complete.\n");
-+	if (bad)
-+		BUG();
-+}
-+#define rsv_window_dump(root, verbose) \
-+	__rsv_window_dump((root), (verbose), __FUNCTION__)
-+#else
-+#define rsv_window_dump(root, verbose) do {} while (0)
-+#endif
-+
-+/**
-+ * goal_in_my_reservation()
-+ * @rsv:		inode's reservation window
-+ * @grp_goal:		given goal block relative to the allocation block group
-+ * @group:		the current allocation block group
-+ * @sb:			filesystem super block
-+ *
-+ * Test if the given goal block (group relative) is within the file's
-+ * own block reservation window range.
-+ *
-+ * If the reservation window is outside the goal allocation group, return 0;
-+ * grp_goal (given goal block) could be -1, which means no specific
-+ * goal block. In this case, always return 1.
-+ * If the goal block is within the reservation window, return 1;
-+ * otherwise, return 0;
-+ */
-+static int
-+goal_in_my_reservation(struct ext3cow_reserve_window *rsv, ext3cow_grpblk_t grp_goal,
-+			unsigned int group, struct super_block * sb)
-+{
-+	ext3cow_fsblk_t group_first_block, group_last_block;
-+
-+	group_first_block = ext3cow_group_first_block_no(sb, group);
-+	group_last_block = group_first_block + (EXT3COW_BLOCKS_PER_GROUP(sb) - 1);
-+
-+	if ((rsv->_rsv_start > group_last_block) ||
-+	    (rsv->_rsv_end < group_first_block))
-+		return 0;
-+	if ((grp_goal >= 0) && ((grp_goal + group_first_block < rsv->_rsv_start)
-+		|| (grp_goal + group_first_block > rsv->_rsv_end)))
-+		return 0;
-+	return 1;
-+}
-+
-+/**
-+ * search_reserve_window()
-+ * @rb_root:		root of reservation tree
-+ * @goal:		target allocation block
-+ *
-+ * Find the reserved window which includes the goal, or the previous one
-+ * if the goal is not in any window.
-+ * Returns NULL if there are no windows or if all windows start after the goal.
-+ */
-+static struct ext3cow_reserve_window_node *
-+search_reserve_window(struct rb_root *root, ext3cow_fsblk_t goal)
-+{
-+	struct rb_node *n = root->rb_node;
-+	struct ext3cow_reserve_window_node *rsv;
-+
-+	if (!n)
-+		return NULL;
-+
-+	do {
-+		rsv = rb_entry(n, struct ext3cow_reserve_window_node, rsv_node);
-+
-+		if (goal < rsv->rsv_start)
-+			n = n->rb_left;
-+		else if (goal > rsv->rsv_end)
-+			n = n->rb_right;
-+		else
-+			return rsv;
-+	} while (n);
-+	/*
-+	 * We've fallen off the end of the tree: the goal wasn't inside
-+	 * any particular node.  OK, the previous node must be to one
-+	 * side of the interval containing the goal.  If it's the RHS,
-+	 * we need to back up one.
-+	 */
-+	if (rsv->rsv_start > goal) {
-+		n = rb_prev(&rsv->rsv_node);
-+		rsv = rb_entry(n, struct ext3cow_reserve_window_node, rsv_node);
-+	}
-+	return rsv;
-+}
-+
-+/**
-+ * ext3cow_rsv_window_add() -- Insert a window to the block reservation rb tree.
-+ * @sb:			super block
-+ * @rsv:		reservation window to add
-+ *
-+ * Must be called with rsv_lock hold.
-+ */
-+void ext3cow_rsv_window_add(struct super_block *sb,
-+		    struct ext3cow_reserve_window_node *rsv)
-+{
-+	struct rb_root *root = &EXT3COW_SB(sb)->s_rsv_window_root;
-+	struct rb_node *node = &rsv->rsv_node;
-+	ext3cow_fsblk_t start = rsv->rsv_start;
-+
-+	struct rb_node ** p = &root->rb_node;
-+	struct rb_node * parent = NULL;
-+	struct ext3cow_reserve_window_node *this;
-+
-+	while (*p)
-+	{
-+		parent = *p;
-+		this = rb_entry(parent, struct ext3cow_reserve_window_node, rsv_node);
-+
-+		if (start < this->rsv_start)
-+			p = &(*p)->rb_left;
-+		else if (start > this->rsv_end)
-+			p = &(*p)->rb_right;
-+		else {
-+			rsv_window_dump(root, 1);
-+			BUG();
-+		}
-+	}
-+
-+	rb_link_node(node, parent, p);
-+	rb_insert_color(node, root);
-+}
-+
-+/**
-+ * ext3cow_rsv_window_remove() -- unlink a window from the reservation rb tree
-+ * @sb:			super block
-+ * @rsv:		reservation window to remove
-+ *
-+ * Mark the block reservation window as not allocated, and unlink it
-+ * from the filesystem reservation window rb tree. Must be called with
-+ * rsv_lock hold.
-+ */
-+static void rsv_window_remove(struct super_block *sb,
-+			      struct ext3cow_reserve_window_node *rsv)
-+{
-+	rsv->rsv_start = EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED;
-+	rsv->rsv_end = EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED;
-+	rsv->rsv_alloc_hit = 0;
-+	rb_erase(&rsv->rsv_node, &EXT3COW_SB(sb)->s_rsv_window_root);
-+}
-+
-+/*
-+ * rsv_is_empty() -- Check if the reservation window is allocated.
-+ * @rsv:		given reservation window to check
-+ *
-+ * returns 1 if the end block is EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED.
-+ */
-+static inline int rsv_is_empty(struct ext3cow_reserve_window *rsv)
-+{
-+	/* a valid reservation end block could not be 0 */
-+	return rsv->_rsv_end == EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED;
-+}
-+
-+/**
-+ * ext3cow_init_block_alloc_info()
-+ * @inode:		file inode structure
-+ *
-+ * Allocate and initialize the	reservation window structure, and
-+ * link the window to the ext3cow inode structure at last
-+ *
-+ * The reservation window structure is only dynamically allocated
-+ * and linked to ext3cow inode the first time the open file
-+ * needs a new block. So, before every ext3cow_new_block(s) call, for
-+ * regular files, we should check whether the reservation window
-+ * structure exists or not. In the latter case, this function is called.
-+ * Fail to do so will result in block reservation being turned off for that
-+ * open file.
-+ *
-+ * This function is called from ext3cow_get_blocks_handle(), also called
-+ * when setting the reservation window size through ioctl before the file
-+ * is open for write (needs block allocation).
-+ *
-+ * Needs truncate_mutex protection prior to call this function.
-+ */
-+void ext3cow_init_block_alloc_info(struct inode *inode)
-+{
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	struct ext3cow_block_alloc_info *block_i = ei->i_block_alloc_info;
-+	struct super_block *sb = inode->i_sb;
-+
-+	block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
-+	if (block_i) {
-+		struct ext3cow_reserve_window_node *rsv = &block_i->rsv_window_node;
-+
-+		rsv->rsv_start = EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED;
-+		rsv->rsv_end = EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED;
-+
-+		/*
-+		 * if filesystem is mounted with NORESERVATION, the goal
-+		 * reservation window size is set to zero to indicate
-+		 * block reservation is off
-+		 */
-+		if (!test_opt(sb, RESERVATION))
-+			rsv->rsv_goal_size = 0;
-+		else
-+			rsv->rsv_goal_size = EXT3COW_DEFAULT_RESERVE_BLOCKS;
-+		rsv->rsv_alloc_hit = 0;
-+		block_i->last_alloc_logical_block = 0;
-+		block_i->last_alloc_physical_block = 0;
-+	}
-+	ei->i_block_alloc_info = block_i;
-+}
-+
-+/**
-+ * ext3cow_discard_reservation()
-+ * @inode:		inode
-+ *
-+ * Discard(free) block reservation window on last file close, or truncate
-+ * or at last iput().
-+ *
-+ * It is being called in three cases:
-+ *	ext3cow_release_file(): last writer close the file
-+ *	ext3cow_clear_inode(): last iput(), when nobody link to this file.
-+ *	ext3cow_truncate(): when the block indirect map is about to change.
-+ *
-+ */
-+void ext3cow_discard_reservation(struct inode *inode)
-+{
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	struct ext3cow_block_alloc_info *block_i = ei->i_block_alloc_info;
-+	struct ext3cow_reserve_window_node *rsv;
-+	spinlock_t *rsv_lock = &EXT3COW_SB(inode->i_sb)->s_rsv_window_lock;
-+
-+	if (!block_i)
-+		return;
-+
-+	rsv = &block_i->rsv_window_node;
-+	if (!rsv_is_empty(&rsv->rsv_window)) {
-+		spin_lock(rsv_lock);
-+		if (!rsv_is_empty(&rsv->rsv_window))
-+			rsv_window_remove(inode->i_sb, rsv);
-+		spin_unlock(rsv_lock);
-+	}
-+}
-+
-+/**
-+ * ext3cow_free_blocks_sb() -- Free given blocks and update quota
-+ * @handle:			handle to this transaction
-+ * @sb:				super block
-+ * @block:			start physcial block to free
-+ * @count:			number of blocks to free
-+ * @pdquot_freed_blocks:	pointer to quota
-+ */
-+void ext3cow_free_blocks_sb(handle_t *handle, struct super_block *sb,
-+			 ext3cow_fsblk_t block, unsigned long count,
-+			 unsigned long *pdquot_freed_blocks)
-+{
-+	struct buffer_head *bitmap_bh = NULL;
-+	struct buffer_head *gd_bh;
-+	unsigned long block_group;
-+	ext3cow_grpblk_t bit;
-+	unsigned long i;
-+	unsigned long overflow;
-+	struct ext3cow_group_desc * desc;
-+	struct ext3cow_super_block * es;
-+	struct ext3cow_sb_info *sbi;
-+	int err = 0, ret;
-+	ext3cow_grpblk_t group_freed;
-+
-+	*pdquot_freed_blocks = 0;
-+	sbi = EXT3COW_SB(sb);
-+	es = sbi->s_es;
-+	if (block < le32_to_cpu(es->s_first_data_block) ||
-+	    block + count < block ||
-+	    block + count > le32_to_cpu(es->s_blocks_count)) {
-+		ext3cow_error (sb, "ext3cow_free_blocks",
-+			    "Freeing blocks not in datazone - "
-+			    "block = "E3FSBLK", count = %lu", block, count);
-+		goto error_return;
-+	}
-+
-+  //TODO: Remove:
-+  printk(KERN_INFO "freeing block(s) %lu-%lu\n", block, block + count - 1);
-+	ext3cow_debug ("freeing block(s) %lu-%lu\n", block, block + count - 1);
-+
-+do_more:
-+	overflow = 0;
-+	block_group = (block - le32_to_cpu(es->s_first_data_block)) /
-+		      EXT3COW_BLOCKS_PER_GROUP(sb);
-+	bit = (block - le32_to_cpu(es->s_first_data_block)) %
-+		      EXT3COW_BLOCKS_PER_GROUP(sb);
-+	/*
-+	 * Check to see if we are freeing blocks across a group
-+	 * boundary.
-+	 */
-+	if (bit + count > EXT3COW_BLOCKS_PER_GROUP(sb)) {
-+		overflow = bit + count - EXT3COW_BLOCKS_PER_GROUP(sb);
-+		count -= overflow;
-+	}
-+	brelse(bitmap_bh);
-+	bitmap_bh = read_block_bitmap(sb, block_group);
-+	if (!bitmap_bh)
-+		goto error_return;
-+	desc = ext3cow_get_group_desc (sb, block_group, &gd_bh);
-+	if (!desc)
-+		goto error_return;
-+
-+	if (in_range (le32_to_cpu(desc->bg_block_bitmap), block, count) ||
-+	    in_range (le32_to_cpu(desc->bg_inode_bitmap), block, count) ||
-+	    in_range (block, le32_to_cpu(desc->bg_inode_table),
-+		      sbi->s_itb_per_group) ||
-+	    in_range (block + count - 1, le32_to_cpu(desc->bg_inode_table),
-+		      sbi->s_itb_per_group))
-+		ext3cow_error (sb, "ext3cow_free_blocks",
-+			    "Freeing blocks in system zones - "
-+			    "Block = "E3FSBLK", count = %lu",
-+			    block, count);
-+
-+	/*
-+	 * We are about to start releasing blocks in the bitmap,
-+	 * so we need undo access.
-+	 */
-+	/* @@@ check errors */
-+	BUFFER_TRACE(bitmap_bh, "getting undo access");
-+	err = ext3cow_journal_get_undo_access(handle, bitmap_bh);
-+	if (err)
-+		goto error_return;
-+
-+	/*
-+	 * We are about to modify some metadata.  Call the journal APIs
-+	 * to unshare ->b_data if a currently-committing transaction is
-+	 * using it
-+	 */
-+	BUFFER_TRACE(gd_bh, "get_write_access");
-+	err = ext3cow_journal_get_write_access(handle, gd_bh);
-+	if (err)
-+		goto error_return;
-+
-+	jbd_lock_bh_state(bitmap_bh);
-+
-+	for (i = 0, group_freed = 0; i < count; i++) {
-+		/*
-+		 * An HJ special.  This is expensive...
-+		 */
-+#ifdef CONFIG_JBD_DEBUG
-+		jbd_unlock_bh_state(bitmap_bh);
-+		{
-+			struct buffer_head *debug_bh;
-+			debug_bh = sb_find_get_block(sb, block + i);
-+			if (debug_bh) {
-+				BUFFER_TRACE(debug_bh, "Deleted!");
-+				if (!bh2jh(bitmap_bh)->b_committed_data)
-+					BUFFER_TRACE(debug_bh,
-+						"No commited data in bitmap");
-+				BUFFER_TRACE2(debug_bh, bitmap_bh, "bitmap");
-+				__brelse(debug_bh);
-+			}
-+		}
-+		jbd_lock_bh_state(bitmap_bh);
-+#endif
-+		if (need_resched()) {
-+			jbd_unlock_bh_state(bitmap_bh);
-+			cond_resched();
-+			jbd_lock_bh_state(bitmap_bh);
-+		}
-+		/* @@@ This prevents newly-allocated data from being
-+		 * freed and then reallocated within the same
-+		 * transaction.
-+		 *
-+		 * Ideally we would want to allow that to happen, but to
-+		 * do so requires making journal_forget() capable of
-+		 * revoking the queued write of a data block, which
-+		 * implies blocking on the journal lock.  *forget()
-+		 * cannot block due to truncate races.
-+		 *
-+		 * Eventually we can fix this by making journal_forget()
-+		 * return a status indicating whether or not it was able
-+		 * to revoke the buffer.  On successful revoke, it is
-+		 * safe not to set the allocation bit in the committed
-+		 * bitmap, because we know that there is no outstanding
-+		 * activity on the buffer any more and so it is safe to
-+		 * reallocate it.
-+		 */
-+		BUFFER_TRACE(bitmap_bh, "set in b_committed_data");
-+		J_ASSERT_BH(bitmap_bh,
-+				bh2jh(bitmap_bh)->b_committed_data != NULL);
-+		ext3cow_set_bit_atomic(sb_bgl_lock(sbi, block_group), bit + i,
-+				bh2jh(bitmap_bh)->b_committed_data);
-+
-+		/*
-+		 * We clear the bit in the bitmap after setting the committed
-+		 * data bit, because this is the reverse order to that which
-+		 * the allocator uses.
-+		 */
-+		BUFFER_TRACE(bitmap_bh, "clear bit");
-+		if (!ext3cow_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
-+						bit + i, bitmap_bh->b_data)) {
-+			jbd_unlock_bh_state(bitmap_bh);
-+			ext3cow_error(sb, __FUNCTION__,
-+				"bit already cleared for block "E3FSBLK,
-+				 block + i);
-+			jbd_lock_bh_state(bitmap_bh);
-+			BUFFER_TRACE(bitmap_bh, "bit already cleared");
-+		} else {
-+			group_freed++;
-+		}
-+	}
-+	jbd_unlock_bh_state(bitmap_bh);
-+
-+	spin_lock(sb_bgl_lock(sbi, block_group));
-+	desc->bg_free_blocks_count =
-+		cpu_to_le16(le16_to_cpu(desc->bg_free_blocks_count) +
-+			group_freed);
-+	spin_unlock(sb_bgl_lock(sbi, block_group));
-+	percpu_counter_mod(&sbi->s_freeblocks_counter, count);
-+
-+	/* We dirtied the bitmap block */
-+	BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
-+	err = ext3cow_journal_dirty_metadata(handle, bitmap_bh);
-+
-+	/* And the group descriptor block */
-+	BUFFER_TRACE(gd_bh, "dirtied group descriptor block");
-+	ret = ext3cow_journal_dirty_metadata(handle, gd_bh);
-+	if (!err) err = ret;
-+	*pdquot_freed_blocks += group_freed;
-+
-+	if (overflow && !err) {
-+		block += count;
-+		count = overflow;
-+		goto do_more;
-+	}
-+	sb->s_dirt = 1;
-+error_return:
-+	brelse(bitmap_bh);
-+	ext3cow_std_error(sb, err);
-+	return;
-+}
-+
-+/**
-+ * ext3cow_free_blocks() -- Free given blocks and update quota
-+ * @handle:		handle for this transaction
-+ * @inode:		inode
-+ * @block:		start physical block to free
-+ * @count:		number of blocks to count
-+ */
-+void ext3cow_free_blocks(handle_t *handle, struct inode *inode,
-+			ext3cow_fsblk_t block, unsigned long count)
-+{
-+	struct super_block * sb;
-+	unsigned long dquot_freed_blocks;
-+
-+	sb = inode->i_sb;
-+	if (!sb) {
-+		printk ("ext3cow_free_blocks: nonexistent device");
-+		return;
-+	}
-+	ext3cow_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
-+	if (dquot_freed_blocks)
-+		DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
-+	return;
-+}
-+
-+/**
-+ * ext3cow_test_allocatable()
-+ * @nr:			given allocation block group
-+ * @bh:			bufferhead contains the bitmap of the given block group
-+ *
-+ * For ext3cow allocations, we must not reuse any blocks which are
-+ * allocated in the bitmap buffer's "last committed data" copy.  This
-+ * prevents deletes from freeing up the page for reuse until we have
-+ * committed the delete transaction.
-+ *
-+ * If we didn't do this, then deleting something and reallocating it as
-+ * data would allow the old block to be overwritten before the
-+ * transaction committed (because we force data to disk before commit).
-+ * This would lead to corruption if we crashed between overwriting the
-+ * data and committing the delete.
-+ *
-+ * @@@ We may want to make this allocation behaviour conditional on
-+ * data-writes at some point, and disable it for metadata allocations or
-+ * sync-data inodes.
-+ */
-+static int ext3cow_test_allocatable(ext3cow_grpblk_t nr, struct buffer_head *bh)
-+{
-+	int ret;
-+	struct journal_head *jh = bh2jh(bh);
-+
-+	if (ext3cow_test_bit(nr, bh->b_data))
-+		return 0;
-+
-+	jbd_lock_bh_state(bh);
-+	if (!jh->b_committed_data)
-+		ret = 1;
-+	else
-+		ret = !ext3cow_test_bit(nr, jh->b_committed_data);
-+	jbd_unlock_bh_state(bh);
-+	return ret;
-+}
-+
-+/**
-+ * bitmap_search_next_usable_block()
-+ * @start:		the starting block (group relative) of the search
-+ * @bh:			bufferhead contains the block group bitmap
-+ * @maxblocks:		the ending block (group relative) of the reservation
-+ *
-+ * The bitmap search --- search forward alternately through the actual
-+ * bitmap on disk and the last-committed copy in journal, until we find a
-+ * bit free in both bitmaps.
-+ */
-+static ext3cow_grpblk_t
-+bitmap_search_next_usable_block(ext3cow_grpblk_t start, struct buffer_head *bh,
-+					ext3cow_grpblk_t maxblocks)
-+{
-+	ext3cow_grpblk_t next;
-+	struct journal_head *jh = bh2jh(bh);
-+
-+	while (start < maxblocks) {
-+		next = ext3cow_find_next_zero_bit(bh->b_data, maxblocks, start);
-+		if (next >= maxblocks)
-+			return -1;
-+		if (ext3cow_test_allocatable(next, bh))
-+			return next;
-+		jbd_lock_bh_state(bh);
-+		if (jh->b_committed_data)
-+			start = ext3cow_find_next_zero_bit(jh->b_committed_data,
-+							maxblocks, next);
-+		jbd_unlock_bh_state(bh);
-+	}
-+	return -1;
-+}
-+
-+/**
-+ * find_next_usable_block()
-+ * @start:		the starting block (group relative) to find next
-+ *			allocatable block in bitmap.
-+ * @bh:			bufferhead contains the block group bitmap
-+ * @maxblocks:		the ending block (group relative) for the search
-+ *
-+ * Find an allocatable block in a bitmap.  We honor both the bitmap and
-+ * its last-committed copy (if that exists), and perform the "most
-+ * appropriate allocation" algorithm of looking for a free block near
-+ * the initial goal; then for a free byte somewhere in the bitmap; then
-+ * for any free bit in the bitmap.
-+ */
-+static ext3cow_grpblk_t
-+find_next_usable_block(ext3cow_grpblk_t start, struct buffer_head *bh,
-+			ext3cow_grpblk_t maxblocks)
-+{
-+	ext3cow_grpblk_t here, next;
-+	char *p, *r;
-+
-+	if (start > 0) {
-+		/*
-+		 * The goal was occupied; search forward for a free
-+		 * block within the next XX blocks.
-+		 *
-+		 * end_goal is more or less random, but it has to be
-+		 * less than EXT3COW_BLOCKS_PER_GROUP. Aligning up to the
-+		 * next 64-bit boundary is simple..
-+		 */
-+		ext3cow_grpblk_t end_goal = (start + 63) & ~63;
-+		if (end_goal > maxblocks)
-+			end_goal = maxblocks;
-+		here = ext3cow_find_next_zero_bit(bh->b_data, end_goal, start);
-+		if (here < end_goal && ext3cow_test_allocatable(here, bh))
-+			return here;
-+		ext3cow_debug("Bit not found near goal\n");
-+	}
-+
-+	here = start;
-+	if (here < 0)
-+		here = 0;
-+
-+	p = ((char *)bh->b_data) + (here >> 3);
-+	r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
-+	next = (r - ((char *)bh->b_data)) << 3;
-+
-+	if (next < maxblocks && next >= start && ext3cow_test_allocatable(next, bh))
-+		return next;
-+
-+	/*
-+	 * The bitmap search --- search forward alternately through the actual
-+	 * bitmap and the last-committed copy until we find a bit free in
-+	 * both
-+	 */
-+	here = bitmap_search_next_usable_block(here, bh, maxblocks);
-+	return here;
-+}
-+
-+/**
-+ * claim_block()
-+ * @block:		the free block (group relative) to allocate
-+ * @bh:			the bufferhead containts the block group bitmap
-+ *
-+ * We think we can allocate this block in this bitmap.  Try to set the bit.
-+ * If that succeeds then check that nobody has allocated and then freed the
-+ * block since we saw that is was not marked in b_committed_data.  If it _was_
-+ * allocated and freed then clear the bit in the bitmap again and return
-+ * zero (failure).
-+ */
-+static inline int
-+claim_block(spinlock_t *lock, ext3cow_grpblk_t block, struct buffer_head *bh)
-+{
-+	struct journal_head *jh = bh2jh(bh);
-+	int ret;
-+
-+	if (ext3cow_set_bit_atomic(lock, block, bh->b_data))
-+		return 0;
-+	jbd_lock_bh_state(bh);
-+	if (jh->b_committed_data && ext3cow_test_bit(block,jh->b_committed_data)) {
-+		ext3cow_clear_bit_atomic(lock, block, bh->b_data);
-+		ret = 0;
-+	} else {
-+		ret = 1;
-+	}
-+	jbd_unlock_bh_state(bh);
-+	return ret;
-+}
-+
-+/**
-+ * ext3cow_try_to_allocate()
-+ * @sb:			superblock
-+ * @handle:		handle to this transaction
-+ * @group:		given allocation block group
-+ * @bitmap_bh:		bufferhead holds the block bitmap
-+ * @grp_goal:		given target block within the group
-+ * @count:		target number of blocks to allocate
-+ * @my_rsv:		reservation window
-+ *
-+ * Attempt to allocate blocks within a give range. Set the range of allocation
-+ * first, then find the first free bit(s) from the bitmap (within the range),
-+ * and at last, allocate the blocks by claiming the found free bit as allocated.
-+ *
-+ * To set the range of this allocation:
-+ *	if there is a reservation window, only try to allocate block(s) from the
-+ *	file's own reservation window;
-+ *	Otherwise, the allocation range starts from the give goal block, ends at
-+ *	the block group's last block.
-+ *
-+ * If we failed to allocate the desired block then we may end up crossing to a
-+ * new bitmap.  In that case we must release write access to the old one via
-+ * ext3cow_journal_release_buffer(), else we'll run out of credits.
-+ */
-+static ext3cow_grpblk_t
-+ext3cow_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
-+			struct buffer_head *bitmap_bh, ext3cow_grpblk_t grp_goal,
-+			unsigned long *count, struct ext3cow_reserve_window *my_rsv)
-+{
-+	ext3cow_fsblk_t group_first_block;
-+	ext3cow_grpblk_t start, end;
-+	unsigned long num = 0;
-+
-+	/* we do allocation within the reservation window if we have a window */
-+	if (my_rsv) {
-+		group_first_block = ext3cow_group_first_block_no(sb, group);
-+		if (my_rsv->_rsv_start >= group_first_block)
-+			start = my_rsv->_rsv_start - group_first_block;
-+		else
-+			/* reservation window cross group boundary */
-+			start = 0;
-+		end = my_rsv->_rsv_end - group_first_block + 1;
-+		if (end > EXT3COW_BLOCKS_PER_GROUP(sb))
-+			/* reservation window crosses group boundary */
-+			end = EXT3COW_BLOCKS_PER_GROUP(sb);
-+		if ((start <= grp_goal) && (grp_goal < end))
-+			start = grp_goal;
-+		else
-+			grp_goal = -1;
-+	} else {
-+		if (grp_goal > 0)
-+			start = grp_goal;
-+		else
-+			start = 0;
-+		end = EXT3COW_BLOCKS_PER_GROUP(sb);
-+	}
-+
-+	BUG_ON(start > EXT3COW_BLOCKS_PER_GROUP(sb));
-+
-+repeat:
-+	if (grp_goal < 0 || !ext3cow_test_allocatable(grp_goal, bitmap_bh)) {
-+		grp_goal = find_next_usable_block(start, bitmap_bh, end);
-+		if (grp_goal < 0)
-+			goto fail_access;
-+		if (!my_rsv) {
-+			int i;
-+
-+			for (i = 0; i < 7 && grp_goal > start &&
-+					ext3cow_test_allocatable(grp_goal - 1,
-+								bitmap_bh);
-+					i++, grp_goal--)
-+				;
-+		}
-+	}
-+	start = grp_goal;
-+
-+	if (!claim_block(sb_bgl_lock(EXT3COW_SB(sb), group),
-+		grp_goal, bitmap_bh)) {
-+		/*
-+		 * The block was allocated by another thread, or it was
-+		 * allocated and then freed by another thread
-+		 */
-+		start++;
-+		grp_goal++;
-+		if (start >= end)
-+			goto fail_access;
-+		goto repeat;
-+	}
-+	num++;
-+	grp_goal++;
-+	while (num < *count && grp_goal < end
-+		&& ext3cow_test_allocatable(grp_goal, bitmap_bh)
-+		&& claim_block(sb_bgl_lock(EXT3COW_SB(sb), group),
-+				grp_goal, bitmap_bh)) {
-+		num++;
-+		grp_goal++;
-+	}
-+	*count = num;
-+	return grp_goal - num;
-+fail_access:
-+	*count = num;
-+	return -1;
-+}
-+
-+/**
-+ *	find_next_reservable_window():
-+ *		find a reservable space within the given range.
-+ *		It does not allocate the reservation window for now:
-+ *		alloc_new_reservation() will do the work later.
-+ *
-+ *	@search_head: the head of the searching list;
-+ *		This is not necessarily the list head of the whole filesystem
-+ *
-+ *		We have both head and start_block to assist the search
-+ *		for the reservable space. The list starts from head,
-+ *		but we will shift to the place where start_block is,
-+ *		then start from there, when looking for a reservable space.
-+ *
-+ *	@size: the target new reservation window size
-+ *
-+ *	@group_first_block: the first block we consider to start
-+ *			the real search from
-+ *
-+ *	@last_block:
-+ *		the maximum block number that our goal reservable space
-+ *		could start from. This is normally the last block in this
-+ *		group. The search will end when we found the start of next
-+ *		possible reservable space is out of this boundary.
-+ *		This could handle the cross boundary reservation window
-+ *		request.
-+ *
-+ *	basically we search from the given range, rather than the whole
-+ *	reservation double linked list, (start_block, last_block)
-+ *	to find a free region that is of my size and has not
-+ *	been reserved.
-+ *
-+ */
-+static int find_next_reservable_window(
-+				struct ext3cow_reserve_window_node *search_head,
-+				struct ext3cow_reserve_window_node *my_rsv,
-+				struct super_block * sb,
-+				ext3cow_fsblk_t start_block,
-+				ext3cow_fsblk_t last_block)
-+{
-+	struct rb_node *next;
-+	struct ext3cow_reserve_window_node *rsv, *prev;
-+	ext3cow_fsblk_t cur;
-+	int size = my_rsv->rsv_goal_size;
-+
-+	/* TODO: make the start of the reservation window byte-aligned */
-+	/* cur = *start_block & ~7;*/
-+	cur = start_block;
-+	rsv = search_head;
-+	if (!rsv)
-+		return -1;
-+
-+	while (1) {
-+		if (cur <= rsv->rsv_end)
-+			cur = rsv->rsv_end + 1;
-+
-+		/* TODO?
-+		 * in the case we could not find a reservable space
-+		 * that is what is expected, during the re-search, we could
-+		 * remember what's the largest reservable space we could have
-+		 * and return that one.
-+		 *
-+		 * For now it will fail if we could not find the reservable
-+		 * space with expected-size (or more)...
-+		 */
-+		if (cur > last_block)
-+			return -1;		/* fail */
-+
-+		prev = rsv;
-+		next = rb_next(&rsv->rsv_node);
-+		rsv = rb_entry(next,struct ext3cow_reserve_window_node,rsv_node);
-+
-+		/*
-+		 * Reached the last reservation, we can just append to the
-+		 * previous one.
-+		 */
-+		if (!next)
-+			break;
-+
-+		if (cur + size <= rsv->rsv_start) {
-+			/*
-+			 * Found a reserveable space big enough.  We could
-+			 * have a reservation across the group boundary here
-+			 */
-+			break;
-+		}
-+	}
-+	/*
-+	 * we come here either :
-+	 * when we reach the end of the whole list,
-+	 * and there is empty reservable space after last entry in the list.
-+	 * append it to the end of the list.
-+	 *
-+	 * or we found one reservable space in the middle of the list,
-+	 * return the reservation window that we could append to.
-+	 * succeed.
-+	 */
-+
-+	if ((prev != my_rsv) && (!rsv_is_empty(&my_rsv->rsv_window)))
-+		rsv_window_remove(sb, my_rsv);
-+
-+	/*
-+	 * Let's book the whole avaliable window for now.  We will check the
-+	 * disk bitmap later and then, if there are free blocks then we adjust
-+	 * the window size if it's larger than requested.
-+	 * Otherwise, we will remove this node from the tree next time
-+	 * call find_next_reservable_window.
-+	 */
-+	my_rsv->rsv_start = cur;
-+	my_rsv->rsv_end = cur + size - 1;
-+	my_rsv->rsv_alloc_hit = 0;
-+
-+	if (prev != my_rsv)
-+		ext3cow_rsv_window_add(sb, my_rsv);
-+
-+	return 0;
-+}
-+
-+/**
-+ *	alloc_new_reservation()--allocate a new reservation window
-+ *
-+ *		To make a new reservation, we search part of the filesystem
-+ *		reservation list (the list that inside the group). We try to
-+ *		allocate a new reservation window near the allocation goal,
-+ *		or the beginning of the group, if there is no goal.
-+ *
-+ *		We first find a reservable space after the goal, then from
-+ *		there, we check the bitmap for the first free block after
-+ *		it. If there is no free block until the end of group, then the
-+ *		whole group is full, we failed. Otherwise, check if the free
-+ *		block is inside the expected reservable space, if so, we
-+ *		succeed.
-+ *		If the first free block is outside the reservable space, then
-+ *		start from the first free block, we search for next available
-+ *		space, and go on.
-+ *
-+ *	on succeed, a new reservation will be found and inserted into the list
-+ *	It contains at least one free block, and it does not overlap with other
-+ *	reservation windows.
-+ *
-+ *	failed: we failed to find a reservation window in this group
-+ *
-+ *	@rsv: the reservation
-+ *
-+ *	@grp_goal: The goal (group-relative).  It is where the search for a
-+ *		free reservable space should start from.
-+ *		if we have a grp_goal(grp_goal >0 ), then start from there,
-+ *		no grp_goal(grp_goal = -1), we start from the first block
-+ *		of the group.
-+ *
-+ *	@sb: the super block
-+ *	@group: the group we are trying to allocate in
-+ *	@bitmap_bh: the block group block bitmap
-+ *
-+ */
-+static int alloc_new_reservation(struct ext3cow_reserve_window_node *my_rsv,
-+		ext3cow_grpblk_t grp_goal, struct super_block *sb,
-+		unsigned int group, struct buffer_head *bitmap_bh)
-+{
-+	struct ext3cow_reserve_window_node *search_head;
-+	ext3cow_fsblk_t group_first_block, group_end_block, start_block;
-+	ext3cow_grpblk_t first_free_block;
-+	struct rb_root *fs_rsv_root = &EXT3COW_SB(sb)->s_rsv_window_root;
-+	unsigned long size;
-+	int ret;
-+	spinlock_t *rsv_lock = &EXT3COW_SB(sb)->s_rsv_window_lock;
-+
-+	group_first_block = ext3cow_group_first_block_no(sb, group);
-+	group_end_block = group_first_block + (EXT3COW_BLOCKS_PER_GROUP(sb) - 1);
-+
-+	if (grp_goal < 0)
-+		start_block = group_first_block;
-+	else
-+		start_block = grp_goal + group_first_block;
-+
-+	size = my_rsv->rsv_goal_size;
-+
-+	if (!rsv_is_empty(&my_rsv->rsv_window)) {
-+		/*
-+		 * if the old reservation is cross group boundary
-+		 * and if the goal is inside the old reservation window,
-+		 * we will come here when we just failed to allocate from
-+		 * the first part of the window. We still have another part
-+		 * that belongs to the next group. In this case, there is no
-+		 * point to discard our window and try to allocate a new one
-+		 * in this group(which will fail). we should
-+		 * keep the reservation window, just simply move on.
-+		 *
-+		 * Maybe we could shift the start block of the reservation
-+		 * window to the first block of next group.
-+		 */
-+
-+		if ((my_rsv->rsv_start <= group_end_block) &&
-+				(my_rsv->rsv_end > group_end_block) &&
-+				(start_block >= my_rsv->rsv_start))
-+			return -1;
-+
-+		if ((my_rsv->rsv_alloc_hit >
-+		     (my_rsv->rsv_end - my_rsv->rsv_start + 1) / 2)) {
-+			/*
-+			 * if the previously allocation hit ratio is
-+			 * greater than 1/2, then we double the size of
-+			 * the reservation window the next time,
-+			 * otherwise we keep the same size window
-+			 */
-+			size = size * 2;
-+			if (size > EXT3COW_MAX_RESERVE_BLOCKS)
-+				size = EXT3COW_MAX_RESERVE_BLOCKS;
-+			my_rsv->rsv_goal_size= size;
-+		}
-+	}
-+
-+	spin_lock(rsv_lock);
-+	/*
-+	 * shift the search start to the window near the goal block
-+	 */
-+	search_head = search_reserve_window(fs_rsv_root, start_block);
-+
-+	/*
-+	 * find_next_reservable_window() simply finds a reservable window
-+	 * inside the given range(start_block, group_end_block).
-+	 *
-+	 * To make sure the reservation window has a free bit inside it, we
-+	 * need to check the bitmap after we found a reservable window.
-+	 */
-+retry:
-+	ret = find_next_reservable_window(search_head, my_rsv, sb,
-+						start_block, group_end_block);
-+
-+	if (ret == -1) {
-+		if (!rsv_is_empty(&my_rsv->rsv_window))
-+			rsv_window_remove(sb, my_rsv);
-+		spin_unlock(rsv_lock);
-+		return -1;
-+	}
-+
-+	/*
-+	 * On success, find_next_reservable_window() returns the
-+	 * reservation window where there is a reservable space after it.
-+	 * Before we reserve this reservable space, we need
-+	 * to make sure there is at least a free block inside this region.
-+	 *
-+	 * searching the first free bit on the block bitmap and copy of
-+	 * last committed bitmap alternatively, until we found a allocatable
-+	 * block. Search start from the start block of the reservable space
-+	 * we just found.
-+	 */
-+	spin_unlock(rsv_lock);
-+	first_free_block = bitmap_search_next_usable_block(
-+			my_rsv->rsv_start - group_first_block,
-+			bitmap_bh, group_end_block - group_first_block + 1);
-+
-+	if (first_free_block < 0) {
-+		/*
-+		 * no free block left on the bitmap, no point
-+		 * to reserve the space. return failed.
-+		 */
-+		spin_lock(rsv_lock);
-+		if (!rsv_is_empty(&my_rsv->rsv_window))
-+			rsv_window_remove(sb, my_rsv);
-+		spin_unlock(rsv_lock);
-+		return -1;		/* failed */
-+	}
-+
-+	start_block = first_free_block + group_first_block;
-+	/*
-+	 * check if the first free block is within the
-+	 * free space we just reserved
-+	 */
-+	if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
-+		return 0;		/* success */
-+	/*
-+	 * if the first free bit we found is out of the reservable space
-+	 * continue search for next reservable space,
-+	 * start from where the free block is,
-+	 * we also shift the list head to where we stopped last time
-+	 */
-+	search_head = my_rsv;
-+	spin_lock(rsv_lock);
-+	goto retry;
-+}
-+
-+/**
-+ * try_to_extend_reservation()
-+ * @my_rsv:		given reservation window
-+ * @sb:			super block
-+ * @size:		the delta to extend
-+ *
-+ * Attempt to expand the reservation window large enough to have
-+ * required number of free blocks
-+ *
-+ * Since ext3cow_try_to_allocate() will always allocate blocks within
-+ * the reservation window range, if the window size is too small,
-+ * multiple blocks allocation has to stop at the end of the reservation
-+ * window. To make this more efficient, given the total number of
-+ * blocks needed and the current size of the window, we try to
-+ * expand the reservation window size if necessary on a best-effort
-+ * basis before ext3cow_new_blocks() tries to allocate blocks,
-+ */
-+static void try_to_extend_reservation(struct ext3cow_reserve_window_node *my_rsv,
-+			struct super_block *sb, int size)
-+{
-+	struct ext3cow_reserve_window_node *next_rsv;
-+	struct rb_node *next;
-+	spinlock_t *rsv_lock = &EXT3COW_SB(sb)->s_rsv_window_lock;
-+
-+	if (!spin_trylock(rsv_lock))
-+		return;
-+
-+	next = rb_next(&my_rsv->rsv_node);
-+
-+	if (!next)
-+		my_rsv->rsv_end += size;
-+	else {
-+		next_rsv = rb_entry(next, struct ext3cow_reserve_window_node, rsv_node);
-+
-+		if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
-+			my_rsv->rsv_end += size;
-+		else
-+			my_rsv->rsv_end = next_rsv->rsv_start - 1;
-+	}
-+	spin_unlock(rsv_lock);
-+}
-+
-+/**
-+ * ext3cow_try_to_allocate_with_rsv()
-+ * @sb:			superblock
-+ * @handle:		handle to this transaction
-+ * @group:		given allocation block group
-+ * @bitmap_bh:		bufferhead holds the block bitmap
-+ * @grp_goal:		given target block within the group
-+ * @count:		target number of blocks to allocate
-+ * @my_rsv:		reservation window
-+ * @errp:		pointer to store the error code
-+ *
-+ * This is the main function used to allocate a new block and its reservation
-+ * window.
-+ *
-+ * Each time when a new block allocation is need, first try to allocate from
-+ * its own reservation.  If it does not have a reservation window, instead of
-+ * looking for a free bit on bitmap first, then look up the reservation list to
-+ * see if it is inside somebody else's reservation window, we try to allocate a
-+ * reservation window for it starting from the goal first. Then do the block
-+ * allocation within the reservation window.
-+ *
-+ * This will avoid keeping on searching the reservation list again and
-+ * again when somebody is looking for a free block (without
-+ * reservation), and there are lots of free blocks, but they are all
-+ * being reserved.
-+ *
-+ * We use a red-black tree for the per-filesystem reservation list.
-+ *
-+ */
-+static ext3cow_grpblk_t
-+ext3cow_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
-+			unsigned int group, struct buffer_head *bitmap_bh,
-+			ext3cow_grpblk_t grp_goal,
-+			struct ext3cow_reserve_window_node * my_rsv,
-+			unsigned long *count, int *errp)
-+{
-+	ext3cow_fsblk_t group_first_block, group_last_block;
-+	ext3cow_grpblk_t ret = 0;
-+	int fatal;
-+	unsigned long num = *count;
-+
-+	*errp = 0;
-+
-+	/*
-+	 * Make sure we use undo access for the bitmap, because it is critical
-+	 * that we do the frozen_data COW on bitmap buffers in all cases even
-+	 * if the buffer is in BJ_Forget state in the committing transaction.
-+	 */
-+	BUFFER_TRACE(bitmap_bh, "get undo access for new block");
-+	fatal = ext3cow_journal_get_undo_access(handle, bitmap_bh);
-+	if (fatal) {
-+		*errp = fatal;
-+		return -1;
-+	}
-+
-+	/*
-+	 * we don't deal with reservation when
-+	 * filesystem is mounted without reservation
-+	 * or the file is not a regular file
-+	 * or last attempt to allocate a block with reservation turned on failed
-+	 */
-+	if (my_rsv == NULL ) {
-+		ret = ext3cow_try_to_allocate(sb, handle, group, bitmap_bh,
-+						grp_goal, count, NULL);
-+		goto out;
-+	}
-+	/*
-+	 * grp_goal is a group relative block number (if there is a goal)
-+	 * 0 <= grp_goal < EXT3COW_BLOCKS_PER_GROUP(sb)
-+	 * first block is a filesystem wide block number
-+	 * first block is the block number of the first block in this group
-+	 */
-+	group_first_block = ext3cow_group_first_block_no(sb, group);
-+	group_last_block = group_first_block + (EXT3COW_BLOCKS_PER_GROUP(sb) - 1);
-+
-+	/*
-+	 * Basically we will allocate a new block from inode's reservation
-+	 * window.
-+	 *
-+	 * We need to allocate a new reservation window, if:
-+	 * a) inode does not have a reservation window; or
-+	 * b) last attempt to allocate a block from existing reservation
-+	 *    failed; or
-+	 * c) we come here with a goal and with a reservation window
-+	 *
-+	 * We do not need to allocate a new reservation window if we come here
-+	 * at the beginning with a goal and the goal is inside the window, or
-+	 * we don't have a goal but already have a reservation window.
-+	 * then we could go to allocate from the reservation window directly.
-+	 */
-+	while (1) {
-+		if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) ||
-+			!goal_in_my_reservation(&my_rsv->rsv_window,
-+						grp_goal, group, sb)) {
-+			if (my_rsv->rsv_goal_size < *count)
-+				my_rsv->rsv_goal_size = *count;
-+			ret = alloc_new_reservation(my_rsv, grp_goal, sb,
-+							group, bitmap_bh);
-+			if (ret < 0)
-+				break;			/* failed */
-+
-+			if (!goal_in_my_reservation(&my_rsv->rsv_window,
-+							grp_goal, group, sb))
-+				grp_goal = -1;
-+		} else if (grp_goal >= 0) {
-+			int curr = my_rsv->rsv_end -
-+					(grp_goal + group_first_block) + 1;
-+
-+			if (curr < *count)
-+				try_to_extend_reservation(my_rsv, sb,
-+							*count - curr);
-+		}
-+
-+		if ((my_rsv->rsv_start > group_last_block) ||
-+				(my_rsv->rsv_end < group_first_block)) {
-+			rsv_window_dump(&EXT3COW_SB(sb)->s_rsv_window_root, 1);
-+			BUG();
-+		}
-+		ret = ext3cow_try_to_allocate(sb, handle, group, bitmap_bh,
-+					   grp_goal, &num, &my_rsv->rsv_window);
-+		if (ret >= 0) {
-+			my_rsv->rsv_alloc_hit += num;
-+			*count = num;
-+			break;				/* succeed */
-+		}
-+		num = *count;
-+	}
-+out:
-+	if (ret >= 0) {
-+		BUFFER_TRACE(bitmap_bh, "journal_dirty_metadata for "
-+					"bitmap block");
-+		fatal = ext3cow_journal_dirty_metadata(handle, bitmap_bh);
-+		if (fatal) {
-+			*errp = fatal;
-+			return -1;
-+		}
-+		return ret;
-+	}
-+
-+	BUFFER_TRACE(bitmap_bh, "journal_release_buffer");
-+	ext3cow_journal_release_buffer(handle, bitmap_bh);
-+	return ret;
-+}
-+
-+/**
-+ * ext3cow_has_free_blocks()
-+ * @sbi:		in-core super block structure.
-+ *
-+ * Check if filesystem has at least 1 free block available for allocation.
-+ */
-+static int ext3cow_has_free_blocks(struct ext3cow_sb_info *sbi)
-+{
-+	ext3cow_fsblk_t free_blocks, root_blocks;
-+
-+	free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
-+	root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
-+	if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
-+		sbi->s_resuid != current->fsuid &&
-+		(sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
-+		return 0;
-+	}
-+	return 1;
-+}
-+
-+/**
-+ * ext3cow_should_retry_alloc()
-+ * @sb:			super block
-+ * @retries		number of attemps has been made
-+ *
-+ * ext3cow_should_retry_alloc() is called when ENOSPC is returned, and if
-+ * it is profitable to retry the operation, this function will wait
-+ * for the current or commiting transaction to complete, and then
-+ * return TRUE.
-+ *
-+ * if the total number of retries exceed three times, return FALSE.
-+ */
-+int ext3cow_should_retry_alloc(struct super_block *sb, int *retries)
-+{
-+	if (!ext3cow_has_free_blocks(EXT3COW_SB(sb)) || (*retries)++ > 3)
-+		return 0;
-+
-+	jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
-+
-+	return journal_force_commit_nested(EXT3COW_SB(sb)->s_journal);
-+}
-+
-+/**
-+ * ext3cow_new_blocks() -- core block(s) allocation function
-+ * @handle:		handle to this transaction
-+ * @inode:		file inode
-+ * @goal:		given target block(filesystem wide)
-+ * @count:		target number of blocks to allocate
-+ * @errp:		error code
-+ *
-+ * ext3cow_new_blocks uses a goal block to assist allocation.  It tries to
-+ * allocate block(s) from the block group contains the goal block first. If that
-+ * fails, it will try to allocate block(s) from other block groups without
-+ * any specific goal block.
-+ *
-+ */
-+ext3cow_fsblk_t ext3cow_new_blocks(handle_t *handle, struct inode *inode,
-+			ext3cow_fsblk_t goal, unsigned long *count, int *errp)
-+{
-+	struct buffer_head *bitmap_bh = NULL;
-+	struct buffer_head *gdp_bh;
-+	int group_no;
-+	int goal_group;
-+	ext3cow_grpblk_t grp_target_blk;	/* blockgroup relative goal block */
-+	ext3cow_grpblk_t grp_alloc_blk;	/* blockgroup-relative allocated block*/
-+	ext3cow_fsblk_t ret_block;		/* filesyetem-wide allocated block */
-+	int bgi;			/* blockgroup iteration index */
-+	int fatal = 0, err;
-+	int performed_allocation = 0;
-+	ext3cow_grpblk_t free_blocks;	/* number of free blocks in a group */
-+	struct super_block *sb;
-+	struct ext3cow_group_desc *gdp;
-+	struct ext3cow_super_block *es;
-+	struct ext3cow_sb_info *sbi;
-+	struct ext3cow_reserve_window_node *my_rsv = NULL;
-+	struct ext3cow_block_alloc_info *block_i;
-+	unsigned short windowsz = 0;
-+#ifdef EXT3COWFS_DEBUG
-+	static int goal_hits, goal_attempts;
-+#endif
-+	unsigned long ngroups;
-+	unsigned long num = *count;
-+
-+	*errp = -ENOSPC;
-+	sb = inode->i_sb;
-+	if (!sb) {
-+		printk("ext3cow_new_block: nonexistent device");
-+		return 0;
-+	}
-+
-+	/*
-+	 * Check quota for allocation of this block.
-+	 */
-+	if (DQUOT_ALLOC_BLOCK(inode, num)) {
-+		*errp = -EDQUOT;
-+		return 0;
-+	}
-+
-+	sbi = EXT3COW_SB(sb);
-+	es = EXT3COW_SB(sb)->s_es;
-+	ext3cow_debug("goal=%lu.\n", goal);
-+	/*
-+	 * Allocate a block from reservation only when
-+	 * filesystem is mounted with reservation(default,-o reservation), and
-+	 * it's a regular file, and
-+	 * the desired window size is greater than 0 (One could use ioctl
-+	 * command EXT3COW_IOC_SETRSVSZ to set the window size to 0 to turn off
-+	 * reservation on that particular file)
-+	 */
-+	block_i = EXT3COW_I(inode)->i_block_alloc_info;
-+	if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
-+		my_rsv = &block_i->rsv_window_node;
-+
-+	if (!ext3cow_has_free_blocks(sbi)) {
-+		*errp = -ENOSPC;
-+		goto out;
-+	}
-+
-+	/*
-+	 * First, test whether the goal block is free.
-+	 */
-+	if (goal < le32_to_cpu(es->s_first_data_block) ||
-+	    goal >= le32_to_cpu(es->s_blocks_count))
-+		goal = le32_to_cpu(es->s_first_data_block);
-+	group_no = (goal - le32_to_cpu(es->s_first_data_block)) /
-+			EXT3COW_BLOCKS_PER_GROUP(sb);
-+	goal_group = group_no;
-+retry_alloc:
-+	gdp = ext3cow_get_group_desc(sb, group_no, &gdp_bh);
-+	if (!gdp)
-+		goto io_error;
-+
-+	free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
-+	/*
-+	 * if there is not enough free blocks to make a new resevation
-+	 * turn off reservation for this allocation
-+	 */
-+	if (my_rsv && (free_blocks < windowsz)
-+		&& (rsv_is_empty(&my_rsv->rsv_window)))
-+		my_rsv = NULL;
-+
-+	if (free_blocks > 0) {
-+		grp_target_blk = ((goal - le32_to_cpu(es->s_first_data_block)) %
-+				EXT3COW_BLOCKS_PER_GROUP(sb));
-+		bitmap_bh = read_block_bitmap(sb, group_no);
-+		if (!bitmap_bh)
-+			goto io_error;
-+		grp_alloc_blk = ext3cow_try_to_allocate_with_rsv(sb, handle,
-+					group_no, bitmap_bh, grp_target_blk,
-+					my_rsv,	&num, &fatal);
-+		if (fatal)
-+			goto out;
-+		if (grp_alloc_blk >= 0)
-+			goto allocated;
-+	}
-+
-+	ngroups = EXT3COW_SB(sb)->s_groups_count;
-+	smp_rmb();
-+
-+	/*
-+	 * Now search the rest of the groups.  We assume that
-+	 * i and gdp correctly point to the last group visited.
-+	 */
-+	for (bgi = 0; bgi < ngroups; bgi++) {
-+		group_no++;
-+		if (group_no >= ngroups)
-+			group_no = 0;
-+		gdp = ext3cow_get_group_desc(sb, group_no, &gdp_bh);
-+		if (!gdp)
-+			goto io_error;
-+		free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
-+		/*
-+		 * skip this group if the number of
-+		 * free blocks is less than half of the reservation
-+		 * window size.
-+		 */
-+		if (free_blocks <= (windowsz/2))
-+			continue;
-+
-+		brelse(bitmap_bh);
-+		bitmap_bh = read_block_bitmap(sb, group_no);
-+		if (!bitmap_bh)
-+			goto io_error;
-+		/*
-+		 * try to allocate block(s) from this group, without a goal(-1).
-+		 */
-+		grp_alloc_blk = ext3cow_try_to_allocate_with_rsv(sb, handle,
-+					group_no, bitmap_bh, -1, my_rsv,
-+					&num, &fatal);
-+		if (fatal)
-+			goto out;
-+		if (grp_alloc_blk >= 0)
-+			goto allocated;
-+	}
-+	/*
-+	 * We may end up a bogus ealier ENOSPC error due to
-+	 * filesystem is "full" of reservations, but
-+	 * there maybe indeed free blocks avaliable on disk
-+	 * In this case, we just forget about the reservations
-+	 * just do block allocation as without reservations.
-+	 */
-+	if (my_rsv) {
-+		my_rsv = NULL;
-+		windowsz = 0;
-+		group_no = goal_group;
-+		goto retry_alloc;
-+	}
-+	/* No space left on the device */
-+	*errp = -ENOSPC;
-+	goto out;
-+
-+allocated:
-+
-+	ext3cow_debug("using block group %d(%d)\n",
-+			group_no, gdp->bg_free_blocks_count);
-+
-+	BUFFER_TRACE(gdp_bh, "get_write_access");
-+	fatal = ext3cow_journal_get_write_access(handle, gdp_bh);
-+	if (fatal)
-+		goto out;
-+
-+	ret_block = grp_alloc_blk + ext3cow_group_first_block_no(sb, group_no);
-+
-+	if (in_range(le32_to_cpu(gdp->bg_block_bitmap), ret_block, num) ||
-+	    in_range(le32_to_cpu(gdp->bg_inode_bitmap), ret_block, num) ||
-+	    in_range(ret_block, le32_to_cpu(gdp->bg_inode_table),
-+		      EXT3COW_SB(sb)->s_itb_per_group) ||
-+	    in_range(ret_block + num - 1, le32_to_cpu(gdp->bg_inode_table),
-+		      EXT3COW_SB(sb)->s_itb_per_group))
-+		ext3cow_error(sb, "ext3cow_new_block",
-+			    "Allocating block in system zone - "
-+			    "blocks from "E3FSBLK", length %lu",
-+			     ret_block, num);
-+
-+	performed_allocation = 1;
-+
-+#ifdef CONFIG_JBD_DEBUG
-+	{
-+		struct buffer_head *debug_bh;
-+
-+		/* Record bitmap buffer state in the newly allocated block */
-+		debug_bh = sb_find_get_block(sb, ret_block);
-+		if (debug_bh) {
-+			BUFFER_TRACE(debug_bh, "state when allocated");
-+			BUFFER_TRACE2(debug_bh, bitmap_bh, "bitmap state");
-+			brelse(debug_bh);
-+		}
-+	}
-+	jbd_lock_bh_state(bitmap_bh);
-+	spin_lock(sb_bgl_lock(sbi, group_no));
-+	if (buffer_jbd(bitmap_bh) && bh2jh(bitmap_bh)->b_committed_data) {
-+		int i;
-+
-+		for (i = 0; i < num; i++) {
-+			if (ext3cow_test_bit(grp_alloc_blk+i,
-+					bh2jh(bitmap_bh)->b_committed_data)) {
-+				printk("%s: block was unexpectedly set in "
-+					"b_committed_data\n", __FUNCTION__);
-+			}
-+		}
-+	}
-+	ext3cow_debug("found bit %d\n", grp_alloc_blk);
-+	spin_unlock(sb_bgl_lock(sbi, group_no));
-+	jbd_unlock_bh_state(bitmap_bh);
-+#endif
-+
-+	if (ret_block + num - 1 >= le32_to_cpu(es->s_blocks_count)) {
-+		ext3cow_error(sb, "ext3cow_new_block",
-+			    "block("E3FSBLK") >= blocks count(%d) - "
-+			    "block_group = %d, es == %p ", ret_block,
-+			le32_to_cpu(es->s_blocks_count), group_no, es);
-+		goto out;
-+	}
-+
-+	/*
-+	 * It is up to the caller to add the new buffer to a journal
-+	 * list of some description.  We don't know in advance whether
-+	 * the caller wants to use it as metadata or data.
-+	 */
-+	ext3cow_debug("allocating block %lu. Goal hits %d of %d.\n",
-+			ret_block, goal_hits, goal_attempts);
-+
-+	spin_lock(sb_bgl_lock(sbi, group_no));
-+	gdp->bg_free_blocks_count =
-+			cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num);
-+	spin_unlock(sb_bgl_lock(sbi, group_no));
-+	percpu_counter_mod(&sbi->s_freeblocks_counter, -num);
-+
-+	BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
-+	err = ext3cow_journal_dirty_metadata(handle, gdp_bh);
-+	if (!fatal)
-+		fatal = err;
-+
-+	sb->s_dirt = 1;
-+	if (fatal)
-+		goto out;
-+
-+	*errp = 0;
-+	brelse(bitmap_bh);
-+	DQUOT_FREE_BLOCK(inode, *count-num);
-+	*count = num;
-+	return ret_block;
-+
-+io_error:
-+	*errp = -EIO;
-+out:
-+	if (fatal) {
-+		*errp = fatal;
-+		ext3cow_std_error(sb, fatal);
-+	}
-+	/*
-+	 * Undo the block allocation
-+	 */
-+	if (!performed_allocation)
-+		DQUOT_FREE_BLOCK(inode, *count);
-+	brelse(bitmap_bh);
-+	return 0;
-+}
-+
-+ext3cow_fsblk_t ext3cow_new_block(handle_t *handle, struct inode *inode,
-+			ext3cow_fsblk_t goal, int *errp)
-+{
-+	unsigned long count = 1;
-+
-+	return ext3cow_new_blocks(handle, inode, goal, &count, errp);
-+}
-+
-+/**
-+ * ext3cow_count_free_blocks() -- count filesystem free blocks
-+ * @sb:		superblock
-+ *
-+ * Adds up the number of free blocks from each block group.
-+ */
-+ext3cow_fsblk_t ext3cow_count_free_blocks(struct super_block *sb)
-+{
-+	ext3cow_fsblk_t desc_count;
-+	struct ext3cow_group_desc *gdp;
-+	int i;
-+	unsigned long ngroups = EXT3COW_SB(sb)->s_groups_count;
-+#ifdef EXT3COWFS_DEBUG
-+	struct ext3cow_super_block *es;
-+	ext3cow_fsblk_t bitmap_count;
-+	unsigned long x;
-+	struct buffer_head *bitmap_bh = NULL;
-+
-+	es = EXT3COW_SB(sb)->s_es;
-+	desc_count = 0;
-+	bitmap_count = 0;
-+	gdp = NULL;
-+
-+	smp_rmb();
-+	for (i = 0; i < ngroups; i++) {
-+		gdp = ext3cow_get_group_desc(sb, i, NULL);
-+		if (!gdp)
-+			continue;
-+		desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
-+		brelse(bitmap_bh);
-+		bitmap_bh = read_block_bitmap(sb, i);
-+		if (bitmap_bh == NULL)
-+			continue;
-+
-+		x = ext3cow_count_free(bitmap_bh, sb->s_blocksize);
-+		printk("group %d: stored = %d, counted = %lu\n",
-+			i, le16_to_cpu(gdp->bg_free_blocks_count), x);
-+		bitmap_count += x;
-+	}
-+	brelse(bitmap_bh);
-+	printk("ext3cow_count_free_blocks: stored = "E3FSBLK
-+		", computed = "E3FSBLK", "E3FSBLK"\n",
-+	       le32_to_cpu(es->s_free_blocks_count),
-+		desc_count, bitmap_count);
-+	return bitmap_count;
-+#else
-+	desc_count = 0;
-+	smp_rmb();
-+	for (i = 0; i < ngroups; i++) {
-+		gdp = ext3cow_get_group_desc(sb, i, NULL);
-+		if (!gdp)
-+			continue;
-+		desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
-+	}
-+
-+	return desc_count;
-+#endif
-+}
-+
-+static inline int
-+block_in_use(ext3cow_fsblk_t block, struct super_block *sb, unsigned char *map)
-+{
-+	return ext3cow_test_bit ((block -
-+		le32_to_cpu(EXT3COW_SB(sb)->s_es->s_first_data_block)) %
-+			 EXT3COW_BLOCKS_PER_GROUP(sb), map);
-+}
-+
-+static inline int test_root(int a, int b)
-+{
-+	int num = b;
-+
-+	while (a > num)
-+		num *= b;
-+	return num == a;
-+}
-+
-+static int ext3cow_group_sparse(int group)
-+{
-+	if (group <= 1)
-+		return 1;
-+	if (!(group & 1))
-+		return 0;
-+	return (test_root(group, 7) || test_root(group, 5) ||
-+		test_root(group, 3));
-+}
-+
-+/**
-+ *	ext3cow_bg_has_super - number of blocks used by the superblock in group
-+ *	@sb: superblock for filesystem
-+ *	@group: group number to check
-+ *
-+ *	Return the number of blocks used by the superblock (primary or backup)
-+ *	in this group.  Currently this will be only 0 or 1.
-+ */
-+int ext3cow_bg_has_super(struct super_block *sb, int group)
-+{
-+	if (EXT3COW_HAS_RO_COMPAT_FEATURE(sb,
-+				EXT3COW_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
-+			!ext3cow_group_sparse(group))
-+		return 0;
-+	return 1;
-+}
-+
-+static unsigned long ext3cow_bg_num_gdb_meta(struct super_block *sb, int group)
-+{
-+	unsigned long metagroup = group / EXT3COW_DESC_PER_BLOCK(sb);
-+	unsigned long first = metagroup * EXT3COW_DESC_PER_BLOCK(sb);
-+	unsigned long last = first + EXT3COW_DESC_PER_BLOCK(sb) - 1;
-+
-+	if (group == first || group == first + 1 || group == last)
-+		return 1;
-+	return 0;
-+}
-+
-+static unsigned long ext3cow_bg_num_gdb_nometa(struct super_block *sb, int group)
-+{
-+	if (EXT3COW_HAS_RO_COMPAT_FEATURE(sb,
-+				EXT3COW_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
-+			!ext3cow_group_sparse(group))
-+		return 0;
-+	return EXT3COW_SB(sb)->s_gdb_count;
-+}
-+
-+/**
-+ *	ext3cow_bg_num_gdb - number of blocks used by the group table in group
-+ *	@sb: superblock for filesystem
-+ *	@group: group number to check
-+ *
-+ *	Return the number of blocks used by the group descriptor table
-+ *	(primary or backup) in this group.  In the future there may be a
-+ *	different number of descriptor blocks in each group.
-+ */
-+unsigned long ext3cow_bg_num_gdb(struct super_block *sb, int group)
-+{
-+	unsigned long first_meta_bg =
-+			le32_to_cpu(EXT3COW_SB(sb)->s_es->s_first_meta_bg);
-+	unsigned long metagroup = group / EXT3COW_DESC_PER_BLOCK(sb);
-+
-+	if (!EXT3COW_HAS_INCOMPAT_FEATURE(sb,EXT3COW_FEATURE_INCOMPAT_META_BG) ||
-+			metagroup < first_meta_bg)
-+		return ext3cow_bg_num_gdb_nometa(sb,group);
-+
-+	return ext3cow_bg_num_gdb_meta(sb,group);
-+
-+}
-diff -Naur linux-2.6.21.7/fs/ext3cow/bitmap.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/bitmap.c
---- linux-2.6.21.7/fs/ext3cow/bitmap.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/bitmap.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,32 @@
-+/*
-+ *  linux/fs/ext3/bitmap.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ */
-+
-+#include <linux/buffer_head.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+
-+#ifdef EXT3COWFS_DEBUG
-+
-+static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
-+
-+unsigned long ext3cow_count_free (struct buffer_head * map, unsigned int numchars)
-+{
-+	unsigned int i;
-+	unsigned long sum = 0;
-+
-+	if (!map)
-+		return (0);
-+	for (i = 0; i < numchars; i++)
-+		sum += nibblemap[map->b_data[i] & 0xf] +
-+			nibblemap[(map->b_data[i] >> 4) & 0xf];
-+	return (sum);
-+}
-+
-+#endif  /*  EXT3COWFS_DEBUG  */
-+
-diff -Naur linux-2.6.21.7/fs/ext3cow/CHANGELOG linux-2.6.21.7_ext3cowPatched/fs/ext3cow/CHANGELOG
---- linux-2.6.21.7/fs/ext3cow/CHANGELOG	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/CHANGELOG	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,7 @@
-+6-20-7
-+- Finished the roll code for inode chains in case of error.
-+
-+6-18-07
-+- Added support for 32-bit uid's and gid's back in again
-+- Took out support for block fragmentation
-+- Hopefully fixed the non-sticking uid/gid bug.
-\ No newline at end of file
-diff -Naur linux-2.6.21.7/fs/ext3cow/dir.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/dir.c
---- linux-2.6.21.7/fs/ext3cow/dir.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/dir.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,732 @@
-+/*
-+ *  linux/fs/ext3cow/dir.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/fs/minix/dir.c
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ *
-+ *  ext3cow directory handling functions
-+ *
-+ *  Big-endian to little-endian byte-swapping/bitmaps by
-+ *        David S. Miller (davem@caip.rutgers.edu), 1995
-+ *
-+ * Hash Tree Directory indexing (c) 2001  Daniel Phillips
-+ *
-+ */
-+
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/buffer_head.h>
-+#include <linux/smp_lock.h>
-+#include <linux/slab.h>
-+#include <linux/rbtree.h>
-+
-+static unsigned char ext3cow_filetype_table[] = {
-+	DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
-+};
-+
-+static int ext3cow_readdir(struct file *, void *, filldir_t);
-+static int ext3cow_dx_readdir(struct file * filp,
-+			   void * dirent, filldir_t filldir);
-+static int ext3cow_release_dir (struct inode * inode,
-+				struct file * filp);
-+
-+const struct file_operations ext3cow_dir_operations = {
-+	.llseek		= generic_file_llseek,
-+	.read		= generic_read_dir,
-+	.readdir	= ext3cow_readdir,		/* we take BKL. needed?*/
-+	.ioctl		= ext3cow_ioctl,		/* BKL held */
-+#ifdef CONFIG_COMPAT
-+	.compat_ioctl	= ext3cow_compat_ioctl,
-+#endif
-+	.fsync		= ext3cow_sync_file,	/* BKL held */
-+#ifdef CONFIG_EXT3COW_INDEX
-+	.release	= ext3cow_release_dir,
-+#endif
-+};
-+
-+
-+static unsigned char get_dtype(struct super_block *sb, int filetype)
-+{
-+	if (!EXT3COW_HAS_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_FILETYPE) ||
-+	    (filetype >= EXT3COW_FT_MAX))
-+		return DT_UNKNOWN;
-+
-+	return (ext3cow_filetype_table[filetype]);
-+}
-+
-+static int ext3cow_readversions(struct file * filp, void * dirent, 
-+                                filldir_t filldir)
-+{
-+  int error = 0;
-+  unsigned long offset;
-+  int i, stored;
-+  struct buffer_head *bh;
-+  struct ext3cow_dir_entry_2 * de;
-+  struct super_block * sb;
-+  int err;
-+  struct inode *dir = filp->f_dentry->d_inode;
-+  char *at;
-+  unsigned long ino;
-+  int ref_len = filp->f_dentry->d_name.len -1;
-+  
-+  sb = dir->i_sb;
-+  
-+  stored = 0;
-+  bh = NULL;
-+  offset = filp->f_pos & (sb->s_blocksize - 1);
-+  
-+  at = strrchr(filp->f_dentry->d_name.name, EXT3COW_FLUX_TOKEN);
-+  
-+  while (!error && !stored && filp->f_pos < dir->i_size) {
-+    unsigned long blk = (filp->f_pos) >> EXT3COW_BLOCK_SIZE_BITS(sb);
-+    struct buffer_head map_bh;
-+
-+    bh = NULL;
-+    map_bh.b_state = 0;
-+		err = ext3cow_get_blocks_handle(NULL, dir, blk, 1,
-+						&map_bh, 0, 0);
-+		if (err > 0) {
-+			page_cache_readahead(sb->s_bdev->bd_inode->i_mapping,
-+				&filp->f_ra,
-+				filp,
-+				map_bh.b_blocknr >>
-+					(PAGE_CACHE_SHIFT - dir->i_blkbits),
-+				1);
-+			bh = ext3cow_bread(NULL, dir, blk, 0, &err);
-+		}
-+
-+		/*
-+		 * We ignore I/O errors on directories so users have a chance
-+		 * of recovering data when there's a bad sector
-+		 */
-+    if (!bh) {
-+      ext3cow_error (sb, "ext3cow_readdir",
-+                     "directory #%lu contains a hole at offset %lu",
-+                     dir->i_ino, (unsigned long)filp->f_pos);
-+      /* corrupt size?  Maybe no more blocks to read */
-+			if (filp->f_pos > dir->i_blocks << 9)
-+				break;
-+      filp->f_pos += sb->s_blocksize - offset;
-+      continue;
-+    }
-+    
-+  ver_revalidate:
-+    /* If the dir block has changed since the last call to
-+     * readdir(2), then we might be pointing to an invalid
-+     * dirent right now.  Scan from the start of the block
-+     * to make sure. */
-+    if (filp->f_version != dir->i_version) {
-+      for (i = 0; i < sb->s_blocksize && i < offset; ) {
-+        de = (struct ext3cow_dir_entry_2 *) 
-+          (bh->b_data + i);
-+				/* It's too expensive to do a full
-+				 * dirent test each time round this
-+				 * loop, but we do have to test at
-+				 * least that it is non-zero.  A
-+				 * failure will be detected in the
-+				 * dirent test below. */
-+        if (le16_to_cpu(de->rec_len) <
-+            EXT3COW_DIR_REC_LEN(1))
-+          break;
-+        i += le16_to_cpu(de->rec_len);
-+      }
-+      offset = i;
-+      filp->f_pos = (filp->f_pos & ~(sb->s_blocksize - 1))
-+        | offset;
-+      filp->f_version = dir->i_version;
-+    }
-+    
-+    while (!error && filp->f_pos < dir->i_size 
-+           && offset < sb->s_blocksize) {
-+      de = (struct ext3cow_dir_entry_2 *) (bh->b_data + offset);
-+      if (!ext3cow_check_dir_entry ("ext3cow_readdir", dir, de,
-+                                    bh, offset)) {
-+				/* On error, skip the f_pos to the
-+           next block. */
-+        filp->f_pos = (filp->f_pos |
-+                       (sb->s_blocksize - 1)) + 1;
-+        brelse (bh);
-+        return stored;
-+      }
-+      offset += le16_to_cpu(de->rec_len);
-+      
-+      if (le32_to_cpu(de->inode)){
-+        unsigned long version = filp->f_version;
-+        unsigned char d_type = DT_UNKNOWN;
-+        
-+        /* We might block in the next section
-+         * if the data destination is
-+         * currently swapped out.  So, use a
-+         * version stamp to detect whether or
-+         * not the directory has been modified
-+         * during the copy operation.
-+         */
-+        
-+        if (EXT3COW_HAS_INCOMPAT_FEATURE(sb,
-+                                         EXT3COW_FEATURE_INCOMPAT_FILETYPE)
-+            && de->file_type < EXT3COW_FT_MAX)
-+          d_type =
-+            ext3cow_filetype_table[de->file_type];
-+        if (de->name_len == ref_len
-+            && strncmp(filp->f_dentry->d_name.name, de->name, ref_len)==0) {
-+          
-+          struct inode * inde;
-+          char * name;
-+          
-+          name = kmalloc(EXT3COW_NAME_LEN, GFP_KERNEL);
-+          strncpy(name, de->name, de->name_len);
-+          inde = iget(dir->i_sb, de->inode);
-+          
-+          if (de->death_epoch!=0 && de->birth_epoch!=de->death_epoch) {
-+            name[de->name_len]='\0';
-+            sprintf(name,"%s@%d",name, de->death_epoch);
-+            error = filldir(dirent, name,
-+                            strlen(name),
-+                            filp->f_pos,
-+                            le32_to_cpu(inde->i_ino),
-+                            d_type);
-+            stored++;
-+          }
-+          
-+          while (EXT3COW_I(inde)->i_next_inode!=0) {
-+            name[de->name_len]='\0';
-+            sprintf(name,"%s@%d",name, EXT3COW_I_EPOCHNUMBER(inde));
-+            error = filldir(dirent, name,
-+                            strlen(name),
-+                            filp->f_pos,
-+                            le32_to_cpu(inde->i_ino),
-+                            d_type);
-+            ino = EXT3COW_I(inde)->i_next_inode;
-+            iput(inde);
-+            inde = iget(dir->i_sb, ino);
-+            stored++;
-+          }
-+          
-+          kfree(name);
-+          iput(inde);
-+                    
-+          if (error)
-+            break;
-+          
-+          if (!stored && 
-+              EXT3COW_IS_DIRENT_SCOPED(de, EXT3COW_I_EPOCHNUMBER(dir))) {
-+            error = filldir(dirent, de->name,
-+                            de->name_len,
-+                            filp->f_pos,
-+                            le32_to_cpu(de->inode),
-+                            d_type);
-+          }
-+            
-+          if (error)
-+            break;
-+          if (version != filp->f_version)
-+            goto ver_revalidate;
-+          stored ++;
-+        }
-+      }
-+      
-+      filp->f_pos += le16_to_cpu(de->rec_len);
-+    }
-+    offset = 0;
-+    brelse (bh);
-+  }
-+  return 0;
-+}
-+
-+
-+int ext3cow_check_dir_entry (const char * function, struct inode * dir,
-+			  struct ext3cow_dir_entry_2 * de,
-+			  struct buffer_head * bh,
-+			  unsigned long offset)
-+{
-+	const char * error_msg = NULL;
-+	const int rlen = le16_to_cpu(de->rec_len);
-+  unsigned int current_epoch = EXT3COW_S_EPOCHNUMBER(dir->i_sb);
-+
-+	if (rlen < EXT3COW_DIR_REC_LEN(1))
-+		error_msg = "rec_len is smaller than minimal";
-+	else if (rlen % 4 != 0)
-+		error_msg = "rec_len % 4 != 0";
-+	else if (rlen < EXT3COW_DIR_REC_LEN(de->name_len))
-+		error_msg = "rec_len is too small for name_len";
-+	else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)
-+		error_msg = "directory entry across blocks";
-+	else if (le32_to_cpu(de->inode) >
-+			le32_to_cpu(EXT3COW_SB(dir->i_sb)->s_es->s_inodes_count))
-+		error_msg = "inode out of bounds";
-+  /* Some bounds on versioned entries -znjp*/
-+  else if (le32_to_cpu(de->death_epoch) != EXT3COW_DIRENT_ALIVE && 
-+           le32_to_cpu(de->birth_epoch) > le32_to_cpu(de->death_epoch))
-+    error_msg = "entry died before it was born";
-+  else if (le32_to_cpu(de->birth_epoch) > current_epoch)
-+    error_msg = "entry was born in the future";
-+  else if (le32_to_cpu(de->death_epoch) > current_epoch)
-+    error_msg = "entry has already died in the future";
-+
-+	if (error_msg != NULL)
-+		ext3cow_error (dir->i_sb, function,
-+			"bad entry in directory #%lu: %s - "
-+			"offset=%lu, inode=%lu, rec_len=%d, name_len=%d, "
-+      "birth_epoch=%d death_epoch=%d",
-+			dir->i_ino, error_msg, offset,
-+			(unsigned long) le32_to_cpu(de->inode),
-+                   rlen, de->name_len, de->birth_epoch, de->death_epoch);
-+	return error_msg == NULL ? 1 : 0;
-+}
-+
-+static int ext3cow_readdir(struct file * filp,
-+			 void * dirent, filldir_t filldir)
-+{
-+	int error = 0;
-+	unsigned long offset;
-+	int i, stored;
-+	struct ext3cow_dir_entry_2 *de;
-+	struct super_block *sb;
-+	int err;
-+	struct inode *inode = filp->f_path.dentry->d_inode;
-+	int ret = 0;
-+  
-+  /* is this a version listing? */
-+  if (filp->f_dentry->d_name.name[filp->f_dentry->d_name.len-1] ==  
-+      EXT3COW_FLUX_TOKEN)
-+    return ext3cow_readversions(filp, dirent, filldir);
-+  
-+	sb = inode->i_sb;
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+	if (EXT3COW_HAS_COMPAT_FEATURE(inode->i_sb, 
-+                                 EXT3COW_FEATURE_COMPAT_DIR_INDEX) &&
-+	    ((EXT3COW_I(inode)->i_flags & EXT3COW_INDEX_FL) ||
-+	     ((inode->i_size >> sb->s_blocksize_bits) == 1))) {
-+
-+		err = ext3cow_dx_readdir(filp, dirent, filldir);
-+		if (err != ERR_BAD_DX_DIR) {
-+			ret = err;
-+			goto out;
-+		}
-+		/*
-+		 * We don't set the inode dirty flag since it's not
-+		 * critical that it get flushed back to the disk.
-+		 */
-+		EXT3COW_I(filp->f_path.dentry->d_inode)->i_flags &= ~EXT3COW_INDEX_FL;
-+	}
-+#endif
-+	stored = 0;
-+	offset = filp->f_pos & (sb->s_blocksize - 1);
-+
-+	while (!error && !stored && filp->f_pos < inode->i_size) {
-+		unsigned long blk = filp->f_pos >> EXT3COW_BLOCK_SIZE_BITS(sb);
-+		struct buffer_head map_bh;
-+		struct buffer_head *bh = NULL;
-+
-+		map_bh.b_state = 0;
-+		err = ext3cow_get_blocks_handle(NULL, inode, blk, 1,
-+						&map_bh, 0, 0);
-+		if (err > 0) {
-+			page_cache_readahead(sb->s_bdev->bd_inode->i_mapping,
-+				&filp->f_ra,
-+				filp,
-+				map_bh.b_blocknr >>
-+					(PAGE_CACHE_SHIFT - inode->i_blkbits),
-+				1);
-+			bh = ext3cow_bread(NULL, inode, blk, 0, &err);
-+		}
-+
-+		/*
-+		 * We ignore I/O errors on directories so users have a chance
-+		 * of recovering data when there's a bad sector
-+		 */
-+		if (!bh) {
-+			ext3cow_error (sb, "ext3cow_readdir",
-+				"directory #%lu contains a hole at offset %lu",
-+				inode->i_ino, (unsigned long)filp->f_pos);
-+			/* corrupt size?  Maybe no more blocks to read */
-+			if (filp->f_pos > inode->i_blocks << 9)
-+				break;
-+			filp->f_pos += sb->s_blocksize - offset;
-+			continue;
-+		}
-+
-+revalidate:
-+		/* If the dir block has changed since the last call to
-+		 * readdir(2), then we might be pointing to an invalid
-+		 * dirent right now.  Scan from the start of the block
-+		 * to make sure. */
-+		if (filp->f_version != inode->i_version) {
-+			for (i = 0; i < sb->s_blocksize && i < offset; ) {
-+				de = (struct ext3cow_dir_entry_2 *)
-+					(bh->b_data + i);
-+				/* It's too expensive to do a full
-+				 * dirent test each time round this
-+				 * loop, but we do have to test at
-+				 * least that it is non-zero.  A
-+				 * failure will be detected in the
-+				 * dirent test below. */
-+				if (le16_to_cpu(de->rec_len) <
-+						EXT3COW_DIR_REC_LEN(1))
-+					break;
-+				i += le16_to_cpu(de->rec_len);
-+			}
-+			offset = i;
-+			filp->f_pos = (filp->f_pos & ~(sb->s_blocksize - 1))
-+				| offset;
-+			filp->f_version = inode->i_version;
-+		}
-+
-+		while (!error && filp->f_pos < inode->i_size
-+		       && offset < sb->s_blocksize) {
-+			de = (struct ext3cow_dir_entry_2 *) (bh->b_data + offset);
-+			if (!ext3cow_check_dir_entry ("ext3cow_readdir", inode, de,
-+						   bh, offset)) {
-+				/* On error, skip the f_pos to the
-+                                   next block. */
-+				filp->f_pos = (filp->f_pos |
-+						(sb->s_blocksize - 1)) + 1;
-+				brelse (bh);
-+				ret = stored;
-+				goto out;
-+			}
-+			offset += le16_to_cpu(de->rec_len);
-+    /*
-+        printk("Inode %ld Epoch number %u: is 
-+        dir %d -> %s be %d de %d scoped? %d\n",
-+        dir->i_ino,
-+        EXT3COW_I_EPOCHNUMBER(dir),
-+        de->inode,
-+        de->name,
-+        de->birth_epoch,
-+        de->death_epoch,
-+        EXT3COW_IS_DIRENT_SCOPED(de, EXT3COW_I_EPOCHNUMBER(dir)));
-+      */
-+
-+      /* Only add scoped dirents - znjp */
-+			if (le32_to_cpu(de->inode)  && 
-+          EXT3COW_IS_DIRENT_SCOPED(de, EXT3COW_I_EPOCHNUMBER(inode))) {
-+				/* We might block in the next section
-+				 * if the data destination is
-+				 * currently swapped out.  So, use a
-+				 * version stamp to detect whether or
-+				 * not the directory has been modified
-+				 * during the copy operation.
-+				 */
-+				unsigned long version = filp->f_version;
-+
-+				error = filldir(dirent, de->name,
-+						de->name_len,
-+						filp->f_pos,
-+						le32_to_cpu(de->inode),
-+						get_dtype(sb, de->file_type));
-+				if (error)
-+					break;
-+				if (version != filp->f_version)
-+					goto revalidate;
-+				stored ++;
-+			}
-+			filp->f_pos += le16_to_cpu(de->rec_len);
-+		}
-+		offset = 0;
-+		brelse (bh);
-+	}
-+out:
-+	return ret;
-+}
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+/*
-+ * These functions convert from the major/minor hash to an f_pos
-+ * value.
-+ *
-+ * Currently we only use major hash numer.  This is unfortunate, but
-+ * on 32-bit machines, the same VFS interface is used for lseek and
-+ * llseek, so if we use the 64 bit offset, then the 32-bit versions of
-+ * lseek/telldir/seekdir will blow out spectacularly, and from within
-+ * the ext2 low-level routine, we don't know if we're being called by
-+ * a 64-bit version of the system call or the 32-bit version of the
-+ * system call.  Worse yet, NFSv2 only allows for a 32-bit readdir
-+ * cookie.  Sigh.
-+ */
-+#define hash2pos(major, minor)	(major >> 1)
-+#define pos2maj_hash(pos)	((pos << 1) & 0xffffffff)
-+#define pos2min_hash(pos)	(0)
-+
-+/*
-+ * This structure holds the nodes of the red-black tree used to store
-+ * the directory entry in hash order.
-+ */
-+struct fname {
-+	__u32		hash;
-+	__u32		minor_hash;
-+	struct rb_node	rb_hash;
-+	struct fname	*next;
-+	__u32		inode;
-+	__u8		name_len;
-+	__u8		file_type;
-+	char		name[0];
-+};
-+
-+/*
-+ * This functoin implements a non-recursive way of freeing all of the
-+ * nodes in the red-black tree.
-+ */
-+static void free_rb_tree_fname(struct rb_root *root)
-+{
-+	struct rb_node	*n = root->rb_node;
-+	struct rb_node	*parent;
-+	struct fname	*fname;
-+
-+	while (n) {
-+		/* Do the node's children first */
-+		if ((n)->rb_left) {
-+			n = n->rb_left;
-+			continue;
-+		}
-+		if (n->rb_right) {
-+			n = n->rb_right;
-+			continue;
-+		}
-+		/*
-+		 * The node has no children; free it, and then zero
-+		 * out parent's link to it.  Finally go to the
-+		 * beginning of the loop and try to free the parent
-+		 * node.
-+		 */
-+		parent = rb_parent(n);
-+		fname = rb_entry(n, struct fname, rb_hash);
-+		while (fname) {
-+			struct fname * old = fname;
-+			fname = fname->next;
-+			kfree (old);
-+		}
-+		if (!parent)
-+			root->rb_node = NULL;
-+		else if (parent->rb_left == n)
-+			parent->rb_left = NULL;
-+		else if (parent->rb_right == n)
-+			parent->rb_right = NULL;
-+		n = parent;
-+	}
-+	root->rb_node = NULL;
-+}
-+
-+
-+static struct dir_private_info *create_dir_info(loff_t pos)
-+{
-+	struct dir_private_info *p;
-+
-+	p = kmalloc(sizeof(struct dir_private_info), GFP_KERNEL);
-+	if (!p)
-+		return NULL;
-+	p->root.rb_node = NULL;
-+	p->curr_node = NULL;
-+	p->extra_fname = NULL;
-+	p->last_pos = 0;
-+	p->curr_hash = pos2maj_hash(pos);
-+	p->curr_minor_hash = pos2min_hash(pos);
-+	p->next_hash = 0;
-+	return p;
-+}
-+
-+void ext3cow_htree_free_dir_info(struct dir_private_info *p)
-+{
-+	free_rb_tree_fname(&p->root);
-+	kfree(p);
-+}
-+
-+/*
-+ * Given a directory entry, enter it into the fname rb tree.
-+ */
-+int ext3cow_htree_store_dirent(struct file *dir_file, __u32 hash,
-+			     __u32 minor_hash,
-+			     struct ext3cow_dir_entry_2 *dirent)
-+{
-+	struct rb_node **p, *parent = NULL;
-+	struct fname * fname, *new_fn;
-+	struct dir_private_info *info;
-+	int len;
-+
-+	info = (struct dir_private_info *) dir_file->private_data;
-+	p = &info->root.rb_node;
-+
-+	/* Create and allocate the fname structure */
-+	len = sizeof(struct fname) + dirent->name_len + 1;
-+	new_fn = kzalloc(len, GFP_KERNEL);
-+	if (!new_fn)
-+		return -ENOMEM;
-+	new_fn->hash = hash;
-+	new_fn->minor_hash = minor_hash;
-+	new_fn->inode = le32_to_cpu(dirent->inode);
-+	new_fn->name_len = dirent->name_len;
-+	new_fn->file_type = dirent->file_type;
-+	memcpy(new_fn->name, dirent->name, dirent->name_len);
-+	new_fn->name[dirent->name_len] = 0;
-+
-+	while (*p) {
-+		parent = *p;
-+		fname = rb_entry(parent, struct fname, rb_hash);
-+
-+		/*
-+		 * If the hash and minor hash match up, then we put
-+		 * them on a linked list.  This rarely happens...
-+		 */
-+		if ((new_fn->hash == fname->hash) &&
-+		    (new_fn->minor_hash == fname->minor_hash)) {
-+			new_fn->next = fname->next;
-+			fname->next = new_fn;
-+			return 0;
-+		}
-+
-+		if (new_fn->hash < fname->hash)
-+			p = &(*p)->rb_left;
-+		else if (new_fn->hash > fname->hash)
-+			p = &(*p)->rb_right;
-+		else if (new_fn->minor_hash < fname->minor_hash)
-+			p = &(*p)->rb_left;
-+		else /* if (new_fn->minor_hash > fname->minor_hash) */
-+			p = &(*p)->rb_right;
-+	}
-+
-+	rb_link_node(&new_fn->rb_hash, parent, p);
-+	rb_insert_color(&new_fn->rb_hash, &info->root);
-+	return 0;
-+}
-+
-+
-+
-+/*
-+ * This is a helper function for ext3cow_dx_readdir.  It calls filldir
-+ * for all entres on the fname linked list.  (Normally there is only
-+ * one entry on the linked list, unless there are 62 bit hash collisions.)
-+ */
-+static int call_filldir(struct file * filp, void * dirent,
-+			filldir_t filldir, struct fname *fname)
-+{
-+	struct dir_private_info *info = filp->private_data;
-+	loff_t	curr_pos;
-+	struct inode *inode = filp->f_path.dentry->d_inode;
-+	struct super_block * sb;
-+	int error;
-+
-+	sb = inode->i_sb;
-+
-+  printk(KERN_INFO, "Got %s\n", filp->f_path.dentry->d_name.name);
-+
-+	if (!fname) {
-+		printk("call_filldir: called with null fname?!?\n");
-+		return 0;
-+	}
-+	curr_pos = hash2pos(fname->hash, fname->minor_hash);
-+	while (fname) {
-+		error = filldir(dirent, fname->name,
-+				fname->name_len, curr_pos,
-+				fname->inode,
-+				get_dtype(sb, fname->file_type));
-+		if (error) {
-+			filp->f_pos = curr_pos;
-+			info->extra_fname = fname->next;
-+			return error;
-+		}
-+		fname = fname->next;
-+	}
-+	return 0;
-+}
-+
-+static int ext3cow_dx_readdir(struct file * filp,
-+			 void * dirent, filldir_t filldir)
-+{
-+	struct dir_private_info *info = filp->private_data;
-+	struct inode *inode = filp->f_path.dentry->d_inode;
-+	struct fname *fname;
-+	int	ret;
-+
-+	if (!info) {
-+		info = create_dir_info(filp->f_pos);
-+		if (!info)
-+			return -ENOMEM;
-+		filp->private_data = info;
-+	}
-+
-+	if (filp->f_pos == EXT3COW_HTREE_EOF)
-+		return 0;	/* EOF */
-+
-+	/* Some one has messed with f_pos; reset the world */
-+	if (info->last_pos != filp->f_pos) {
-+		free_rb_tree_fname(&info->root);
-+		info->curr_node = NULL;
-+		info->extra_fname = NULL;
-+		info->curr_hash = pos2maj_hash(filp->f_pos);
-+		info->curr_minor_hash = pos2min_hash(filp->f_pos);
-+	}
-+
-+	/*
-+	 * If there are any leftover names on the hash collision
-+	 * chain, return them first.
-+	 */
-+	if (info->extra_fname &&
-+	    call_filldir(filp, dirent, filldir, info->extra_fname))
-+		goto finished;
-+
-+	if (!info->curr_node)
-+		info->curr_node = rb_first(&info->root);
-+
-+	while (1) {
-+		/*
-+		 * Fill the rbtree if we have no more entries,
-+		 * or the inode has changed since we last read in the
-+		 * cached entries.
-+		 */
-+		if ((!info->curr_node) ||
-+		    (filp->f_version != inode->i_version)) {
-+			info->curr_node = NULL;
-+			free_rb_tree_fname(&info->root);
-+			filp->f_version = inode->i_version;
-+			ret = ext3cow_htree_fill_tree(filp, info->curr_hash,
-+						   info->curr_minor_hash,
-+						   &info->next_hash);
-+			if (ret < 0)
-+				return ret;
-+			if (ret == 0) {
-+				filp->f_pos = EXT3COW_HTREE_EOF;
-+				break;
-+			}
-+			info->curr_node = rb_first(&info->root);
-+		}
-+
-+		fname = rb_entry(info->curr_node, struct fname, rb_hash);
-+		info->curr_hash = fname->hash;
-+		info->curr_minor_hash = fname->minor_hash;
-+		if (call_filldir(filp, dirent, filldir, fname))
-+			break;
-+
-+		info->curr_node = rb_next(info->curr_node);
-+		if (!info->curr_node) {
-+			if (info->next_hash == ~0) {
-+				filp->f_pos = EXT3COW_HTREE_EOF;
-+				break;
-+			}
-+			info->curr_hash = info->next_hash;
-+			info->curr_minor_hash = 0;
-+		}
-+	}
-+finished:
-+	info->last_pos = filp->f_pos;
-+	return 0;
-+}
-+
-+static int ext3cow_release_dir (struct inode * inode, struct file * filp)
-+{
-+       if (filp->private_data)
-+		ext3cow_htree_free_dir_info(filp->private_data);
-+
-+	return 0;
-+}
-+
-+#endif
-diff -Naur linux-2.6.21.7/fs/ext3cow/ext3cow_jbd.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/ext3cow_jbd.c
---- linux-2.6.21.7/fs/ext3cow/ext3cow_jbd.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/ext3cow_jbd.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,59 @@
-+/*
-+ * Interface between ext3cow and JBD
-+ */
-+
-+#include <linux/ext3cow_jbd.h>
-+
-+int __ext3cow_journal_get_undo_access(const char *where, handle_t *handle,
-+				struct buffer_head *bh)
-+{
-+	int err = journal_get_undo_access(handle, bh);
-+	if (err)
-+		ext3cow_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-+	return err;
-+}
-+
-+int __ext3cow_journal_get_write_access(const char *where, handle_t *handle,
-+				struct buffer_head *bh)
-+{
-+	int err = journal_get_write_access(handle, bh);
-+	if (err)
-+		ext3cow_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-+	return err;
-+}
-+
-+int __ext3cow_journal_forget(const char *where, handle_t *handle,
-+				struct buffer_head *bh)
-+{
-+	int err = journal_forget(handle, bh);
-+	if (err)
-+		ext3cow_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-+	return err;
-+}
-+
-+int __ext3cow_journal_revoke(const char *where, handle_t *handle,
-+				unsigned long blocknr, struct buffer_head *bh)
-+{
-+	int err = journal_revoke(handle, blocknr, bh);
-+	if (err)
-+		ext3cow_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-+	return err;
-+}
-+
-+int __ext3cow_journal_get_create_access(const char *where,
-+				handle_t *handle, struct buffer_head *bh)
-+{
-+	int err = journal_get_create_access(handle, bh);
-+	if (err)
-+		ext3cow_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-+	return err;
-+}
-+
-+int __ext3cow_journal_dirty_metadata(const char *where,
-+				handle_t *handle, struct buffer_head *bh)
-+{
-+	int err = journal_dirty_metadata(handle, bh);
-+	if (err)
-+		ext3cow_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
-+	return err;
-+}
-diff -Naur linux-2.6.21.7/fs/ext3cow/file.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/file.c
---- linux-2.6.21.7/fs/ext3cow/file.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/file.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,147 @@
-+/*
-+ *  linux/fs/ext3cow/file.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/fs/minix/file.c
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ *
-+ *  ext3cow fs regular file handling primitives
-+ *
-+ *  64-bit file support on 64-bit platforms by Jakub Jelinek
-+ *	(jj@sunsite.ms.mff.cuni.cz)
-+ */
-+
-+#include <linux/time.h>
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/ext3cow_jbd.h>
-+#include "xattr.h"
-+#include "acl.h"
-+
-+/*
-+ * Called when an inode is released. Note that this is different
-+ * from ext3cow_file_open: open gets called at every open, but release
-+ * gets called only when /all/ the files are closed.
-+ */
-+static int ext3cow_release_file (struct inode * inode, struct file * filp)
-+{
-+	/* if we are the last writer on the inode, drop the block reservation */
-+	if ((filp->f_mode & FMODE_WRITE) &&
-+			(atomic_read(&inode->i_writecount) == 1))
-+	{
-+		mutex_lock(&EXT3COW_I(inode)->truncate_mutex);
-+		ext3cow_discard_reservation(inode);
-+		mutex_unlock(&EXT3COW_I(inode)->truncate_mutex);
-+	}
-+	if (is_dx(inode) && filp->private_data)
-+		ext3cow_htree_free_dir_info(filp->private_data);
-+
-+	return 0;
-+}
-+
-+static ssize_t
-+ext3cow_file_write(struct kiocb *iocb, const struct iovec *iov,
-+		unsigned long nr_segs, loff_t pos)
-+{
-+	struct file *file = iocb->ki_filp;
-+	struct inode *inode = file->f_path.dentry->d_inode;
-+  struct inode *dir   = file->f_path.dentry->d_parent->d_inode;
-+	ssize_t ret = 0;
-+	int err = 0;
-+  
-+  /* This is the place where we create a new version on write -znjp */
-+  if(EXT3COW_S_EPOCHNUMBER(inode->i_sb) > EXT3COW_I_EPOCHNUMBER(inode)){
-+    err = ext3cow_dup_inode(dir, inode);
-+    if(err)
-+      return err;
-+  }
-+
-+	ret = generic_file_aio_write(iocb, iov, nr_segs, pos);
-+
-+	/*
-+	 * Skip flushing if there was an error, or if nothing was written.
-+	 */
-+	if (ret <= 0)
-+		return ret;
-+
-+	/*
-+	 * If the inode is IS_SYNC, or is O_SYNC and we are doing data
-+	 * journalling then we need to make sure that we force the transaction
-+	 * to disk to keep all metadata uptodate synchronously.
-+	 */
-+	if (file->f_flags & O_SYNC) {
-+		/*
-+		 * If we are non-data-journaled, then the dirty data has
-+		 * already been flushed to backing store by generic_osync_inode,
-+		 * and the inode has been flushed too if there have been any
-+		 * modifications other than mere timestamp updates.
-+		 *
-+		 * Open question --- do we care about flushing timestamps too
-+		 * if the inode is IS_SYNC?
-+		 */
-+		if (!ext3cow_should_journal_data(inode))
-+			return ret;
-+
-+		goto force_commit;
-+	}
-+
-+	/*
-+	 * So we know that there has been no forced data flush.  If the inode
-+	 * is marked IS_SYNC, we need to force one ourselves.
-+	 */
-+	if (!IS_SYNC(inode))
-+		return ret;
-+
-+	/*
-+	 * Open question #2 --- should we force data to disk here too?  If we
-+	 * don't, the only impact is that data=writeback filesystems won't
-+	 * flush data to disk automatically on IS_SYNC, only metadata (but
-+	 * historically, that is what ext2 has done.)
-+	 */
-+
-+force_commit:
-+	err = ext3cow_force_commit(inode->i_sb);
-+	if (err)
-+		return err;
-+	return ret;
-+}
-+
-+const struct file_operations ext3cow_file_operations = {
-+	.llseek		= generic_file_llseek,
-+	.read		= do_sync_read,
-+	.write		= do_sync_write,
-+	.aio_read	= generic_file_aio_read,
-+	.aio_write	= ext3cow_file_write,
-+	.ioctl		= ext3cow_ioctl,
-+#ifdef CONFIG_COMPAT
-+	.compat_ioctl	= ext3cow_compat_ioctl,
-+#endif
-+	.mmap		= generic_file_mmap,
-+	.open		= generic_file_open,
-+	.release	= ext3cow_release_file,
-+	.fsync		= ext3cow_sync_file,
-+	.sendfile	= generic_file_sendfile,
-+	.splice_read	= generic_file_splice_read,
-+	.splice_write	= generic_file_splice_write,
-+};
-+
-+struct inode_operations ext3cow_file_inode_operations = {
-+	.truncate	= ext3cow_truncate,
-+	.setattr	= ext3cow_setattr,
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+	.setxattr	= generic_setxattr,
-+	.getxattr	= generic_getxattr,
-+	.listxattr	= ext3cow_listxattr,
-+	.removexattr	= generic_removexattr,
-+#endif
-+	.permission	= ext3cow_permission,
-+};
-+
-diff -Naur linux-2.6.21.7/fs/ext3cow/fsync.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/fsync.c
---- linux-2.6.21.7/fs/ext3cow/fsync.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/fsync.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,88 @@
-+/*
-+ *  linux/fs/ext3cow/fsync.c
-+ *
-+ *  Copyright (C) 1993  Stephen Tweedie (sct@redhat.com)
-+ *  from
-+ *  Copyright (C) 1992  Remy Card (card@masi.ibp.fr)
-+ *                      Laboratoire MASI - Institut Blaise Pascal
-+ *                      Universite Pierre et Marie Curie (Paris VI)
-+ *  from
-+ *  linux/fs/minix/truncate.c   Copyright (C) 1991, 1992  Linus Torvalds
-+ *
-+ *  ext3cowfs fsync primitive
-+ *
-+ *  Big-endian to little-endian byte-swapping/bitmaps by
-+ *        David S. Miller (davem@caip.rutgers.edu), 1995
-+ *
-+ *  Removed unnecessary code duplication for little endian machines
-+ *  and excessive __inline__s.
-+ *        Andi Kleen, 1997
-+ *
-+ * Major simplications and cleanup - we only need to do the metadata, because
-+ * we can depend on generic_block_fdatasync() to sync the data blocks.
-+ */
-+
-+#include <linux/time.h>
-+#include <linux/fs.h>
-+#include <linux/sched.h>
-+#include <linux/writeback.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/ext3cow_jbd.h>
-+
-+/*
-+ * akpm: A new design for ext3cow_sync_file().
-+ *
-+ * This is only called from sys_fsync(), sys_fdatasync() and sys_msync().
-+ * There cannot be a transaction open by this task.
-+ * Another task could have dirtied this inode.  Its data can be in any
-+ * state in the journalling system.
-+ *
-+ * What we do is just kick off a commit and wait on it.  This will snapshot the
-+ * inode to disk.
-+ */
-+
-+int ext3cow_sync_file(struct file * file, struct dentry *dentry, int datasync)
-+{
-+	struct inode *inode = dentry->d_inode;
-+	int ret = 0;
-+
-+	J_ASSERT(ext3cow_journal_current_handle() == 0);
-+
-+	/*
-+	 * data=writeback:
-+	 *  The caller's filemap_fdatawrite()/wait will sync the data.
-+	 *  sync_inode() will sync the metadata
-+	 *
-+	 * data=ordered:
-+	 *  The caller's filemap_fdatawrite() will write the data and
-+	 *  sync_inode() will write the inode if it is dirty.  Then the caller's
-+	 *  filemap_fdatawait() will wait on the pages.
-+	 *
-+	 * data=journal:
-+	 *  filemap_fdatawrite won't do anything (the buffers are clean).
-+	 *  ext3cow_force_commit will write the file data into the journal and
-+	 *  will wait on that.
-+	 *  filemap_fdatawait() will encounter a ton of newly-dirtied pages
-+	 *  (they were dirtied by commit).  But that's OK - the blocks are
-+	 *  safe in-journal, which is all fsync() needs to ensure.
-+	 */
-+	if (ext3cow_should_journal_data(inode)) {
-+		ret = ext3cow_force_commit(inode->i_sb);
-+		goto out;
-+	}
-+
-+	/*
-+	 * The VFS has written the file data.  If the inode is unaltered
-+	 * then we need not start a commit.
-+	 */
-+	if (inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC)) {
-+		struct writeback_control wbc = {
-+			.sync_mode = WB_SYNC_ALL,
-+			.nr_to_write = 0, /* sys_fsync did this */
-+		};
-+		ret = sync_inode(inode, &wbc);
-+	}
-+out:
-+	return ret;
-+}
-diff -Naur linux-2.6.21.7/fs/ext3cow/hash.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/hash.c
---- linux-2.6.21.7/fs/ext3cow/hash.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/hash.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,152 @@
-+/*
-+ *  linux/fs/ext3cow/hash.c
-+ *
-+ * Copyright (C) 2002 by Theodore Ts'o
-+ *
-+ * This file is released under the GPL v2.
-+ *
-+ * This file may be redistributed under the terms of the GNU Public
-+ * License.
-+ */
-+
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/sched.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/cryptohash.h>
-+
-+#define DELTA 0x9E3779B9
-+
-+static void TEA_transform(__u32 buf[4], __u32 const in[])
-+{
-+	__u32	sum = 0;
-+	__u32	b0 = buf[0], b1 = buf[1];
-+	__u32	a = in[0], b = in[1], c = in[2], d = in[3];
-+	int	n = 16;
-+
-+	do {
-+		sum += DELTA;
-+		b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b);
-+		b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d);
-+	} while(--n);
-+
-+	buf[0] += b0;
-+	buf[1] += b1;
-+}
-+
-+
-+/* The old legacy hash */
-+static __u32 dx_hack_hash (const char *name, int len)
-+{
-+	__u32 hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9;
-+	while (len--) {
-+		__u32 hash = hash1 + (hash0 ^ (*name++ * 7152373));
-+
-+		if (hash & 0x80000000) hash -= 0x7fffffff;
-+		hash1 = hash0;
-+		hash0 = hash;
-+	}
-+	return (hash0 << 1);
-+}
-+
-+static void str2hashbuf(const char *msg, int len, __u32 *buf, int num)
-+{
-+	__u32	pad, val;
-+	int	i;
-+
-+	pad = (__u32)len | ((__u32)len << 8);
-+	pad |= pad << 16;
-+
-+	val = pad;
-+	if (len > num*4)
-+		len = num * 4;
-+	for (i=0; i < len; i++) {
-+		if ((i % 4) == 0)
-+			val = pad;
-+		val = msg[i] + (val << 8);
-+		if ((i % 4) == 3) {
-+			*buf++ = val;
-+			val = pad;
-+			num--;
-+		}
-+	}
-+	if (--num >= 0)
-+		*buf++ = val;
-+	while (--num >= 0)
-+		*buf++ = pad;
-+}
-+
-+/*
-+ * Returns the hash of a filename.  If len is 0 and name is NULL, then
-+ * this function can be used to test whether or not a hash version is
-+ * supported.
-+ *
-+ * The seed is an 4 longword (32 bits) "secret" which can be used to
-+ * uniquify a hash.  If the seed is all zero's, then some default seed
-+ * may be used.
-+ *
-+ * A particular hash version specifies whether or not the seed is
-+ * represented, and whether or not the returned hash is 32 bits or 64
-+ * bits.  32 bit hashes will return 0 for the minor hash.
-+ */
-+int ext3cowfs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
-+{
-+	__u32	hash;
-+	__u32	minor_hash = 0;
-+	const char	*p;
-+	int		i;
-+	__u32		in[8], buf[4];
-+
-+	/* Initialize the default seed for the hash checksum functions */
-+	buf[0] = 0x67452301;
-+	buf[1] = 0xefcdab89;
-+	buf[2] = 0x98badcfe;
-+	buf[3] = 0x10325476;
-+
-+	/* Check to see if the seed is all zero's */
-+	if (hinfo->seed) {
-+		for (i=0; i < 4; i++) {
-+			if (hinfo->seed[i])
-+				break;
-+		}
-+		if (i < 4)
-+			memcpy(buf, hinfo->seed, sizeof(buf));
-+	}
-+
-+	switch (hinfo->hash_version) {
-+	case DX_HASH_LEGACY:
-+		hash = dx_hack_hash(name, len);
-+		break;
-+	case DX_HASH_HALF_MD4:
-+		p = name;
-+		while (len > 0) {
-+			str2hashbuf(p, len, in, 8);
-+			half_md4_transform(buf, in);
-+			len -= 32;
-+			p += 32;
-+		}
-+		minor_hash = buf[2];
-+		hash = buf[1];
-+		break;
-+	case DX_HASH_TEA:
-+		p = name;
-+		while (len > 0) {
-+			str2hashbuf(p, len, in, 4);
-+			TEA_transform(buf, in);
-+			len -= 16;
-+			p += 16;
-+		}
-+		hash = buf[0];
-+		minor_hash = buf[1];
-+		break;
-+	default:
-+		hinfo->hash = 0;
-+		return -1;
-+	}
-+	hash = hash & ~1;
-+	if (hash == (EXT3COW_HTREE_EOF << 1))
-+		hash = (EXT3COW_HTREE_EOF-1) << 1;
-+	hinfo->hash = hash;
-+	hinfo->minor_hash = minor_hash;
-+	return 0;
-+}
-diff -Naur linux-2.6.21.7/fs/ext3cow/ialloc.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/ialloc.c
---- linux-2.6.21.7/fs/ext3cow/ialloc.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/ialloc.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,764 @@
-+/*
-+ *  linux/fs/ext3cow/ialloc.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  BSD ufs-inspired inode and directory allocation by
-+ *  Stephen Tweedie (sct@redhat.com), 1993
-+ *  Big-endian to little-endian byte-swapping/bitmaps by
-+ *        David S. Miller (davem@caip.rutgers.edu), 1995
-+ */
-+
-+#include <linux/time.h>
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/stat.h>
-+#include <linux/string.h>
-+#include <linux/quotaops.h>
-+#include <linux/buffer_head.h>
-+#include <linux/random.h>
-+#include <linux/bitops.h>
-+
-+#include <asm/byteorder.h>
-+
-+#include "xattr.h"
-+#include "acl.h"
-+
-+/*
-+ * ialloc.c contains the inodes allocation and deallocation routines
-+ */
-+
-+/*
-+ * The free inodes are managed by bitmaps.  A file system contains several
-+ * blocks groups.  Each group contains 1 bitmap block for blocks, 1 bitmap
-+ * block for inodes, N blocks for the inode table and data blocks.
-+ *
-+ * The file system contains group descriptors which are located after the
-+ * super block.  Each descriptor contains the number of the bitmap block and
-+ * the free blocks count in the block.
-+ */
-+
-+
-+/*
-+ * Read the inode allocation bitmap for a given block_group, reading
-+ * into the specified slot in the superblock's bitmap cache.
-+ *
-+ * Return buffer_head of bitmap on success or NULL.
-+ */
-+static struct buffer_head *
-+read_inode_bitmap(struct super_block * sb, unsigned long block_group)
-+{
-+	struct ext3cow_group_desc *desc;
-+	struct buffer_head *bh = NULL;
-+
-+	desc = ext3cow_get_group_desc(sb, block_group, NULL);
-+	if (!desc)
-+		goto error_out;
-+
-+	bh = sb_bread(sb, le32_to_cpu(desc->bg_inode_bitmap));
-+	if (!bh)
-+		ext3cow_error(sb, "read_inode_bitmap",
-+			    "Cannot read inode bitmap - "
-+			    "block_group = %lu, inode_bitmap = %u",
-+			    block_group, le32_to_cpu(desc->bg_inode_bitmap));
-+error_out:
-+	return bh;
-+}
-+
-+/*
-+ * NOTE! When we get the inode, we're the only people
-+ * that have access to it, and as such there are no
-+ * race conditions we have to worry about. The inode
-+ * is not on the hash-lists, and it cannot be reached
-+ * through the filesystem because the directory entry
-+ * has been deleted earlier.
-+ *
-+ * HOWEVER: we must make sure that we get no aliases,
-+ * which means that we have to call "clear_inode()"
-+ * _before_ we mark the inode not in use in the inode
-+ * bitmaps. Otherwise a newly created file might use
-+ * the same inode number (not actually the same pointer
-+ * though), and then we'd have two inodes sharing the
-+ * same inode number and space on the harddisk.
-+ */
-+void ext3cow_free_inode (handle_t *handle, struct inode * inode)
-+{
-+	struct super_block * sb = inode->i_sb;
-+	int is_directory;
-+	unsigned long ino;
-+	struct buffer_head *bitmap_bh = NULL;
-+	struct buffer_head *bh2;
-+	unsigned long block_group;
-+	unsigned long bit;
-+	struct ext3cow_group_desc * gdp;
-+	struct ext3cow_super_block * es;
-+	struct ext3cow_sb_info *sbi;
-+	int fatal = 0, err;
-+
-+	if (atomic_read(&inode->i_count) > 1) {
-+		printk ("ext3cow_free_inode: inode has count=%d\n",
-+					atomic_read(&inode->i_count));
-+		return;
-+	}
-+	if (inode->i_nlink) {
-+		printk ("ext3cow_free_inode: inode has nlink=%d\n",
-+			inode->i_nlink);
-+		return;
-+	}
-+	if (!sb) {
-+		printk("ext3cow_free_inode: inode on nonexistent device\n");
-+		return;
-+	}
-+	sbi = EXT3COW_SB(sb);
-+
-+	ino = inode->i_ino;
-+	ext3cow_debug ("freeing inode %lu\n", ino);
-+
-+	/*
-+	 * Note: we must free any quota before locking the superblock,
-+	 * as writing the quota to disk may need the lock as well.
-+	 */
-+	DQUOT_INIT(inode);
-+	ext3cow_xattr_delete_inode(handle, inode);
-+	DQUOT_FREE_INODE(inode);
-+	DQUOT_DROP(inode);
-+
-+	is_directory = S_ISDIR(inode->i_mode);
-+
-+	/* Do this BEFORE marking the inode not in use or returning an error */
-+	clear_inode (inode);
-+
-+	es = EXT3COW_SB(sb)->s_es;
-+	if (ino < EXT3COW_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
-+		ext3cow_error (sb, "ext3cow_free_inode",
-+			    "reserved or nonexistent inode %lu", ino);
-+		goto error_return;
-+	}
-+	block_group = (ino - 1) / EXT3COW_INODES_PER_GROUP(sb);
-+	bit = (ino - 1) % EXT3COW_INODES_PER_GROUP(sb);
-+	bitmap_bh = read_inode_bitmap(sb, block_group);
-+	if (!bitmap_bh)
-+		goto error_return;
-+
-+	BUFFER_TRACE(bitmap_bh, "get_write_access");
-+	fatal = ext3cow_journal_get_write_access(handle, bitmap_bh);
-+	if (fatal)
-+		goto error_return;
-+
-+	/* Ok, now we can actually update the inode bitmaps.. */
-+	if (!ext3cow_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
-+					bit, bitmap_bh->b_data))
-+		ext3cow_error (sb, "ext3cow_free_inode",
-+			      "bit already cleared for inode %lu", ino);
-+	else {
-+		gdp = ext3cow_get_group_desc (sb, block_group, &bh2);
-+
-+		BUFFER_TRACE(bh2, "get_write_access");
-+		fatal = ext3cow_journal_get_write_access(handle, bh2);
-+		if (fatal) goto error_return;
-+
-+		if (gdp) {
-+			spin_lock(sb_bgl_lock(sbi, block_group));
-+			gdp->bg_free_inodes_count = cpu_to_le16(
-+				le16_to_cpu(gdp->bg_free_inodes_count) + 1);
-+			if (is_directory)
-+				gdp->bg_used_dirs_count = cpu_to_le16(
-+				  le16_to_cpu(gdp->bg_used_dirs_count) - 1);
-+			spin_unlock(sb_bgl_lock(sbi, block_group));
-+			percpu_counter_inc(&sbi->s_freeinodes_counter);
-+			if (is_directory)
-+				percpu_counter_dec(&sbi->s_dirs_counter);
-+
-+		}
-+		BUFFER_TRACE(bh2, "call ext3cow_journal_dirty_metadata");
-+		err = ext3cow_journal_dirty_metadata(handle, bh2);
-+		if (!fatal) fatal = err;
-+	}
-+	BUFFER_TRACE(bitmap_bh, "call ext3cow_journal_dirty_metadata");
-+	err = ext3cow_journal_dirty_metadata(handle, bitmap_bh);
-+	if (!fatal)
-+		fatal = err;
-+	sb->s_dirt = 1;
-+error_return:
-+	brelse(bitmap_bh);
-+	ext3cow_std_error(sb, fatal);
-+}
-+
-+/*
-+ * There are two policies for allocating an inode.  If the new inode is
-+ * a directory, then a forward search is made for a block group with both
-+ * free space and a low directory-to-inode ratio; if that fails, then of
-+ * the groups with above-average free space, that group with the fewest
-+ * directories already is chosen.
-+ *
-+ * For other inodes, search forward from the parent directory\'s block
-+ * group to find a free inode.
-+ */
-+static int find_group_dir(struct super_block *sb, struct inode *parent)
-+{
-+	int ngroups = EXT3COW_SB(sb)->s_groups_count;
-+	unsigned int freei, avefreei;
-+	struct ext3cow_group_desc *desc, *best_desc = NULL;
-+	struct buffer_head *bh;
-+	int group, best_group = -1;
-+
-+	freei = percpu_counter_read_positive(&EXT3COW_SB(sb)->s_freeinodes_counter);
-+	avefreei = freei / ngroups;
-+
-+	for (group = 0; group < ngroups; group++) {
-+		desc = ext3cow_get_group_desc (sb, group, &bh);
-+		if (!desc || !desc->bg_free_inodes_count)
-+			continue;
-+		if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
-+			continue;
-+		if (!best_desc ||
-+		    (le16_to_cpu(desc->bg_free_blocks_count) >
-+		     le16_to_cpu(best_desc->bg_free_blocks_count))) {
-+			best_group = group;
-+			best_desc = desc;
-+		}
-+	}
-+	return best_group;
-+}
-+
-+/*
-+ * Orlov's allocator for directories.
-+ *
-+ * We always try to spread first-level directories.
-+ *
-+ * If there are blockgroups with both free inodes and free blocks counts
-+ * not worse than average we return one with smallest directory count.
-+ * Otherwise we simply return a random group.
-+ *
-+ * For the rest rules look so:
-+ *
-+ * It's OK to put directory into a group unless
-+ * it has too many directories already (max_dirs) or
-+ * it has too few free inodes left (min_inodes) or
-+ * it has too few free blocks left (min_blocks) or
-+ * it's already running too large debt (max_debt).
-+ * Parent's group is prefered, if it doesn't satisfy these
-+ * conditions we search cyclically through the rest. If none
-+ * of the groups look good we just look for a group with more
-+ * free inodes than average (starting at parent's group).
-+ *
-+ * Debt is incremented each time we allocate a directory and decremented
-+ * when we allocate an inode, within 0--255.
-+ */
-+
-+#define INODE_COST 64
-+#define BLOCK_COST 256
-+
-+static int find_group_orlov(struct super_block *sb, struct inode *parent)
-+{
-+	int parent_group = EXT3COW_I(parent)->i_block_group;
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	struct ext3cow_super_block *es = sbi->s_es;
-+	int ngroups = sbi->s_groups_count;
-+	int inodes_per_group = EXT3COW_INODES_PER_GROUP(sb);
-+	unsigned int freei, avefreei;
-+	ext3cow_fsblk_t freeb, avefreeb;
-+	ext3cow_fsblk_t blocks_per_dir;
-+	unsigned int ndirs;
-+	int max_debt, max_dirs, min_inodes;
-+	ext3cow_grpblk_t min_blocks;
-+	int group = -1, i;
-+	struct ext3cow_group_desc *desc;
-+	struct buffer_head *bh;
-+
-+	freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
-+	avefreei = freei / ngroups;
-+	freeb = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
-+	avefreeb = freeb / ngroups;
-+	ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);
-+
-+	if ((parent == sb->s_root->d_inode) ||
-+	    (EXT3COW_I(parent)->i_flags & EXT3COW_TOPDIR_FL)) {
-+		int best_ndir = inodes_per_group;
-+		int best_group = -1;
-+
-+		get_random_bytes(&group, sizeof(group));
-+		parent_group = (unsigned)group % ngroups;
-+		for (i = 0; i < ngroups; i++) {
-+			group = (parent_group + i) % ngroups;
-+			desc = ext3cow_get_group_desc (sb, group, &bh);
-+			if (!desc || !desc->bg_free_inodes_count)
-+				continue;
-+			if (le16_to_cpu(desc->bg_used_dirs_count) >= best_ndir)
-+				continue;
-+			if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
-+				continue;
-+			if (le16_to_cpu(desc->bg_free_blocks_count) < avefreeb)
-+				continue;
-+			best_group = group;
-+			best_ndir = le16_to_cpu(desc->bg_used_dirs_count);
-+		}
-+		if (best_group >= 0)
-+			return best_group;
-+		goto fallback;
-+	}
-+
-+	blocks_per_dir = (le32_to_cpu(es->s_blocks_count) - freeb) / ndirs;
-+
-+	max_dirs = ndirs / ngroups + inodes_per_group / 16;
-+	min_inodes = avefreei - inodes_per_group / 4;
-+	min_blocks = avefreeb - EXT3COW_BLOCKS_PER_GROUP(sb) / 4;
-+
-+	max_debt = EXT3COW_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, (ext3cow_fsblk_t)BLOCK_COST);
-+	if (max_debt * INODE_COST > inodes_per_group)
-+		max_debt = inodes_per_group / INODE_COST;
-+	if (max_debt > 255)
-+		max_debt = 255;
-+	if (max_debt == 0)
-+		max_debt = 1;
-+
-+	for (i = 0; i < ngroups; i++) {
-+		group = (parent_group + i) % ngroups;
-+		desc = ext3cow_get_group_desc (sb, group, &bh);
-+		if (!desc || !desc->bg_free_inodes_count)
-+			continue;
-+		if (le16_to_cpu(desc->bg_used_dirs_count) >= max_dirs)
-+			continue;
-+		if (le16_to_cpu(desc->bg_free_inodes_count) < min_inodes)
-+			continue;
-+		if (le16_to_cpu(desc->bg_free_blocks_count) < min_blocks)
-+			continue;
-+		return group;
-+	}
-+
-+fallback:
-+	for (i = 0; i < ngroups; i++) {
-+		group = (parent_group + i) % ngroups;
-+		desc = ext3cow_get_group_desc (sb, group, &bh);
-+		if (!desc || !desc->bg_free_inodes_count)
-+			continue;
-+		if (le16_to_cpu(desc->bg_free_inodes_count) >= avefreei)
-+			return group;
-+	}
-+
-+	if (avefreei) {
-+		/*
-+		 * The free-inodes counter is approximate, and for really small
-+		 * filesystems the above test can fail to find any blockgroups
-+		 */
-+		avefreei = 0;
-+		goto fallback;
-+	}
-+
-+	return -1;
-+}
-+
-+static int find_group_other(struct super_block *sb, struct inode *parent)
-+{
-+	int parent_group = EXT3COW_I(parent)->i_block_group;
-+	int ngroups = EXT3COW_SB(sb)->s_groups_count;
-+	struct ext3cow_group_desc *desc;
-+	struct buffer_head *bh;
-+	int group, i;
-+
-+	/*
-+	 * Try to place the inode in its parent directory
-+	 */
-+	group = parent_group;
-+	desc = ext3cow_get_group_desc (sb, group, &bh);
-+	if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
-+			le16_to_cpu(desc->bg_free_blocks_count))
-+		return group;
-+
-+	/*
-+	 * We're going to place this inode in a different blockgroup from its
-+	 * parent.  We want to cause files in a common directory to all land in
-+	 * the same blockgroup.  But we want files which are in a different
-+	 * directory which shares a blockgroup with our parent to land in a
-+	 * different blockgroup.
-+	 *
-+	 * So add our directory's i_ino into the starting point for the hash.
-+	 */
-+	group = (group + parent->i_ino) % ngroups;
-+
-+	/*
-+	 * Use a quadratic hash to find a group with a free inode and some free
-+	 * blocks.
-+	 */
-+	for (i = 1; i < ngroups; i <<= 1) {
-+		group += i;
-+		if (group >= ngroups)
-+			group -= ngroups;
-+		desc = ext3cow_get_group_desc (sb, group, &bh);
-+		if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
-+				le16_to_cpu(desc->bg_free_blocks_count))
-+			return group;
-+	}
-+
-+	/*
-+	 * That failed: try linear search for a free inode, even if that group
-+	 * has no free blocks.
-+	 */
-+	group = parent_group;
-+	for (i = 0; i < ngroups; i++) {
-+		if (++group >= ngroups)
-+			group = 0;
-+		desc = ext3cow_get_group_desc (sb, group, &bh);
-+		if (desc && le16_to_cpu(desc->bg_free_inodes_count))
-+			return group;
-+	}
-+
-+	return -1;
-+}
-+
-+/*
-+ * There are two policies for allocating an inode.  If the new inode is
-+ * a directory, then a forward search is made for a block group with both
-+ * free space and a low directory-to-inode ratio; if that fails, then of
-+ * the groups with above-average free space, that group with the fewest
-+ * directories already is chosen.
-+ *
-+ * For other inodes, search forward from the parent directory's block
-+ * group to find a free inode.
-+ */
-+struct inode *ext3cow_new_inode(handle_t *handle, struct inode * dir, int mode)
-+{
-+	struct super_block *sb;
-+	struct buffer_head *bitmap_bh = NULL;
-+	struct buffer_head *bh2;
-+	int group;
-+	unsigned long ino = 0;
-+	struct inode * inode;
-+	struct ext3cow_group_desc * gdp = NULL;
-+	struct ext3cow_super_block * es;
-+	struct ext3cow_inode_info *ei;
-+	struct ext3cow_sb_info *sbi;
-+	int err = 0;
-+	struct inode *ret;
-+	int i;
-+
-+	/* Cannot create files in a deleted directory */
-+	if (!dir || !dir->i_nlink)
-+		return ERR_PTR(-EPERM);
-+
-+	sb = dir->i_sb;
-+	inode = new_inode(sb);
-+	if (!inode)
-+		return ERR_PTR(-ENOMEM);
-+	ei = EXT3COW_I(inode);
-+
-+	sbi = EXT3COW_SB(sb);
-+	es = sbi->s_es;
-+	if (S_ISDIR(mode)) {
-+		if (test_opt (sb, OLDALLOC))
-+			group = find_group_dir(sb, dir);
-+		else
-+			group = find_group_orlov(sb, dir);
-+	} else
-+		group = find_group_other(sb, dir);
-+
-+	err = -ENOSPC;
-+	if (group == -1)
-+		goto out;
-+
-+	for (i = 0; i < sbi->s_groups_count; i++) {
-+		err = -EIO;
-+
-+		gdp = ext3cow_get_group_desc(sb, group, &bh2);
-+		if (!gdp)
-+			goto fail;
-+
-+		brelse(bitmap_bh);
-+		bitmap_bh = read_inode_bitmap(sb, group);
-+		if (!bitmap_bh)
-+			goto fail;
-+
-+		ino = 0;
-+
-+repeat_in_this_group:
-+		ino = ext3cow_find_next_zero_bit((unsigned long *)
-+				bitmap_bh->b_data, EXT3COW_INODES_PER_GROUP(sb), ino);
-+		if (ino < EXT3COW_INODES_PER_GROUP(sb)) {
-+
-+			BUFFER_TRACE(bitmap_bh, "get_write_access");
-+			err = ext3cow_journal_get_write_access(handle, bitmap_bh);
-+			if (err)
-+				goto fail;
-+
-+			if (!ext3cow_set_bit_atomic(sb_bgl_lock(sbi, group),
-+						ino, bitmap_bh->b_data)) {
-+				/* we won it */
-+				BUFFER_TRACE(bitmap_bh,
-+					"call ext3cow_journal_dirty_metadata");
-+				err = ext3cow_journal_dirty_metadata(handle,
-+								bitmap_bh);
-+				if (err)
-+					goto fail;
-+				goto got;
-+			}
-+			/* we lost it */
-+			journal_release_buffer(handle, bitmap_bh);
-+
-+			if (++ino < EXT3COW_INODES_PER_GROUP(sb))
-+				goto repeat_in_this_group;
-+		}
-+
-+		/*
-+		 * This case is possible in concurrent environment.  It is very
-+		 * rare.  We cannot repeat the find_group_xxx() call because
-+		 * that will simply return the same blockgroup, because the
-+		 * group descriptor metadata has not yet been updated.
-+		 * So we just go onto the next blockgroup.
-+		 */
-+		if (++group == sbi->s_groups_count)
-+			group = 0;
-+	}
-+	err = -ENOSPC;
-+	goto out;
-+
-+got:
-+	ino += group * EXT3COW_INODES_PER_GROUP(sb) + 1;
-+	if (ino < EXT3COW_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
-+		ext3cow_error (sb, "ext3cow_new_inode",
-+			    "reserved inode or inode > inodes count - "
-+			    "block_group = %d, inode=%lu", group, ino);
-+		err = -EIO;
-+		goto fail;
-+	}
-+
-+	BUFFER_TRACE(bh2, "get_write_access");
-+	err = ext3cow_journal_get_write_access(handle, bh2);
-+	if (err) goto fail;
-+	spin_lock(sb_bgl_lock(sbi, group));
-+	gdp->bg_free_inodes_count =
-+		cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1);
-+	if (S_ISDIR(mode)) {
-+		gdp->bg_used_dirs_count =
-+			cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1);
-+	}
-+	spin_unlock(sb_bgl_lock(sbi, group));
-+	BUFFER_TRACE(bh2, "call ext3cow_journal_dirty_metadata");
-+	err = ext3cow_journal_dirty_metadata(handle, bh2);
-+	if (err) goto fail;
-+
-+	percpu_counter_dec(&sbi->s_freeinodes_counter);
-+	if (S_ISDIR(mode))
-+		percpu_counter_inc(&sbi->s_dirs_counter);
-+	sb->s_dirt = 1;
-+
-+	inode->i_uid = current->fsuid;
-+	if (test_opt (sb, GRPID))
-+		inode->i_gid = dir->i_gid;
-+	else if (dir->i_mode & S_ISGID) {
-+		inode->i_gid = dir->i_gid;
-+		if (S_ISDIR(mode))
-+			mode |= S_ISGID;
-+	} else
-+		inode->i_gid = current->fsgid;
-+	inode->i_mode = mode;
-+
-+	inode->i_ino = ino;
-+	/* This is the optimal IO size (for stat), not the fs block size */
-+	inode->i_blocks = 0;
-+	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
-+
-+  /* For versioning -znjp */
-+  ei->i_cow_bitmap   = 0x0000;
-+  ei->i_epoch_number = EXT3COW_S_EPOCHNUMBER(dir->i_sb);
-+  ei->i_next_inode   = 0;
-+
-+	memset(ei->i_data, 0, sizeof(ei->i_data));
-+	ei->i_dir_start_lookup = 0;
-+	ei->i_disksize = 0;
-+
-+	ei->i_flags = EXT3COW_I(dir)->i_flags & ~EXT3COW_INDEX_FL;
-+	if (S_ISLNK(mode))
-+		ei->i_flags &= ~(EXT3COW_IMMUTABLE_FL|EXT3COW_APPEND_FL);
-+	/* dirsync only applies to directories */
-+	if (!S_ISDIR(mode))
-+		ei->i_flags &= ~EXT3COW_DIRSYNC_FL;
-+#ifdef EXT3COW_FRAGMENTS
-+  /* Taken out for versioning -znjp */
-+	//ei->i_faddr = 0;
-+	//ei->i_frag_no = 0;
-+	//ei->i_frag_size = 0;
-+#endif
-+	ei->i_file_acl = 0;
-+	ei->i_dir_acl = 0;
-+	ei->i_dtime = 0;
-+	ei->i_block_alloc_info = NULL;
-+	ei->i_block_group = group;
-+
-+	ext3cow_set_inode_flags(inode);
-+	if (IS_DIRSYNC(inode))
-+		handle->h_sync = 1;
-+	insert_inode_hash(inode);
-+	spin_lock(&sbi->s_next_gen_lock);
-+	inode->i_generation = sbi->s_next_generation++;
-+	spin_unlock(&sbi->s_next_gen_lock);
-+
-+	ei->i_state = EXT3COW_STATE_NEW;
-+	ei->i_extra_isize =
-+		(EXT3COW_INODE_SIZE(inode->i_sb) > EXT3COW_GOOD_OLD_INODE_SIZE) ?
-+		sizeof(struct ext3cow_inode) - EXT3COW_GOOD_OLD_INODE_SIZE : 0;
-+
-+	ret = inode;
-+	if(DQUOT_ALLOC_INODE(inode)) {
-+		err = -EDQUOT;
-+		goto fail_drop;
-+	}
-+
-+	err = ext3cow_init_acl(handle, inode, dir);
-+	if (err)
-+		goto fail_free_drop;
-+
-+	err = ext3cow_init_security(handle,inode, dir);
-+	if (err)
-+		goto fail_free_drop;
-+
-+	err = ext3cow_mark_inode_dirty(handle, inode);
-+	if (err) {
-+		ext3cow_std_error(sb, err);
-+		goto fail_free_drop;
-+	}
-+
-+	ext3cow_debug("allocating inode %lu\n", inode->i_ino);
-+	goto really_out;
-+fail:
-+	ext3cow_std_error(sb, err);
-+out:
-+	iput(inode);
-+	ret = ERR_PTR(err);
-+really_out:
-+	brelse(bitmap_bh);
-+	return ret;
-+
-+fail_free_drop:
-+	DQUOT_FREE_INODE(inode);
-+
-+fail_drop:
-+	DQUOT_DROP(inode);
-+	inode->i_flags |= S_NOQUOTA;
-+	inode->i_nlink = 0;
-+	iput(inode);
-+	brelse(bitmap_bh);
-+	return ERR_PTR(err);
-+}
-+
-+/* Verify that we are loading a valid orphan from disk */
-+struct inode *ext3cow_orphan_get(struct super_block *sb, unsigned long ino)
-+{
-+	unsigned long max_ino = le32_to_cpu(EXT3COW_SB(sb)->s_es->s_inodes_count);
-+	unsigned long block_group;
-+	int bit;
-+	struct buffer_head *bitmap_bh = NULL;
-+	struct inode *inode = NULL;
-+
-+	/* Error cases - e2fsck has already cleaned up for us */
-+	if (ino > max_ino) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "bad orphan ino %lu!  e2fsck was run?", ino);
-+		goto out;
-+	}
-+
-+	block_group = (ino - 1) / EXT3COW_INODES_PER_GROUP(sb);
-+	bit = (ino - 1) % EXT3COW_INODES_PER_GROUP(sb);
-+	bitmap_bh = read_inode_bitmap(sb, block_group);
-+	if (!bitmap_bh) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "inode bitmap error for orphan %lu", ino);
-+		goto out;
-+	}
-+
-+	/* Having the inode bit set should be a 100% indicator that this
-+	 * is a valid orphan (no e2fsck run on fs).  Orphans also include
-+	 * inodes that were being truncated, so we can't check i_nlink==0.
-+	 */
-+	if (!ext3cow_test_bit(bit, bitmap_bh->b_data) ||
-+			!(inode = iget(sb, ino)) || is_bad_inode(inode) ||
-+			NEXT_ORPHAN(inode) > max_ino) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "bad orphan inode %lu!  e2fsck was run?", ino);
-+		printk(KERN_NOTICE "ext3cow_test_bit(bit=%d, block=%llu) = %d\n",
-+		       bit, (unsigned long long)bitmap_bh->b_blocknr,
-+		       ext3cow_test_bit(bit, bitmap_bh->b_data));
-+		printk(KERN_NOTICE "inode=%p\n", inode);
-+		if (inode) {
-+			printk(KERN_NOTICE "is_bad_inode(inode)=%d\n",
-+			       is_bad_inode(inode));
-+			printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n",
-+			       NEXT_ORPHAN(inode));
-+			printk(KERN_NOTICE "max_ino=%lu\n", max_ino);
-+		}
-+		/* Avoid freeing blocks if we got a bad deleted inode */
-+		if (inode && inode->i_nlink == 0)
-+			inode->i_blocks = 0;
-+		iput(inode);
-+		inode = NULL;
-+	}
-+out:
-+	brelse(bitmap_bh);
-+	return inode;
-+}
-+
-+unsigned long ext3cow_count_free_inodes (struct super_block * sb)
-+{
-+	unsigned long desc_count;
-+	struct ext3cow_group_desc *gdp;
-+	int i;
-+#ifdef EXT3COWFS_DEBUG
-+	struct ext3cow_super_block *es;
-+	unsigned long bitmap_count, x;
-+	struct buffer_head *bitmap_bh = NULL;
-+
-+	es = EXT3COW_SB(sb)->s_es;
-+	desc_count = 0;
-+	bitmap_count = 0;
-+	gdp = NULL;
-+	for (i = 0; i < EXT3COW_SB(sb)->s_groups_count; i++) {
-+		gdp = ext3cow_get_group_desc (sb, i, NULL);
-+		if (!gdp)
-+			continue;
-+		desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
-+		brelse(bitmap_bh);
-+		bitmap_bh = read_inode_bitmap(sb, i);
-+		if (!bitmap_bh)
-+			continue;
-+
-+		x = ext3cow_count_free(bitmap_bh, EXT3COW_INODES_PER_GROUP(sb) / 8);
-+		printk("group %d: stored = %d, counted = %lu\n",
-+			i, le16_to_cpu(gdp->bg_free_inodes_count), x);
-+		bitmap_count += x;
-+	}
-+	brelse(bitmap_bh);
-+	printk("ext3cow_count_free_inodes: stored = %u, computed = %lu, %lu\n",
-+		le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count);
-+	return desc_count;
-+#else
-+	desc_count = 0;
-+	for (i = 0; i < EXT3COW_SB(sb)->s_groups_count; i++) {
-+		gdp = ext3cow_get_group_desc (sb, i, NULL);
-+		if (!gdp)
-+			continue;
-+		desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
-+		cond_resched();
-+	}
-+	return desc_count;
-+#endif
-+}
-+
-+/* Called at mount-time, super-block is locked */
-+unsigned long ext3cow_count_dirs (struct super_block * sb)
-+{
-+	unsigned long count = 0;
-+	int i;
-+
-+	for (i = 0; i < EXT3COW_SB(sb)->s_groups_count; i++) {
-+		struct ext3cow_group_desc *gdp = ext3cow_get_group_desc (sb, i, NULL);
-+		if (!gdp)
-+			continue;
-+		count += le16_to_cpu(gdp->bg_used_dirs_count);
-+	}
-+	return count;
-+}
-+
-diff -Naur linux-2.6.21.7/fs/ext3cow/inode.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/inode.c
---- linux-2.6.21.7/fs/ext3cow/inode.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/inode.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,3474 @@
-+/*
-+ *  linux/fs/ext3cow/inode.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/fs/minix/inode.c
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ *
-+ *  Goal-directed block allocation by Stephen Tweedie
-+ *	(sct@redhat.com), 1993, 1998
-+ *  Big-endian to little-endian byte-swapping/bitmaps by
-+ *        David S. Miller (davem@caip.rutgers.edu), 1995
-+ *  64-bit file support on 64-bit platforms by Jakub Jelinek
-+ *	(jj@sunsite.ms.mff.cuni.cz)
-+ *
-+ *  Assorted race fixes, rewrite of ext3cow_get_block() by Al Viro, 2000
-+ */
-+
-+#include <linux/module.h>
-+#include <linux/fs.h>
-+#include <linux/time.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/jbd.h>
-+#include <linux/smp_lock.h>
-+#include <linux/highuid.h>
-+#include <linux/pagemap.h>
-+#include <linux/quotaops.h>
-+#include <linux/string.h>
-+#include <linux/buffer_head.h>
-+#include <linux/writeback.h>
-+#include <linux/mpage.h>
-+#include <linux/uio.h>
-+#include <linux/bio.h>
-+#include "xattr.h"
-+#include "acl.h"
-+
-+static int ext3cow_writepage_trans_blocks(struct inode *inode);
-+
-+/*
-+ * Test whether an inode is a fast symlink.
-+ */
-+static int ext3cow_inode_is_fast_symlink(struct inode *inode)
-+{
-+	int ea_blocks = EXT3COW_I(inode)->i_file_acl ?
-+		(inode->i_sb->s_blocksize >> 9) : 0;
-+
-+	return (S_ISLNK(inode->i_mode) && inode->i_blocks - ea_blocks == 0);
-+}
-+
-+/*
-+ * The ext3cow forget function must perform a revoke if we are freeing data
-+ * which has been journaled.  Metadata (eg. indirect blocks) must be
-+ * revoked in all cases.
-+ *
-+ * "bh" may be NULL: a metadata block may have been freed from memory
-+ * but there may still be a record of it in the journal, and that record
-+ * still needs to be revoked.
-+ */
-+int ext3cow_forget(handle_t *handle, int is_metadata, struct inode *inode,
-+			struct buffer_head *bh, ext3cow_fsblk_t blocknr)
-+{
-+	int err;
-+
-+	might_sleep();
-+
-+	BUFFER_TRACE(bh, "enter");
-+
-+	jbd_debug(4, "forgetting bh %p: is_metadata = %d, mode %o, "
-+		  "data mode %lx\n",
-+		  bh, is_metadata, inode->i_mode,
-+		  test_opt(inode->i_sb, DATA_FLAGS));
-+
-+	/* Never use the revoke function if we are doing full data
-+	 * journaling: there is no need to, and a V1 superblock won't
-+	 * support it.  Otherwise, only skip the revoke on un-journaled
-+	 * data blocks. */
-+
-+	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3COW_MOUNT_JOURNAL_DATA ||
-+	    (!is_metadata && !ext3cow_should_journal_data(inode))) {
-+		if (bh) {
-+			BUFFER_TRACE(bh, "call journal_forget");
-+			return ext3cow_journal_forget(handle, bh);
-+		}
-+		return 0;
-+	}
-+
-+	/*
-+	 * data!=journal && (is_metadata || should_journal_data(inode))
-+	 */
-+	BUFFER_TRACE(bh, "call ext3cow_journal_revoke");
-+	err = ext3cow_journal_revoke(handle, blocknr, bh);
-+	if (err)
-+		ext3cow_abort(inode->i_sb, __FUNCTION__,
-+			   "error %d when attempting revoke", err);
-+	BUFFER_TRACE(bh, "exit");
-+	return err;
-+}
-+
-+/*
-+ * Work out how many blocks we need to proceed with the next chunk of a
-+ * truncate transaction.
-+ */
-+static unsigned long blocks_for_truncate(struct inode *inode)
-+{
-+	unsigned long needed;
-+
-+	needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
-+
-+	/* Give ourselves just enough room to cope with inodes in which
-+	 * i_blocks is corrupt: we've seen disk corruptions in the past
-+	 * which resulted in random data in an inode which looked enough
-+	 * like a regular file for ext3cow to try to delete it.  Things
-+	 * will go a bit crazy if that happens, but at least we should
-+	 * try not to panic the whole kernel. */
-+	if (needed < 2)
-+		needed = 2;
-+
-+	/* But we need to bound the transaction so we don't overflow the
-+	 * journal. */
-+	if (needed > EXT3COW_MAX_TRANS_DATA)
-+		needed = EXT3COW_MAX_TRANS_DATA;
-+
-+	return EXT3COW_DATA_TRANS_BLOCKS(inode->i_sb) + needed;
-+}
-+
-+/*
-+ * Truncate transactions can be complex and absolutely huge.  So we need to
-+ * be able to restart the transaction at a conventient checkpoint to make
-+ * sure we don't overflow the journal.
-+ *
-+ * start_transaction gets us a new handle for a truncate transaction,
-+ * and extend_transaction tries to extend the existing one a bit.  If
-+ * extend fails, we need to propagate the failure up and restart the
-+ * transaction in the top-level truncate loop. --sct
-+ */
-+static handle_t *start_transaction(struct inode *inode)
-+{
-+	handle_t *result;
-+
-+	result = ext3cow_journal_start(inode, blocks_for_truncate(inode));
-+	if (!IS_ERR(result))
-+		return result;
-+
-+	ext3cow_std_error(inode->i_sb, PTR_ERR(result));
-+	return result;
-+}
-+
-+/*
-+ * Try to extend this transaction for the purposes of truncation.
-+ *
-+ * Returns 0 if we managed to create more room.  If we can't create more
-+ * room, and the transaction must be restarted we return 1.
-+ */
-+static int try_to_extend_transaction(handle_t *handle, struct inode *inode)
-+{
-+	if (handle->h_buffer_credits > EXT3COW_RESERVE_TRANS_BLOCKS)
-+		return 0;
-+	if (!ext3cow_journal_extend(handle, blocks_for_truncate(inode)))
-+		return 0;
-+	return 1;
-+}
-+
-+/*
-+ * Restart the transaction associated with *handle.  This does a commit,
-+ * so before we call here everything must be consistently dirtied against
-+ * this transaction.
-+ */
-+static int ext3cow_journal_test_restart(handle_t *handle, struct inode *inode)
-+{
-+	jbd_debug(2, "restarting handle %p\n", handle);
-+	return ext3cow_journal_restart(handle, blocks_for_truncate(inode));
-+}
-+
-+/*
-+ * Called at the last iput() if i_nlink is zero.
-+ */
-+void ext3cow_delete_inode (struct inode * inode)
-+{
-+	handle_t *handle;
-+
-+	truncate_inode_pages(&inode->i_data, 0);
-+
-+	if (is_bad_inode(inode))
-+		goto no_delete;
-+
-+	handle = start_transaction(inode);
-+	if (IS_ERR(handle)) {
-+		/*
-+		 * If we're going to skip the normal cleanup, we still need to
-+		 * make sure that the in-core orphan linked list is properly
-+		 * cleaned up.
-+		 */
-+		ext3cow_orphan_del(NULL, inode);
-+		goto no_delete;
-+	}
-+
-+	if (IS_SYNC(inode))
-+		handle->h_sync = 1;
-+	inode->i_size = 0;
-+	if (inode->i_blocks)
-+		ext3cow_truncate(inode);
-+	/*
-+	 * Kill off the orphan record which ext3cow_truncate created.
-+	 * AKPM: I think this can be inside the above `if'.
-+	 * Note that ext3cow_orphan_del() has to be able to cope with the
-+	 * deletion of a non-existent orphan - this is because we don't
-+	 * know if ext3cow_truncate() actually created an orphan record.
-+	 * (Well, we could do this if we need to, but heck - it works)
-+	 */
-+	ext3cow_orphan_del(handle, inode);
-+	EXT3COW_I(inode)->i_dtime	= get_seconds();
-+
-+	/*
-+	 * One subtle ordering requirement: if anything has gone wrong
-+	 * (transaction abort, IO errors, whatever), then we can still
-+	 * do these next steps (the fs will already have been marked as
-+	 * having errors), but we can't free the inode if the mark_dirty
-+	 * fails.
-+	 */
-+	if (ext3cow_mark_inode_dirty(handle, inode))
-+		/* If that failed, just do the required in-core inode clear. */
-+		clear_inode(inode);
-+	else
-+		ext3cow_free_inode(handle, inode);
-+	ext3cow_journal_stop(handle);
-+	return;
-+no_delete:
-+	clear_inode(inode);	/* We must guarantee clearing of inode... */
-+}
-+
-+typedef struct {
-+	__le32	*p;
-+	__le32	key;
-+	struct buffer_head *bh;
-+} Indirect;
-+
-+static inline void add_chain(Indirect *p, struct buffer_head *bh, __le32 *v)
-+{
-+	p->key = *(p->p = v);
-+	p->bh = bh;
-+}
-+
-+static int verify_chain(Indirect *from, Indirect *to)
-+{
-+	while (from <= to && from->key == *from->p)
-+		from++;
-+	return (from > to);
-+}
-+
-+//TODO: Delete at some point
-+/* znjp - used for bitmap testing */
-+
-+ static void printbin(u32 val, int size) {
-+  u32 mask;
-+  
-+  mask=(1UL << (size-1));
-+  while (mask) {
-+    if (mask & val) 
-+      printk("1");
-+    else 
-+      printk("0");
-+    mask /= 2;
-+  }
-+  printk("\n");
-+ 
-+ }
-+
-+
-+/**
-+ *	ext3cow_block_to_path - parse the block number into array of offsets
-+ *	@inode: inode in question (we are only interested in its superblock)
-+ *	@i_block: block number to be parsed
-+ *	@offsets: array to store the offsets in
-+ *      @boundary: set this non-zero if the referred-to block is likely to be
-+ *             followed (on disk) by an indirect block.
-+ *
-+ *	To store the locations of file's data ext3cow uses a data structure common
-+ *	for UNIX filesystems - tree of pointers anchored in the inode, with
-+ *	data blocks at leaves and indirect blocks in intermediate nodes.
-+ *	This function translates the block number into path in that tree -
-+ *	return value is the path length and @offsets[n] is the offset of
-+ *	pointer to (n+1)th node in the nth one. If @block is out of range
-+ *	(negative or too large) warning is printed and zero returned.
-+ *
-+ *	Note: function doesn't find node addresses, so no IO is needed. All
-+ *	we need to know is the capacity of indirect blocks (taken from the
-+ *	inode->i_sb).
-+ */
-+
-+/*
-+ * Portability note: the last comparison (check that we fit into triple
-+ * indirect block) is spelled differently, because otherwise on an
-+ * architecture with 32-bit longs and 8Kb pages we might get into trouble
-+ * if our filesystem had 8Kb blocks. We might use long long, but that would
-+ * kill us on x86. Oh, well, at least the sign propagation does not matter -
-+ * i_block would have to be negative in the very beginning, so we would not
-+ * get there at all.
-+ */
-+
-+static int ext3cow_block_to_path(struct inode *inode,
-+			long i_block, int offsets[4], int *boundary)
-+{
-+  /* TODO: Check for efficientcy -znjp */
-+	int ptrs = EXT3COW_ADDR_PER_BLOCK(inode->i_sb);
-+	const long direct_blocks = EXT3COW_NDIR_BLOCKS,
-+		indirect_blocks = ptrs,
-+    double_blocks = (ptrs * ptrs);
-+		//double_blocks = (1 << (ptrs_bits * 2));
-+	int n = 0;
-+	int final = 0;
-+
-+	if (i_block < 0) {
-+		ext3cow_warning (inode->i_sb, "ext3cow_block_to_path", "block < 0");
-+	} else if (i_block < direct_blocks) {
-+		offsets[n++] = i_block;
-+		final = direct_blocks;
-+	} else if ( (i_block -= direct_blocks) < indirect_blocks) {
-+		offsets[n++] = EXT3COW_IND_BLOCK;
-+		offsets[n++] = i_block;
-+		final = ptrs;
-+	} else if ((i_block -= indirect_blocks) < double_blocks) {
-+		offsets[n++] = EXT3COW_DIND_BLOCK;
-+		offsets[n++] = (i_block/ptrs); //i_block >> ptrs_bits;
-+		offsets[n++] = (i_block%ptrs); //i_block & (ptrs - 1);
-+		final = ptrs;
-+	} else if (((i_block -= double_blocks)/(double_blocks)) < ptrs) {
-+    //	} else if (((i_block -= double_blocks) >> (ptrs_bits * 2)) < ptrs) {
-+		offsets[n++] = EXT3COW_TIND_BLOCK;
-+		offsets[n++] = (i_block/double_blocks); //i_block >> (ptrs_bits * 2);
-+		offsets[n++] = (i_block/double_blocks)%ptrs; //(i_block >> ptrs_bits) & (ptrs - 1);
-+		offsets[n++] = i_block%ptrs; //i_block & (ptrs - 1);
-+		final = ptrs;
-+	} else {
-+		ext3cow_warning(inode->i_sb, "ext3cow_block_to_path", "block > big");
-+	}
-+	if (boundary)
-+		*boundary = final - 1 - (i_block & (ptrs - 1));
-+	return n;
-+}
-+
-+/**
-+ *	ext3cow_get_branch - read the chain of indirect blocks leading to data
-+ *	@inode: inode in question
-+ *	@depth: depth of the chain (1 - direct pointer, etc.)
-+ *	@offsets: offsets of pointers in inode/indirect blocks
-+ *	@chain: place to store the result
-+ *	@err: here we store the error value
-+ *
-+ *	Function fills the array of triples <key, p, bh> and returns %NULL
-+ *	if everything went OK or the pointer to the last filled triple
-+ *	(incomplete one) otherwise. Upon the return chain[i].key contains
-+ *	the number of (i+1)-th block in the chain (as it is stored in memory,
-+ *	i.e. little-endian 32-bit), chain[i].p contains the address of that
-+ *	number (it points into struct inode for i==0 and into the bh->b_data
-+ *	for i>0) and chain[i].bh points to the buffer_head of i-th indirect
-+ *	block for i>0 and NULL for i==0. In other words, it holds the block
-+ *	numbers of the chain, addresses they were taken from (and where we can
-+ *	verify that chain did not change) and buffer_heads hosting these
-+ *	numbers.
-+ *
-+ *	Function stops when it stumbles upon zero pointer (absent block)
-+ *		(pointer to last triple returned, *@err == 0)
-+ *	or when it gets an IO error reading an indirect block
-+ *		(ditto, *@err == -EIO)
-+ *	or when it notices that chain had been changed while it was reading
-+ *		(ditto, *@err == -EAGAIN)
-+ *	or when it reads all @depth-1 indirect blocks successfully and finds
-+ *	the whole chain, all way to the data (returns %NULL, *err == 0).
-+ *  If this is COW we set the cow field to 1.  We know if it's COW
-+ *  because there will already be a key.  We need this field so we
-+ *  zero out the data already in the buffer.
-+ *  The create flag let's us know if were just looking for a block
-+ *  to read, or a block to write.  We only set the bitmap when
-+ *  we're looking for a block to write, either on new allocation
-+ *  or on COWing. -znjp
-+ */
-+static Indirect *ext3cow_get_branch(struct inode *inode, int depth, 
-+                                    int *offsets,
-+                                    Indirect chain[4], int *err, int *cow,
-+                                    int create)
-+{
-+	struct super_block *sb = inode->i_sb;
-+	Indirect *p = chain;
-+	struct buffer_head *bh;
-+  u32* bitmap_w;
-+  int ptrs = EXT3COW_ADDR_PER_BLOCK(inode->i_sb);
-+  int nbitsperword = (sizeof(u32) * 8);
-+
-+	*err = 0;
-+  *cow = 0;
-+	/* i_data is not going away, no lock needed */
-+	add_chain (chain, NULL, EXT3COW_I(inode)->i_data + *offsets);
-+	if (!p->key){
-+    /* Set the bitmap on allocation - znjp */
-+    if(create)
-+      EXT3COW_I(inode)->i_cow_bitmap |= (1UL << *offsets);
-+		goto no_block;
-+  }
-+
-+  /* Are we COWing any direct blocks? -znjp */
-+  if(create && !(EXT3COW_I(inode)->i_cow_bitmap & (1UL << *offsets))){    
-+    printk(KERN_INFO "COWing direct block\n");
-+    *(p->p) = 0;
-+    p->key = 0;
-+    /* Set the bitamp when COWing -znjp */
-+    EXT3COW_I(inode)->i_cow_bitmap |= (1UL << *offsets);
-+    *cow = 1;
-+    goto no_block;
-+  }
-+
-+	while (--depth) {
-+		bh = sb_bread(sb, le32_to_cpu(p->key));
-+		if (!bh)
-+			goto failure;
-+
-+		/* Reader: pointers */
-+		if (!verify_chain(chain, p))
-+			goto changed;
-+		add_chain(++p, bh, (__le32*)bh->b_data + *++offsets);
-+		/* Reader: end */
-+    /* Find correct bitamp word */
-+    bitmap_w = (u32*)bh->b_data + ptrs + (*offsets/nbitsperword);
-+		if (!p->key){
-+      /* Set the bitmap when allocating -znjp */
-+      if(create)
-+       *bitmap_w = (u32)*bitmap_w | (u32)(1UL << (int)(*offsets%nbitsperword));
-+			goto no_block;
-+    }
-+
-+    /* Are we COWing any indirect blocks? -znjp */
-+    if(create && !((1UL << (int)(*offsets%nbitsperword)) & 
-+         le32_to_cpu((u32)*bitmap_w))){
-+      printk(KERN_INFO "COWing indirect block\n");
-+      *(p->p) = 0;
-+      p->key = 0;
-+      /* Set the bitmap -znjp */
-+      *bitmap_w = (u32)*bitmap_w | (u32)(1UL << (int)(*offsets%nbitsperword));
-+      *cow = 1;
-+      goto no_block;
-+    }
-+	}
-+	return NULL;
-+
-+changed:
-+	brelse(bh);
-+	*err = -EAGAIN;
-+	goto no_block;
-+failure:
-+	*err = -EIO;
-+no_block:
-+	return p;
-+}
-+
-+/**
-+ *	ext3cow_find_near - find a place for allocation with sufficient locality
-+ *	@inode: owner
-+ *	@ind: descriptor of indirect block.
-+ *
-+ *	This function returns the prefered place for block allocation.
-+ *	It is used when heuristic for sequential allocation fails.
-+ *	Rules are:
-+ *	  + if there is a block to the left of our position - allocate near it.
-+ *	  + if pointer will live in indirect block - allocate near that block.
-+ *	  + if pointer will live in inode - allocate in the same
-+ *	    cylinder group.
-+ *
-+ * In the latter case we colour the starting block by the callers PID to
-+ * prevent it from clashing with concurrent allocations for a different inode
-+ * in the same block group.   The PID is used here so that functionally related
-+ * files will be close-by on-disk.
-+ *
-+ *	Caller must make sure that @ind is valid and will stay that way.
-+ */
-+static ext3cow_fsblk_t ext3cow_find_near(struct inode *inode, Indirect *ind)
-+{
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	__le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data;
-+	__le32 *p;
-+	ext3cow_fsblk_t bg_start;
-+	ext3cow_grpblk_t colour;
-+
-+	/* Try to find previous block */
-+	for (p = ind->p - 1; p >= start; p--) {
-+		if (*p)
-+			return le32_to_cpu(*p);
-+	}
-+
-+	/* No such thing, so let's try location of indirect block */
-+	if (ind->bh)
-+		return ind->bh->b_blocknr;
-+
-+	/*
-+	 * It is going to be referred to from the inode itself? OK, just put it
-+	 * into the same cylinder group then.
-+	 */
-+	bg_start = ext3cow_group_first_block_no(inode->i_sb, ei->i_block_group);
-+	colour = (current->pid % 16) *
-+			(EXT3COW_BLOCKS_PER_GROUP(inode->i_sb) / 16);
-+	return bg_start + colour;
-+}
-+
-+/**
-+ *	ext3cow_find_goal - find a prefered place for allocation.
-+ *	@inode: owner
-+ *	@block:  block we want
-+ *	@chain:  chain of indirect blocks
-+ *	@partial: pointer to the last triple within a chain
-+ *	@goal:	place to store the result.
-+ *
-+ *	Normally this function find the prefered place for block allocation,
-+ *	stores it in *@goal and returns zero.
-+ */
-+
-+static ext3cow_fsblk_t ext3cow_find_goal(struct inode *inode, long block,
-+		Indirect chain[4], Indirect *partial)
-+{
-+	struct ext3cow_block_alloc_info *block_i;
-+
-+	block_i =  EXT3COW_I(inode)->i_block_alloc_info;
-+
-+	/*
-+	 * try the heuristic for sequential allocation,
-+	 * failing that at least try to get decent locality.
-+	 */
-+	if (block_i && (block == block_i->last_alloc_logical_block + 1)
-+		&& (block_i->last_alloc_physical_block != 0)) {
-+		return block_i->last_alloc_physical_block + 1;
-+	}
-+
-+	return ext3cow_find_near(inode, partial);
-+}
-+
-+/**
-+ *	ext3cow_blks_to_allocate: Look up the block map and count the number
-+ *	of direct blocks need to be allocated for the given branch.
-+ *
-+ *	@branch: chain of indirect blocks
-+ *	@k: number of blocks need for indirect blocks
-+ *	@blks: number of data blocks to be mapped.
-+ *	@blocks_to_boundary:  the offset in the indirect block
-+ *
-+ *	return the total number of blocks to be allocate, including the
-+ *	direct and indirect blocks.
-+ */
-+static int ext3cow_blks_to_allocate(Indirect *branch, int k, unsigned long blks,
-+		int blocks_to_boundary)
-+{
-+	unsigned long count = 0;
-+
-+	/*
-+	 * Simple case, [t,d]Indirect block(s) has not allocated yet
-+	 * then it's clear blocks on that path have not allocated
-+	 */
-+	if (k > 0) {
-+		/* right now we don't handle cross boundary allocation */
-+		if (blks < blocks_to_boundary + 1)
-+			count += blks;
-+		else
-+			count += blocks_to_boundary + 1;
-+		return count;
-+	}
-+
-+	count++;
-+	while (count < blks && count <= blocks_to_boundary &&
-+		le32_to_cpu(*(branch[0].p + count)) == 0) {
-+		count++;
-+	}
-+	return count;
-+}
-+
-+/**
-+ *	ext3cow_alloc_blocks: multiple allocate blocks needed for a branch
-+ *	@indirect_blks: the number of blocks need to allocate for indirect
-+ *			blocks
-+ *
-+ *	@new_blocks: on return it will store the new block numbers for
-+ *	the indirect blocks(if needed) and the first direct block,
-+ *	@blks:	on return it will store the total number of allocated
-+ *		direct blocks
-+ */
-+static int ext3cow_alloc_blocks(handle_t *handle, struct inode *inode,
-+			ext3cow_fsblk_t goal, int indirect_blks, int blks,
-+			ext3cow_fsblk_t new_blocks[4], int *err)
-+{
-+	int target, i;
-+	unsigned long count = 0;
-+	int index = 0;
-+	ext3cow_fsblk_t current_block = 0;
-+	int ret = 0;
-+
-+	/*
-+	 * Here we try to allocate the requested multiple blocks at once,
-+	 * on a best-effort basis.
-+	 * To build a branch, we should allocate blocks for
-+	 * the indirect blocks(if not allocated yet), and at least
-+	 * the first direct block of this branch.  That's the
-+	 * minimum number of blocks need to allocate(required)
-+	 */
-+	target = blks + indirect_blks;
-+
-+	while (1) {
-+		count = target;
-+		/* allocating blocks for indirect blocks and direct blocks */
-+		current_block = ext3cow_new_blocks(handle,inode,goal,&count,err);
-+		if (*err)
-+			goto failed_out;
-+
-+		target -= count;
-+		/* allocate blocks for indirect blocks */
-+		while (index < indirect_blks && count) {
-+			new_blocks[index++] = current_block++;
-+			count--;
-+		}
-+
-+		if (count > 0)
-+			break;
-+	}
-+
-+	/* save the new block number for the first direct block */
-+	new_blocks[index] = current_block;
-+
-+	/* total number of blocks allocated for direct blocks */
-+	ret = count;
-+	*err = 0;
-+	return ret;
-+failed_out:
-+	for (i = 0; i <index; i++)
-+		ext3cow_free_blocks(handle, inode, new_blocks[i], 1);
-+	return ret;
-+}
-+
-+/**
-+ *	ext3cow_alloc_branch - allocate and set up a chain of blocks.
-+ *	@inode: owner
-+ *	@indirect_blks: number of allocated indirect blocks
-+ *	@blks: number of allocated direct blocks
-+ *	@offsets: offsets (in the blocks) to store the pointers to next.
-+ *	@branch: place to store the chain in.
-+ *
-+ *	This function allocates blocks, zeroes out all but the last one,
-+ *	links them into chain and (if we are synchronous) writes them to disk.
-+ *	In other words, it prepares a branch that can be spliced onto the
-+ *	inode. It stores the information about that chain in the branch[], in
-+ *	the same format as ext3cow_get_branch() would do. We are calling it after
-+ *	we had read the existing part of chain and partial points to the last
-+ *	triple of that (one with zero ->key). Upon the exit we have the same
-+ *	picture as after the successful ext3cow_get_block(), except that in one
-+ *	place chain is disconnected - *branch->p is still zero (we did not
-+ *	set the last link), but branch->key contains the number that should
-+ *	be placed into *branch->p to fill that gap.
-+ *
-+ *	If allocation fails we free all blocks we've allocated (and forget
-+ *	their buffer_heads) and return the error value the from failed
-+ *	ext3cow_alloc_block() (normally -ENOSPC). Otherwise we set the chain
-+ *	as described above and return 0.
-+ */
-+static int ext3cow_alloc_branch(handle_t *handle, struct inode *inode,
-+			int indirect_blks, int *blks, ext3cow_fsblk_t goal,
-+			int *offsets, Indirect *branch)
-+{
-+	int blocksize = inode->i_sb->s_blocksize;
-+	int i, n = 0;
-+	int err = 0;
-+	struct buffer_head *bh;
-+	int num;
-+	ext3cow_fsblk_t new_blocks[4];
-+	ext3cow_fsblk_t current_block;
-+
-+	num = ext3cow_alloc_blocks(handle, inode, goal, indirect_blks,
-+				*blks, new_blocks, &err);
-+	if (err)
-+		return err;
-+
-+	branch[0].key = cpu_to_le32(new_blocks[0]);
-+	/*
-+	 * metadata blocks and data blocks are allocated.
-+	 */
-+	for (n = 1; n <= indirect_blks;  n++) {
-+		/*
-+		 * Get buffer_head for parent block, zero it out
-+		 * and set the pointer to new one, then send
-+		 * parent to disk.
-+		 */
-+		bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
-+		branch[n].bh = bh;
-+		lock_buffer(bh);
-+		BUFFER_TRACE(bh, "call get_create_access");
-+		err = ext3cow_journal_get_create_access(handle, bh);
-+		if (err) {
-+			unlock_buffer(bh);
-+			brelse(bh);
-+			goto failed;
-+		}
-+
-+		memset(bh->b_data, 0, blocksize);
-+		branch[n].p = (__le32 *) bh->b_data + offsets[n];
-+		branch[n].key = cpu_to_le32(new_blocks[n]);
-+		*branch[n].p = branch[n].key;
-+		if ( n == indirect_blks) {
-+			current_block = new_blocks[n];
-+			/*
-+			 * End of chain, update the last new metablock of
-+			 * the chain to point to the new allocated
-+			 * data blocks numbers
-+			 */
-+			for (i=1; i < num; i++)
-+				*(branch[n].p + i) = cpu_to_le32(++current_block);
-+		}
-+		BUFFER_TRACE(bh, "marking uptodate");
-+		set_buffer_uptodate(bh);
-+		unlock_buffer(bh);
-+
-+		BUFFER_TRACE(bh, "call ext3cow_journal_dirty_metadata");
-+		err = ext3cow_journal_dirty_metadata(handle, bh);
-+		if (err)
-+			goto failed;
-+	}
-+	*blks = num;
-+	return err;
-+failed:
-+	/* Allocation failed, free what we already allocated */
-+	for (i = 1; i <= n ; i++) {
-+		BUFFER_TRACE(branch[i].bh, "call journal_forget");
-+		ext3cow_journal_forget(handle, branch[i].bh);
-+	}
-+	for (i = 0; i <indirect_blks; i++)
-+		ext3cow_free_blocks(handle, inode, new_blocks[i], 1);
-+
-+	ext3cow_free_blocks(handle, inode, new_blocks[i], num);
-+
-+	return err;
-+}
-+
-+/**
-+ * ext3cow_splice_branch - splice the allocated branch onto inode.
-+ * @inode: owner
-+ * @block: (logical) number of block we are adding
-+ * @chain: chain of indirect blocks (with a missing link - see
-+ *	ext3cow_alloc_branch)
-+ * @where: location of missing link
-+ * @num:   number of indirect blocks we are adding
-+ * @blks:  number of direct blocks we are adding
-+ *
-+ * This function fills the missing link and does all housekeeping needed in
-+ * inode (->i_blocks, etc.). In case of success we end up with the full
-+ * chain to new block and return 0.
-+ */
-+static int ext3cow_splice_branch(handle_t *handle, struct inode *inode,
-+			long block, Indirect *where, int num, int blks)
-+{
-+	int i;
-+	int err = 0;
-+	struct ext3cow_block_alloc_info *block_i;
-+	ext3cow_fsblk_t current_block;
-+
-+	block_i = EXT3COW_I(inode)->i_block_alloc_info;
-+	/*
-+	 * If we're splicing into a [td]indirect block (as opposed to the
-+	 * inode) then we need to get write access to the [td]indirect block
-+	 * before the splice.
-+	 */
-+	if (where->bh) {
-+		BUFFER_TRACE(where->bh, "get_write_access");
-+		err = ext3cow_journal_get_write_access(handle, where->bh);
-+		if (err)
-+			goto err_out;
-+	}
-+	/* That's it */
-+
-+	*where->p = where->key;
-+
-+	/*
-+	 * Update the host buffer_head or inode to point to more just allocated
-+	 * direct blocks blocks
-+	 */
-+	if (num == 0 && blks > 1) {
-+		current_block = le32_to_cpu(where->key) + 1;
-+		for (i = 1; i < blks; i++)
-+			*(where->p + i ) = cpu_to_le32(current_block++);
-+	}
-+
-+	/*
-+	 * update the most recently allocated logical & physical block
-+	 * in i_block_alloc_info, to assist find the proper goal block for next
-+	 * allocation
-+	 */
-+	if (block_i) {
-+		block_i->last_alloc_logical_block = block + blks - 1;
-+		block_i->last_alloc_physical_block =
-+				le32_to_cpu(where[num].key) + blks - 1;
-+	}
-+
-+	/* We are done with atomic stuff, now do the rest of housekeeping */
-+
-+	inode->i_ctime = CURRENT_TIME_SEC;
-+	ext3cow_mark_inode_dirty(handle, inode);
-+
-+	/* had we spliced it onto indirect block? */
-+	if (where->bh) {
-+		/*
-+		 * If we spliced it onto an indirect block, we haven't
-+		 * altered the inode.  Note however that if it is being spliced
-+		 * onto an indirect block at the very end of the file (the
-+		 * file is growing) then we *will* alter the inode to reflect
-+		 * the new i_size.  But that is not done here - it is done in
-+		 * generic_commit_write->__mark_inode_dirty->ext3cow_dirty_inode.
-+		 */
-+		jbd_debug(5, "splicing indirect only\n");
-+		BUFFER_TRACE(where->bh, "call ext3cow_journal_dirty_metadata");
-+		err = ext3cow_journal_dirty_metadata(handle, where->bh);
-+		if (err)
-+			goto err_out;
-+	} else {
-+		/*
-+		 * OK, we spliced it into the inode itself on a direct block.
-+		 * Inode was dirtied above.
-+		 */
-+		jbd_debug(5, "splicing direct\n");
-+	}
-+	return err;
-+
-+err_out:
-+	for (i = 1; i <= num; i++) {
-+		BUFFER_TRACE(where[i].bh, "call journal_forget");
-+		ext3cow_journal_forget(handle, where[i].bh);
-+		ext3cow_free_blocks(handle,inode,le32_to_cpu(where[i-1].key),1);
-+	}
-+	ext3cow_free_blocks(handle, inode, le32_to_cpu(where[num].key), blks);
-+
-+	return err;
-+}
-+
-+/*
-+ * Allocation strategy is simple: if we have to allocate something, we will
-+ * have to go the whole way to leaf. So let's do it before attaching anything
-+ * to tree, set linkage between the newborn blocks, write them if sync is
-+ * required, recheck the path, free and repeat if check fails, otherwise
-+ * set the last missing link (that will protect us from any truncate-generated
-+ * removals - all blocks on the path are immune now) and possibly force the
-+ * write on the parent block.
-+ * That has a nice additional property: no special recovery from the failed
-+ * allocations is needed - we simply release blocks and do not touch anything
-+ * reachable from inode.
-+ *
-+ * `handle' can be NULL if create == 0.
-+ *
-+ * The BKL may not be held on entry here.  Be sure to take it early.
-+ * return > 0, # of blocks mapped or allocated.
-+ * return = 0, if plain lookup failed.
-+ * return < 0, error case.
-+ */
-+int ext3cow_get_blocks_handle(handle_t *handle, struct inode *inode,
-+		sector_t iblock, unsigned long maxblocks,
-+		struct buffer_head *bh_result,
-+		int create, int extend_disksize)
-+{
-+	int err = -EIO;
-+	int offsets[4];
-+	Indirect chain[4];
-+	Indirect *partial;
-+	ext3cow_fsblk_t goal;
-+	int indirect_blks;
-+	int blocks_to_boundary = 0;
-+	int depth;
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	int count = 0;
-+	ext3cow_fsblk_t first_block = 0;
-+  int cow = 0; /* To determine wether we clear the buffer of not -znjp */
-+
-+
-+	J_ASSERT(handle != NULL || create == 0);
-+	depth = ext3cow_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
-+
-+	if (depth == 0)
-+		goto out;
-+
-+	partial = ext3cow_get_branch(inode, depth, offsets, 
-+                               chain, &err, &cow, create);
-+
-+	/* Simplest case - block found, no allocation needed */
-+	if (!partial) {
-+		first_block = le32_to_cpu(chain[depth - 1].key);
-+    if(!cow) /* Don't clear the buffer if it's a COW allocation -znjp */
-+      clear_buffer_new(bh_result);
-+		count++;
-+		/*map more blocks*/
-+		while (count < maxblocks && count <= blocks_to_boundary) {
-+			ext3cow_fsblk_t blk;
-+
-+			if (!verify_chain(chain, partial)) {
-+				/*
-+				 * Indirect block might be removed by
-+				 * truncate while we were reading it.
-+				 * Handling of that case: forget what we've
-+				 * got now. Flag the err as EAGAIN, so it
-+				 * will reread.
-+				 */
-+				err = -EAGAIN;
-+				count = 0;
-+				break;
-+			}
-+			blk = le32_to_cpu(*(chain[depth-1].p + count));
-+
-+			if (blk == first_block + count)
-+				count++;
-+			else
-+				break;
-+		}
-+		if (err != -EAGAIN)
-+			goto got_it;
-+	}
-+
-+	/* Next simple case - plain lookup or failed read of indirect block */
-+	if (!create || err == -EIO)
-+		goto cleanup;
-+
-+	mutex_lock(&ei->truncate_mutex);
-+
-+	/*
-+	 * If the indirect block is missing while we are reading
-+	 * the chain(ext3cow_get_branch() returns -EAGAIN err), or
-+	 * if the chain has been changed after we grab the semaphore,
-+	 * (either because another process truncated this branch, or
-+	 * another get_block allocated this branch) re-grab the chain to see if
-+	 * the request block has been allocated or not.
-+	 *
-+	 * Since we already block the truncate/other get_block
-+	 * at this point, we will have the current copy of the chain when we
-+	 * splice the branch into the tree.
-+	 */
-+	if (err == -EAGAIN || !verify_chain(chain, partial)) {
-+		while (partial > chain) {
-+			brelse(partial->bh);
-+			partial--;
-+		}
-+		partial = ext3cow_get_branch(inode, depth, offsets, 
-+                                 chain, &err, &cow, create);
-+		if (!partial) {
-+			count++;
-+			mutex_unlock(&ei->truncate_mutex);
-+			if (err)
-+				goto cleanup;
-+      /* Don't clear the buffer if we're COWing it -znjp */
-+      if(!cow)
-+        clear_buffer_new(bh_result);
-+			goto got_it;
-+		}
-+	}
-+
-+	/*
-+	 * Okay, we need to do block allocation.  Lazily initialize the block
-+	 * allocation info here if necessary
-+	*/
-+	if (S_ISREG(inode->i_mode) && (!ei->i_block_alloc_info))
-+		ext3cow_init_block_alloc_info(inode);
-+
-+	goal = ext3cow_find_goal(inode, iblock, chain, partial);
-+
-+	/* the number of blocks need to allocate for [d,t]indirect blocks */
-+	indirect_blks = (chain + depth) - partial - 1;
-+
-+	/*
-+	 * Next look up the indirect map to count the totoal number of
-+	 * direct blocks to allocate for this branch.
-+	 */
-+	count = ext3cow_blks_to_allocate(partial, indirect_blks,
-+					maxblocks, blocks_to_boundary);
-+	/*
-+	 * Block out ext3cow_truncate while we alter the tree
-+	 */
-+	err = ext3cow_alloc_branch(handle, inode, indirect_blks, &count, goal,
-+				offsets + (partial - chain), partial);
-+
-+	/*
-+	 * The ext3cow_splice_branch call will free and forget any buffers
-+	 * on the new chain if there is a failure, but that risks using
-+	 * up transaction credits, especially for bitmaps where the
-+	 * credits cannot be returned.  Can we handle this somehow?  We
-+	 * may need to return -EAGAIN upwards in the worst case.  --sct
-+	 */
-+	if (!err)
-+		err = ext3cow_splice_branch(handle, inode, iblock,
-+					partial, indirect_blks, count);
-+	/*
-+	 * i_disksize growing is protected by truncate_mutex.  Don't forget to
-+	 * protect it if you're about to implement concurrent
-+	 * ext3cow_get_block() -bzzz
-+	*/
-+	if (!err && extend_disksize && inode->i_size > ei->i_disksize)
-+		ei->i_disksize = inode->i_size;
-+	mutex_unlock(&ei->truncate_mutex);
-+	if (err)
-+		goto cleanup;
-+
-+	set_buffer_new(bh_result);
-+got_it:
-+	map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key));
-+	if (count > blocks_to_boundary)
-+		set_buffer_boundary(bh_result);
-+	err = count;
-+	/* Clean up and exit */
-+	partial = chain + depth - 1;	/* the whole chain */
-+cleanup:
-+	while (partial > chain) {
-+		BUFFER_TRACE(partial->bh, "call brelse");
-+		brelse(partial->bh);
-+		partial--;
-+	}
-+	BUFFER_TRACE(bh_result, "returned");
-+out:
-+	return err;
-+}
-+
-+#define DIO_CREDITS (EXT3COW_RESERVE_TRANS_BLOCKS + 32)
-+
-+static int ext3cow_get_block(struct inode *inode, sector_t iblock,
-+			struct buffer_head *bh_result, int create)
-+{
-+	handle_t *handle = journal_current_handle();
-+	int ret = 0;
-+	unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
-+
-+	if (!create)
-+		goto get_block;		/* A read */
-+
-+	if (max_blocks == 1)
-+		goto get_block;		/* A single block get */
-+
-+	if (handle->h_transaction->t_state == T_LOCKED) {
-+		/*
-+		 * Huge direct-io writes can hold off commits for long
-+		 * periods of time.  Let this commit run.
-+		 */
-+		ext3cow_journal_stop(handle);
-+		handle = ext3cow_journal_start(inode, DIO_CREDITS);
-+		if (IS_ERR(handle))
-+			ret = PTR_ERR(handle);
-+		goto get_block;
-+	}
-+
-+	if (handle->h_buffer_credits <= EXT3COW_RESERVE_TRANS_BLOCKS) {
-+		/*
-+		 * Getting low on buffer credits...
-+		 */
-+		ret = ext3cow_journal_extend(handle, DIO_CREDITS);
-+		if (ret > 0) {
-+			/*
-+			 * Couldn't extend the transaction.  Start a new one.
-+			 */
-+			ret = ext3cow_journal_restart(handle, DIO_CREDITS);
-+		}
-+	}
-+
-+get_block:
-+	if (ret == 0) {
-+		ret = ext3cow_get_blocks_handle(handle, inode, iblock,
-+					max_blocks, bh_result, create, 0);
-+		if (ret > 0) {
-+			bh_result->b_size = (ret << inode->i_blkbits);
-+			ret = 0;
-+		}
-+	}
-+	return ret;
-+}
-+
-+/*
-+ * `handle' can be NULL if create is zero
-+ */
-+struct buffer_head *ext3cow_getblk(handle_t *handle, struct inode *inode,
-+				long block, int create, int *errp)
-+{
-+	struct buffer_head dummy;
-+	int fatal = 0, err;
-+
-+	J_ASSERT(handle != NULL || create == 0);
-+
-+	dummy.b_state = 0;
-+	dummy.b_blocknr = -1000;
-+	buffer_trace_init(&dummy.b_history);
-+	err = ext3cow_get_blocks_handle(handle, inode, block, 1,
-+					&dummy, create, 1);
-+	/*
-+	 * ext3cow_get_blocks_handle() returns number of blocks
-+	 * mapped. 0 in case of a HOLE.
-+	 */
-+	if (err > 0) {
-+		if (err > 1)
-+			WARN_ON(1);
-+		err = 0;
-+	}
-+	*errp = err;
-+	if (!err && buffer_mapped(&dummy)) {
-+		struct buffer_head *bh;
-+		bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
-+		if (!bh) {
-+			*errp = -EIO;
-+			goto err;
-+		}
-+		if (buffer_new(&dummy)) {
-+			J_ASSERT(create != 0);
-+			J_ASSERT(handle != 0);
-+
-+			/*
-+			 * Now that we do not always journal data, we should
-+			 * keep in mind whether this should always journal the
-+			 * new buffer as metadata.  For now, regular file
-+			 * writes use ext3cow_get_block instead, so it's not a
-+			 * problem.
-+			 */
-+			lock_buffer(bh);
-+			BUFFER_TRACE(bh, "call get_create_access");
-+			fatal = ext3cow_journal_get_create_access(handle, bh);
-+			if (!fatal && !buffer_uptodate(bh)) {
-+				memset(bh->b_data,0,inode->i_sb->s_blocksize);
-+				set_buffer_uptodate(bh);
-+			}
-+			unlock_buffer(bh);
-+			BUFFER_TRACE(bh, "call ext3cow_journal_dirty_metadata");
-+			err = ext3cow_journal_dirty_metadata(handle, bh);
-+			if (!fatal)
-+				fatal = err;
-+		} else {
-+			BUFFER_TRACE(bh, "not a new buffer");
-+		}
-+		if (fatal) {
-+			*errp = fatal;
-+			brelse(bh);
-+			bh = NULL;
-+		}
-+		return bh;
-+	}
-+err:
-+	return NULL;
-+}
-+
-+struct buffer_head *ext3cow_bread(handle_t *handle, struct inode *inode,
-+			       int block, int create, int *err)
-+{
-+	struct buffer_head * bh;
-+
-+	bh = ext3cow_getblk(handle, inode, block, create, err);
-+	if (!bh)
-+		return bh;
-+	if (buffer_uptodate(bh))
-+		return bh;
-+	ll_rw_block(READ_META, 1, &bh);
-+	wait_on_buffer(bh);
-+	if (buffer_uptodate(bh))
-+		return bh;
-+	put_bh(bh);
-+	*err = -EIO;
-+	return NULL;
-+}
-+
-+static int walk_page_buffers(	handle_t *handle,
-+				struct buffer_head *head,
-+				unsigned from,
-+				unsigned to,
-+				int *partial,
-+				int (*fn)(	handle_t *handle,
-+						struct buffer_head *bh))
-+{
-+	struct buffer_head *bh;
-+	unsigned block_start, block_end;
-+	unsigned blocksize = head->b_size;
-+	int err, ret = 0;
-+	struct buffer_head *next;
-+
-+	for (	bh = head, block_start = 0;
-+		ret == 0 && (bh != head || !block_start);
-+		block_start = block_end, bh = next)
-+	{
-+		next = bh->b_this_page;
-+		block_end = block_start + blocksize;
-+		if (block_end <= from || block_start >= to) {
-+			if (partial && !buffer_uptodate(bh))
-+				*partial = 1;
-+			continue;
-+		}
-+		err = (*fn)(handle, bh);
-+		if (!ret)
-+			ret = err;
-+	}
-+	return ret;
-+}
-+
-+/*
-+ * To preserve ordering, it is essential that the hole instantiation and
-+ * the data write be encapsulated in a single transaction.  We cannot
-+ * close off a transaction and start a new one between the ext3cow_get_block()
-+ * and the commit_write().  So doing the journal_start at the start of
-+ * prepare_write() is the right place.
-+ *
-+ * Also, this function can nest inside ext3cow_writepage() ->
-+ * block_write_full_page(). In that case, we *know* that ext3cow_writepage()
-+ * has generated enough buffer credits to do the whole page.  So we won't
-+ * block on the journal in that case, which is good, because the caller may
-+ * be PF_MEMALLOC.
-+ *
-+ * By accident, ext3cow can be reentered when a transaction is open via
-+ * quota file writes.  If we were to commit the transaction while thus
-+ * reentered, there can be a deadlock - we would be holding a quota
-+ * lock, and the commit would never complete if another thread had a
-+ * transaction open and was blocking on the quota lock - a ranking
-+ * violation.
-+ *
-+ * So what we do is to rely on the fact that journal_stop/journal_start
-+ * will _not_ run commit under these circumstances because handle->h_ref
-+ * is elevated.  We'll still have enough credits for the tiny quotafile
-+ * write.
-+ */
-+static int do_journal_get_write_access(handle_t *handle,
-+					struct buffer_head *bh)
-+{
-+	if (!buffer_mapped(bh) || buffer_freed(bh))
-+		return 0;
-+	return ext3cow_journal_get_write_access(handle, bh);
-+}
-+
-+/*
-+ * The idea of this helper function is following:
-+ * if prepare_write has allocated some blocks, but not all of them, the
-+ * transaction must include the content of the newly allocated blocks.
-+ * This content is expected to be set to zeroes by block_prepare_write().
-+ * 2006/10/14  SAW
-+ */
-+static int ext3cow_prepare_failure(struct file *file, struct page *page,
-+				unsigned from, unsigned to)
-+{
-+	struct address_space *mapping;
-+	struct buffer_head *bh, *head, *next;
-+	unsigned block_start, block_end;
-+	unsigned blocksize;
-+	int ret;
-+	handle_t *handle = ext3cow_journal_current_handle();
-+
-+	mapping = page->mapping;
-+	if (ext3cow_should_writeback_data(mapping->host)) {
-+		/* optimization: no constraints about data */
-+skip:
-+		return ext3cow_journal_stop(handle);
-+	}
-+
-+	head = page_buffers(page);
-+	blocksize = head->b_size;
-+	for (	bh = head, block_start = 0;
-+		bh != head || !block_start;
-+	    	block_start = block_end, bh = next)
-+	{
-+		next = bh->b_this_page;
-+		block_end = block_start + blocksize;
-+		if (block_end <= from)
-+			continue;
-+		if (block_start >= to) {
-+			block_start = to;
-+			break;
-+		}
-+		if (!buffer_mapped(bh))
-+		/* prepare_write failed on this bh */
-+			break;
-+		if (ext3cow_should_journal_data(mapping->host)) {
-+			ret = do_journal_get_write_access(handle, bh);
-+			if (ret) {
-+				ext3cow_journal_stop(handle);
-+				return ret;
-+			}
-+		}
-+	/*
-+	 * block_start here becomes the first block where the current iteration
-+	 * of prepare_write failed.
-+	 */
-+	}
-+	if (block_start <= from)
-+		goto skip;
-+
-+	/* commit allocated and zeroed buffers */
-+	return mapping->a_ops->commit_write(file, page, from, block_start);
-+}
-+
-+/* Used to quickly unmap all buffers in a page for COWing -znjp */
-+static int ext3cow_clear_buffer_mapped(handle_t *handle, 
-+                                       struct buffer_head *bh)
-+{
-+  clear_buffer_mapped(bh);
-+  return 0;
-+}
-+
-+static int ext3cow_prepare_write(struct file *file, struct page *page,
-+			      unsigned from, unsigned to)
-+{
-+	struct inode *inode = page->mapping->host;
-+	int ret, ret2;
-+	int needed_blocks = ext3cow_writepage_trans_blocks(inode);
-+	handle_t *handle;
-+	int retries = 0;
-+
-+retry:
-+	handle = ext3cow_journal_start(inode, needed_blocks);
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+  /* Unset the BH_Mapped flag so get_block is always called -znjp */
-+  if(page_has_buffers(page))
-+    ret = walk_page_buffers(handle, page_buffers(page),
-+                            from, to, NULL, ext3cow_clear_buffer_mapped);
-+
-+	if (test_opt(inode->i_sb, NOBH) && ext3cow_should_writeback_data(inode))
-+		ret = nobh_prepare_write(page, from, to, ext3cow_get_block);
-+	else
-+		ret = block_prepare_write(page, from, to, ext3cow_get_block);
-+	if (ret)
-+		goto failure;
-+
-+	if (ext3cow_should_journal_data(inode)) {
-+		ret = walk_page_buffers(handle, page_buffers(page),
-+				from, to, NULL, do_journal_get_write_access);
-+		if (ret)
-+			/* fatal error, just put the handle and return */
-+			journal_stop(handle);
-+	}
-+	return ret;
-+
-+failure:
-+	ret2 = ext3cow_prepare_failure(file, page, from, to);
-+	if (ret2 < 0)
-+		return ret2;
-+	if (ret == -ENOSPC && ext3cow_should_retry_alloc(inode->i_sb, &retries))
-+		goto retry;
-+	/* retry number exceeded, or other error like -EDQUOT */
-+	return ret;
-+}
-+
-+int ext3cow_journal_dirty_data(handle_t *handle, struct buffer_head *bh)
-+{
-+	int err = journal_dirty_data(handle, bh);
-+	if (err)
-+		ext3cow_journal_abort_handle(__FUNCTION__, __FUNCTION__,
-+						bh, handle,err);
-+	return err;
-+}
-+
-+/* For commit_write() in data=journal mode */
-+static int commit_write_fn(handle_t *handle, struct buffer_head *bh)
-+{
-+	if (!buffer_mapped(bh) || buffer_freed(bh))
-+		return 0;
-+	set_buffer_uptodate(bh);
-+	return ext3cow_journal_dirty_metadata(handle, bh);
-+}
-+
-+/*
-+ * We need to pick up the new inode size which generic_commit_write gave us
-+ * `file' can be NULL - eg, when called from page_symlink().
-+ *
-+ * ext3cow never places buffers on inode->i_mapping->private_list.  metadata
-+ * buffers are managed internally.
-+ */
-+static int ext3cow_ordered_commit_write(struct file *file, struct page *page,
-+			     unsigned from, unsigned to)
-+{
-+	handle_t *handle = ext3cow_journal_current_handle();
-+	struct inode *inode = page->mapping->host;
-+	int ret = 0, ret2;
-+
-+	ret = walk_page_buffers(handle, page_buffers(page),
-+		from, to, NULL, ext3cow_journal_dirty_data);
-+
-+	if (ret == 0) {
-+		/*
-+		 * generic_commit_write() will run mark_inode_dirty() if i_size
-+		 * changes.  So let's piggyback the i_disksize mark_inode_dirty
-+		 * into that.
-+		 */
-+		loff_t new_i_size;
-+
-+		new_i_size = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
-+		if (new_i_size > EXT3COW_I(inode)->i_disksize)
-+			EXT3COW_I(inode)->i_disksize = new_i_size;
-+		ret = generic_commit_write(file, page, from, to);
-+	}
-+	ret2 = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = ret2;
-+	return ret;
-+}
-+
-+static int ext3cow_writeback_commit_write(struct file *file, struct page *page,
-+			     unsigned from, unsigned to)
-+{
-+	handle_t *handle = ext3cow_journal_current_handle();
-+	struct inode *inode = page->mapping->host;
-+	int ret = 0, ret2;
-+	loff_t new_i_size;
-+
-+	new_i_size = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
-+	if (new_i_size > EXT3COW_I(inode)->i_disksize)
-+		EXT3COW_I(inode)->i_disksize = new_i_size;
-+
-+	if (test_opt(inode->i_sb, NOBH) && ext3cow_should_writeback_data(inode))
-+		ret = nobh_commit_write(file, page, from, to);
-+	else
-+		ret = generic_commit_write(file, page, from, to);
-+
-+	ret2 = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = ret2;
-+	return ret;
-+}
-+
-+static int ext3cow_journalled_commit_write(struct file *file,
-+			struct page *page, unsigned from, unsigned to)
-+{
-+	handle_t *handle = ext3cow_journal_current_handle();
-+	struct inode *inode = page->mapping->host;
-+	int ret = 0, ret2;
-+	int partial = 0;
-+	loff_t pos;
-+
-+	/*
-+	 * Here we duplicate the generic_commit_write() functionality
-+	 */
-+	pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
-+
-+	ret = walk_page_buffers(handle, page_buffers(page), from,
-+				to, &partial, commit_write_fn);
-+	if (!partial)
-+		SetPageUptodate(page);
-+	if (pos > inode->i_size)
-+		i_size_write(inode, pos);
-+	EXT3COW_I(inode)->i_state |= EXT3COW_STATE_JDATA;
-+	if (inode->i_size > EXT3COW_I(inode)->i_disksize) {
-+		EXT3COW_I(inode)->i_disksize = inode->i_size;
-+		ret2 = ext3cow_mark_inode_dirty(handle, inode);
-+		if (!ret)
-+			ret = ret2;
-+	}
-+	ret2 = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = ret2;
-+	return ret;
-+}
-+
-+/*
-+ * bmap() is special.  It gets used by applications such as lilo and by
-+ * the swapper to find the on-disk block of a specific piece of data.
-+ *
-+ * Naturally, this is dangerous if the block concerned is still in the
-+ * journal.  If somebody makes a swapfile on an ext3cow data-journaling
-+ * filesystem and enables swap, then they may get a nasty shock when the
-+ * data getting swapped to that swapfile suddenly gets overwritten by
-+ * the original zero's written out previously to the journal and
-+ * awaiting writeback in the kernel's buffer cache.
-+ *
-+ * So, if we see any bmap calls here on a modified, data-journaled file,
-+ * take extra steps to flush any blocks which might be in the cache.
-+ */
-+static sector_t ext3cow_bmap(struct address_space *mapping, sector_t block)
-+{
-+	struct inode *inode = mapping->host;
-+	journal_t *journal;
-+	int err;
-+
-+	if (EXT3COW_I(inode)->i_state & EXT3COW_STATE_JDATA) {
-+		/*
-+		 * This is a REALLY heavyweight approach, but the use of
-+		 * bmap on dirty files is expected to be extremely rare:
-+		 * only if we run lilo or swapon on a freshly made file
-+		 * do we expect this to happen.
-+		 *
-+		 * (bmap requires CAP_SYS_RAWIO so this does not
-+		 * represent an unprivileged user DOS attack --- we'd be
-+		 * in trouble if mortal users could trigger this path at
-+		 * will.)
-+		 *
-+		 * NB. EXT3COW_STATE_JDATA is not set on files other than
-+		 * regular files.  If somebody wants to bmap a directory
-+		 * or symlink and gets confused because the buffer
-+		 * hasn't yet been flushed to disk, they deserve
-+		 * everything they get.
-+		 */
-+
-+		EXT3COW_I(inode)->i_state &= ~EXT3COW_STATE_JDATA;
-+		journal = EXT3COW_JOURNAL(inode);
-+		journal_lock_updates(journal);
-+		err = journal_flush(journal);
-+		journal_unlock_updates(journal);
-+
-+		if (err)
-+			return 0;
-+	}
-+
-+	return generic_block_bmap(mapping,block,ext3cow_get_block);
-+}
-+
-+static int bget_one(handle_t *handle, struct buffer_head *bh)
-+{
-+	get_bh(bh);
-+	return 0;
-+}
-+
-+static int bput_one(handle_t *handle, struct buffer_head *bh)
-+{
-+	put_bh(bh);
-+	return 0;
-+}
-+
-+static int journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
-+{
-+	if (buffer_mapped(bh))
-+		return ext3cow_journal_dirty_data(handle, bh);
-+	return 0;
-+}
-+
-+/*
-+ * Note that we always start a transaction even if we're not journalling
-+ * data.  This is to preserve ordering: any hole instantiation within
-+ * __block_write_full_page -> ext3cow_get_block() should be journalled
-+ * along with the data so we don't crash and then get metadata which
-+ * refers to old data.
-+ *
-+ * In all journalling modes block_write_full_page() will start the I/O.
-+ *
-+ * Problem:
-+ *
-+ *	ext3cow_writepage() -> kmalloc() -> __alloc_pages() -> page_launder() ->
-+ *		ext3cow_writepage()
-+ *
-+ * Similar for:
-+ *
-+ *	ext3cow_file_write() -> generic_file_write() -> __alloc_pages() -> ...
-+ *
-+ * Same applies to ext3cow_get_block().  We will deadlock on various things like
-+ * lock_journal and i_truncate_mutex.
-+ *
-+ * Setting PF_MEMALLOC here doesn't work - too many internal memory
-+ * allocations fail.
-+ *
-+ * 16May01: If we're reentered then journal_current_handle() will be
-+ *	    non-zero. We simply *return*.
-+ *
-+ * 1 July 2001: @@@ FIXME:
-+ *   In journalled data mode, a data buffer may be metadata against the
-+ *   current transaction.  But the same file is part of a shared mapping
-+ *   and someone does a writepage() on it.
-+ *
-+ *   We will move the buffer onto the async_data list, but *after* it has
-+ *   been dirtied. So there's a small window where we have dirty data on
-+ *   BJ_Metadata.
-+ *
-+ *   Note that this only applies to the last partial page in the file.  The
-+ *   bit which block_write_full_page() uses prepare/commit for.  (That's
-+ *   broken code anyway: it's wrong for msync()).
-+ *
-+ *   It's a rare case: affects the final partial page, for journalled data
-+ *   where the file is subject to bith write() and writepage() in the same
-+ *   transction.  To fix it we'll need a custom block_write_full_page().
-+ *   We'll probably need that anyway for journalling writepage() output.
-+ *
-+ * We don't honour synchronous mounts for writepage().  That would be
-+ * disastrous.  Any write() or metadata operation will sync the fs for
-+ * us.
-+ *
-+ * AKPM2: if all the page's buffers are mapped to disk and !data=journal,
-+ * we don't need to open a transaction here.
-+ */
-+static int ext3cow_ordered_writepage(struct page *page,
-+				struct writeback_control *wbc)
-+{
-+	struct inode *inode = page->mapping->host;
-+	struct buffer_head *page_bufs;
-+	handle_t *handle = NULL;
-+	int ret = 0;
-+	int err;
-+
-+	J_ASSERT(PageLocked(page));
-+
-+	/*
-+	 * We give up here if we're reentered, because it might be for a
-+	 * different filesystem.
-+	 */
-+	if (ext3cow_journal_current_handle())
-+		goto out_fail;
-+
-+	handle = ext3cow_journal_start(inode, ext3cow_writepage_trans_blocks(inode));
-+
-+	if (IS_ERR(handle)) {
-+		ret = PTR_ERR(handle);
-+		goto out_fail;
-+	}
-+
-+	if (!page_has_buffers(page)) {
-+		create_empty_buffers(page, inode->i_sb->s_blocksize,
-+				(1 << BH_Dirty)|(1 << BH_Uptodate));
-+	}
-+	page_bufs = page_buffers(page);
-+	walk_page_buffers(handle, page_bufs, 0,
-+			PAGE_CACHE_SIZE, NULL, bget_one);
-+
-+	ret = block_write_full_page(page, ext3cow_get_block, wbc);
-+
-+	/*
-+	 * The page can become unlocked at any point now, and
-+	 * truncate can then come in and change things.  So we
-+	 * can't touch *page from now on.  But *page_bufs is
-+	 * safe due to elevated refcount.
-+	 */
-+
-+	/*
-+	 * And attach them to the current transaction.  But only if
-+	 * block_write_full_page() succeeded.  Otherwise they are unmapped,
-+	 * and generally junk.
-+	 */
-+	if (ret == 0) {
-+		err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
-+					NULL, journal_dirty_data_fn);
-+		if (!ret)
-+			ret = err;
-+	}
-+	walk_page_buffers(handle, page_bufs, 0,
-+			PAGE_CACHE_SIZE, NULL, bput_one);
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+
-+out_fail:
-+	redirty_page_for_writepage(wbc, page);
-+	unlock_page(page);
-+	return ret;
-+}
-+
-+static int ext3cow_writeback_writepage(struct page *page,
-+				struct writeback_control *wbc)
-+{
-+	struct inode *inode = page->mapping->host;
-+	handle_t *handle = NULL;
-+	int ret = 0;
-+	int err;
-+
-+	if (ext3cow_journal_current_handle())
-+		goto out_fail;
-+
-+	handle = ext3cow_journal_start(inode, ext3cow_writepage_trans_blocks(inode));
-+	if (IS_ERR(handle)) {
-+		ret = PTR_ERR(handle);
-+		goto out_fail;
-+	}
-+
-+	if (test_opt(inode->i_sb, NOBH) && ext3cow_should_writeback_data(inode))
-+		ret = nobh_writepage(page, ext3cow_get_block, wbc);
-+	else
-+		ret = block_write_full_page(page, ext3cow_get_block, wbc);
-+
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+
-+out_fail:
-+	redirty_page_for_writepage(wbc, page);
-+	unlock_page(page);
-+	return ret;
-+}
-+
-+static int ext3cow_journalled_writepage(struct page *page,
-+				struct writeback_control *wbc)
-+{
-+	struct inode *inode = page->mapping->host;
-+	handle_t *handle = NULL;
-+	int ret = 0;
-+	int err;
-+
-+	if (ext3cow_journal_current_handle())
-+		goto no_write;
-+
-+	handle = ext3cow_journal_start(inode, ext3cow_writepage_trans_blocks(inode));
-+	if (IS_ERR(handle)) {
-+		ret = PTR_ERR(handle);
-+		goto no_write;
-+	}
-+
-+	if (!page_has_buffers(page) || PageChecked(page)) {
-+		/*
-+		 * It's mmapped pagecache.  Add buffers and journal it.  There
-+		 * doesn't seem much point in redirtying the page here.
-+		 */
-+		ClearPageChecked(page);
-+		ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
-+					ext3cow_get_block);
-+		if (ret != 0) {
-+			ext3cow_journal_stop(handle);
-+			goto out_unlock;
-+		}
-+		ret = walk_page_buffers(handle, page_buffers(page), 0,
-+			PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
-+
-+		err = walk_page_buffers(handle, page_buffers(page), 0,
-+				PAGE_CACHE_SIZE, NULL, commit_write_fn);
-+		if (ret == 0)
-+			ret = err;
-+		EXT3COW_I(inode)->i_state |= EXT3COW_STATE_JDATA;
-+		unlock_page(page);
-+	} else {
-+		/*
-+		 * It may be a page full of checkpoint-mode buffers.  We don't
-+		 * really know unless we go poke around in the buffer_heads.
-+		 * But block_write_full_page will do the right thing.
-+		 */
-+		ret = block_write_full_page(page, ext3cow_get_block, wbc);
-+	}
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+out:
-+	return ret;
-+
-+no_write:
-+	redirty_page_for_writepage(wbc, page);
-+out_unlock:
-+	unlock_page(page);
-+	goto out;
-+}
-+
-+static int ext3cow_readpage(struct file *file, struct page *page)
-+{
-+	return mpage_readpage(page, ext3cow_get_block);
-+}
-+
-+static int
-+ext3cow_readpages(struct file *file, struct address_space *mapping,
-+		struct list_head *pages, unsigned nr_pages)
-+{
-+	return mpage_readpages(mapping, pages, nr_pages, ext3cow_get_block);
-+}
-+
-+static void ext3cow_invalidatepage(struct page *page, unsigned long offset)
-+{
-+	journal_t *journal = EXT3COW_JOURNAL(page->mapping->host);
-+
-+	/*
-+	 * If it's a full truncate we just forget about the pending dirtying
-+	 */
-+	if (offset == 0)
-+		ClearPageChecked(page);
-+
-+	journal_invalidatepage(journal, page, offset);
-+}
-+
-+static int ext3cow_releasepage(struct page *page, gfp_t wait)
-+{
-+	journal_t *journal = EXT3COW_JOURNAL(page->mapping->host);
-+
-+	WARN_ON(PageChecked(page));
-+	if (!page_has_buffers(page))
-+		return 0;
-+	return journal_try_to_free_buffers(journal, page, wait);
-+}
-+
-+/*
-+ * If the O_DIRECT write will extend the file then add this inode to the
-+ * orphan list.  So recovery will truncate it back to the original size
-+ * if the machine crashes during the write.
-+ *
-+ * If the O_DIRECT write is intantiating holes inside i_size and the machine
-+ * crashes then stale disk data _may_ be exposed inside the file.
-+ */
-+static ssize_t ext3cow_direct_IO(int rw, struct kiocb *iocb,
-+			const struct iovec *iov, loff_t offset,
-+			unsigned long nr_segs)
-+{
-+	struct file *file = iocb->ki_filp;
-+	struct inode *inode = file->f_mapping->host;
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	handle_t *handle = NULL;
-+	ssize_t ret;
-+	int orphan = 0;
-+	size_t count = iov_length(iov, nr_segs);
-+
-+	if (rw == WRITE) {
-+		loff_t final_size = offset + count;
-+
-+		handle = ext3cow_journal_start(inode, DIO_CREDITS);
-+		if (IS_ERR(handle)) {
-+			ret = PTR_ERR(handle);
-+			goto out;
-+		}
-+		if (final_size > inode->i_size) {
-+			ret = ext3cow_orphan_add(handle, inode);
-+			if (ret)
-+				goto out_stop;
-+			orphan = 1;
-+			ei->i_disksize = inode->i_size;
-+		}
-+	}
-+
-+	ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
-+				 offset, nr_segs,
-+				 ext3cow_get_block, NULL);
-+
-+	/*
-+	 * Reacquire the handle: ext3cow_get_block() can restart the transaction
-+	 */
-+	handle = journal_current_handle();
-+
-+out_stop:
-+	if (handle) {
-+		int err;
-+
-+		if (orphan && inode->i_nlink)
-+			ext3cow_orphan_del(handle, inode);
-+		if (orphan && ret > 0) {
-+			loff_t end = offset + ret;
-+			if (end > inode->i_size) {
-+				ei->i_disksize = end;
-+				i_size_write(inode, end);
-+				/*
-+				 * We're going to return a positive `ret'
-+				 * here due to non-zero-length I/O, so there's
-+				 * no way of reporting error returns from
-+				 * ext3cow_mark_inode_dirty() to userspace.  So
-+				 * ignore it.
-+				 */
-+				ext3cow_mark_inode_dirty(handle, inode);
-+			}
-+		}
-+		err = ext3cow_journal_stop(handle);
-+		if (ret == 0)
-+			ret = err;
-+	}
-+out:
-+	return ret;
-+}
-+
-+/*
-+ * Pages can be marked dirty completely asynchronously from ext3cow's journalling
-+ * activity.  By filemap_sync_pte(), try_to_unmap_one(), etc.  We cannot do
-+ * much here because ->set_page_dirty is called under VFS locks.  The page is
-+ * not necessarily locked.
-+ *
-+ * We cannot just dirty the page and leave attached buffers clean, because the
-+ * buffers' dirty state is "definitive".  We cannot just set the buffers dirty
-+ * or jbddirty because all the journalling code will explode.
-+ *
-+ * So what we do is to mark the page "pending dirty" and next time writepage
-+ * is called, propagate that into the buffers appropriately.
-+ */
-+static int ext3cow_journalled_set_page_dirty(struct page *page)
-+{
-+	SetPageChecked(page);
-+	return __set_page_dirty_nobuffers(page);
-+}
-+
-+static const struct address_space_operations ext3cow_ordered_aops = {
-+	.readpage	= ext3cow_readpage,
-+	.readpages	= ext3cow_readpages,
-+	.writepage	= ext3cow_ordered_writepage,
-+	.sync_page	= block_sync_page,
-+	.prepare_write	= ext3cow_prepare_write,
-+	.commit_write	= ext3cow_ordered_commit_write,
-+	.bmap		= ext3cow_bmap,
-+	.invalidatepage	= ext3cow_invalidatepage,
-+	.releasepage	= ext3cow_releasepage,
-+	.direct_IO	= ext3cow_direct_IO,
-+	.migratepage	= buffer_migrate_page,
-+};
-+
-+static const struct address_space_operations ext3cow_writeback_aops = {
-+	.readpage	= ext3cow_readpage,
-+	.readpages	= ext3cow_readpages,
-+	.writepage	= ext3cow_writeback_writepage,
-+	.sync_page	= block_sync_page,
-+	.prepare_write	= ext3cow_prepare_write,
-+	.commit_write	= ext3cow_writeback_commit_write,
-+	.bmap		= ext3cow_bmap,
-+	.invalidatepage	= ext3cow_invalidatepage,
-+	.releasepage	= ext3cow_releasepage,
-+	.direct_IO	= ext3cow_direct_IO,
-+	.migratepage	= buffer_migrate_page,
-+};
-+
-+static const struct address_space_operations ext3cow_journalled_aops = {
-+	.readpage	= ext3cow_readpage,
-+	.readpages	= ext3cow_readpages,
-+	.writepage	= ext3cow_journalled_writepage,
-+	.sync_page	= block_sync_page,
-+	.prepare_write	= ext3cow_prepare_write,
-+	.commit_write	= ext3cow_journalled_commit_write,
-+	.set_page_dirty	= ext3cow_journalled_set_page_dirty,
-+	.bmap		= ext3cow_bmap,
-+	.invalidatepage	= ext3cow_invalidatepage,
-+	.releasepage	= ext3cow_releasepage,
-+};
-+
-+void ext3cow_set_aops(struct inode *inode)
-+{
-+	if (ext3cow_should_order_data(inode))
-+		inode->i_mapping->a_ops = &ext3cow_ordered_aops;
-+	else if (ext3cow_should_writeback_data(inode))
-+		inode->i_mapping->a_ops = &ext3cow_writeback_aops;
-+	else
-+		inode->i_mapping->a_ops = &ext3cow_journalled_aops;
-+}
-+
-+/*
-+ * ext3cow_block_truncate_page() zeroes out a mapping from file offset `from'
-+ * up to the end of the block which corresponds to `from'.
-+ * This required during truncate. We need to physically zero the tail end
-+ * of that block so it doesn't yield old data if the file is later grown.
-+ */
-+static int ext3cow_block_truncate_page(handle_t *handle, struct page *page,
-+		struct address_space *mapping, loff_t from)
-+{
-+	ext3cow_fsblk_t index = from >> PAGE_CACHE_SHIFT;
-+	unsigned offset = from & (PAGE_CACHE_SIZE-1);
-+	unsigned blocksize, iblock, length, pos;
-+	struct inode *inode = mapping->host;
-+	struct buffer_head *bh;
-+	int err = 0;
-+	void *kaddr;
-+
-+	blocksize = inode->i_sb->s_blocksize;
-+	length = blocksize - (offset & (blocksize - 1));
-+	iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
-+
-+	/*
-+	 * For "nobh" option,  we can only work if we don't need to
-+	 * read-in the page - otherwise we create buffers to do the IO.
-+	 */
-+	if (!page_has_buffers(page) && test_opt(inode->i_sb, NOBH) &&
-+	     ext3cow_should_writeback_data(inode) && PageUptodate(page)) {
-+		kaddr = kmap_atomic(page, KM_USER0);
-+		memset(kaddr + offset, 0, length);
-+		flush_dcache_page(page);
-+		kunmap_atomic(kaddr, KM_USER0);
-+		set_page_dirty(page);
-+		goto unlock;
-+	}
-+
-+	if (!page_has_buffers(page))
-+		create_empty_buffers(page, blocksize, 0);
-+
-+	/* Find the buffer that contains "offset" */
-+	bh = page_buffers(page);
-+	pos = blocksize;
-+	while (offset >= pos) {
-+		bh = bh->b_this_page;
-+		iblock++;
-+		pos += blocksize;
-+	}
-+
-+	err = 0;
-+	if (buffer_freed(bh)) {
-+		BUFFER_TRACE(bh, "freed: skip");
-+		goto unlock;
-+	}
-+
-+	if (!buffer_mapped(bh)) {
-+		BUFFER_TRACE(bh, "unmapped");
-+		ext3cow_get_block(inode, iblock, bh, 0);
-+		/* unmapped? It's a hole - nothing to do */
-+		if (!buffer_mapped(bh)) {
-+			BUFFER_TRACE(bh, "still unmapped");
-+			goto unlock;
-+		}
-+	}
-+
-+	/* Ok, it's mapped. Make sure it's up-to-date */
-+	if (PageUptodate(page))
-+		set_buffer_uptodate(bh);
-+
-+	if (!buffer_uptodate(bh)) {
-+		err = -EIO;
-+		ll_rw_block(READ, 1, &bh);
-+		wait_on_buffer(bh);
-+		/* Uhhuh. Read error. Complain and punt. */
-+		if (!buffer_uptodate(bh))
-+			goto unlock;
-+	}
-+
-+	if (ext3cow_should_journal_data(inode)) {
-+		BUFFER_TRACE(bh, "get write access");
-+		err = ext3cow_journal_get_write_access(handle, bh);
-+		if (err)
-+			goto unlock;
-+	}
-+
-+	kaddr = kmap_atomic(page, KM_USER0);
-+	memset(kaddr + offset, 0, length);
-+	flush_dcache_page(page);
-+	kunmap_atomic(kaddr, KM_USER0);
-+
-+	BUFFER_TRACE(bh, "zeroed end of block");
-+
-+	err = 0;
-+	if (ext3cow_should_journal_data(inode)) {
-+		err = ext3cow_journal_dirty_metadata(handle, bh);
-+	} else {
-+		if (ext3cow_should_order_data(inode))
-+			err = ext3cow_journal_dirty_data(handle, bh);
-+		mark_buffer_dirty(bh);
-+	}
-+
-+unlock:
-+	unlock_page(page);
-+	page_cache_release(page);
-+	return err;
-+}
-+
-+/*
-+ * Probably it should be a library function... search for first non-zero word
-+ * or memcmp with zero_page, whatever is better for particular architecture.
-+ * Linus?
-+ */
-+static inline int all_zeroes(__le32 *p, __le32 *q)
-+{
-+	while (p < q)
-+		if (*p++)
-+			return 0;
-+	return 1;
-+}
-+
-+/**
-+ *	ext3cow_find_shared - find the indirect blocks for partial truncation.
-+ *	@inode:	  inode in question
-+ *	@depth:	  depth of the affected branch
-+ *	@offsets: offsets of pointers in that branch (see ext3cow_block_to_path)
-+ *	@chain:	  place to store the pointers to partial indirect blocks
-+ *	@top:	  place to the (detached) top of branch
-+ *
-+ *	This is a helper function used by ext3cow_truncate().
-+ *
-+ *	When we do truncate() we may have to clean the ends of several
-+ *	indirect blocks but leave the blocks themselves alive. Block is
-+ *	partially truncated if some data below the new i_size is refered
-+ *	from it (and it is on the path to the first completely truncated
-+ *	data block, indeed).  We have to free the top of that path along
-+ *	with everything to the right of the path. Since no allocation
-+ *	past the truncation point is possible until ext3cow_truncate()
-+ *	finishes, we may safely do the latter, but top of branch may
-+ *	require special attention - pageout below the truncation point
-+ *	might try to populate it.
-+ *
-+ *	We atomically detach the top of branch from the tree, store the
-+ *	block number of its root in *@top, pointers to buffer_heads of
-+ *	partially truncated blocks - in @chain[].bh and pointers to
-+ *	their last elements that should not be removed - in
-+ *	@chain[].p. Return value is the pointer to last filled element
-+ *	of @chain.
-+ *
-+ *	The work left to caller to do the actual freeing of subtrees:
-+ *		a) free the subtree starting from *@top
-+ *		b) free the subtrees whose roots are stored in
-+ *			(@chain[i].p+1 .. end of @chain[i].bh->b_data)
-+ *		c) free the subtrees growing from the inode past the @chain[0].
-+ *			(no partially truncated stuff there).  */
-+
-+static Indirect *ext3cow_find_shared(struct inode *inode, int depth,
-+			int offsets[4], Indirect chain[4], __le32 *top)
-+{
-+	Indirect *partial, *p;
-+	int k, err, cow;
-+
-+	*top = 0;
-+	/* Make k index the deepest non-null offest + 1 */
-+	for (k = depth; k > 1 && !offsets[k-1]; k--)
-+		;
-+	partial = ext3cow_get_branch(inode, k, offsets, chain, &err, &cow, 0);
-+	/* Writer: pointers */
-+	if (!partial)
-+		partial = chain + k-1;
-+	/*
-+	 * If the branch acquired continuation since we've looked at it -
-+	 * fine, it should all survive and (new) top doesn't belong to us.
-+	 */
-+	if (!partial->key && *partial->p)
-+		/* Writer: end */
-+		goto no_top;
-+	for (p=partial; p>chain && all_zeroes((__le32*)p->bh->b_data,p->p); p--)
-+		;
-+	/*
-+	 * OK, we've found the last block that must survive. The rest of our
-+	 * branch should be detached before unlocking. However, if that rest
-+	 * of branch is all ours and does not grow immediately from the inode
-+	 * it's easier to cheat and just decrement partial->p.
-+	 */
-+	if (p == chain + k - 1 && p > chain) {
-+		p->p--;
-+	} else {
-+		*top = *p->p;
-+		/* Nope, don't do this in ext3cow.  Must leave the tree intact */
-+#if 0
-+		*p->p = 0;
-+#endif
-+	}
-+	/* Writer: end */
-+
-+	while(partial > p) {
-+		brelse(partial->bh);
-+		partial--;
-+	}
-+no_top:
-+	return partial;
-+}
-+
-+/*
-+ * Zero a number of block pointers in either an inode or an indirect block.
-+ * If we restart the transaction we must again get write access to the
-+ * indirect block for further modification.
-+ *
-+ * We release `count' blocks on disk, but (last - first) may be greater
-+ * than `count' because there can be holes in there.
-+ */
-+static void ext3cow_clear_blocks(handle_t *handle, struct inode *inode,
-+		struct buffer_head *bh, ext3cow_fsblk_t block_to_free,
-+		unsigned long count, __le32 *first, __le32 *last)
-+{
-+	__le32 *p;
-+	if (try_to_extend_transaction(handle, inode)) {
-+		if (bh) {
-+			BUFFER_TRACE(bh, "call ext3cow_journal_dirty_metadata");
-+			ext3cow_journal_dirty_metadata(handle, bh);
-+		}
-+		ext3cow_mark_inode_dirty(handle, inode);
-+		ext3cow_journal_test_restart(handle, inode);
-+		if (bh) {
-+			BUFFER_TRACE(bh, "retaking write access");
-+			ext3cow_journal_get_write_access(handle, bh);
-+		}
-+	}
-+
-+	/*
-+	 * Any buffers which are on the journal will be in memory. We find
-+	 * them on the hash table so journal_revoke() will run journal_forget()
-+	 * on them.  We've already detached each block from the file, so
-+	 * bforget() in journal_forget() should be safe.
-+	 *
-+	 * AKPM: turn on bforget in journal_forget()!!!
-+	 */
-+	for (p = first; p < last; p++) {
-+		u32 nr = le32_to_cpu(*p);
-+		if (nr) {
-+			struct buffer_head *bh;
-+
-+			*p = 0;
-+			bh = sb_find_get_block(inode->i_sb, nr);
-+			ext3cow_forget(handle, 0, inode, bh, nr);
-+		}
-+	}
-+
-+	ext3cow_free_blocks(handle, inode, block_to_free, count);
-+}
-+
-+/**
-+ * ext3cow_free_data - free a list of data blocks
-+ * @handle:	handle for this transaction
-+ * @inode:	inode we are dealing with
-+ * @this_bh:	indirect buffer_head which contains *@first and *@last
-+ * @first:	array of block numbers
-+ * @last:	points immediately past the end of array
-+ *
-+ * We are freeing all blocks refered from that array (numbers are stored as
-+ * little-endian 32-bit) and updating @inode->i_blocks appropriately.
-+ *
-+ * We accumulate contiguous runs of blocks to free.  Conveniently, if these
-+ * blocks are contiguous then releasing them at one time will only affect one
-+ * or two bitmap blocks (+ group descriptor(s) and superblock) and we won't
-+ * actually use a lot of journal space.
-+ *
-+ * @this_bh will be %NULL if @first and @last point into the inode's direct
-+ * block pointers.
-+ */
-+static void ext3cow_free_data(handle_t *handle, struct inode *inode,
-+			   struct buffer_head *this_bh,
-+			   __le32 *first, __le32 *last)
-+{
-+	ext3cow_fsblk_t block_to_free = 0;    /* Starting block # of a run */
-+	unsigned long count = 0;	    /* Number of blocks in the run */
-+	__le32 *block_to_free_p = NULL;	    /* Pointer into inode/ind
-+					       corresponding to
-+					       block_to_free */
-+	ext3cow_fsblk_t nr;		    /* Current block # */
-+	__le32 *p;			    /* Pointer into inode/ind
-+					       for current block */
-+	int err;
-+
-+	if (this_bh) {				/* For indirect block */
-+		BUFFER_TRACE(this_bh, "get_write_access");
-+		err = ext3cow_journal_get_write_access(handle, this_bh);
-+		/* Important: if we can't update the indirect pointers
-+		 * to the blocks, we can't free them. */
-+		if (err)
-+			return;
-+	}
-+
-+	for (p = first; p < last; p++) {
-+		nr = le32_to_cpu(*p);
-+		if (nr) {
-+			/* accumulate blocks to free if they're contiguous */
-+			if (count == 0) {
-+				block_to_free = nr;
-+				block_to_free_p = p;
-+				count = 1;
-+			} else if (nr == block_to_free + count) {
-+				count++;
-+			} else {
-+				ext3cow_clear_blocks(handle, inode, this_bh,
-+						  block_to_free,
-+						  count, block_to_free_p, p);
-+				block_to_free = nr;
-+				block_to_free_p = p;
-+				count = 1;
-+			}
-+		}
-+	}
-+
-+	if (count > 0)
-+		ext3cow_clear_blocks(handle, inode, this_bh, block_to_free,
-+				  count, block_to_free_p, p);
-+
-+	if (this_bh) {
-+		BUFFER_TRACE(this_bh, "call ext3cow_journal_dirty_metadata");
-+		ext3cow_journal_dirty_metadata(handle, this_bh);
-+	}
-+}
-+
-+/**
-+ *	ext3cow_free_branches - free an array of branches
-+ *	@handle: JBD handle for this transaction
-+ *	@inode:	inode we are dealing with
-+ *	@parent_bh: the buffer_head which contains *@first and *@last
-+ *	@first:	array of block numbers
-+ *	@last:	pointer immediately past the end of array
-+ *	@depth:	depth of the branches to free
-+ *
-+ *	We are freeing all blocks refered from these branches (numbers are
-+ *	stored as little-endian 32-bit) and updating @inode->i_blocks
-+ *	appropriately.
-+ */
-+static void ext3cow_free_branches(handle_t *handle, struct inode *inode,
-+			       struct buffer_head *parent_bh,
-+			       __le32 *first, __le32 *last, int depth)
-+{
-+	ext3cow_fsblk_t nr;
-+	__le32 *p;
-+
-+	if (is_handle_aborted(handle))
-+		return;
-+
-+	if (depth--) {
-+		struct buffer_head *bh;
-+		int addr_per_block = EXT3COW_ADDR_PER_BLOCK(inode->i_sb);
-+    u32 *bitmap_word = NULL, *first_block = NULL;
-+    unsigned int count = 0, cur = 0, bcount = 0;
-+    int i = 0;
-+		p = last;
-+		while (--p >= first) {
-+			nr = le32_to_cpu(*p);
-+			if (!nr)
-+				continue;		/* A hole */
-+
-+			/* Go read the buffer for the next level down */
-+			bh = sb_bread(inode->i_sb, nr);
-+
-+			/*
-+			 * A read failure? Report error and clear slot
-+			 * (should be rare).
-+			 */
-+			if (!bh) {
-+				ext3cow_error(inode->i_sb, "ext3cow_free_branches",
-+					   "Read failure, inode=%lu, block="E3FSBLK,
-+					   inode->i_ino, nr);
-+				continue;
-+			}
-+      /* Only free the branches that have been newly allocated - znjp */
-+      cur = 0;
-+      count = 0;
-+      bitmap_word = (u32*)bh->b_data + addr_per_block;
-+      
-+      for(bcount = 0; bcount < EXT3COW_COWBITMAPS_PER_IBLOCK(inode->i_sb);
-+          bcount++){
-+        for(i = 0; i < EXT3COW_COWBITMAP_SIZE; i++, cur++){
-+          if(cur >= addr_per_block)
-+            goto free;
-+          if(le32_to_cpu(*bitmap_word) & (1UL << i)){
-+            if(count == 0){
-+              first_block = (u32*)bh->b_data + cur;
-+              count = 1;
-+            }else if((u32*)first_block + count == (u32*)bh->b_data + cur){
-+              count++;
-+            }else{
-+              BUFFER_TRACE(bh, "free child branches");
-+              ext3cow_free_branches(handle, inode, bh, (u32*)first_block,
-+                                    (u32*)first_block + count, depth);
-+              first_block = (u32*)bh->b_data + cur;
-+              count = 1;
-+            }
-+          }
-+        }
-+        (u32*)bitmap_word++;
-+      }   
-+    free:
-+      if(count){
-+        BUFFER_TRACE(bh, "free child branches");
-+        ext3cow_free_branches(handle, inode, bh, (u32*)first_block,
-+                              (u32*)first_block + count, depth);
-+      }
-+
-+			/*
-+			 * We've probably journalled the indirect block several
-+			 * times during the truncate.  But it's no longer
-+			 * needed and we now drop it from the transaction via
-+			 * journal_revoke().
-+			 *
-+			 * That's easy if it's exclusively part of this
-+			 * transaction.  But if it's part of the committing
-+			 * transaction then journal_forget() will simply
-+			 * brelse() it.  That means that if the underlying
-+			 * block is reallocated in ext3cow_get_block(),
-+			 * unmap_underlying_metadata() will find this block
-+			 * and will try to get rid of it.  damn, damn.
-+			 *
-+			 * If this block has already been committed to the
-+			 * journal, a revoke record will be written.  And
-+			 * revoke records must be emitted *before* clearing
-+			 * this block's bit in the bitmaps.
-+			 */
-+			ext3cow_forget(handle, 1, inode, bh, bh->b_blocknr);
-+
-+			/*
-+			 * Everything below this this pointer has been
-+			 * released.  Now let this top-of-subtree go.
-+			 *
-+			 * We want the freeing of this indirect block to be
-+			 * atomic in the journal with the updating of the
-+			 * bitmap block which owns it.  So make some room in
-+			 * the journal.
-+			 *
-+			 * We zero the parent pointer *after* freeing its
-+			 * pointee in the bitmaps, so if extend_transaction()
-+			 * for some reason fails to put the bitmap changes and
-+			 * the release into the same transaction, recovery
-+			 * will merely complain about releasing a free block,
-+			 * rather than leaking blocks.
-+			 */
-+			if (is_handle_aborted(handle))
-+				return;
-+			if (try_to_extend_transaction(handle, inode)) {
-+				ext3cow_mark_inode_dirty(handle, inode);
-+				ext3cow_journal_test_restart(handle, inode);
-+			}
-+
-+			ext3cow_free_blocks(handle, inode, nr, 1);
-+
-+			if (parent_bh) {
-+				/*
-+				 * The block which we have just freed is
-+				 * pointed to by an indirect block: journal it
-+				 */
-+				BUFFER_TRACE(parent_bh, "get_write_access");
-+				if (!ext3cow_journal_get_write_access(handle,
-+								   parent_bh)){
-+					*p = 0;
-+					BUFFER_TRACE(parent_bh,
-+					"call ext3cow_journal_dirty_metadata");
-+					ext3cow_journal_dirty_metadata(handle,
-+								    parent_bh);
-+				}
-+			}
-+		}
-+	} else {
-+		/* We have reached the bottom of the tree. */
-+		BUFFER_TRACE(parent_bh, "free data blocks");
-+		ext3cow_free_data(handle, inode, parent_bh, first, last);
-+	}
-+}
-+
-+/*
-+ * ext3cow_truncate()
-+ *
-+ * We block out ext3cow_get_block() block instantiations across the entire
-+ * transaction, and VFS/VM ensures that ext3cow_truncate() cannot run
-+ * simultaneously on behalf of the same inode.
-+ *
-+ * As we work through the truncate and commmit bits of it to the journal there
-+ * is one core, guiding principle: the file's tree must always be consistent on
-+ * disk.  We must be able to restart the truncate after a crash.
-+ *
-+ * The file's tree may be transiently inconsistent in memory (although it
-+ * probably isn't), but whenever we close off and commit a journal transaction,
-+ * the contents of (the filesystem + the journal) must be consistent and
-+ * restartable.  It's pretty simple, really: bottom up, right to left (although
-+ * left-to-right works OK too).
-+ *
-+ * Note that at recovery time, journal replay occurs *before* the restart of
-+ * truncate against the orphan inode list.
-+ *
-+ * The committed inode has the new, desired i_size (which is the same as
-+ * i_disksize in this case).  After a crash, ext3cow_orphan_cleanup() will see
-+ * that this inode's truncate did not complete and it will again call
-+ * ext3cow_truncate() to have another go.  So there will be instantiated blocks
-+ * to the right of the truncation point in a crashed ext3cow filesystem.  But
-+ * that's fine - as long as they are linked from the inode, the post-crash
-+ * ext3cow_truncate() run will find them and release them.
-+ */
-+void ext3cow_truncate(struct inode *inode)
-+{
-+	handle_t *handle;
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	__le32 *i_data = ei->i_data;
-+	int addr_per_block = EXT3COW_ADDR_PER_BLOCK(inode->i_sb);
-+	struct address_space *mapping = inode->i_mapping;
-+	int offsets[4];
-+	Indirect chain[4];
-+	Indirect *partial;
-+	__le32 nr = 0;
-+	int n;
-+	long last_block;
-+	unsigned blocksize = inode->i_sb->s_blocksize;
-+	struct page *page;
-+
-+
-+	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
-+	    S_ISLNK(inode->i_mode)))
-+		return;
-+	if (ext3cow_inode_is_fast_symlink(inode))
-+		return;
-+	if (IS_APPEND(inode) || IS_IMMUTABLE(inode) || 
-+      EXT3COW_IS_UNCHANGEABLE(inode)) /* znjp */
-+		return;
-+
-+  /* If the inode needs to be dup'd, then there are no blocks
-+   * to truncate; they all are part of the previous version.
-+   * - znjp */
-+  if(EXT3COW_S_EPOCHNUMBER(inode->i_sb) > EXT3COW_I_EPOCHNUMBER(inode)){
-+    ext3cow_dup_inode(NULL, inode);
-+    return;
-+  }
-+
-+	/*
-+	 * We have to lock the EOF page here, because lock_page() nests
-+	 * outside journal_start().
-+	 */
-+	if ((inode->i_size & (blocksize - 1)) == 0) {
-+		/* Block boundary? Nothing to do */
-+		page = NULL;
-+	} else {
-+		page = grab_cache_page(mapping,
-+				inode->i_size >> PAGE_CACHE_SHIFT);
-+		if (!page)
-+			return;
-+	}
-+
-+	handle = start_transaction(inode);
-+	if (IS_ERR(handle)) {
-+		if (page) {
-+			clear_highpage(page);
-+			flush_dcache_page(page);
-+			unlock_page(page);
-+			page_cache_release(page);
-+		}
-+		return;		/* AKPM: return what? */
-+	}
-+
-+	last_block = (inode->i_size + blocksize-1)
-+					>> EXT3COW_BLOCK_SIZE_BITS(inode->i_sb);
-+
-+	if (page)
-+		ext3cow_block_truncate_page(handle, page, mapping, inode->i_size);
-+
-+	n = ext3cow_block_to_path(inode, last_block, offsets, NULL);
-+	if (n == 0)
-+		goto out_stop;	/* error */
-+
-+	/*
-+	 * OK.  This truncate is going to happen.  We add the inode to the
-+	 * orphan list, so that if this truncate spans multiple transactions,
-+	 * and we crash, we will resume the truncate when the filesystem
-+	 * recovers.  It also marks the inode dirty, to catch the new size.
-+	 *
-+	 * Implication: the file must always be in a sane, consistent
-+	 * truncatable state while each transaction commits.
-+	 */
-+	if (ext3cow_orphan_add(handle, inode))
-+		goto out_stop;
-+
-+	/*
-+	 * The orphan list entry will now protect us from any crash which
-+	 * occurs before the truncate completes, so it is now safe to propagate
-+	 * the new, shorter inode size (held for now in i_size) into the
-+	 * on-disk inode. We do this via i_disksize, which is the value which
-+	 * ext3cow *really* writes onto the disk inode.
-+	 */
-+	ei->i_disksize = inode->i_size;
-+
-+	/*
-+	 * From here we block out all ext3cow_get_block() callers who want to
-+	 * modify the block allocation tree.
-+	 */
-+	mutex_lock(&ei->truncate_mutex);
-+
-+	if (n == 1) {		/* direct blocks */
-+    unsigned int count = 0;
-+    unsigned long block_to_free = 0;
-+    unsigned long b = 0; 
-+
-+    /* We only want to remove blocks that were allocated in this
-+     * epoch, i.e., have 1 bit in the bitmap. -znjp */
-+    for(b = offsets[0]; b < EXT3COW_NDIR_BLOCKS; b++){
-+      if(EXT3COW_I(inode)->i_cow_bitmap & (1UL << b)){
-+        if(count == 0){
-+          block_to_free = b;
-+          count = 1;
-+        }else if(b == block_to_free + count){
-+          count++;
-+        }else{
-+          ext3cow_free_data(handle, inode, NULL, i_data + (int)block_to_free,
-+                            i_data + (int)(block_to_free + count));
-+          block_to_free = b;
-+          count = 1;
-+        }
-+      }
-+    }
-+    if(count > 0)
-+      ext3cow_free_data(handle, inode, NULL, i_data+(int)block_to_free,
-+                        i_data + (int)(block_to_free + count));
-+		goto do_indirects;
-+	}
-+
-+	partial = ext3cow_find_shared(inode, n, offsets, chain, &nr);
-+	/* Kill the top of shared branch (not detached) */
-+	if (nr) {
-+		if (partial == chain) {
-+			/* Shared branch grows from the inode */
-+			ext3cow_free_branches(handle, inode, NULL,
-+					   &nr, &nr+1, (chain+n-1) - partial);
-+			*partial->p = 0;
-+			/*
-+			 * We mark the inode dirty prior to restart,
-+			 * and prior to stop.  No need for it here.
-+			 */
-+		} else {
-+			/* Shared branch grows from an indirect block */
-+			BUFFER_TRACE(partial->bh, "get_write_access");
-+			ext3cow_free_branches(handle, inode, partial->bh,
-+					partial->p,
-+					partial->p+1, (chain+n-1) - partial);
-+		}
-+	}
-+	/* Clear the ends of indirect blocks on the shared branch */
-+	while (partial > chain) {
-+		ext3cow_free_branches(handle, inode, partial->bh, partial->p + 1,
-+				   (__le32*)partial->bh->b_data+addr_per_block,
-+				   (chain+n-1) - partial);
-+		BUFFER_TRACE(partial->bh, "call brelse");
-+		brelse (partial->bh);
-+		partial--;
-+	}
-+do_indirects:
-+	/* Kill the remaining (whole) subtrees */
-+  /* Unless we don't have to.  If the indirect block has a 0 bit
-+   * then all of the children do too, so we can skip the branch - znjp
-+   */
-+	switch (offsets[0]) {
-+	default:
-+   if(EXT3COW_I(inode)->i_cow_bitmap & (1UL << EXT3COW_IND_BLOCK)){
-+     nr = i_data[EXT3COW_IND_BLOCK];
-+     if (nr) {
-+       ext3cow_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
-+       i_data[EXT3COW_IND_BLOCK] = 0;
-+     }
-+   }
-+	case EXT3COW_IND_BLOCK:
-+   if(EXT3COW_I(inode)->i_cow_bitmap & (1UL << EXT3COW_DIND_BLOCK)){
-+     nr = i_data[EXT3COW_DIND_BLOCK];
-+     if (nr) {
-+       ext3cow_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
-+       i_data[EXT3COW_DIND_BLOCK] = 0;
-+     }
-+   }
-+	case EXT3COW_DIND_BLOCK:
-+   if(EXT3COW_I(inode)->i_cow_bitmap & (1UL << EXT3COW_TIND_BLOCK)){
-+     nr = i_data[EXT3COW_TIND_BLOCK];
-+     if (nr) {
-+       ext3cow_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
-+       i_data[EXT3COW_TIND_BLOCK] = 0;
-+     }
-+   }
-+	case EXT3COW_TIND_BLOCK:
-+		;
-+	}
-+
-+	ext3cow_discard_reservation(inode);
-+
-+	mutex_unlock(&ei->truncate_mutex);
-+	inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
-+	ext3cow_mark_inode_dirty(handle, inode);
-+
-+	/*
-+	 * In a multi-transaction truncate, we only make the final transaction
-+	 * synchronous
-+	 */
-+	if (IS_SYNC(inode))
-+		handle->h_sync = 1;
-+out_stop:
-+	/*
-+	 * If this was a simple ftruncate(), and the file will remain alive
-+	 * then we need to clear up the orphan record which we created above.
-+	 * However, if this was a real unlink then we were called by
-+	 * ext3cow_delete_inode(), and we allow that function to clean up the
-+	 * orphan info for us.
-+	 */
-+	if (inode->i_nlink)
-+		ext3cow_orphan_del(handle, inode);
-+
-+	ext3cow_journal_stop(handle);
-+}
-+
-+static ext3cow_fsblk_t ext3cow_get_inode_block(struct super_block *sb,
-+		unsigned long ino, struct ext3cow_iloc *iloc)
-+{
-+	unsigned long desc, group_desc, block_group;
-+	unsigned long offset;
-+	ext3cow_fsblk_t block;
-+	struct buffer_head *bh;
-+	struct ext3cow_group_desc * gdp;
-+
-+	if (!ext3cow_valid_inum(sb, ino)) {
-+		/*
-+		 * This error is already checked for in namei.c unless we are
-+		 * looking at an NFS filehandle, in which case no error
-+		 * report is needed
-+		 */
-+		return 0;
-+	}
-+
-+	block_group = (ino - 1) / EXT3COW_INODES_PER_GROUP(sb);
-+	if (block_group >= EXT3COW_SB(sb)->s_groups_count) {
-+		ext3cow_error(sb,"ext3cow_get_inode_block","group >= groups count");
-+		return 0;
-+	}
-+	smp_rmb();
-+	group_desc = block_group >> EXT3COW_DESC_PER_BLOCK_BITS(sb);
-+	desc = block_group & (EXT3COW_DESC_PER_BLOCK(sb) - 1);
-+	bh = EXT3COW_SB(sb)->s_group_desc[group_desc];
-+	if (!bh) {
-+		ext3cow_error (sb, "ext3cow_get_inode_block",
-+			    "Descriptor not loaded");
-+		return 0;
-+	}
-+
-+	gdp = (struct ext3cow_group_desc *)bh->b_data;
-+	/*
-+	 * Figure out the offset within the block group inode table
-+	 */
-+	offset = ((ino - 1) % EXT3COW_INODES_PER_GROUP(sb)) *
-+		EXT3COW_INODE_SIZE(sb);
-+	block = le32_to_cpu(gdp[desc].bg_inode_table) +
-+		(offset >> EXT3COW_BLOCK_SIZE_BITS(sb));
-+
-+	iloc->block_group = block_group;
-+	iloc->offset = offset & (EXT3COW_BLOCK_SIZE(sb) - 1);
-+	return block;
-+}
-+
-+/*
-+ * ext3cow_get_inode_loc returns with an extra refcount against the inode's
-+ * underlying buffer_head on success. If 'in_mem' is true, we have all
-+ * data in memory that is needed to recreate the on-disk version of this
-+ * inode.
-+ */
-+static int __ext3cow_get_inode_loc(struct inode *inode,
-+				struct ext3cow_iloc *iloc, int in_mem)
-+{
-+	ext3cow_fsblk_t block;
-+	struct buffer_head *bh;
-+
-+	block = ext3cow_get_inode_block(inode->i_sb, inode->i_ino, iloc);
-+	if (!block)
-+		return -EIO;
-+
-+	bh = sb_getblk(inode->i_sb, block);
-+	if (!bh) {
-+		ext3cow_error (inode->i_sb, "ext3cow_get_inode_loc",
-+				"unable to read inode block - "
-+				"inode=%lu, block="E3FSBLK,
-+				 inode->i_ino, block);
-+		return -EIO;
-+	}
-+	if (!buffer_uptodate(bh)) {
-+		lock_buffer(bh);
-+		if (buffer_uptodate(bh)) {
-+			/* someone brought it uptodate while we waited */
-+			unlock_buffer(bh);
-+			goto has_buffer;
-+		}
-+
-+		/*
-+		 * If we have all information of the inode in memory and this
-+		 * is the only valid inode in the block, we need not read the
-+		 * block.
-+		 */
-+		if (in_mem) {
-+			struct buffer_head *bitmap_bh;
-+			struct ext3cow_group_desc *desc;
-+			int inodes_per_buffer;
-+			int inode_offset, i;
-+			int block_group;
-+			int start;
-+
-+			block_group = (inode->i_ino - 1) /
-+					EXT3COW_INODES_PER_GROUP(inode->i_sb);
-+			inodes_per_buffer = bh->b_size /
-+				EXT3COW_INODE_SIZE(inode->i_sb);
-+			inode_offset = ((inode->i_ino - 1) %
-+					EXT3COW_INODES_PER_GROUP(inode->i_sb));
-+			start = inode_offset & ~(inodes_per_buffer - 1);
-+
-+			/* Is the inode bitmap in cache? */
-+			desc = ext3cow_get_group_desc(inode->i_sb,
-+						block_group, NULL);
-+			if (!desc)
-+				goto make_io;
-+
-+			bitmap_bh = sb_getblk(inode->i_sb,
-+					le32_to_cpu(desc->bg_inode_bitmap));
-+			if (!bitmap_bh)
-+				goto make_io;
-+
-+			/*
-+			 * If the inode bitmap isn't in cache then the
-+			 * optimisation may end up performing two reads instead
-+			 * of one, so skip it.
-+			 */
-+			if (!buffer_uptodate(bitmap_bh)) {
-+				brelse(bitmap_bh);
-+				goto make_io;
-+			}
-+			for (i = start; i < start + inodes_per_buffer; i++) {
-+				if (i == inode_offset)
-+					continue;
-+				if (ext3cow_test_bit(i, bitmap_bh->b_data))
-+					break;
-+			}
-+			brelse(bitmap_bh);
-+			if (i == start + inodes_per_buffer) {
-+				/* all other inodes are free, so skip I/O */
-+				memset(bh->b_data, 0, bh->b_size);
-+				set_buffer_uptodate(bh);
-+				unlock_buffer(bh);
-+				goto has_buffer;
-+			}
-+		}
-+
-+make_io:
-+		/*
-+		 * There are other valid inodes in the buffer, this inode
-+		 * has in-inode xattrs, or we don't have this inode in memory.
-+		 * Read the block from disk.
-+		 */
-+		get_bh(bh);
-+		bh->b_end_io = end_buffer_read_sync;
-+		submit_bh(READ_META, bh);
-+		wait_on_buffer(bh);
-+		if (!buffer_uptodate(bh)) {
-+			ext3cow_error(inode->i_sb, "ext3cow_get_inode_loc",
-+					"unable to read inode block - "
-+					"inode=%lu, block="E3FSBLK,
-+					inode->i_ino, block);
-+			brelse(bh);
-+			return -EIO;
-+		}
-+	}
-+has_buffer:
-+	iloc->bh = bh;
-+	return 0;
-+}
-+
-+int ext3cow_get_inode_loc(struct inode *inode, struct ext3cow_iloc *iloc)
-+{
-+	/* We have all inode data except xattrs in memory here. */
-+	return __ext3cow_get_inode_loc(inode, iloc,
-+		!(EXT3COW_I(inode)->i_state & EXT3COW_STATE_XATTR));
-+}
-+
-+void ext3cow_set_inode_flags(struct inode *inode)
-+{
-+	unsigned int flags = EXT3COW_I(inode)->i_flags;
-+
-+	inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
-+	if (flags & EXT3COW_SYNC_FL)
-+		inode->i_flags |= S_SYNC;
-+	if (flags & EXT3COW_APPEND_FL)
-+		inode->i_flags |= S_APPEND;
-+	if (flags & EXT3COW_IMMUTABLE_FL)
-+		inode->i_flags |= S_IMMUTABLE;
-+	if (flags & EXT3COW_NOATIME_FL)
-+		inode->i_flags |= S_NOATIME;
-+	if (flags & EXT3COW_DIRSYNC_FL)
-+		inode->i_flags |= S_DIRSYNC;
-+}
-+
-+void ext3cow_read_inode(struct inode * inode)
-+{
-+	struct ext3cow_iloc iloc;
-+	struct ext3cow_inode *raw_inode;
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	struct buffer_head *bh;
-+	int block;
-+
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+	ei->i_acl = EXT3COW_ACL_NOT_CACHED;
-+	ei->i_default_acl = EXT3COW_ACL_NOT_CACHED;
-+#endif
-+	ei->i_block_alloc_info = NULL;
-+
-+	if (__ext3cow_get_inode_loc(inode, &iloc, 0))
-+		goto bad_inode;
-+	bh = iloc.bh;
-+	raw_inode = ext3cow_raw_inode(&iloc);
-+	inode->i_mode = le16_to_cpu(raw_inode->i_mode);
-+	inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
-+	inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
-+	if(!(test_opt (inode->i_sb, NO_UID32))) {
-+		inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
-+		inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
-+	}
-+	inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
-+	inode->i_size = le32_to_cpu(raw_inode->i_size);
-+	inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime);
-+	inode->i_ctime.tv_sec = le32_to_cpu(raw_inode->i_ctime);
-+	inode->i_mtime.tv_sec = le32_to_cpu(raw_inode->i_mtime);
-+	inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
-+
-+	ei->i_state = 0;
-+	ei->i_dir_start_lookup = 0;
-+	ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
-+	/* We now have enough fields to check if the inode was active or not.
-+	 * This is needed because nfsd might try to access dead inodes
-+	 * the test is that same one that e2fsck uses
-+	 * NeilBrown 1999oct15
-+	 */
-+	if (inode->i_nlink == 0) {
-+		if (inode->i_mode == 0 ||
-+		    !(EXT3COW_SB(inode->i_sb)->s_mount_state & EXT3COW_ORPHAN_FS)) {
-+			/* this inode is deleted */
-+			brelse (bh);
-+			goto bad_inode;
-+		}
-+		/* The only unlinked inodes we let through here have
-+		 * valid i_mode and are being read by the orphan
-+		 * recovery code: that's fine, we're about to complete
-+		 * the process of deleting those. */
-+	}
-+	inode->i_blocks = le32_to_cpu(raw_inode->i_blocks);
-+	ei->i_flags = le32_to_cpu(raw_inode->i_flags);
-+  /* For versioning -znjp */
-+  ei->i_cow_bitmap   = le32_to_cpu(raw_inode->i_cowbitmap);
-+  ei->i_epoch_number = le32_to_cpu(raw_inode->i_epch_number);
-+  ei->i_next_inode   = le32_to_cpu(raw_inode->i_nxt_inode);
-+  
-+#ifdef EXT3COW_FRAGMENTS
-+  /* Taken out for versioning -znjp */
-+	//ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
-+	//ei->i_frag_no = raw_inode->i_frag;
-+	//ei->i_frag_size = raw_inode->i_fsize;
-+#endif
-+	ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl);
-+	if (!S_ISREG(inode->i_mode)) {
-+		ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
-+	} else {
-+		inode->i_size |=
-+			((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32;
-+	}
-+	ei->i_disksize = inode->i_size;
-+	inode->i_generation = le32_to_cpu(raw_inode->i_generation);
-+	ei->i_block_group = iloc.block_group;
-+	/*
-+	 * NOTE! The in-memory inode i_data array is in little-endian order
-+	 * even on big-endian machines: we do NOT byteswap the block numbers!
-+	 */
-+	for (block = 0; block < EXT3COW_N_BLOCKS; block++)
-+		ei->i_data[block] = raw_inode->i_block[block];
-+	INIT_LIST_HEAD(&ei->i_orphan);
-+
-+	if (inode->i_ino >= EXT3COW_FIRST_INO(inode->i_sb) + 1 &&
-+	    EXT3COW_INODE_SIZE(inode->i_sb) > EXT3COW_GOOD_OLD_INODE_SIZE) {
-+		/*
-+		 * When mke2fs creates big inodes it does not zero out
-+		 * the unused bytes above EXT3COW_GOOD_OLD_INODE_SIZE,
-+		 * so ignore those first few inodes.
-+		 */
-+		ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize);
-+		if (EXT3COW_GOOD_OLD_INODE_SIZE + ei->i_extra_isize >
-+		    EXT3COW_INODE_SIZE(inode->i_sb))
-+			goto bad_inode;
-+		if (ei->i_extra_isize == 0) {
-+			/* The extra space is currently unused. Use it. */
-+			ei->i_extra_isize = sizeof(struct ext3cow_inode) -
-+					    EXT3COW_GOOD_OLD_INODE_SIZE;
-+		} else {
-+			__le32 *magic = (void *)raw_inode +
-+					EXT3COW_GOOD_OLD_INODE_SIZE +
-+					ei->i_extra_isize;
-+			if (*magic == cpu_to_le32(EXT3COW_XATTR_MAGIC))
-+				 ei->i_state |= EXT3COW_STATE_XATTR;
-+		}
-+	} else
-+		ei->i_extra_isize = 0;
-+
-+	if (S_ISREG(inode->i_mode)) {
-+		inode->i_op = &ext3cow_file_inode_operations;
-+		inode->i_fop = &ext3cow_file_operations;
-+		ext3cow_set_aops(inode);
-+	} else if (S_ISDIR(inode->i_mode)) {
-+		inode->i_op = &ext3cow_dir_inode_operations;
-+		inode->i_fop = &ext3cow_dir_operations;
-+	} else if (S_ISLNK(inode->i_mode)) {
-+		if (ext3cow_inode_is_fast_symlink(inode))
-+			inode->i_op = &ext3cow_fast_symlink_inode_operations;
-+		else {
-+			inode->i_op = &ext3cow_symlink_inode_operations;
-+			ext3cow_set_aops(inode);
-+		}
-+	} else {
-+		inode->i_op = &ext3cow_special_inode_operations;
-+		if (raw_inode->i_block[0])
-+			init_special_inode(inode, inode->i_mode,
-+			   old_decode_dev(le32_to_cpu(raw_inode->i_block[0])));
-+		else
-+			init_special_inode(inode, inode->i_mode,
-+			   new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
-+	}
-+	brelse (iloc.bh);
-+	ext3cow_set_inode_flags(inode);
-+	return;
-+
-+bad_inode:
-+	make_bad_inode(inode);
-+	return;
-+}
-+
-+/*
-+ * Post the struct inode info into an on-disk inode location in the
-+ * buffer-cache.  This gobbles the caller's reference to the
-+ * buffer_head in the inode location struct.
-+ *
-+ * The caller must have write access to iloc->bh.
-+ */
-+static int ext3cow_do_update_inode(handle_t *handle,
-+				struct inode *inode,
-+				struct ext3cow_iloc *iloc)
-+{
-+	struct ext3cow_inode *raw_inode = ext3cow_raw_inode(iloc);
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	struct buffer_head *bh = iloc->bh;
-+	int err = 0, rc, block;
-+
-+	/* For fields not not tracking in the in-memory inode,
-+	 * initialise them to zero for new inodes. */
-+	if (ei->i_state & EXT3COW_STATE_NEW)
-+		memset(raw_inode, 0, EXT3COW_SB(inode->i_sb)->s_inode_size);
-+
-+	raw_inode->i_mode = cpu_to_le16(inode->i_mode);
-+
-+
-+	if(!(test_opt(inode->i_sb, NO_UID32))) {
-+		raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
-+		raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
-+    
-+    /* Fix up interoperability with old kernels. Otherwise, old inodes get
-+     * re-used with the upper 16 bits of the uid/gid intact
-+     */
-+    
-+		if(!ei->i_dtime) {
-+			raw_inode->i_uid_high =
-+				cpu_to_le16(high_16_bits(inode->i_uid));
-+			raw_inode->i_gid_high =
-+				cpu_to_le16(high_16_bits(inode->i_gid));
-+		} else {
-+			raw_inode->i_uid_high = 0;
-+			raw_inode->i_gid_high = 0;
-+		}
-+    
-+	} else {
-+		raw_inode->i_uid_low =
-+			cpu_to_le16(fs_high2lowuid(inode->i_uid));
-+		raw_inode->i_gid_low =
-+			cpu_to_le16(fs_high2lowgid(inode->i_gid));
-+		raw_inode->i_uid_high = 0;
-+		raw_inode->i_gid_high = 0;
-+	}
-+ 
-+	raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
-+	raw_inode->i_size = cpu_to_le32(ei->i_disksize);
-+	raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
-+	raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
-+	raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
-+	raw_inode->i_blocks = cpu_to_le32(inode->i_blocks);
-+	raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
-+	raw_inode->i_flags = cpu_to_le32(ei->i_flags);
-+  /* For versioning -znjp */
-+  raw_inode->i_cowbitmap   = cpu_to_le16(EXT3COW_I(inode)->i_cow_bitmap);
-+  raw_inode->i_epch_number = cpu_to_le32(EXT3COW_I(inode)->i_epoch_number);
-+  raw_inode->i_nxt_inode   = cpu_to_le32(EXT3COW_I(inode)->i_next_inode);
-+
-+#ifdef EXT3COW_FRAGMENTS
-+  /* Taken out for versioning -znjp */
-+	//raw_inode->i_faddr = cpu_to_le32(ei->i_faddr);
-+	//raw_inode->i_frag = ei->i_frag_no;
-+	//raw_inode->i_fsize = ei->i_frag_size;
-+#endif
-+	raw_inode->i_file_acl = cpu_to_le32(ei->i_file_acl);
-+	if (!S_ISREG(inode->i_mode)) {
-+		raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl);
-+	} else {
-+		raw_inode->i_size_high =
-+			cpu_to_le32(ei->i_disksize >> 32);
-+		if (ei->i_disksize > 0x7fffffffULL) {
-+			struct super_block *sb = inode->i_sb;
-+			if (!EXT3COW_HAS_RO_COMPAT_FEATURE(sb,
-+					EXT3COW_FEATURE_RO_COMPAT_LARGE_FILE) ||
-+			    EXT3COW_SB(sb)->s_es->s_rev_level ==
-+					cpu_to_le32(EXT3COW_GOOD_OLD_REV)) {
-+			       /* If this is the first large file
-+				* created, add a flag to the superblock.
-+				*/
-+				err = ext3cow_journal_get_write_access(handle,
-+						EXT3COW_SB(sb)->s_sbh);
-+				if (err)
-+					goto out_brelse;
-+				ext3cow_update_dynamic_rev(sb);
-+				EXT3COW_SET_RO_COMPAT_FEATURE(sb,
-+					EXT3COW_FEATURE_RO_COMPAT_LARGE_FILE);
-+				sb->s_dirt = 1;
-+				handle->h_sync = 1;
-+				err = ext3cow_journal_dirty_metadata(handle,
-+						EXT3COW_SB(sb)->s_sbh);
-+			}
-+		}
-+	}
-+	raw_inode->i_generation = cpu_to_le32(inode->i_generation);
-+	if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
-+		if (old_valid_dev(inode->i_rdev)) {
-+			raw_inode->i_block[0] =
-+				cpu_to_le32(old_encode_dev(inode->i_rdev));
-+			raw_inode->i_block[1] = 0;
-+		} else {
-+			raw_inode->i_block[0] = 0;
-+			raw_inode->i_block[1] =
-+				cpu_to_le32(new_encode_dev(inode->i_rdev));
-+			raw_inode->i_block[2] = 0;
-+		}
-+	} else for (block = 0; block < EXT3COW_N_BLOCKS; block++)
-+		raw_inode->i_block[block] = ei->i_data[block];
-+
-+	if (ei->i_extra_isize)
-+		raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
-+
-+	BUFFER_TRACE(bh, "call ext3cow_journal_dirty_metadata");
-+	rc = ext3cow_journal_dirty_metadata(handle, bh);
-+	if (!err)
-+		err = rc;
-+	ei->i_state &= ~EXT3COW_STATE_NEW;
-+
-+out_brelse:
-+	brelse (bh);
-+	ext3cow_std_error(inode->i_sb, err);
-+	return err;
-+}
-+
-+/*
-+ * ext3cow_write_inode()
-+ *
-+ * We are called from a few places:
-+ *
-+ * - Within generic_file_write() for O_SYNC files.
-+ *   Here, there will be no transaction running. We wait for any running
-+ *   trasnaction to commit.
-+ *
-+ * - Within sys_sync(), kupdate and such.
-+ *   We wait on commit, if tol to.
-+ *
-+ * - Within prune_icache() (PF_MEMALLOC == true)
-+ *   Here we simply return.  We can't afford to block kswapd on the
-+ *   journal commit.
-+ *
-+ * In all cases it is actually safe for us to return without doing anything,
-+ * because the inode has been copied into a raw inode buffer in
-+ * ext3cow_mark_inode_dirty().  This is a correctness thing for O_SYNC and for
-+ * knfsd.
-+ *
-+ * Note that we are absolutely dependent upon all inode dirtiers doing the
-+ * right thing: they *must* call mark_inode_dirty() after dirtying info in
-+ * which we are interested.
-+ *
-+ * It would be a bug for them to not do this.  The code:
-+ *
-+ *	mark_inode_dirty(inode)
-+ *	stuff();
-+ *	inode->i_size = expr;
-+ *
-+ * is in error because a kswapd-driven write_inode() could occur while
-+ * `stuff()' is running, and the new i_size will be lost.  Plus the inode
-+ * will no longer be on the superblock's dirty inode list.
-+ */
-+int ext3cow_write_inode(struct inode *inode, int wait)
-+{
-+	if (current->flags & PF_MEMALLOC)
-+		return 0;
-+
-+	if (ext3cow_journal_current_handle()) {
-+		jbd_debug(0, "called recursively, non-PF_MEMALLOC!\n");
-+		dump_stack();
-+		return -EIO;
-+	}
-+
-+	if (!wait)
-+		return 0;
-+
-+	return ext3cow_force_commit(inode->i_sb);
-+}
-+
-+/*
-+ * ext3cow_setattr()
-+ *
-+ * Called from notify_change.
-+ *
-+ * We want to trap VFS attempts to truncate the file as soon as
-+ * possible.  In particular, we want to make sure that when the VFS
-+ * shrinks i_size, we put the inode on the orphan list and modify
-+ * i_disksize immediately, so that during the subsequent flushing of
-+ * dirty pages and freeing of disk blocks, we can guarantee that any
-+ * commit will leave the blocks being flushed in an unused state on
-+ * disk.  (On recovery, the inode will get truncated and the blocks will
-+ * be freed, so we have a strong guarantee that no future commit will
-+ * leave these blocks visible to the user.)
-+ *
-+ * Called with inode->sem down.
-+ */
-+int ext3cow_setattr(struct dentry *dentry, struct iattr *attr)
-+{
-+	struct inode *inode = dentry->d_inode;
-+	int error, rc = 0;
-+	const unsigned int ia_valid = attr->ia_valid;
-+
-+	error = inode_change_ok(inode, attr);
-+	if (error)
-+		return error;
-+
-+  /* For versioning -znjp */
-+  if(is_unchangeable(inode, dentry)){
-+    error = -EROFS;
-+    goto err_out;
-+  }
-+  
-+  if(EXT3COW_S_EPOCHNUMBER(inode->i_sb) > EXT3COW_I_EPOCHNUMBER(inode)){
-+    error = ext3cow_dup_inode(dentry->d_parent->d_inode, inode);
-+    if(error)
-+      goto err_out;
-+  }
-+  
-+	if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
-+		(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
-+		handle_t *handle;
-+
-+		/* (user+group)*(old+new) structure, inode write (sb,
-+		 * inode block, ? - but truncate inode update has it) */
-+		handle = ext3cow_journal_start(inode, 2*(EXT3COW_QUOTA_INIT_BLOCKS(inode->i_sb)+
-+					EXT3COW_QUOTA_DEL_BLOCKS(inode->i_sb))+3);
-+		if (IS_ERR(handle)) {
-+			error = PTR_ERR(handle);
-+			goto err_out;
-+		}
-+		error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
-+		if (error) {
-+			ext3cow_journal_stop(handle);
-+			return error;
-+		}
-+		/* Update corresponding info in inode so that everything is in
-+		 * one transaction */
-+		if (attr->ia_valid & ATTR_UID)
-+			inode->i_uid = attr->ia_uid;
-+		if (attr->ia_valid & ATTR_GID)
-+			inode->i_gid = attr->ia_gid;
-+		error = ext3cow_mark_inode_dirty(handle, inode);
-+		ext3cow_journal_stop(handle);
-+	}
-+
-+	if (S_ISREG(inode->i_mode) &&
-+	    attr->ia_valid & ATTR_SIZE && attr->ia_size < inode->i_size) {
-+		handle_t *handle;
-+
-+		handle = ext3cow_journal_start(inode, 3);
-+		if (IS_ERR(handle)) {
-+			error = PTR_ERR(handle);
-+			goto err_out;
-+		}
-+
-+		error = ext3cow_orphan_add(handle, inode);
-+		EXT3COW_I(inode)->i_disksize = attr->ia_size;
-+		rc = ext3cow_mark_inode_dirty(handle, inode);
-+		if (!error)
-+			error = rc;
-+		ext3cow_journal_stop(handle);
-+	}
-+
-+	rc = inode_setattr(inode, attr);
-+
-+	/* If inode_setattr's call to ext3cow_truncate failed to get a
-+	 * transaction handle at all, we need to clean up the in-core
-+	 * orphan list manually. */
-+	if (inode->i_nlink)
-+		ext3cow_orphan_del(NULL, inode);
-+
-+	if (!rc && (ia_valid & ATTR_MODE))
-+		rc = ext3cow_acl_chmod(inode);
-+
-+err_out:
-+	ext3cow_std_error(inode->i_sb, error);
-+	if (!error)
-+		error = rc;
-+	return error;
-+}
-+
-+
-+/*
-+ * How many blocks doth make a writepage()?
-+ *
-+ * With N blocks per page, it may be:
-+ * N data blocks
-+ * 2 indirect block
-+ * 2 dindirect
-+ * 1 tindirect
-+ * N+5 bitmap blocks (from the above)
-+ * N+5 group descriptor summary blocks
-+ * 1 inode block
-+ * 1 superblock.
-+ * 2 * EXT3COW_SINGLEDATA_TRANS_BLOCKS for the quote files
-+ *
-+ * 3 * (N + 5) + 2 + 2 * EXT3COW_SINGLEDATA_TRANS_BLOCKS
-+ *
-+ * With ordered or writeback data it's the same, less the N data blocks.
-+ *
-+ * If the inode's direct blocks can hold an integral number of pages then a
-+ * page cannot straddle two indirect blocks, and we can only touch one indirect
-+ * and dindirect block, and the "5" above becomes "3".
-+ *
-+ * This still overestimates under most circumstances.  If we were to pass the
-+ * start and end offsets in here as well we could do block_to_path() on each
-+ * block and work out the exact number of indirects which are touched.  Pah.
-+ */
-+
-+static int ext3cow_writepage_trans_blocks(struct inode *inode)
-+{
-+	int bpp = ext3cow_journal_blocks_per_page(inode);
-+	int indirects = (EXT3COW_NDIR_BLOCKS % bpp) ? 5 : 3;
-+	int ret;
-+
-+	if (ext3cow_should_journal_data(inode))
-+		ret = 3 * (bpp + indirects) + 2;
-+	else
-+		ret = 2 * (bpp + indirects) + 2;
-+
-+#ifdef CONFIG_QUOTA
-+	/* We know that structure was already allocated during DQUOT_INIT so
-+	 * we will be updating only the data blocks + inodes */
-+	ret += 2*EXT3COW_QUOTA_TRANS_BLOCKS(inode->i_sb);
-+#endif
-+
-+	return ret;
-+}
-+
-+/*
-+ * The caller must have previously called ext3cow_reserve_inode_write().
-+ * Give this, we know that the caller already has write access to iloc->bh.
-+ */
-+int ext3cow_mark_iloc_dirty(handle_t *handle,
-+		struct inode *inode, struct ext3cow_iloc *iloc)
-+{
-+	int err = 0;
-+
-+	/* the do_update_inode consumes one bh->b_count */
-+	get_bh(iloc->bh);
-+
-+	/* ext3cow_do_update_inode() does journal_dirty_metadata */
-+	err = ext3cow_do_update_inode(handle, inode, iloc);
-+	put_bh(iloc->bh);
-+	return err;
-+}
-+
-+/*
-+ * On success, We end up with an outstanding reference count against
-+ * iloc->bh.  This _must_ be cleaned up later.
-+ */
-+
-+int
-+ext3cow_reserve_inode_write(handle_t *handle, struct inode *inode,
-+			 struct ext3cow_iloc *iloc)
-+{
-+	int err = 0;
-+	if (handle) {
-+		err = ext3cow_get_inode_loc(inode, iloc);
-+		if (!err) {
-+			BUFFER_TRACE(iloc->bh, "get_write_access");
-+			err = ext3cow_journal_get_write_access(handle, iloc->bh);
-+			if (err) {
-+				brelse(iloc->bh);
-+				iloc->bh = NULL;
-+			}
-+		}
-+	}
-+	ext3cow_std_error(inode->i_sb, err);
-+	return err;
-+}
-+
-+/*
-+ * What we do here is to mark the in-core inode as clean with respect to inode
-+ * dirtiness (it may still be data-dirty).
-+ * This means that the in-core inode may be reaped by prune_icache
-+ * without having to perform any I/O.  This is a very good thing,
-+ * because *any* task may call prune_icache - even ones which
-+ * have a transaction open against a different journal.
-+ *
-+ * Is this cheating?  Not really.  Sure, we haven't written the
-+ * inode out, but prune_icache isn't a user-visible syncing function.
-+ * Whenever the user wants stuff synced (sys_sync, sys_msync, sys_fsync)
-+ * we start and wait on commits.
-+ *
-+ * Is this efficient/effective?  Well, we're being nice to the system
-+ * by cleaning up our inodes proactively so they can be reaped
-+ * without I/O.  But we are potentially leaving up to five seconds'
-+ * worth of inodes floating about which prune_icache wants us to
-+ * write out.  One way to fix that would be to get prune_icache()
-+ * to do a write_super() to free up some memory.  It has the desired
-+ * effect.
-+ */
-+int ext3cow_mark_inode_dirty(handle_t *handle, struct inode *inode)
-+{
-+	struct ext3cow_iloc iloc;
-+	int err;
-+
-+  if(EXT3COW_IS_FAKEINODE(inode))
-+    return 0;
-+
-+	might_sleep();
-+	err = ext3cow_reserve_inode_write(handle, inode, &iloc);
-+	if (!err)
-+		err = ext3cow_mark_iloc_dirty(handle, inode, &iloc);
-+	return err;
-+}
-+
-+/*
-+ * ext3cow_dirty_inode() is called from __mark_inode_dirty()
-+ *
-+ * We're really interested in the case where a file is being extended.
-+ * i_size has been changed by generic_commit_write() and we thus need
-+ * to include the updated inode in the current transaction.
-+ *
-+ * Also, DQUOT_ALLOC_SPACE() will always dirty the inode when blocks
-+ * are allocated to the file.
-+ *
-+ * If the inode is marked synchronous, we don't honour that here - doing
-+ * so would cause a commit on atime updates, which we don't bother doing.
-+ * We handle synchronous inodes at the highest possible level.
-+ */
-+void ext3cow_dirty_inode(struct inode *inode)
-+{
-+	handle_t *current_handle = ext3cow_journal_current_handle();
-+	handle_t *handle;
-+
-+	handle = ext3cow_journal_start(inode, 2);
-+	if (IS_ERR(handle))
-+		goto out;
-+	if (current_handle &&
-+		current_handle->h_transaction != handle->h_transaction) {
-+		/* This task has a transaction open against a different fs */
-+		printk(KERN_EMERG "%s: transactions do not match!\n",
-+		       __FUNCTION__);
-+	} else {
-+		jbd_debug(5, "marking dirty.  outer handle=%p\n",
-+				current_handle);
-+		ext3cow_mark_inode_dirty(handle, inode);
-+	}
-+	ext3cow_journal_stop(handle);
-+out:
-+	return;
-+}
-+
-+#if 0
-+/*
-+ * Bind an inode's backing buffer_head into this transaction, to prevent
-+ * it from being flushed to disk early.  Unlike
-+ * ext3cow_reserve_inode_write, this leaves behind no bh reference and
-+ * returns no iloc structure, so the caller needs to repeat the iloc
-+ * lookup to mark the inode dirty later.
-+ */
-+static int ext3cow_pin_inode(handle_t *handle, struct inode *inode)
-+{
-+	struct ext3cow_iloc iloc;
-+
-+	int err = 0;
-+	if (handle) {
-+		err = ext3cow_get_inode_loc(inode, &iloc);
-+		if (!err) {
-+			BUFFER_TRACE(iloc.bh, "get_write_access");
-+			err = journal_get_write_access(handle, iloc.bh);
-+			if (!err)
-+				err = ext3cow_journal_dirty_metadata(handle,
-+								  iloc.bh);
-+			brelse(iloc.bh);
-+		}
-+	}
-+	ext3cow_std_error(inode->i_sb, err);
-+	return err;
-+}
-+#endif
-+
-+int ext3cow_change_inode_journal_flag(struct inode *inode, int val)
-+{
-+	journal_t *journal;
-+	handle_t *handle;
-+	int err;
-+
-+	/*
-+	 * We have to be very careful here: changing a data block's
-+	 * journaling status dynamically is dangerous.  If we write a
-+	 * data block to the journal, change the status and then delete
-+	 * that block, we risk forgetting to revoke the old log record
-+	 * from the journal and so a subsequent replay can corrupt data.
-+	 * So, first we make sure that the journal is empty and that
-+	 * nobody is changing anything.
-+	 */
-+
-+	journal = EXT3COW_JOURNAL(inode);
-+	if (is_journal_aborted(journal) || IS_RDONLY(inode))
-+		return -EROFS;
-+
-+	journal_lock_updates(journal);
-+	journal_flush(journal);
-+
-+	/*
-+	 * OK, there are no updates running now, and all cached data is
-+	 * synced to disk.  We are now in a completely consistent state
-+	 * which doesn't have anything in the journal, and we know that
-+	 * no filesystem updates are running, so it is safe to modify
-+	 * the inode's in-core data-journaling state flag now.
-+	 */
-+
-+	if (val)
-+		EXT3COW_I(inode)->i_flags |= EXT3COW_JOURNAL_DATA_FL;
-+	else
-+		EXT3COW_I(inode)->i_flags &= ~EXT3COW_JOURNAL_DATA_FL;
-+	ext3cow_set_aops(inode);
-+
-+	journal_unlock_updates(journal);
-+
-+	/* Finally we can mark the inode as dirty. */
-+
-+	handle = ext3cow_journal_start(inode, 1);
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	err = ext3cow_mark_inode_dirty(handle, inode);
-+	handle->h_sync = 1;
-+	ext3cow_journal_stop(handle);
-+	ext3cow_std_error(inode->i_sb, err);
-+
-+	return err;
-+}
-diff -Naur linux-2.6.21.7/fs/ext3cow/ioctl.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/ioctl.c
---- linux-2.6.21.7/fs/ext3cow/ioctl.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/ioctl.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,312 @@
-+/*
-+ * linux/fs/ext3cow/ioctl.c
-+ *
-+ * Copyright (C) 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ */
-+
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/capability.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/time.h>
-+#include <linux/compat.h>
-+#include <linux/smp_lock.h>
-+#include <asm/uaccess.h>
-+
-+int ext3cow_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
-+		unsigned long arg)
-+{
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	unsigned int flags;
-+	unsigned short rsv_window_size;
-+
-+	ext3cow_debug ("cmd = %u, arg = %lu\n", cmd, arg);
-+
-+	switch (cmd) {
-+    /* Some IOCTLs for version */
-+   case EXT3COW_IOC_TAKESNAPSHOT:
-+    return (unsigned int)ext3cow_take_snapshot(inode->i_sb);
-+   case EXT3COW_IOC_GETEPOCH:
-+    return (unsigned int)EXT3COW_S_EPOCHNUMBER(inode->i_sb);
-+	case EXT3COW_IOC_GETFLAGS:
-+		flags = ei->i_flags & EXT3COW_FL_USER_VISIBLE;
-+		return put_user(flags, (int __user *) arg);
-+	case EXT3COW_IOC_SETFLAGS: {
-+		handle_t *handle = NULL;
-+		int err;
-+		struct ext3cow_iloc iloc;
-+		unsigned int oldflags;
-+		unsigned int jflag;
-+
-+		if (IS_RDONLY(inode))
-+			return -EROFS;
-+
-+		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-+			return -EACCES;
-+
-+		if (get_user(flags, (int __user *) arg))
-+			return -EFAULT;
-+
-+		if (!S_ISDIR(inode->i_mode))
-+			flags &= ~EXT3COW_DIRSYNC_FL;
-+
-+		mutex_lock(&inode->i_mutex);
-+		oldflags = ei->i_flags;
-+
-+		/* The JOURNAL_DATA flag is modifiable only by root */
-+		jflag = flags & EXT3COW_JOURNAL_DATA_FL;
-+
-+		/*
-+		 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
-+		 * the relevant capability.
-+		 *
-+		 * This test looks nicer. Thanks to Pauline Middelink
-+		 */
-+		if ((flags ^ oldflags) & (EXT3COW_APPEND_FL | EXT3COW_IMMUTABLE_FL)) {
-+			if (!capable(CAP_LINUX_IMMUTABLE)) {
-+				mutex_unlock(&inode->i_mutex);
-+				return -EPERM;
-+			}
-+		}
-+
-+		/*
-+		 * The JOURNAL_DATA flag can only be changed by
-+		 * the relevant capability.
-+		 */
-+		if ((jflag ^ oldflags) & (EXT3COW_JOURNAL_DATA_FL)) {
-+			if (!capable(CAP_SYS_RESOURCE)) {
-+				mutex_unlock(&inode->i_mutex);
-+				return -EPERM;
-+			}
-+		}
-+
-+
-+		handle = ext3cow_journal_start(inode, 1);
-+		if (IS_ERR(handle)) {
-+			mutex_unlock(&inode->i_mutex);
-+			return PTR_ERR(handle);
-+		}
-+		if (IS_SYNC(inode))
-+			handle->h_sync = 1;
-+		err = ext3cow_reserve_inode_write(handle, inode, &iloc);
-+		if (err)
-+			goto flags_err;
-+
-+		flags = flags & EXT3COW_FL_USER_MODIFIABLE;
-+		flags |= oldflags & ~EXT3COW_FL_USER_MODIFIABLE;
-+		ei->i_flags = flags;
-+
-+		ext3cow_set_inode_flags(inode);
-+		inode->i_ctime = CURRENT_TIME_SEC;
-+
-+		err = ext3cow_mark_iloc_dirty(handle, inode, &iloc);
-+flags_err:
-+		ext3cow_journal_stop(handle);
-+		if (err) {
-+			mutex_unlock(&inode->i_mutex);
-+			return err;
-+		}
-+
-+		if ((jflag ^ oldflags) & (EXT3COW_JOURNAL_DATA_FL))
-+			err = ext3cow_change_inode_journal_flag(inode, jflag);
-+		mutex_unlock(&inode->i_mutex);
-+		return err;
-+	}
-+	case EXT3COW_IOC_GETVERSION:
-+	case EXT3COW_IOC_GETVERSION_OLD:
-+		return put_user(inode->i_generation, (int __user *) arg);
-+	case EXT3COW_IOC_SETVERSION:
-+	case EXT3COW_IOC_SETVERSION_OLD: {
-+		handle_t *handle;
-+		struct ext3cow_iloc iloc;
-+		__u32 generation;
-+		int err;
-+
-+		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-+			return -EPERM;
-+		if (IS_RDONLY(inode))
-+			return -EROFS;
-+		if (get_user(generation, (int __user *) arg))
-+			return -EFAULT;
-+
-+		handle = ext3cow_journal_start(inode, 1);
-+		if (IS_ERR(handle))
-+			return PTR_ERR(handle);
-+		err = ext3cow_reserve_inode_write(handle, inode, &iloc);
-+		if (err == 0) {
-+			inode->i_ctime = CURRENT_TIME_SEC;
-+			inode->i_generation = generation;
-+			err = ext3cow_mark_iloc_dirty(handle, inode, &iloc);
-+		}
-+		ext3cow_journal_stop(handle);
-+		return err;
-+	}
-+#ifdef CONFIG_JBD_DEBUG
-+	case EXT3COW_IOC_WAIT_FOR_READONLY:
-+		/*
-+		 * This is racy - by the time we're woken up and running,
-+		 * the superblock could be released.  And the module could
-+		 * have been unloaded.  So sue me.
-+		 *
-+		 * Returns 1 if it slept, else zero.
-+		 */
-+		{
-+			struct super_block *sb = inode->i_sb;
-+			DECLARE_WAITQUEUE(wait, current);
-+			int ret = 0;
-+
-+			set_current_state(TASK_INTERRUPTIBLE);
-+			add_wait_queue(&EXT3COW_SB(sb)->ro_wait_queue, &wait);
-+			if (timer_pending(&EXT3COW_SB(sb)->turn_ro_timer)) {
-+				schedule();
-+				ret = 1;
-+			}
-+			remove_wait_queue(&EXT3COW_SB(sb)->ro_wait_queue, &wait);
-+			return ret;
-+		}
-+#endif
-+	case EXT3COW_IOC_GETRSVSZ:
-+		if (test_opt(inode->i_sb, RESERVATION)
-+			&& S_ISREG(inode->i_mode)
-+			&& ei->i_block_alloc_info) {
-+			rsv_window_size = ei->i_block_alloc_info->rsv_window_node.rsv_goal_size;
-+			return put_user(rsv_window_size, (int __user *)arg);
-+		}
-+		return -ENOTTY;
-+	case EXT3COW_IOC_SETRSVSZ: {
-+
-+		if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
-+			return -ENOTTY;
-+
-+		if (IS_RDONLY(inode))
-+			return -EROFS;
-+
-+		if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-+			return -EACCES;
-+
-+		if (get_user(rsv_window_size, (int __user *)arg))
-+			return -EFAULT;
-+
-+		if (rsv_window_size > EXT3COW_MAX_RESERVE_BLOCKS)
-+			rsv_window_size = EXT3COW_MAX_RESERVE_BLOCKS;
-+
-+		/*
-+		 * need to allocate reservation structure for this inode
-+		 * before set the window size
-+		 */
-+		mutex_lock(&ei->truncate_mutex);
-+		if (!ei->i_block_alloc_info)
-+			ext3cow_init_block_alloc_info(inode);
-+
-+		if (ei->i_block_alloc_info){
-+			struct ext3cow_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
-+			rsv->rsv_goal_size = rsv_window_size;
-+		}
-+		mutex_unlock(&ei->truncate_mutex);
-+		return 0;
-+	}
-+	case EXT3COW_IOC_GROUP_EXTEND: {
-+		ext3cow_fsblk_t n_blocks_count;
-+		struct super_block *sb = inode->i_sb;
-+		int err;
-+
-+		if (!capable(CAP_SYS_RESOURCE))
-+			return -EPERM;
-+
-+		if (IS_RDONLY(inode))
-+			return -EROFS;
-+
-+		if (get_user(n_blocks_count, (__u32 __user *)arg))
-+			return -EFAULT;
-+
-+		err = ext3cow_group_extend(sb, EXT3COW_SB(sb)->s_es, n_blocks_count);
-+		journal_lock_updates(EXT3COW_SB(sb)->s_journal);
-+		journal_flush(EXT3COW_SB(sb)->s_journal);
-+		journal_unlock_updates(EXT3COW_SB(sb)->s_journal);
-+
-+		return err;
-+	}
-+	case EXT3COW_IOC_GROUP_ADD: {
-+		struct ext3cow_new_group_data input;
-+		struct super_block *sb = inode->i_sb;
-+		int err;
-+
-+		if (!capable(CAP_SYS_RESOURCE))
-+			return -EPERM;
-+
-+		if (IS_RDONLY(inode))
-+			return -EROFS;
-+
-+		if (copy_from_user(&input, (struct ext3cow_new_group_input __user *)arg,
-+				sizeof(input)))
-+			return -EFAULT;
-+
-+		err = ext3cow_group_add(sb, &input);
-+		journal_lock_updates(EXT3COW_SB(sb)->s_journal);
-+		journal_flush(EXT3COW_SB(sb)->s_journal);
-+		journal_unlock_updates(EXT3COW_SB(sb)->s_journal);
-+
-+		return err;
-+	}
-+
-+
-+	default:
-+		return -ENOTTY;
-+	}
-+}
-+
-+#ifdef CONFIG_COMPAT
-+long ext3cow_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-+{
-+	struct inode *inode = file->f_path.dentry->d_inode;
-+	int ret;
-+
-+	/* These are just misnamed, they actually get/put from/to user an int */
-+	switch (cmd) {
-+	case EXT3COW_IOC32_GETFLAGS:
-+		cmd = EXT3COW_IOC_GETFLAGS;
-+		break;
-+	case EXT3COW_IOC32_SETFLAGS:
-+		cmd = EXT3COW_IOC_SETFLAGS;
-+		break;
-+	case EXT3COW_IOC32_GETVERSION:
-+		cmd = EXT3COW_IOC_GETVERSION;
-+		break;
-+	case EXT3COW_IOC32_SETVERSION:
-+		cmd = EXT3COW_IOC_SETVERSION;
-+		break;
-+	case EXT3COW_IOC32_GROUP_EXTEND:
-+		cmd = EXT3COW_IOC_GROUP_EXTEND;
-+		break;
-+	case EXT3COW_IOC32_GETVERSION_OLD:
-+		cmd = EXT3COW_IOC_GETVERSION_OLD;
-+		break;
-+	case EXT3COW_IOC32_SETVERSION_OLD:
-+		cmd = EXT3COW_IOC_SETVERSION_OLD;
-+		break;
-+#ifdef CONFIG_JBD_DEBUG
-+	case EXT3COW_IOC32_WAIT_FOR_READONLY:
-+		cmd = EXT3COW_IOC_WAIT_FOR_READONLY;
-+		break;
-+#endif
-+	case EXT3COW_IOC32_GETRSVSZ:
-+		cmd = EXT3COW_IOC_GETRSVSZ;
-+		break;
-+	case EXT3COW_IOC32_SETRSVSZ:
-+		cmd = EXT3COW_IOC_SETRSVSZ;
-+		break;
-+	case EXT3COW_IOC_GROUP_ADD:
-+		break;
-+	default:
-+		return -ENOIOCTLCMD;
-+	}
-+	lock_kernel();
-+	ret = ext3cow_ioctl(inode, file, cmd, (unsigned long) compat_ptr(arg));
-+	unlock_kernel();
-+	return ret;
-+}
-+#endif
-diff -Naur linux-2.6.21.7/fs/ext3cow/Makefile linux-2.6.21.7_ext3cowPatched/fs/ext3cow/Makefile
---- linux-2.6.21.7/fs/ext3cow/Makefile	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/Makefile	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,12 @@
-+#
-+# Makefile for the linux ext3cow-filesystem routines.
-+#
-+
-+obj-$(CONFIG_EXT3COW_FS) += ext3cow.o
-+
-+ext3cow-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
-+	   ioctl.o namei.o super.o symlink.o hash.o resize.o ext3cow_jbd.o
-+
-+ext3cow-$(CONFIG_EXT3COW_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
-+ext3cow-$(CONFIG_EXT3COW_FS_POSIX_ACL) += acl.o
-+ext3cow-$(CONFIG_EXT3COW_FS_SECURITY)	 += xattr_security.o
-diff -Naur linux-2.6.21.7/fs/ext3cow/namei.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/namei.c
---- linux-2.6.21.7/fs/ext3cow/namei.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/namei.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,2981 @@
-+/*
-+ *  linux/fs/ext3cow/namei.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/fs/minix/namei.c
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ *
-+ *  Big-endian to little-endian byte-swapping/bitmaps by
-+ *        David S. Miller (davem@caip.rutgers.edu), 1995
-+ *  Directory entry file type support and forward compatibility hooks
-+ *	for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998
-+ *  Hash Tree Directory indexing (c)
-+ *	Daniel Phillips, 2001
-+ *  Hash Tree Directory indexing porting
-+ *	Christopher Li, 2002
-+ *  Hash Tree Directory indexing cleanup
-+ *	Theodore Ts'o, 2002
-+ */
-+
-+#include <linux/fs.h>
-+#include <linux/pagemap.h>
-+#include <linux/jbd.h>
-+#include <linux/time.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/fcntl.h>
-+#include <linux/stat.h>
-+#include <linux/string.h>
-+#include <linux/quotaops.h>
-+#include <linux/buffer_head.h>
-+#include <linux/bio.h>
-+#include <linux/smp_lock.h>
-+
-+#include "namei.h"
-+#include "xattr.h"
-+#include "acl.h"
-+
-+/*
-+ * define how far ahead to read directories while searching them.
-+ */
-+#define NAMEI_RA_CHUNKS  2
-+#define NAMEI_RA_BLOCKS  4
-+#define NAMEI_RA_SIZE        (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
-+#define NAMEI_RA_INDEX(c,b)  (((c) * NAMEI_RA_BLOCKS) + (b))
-+
-+/* is the inode marked unchangeable or does the name
-+   contain an epoch less than the current system epoch -znjp */
-+int is_unchangeable(struct inode *inode, struct dentry *dentry){
-+  
-+  char *at = NULL;
-+
-+  if (inode && (EXT3COW_IS_UNCHANGEABLE(inode) || IS_IMMUTABLE(inode)))
-+    return 1;
-+  if(dentry)
-+    at = strrchr(dentry->d_name.name, EXT3COW_FLUX_TOKEN);
-+  if(at && (simple_strtol(&at[1], (char **)NULL, 10) > 0))
-+    return 1;
-+
-+  return 0;
-+}
-+
-+static struct buffer_head *ext3cow_append(handle_t *handle,
-+					struct inode *inode,
-+					u32 *block, int *err)
-+{
-+	struct buffer_head *bh;
-+
-+	*block = inode->i_size >> inode->i_sb->s_blocksize_bits;
-+
-+	if ((bh = ext3cow_bread(handle, inode, *block, 1, err))) {
-+		inode->i_size += inode->i_sb->s_blocksize;
-+		EXT3COW_I(inode)->i_disksize = inode->i_size;
-+		ext3cow_journal_get_write_access(handle,bh);
-+	}
-+	return bh;
-+}
-+
-+#ifndef assert
-+#define assert(test) J_ASSERT(test)
-+#endif
-+
-+#ifndef swap
-+#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
-+#endif
-+
-+#ifdef DX_DEBUG
-+#define dxtrace(command) command
-+#else
-+#define dxtrace(command)
-+#endif
-+
-+struct fake_dirent
-+{
-+	__le32 inode;
-+	__le16 rec_len;
-+	u8 name_len;
-+	u8 file_type;
-+};
-+
-+struct dx_countlimit
-+{
-+	__le16 limit;
-+	__le16 count;
-+};
-+
-+struct dx_entry
-+{
-+	__le32 hash;
-+	__le32 block;
-+};
-+
-+/*
-+ * dx_root_info is laid out so that if it should somehow get overlaid by a
-+ * dirent the two low bits of the hash version will be zero.  Therefore, the
-+ * hash version mod 4 should never be 0.  Sincerely, the paranoia department.
-+ */
-+
-+struct dx_root
-+{
-+	struct fake_dirent dot;
-+	char dot_name[4];
-+	struct fake_dirent dotdot;
-+	char dotdot_name[4];
-+	struct dx_root_info
-+	{
-+		__le32 reserved_zero;
-+		u8 hash_version;
-+		u8 info_length; /* 8 */
-+		u8 indirect_levels;
-+		u8 unused_flags;
-+	}
-+	info;
-+	struct dx_entry	entries[0];
-+};
-+
-+struct dx_node
-+{
-+	struct fake_dirent fake;
-+	struct dx_entry	entries[0];
-+};
-+
-+
-+struct dx_frame
-+{
-+	struct buffer_head *bh;
-+	struct dx_entry *entries;
-+	struct dx_entry *at;
-+};
-+
-+struct dx_map_entry
-+{
-+	u32 hash;
-+	u32 offs;
-+};
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+static inline unsigned dx_get_block (struct dx_entry *entry);
-+static void dx_set_block (struct dx_entry *entry, unsigned value);
-+static inline unsigned dx_get_hash (struct dx_entry *entry);
-+static void dx_set_hash (struct dx_entry *entry, unsigned value);
-+static unsigned dx_get_count (struct dx_entry *entries);
-+static unsigned dx_get_limit (struct dx_entry *entries);
-+static void dx_set_count (struct dx_entry *entries, unsigned value);
-+static void dx_set_limit (struct dx_entry *entries, unsigned value);
-+static unsigned dx_root_limit (struct inode *dir, unsigned infosize);
-+static unsigned dx_node_limit (struct inode *dir);
-+static struct dx_frame *dx_probe(struct dentry *dentry,
-+				 struct inode *dir,
-+				 struct dx_hash_info *hinfo,
-+				 struct dx_frame *frame,
-+				 int *err);
-+static void dx_release (struct dx_frame *frames);
-+static int dx_make_map (struct ext3cow_dir_entry_2 *de, int size,
-+			struct dx_hash_info *hinfo, struct dx_map_entry map[]);
-+static void dx_sort_map(struct dx_map_entry *map, unsigned count);
-+static struct ext3cow_dir_entry_2 *dx_move_dirents (char *from, char *to,
-+		struct dx_map_entry *offsets, int count);
-+static struct ext3cow_dir_entry_2* dx_pack_dirents (char *base, int size);
-+static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block);
-+static int ext3cow_htree_next_block(struct inode *dir, __u32 hash,
-+				 struct dx_frame *frame,
-+				 struct dx_frame *frames,
-+				 __u32 *start_hash);
-+static struct buffer_head * ext3cow_dx_find_entry(struct dentry *dentry,
-+		       struct ext3cow_dir_entry_2 **res_dir, int *err);
-+static int ext3cow_dx_add_entry(handle_t *handle, struct dentry *dentry,
-+			     struct inode *inode);
-+
-+/*
-+ * Future: use high four bits of block for coalesce-on-delete flags
-+ * Mask them off for now.
-+ */
-+
-+static inline unsigned dx_get_block (struct dx_entry *entry)
-+{
-+	return le32_to_cpu(entry->block) & 0x00ffffff;
-+}
-+
-+static inline void dx_set_block (struct dx_entry *entry, unsigned value)
-+{
-+	entry->block = cpu_to_le32(value);
-+}
-+
-+static inline unsigned dx_get_hash (struct dx_entry *entry)
-+{
-+	return le32_to_cpu(entry->hash);
-+}
-+
-+static inline void dx_set_hash (struct dx_entry *entry, unsigned value)
-+{
-+	entry->hash = cpu_to_le32(value);
-+}
-+
-+static inline unsigned dx_get_count (struct dx_entry *entries)
-+{
-+	return le16_to_cpu(((struct dx_countlimit *) entries)->count);
-+}
-+
-+static inline unsigned dx_get_limit (struct dx_entry *entries)
-+{
-+	return le16_to_cpu(((struct dx_countlimit *) entries)->limit);
-+}
-+
-+static inline void dx_set_count (struct dx_entry *entries, unsigned value)
-+{
-+	((struct dx_countlimit *) entries)->count = cpu_to_le16(value);
-+}
-+
-+static inline void dx_set_limit (struct dx_entry *entries, unsigned value)
-+{
-+	((struct dx_countlimit *) entries)->limit = cpu_to_le16(value);
-+}
-+
-+static inline unsigned dx_root_limit (struct inode *dir, unsigned infosize)
-+{
-+	unsigned entry_space = dir->i_sb->s_blocksize - EXT3COW_DIR_REC_LEN(1) -
-+		EXT3COW_DIR_REC_LEN(2) - infosize;
-+	return 0? 20: entry_space / sizeof(struct dx_entry);
-+}
-+
-+static inline unsigned dx_node_limit (struct inode *dir)
-+{
-+	unsigned entry_space = dir->i_sb->s_blocksize - EXT3COW_DIR_REC_LEN(0);
-+	return 0? 22: entry_space / sizeof(struct dx_entry);
-+}
-+
-+/*
-+ * Debug
-+ */
-+#ifdef DX_DEBUG
-+static void dx_show_index (char * label, struct dx_entry *entries)
-+{
-+        int i, n = dx_get_count (entries);
-+        printk("%s index ", label);
-+        for (i = 0; i < n; i++)
-+        {
-+                printk("%x->%u ", i? dx_get_hash(entries + i): 0, dx_get_block(entries + i));
-+        }
-+        printk("\n");
-+}
-+
-+struct stats
-+{
-+	unsigned names;
-+	unsigned space;
-+	unsigned bcount;
-+};
-+
-+static struct stats dx_show_leaf(struct dx_hash_info *hinfo, struct ext3cow_dir_entry_2 *de,
-+				 int size, int show_names)
-+{
-+	unsigned names = 0, space = 0;
-+	char *base = (char *) de;
-+	struct dx_hash_info h = *hinfo;
-+
-+	printk("names: ");
-+	while ((char *) de < base + size)
-+	{
-+		if (de->inode)
-+		{
-+			if (show_names)
-+			{
-+				int len = de->name_len;
-+				char *name = de->name;
-+				while (len--) printk("%c", *name++);
-+				ext3cowfs_dirhash(de->name, de->name_len, &h);
-+				printk(":%x.%u ", h.hash,
-+				       ((char *) de - base));
-+			}
-+			space += EXT3COW_DIR_REC_LEN(de->name_len);
-+			names++;
-+		}
-+		de = (struct ext3cow_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len));
-+	}
-+	printk("(%i)\n", names);
-+	return (struct stats) { names, space, 1 };
-+}
-+
-+struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
-+			     struct dx_entry *entries, int levels)
-+{
-+	unsigned blocksize = dir->i_sb->s_blocksize;
-+	unsigned count = dx_get_count (entries), names = 0, space = 0, i;
-+	unsigned bcount = 0;
-+	struct buffer_head *bh;
-+	int err;
-+	printk("%i indexed blocks...\n", count);
-+	for (i = 0; i < count; i++, entries++)
-+	{
-+		u32 block = dx_get_block(entries), hash = i? dx_get_hash(entries): 0;
-+		u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash;
-+		struct stats stats;
-+		printk("%s%3u:%03u hash %8x/%8x ",levels?"":"   ", i, block, hash, range);
-+		if (!(bh = ext3cow_bread (NULL,dir, block, 0,&err))) continue;
-+		stats = levels?
-+		   dx_show_entries(hinfo, dir, ((struct dx_node *) bh->b_data)->entries, levels - 1):
-+		   dx_show_leaf(hinfo, (struct ext3cow_dir_entry_2 *) bh->b_data, blocksize, 0);
-+		names += stats.names;
-+		space += stats.space;
-+		bcount += stats.bcount;
-+		brelse (bh);
-+	}
-+	if (bcount)
-+		printk("%snames %u, fullness %u (%u%%)\n", levels?"":"   ",
-+			names, space/bcount,(space/bcount)*100/blocksize);
-+	return (struct stats) { names, space, bcount};
-+}
-+#endif /* DX_DEBUG */
-+
-+/*
-+ * Probe for a directory leaf block to search.
-+ *
-+ * dx_probe can return ERR_BAD_DX_DIR, which means there was a format
-+ * error in the directory index, and the caller should fall back to
-+ * searching the directory normally.  The callers of dx_probe **MUST**
-+ * check for this error code, and make sure it never gets reflected
-+ * back to userspace.
-+ */
-+static struct dx_frame *
-+dx_probe(struct dentry *dentry, struct inode *dir,
-+	 struct dx_hash_info *hinfo, struct dx_frame *frame_in, int *err)
-+{
-+	unsigned count, indirect;
-+	struct dx_entry *at, *entries, *p, *q, *m;
-+	struct dx_root *root;
-+	struct buffer_head *bh;
-+	struct dx_frame *frame = frame_in;
-+	u32 hash;
-+
-+	frame->bh = NULL;
-+	if (dentry)
-+		dir = dentry->d_parent->d_inode;
-+	if (!(bh = ext3cow_bread (NULL,dir, 0, 0, err)))
-+		goto fail;
-+	root = (struct dx_root *) bh->b_data;
-+	if (root->info.hash_version != DX_HASH_TEA &&
-+	    root->info.hash_version != DX_HASH_HALF_MD4 &&
-+	    root->info.hash_version != DX_HASH_LEGACY) {
-+		ext3cow_warning(dir->i_sb, __FUNCTION__,
-+			     "Unrecognised inode hash code %d",
-+			     root->info.hash_version);
-+		brelse(bh);
-+		*err = ERR_BAD_DX_DIR;
-+		goto fail;
-+	}
-+	hinfo->hash_version = root->info.hash_version;
-+	hinfo->seed = EXT3COW_SB(dir->i_sb)->s_hash_seed;
-+	if (dentry)
-+		ext3cowfs_dirhash(dentry->d_name.name, dentry->d_name.len, hinfo);
-+	hash = hinfo->hash;
-+
-+	if (root->info.unused_flags & 1) {
-+		ext3cow_warning(dir->i_sb, __FUNCTION__,
-+			     "Unimplemented inode hash flags: %#06x",
-+			     root->info.unused_flags);
-+		brelse(bh);
-+		*err = ERR_BAD_DX_DIR;
-+		goto fail;
-+	}
-+
-+	if ((indirect = root->info.indirect_levels) > 1) {
-+		ext3cow_warning(dir->i_sb, __FUNCTION__,
-+			     "Unimplemented inode hash depth: %#06x",
-+			     root->info.indirect_levels);
-+		brelse(bh);
-+		*err = ERR_BAD_DX_DIR;
-+		goto fail;
-+	}
-+
-+	entries = (struct dx_entry *) (((char *)&root->info) +
-+				       root->info.info_length);
-+	assert(dx_get_limit(entries) == dx_root_limit(dir,
-+						      root->info.info_length));
-+	dxtrace (printk("Look up %x", hash));
-+	while (1)
-+	{
-+		count = dx_get_count(entries);
-+		assert (count && count <= dx_get_limit(entries));
-+		p = entries + 1;
-+		q = entries + count - 1;
-+		while (p <= q)
-+		{
-+			m = p + (q - p)/2;
-+			dxtrace(printk("."));
-+			if (dx_get_hash(m) > hash)
-+				q = m - 1;
-+			else
-+				p = m + 1;
-+		}
-+
-+		if (0) // linear search cross check
-+		{
-+			unsigned n = count - 1;
-+			at = entries;
-+			while (n--)
-+			{
-+				dxtrace(printk(","));
-+				if (dx_get_hash(++at) > hash)
-+				{
-+					at--;
-+					break;
-+				}
-+			}
-+			assert (at == p - 1);
-+		}
-+
-+		at = p - 1;
-+		dxtrace(printk(" %x->%u\n", at == entries? 0: dx_get_hash(at), dx_get_block(at)));
-+		frame->bh = bh;
-+		frame->entries = entries;
-+		frame->at = at;
-+		if (!indirect--) return frame;
-+		if (!(bh = ext3cow_bread (NULL,dir, dx_get_block(at), 0, err)))
-+			goto fail2;
-+		at = entries = ((struct dx_node *) bh->b_data)->entries;
-+		assert (dx_get_limit(entries) == dx_node_limit (dir));
-+		frame++;
-+	}
-+fail2:
-+	while (frame >= frame_in) {
-+		brelse(frame->bh);
-+		frame--;
-+	}
-+fail:
-+	return NULL;
-+}
-+
-+static void dx_release (struct dx_frame *frames)
-+{
-+	if (frames[0].bh == NULL)
-+		return;
-+
-+	if (((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels)
-+		brelse(frames[1].bh);
-+	brelse(frames[0].bh);
-+}
-+
-+/*
-+ * This function increments the frame pointer to search the next leaf
-+ * block, and reads in the necessary intervening nodes if the search
-+ * should be necessary.  Whether or not the search is necessary is
-+ * controlled by the hash parameter.  If the hash value is even, then
-+ * the search is only continued if the next block starts with that
-+ * hash value.  This is used if we are searching for a specific file.
-+ *
-+ * If the hash value is HASH_NB_ALWAYS, then always go to the next block.
-+ *
-+ * This function returns 1 if the caller should continue to search,
-+ * or 0 if it should not.  If there is an error reading one of the
-+ * index blocks, it will a negative error code.
-+ *
-+ * If start_hash is non-null, it will be filled in with the starting
-+ * hash of the next page.
-+ */
-+static int ext3cow_htree_next_block(struct inode *dir, __u32 hash,
-+				 struct dx_frame *frame,
-+				 struct dx_frame *frames,
-+				 __u32 *start_hash)
-+{
-+	struct dx_frame *p;
-+	struct buffer_head *bh;
-+	int err, num_frames = 0;
-+	__u32 bhash;
-+
-+	p = frame;
-+	/*
-+	 * Find the next leaf page by incrementing the frame pointer.
-+	 * If we run out of entries in the interior node, loop around and
-+	 * increment pointer in the parent node.  When we break out of
-+	 * this loop, num_frames indicates the number of interior
-+	 * nodes need to be read.
-+	 */
-+	while (1) {
-+		if (++(p->at) < p->entries + dx_get_count(p->entries))
-+			break;
-+		if (p == frames)
-+			return 0;
-+		num_frames++;
-+		p--;
-+	}
-+
-+	/*
-+	 * If the hash is 1, then continue only if the next page has a
-+	 * continuation hash of any value.  This is used for readdir
-+	 * handling.  Otherwise, check to see if the hash matches the
-+	 * desired contiuation hash.  If it doesn't, return since
-+	 * there's no point to read in the successive index pages.
-+	 */
-+	bhash = dx_get_hash(p->at);
-+	if (start_hash)
-+		*start_hash = bhash;
-+	if ((hash & 1) == 0) {
-+		if ((bhash & ~1) != hash)
-+			return 0;
-+	}
-+	/*
-+	 * If the hash is HASH_NB_ALWAYS, we always go to the next
-+	 * block so no check is necessary
-+	 */
-+	while (num_frames--) {
-+		if (!(bh = ext3cow_bread(NULL, dir, dx_get_block(p->at),
-+				      0, &err)))
-+			return err; /* Failure */
-+		p++;
-+		brelse (p->bh);
-+		p->bh = bh;
-+		p->at = p->entries = ((struct dx_node *) bh->b_data)->entries;
-+	}
-+	return 1;
-+}
-+
-+
-+/*
-+ * p is at least 6 bytes before the end of page
-+ */
-+static inline struct ext3cow_dir_entry_2 *ext3cow_next_entry(struct ext3cow_dir_entry_2 *p)
-+{
-+	return (struct ext3cow_dir_entry_2 *)((char*)p + le16_to_cpu(p->rec_len));
-+}
-+
-+/*
-+ * This function fills a red-black tree with information from a
-+ * directory block.  It returns the number directory entries loaded
-+ * into the tree.  If there is an error it is returned in err.
-+ */
-+static int htree_dirblock_to_tree(struct file *dir_file,
-+				  struct inode *dir, int block,
-+				  struct dx_hash_info *hinfo,
-+				  __u32 start_hash, __u32 start_minor_hash)
-+{
-+	struct buffer_head *bh;
-+	struct ext3cow_dir_entry_2 *de, *top;
-+	int err, count = 0;
-+
-+	dxtrace(printk("In htree dirblock_to_tree: block %d\n", block));
-+	if (!(bh = ext3cow_bread (NULL, dir, block, 0, &err)))
-+		return err;
-+
-+	de = (struct ext3cow_dir_entry_2 *) bh->b_data;
-+	top = (struct ext3cow_dir_entry_2 *) ((char *) de +
-+					   dir->i_sb->s_blocksize -
-+					   EXT3COW_DIR_REC_LEN(0));
-+	for (; de < top; de = ext3cow_next_entry(de)) {
-+		if (!ext3cow_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
-+					(block<<EXT3COW_BLOCK_SIZE_BITS(dir->i_sb))
-+						+((char *)de - bh->b_data))) {
-+			/* On error, skip the f_pos to the next block. */
-+			dir_file->f_pos = (dir_file->f_pos |
-+					(dir->i_sb->s_blocksize - 1)) + 1;
-+			brelse (bh);
-+			return count;
-+		}
-+		ext3cowfs_dirhash(de->name, de->name_len, hinfo);
-+		if ((hinfo->hash < start_hash) ||
-+		    ((hinfo->hash == start_hash) &&
-+		     (hinfo->minor_hash < start_minor_hash)))
-+			continue;
-+		if (de->inode == 0)
-+			continue;
-+		if ((err = ext3cow_htree_store_dirent(dir_file,
-+				   hinfo->hash, hinfo->minor_hash, de)) != 0) {
-+			brelse(bh);
-+			return err;
-+		}
-+		count++;
-+	}
-+	brelse(bh);
-+	return count;
-+}
-+
-+
-+/*
-+ * This function fills a red-black tree with information from a
-+ * directory.  We start scanning the directory in hash order, starting
-+ * at start_hash and start_minor_hash.
-+ *
-+ * This function returns the number of entries inserted into the tree,
-+ * or a negative error code.
-+ */
-+int ext3cow_htree_fill_tree(struct file *dir_file, __u32 start_hash,
-+			 __u32 start_minor_hash, __u32 *next_hash)
-+{
-+	struct dx_hash_info hinfo;
-+	struct ext3cow_dir_entry_2 *de;
-+	struct dx_frame frames[2], *frame;
-+	struct inode *dir;
-+	int block, err;
-+	int count = 0;
-+	int ret;
-+	__u32 hashval;
-+
-+	dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash,
-+		       start_minor_hash));
-+	dir = dir_file->f_path.dentry->d_inode;
-+	if (!(EXT3COW_I(dir)->i_flags & EXT3COW_INDEX_FL)) {
-+		hinfo.hash_version = EXT3COW_SB(dir->i_sb)->s_def_hash_version;
-+		hinfo.seed = EXT3COW_SB(dir->i_sb)->s_hash_seed;
-+		count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo,
-+					       start_hash, start_minor_hash);
-+		*next_hash = ~0;
-+		return count;
-+	}
-+	hinfo.hash = start_hash;
-+	hinfo.minor_hash = 0;
-+	frame = dx_probe(NULL, dir_file->f_path.dentry->d_inode, &hinfo, frames, &err);
-+	if (!frame)
-+		return err;
-+
-+	/* Add '.' and '..' from the htree header */
-+	if (!start_hash && !start_minor_hash) {
-+		de = (struct ext3cow_dir_entry_2 *) frames[0].bh->b_data;
-+		if ((err = ext3cow_htree_store_dirent(dir_file, 0, 0, de)) != 0)
-+			goto errout;
-+		count++;
-+	}
-+	if (start_hash < 2 || (start_hash ==2 && start_minor_hash==0)) {
-+		de = (struct ext3cow_dir_entry_2 *) frames[0].bh->b_data;
-+		de = ext3cow_next_entry(de);
-+		if ((err = ext3cow_htree_store_dirent(dir_file, 2, 0, de)) != 0)
-+			goto errout;
-+		count++;
-+	}
-+
-+	while (1) {
-+		block = dx_get_block(frame->at);
-+		ret = htree_dirblock_to_tree(dir_file, dir, block, &hinfo,
-+					     start_hash, start_minor_hash);
-+		if (ret < 0) {
-+			err = ret;
-+			goto errout;
-+		}
-+		count += ret;
-+		hashval = ~0;
-+		ret = ext3cow_htree_next_block(dir, HASH_NB_ALWAYS,
-+					    frame, frames, &hashval);
-+		*next_hash = hashval;
-+		if (ret < 0) {
-+			err = ret;
-+			goto errout;
-+		}
-+		/*
-+		 * Stop if:  (a) there are no more entries, or
-+		 * (b) we have inserted at least one entry and the
-+		 * next hash value is not a continuation
-+		 */
-+		if ((ret == 0) ||
-+		    (count && ((hashval & 1) == 0)))
-+			break;
-+	}
-+	dx_release(frames);
-+	dxtrace(printk("Fill tree: returned %d entries, next hash: %x\n",
-+		       count, *next_hash));
-+	return count;
-+errout:
-+	dx_release(frames);
-+	return (err);
-+}
-+
-+
-+/*
-+ * Directory block splitting, compacting
-+ */
-+
-+static int dx_make_map (struct ext3cow_dir_entry_2 *de, int size,
-+			struct dx_hash_info *hinfo, struct dx_map_entry *map_tail)
-+{
-+	int count = 0;
-+	char *base = (char *) de;
-+	struct dx_hash_info h = *hinfo;
-+
-+	while ((char *) de < base + size)
-+	{
-+		if (de->name_len && de->inode) {
-+			ext3cowfs_dirhash(de->name, de->name_len, &h);
-+			map_tail--;
-+			map_tail->hash = h.hash;
-+			map_tail->offs = (u32) ((char *) de - base);
-+			count++;
-+			cond_resched();
-+		}
-+		/* XXX: do we need to check rec_len == 0 case? -Chris */
-+		de = (struct ext3cow_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len));
-+	}
-+	return count;
-+}
-+
-+static void dx_sort_map (struct dx_map_entry *map, unsigned count)
-+{
-+        struct dx_map_entry *p, *q, *top = map + count - 1;
-+        int more;
-+        /* Combsort until bubble sort doesn't suck */
-+        while (count > 2)
-+	{
-+                count = count*10/13;
-+                if (count - 9 < 2) /* 9, 10 -> 11 */
-+                        count = 11;
-+                for (p = top, q = p - count; q >= map; p--, q--)
-+                        if (p->hash < q->hash)
-+                                swap(*p, *q);
-+        }
-+        /* Garden variety bubble sort */
-+        do {
-+                more = 0;
-+                q = top;
-+                while (q-- > map)
-+		{
-+                        if (q[1].hash >= q[0].hash)
-+				continue;
-+                        swap(*(q+1), *q);
-+                        more = 1;
-+		}
-+	} while(more);
-+}
-+
-+static void dx_insert_block(struct dx_frame *frame, u32 hash, u32 block)
-+{
-+	struct dx_entry *entries = frame->entries;
-+	struct dx_entry *old = frame->at, *new = old + 1;
-+	int count = dx_get_count(entries);
-+
-+	assert(count < dx_get_limit(entries));
-+	assert(old < entries + count);
-+	memmove(new + 1, new, (char *)(entries + count) - (char *)(new));
-+	dx_set_hash(new, hash);
-+	dx_set_block(new, block);
-+	dx_set_count(entries, count + 1);
-+}
-+#endif
-+
-+
-+static void ext3cow_update_dx_flag(struct inode *inode)
-+{
-+	if (!EXT3COW_HAS_COMPAT_FEATURE(inode->i_sb,
-+				     EXT3COW_FEATURE_COMPAT_DIR_INDEX))
-+		EXT3COW_I(inode)->i_flags &= ~EXT3COW_INDEX_FL;
-+}
-+
-+/*
-+ * NOTE! unlike strncmp, ext3cow_match returns 1 for success, 0 for failure.
-+ *
-+ * `len <= EXT3COW_NAME_LEN' is guaranteed by caller.
-+ * `de != NULL' is guaranteed by caller.
-+ */
-+static inline int ext3cow_match (int len, const char * const name,
-+			      struct ext3cow_dir_entry_2 * de)
-+{
-+	if (len != de->name_len)
-+		return 0;
-+	if (!de->inode)
-+		return 0;
-+	return !memcmp(name, de->name, len);
-+}
-+
-+/*
-+ * Returns 0 if not found, -1 on failure, and 1 on success
-+ */
-+/* For versioning - this is the function used when looking for
-+ * names.  We now handle names which include the flux token,
-+ * strip it off and continue looking -znjp */
-+static inline int search_dirblock(struct buffer_head * bh,
-+				  struct inode *dir,
-+				  struct dentry *dentry,
-+				  unsigned long offset,
-+				  struct ext3cow_dir_entry_2 ** res_dir)
-+{
-+	struct ext3cow_dir_entry_2 * de;
-+	char * dlimit, * flux = NULL;
-+	int de_len;
-+	char name[EXT3COW_NAME_LEN];
-+	int namelen = dentry->d_name.len;
-+  unsigned int epoch_number = EXT3COW_I_EPOCHNUMBER(dir);
-+
-+  /* Get the name for the dentry */
-+  memcpy(name, dentry->d_name.name, namelen);
-+  name[namelen] = '\0';
-+
-+  /* Check to see if the flux token is in the name */
-+  flux = strrchr(dentry->d_name.name, EXT3COW_FLUX_TOKEN);
-+  if(NULL != flux){
-+    /* If we're here, the name we want is in the past. */
-+    int new_namelen = strlen(dentry->d_name.name) - strlen(flux);
-+    /* Get the epoch number */
-+    epoch_number = simple_strtol(&flux[1], (char **)NULL, 10) - 1;
-+    /* If there's a valid epoch number or if we're version listing
-+     * we need the name seperately, otherwise the FLUX_TOKEN exists
-+     * in the file name */
-+    if(epoch_number + 1 == 0 && (strlen(flux) > 1)){ 
-+      /* EXT3COW_FLUX_TOKEN exists in the file name */
-+      epoch_number = EXT3COW_S_EPOCHNUMBER(dir->i_sb);
-+    }else{
-+      /* Grab the correct name and length */
-+      memcpy(name, dentry->d_name.name, new_namelen);
-+      name[new_namelen] = '\0';
-+      namelen = strlen(name);
-+    }
-+  }
-+
-+
-+	de = (struct ext3cow_dir_entry_2 *) bh->b_data;
-+	dlimit = bh->b_data + dir->i_sb->s_blocksize;
-+	while ((char *) de < dlimit) {
-+		/* this code is executed quadratically often */
-+		/* do minimal checking `by hand' */
-+
-+    /* Can't just return first entry of something;
-+     * may exist twice if died and same name appears again. - znjp
-+     */
-+		if ((char *) de + namelen <= dlimit &&
-+		    ext3cow_match (namelen, name, de) && 
-+        EXT3COW_IS_DIRENT_SCOPED(de, epoch_number)) {
-+			/* found a match - just to be sure, do a full check */
-+			if (!ext3cow_check_dir_entry("ext3cow_find_entry",
-+						  dir, de, bh, offset))
-+				return -1;
-+			*res_dir = de;
-+			return 1;
-+		}
-+		/* prevent looping on a bad block */
-+		de_len = le16_to_cpu(de->rec_len);
-+		if (de_len <= 0)
-+			return -1;
-+		offset += de_len;
-+		de = (struct ext3cow_dir_entry_2 *) ((char *) de + de_len);
-+	}
-+	return 0;
-+}
-+
-+
-+/*
-+ *	ext3cow_find_entry()
-+ *
-+ * finds an entry in the specified directory with the wanted name. It
-+ * returns the cache buffer in which the entry was found, and the entry
-+ * itself (as a parameter - res_dir). It does NOT read the inode of the
-+ * entry - you'll have to do that yourself if you want to.
-+ *
-+ * The returned buffer_head has ->b_count elevated.  The caller is expected
-+ * to brelse() it when appropriate.
-+ */
-+static struct buffer_head * ext3cow_find_entry (struct dentry *dentry,
-+					struct ext3cow_dir_entry_2 ** res_dir)
-+{
-+	struct super_block * sb;
-+	struct buffer_head * bh_use[NAMEI_RA_SIZE];
-+	struct buffer_head * bh, *ret = NULL;
-+	unsigned long start, block, b;
-+	int ra_max = 0;		/* Number of bh's in the readahead
-+				   buffer, bh_use[] */
-+	int ra_ptr = 0;		/* Current index into readahead
-+				   buffer */
-+	int num = 0;
-+	int nblocks, i, err;
-+	struct inode *dir = dentry->d_parent->d_inode;
-+	int namelen;
-+	const u8 *name;
-+	unsigned blocksize;
-+
-+	*res_dir = NULL;
-+	sb = dir->i_sb;
-+	blocksize = sb->s_blocksize;
-+	namelen = dentry->d_name.len;
-+	name = dentry->d_name.name;
-+	if (namelen > EXT3COW_NAME_LEN)
-+		return NULL;
-+#ifdef CONFIG_EXT3COW_INDEX
-+	if (is_dx(dir)) {
-+		bh = ext3cow_dx_find_entry(dentry, res_dir, &err);
-+		/*
-+		 * On success, or if the error was file not found,
-+		 * return.  Otherwise, fall back to doing a search the
-+		 * old fashioned way.
-+		 */
-+		if (bh || (err != ERR_BAD_DX_DIR))
-+			return bh;
-+		dxtrace(printk("ext3cow_find_entry: dx failed, falling back\n"));
-+	}
-+#endif
-+	nblocks = dir->i_size >> EXT3COW_BLOCK_SIZE_BITS(sb);
-+	start = EXT3COW_I(dir)->i_dir_start_lookup;
-+	if (start >= nblocks)
-+		start = 0;
-+	block = start;
-+restart:
-+	do {
-+		/*
-+		 * We deal with the read-ahead logic here.
-+		 */
-+		if (ra_ptr >= ra_max) {
-+			/* Refill the readahead buffer */
-+			ra_ptr = 0;
-+			b = block;
-+			for (ra_max = 0; ra_max < NAMEI_RA_SIZE; ra_max++) {
-+				/*
-+				 * Terminate if we reach the end of the
-+				 * directory and must wrap, or if our
-+				 * search has finished at this block.
-+				 */
-+				if (b >= nblocks || (num && block == start)) {
-+					bh_use[ra_max] = NULL;
-+					break;
-+				}
-+				num++;
-+				bh = ext3cow_getblk(NULL, dir, b++, 0, &err);
-+				bh_use[ra_max] = bh;
-+				if (bh)
-+					ll_rw_block(READ_META, 1, &bh);
-+			}
-+		}
-+		if ((bh = bh_use[ra_ptr++]) == NULL)
-+			goto next;
-+		wait_on_buffer(bh);
-+		if (!buffer_uptodate(bh)) {
-+			/* read error, skip block & hope for the best */
-+			ext3cow_error(sb, __FUNCTION__, "reading directory #%lu "
-+				   "offset %lu", dir->i_ino, block);
-+			brelse(bh);
-+			goto next;
-+		}
-+		i = search_dirblock(bh, dir, dentry,
-+			    block << EXT3COW_BLOCK_SIZE_BITS(sb), res_dir);
-+		if (i == 1) {
-+			EXT3COW_I(dir)->i_dir_start_lookup = block;
-+			ret = bh;
-+			goto cleanup_and_exit;
-+		} else {
-+			brelse(bh);
-+			if (i < 0)
-+				goto cleanup_and_exit;
-+		}
-+	next:
-+		if (++block >= nblocks)
-+			block = 0;
-+	} while (block != start);
-+
-+	/*
-+	 * If the directory has grown while we were searching, then
-+	 * search the last part of the directory before giving up.
-+	 */
-+	block = nblocks;
-+	nblocks = dir->i_size >> EXT3COW_BLOCK_SIZE_BITS(sb);
-+	if (block < nblocks) {
-+		start = 0;
-+		goto restart;
-+	}
-+
-+cleanup_and_exit:
-+	/* Clean up the read-ahead blocks */
-+	for (; ra_ptr < ra_max; ra_ptr++)
-+		brelse (bh_use[ra_ptr]);
-+	return ret;
-+}
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+static struct buffer_head * ext3cow_dx_find_entry(struct dentry *dentry,
-+		       struct ext3cow_dir_entry_2 **res_dir, int *err)
-+{
-+	struct super_block * sb;
-+	struct dx_hash_info	hinfo;
-+	u32 hash;
-+	struct dx_frame frames[2], *frame;
-+	struct ext3cow_dir_entry_2 *de, *top;
-+	struct buffer_head *bh;
-+	unsigned long block;
-+	int retval;
-+	int namelen = dentry->d_name.len;
-+	const u8 *name = dentry->d_name.name;
-+	struct inode *dir = dentry->d_parent->d_inode;
-+
-+	sb = dir->i_sb;
-+	/* NFS may look up ".." - look at dx_root directory block */
-+	if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){
-+		if (!(frame = dx_probe(dentry, NULL, &hinfo, frames, err)))
-+			return NULL;
-+	} else {
-+		frame = frames;
-+		frame->bh = NULL;			/* for dx_release() */
-+		frame->at = (struct dx_entry *)frames;	/* hack for zero entry*/
-+		dx_set_block(frame->at, 0);		/* dx_root block is 0 */
-+	}
-+	hash = hinfo.hash;
-+	do {
-+		block = dx_get_block(frame->at);
-+		if (!(bh = ext3cow_bread (NULL,dir, block, 0, err)))
-+			goto errout;
-+		de = (struct ext3cow_dir_entry_2 *) bh->b_data;
-+		top = (struct ext3cow_dir_entry_2 *) ((char *) de + sb->s_blocksize -
-+				       EXT3COW_DIR_REC_LEN(0));
-+		for (; de < top; de = ext3cow_next_entry(de))
-+		if (ext3cow_match (namelen, name, de)) {
-+			if (!ext3cow_check_dir_entry("ext3cow_find_entry",
-+						  dir, de, bh,
-+				  (block<<EXT3COW_BLOCK_SIZE_BITS(sb))
-+					  +((char *)de - bh->b_data))) {
-+				brelse (bh);
-+				goto errout;
-+			}
-+			*res_dir = de;
-+			dx_release (frames);
-+			return bh;
-+		}
-+		brelse (bh);
-+		/* Check to see if we should continue to search */
-+		retval = ext3cow_htree_next_block(dir, hash, frame,
-+					       frames, NULL);
-+		if (retval < 0) {
-+			ext3cow_warning(sb, __FUNCTION__,
-+			     "error reading index page in directory #%lu",
-+			     dir->i_ino);
-+			*err = retval;
-+			goto errout;
-+		}
-+	} while (retval == 1);
-+
-+	*err = -ENOENT;
-+errout:
-+	dxtrace(printk("%s not found\n", name));
-+	dx_release (frames);
-+	return NULL;
-+}
-+#endif
-+
-+/* ext3cow_lookup: One the key functions of this versioning file sytem,
-+ * allowing people to return to the past.
-+ *
-+ * Two policies for inode chains:
-+ * 1) If it's the head of the list, it's the most current inode
-+ *    and always changable.  The inode number is static.
-+ * 2) If it's any inode in the chain that's not the head,
-+ *    than it's an inode in the past and unchangeable.  The inode
-+ *    number may change.
-+ */
-+static struct dentry *ext3cow_lookup(struct inode * dir, struct dentry *dentry,
-+                                     struct nameidata *nd)
-+{
-+	struct inode * inode = NULL;
-+	struct ext3cow_dir_entry_2 * de = NULL;
-+	struct buffer_head * bh = NULL;
-+  unsigned int epoch_number = 0;
-+  char * flux = NULL;
-+  
-+	if (dentry->d_name.len > EXT3COW_NAME_LEN)
-+		return ERR_PTR(-ENAMETOOLONG);
-+
-+  /* Find the epoch number to scope with -znjp 
-+   * if the parent is unchangeable, so is the inode 
-+   */
-+  if(EXT3COW_IS_UNCHANGEABLE(dir))     
-+    epoch_number = EXT3COW_I_EPOCHNUMBER(dir);
-+  else
-+    epoch_number = EXT3COW_S_EPOCHNUMBER(dir->i_sb);
-+
-+	bh = ext3cow_find_entry(dentry, &de);
-+	if (bh) {
-+		unsigned long ino = le32_to_cpu(de->inode);
-+		brelse (bh);
-+		if (!ext3cow_valid_inum(dir->i_sb, ino)) {
-+			ext3cow_error(dir->i_sb, "ext3cow_lookup",
-+				   "bad inode number: %lu", ino);
-+			inode = NULL;
-+		} else
-+			inode = iget(dir->i_sb, ino);
-+
-+		if (!inode)
-+			return ERR_PTR(-EACCES);
-+
-+    /* Is this a version listing ? */
-+    if ((char)dentry->d_name.name[dentry->d_name.len - 1] == 
-+        EXT3COW_FLUX_TOKEN) {
-+      /* prevent going round in circles */
-+      if (dentry->d_parent && 
-+          dentry->d_parent->d_name.name[dentry->d_parent->d_name.len - 1] ==
-+          EXT3COW_FLUX_TOKEN) {
-+        return NULL;
-+      }
-+      /* we fake a directory using the directory inode instead of
-+       * the file one and subsequently force a call to ext3cow_readdir */
-+      iput(inode);
-+      inode = ext3cow_fake_inode(dir, EXT3COW_S_EPOCHNUMBER(dir->i_sb));
-+      EXT3COW_I(inode)->i_next_inode = EXT3COW_I(dir)->i_next_inode;
-+      d_splice_alias(inode, dentry);
-+      
-+      return NULL;
-+    }
-+
-+    /* Is the user time-shifting to the past? */
-+    flux = strrchr(dentry->d_name.name, EXT3COW_FLUX_TOKEN);
-+    if(NULL != flux){
-+
-+      if(strnicmp(&flux[1], "onehour", 8) == 0){
-+        epoch_number = get_seconds() - ONEHOUR;
-+        printk(KERN_INFO "ONEHOUR!\n");
-+      }else if(strnicmp(&flux[1], "yesterday", 10) == 0 ||
-+               strnicmp(&flux[1], "oneday", 7) == 0){
-+        epoch_number = get_seconds() - YESTERDAY;
-+      }else if(strnicmp(&flux[1], "oneweek", 8) == 0){
-+        epoch_number = get_seconds() - ONEWEEK;
-+      }else if(strnicmp(&flux[1], "onemonth", 9) == 0){
-+        epoch_number = get_seconds() - ONEMONTH;
-+      }else if(strnicmp(&flux[1], "oneyear", 8) == 0){
-+        epoch_number = get_seconds() - ONEYEAR;
-+      }else
-+        epoch_number = simple_strtol(&flux[1], (char **)NULL, 10) - 1;
-+
-+      /* No future epochs */
-+      if(epoch_number + 1 > EXT3COW_S_EPOCHNUMBER(dir->i_sb))                
-+        return ERR_PTR(-ENOENT); 
-+
-+      /* Move to present 
-+      if(epoch_number + 1 == 0)
-+        epoch_number = EXT3COW_S_EPOCHNUMBER(dir->i_sb);       
-+      */
-+    }
-+     
-+    /* Find correct inode in chain */
-+    while(EXT3COW_I_EPOCHNUMBER(inode) > epoch_number){
-+
-+      printk(KERN_INFO "Looking for %u with epoch %u\n", epoch_number, 
-+             EXT3COW_I_EPOCHNUMBER(inode));
-+
-+      ino = EXT3COW_I(inode)->i_next_inode;
-+      if(ino == 0){
-+        ext3cow_warning(dir->i_sb, "ext3cow_lookup",
-+                        "Next inode is 0 in lookup.");
-+        iput(inode);
-+        return ERR_PTR(-ENOENT);
-+      }
-+      iput(inode); /* for correct usage count (i_count) */
-+      inode = iget(dir->i_sb, ino);
-+      
-+      if (!inode){
-+        ext3cow_warning(dir->i_sb, "ext3cow_lookup",
-+                        "Could not access inode number %lu",
-+                        ino);
-+        return ERR_PTR(-EACCES);
-+      }
-+    }
-+
-+    /* If we're in the past, fake the inode for scoping and "unchangability" */
-+    if(flux || (epoch_number != EXT3COW_S_EPOCHNUMBER(dir->i_sb))){
-+      printk(KERN_INFO "Faking %s\n", dentry->d_name.name);
-+      inode = ext3cow_fake_inode(inode, epoch_number);
-+    }
-+
-+    if (!inode)
-+      return ERR_PTR(-EACCES);
-+	}
-+	return d_splice_alias(inode, dentry);
-+}
-+
-+
-+struct dentry *ext3cow_get_parent(struct dentry *child)
-+{
-+	unsigned long ino;
-+	struct dentry *parent;
-+	struct inode *inode;
-+	struct dentry dotdot;
-+	struct ext3cow_dir_entry_2 * de;
-+	struct buffer_head *bh;
-+
-+	dotdot.d_name.name = "..";
-+	dotdot.d_name.len = 2;
-+	dotdot.d_parent = child; /* confusing, isn't it! */
-+
-+	bh = ext3cow_find_entry(&dotdot, &de);
-+	inode = NULL;
-+	if (!bh)
-+		return ERR_PTR(-ENOENT);
-+	ino = le32_to_cpu(de->inode);
-+	brelse(bh);
-+
-+	if (!ext3cow_valid_inum(child->d_inode->i_sb, ino)) {
-+		ext3cow_error(child->d_inode->i_sb, "ext3cow_get_parent",
-+			   "bad inode number: %lu", ino);
-+		inode = NULL;
-+	} else
-+		inode = iget(child->d_inode->i_sb, ino);
-+
-+	if (!inode)
-+		return ERR_PTR(-EACCES);
-+
-+	parent = d_alloc_anon(inode);
-+	if (!parent) {
-+		iput(inode);
-+		parent = ERR_PTR(-ENOMEM);
-+	}
-+	return parent;
-+}
-+
-+#define S_SHIFT 12
-+static unsigned char ext3cow_type_by_mode[S_IFMT >> S_SHIFT] = {
-+	[S_IFREG >> S_SHIFT]	= EXT3COW_FT_REG_FILE,
-+	[S_IFDIR >> S_SHIFT]	= EXT3COW_FT_DIR,
-+	[S_IFCHR >> S_SHIFT]	= EXT3COW_FT_CHRDEV,
-+	[S_IFBLK >> S_SHIFT]	= EXT3COW_FT_BLKDEV,
-+	[S_IFIFO >> S_SHIFT]	= EXT3COW_FT_FIFO,
-+	[S_IFSOCK >> S_SHIFT]	= EXT3COW_FT_SOCK,
-+	[S_IFLNK >> S_SHIFT]	= EXT3COW_FT_SYMLINK,
-+};
-+
-+static inline void ext3cow_set_de_type(struct super_block *sb,
-+				struct ext3cow_dir_entry_2 *de,
-+				umode_t mode) {
-+	if (EXT3COW_HAS_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_FILETYPE))
-+		de->file_type = ext3cow_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
-+}
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+static struct ext3cow_dir_entry_2 *
-+dx_move_dirents(char *from, char *to, struct dx_map_entry *map, int count)
-+{
-+	unsigned rec_len = 0;
-+
-+	while (count--) {
-+		struct ext3cow_dir_entry_2 *de = (struct ext3cow_dir_entry_2 *) (from + map->offs);
-+		rec_len = EXT3COW_DIR_REC_LEN(de->name_len);
-+		memcpy (to, de, rec_len);
-+		((struct ext3cow_dir_entry_2 *) to)->rec_len =
-+				cpu_to_le16(rec_len);
-+		de->inode = 0;
-+		map++;
-+		to += rec_len;
-+	}
-+	return (struct ext3cow_dir_entry_2 *) (to - rec_len);
-+}
-+
-+static struct ext3cow_dir_entry_2* dx_pack_dirents(char *base, int size)
-+{
-+	struct ext3cow_dir_entry_2 *next, *to, *prev, *de = (struct ext3cow_dir_entry_2 *) base;
-+	unsigned rec_len = 0;
-+
-+	prev = to = de;
-+	while ((char*)de < base + size) {
-+		next = (struct ext3cow_dir_entry_2 *) ((char *) de +
-+						    le16_to_cpu(de->rec_len));
-+		if (de->inode && de->name_len) {
-+			rec_len = EXT3COW_DIR_REC_LEN(de->name_len);
-+			if (de > to)
-+				memmove(to, de, rec_len);
-+			to->rec_len = cpu_to_le16(rec_len);
-+			prev = to;
-+			to = (struct ext3cow_dir_entry_2 *) (((char *) to) + rec_len);
-+		}
-+		de = next;
-+	}
-+	return prev;
-+}
-+
-+static struct ext3cow_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
-+			struct buffer_head **bh,struct dx_frame *frame,
-+			struct dx_hash_info *hinfo, int *error)
-+{
-+	unsigned blocksize = dir->i_sb->s_blocksize;
-+	unsigned count, continued;
-+	struct buffer_head *bh2;
-+	u32 newblock;
-+	u32 hash2;
-+	struct dx_map_entry *map;
-+	char *data1 = (*bh)->b_data, *data2;
-+	unsigned split;
-+	struct ext3cow_dir_entry_2 *de = NULL, *de2;
-+	int	err;
-+
-+	bh2 = ext3cow_append (handle, dir, &newblock, error);
-+	if (!(bh2)) {
-+		brelse(*bh);
-+		*bh = NULL;
-+		goto errout;
-+	}
-+
-+	BUFFER_TRACE(*bh, "get_write_access");
-+	err = ext3cow_journal_get_write_access(handle, *bh);
-+	if (err) {
-+	journal_error:
-+		brelse(*bh);
-+		brelse(bh2);
-+		*bh = NULL;
-+		ext3cow_std_error(dir->i_sb, err);
-+		goto errout;
-+	}
-+	BUFFER_TRACE(frame->bh, "get_write_access");
-+	err = ext3cow_journal_get_write_access(handle, frame->bh);
-+	if (err)
-+		goto journal_error;
-+
-+	data2 = bh2->b_data;
-+
-+	/* create map in the end of data2 block */
-+	map = (struct dx_map_entry *) (data2 + blocksize);
-+	count = dx_make_map ((struct ext3cow_dir_entry_2 *) data1,
-+			     blocksize, hinfo, map);
-+	map -= count;
-+	split = count/2; // need to adjust to actual middle
-+	dx_sort_map (map, count);
-+	hash2 = map[split].hash;
-+	continued = hash2 == map[split - 1].hash;
-+	dxtrace(printk("Split block %i at %x, %i/%i\n",
-+		dx_get_block(frame->at), hash2, split, count-split));
-+
-+	/* Fancy dance to stay within two buffers */
-+	de2 = dx_move_dirents(data1, data2, map + split, count - split);
-+	de = dx_pack_dirents(data1,blocksize);
-+	de->rec_len = cpu_to_le16(data1 + blocksize - (char *) de);
-+	de2->rec_len = cpu_to_le16(data2 + blocksize - (char *) de2);
-+	dxtrace(dx_show_leaf (hinfo, (struct ext3cow_dir_entry_2 *) data1, blocksize, 1));
-+	dxtrace(dx_show_leaf (hinfo, (struct ext3cow_dir_entry_2 *) data2, blocksize, 1));
-+
-+	/* Which block gets the new entry? */
-+	if (hinfo->hash >= hash2)
-+	{
-+		swap(*bh, bh2);
-+		de = de2;
-+	}
-+	dx_insert_block (frame, hash2 + continued, newblock);
-+	err = ext3cow_journal_dirty_metadata (handle, bh2);
-+	if (err)
-+		goto journal_error;
-+	err = ext3cow_journal_dirty_metadata (handle, frame->bh);
-+	if (err)
-+		goto journal_error;
-+	brelse (bh2);
-+	dxtrace(dx_show_index ("frame", frame->entries));
-+errout:
-+	return de;
-+}
-+#endif
-+
-+
-+/*
-+ * Add a new entry into a directory (leaf) block.  If de is non-NULL,
-+ * it points to a directory entry which is guaranteed to be large
-+ * enough for new directory entry.  If de is NULL, then
-+ * add_dirent_to_buf will attempt search the directory block for
-+ * space.  It will return -ENOSPC if no space is available, and -EIO
-+ * and -EEXIST if directory entry already exists.
-+ *
-+ * NOTE!  bh is NOT released in the case where ENOSPC is returned.  In
-+ * all other cases bh is released.
-+ */
-+static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
-+			     struct inode *inode, struct ext3cow_dir_entry_2 *de,
-+			     struct buffer_head * bh)
-+{
-+	struct inode	*dir = dentry->d_parent->d_inode;
-+	const char	*name = dentry->d_name.name;
-+	int		namelen = dentry->d_name.len;
-+	unsigned long	offset = 0;
-+	unsigned short	reclen;
-+	int		nlen, rlen, err;
-+	char		*top;
-+
-+	reclen = EXT3COW_DIR_REC_LEN(namelen);
-+	if (!de) {
-+		de = (struct ext3cow_dir_entry_2 *)bh->b_data;
-+		top = bh->b_data + dir->i_sb->s_blocksize - reclen;
-+		while ((char *) de <= top) {
-+			if (!ext3cow_check_dir_entry("ext3cow_add_entry", dir, de,
-+						  bh, offset)) {
-+				brelse (bh);
-+        ext3cow_reclaim_dup_inode(dentry->d_parent->d_parent->d_inode, dir);
-+				return -EIO;
-+			}
-+      /* If name exists and it's still alive, no add. But if it's a new
-+       * name in this scope, ok to add. -znjp */
-+			if (ext3cow_match (namelen, name, de) && EXT3COW_IS_DIRENT_ALIVE(de)) {
-+				brelse (bh);
-+				return -EEXIST;
-+			}
-+			nlen = EXT3COW_DIR_REC_LEN(de->name_len);
-+			rlen = le16_to_cpu(de->rec_len);
-+			if ((de->inode? rlen - nlen: rlen) >= reclen)
-+				break;
-+			de = (struct ext3cow_dir_entry_2 *)((char *)de + rlen);
-+			offset += rlen;
-+		}
-+		if ((char *) de > top)
-+			return -ENOSPC;
-+	}
-+	BUFFER_TRACE(bh, "get_write_access");
-+	err = ext3cow_journal_get_write_access(handle, bh);
-+	if (err) {
-+		ext3cow_std_error(dir->i_sb, err);
-+		brelse(bh);
-+		return err;
-+	}
-+
-+	/* By now the buffer is marked for journaling */
-+	nlen = EXT3COW_DIR_REC_LEN(de->name_len);
-+	rlen = le16_to_cpu(de->rec_len);
-+	if (de->inode) {
-+		struct ext3cow_dir_entry_2 *de1 = (struct ext3cow_dir_entry_2 *)((char *)de + nlen);
-+		de1->rec_len = cpu_to_le16(rlen - nlen);
-+		de->rec_len = cpu_to_le16(nlen);
-+		de = de1;
-+	}
-+	de->file_type = EXT3COW_FT_UNKNOWN;
-+	if (inode) {
-+		de->inode = cpu_to_le32(inode->i_ino);
-+		ext3cow_set_de_type(dir->i_sb, de, inode->i_mode);
-+	} else
-+		de->inode = 0;
-+  /* For versioning -znjp */
-+  de->birth_epoch = cpu_to_le32(EXT3COW_S_EPOCHNUMBER(dir->i_sb));
-+  de->death_epoch = cpu_to_le32(EXT3COW_DIRENT_ALIVE);
-+	de->name_len = namelen;
-+	memcpy (de->name, name, namelen);
-+	/*
-+	 * XXX shouldn't update any times until successful
-+	 * completion of syscall, but too many callers depend
-+	 * on this.
-+	 *
-+	 * XXX similarly, too many callers depend on
-+	 * ext3cow_new_inode() setting the times, but error
-+	 * recovery deletes the inode, so the worst that can
-+	 * happen is that the times are slightly out of date
-+	 * and/or different from the directory change time.
-+	 */
-+	dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
-+	ext3cow_update_dx_flag(dir);
-+	dir->i_version++;
-+	ext3cow_mark_inode_dirty(handle, dir);
-+	BUFFER_TRACE(bh, "call ext3cow_journal_dirty_metadata");
-+	err = ext3cow_journal_dirty_metadata(handle, bh);
-+	if (err)
-+		ext3cow_std_error(dir->i_sb, err);
-+	brelse(bh);
-+	return 0;
-+}
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+/*
-+ * This converts a one block unindexed directory to a 3 block indexed
-+ * directory, and adds the dentry to the indexed directory.
-+ */
-+static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
-+			    struct inode *inode, struct buffer_head *bh)
-+{
-+	struct inode	*dir = dentry->d_parent->d_inode;
-+	const char	*name = dentry->d_name.name;
-+	int		namelen = dentry->d_name.len;
-+	struct buffer_head *bh2;
-+	struct dx_root	*root;
-+	struct dx_frame	frames[2], *frame;
-+	struct dx_entry *entries;
-+	struct ext3cow_dir_entry_2	*de, *de2;
-+	char		*data1, *top;
-+	unsigned	len;
-+	int		retval;
-+	unsigned	blocksize;
-+	struct dx_hash_info hinfo;
-+	u32		block;
-+	struct fake_dirent *fde;
-+
-+	blocksize =  dir->i_sb->s_blocksize;
-+	dxtrace(printk("Creating index\n"));
-+	retval = ext3cow_journal_get_write_access(handle, bh);
-+	if (retval) {
-+		ext3cow_std_error(dir->i_sb, retval);
-+		brelse(bh);
-+		return retval;
-+	}
-+	root = (struct dx_root *) bh->b_data;
-+
-+	bh2 = ext3cow_append (handle, dir, &block, &retval);
-+	if (!(bh2)) {
-+		brelse(bh);
-+		return retval;
-+	}
-+	EXT3COW_I(dir)->i_flags |= EXT3COW_INDEX_FL;
-+	data1 = bh2->b_data;
-+
-+	/* The 0th block becomes the root, move the dirents out */
-+	fde = &root->dotdot;
-+	de = (struct ext3cow_dir_entry_2 *)((char *)fde + le16_to_cpu(fde->rec_len));
-+	len = ((char *) root) + blocksize - (char *) de;
-+	memcpy (data1, de, len);
-+	de = (struct ext3cow_dir_entry_2 *) data1;
-+	top = data1 + len;
-+	while ((char *)(de2=(void*)de+le16_to_cpu(de->rec_len)) < top)
-+		de = de2;
-+	de->rec_len = cpu_to_le16(data1 + blocksize - (char *) de);
-+	/* Initialize the root; the dot dirents already exist */
-+	de = (struct ext3cow_dir_entry_2 *) (&root->dotdot);
-+	de->rec_len = cpu_to_le16(blocksize - EXT3COW_DIR_REC_LEN(2));
-+	memset (&root->info, 0, sizeof(root->info));
-+	root->info.info_length = sizeof(root->info);
-+	root->info.hash_version = EXT3COW_SB(dir->i_sb)->s_def_hash_version;
-+	entries = root->entries;
-+	dx_set_block (entries, 1);
-+	dx_set_count (entries, 1);
-+	dx_set_limit (entries, dx_root_limit(dir, sizeof(root->info)));
-+
-+	/* Initialize as for dx_probe */
-+	hinfo.hash_version = root->info.hash_version;
-+	hinfo.seed = EXT3COW_SB(dir->i_sb)->s_hash_seed;
-+	ext3cowfs_dirhash(name, namelen, &hinfo);
-+	frame = frames;
-+	frame->entries = entries;
-+	frame->at = entries;
-+	frame->bh = bh;
-+	bh = bh2;
-+	de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
-+	dx_release (frames);
-+	if (!(de))
-+		return retval;
-+
-+	return add_dirent_to_buf(handle, dentry, inode, de, bh);
-+}
-+#endif
-+
-+/*
-+ *	ext3cow_add_entry()
-+ *
-+ * adds a file entry to the specified directory, using the same
-+ * semantics as ext3cow_find_entry(). It returns NULL if it failed.
-+ *
-+ * NOTE!! The inode part of 'de' is left at 0 - which means you
-+ * may not sleep between calling this and putting something into
-+ * the entry, as someone else might have used it while you slept.
-+ */
-+static int ext3cow_add_entry (handle_t *handle, struct dentry *dentry,
-+	struct inode *inode)
-+{
-+	struct inode *dir = dentry->d_parent->d_inode;
-+	unsigned long offset;
-+	struct buffer_head * bh;
-+	struct ext3cow_dir_entry_2 *de;
-+	struct super_block * sb;
-+	int	retval;
-+#ifdef CONFIG_EXT3COW_INDEX
-+	int	dx_fallback=0;
-+#endif
-+	unsigned blocksize;
-+	u32 block, blocks;
-+
-+	sb = dir->i_sb;
-+	blocksize = sb->s_blocksize;
-+	if (!dentry->d_name.len)
-+		return -EINVAL;
-+  /* No additions in the past -znjp */
-+  if(is_unchangeable(dir, dentry))
-+    return -EROFS;
-+
-+  if(EXT3COW_S_EPOCHNUMBER(sb) > EXT3COW_I_EPOCHNUMBER(dir)){   
-+    if(ext3cow_dup_inode(dentry->d_parent->d_parent->d_inode, dir))
-+      //if(ext3cow_dup_inode(NULL, dir))
-+      return -1;
-+  }
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+	if (is_dx(dir)) {
-+		retval = ext3cow_dx_add_entry(handle, dentry, inode);
-+		if (!retval || (retval != ERR_BAD_DX_DIR)){
-+      ext3cow_reclaim_dup_inode(dentry->d_parent->d_parent->d_inode, dir);
-+			return retval;
-+    }
-+		EXT3COW_I(dir)->i_flags &= ~EXT3COW_INDEX_FL;
-+		dx_fallback++;
-+		ext3cow_mark_inode_dirty(handle, dir);
-+	}
-+#endif
-+	blocks = dir->i_size >> sb->s_blocksize_bits;
-+	for (block = 0, offset = 0; block < blocks; block++) {
-+		bh = ext3cow_bread(handle, dir, block, 0, &retval);
-+		if(!bh){
-+      ext3cow_reclaim_dup_inode(dentry->d_parent->d_parent->d_inode, dir);
-+			return retval;
-+    }
-+		retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
-+		if (retval != -ENOSPC)
-+			return retval;
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+		if (blocks == 1 && !dx_fallback &&
-+		    EXT3COW_HAS_COMPAT_FEATURE(sb, EXT3COW_FEATURE_COMPAT_DIR_INDEX))
-+			return make_indexed_dir(handle, dentry, inode, bh);
-+#endif
-+		brelse(bh);
-+	}
-+
-+	bh = ext3cow_append(handle, dir, &block, &retval);
-+	if (!bh){
-+    ext3cow_reclaim_dup_inode(dentry->d_parent->d_parent->d_inode, dir);
-+		return retval;
-+  }
-+	de = (struct ext3cow_dir_entry_2 *) bh->b_data;
-+	de->inode = 0;
-+	de->rec_len = cpu_to_le16(blocksize);
-+	return add_dirent_to_buf(handle, dentry, inode, de, bh);
-+}
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+/*
-+ * Returns 0 for success, or a negative error value
-+ */
-+static int ext3cow_dx_add_entry(handle_t *handle, struct dentry *dentry,
-+			     struct inode *inode)
-+{
-+	struct dx_frame frames[2], *frame;
-+	struct dx_entry *entries, *at;
-+	struct dx_hash_info hinfo;
-+	struct buffer_head * bh;
-+	struct inode *dir = dentry->d_parent->d_inode;
-+	struct super_block * sb = dir->i_sb;
-+	struct ext3cow_dir_entry_2 *de;
-+	int err;
-+
-+	frame = dx_probe(dentry, NULL, &hinfo, frames, &err);
-+	if (!frame)
-+		return err;
-+	entries = frame->entries;
-+	at = frame->at;
-+
-+	if (!(bh = ext3cow_bread(handle,dir, dx_get_block(frame->at), 0, &err)))
-+		goto cleanup;
-+
-+	BUFFER_TRACE(bh, "get_write_access");
-+	err = ext3cow_journal_get_write_access(handle, bh);
-+	if (err)
-+		goto journal_error;
-+
-+	err = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
-+	if (err != -ENOSPC) {
-+		bh = NULL;
-+		goto cleanup;
-+	}
-+
-+	/* Block full, should compress but for now just split */
-+	dxtrace(printk("using %u of %u node entries\n",
-+		       dx_get_count(entries), dx_get_limit(entries)));
-+	/* Need to split index? */
-+	if (dx_get_count(entries) == dx_get_limit(entries)) {
-+		u32 newblock;
-+		unsigned icount = dx_get_count(entries);
-+		int levels = frame - frames;
-+		struct dx_entry *entries2;
-+		struct dx_node *node2;
-+		struct buffer_head *bh2;
-+
-+		if (levels && (dx_get_count(frames->entries) ==
-+			       dx_get_limit(frames->entries))) {
-+			ext3cow_warning(sb, __FUNCTION__,
-+				     "Directory index full!");
-+			err = -ENOSPC;
-+			goto cleanup;
-+		}
-+		bh2 = ext3cow_append (handle, dir, &newblock, &err);
-+		if (!(bh2))
-+			goto cleanup;
-+		node2 = (struct dx_node *)(bh2->b_data);
-+		entries2 = node2->entries;
-+		node2->fake.rec_len = cpu_to_le16(sb->s_blocksize);
-+		node2->fake.inode = 0;
-+		BUFFER_TRACE(frame->bh, "get_write_access");
-+		err = ext3cow_journal_get_write_access(handle, frame->bh);
-+		if (err)
-+			goto journal_error;
-+		if (levels) {
-+			unsigned icount1 = icount/2, icount2 = icount - icount1;
-+			unsigned hash2 = dx_get_hash(entries + icount1);
-+			dxtrace(printk("Split index %i/%i\n", icount1, icount2));
-+
-+			BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */
-+			err = ext3cow_journal_get_write_access(handle,
-+							     frames[0].bh);
-+			if (err)
-+				goto journal_error;
-+
-+			memcpy ((char *) entries2, (char *) (entries + icount1),
-+				icount2 * sizeof(struct dx_entry));
-+			dx_set_count (entries, icount1);
-+			dx_set_count (entries2, icount2);
-+			dx_set_limit (entries2, dx_node_limit(dir));
-+
-+			/* Which index block gets the new entry? */
-+			if (at - entries >= icount1) {
-+				frame->at = at = at - entries - icount1 + entries2;
-+				frame->entries = entries = entries2;
-+				swap(frame->bh, bh2);
-+			}
-+			dx_insert_block (frames + 0, hash2, newblock);
-+			dxtrace(dx_show_index ("node", frames[1].entries));
-+			dxtrace(dx_show_index ("node",
-+			       ((struct dx_node *) bh2->b_data)->entries));
-+			err = ext3cow_journal_dirty_metadata(handle, bh2);
-+			if (err)
-+				goto journal_error;
-+			brelse (bh2);
-+		} else {
-+			dxtrace(printk("Creating second level index...\n"));
-+			memcpy((char *) entries2, (char *) entries,
-+			       icount * sizeof(struct dx_entry));
-+			dx_set_limit(entries2, dx_node_limit(dir));
-+
-+			/* Set up root */
-+			dx_set_count(entries, 1);
-+			dx_set_block(entries + 0, newblock);
-+			((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1;
-+
-+			/* Add new access path frame */
-+			frame = frames + 1;
-+			frame->at = at = at - entries + entries2;
-+			frame->entries = entries = entries2;
-+			frame->bh = bh2;
-+			err = ext3cow_journal_get_write_access(handle,
-+							     frame->bh);
-+			if (err)
-+				goto journal_error;
-+		}
-+		ext3cow_journal_dirty_metadata(handle, frames[0].bh);
-+	}
-+	de = do_split(handle, dir, &bh, frame, &hinfo, &err);
-+	if (!de)
-+		goto cleanup;
-+	err = add_dirent_to_buf(handle, dentry, inode, de, bh);
-+	bh = NULL;
-+	goto cleanup;
-+
-+journal_error:
-+	ext3cow_std_error(dir->i_sb, err);
-+cleanup:
-+	if (bh)
-+		brelse(bh);
-+	dx_release(frames);
-+	return err;
-+}
-+#endif
-+
-+/*
-+ * ext3cow_delete_entry deletes a directory entry by merging it with the
-+ * previous entry
-+ */
-+static int ext3cow_delete_entry (handle_t *handle,
-+                                 struct inode * dir,
-+                                 struct ext3cow_dir_entry_2 * de_del,
-+                                 struct buffer_head * bh,
-+                                 struct dentry *dentry)
-+{
-+	struct ext3cow_dir_entry_2 * de, * pde;
-+	int i;
-+
-+	i = 0;
-+	pde = NULL;
-+	de = (struct ext3cow_dir_entry_2 *) bh->b_data;
-+	while (i < bh->b_size) {
-+		if (!ext3cow_check_dir_entry("ext3cow_delete_entry", dir, de, bh, i))
-+			return -EIO;
-+		if (de == de_del)  {
-+      /* Can't delete an already dead entry - znjp */
-+      if(!EXT3COW_IS_DIRENT_ALIVE(de))
-+        return 0;
-+      
-+      if(EXT3COW_S_EPOCHNUMBER(dir->i_sb) > EXT3COW_I_EPOCHNUMBER(dir)){
-+        if(ext3cow_dup_inode(dentry->d_parent->d_parent->d_inode, dir))
-+          //if(ext3cow_dup_inode(NULL, dir))
-+          return -1;
-+      }
-+
-+			BUFFER_TRACE(bh, "get_write_access");
-+			ext3cow_journal_get_write_access(handle, bh);
-+      /* There used to be code here to adjust the rec_len
-+       * but since names really never go away, the code was deleted 
-+			if (pde)
-+				pde->rec_len =
-+					cpu_to_le16(le16_to_cpu(pde->rec_len) +
-+						    le16_to_cpu(de->rec_len));
-+			else
-+				de->inode = 0;
-+      */
-+      /* Mark it dead - znjp */
-+      de->death_epoch = cpu_to_le32(EXT3COW_I_EPOCHNUMBER(dir));
-+			dir->i_version++;
-+			BUFFER_TRACE(bh, "call ext3cow_journal_dirty_metadata");
-+			ext3cow_journal_dirty_metadata(handle, bh);
-+			return 0;
-+		}
-+		i += le16_to_cpu(de->rec_len);
-+		pde = de;
-+		de = (struct ext3cow_dir_entry_2 *)
-+			((char *) de + le16_to_cpu(de->rec_len));
-+	}
-+	return -ENOENT;
-+}
-+
-+/*
-+ * ext3cow_mark_inode_dirty is somewhat expensive, so unlike ext2 we
-+ * do not perform it in these functions.  We perform it at the call site,
-+ * if it is needed.
-+ */
-+static inline void ext3cow_inc_count(handle_t *handle, struct inode *inode)
-+{
-+	inc_nlink(inode);
-+}
-+
-+static inline void ext3cow_dec_count(handle_t *handle, struct inode *inode)
-+{
-+	drop_nlink(inode);
-+}
-+
-+static int ext3cow_add_nondir(handle_t *handle,
-+		struct dentry *dentry, struct inode *inode)
-+{
-+	int err = ext3cow_add_entry(handle, dentry, inode);
-+	if (!err) {
-+		ext3cow_mark_inode_dirty(handle, inode);
-+		d_instantiate(dentry, inode);
-+		return 0;
-+	}
-+	ext3cow_dec_count(handle, inode);
-+	iput(inode);
-+	return err;
-+}
-+
-+/*
-+ * By the time this is called, we already have created
-+ * the directory cache entry for the new file, but it
-+ * is so far negative - it has no inode.
-+ *
-+ * If the create succeeds, we fill in the inode information
-+ * with d_instantiate().
-+ */
-+static int ext3cow_create (struct inode * dir, struct dentry * dentry, int mode,
-+		struct nameidata *nd)
-+{
-+	handle_t *handle;
-+	struct inode * inode;
-+	int err, retries = 0;
-+
-+  /* Can't create in the past -znjp */
-+  if(is_unchangeable(dir, dentry))
-+    return -EROFS;
-+
-+retry:
-+	handle = ext3cow_journal_start(dir, EXT3COW_DATA_TRANS_BLOCKS(dir->i_sb) +
-+					EXT3COW_INDEX_EXTRA_TRANS_BLOCKS + 3 +
-+					2*EXT3COW_QUOTA_INIT_BLOCKS(dir->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(dir))
-+		handle->h_sync = 1;
-+
-+	inode = ext3cow_new_inode (handle, dir, mode);
-+	err = PTR_ERR(inode);
-+	if (!IS_ERR(inode)) {
-+		inode->i_op = &ext3cow_file_inode_operations;
-+		inode->i_fop = &ext3cow_file_operations;
-+		ext3cow_set_aops(inode);
-+		err = ext3cow_add_nondir(handle, dentry, inode);
-+	}
-+	ext3cow_journal_stop(handle);
-+	if (err == -ENOSPC && ext3cow_should_retry_alloc(dir->i_sb, &retries))
-+		goto retry;
-+	return err;
-+}
-+
-+static int ext3cow_mknod (struct inode * dir, struct dentry *dentry,
-+			int mode, dev_t rdev)
-+{
-+	handle_t *handle;
-+	struct inode *inode;
-+	int err, retries = 0;
-+
-+	if (!new_valid_dev(rdev))
-+		return -EINVAL;
-+
-+retry:
-+	handle = ext3cow_journal_start(dir, EXT3COW_DATA_TRANS_BLOCKS(dir->i_sb) +
-+					EXT3COW_INDEX_EXTRA_TRANS_BLOCKS + 3 +
-+					2*EXT3COW_QUOTA_INIT_BLOCKS(dir->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(dir))
-+		handle->h_sync = 1;
-+
-+	inode = ext3cow_new_inode (handle, dir, mode);
-+	err = PTR_ERR(inode);
-+	if (!IS_ERR(inode)) {
-+		init_special_inode(inode, inode->i_mode, rdev);
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+		inode->i_op = &ext3cow_special_inode_operations;
-+#endif
-+		err = ext3cow_add_nondir(handle, dentry, inode);
-+	}
-+	ext3cow_journal_stop(handle);
-+	if (err == -ENOSPC && ext3cow_should_retry_alloc(dir->i_sb, &retries))
-+		goto retry;
-+	return err;
-+}
-+
-+static int ext3cow_mkdir(struct inode * dir, struct dentry * dentry, int mode)
-+{
-+	handle_t *handle;
-+	struct inode * inode;
-+	struct buffer_head * dir_block;
-+	struct ext3cow_dir_entry_2 * de;
-+	int err, retries = 0;
-+
-+	if (dir->i_nlink >= EXT3COW_LINK_MAX)
-+		return -EMLINK;
-+  /* No mkdirs in the past -znjp */
-+  if(is_unchangeable(dir, dentry))
-+    return -EROFS;
-+
-+
-+retry:
-+	handle = ext3cow_journal_start(dir, EXT3COW_DATA_TRANS_BLOCKS(dir->i_sb) +
-+					EXT3COW_INDEX_EXTRA_TRANS_BLOCKS + 3 +
-+					2*EXT3COW_QUOTA_INIT_BLOCKS(dir->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(dir))
-+		handle->h_sync = 1;
-+
-+	inode = ext3cow_new_inode (handle, dir, S_IFDIR | mode);
-+	err = PTR_ERR(inode);
-+	if (IS_ERR(inode))
-+		goto out_stop;
-+
-+	inode->i_op = &ext3cow_dir_inode_operations;
-+	inode->i_fop = &ext3cow_dir_operations;
-+	inode->i_size = EXT3COW_I(inode)->i_disksize = inode->i_sb->s_blocksize;
-+	dir_block = ext3cow_bread (handle, inode, 0, 1, &err);
-+	if (!dir_block) {
-+		drop_nlink(inode); /* is this nlink == 0? */
-+		ext3cow_mark_inode_dirty(handle, inode);
-+		iput (inode);
-+		goto out_stop;
-+	}
-+	BUFFER_TRACE(dir_block, "get_write_access");
-+	ext3cow_journal_get_write_access(handle, dir_block);
-+	de = (struct ext3cow_dir_entry_2 *) dir_block->b_data;
-+	de->inode = cpu_to_le32(inode->i_ino);
-+	de->name_len = 1;
-+	de->rec_len = cpu_to_le16(EXT3COW_DIR_REC_LEN(de->name_len));
-+  /* For versioning -znjp */
-+  de->birth_epoch = cpu_to_le32(EXT3COW_S_EPOCHNUMBER(dir->i_sb));
-+  de->death_epoch = cpu_to_le32(EXT3COW_DIRENT_ALIVE);
-+	strcpy (de->name, ".");
-+	ext3cow_set_de_type(dir->i_sb, de, S_IFDIR);
-+	de = (struct ext3cow_dir_entry_2 *)
-+			((char *) de + le16_to_cpu(de->rec_len));
-+	de->inode = cpu_to_le32(dir->i_ino);
-+	de->rec_len = cpu_to_le16(inode->i_sb->s_blocksize-EXT3COW_DIR_REC_LEN(1));
-+	de->name_len = 2;
-+	strcpy (de->name, "..");
-+	ext3cow_set_de_type(dir->i_sb, de, S_IFDIR);
-+	inode->i_nlink = 2;
-+  /* For versioning -znjp */
-+  de->birth_epoch = cpu_to_le32(EXT3COW_I_EPOCHNUMBER(dir)); 
-+  de->death_epoch = cpu_to_le32(EXT3COW_DIRENT_ALIVE);
-+	BUFFER_TRACE(dir_block, "call ext3cow_journal_dirty_metadata");
-+	ext3cow_journal_dirty_metadata(handle, dir_block);
-+	brelse (dir_block);
-+	ext3cow_mark_inode_dirty(handle, inode);
-+	err = ext3cow_add_entry (handle, dentry, inode);
-+	if (err) {
-+		inode->i_nlink = 0;
-+		ext3cow_mark_inode_dirty(handle, inode);
-+		iput (inode);
-+		goto out_stop;
-+	}
-+	inc_nlink(dir);
-+	ext3cow_update_dx_flag(dir);
-+	ext3cow_mark_inode_dirty(handle, dir);
-+	d_instantiate(dentry, inode);
-+out_stop:
-+	ext3cow_journal_stop(handle);
-+	if (err == -ENOSPC && ext3cow_should_retry_alloc(dir->i_sb, &retries))
-+		goto retry;
-+	return err;
-+}
-+
-+/*
-+ * routine to check that the specified directory is empty (for rmdir)
-+ */
-+static int empty_dir (struct inode * inode)
-+{
-+	unsigned long offset;
-+	struct buffer_head * bh;
-+	struct ext3cow_dir_entry_2 * de, * de1;
-+	struct super_block * sb;
-+	int err = 0;
-+
-+	sb = inode->i_sb;
-+	if (inode->i_size < EXT3COW_DIR_REC_LEN(1) + EXT3COW_DIR_REC_LEN(2) ||
-+	    !(bh = ext3cow_bread (NULL, inode, 0, 0, &err))) {
-+		if (err)
-+			ext3cow_error(inode->i_sb, __FUNCTION__,
-+				   "error %d reading directory #%lu offset 0",
-+				   err, inode->i_ino);
-+		else
-+			ext3cow_warning(inode->i_sb, __FUNCTION__,
-+				     "bad directory (dir #%lu) - no data block",
-+				     inode->i_ino);
-+		return 1;
-+	}
-+	de = (struct ext3cow_dir_entry_2 *) bh->b_data;
-+	de1 = (struct ext3cow_dir_entry_2 *)
-+			((char *) de + le16_to_cpu(de->rec_len));
-+	if (le32_to_cpu(de->inode) != inode->i_ino ||
-+			!le32_to_cpu(de1->inode) ||
-+			strcmp (".", de->name) ||
-+			strcmp ("..", de1->name)) {
-+		ext3cow_warning (inode->i_sb, "empty_dir",
-+			      "bad directory (dir #%lu) - no `.' or `..'",
-+			      inode->i_ino);
-+		brelse (bh);
-+		return 1;
-+	}
-+	offset = le16_to_cpu(de->rec_len) + le16_to_cpu(de1->rec_len);
-+	de = (struct ext3cow_dir_entry_2 *)
-+			((char *) de1 + le16_to_cpu(de1->rec_len));
-+	while (offset < inode->i_size ) {
-+		if (!bh ||
-+			(void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
-+			err = 0;
-+			brelse (bh);
-+			bh = ext3cow_bread (NULL, inode,
-+				offset >> EXT3COW_BLOCK_SIZE_BITS(sb), 0, &err);
-+			if (!bh) {
-+				if (err)
-+					ext3cow_error(sb, __FUNCTION__,
-+						   "error %d reading directory"
-+						   " #%lu offset %lu",
-+						   err, inode->i_ino, offset);
-+				offset += sb->s_blocksize;
-+				continue;
-+			}
-+			de = (struct ext3cow_dir_entry_2 *) bh->b_data;
-+		}
-+		if (!ext3cow_check_dir_entry("empty_dir", inode, de, bh, offset)) {
-+			de = (struct ext3cow_dir_entry_2 *)(bh->b_data +
-+							 sb->s_blocksize);
-+			offset = (offset | (sb->s_blocksize - 1)) + 1;
-+			continue;
-+		}
-+    /* Can remove a dir only if all dirents are out of scope -znjp */
-+		if (le32_to_cpu(de->inode) &&
-+        EXT3COW_IS_DIRENT_SCOPED(de, EXT3COW_I_EPOCHNUMBER(inode))) {
-+			brelse (bh);
-+			return 0;
-+		}
-+		offset += le16_to_cpu(de->rec_len);
-+		de = (struct ext3cow_dir_entry_2 *)
-+				((char *) de + le16_to_cpu(de->rec_len));
-+	}
-+	brelse (bh);
-+	return 1;
-+}
-+
-+/* ext3cow_orphan_add() links an unlinked or truncated inode into a list of
-+ * such inodes, starting at the superblock, in case we crash before the
-+ * file is closed/deleted, or in case the inode truncate spans multiple
-+ * transactions and the last transaction is not recovered after a crash.
-+ *
-+ * At filesystem recovery time, we walk this list deleting unlinked
-+ * inodes and truncating linked inodes in ext3cow_orphan_cleanup().
-+ */
-+int ext3cow_orphan_add(handle_t *handle, struct inode *inode)
-+{
-+	struct super_block *sb = inode->i_sb;
-+	struct ext3cow_iloc iloc;
-+	int err = 0, rc;
-+
-+	lock_super(sb);
-+	if (!list_empty(&EXT3COW_I(inode)->i_orphan))
-+		goto out_unlock;
-+
-+	/* Orphan handling is only valid for files with data blocks
-+	 * being truncated, or files being unlinked. */
-+
-+	/* @@@ FIXME: Observation from aviro:
-+	 * I think I can trigger J_ASSERT in ext3cow_orphan_add().  We block
-+	 * here (on lock_super()), so race with ext3cow_link() which might bump
-+	 * ->i_nlink. For, say it, character device. Not a regular file,
-+	 * not a directory, not a symlink and ->i_nlink > 0.
-+	 */
-+	J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
-+		S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
-+
-+	BUFFER_TRACE(EXT3COW_SB(sb)->s_sbh, "get_write_access");
-+	err = ext3cow_journal_get_write_access(handle, EXT3COW_SB(sb)->s_sbh);
-+	if (err)
-+		goto out_unlock;
-+
-+	err = ext3cow_reserve_inode_write(handle, inode, &iloc);
-+	if (err)
-+		goto out_unlock;
-+
-+	/* Insert this inode at the head of the on-disk orphan list... */
-+	NEXT_ORPHAN(inode) = le32_to_cpu(EXT3COW_SB(sb)->s_es->s_last_orphan);
-+	EXT3COW_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
-+	err = ext3cow_journal_dirty_metadata(handle, EXT3COW_SB(sb)->s_sbh);
-+	rc = ext3cow_mark_iloc_dirty(handle, inode, &iloc);
-+	if (!err)
-+		err = rc;
-+
-+	/* Only add to the head of the in-memory list if all the
-+	 * previous operations succeeded.  If the orphan_add is going to
-+	 * fail (possibly taking the journal offline), we can't risk
-+	 * leaving the inode on the orphan list: stray orphan-list
-+	 * entries can cause panics at unmount time.
-+	 *
-+	 * This is safe: on error we're going to ignore the orphan list
-+	 * anyway on the next recovery. */
-+	if (!err)
-+		list_add(&EXT3COW_I(inode)->i_orphan, &EXT3COW_SB(sb)->s_orphan);
-+
-+	jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
-+	jbd_debug(4, "orphan inode %lu will point to %d\n",
-+			inode->i_ino, NEXT_ORPHAN(inode));
-+out_unlock:
-+	unlock_super(sb);
-+	ext3cow_std_error(inode->i_sb, err);
-+	return err;
-+}
-+
-+/*
-+ * ext3cow_orphan_del() removes an unlinked or truncated inode from the list
-+ * of such inodes stored on disk, because it is finally being cleaned up.
-+ */
-+int ext3cow_orphan_del(handle_t *handle, struct inode *inode)
-+{
-+	struct list_head *prev;
-+	struct ext3cow_inode_info *ei = EXT3COW_I(inode);
-+	struct ext3cow_sb_info *sbi;
-+	unsigned long ino_next;
-+	struct ext3cow_iloc iloc;
-+	int err = 0;
-+
-+	lock_super(inode->i_sb);
-+	if (list_empty(&ei->i_orphan)) {
-+		unlock_super(inode->i_sb);
-+		return 0;
-+	}
-+
-+	ino_next = NEXT_ORPHAN(inode);
-+	prev = ei->i_orphan.prev;
-+	sbi = EXT3COW_SB(inode->i_sb);
-+
-+	jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino);
-+
-+	list_del_init(&ei->i_orphan);
-+
-+	/* If we're on an error path, we may not have a valid
-+	 * transaction handle with which to update the orphan list on
-+	 * disk, but we still need to remove the inode from the linked
-+	 * list in memory. */
-+	if (!handle)
-+		goto out;
-+
-+	err = ext3cow_reserve_inode_write(handle, inode, &iloc);
-+	if (err)
-+		goto out_err;
-+
-+	if (prev == &sbi->s_orphan) {
-+		jbd_debug(4, "superblock will point to %lu\n", ino_next);
-+		BUFFER_TRACE(sbi->s_sbh, "get_write_access");
-+		err = ext3cow_journal_get_write_access(handle, sbi->s_sbh);
-+		if (err)
-+			goto out_brelse;
-+		sbi->s_es->s_last_orphan = cpu_to_le32(ino_next);
-+		err = ext3cow_journal_dirty_metadata(handle, sbi->s_sbh);
-+	} else {
-+		struct ext3cow_iloc iloc2;
-+		struct inode *i_prev =
-+			&list_entry(prev, struct ext3cow_inode_info, i_orphan)->vfs_inode;
-+
-+		jbd_debug(4, "orphan inode %lu will point to %lu\n",
-+			  i_prev->i_ino, ino_next);
-+		err = ext3cow_reserve_inode_write(handle, i_prev, &iloc2);
-+		if (err)
-+			goto out_brelse;
-+		NEXT_ORPHAN(i_prev) = ino_next;
-+		err = ext3cow_mark_iloc_dirty(handle, i_prev, &iloc2);
-+	}
-+	if (err)
-+		goto out_brelse;
-+	NEXT_ORPHAN(inode) = 0;
-+	err = ext3cow_mark_iloc_dirty(handle, inode, &iloc);
-+
-+out_err:
-+	ext3cow_std_error(inode->i_sb, err);
-+out:
-+	unlock_super(inode->i_sb);
-+	return err;
-+
-+out_brelse:
-+	brelse(iloc.bh);
-+	goto out_err;
-+}
-+
-+static int ext3cow_rmdir (struct inode * dir, struct dentry *dentry)
-+{
-+	int retval;
-+	struct inode * inode;
-+	struct buffer_head * bh;
-+	struct ext3cow_dir_entry_2 * de;
-+	handle_t *handle;
-+
-+	/* Initialize quotas before so that eventual writes go in
-+	 * separate transaction */
-+	DQUOT_INIT(dentry->d_inode);
-+	handle = ext3cow_journal_start(dir, EXT3COW_DELETE_TRANS_BLOCKS(dir->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	retval = -ENOENT;
-+	bh = ext3cow_find_entry (dentry, &de);
-+	if (!bh)
-+		goto end_rmdir;
-+
-+	if (IS_DIRSYNC(dir))
-+		handle->h_sync = 1;
-+
-+	inode = dentry->d_inode;
-+
-+  /* Can't rmdir in the past -znjp */
-+  retval = -EROFS;
-+  if(is_unchangeable(inode, dentry))
-+    goto end_rmdir;
-+
-+	retval = -EIO;
-+	if (le32_to_cpu(de->inode) != inode->i_ino)
-+		goto end_rmdir;
-+
-+	retval = -ENOTEMPTY;
-+	if (!empty_dir (inode))
-+		goto end_rmdir;
-+
-+	retval = ext3cow_delete_entry(handle, dir, de, bh, dentry);
-+	if (retval)
-+		goto end_rmdir;
-+	if (inode->i_nlink != 2)
-+		ext3cow_warning (inode->i_sb, "ext3cow_rmdir",
-+			      "empty directory has nlink!=2 (%d)",
-+			      inode->i_nlink);
-+	inode->i_version++;
-+
-+  /* We only delete things that were created in the same epoch -znjp */
-+  if(de->birth_epoch == de->death_epoch){
-+    clear_nlink(inode);
-+    /* There's no need to set i_disksize: the fact that i_nlink is
-+     * zero will ensure that the right thing happens during any
-+     * recovery. */
-+    inode->i_size = 0;
-+    ext3cow_orphan_add(handle, inode);
-+    drop_nlink(dir);
-+  }
-+  EXT3COW_I(inode)->i_flags |= EXT3COW_UNCHANGEABLE_FL;
-+  inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
-+  ext3cow_mark_inode_dirty(handle, inode);
-+  ext3cow_update_dx_flag(dir);
-+	ext3cow_mark_inode_dirty(handle, dir);
-+
-+end_rmdir:
-+	ext3cow_journal_stop(handle);
-+	brelse (bh);
-+	return retval;
-+}
-+
-+static int ext3cow_unlink(struct inode * dir, struct dentry *dentry)
-+{
-+	int retval;
-+	struct inode * inode;
-+	struct buffer_head * bh;
-+	struct ext3cow_dir_entry_2 * de;
-+	handle_t *handle;
-+
-+	/* Initialize quotas before so that eventual writes go
-+	 * in separate transaction */
-+	DQUOT_INIT(dentry->d_inode);
-+	handle = ext3cow_journal_start(dir, EXT3COW_DELETE_TRANS_BLOCKS(dir->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(dir))
-+		handle->h_sync = 1;
-+
-+	retval = -ENOENT;
-+	bh = ext3cow_find_entry (dentry, &de);
-+	if (!bh)
-+		goto end_unlink;
-+
-+	inode = dentry->d_inode;
-+
-+  /* Can't unlink in the past -znjp */
-+  retval = -EROFS;
-+  if(is_unchangeable(inode, dentry))
-+    goto end_unlink;  
-+  
-+	retval = -EIO;
-+	if (le32_to_cpu(de->inode) != inode->i_ino)
-+		goto end_unlink;
-+
-+	if (!inode->i_nlink) {
-+		ext3cow_warning (inode->i_sb, "ext3cow_unlink",
-+			      "Deleting nonexistent file (%lu), %d",
-+			      inode->i_ino, inode->i_nlink);
-+		inode->i_nlink = 1;
-+	}
-+	retval = ext3cow_delete_entry(handle, dir, de, bh, dentry);
-+	if (retval)
-+		goto end_unlink;
-+	dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
-+	ext3cow_update_dx_flag(dir);
-+	ext3cow_mark_inode_dirty(handle, dir);
-+
-+  /* If the file should be deleted here, don't actually delete it
-+   * but mark it unchangeable, i.e. it's now in the past. -znjp */
-+
-+  /* If file was created in this epoch, then we actually unlink it,
-+   * if not, then it belongs to the past, so mark it unchangeable -znjp */
-+  if(de->birth_epoch == de->death_epoch){
-+  	drop_nlink(inode);
-+    if (!inode->i_nlink){
-+      ext3cow_orphan_add(handle, inode);
-+    }
-+  }else{
-+    if(!(inode->i_nlink - 1))
-+      EXT3COW_I(inode)->i_flags |= EXT3COW_UNCHANGEABLE_FL; 
-+  }
-+	inode->i_ctime = dir->i_ctime;
-+	ext3cow_mark_inode_dirty(handle, inode);
-+	retval = 0;
-+
-+end_unlink:
-+	ext3cow_journal_stop(handle);
-+	brelse (bh);
-+	return retval;
-+}
-+
-+static int ext3cow_symlink (struct inode * dir,
-+		struct dentry *dentry, const char * symname)
-+{
-+	handle_t *handle;
-+	struct inode * inode;
-+	int l, err, retries = 0;
-+
-+	l = strlen(symname)+1;
-+	if (l > dir->i_sb->s_blocksize)
-+		return -ENAMETOOLONG;
-+
-+retry:
-+	handle = ext3cow_journal_start(dir, EXT3COW_DATA_TRANS_BLOCKS(dir->i_sb) +
-+					EXT3COW_INDEX_EXTRA_TRANS_BLOCKS + 5 +
-+					2*EXT3COW_QUOTA_INIT_BLOCKS(dir->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(dir))
-+		handle->h_sync = 1;
-+
-+	inode = ext3cow_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
-+	err = PTR_ERR(inode);
-+	if (IS_ERR(inode))
-+		goto out_stop;
-+
-+	if (l > sizeof (EXT3COW_I(inode)->i_data)) {
-+		inode->i_op = &ext3cow_symlink_inode_operations;
-+		ext3cow_set_aops(inode);
-+		/*
-+		 * page_symlink() calls into ext3cow_prepare/commit_write.
-+		 * We have a transaction open.  All is sweetness.  It also sets
-+		 * i_size in generic_commit_write().
-+		 */
-+		err = __page_symlink(inode, symname, l,
-+				mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
-+		if (err) {
-+			ext3cow_dec_count(handle, inode);
-+			ext3cow_mark_inode_dirty(handle, inode);
-+			iput (inode);
-+			goto out_stop;
-+		}
-+	} else {
-+		inode->i_op = &ext3cow_fast_symlink_inode_operations;
-+		memcpy((char*)&EXT3COW_I(inode)->i_data,symname,l);
-+		inode->i_size = l-1;
-+	}
-+	EXT3COW_I(inode)->i_disksize = inode->i_size;
-+	err = ext3cow_add_nondir(handle, dentry, inode);
-+out_stop:
-+	ext3cow_journal_stop(handle);
-+	if (err == -ENOSPC && ext3cow_should_retry_alloc(dir->i_sb, &retries))
-+		goto retry;
-+	return err;
-+}
-+
-+static int ext3cow_link (struct dentry * old_dentry,
-+		struct inode * dir, struct dentry *dentry)
-+{
-+	handle_t *handle;
-+	struct inode *inode = old_dentry->d_inode;
-+	int err, retries = 0;
-+
-+	if (inode->i_nlink >= EXT3COW_LINK_MAX)
-+		return -EMLINK;
-+
-+retry:
-+	handle = ext3cow_journal_start(dir, EXT3COW_DATA_TRANS_BLOCKS(dir->i_sb) +
-+					EXT3COW_INDEX_EXTRA_TRANS_BLOCKS);
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(dir))
-+		handle->h_sync = 1;
-+
-+	inode->i_ctime = CURRENT_TIME_SEC;
-+	ext3cow_inc_count(handle, inode);
-+	atomic_inc(&inode->i_count);
-+
-+	err = ext3cow_add_nondir(handle, dentry, inode);
-+	ext3cow_journal_stop(handle);
-+	if (err == -ENOSPC && ext3cow_should_retry_alloc(dir->i_sb, &retries))
-+		goto retry;
-+	return err;
-+}
-+
-+#define PARENT_INO(buffer) \
-+	((struct ext3cow_dir_entry_2 *) ((char *) buffer + \
-+	le16_to_cpu(((struct ext3cow_dir_entry_2 *) buffer)->rec_len)))->inode
-+
-+/*
-+ * Anybody can rename anything with this: the permission checks are left to the
-+ * higher-level routines.
-+ */
-+static int ext3cow_rename (struct inode * old_dir, struct dentry *old_dentry,
-+			   struct inode * new_dir,struct dentry *new_dentry)
-+{
-+	handle_t *handle;
-+	struct inode * old_inode, * new_inode;
-+	struct buffer_head * old_bh, * new_bh, * dir_bh;
-+	struct ext3cow_dir_entry_2 * old_de, * new_de;
-+	int retval;
-+
-+	old_bh = new_bh = dir_bh = NULL;
-+
-+	/* Initialize quotas before so that eventual writes go
-+	 * in separate transaction */
-+	if (new_dentry->d_inode)
-+		DQUOT_INIT(new_dentry->d_inode);
-+	handle = ext3cow_journal_start(old_dir, 2 *
-+                                 EXT3COW_DATA_TRANS_BLOCKS(old_dir->i_sb) +
-+                                 EXT3COW_INDEX_EXTRA_TRANS_BLOCKS + 2);
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
-+		handle->h_sync = 1;
-+
-+	old_bh = ext3cow_find_entry (old_dentry, &old_de);
-+	/*
-+	 *  Check for inode number is _not_ due to possible IO errors.
-+	 *  We might rmdir the source, keep it as pwd of some process
-+	 *  and merrily kill the link to whatever was created under the
-+	 *  same name. Goodbye sticky bit ;-<
-+	 */
-+	old_inode = old_dentry->d_inode;
-+	retval = -ENOENT;
-+	if (!old_bh || le32_to_cpu(old_de->inode) != old_inode->i_ino)
-+		goto end_rename;
-+
-+	new_inode = new_dentry->d_inode;
-+	new_bh = ext3cow_find_entry (new_dentry, &new_de);
-+	if (new_bh) {
-+		if (!new_inode) {
-+			brelse (new_bh);
-+			new_bh = NULL;
-+		}
-+	}
-+
-+  /* can't move something into the past -znjp */
-+  retval = -EROFS;
-+  if(is_unchangeable(new_inode, new_dentry)) 
-+    goto end_rename;
-+  /* can't some move from the past -znjp */
-+  if(is_unchangeable(old_inode, old_dentry))
-+    goto end_rename;
-+
-+	if (S_ISDIR(old_inode->i_mode)) {
-+		if (new_inode) {
-+			retval = -ENOTEMPTY;
-+			if (!empty_dir (new_inode))
-+				goto end_rename;
-+		}
-+		retval = -EIO;
-+		dir_bh = ext3cow_bread (handle, old_inode, 0, 0, &retval);
-+		if (!dir_bh)
-+			goto end_rename;
-+		if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino)
-+			goto end_rename;
-+		retval = -EMLINK;
-+		if (!new_inode && new_dir!=old_dir &&
-+				new_dir->i_nlink >= EXT3COW_LINK_MAX)
-+			goto end_rename;
-+	}
-+	if (!new_bh) {
-+		retval = ext3cow_add_entry (handle, new_dentry, old_inode);
-+		if (retval)
-+			goto end_rename;
-+	} else {
-+		BUFFER_TRACE(new_bh, "get write access");
-+		ext3cow_journal_get_write_access(handle, new_bh);
-+		new_de->inode = cpu_to_le32(old_inode->i_ino);
-+		if (EXT3COW_HAS_INCOMPAT_FEATURE(new_dir->i_sb,
-+					      EXT3COW_FEATURE_INCOMPAT_FILETYPE))
-+			new_de->file_type = old_de->file_type;
-+		new_dir->i_version++;
-+		BUFFER_TRACE(new_bh, "call ext3cow_journal_dirty_metadata");
-+		ext3cow_journal_dirty_metadata(handle, new_bh);
-+		brelse(new_bh);
-+		new_bh = NULL;
-+	}
-+
-+	/*
-+	 * Like most other Unix systems, set the ctime for inodes on a
-+	 * rename.
-+	 */
-+	old_inode->i_ctime = CURRENT_TIME_SEC;
-+	ext3cow_mark_inode_dirty(handle, old_inode);
-+
-+	/*
-+	 * ok, that's it
-+	 */
-+	if (le32_to_cpu(old_de->inode) != old_inode->i_ino ||
-+	    old_de->name_len != old_dentry->d_name.len ||
-+	    strncmp(old_de->name, old_dentry->d_name.name, old_de->name_len) ||
-+	    (retval = ext3cow_delete_entry(handle, old_dir,
-+                                     old_de, old_bh, new_dentry)) == -ENOENT) {
-+		/* old_de could have moved from under us during htree split, so
-+		 * make sure that we are deleting the right entry.  We might
-+		 * also be pointing to a stale entry in the unused part of
-+		 * old_bh so just checking inum and the name isn't enough. */
-+		struct buffer_head *old_bh2;
-+		struct ext3cow_dir_entry_2 *old_de2;
-+
-+		old_bh2 = ext3cow_find_entry(old_dentry, &old_de2);
-+		if (old_bh2) {
-+			retval = ext3cow_delete_entry(handle, old_dir,
-+                                    old_de2, old_bh2, new_dentry);
-+			brelse(old_bh2);
-+		}
-+	}
-+	if (retval) {
-+		ext3cow_warning(old_dir->i_sb, "ext3cow_rename",
-+				"Deleting old file (%lu), %d, error=%d",
-+				old_dir->i_ino, old_dir->i_nlink, retval);
-+	}
-+
-+	if (new_inode) {
-+		new_inode->i_ctime = CURRENT_TIME_SEC;
-+	}
-+  if(!is_unchangeable(old_inode, old_dentry))
-+    old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
-+	ext3cow_update_dx_flag(old_dir);
-+	if (dir_bh) {
-+		BUFFER_TRACE(dir_bh, "get_write_access");
-+		ext3cow_journal_get_write_access(handle, dir_bh);
-+		PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino);
-+		BUFFER_TRACE(dir_bh, "call ext3cow_journal_dirty_metadata");
-+		ext3cow_journal_dirty_metadata(handle, dir_bh);
-+		if (!new_inode) {
-+			inc_nlink(new_dir);
-+			ext3cow_update_dx_flag(new_dir);
-+			ext3cow_mark_inode_dirty(handle, new_dir);
-+		}
-+	}
-+	ext3cow_mark_inode_dirty(handle, old_dir);
-+	if (new_inode) {
-+		ext3cow_mark_inode_dirty(handle, new_inode);
-+		if (!new_inode->i_nlink)
-+			ext3cow_orphan_add(handle, new_inode);
-+	}
-+	retval = 0;
-+
-+end_rename:
-+	brelse (dir_bh);
-+	brelse (old_bh);
-+	brelse (new_bh);
-+	ext3cow_journal_stop(handle);
-+	return retval;
-+}
-+
-+/* ext3cow_fake_inode: This function creates a VFS-only inode
-+ * used for properly scoping views into the past file system - znjp
-+ */
-+struct inode *ext3cow_fake_inode(struct inode *inode,
-+                                 unsigned int epoch_number)
-+{
-+  struct inode * fake_inode = NULL;
-+  struct ext3cow_inode_info * ini = NULL;
-+  struct ext3cow_inode_info * fake_ini = NULL;
-+  static unsigned int last_ino = UINT_MAX;
-+  int err = 0;
-+  int block = -1;
-+
-+  if(NULL == inode){
-+    printk(KERN_ERR "Trying to duplicate a NULL inode.\n");
-+    return NULL;
-+  }
-+
-+  if(EXT3COW_IS_FAKEINODE(inode)){
-+    printk(KERN_ERR "Trying to fake a fake inode.\n");
-+    return inode;
-+  }
-+
-+  printk(KERN_INFO "** faking inode %lu\n", inode->i_ino);
-+
-+  ini = EXT3COW_I(inode);
-+  
-+  /* Create a new VFS-only inode */
-+  fake_inode = new_inode(inode->i_sb);   
-+  err = PTR_ERR(fake_inode);
-+  if(!IS_ERR(fake_inode)){
-+
-+    fake_ini = EXT3COW_I(fake_inode);
-+
-+    printk(KERN_INFO "** got inode %lu setting with %u\n", fake_inode->i_ino,
-+           last_ino);
-+
-+    /* When inode is a directory, we can fake the inode number */
-+    //if(S_ISDIR(inode->i_mode))
-+    fake_inode->i_ino  = --last_ino;
-+
-+    fake_inode->i_mode = inode->i_mode;
-+    fake_inode->i_uid  = inode->i_uid;
-+    fake_inode->i_gid  = inode->i_gid;
-+
-+    atomic_set(&fake_inode->i_count, 1);
-+
-+    fake_inode->i_nlink         = inode->i_nlink;
-+    fake_inode->i_size          = inode->i_size;
-+    fake_inode->i_atime.tv_sec  = inode->i_atime.tv_sec;
-+    fake_inode->i_ctime.tv_sec  = inode->i_ctime.tv_sec;
-+    fake_inode->i_mtime.tv_sec  = inode->i_mtime.tv_sec;
-+    fake_inode->i_atime.tv_nsec = inode->i_atime.tv_nsec;
-+    fake_inode->i_ctime.tv_nsec = inode->i_ctime.tv_nsec;
-+    fake_inode->i_mtime.tv_nsec = inode->i_mtime.tv_nsec;
-+
-+    fake_ini->i_state = ini->i_state;
-+    fake_ini->i_dir_start_lookup = ini->i_dir_start_lookup;
-+    fake_ini->i_dtime = ini->i_dtime;
-+
-+    fake_inode->i_blocks  = inode->i_blocks;
-+    fake_ini->i_flags     = ini->i_flags;
-+#ifdef EXT3COW_FRAGMENTS
-+    /* Taken out for versioning -znjp */
-+    //fake_ini->i_faddr     = ini->i_faddr;
-+    //fake_ini->i_frag_no   = ini->i_frag_no;
-+    //fake_ini->i_frag_size = ini->i_frag_size;
-+#endif
-+    fake_ini->i_file_acl = ini->i_file_acl;
-+    if (!S_ISREG(fake_inode->i_mode)) {
-+      fake_ini->i_dir_acl = ini->i_dir_acl;
-+    } 
-+    fake_ini->i_disksize = inode->i_size;
-+    fake_inode->i_generation = inode->i_generation;
-+    //TODO: This could be wrong.
-+    //fake_ini->i_block_group = ini->i_block_group; //iloc.block_group;
-+
-+    for (block = 0; block < EXT3COW_N_BLOCKS; block++)
-+      fake_ini->i_data[block] = ini->i_data[block];
-+
-+    fake_ini->i_extra_isize = ini->i_extra_isize;
-+
-+    /* set copy-on-write bitmap to 0 */
-+    fake_ini->i_cow_bitmap = 0x0000;
-+    
-+    /* Mark fake inode unchangeable, etc. */
-+    fake_ini->i_flags |= EXT3COW_UNCHANGEABLE_FL;
-+    fake_ini->i_flags |= EXT3COW_UNVERSIONABLE_FL;
-+    fake_ini->i_flags |= EXT3COW_FAKEINODE_FL;
-+    fake_ini->i_flags |= EXT3COW_IMMUTABLE_FL;
-+
-+    /* Make sure we get the right operations */
-+    if (S_ISREG(fake_inode->i_mode)) {
-+      fake_inode->i_op = &ext3cow_file_inode_operations;
-+      fake_inode->i_fop = &ext3cow_file_operations;
-+      ext3cow_set_aops(fake_inode);
-+    } else if (S_ISDIR(fake_inode->i_mode)) {
-+      fake_inode->i_op = &ext3cow_dir_inode_operations;
-+      fake_inode->i_fop = &ext3cow_dir_operations;
-+    } else if (S_ISLNK(fake_inode->i_mode)) {
-+      //if (ext3cow_inode_is_fast_symlink(cow_inode))
-+      if((S_ISLNK(fake_inode->i_mode) && fake_inode->i_blocks - 
-+          (EXT3COW_I(fake_inode)->i_file_acl ? 
-+           (fake_inode->i_sb->s_blocksize >> 9) : 0)))
-+        fake_inode->i_op = &ext3cow_fast_symlink_inode_operations;
-+      else {
-+        fake_inode->i_op = &ext3cow_symlink_inode_operations;
-+        ext3cow_set_aops(fake_inode);
-+      }
-+    } else {
-+      fake_inode->i_op = &ext3cow_special_inode_operations;
-+    }
-+
-+    fake_ini->i_epoch_number = epoch_number;
-+    fake_ini->i_next_inode = 0;
-+    
-+    iput(inode); /* dec i_count */
-+
-+    return fake_inode;
-+  }else
-+    ext3cow_warning(inode->i_sb, "ext3cow_fake_inode",
-+                    "Could not create fake inode.");
-+   
-+ 	return NULL;
-+}
-+
-+/* 
-+ * ext3cow_dup_inode: This function creates a new inode, 
-+ * copies all the metadata from the passed in inode,  
-+ * and adds it to the version chain, creating a new version.  
-+ * The head of the chain never changes; it is always the most current version.
-+ * Similar in nature to ext3cow_creat and ext3cow_read_inode. -znjp
-+ */
-+int ext3cow_dup_inode(struct inode *dir, struct inode *inode){
-+
-+  struct inode *cow_inode = NULL;
-+  struct inode *parent = NULL;
-+  struct ext3cow_inode_info *ini = NULL;
-+  struct ext3cow_inode_info *cow_ini = NULL;
-+  handle_t *handle = NULL;
-+  int err = 0;
-+  int block = -1;
-+  unsigned int epoch_number_temp = 0;
-+  int retries = 0;
-+
-+  printk(KERN_INFO "** duping inode %lu\n", inode->i_ino);
-+
-+  if(EXT3COW_IS_UNVERSIONABLE(inode))
-+    return 0;
-+
-+  if(NULL == inode){
-+    printk(KERN_ERR "Trying to duplicate a NULL inode.\n");
-+    return -1;
-+  }
-+
-+	if (inode->i_nlink == 0) {
-+		if (inode->i_mode == 0 ||
-+		    !(EXT3COW_SB(inode->i_sb)->s_mount_state & EXT3COW_ORPHAN_FS)) {
-+			/* this inode is deleted */
-+      return -1;
-+		}
-+		/* The only unlinked inodes we let through here have
-+		 * valid i_mode and are being read by the orphan
-+		 * recovery code: that's fine, we're about to complete
-+		 * the process of deleting those. */
-+	}
-+
-+  ini = EXT3COW_I(inode);
-+
-+  /* This is for truncate, which can't pass in a parent */
-+  if(NULL == dir)
-+    parent = inode;
-+  else
-+    parent = dir;
-+
-+ retry:
-+	handle = ext3cow_journal_start(parent, EXT3COW_DATA_TRANS_BLOCKS(dir->i_sb) +
-+					EXT3COW_INDEX_EXTRA_TRANS_BLOCKS + 3 +
-+					2*EXT3COW_QUOTA_INIT_BLOCKS(dir->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	if (IS_DIRSYNC(parent))
-+		handle->h_sync = 1;
-+
-+	cow_inode = ext3cow_new_inode (handle, parent, inode->i_mode);
-+	err = PTR_ERR(cow_inode);
-+	if (!IS_ERR(cow_inode)) {
-+
-+    printk(KERN_INFO "  ** Allocated new inode %lu\n", cow_inode->i_ino);
-+
-+    cow_ini = EXT3COW_I(cow_inode);
-+    
-+    cow_inode->i_mode = inode->i_mode;
-+    cow_inode->i_uid  = inode->i_uid;
-+    cow_inode->i_gid  = inode->i_gid;
-+
-+    cow_inode->i_nlink         = inode->i_nlink;
-+    cow_inode->i_size          = inode->i_size;
-+    cow_inode->i_atime.tv_sec  = inode->i_atime.tv_sec;
-+    cow_inode->i_ctime.tv_sec  = inode->i_ctime.tv_sec;
-+    cow_inode->i_mtime.tv_sec  = inode->i_mtime.tv_sec;
-+    cow_inode->i_atime.tv_nsec = inode->i_atime.tv_nsec;
-+    cow_inode->i_ctime.tv_nsec = inode->i_ctime.tv_nsec;
-+    cow_inode->i_mtime.tv_nsec = inode->i_mtime.tv_nsec;
-+
-+    cow_ini->i_state = ini->i_state;
-+    cow_ini->i_dir_start_lookup = ini->i_dir_start_lookup;
-+    cow_ini->i_dtime = ini->i_dtime;
-+
-+    cow_inode->i_blocks  = inode->i_blocks;
-+    cow_ini->i_flags     = ini->i_flags;
-+#ifdef EXT3COW_FRAGMENTS
-+    /* Taken out for versioning -znjp */
-+    //cow_ini->i_faddr     = ini->i_faddr;
-+    //cow_ini->i_frag_no   = ini->i_frag_no;
-+    //cow_ini->i_frag_size = ini->i_frag_size;
-+#endif
-+    cow_ini->i_file_acl = ini->i_file_acl;
-+    if (!S_ISREG(cow_inode->i_mode)) {
-+      cow_ini->i_dir_acl = ini->i_dir_acl;
-+    } 
-+    cow_ini->i_disksize = inode->i_size;
-+    cow_inode->i_generation = inode->i_generation;
-+    //TODO: This could be wrong.
-+    cow_ini->i_block_group = ini->i_block_group; //iloc.block_group;
-+
-+    for (block = 0; block < EXT3COW_N_BLOCKS; block++)
-+      cow_ini->i_data[block] = ini->i_data[block];
-+
-+    //TODO: This could be wrong
-+    //cow_ini->i_orphan = NULL; //INIT_LIST_HEAD(&ei->i_orphan);
-+   
-+    cow_ini->i_extra_isize = ini->i_extra_isize;
-+
-+    /* Make sure we get the right operations */
-+    if (S_ISREG(cow_inode->i_mode)) {
-+      cow_inode->i_op = &ext3cow_file_inode_operations;
-+      cow_inode->i_fop = &ext3cow_file_operations;
-+      ext3cow_set_aops(cow_inode);
-+    } else if (S_ISDIR(cow_inode->i_mode)) {
-+      cow_inode->i_op = &ext3cow_dir_inode_operations;
-+      cow_inode->i_fop = &ext3cow_dir_operations;
-+    } else if (S_ISLNK(cow_inode->i_mode)) {
-+      //if (ext3cow_inode_is_fast_symlink(cow_inode))
-+      if((S_ISLNK(cow_inode->i_mode) && cow_inode->i_blocks - 
-+          (EXT3COW_I(cow_inode)->i_file_acl ? 
-+           (cow_inode->i_sb->s_blocksize >> 9) : 0)))
-+        cow_inode->i_op = &ext3cow_fast_symlink_inode_operations;
-+      else {
-+        cow_inode->i_op = &ext3cow_symlink_inode_operations;
-+        ext3cow_set_aops(cow_inode);
-+      }
-+    } else {
-+      cow_inode->i_op = &ext3cow_special_inode_operations;
-+      /*
-+      if (raw_inode->i_block[0])
-+        init_special_inode(inode, inode->i_mode,
-+                           old_decode_dev(le32_to_cpu(raw_inode->i_block[0])));
-+      else
-+        init_special_inode(inode, inode->i_mode,
-+                           new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
-+      */
-+    }
-+    
-+    /* Dup in the direct cow bitmap */
-+    cow_ini->i_cow_bitmap = ini->i_cow_bitmap;
-+    ini->i_cow_bitmap     = 0x0000;
-+    /* Mark new inode unchangeable */
-+    cow_ini->i_flags |= EXT3COW_UNCHANGEABLE_FL;
-+    /* Switch epoch numbers */
-+    epoch_number_temp = ini->i_epoch_number;
-+    ini->i_epoch_number = cow_ini->i_epoch_number;
-+    cow_ini->i_epoch_number = epoch_number_temp;
-+    /* Chain Inodes together */
-+    cow_ini->i_next_inode = ini->i_next_inode;
-+    ini->i_next_inode = cow_inode->i_ino;
-+
-+    ext3cow_mark_inode_dirty(handle, cow_inode);
-+    ext3cow_mark_inode_dirty(handle, inode);
-+    
-+    iput(cow_inode); /* dec i_count */
-+
-+    err = 0;
-+	}
-+	ext3cow_journal_stop(handle);
-+	if (err == -ENOSPC && ext3cow_should_retry_alloc(dir->i_sb, &retries))
-+		goto retry;
-+	return err;
-+
-+}
-+
-+/* ext3cow_reclaim_dup_inode: rolls back a recently dup'd inode
-+ * on error, including epoch number and bitmaps.  Should not
-+ * be used for removing versions.  */
-+int ext3cow_reclaim_dup_inode(struct inode *dir, struct inode *inode)
-+{
-+  handle_t *handle = NULL;
-+  int err = 0;
-+  struct inode *old_inode = NULL;
-+  struct inode *parent = dir;
-+
-+  if(!parent)
-+    parent = inode;
-+
-+  if(is_bad_inode(inode))
-+    return -1;
-+  
-+  handle = ext3cow_journal_start(parent, 
-+                                 EXT3COW_DELETE_TRANS_BLOCKS(parent->i_sb));
-+  if(IS_ERR(handle))
-+    return PTR_ERR(handle);
-+
-+  if(IS_DIRSYNC(parent))
-+    handle->h_sync = 1;
-+
-+  old_inode = iget(parent->i_sb, EXT3COW_I_NEXT_INODE(inode));
-+  err = PTR_ERR(old_inode);
-+  if (!IS_ERR(old_inode)){
-+
-+    EXT3COW_I(inode)->i_epoch_number = EXT3COW_I_EPOCHNUMBER(old_inode);
-+    EXT3COW_I(inode)->i_cow_bitmap   = EXT3COW_I(old_inode)->i_cow_bitmap;
-+    EXT3COW_I(inode)->i_next_inode   = EXT3COW_I(old_inode)->i_next_inode;
-+    old_inode->i_nlink = 0;
-+
-+    iput(old_inode);
-+    ext3cow_mark_inode_dirty(handle, inode);
-+  }else
-+    ext3cow_error(inode->i_sb, "ext3cow_reclaim_dup_inode", 
-+                  "Couldn't remove dup'd inode.");
-+  
-+  ext3cow_journal_stop(handle);
-+  
-+  return 0;
-+}
-+
-+/*
-+ * directories can handle most operations...
-+ */
-+struct inode_operations ext3cow_dir_inode_operations = {
-+	.create		= ext3cow_create,
-+	.lookup		= ext3cow_lookup,
-+	.link		= ext3cow_link,
-+	.unlink		= ext3cow_unlink,
-+	.symlink	= ext3cow_symlink,
-+	.mkdir		= ext3cow_mkdir,
-+	.rmdir		= ext3cow_rmdir,
-+	.mknod		= ext3cow_mknod,
-+	.rename		= ext3cow_rename,
-+	.setattr	= ext3cow_setattr,
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+	.setxattr	= generic_setxattr,
-+	.getxattr	= generic_getxattr,
-+	.listxattr	= ext3cow_listxattr,
-+	.removexattr	= generic_removexattr,
-+#endif
-+	.permission	= ext3cow_permission,
-+};
-+
-+struct inode_operations ext3cow_special_inode_operations = {
-+	.setattr	= ext3cow_setattr,
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+	.setxattr	= generic_setxattr,
-+	.getxattr	= generic_getxattr,
-+	.listxattr	= ext3cow_listxattr,
-+	.removexattr	= generic_removexattr,
-+#endif
-+	.permission	= ext3cow_permission,
-+};
-diff -Naur linux-2.6.21.7/fs/ext3cow/namei.h linux-2.6.21.7_ext3cowPatched/fs/ext3cow/namei.h
---- linux-2.6.21.7/fs/ext3cow/namei.h	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/namei.h	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,8 @@
-+/*  linux/fs/ext3cow/namei.h
-+ *
-+ * Copyright (C) 2005 Simtec Electronics
-+ *	Ben Dooks <ben@simtec.co.uk>
-+ *
-+*/
-+
-+extern struct dentry *ext3cow_get_parent(struct dentry *child);
-diff -Naur linux-2.6.21.7/fs/ext3cow/resize.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/resize.c
---- linux-2.6.21.7/fs/ext3cow/resize.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/resize.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,1042 @@
-+/*
-+ *  linux/fs/ext3cow/resize.c
-+ *
-+ * Support for resizing an ext3cow filesystem while it is mounted.
-+ *
-+ * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com>
-+ *
-+ * This could probably be made into a module, because it is not often in use.
-+ */
-+
-+
-+#define EXT3COWFS_DEBUG
-+
-+#include <linux/sched.h>
-+#include <linux/smp_lock.h>
-+#include <linux/ext3cow_jbd.h>
-+
-+#include <linux/errno.h>
-+#include <linux/slab.h>
-+
-+
-+#define outside(b, first, last)	((b) < (first) || (b) >= (last))
-+#define inside(b, first, last)	((b) >= (first) && (b) < (last))
-+
-+static int verify_group_input(struct super_block *sb,
-+			      struct ext3cow_new_group_data *input)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	struct ext3cow_super_block *es = sbi->s_es;
-+	ext3cow_fsblk_t start = le32_to_cpu(es->s_blocks_count);
-+	ext3cow_fsblk_t end = start + input->blocks_count;
-+	unsigned group = input->group;
-+	ext3cow_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
-+	unsigned overhead = ext3cow_bg_has_super(sb, group) ?
-+		(1 + ext3cow_bg_num_gdb(sb, group) +
-+		 le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
-+	ext3cow_fsblk_t metaend = start + overhead;
-+	struct buffer_head *bh = NULL;
-+	ext3cow_grpblk_t free_blocks_count;
-+	int err = -EINVAL;
-+
-+	input->free_blocks_count = free_blocks_count =
-+		input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
-+
-+	if (test_opt(sb, DEBUG))
-+		printk(KERN_DEBUG "EXT3COW-fs: adding %s group %u: %u blocks "
-+		       "(%d free, %u reserved)\n",
-+		       ext3cow_bg_has_super(sb, input->group) ? "normal" :
-+		       "no-super", input->group, input->blocks_count,
-+		       free_blocks_count, input->reserved_blocks);
-+
-+	if (group != sbi->s_groups_count)
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Cannot add at group %u (only %lu groups)",
-+			     input->group, sbi->s_groups_count);
-+	else if ((start - le32_to_cpu(es->s_first_data_block)) %
-+		 EXT3COW_BLOCKS_PER_GROUP(sb))
-+		ext3cow_warning(sb, __FUNCTION__, "Last group not full");
-+	else if (input->reserved_blocks > input->blocks_count / 5)
-+		ext3cow_warning(sb, __FUNCTION__, "Reserved blocks too high (%u)",
-+			     input->reserved_blocks);
-+	else if (free_blocks_count < 0)
-+		ext3cow_warning(sb, __FUNCTION__, "Bad blocks count %u",
-+			     input->blocks_count);
-+	else if (!(bh = sb_bread(sb, end - 1)))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Cannot read last block ("E3FSBLK")",
-+			     end - 1);
-+	else if (outside(input->block_bitmap, start, end))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Block bitmap not in group (block %u)",
-+			     input->block_bitmap);
-+	else if (outside(input->inode_bitmap, start, end))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Inode bitmap not in group (block %u)",
-+			     input->inode_bitmap);
-+	else if (outside(input->inode_table, start, end) ||
-+	         outside(itend - 1, start, end))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Inode table not in group (blocks %u-"E3FSBLK")",
-+			     input->inode_table, itend - 1);
-+	else if (input->inode_bitmap == input->block_bitmap)
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Block bitmap same as inode bitmap (%u)",
-+			     input->block_bitmap);
-+	else if (inside(input->block_bitmap, input->inode_table, itend))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Block bitmap (%u) in inode table (%u-"E3FSBLK")",
-+			     input->block_bitmap, input->inode_table, itend-1);
-+	else if (inside(input->inode_bitmap, input->inode_table, itend))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Inode bitmap (%u) in inode table (%u-"E3FSBLK")",
-+			     input->inode_bitmap, input->inode_table, itend-1);
-+	else if (inside(input->block_bitmap, start, metaend))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Block bitmap (%u) in GDT table"
-+			     " ("E3FSBLK"-"E3FSBLK")",
-+			     input->block_bitmap, start, metaend - 1);
-+	else if (inside(input->inode_bitmap, start, metaend))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Inode bitmap (%u) in GDT table"
-+			     " ("E3FSBLK"-"E3FSBLK")",
-+			     input->inode_bitmap, start, metaend - 1);
-+	else if (inside(input->inode_table, start, metaend) ||
-+	         inside(itend - 1, start, metaend))
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Inode table (%u-"E3FSBLK") overlaps"
-+			     "GDT table ("E3FSBLK"-"E3FSBLK")",
-+			     input->inode_table, itend - 1, start, metaend - 1);
-+	else
-+		err = 0;
-+	brelse(bh);
-+
-+	return err;
-+}
-+
-+static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
-+				  ext3cow_fsblk_t blk)
-+{
-+	struct buffer_head *bh;
-+	int err;
-+
-+	bh = sb_getblk(sb, blk);
-+	if (!bh)
-+		return ERR_PTR(-EIO);
-+	if ((err = ext3cow_journal_get_write_access(handle, bh))) {
-+		brelse(bh);
-+		bh = ERR_PTR(err);
-+	} else {
-+		lock_buffer(bh);
-+		memset(bh->b_data, 0, sb->s_blocksize);
-+		set_buffer_uptodate(bh);
-+		unlock_buffer(bh);
-+	}
-+
-+	return bh;
-+}
-+
-+/*
-+ * To avoid calling the atomic setbit hundreds or thousands of times, we only
-+ * need to use it within a single byte (to ensure we get endianness right).
-+ * We can use memset for the rest of the bitmap as there are no other users.
-+ */
-+static void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
-+{
-+	int i;
-+
-+	if (start_bit >= end_bit)
-+		return;
-+
-+	ext3cow_debug("mark end bits +%d through +%d used\n", start_bit, end_bit);
-+	for (i = start_bit; i < ((start_bit + 7) & ~7UL); i++)
-+		ext3cow_set_bit(i, bitmap);
-+	if (i < end_bit)
-+		memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
-+}
-+
-+/*
-+ * Set up the block and inode bitmaps, and the inode table for the new group.
-+ * This doesn't need to be part of the main transaction, since we are only
-+ * changing blocks outside the actual filesystem.  We still do journaling to
-+ * ensure the recovery is correct in case of a failure just after resize.
-+ * If any part of this fails, we simply abort the resize.
-+ */
-+static int setup_new_group_blocks(struct super_block *sb,
-+				  struct ext3cow_new_group_data *input)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	ext3cow_fsblk_t start = ext3cow_group_first_block_no(sb, input->group);
-+	int reserved_gdb = ext3cow_bg_has_super(sb, input->group) ?
-+		le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0;
-+	unsigned long gdblocks = ext3cow_bg_num_gdb(sb, input->group);
-+	struct buffer_head *bh;
-+	handle_t *handle;
-+	ext3cow_fsblk_t block;
-+	ext3cow_grpblk_t bit;
-+	int i;
-+	int err = 0, err2;
-+
-+	handle = ext3cow_journal_start_sb(sb, reserved_gdb + gdblocks +
-+				       2 + sbi->s_itb_per_group);
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+
-+	lock_super(sb);
-+	if (input->group != sbi->s_groups_count) {
-+		err = -EBUSY;
-+		goto exit_journal;
-+	}
-+
-+	if (IS_ERR(bh = bclean(handle, sb, input->block_bitmap))) {
-+		err = PTR_ERR(bh);
-+		goto exit_journal;
-+	}
-+
-+	if (ext3cow_bg_has_super(sb, input->group)) {
-+		ext3cow_debug("mark backup superblock %#04lx (+0)\n", start);
-+		ext3cow_set_bit(0, bh->b_data);
-+	}
-+
-+	/* Copy all of the GDT blocks into the backup in this group */
-+	for (i = 0, bit = 1, block = start + 1;
-+	     i < gdblocks; i++, block++, bit++) {
-+		struct buffer_head *gdb;
-+
-+		ext3cow_debug("update backup group %#04lx (+%d)\n", block, bit);
-+
-+		gdb = sb_getblk(sb, block);
-+		if (!gdb) {
-+			err = -EIO;
-+			goto exit_bh;
-+		}
-+		if ((err = ext3cow_journal_get_write_access(handle, gdb))) {
-+			brelse(gdb);
-+			goto exit_bh;
-+		}
-+		lock_buffer(bh);
-+		memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, bh->b_size);
-+		set_buffer_uptodate(gdb);
-+		unlock_buffer(bh);
-+		ext3cow_journal_dirty_metadata(handle, gdb);
-+		ext3cow_set_bit(bit, bh->b_data);
-+		brelse(gdb);
-+	}
-+
-+	/* Zero out all of the reserved backup group descriptor table blocks */
-+	for (i = 0, bit = gdblocks + 1, block = start + bit;
-+	     i < reserved_gdb; i++, block++, bit++) {
-+		struct buffer_head *gdb;
-+
-+		ext3cow_debug("clear reserved block %#04lx (+%d)\n", block, bit);
-+
-+		if (IS_ERR(gdb = bclean(handle, sb, block))) {
-+			err = PTR_ERR(bh);
-+			goto exit_bh;
-+		}
-+		ext3cow_journal_dirty_metadata(handle, gdb);
-+		ext3cow_set_bit(bit, bh->b_data);
-+		brelse(gdb);
-+	}
-+	ext3cow_debug("mark block bitmap %#04x (+%ld)\n", input->block_bitmap,
-+		   input->block_bitmap - start);
-+	ext3cow_set_bit(input->block_bitmap - start, bh->b_data);
-+	ext3cow_debug("mark inode bitmap %#04x (+%ld)\n", input->inode_bitmap,
-+		   input->inode_bitmap - start);
-+	ext3cow_set_bit(input->inode_bitmap - start, bh->b_data);
-+
-+	/* Zero out all of the inode table blocks */
-+	for (i = 0, block = input->inode_table, bit = block - start;
-+	     i < sbi->s_itb_per_group; i++, bit++, block++) {
-+		struct buffer_head *it;
-+
-+		ext3cow_debug("clear inode block %#04lx (+%d)\n", block, bit);
-+		if (IS_ERR(it = bclean(handle, sb, block))) {
-+			err = PTR_ERR(it);
-+			goto exit_bh;
-+		}
-+		ext3cow_journal_dirty_metadata(handle, it);
-+		brelse(it);
-+		ext3cow_set_bit(bit, bh->b_data);
-+	}
-+	mark_bitmap_end(input->blocks_count, EXT3COW_BLOCKS_PER_GROUP(sb),
-+			bh->b_data);
-+	ext3cow_journal_dirty_metadata(handle, bh);
-+	brelse(bh);
-+
-+	/* Mark unused entries in inode bitmap used */
-+	ext3cow_debug("clear inode bitmap %#04x (+%ld)\n",
-+		   input->inode_bitmap, input->inode_bitmap - start);
-+	if (IS_ERR(bh = bclean(handle, sb, input->inode_bitmap))) {
-+		err = PTR_ERR(bh);
-+		goto exit_journal;
-+	}
-+
-+	mark_bitmap_end(EXT3COW_INODES_PER_GROUP(sb), EXT3COW_BLOCKS_PER_GROUP(sb),
-+			bh->b_data);
-+	ext3cow_journal_dirty_metadata(handle, bh);
-+exit_bh:
-+	brelse(bh);
-+
-+exit_journal:
-+	unlock_super(sb);
-+	if ((err2 = ext3cow_journal_stop(handle)) && !err)
-+		err = err2;
-+
-+	return err;
-+}
-+
-+/*
-+ * Iterate through the groups which hold BACKUP superblock/GDT copies in an
-+ * ext3cow filesystem.  The counters should be initialized to 1, 5, and 7 before
-+ * calling this for the first time.  In a sparse filesystem it will be the
-+ * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
-+ * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
-+ */
-+static unsigned ext3cow_list_backups(struct super_block *sb, unsigned *three,
-+				  unsigned *five, unsigned *seven)
-+{
-+	unsigned *min = three;
-+	int mult = 3;
-+	unsigned ret;
-+
-+	if (!EXT3COW_HAS_RO_COMPAT_FEATURE(sb,
-+					EXT3COW_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
-+		ret = *min;
-+		*min += 1;
-+		return ret;
-+	}
-+
-+	if (*five < *min) {
-+		min = five;
-+		mult = 5;
-+	}
-+	if (*seven < *min) {
-+		min = seven;
-+		mult = 7;
-+	}
-+
-+	ret = *min;
-+	*min *= mult;
-+
-+	return ret;
-+}
-+
-+/*
-+ * Check that all of the backup GDT blocks are held in the primary GDT block.
-+ * It is assumed that they are stored in group order.  Returns the number of
-+ * groups in current filesystem that have BACKUPS, or -ve error code.
-+ */
-+static int verify_reserved_gdb(struct super_block *sb,
-+			       struct buffer_head *primary)
-+{
-+	const ext3cow_fsblk_t blk = primary->b_blocknr;
-+	const unsigned long end = EXT3COW_SB(sb)->s_groups_count;
-+	unsigned three = 1;
-+	unsigned five = 5;
-+	unsigned seven = 7;
-+	unsigned grp;
-+	__le32 *p = (__le32 *)primary->b_data;
-+	int gdbackups = 0;
-+
-+	while ((grp = ext3cow_list_backups(sb, &three, &five, &seven)) < end) {
-+		if (le32_to_cpu(*p++) != grp * EXT3COW_BLOCKS_PER_GROUP(sb) + blk){
-+			ext3cow_warning(sb, __FUNCTION__,
-+				     "reserved GDT "E3FSBLK
-+				     " missing grp %d ("E3FSBLK")",
-+				     blk, grp,
-+				     grp * EXT3COW_BLOCKS_PER_GROUP(sb) + blk);
-+			return -EINVAL;
-+		}
-+		if (++gdbackups > EXT3COW_ADDR_PER_BLOCK(sb))
-+			return -EFBIG;
-+	}
-+
-+	return gdbackups;
-+}
-+
-+/*
-+ * Called when we need to bring a reserved group descriptor table block into
-+ * use from the resize inode.  The primary copy of the new GDT block currently
-+ * is an indirect block (under the double indirect block in the resize inode).
-+ * The new backup GDT blocks will be stored as leaf blocks in this indirect
-+ * block, in group order.  Even though we know all the block numbers we need,
-+ * we check to ensure that the resize inode has actually reserved these blocks.
-+ *
-+ * Don't need to update the block bitmaps because the blocks are still in use.
-+ *
-+ * We get all of the error cases out of the way, so that we are sure to not
-+ * fail once we start modifying the data on disk, because JBD has no rollback.
-+ */
-+static int add_new_gdb(handle_t *handle, struct inode *inode,
-+		       struct ext3cow_new_group_data *input,
-+		       struct buffer_head **primary)
-+{
-+	struct super_block *sb = inode->i_sb;
-+	struct ext3cow_super_block *es = EXT3COW_SB(sb)->s_es;
-+	unsigned long gdb_num = input->group / EXT3COW_DESC_PER_BLOCK(sb);
-+	ext3cow_fsblk_t gdblock = EXT3COW_SB(sb)->s_sbh->b_blocknr + 1 + gdb_num;
-+	struct buffer_head **o_group_desc, **n_group_desc;
-+	struct buffer_head *dind;
-+	int gdbackups;
-+	struct ext3cow_iloc iloc;
-+	__le32 *data;
-+	int err;
-+
-+	if (test_opt(sb, DEBUG))
-+		printk(KERN_DEBUG
-+		       "EXT3COW-fs: ext3cow_add_new_gdb: adding group block %lu\n",
-+		       gdb_num);
-+
-+	/*
-+	 * If we are not using the primary superblock/GDT copy don't resize,
-+	 * because the user tools have no way of handling this.  Probably a
-+	 * bad time to do it anyways.
-+	 */
-+	if (EXT3COW_SB(sb)->s_sbh->b_blocknr !=
-+	    le32_to_cpu(EXT3COW_SB(sb)->s_es->s_first_data_block)) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			"won't resize using backup superblock at %llu",
-+			(unsigned long long)EXT3COW_SB(sb)->s_sbh->b_blocknr);
-+		return -EPERM;
-+	}
-+
-+	*primary = sb_bread(sb, gdblock);
-+	if (!*primary)
-+		return -EIO;
-+
-+	if ((gdbackups = verify_reserved_gdb(sb, *primary)) < 0) {
-+		err = gdbackups;
-+		goto exit_bh;
-+	}
-+
-+	data = EXT3COW_I(inode)->i_data + EXT3COW_DIND_BLOCK;
-+	dind = sb_bread(sb, le32_to_cpu(*data));
-+	if (!dind) {
-+		err = -EIO;
-+		goto exit_bh;
-+	}
-+
-+	data = (__le32 *)dind->b_data;
-+	if (le32_to_cpu(data[gdb_num % EXT3COW_ADDR_PER_BLOCK(sb)]) != gdblock) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "new group %u GDT block "E3FSBLK" not reserved",
-+			     input->group, gdblock);
-+		err = -EINVAL;
-+		goto exit_dind;
-+	}
-+
-+	if ((err = ext3cow_journal_get_write_access(handle, EXT3COW_SB(sb)->s_sbh)))
-+		goto exit_dind;
-+
-+	if ((err = ext3cow_journal_get_write_access(handle, *primary)))
-+		goto exit_sbh;
-+
-+	if ((err = ext3cow_journal_get_write_access(handle, dind)))
-+		goto exit_primary;
-+
-+	/* ext3cow_reserve_inode_write() gets a reference on the iloc */
-+	if ((err = ext3cow_reserve_inode_write(handle, inode, &iloc)))
-+		goto exit_dindj;
-+
-+	n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *),
-+			GFP_KERNEL);
-+	if (!n_group_desc) {
-+		err = -ENOMEM;
-+		ext3cow_warning (sb, __FUNCTION__,
-+			      "not enough memory for %lu groups", gdb_num + 1);
-+		goto exit_inode;
-+	}
-+
-+	/*
-+	 * Finally, we have all of the possible failures behind us...
-+	 *
-+	 * Remove new GDT block from inode double-indirect block and clear out
-+	 * the new GDT block for use (which also "frees" the backup GDT blocks
-+	 * from the reserved inode).  We don't need to change the bitmaps for
-+	 * these blocks, because they are marked as in-use from being in the
-+	 * reserved inode, and will become GDT blocks (primary and backup).
-+	 */
-+	data[gdb_num % EXT3COW_ADDR_PER_BLOCK(sb)] = 0;
-+	ext3cow_journal_dirty_metadata(handle, dind);
-+	brelse(dind);
-+	inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
-+	ext3cow_mark_iloc_dirty(handle, inode, &iloc);
-+	memset((*primary)->b_data, 0, sb->s_blocksize);
-+	ext3cow_journal_dirty_metadata(handle, *primary);
-+
-+	o_group_desc = EXT3COW_SB(sb)->s_group_desc;
-+	memcpy(n_group_desc, o_group_desc,
-+	       EXT3COW_SB(sb)->s_gdb_count * sizeof(struct buffer_head *));
-+	n_group_desc[gdb_num] = *primary;
-+	EXT3COW_SB(sb)->s_group_desc = n_group_desc;
-+	EXT3COW_SB(sb)->s_gdb_count++;
-+	kfree(o_group_desc);
-+
-+	es->s_reserved_gdt_blocks =
-+		cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1);
-+	ext3cow_journal_dirty_metadata(handle, EXT3COW_SB(sb)->s_sbh);
-+
-+	return 0;
-+
-+exit_inode:
-+	//ext3cow_journal_release_buffer(handle, iloc.bh);
-+	brelse(iloc.bh);
-+exit_dindj:
-+	//ext3cow_journal_release_buffer(handle, dind);
-+exit_primary:
-+	//ext3cow_journal_release_buffer(handle, *primary);
-+exit_sbh:
-+	//ext3cow_journal_release_buffer(handle, *primary);
-+exit_dind:
-+	brelse(dind);
-+exit_bh:
-+	brelse(*primary);
-+
-+	ext3cow_debug("leaving with error %d\n", err);
-+	return err;
-+}
-+
-+/*
-+ * Called when we are adding a new group which has a backup copy of each of
-+ * the GDT blocks (i.e. sparse group) and there are reserved GDT blocks.
-+ * We need to add these reserved backup GDT blocks to the resize inode, so
-+ * that they are kept for future resizing and not allocated to files.
-+ *
-+ * Each reserved backup GDT block will go into a different indirect block.
-+ * The indirect blocks are actually the primary reserved GDT blocks,
-+ * so we know in advance what their block numbers are.  We only get the
-+ * double-indirect block to verify it is pointing to the primary reserved
-+ * GDT blocks so we don't overwrite a data block by accident.  The reserved
-+ * backup GDT blocks are stored in their reserved primary GDT block.
-+ */
-+static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
-+			      struct ext3cow_new_group_data *input)
-+{
-+	struct super_block *sb = inode->i_sb;
-+	int reserved_gdb =le16_to_cpu(EXT3COW_SB(sb)->s_es->s_reserved_gdt_blocks);
-+	struct buffer_head **primary;
-+	struct buffer_head *dind;
-+	struct ext3cow_iloc iloc;
-+	ext3cow_fsblk_t blk;
-+	__le32 *data, *end;
-+	int gdbackups = 0;
-+	int res, i;
-+	int err;
-+
-+	primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_KERNEL);
-+	if (!primary)
-+		return -ENOMEM;
-+
-+	data = EXT3COW_I(inode)->i_data + EXT3COW_DIND_BLOCK;
-+	dind = sb_bread(sb, le32_to_cpu(*data));
-+	if (!dind) {
-+		err = -EIO;
-+		goto exit_free;
-+	}
-+
-+	blk = EXT3COW_SB(sb)->s_sbh->b_blocknr + 1 + EXT3COW_SB(sb)->s_gdb_count;
-+	data = (__le32 *)dind->b_data + EXT3COW_SB(sb)->s_gdb_count;
-+	end = (__le32 *)dind->b_data + EXT3COW_ADDR_PER_BLOCK(sb);
-+
-+	/* Get each reserved primary GDT block and verify it holds backups */
-+	for (res = 0; res < reserved_gdb; res++, blk++) {
-+		if (le32_to_cpu(*data) != blk) {
-+			ext3cow_warning(sb, __FUNCTION__,
-+				     "reserved block "E3FSBLK
-+				     " not at offset %ld",
-+				     blk,
-+				     (long)(data - (__le32 *)dind->b_data));
-+			err = -EINVAL;
-+			goto exit_bh;
-+		}
-+		primary[res] = sb_bread(sb, blk);
-+		if (!primary[res]) {
-+			err = -EIO;
-+			goto exit_bh;
-+		}
-+		if ((gdbackups = verify_reserved_gdb(sb, primary[res])) < 0) {
-+			brelse(primary[res]);
-+			err = gdbackups;
-+			goto exit_bh;
-+		}
-+		if (++data >= end)
-+			data = (__le32 *)dind->b_data;
-+	}
-+
-+	for (i = 0; i < reserved_gdb; i++) {
-+		if ((err = ext3cow_journal_get_write_access(handle, primary[i]))) {
-+			/*
-+			int j;
-+			for (j = 0; j < i; j++)
-+				ext3cow_journal_release_buffer(handle, primary[j]);
-+			 */
-+			goto exit_bh;
-+		}
-+	}
-+
-+	if ((err = ext3cow_reserve_inode_write(handle, inode, &iloc)))
-+		goto exit_bh;
-+
-+	/*
-+	 * Finally we can add each of the reserved backup GDT blocks from
-+	 * the new group to its reserved primary GDT block.
-+	 */
-+	blk = input->group * EXT3COW_BLOCKS_PER_GROUP(sb);
-+	for (i = 0; i < reserved_gdb; i++) {
-+		int err2;
-+		data = (__le32 *)primary[i]->b_data;
-+		/* printk("reserving backup %lu[%u] = %lu\n",
-+		       primary[i]->b_blocknr, gdbackups,
-+		       blk + primary[i]->b_blocknr); */
-+		data[gdbackups] = cpu_to_le32(blk + primary[i]->b_blocknr);
-+		err2 = ext3cow_journal_dirty_metadata(handle, primary[i]);
-+		if (!err)
-+			err = err2;
-+	}
-+	inode->i_blocks += reserved_gdb * sb->s_blocksize >> 9;
-+	ext3cow_mark_iloc_dirty(handle, inode, &iloc);
-+
-+exit_bh:
-+	while (--res >= 0)
-+		brelse(primary[res]);
-+	brelse(dind);
-+
-+exit_free:
-+	kfree(primary);
-+
-+	return err;
-+}
-+
-+/*
-+ * Update the backup copies of the ext3cow metadata.  These don't need to be part
-+ * of the main resize transaction, because e2fsck will re-write them if there
-+ * is a problem (basically only OOM will cause a problem).  However, we
-+ * _should_ update the backups if possible, in case the primary gets trashed
-+ * for some reason and we need to run e2fsck from a backup superblock.  The
-+ * important part is that the new block and inode counts are in the backup
-+ * superblocks, and the location of the new group metadata in the GDT backups.
-+ *
-+ * We do not need lock_super() for this, because these blocks are not
-+ * otherwise touched by the filesystem code when it is mounted.  We don't
-+ * need to worry about last changing from sbi->s_groups_count, because the
-+ * worst that can happen is that we do not copy the full number of backups
-+ * at this time.  The resize which changed s_groups_count will backup again.
-+ */
-+static void update_backups(struct super_block *sb,
-+			   int blk_off, char *data, int size)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	const unsigned long last = sbi->s_groups_count;
-+	const int bpg = EXT3COW_BLOCKS_PER_GROUP(sb);
-+	unsigned three = 1;
-+	unsigned five = 5;
-+	unsigned seven = 7;
-+	unsigned group;
-+	int rest = sb->s_blocksize - size;
-+	handle_t *handle;
-+	int err = 0, err2;
-+
-+	handle = ext3cow_journal_start_sb(sb, EXT3COW_MAX_TRANS_DATA);
-+	if (IS_ERR(handle)) {
-+		group = 1;
-+		err = PTR_ERR(handle);
-+		goto exit_err;
-+	}
-+
-+	while ((group = ext3cow_list_backups(sb, &three, &five, &seven)) < last) {
-+		struct buffer_head *bh;
-+
-+		/* Out of journal space, and can't get more - abort - so sad */
-+		if (handle->h_buffer_credits == 0 &&
-+		    ext3cow_journal_extend(handle, EXT3COW_MAX_TRANS_DATA) &&
-+		    (err = ext3cow_journal_restart(handle, EXT3COW_MAX_TRANS_DATA)))
-+			break;
-+
-+		bh = sb_getblk(sb, group * bpg + blk_off);
-+		if (!bh) {
-+			err = -EIO;
-+			break;
-+		}
-+		ext3cow_debug("update metadata backup %#04lx\n",
-+			  (unsigned long)bh->b_blocknr);
-+		if ((err = ext3cow_journal_get_write_access(handle, bh)))
-+			break;
-+		lock_buffer(bh);
-+		memcpy(bh->b_data, data, size);
-+		if (rest)
-+			memset(bh->b_data + size, 0, rest);
-+		set_buffer_uptodate(bh);
-+		unlock_buffer(bh);
-+		ext3cow_journal_dirty_metadata(handle, bh);
-+		brelse(bh);
-+	}
-+	if ((err2 = ext3cow_journal_stop(handle)) && !err)
-+		err = err2;
-+
-+	/*
-+	 * Ugh! Need to have e2fsck write the backup copies.  It is too
-+	 * late to revert the resize, we shouldn't fail just because of
-+	 * the backup copies (they are only needed in case of corruption).
-+	 *
-+	 * However, if we got here we have a journal problem too, so we
-+	 * can't really start a transaction to mark the superblock.
-+	 * Chicken out and just set the flag on the hope it will be written
-+	 * to disk, and if not - we will simply wait until next fsck.
-+	 */
-+exit_err:
-+	if (err) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "can't update backup for group %d (err %d), "
-+			     "forcing fsck on next reboot", group, err);
-+		sbi->s_mount_state &= ~EXT3COW_VALID_FS;
-+		sbi->s_es->s_state &= cpu_to_le16(~EXT3COW_VALID_FS);
-+		mark_buffer_dirty(sbi->s_sbh);
-+	}
-+}
-+
-+/* Add group descriptor data to an existing or new group descriptor block.
-+ * Ensure we handle all possible error conditions _before_ we start modifying
-+ * the filesystem, because we cannot abort the transaction and not have it
-+ * write the data to disk.
-+ *
-+ * If we are on a GDT block boundary, we need to get the reserved GDT block.
-+ * Otherwise, we may need to add backup GDT blocks for a sparse group.
-+ *
-+ * We only need to hold the superblock lock while we are actually adding
-+ * in the new group's counts to the superblock.  Prior to that we have
-+ * not really "added" the group at all.  We re-check that we are still
-+ * adding in the last group in case things have changed since verifying.
-+ */
-+int ext3cow_group_add(struct super_block *sb, struct ext3cow_new_group_data *input)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	struct ext3cow_super_block *es = sbi->s_es;
-+	int reserved_gdb = ext3cow_bg_has_super(sb, input->group) ?
-+		le16_to_cpu(es->s_reserved_gdt_blocks) : 0;
-+	struct buffer_head *primary = NULL;
-+	struct ext3cow_group_desc *gdp;
-+	struct inode *inode = NULL;
-+	handle_t *handle;
-+	int gdb_off, gdb_num;
-+	int err, err2;
-+
-+	gdb_num = input->group / EXT3COW_DESC_PER_BLOCK(sb);
-+	gdb_off = input->group % EXT3COW_DESC_PER_BLOCK(sb);
-+
-+	if (gdb_off == 0 && !EXT3COW_HAS_RO_COMPAT_FEATURE(sb,
-+					EXT3COW_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "Can't resize non-sparse filesystem further");
-+		return -EPERM;
-+	}
-+
-+	if (le32_to_cpu(es->s_blocks_count) + input->blocks_count <
-+	    le32_to_cpu(es->s_blocks_count)) {
-+		ext3cow_warning(sb, __FUNCTION__, "blocks_count overflow\n");
-+		return -EINVAL;
-+	}
-+
-+	if (le32_to_cpu(es->s_inodes_count) + EXT3COW_INODES_PER_GROUP(sb) <
-+	    le32_to_cpu(es->s_inodes_count)) {
-+		ext3cow_warning(sb, __FUNCTION__, "inodes_count overflow\n");
-+		return -EINVAL;
-+	}
-+
-+	if (reserved_gdb || gdb_off == 0) {
-+		if (!EXT3COW_HAS_COMPAT_FEATURE(sb,
-+					     EXT3COW_FEATURE_COMPAT_RESIZE_INODE)){
-+			ext3cow_warning(sb, __FUNCTION__,
-+				     "No reserved GDT blocks, can't resize");
-+			return -EPERM;
-+		}
-+		inode = iget(sb, EXT3COW_RESIZE_INO);
-+		if (!inode || is_bad_inode(inode)) {
-+			ext3cow_warning(sb, __FUNCTION__,
-+				     "Error opening resize inode");
-+			iput(inode);
-+			return -ENOENT;
-+		}
-+	}
-+
-+	if ((err = verify_group_input(sb, input)))
-+		goto exit_put;
-+
-+	if ((err = setup_new_group_blocks(sb, input)))
-+		goto exit_put;
-+
-+	/*
-+	 * We will always be modifying at least the superblock and a GDT
-+	 * block.  If we are adding a group past the last current GDT block,
-+	 * we will also modify the inode and the dindirect block.  If we
-+	 * are adding a group with superblock/GDT backups  we will also
-+	 * modify each of the reserved GDT dindirect blocks.
-+	 */
-+	handle = ext3cow_journal_start_sb(sb,
-+				       ext3cow_bg_has_super(sb, input->group) ?
-+				       3 + reserved_gdb : 4);
-+	if (IS_ERR(handle)) {
-+		err = PTR_ERR(handle);
-+		goto exit_put;
-+	}
-+
-+	lock_super(sb);
-+	if (input->group != sbi->s_groups_count) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "multiple resizers run on filesystem!");
-+		err = -EBUSY;
-+		goto exit_journal;
-+	}
-+
-+	if ((err = ext3cow_journal_get_write_access(handle, sbi->s_sbh)))
-+		goto exit_journal;
-+
-+	/*
-+	 * We will only either add reserved group blocks to a backup group
-+	 * or remove reserved blocks for the first group in a new group block.
-+	 * Doing both would be mean more complex code, and sane people don't
-+	 * use non-sparse filesystems anymore.  This is already checked above.
-+	 */
-+	if (gdb_off) {
-+		primary = sbi->s_group_desc[gdb_num];
-+		if ((err = ext3cow_journal_get_write_access(handle, primary)))
-+			goto exit_journal;
-+
-+		if (reserved_gdb && ext3cow_bg_num_gdb(sb, input->group) &&
-+		    (err = reserve_backup_gdb(handle, inode, input)))
-+			goto exit_journal;
-+	} else if ((err = add_new_gdb(handle, inode, input, &primary)))
-+		goto exit_journal;
-+
-+	/*
-+	 * OK, now we've set up the new group.  Time to make it active.
-+	 *
-+	 * Current kernels don't lock all allocations via lock_super(),
-+	 * so we have to be safe wrt. concurrent accesses the group
-+	 * data.  So we need to be careful to set all of the relevant
-+	 * group descriptor data etc. *before* we enable the group.
-+	 *
-+	 * The key field here is sbi->s_groups_count: as long as
-+	 * that retains its old value, nobody is going to access the new
-+	 * group.
-+	 *
-+	 * So first we update all the descriptor metadata for the new
-+	 * group; then we update the total disk blocks count; then we
-+	 * update the groups count to enable the group; then finally we
-+	 * update the free space counts so that the system can start
-+	 * using the new disk blocks.
-+	 */
-+
-+	/* Update group descriptor block for new group */
-+	gdp = (struct ext3cow_group_desc *)primary->b_data + gdb_off;
-+
-+	gdp->bg_block_bitmap = cpu_to_le32(input->block_bitmap);
-+	gdp->bg_inode_bitmap = cpu_to_le32(input->inode_bitmap);
-+	gdp->bg_inode_table = cpu_to_le32(input->inode_table);
-+	gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
-+	gdp->bg_free_inodes_count = cpu_to_le16(EXT3COW_INODES_PER_GROUP(sb));
-+
-+	/*
-+	 * Make the new blocks and inodes valid next.  We do this before
-+	 * increasing the group count so that once the group is enabled,
-+	 * all of its blocks and inodes are already valid.
-+	 *
-+	 * We always allocate group-by-group, then block-by-block or
-+	 * inode-by-inode within a group, so enabling these
-+	 * blocks/inodes before the group is live won't actually let us
-+	 * allocate the new space yet.
-+	 */
-+	es->s_blocks_count = cpu_to_le32(le32_to_cpu(es->s_blocks_count) +
-+		input->blocks_count);
-+	es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
-+		EXT3COW_INODES_PER_GROUP(sb));
-+
-+	/*
-+	 * We need to protect s_groups_count against other CPUs seeing
-+	 * inconsistent state in the superblock.
-+	 *
-+	 * The precise rules we use are:
-+	 *
-+	 * * Writers of s_groups_count *must* hold lock_super
-+	 * AND
-+	 * * Writers must perform a smp_wmb() after updating all dependent
-+	 *   data and before modifying the groups count
-+	 *
-+	 * * Readers must hold lock_super() over the access
-+	 * OR
-+	 * * Readers must perform an smp_rmb() after reading the groups count
-+	 *   and before reading any dependent data.
-+	 *
-+	 * NB. These rules can be relaxed when checking the group count
-+	 * while freeing data, as we can only allocate from a block
-+	 * group after serialising against the group count, and we can
-+	 * only then free after serialising in turn against that
-+	 * allocation.
-+	 */
-+	smp_wmb();
-+
-+	/* Update the global fs size fields */
-+	sbi->s_groups_count++;
-+
-+	ext3cow_journal_dirty_metadata(handle, primary);
-+
-+	/* Update the reserved block counts only once the new group is
-+	 * active. */
-+	es->s_r_blocks_count = cpu_to_le32(le32_to_cpu(es->s_r_blocks_count) +
-+		input->reserved_blocks);
-+
-+	/* Update the free space counts */
-+	percpu_counter_mod(&sbi->s_freeblocks_counter,
-+			   input->free_blocks_count);
-+	percpu_counter_mod(&sbi->s_freeinodes_counter,
-+			   EXT3COW_INODES_PER_GROUP(sb));
-+
-+	ext3cow_journal_dirty_metadata(handle, sbi->s_sbh);
-+	sb->s_dirt = 1;
-+
-+exit_journal:
-+	unlock_super(sb);
-+	if ((err2 = ext3cow_journal_stop(handle)) && !err)
-+		err = err2;
-+	if (!err) {
-+		update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
-+			       sizeof(struct ext3cow_super_block));
-+		update_backups(sb, primary->b_blocknr, primary->b_data,
-+			       primary->b_size);
-+	}
-+exit_put:
-+	iput(inode);
-+	return err;
-+} /* ext3cow_group_add */
-+
-+/* Extend the filesystem to the new number of blocks specified.  This entry
-+ * point is only used to extend the current filesystem to the end of the last
-+ * existing group.  It can be accessed via ioctl, or by "remount,resize=<size>"
-+ * for emergencies (because it has no dependencies on reserved blocks).
-+ *
-+ * If we _really_ wanted, we could use default values to call ext3cow_group_add()
-+ * allow the "remount" trick to work for arbitrary resizing, assuming enough
-+ * GDT blocks are reserved to grow to the desired size.
-+ */
-+int ext3cow_group_extend(struct super_block *sb, struct ext3cow_super_block *es,
-+		      ext3cow_fsblk_t n_blocks_count)
-+{
-+	ext3cow_fsblk_t o_blocks_count;
-+	unsigned long o_groups_count;
-+	ext3cow_grpblk_t last;
-+	ext3cow_grpblk_t add;
-+	struct buffer_head * bh;
-+	handle_t *handle;
-+	int err;
-+	unsigned long freed_blocks;
-+
-+	/* We don't need to worry about locking wrt other resizers just
-+	 * yet: we're going to revalidate es->s_blocks_count after
-+	 * taking lock_super() below. */
-+	o_blocks_count = le32_to_cpu(es->s_blocks_count);
-+	o_groups_count = EXT3COW_SB(sb)->s_groups_count;
-+
-+	if (test_opt(sb, DEBUG))
-+		printk(KERN_DEBUG "EXT3COW-fs: extending last group from "E3FSBLK" uto "E3FSBLK" blocks\n",
-+		       o_blocks_count, n_blocks_count);
-+
-+	if (n_blocks_count == 0 || n_blocks_count == o_blocks_count)
-+		return 0;
-+
-+	if (n_blocks_count > (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
-+		printk(KERN_ERR "EXT3COW-fs: filesystem on %s:"
-+			" too large to resize to %lu blocks safely\n",
-+			sb->s_id, n_blocks_count);
-+		if (sizeof(sector_t) < 8)
-+			ext3cow_warning(sb, __FUNCTION__,
-+			"CONFIG_LBD not enabled\n");
-+		return -EINVAL;
-+	}
-+
-+	if (n_blocks_count < o_blocks_count) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "can't shrink FS - resize aborted");
-+		return -EBUSY;
-+	}
-+
-+	/* Handle the remaining blocks in the last group only. */
-+	last = (o_blocks_count - le32_to_cpu(es->s_first_data_block)) %
-+		EXT3COW_BLOCKS_PER_GROUP(sb);
-+
-+	if (last == 0) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "need to use ext2online to resize further");
-+		return -EPERM;
-+	}
-+
-+	add = EXT3COW_BLOCKS_PER_GROUP(sb) - last;
-+
-+	if (o_blocks_count + add < o_blocks_count) {
-+		ext3cow_warning(sb, __FUNCTION__, "blocks_count overflow");
-+		return -EINVAL;
-+	}
-+
-+	if (o_blocks_count + add > n_blocks_count)
-+		add = n_blocks_count - o_blocks_count;
-+
-+	if (o_blocks_count + add < n_blocks_count)
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "will only finish group ("E3FSBLK
-+			     " blocks, %u new)",
-+			     o_blocks_count + add, add);
-+
-+	/* See if the device is actually as big as what was requested */
-+	bh = sb_bread(sb, o_blocks_count + add -1);
-+	if (!bh) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "can't read last block, resize aborted");
-+		return -ENOSPC;
-+	}
-+	brelse(bh);
-+
-+	/* We will update the superblock, one block bitmap, and
-+	 * one group descriptor via ext3cow_free_blocks().
-+	 */
-+	handle = ext3cow_journal_start_sb(sb, 3);
-+	if (IS_ERR(handle)) {
-+		err = PTR_ERR(handle);
-+		ext3cow_warning(sb, __FUNCTION__, "error %d on journal start",err);
-+		goto exit_put;
-+	}
-+
-+	lock_super(sb);
-+	if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "multiple resizers run on filesystem!");
-+		unlock_super(sb);
-+		err = -EBUSY;
-+		goto exit_put;
-+	}
-+
-+	if ((err = ext3cow_journal_get_write_access(handle,
-+						 EXT3COW_SB(sb)->s_sbh))) {
-+		ext3cow_warning(sb, __FUNCTION__,
-+			     "error %d on journal write access", err);
-+		unlock_super(sb);
-+		ext3cow_journal_stop(handle);
-+		goto exit_put;
-+	}
-+	es->s_blocks_count = cpu_to_le32(o_blocks_count + add);
-+	ext3cow_journal_dirty_metadata(handle, EXT3COW_SB(sb)->s_sbh);
-+	sb->s_dirt = 1;
-+	unlock_super(sb);
-+	ext3cow_debug("freeing blocks %lu through "E3FSBLK"\n", o_blocks_count,
-+		   o_blocks_count + add);
-+	ext3cow_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks);
-+	ext3cow_debug("freed blocks "E3FSBLK" through "E3FSBLK"\n", o_blocks_count,
-+		   o_blocks_count + add);
-+	if ((err = ext3cow_journal_stop(handle)))
-+		goto exit_put;
-+	if (test_opt(sb, DEBUG))
-+		printk(KERN_DEBUG "EXT3COW-fs: extended group to %u blocks\n",
-+		       le32_to_cpu(es->s_blocks_count));
-+	update_backups(sb, EXT3COW_SB(sb)->s_sbh->b_blocknr, (char *)es,
-+		       sizeof(struct ext3cow_super_block));
-+exit_put:
-+	return err;
-+} /* ext3cow_group_extend */
-diff -Naur linux-2.6.21.7/fs/ext3cow/super.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/super.c
---- linux-2.6.21.7/fs/ext3cow/super.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/super.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,2808 @@
-+/*
-+ *  linux/fs/ext3cow/super.c
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/fs/minix/inode.c
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ *
-+ *  Big-endian to little-endian byte-swapping/bitmaps by
-+ *        David S. Miller (davem@caip.rutgers.edu), 1995
-+ */
-+
-+#include <linux/module.h>
-+#include <linux/string.h>
-+#include <linux/fs.h>
-+#include <linux/time.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/slab.h>
-+#include <linux/init.h>
-+#include <linux/blkdev.h>
-+#include <linux/parser.h>
-+#include <linux/smp_lock.h>
-+#include <linux/buffer_head.h>
-+#include <linux/vfs.h>
-+#include <linux/random.h>
-+#include <linux/mount.h>
-+#include <linux/namei.h>
-+#include <linux/quotaops.h>
-+#include <linux/seq_file.h>
-+
-+#include <asm/uaccess.h>
-+
-+#include "xattr.h"
-+#include "acl.h"
-+#include "namei.h"
-+
-+static int ext3cow_load_journal(struct super_block *, struct ext3cow_super_block *,
-+			     unsigned long journal_devnum);
-+static int ext3cow_create_journal(struct super_block *, struct ext3cow_super_block *,
-+			       unsigned int);
-+static void ext3cow_commit_super (struct super_block * sb,
-+			       struct ext3cow_super_block * es,
-+			       int sync);
-+static void ext3cow_mark_recovery_complete(struct super_block * sb,
-+					struct ext3cow_super_block * es);
-+static void ext3cow_clear_journal_err(struct super_block * sb,
-+				   struct ext3cow_super_block * es);
-+static int ext3cow_sync_fs(struct super_block *sb, int wait);
-+static const char *ext3cow_decode_error(struct super_block * sb, int errno,
-+				     char nbuf[16]);
-+static int ext3cow_remount (struct super_block * sb, int * flags, char * data);
-+static int ext3cow_statfs (struct dentry * dentry, struct kstatfs * buf);
-+static void ext3cow_unlockfs(struct super_block *sb);
-+static void ext3cow_write_super (struct super_block * sb);
-+static void ext3cow_write_super_lockfs(struct super_block *sb);
-+
-+/*
-+ * Wrappers for journal_start/end.
-+ *
-+ * The only special thing we need to do here is to make sure that all
-+ * journal_end calls result in the superblock being marked dirty, so
-+ * that sync() will call the filesystem's write_super callback if
-+ * appropriate.
-+ */
-+handle_t *ext3cow_journal_start_sb(struct super_block *sb, int nblocks)
-+{
-+	journal_t *journal;
-+
-+	if (sb->s_flags & MS_RDONLY)
-+		return ERR_PTR(-EROFS);
-+
-+	/* Special case here: if the journal has aborted behind our
-+	 * backs (eg. EIO in the commit thread), then we still need to
-+	 * take the FS itself readonly cleanly. */
-+	journal = EXT3COW_SB(sb)->s_journal;
-+	if (is_journal_aborted(journal)) {
-+		ext3cow_abort(sb, __FUNCTION__,
-+			   "Detected aborted journal");
-+		return ERR_PTR(-EROFS);
-+	}
-+
-+	return journal_start(journal, nblocks);
-+}
-+
-+/*
-+ * The only special thing we need to do here is to make sure that all
-+ * journal_stop calls result in the superblock being marked dirty, so
-+ * that sync() will call the filesystem's write_super callback if
-+ * appropriate.
-+ */
-+int __ext3cow_journal_stop(const char *where, handle_t *handle)
-+{
-+	struct super_block *sb;
-+	int err;
-+	int rc;
-+
-+	sb = handle->h_transaction->t_journal->j_private;
-+	err = handle->h_err;
-+	rc = journal_stop(handle);
-+
-+	if (!err)
-+		err = rc;
-+	if (err)
-+		__ext3cow_std_error(sb, where, err);
-+	return err;
-+}
-+
-+void ext3cow_journal_abort_handle(const char *caller, const char *err_fn,
-+		struct buffer_head *bh, handle_t *handle, int err)
-+{
-+	char nbuf[16];
-+	const char *errstr = ext3cow_decode_error(NULL, err, nbuf);
-+
-+	if (bh)
-+		BUFFER_TRACE(bh, "abort");
-+
-+	if (!handle->h_err)
-+		handle->h_err = err;
-+
-+	if (is_handle_aborted(handle))
-+		return;
-+
-+	printk(KERN_ERR "%s: aborting transaction: %s in %s\n",
-+	       caller, errstr, err_fn);
-+
-+	journal_abort_handle(handle);
-+}
-+
-+/* Deal with the reporting of failure conditions on a filesystem such as
-+ * inconsistencies detected or read IO failures.
-+ *
-+ * On ext2, we can store the error state of the filesystem in the
-+ * superblock.  That is not possible on ext3cow, because we may have other
-+ * write ordering constraints on the superblock which prevent us from
-+ * writing it out straight away; and given that the journal is about to
-+ * be aborted, we can't rely on the current, or future, transactions to
-+ * write out the superblock safely.
-+ *
-+ * We'll just use the journal_abort() error code to record an error in
-+ * the journal instead.  On recovery, the journal will compain about
-+ * that error until we've noted it down and cleared it.
-+ */
-+
-+static void ext3cow_handle_error(struct super_block *sb)
-+{
-+	struct ext3cow_super_block *es = EXT3COW_SB(sb)->s_es;
-+
-+	EXT3COW_SB(sb)->s_mount_state |= EXT3COW_ERROR_FS;
-+	es->s_state |= cpu_to_le16(EXT3COW_ERROR_FS);
-+
-+	if (sb->s_flags & MS_RDONLY)
-+		return;
-+
-+	if (!test_opt (sb, ERRORS_CONT)) {
-+		journal_t *journal = EXT3COW_SB(sb)->s_journal;
-+
-+		EXT3COW_SB(sb)->s_mount_opt |= EXT3COW_MOUNT_ABORT;
-+		if (journal)
-+			journal_abort(journal, -EIO);
-+	}
-+	if (test_opt (sb, ERRORS_RO)) {
-+		printk (KERN_CRIT "Remounting filesystem read-only\n");
-+		sb->s_flags |= MS_RDONLY;
-+	}
-+	ext3cow_commit_super(sb, es, 1);
-+	if (test_opt(sb, ERRORS_PANIC))
-+		panic("EXT3COW-fs (device %s): panic forced after error\n",
-+			sb->s_id);
-+}
-+
-+void ext3cow_error (struct super_block * sb, const char * function,
-+		 const char * fmt, ...)
-+{
-+	va_list args;
-+
-+	va_start(args, fmt);
-+	printk(KERN_CRIT "EXT3COW-fs error (device %s): %s: ",sb->s_id, function);
-+	vprintk(fmt, args);
-+	printk("\n");
-+	va_end(args);
-+
-+	ext3cow_handle_error(sb);
-+}
-+
-+static const char *ext3cow_decode_error(struct super_block * sb, int errno,
-+				     char nbuf[16])
-+{
-+	char *errstr = NULL;
-+
-+	switch (errno) {
-+	case -EIO:
-+		errstr = "IO failure";
-+		break;
-+	case -ENOMEM:
-+		errstr = "Out of memory";
-+		break;
-+	case -EROFS:
-+		if (!sb || EXT3COW_SB(sb)->s_journal->j_flags & JFS_ABORT)
-+			errstr = "Journal has aborted";
-+		else
-+			errstr = "Readonly filesystem";
-+		break;
-+	default:
-+		/* If the caller passed in an extra buffer for unknown
-+		 * errors, textualise them now.  Else we just return
-+		 * NULL. */
-+		if (nbuf) {
-+			/* Check for truncated error codes... */
-+			if (snprintf(nbuf, 16, "error %d", -errno) >= 0)
-+				errstr = nbuf;
-+		}
-+		break;
-+	}
-+
-+	return errstr;
-+}
-+
-+/* __ext3cow_std_error decodes expected errors from journaling functions
-+ * automatically and invokes the appropriate error response.  */
-+
-+void __ext3cow_std_error (struct super_block * sb, const char * function,
-+		       int errno)
-+{
-+	char nbuf[16];
-+	const char *errstr;
-+
-+	/* Special case: if the error is EROFS, and we're not already
-+	 * inside a transaction, then there's really no point in logging
-+	 * an error. */
-+	if (errno == -EROFS && journal_current_handle() == NULL &&
-+	    (sb->s_flags & MS_RDONLY))
-+		return;
-+
-+	errstr = ext3cow_decode_error(sb, errno, nbuf);
-+	printk (KERN_CRIT "EXT3COW-fs error (device %s) in %s: %s\n",
-+		sb->s_id, function, errstr);
-+
-+	ext3cow_handle_error(sb);
-+}
-+
-+/*
-+ * ext3cow_abort is a much stronger failure handler than ext3cow_error.  The
-+ * abort function may be used to deal with unrecoverable failures such
-+ * as journal IO errors or ENOMEM at a critical moment in log management.
-+ *
-+ * We unconditionally force the filesystem into an ABORT|READONLY state,
-+ * unless the error response on the fs has been set to panic in which
-+ * case we take the easy way out and panic immediately.
-+ */
-+
-+void ext3cow_abort (struct super_block * sb, const char * function,
-+		 const char * fmt, ...)
-+{
-+	va_list args;
-+
-+	printk (KERN_CRIT "ext3cow_abort called.\n");
-+
-+	va_start(args, fmt);
-+	printk(KERN_CRIT "EXT3COW-fs error (device %s): %s: ",sb->s_id, function);
-+	vprintk(fmt, args);
-+	printk("\n");
-+	va_end(args);
-+
-+	if (test_opt(sb, ERRORS_PANIC))
-+		panic("EXT3COW-fs panic from previous error\n");
-+
-+	if (sb->s_flags & MS_RDONLY)
-+		return;
-+
-+	printk(KERN_CRIT "Remounting filesystem read-only\n");
-+	EXT3COW_SB(sb)->s_mount_state |= EXT3COW_ERROR_FS;
-+	sb->s_flags |= MS_RDONLY;
-+	EXT3COW_SB(sb)->s_mount_opt |= EXT3COW_MOUNT_ABORT;
-+	journal_abort(EXT3COW_SB(sb)->s_journal, -EIO);
-+}
-+
-+void ext3cow_warning (struct super_block * sb, const char * function,
-+		   const char * fmt, ...)
-+{
-+	va_list args;
-+
-+	va_start(args, fmt);
-+	printk(KERN_WARNING "EXT3COW-fs warning (device %s): %s: ",
-+	       sb->s_id, function);
-+	vprintk(fmt, args);
-+	printk("\n");
-+	va_end(args);
-+}
-+
-+void ext3cow_update_dynamic_rev(struct super_block *sb)
-+{
-+	struct ext3cow_super_block *es = EXT3COW_SB(sb)->s_es;
-+
-+	if (le32_to_cpu(es->s_rev_level) > EXT3COW_GOOD_OLD_REV)
-+		return;
-+
-+	ext3cow_warning(sb, __FUNCTION__,
-+		     "updating to rev %d because of new feature flag, "
-+		     "running e2fsck is recommended",
-+		     EXT3COW_DYNAMIC_REV);
-+
-+	es->s_first_ino = cpu_to_le32(EXT3COW_GOOD_OLD_FIRST_INO);
-+	es->s_inode_size = cpu_to_le16(EXT3COW_GOOD_OLD_INODE_SIZE);
-+	es->s_rev_level = cpu_to_le32(EXT3COW_DYNAMIC_REV);
-+	/* leave es->s_feature_*compat flags alone */
-+	/* es->s_uuid will be set by e2fsck if empty */
-+
-+	/*
-+	 * The rest of the superblock fields should be zero, and if not it
-+	 * means they are likely already in use, so leave them alone.  We
-+	 * can leave it up to e2fsck to clean up any inconsistencies there.
-+	 */
-+}
-+
-+/*
-+ * Open the external journal device
-+ */
-+static struct block_device *ext3cow_blkdev_get(dev_t dev)
-+{
-+	struct block_device *bdev;
-+	char b[BDEVNAME_SIZE];
-+
-+	bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE);
-+	if (IS_ERR(bdev))
-+		goto fail;
-+	return bdev;
-+
-+fail:
-+	printk(KERN_ERR "EXT3COW: failed to open journal device %s: %ld\n",
-+			__bdevname(dev, b), PTR_ERR(bdev));
-+	return NULL;
-+}
-+
-+/*
-+ * Release the journal device
-+ */
-+static int ext3cow_blkdev_put(struct block_device *bdev)
-+{
-+	bd_release(bdev);
-+	return blkdev_put(bdev);
-+}
-+
-+static int ext3cow_blkdev_remove(struct ext3cow_sb_info *sbi)
-+{
-+	struct block_device *bdev;
-+	int ret = -ENODEV;
-+
-+	bdev = sbi->journal_bdev;
-+	if (bdev) {
-+		ret = ext3cow_blkdev_put(bdev);
-+		sbi->journal_bdev = NULL;
-+	}
-+	return ret;
-+}
-+
-+static inline struct inode *orphan_list_entry(struct list_head *l)
-+{
-+	return &list_entry(l, struct ext3cow_inode_info, i_orphan)->vfs_inode;
-+}
-+
-+static void dump_orphan_list(struct super_block *sb, struct ext3cow_sb_info *sbi)
-+{
-+	struct list_head *l;
-+
-+	printk(KERN_ERR "sb orphan head is %d\n",
-+	       le32_to_cpu(sbi->s_es->s_last_orphan));
-+
-+	printk(KERN_ERR "sb_info orphan list:\n");
-+	list_for_each(l, &sbi->s_orphan) {
-+		struct inode *inode = orphan_list_entry(l);
-+		printk(KERN_ERR "  "
-+		       "inode %s:%lu at %p: mode %o, nlink %d, next %d\n",
-+		       inode->i_sb->s_id, inode->i_ino, inode,
-+		       inode->i_mode, inode->i_nlink,
-+		       NEXT_ORPHAN(inode));
-+	}
-+}
-+
-+static void ext3cow_put_super (struct super_block * sb)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	struct ext3cow_super_block *es = sbi->s_es;
-+	int i;
-+
-+	ext3cow_xattr_put_super(sb);
-+	journal_destroy(sbi->s_journal);
-+	if (!(sb->s_flags & MS_RDONLY)) {
-+		EXT3COW_CLEAR_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER);
-+		es->s_state = cpu_to_le16(sbi->s_mount_state);
-+		BUFFER_TRACE(sbi->s_sbh, "marking dirty");
-+		mark_buffer_dirty(sbi->s_sbh);
-+		ext3cow_commit_super(sb, es, 1);
-+	}
-+
-+	for (i = 0; i < sbi->s_gdb_count; i++)
-+		brelse(sbi->s_group_desc[i]);
-+	kfree(sbi->s_group_desc);
-+	percpu_counter_destroy(&sbi->s_freeblocks_counter);
-+	percpu_counter_destroy(&sbi->s_freeinodes_counter);
-+	percpu_counter_destroy(&sbi->s_dirs_counter);
-+	brelse(sbi->s_sbh);
-+#ifdef CONFIG_QUOTA
-+	for (i = 0; i < MAXQUOTAS; i++)
-+		kfree(sbi->s_qf_names[i]);
-+#endif
-+
-+	/* Debugging code just in case the in-memory inode orphan list
-+	 * isn't empty.  The on-disk one can be non-empty if we've
-+	 * detected an error and taken the fs readonly, but the
-+	 * in-memory list had better be clean by this point. */
-+	if (!list_empty(&sbi->s_orphan))
-+		dump_orphan_list(sb, sbi);
-+	J_ASSERT(list_empty(&sbi->s_orphan));
-+
-+	invalidate_bdev(sb->s_bdev, 0);
-+	if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) {
-+		/*
-+		 * Invalidate the journal device's buffers.  We don't want them
-+		 * floating about in memory - the physical journal device may
-+		 * hotswapped, and it breaks the `ro-after' testing code.
-+		 */
-+		sync_blockdev(sbi->journal_bdev);
-+		invalidate_bdev(sbi->journal_bdev, 0);
-+		ext3cow_blkdev_remove(sbi);
-+	}
-+	sb->s_fs_info = NULL;
-+	kfree(sbi);
-+	return;
-+}
-+
-+static struct kmem_cache *ext3cow_inode_cachep;
-+
-+/*
-+ * Called inside transaction, so use GFP_NOFS
-+ */
-+static struct inode *ext3cow_alloc_inode(struct super_block *sb)
-+{
-+	struct ext3cow_inode_info *ei;
-+
-+	ei = kmem_cache_alloc(ext3cow_inode_cachep, GFP_NOFS);
-+	if (!ei)
-+		return NULL;
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+	ei->i_acl = EXT3COW_ACL_NOT_CACHED;
-+	ei->i_default_acl = EXT3COW_ACL_NOT_CACHED;
-+#endif
-+	ei->i_block_alloc_info = NULL;
-+	ei->vfs_inode.i_version = 1;
-+	return &ei->vfs_inode;
-+}
-+
-+static void ext3cow_destroy_inode(struct inode *inode)
-+{
-+	kmem_cache_free(ext3cow_inode_cachep, EXT3COW_I(inode));
-+}
-+
-+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
-+{
-+	struct ext3cow_inode_info *ei = (struct ext3cow_inode_info *) foo;
-+
-+	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
-+	    SLAB_CTOR_CONSTRUCTOR) {
-+		INIT_LIST_HEAD(&ei->i_orphan);
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+		init_rwsem(&ei->xattr_sem);
-+#endif
-+		mutex_init(&ei->truncate_mutex);
-+		inode_init_once(&ei->vfs_inode);
-+	}
-+}
-+
-+static int init_inodecache(void)
-+{
-+	ext3cow_inode_cachep = kmem_cache_create("ext3cow_inode_cache",
-+					     sizeof(struct ext3cow_inode_info),
-+					     0, (SLAB_RECLAIM_ACCOUNT|
-+						SLAB_MEM_SPREAD),
-+					     init_once, NULL);
-+	if (ext3cow_inode_cachep == NULL)
-+		return -ENOMEM;
-+	return 0;
-+}
-+
-+static void destroy_inodecache(void)
-+{
-+	kmem_cache_destroy(ext3cow_inode_cachep);
-+}
-+
-+static void ext3cow_clear_inode(struct inode *inode)
-+{
-+	struct ext3cow_block_alloc_info *rsv = EXT3COW_I(inode)->i_block_alloc_info;
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+	if (EXT3COW_I(inode)->i_acl &&
-+			EXT3COW_I(inode)->i_acl != EXT3COW_ACL_NOT_CACHED) {
-+		posix_acl_release(EXT3COW_I(inode)->i_acl);
-+		EXT3COW_I(inode)->i_acl = EXT3COW_ACL_NOT_CACHED;
-+	}
-+	if (EXT3COW_I(inode)->i_default_acl &&
-+			EXT3COW_I(inode)->i_default_acl != EXT3COW_ACL_NOT_CACHED) {
-+		posix_acl_release(EXT3COW_I(inode)->i_default_acl);
-+		EXT3COW_I(inode)->i_default_acl = EXT3COW_ACL_NOT_CACHED;
-+	}
-+#endif
-+	ext3cow_discard_reservation(inode);
-+	EXT3COW_I(inode)->i_block_alloc_info = NULL;
-+	if (unlikely(rsv))
-+		kfree(rsv);
-+}
-+
-+static inline void ext3cow_show_quota_options(struct seq_file *seq, struct super_block *sb)
-+{
-+#if defined(CONFIG_QUOTA)
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+
-+	if (sbi->s_jquota_fmt)
-+		seq_printf(seq, ",jqfmt=%s",
-+		(sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0");
-+
-+	if (sbi->s_qf_names[USRQUOTA])
-+		seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
-+
-+	if (sbi->s_qf_names[GRPQUOTA])
-+		seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
-+
-+	if (sbi->s_mount_opt & EXT3COW_MOUNT_USRQUOTA)
-+		seq_puts(seq, ",usrquota");
-+
-+	if (sbi->s_mount_opt & EXT3COW_MOUNT_GRPQUOTA)
-+		seq_puts(seq, ",grpquota");
-+#endif
-+}
-+
-+static int ext3cow_show_options(struct seq_file *seq, struct vfsmount *vfs)
-+{
-+	struct super_block *sb = vfs->mnt_sb;
-+
-+	if (test_opt(sb, DATA_FLAGS) == EXT3COW_MOUNT_JOURNAL_DATA)
-+		seq_puts(seq, ",data=journal");
-+	else if (test_opt(sb, DATA_FLAGS) == EXT3COW_MOUNT_ORDERED_DATA)
-+		seq_puts(seq, ",data=ordered");
-+	else if (test_opt(sb, DATA_FLAGS) == EXT3COW_MOUNT_WRITEBACK_DATA)
-+		seq_puts(seq, ",data=writeback");
-+
-+	ext3cow_show_quota_options(seq, sb);
-+
-+	return 0;
-+}
-+
-+
-+static struct dentry *ext3cow_get_dentry(struct super_block *sb, void *vobjp)
-+{
-+	__u32 *objp = vobjp;
-+	unsigned long ino = objp[0];
-+	__u32 generation = objp[1];
-+	struct inode *inode;
-+	struct dentry *result;
-+
-+	if (ino < EXT3COW_FIRST_INO(sb) && ino != EXT3COW_ROOT_INO)
-+		return ERR_PTR(-ESTALE);
-+	if (ino > le32_to_cpu(EXT3COW_SB(sb)->s_es->s_inodes_count))
-+		return ERR_PTR(-ESTALE);
-+
-+	/* iget isn't really right if the inode is currently unallocated!!
-+	 *
-+	 * ext3cow_read_inode will return a bad_inode if the inode had been
-+	 * deleted, so we should be safe.
-+	 *
-+	 * Currently we don't know the generation for parent directory, so
-+	 * a generation of 0 means "accept any"
-+	 */
-+	inode = iget(sb, ino);
-+	if (inode == NULL)
-+		return ERR_PTR(-ENOMEM);
-+	if (is_bad_inode(inode) ||
-+	    (generation && inode->i_generation != generation)) {
-+		iput(inode);
-+		return ERR_PTR(-ESTALE);
-+	}
-+	/* now to find a dentry.
-+	 * If possible, get a well-connected one
-+	 */
-+	result = d_alloc_anon(inode);
-+	if (!result) {
-+		iput(inode);
-+		return ERR_PTR(-ENOMEM);
-+	}
-+	return result;
-+}
-+
-+#ifdef CONFIG_QUOTA
-+#define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
-+#define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
-+
-+static int ext3cow_dquot_initialize(struct inode *inode, int type);
-+static int ext3cow_dquot_drop(struct inode *inode);
-+static int ext3cow_write_dquot(struct dquot *dquot);
-+static int ext3cow_acquire_dquot(struct dquot *dquot);
-+static int ext3cow_release_dquot(struct dquot *dquot);
-+static int ext3cow_mark_dquot_dirty(struct dquot *dquot);
-+static int ext3cow_write_info(struct super_block *sb, int type);
-+static int ext3cow_quota_on(struct super_block *sb, int type, int format_id, char *path);
-+static int ext3cow_quota_on_mount(struct super_block *sb, int type);
-+static ssize_t ext3cow_quota_read(struct super_block *sb, int type, char *data,
-+			       size_t len, loff_t off);
-+static ssize_t ext3cow_quota_write(struct super_block *sb, int type,
-+				const char *data, size_t len, loff_t off);
-+
-+static struct dquot_operations ext3cow_quota_operations = {
-+	.initialize	= ext3cow_dquot_initialize,
-+	.drop		= ext3cow_dquot_drop,
-+	.alloc_space	= dquot_alloc_space,
-+	.alloc_inode	= dquot_alloc_inode,
-+	.free_space	= dquot_free_space,
-+	.free_inode	= dquot_free_inode,
-+	.transfer	= dquot_transfer,
-+	.write_dquot	= ext3cow_write_dquot,
-+	.acquire_dquot	= ext3cow_acquire_dquot,
-+	.release_dquot	= ext3cow_release_dquot,
-+	.mark_dirty	= ext3cow_mark_dquot_dirty,
-+	.write_info	= ext3cow_write_info
-+};
-+
-+static struct quotactl_ops ext3cow_qctl_operations = {
-+	.quota_on	= ext3cow_quota_on,
-+	.quota_off	= vfs_quota_off,
-+	.quota_sync	= vfs_quota_sync,
-+	.get_info	= vfs_get_dqinfo,
-+	.set_info	= vfs_set_dqinfo,
-+	.get_dqblk	= vfs_get_dqblk,
-+	.set_dqblk	= vfs_set_dqblk
-+};
-+#endif
-+
-+static struct super_operations ext3cow_sops = {
-+	.alloc_inode	= ext3cow_alloc_inode,
-+	.destroy_inode	= ext3cow_destroy_inode,
-+	.read_inode	= ext3cow_read_inode,
-+	.write_inode	= ext3cow_write_inode,
-+	.dirty_inode	= ext3cow_dirty_inode,
-+	.delete_inode	= ext3cow_delete_inode,
-+	.put_super	= ext3cow_put_super,
-+	.write_super	= ext3cow_write_super,
-+	.sync_fs	= ext3cow_sync_fs,
-+	.write_super_lockfs = ext3cow_write_super_lockfs,
-+	.unlockfs	= ext3cow_unlockfs,
-+	.statfs		= ext3cow_statfs,
-+	.remount_fs	= ext3cow_remount,
-+	.clear_inode	= ext3cow_clear_inode,
-+	.show_options	= ext3cow_show_options,
-+#ifdef CONFIG_QUOTA
-+	.quota_read	= ext3cow_quota_read,
-+	.quota_write	= ext3cow_quota_write,
-+#endif
-+};
-+
-+static struct export_operations ext3cow_export_ops = {
-+	.get_parent = ext3cow_get_parent,
-+	.get_dentry = ext3cow_get_dentry,
-+};
-+
-+enum {
-+	Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
-+	Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
-+	Opt_nouid32, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov,
-+	Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
-+	Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh,
-+	Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev,
-+	Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
-+	Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
-+	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
-+	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
-+	Opt_grpquota
-+};
-+
-+static match_table_t tokens = {
-+	{Opt_bsd_df, "bsddf"},
-+	{Opt_minix_df, "minixdf"},
-+	{Opt_grpid, "grpid"},
-+	{Opt_grpid, "bsdgroups"},
-+	{Opt_nogrpid, "nogrpid"},
-+	{Opt_nogrpid, "sysvgroups"},
-+	{Opt_resgid, "resgid=%u"},
-+	{Opt_resuid, "resuid=%u"},
-+	{Opt_sb, "sb=%u"},
-+	{Opt_err_cont, "errors=continue"},
-+	{Opt_err_panic, "errors=panic"},
-+	{Opt_err_ro, "errors=remount-ro"},
-+	{Opt_nouid32, "nouid32"},
-+	{Opt_nocheck, "nocheck"},
-+	{Opt_nocheck, "check=none"},
-+	{Opt_debug, "debug"},
-+	{Opt_oldalloc, "oldalloc"},
-+	{Opt_orlov, "orlov"},
-+	{Opt_user_xattr, "user_xattr"},
-+	{Opt_nouser_xattr, "nouser_xattr"},
-+	{Opt_acl, "acl"},
-+	{Opt_noacl, "noacl"},
-+	{Opt_reservation, "reservation"},
-+	{Opt_noreservation, "noreservation"},
-+	{Opt_noload, "noload"},
-+	{Opt_nobh, "nobh"},
-+	{Opt_bh, "bh"},
-+	{Opt_commit, "commit=%u"},
-+	{Opt_journal_update, "journal=update"},
-+	{Opt_journal_inum, "journal=%u"},
-+	{Opt_journal_dev, "journal_dev=%u"},
-+	{Opt_abort, "abort"},
-+	{Opt_data_journal, "data=journal"},
-+	{Opt_data_ordered, "data=ordered"},
-+	{Opt_data_writeback, "data=writeback"},
-+	{Opt_offusrjquota, "usrjquota="},
-+	{Opt_usrjquota, "usrjquota=%s"},
-+	{Opt_offgrpjquota, "grpjquota="},
-+	{Opt_grpjquota, "grpjquota=%s"},
-+	{Opt_jqfmt_vfsold, "jqfmt=vfsold"},
-+	{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
-+	{Opt_grpquota, "grpquota"},
-+	{Opt_noquota, "noquota"},
-+	{Opt_quota, "quota"},
-+	{Opt_usrquota, "usrquota"},
-+	{Opt_barrier, "barrier=%u"},
-+	{Opt_err, NULL},
-+	{Opt_resize, "resize"},
-+};
-+
-+static ext3cow_fsblk_t get_sb_block(void **data)
-+{
-+	ext3cow_fsblk_t	sb_block;
-+	char		*options = (char *) *data;
-+
-+	if (!options || strncmp(options, "sb=", 3) != 0)
-+		return 1;	/* Default location */
-+	options += 3;
-+	/*todo: use simple_strtoll with >32bit ext3cow */
-+	sb_block = simple_strtoul(options, &options, 0);
-+	if (*options && *options != ',') {
-+		printk("EXT3COW-fs: Invalid sb specification: %s\n",
-+		       (char *) *data);
-+		return 1;
-+	}
-+	if (*options == ',')
-+		options++;
-+	*data = (void *) options;
-+	return sb_block;
-+}
-+
-+static int parse_options (char *options, struct super_block *sb,
-+			  unsigned int *inum, unsigned long *journal_devnum,
-+			  ext3cow_fsblk_t *n_blocks_count, int is_remount)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	char * p;
-+	substring_t args[MAX_OPT_ARGS];
-+	int data_opt = 0;
-+	int option;
-+#ifdef CONFIG_QUOTA
-+	int qtype;
-+	char *qname;
-+#endif
-+
-+	if (!options)
-+		return 1;
-+
-+	while ((p = strsep (&options, ",")) != NULL) {
-+		int token;
-+		if (!*p)
-+			continue;
-+
-+		token = match_token(p, tokens, args);
-+		switch (token) {
-+		case Opt_bsd_df:
-+			clear_opt (sbi->s_mount_opt, MINIX_DF);
-+			break;
-+		case Opt_minix_df:
-+			set_opt (sbi->s_mount_opt, MINIX_DF);
-+			break;
-+		case Opt_grpid:
-+			set_opt (sbi->s_mount_opt, GRPID);
-+			break;
-+		case Opt_nogrpid:
-+			clear_opt (sbi->s_mount_opt, GRPID);
-+			break;
-+		case Opt_resuid:
-+			if (match_int(&args[0], &option))
-+				return 0;
-+			sbi->s_resuid = option;
-+			break;
-+		case Opt_resgid:
-+			if (match_int(&args[0], &option))
-+				return 0;
-+			sbi->s_resgid = option;
-+			break;
-+		case Opt_sb:
-+			/* handled by get_sb_block() instead of here */
-+			/* *sb_block = match_int(&args[0]); */
-+			break;
-+		case Opt_err_panic:
-+			clear_opt (sbi->s_mount_opt, ERRORS_CONT);
-+			clear_opt (sbi->s_mount_opt, ERRORS_RO);
-+			set_opt (sbi->s_mount_opt, ERRORS_PANIC);
-+			break;
-+		case Opt_err_ro:
-+			clear_opt (sbi->s_mount_opt, ERRORS_CONT);
-+			clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
-+			set_opt (sbi->s_mount_opt, ERRORS_RO);
-+			break;
-+		case Opt_err_cont:
-+			clear_opt (sbi->s_mount_opt, ERRORS_RO);
-+			clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
-+			set_opt (sbi->s_mount_opt, ERRORS_CONT);
-+			break;
-+		case Opt_nouid32:
-+			set_opt (sbi->s_mount_opt, NO_UID32);
-+			break;
-+		case Opt_nocheck:
-+			clear_opt (sbi->s_mount_opt, CHECK);
-+			break;
-+		case Opt_debug:
-+			set_opt (sbi->s_mount_opt, DEBUG);
-+			break;
-+		case Opt_oldalloc:
-+			set_opt (sbi->s_mount_opt, OLDALLOC);
-+			break;
-+		case Opt_orlov:
-+			clear_opt (sbi->s_mount_opt, OLDALLOC);
-+			break;
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+		case Opt_user_xattr:
-+			set_opt (sbi->s_mount_opt, XATTR_USER);
-+			break;
-+		case Opt_nouser_xattr:
-+			clear_opt (sbi->s_mount_opt, XATTR_USER);
-+			break;
-+#else
-+		case Opt_user_xattr:
-+		case Opt_nouser_xattr:
-+			printk("EXT3COW (no)user_xattr options not supported\n");
-+			break;
-+#endif
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+		case Opt_acl:
-+			set_opt(sbi->s_mount_opt, POSIX_ACL);
-+			break;
-+		case Opt_noacl:
-+			clear_opt(sbi->s_mount_opt, POSIX_ACL);
-+			break;
-+#else
-+		case Opt_acl:
-+		case Opt_noacl:
-+			printk("EXT3COW (no)acl options not supported\n");
-+			break;
-+#endif
-+		case Opt_reservation:
-+			set_opt(sbi->s_mount_opt, RESERVATION);
-+			break;
-+		case Opt_noreservation:
-+			clear_opt(sbi->s_mount_opt, RESERVATION);
-+			break;
-+		case Opt_journal_update:
-+			/* @@@ FIXME */
-+			/* Eventually we will want to be able to create
-+			   a journal file here.  For now, only allow the
-+			   user to specify an existing inode to be the
-+			   journal file. */
-+			if (is_remount) {
-+				printk(KERN_ERR "EXT3COW-fs: cannot specify "
-+				       "journal on remount\n");
-+				return 0;
-+			}
-+			set_opt (sbi->s_mount_opt, UPDATE_JOURNAL);
-+			break;
-+		case Opt_journal_inum:
-+			if (is_remount) {
-+				printk(KERN_ERR "EXT3COW-fs: cannot specify "
-+				       "journal on remount\n");
-+				return 0;
-+			}
-+			if (match_int(&args[0], &option))
-+				return 0;
-+			*inum = option;
-+			break;
-+		case Opt_journal_dev:
-+			if (is_remount) {
-+				printk(KERN_ERR "EXT3COW-fs: cannot specify "
-+				       "journal on remount\n");
-+				return 0;
-+			}
-+			if (match_int(&args[0], &option))
-+				return 0;
-+			*journal_devnum = option;
-+			break;
-+		case Opt_noload:
-+			set_opt (sbi->s_mount_opt, NOLOAD);
-+			break;
-+		case Opt_commit:
-+			if (match_int(&args[0], &option))
-+				return 0;
-+			if (option < 0)
-+				return 0;
-+			if (option == 0)
-+				option = JBD_DEFAULT_MAX_COMMIT_AGE;
-+			sbi->s_commit_interval = HZ * option;
-+			break;
-+		case Opt_data_journal:
-+			data_opt = EXT3COW_MOUNT_JOURNAL_DATA;
-+			goto datacheck;
-+		case Opt_data_ordered:
-+			data_opt = EXT3COW_MOUNT_ORDERED_DATA;
-+			goto datacheck;
-+		case Opt_data_writeback:
-+			data_opt = EXT3COW_MOUNT_WRITEBACK_DATA;
-+		datacheck:
-+			if (is_remount) {
-+				if ((sbi->s_mount_opt & EXT3COW_MOUNT_DATA_FLAGS)
-+						!= data_opt) {
-+					printk(KERN_ERR
-+						"EXT3COW-fs: cannot change data "
-+						"mode on remount\n");
-+					return 0;
-+				}
-+			} else {
-+				sbi->s_mount_opt &= ~EXT3COW_MOUNT_DATA_FLAGS;
-+				sbi->s_mount_opt |= data_opt;
-+			}
-+			break;
-+#ifdef CONFIG_QUOTA
-+		case Opt_usrjquota:
-+			qtype = USRQUOTA;
-+			goto set_qf_name;
-+		case Opt_grpjquota:
-+			qtype = GRPQUOTA;
-+set_qf_name:
-+			if (sb_any_quota_enabled(sb)) {
-+				printk(KERN_ERR
-+					"EXT3COW-fs: Cannot change journalled "
-+					"quota options when quota turned on.\n");
-+				return 0;
-+			}
-+			qname = match_strdup(&args[0]);
-+			if (!qname) {
-+				printk(KERN_ERR
-+					"EXT3COW-fs: not enough memory for "
-+					"storing quotafile name.\n");
-+				return 0;
-+			}
-+			if (sbi->s_qf_names[qtype] &&
-+			    strcmp(sbi->s_qf_names[qtype], qname)) {
-+				printk(KERN_ERR
-+					"EXT3COW-fs: %s quota file already "
-+					"specified.\n", QTYPE2NAME(qtype));
-+				kfree(qname);
-+				return 0;
-+			}
-+			sbi->s_qf_names[qtype] = qname;
-+			if (strchr(sbi->s_qf_names[qtype], '/')) {
-+				printk(KERN_ERR
-+					"EXT3COW-fs: quotafile must be on "
-+					"filesystem root.\n");
-+				kfree(sbi->s_qf_names[qtype]);
-+				sbi->s_qf_names[qtype] = NULL;
-+				return 0;
-+			}
-+			set_opt(sbi->s_mount_opt, QUOTA);
-+			break;
-+		case Opt_offusrjquota:
-+			qtype = USRQUOTA;
-+			goto clear_qf_name;
-+		case Opt_offgrpjquota:
-+			qtype = GRPQUOTA;
-+clear_qf_name:
-+			if (sb_any_quota_enabled(sb)) {
-+				printk(KERN_ERR "EXT3COW-fs: Cannot change "
-+					"journalled quota options when "
-+					"quota turned on.\n");
-+				return 0;
-+			}
-+			/*
-+			 * The space will be released later when all options
-+			 * are confirmed to be correct
-+			 */
-+			sbi->s_qf_names[qtype] = NULL;
-+			break;
-+		case Opt_jqfmt_vfsold:
-+			sbi->s_jquota_fmt = QFMT_VFS_OLD;
-+			break;
-+		case Opt_jqfmt_vfsv0:
-+			sbi->s_jquota_fmt = QFMT_VFS_V0;
-+			break;
-+		case Opt_quota:
-+		case Opt_usrquota:
-+			set_opt(sbi->s_mount_opt, QUOTA);
-+			set_opt(sbi->s_mount_opt, USRQUOTA);
-+			break;
-+		case Opt_grpquota:
-+			set_opt(sbi->s_mount_opt, QUOTA);
-+			set_opt(sbi->s_mount_opt, GRPQUOTA);
-+			break;
-+		case Opt_noquota:
-+			if (sb_any_quota_enabled(sb)) {
-+				printk(KERN_ERR "EXT3COW-fs: Cannot change quota "
-+					"options when quota turned on.\n");
-+				return 0;
-+			}
-+			clear_opt(sbi->s_mount_opt, QUOTA);
-+			clear_opt(sbi->s_mount_opt, USRQUOTA);
-+			clear_opt(sbi->s_mount_opt, GRPQUOTA);
-+			break;
-+#else
-+		case Opt_quota:
-+		case Opt_usrquota:
-+		case Opt_grpquota:
-+		case Opt_usrjquota:
-+		case Opt_grpjquota:
-+		case Opt_offusrjquota:
-+		case Opt_offgrpjquota:
-+		case Opt_jqfmt_vfsold:
-+		case Opt_jqfmt_vfsv0:
-+			printk(KERN_ERR
-+				"EXT3COW-fs: journalled quota options not "
-+				"supported.\n");
-+			break;
-+		case Opt_noquota:
-+			break;
-+#endif
-+		case Opt_abort:
-+			set_opt(sbi->s_mount_opt, ABORT);
-+			break;
-+		case Opt_barrier:
-+			if (match_int(&args[0], &option))
-+				return 0;
-+			if (option)
-+				set_opt(sbi->s_mount_opt, BARRIER);
-+			else
-+				clear_opt(sbi->s_mount_opt, BARRIER);
-+			break;
-+		case Opt_ignore:
-+			break;
-+		case Opt_resize:
-+			if (!is_remount) {
-+				printk("EXT3COW-fs: resize option only available "
-+					"for remount\n");
-+				return 0;
-+			}
-+			if (match_int(&args[0], &option) != 0)
-+				return 0;
-+			*n_blocks_count = option;
-+			break;
-+		case Opt_nobh:
-+			set_opt(sbi->s_mount_opt, NOBH);
-+			break;
-+		case Opt_bh:
-+			clear_opt(sbi->s_mount_opt, NOBH);
-+			break;
-+		default:
-+			printk (KERN_ERR
-+				"EXT3COW-fs: Unrecognized mount option \"%s\" "
-+				"or missing value\n", p);
-+			return 0;
-+		}
-+	}
-+#ifdef CONFIG_QUOTA
-+	if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
-+		if ((sbi->s_mount_opt & EXT3COW_MOUNT_USRQUOTA) &&
-+		     sbi->s_qf_names[USRQUOTA])
-+			clear_opt(sbi->s_mount_opt, USRQUOTA);
-+
-+		if ((sbi->s_mount_opt & EXT3COW_MOUNT_GRPQUOTA) &&
-+		     sbi->s_qf_names[GRPQUOTA])
-+			clear_opt(sbi->s_mount_opt, GRPQUOTA);
-+
-+		if ((sbi->s_qf_names[USRQUOTA] &&
-+				(sbi->s_mount_opt & EXT3COW_MOUNT_GRPQUOTA)) ||
-+		    (sbi->s_qf_names[GRPQUOTA] &&
-+				(sbi->s_mount_opt & EXT3COW_MOUNT_USRQUOTA))) {
-+			printk(KERN_ERR "EXT3COW-fs: old and new quota "
-+					"format mixing.\n");
-+			return 0;
-+		}
-+
-+		if (!sbi->s_jquota_fmt) {
-+			printk(KERN_ERR "EXT3COW-fs: journalled quota format "
-+					"not specified.\n");
-+			return 0;
-+		}
-+	} else {
-+		if (sbi->s_jquota_fmt) {
-+			printk(KERN_ERR "EXT3COW-fs: journalled quota format "
-+					"specified with no journalling "
-+					"enabled.\n");
-+			return 0;
-+		}
-+	}
-+#endif
-+	return 1;
-+}
-+
-+static int ext3cow_setup_super(struct super_block *sb, struct ext3cow_super_block *es,
-+			    int read_only)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	int res = 0;
-+
-+	if (le32_to_cpu(es->s_rev_level) > EXT3COW_MAX_SUPP_REV) {
-+		printk (KERN_ERR "EXT3COW-fs warning: revision level too high, "
-+			"forcing read-only mode\n");
-+		res = MS_RDONLY;
-+	}
-+	if (read_only)
-+		return res;
-+	if (!(sbi->s_mount_state & EXT3COW_VALID_FS))
-+		printk (KERN_WARNING "EXT3COW-fs warning: mounting unchecked fs, "
-+			"running e2fsck is recommended\n");
-+	else if ((sbi->s_mount_state & EXT3COW_ERROR_FS))
-+		printk (KERN_WARNING
-+			"EXT3COW-fs warning: mounting fs with errors, "
-+			"running e2fsck is recommended\n");
-+	else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
-+		 le16_to_cpu(es->s_mnt_count) >=
-+		 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
-+		printk (KERN_WARNING
-+			"EXT3COW-fs warning: maximal mount count reached, "
-+			"running e2fsck is recommended\n");
-+	else if (le32_to_cpu(es->s_checkinterval) &&
-+		(le32_to_cpu(es->s_lastcheck) +
-+			le32_to_cpu(es->s_checkinterval) <= get_seconds()))
-+		printk (KERN_WARNING
-+			"EXT3COW-fs warning: checktime reached, "
-+			"running e2fsck is recommended\n");
-+#if 0
-+		/* @@@ We _will_ want to clear the valid bit if we find
-+                   inconsistencies, to force a fsck at reboot.  But for
-+                   a plain journaled filesystem we can keep it set as
-+                   valid forever! :) */
-+	es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT3COW_VALID_FS);
-+#endif
-+	if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
-+		es->s_max_mnt_count = cpu_to_le16(EXT3COW_DFL_MAX_MNT_COUNT);
-+	es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1);
-+	es->s_mtime = cpu_to_le32(get_seconds());
-+	ext3cow_update_dynamic_rev(sb);
-+	EXT3COW_SET_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER);
-+
-+	ext3cow_commit_super(sb, es, 1);
-+	if (test_opt(sb, DEBUG))
-+		printk(KERN_INFO "[EXT3COW FS bs=%lu, gc=%lu, "
-+				"bpg=%lu, ipg=%lu, mo=%04lx]\n",
-+			sb->s_blocksize,
-+			sbi->s_groups_count,
-+			EXT3COW_BLOCKS_PER_GROUP(sb),
-+			EXT3COW_INODES_PER_GROUP(sb),
-+			sbi->s_mount_opt);
-+
-+	printk(KERN_INFO "EXT3COW FS on %s, ", sb->s_id);
-+	if (EXT3COW_SB(sb)->s_journal->j_inode == NULL) {
-+		char b[BDEVNAME_SIZE];
-+
-+		printk("external journal on %s\n",
-+			bdevname(EXT3COW_SB(sb)->s_journal->j_dev, b));
-+	} else {
-+		printk("internal journal\n");
-+	}
-+	return res;
-+}
-+
-+/* Called at mount-time, super-block is locked */
-+static int ext3cow_check_descriptors (struct super_block * sb)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	ext3cow_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
-+	ext3cow_fsblk_t last_block;
-+	struct ext3cow_group_desc * gdp = NULL;
-+	int desc_block = 0;
-+	int i;
-+
-+	ext3cow_debug ("Checking group descriptors");
-+
-+	for (i = 0; i < sbi->s_groups_count; i++)
-+	{
-+		if (i == sbi->s_groups_count - 1)
-+			last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
-+		else
-+			last_block = first_block +
-+				(EXT3COW_BLOCKS_PER_GROUP(sb) - 1);
-+
-+		if ((i % EXT3COW_DESC_PER_BLOCK(sb)) == 0)
-+			gdp = (struct ext3cow_group_desc *)
-+					sbi->s_group_desc[desc_block++]->b_data;
-+		if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
-+		    le32_to_cpu(gdp->bg_block_bitmap) > last_block)
-+		{
-+			ext3cow_error (sb, "ext3cow_check_descriptors",
-+				    "Block bitmap for group %d"
-+				    " not in group (block %lu)!",
-+				    i, (unsigned long)
-+					le32_to_cpu(gdp->bg_block_bitmap));
-+			return 0;
-+		}
-+		if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
-+		    le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
-+		{
-+			ext3cow_error (sb, "ext3cow_check_descriptors",
-+				    "Inode bitmap for group %d"
-+				    " not in group (block %lu)!",
-+				    i, (unsigned long)
-+					le32_to_cpu(gdp->bg_inode_bitmap));
-+			return 0;
-+		}
-+		if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
-+		    le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >
-+		    last_block)
-+		{
-+			ext3cow_error (sb, "ext3cow_check_descriptors",
-+				    "Inode table for group %d"
-+				    " not in group (block %lu)!",
-+				    i, (unsigned long)
-+					le32_to_cpu(gdp->bg_inode_table));
-+			return 0;
-+		}
-+		first_block += EXT3COW_BLOCKS_PER_GROUP(sb);
-+		gdp++;
-+	}
-+
-+	sbi->s_es->s_free_blocks_count=cpu_to_le32(ext3cow_count_free_blocks(sb));
-+	sbi->s_es->s_free_inodes_count=cpu_to_le32(ext3cow_count_free_inodes(sb));
-+	return 1;
-+}
-+
-+
-+/* ext3cow_orphan_cleanup() walks a singly-linked list of inodes (starting at
-+ * the superblock) which were deleted from all directories, but held open by
-+ * a process at the time of a crash.  We walk the list and try to delete these
-+ * inodes at recovery time (only with a read-write filesystem).
-+ *
-+ * In order to keep the orphan inode chain consistent during traversal (in
-+ * case of crash during recovery), we link each inode into the superblock
-+ * orphan list_head and handle it the same way as an inode deletion during
-+ * normal operation (which journals the operations for us).
-+ *
-+ * We only do an iget() and an iput() on each inode, which is very safe if we
-+ * accidentally point at an in-use or already deleted inode.  The worst that
-+ * can happen in this case is that we get a "bit already cleared" message from
-+ * ext3cow_free_inode().  The only reason we would point at a wrong inode is if
-+ * e2fsck was run on this filesystem, and it must have already done the orphan
-+ * inode cleanup for us, so we can safely abort without any further action.
-+ */
-+static void ext3cow_orphan_cleanup (struct super_block * sb,
-+				 struct ext3cow_super_block * es)
-+{
-+	unsigned int s_flags = sb->s_flags;
-+	int nr_orphans = 0, nr_truncates = 0;
-+#ifdef CONFIG_QUOTA
-+	int i;
-+#endif
-+	if (!es->s_last_orphan) {
-+		jbd_debug(4, "no orphan inodes to clean up\n");
-+		return;
-+	}
-+
-+	if (bdev_read_only(sb->s_bdev)) {
-+		printk(KERN_ERR "EXT3COW-fs: write access "
-+			"unavailable, skipping orphan cleanup.\n");
-+		return;
-+	}
-+
-+	if (EXT3COW_SB(sb)->s_mount_state & EXT3COW_ERROR_FS) {
-+		if (es->s_last_orphan)
-+			jbd_debug(1, "Errors on filesystem, "
-+				  "clearing orphan list.\n");
-+		es->s_last_orphan = 0;
-+		jbd_debug(1, "Skipping orphan recovery on fs with errors.\n");
-+		return;
-+	}
-+
-+	if (s_flags & MS_RDONLY) {
-+		printk(KERN_INFO "EXT3COW-fs: %s: orphan cleanup on readonly fs\n",
-+		       sb->s_id);
-+		sb->s_flags &= ~MS_RDONLY;
-+	}
-+#ifdef CONFIG_QUOTA
-+	/* Needed for iput() to work correctly and not trash data */
-+	sb->s_flags |= MS_ACTIVE;
-+	/* Turn on quotas so that they are updated correctly */
-+	for (i = 0; i < MAXQUOTAS; i++) {
-+		if (EXT3COW_SB(sb)->s_qf_names[i]) {
-+			int ret = ext3cow_quota_on_mount(sb, i);
-+			if (ret < 0)
-+				printk(KERN_ERR
-+					"EXT3COW-fs: Cannot turn on journalled "
-+					"quota: error %d\n", ret);
-+		}
-+	}
-+#endif
-+
-+	while (es->s_last_orphan) {
-+		struct inode *inode;
-+
-+		if (!(inode =
-+		      ext3cow_orphan_get(sb, le32_to_cpu(es->s_last_orphan)))) {
-+			es->s_last_orphan = 0;
-+			break;
-+		}
-+
-+		list_add(&EXT3COW_I(inode)->i_orphan, &EXT3COW_SB(sb)->s_orphan);
-+		DQUOT_INIT(inode);
-+		if (inode->i_nlink) {
-+			printk(KERN_DEBUG
-+				"%s: truncating inode %lu to %Ld bytes\n",
-+				__FUNCTION__, inode->i_ino, inode->i_size);
-+			jbd_debug(2, "truncating inode %lu to %Ld bytes\n",
-+				  inode->i_ino, inode->i_size);
-+			ext3cow_truncate(inode);
-+			nr_truncates++;
-+		} else {
-+			printk(KERN_DEBUG
-+				"%s: deleting unreferenced inode %lu\n",
-+				__FUNCTION__, inode->i_ino);
-+			jbd_debug(2, "deleting unreferenced inode %lu\n",
-+				  inode->i_ino);
-+			nr_orphans++;
-+		}
-+		iput(inode);  /* The delete magic happens here! */
-+	}
-+
-+#define PLURAL(x) (x), ((x)==1) ? "" : "s"
-+
-+	if (nr_orphans)
-+		printk(KERN_INFO "EXT3COW-fs: %s: %d orphan inode%s deleted\n",
-+		       sb->s_id, PLURAL(nr_orphans));
-+	if (nr_truncates)
-+		printk(KERN_INFO "EXT3COW-fs: %s: %d truncate%s cleaned up\n",
-+		       sb->s_id, PLURAL(nr_truncates));
-+#ifdef CONFIG_QUOTA
-+	/* Turn quotas off */
-+	for (i = 0; i < MAXQUOTAS; i++) {
-+		if (sb_dqopt(sb)->files[i])
-+			vfs_quota_off(sb, i);
-+	}
-+#endif
-+	sb->s_flags = s_flags; /* Restore MS_RDONLY status */
-+}
-+
-+/*
-+ * Maximal file size.  There is a direct, and {,double-,triple-}indirect
-+ * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
-+ * We need to be 1 filesystem block less than the 2^32 sector limit.
-+ */
-+static loff_t ext3cow_max_size(int bits)
-+{
-+	loff_t res = EXT3COW_NDIR_BLOCKS;
-+	/* This constant is calculated to be the largest file size for a
-+	 * dense, 4k-blocksize file such that the total number of
-+	 * sectors in the file, including data and all indirect blocks,
-+	 * does not exceed 2^32. */
-+	const loff_t upper_limit = 0x1ff7fffd000LL;
-+
-+	res += 1LL << (bits-2);
-+	res += 1LL << (2*(bits-2));
-+	res += 1LL << (3*(bits-2));
-+	res <<= bits;
-+	if (res > upper_limit)
-+		res = upper_limit;
-+	return res;
-+}
-+
-+static ext3cow_fsblk_t descriptor_loc(struct super_block *sb,
-+				    ext3cow_fsblk_t logic_sb_block,
-+				    int nr)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	unsigned long bg, first_meta_bg;
-+	int has_super = 0;
-+
-+	first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
-+
-+	if (!EXT3COW_HAS_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_META_BG) ||
-+	    nr < first_meta_bg)
-+		return (logic_sb_block + nr + 1);
-+	bg = sbi->s_desc_per_block * nr;
-+	if (ext3cow_bg_has_super(sb, bg))
-+		has_super = 1;
-+	return (has_super + ext3cow_group_first_block_no(sb, bg));
-+}
-+
-+
-+static int ext3cow_fill_super (struct super_block *sb, void *data, int silent)
-+{
-+	struct buffer_head * bh;
-+	struct ext3cow_super_block *es = NULL;
-+	struct ext3cow_sb_info *sbi;
-+	ext3cow_fsblk_t block;
-+	ext3cow_fsblk_t sb_block = get_sb_block(&data);
-+	ext3cow_fsblk_t logic_sb_block;
-+	unsigned long offset = 0;
-+	unsigned int journal_inum = 0;
-+	unsigned long journal_devnum = 0;
-+	unsigned long def_mount_opts;
-+	struct inode *root;
-+	int blocksize;
-+	int hblock;
-+	int db_count;
-+	int i;
-+	int needs_recovery;
-+	__le32 features;
-+
-+	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
-+	if (!sbi)
-+		return -ENOMEM;
-+	sb->s_fs_info = sbi;
-+	sbi->s_mount_opt = 0;
-+	sbi->s_resuid = EXT3COW_DEF_RESUID;
-+	sbi->s_resgid = EXT3COW_DEF_RESGID;
-+
-+	unlock_kernel();
-+
-+	blocksize = sb_min_blocksize(sb, EXT3COW_MIN_BLOCK_SIZE);
-+	if (!blocksize) {
-+		printk(KERN_ERR "EXT3COW-fs: unable to set blocksize\n");
-+		goto out_fail;
-+	}
-+
-+	/*
-+	 * The ext3cow superblock will not be buffer aligned for other than 1kB
-+	 * block sizes.  We need to calculate the offset from buffer start.
-+	 */
-+	if (blocksize != EXT3COW_MIN_BLOCK_SIZE) {
-+		logic_sb_block = (sb_block * EXT3COW_MIN_BLOCK_SIZE) / blocksize;
-+		offset = (sb_block * EXT3COW_MIN_BLOCK_SIZE) % blocksize;
-+	} else {
-+		logic_sb_block = sb_block;
-+	}
-+
-+	if (!(bh = sb_bread(sb, logic_sb_block))) {
-+		printk (KERN_ERR "EXT3COW-fs: unable to read superblock\n");
-+		goto out_fail;
-+	}
-+	/*
-+	 * Note: s_es must be initialized as soon as possible because
-+	 *       some ext3cow macro-instructions depend on its value
-+	 */
-+	es = (struct ext3cow_super_block *) (((char *)bh->b_data) + offset);
-+	sbi->s_es = es;
-+	sb->s_magic = le16_to_cpu(es->s_magic);
-+	if (sb->s_magic != EXT3COW_SUPER_MAGIC)
-+		goto cantfind_ext3cow;
-+
-+	/* Set defaults before we parse the mount options */
-+	def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
-+	if (def_mount_opts & EXT3COW_DEFM_DEBUG)
-+		set_opt(sbi->s_mount_opt, DEBUG);
-+	if (def_mount_opts & EXT3COW_DEFM_BSDGROUPS)
-+		set_opt(sbi->s_mount_opt, GRPID);
-+	if (def_mount_opts & EXT3COW_DEFM_UID16)
-+		set_opt(sbi->s_mount_opt, NO_UID32);
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+	if (def_mount_opts & EXT3COW_DEFM_XATTR_USER)
-+		set_opt(sbi->s_mount_opt, XATTR_USER);
-+#endif
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+	if (def_mount_opts & EXT3COW_DEFM_ACL)
-+		set_opt(sbi->s_mount_opt, POSIX_ACL);
-+#endif
-+	if ((def_mount_opts & EXT3COW_DEFM_JMODE) == EXT3COW_DEFM_JMODE_DATA)
-+		sbi->s_mount_opt |= EXT3COW_MOUNT_JOURNAL_DATA;
-+	else if ((def_mount_opts & EXT3COW_DEFM_JMODE) == EXT3COW_DEFM_JMODE_ORDERED)
-+		sbi->s_mount_opt |= EXT3COW_MOUNT_ORDERED_DATA;
-+	else if ((def_mount_opts & EXT3COW_DEFM_JMODE) == EXT3COW_DEFM_JMODE_WBACK)
-+		sbi->s_mount_opt |= EXT3COW_MOUNT_WRITEBACK_DATA;
-+
-+	if (le16_to_cpu(sbi->s_es->s_errors) == EXT3COW_ERRORS_PANIC)
-+		set_opt(sbi->s_mount_opt, ERRORS_PANIC);
-+	else if (le16_to_cpu(sbi->s_es->s_errors) == EXT3COW_ERRORS_RO)
-+		set_opt(sbi->s_mount_opt, ERRORS_RO);
-+	else
-+		set_opt(sbi->s_mount_opt, ERRORS_CONT);
-+
-+	sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
-+	sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
-+
-+	set_opt(sbi->s_mount_opt, RESERVATION);
-+
-+	if (!parse_options ((char *) data, sb, &journal_inum, &journal_devnum,
-+			    NULL, 0))
-+		goto failed_mount;
-+
-+	sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
-+		((sbi->s_mount_opt & EXT3COW_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
-+
-+	if (le32_to_cpu(es->s_rev_level) == EXT3COW_GOOD_OLD_REV &&
-+	    (EXT3COW_HAS_COMPAT_FEATURE(sb, ~0U) ||
-+	     EXT3COW_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
-+	     EXT3COW_HAS_INCOMPAT_FEATURE(sb, ~0U)))
-+		printk(KERN_WARNING
-+		       "EXT3COW-fs warning: feature flags set on rev 0 fs, "
-+		       "running e2fsck is recommended\n");
-+	/*
-+	 * Check feature flags regardless of the revision level, since we
-+	 * previously didn't change the revision level when setting the flags,
-+	 * so there is a chance incompat flags are set on a rev 0 filesystem.
-+	 */
-+	features = EXT3COW_HAS_INCOMPAT_FEATURE(sb, ~EXT3COW_FEATURE_INCOMPAT_SUPP);
-+	if (features) {
-+		printk(KERN_ERR "EXT3COW-fs: %s: couldn't mount because of "
-+		       "unsupported optional features (%x).\n",
-+		       sb->s_id, le32_to_cpu(features));
-+		goto failed_mount;
-+	}
-+	features = EXT3COW_HAS_RO_COMPAT_FEATURE(sb, ~EXT3COW_FEATURE_RO_COMPAT_SUPP);
-+	if (!(sb->s_flags & MS_RDONLY) && features) {
-+		printk(KERN_ERR "EXT3COW-fs: %s: couldn't mount RDWR because of "
-+		       "unsupported optional features (%x).\n",
-+		       sb->s_id, le32_to_cpu(features));
-+		goto failed_mount;
-+	}
-+	blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
-+
-+	if (blocksize < EXT3COW_MIN_BLOCK_SIZE ||
-+	    blocksize > EXT3COW_MAX_BLOCK_SIZE) {
-+		printk(KERN_ERR
-+		       "EXT3COW-fs: Unsupported filesystem blocksize %d on %s.\n",
-+		       blocksize, sb->s_id);
-+		goto failed_mount;
-+	}
-+
-+	hblock = bdev_hardsect_size(sb->s_bdev);
-+	if (sb->s_blocksize != blocksize) {
-+		/*
-+		 * Make sure the blocksize for the filesystem is larger
-+		 * than the hardware sectorsize for the machine.
-+		 */
-+		if (blocksize < hblock) {
-+			printk(KERN_ERR "EXT3COW-fs: blocksize %d too small for "
-+			       "device blocksize %d.\n", blocksize, hblock);
-+			goto failed_mount;
-+		}
-+
-+		brelse (bh);
-+		sb_set_blocksize(sb, blocksize);
-+		logic_sb_block = (sb_block * EXT3COW_MIN_BLOCK_SIZE) / blocksize;
-+		offset = (sb_block * EXT3COW_MIN_BLOCK_SIZE) % blocksize;
-+		bh = sb_bread(sb, logic_sb_block);
-+		if (!bh) {
-+			printk(KERN_ERR
-+			       "EXT3COW-fs: Can't read superblock on 2nd try.\n");
-+			goto failed_mount;
-+		}
-+		es = (struct ext3cow_super_block *)(((char *)bh->b_data) + offset);
-+		sbi->s_es = es;
-+		if (es->s_magic != cpu_to_le16(EXT3COW_SUPER_MAGIC)) {
-+			printk (KERN_ERR
-+				"EXT3COW-fs: Magic mismatch, very weird !\n");
-+			goto failed_mount;
-+		}
-+	}
-+
-+	sb->s_maxbytes = ext3cow_max_size(sb->s_blocksize_bits);
-+
-+	if (le32_to_cpu(es->s_rev_level) == EXT3COW_GOOD_OLD_REV) {
-+		sbi->s_inode_size = EXT3COW_GOOD_OLD_INODE_SIZE;
-+		sbi->s_first_ino = EXT3COW_GOOD_OLD_FIRST_INO;
-+	} else {
-+		sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
-+		sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
-+		if ((sbi->s_inode_size < EXT3COW_GOOD_OLD_INODE_SIZE) ||
-+		    (sbi->s_inode_size & (sbi->s_inode_size - 1)) ||
-+		    (sbi->s_inode_size > blocksize)) {
-+			printk (KERN_ERR
-+				"EXT3COW-fs: unsupported inode size: %d\n",
-+				sbi->s_inode_size);
-+			goto failed_mount;
-+		}
-+	}
-+	sbi->s_frag_size = EXT3COW_MIN_FRAG_SIZE <<
-+				   le32_to_cpu(es->s_log_frag_size);
-+	if (blocksize != sbi->s_frag_size) {
-+		printk(KERN_ERR
-+		       "EXT3COW-fs: fragsize %lu != blocksize %u (unsupported)\n",
-+		       sbi->s_frag_size, blocksize);
-+		goto failed_mount;
-+	}
-+	sbi->s_frags_per_block = 1;
-+	sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
-+	sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
-+	sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
-+	if (EXT3COW_INODE_SIZE(sb) == 0)
-+		goto cantfind_ext3cow;
-+	sbi->s_inodes_per_block = blocksize / EXT3COW_INODE_SIZE(sb);
-+	if (sbi->s_inodes_per_block == 0)
-+		goto cantfind_ext3cow;
-+	sbi->s_itb_per_group = sbi->s_inodes_per_group /
-+					sbi->s_inodes_per_block;
-+	sbi->s_desc_per_block = blocksize / sizeof(struct ext3cow_group_desc);
-+	sbi->s_sbh = bh;
-+	sbi->s_mount_state = le16_to_cpu(es->s_state);
-+	sbi->s_addr_per_block_bits = ilog2(EXT3COW_ADDR_PER_BLOCK(sb));
-+	sbi->s_desc_per_block_bits = ilog2(EXT3COW_DESC_PER_BLOCK(sb));
-+	for (i=0; i < 4; i++)
-+		sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
-+	sbi->s_def_hash_version = es->s_def_hash_version;
-+
-+  /* Epoch number for versioning -znjp */
-+  sbi->s_epoch_number = le32_to_cpu(es->s_epoch_number);
-+  printk(KERN_INFO "EXT3COW-fs: System epoch number: %u\n",
-+         sbi->s_epoch_number);
-+
-+	if (sbi->s_blocks_per_group > blocksize * 8) {
-+		printk (KERN_ERR
-+			"EXT3COW-fs: #blocks per group too big: %lu\n",
-+			sbi->s_blocks_per_group);
-+		goto failed_mount;
-+	}
-+	if (sbi->s_frags_per_group > blocksize * 8) {
-+		printk (KERN_ERR
-+			"EXT3COW-fs: #fragments per group too big: %lu\n",
-+			sbi->s_frags_per_group);
-+		goto failed_mount;
-+	}
-+	if (sbi->s_inodes_per_group > blocksize * 8) {
-+		printk (KERN_ERR
-+			"EXT3COW-fs: #inodes per group too big: %lu\n",
-+			sbi->s_inodes_per_group);
-+		goto failed_mount;
-+	}
-+
-+	if (le32_to_cpu(es->s_blocks_count) >
-+		    (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
-+		printk(KERN_ERR "EXT3COW-fs: filesystem on %s:"
-+			" too large to mount safely\n", sb->s_id);
-+		if (sizeof(sector_t) < 8)
-+			printk(KERN_WARNING "EXT3COW-fs: CONFIG_LBD not "
-+					"enabled\n");
-+		goto failed_mount;
-+	}
-+
-+	if (EXT3COW_BLOCKS_PER_GROUP(sb) == 0)
-+		goto cantfind_ext3cow;
-+	sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
-+			       le32_to_cpu(es->s_first_data_block) - 1)
-+				       / EXT3COW_BLOCKS_PER_GROUP(sb)) + 1;
-+	db_count = (sbi->s_groups_count + EXT3COW_DESC_PER_BLOCK(sb) - 1) /
-+		   EXT3COW_DESC_PER_BLOCK(sb);
-+	sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
-+				    GFP_KERNEL);
-+	if (sbi->s_group_desc == NULL) {
-+		printk (KERN_ERR "EXT3COW-fs: not enough memory\n");
-+		goto failed_mount;
-+	}
-+
-+	bgl_lock_init(&sbi->s_blockgroup_lock);
-+
-+	for (i = 0; i < db_count; i++) {
-+		block = descriptor_loc(sb, logic_sb_block, i);
-+		sbi->s_group_desc[i] = sb_bread(sb, block);
-+		if (!sbi->s_group_desc[i]) {
-+			printk (KERN_ERR "EXT3COW-fs: "
-+				"can't read group descriptor %d\n", i);
-+			db_count = i;
-+			goto failed_mount2;
-+		}
-+	}
-+	if (!ext3cow_check_descriptors (sb)) {
-+		printk(KERN_ERR "EXT3COW-fs: group descriptors corrupted!\n");
-+		goto failed_mount2;
-+	}
-+	sbi->s_gdb_count = db_count;
-+	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
-+	spin_lock_init(&sbi->s_next_gen_lock);
-+
-+	percpu_counter_init(&sbi->s_freeblocks_counter,
-+		ext3cow_count_free_blocks(sb));
-+	percpu_counter_init(&sbi->s_freeinodes_counter,
-+		ext3cow_count_free_inodes(sb));
-+	percpu_counter_init(&sbi->s_dirs_counter,
-+		ext3cow_count_dirs(sb));
-+
-+	/* per fileystem reservation list head & lock */
-+	spin_lock_init(&sbi->s_rsv_window_lock);
-+	sbi->s_rsv_window_root = RB_ROOT;
-+	/* Add a single, static dummy reservation to the start of the
-+	 * reservation window list --- it gives us a placeholder for
-+	 * append-at-start-of-list which makes the allocation logic
-+	 * _much_ simpler. */
-+	sbi->s_rsv_window_head.rsv_start = EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED;
-+	sbi->s_rsv_window_head.rsv_end = EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED;
-+	sbi->s_rsv_window_head.rsv_alloc_hit = 0;
-+	sbi->s_rsv_window_head.rsv_goal_size = 0;
-+	ext3cow_rsv_window_add(sb, &sbi->s_rsv_window_head);
-+
-+	/*
-+	 * set up enough so that it can read an inode
-+	 */
-+	sb->s_op = &ext3cow_sops;
-+	sb->s_export_op = &ext3cow_export_ops;
-+	sb->s_xattr = ext3cow_xattr_handlers;
-+#ifdef CONFIG_QUOTA
-+	sb->s_qcop = &ext3cow_qctl_operations;
-+	sb->dq_op = &ext3cow_quota_operations;
-+#endif
-+	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
-+
-+	sb->s_root = NULL;
-+
-+	needs_recovery = (es->s_last_orphan != 0 ||
-+			  EXT3COW_HAS_INCOMPAT_FEATURE(sb,
-+				    EXT3COW_FEATURE_INCOMPAT_RECOVER));
-+
-+	/*
-+	 * The first inode we look at is the journal inode.  Don't try
-+	 * root first: it may be modified in the journal!
-+	 */
-+	if (!test_opt(sb, NOLOAD) &&
-+	    EXT3COW_HAS_COMPAT_FEATURE(sb, EXT3COW_FEATURE_COMPAT_HAS_JOURNAL)) {
-+		if (ext3cow_load_journal(sb, es, journal_devnum))
-+			goto failed_mount3;
-+	} else if (journal_inum) {
-+		if (ext3cow_create_journal(sb, es, journal_inum))
-+			goto failed_mount3;
-+	} else {
-+		if (!silent)
-+			printk (KERN_ERR
-+				"ext3cow: No journal on filesystem on %s\n",
-+				sb->s_id);
-+		goto failed_mount3;
-+	}
-+
-+	/* We have now updated the journal if required, so we can
-+	 * validate the data journaling mode. */
-+	switch (test_opt(sb, DATA_FLAGS)) {
-+	case 0:
-+		/* No mode set, assume a default based on the journal
-+                   capabilities: ORDERED_DATA if the journal can
-+                   cope, else JOURNAL_DATA */
-+		if (journal_check_available_features
-+		    (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE))
-+			set_opt(sbi->s_mount_opt, ORDERED_DATA);
-+		else
-+			set_opt(sbi->s_mount_opt, JOURNAL_DATA);
-+		break;
-+
-+	case EXT3COW_MOUNT_ORDERED_DATA:
-+	case EXT3COW_MOUNT_WRITEBACK_DATA:
-+		if (!journal_check_available_features
-+		    (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) {
-+			printk(KERN_ERR "EXT3COW-fs: Journal does not support "
-+			       "requested data journaling mode\n");
-+			goto failed_mount4;
-+		}
-+	default:
-+		break;
-+	}
-+
-+	if (test_opt(sb, NOBH)) {
-+		if (!(test_opt(sb, DATA_FLAGS) == EXT3COW_MOUNT_WRITEBACK_DATA)) {
-+			printk(KERN_WARNING "EXT3COW-fs: Ignoring nobh option - "
-+				"its supported only with writeback mode\n");
-+			clear_opt(sbi->s_mount_opt, NOBH);
-+		}
-+	}
-+	/*
-+	 * The journal_load will have done any necessary log recovery,
-+	 * so we can safely mount the rest of the filesystem now.
-+	 */
-+
-+	root = iget(sb, EXT3COW_ROOT_INO);
-+	sb->s_root = d_alloc_root(root);
-+	if (!sb->s_root) {
-+		printk(KERN_ERR "EXT3COW-fs: get root inode failed\n");
-+		iput(root);
-+		goto failed_mount4;
-+	}
-+	if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
-+		dput(sb->s_root);
-+		sb->s_root = NULL;
-+		printk(KERN_ERR "EXT3COW-fs: corrupt root inode, run e2fsck\n");
-+		goto failed_mount4;
-+	}
-+
-+	ext3cow_setup_super (sb, es, sb->s_flags & MS_RDONLY);
-+	/*
-+	 * akpm: core read_super() calls in here with the superblock locked.
-+	 * That deadlocks, because orphan cleanup needs to lock the superblock
-+	 * in numerous places.  Here we just pop the lock - it's relatively
-+	 * harmless, because we are now ready to accept write_super() requests,
-+	 * and aviro says that's the only reason for hanging onto the
-+	 * superblock lock.
-+	 */
-+	EXT3COW_SB(sb)->s_mount_state |= EXT3COW_ORPHAN_FS;
-+	ext3cow_orphan_cleanup(sb, es);
-+	EXT3COW_SB(sb)->s_mount_state &= ~EXT3COW_ORPHAN_FS;
-+	if (needs_recovery)
-+		printk (KERN_INFO "EXT3COW-fs: recovery complete.\n");
-+	ext3cow_mark_recovery_complete(sb, es);
-+	printk (KERN_INFO "EXT3COW-fs: mounted filesystem with %s data mode.\n",
-+		test_opt(sb,DATA_FLAGS) == EXT3COW_MOUNT_JOURNAL_DATA ? "journal":
-+		test_opt(sb,DATA_FLAGS) == EXT3COW_MOUNT_ORDERED_DATA ? "ordered":
-+		"writeback");
-+
-+	lock_kernel();
-+	return 0;
-+
-+cantfind_ext3cow:
-+	if (!silent)
-+		printk(KERN_ERR "VFS: Can't find ext3cow filesystem on dev %s.\n",
-+		       sb->s_id);
-+	goto failed_mount;
-+
-+failed_mount4:
-+	journal_destroy(sbi->s_journal);
-+failed_mount3:
-+	percpu_counter_destroy(&sbi->s_freeblocks_counter);
-+	percpu_counter_destroy(&sbi->s_freeinodes_counter);
-+	percpu_counter_destroy(&sbi->s_dirs_counter);
-+failed_mount2:
-+	for (i = 0; i < db_count; i++)
-+		brelse(sbi->s_group_desc[i]);
-+	kfree(sbi->s_group_desc);
-+failed_mount:
-+#ifdef CONFIG_QUOTA
-+	for (i = 0; i < MAXQUOTAS; i++)
-+		kfree(sbi->s_qf_names[i]);
-+#endif
-+	ext3cow_blkdev_remove(sbi);
-+	brelse(bh);
-+out_fail:
-+	sb->s_fs_info = NULL;
-+	kfree(sbi);
-+	lock_kernel();
-+	return -EINVAL;
-+}
-+
-+/*
-+ * Setup any per-fs journal parameters now.  We'll do this both on
-+ * initial mount, once the journal has been initialised but before we've
-+ * done any recovery; and again on any subsequent remount.
-+ */
-+static void ext3cow_init_journal_params(struct super_block *sb, journal_t *journal)
-+{
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+
-+	if (sbi->s_commit_interval)
-+		journal->j_commit_interval = sbi->s_commit_interval;
-+	/* We could also set up an ext3cow-specific default for the commit
-+	 * interval here, but for now we'll just fall back to the jbd
-+	 * default. */
-+
-+	spin_lock(&journal->j_state_lock);
-+	if (test_opt(sb, BARRIER))
-+		journal->j_flags |= JFS_BARRIER;
-+	else
-+		journal->j_flags &= ~JFS_BARRIER;
-+	spin_unlock(&journal->j_state_lock);
-+}
-+
-+static journal_t *ext3cow_get_journal(struct super_block *sb,
-+				   unsigned int journal_inum)
-+{
-+	struct inode *journal_inode;
-+	journal_t *journal;
-+
-+	/* First, test for the existence of a valid inode on disk.  Bad
-+	 * things happen if we iget() an unused inode, as the subsequent
-+	 * iput() will try to delete it. */
-+
-+	journal_inode = iget(sb, journal_inum);
-+	if (!journal_inode) {
-+		printk(KERN_ERR "EXT3COW-fs: no journal found.\n");
-+		return NULL;
-+	}
-+	if (!journal_inode->i_nlink) {
-+		make_bad_inode(journal_inode);
-+		iput(journal_inode);
-+		printk(KERN_ERR "EXT3COW-fs: journal inode is deleted.\n");
-+		return NULL;
-+	}
-+
-+	jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
-+		  journal_inode, journal_inode->i_size);
-+	if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) {
-+		printk(KERN_ERR "EXT3COW-fs: invalid journal inode.\n");
-+		iput(journal_inode);
-+		return NULL;
-+	}
-+
-+	journal = journal_init_inode(journal_inode);
-+	if (!journal) {
-+		printk(KERN_ERR "EXT3COW-fs: Could not load journal inode\n");
-+		iput(journal_inode);
-+		return NULL;
-+	}
-+  /* Make sure the journal never gets versioned -znjp */
-+  EXT3COW_I(journal_inode)->i_flags |= EXT3COW_UNVERSIONABLE_FL;
-+	journal->j_private = sb;
-+	ext3cow_init_journal_params(sb, journal);
-+	return journal;
-+}
-+
-+static journal_t *ext3cow_get_dev_journal(struct super_block *sb,
-+				       dev_t j_dev)
-+{
-+	struct buffer_head * bh;
-+	journal_t *journal;
-+	ext3cow_fsblk_t start;
-+	ext3cow_fsblk_t len;
-+	int hblock, blocksize;
-+	ext3cow_fsblk_t sb_block;
-+	unsigned long offset;
-+	struct ext3cow_super_block * es;
-+	struct block_device *bdev;
-+
-+	bdev = ext3cow_blkdev_get(j_dev);
-+	if (bdev == NULL)
-+		return NULL;
-+
-+	if (bd_claim(bdev, sb)) {
-+		printk(KERN_ERR
-+		        "EXT3COW: failed to claim external journal device.\n");
-+		blkdev_put(bdev);
-+		return NULL;
-+	}
-+
-+	blocksize = sb->s_blocksize;
-+	hblock = bdev_hardsect_size(bdev);
-+	if (blocksize < hblock) {
-+		printk(KERN_ERR
-+			"EXT3COW-fs: blocksize too small for journal device.\n");
-+		goto out_bdev;
-+	}
-+
-+	sb_block = EXT3COW_MIN_BLOCK_SIZE / blocksize;
-+	offset = EXT3COW_MIN_BLOCK_SIZE % blocksize;
-+	set_blocksize(bdev, blocksize);
-+	if (!(bh = __bread(bdev, sb_block, blocksize))) {
-+		printk(KERN_ERR "EXT3COW-fs: couldn't read superblock of "
-+		       "external journal\n");
-+		goto out_bdev;
-+	}
-+
-+	es = (struct ext3cow_super_block *) (((char *)bh->b_data) + offset);
-+	if ((le16_to_cpu(es->s_magic) != EXT3COW_SUPER_MAGIC) ||
-+	    !(le32_to_cpu(es->s_feature_incompat) &
-+	      EXT3COW_FEATURE_INCOMPAT_JOURNAL_DEV)) {
-+		printk(KERN_ERR "EXT3COW-fs: external journal has "
-+					"bad superblock\n");
-+		brelse(bh);
-+		goto out_bdev;
-+	}
-+
-+	if (memcmp(EXT3COW_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) {
-+		printk(KERN_ERR "EXT3COW-fs: journal UUID does not match\n");
-+		brelse(bh);
-+		goto out_bdev;
-+	}
-+
-+	len = le32_to_cpu(es->s_blocks_count);
-+	start = sb_block + 1;
-+	brelse(bh);	/* we're done with the superblock */
-+
-+	journal = journal_init_dev(bdev, sb->s_bdev,
-+					start, len, blocksize);
-+	if (!journal) {
-+		printk(KERN_ERR "EXT3COW-fs: failed to create device journal\n");
-+		goto out_bdev;
-+	}
-+	journal->j_private = sb;
-+	ll_rw_block(READ, 1, &journal->j_sb_buffer);
-+	wait_on_buffer(journal->j_sb_buffer);
-+	if (!buffer_uptodate(journal->j_sb_buffer)) {
-+		printk(KERN_ERR "EXT3COW-fs: I/O error on journal device\n");
-+		goto out_journal;
-+	}
-+	if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) {
-+		printk(KERN_ERR "EXT3COW-fs: External journal has more than one "
-+					"user (unsupported) - %d\n",
-+			be32_to_cpu(journal->j_superblock->s_nr_users));
-+		goto out_journal;
-+	}
-+	EXT3COW_SB(sb)->journal_bdev = bdev;
-+	ext3cow_init_journal_params(sb, journal);
-+	return journal;
-+out_journal:
-+	journal_destroy(journal);
-+out_bdev:
-+	ext3cow_blkdev_put(bdev);
-+	return NULL;
-+}
-+
-+static int ext3cow_load_journal(struct super_block *sb,
-+			     struct ext3cow_super_block *es,
-+			     unsigned long journal_devnum)
-+{
-+	journal_t *journal;
-+	unsigned int journal_inum = le32_to_cpu(es->s_journal_inum);
-+	dev_t journal_dev;
-+	int err = 0;
-+	int really_read_only;
-+
-+	if (journal_devnum &&
-+	    journal_devnum != le32_to_cpu(es->s_journal_dev)) {
-+		printk(KERN_INFO "EXT3COW-fs: external journal device major/minor "
-+			"numbers have changed\n");
-+		journal_dev = new_decode_dev(journal_devnum);
-+	} else
-+		journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev));
-+
-+	really_read_only = bdev_read_only(sb->s_bdev);
-+
-+	/*
-+	 * Are we loading a blank journal or performing recovery after a
-+	 * crash?  For recovery, we need to check in advance whether we
-+	 * can get read-write access to the device.
-+	 */
-+
-+	if (EXT3COW_HAS_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER)) {
-+		if (sb->s_flags & MS_RDONLY) {
-+			printk(KERN_INFO "EXT3COW-fs: INFO: recovery "
-+					"required on readonly filesystem.\n");
-+			if (really_read_only) {
-+				printk(KERN_ERR "EXT3COW-fs: write access "
-+					"unavailable, cannot proceed.\n");
-+				return -EROFS;
-+			}
-+			printk (KERN_INFO "EXT3COW-fs: write access will "
-+					"be enabled during recovery.\n");
-+		}
-+	}
-+
-+	if (journal_inum && journal_dev) {
-+		printk(KERN_ERR "EXT3COW-fs: filesystem has both journal "
-+		       "and inode journals!\n");
-+		return -EINVAL;
-+	}
-+
-+	if (journal_inum) {
-+		if (!(journal = ext3cow_get_journal(sb, journal_inum)))
-+			return -EINVAL;
-+	} else {
-+		if (!(journal = ext3cow_get_dev_journal(sb, journal_dev)))
-+			return -EINVAL;
-+	}
-+
-+	if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
-+		err = journal_update_format(journal);
-+		if (err)  {
-+			printk(KERN_ERR "EXT3COW-fs: error updating journal.\n");
-+			journal_destroy(journal);
-+			return err;
-+		}
-+	}
-+
-+	if (!EXT3COW_HAS_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER))
-+		err = journal_wipe(journal, !really_read_only);
-+	if (!err)
-+		err = journal_load(journal);
-+
-+	if (err) {
-+		printk(KERN_ERR "EXT3COW-fs: error loading journal.\n");
-+		journal_destroy(journal);
-+		return err;
-+	}
-+
-+	EXT3COW_SB(sb)->s_journal = journal;
-+	ext3cow_clear_journal_err(sb, es);
-+
-+	if (journal_devnum &&
-+	    journal_devnum != le32_to_cpu(es->s_journal_dev)) {
-+		es->s_journal_dev = cpu_to_le32(journal_devnum);
-+		sb->s_dirt = 1;
-+
-+		/* Make sure we flush the recovery flag to disk. */
-+		ext3cow_commit_super(sb, es, 1);
-+	}
-+
-+	return 0;
-+}
-+
-+static int ext3cow_create_journal(struct super_block * sb,
-+			       struct ext3cow_super_block * es,
-+			       unsigned int journal_inum)
-+{
-+	journal_t *journal;
-+
-+	if (sb->s_flags & MS_RDONLY) {
-+		printk(KERN_ERR "EXT3COW-fs: readonly filesystem when trying to "
-+				"create journal.\n");
-+		return -EROFS;
-+	}
-+
-+	if (!(journal = ext3cow_get_journal(sb, journal_inum)))
-+		return -EINVAL;
-+
-+	printk(KERN_INFO "EXT3COW-fs: creating new journal on inode %u\n",
-+	       journal_inum);
-+
-+	if (journal_create(journal)) {
-+		printk(KERN_ERR "EXT3COW-fs: error creating journal.\n");
-+		journal_destroy(journal);
-+		return -EIO;
-+	}
-+
-+	EXT3COW_SB(sb)->s_journal = journal;
-+
-+	ext3cow_update_dynamic_rev(sb);
-+	EXT3COW_SET_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER);
-+	EXT3COW_SET_COMPAT_FEATURE(sb, EXT3COW_FEATURE_COMPAT_HAS_JOURNAL);
-+
-+	es->s_journal_inum = cpu_to_le32(journal_inum);
-+	sb->s_dirt = 1;
-+
-+	/* Make sure we flush the recovery flag to disk. */
-+	ext3cow_commit_super(sb, es, 1);
-+
-+	return 0;
-+}
-+
-+static void ext3cow_commit_super (struct super_block * sb,
-+			       struct ext3cow_super_block * es,
-+			       int sync)
-+{
-+	struct buffer_head *sbh = EXT3COW_SB(sb)->s_sbh;
-+
-+	if (!sbh)
-+		return;
-+	es->s_wtime = cpu_to_le32(get_seconds());
-+	es->s_free_blocks_count = cpu_to_le32(ext3cow_count_free_blocks(sb));
-+	es->s_free_inodes_count = cpu_to_le32(ext3cow_count_free_inodes(sb));
-+	BUFFER_TRACE(sbh, "marking dirty");
-+	mark_buffer_dirty(sbh);
-+	if (sync)
-+		sync_dirty_buffer(sbh);
-+}
-+
-+
-+/*
-+ * Have we just finished recovery?  If so, and if we are mounting (or
-+ * remounting) the filesystem readonly, then we will end up with a
-+ * consistent fs on disk.  Record that fact.
-+ */
-+static void ext3cow_mark_recovery_complete(struct super_block * sb,
-+					struct ext3cow_super_block * es)
-+{
-+	journal_t *journal = EXT3COW_SB(sb)->s_journal;
-+
-+	journal_lock_updates(journal);
-+	journal_flush(journal);
-+	if (EXT3COW_HAS_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER) &&
-+	    sb->s_flags & MS_RDONLY) {
-+		EXT3COW_CLEAR_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER);
-+		sb->s_dirt = 0;
-+		ext3cow_commit_super(sb, es, 1);
-+	}
-+	journal_unlock_updates(journal);
-+}
-+
-+/*
-+ * If we are mounting (or read-write remounting) a filesystem whose journal
-+ * has recorded an error from a previous lifetime, move that error to the
-+ * main filesystem now.
-+ */
-+static void ext3cow_clear_journal_err(struct super_block * sb,
-+				   struct ext3cow_super_block * es)
-+{
-+	journal_t *journal;
-+	int j_errno;
-+	const char *errstr;
-+
-+	journal = EXT3COW_SB(sb)->s_journal;
-+
-+	/*
-+	 * Now check for any error status which may have been recorded in the
-+	 * journal by a prior ext3cow_error() or ext3cow_abort()
-+	 */
-+
-+	j_errno = journal_errno(journal);
-+	if (j_errno) {
-+		char nbuf[16];
-+
-+		errstr = ext3cow_decode_error(sb, j_errno, nbuf);
-+		ext3cow_warning(sb, __FUNCTION__, "Filesystem error recorded "
-+			     "from previous mount: %s", errstr);
-+		ext3cow_warning(sb, __FUNCTION__, "Marking fs in need of "
-+			     "filesystem check.");
-+
-+		EXT3COW_SB(sb)->s_mount_state |= EXT3COW_ERROR_FS;
-+		es->s_state |= cpu_to_le16(EXT3COW_ERROR_FS);
-+		ext3cow_commit_super (sb, es, 1);
-+
-+		journal_clear_err(journal);
-+	}
-+}
-+
-+/*
-+ * Force the running and committing transactions to commit,
-+ * and wait on the commit.
-+ */
-+int ext3cow_force_commit(struct super_block *sb)
-+{
-+	journal_t *journal;
-+	int ret;
-+
-+	if (sb->s_flags & MS_RDONLY)
-+		return 0;
-+
-+	journal = EXT3COW_SB(sb)->s_journal;
-+	sb->s_dirt = 0;
-+	ret = ext3cow_journal_force_commit(journal);
-+	return ret;
-+}
-+
-+/*
-+ * Ext3 always journals updates to the superblock itself, so we don't
-+ * have to propagate any other updates to the superblock on disk at this
-+ * point.  Just start an async writeback to get the buffers on their way
-+ * to the disk.
-+ *
-+ * This implicitly triggers the writebehind on sync().
-+ */
-+
-+static void ext3cow_write_super (struct super_block * sb)
-+{
-+	if (mutex_trylock(&sb->s_lock) != 0)
-+		BUG();
-+	sb->s_dirt = 0;
-+}
-+
-+static int ext3cow_sync_fs(struct super_block *sb, int wait)
-+{
-+	tid_t target;
-+
-+	sb->s_dirt = 0;
-+	if (journal_start_commit(EXT3COW_SB(sb)->s_journal, &target)) {
-+		if (wait)
-+			log_wait_commit(EXT3COW_SB(sb)->s_journal, target);
-+	}
-+	return 0;
-+}
-+
-+/*
-+ * LVM calls this function before a (read-only) snapshot is created.  This
-+ * gives us a chance to flush the journal completely and mark the fs clean.
-+ */
-+static void ext3cow_write_super_lockfs(struct super_block *sb)
-+{
-+	sb->s_dirt = 0;
-+
-+	if (!(sb->s_flags & MS_RDONLY)) {
-+		journal_t *journal = EXT3COW_SB(sb)->s_journal;
-+
-+		/* Now we set up the journal barrier. */
-+		journal_lock_updates(journal);
-+		journal_flush(journal);
-+
-+		/* Journal blocked and flushed, clear needs_recovery flag. */
-+		EXT3COW_CLEAR_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER);
-+		ext3cow_commit_super(sb, EXT3COW_SB(sb)->s_es, 1);
-+	}
-+}
-+
-+/*
-+ * Called by LVM after the snapshot is done.  We need to reset the RECOVER
-+ * flag here, even though the filesystem is not technically dirty yet.
-+ */
-+static void ext3cow_unlockfs(struct super_block *sb)
-+{
-+	if (!(sb->s_flags & MS_RDONLY)) {
-+		lock_super(sb);
-+		/* Reser the needs_recovery flag before the fs is unlocked. */
-+		EXT3COW_SET_INCOMPAT_FEATURE(sb, EXT3COW_FEATURE_INCOMPAT_RECOVER);
-+		ext3cow_commit_super(sb, EXT3COW_SB(sb)->s_es, 1);
-+		unlock_super(sb);
-+		journal_unlock_updates(EXT3COW_SB(sb)->s_journal);
-+	}
-+}
-+
-+static int ext3cow_remount (struct super_block * sb, int * flags, char * data)
-+{
-+	struct ext3cow_super_block * es;
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	ext3cow_fsblk_t n_blocks_count = 0;
-+	unsigned long old_sb_flags;
-+	struct ext3cow_mount_options old_opts;
-+	int err;
-+#ifdef CONFIG_QUOTA
-+	int i;
-+#endif
-+
-+	/* Store the original options */
-+	old_sb_flags = sb->s_flags;
-+	old_opts.s_mount_opt = sbi->s_mount_opt;
-+	old_opts.s_resuid = sbi->s_resuid;
-+	old_opts.s_resgid = sbi->s_resgid;
-+	old_opts.s_commit_interval = sbi->s_commit_interval;
-+#ifdef CONFIG_QUOTA
-+	old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
-+	for (i = 0; i < MAXQUOTAS; i++)
-+		old_opts.s_qf_names[i] = sbi->s_qf_names[i];
-+#endif
-+
-+	/*
-+	 * Allow the "check" option to be passed as a remount option.
-+	 */
-+	if (!parse_options(data, sb, NULL, NULL, &n_blocks_count, 1)) {
-+		err = -EINVAL;
-+		goto restore_opts;
-+	}
-+
-+	if (sbi->s_mount_opt & EXT3COW_MOUNT_ABORT)
-+		ext3cow_abort(sb, __FUNCTION__, "Abort forced by user");
-+
-+	sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
-+		((sbi->s_mount_opt & EXT3COW_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
-+
-+	es = sbi->s_es;
-+
-+	ext3cow_init_journal_params(sb, sbi->s_journal);
-+
-+	if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
-+		n_blocks_count > le32_to_cpu(es->s_blocks_count)) {
-+		if (sbi->s_mount_opt & EXT3COW_MOUNT_ABORT) {
-+			err = -EROFS;
-+			goto restore_opts;
-+		}
-+
-+		if (*flags & MS_RDONLY) {
-+			/*
-+			 * First of all, the unconditional stuff we have to do
-+			 * to disable replay of the journal when we next remount
-+			 */
-+			sb->s_flags |= MS_RDONLY;
-+
-+			/*
-+			 * OK, test if we are remounting a valid rw partition
-+			 * readonly, and if so set the rdonly flag and then
-+			 * mark the partition as valid again.
-+			 */
-+			if (!(es->s_state & cpu_to_le16(EXT3COW_VALID_FS)) &&
-+			    (sbi->s_mount_state & EXT3COW_VALID_FS))
-+				es->s_state = cpu_to_le16(sbi->s_mount_state);
-+
-+			ext3cow_mark_recovery_complete(sb, es);
-+		} else {
-+			__le32 ret;
-+			if ((ret = EXT3COW_HAS_RO_COMPAT_FEATURE(sb,
-+					~EXT3COW_FEATURE_RO_COMPAT_SUPP))) {
-+				printk(KERN_WARNING "EXT3COW-fs: %s: couldn't "
-+				       "remount RDWR because of unsupported "
-+				       "optional features (%x).\n",
-+				       sb->s_id, le32_to_cpu(ret));
-+				err = -EROFS;
-+				goto restore_opts;
-+			}
-+			/*
-+			 * Mounting a RDONLY partition read-write, so reread
-+			 * and store the current valid flag.  (It may have
-+			 * been changed by e2fsck since we originally mounted
-+			 * the partition.)
-+			 */
-+			ext3cow_clear_journal_err(sb, es);
-+			sbi->s_mount_state = le16_to_cpu(es->s_state);
-+			if ((err = ext3cow_group_extend(sb, es, n_blocks_count)))
-+				goto restore_opts;
-+			if (!ext3cow_setup_super (sb, es, 0))
-+				sb->s_flags &= ~MS_RDONLY;
-+		}
-+	}
-+#ifdef CONFIG_QUOTA
-+	/* Release old quota file names */
-+	for (i = 0; i < MAXQUOTAS; i++)
-+		if (old_opts.s_qf_names[i] &&
-+		    old_opts.s_qf_names[i] != sbi->s_qf_names[i])
-+			kfree(old_opts.s_qf_names[i]);
-+#endif
-+	return 0;
-+restore_opts:
-+	sb->s_flags = old_sb_flags;
-+	sbi->s_mount_opt = old_opts.s_mount_opt;
-+	sbi->s_resuid = old_opts.s_resuid;
-+	sbi->s_resgid = old_opts.s_resgid;
-+	sbi->s_commit_interval = old_opts.s_commit_interval;
-+#ifdef CONFIG_QUOTA
-+	sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
-+	for (i = 0; i < MAXQUOTAS; i++) {
-+		if (sbi->s_qf_names[i] &&
-+		    old_opts.s_qf_names[i] != sbi->s_qf_names[i])
-+			kfree(sbi->s_qf_names[i]);
-+		sbi->s_qf_names[i] = old_opts.s_qf_names[i];
-+	}
-+#endif
-+	return err;
-+}
-+
-+static int ext3cow_statfs (struct dentry * dentry, struct kstatfs * buf)
-+{
-+	struct super_block *sb = dentry->d_sb;
-+	struct ext3cow_sb_info *sbi = EXT3COW_SB(sb);
-+	struct ext3cow_super_block *es = sbi->s_es;
-+	ext3cow_fsblk_t overhead;
-+	int i;
-+	u64 fsid;
-+
-+	if (test_opt (sb, MINIX_DF))
-+		overhead = 0;
-+	else {
-+		unsigned long ngroups;
-+		ngroups = EXT3COW_SB(sb)->s_groups_count;
-+		smp_rmb();
-+
-+		/*
-+		 * Compute the overhead (FS structures)
-+		 */
-+
-+		/*
-+		 * All of the blocks before first_data_block are
-+		 * overhead
-+		 */
-+		overhead = le32_to_cpu(es->s_first_data_block);
-+
-+		/*
-+		 * Add the overhead attributed to the superblock and
-+		 * block group descriptors.  If the sparse superblocks
-+		 * feature is turned on, then not all groups have this.
-+		 */
-+		for (i = 0; i < ngroups; i++) {
-+			overhead += ext3cow_bg_has_super(sb, i) +
-+				ext3cow_bg_num_gdb(sb, i);
-+			cond_resched();
-+		}
-+
-+		/*
-+		 * Every block group has an inode bitmap, a block
-+		 * bitmap, and an inode table.
-+		 */
-+		overhead += (ngroups * (2 + EXT3COW_SB(sb)->s_itb_per_group));
-+	}
-+
-+	buf->f_type = EXT3COW_SUPER_MAGIC;
-+	buf->f_bsize = sb->s_blocksize;
-+	buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
-+	buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter);
-+	buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
-+	if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
-+		buf->f_bavail = 0;
-+	buf->f_files = le32_to_cpu(es->s_inodes_count);
-+	buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
-+	buf->f_namelen = EXT3COW_NAME_LEN;
-+	fsid = le64_to_cpup((void *)es->s_uuid) ^
-+	       le64_to_cpup((void *)es->s_uuid + sizeof(u64));
-+	buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
-+	buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
-+	return 0;
-+}
-+
-+/* Helper function for writing quotas on sync - we need to start transaction before quota file
-+ * is locked for write. Otherwise the are possible deadlocks:
-+ * Process 1                         Process 2
-+ * ext3cow_create()                     quota_sync()
-+ *   journal_start()                   write_dquot()
-+ *   DQUOT_INIT()                        down(dqio_mutex)
-+ *     down(dqio_mutex)                    journal_start()
-+ *
-+ */
-+
-+#ifdef CONFIG_QUOTA
-+
-+static inline struct inode *dquot_to_inode(struct dquot *dquot)
-+{
-+	return sb_dqopt(dquot->dq_sb)->files[dquot->dq_type];
-+}
-+
-+static int ext3cow_dquot_initialize(struct inode *inode, int type)
-+{
-+	handle_t *handle;
-+	int ret, err;
-+
-+	/* We may create quota structure so we need to reserve enough blocks */
-+	handle = ext3cow_journal_start(inode, 2*EXT3COW_QUOTA_INIT_BLOCKS(inode->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+	ret = dquot_initialize(inode, type);
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+}
-+
-+static int ext3cow_dquot_drop(struct inode *inode)
-+{
-+	handle_t *handle;
-+	int ret, err;
-+
-+	/* We may delete quota structure so we need to reserve enough blocks */
-+	handle = ext3cow_journal_start(inode, 2*EXT3COW_QUOTA_DEL_BLOCKS(inode->i_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+	ret = dquot_drop(inode);
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+}
-+
-+static int ext3cow_write_dquot(struct dquot *dquot)
-+{
-+	int ret, err;
-+	handle_t *handle;
-+	struct inode *inode;
-+
-+	inode = dquot_to_inode(dquot);
-+	handle = ext3cow_journal_start(inode,
-+					EXT3COW_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+	ret = dquot_commit(dquot);
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+}
-+
-+static int ext3cow_acquire_dquot(struct dquot *dquot)
-+{
-+	int ret, err;
-+	handle_t *handle;
-+
-+	handle = ext3cow_journal_start(dquot_to_inode(dquot),
-+					EXT3COW_QUOTA_INIT_BLOCKS(dquot->dq_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+	ret = dquot_acquire(dquot);
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+}
-+
-+static int ext3cow_release_dquot(struct dquot *dquot)
-+{
-+	int ret, err;
-+	handle_t *handle;
-+
-+	handle = ext3cow_journal_start(dquot_to_inode(dquot),
-+					EXT3COW_QUOTA_DEL_BLOCKS(dquot->dq_sb));
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+	ret = dquot_release(dquot);
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+}
-+
-+static int ext3cow_mark_dquot_dirty(struct dquot *dquot)
-+{
-+	/* Are we journalling quotas? */
-+	if (EXT3COW_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
-+	    EXT3COW_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
-+		dquot_mark_dquot_dirty(dquot);
-+		return ext3cow_write_dquot(dquot);
-+	} else {
-+		return dquot_mark_dquot_dirty(dquot);
-+	}
-+}
-+
-+static int ext3cow_write_info(struct super_block *sb, int type)
-+{
-+	int ret, err;
-+	handle_t *handle;
-+
-+	/* Data block + inode block */
-+	handle = ext3cow_journal_start(sb->s_root->d_inode, 2);
-+	if (IS_ERR(handle))
-+		return PTR_ERR(handle);
-+	ret = dquot_commit_info(sb, type);
-+	err = ext3cow_journal_stop(handle);
-+	if (!ret)
-+		ret = err;
-+	return ret;
-+}
-+
-+/*
-+ * Turn on quotas during mount time - we need to find
-+ * the quota file and such...
-+ */
-+static int ext3cow_quota_on_mount(struct super_block *sb, int type)
-+{
-+	return vfs_quota_on_mount(sb, EXT3COW_SB(sb)->s_qf_names[type],
-+			EXT3COW_SB(sb)->s_jquota_fmt, type);
-+}
-+
-+/*
-+ * Standard function to be called on quota_on
-+ */
-+static int ext3cow_quota_on(struct super_block *sb, int type, int format_id,
-+			 char *path)
-+{
-+	int err;
-+	struct nameidata nd;
-+
-+	if (!test_opt(sb, QUOTA))
-+		return -EINVAL;
-+	/* Not journalling quota? */
-+	if (!EXT3COW_SB(sb)->s_qf_names[USRQUOTA] &&
-+	    !EXT3COW_SB(sb)->s_qf_names[GRPQUOTA])
-+		return vfs_quota_on(sb, type, format_id, path);
-+	err = path_lookup(path, LOOKUP_FOLLOW, &nd);
-+	if (err)
-+		return err;
-+	/* Quotafile not on the same filesystem? */
-+	if (nd.mnt->mnt_sb != sb) {
-+		path_release(&nd);
-+		return -EXDEV;
-+	}
-+	/* Quotafile not of fs root? */
-+	if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
-+		printk(KERN_WARNING
-+			"EXT3COW-fs: Quota file not on filesystem root. "
-+			"Journalled quota will not work.\n");
-+	path_release(&nd);
-+	return vfs_quota_on(sb, type, format_id, path);
-+}
-+
-+/* Read data from quotafile - avoid pagecache and such because we cannot afford
-+ * acquiring the locks... As quota files are never truncated and quota code
-+ * itself serializes the operations (and noone else should touch the files)
-+ * we don't have to be afraid of races */
-+static ssize_t ext3cow_quota_read(struct super_block *sb, int type, char *data,
-+			       size_t len, loff_t off)
-+{
-+	struct inode *inode = sb_dqopt(sb)->files[type];
-+	sector_t blk = off >> EXT3COW_BLOCK_SIZE_BITS(sb);
-+	int err = 0;
-+	int offset = off & (sb->s_blocksize - 1);
-+	int tocopy;
-+	size_t toread;
-+	struct buffer_head *bh;
-+	loff_t i_size = i_size_read(inode);
-+
-+	if (off > i_size)
-+		return 0;
-+	if (off+len > i_size)
-+		len = i_size-off;
-+	toread = len;
-+	while (toread > 0) {
-+		tocopy = sb->s_blocksize - offset < toread ?
-+				sb->s_blocksize - offset : toread;
-+		bh = ext3cow_bread(NULL, inode, blk, 0, &err);
-+		if (err)
-+			return err;
-+		if (!bh)	/* A hole? */
-+			memset(data, 0, tocopy);
-+		else
-+			memcpy(data, bh->b_data+offset, tocopy);
-+		brelse(bh);
-+		offset = 0;
-+		toread -= tocopy;
-+		data += tocopy;
-+		blk++;
-+	}
-+	return len;
-+}
-+
-+/* Write to quotafile (we know the transaction is already started and has
-+ * enough credits) */
-+static ssize_t ext3cow_quota_write(struct super_block *sb, int type,
-+				const char *data, size_t len, loff_t off)
-+{
-+	struct inode *inode = sb_dqopt(sb)->files[type];
-+	sector_t blk = off >> EXT3COW_BLOCK_SIZE_BITS(sb);
-+	int err = 0;
-+	int offset = off & (sb->s_blocksize - 1);
-+	int tocopy;
-+	int journal_quota = EXT3COW_SB(sb)->s_qf_names[type] != NULL;
-+	size_t towrite = len;
-+	struct buffer_head *bh;
-+	handle_t *handle = journal_current_handle();
-+
-+	mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
-+	while (towrite > 0) {
-+		tocopy = sb->s_blocksize - offset < towrite ?
-+				sb->s_blocksize - offset : towrite;
-+		bh = ext3cow_bread(handle, inode, blk, 1, &err);
-+		if (!bh)
-+			goto out;
-+		if (journal_quota) {
-+			err = ext3cow_journal_get_write_access(handle, bh);
-+			if (err) {
-+				brelse(bh);
-+				goto out;
-+			}
-+		}
-+		lock_buffer(bh);
-+		memcpy(bh->b_data+offset, data, tocopy);
-+		flush_dcache_page(bh->b_page);
-+		unlock_buffer(bh);
-+		if (journal_quota)
-+			err = ext3cow_journal_dirty_metadata(handle, bh);
-+		else {
-+			/* Always do at least ordered writes for quotas */
-+			err = ext3cow_journal_dirty_data(handle, bh);
-+			mark_buffer_dirty(bh);
-+		}
-+		brelse(bh);
-+		if (err)
-+			goto out;
-+		offset = 0;
-+		towrite -= tocopy;
-+		data += tocopy;
-+		blk++;
-+	}
-+out:
-+	if (len == towrite)
-+		return err;
-+	if (inode->i_size < off+len-towrite) {
-+		i_size_write(inode, off+len-towrite);
-+		EXT3COW_I(inode)->i_disksize = inode->i_size;
-+	}
-+	inode->i_version++;
-+	inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-+	ext3cow_mark_inode_dirty(handle, inode);
-+	mutex_unlock(&inode->i_mutex);
-+	return len - towrite;
-+}
-+
-+#endif
-+
-+static int ext3cow_get_sb(struct file_system_type *fs_type,
-+	int flags, const char *dev_name, void *data, struct vfsmount *mnt)
-+{
-+	return get_sb_bdev(fs_type, flags, dev_name, data, ext3cow_fill_super, mnt);
-+}
-+
-+/* Code to update the epoch counter in the super block -znjp */
-+unsigned int ext3cow_take_snapshot(struct super_block *sb){
-+
-+  struct ext3cow_sb_info *sbi = NULL;
-+  struct ext3cow_super_block *es = NULL;
-+  tid_t target;
-+
-+  if(NULL == sb){
-+    printk("EXT3COW-fs: superblock is NULL when taking snapshot.\n");
-+    return -1;
-+  }
-+
-+  sbi = EXT3COW_SB(sb);
-+  es = sbi->s_es;
-+
-+  /* Sync the dirty blocks */
-+  if (journal_start_commit(EXT3COW_SB(sb)->s_journal, &target)) {
-+    log_wait_commit(EXT3COW_SB(sb)->s_journal, target);
-+	}
-+  
-+
-+  sbi->s_epoch_number = cpu_to_le32(get_seconds());
-+  es->s_epoch_number = sbi->s_epoch_number;
-+  sb->s_dirt = 1;
-+
-+  BUFFER_TRACE(EXT3COW_SB(sb)->s_sbh, "marking dirty");
-+  mark_buffer_dirty(sbi->s_sbh);
-+  ext3cow_commit_super (sb, es, 1);
-+
-+  return (unsigned int)sbi->s_epoch_number;
-+}
-+
-+static struct file_system_type ext3cow_fs_type = {
-+	.owner		= THIS_MODULE,
-+	.name		= "ext3cow",
-+	.get_sb		= ext3cow_get_sb,
-+	.kill_sb	= kill_block_super,
-+	.fs_flags	= FS_REQUIRES_DEV,
-+};
-+
-+static int __init init_ext3cow_fs(void)
-+{
-+	int err = init_ext3cow_xattr();
-+	if (err)
-+		return err;
-+	err = init_inodecache();
-+	if (err)
-+		goto out1;
-+        err = register_filesystem(&ext3cow_fs_type);
-+	if (err)
-+		goto out;
-+	return 0;
-+out:
-+	destroy_inodecache();
-+out1:
-+	exit_ext3cow_xattr();
-+	return err;
-+}
-+
-+static void __exit exit_ext3cow_fs(void)
-+{
-+	unregister_filesystem(&ext3cow_fs_type);
-+	destroy_inodecache();
-+	exit_ext3cow_xattr();
-+}
-+
-+MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
-+MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
-+MODULE_LICENSE("GPL");
-+module_init(init_ext3cow_fs)
-+module_exit(exit_ext3cow_fs)
-diff -Naur linux-2.6.21.7/fs/ext3cow/symlink.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/symlink.c
---- linux-2.6.21.7/fs/ext3cow/symlink.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/symlink.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,54 @@
-+/*
-+ *  linux/fs/ext3cow/symlink.c
-+ *
-+ * Only fast symlinks left here - the rest is done by generic code. AV, 1999
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/fs/minix/symlink.c
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ *
-+ *  ext3cow symlink handling code
-+ */
-+
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/namei.h>
-+#include "xattr.h"
-+
-+static void * ext3cow_follow_link(struct dentry *dentry, struct nameidata *nd)
-+{
-+	struct ext3cow_inode_info *ei = EXT3COW_I(dentry->d_inode);
-+	nd_set_link(nd, (char*)ei->i_data);
-+	return NULL;
-+}
-+
-+struct inode_operations ext3cow_symlink_inode_operations = {
-+	.readlink	= generic_readlink,
-+	.follow_link	= page_follow_link_light,
-+	.put_link	= page_put_link,
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+	.setxattr	= generic_setxattr,
-+	.getxattr	= generic_getxattr,
-+	.listxattr	= ext3cow_listxattr,
-+	.removexattr	= generic_removexattr,
-+#endif
-+};
-+
-+struct inode_operations ext3cow_fast_symlink_inode_operations = {
-+	.readlink	= generic_readlink,
-+	.follow_link	= ext3cow_follow_link,
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+	.setxattr	= generic_setxattr,
-+	.getxattr	= generic_getxattr,
-+	.listxattr	= ext3cow_listxattr,
-+	.removexattr	= generic_removexattr,
-+#endif
-+};
-diff -Naur linux-2.6.21.7/fs/ext3cow/xattr.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr.c
---- linux-2.6.21.7/fs/ext3cow/xattr.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,1314 @@
-+/*
-+ * linux/fs/ext3cow/xattr.c
-+ *
-+ * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
-+ *
-+ * Fix by Harrison Xing <harrison@mountainviewdata.com>.
-+ * Ext3 code with a lot of help from Eric Jarman <ejarman@acm.org>.
-+ * Extended attributes for symlinks and special files added per
-+ *  suggestion of Luka Renko <luka.renko@hermes.si>.
-+ * xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>,
-+ *  Red Hat Inc.
-+ * ea-in-inode support by Alex Tomas <alex@clusterfs.com> aka bzzz
-+ *  and Andreas Gruenbacher <agruen@suse.de>.
-+ */
-+
-+/*
-+ * Extended attributes are stored directly in inodes (on file systems with
-+ * inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl
-+ * field contains the block number if an inode uses an additional block. All
-+ * attributes must fit in the inode and one additional block. Blocks that
-+ * contain the identical set of attributes may be shared among several inodes.
-+ * Identical blocks are detected by keeping a cache of blocks that have
-+ * recently been accessed.
-+ *
-+ * The attributes in inodes and on blocks have a different header; the entries
-+ * are stored in the same format:
-+ *
-+ *   +------------------+
-+ *   | header           |
-+ *   | entry 1          | |
-+ *   | entry 2          | | growing downwards
-+ *   | entry 3          | v
-+ *   | four null bytes  |
-+ *   | . . .            |
-+ *   | value 1          | ^
-+ *   | value 3          | | growing upwards
-+ *   | value 2          | |
-+ *   +------------------+
-+ *
-+ * The header is followed by multiple entry descriptors. In disk blocks, the
-+ * entry descriptors are kept sorted. In inodes, they are unsorted. The
-+ * attribute values are aligned to the end of the block in no specific order.
-+ *
-+ * Locking strategy
-+ * ----------------
-+ * EXT3COW_I(inode)->i_file_acl is protected by EXT3COW_I(inode)->xattr_sem.
-+ * EA blocks are only changed if they are exclusive to an inode, so
-+ * holding xattr_sem also means that nothing but the EA block's reference
-+ * count can change. Multiple writers to the same block are synchronized
-+ * by the buffer lock.
-+ */
-+
-+#include <linux/init.h>
-+#include <linux/fs.h>
-+#include <linux/slab.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/mbcache.h>
-+#include <linux/quotaops.h>
-+#include <linux/rwsem.h>
-+#include "xattr.h"
-+#include "acl.h"
-+
-+#define BHDR(bh) ((struct ext3cow_xattr_header *)((bh)->b_data))
-+#define ENTRY(ptr) ((struct ext3cow_xattr_entry *)(ptr))
-+#define BFIRST(bh) ENTRY(BHDR(bh)+1)
-+#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
-+
-+#define IHDR(inode, raw_inode) \
-+	((struct ext3cow_xattr_ibody_header *) \
-+		((void *)raw_inode + \
-+		 EXT3COW_GOOD_OLD_INODE_SIZE + \
-+		 EXT3COW_I(inode)->i_extra_isize))
-+#define IFIRST(hdr) ((struct ext3cow_xattr_entry *)((hdr)+1))
-+
-+#ifdef EXT3COW_XATTR_DEBUG
-+# define ea_idebug(inode, f...) do { \
-+		printk(KERN_DEBUG "inode %s:%lu: ", \
-+			inode->i_sb->s_id, inode->i_ino); \
-+		printk(f); \
-+		printk("\n"); \
-+	} while (0)
-+# define ea_bdebug(bh, f...) do { \
-+		char b[BDEVNAME_SIZE]; \
-+		printk(KERN_DEBUG "block %s:%lu: ", \
-+			bdevname(bh->b_bdev, b), \
-+			(unsigned long) bh->b_blocknr); \
-+		printk(f); \
-+		printk("\n"); \
-+	} while (0)
-+#else
-+# define ea_idebug(f...)
-+# define ea_bdebug(f...)
-+#endif
-+
-+static void ext3cow_xattr_cache_insert(struct buffer_head *);
-+static struct buffer_head *ext3cow_xattr_cache_find(struct inode *,
-+						 struct ext3cow_xattr_header *,
-+						 struct mb_cache_entry **);
-+static void ext3cow_xattr_rehash(struct ext3cow_xattr_header *,
-+			      struct ext3cow_xattr_entry *);
-+
-+static struct mb_cache *ext3cow_xattr_cache;
-+
-+static struct xattr_handler *ext3cow_xattr_handler_map[] = {
-+	[EXT3COW_XATTR_INDEX_USER]		     = &ext3cow_xattr_user_handler,
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+	[EXT3COW_XATTR_INDEX_POSIX_ACL_ACCESS]  = &ext3cow_xattr_acl_access_handler,
-+	[EXT3COW_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext3cow_xattr_acl_default_handler,
-+#endif
-+	[EXT3COW_XATTR_INDEX_TRUSTED]	     = &ext3cow_xattr_trusted_handler,
-+#ifdef CONFIG_EXT3COW_FS_SECURITY
-+	[EXT3COW_XATTR_INDEX_SECURITY]	     = &ext3cow_xattr_security_handler,
-+#endif
-+};
-+
-+struct xattr_handler *ext3cow_xattr_handlers[] = {
-+	&ext3cow_xattr_user_handler,
-+	&ext3cow_xattr_trusted_handler,
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+	&ext3cow_xattr_acl_access_handler,
-+	&ext3cow_xattr_acl_default_handler,
-+#endif
-+#ifdef CONFIG_EXT3COW_FS_SECURITY
-+	&ext3cow_xattr_security_handler,
-+#endif
-+	NULL
-+};
-+
-+static inline struct xattr_handler *
-+ext3cow_xattr_handler(int name_index)
-+{
-+	struct xattr_handler *handler = NULL;
-+
-+	if (name_index > 0 && name_index < ARRAY_SIZE(ext3cow_xattr_handler_map))
-+		handler = ext3cow_xattr_handler_map[name_index];
-+	return handler;
-+}
-+
-+/*
-+ * Inode operation listxattr()
-+ *
-+ * dentry->d_inode->i_mutex: don't care
-+ */
-+ssize_t
-+ext3cow_listxattr(struct dentry *dentry, char *buffer, size_t size)
-+{
-+	return ext3cow_xattr_list(dentry->d_inode, buffer, size);
-+}
-+
-+static int
-+ext3cow_xattr_check_names(struct ext3cow_xattr_entry *entry, void *end)
-+{
-+	while (!IS_LAST_ENTRY(entry)) {
-+		struct ext3cow_xattr_entry *next = EXT3COW_XATTR_NEXT(entry);
-+		if ((void *)next >= end)
-+			return -EIO;
-+		entry = next;
-+	}
-+	return 0;
-+}
-+
-+static inline int
-+ext3cow_xattr_check_block(struct buffer_head *bh)
-+{
-+	int error;
-+
-+	if (BHDR(bh)->h_magic != cpu_to_le32(EXT3COW_XATTR_MAGIC) ||
-+	    BHDR(bh)->h_blocks != cpu_to_le32(1))
-+		return -EIO;
-+	error = ext3cow_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size);
-+	return error;
-+}
-+
-+static inline int
-+ext3cow_xattr_check_entry(struct ext3cow_xattr_entry *entry, size_t size)
-+{
-+	size_t value_size = le32_to_cpu(entry->e_value_size);
-+
-+	if (entry->e_value_block != 0 || value_size > size ||
-+	    le16_to_cpu(entry->e_value_offs) + value_size > size)
-+		return -EIO;
-+	return 0;
-+}
-+
-+static int
-+ext3cow_xattr_find_entry(struct ext3cow_xattr_entry **pentry, int name_index,
-+		      const char *name, size_t size, int sorted)
-+{
-+	struct ext3cow_xattr_entry *entry;
-+	size_t name_len;
-+	int cmp = 1;
-+
-+	if (name == NULL)
-+		return -EINVAL;
-+	name_len = strlen(name);
-+	entry = *pentry;
-+	for (; !IS_LAST_ENTRY(entry); entry = EXT3COW_XATTR_NEXT(entry)) {
-+		cmp = name_index - entry->e_name_index;
-+		if (!cmp)
-+			cmp = name_len - entry->e_name_len;
-+		if (!cmp)
-+			cmp = memcmp(name, entry->e_name, name_len);
-+		if (cmp <= 0 && (sorted || cmp == 0))
-+			break;
-+	}
-+	*pentry = entry;
-+	if (!cmp && ext3cow_xattr_check_entry(entry, size))
-+			return -EIO;
-+	return cmp ? -ENODATA : 0;
-+}
-+
-+static int
-+ext3cow_xattr_block_get(struct inode *inode, int name_index, const char *name,
-+		     void *buffer, size_t buffer_size)
-+{
-+	struct buffer_head *bh = NULL;
-+	struct ext3cow_xattr_entry *entry;
-+	size_t size;
-+	int error;
-+
-+	ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
-+		  name_index, name, buffer, (long)buffer_size);
-+
-+	error = -ENODATA;
-+	if (!EXT3COW_I(inode)->i_file_acl)
-+		goto cleanup;
-+	ea_idebug(inode, "reading block %u", EXT3COW_I(inode)->i_file_acl);
-+	bh = sb_bread(inode->i_sb, EXT3COW_I(inode)->i_file_acl);
-+	if (!bh)
-+		goto cleanup;
-+	ea_bdebug(bh, "b_count=%d, refcount=%d",
-+		atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
-+	if (ext3cow_xattr_check_block(bh)) {
-+bad_block:	ext3cow_error(inode->i_sb, __FUNCTION__,
-+			   "inode %lu: bad block "E3FSBLK, inode->i_ino,
-+			   EXT3COW_I(inode)->i_file_acl);
-+		error = -EIO;
-+		goto cleanup;
-+	}
-+	ext3cow_xattr_cache_insert(bh);
-+	entry = BFIRST(bh);
-+	error = ext3cow_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
-+	if (error == -EIO)
-+		goto bad_block;
-+	if (error)
-+		goto cleanup;
-+	size = le32_to_cpu(entry->e_value_size);
-+	if (buffer) {
-+		error = -ERANGE;
-+		if (size > buffer_size)
-+			goto cleanup;
-+		memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
-+		       size);
-+	}
-+	error = size;
-+
-+cleanup:
-+	brelse(bh);
-+	return error;
-+}
-+
-+static int
-+ext3cow_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
-+		     void *buffer, size_t buffer_size)
-+{
-+	struct ext3cow_xattr_ibody_header *header;
-+	struct ext3cow_xattr_entry *entry;
-+	struct ext3cow_inode *raw_inode;
-+	struct ext3cow_iloc iloc;
-+	size_t size;
-+	void *end;
-+	int error;
-+
-+	if (!(EXT3COW_I(inode)->i_state & EXT3COW_STATE_XATTR))
-+		return -ENODATA;
-+	error = ext3cow_get_inode_loc(inode, &iloc);
-+	if (error)
-+		return error;
-+	raw_inode = ext3cow_raw_inode(&iloc);
-+	header = IHDR(inode, raw_inode);
-+	entry = IFIRST(header);
-+	end = (void *)raw_inode + EXT3COW_SB(inode->i_sb)->s_inode_size;
-+	error = ext3cow_xattr_check_names(entry, end);
-+	if (error)
-+		goto cleanup;
-+	error = ext3cow_xattr_find_entry(&entry, name_index, name,
-+				      end - (void *)entry, 0);
-+	if (error)
-+		goto cleanup;
-+	size = le32_to_cpu(entry->e_value_size);
-+	if (buffer) {
-+		error = -ERANGE;
-+		if (size > buffer_size)
-+			goto cleanup;
-+		memcpy(buffer, (void *)IFIRST(header) +
-+		       le16_to_cpu(entry->e_value_offs), size);
-+	}
-+	error = size;
-+
-+cleanup:
-+	brelse(iloc.bh);
-+	return error;
-+}
-+
-+/*
-+ * ext3cow_xattr_get()
-+ *
-+ * Copy an extended attribute into the buffer
-+ * provided, or compute the buffer size required.
-+ * Buffer is NULL to compute the size of the buffer required.
-+ *
-+ * Returns a negative error number on failure, or the number of bytes
-+ * used / required on success.
-+ */
-+int
-+ext3cow_xattr_get(struct inode *inode, int name_index, const char *name,
-+	       void *buffer, size_t buffer_size)
-+{
-+	int error;
-+
-+	down_read(&EXT3COW_I(inode)->xattr_sem);
-+	error = ext3cow_xattr_ibody_get(inode, name_index, name, buffer,
-+				     buffer_size);
-+	if (error == -ENODATA)
-+		error = ext3cow_xattr_block_get(inode, name_index, name, buffer,
-+					     buffer_size);
-+	up_read(&EXT3COW_I(inode)->xattr_sem);
-+	return error;
-+}
-+
-+static int
-+ext3cow_xattr_list_entries(struct inode *inode, struct ext3cow_xattr_entry *entry,
-+			char *buffer, size_t buffer_size)
-+{
-+	size_t rest = buffer_size;
-+
-+	for (; !IS_LAST_ENTRY(entry); entry = EXT3COW_XATTR_NEXT(entry)) {
-+		struct xattr_handler *handler =
-+			ext3cow_xattr_handler(entry->e_name_index);
-+
-+		if (handler) {
-+			size_t size = handler->list(inode, buffer, rest,
-+						    entry->e_name,
-+						    entry->e_name_len);
-+			if (buffer) {
-+				if (size > rest)
-+					return -ERANGE;
-+				buffer += size;
-+			}
-+			rest -= size;
-+		}
-+	}
-+	return buffer_size - rest;
-+}
-+
-+static int
-+ext3cow_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
-+{
-+	struct buffer_head *bh = NULL;
-+	int error;
-+
-+	ea_idebug(inode, "buffer=%p, buffer_size=%ld",
-+		  buffer, (long)buffer_size);
-+
-+	error = 0;
-+	if (!EXT3COW_I(inode)->i_file_acl)
-+		goto cleanup;
-+	ea_idebug(inode, "reading block %u", EXT3COW_I(inode)->i_file_acl);
-+	bh = sb_bread(inode->i_sb, EXT3COW_I(inode)->i_file_acl);
-+	error = -EIO;
-+	if (!bh)
-+		goto cleanup;
-+	ea_bdebug(bh, "b_count=%d, refcount=%d",
-+		atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
-+	if (ext3cow_xattr_check_block(bh)) {
-+		ext3cow_error(inode->i_sb, __FUNCTION__,
-+			   "inode %lu: bad block "E3FSBLK, inode->i_ino,
-+			   EXT3COW_I(inode)->i_file_acl);
-+		error = -EIO;
-+		goto cleanup;
-+	}
-+	ext3cow_xattr_cache_insert(bh);
-+	error = ext3cow_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size);
-+
-+cleanup:
-+	brelse(bh);
-+
-+	return error;
-+}
-+
-+static int
-+ext3cow_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size)
-+{
-+	struct ext3cow_xattr_ibody_header *header;
-+	struct ext3cow_inode *raw_inode;
-+	struct ext3cow_iloc iloc;
-+	void *end;
-+	int error;
-+
-+	if (!(EXT3COW_I(inode)->i_state & EXT3COW_STATE_XATTR))
-+		return 0;
-+	error = ext3cow_get_inode_loc(inode, &iloc);
-+	if (error)
-+		return error;
-+	raw_inode = ext3cow_raw_inode(&iloc);
-+	header = IHDR(inode, raw_inode);
-+	end = (void *)raw_inode + EXT3COW_SB(inode->i_sb)->s_inode_size;
-+	error = ext3cow_xattr_check_names(IFIRST(header), end);
-+	if (error)
-+		goto cleanup;
-+	error = ext3cow_xattr_list_entries(inode, IFIRST(header),
-+					buffer, buffer_size);
-+
-+cleanup:
-+	brelse(iloc.bh);
-+	return error;
-+}
-+
-+/*
-+ * ext3cow_xattr_list()
-+ *
-+ * Copy a list of attribute names into the buffer
-+ * provided, or compute the buffer size required.
-+ * Buffer is NULL to compute the size of the buffer required.
-+ *
-+ * Returns a negative error number on failure, or the number of bytes
-+ * used / required on success.
-+ */
-+int
-+ext3cow_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
-+{
-+	int i_error, b_error;
-+
-+	down_read(&EXT3COW_I(inode)->xattr_sem);
-+	i_error = ext3cow_xattr_ibody_list(inode, buffer, buffer_size);
-+	if (i_error < 0) {
-+		b_error = 0;
-+	} else {
-+		if (buffer) {
-+			buffer += i_error;
-+			buffer_size -= i_error;
-+		}
-+		b_error = ext3cow_xattr_block_list(inode, buffer, buffer_size);
-+		if (b_error < 0)
-+			i_error = 0;
-+	}
-+	up_read(&EXT3COW_I(inode)->xattr_sem);
-+	return i_error + b_error;
-+}
-+
-+/*
-+ * If the EXT3COW_FEATURE_COMPAT_EXT_ATTR feature of this file system is
-+ * not set, set it.
-+ */
-+static void ext3cow_xattr_update_super_block(handle_t *handle,
-+					  struct super_block *sb)
-+{
-+	if (EXT3COW_HAS_COMPAT_FEATURE(sb, EXT3COW_FEATURE_COMPAT_EXT_ATTR))
-+		return;
-+
-+	if (ext3cow_journal_get_write_access(handle, EXT3COW_SB(sb)->s_sbh) == 0) {
-+		EXT3COW_SET_COMPAT_FEATURE(sb, EXT3COW_FEATURE_COMPAT_EXT_ATTR);
-+		sb->s_dirt = 1;
-+		ext3cow_journal_dirty_metadata(handle, EXT3COW_SB(sb)->s_sbh);
-+	}
-+}
-+
-+/*
-+ * Release the xattr block BH: If the reference count is > 1, decrement
-+ * it; otherwise free the block.
-+ */
-+static void
-+ext3cow_xattr_release_block(handle_t *handle, struct inode *inode,
-+			 struct buffer_head *bh)
-+{
-+	struct mb_cache_entry *ce = NULL;
-+
-+	ce = mb_cache_entry_get(ext3cow_xattr_cache, bh->b_bdev, bh->b_blocknr);
-+	if (BHDR(bh)->h_refcount == cpu_to_le32(1)) {
-+		ea_bdebug(bh, "refcount now=0; freeing");
-+		if (ce)
-+			mb_cache_entry_free(ce);
-+		ext3cow_free_blocks(handle, inode, bh->b_blocknr, 1);
-+		get_bh(bh);
-+		ext3cow_forget(handle, 1, inode, bh, bh->b_blocknr);
-+	} else {
-+		if (ext3cow_journal_get_write_access(handle, bh) == 0) {
-+			lock_buffer(bh);
-+			BHDR(bh)->h_refcount = cpu_to_le32(
-+				le32_to_cpu(BHDR(bh)->h_refcount) - 1);
-+			ext3cow_journal_dirty_metadata(handle, bh);
-+			if (IS_SYNC(inode))
-+				handle->h_sync = 1;
-+			DQUOT_FREE_BLOCK(inode, 1);
-+			unlock_buffer(bh);
-+			ea_bdebug(bh, "refcount now=%d; releasing",
-+				  le32_to_cpu(BHDR(bh)->h_refcount));
-+		}
-+		if (ce)
-+			mb_cache_entry_release(ce);
-+	}
-+}
-+
-+struct ext3cow_xattr_info {
-+	int name_index;
-+	const char *name;
-+	const void *value;
-+	size_t value_len;
-+};
-+
-+struct ext3cow_xattr_search {
-+	struct ext3cow_xattr_entry *first;
-+	void *base;
-+	void *end;
-+	struct ext3cow_xattr_entry *here;
-+	int not_found;
-+};
-+
-+static int
-+ext3cow_xattr_set_entry(struct ext3cow_xattr_info *i, struct ext3cow_xattr_search *s)
-+{
-+	struct ext3cow_xattr_entry *last;
-+	size_t free, min_offs = s->end - s->base, name_len = strlen(i->name);
-+
-+	/* Compute min_offs and last. */
-+	last = s->first;
-+	for (; !IS_LAST_ENTRY(last); last = EXT3COW_XATTR_NEXT(last)) {
-+		if (!last->e_value_block && last->e_value_size) {
-+			size_t offs = le16_to_cpu(last->e_value_offs);
-+			if (offs < min_offs)
-+				min_offs = offs;
-+		}
-+	}
-+	free = min_offs - ((void *)last - s->base) - sizeof(__u32);
-+	if (!s->not_found) {
-+		if (!s->here->e_value_block && s->here->e_value_size) {
-+			size_t size = le32_to_cpu(s->here->e_value_size);
-+			free += EXT3COW_XATTR_SIZE(size);
-+		}
-+		free += EXT3COW_XATTR_LEN(name_len);
-+	}
-+	if (i->value) {
-+		if (free < EXT3COW_XATTR_SIZE(i->value_len) ||
-+		    free < EXT3COW_XATTR_LEN(name_len) +
-+			   EXT3COW_XATTR_SIZE(i->value_len))
-+			return -ENOSPC;
-+	}
-+
-+	if (i->value && s->not_found) {
-+		/* Insert the new name. */
-+		size_t size = EXT3COW_XATTR_LEN(name_len);
-+		size_t rest = (void *)last - (void *)s->here + sizeof(__u32);
-+		memmove((void *)s->here + size, s->here, rest);
-+		memset(s->here, 0, size);
-+		s->here->e_name_index = i->name_index;
-+		s->here->e_name_len = name_len;
-+		memcpy(s->here->e_name, i->name, name_len);
-+	} else {
-+		if (!s->here->e_value_block && s->here->e_value_size) {
-+			void *first_val = s->base + min_offs;
-+			size_t offs = le16_to_cpu(s->here->e_value_offs);
-+			void *val = s->base + offs;
-+			size_t size = EXT3COW_XATTR_SIZE(
-+				le32_to_cpu(s->here->e_value_size));
-+
-+			if (i->value && size == EXT3COW_XATTR_SIZE(i->value_len)) {
-+				/* The old and the new value have the same
-+				   size. Just replace. */
-+				s->here->e_value_size =
-+					cpu_to_le32(i->value_len);
-+				memset(val + size - EXT3COW_XATTR_PAD, 0,
-+				       EXT3COW_XATTR_PAD); /* Clear pad bytes. */
-+				memcpy(val, i->value, i->value_len);
-+				return 0;
-+			}
-+
-+			/* Remove the old value. */
-+			memmove(first_val + size, first_val, val - first_val);
-+			memset(first_val, 0, size);
-+			s->here->e_value_size = 0;
-+			s->here->e_value_offs = 0;
-+			min_offs += size;
-+
-+			/* Adjust all value offsets. */
-+			last = s->first;
-+			while (!IS_LAST_ENTRY(last)) {
-+				size_t o = le16_to_cpu(last->e_value_offs);
-+				if (!last->e_value_block &&
-+				    last->e_value_size && o < offs)
-+					last->e_value_offs =
-+						cpu_to_le16(o + size);
-+				last = EXT3COW_XATTR_NEXT(last);
-+			}
-+		}
-+		if (!i->value) {
-+			/* Remove the old name. */
-+			size_t size = EXT3COW_XATTR_LEN(name_len);
-+			last = ENTRY((void *)last - size);
-+			memmove(s->here, (void *)s->here + size,
-+				(void *)last - (void *)s->here + sizeof(__u32));
-+			memset(last, 0, size);
-+		}
-+	}
-+
-+	if (i->value) {
-+		/* Insert the new value. */
-+		s->here->e_value_size = cpu_to_le32(i->value_len);
-+		if (i->value_len) {
-+			size_t size = EXT3COW_XATTR_SIZE(i->value_len);
-+			void *val = s->base + min_offs - size;
-+			s->here->e_value_offs = cpu_to_le16(min_offs - size);
-+			memset(val + size - EXT3COW_XATTR_PAD, 0,
-+			       EXT3COW_XATTR_PAD); /* Clear the pad bytes. */
-+			memcpy(val, i->value, i->value_len);
-+		}
-+	}
-+	return 0;
-+}
-+
-+struct ext3cow_xattr_block_find {
-+	struct ext3cow_xattr_search s;
-+	struct buffer_head *bh;
-+};
-+
-+static int
-+ext3cow_xattr_block_find(struct inode *inode, struct ext3cow_xattr_info *i,
-+		      struct ext3cow_xattr_block_find *bs)
-+{
-+	struct super_block *sb = inode->i_sb;
-+	int error;
-+
-+	ea_idebug(inode, "name=%d.%s, value=%p, value_len=%ld",
-+		  i->name_index, i->name, i->value, (long)i->value_len);
-+
-+	if (EXT3COW_I(inode)->i_file_acl) {
-+		/* The inode already has an extended attribute block. */
-+		bs->bh = sb_bread(sb, EXT3COW_I(inode)->i_file_acl);
-+		error = -EIO;
-+		if (!bs->bh)
-+			goto cleanup;
-+		ea_bdebug(bs->bh, "b_count=%d, refcount=%d",
-+			atomic_read(&(bs->bh->b_count)),
-+			le32_to_cpu(BHDR(bs->bh)->h_refcount));
-+		if (ext3cow_xattr_check_block(bs->bh)) {
-+			ext3cow_error(sb, __FUNCTION__,
-+				"inode %lu: bad block "E3FSBLK, inode->i_ino,
-+				EXT3COW_I(inode)->i_file_acl);
-+			error = -EIO;
-+			goto cleanup;
-+		}
-+		/* Find the named attribute. */
-+		bs->s.base = BHDR(bs->bh);
-+		bs->s.first = BFIRST(bs->bh);
-+		bs->s.end = bs->bh->b_data + bs->bh->b_size;
-+		bs->s.here = bs->s.first;
-+		error = ext3cow_xattr_find_entry(&bs->s.here, i->name_index,
-+					      i->name, bs->bh->b_size, 1);
-+		if (error && error != -ENODATA)
-+			goto cleanup;
-+		bs->s.not_found = error;
-+	}
-+	error = 0;
-+
-+cleanup:
-+	return error;
-+}
-+
-+static int
-+ext3cow_xattr_block_set(handle_t *handle, struct inode *inode,
-+		     struct ext3cow_xattr_info *i,
-+		     struct ext3cow_xattr_block_find *bs)
-+{
-+	struct super_block *sb = inode->i_sb;
-+	struct buffer_head *new_bh = NULL;
-+	struct ext3cow_xattr_search *s = &bs->s;
-+	struct mb_cache_entry *ce = NULL;
-+	int error;
-+
-+#define header(x) ((struct ext3cow_xattr_header *)(x))
-+
-+	if (i->value && i->value_len > sb->s_blocksize)
-+		return -ENOSPC;
-+	if (s->base) {
-+		ce = mb_cache_entry_get(ext3cow_xattr_cache, bs->bh->b_bdev,
-+					bs->bh->b_blocknr);
-+		if (header(s->base)->h_refcount == cpu_to_le32(1)) {
-+			if (ce) {
-+				mb_cache_entry_free(ce);
-+				ce = NULL;
-+			}
-+			ea_bdebug(bs->bh, "modifying in-place");
-+			error = ext3cow_journal_get_write_access(handle, bs->bh);
-+			if (error)
-+				goto cleanup;
-+			lock_buffer(bs->bh);
-+			error = ext3cow_xattr_set_entry(i, s);
-+			if (!error) {
-+				if (!IS_LAST_ENTRY(s->first))
-+					ext3cow_xattr_rehash(header(s->base),
-+							  s->here);
-+				ext3cow_xattr_cache_insert(bs->bh);
-+			}
-+			unlock_buffer(bs->bh);
-+			if (error == -EIO)
-+				goto bad_block;
-+			if (!error)
-+				error = ext3cow_journal_dirty_metadata(handle,
-+								    bs->bh);
-+			if (error)
-+				goto cleanup;
-+			goto inserted;
-+		} else {
-+			int offset = (char *)s->here - bs->bh->b_data;
-+
-+			if (ce) {
-+				mb_cache_entry_release(ce);
-+				ce = NULL;
-+			}
-+			ea_bdebug(bs->bh, "cloning");
-+			s->base = kmalloc(bs->bh->b_size, GFP_KERNEL);
-+			error = -ENOMEM;
-+			if (s->base == NULL)
-+				goto cleanup;
-+			memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
-+			s->first = ENTRY(header(s->base)+1);
-+			header(s->base)->h_refcount = cpu_to_le32(1);
-+			s->here = ENTRY(s->base + offset);
-+			s->end = s->base + bs->bh->b_size;
-+		}
-+	} else {
-+		/* Allocate a buffer where we construct the new block. */
-+		s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
-+		/* assert(header == s->base) */
-+		error = -ENOMEM;
-+		if (s->base == NULL)
-+			goto cleanup;
-+		memset(s->base, 0, sb->s_blocksize);
-+		header(s->base)->h_magic = cpu_to_le32(EXT3COW_XATTR_MAGIC);
-+		header(s->base)->h_blocks = cpu_to_le32(1);
-+		header(s->base)->h_refcount = cpu_to_le32(1);
-+		s->first = ENTRY(header(s->base)+1);
-+		s->here = ENTRY(header(s->base)+1);
-+		s->end = s->base + sb->s_blocksize;
-+	}
-+
-+	error = ext3cow_xattr_set_entry(i, s);
-+	if (error == -EIO)
-+		goto bad_block;
-+	if (error)
-+		goto cleanup;
-+	if (!IS_LAST_ENTRY(s->first))
-+		ext3cow_xattr_rehash(header(s->base), s->here);
-+
-+inserted:
-+	if (!IS_LAST_ENTRY(s->first)) {
-+		new_bh = ext3cow_xattr_cache_find(inode, header(s->base), &ce);
-+		if (new_bh) {
-+			/* We found an identical block in the cache. */
-+			if (new_bh == bs->bh)
-+				ea_bdebug(new_bh, "keeping");
-+			else {
-+				/* The old block is released after updating
-+				   the inode. */
-+				error = -EDQUOT;
-+				if (DQUOT_ALLOC_BLOCK(inode, 1))
-+					goto cleanup;
-+				error = ext3cow_journal_get_write_access(handle,
-+								      new_bh);
-+				if (error)
-+					goto cleanup_dquot;
-+				lock_buffer(new_bh);
-+				BHDR(new_bh)->h_refcount = cpu_to_le32(1 +
-+					le32_to_cpu(BHDR(new_bh)->h_refcount));
-+				ea_bdebug(new_bh, "reusing; refcount now=%d",
-+					le32_to_cpu(BHDR(new_bh)->h_refcount));
-+				unlock_buffer(new_bh);
-+				error = ext3cow_journal_dirty_metadata(handle,
-+								    new_bh);
-+				if (error)
-+					goto cleanup_dquot;
-+			}
-+			mb_cache_entry_release(ce);
-+			ce = NULL;
-+		} else if (bs->bh && s->base == bs->bh->b_data) {
-+			/* We were modifying this block in-place. */
-+			ea_bdebug(bs->bh, "keeping this block");
-+			new_bh = bs->bh;
-+			get_bh(new_bh);
-+		} else {
-+			/* We need to allocate a new block */
-+			ext3cow_fsblk_t goal = le32_to_cpu(
-+					EXT3COW_SB(sb)->s_es->s_first_data_block) +
-+				(ext3cow_fsblk_t)EXT3COW_I(inode)->i_block_group *
-+				EXT3COW_BLOCKS_PER_GROUP(sb);
-+			ext3cow_fsblk_t block = ext3cow_new_block(handle, inode,
-+							goal, &error);
-+			if (error)
-+				goto cleanup;
-+			ea_idebug(inode, "creating block %d", block);
-+
-+			new_bh = sb_getblk(sb, block);
-+			if (!new_bh) {
-+getblk_failed:
-+				ext3cow_free_blocks(handle, inode, block, 1);
-+				error = -EIO;
-+				goto cleanup;
-+			}
-+			lock_buffer(new_bh);
-+			error = ext3cow_journal_get_create_access(handle, new_bh);
-+			if (error) {
-+				unlock_buffer(new_bh);
-+				goto getblk_failed;
-+			}
-+			memcpy(new_bh->b_data, s->base, new_bh->b_size);
-+			set_buffer_uptodate(new_bh);
-+			unlock_buffer(new_bh);
-+			ext3cow_xattr_cache_insert(new_bh);
-+			error = ext3cow_journal_dirty_metadata(handle, new_bh);
-+			if (error)
-+				goto cleanup;
-+		}
-+	}
-+
-+	/* Update the inode. */
-+	EXT3COW_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
-+
-+	/* Drop the previous xattr block. */
-+	if (bs->bh && bs->bh != new_bh)
-+		ext3cow_xattr_release_block(handle, inode, bs->bh);
-+	error = 0;
-+
-+cleanup:
-+	if (ce)
-+		mb_cache_entry_release(ce);
-+	brelse(new_bh);
-+	if (!(bs->bh && s->base == bs->bh->b_data))
-+		kfree(s->base);
-+
-+	return error;
-+
-+cleanup_dquot:
-+	DQUOT_FREE_BLOCK(inode, 1);
-+	goto cleanup;
-+
-+bad_block:
-+	ext3cow_error(inode->i_sb, __FUNCTION__,
-+		   "inode %lu: bad block "E3FSBLK, inode->i_ino,
-+		   EXT3COW_I(inode)->i_file_acl);
-+	goto cleanup;
-+
-+#undef header
-+}
-+
-+struct ext3cow_xattr_ibody_find {
-+	struct ext3cow_xattr_search s;
-+	struct ext3cow_iloc iloc;
-+};
-+
-+static int
-+ext3cow_xattr_ibody_find(struct inode *inode, struct ext3cow_xattr_info *i,
-+		      struct ext3cow_xattr_ibody_find *is)
-+{
-+	struct ext3cow_xattr_ibody_header *header;
-+	struct ext3cow_inode *raw_inode;
-+	int error;
-+
-+	if (EXT3COW_I(inode)->i_extra_isize == 0)
-+		return 0;
-+	raw_inode = ext3cow_raw_inode(&is->iloc);
-+	header = IHDR(inode, raw_inode);
-+	is->s.base = is->s.first = IFIRST(header);
-+	is->s.here = is->s.first;
-+	is->s.end = (void *)raw_inode + EXT3COW_SB(inode->i_sb)->s_inode_size;
-+	if (EXT3COW_I(inode)->i_state & EXT3COW_STATE_XATTR) {
-+		error = ext3cow_xattr_check_names(IFIRST(header), is->s.end);
-+		if (error)
-+			return error;
-+		/* Find the named attribute. */
-+		error = ext3cow_xattr_find_entry(&is->s.here, i->name_index,
-+					      i->name, is->s.end -
-+					      (void *)is->s.base, 0);
-+		if (error && error != -ENODATA)
-+			return error;
-+		is->s.not_found = error;
-+	}
-+	return 0;
-+}
-+
-+static int
-+ext3cow_xattr_ibody_set(handle_t *handle, struct inode *inode,
-+		     struct ext3cow_xattr_info *i,
-+		     struct ext3cow_xattr_ibody_find *is)
-+{
-+	struct ext3cow_xattr_ibody_header *header;
-+	struct ext3cow_xattr_search *s = &is->s;
-+	int error;
-+
-+	if (EXT3COW_I(inode)->i_extra_isize == 0)
-+		return -ENOSPC;
-+	error = ext3cow_xattr_set_entry(i, s);
-+	if (error)
-+		return error;
-+	header = IHDR(inode, ext3cow_raw_inode(&is->iloc));
-+	if (!IS_LAST_ENTRY(s->first)) {
-+		header->h_magic = cpu_to_le32(EXT3COW_XATTR_MAGIC);
-+		EXT3COW_I(inode)->i_state |= EXT3COW_STATE_XATTR;
-+	} else {
-+		header->h_magic = cpu_to_le32(0);
-+		EXT3COW_I(inode)->i_state &= ~EXT3COW_STATE_XATTR;
-+	}
-+	return 0;
-+}
-+
-+/*
-+ * ext3cow_xattr_set_handle()
-+ *
-+ * Create, replace or remove an extended attribute for this inode. Buffer
-+ * is NULL to remove an existing extended attribute, and non-NULL to
-+ * either replace an existing extended attribute, or create a new extended
-+ * attribute. The flags XATTR_REPLACE and XATTR_CREATE
-+ * specify that an extended attribute must exist and must not exist
-+ * previous to the call, respectively.
-+ *
-+ * Returns 0, or a negative error number on failure.
-+ */
-+int
-+ext3cow_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
-+		      const char *name, const void *value, size_t value_len,
-+		      int flags)
-+{
-+	struct ext3cow_xattr_info i = {
-+		.name_index = name_index,
-+		.name = name,
-+		.value = value,
-+		.value_len = value_len,
-+
-+	};
-+	struct ext3cow_xattr_ibody_find is = {
-+		.s = { .not_found = -ENODATA, },
-+	};
-+	struct ext3cow_xattr_block_find bs = {
-+		.s = { .not_found = -ENODATA, },
-+	};
-+	int error;
-+
-+	if (!name)
-+		return -EINVAL;
-+	if (strlen(name) > 255)
-+		return -ERANGE;
-+	down_write(&EXT3COW_I(inode)->xattr_sem);
-+	error = ext3cow_get_inode_loc(inode, &is.iloc);
-+	if (error)
-+		goto cleanup;
-+
-+	if (EXT3COW_I(inode)->i_state & EXT3COW_STATE_NEW) {
-+		struct ext3cow_inode *raw_inode = ext3cow_raw_inode(&is.iloc);
-+		memset(raw_inode, 0, EXT3COW_SB(inode->i_sb)->s_inode_size);
-+		EXT3COW_I(inode)->i_state &= ~EXT3COW_STATE_NEW;
-+	}
-+
-+	error = ext3cow_xattr_ibody_find(inode, &i, &is);
-+	if (error)
-+		goto cleanup;
-+	if (is.s.not_found)
-+		error = ext3cow_xattr_block_find(inode, &i, &bs);
-+	if (error)
-+		goto cleanup;
-+	if (is.s.not_found && bs.s.not_found) {
-+		error = -ENODATA;
-+		if (flags & XATTR_REPLACE)
-+			goto cleanup;
-+		error = 0;
-+		if (!value)
-+			goto cleanup;
-+	} else {
-+		error = -EEXIST;
-+		if (flags & XATTR_CREATE)
-+			goto cleanup;
-+	}
-+	error = ext3cow_journal_get_write_access(handle, is.iloc.bh);
-+	if (error)
-+		goto cleanup;
-+	if (!value) {
-+		if (!is.s.not_found)
-+			error = ext3cow_xattr_ibody_set(handle, inode, &i, &is);
-+		else if (!bs.s.not_found)
-+			error = ext3cow_xattr_block_set(handle, inode, &i, &bs);
-+	} else {
-+		error = ext3cow_xattr_ibody_set(handle, inode, &i, &is);
-+		if (!error && !bs.s.not_found) {
-+			i.value = NULL;
-+			error = ext3cow_xattr_block_set(handle, inode, &i, &bs);
-+		} else if (error == -ENOSPC) {
-+			error = ext3cow_xattr_block_set(handle, inode, &i, &bs);
-+			if (error)
-+				goto cleanup;
-+			if (!is.s.not_found) {
-+				i.value = NULL;
-+				error = ext3cow_xattr_ibody_set(handle, inode, &i,
-+							     &is);
-+			}
-+		}
-+	}
-+	if (!error) {
-+		ext3cow_xattr_update_super_block(handle, inode->i_sb);
-+		inode->i_ctime = CURRENT_TIME_SEC;
-+		error = ext3cow_mark_iloc_dirty(handle, inode, &is.iloc);
-+		/*
-+		 * The bh is consumed by ext3cow_mark_iloc_dirty, even with
-+		 * error != 0.
-+		 */
-+		is.iloc.bh = NULL;
-+		if (IS_SYNC(inode))
-+			handle->h_sync = 1;
-+	}
-+
-+cleanup:
-+	brelse(is.iloc.bh);
-+	brelse(bs.bh);
-+	up_write(&EXT3COW_I(inode)->xattr_sem);
-+	return error;
-+}
-+
-+/*
-+ * ext3cow_xattr_set()
-+ *
-+ * Like ext3cow_xattr_set_handle, but start from an inode. This extended
-+ * attribute modification is a filesystem transaction by itself.
-+ *
-+ * Returns 0, or a negative error number on failure.
-+ */
-+int
-+ext3cow_xattr_set(struct inode *inode, int name_index, const char *name,
-+	       const void *value, size_t value_len, int flags)
-+{
-+	handle_t *handle;
-+	int error, retries = 0;
-+
-+retry:
-+	handle = ext3cow_journal_start(inode, EXT3COW_DATA_TRANS_BLOCKS(inode->i_sb));
-+	if (IS_ERR(handle)) {
-+		error = PTR_ERR(handle);
-+	} else {
-+		int error2;
-+
-+		error = ext3cow_xattr_set_handle(handle, inode, name_index, name,
-+					      value, value_len, flags);
-+		error2 = ext3cow_journal_stop(handle);
-+		if (error == -ENOSPC &&
-+		    ext3cow_should_retry_alloc(inode->i_sb, &retries))
-+			goto retry;
-+		if (error == 0)
-+			error = error2;
-+	}
-+
-+	return error;
-+}
-+
-+/*
-+ * ext3cow_xattr_delete_inode()
-+ *
-+ * Free extended attribute resources associated with this inode. This
-+ * is called immediately before an inode is freed. We have exclusive
-+ * access to the inode.
-+ */
-+void
-+ext3cow_xattr_delete_inode(handle_t *handle, struct inode *inode)
-+{
-+	struct buffer_head *bh = NULL;
-+
-+	if (!EXT3COW_I(inode)->i_file_acl)
-+		goto cleanup;
-+	bh = sb_bread(inode->i_sb, EXT3COW_I(inode)->i_file_acl);
-+	if (!bh) {
-+		ext3cow_error(inode->i_sb, __FUNCTION__,
-+			"inode %lu: block "E3FSBLK" read error", inode->i_ino,
-+			EXT3COW_I(inode)->i_file_acl);
-+		goto cleanup;
-+	}
-+	if (BHDR(bh)->h_magic != cpu_to_le32(EXT3COW_XATTR_MAGIC) ||
-+	    BHDR(bh)->h_blocks != cpu_to_le32(1)) {
-+		ext3cow_error(inode->i_sb, __FUNCTION__,
-+			"inode %lu: bad block "E3FSBLK, inode->i_ino,
-+			EXT3COW_I(inode)->i_file_acl);
-+		goto cleanup;
-+	}
-+	ext3cow_xattr_release_block(handle, inode, bh);
-+	EXT3COW_I(inode)->i_file_acl = 0;
-+
-+cleanup:
-+	brelse(bh);
-+}
-+
-+/*
-+ * ext3cow_xattr_put_super()
-+ *
-+ * This is called when a file system is unmounted.
-+ */
-+void
-+ext3cow_xattr_put_super(struct super_block *sb)
-+{
-+	mb_cache_shrink(sb->s_bdev);
-+}
-+
-+/*
-+ * ext3cow_xattr_cache_insert()
-+ *
-+ * Create a new entry in the extended attribute cache, and insert
-+ * it unless such an entry is already in the cache.
-+ *
-+ * Returns 0, or a negative error number on failure.
-+ */
-+static void
-+ext3cow_xattr_cache_insert(struct buffer_head *bh)
-+{
-+	__u32 hash = le32_to_cpu(BHDR(bh)->h_hash);
-+	struct mb_cache_entry *ce;
-+	int error;
-+
-+	ce = mb_cache_entry_alloc(ext3cow_xattr_cache);
-+	if (!ce) {
-+		ea_bdebug(bh, "out of memory");
-+		return;
-+	}
-+	error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, &hash);
-+	if (error) {
-+		mb_cache_entry_free(ce);
-+		if (error == -EBUSY) {
-+			ea_bdebug(bh, "already in cache");
-+			error = 0;
-+		}
-+	} else {
-+		ea_bdebug(bh, "inserting [%x]", (int)hash);
-+		mb_cache_entry_release(ce);
-+	}
-+}
-+
-+/*
-+ * ext3cow_xattr_cmp()
-+ *
-+ * Compare two extended attribute blocks for equality.
-+ *
-+ * Returns 0 if the blocks are equal, 1 if they differ, and
-+ * a negative error number on errors.
-+ */
-+static int
-+ext3cow_xattr_cmp(struct ext3cow_xattr_header *header1,
-+	       struct ext3cow_xattr_header *header2)
-+{
-+	struct ext3cow_xattr_entry *entry1, *entry2;
-+
-+	entry1 = ENTRY(header1+1);
-+	entry2 = ENTRY(header2+1);
-+	while (!IS_LAST_ENTRY(entry1)) {
-+		if (IS_LAST_ENTRY(entry2))
-+			return 1;
-+		if (entry1->e_hash != entry2->e_hash ||
-+		    entry1->e_name_index != entry2->e_name_index ||
-+		    entry1->e_name_len != entry2->e_name_len ||
-+		    entry1->e_value_size != entry2->e_value_size ||
-+		    memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
-+			return 1;
-+		if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
-+			return -EIO;
-+		if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
-+			   (char *)header2 + le16_to_cpu(entry2->e_value_offs),
-+			   le32_to_cpu(entry1->e_value_size)))
-+			return 1;
-+
-+		entry1 = EXT3COW_XATTR_NEXT(entry1);
-+		entry2 = EXT3COW_XATTR_NEXT(entry2);
-+	}
-+	if (!IS_LAST_ENTRY(entry2))
-+		return 1;
-+	return 0;
-+}
-+
-+/*
-+ * ext3cow_xattr_cache_find()
-+ *
-+ * Find an identical extended attribute block.
-+ *
-+ * Returns a pointer to the block found, or NULL if such a block was
-+ * not found or an error occurred.
-+ */
-+static struct buffer_head *
-+ext3cow_xattr_cache_find(struct inode *inode, struct ext3cow_xattr_header *header,
-+		      struct mb_cache_entry **pce)
-+{
-+	__u32 hash = le32_to_cpu(header->h_hash);
-+	struct mb_cache_entry *ce;
-+
-+	if (!header->h_hash)
-+		return NULL;  /* never share */
-+	ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
-+again:
-+	ce = mb_cache_entry_find_first(ext3cow_xattr_cache, 0,
-+				       inode->i_sb->s_bdev, hash);
-+	while (ce) {
-+		struct buffer_head *bh;
-+
-+		if (IS_ERR(ce)) {
-+			if (PTR_ERR(ce) == -EAGAIN)
-+				goto again;
-+			break;
-+		}
-+		bh = sb_bread(inode->i_sb, ce->e_block);
-+		if (!bh) {
-+			ext3cow_error(inode->i_sb, __FUNCTION__,
-+				"inode %lu: block %lu read error",
-+				inode->i_ino, (unsigned long) ce->e_block);
-+		} else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
-+				EXT3COW_XATTR_REFCOUNT_MAX) {
-+			ea_idebug(inode, "block %lu refcount %d>=%d",
-+				  (unsigned long) ce->e_block,
-+				  le32_to_cpu(BHDR(bh)->h_refcount),
-+					  EXT3COW_XATTR_REFCOUNT_MAX);
-+		} else if (ext3cow_xattr_cmp(header, BHDR(bh)) == 0) {
-+			*pce = ce;
-+			return bh;
-+		}
-+		brelse(bh);
-+		ce = mb_cache_entry_find_next(ce, 0, inode->i_sb->s_bdev, hash);
-+	}
-+	return NULL;
-+}
-+
-+#define NAME_HASH_SHIFT 5
-+#define VALUE_HASH_SHIFT 16
-+
-+/*
-+ * ext3cow_xattr_hash_entry()
-+ *
-+ * Compute the hash of an extended attribute.
-+ */
-+static inline void ext3cow_xattr_hash_entry(struct ext3cow_xattr_header *header,
-+					 struct ext3cow_xattr_entry *entry)
-+{
-+	__u32 hash = 0;
-+	char *name = entry->e_name;
-+	int n;
-+
-+	for (n=0; n < entry->e_name_len; n++) {
-+		hash = (hash << NAME_HASH_SHIFT) ^
-+		       (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
-+		       *name++;
-+	}
-+
-+	if (entry->e_value_block == 0 && entry->e_value_size != 0) {
-+		__le32 *value = (__le32 *)((char *)header +
-+			le16_to_cpu(entry->e_value_offs));
-+		for (n = (le32_to_cpu(entry->e_value_size) +
-+		     EXT3COW_XATTR_ROUND) >> EXT3COW_XATTR_PAD_BITS; n; n--) {
-+			hash = (hash << VALUE_HASH_SHIFT) ^
-+			       (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
-+			       le32_to_cpu(*value++);
-+		}
-+	}
-+	entry->e_hash = cpu_to_le32(hash);
-+}
-+
-+#undef NAME_HASH_SHIFT
-+#undef VALUE_HASH_SHIFT
-+
-+#define BLOCK_HASH_SHIFT 16
-+
-+/*
-+ * ext3cow_xattr_rehash()
-+ *
-+ * Re-compute the extended attribute hash value after an entry has changed.
-+ */
-+static void ext3cow_xattr_rehash(struct ext3cow_xattr_header *header,
-+			      struct ext3cow_xattr_entry *entry)
-+{
-+	struct ext3cow_xattr_entry *here;
-+	__u32 hash = 0;
-+
-+	ext3cow_xattr_hash_entry(header, entry);
-+	here = ENTRY(header+1);
-+	while (!IS_LAST_ENTRY(here)) {
-+		if (!here->e_hash) {
-+			/* Block is not shared if an entry's hash value == 0 */
-+			hash = 0;
-+			break;
-+		}
-+		hash = (hash << BLOCK_HASH_SHIFT) ^
-+		       (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
-+		       le32_to_cpu(here->e_hash);
-+		here = EXT3COW_XATTR_NEXT(here);
-+	}
-+	header->h_hash = cpu_to_le32(hash);
-+}
-+
-+#undef BLOCK_HASH_SHIFT
-+
-+int __init
-+init_ext3cow_xattr(void)
-+{
-+	ext3cow_xattr_cache = mb_cache_create("ext3cow_xattr", NULL,
-+		sizeof(struct mb_cache_entry) +
-+		sizeof(((struct mb_cache_entry *) 0)->e_indexes[0]), 1, 6);
-+	if (!ext3cow_xattr_cache)
-+		return -ENOMEM;
-+	return 0;
-+}
-+
-+void
-+exit_ext3cow_xattr(void)
-+{
-+	if (ext3cow_xattr_cache)
-+		mb_cache_destroy(ext3cow_xattr_cache);
-+	ext3cow_xattr_cache = NULL;
-+}
-diff -Naur linux-2.6.21.7/fs/ext3cow/xattr.h linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr.h
---- linux-2.6.21.7/fs/ext3cow/xattr.h	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr.h	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,145 @@
-+/*
-+  File: fs/ext3cow/xattr.h
-+
-+  On-disk format of extended attributes for the ext3cow filesystem.
-+
-+  (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
-+*/
-+
-+#include <linux/xattr.h>
-+
-+/* Magic value in attribute blocks */
-+#define EXT3COW_XATTR_MAGIC		0xEA020000
-+
-+/* Maximum number of references to one attribute block */
-+#define EXT3COW_XATTR_REFCOUNT_MAX		1024
-+
-+/* Name indexes */
-+#define EXT3COW_XATTR_INDEX_USER			1
-+#define EXT3COW_XATTR_INDEX_POSIX_ACL_ACCESS	2
-+#define EXT3COW_XATTR_INDEX_POSIX_ACL_DEFAULT	3
-+#define EXT3COW_XATTR_INDEX_TRUSTED		4
-+#define	EXT3COW_XATTR_INDEX_LUSTRE			5
-+#define EXT3COW_XATTR_INDEX_SECURITY	        6
-+
-+struct ext3cow_xattr_header {
-+	__le32	h_magic;	/* magic number for identification */
-+	__le32	h_refcount;	/* reference count */
-+	__le32	h_blocks;	/* number of disk blocks used */
-+	__le32	h_hash;		/* hash value of all attributes */
-+	__u32	h_reserved[4];	/* zero right now */
-+};
-+
-+struct ext3cow_xattr_ibody_header {
-+	__le32	h_magic;	/* magic number for identification */
-+};
-+
-+struct ext3cow_xattr_entry {
-+	__u8	e_name_len;	/* length of name */
-+	__u8	e_name_index;	/* attribute name index */
-+	__le16	e_value_offs;	/* offset in disk block of value */
-+	__le32	e_value_block;	/* disk block attribute is stored on (n/i) */
-+	__le32	e_value_size;	/* size of attribute value */
-+	__le32	e_hash;		/* hash value of name and value */
-+	char	e_name[0];	/* attribute name */
-+};
-+
-+#define EXT3COW_XATTR_PAD_BITS		2
-+#define EXT3COW_XATTR_PAD		(1<<EXT3COW_XATTR_PAD_BITS)
-+#define EXT3COW_XATTR_ROUND		(EXT3COW_XATTR_PAD-1)
-+#define EXT3COW_XATTR_LEN(name_len) \
-+	(((name_len) + EXT3COW_XATTR_ROUND + \
-+	sizeof(struct ext3cow_xattr_entry)) & ~EXT3COW_XATTR_ROUND)
-+#define EXT3COW_XATTR_NEXT(entry) \
-+	( (struct ext3cow_xattr_entry *)( \
-+	  (char *)(entry) + EXT3COW_XATTR_LEN((entry)->e_name_len)) )
-+#define EXT3COW_XATTR_SIZE(size) \
-+	(((size) + EXT3COW_XATTR_ROUND) & ~EXT3COW_XATTR_ROUND)
-+
-+# ifdef CONFIG_EXT3COW_FS_XATTR
-+
-+extern struct xattr_handler ext3cow_xattr_user_handler;
-+extern struct xattr_handler ext3cow_xattr_trusted_handler;
-+extern struct xattr_handler ext3cow_xattr_acl_access_handler;
-+extern struct xattr_handler ext3cow_xattr_acl_default_handler;
-+extern struct xattr_handler ext3cow_xattr_security_handler;
-+
-+extern ssize_t ext3cow_listxattr(struct dentry *, char *, size_t);
-+
-+extern int ext3cow_xattr_get(struct inode *, int, const char *, void *, size_t);
-+extern int ext3cow_xattr_list(struct inode *, char *, size_t);
-+extern int ext3cow_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
-+extern int ext3cow_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
-+
-+extern void ext3cow_xattr_delete_inode(handle_t *, struct inode *);
-+extern void ext3cow_xattr_put_super(struct super_block *);
-+
-+extern int init_ext3cow_xattr(void);
-+extern void exit_ext3cow_xattr(void);
-+
-+extern struct xattr_handler *ext3cow_xattr_handlers[];
-+
-+# else  /* CONFIG_EXT3COW_FS_XATTR */
-+
-+static inline int
-+ext3cow_xattr_get(struct inode *inode, int name_index, const char *name,
-+	       void *buffer, size_t size, int flags)
-+{
-+	return -EOPNOTSUPP;
-+}
-+
-+static inline int
-+ext3cow_xattr_list(struct inode *inode, void *buffer, size_t size)
-+{
-+	return -EOPNOTSUPP;
-+}
-+
-+static inline int
-+ext3cow_xattr_set(struct inode *inode, int name_index, const char *name,
-+	       const void *value, size_t size, int flags)
-+{
-+	return -EOPNOTSUPP;
-+}
-+
-+static inline int
-+ext3cow_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
-+	       const char *name, const void *value, size_t size, int flags)
-+{
-+	return -EOPNOTSUPP;
-+}
-+
-+static inline void
-+ext3cow_xattr_delete_inode(handle_t *handle, struct inode *inode)
-+{
-+}
-+
-+static inline void
-+ext3cow_xattr_put_super(struct super_block *sb)
-+{
-+}
-+
-+static inline int
-+init_ext3cow_xattr(void)
-+{
-+	return 0;
-+}
-+
-+static inline void
-+exit_ext3cow_xattr(void)
-+{
-+}
-+
-+#define ext3cow_xattr_handlers	NULL
-+
-+# endif  /* CONFIG_EXT3COW_FS_XATTR */
-+
-+#ifdef CONFIG_EXT3COW_FS_SECURITY
-+extern int ext3cow_init_security(handle_t *handle, struct inode *inode,
-+				struct inode *dir);
-+#else
-+static inline int ext3cow_init_security(handle_t *handle, struct inode *inode,
-+				struct inode *dir)
-+{
-+	return 0;
-+}
-+#endif
-diff -Naur linux-2.6.21.7/fs/ext3cow/xattr_security.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr_security.c
---- linux-2.6.21.7/fs/ext3cow/xattr_security.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr_security.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,77 @@
-+/*
-+ * linux/fs/ext3cow/xattr_security.c
-+ * Handler for storing security labels as extended attributes.
-+ */
-+
-+#include <linux/module.h>
-+#include <linux/string.h>
-+#include <linux/fs.h>
-+#include <linux/smp_lock.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include <linux/security.h>
-+#include "xattr.h"
-+
-+static size_t
-+ext3cow_xattr_security_list(struct inode *inode, char *list, size_t list_size,
-+			 const char *name, size_t name_len)
-+{
-+	const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
-+	const size_t total_len = prefix_len + name_len + 1;
-+
-+
-+	if (list && total_len <= list_size) {
-+		memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
-+		memcpy(list+prefix_len, name, name_len);
-+		list[prefix_len + name_len] = '\0';
-+	}
-+	return total_len;
-+}
-+
-+static int
-+ext3cow_xattr_security_get(struct inode *inode, const char *name,
-+		       void *buffer, size_t size)
-+{
-+	if (strcmp(name, "") == 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_get(inode, EXT3COW_XATTR_INDEX_SECURITY, name,
-+			      buffer, size);
-+}
-+
-+static int
-+ext3cow_xattr_security_set(struct inode *inode, const char *name,
-+		       const void *value, size_t size, int flags)
-+{
-+	if (strcmp(name, "") == 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_set(inode, EXT3COW_XATTR_INDEX_SECURITY, name,
-+			      value, size, flags);
-+}
-+
-+int
-+ext3cow_init_security(handle_t *handle, struct inode *inode, struct inode *dir)
-+{
-+	int err;
-+	size_t len;
-+	void *value;
-+	char *name;
-+
-+	err = security_inode_init_security(inode, dir, &name, &value, &len);
-+	if (err) {
-+		if (err == -EOPNOTSUPP)
-+			return 0;
-+		return err;
-+	}
-+	err = ext3cow_xattr_set_handle(handle, inode, EXT3COW_XATTR_INDEX_SECURITY,
-+				    name, value, len, 0);
-+	kfree(name);
-+	kfree(value);
-+	return err;
-+}
-+
-+struct xattr_handler ext3cow_xattr_security_handler = {
-+	.prefix	= XATTR_SECURITY_PREFIX,
-+	.list	= ext3cow_xattr_security_list,
-+	.get	= ext3cow_xattr_security_get,
-+	.set	= ext3cow_xattr_security_set,
-+};
-diff -Naur linux-2.6.21.7/fs/ext3cow/xattr_trusted.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr_trusted.c
---- linux-2.6.21.7/fs/ext3cow/xattr_trusted.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr_trusted.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,62 @@
-+/*
-+ * linux/fs/ext3cow/xattr_trusted.c
-+ * Handler for trusted extended attributes.
-+ *
-+ * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
-+ */
-+
-+#include <linux/module.h>
-+#include <linux/string.h>
-+#include <linux/capability.h>
-+#include <linux/fs.h>
-+#include <linux/smp_lock.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include "xattr.h"
-+
-+#define XATTR_TRUSTED_PREFIX "trusted."
-+
-+static size_t
-+ext3cow_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
-+			const char *name, size_t name_len)
-+{
-+	const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1;
-+	const size_t total_len = prefix_len + name_len + 1;
-+
-+	if (!capable(CAP_SYS_ADMIN))
-+		return 0;
-+
-+	if (list && total_len <= list_size) {
-+		memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
-+		memcpy(list+prefix_len, name, name_len);
-+		list[prefix_len + name_len] = '\0';
-+	}
-+	return total_len;
-+}
-+
-+static int
-+ext3cow_xattr_trusted_get(struct inode *inode, const char *name,
-+		       void *buffer, size_t size)
-+{
-+	if (strcmp(name, "") == 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_get(inode, EXT3COW_XATTR_INDEX_TRUSTED, name,
-+			      buffer, size);
-+}
-+
-+static int
-+ext3cow_xattr_trusted_set(struct inode *inode, const char *name,
-+		       const void *value, size_t size, int flags)
-+{
-+	if (strcmp(name, "") == 0)
-+		return -EINVAL;
-+	return ext3cow_xattr_set(inode, EXT3COW_XATTR_INDEX_TRUSTED, name,
-+			      value, size, flags);
-+}
-+
-+struct xattr_handler ext3cow_xattr_trusted_handler = {
-+	.prefix	= XATTR_TRUSTED_PREFIX,
-+	.list	= ext3cow_xattr_trusted_list,
-+	.get	= ext3cow_xattr_trusted_get,
-+	.set	= ext3cow_xattr_trusted_set,
-+};
-diff -Naur linux-2.6.21.7/fs/ext3cow/xattr_user.c linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr_user.c
---- linux-2.6.21.7/fs/ext3cow/xattr_user.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/fs/ext3cow/xattr_user.c	2007-10-23 17:47:18.000000000 +0200
-@@ -0,0 +1,64 @@
-+/*
-+ * linux/fs/ext3cow/xattr_user.c
-+ * Handler for extended user attributes.
-+ *
-+ * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
-+ */
-+
-+#include <linux/module.h>
-+#include <linux/string.h>
-+#include <linux/fs.h>
-+#include <linux/smp_lock.h>
-+#include <linux/ext3cow_jbd.h>
-+#include <linux/ext3cow_fs.h>
-+#include "xattr.h"
-+
-+#define XATTR_USER_PREFIX "user."
-+
-+static size_t
-+ext3cow_xattr_user_list(struct inode *inode, char *list, size_t list_size,
-+		     const char *name, size_t name_len)
-+{
-+	const size_t prefix_len = sizeof(XATTR_USER_PREFIX)-1;
-+	const size_t total_len = prefix_len + name_len + 1;
-+
-+	if (!test_opt(inode->i_sb, XATTR_USER))
-+		return 0;
-+
-+	if (list && total_len <= list_size) {
-+		memcpy(list, XATTR_USER_PREFIX, prefix_len);
-+		memcpy(list+prefix_len, name, name_len);
-+		list[prefix_len + name_len] = '\0';
-+	}
-+	return total_len;
-+}
-+
-+static int
-+ext3cow_xattr_user_get(struct inode *inode, const char *name,
-+		    void *buffer, size_t size)
-+{
-+	if (strcmp(name, "") == 0)
-+		return -EINVAL;
-+	if (!test_opt(inode->i_sb, XATTR_USER))
-+		return -EOPNOTSUPP;
-+	return ext3cow_xattr_get(inode, EXT3COW_XATTR_INDEX_USER, name, buffer, size);
-+}
-+
-+static int
-+ext3cow_xattr_user_set(struct inode *inode, const char *name,
-+		    const void *value, size_t size, int flags)
-+{
-+	if (strcmp(name, "") == 0)
-+		return -EINVAL;
-+	if (!test_opt(inode->i_sb, XATTR_USER))
-+		return -EOPNOTSUPP;
-+	return ext3cow_xattr_set(inode, EXT3COW_XATTR_INDEX_USER, name,
-+			      value, size, flags);
-+}
-+
-+struct xattr_handler ext3cow_xattr_user_handler = {
-+	.prefix	= XATTR_USER_PREFIX,
-+	.list	= ext3cow_xattr_user_list,
-+	.get	= ext3cow_xattr_user_get,
-+	.set	= ext3cow_xattr_user_set,
-+};
-diff -Naur linux-2.6.21.7/fs/Kconfig linux-2.6.21.7_ext3cowPatched/fs/Kconfig
---- linux-2.6.21.7/fs/Kconfig	2007-08-04 18:11:13.000000000 +0200
-+++ linux-2.6.21.7_ext3cowPatched/fs/Kconfig	2007-10-23 17:46:52.000000000 +0200
-@@ -136,6 +136,77 @@
- 	  If you are not using a security module that requires using
- 	  extended attributes for file security labels, say N.
- 
-+
-+
-+config EXT3COW_FS
-+	tristate "Ext3cow journalling and versioning file system support"
-+	select JBD
-+	help
-+	  This is the journalling version of the Second extended file system
-+	  (often called ext3), the de facto standard Linux file system
-+	  (method to organize files on a storage device) for hard disks.
-+
-+	  The journalling code included in this driver means you do not have
-+	  to run e2fsck (file system checker) on your file systems after a
-+	  crash.  The journal keeps track of any changes that were being made
-+	  at the time the system crashed, and can ensure that your file system
-+	  is consistent without the need for a lengthy check.
-+
-+	  Other than adding the journal to the file system, the on-disk format
-+	  of ext3 is identical to ext2.  It is possible to freely switch
-+	  between using the ext3 driver and the ext2 driver, as long as the
-+	  file system has been cleanly unmounted, or e2fsck is run on the file
-+	  system.
-+
-+	  To add a journal on an existing ext2 file system or change the
-+	  behavior of ext3 file systems, you can use the tune2fs utility ("man
-+	  tune2fs").  To modify attributes of files and directories on ext3
-+	  file systems, use chattr ("man chattr").  You need to be using
-+	  e2fsprogs version 1.20 or later in order to create ext3 journals
-+	  (available at <http://sourceforge.net/projects/e2fsprogs/>).
-+
-+	  To compile this file system support as a module, choose M here: the
-+	  module will be called ext3.
-+
-+config EXT3COW_FS_XATTR
-+	bool "Ext3cow extended attributes"
-+	depends on EXT3COW_FS
-+	default y
-+	help
-+	  Extended attributes are name:value pairs associated with inodes by
-+	  the kernel or by users (see the attr(5) manual page, or visit
-+	  <http://acl.bestbits.at/> for details).
-+
-+	  If unsure, say N.
-+
-+	  You need this for POSIX ACL support on ext3cow.
-+
-+config EXT3COW_FS_POSIX_ACL
-+	bool "Ext3cow POSIX Access Control Lists"
-+	depends on EXT3COW_FS_XATTR
-+	select FS_POSIX_ACL
-+	help
-+	  Posix Access Control Lists (ACLs) support permissions for users and
-+	  groups beyond the owner/group/world scheme.
-+
-+	  To learn more about Access Control Lists, visit the Posix ACLs for
-+	  Linux website <http://acl.bestbits.at/>.
-+
-+	  If you don't know what Access Control Lists are, say N
-+
-+config EXT3COW_FS_SECURITY
-+	bool "Ext3cow Security Labels"
-+	depends on EXT3COW_FS_XATTR
-+	help
-+	  Security labels support alternative access control models
-+	  implemented by security modules like SELinux.  This option
-+	  enables an extended attribute handler for file security
-+	  labels in the ext3cow filesystem.
-+
-+	  If you are not using a security module that requires using
-+	  extended attributes for file security labels, say N.
-+
-+
- config EXT4DEV_FS
- 	tristate "Ext4dev/ext4 extended fs support development (EXPERIMENTAL)"
- 	depends on EXPERIMENTAL
-@@ -205,23 +276,23 @@
- 	tristate
- 	help
- 	  This is a generic journalling layer for block devices.  It is
--	  currently used by the ext3 and OCFS2 file systems, but it could
-+	  currently used by the ext3, ext3cow and OCFS2 file systems, but it could
- 	  also be used to add journal support to other file systems or block
- 	  devices such as RAID or LVM.
- 
--	  If you are using the ext3 or OCFS2 file systems, you need to
-+	  If you are using the ext3, ext3cow or OCFS2 file systems, you need to
- 	  say Y here. If you are not using ext3 OCFS2 then you will probably
- 	  want to say N.
- 
- 	  To compile this device as a module, choose M here: the module will be
--	  called jbd.  If you are compiling ext3 or OCFS2 into the kernel,
-+	  called jbd.  If you are compiling ext3, ext3cow or OCFS2 into the kernel,
- 	  you cannot compile this code as a module.
- 
- config JBD_DEBUG
- 	bool "JBD (ext3) debugging support"
- 	depends on JBD
- 	help
--	  If you are using the ext3 journaled file system (or potentially any
-+	  If you are using the ext3 or ext3cow journaled file system (or potentially any
- 	  other file system/device using JBD), this option allows you to
- 	  enable debugging output while the system is running, in order to
- 	  help track down any problems you are having.  By default the
-@@ -266,11 +337,12 @@
- 	  "echo 0 > /proc/sys/fs/jbd2-debug".
- 
- config FS_MBCACHE
--# Meta block cache for Extended Attributes (ext2/ext3/ext4)
-+# Meta block cache for Extended Attributes (ext2/ext3(cow)/ext4)
- 	tristate
--	depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT4DEV_FS_XATTR
--	default y if EXT2_FS=y || EXT3_FS=y || EXT4DEV_FS=y
--	default m if EXT2_FS=m || EXT3_FS=m || EXT4DEV_FS=m
-+	depends on EXT2_FS_XATTR || EXT3_FS_XATTR || EXT3COW_FS_XATTR || EXT4DEV_FS_XATTR
-+	default y if EXT2_FS=y || EXT3_FS=y || EXT3COW_FS=y || EXT4DEV_FS=y
-+	default m if EXT2_FS=m || EXT3_FS=m || EXT3COW_FS=m || EXT4DEV_FS=m
-+
- 
- config REISERFS_FS
- 	tristate "Reiserfs support"
-diff -Naur linux-2.6.21.7/fs/Makefile linux-2.6.21.7_ext3cowPatched/fs/Makefile
---- linux-2.6.21.7/fs/Makefile	2007-08-04 18:11:13.000000000 +0200
-+++ linux-2.6.21.7_ext3cowPatched/fs/Makefile	2007-10-23 17:46:52.000000000 +0200
-@@ -63,6 +63,7 @@
- # Do not add any filesystems before this line
- obj-$(CONFIG_REISERFS_FS)	+= reiserfs/
- obj-$(CONFIG_EXT3_FS)		+= ext3/ # Before ext2 so root fs can be ext3
-+obj-$(CONFIG_EXT3COW_FS)		+= ext3cow/ # Before ext2 so root fs can be ext3
- obj-$(CONFIG_EXT4DEV_FS)	+= ext4/ # Before ext2 so root fs can be ext4dev
- obj-$(CONFIG_JBD)		+= jbd/
- obj-$(CONFIG_JBD2)		+= jbd2/
-diff -Naur linux-2.6.21.7/include/linux/ext3cow_fs.h linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_fs.h
---- linux-2.6.21.7/include/linux/ext3cow_fs.h	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_fs.h	2007-10-23 17:48:10.000000000 +0200
-@@ -0,0 +1,948 @@
-+/*
-+ *  linux/include/linux/ext3cow_fs.h
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/include/linux/minix_fs.h
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ */
-+
-+#ifndef _LINUX_EXT3COW_FS_H
-+#define _LINUX_EXT3COW_FS_H
-+
-+#include <linux/types.h>
-+#include <linux/magic.h>
-+
-+/*
-+ * The second extended filesystem constants/structures
-+ */
-+
-+/*
-+ * Define EXT3COWFS_DEBUG to produce debug messages
-+ */
-+#undef EXT3COWFS_DEBUG
-+
-+
-+/*
-+ * Define EXT3COW_RESERVATION to reserve data blocks for expanding files
-+ */
-+#define EXT3COW_DEFAULT_RESERVE_BLOCKS     8
-+/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
-+#define EXT3COW_MAX_RESERVE_BLOCKS         1027
-+#define EXT3COW_RESERVE_WINDOW_NOT_ALLOCATED 0
-+/*
-+ * Always enable hashed directories
-+ */
-+//#define CONFIG_EXT3COW_INDEX
-+
-+/*
-+ * Debug code
-+ */
-+#ifdef EXT3COWFS_DEBUG
-+#define ext3cow_debug(f, a...)						\
-+	do {								\
-+		printk (KERN_DEBUG "EXT3COW-fs DEBUG (%s, %d): %s:",	\
-+			__FILE__, __LINE__, __FUNCTION__);		\
-+		printk (KERN_DEBUG f, ## a);				\
-+	} while (0)
-+#else
-+#define ext3cow_debug(f, a...)	do {} while (0)
-+#endif
-+
-+/*
-+ * Special inodes numbers
-+ */
-+#define	EXT3COW_BAD_INO		 1	/* Bad blocks inode */
-+#define EXT3COW_ROOT_INO		 2	/* Root inode */
-+#define EXT3COW_BOOT_LOADER_INO	 5	/* Boot loader inode */
-+#define EXT3COW_UNDEL_DIR_INO	 6	/* Undelete directory inode */
-+#define EXT3COW_RESIZE_INO		 7	/* Reserved group descriptors inode */
-+#define EXT3COW_JOURNAL_INO	 8	/* Journal inode */
-+
-+/* First non-reserved inode for old ext3cow filesystems */
-+#define EXT3COW_GOOD_OLD_FIRST_INO	11
-+
-+/*
-+ * Maximal count of links to a file
-+ */
-+#define EXT3COW_LINK_MAX		32000
-+
-+/* For versioning -znjp */
-+#define EXT3COW_FLUX_TOKEN '@'
-+/* Macros for scoping - in seconds -znjp */
-+#define ONEHOUR   3600
-+#define YESTERDAY 86400
-+#define ONEWEEK   604800
-+#define ONEMONTH  2419200
-+#define ONEYEAR   31449600
-+
-+/*
-+ * Macro-instructions used to manage several block sizes
-+ */
-+#define EXT3COW_MIN_BLOCK_SIZE		1024
-+#define	EXT3COW_MAX_BLOCK_SIZE		4096
-+#define EXT3COW_MIN_BLOCK_LOG_SIZE		  10
-+#ifdef __KERNEL__
-+# define EXT3COW_BLOCK_SIZE(s)		((s)->s_blocksize)
-+#else
-+# define EXT3COW_BLOCK_SIZE(s)		(EXT3COW_MIN_BLOCK_SIZE << (s)->s_log_block_size)
-+#endif
-+//#define	EXT3COW_ADDR_PER_BLOCK(s)		(EXT3COW_BLOCK_SIZE(s) / sizeof (__u32))
-+#ifdef __KERNEL__
-+# define EXT3COW_BLOCK_SIZE_BITS(s)	((s)->s_blocksize_bits)
-+#else
-+# define EXT3COW_BLOCK_SIZE_BITS(s)	((s)->s_log_block_size + 10)
-+#endif
-+#ifdef __KERNEL__
-+#define	EXT3COW_ADDR_PER_BLOCK_BITS(s)	(EXT3COW_SB(s)->s_addr_per_block_bits)
-+#define EXT3COW_INODE_SIZE(s)		(EXT3COW_SB(s)->s_inode_size)
-+#define EXT3COW_FIRST_INO(s)		(EXT3COW_SB(s)->s_first_ino)
-+#else
-+#define EXT3COW_INODE_SIZE(s)	(((s)->s_rev_level == EXT3COW_GOOD_OLD_REV) ? \
-+				 EXT3COW_GOOD_OLD_INODE_SIZE : \
-+				 (s)->s_inode_size)
-+#define EXT3COW_FIRST_INO(s)	(((s)->s_rev_level == EXT3COW_GOOD_OLD_REV) ? \
-+				 EXT3COW_GOOD_OLD_FIRST_INO : \
-+				 (s)->s_first_ino)
-+#endif
-+/*
-+ * Macro-instructions for versioning support - znjp
-+ */
-+#define EXT3COW_COWBITMAP_SIZE (sizeof(__u32) * 8) /* one word */
-+#define EXT3COW_COWBITMAPS_PER_IBLOCK(s) \
-+  (( (EXT3COW_BLOCK_SIZE(s) / sizeof(__u32)) / (EXT3COW_COWBITMAP_SIZE)))
-+/* Accounts for COW bitmaps */
-+#define EXT3COW_ADDR_PER_BLOCK(s) ((EXT3COW_BLOCK_SIZE(s) / sizeof(__u32)) - EXT3COW_COWBITMAPS_PER_IBLOCK(s))
-+
-+/*
-+ * Macro-instructions used to manage fragments
-+ */
-+#define EXT3COW_MIN_FRAG_SIZE		1024
-+#define	EXT3COW_MAX_FRAG_SIZE		4096
-+#define EXT3COW_MIN_FRAG_LOG_SIZE		  10
-+#ifdef __KERNEL__
-+# define EXT3COW_FRAG_SIZE(s)		(EXT3COW_SB(s)->s_frag_size)
-+# define EXT3COW_FRAGS_PER_BLOCK(s)	(EXT3COW_SB(s)->s_frags_per_block)
-+#else
-+# define EXT3COW_FRAG_SIZE(s)		(EXT3COW_MIN_FRAG_SIZE << (s)->s_log_frag_size)
-+# define EXT3COW_FRAGS_PER_BLOCK(s)	(EXT3COW_BLOCK_SIZE(s) / EXT3COW_FRAG_SIZE(s))
-+#endif
-+
-+/*
-+ * Structure of a blocks group descriptor
-+ */
-+struct ext3cow_group_desc
-+{
-+	__le32	bg_block_bitmap;		/* Blocks bitmap block */
-+	__le32	bg_inode_bitmap;		/* Inodes bitmap block */
-+	__le32	bg_inode_table;		/* Inodes table block */
-+	__le16	bg_free_blocks_count;	/* Free blocks count */
-+	__le16	bg_free_inodes_count;	/* Free inodes count */
-+	__le16	bg_used_dirs_count;	/* Directories count */
-+	__u16	bg_pad;
-+	__le32	bg_reserved[3];
-+};
-+
-+/*
-+ * Macro-instructions used to manage group descriptors
-+ */
-+#ifdef __KERNEL__
-+# define EXT3COW_BLOCKS_PER_GROUP(s)	(EXT3COW_SB(s)->s_blocks_per_group)
-+# define EXT3COW_DESC_PER_BLOCK(s)		(EXT3COW_SB(s)->s_desc_per_block)
-+# define EXT3COW_INODES_PER_GROUP(s)	(EXT3COW_SB(s)->s_inodes_per_group)
-+# define EXT3COW_DESC_PER_BLOCK_BITS(s)	(EXT3COW_SB(s)->s_desc_per_block_bits)
-+#else
-+# define EXT3COW_BLOCKS_PER_GROUP(s)	((s)->s_blocks_per_group)
-+# define EXT3COW_DESC_PER_BLOCK(s)		(EXT3COW_BLOCK_SIZE(s) / sizeof (struct ext3cow_group_desc))
-+# define EXT3COW_INODES_PER_GROUP(s)	((s)->s_inodes_per_group)
-+#endif
-+
-+/*
-+ * Constants relative to the data blocks
-+ */
-+#define	EXT3COW_NDIR_BLOCKS		12
-+#define	EXT3COW_IND_BLOCK			EXT3COW_NDIR_BLOCKS
-+#define	EXT3COW_DIND_BLOCK			(EXT3COW_IND_BLOCK + 1)
-+#define	EXT3COW_TIND_BLOCK			(EXT3COW_DIND_BLOCK + 1)
-+#define	EXT3COW_N_BLOCKS			(EXT3COW_TIND_BLOCK + 1)
-+
-+/*
-+ * Inode flags
-+ */
-+#define	EXT3COW_SECRM_FL			0x00000001 /* Secure deletion */
-+#define	EXT3COW_UNRM_FL			0x00000002 /* Undelete */
-+#define	EXT3COW_COMPR_FL			0x00000004 /* Compress file */
-+#define EXT3COW_SYNC_FL			0x00000008 /* Synchronous updates */
-+#define EXT3COW_IMMUTABLE_FL		0x00000010 /* Immutable file */
-+#define EXT3COW_APPEND_FL			0x00000020 /* writes to file may only append */
-+#define EXT3COW_NODUMP_FL			0x00000040 /* do not dump file */
-+#define EXT3COW_NOATIME_FL			0x00000080 /* do not update atime */
-+/* Reserved for compression usage... */
-+#define EXT3COW_DIRTY_FL			0x00000100
-+#define EXT3COW_COMPRBLK_FL		0x00000200 /* One or more compressed clusters */
-+#define EXT3COW_NOCOMPR_FL			0x00000400 /* Don't compress */
-+#define EXT3COW_ECOMPR_FL			0x00000800 /* Compression error */
-+/* End compression flags --- maybe not all used */
-+#define EXT3COW_INDEX_FL			0x00001000 /* hash-indexed directory */
-+#define EXT3COW_IMAGIC_FL			0x00002000 /* AFS directory */
-+#define EXT3COW_JOURNAL_DATA_FL		0x00004000 /* file data should be journaled */
-+#define EXT3COW_NOTAIL_FL			0x00008000 /* file tail should not be merged */
-+#define EXT3COW_DIRSYNC_FL			0x00010000 /* dirsync behaviour (directories only) */
-+#define EXT3COW_TOPDIR_FL			0x00020000 /* Top of directory hierarchies*/
-+/* Used for Versioning - znjp */
-+#define EXT3COW_UNCHANGEABLE_FL 0x00040000
-+#define EXT3COW_UNVERSIONABLE_FL 0x00080000
-+#define EXT3COW_FAKEINODE_FL    0x00100000
-+#define EXT3COW_RESERVED_FL		0x80000000 /* reserved for ext3cow lib */
-+
-+#define EXT3COW_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */
-+#define EXT3COW_FL_USER_MODIFIABLE		0x000380FF /* User modifiable flags */
-+
-+/*
-+ * Inode dynamic state flags
-+ */
-+#define EXT3COW_STATE_JDATA		0x00000001 /* journaled data exists */
-+#define EXT3COW_STATE_NEW			0x00000002 /* inode is newly created */
-+#define EXT3COW_STATE_XATTR		0x00000004 /* has in-inode xattrs */
-+
-+/* Used to pass group descriptor data when online resize is done */
-+struct ext3cow_new_group_input {
-+	__u32 group;            /* Group number for this data */
-+	__u32 block_bitmap;     /* Absolute block number of block bitmap */
-+	__u32 inode_bitmap;     /* Absolute block number of inode bitmap */
-+	__u32 inode_table;      /* Absolute block number of inode table start */
-+	__u32 blocks_count;     /* Total number of blocks in this group */
-+	__u16 reserved_blocks;  /* Number of reserved blocks in this group */
-+	__u16 unused;
-+};
-+
-+/* The struct ext3cow_new_group_input in kernel space, with free_blocks_count */
-+struct ext3cow_new_group_data {
-+	__u32 group;
-+	__u32 block_bitmap;
-+	__u32 inode_bitmap;
-+	__u32 inode_table;
-+	__u32 blocks_count;
-+	__u16 reserved_blocks;
-+	__u16 unused;
-+	__u32 free_blocks_count;
-+};
-+
-+
-+/*
-+ * ioctl commands
-+ */
-+#define	EXT3COW_IOC_GETFLAGS		FS_IOC_GETFLAGS
-+#define	EXT3COW_IOC_SETFLAGS		FS_IOC_SETFLAGS
-+#define	EXT3COW_IOC_GETVERSION		_IOR('f', 3, long)
-+#define	EXT3COW_IOC_SETVERSION		_IOW('f', 4, long)
-+#define EXT3COW_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
-+#define EXT3COW_IOC_GROUP_ADD		_IOW('f', 8,struct ext3cow_new_group_input)
-+#define	EXT3COW_IOC_GETVERSION_OLD		FS_IOC_GETVERSION
-+#define	EXT3COW_IOC_SETVERSION_OLD		FS_IOC_SETVERSION
-+#ifdef CONFIG_JBD_DEBUG
-+#define EXT3COW_IOC_WAIT_FOR_READONLY	_IOR('f', 99, long)
-+#endif
-+#define EXT3COW_IOC_GETRSVSZ		_IOR('f', 5, long)
-+#define EXT3COW_IOC_SETRSVSZ		_IOW('f', 6, long)
-+/* ioctls for versioning - znjp */
-+#define EXT3COW_IOC_TAKESNAPSHOT _IOR('f', 7, long)
-+#define EXT3COW_IOC_GETEPOCH _IOR('f', 8, long)
-+
-+/*
-+ * ioctl commands in 32 bit emulation
-+ */
-+#define EXT3COW_IOC32_GETFLAGS		FS_IOC32_GETFLAGS
-+#define EXT3COW_IOC32_SETFLAGS		FS_IOC32_SETFLAGS
-+#define EXT3COW_IOC32_GETVERSION		_IOR('f', 3, int)
-+#define EXT3COW_IOC32_SETVERSION		_IOW('f', 4, int)
-+#define EXT3COW_IOC32_GETRSVSZ		_IOR('f', 5, int)
-+#define EXT3COW_IOC32_SETRSVSZ		_IOW('f', 6, int)
-+#define EXT3COW_IOC32_GROUP_EXTEND		_IOW('f', 7, unsigned int)
-+#ifdef CONFIG_JBD_DEBUG
-+#define EXT3COW_IOC32_WAIT_FOR_READONLY	_IOR('f', 99, int)
-+#endif
-+#define EXT3COW_IOC32_GETVERSION_OLD	FS_IOC32_GETVERSION
-+#define EXT3COW_IOC32_SETVERSION_OLD	FS_IOC32_SETVERSION
-+
-+
-+/*
-+ *  Mount options
-+ */
-+struct ext3cow_mount_options {
-+	unsigned long s_mount_opt;
-+	uid_t s_resuid;
-+	gid_t s_resgid;
-+	unsigned long s_commit_interval;
-+#ifdef CONFIG_QUOTA
-+	int s_jquota_fmt;
-+	char *s_qf_names[MAXQUOTAS];
-+#endif
-+};
-+
-+/*
-+ * Structure of an inode on the disk
-+ */
-+struct ext3cow_inode {
-+	__le16	i_mode;		/* File mode */
-+	__le16	i_uid;		/* Low 16 bits of Owner Uid */
-+	__le32	i_size;		/* Size in bytes */
-+	__le32	i_atime;	/* Access time */
-+	__le32	i_ctime;	/* Creation time */
-+	__le32	i_mtime;	/* Modification time */
-+	__le32	i_dtime;	/* Deletion Time */
-+	__le16	i_gid;		/* Low 16 bits of Group Id */
-+	__le16	i_links_count;	/* Links count */
-+	__le32	i_blocks;	/* Blocks count */
-+	__le32	i_flags;	/* File flags */
-+	union {
-+		struct {
-+			//__u32  l_i_reserved1;
-+      /* Direct block COW bitmap -znjp */
-+      __u16 l_i_direct_cow_bitmap;
-+      __u16 l_i_pad1;
-+		} linux1;
-+		struct {
-+			__u32  h_i_translator;
-+		} hurd1;
-+		struct {
-+			__u32  m_i_reserved1;
-+		} masix1;
-+	} osd1;				/* OS dependent 1 */
-+	__le32	i_block[EXT3COW_N_BLOCKS];/* Pointers to blocks */
-+	__le32	i_generation;	/* File version (for NFS) */
-+	__le32	i_file_acl;	/* File ACL */
-+	__le32	i_dir_acl;	/* Directory ACL */
-+	__le32	i_faddr;	/* Fragment address */
-+	union {
-+		struct {
-+			//__u8	l_i_frag;	/* Fragment number */
-+			//__u8	l_i_fsize;	/* Fragment size */
-+			//__u16	i_pad1;
-+			__le16	l_i_uid_high;	/* these 2 fields    */
-+			__le16	l_i_gid_high;	/* were reserved2[0] */
-+			//__u32	l_i_reserved2;
-+      /* Epoch number for versioning -znjp */
-+      __le32 l_i_epoch_number;
-+      __u32 l_i_next_inode;
-+		} linux2;
-+		struct {
-+			__u8	h_i_frag;	/* Fragment number */
-+			__u8	h_i_fsize;	/* Fragment size */
-+			__u16	h_i_mode_high;
-+			__u16	h_i_uid_high;
-+			__u16	h_i_gid_high;
-+			__u32	h_i_author;
-+		} hurd2;
-+		struct {
-+			__u8	m_i_frag;	/* Fragment number */
-+			__u8	m_i_fsize;	/* Fragment size */
-+			__u16	m_pad1;
-+			__u32	m_i_reserved2[2];
-+		} masix2;
-+	} osd2;				/* OS dependent 2 */
-+	__le16	i_extra_isize;
-+	__le16	i_pad1;
-+};
-+
-+#define i_size_high	i_dir_acl
-+
-+#if defined(__KERNEL__) || defined(__linux__)
-+/* For versioning -znjp */
-+//#define i_reserved1	osd1.linux1.l_i_reserved1
-+#define i_cowbitmap osd1.linux1.l_i_direct_cow_bitmap
-+//#define i_frag		osd2.linux2.l_i_frag
-+//#define i_fsize		osd2.linux2.l_i_fsize
-+#define i_uid_low	i_uid
-+#define i_gid_low	i_gid
-+/* For versioning -znjp */
-+#define i_uid_high	osd2.linux2.l_i_uid_high
-+#define i_gid_high	osd2.linux2.l_i_gid_high
-+//#define i_reserved2	osd2.linux2.l_i_reserved2
-+#define i_epch_number osd2.linux2.l_i_epoch_number
-+#define i_nxt_inode osd2.linux2.l_i_next_inode
-+
-+#elif defined(__GNU__)
-+
-+#define i_translator	osd1.hurd1.h_i_translator
-+#define i_frag		osd2.hurd2.h_i_frag;
-+#define i_fsize		osd2.hurd2.h_i_fsize;
-+#define i_uid_high	osd2.hurd2.h_i_uid_high
-+#define i_gid_high	osd2.hurd2.h_i_gid_high
-+#define i_author	osd2.hurd2.h_i_author
-+
-+#elif defined(__masix__)
-+
-+#define i_reserved1	osd1.masix1.m_i_reserved1
-+#define i_frag		osd2.masix2.m_i_frag
-+#define i_fsize		osd2.masix2.m_i_fsize
-+#define i_reserved2	osd2.masix2.m_i_reserved2
-+
-+#endif /* defined(__KERNEL__) || defined(__linux__) */
-+
-+/*
-+ * File system states
-+ */
-+#define	EXT3COW_VALID_FS			0x0001	/* Unmounted cleanly */
-+#define	EXT3COW_ERROR_FS			0x0002	/* Errors detected */
-+#define	EXT3COW_ORPHAN_FS			0x0004	/* Orphans being recovered */
-+
-+/*
-+ * Mount flags
-+ */
-+#define EXT3COW_MOUNT_CHECK		0x00001	/* Do mount-time checks */
-+#define EXT3COW_MOUNT_OLDALLOC		0x00002  /* Don't use the new Orlov allocator */
-+#define EXT3COW_MOUNT_GRPID		0x00004	/* Create files with directory's group */
-+#define EXT3COW_MOUNT_DEBUG		0x00008	/* Some debugging messages */
-+#define EXT3COW_MOUNT_ERRORS_CONT		0x00010	/* Continue on errors */
-+#define EXT3COW_MOUNT_ERRORS_RO		0x00020	/* Remount fs ro on errors */
-+#define EXT3COW_MOUNT_ERRORS_PANIC		0x00040	/* Panic on errors */
-+#define EXT3COW_MOUNT_MINIX_DF		0x00080	/* Mimics the Minix statfs */
-+#define EXT3COW_MOUNT_NOLOAD		0x00100	/* Don't use existing journal*/
-+#define EXT3COW_MOUNT_ABORT		0x00200	/* Fatal error detected */
-+#define EXT3COW_MOUNT_DATA_FLAGS		0x00C00	/* Mode for data writes: */
-+#define EXT3COW_MOUNT_JOURNAL_DATA		0x00400	/* Write data to journal */
-+#define EXT3COW_MOUNT_ORDERED_DATA		0x00800	/* Flush data before commit */
-+#define EXT3COW_MOUNT_WRITEBACK_DATA	0x00C00	/* No data ordering */
-+#define EXT3COW_MOUNT_UPDATE_JOURNAL	0x01000	/* Update the journal format */
-+#define EXT3COW_MOUNT_NO_UID32		0x02000  /* Disable 32-bit UIDs */
-+#define EXT3COW_MOUNT_XATTR_USER		0x04000	/* Extended user attributes */
-+#define EXT3COW_MOUNT_POSIX_ACL		0x08000	/* POSIX Access Control Lists */
-+#define EXT3COW_MOUNT_RESERVATION		0x10000	/* Preallocation */
-+#define EXT3COW_MOUNT_BARRIER		0x20000 /* Use block barriers */
-+#define EXT3COW_MOUNT_NOBH			0x40000 /* No bufferheads */
-+#define EXT3COW_MOUNT_QUOTA		0x80000 /* Some quota option set */
-+#define EXT3COW_MOUNT_USRQUOTA		0x100000 /* "old" user quota */
-+#define EXT3COW_MOUNT_GRPQUOTA		0x200000 /* "old" group quota */
-+
-+/* Compatibility, for having both ext2_fs.h and ext3cow_fs.h included at once */
-+#ifndef _LINUX_EXT2_FS_H
-+#define clear_opt(o, opt)		o &= ~EXT3COW_MOUNT_##opt
-+#define set_opt(o, opt)			o |= EXT3COW_MOUNT_##opt
-+#define test_opt(sb, opt)		(EXT3COW_SB(sb)->s_mount_opt & \
-+					 EXT3COW_MOUNT_##opt)
-+#else
-+#define EXT2_MOUNT_NOLOAD		EXT3COW_MOUNT_NOLOAD
-+#define EXT2_MOUNT_ABORT		EXT3COW_MOUNT_ABORT
-+#define EXT2_MOUNT_DATA_FLAGS		EXT3COW_MOUNT_DATA_FLAGS
-+#endif
-+
-+#define ext3cow_set_bit			ext2_set_bit
-+#define ext3cow_set_bit_atomic		ext2_set_bit_atomic
-+#define ext3cow_clear_bit			ext2_clear_bit
-+#define ext3cow_clear_bit_atomic		ext2_clear_bit_atomic
-+#define ext3cow_test_bit			ext2_test_bit
-+#define ext3cow_find_first_zero_bit	ext2_find_first_zero_bit
-+#define ext3cow_find_next_zero_bit		ext2_find_next_zero_bit
-+
-+/*
-+ * Maximal mount counts between two filesystem checks
-+ */
-+#define EXT3COW_DFL_MAX_MNT_COUNT		20	/* Allow 20 mounts */
-+#define EXT3COW_DFL_CHECKINTERVAL		0	/* Don't use interval check */
-+
-+/*
-+ * Behaviour when detecting errors
-+ */
-+#define EXT3COW_ERRORS_CONTINUE		1	/* Continue execution */
-+#define EXT3COW_ERRORS_RO			2	/* Remount fs read-only */
-+#define EXT3COW_ERRORS_PANIC		3	/* Panic */
-+#define EXT3COW_ERRORS_DEFAULT		EXT3COW_ERRORS_CONTINUE
-+
-+/*
-+ * Structure of the super block
-+ */
-+struct ext3cow_super_block {
-+/*00*/	__le32	s_inodes_count;		/* Inodes count */
-+	__le32	s_blocks_count;		/* Blocks count */
-+	__le32	s_r_blocks_count;	/* Reserved blocks count */
-+	__le32	s_free_blocks_count;	/* Free blocks count */
-+/*10*/	__le32	s_free_inodes_count;	/* Free inodes count */
-+	__le32	s_first_data_block;	/* First Data Block */
-+	__le32	s_log_block_size;	/* Block size */
-+	__le32	s_log_frag_size;	/* Fragment size */
-+/*20*/	__le32	s_blocks_per_group;	/* # Blocks per group */
-+	__le32	s_frags_per_group;	/* # Fragments per group */
-+	__le32	s_inodes_per_group;	/* # Inodes per group */
-+	__le32	s_mtime;		/* Mount time */
-+/*30*/	__le32	s_wtime;		/* Write time */
-+	__le16	s_mnt_count;		/* Mount count */
-+	__le16	s_max_mnt_count;	/* Maximal mount count */
-+	__le16	s_magic;		/* Magic signature */
-+	__le16	s_state;		/* File system state */
-+	__le16	s_errors;		/* Behaviour when detecting errors */
-+	__le16	s_minor_rev_level;	/* minor revision level */
-+/*40*/	__le32	s_lastcheck;		/* time of last check */
-+	__le32	s_checkinterval;	/* max. time between checks */
-+	__le32	s_creator_os;		/* OS */
-+	__le32	s_rev_level;		/* Revision level */
-+/*50*/	__le16	s_def_resuid;		/* Default uid for reserved blocks */
-+	__le16	s_def_resgid;		/* Default gid for reserved blocks */
-+	/*
-+	 * These fields are for EXT3COW_DYNAMIC_REV superblocks only.
-+	 *
-+	 * Note: the difference between the compatible feature set and
-+	 * the incompatible feature set is that if there is a bit set
-+	 * in the incompatible feature set that the kernel doesn't
-+	 * know about, it should refuse to mount the filesystem.
-+	 *
-+	 * e2fsck's requirements are more strict; if it doesn't know
-+	 * about a feature in either the compatible or incompatible
-+	 * feature set, it must abort and not try to meddle with
-+	 * things it doesn't understand...
-+	 */
-+	__le32	s_first_ino;		/* First non-reserved inode */
-+	__le16   s_inode_size;		/* size of inode structure */
-+	__le16	s_block_group_nr;	/* block group # of this superblock */
-+	__le32	s_feature_compat;	/* compatible feature set */
-+/*60*/	__le32	s_feature_incompat;	/* incompatible feature set */
-+	__le32	s_feature_ro_compat;	/* readonly-compatible feature set */
-+/*68*/	__u8	s_uuid[16];		/* 128-bit uuid for volume */
-+/*78*/	char	s_volume_name[16];	/* volume name */
-+/*88*/	char	s_last_mounted[64];	/* directory where last mounted */
-+/*C8*/	__le32	s_algorithm_usage_bitmap; /* For compression */
-+	/*
-+	 * Performance hints.  Directory preallocation should only
-+	 * happen if the EXT3COW_FEATURE_COMPAT_DIR_PREALLOC flag is on.
-+	 */
-+	__u8	s_prealloc_blocks;	/* Nr of blocks to try to preallocate*/
-+	__u8	s_prealloc_dir_blocks;	/* Nr to preallocate for dirs */
-+	__le16	s_reserved_gdt_blocks;	/* Per group desc for online growth */
-+	/*
-+	 * Journaling support valid if EXT3COW_FEATURE_COMPAT_HAS_JOURNAL set.
-+	 */
-+/*D0*/	__u8	s_journal_uuid[16];	/* uuid of journal superblock */
-+/*E0*/	__le32	s_journal_inum;		/* inode number of journal file */
-+	__le32	s_journal_dev;		/* device number of journal file */
-+	__le32	s_last_orphan;		/* start of list of inodes to delete */
-+	__le32	s_hash_seed[4];		/* HTREE hash seed */
-+	__u8	s_def_hash_version;	/* Default hash version to use */
-+	__u8	s_reserved_char_pad;
-+	__u16	s_reserved_word_pad;
-+	__le32	s_default_mount_opts;
-+	__le32	s_first_meta_bg;	/* First metablock block group */
-+  /* Added for version - znjp */
-+  __le32 s_epoch_number;
-+	__u32	s_reserved[189];	/* Padding to the end of the block */
-+};
-+
-+#ifdef __KERNEL__
-+#include <linux/ext3cow_fs_i.h>
-+#include <linux/ext3cow_fs_sb.h>
-+static inline struct ext3cow_sb_info * EXT3COW_SB(struct super_block *sb)
-+{
-+	return sb->s_fs_info;
-+}
-+static inline struct ext3cow_inode_info *EXT3COW_I(struct inode *inode)
-+{
-+	return container_of(inode, struct ext3cow_inode_info, vfs_inode);
-+}
-+
-+static inline int ext3cow_valid_inum(struct super_block *sb, unsigned long ino)
-+{
-+	return ino == EXT3COW_ROOT_INO ||
-+		ino == EXT3COW_JOURNAL_INO ||
-+		ino == EXT3COW_RESIZE_INO ||
-+		(ino >= EXT3COW_FIRST_INO(sb) &&
-+		 ino <= le32_to_cpu(EXT3COW_SB(sb)->s_es->s_inodes_count));
-+}
-+#else
-+/* Assume that user mode programs are passing in an ext3cowfs superblock, not
-+ * a kernel struct super_block.  This will allow us to call the feature-test
-+ * macros from user land. */
-+#define EXT3COW_SB(sb)	(sb)
-+#endif
-+
-+#define NEXT_ORPHAN(inode) EXT3COW_I(inode)->i_dtime
-+
-+/*
-+ * Codes for operating systems
-+ */
-+#define EXT3COW_OS_LINUX		0
-+#define EXT3COW_OS_HURD		1
-+#define EXT3COW_OS_MASIX		2
-+#define EXT3COW_OS_FREEBSD		3
-+#define EXT3COW_OS_LITES		4
-+
-+/*
-+ * Revision levels
-+ */
-+#define EXT3COW_GOOD_OLD_REV	0	/* The good old (original) format */
-+#define EXT3COW_DYNAMIC_REV	1	/* V2 format w/ dynamic inode sizes */
-+
-+#define EXT3COW_CURRENT_REV	EXT3COW_GOOD_OLD_REV
-+#define EXT3COW_MAX_SUPP_REV	EXT3COW_DYNAMIC_REV
-+
-+#define EXT3COW_GOOD_OLD_INODE_SIZE 128
-+
-+/*
-+ * Feature set definitions
-+ */
-+
-+#define EXT3COW_HAS_COMPAT_FEATURE(sb,mask)			\
-+	( EXT3COW_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
-+#define EXT3COW_HAS_RO_COMPAT_FEATURE(sb,mask)			\
-+	( EXT3COW_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
-+#define EXT3COW_HAS_INCOMPAT_FEATURE(sb,mask)			\
-+	( EXT3COW_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
-+#define EXT3COW_SET_COMPAT_FEATURE(sb,mask)			\
-+	EXT3COW_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
-+#define EXT3COW_SET_RO_COMPAT_FEATURE(sb,mask)			\
-+	EXT3COW_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
-+#define EXT3COW_SET_INCOMPAT_FEATURE(sb,mask)			\
-+	EXT3COW_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
-+#define EXT3COW_CLEAR_COMPAT_FEATURE(sb,mask)			\
-+	EXT3COW_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
-+#define EXT3COW_CLEAR_RO_COMPAT_FEATURE(sb,mask)			\
-+	EXT3COW_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
-+#define EXT3COW_CLEAR_INCOMPAT_FEATURE(sb,mask)			\
-+	EXT3COW_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
-+
-+#define EXT3COW_FEATURE_COMPAT_DIR_PREALLOC	0x0001
-+#define EXT3COW_FEATURE_COMPAT_IMAGIC_INODES	0x0002
-+#define EXT3COW_FEATURE_COMPAT_HAS_JOURNAL		0x0004
-+#define EXT3COW_FEATURE_COMPAT_EXT_ATTR		0x0008
-+#define EXT3COW_FEATURE_COMPAT_RESIZE_INODE	0x0010
-+#define EXT3COW_FEATURE_COMPAT_DIR_INDEX		0x0020
-+
-+#define EXT3COW_FEATURE_RO_COMPAT_SPARSE_SUPER	0x0001
-+#define EXT3COW_FEATURE_RO_COMPAT_LARGE_FILE	0x0002
-+#define EXT3COW_FEATURE_RO_COMPAT_BTREE_DIR	0x0004
-+
-+#define EXT3COW_FEATURE_INCOMPAT_COMPRESSION	0x0001
-+#define EXT3COW_FEATURE_INCOMPAT_FILETYPE		0x0002
-+#define EXT3COW_FEATURE_INCOMPAT_RECOVER		0x0004 /* Needs recovery */
-+#define EXT3COW_FEATURE_INCOMPAT_JOURNAL_DEV	0x0008 /* Journal device */
-+#define EXT3COW_FEATURE_INCOMPAT_META_BG		0x0010
-+
-+#define EXT3COW_FEATURE_COMPAT_SUPP	EXT2_FEATURE_COMPAT_EXT_ATTR
-+#define EXT3COW_FEATURE_INCOMPAT_SUPP	(EXT3COW_FEATURE_INCOMPAT_FILETYPE| \
-+					 EXT3COW_FEATURE_INCOMPAT_RECOVER| \
-+					 EXT3COW_FEATURE_INCOMPAT_META_BG)
-+#define EXT3COW_FEATURE_RO_COMPAT_SUPP	(EXT3COW_FEATURE_RO_COMPAT_SPARSE_SUPER| \
-+					 EXT3COW_FEATURE_RO_COMPAT_LARGE_FILE| \
-+					 EXT3COW_FEATURE_RO_COMPAT_BTREE_DIR)
-+
-+/*
-+ * Default values for user and/or group using reserved blocks
-+ */
-+#define	EXT3COW_DEF_RESUID		0
-+#define	EXT3COW_DEF_RESGID		0
-+
-+/*
-+ * Default mount options
-+ */
-+#define EXT3COW_DEFM_DEBUG		0x0001
-+#define EXT3COW_DEFM_BSDGROUPS	0x0002
-+#define EXT3COW_DEFM_XATTR_USER	0x0004
-+#define EXT3COW_DEFM_ACL		0x0008
-+#define EXT3COW_DEFM_UID16		0x0010
-+#define EXT3COW_DEFM_JMODE		0x0060
-+#define EXT3COW_DEFM_JMODE_DATA	0x0020
-+#define EXT3COW_DEFM_JMODE_ORDERED	0x0040
-+#define EXT3COW_DEFM_JMODE_WBACK	0x0060
-+
-+/*
-+ * Structure of a directory entry
-+ */
-+#define EXT3COW_NAME_LEN 255
-+
-+struct ext3cow_dir_entry {
-+	__le32	inode;			/* Inode number */
-+	__le16	rec_len;		/* Directory entry length */
-+	__le16	name_len;		/* Name length */
-+	char	name[EXT3COW_NAME_LEN];	/* File name */
-+};
-+
-+/*
-+ * The new version of the directory entry.  Since EXT3COW structures are
-+ * stored in intel byte order, and the name_len field could never be
-+ * bigger than 255 chars, it's safe to reclaim the extra byte for the
-+ * file_type field.
-+ */
-+struct ext3cow_dir_entry_2 {
-+	__le32	inode;			/* Inode number */
-+	__le16	rec_len;		/* Directory entry length */
-+	__u8	name_len;		/* Name length */
-+	__u8	file_type;
-+  /* Added for versioning - znjp */
-+  __u32 birth_epoch;
-+  __u32 death_epoch;
-+	char	name[EXT3COW_NAME_LEN];	/* File name */
-+};
-+
-+/*
-+ * Ext3 directory file types.  Only the low 3 bits are used.  The
-+ * other bits are reserved for now.
-+ */
-+#define EXT3COW_FT_UNKNOWN		0
-+#define EXT3COW_FT_REG_FILE	1
-+#define EXT3COW_FT_DIR		2
-+#define EXT3COW_FT_CHRDEV		3
-+#define EXT3COW_FT_BLKDEV		4
-+#define EXT3COW_FT_FIFO		5
-+#define EXT3COW_FT_SOCK		6
-+#define EXT3COW_FT_SYMLINK		7
-+
-+#define EXT3COW_FT_MAX		8
-+
-+/* Versioning macros - znjp */
-+#define EXT3COW_DIRENT_ALIVE 0
-+#define EXT3COW_IS_DIRENT_ALIVE(de) ((le32_to_cpu(de->death_epoch) == EXT3COW_DIRENT_ALIVE))
-+#define EXT3COW_IS_DIRENT_SCOPED(de, epoch) \
-+((le32_to_cpu(de->birth_epoch) <= epoch) && \
-+(EXT3COW_IS_DIRENT_ALIVE(de) || (!EXT3COW_IS_DIRENT_ALIVE(de) && \
-+le32_to_cpu(de->death_epoch) > epoch)))
-+#define EXT3COW_I_EPOCHNUMBER(inode) (((unsigned int)EXT3COW_I(inode)->i_epoch_number))
-+#define EXT3COW_S_EPOCHNUMBER(sb) (((unsigned int)EXT3COW_SB(sb)->s_epoch_number))
-+#define EXT3COW_I_NEXT_INODE(inode) (((unsigned int)EXT3COW_I(inode)->i_next_inode))
-+#define EXT3COW_IS_UNVERSIONABLE(inode) (((unsigned int)EXT3COW_I(inode)->i_flags & EXT3COW_UNVERSIONABLE_FL))
-+#define EXT3COW_IS_UNCHANGEABLE(inode) (((unsigned int)EXT3COW_I(inode)->i_flags & EXT3COW_UNCHANGEABLE_FL))
-+#define EXT3COW_IS_FAKEINODE(inode) (((unsigned int)EXT3COW_I(inode)->i_flags & EXT3COW_FAKEINODE_FL))
-+
-+
-+/*
-+ * EXT3COW_DIR_PAD defines the directory entries boundaries
-+ *
-+ * NOTE: It must be a multiple of 4
-+ */
-+#define EXT3COW_DIR_PAD			4
-+#define EXT3COW_DIR_ROUND			(EXT3COW_DIR_PAD - 1)
-+/* Added 8 to account for birth and death epochs -znjp */
-+#define EXT3COW_DIR_REC_LEN(name_len)	(((name_len) + 16 + EXT3COW_DIR_ROUND) & \
-+					 ~EXT3COW_DIR_ROUND)
-+/*
-+ * Hash Tree Directory indexing
-+ * (c) Daniel Phillips, 2001
-+ */
-+
-+#ifdef CONFIG_EXT3COW_INDEX
-+  #define is_dx(dir) (EXT3COW_HAS_COMPAT_FEATURE(dir->i_sb, \
-+					      EXT3COW_FEATURE_COMPAT_DIR_INDEX) && \
-+		      (EXT3COW_I(dir)->i_flags & EXT3COW_INDEX_FL))
-+#define EXT3COW_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT3COW_LINK_MAX)
-+#define EXT3COW_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
-+#else
-+  #define is_dx(dir) 0
-+#define EXT3COW_DIR_LINK_MAX(dir) ((dir)->i_nlink >= EXT3COW_LINK_MAX)
-+#define EXT3COW_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2)
-+#endif
-+
-+/* Legal values for the dx_root hash_version field: */
-+
-+#define DX_HASH_LEGACY		0
-+#define DX_HASH_HALF_MD4	1
-+#define DX_HASH_TEA		2
-+
-+#ifdef __KERNEL__
-+
-+/* hash info structure used by the directory hash */
-+struct dx_hash_info
-+{
-+	u32		hash;
-+	u32		minor_hash;
-+	int		hash_version;
-+	u32		*seed;
-+};
-+
-+#define EXT3COW_HTREE_EOF	0x7fffffff
-+
-+/*
-+ * Control parameters used by ext3cow_htree_next_block
-+ */
-+#define HASH_NB_ALWAYS		1
-+
-+
-+/*
-+ * Describe an inode's exact location on disk and in memory
-+ */
-+struct ext3cow_iloc
-+{
-+	struct buffer_head *bh;
-+	unsigned long offset;
-+	unsigned long block_group;
-+};
-+
-+static inline struct ext3cow_inode *ext3cow_raw_inode(struct ext3cow_iloc *iloc)
-+{
-+	return (struct ext3cow_inode *) (iloc->bh->b_data + iloc->offset);
-+}
-+
-+/*
-+ * This structure is stuffed into the struct file's private_data field
-+ * for directories.  It is where we put information so that we can do
-+ * readdir operations in hash tree order.
-+ */
-+struct dir_private_info {
-+	struct rb_root	root;
-+	struct rb_node	*curr_node;
-+	struct fname	*extra_fname;
-+	loff_t		last_pos;
-+	__u32		curr_hash;
-+	__u32		curr_minor_hash;
-+	__u32		next_hash;
-+};
-+
-+/* calculate the first block number of the group */
-+static inline ext3cow_fsblk_t
-+ext3cow_group_first_block_no(struct super_block *sb, unsigned long group_no)
-+{
-+	return group_no * (ext3cow_fsblk_t)EXT3COW_BLOCKS_PER_GROUP(sb) +
-+		le32_to_cpu(EXT3COW_SB(sb)->s_es->s_first_data_block);
-+}
-+
-+/*
-+ * Special error return code only used by dx_probe() and its callers.
-+ */
-+#define ERR_BAD_DX_DIR	-75000
-+
-+/*
-+ * Function prototypes
-+ */
-+
-+/*
-+ * Ok, these declarations are also in <linux/kernel.h> but none of the
-+ * ext3cow source programs needs to include it so they are duplicated here.
-+ */
-+# define NORET_TYPE    /**/
-+# define ATTRIB_NORET  __attribute__((noreturn))
-+# define NORET_AND     noreturn,
-+
-+/* balloc.c */
-+extern int ext3cow_bg_has_super(struct super_block *sb, int group);
-+extern unsigned long ext3cow_bg_num_gdb(struct super_block *sb, int group);
-+extern ext3cow_fsblk_t ext3cow_new_block (handle_t *handle, struct inode *inode,
-+			ext3cow_fsblk_t goal, int *errp);
-+extern ext3cow_fsblk_t ext3cow_new_blocks (handle_t *handle, struct inode *inode,
-+			ext3cow_fsblk_t goal, unsigned long *count, int *errp);
-+extern void ext3cow_free_blocks (handle_t *handle, struct inode *inode,
-+			ext3cow_fsblk_t block, unsigned long count);
-+extern void ext3cow_free_blocks_sb (handle_t *handle, struct super_block *sb,
-+				 ext3cow_fsblk_t block, unsigned long count,
-+				unsigned long *pdquot_freed_blocks);
-+extern ext3cow_fsblk_t ext3cow_count_free_blocks (struct super_block *);
-+extern void ext3cow_check_blocks_bitmap (struct super_block *);
-+extern struct ext3cow_group_desc * ext3cow_get_group_desc(struct super_block * sb,
-+						    unsigned int block_group,
-+						    struct buffer_head ** bh);
-+extern int ext3cow_should_retry_alloc(struct super_block *sb, int *retries);
-+extern void ext3cow_init_block_alloc_info(struct inode *);
-+extern void ext3cow_rsv_window_add(struct super_block *sb, struct ext3cow_reserve_window_node *rsv);
-+
-+
-+/* dir.c */
-+extern int ext3cow_check_dir_entry(const char *, struct inode *,
-+				struct ext3cow_dir_entry_2 *,
-+				struct buffer_head *, unsigned long);
-+extern int ext3cow_htree_store_dirent(struct file *dir_file, __u32 hash,
-+				    __u32 minor_hash,
-+				    struct ext3cow_dir_entry_2 *dirent);
-+extern void ext3cow_htree_free_dir_info(struct dir_private_info *p);
-+
-+/* fsync.c */
-+extern int ext3cow_sync_file (struct file *, struct dentry *, int);
-+
-+/* hash.c */
-+extern int ext3cowfs_dirhash(const char *name, int len, struct
-+			  dx_hash_info *hinfo);
-+
-+/* ialloc.c */
-+extern struct inode * ext3cow_new_inode (handle_t *, struct inode *, int);
-+extern void ext3cow_free_inode (handle_t *, struct inode *);
-+extern struct inode * ext3cow_orphan_get (struct super_block *, unsigned long);
-+extern unsigned long ext3cow_count_free_inodes (struct super_block *);
-+extern unsigned long ext3cow_count_dirs (struct super_block *);
-+extern void ext3cow_check_inodes_bitmap (struct super_block *);
-+extern unsigned long ext3cow_count_free (struct buffer_head *, unsigned);
-+
-+
-+/* inode.c */
-+int ext3cow_forget(handle_t *handle, int is_metadata, struct inode *inode,
-+		struct buffer_head *bh, ext3cow_fsblk_t blocknr);
-+struct buffer_head * ext3cow_getblk (handle_t *, struct inode *, long, int, int *);
-+struct buffer_head * ext3cow_bread (handle_t *, struct inode *, int, int, int *);
-+int ext3cow_get_blocks_handle(handle_t *handle, struct inode *inode,
-+	sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
-+	int create, int extend_disksize);
-+
-+extern void ext3cow_read_inode (struct inode *);
-+extern int  ext3cow_write_inode (struct inode *, int);
-+extern int  ext3cow_setattr (struct dentry *, struct iattr *);
-+extern void ext3cow_delete_inode (struct inode *);
-+extern int  ext3cow_sync_inode (handle_t *, struct inode *);
-+extern void ext3cow_discard_reservation (struct inode *);
-+extern void ext3cow_dirty_inode(struct inode *);
-+extern int ext3cow_change_inode_journal_flag(struct inode *, int);
-+extern int ext3cow_get_inode_loc(struct inode *, struct ext3cow_iloc *);
-+extern void ext3cow_truncate (struct inode *);
-+extern void ext3cow_set_inode_flags(struct inode *);
-+extern void ext3cow_set_aops(struct inode *inode);
-+
-+/* ioctl.c */
-+extern int ext3cow_ioctl (struct inode *, struct file *, unsigned int,
-+		       unsigned long);
-+extern long ext3cow_compat_ioctl (struct file *, unsigned int, unsigned long);
-+
-+/* namei.c */
-+extern int is_unchangeable(struct inode *, struct dentry *);
-+extern int ext3cow_orphan_add(handle_t *, struct inode *);
-+extern int ext3cow_orphan_del(handle_t *, struct inode *);
-+extern int ext3cow_htree_fill_tree(struct file *dir_file, __u32 start_hash,
-+				__u32 start_minor_hash, __u32 *next_hash);
-+extern struct inode *ext3cow_fake_inode(struct inode *, unsigned int);
-+extern int ext3cow_dup_inode(struct inode *, struct inode *);
-+extern int ext3cow_reclaim_dup_inode(struct inode *, struct inode *);
-+
-+/* resize.c */
-+extern int ext3cow_group_add(struct super_block *sb,
-+				struct ext3cow_new_group_data *input);
-+extern int ext3cow_group_extend(struct super_block *sb,
-+				struct ext3cow_super_block *es,
-+				ext3cow_fsblk_t n_blocks_count);
-+
-+/* super.c */
-+extern void ext3cow_error (struct super_block *, const char *, const char *, ...)
-+	__attribute__ ((format (printf, 3, 4)));
-+extern void __ext3cow_std_error (struct super_block *, const char *, int);
-+extern void ext3cow_abort (struct super_block *, const char *, const char *, ...)
-+	__attribute__ ((format (printf, 3, 4)));
-+extern void ext3cow_warning (struct super_block *, const char *, const char *, ...)
-+	__attribute__ ((format (printf, 3, 4)));
-+extern void ext3cow_update_dynamic_rev (struct super_block *sb);
-+extern unsigned int ext3cow_take_snapshot(struct super_block *sb);
-+
-+#define ext3cow_std_error(sb, errno)				\
-+do {								\
-+	if ((errno))						\
-+		__ext3cow_std_error((sb), __FUNCTION__, (errno));	\
-+} while (0)
-+
-+/*
-+ * Inodes and files operations
-+ */
-+
-+/* dir.c */
-+extern const struct file_operations ext3cow_dir_operations;
-+
-+/* file.c */
-+extern struct inode_operations ext3cow_file_inode_operations;
-+extern const struct file_operations ext3cow_file_operations;
-+
-+/* namei.c */
-+extern struct inode_operations ext3cow_dir_inode_operations;
-+extern struct inode_operations ext3cow_special_inode_operations;
-+
-+/* symlink.c */
-+extern struct inode_operations ext3cow_symlink_inode_operations;
-+extern struct inode_operations ext3cow_fast_symlink_inode_operations;
-+
-+
-+#endif	/* __KERNEL__ */
-+
-+#endif	/* _LINUX_EXT3COW_FS_H */
-diff -Naur linux-2.6.21.7/include/linux/ext3cow_fs_i.h linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_fs_i.h
---- linux-2.6.21.7/include/linux/ext3cow_fs_i.h	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_fs_i.h	2007-10-23 17:48:10.000000000 +0200
-@@ -0,0 +1,152 @@
-+/*
-+ *  linux/include/linux/ext3cow_fs_i.h
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/include/linux/minix_fs_i.h
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ */
-+
-+#ifndef _LINUX_EXT3COW_FS_I
-+#define _LINUX_EXT3COW_FS_I
-+
-+#include <linux/rwsem.h>
-+#include <linux/rbtree.h>
-+#include <linux/seqlock.h>
-+#include <linux/mutex.h>
-+
-+/* data type for block offset of block group */
-+typedef int ext3cow_grpblk_t;
-+
-+/* data type for filesystem-wide blocks number */
-+typedef unsigned long ext3cow_fsblk_t;
-+
-+#define E3FSBLK "%lu"
-+
-+struct ext3cow_reserve_window {
-+	ext3cow_fsblk_t	_rsv_start;	/* First byte reserved */
-+	ext3cow_fsblk_t	_rsv_end;	/* Last byte reserved or 0 */
-+};
-+
-+struct ext3cow_reserve_window_node {
-+	struct rb_node		rsv_node;
-+	__u32			rsv_goal_size;
-+	__u32			rsv_alloc_hit;
-+	struct ext3cow_reserve_window	rsv_window;
-+};
-+
-+struct ext3cow_block_alloc_info {
-+	/* information about reservation window */
-+	struct ext3cow_reserve_window_node	rsv_window_node;
-+	/*
-+	 * was i_next_alloc_block in ext3cow_inode_info
-+	 * is the logical (file-relative) number of the
-+	 * most-recently-allocated block in this file.
-+	 * We use this for detecting linearly ascending allocation requests.
-+	 */
-+	__u32                   last_alloc_logical_block;
-+	/*
-+	 * Was i_next_alloc_goal in ext3cow_inode_info
-+	 * is the *physical* companion to i_next_alloc_block.
-+	 * it the the physical block number of the block which was most-recentl
-+	 * allocated to this file.  This give us the goal (target) for the next
-+	 * allocation when we detect linearly ascending requests.
-+	 */
-+	ext3cow_fsblk_t		last_alloc_physical_block;
-+};
-+
-+#define rsv_start rsv_window._rsv_start
-+#define rsv_end rsv_window._rsv_end
-+
-+/*
-+ * third extended file system inode data in memory
-+ */
-+struct ext3cow_inode_info {
-+	__le32	i_data[15];	/* unconverted */
-+	__u32	i_flags;
-+#ifdef EXT3COW_FRAGMENTS
-+	__u32	i_faddr;
-+	__u8	i_frag_no;
-+	__u8	i_frag_size;
-+#endif
-+	ext3cow_fsblk_t	i_file_acl;
-+	__u32	i_dir_acl;
-+	__u32	i_dtime;
-+
-+	/*
-+	 * i_block_group is the number of the block group which contains
-+	 * this file's inode.  Constant across the lifetime of the inode,
-+	 * it is ued for making block allocation decisions - we try to
-+	 * place a file's data blocks near its inode block, and new inodes
-+	 * near to their parent directory's inode.
-+	 */
-+	__u32	i_block_group;
-+	__u32	i_state;		/* Dynamic state flags for ext3cow */
-+
-+	/* block reservation info */
-+	struct ext3cow_block_alloc_info *i_block_alloc_info;
-+
-+	__u32	i_dir_start_lookup;
-+
-+  /* For versioning -znjp */
-+  __u16 i_cow_bitmap;
-+  __u32 i_epoch_number;
-+  __u32 i_next_inode;
-+#ifdef CONFIG_EXT3COW_FS_XATTR
-+	/*
-+	 * Extended attributes can be read independently of the main file
-+	 * data. Taking i_mutex even when reading would cause contention
-+	 * between readers of EAs and writers of regular file data, so
-+	 * instead we synchronize on xattr_sem when reading or changing
-+	 * EAs.
-+	 */
-+	struct rw_semaphore xattr_sem;
-+#endif
-+#ifdef CONFIG_EXT3COW_FS_POSIX_ACL
-+	struct posix_acl	*i_acl;
-+	struct posix_acl	*i_default_acl;
-+#endif
-+
-+	struct list_head i_orphan;	/* unlinked but open inodes */
-+
-+	/*
-+	 * i_disksize keeps track of what the inode size is ON DISK, not
-+	 * in memory.  During truncate, i_size is set to the new size by
-+	 * the VFS prior to calling ext3cow_truncate(), but the filesystem won't
-+	 * set i_disksize to 0 until the truncate is actually under way.
-+	 *
-+	 * The intent is that i_disksize always represents the blocks which
-+	 * are used by this file.  This allows recovery to restart truncate
-+	 * on orphans if we crash during truncate.  We actually write i_disksize
-+	 * into the on-disk inode when writing inodes out, instead of i_size.
-+	 *
-+	 * The only time when i_disksize and i_size may be different is when
-+	 * a truncate is in progress.  The only things which change i_disksize
-+	 * are ext3cow_get_block (growth) and ext3cow_truncate (shrinkth).
-+	 */
-+	loff_t	i_disksize;
-+
-+	/* on-disk additional length */
-+	__u16 i_extra_isize;
-+
-+	/*
-+	 * truncate_mutex is for serialising ext3cow_truncate() against
-+	 * ext3cow_getblock().  In the 2.4 ext2 design, great chunks of inode's
-+	 * data tree are chopped off during truncate. We can't do that in
-+	 * ext3cow because whenever we perform intermediate commits during
-+	 * truncate, the inode and all the metadata blocks *must* be in a
-+	 * consistent state which allows truncation of the orphans to restart
-+	 * during recovery.  Hence we must fix the get_block-vs-truncate race
-+	 * by other means, so we have truncate_mutex.
-+	 */
-+	struct mutex truncate_mutex;
-+	struct inode vfs_inode;
-+};
-+
-+#endif	/* _LINUX_EXT3COW_FS_I */
-diff -Naur linux-2.6.21.7/include/linux/ext3cow_fs_sb.h linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_fs_sb.h
---- linux-2.6.21.7/include/linux/ext3cow_fs_sb.h	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_fs_sb.h	2007-10-23 17:48:10.000000000 +0200
-@@ -0,0 +1,86 @@
-+/*
-+ *  linux/include/linux/ext3cow_fs_sb.h
-+ *
-+ * Copyright (C) 1992, 1993, 1994, 1995
-+ * Remy Card (card@masi.ibp.fr)
-+ * Laboratoire MASI - Institut Blaise Pascal
-+ * Universite Pierre et Marie Curie (Paris VI)
-+ *
-+ *  from
-+ *
-+ *  linux/include/linux/minix_fs_sb.h
-+ *
-+ *  Copyright (C) 1991, 1992  Linus Torvalds
-+ */
-+
-+#ifndef _LINUX_EXT3COW_FS_SB
-+#define _LINUX_EXT3COW_FS_SB
-+
-+#ifdef __KERNEL__
-+#include <linux/timer.h>
-+#include <linux/wait.h>
-+#include <linux/blockgroup_lock.h>
-+#include <linux/percpu_counter.h>
-+#endif
-+#include <linux/rbtree.h>
-+
-+/*
-+ * third extended-fs super-block data in memory
-+ */
-+struct ext3cow_sb_info {
-+	unsigned long s_frag_size;	/* Size of a fragment in bytes */
-+	unsigned long s_frags_per_block;/* Number of fragments per block */
-+	unsigned long s_inodes_per_block;/* Number of inodes per block */
-+	unsigned long s_frags_per_group;/* Number of fragments in a group */
-+	unsigned long s_blocks_per_group;/* Number of blocks in a group */
-+	unsigned long s_inodes_per_group;/* Number of inodes in a group */
-+	unsigned long s_itb_per_group;	/* Number of inode table blocks per group */
-+	unsigned long s_gdb_count;	/* Number of group descriptor blocks */
-+	unsigned long s_desc_per_block;	/* Number of group descriptors per block */
-+	unsigned long s_groups_count;	/* Number of groups in the fs */
-+	struct buffer_head * s_sbh;	/* Buffer containing the super block */
-+	struct ext3cow_super_block * s_es;	/* Pointer to the super block in the buffer */
-+	struct buffer_head ** s_group_desc;
-+	unsigned long  s_mount_opt;
-+	uid_t s_resuid;
-+	gid_t s_resgid;
-+	unsigned short s_mount_state;
-+	unsigned short s_pad;
-+	int s_addr_per_block_bits;
-+	int s_desc_per_block_bits;
-+	int s_inode_size;
-+	int s_first_ino;
-+	spinlock_t s_next_gen_lock;
-+	u32 s_next_generation;
-+	u32 s_hash_seed[4];
-+	int s_def_hash_version;
-+	struct percpu_counter s_freeblocks_counter;
-+	struct percpu_counter s_freeinodes_counter;
-+	struct percpu_counter s_dirs_counter;
-+	struct blockgroup_lock s_blockgroup_lock;
-+
-+	/* root of the per fs reservation window tree */
-+	spinlock_t s_rsv_window_lock;
-+	struct rb_root s_rsv_window_root;
-+	struct ext3cow_reserve_window_node s_rsv_window_head;
-+
-+  /* For versioning -znjp */
-+  u32 s_epoch_number;
-+
-+	/* Journaling */
-+	struct inode * s_journal_inode;
-+	struct journal_s * s_journal;
-+	struct list_head s_orphan;
-+	unsigned long s_commit_interval;
-+	struct block_device *journal_bdev;
-+#ifdef CONFIG_JBD_DEBUG
-+	struct timer_list turn_ro_timer;	/* For turning read-only (crash simulation) */
-+	wait_queue_head_t ro_wait_queue;	/* For people waiting for the fs to go read-only */
-+#endif
-+#ifdef CONFIG_QUOTA
-+	char *s_qf_names[MAXQUOTAS];		/* Names of quota files with journalled quota */
-+	int s_jquota_fmt;			/* Format of quota to use */
-+#endif
-+};
-+
-+#endif	/* _LINUX_EXT3COW_FS_SB */
-diff -Naur linux-2.6.21.7/include/linux/ext3cow_jbd.h linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_jbd.h
---- linux-2.6.21.7/include/linux/ext3cow_jbd.h	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.21.7_ext3cowPatched/include/linux/ext3cow_jbd.h	2007-10-23 17:48:10.000000000 +0200
-@@ -0,0 +1,226 @@
-+/*
-+ * linux/include/linux/ext3cow_jbd.h
-+ *
-+ * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
-+ *
-+ * Copyright 1998--1999 Red Hat corp --- All Rights Reserved
-+ *
-+ * This file is part of the Linux kernel and is made available under
-+ * the terms of the GNU General Public License, version 2, or at your
-+ * option, any later version, incorporated herein by reference.
-+ *
-+ * Ext3-specific journaling extensions.
-+ */
-+
-+#ifndef _LINUX_EXT3COW_JBD_H
-+#define _LINUX_EXT3COW_JBD_H
-+
-+#include <linux/fs.h>
-+#include <linux/jbd.h>
-+#include <linux/ext3cow_fs.h>
-+
-+#define EXT3COW_JOURNAL(inode)	(EXT3COW_SB((inode)->i_sb)->s_journal)
-+
-+/* Define the number of blocks we need to account to a transaction to
-+ * modify one block of data.
-+ *
-+ * We may have to touch one inode, one bitmap buffer, up to three
-+ * indirection blocks, the group and superblock summaries, and the data
-+ * block to complete the transaction.  */
-+
-+#define EXT3COW_SINGLEDATA_TRANS_BLOCKS	8U
-+
-+/* Extended attribute operations touch at most two data buffers,
-+ * two bitmap buffers, and two group summaries, in addition to the inode
-+ * and the superblock, which are already accounted for. */
-+
-+#define EXT3COW_XATTR_TRANS_BLOCKS		6U
-+
-+/* Define the minimum size for a transaction which modifies data.  This
-+ * needs to take into account the fact that we may end up modifying two
-+ * quota files too (one for the group, one for the user quota).  The
-+ * superblock only gets updated once, of course, so don't bother
-+ * counting that again for the quota updates. */
-+
-+#define EXT3COW_DATA_TRANS_BLOCKS(sb)	(EXT3COW_SINGLEDATA_TRANS_BLOCKS + \
-+					 EXT3COW_XATTR_TRANS_BLOCKS - 2 + \
-+					 2*EXT3COW_QUOTA_TRANS_BLOCKS(sb))
-+
-+/* Delete operations potentially hit one directory's namespace plus an
-+ * entire inode, plus arbitrary amounts of bitmap/indirection data.  Be
-+ * generous.  We can grow the delete transaction later if necessary. */
-+
-+#define EXT3COW_DELETE_TRANS_BLOCKS(sb)	(2 * EXT3COW_DATA_TRANS_BLOCKS(sb) + 64)
-+
-+/* Define an arbitrary limit for the amount of data we will anticipate
-+ * writing to any given transaction.  For unbounded transactions such as
-+ * write(2) and truncate(2) we can write more than this, but we always
-+ * start off at the maximum transaction size and grow the transaction
-+ * optimistically as we go. */
-+
-+#define EXT3COW_MAX_TRANS_DATA		64U
-+
-+/* We break up a large truncate or write transaction once the handle's
-+ * buffer credits gets this low, we need either to extend the
-+ * transaction or to start a new one.  Reserve enough space here for
-+ * inode, bitmap, superblock, group and indirection updates for at least
-+ * one block, plus two quota updates.  Quota allocations are not
-+ * needed. */
-+
-+#define EXT3COW_RESERVE_TRANS_BLOCKS	12U
-+
-+#define EXT3COW_INDEX_EXTRA_TRANS_BLOCKS	8
-+
-+#ifdef CONFIG_QUOTA
-+/* Amount of blocks needed for quota update - we know that the structure was
-+ * allocated so we need to update only inode+data */
-+#define EXT3COW_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0)
-+/* Amount of blocks needed for quota insert/delete - we do some block writes
-+ * but inode, sb and group updates are done only once */
-+#define EXT3COW_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
-+		(EXT3COW_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_INIT_REWRITE) : 0)
-+#define EXT3COW_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
-+		(EXT3COW_SINGLEDATA_TRANS_BLOCKS-3)+3+DQUOT_DEL_REWRITE) : 0)
-+#else
-+#define EXT3COW_QUOTA_TRANS_BLOCKS(sb) 0
-+#define EXT3COW_QUOTA_INIT_BLOCKS(sb) 0
-+#define EXT3COW_QUOTA_DEL_BLOCKS(sb) 0
-+#endif
-+
-+int
-+ext3cow_mark_iloc_dirty(handle_t *handle,
-+		     struct inode *inode,
-+		     struct ext3cow_iloc *iloc);
-+
-+/*
-+ * On success, We end up with an outstanding reference count against
-+ * iloc->bh.  This _must_ be cleaned up later.
-+ */
-+
-+int ext3cow_reserve_inode_write(handle_t *handle, struct inode *inode,
-+			struct ext3cow_iloc *iloc);
-+
-+int ext3cow_mark_inode_dirty(handle_t *handle, struct inode *inode);
-+
-+/*
-+ * Wrapper functions with which ext3cow calls into JBD.  The intent here is
-+ * to allow these to be turned into appropriate stubs so ext3cow can control
-+ * ext2 filesystems, so ext2+ext3cow systems only nee one fs.  This work hasn't
-+ * been done yet.
-+ */
-+
-+static inline void ext3cow_journal_release_buffer(handle_t *handle,
-+						struct buffer_head *bh)
-+{
-+	journal_release_buffer(handle, bh);
-+}
-+
-+void ext3cow_journal_abort_handle(const char *caller, const char *err_fn,
-+		struct buffer_head *bh, handle_t *handle, int err);
-+
-+int __ext3cow_journal_get_undo_access(const char *where, handle_t *handle,
-+				struct buffer_head *bh);
-+
-+int __ext3cow_journal_get_write_access(const char *where, handle_t *handle,
-+				struct buffer_head *bh);
-+
-+int __ext3cow_journal_forget(const char *where, handle_t *handle,
-+				struct buffer_head *bh);
-+
-+int __ext3cow_journal_revoke(const char *where, handle_t *handle,
-+				unsigned long blocknr, struct buffer_head *bh);
-+
-+int __ext3cow_journal_get_create_access(const char *where,
-+				handle_t *handle, struct buffer_head *bh);
-+
-+int __ext3cow_journal_dirty_metadata(const char *where,
-+				handle_t *handle, struct buffer_head *bh);
-+
-+#define ext3cow_journal_get_undo_access(handle, bh) \
-+	__ext3cow_journal_get_undo_access(__FUNCTION__, (handle), (bh))
-+#define ext3cow_journal_get_write_access(handle, bh) \
-+	__ext3cow_journal_get_write_access(__FUNCTION__, (handle), (bh))
-+#define ext3cow_journal_revoke(handle, blocknr, bh) \
-+	__ext3cow_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh))
-+#define ext3cow_journal_get_create_access(handle, bh) \
-+	__ext3cow_journal_get_create_access(__FUNCTION__, (handle), (bh))
-+#define ext3cow_journal_dirty_metadata(handle, bh) \
-+	__ext3cow_journal_dirty_metadata(__FUNCTION__, (handle), (bh))
-+#define ext3cow_journal_forget(handle, bh) \
-+	__ext3cow_journal_forget(__FUNCTION__, (handle), (bh))
-+
-+int ext3cow_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
-+
-+handle_t *ext3cow_journal_start_sb(struct super_block *sb, int nblocks);
-+int __ext3cow_journal_stop(const char *where, handle_t *handle);
-+
-+static inline handle_t *ext3cow_journal_start(struct inode *inode, int nblocks)
-+{
-+	return ext3cow_journal_start_sb(inode->i_sb, nblocks);
-+}
-+
-+#define ext3cow_journal_stop(handle) \
-+	__ext3cow_journal_stop(__FUNCTION__, (handle))
-+
-+static inline handle_t *ext3cow_journal_current_handle(void)
-+{
-+	return journal_current_handle();
-+}
-+
-+static inline int ext3cow_journal_extend(handle_t *handle, int nblocks)
-+{
-+	return journal_extend(handle, nblocks);
-+}
-+
-+static inline int ext3cow_journal_restart(handle_t *handle, int nblocks)
-+{
-+	return journal_restart(handle, nblocks);
-+}
-+
-+static inline int ext3cow_journal_blocks_per_page(struct inode *inode)
-+{
-+	return journal_blocks_per_page(inode);
-+}
-+
-+static inline int ext3cow_journal_force_commit(journal_t *journal)
-+{
-+	return journal_force_commit(journal);
-+}
-+
-+/* super.c */
-+int ext3cow_force_commit(struct super_block *sb);
-+
-+static inline int ext3cow_should_journal_data(struct inode *inode)
-+{
-+	if (!S_ISREG(inode->i_mode))
-+		return 1;
-+	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3COW_MOUNT_JOURNAL_DATA)
-+		return 1;
-+	if (EXT3COW_I(inode)->i_flags & EXT3COW_JOURNAL_DATA_FL)
-+		return 1;
-+	return 0;
-+}
-+
-+static inline int ext3cow_should_order_data(struct inode *inode)
-+{
-+	if (!S_ISREG(inode->i_mode))
-+		return 0;
-+	if (EXT3COW_I(inode)->i_flags & EXT3COW_JOURNAL_DATA_FL)
-+		return 0;
-+	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3COW_MOUNT_ORDERED_DATA)
-+		return 1;
-+	return 0;
-+}
-+
-+static inline int ext3cow_should_writeback_data(struct inode *inode)
-+{
-+	if (!S_ISREG(inode->i_mode))
-+		return 0;
-+	if (EXT3COW_I(inode)->i_flags & EXT3COW_JOURNAL_DATA_FL)
-+		return 0;
-+	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3COW_MOUNT_WRITEBACK_DATA)
-+		return 1;
-+	return 0;
-+}
-+
-+#endif	/* _LINUX_EXT3COW_JBD_H */
-diff -Naur linux-2.6.21.7/include/linux/magic.h linux-2.6.21.7_ext3cowPatched/include/linux/magic.h
---- linux-2.6.21.7/include/linux/magic.h	2007-08-04 18:11:13.000000000 +0200
-+++ linux-2.6.21.7_ext3cowPatched/include/linux/magic.h	2007-10-23 17:46:52.000000000 +0200
-@@ -9,6 +9,7 @@
- #define EFS_SUPER_MAGIC		0x414A53
- #define EXT2_SUPER_MAGIC	0xEF53
- #define EXT3_SUPER_MAGIC	0xEF53
-+#define EXT3COW_SUPER_MAGIC	0xEF53
- #define EXT4_SUPER_MAGIC	0xEF53
- #define HPFS_SUPER_MAGIC	0xf995e849
- #define ISOFS_SUPER_MAGIC	0x9660
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.23.nix b/pkgs/os-specific/linux/kernel/linux-2.6.23.nix
index b58fb41601e..b6756c113dd 100644
--- a/pkgs/os-specific/linux/kernel/linux-2.6.23.nix
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.23.nix
@@ -34,6 +34,13 @@ in
 
 stdenv.mkDerivation {
   name = if userModeLinux then "user-mode-linux-${version}" else "linux-${version}";
+
+  passthru = {
+    inherit version;
+    # Combine the `features' attribute sets of all the kernel patches.
+    features = lib.fold (x: y: (if x ? features then x.features else {}) // y) {} kernelPatches;
+  };
+  
   builder = ./builder.sh;
   
   src = fetchurl {
diff --git a/pkgs/os-specific/linux/kernel/linux-2.6.25.nix b/pkgs/os-specific/linux/kernel/linux-2.6.25.nix
new file mode 100644
index 00000000000..b1c64dc7168
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-2.6.25.nix
@@ -0,0 +1,95 @@
+{ stdenv, fetchurl, perl, mktemp, module_init_tools
+
+  # A list of patches to apply to the kernel.  Each element of this list
+  # should be an attribute set {name, patch} where `name' is a
+  # symbolic name and `patch' is the actual patch.  The patch may
+  # optionally be compressed with gzip or bzip2.
+, kernelPatches ? []
+
+, # Whether to build a User-Mode Linux kernel.
+  userModeLinux ? false
+
+, # Allows you to set your own kernel version suffix (e.g.,
+  # "-my-kernel").
+  localVersion ? ""
+
+, # Your own kernel configuration file, if you don't want to use the
+  # default. 
+  kernelConfig ? null
+
+, # A list of additional statements to be appended to the
+  # configuration file.
+  extraConfig ? []
+}:
+
+assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
+
+let
+
+  lib = stdenv.lib;
+
+  version = "2.6.25.6";
+
+  baseFeatures = {
+    iwlwifi = true;
+  };
+
+in
+
+stdenv.mkDerivation {
+  name = if userModeLinux then "user-mode-linux-${version}" else "linux-${version}";
+
+  passthru = {
+    inherit version;
+    # Combine the `features' attribute sets of all the kernel patches.
+    features = lib.fold (x: y: (if x ? features then x.features else {}) // y) baseFeatures kernelPatches;
+  };
+  
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/v2.6/linux-${version}.tar.bz2";
+    sha256 = "1vf4hrj6qvdii4py6wwrkxx42pqaxzrn7a7sk34dsjm5n93i4sbi";
+  };
+  
+  patches = map (p: p.patch) kernelPatches;
+  extraConfig =
+    let addNewlines = map (s: "\n" + s + "\n");
+        configFromPatches =
+          map (p: if p ? extraConfig then p.extraConfig else "") kernelPatches;
+    in lib.concatStrings (addNewlines (configFromPatches ++ extraConfig));
+
+  config =
+    if kernelConfig != null then kernelConfig else
+    if userModeLinux then ./config-2.6.25-uml else
+    if stdenv.system == "i686-linux" then ./config-2.6.25-i686-smp else
+    if stdenv.system == "x86_64-linux" then ./config-2.6.25-x86_64-smp else
+    abort "No kernel configuration for your platform!";
+  
+  buildInputs = [perl mktemp];
+  
+  arch =
+    if userModeLinux then "um" else
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    abort "Platform ${stdenv.system} is not supported.";
+
+  makeFlags = if userModeLinux then "ARCH=um SHELL=bash" else "";
+
+  inherit module_init_tools;
+
+  allowLocalVersion = false; # don't allow patches to set a suffix
+  inherit localVersion; # but do allow the user to set one.
+
+  meta = {
+    description =
+      (if userModeLinux then
+        "User-Mode Linux"
+       else
+        "The Linux kernel") +
+      (if kernelPatches == [] then "" else
+        " (with patches: "
+        + lib.concatStrings (lib.intersperse ", " (map (x: x.name) kernelPatches))
+        + ")");
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel/linux.nix b/pkgs/os-specific/linux/kernel/linux.nix
new file mode 100644
index 00000000000..dc1996c0b9f
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux.nix
@@ -0,0 +1,97 @@
+{ stdenv, fetchurl, perl, mktemp, module_init_tools, lib
+
+  # The base source file
+, src
+
+  # A list of patches to apply to the kernel.  Each element of this list
+  # should be an attribute set {name, patch} where `name' is a
+  # symbolic name and `patch' is the actual patch.  The patch may
+  # optionally be compressed with gzip or bzip2.
+, kernelPatches ? []
+
+  # A list of commands to run on patched kernel before 
+  # mke oldconfig
+, preConfigure? ""
+
+, # Whether to build a User-Mode Linux kernel.
+  userModeLinux ? false
+
+, # Allows you to set your own kernel version for output
+  version ? "unknown"
+
+  # To change how kernel thinks of itself
+, localVersion ? ""
+
+, # Your own kernel configuration file, if you don't want to use the
+  # default. 
+  kernelConfig ? null
+
+, # A list of additional statements to be appended to the
+  # configuration file.
+  extraConfig ? []
+
+, features ? []
+}:
+
+assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
+
+let
+
+  lib = import ../../../lib;
+
+in
+
+stdenv.mkDerivation {
+  name = if userModeLinux then "user-mode-linux-${version}" else "linux-${version}";
+  builder = ./builder-custom.sh;
+
+  passthru = {
+    inherit version;
+    # Combine the `features' attribute sets of all the kernel patches.
+    features = lib.fold (x: y: (if x ? features then x.features else {}) // y) features kernelPatches;
+  };
+  
+  inherit src;
+  preConfigure = preConfigure;
+
+  patches = map (p: p.patch) kernelPatches;
+  extraConfig =
+    let addNewlines = map (s: "\n" + s + "\n");
+        configFromPatches =
+          map (p: if p ? extraConfig then p.extraConfig else "") kernelPatches;
+    in lib.concatStrings (addNewlines (configFromPatches ++ extraConfig));
+
+  config =
+    if kernelConfig != null then kernelConfig else
+    if userModeLinux then ./config-2.6.23-uml else
+    if stdenv.system == "i686-linux" then ./config-2.6.23-i686-smp else
+    if stdenv.system == "x86_64-linux" then ./config-2.6.23-x86_64-smp else
+    abort "No kernel configuration for your platform!";
+  
+  buildInputs = [perl mktemp];
+  
+  arch =
+    if userModeLinux then "um" else
+    if stdenv.system == "i686-linux" then "i386" else
+    if stdenv.system == "x86_64-linux" then "x86_64" else
+    abort "Platform ${stdenv.system} is not supported.";
+
+  makeFlags = if userModeLinux then "ARCH=um SHELL=bash" else "";
+
+  inherit module_init_tools;
+
+  allowLocalVersion = false; # don't allow patches to set a suffix
+  inherit localVersion; # but do allow the user to set one.
+
+  meta = {
+    description =
+      (if userModeLinux then
+        "User-Mode Linux"
+       else
+        "The Linux kernel") +
+      (if kernelPatches == [] then "" else
+        " (with patches: "
+        + lib.concatStrings (lib.intersperse ", " (map (x: x.name) kernelPatches))
+        + ")");
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel/sec_perm-2.6.24.patch b/pkgs/os-specific/linux/kernel/sec_perm-2.6.24.patch
new file mode 100644
index 00000000000..de9b29949c3
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/sec_perm-2.6.24.patch
@@ -0,0 +1,16 @@
+Index: linux-2.6.24-rc3/security/security.c
+===================================================================
+RCS file: /ext1/sysadm/transparent/repository/linux-2.6.24-rc3/security/security.c,v
+retrieving revision 1.1
+retrieving revision 1.2
+diff -u -p -r1.1 -r1.2
+--- linux-2.6.24-rc3/security/security.c	21 Nov 2007 13:03:11 -0000	1.1
++++ linux-2.6.24-rc3/security/security.c	21 Nov 2007 13:07:55 -0000	1.2
+@@ -409,6 +409,7 @@ int security_inode_permission(struct ino
+ 		return 0;
+ 	return security_ops->inode_permission(inode, mask, nd);
+ }
++EXPORT_SYMBOL(security_inode_permission);
+ 
+ int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
+ {
diff --git a/pkgs/os-specific/linux/kernelscripts/builder.sh b/pkgs/os-specific/linux/kernelscripts/builder.sh
deleted file mode 100755
index 9517844ee05..00000000000
--- a/pkgs/os-specific/linux/kernelscripts/builder.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-source $stdenv/setup
-
-export MODULE_DIR=$out/lib/modules/
-
-kernelVersion=$(cd $kernel/lib/modules/; ls -d *)
-
-mkdir -p $out/lib/modules/$kernelVersion
-
-cd $kernel
-
-echo making kernel directories
-
-find . -not -path "./lib/modules/$kernelVersion/build*" -type d | xargs -n 1 -i% mkdir -p $out/%
-
-echo symlinking kernel modules
-
-find . -not -path "./lib/modules/$kernelVersion/build*" -a -not -path \
-  "./System*" -a -not -path "./vmlinuz*" -type f | xargs -n 1 -i% \
-  ln -s $kernel/% $out/%
-
-echo $modules
-for i in $modules; do
-  echo making directories for $i
-  cd $i
-  find . -not -path "./lib/modules/$kernelVersion/build*" -type d | xargs -n 1 -i% mkdir -p $out/%
-
-  echo symlinking modules for $i
-
-  find . -not -path "./lib/modules/$kernelVersion/build*" -type f | xargs -n 1 -i% ln -s $i/% $out/%
-
-done
-
-echo running depmod
-$module_init_tools/sbin/depmod -ae $kernelVersion
diff --git a/pkgs/os-specific/linux/kernelscripts/default.nix b/pkgs/os-specific/linux/kernelscripts/default.nix
deleted file mode 100644
index 55d91e27d13..00000000000
--- a/pkgs/os-specific/linux/kernelscripts/default.nix
+++ /dev/null
@@ -1,8 +0,0 @@
-{stdenv, module_init_tools, kernel, modules}:
-
-stdenv.mkDerivation {
-  builder = ./builder.sh;
-  name = "kernelscripts-0.0.1";
-
-  inherit module_init_tools kernel modules;
-}
diff --git a/pkgs/os-specific/linux/klibc/shrunk.nix b/pkgs/os-specific/linux/klibc/shrunk.nix
new file mode 100644
index 00000000000..ff72d1f72b8
--- /dev/null
+++ b/pkgs/os-specific/linux/klibc/shrunk.nix
@@ -0,0 +1,24 @@
+{stdenv, klibc}:
+
+stdenv.mkDerivation {
+  # !!! For now, the name has to be exactly as long as the original
+  # name due to the sed hackery below.  Once patchelf 0.4 is in the
+  # tree, we can do this properly.
+  #name = "${klibc.name}-shrunk";
+  name = "${klibc.name}";
+  buildCommand = ''
+    ensureDir $out/lib
+    cp -prd ${klibc}/lib/klibc/bin $out/
+    cp -p ${klibc}/lib/*.so $out/lib/
+    chmod +w $out/*
+    old=$(echo ${klibc}/lib/klibc-*.so)
+    new=$(echo $out/lib/klibc-*.so)
+    for i in $out/bin/*; do
+      echo $i
+      sed "s^$old^$new^" -i $i
+      # !!! use patchelf
+      #patchelf --set-interpreter $new $i
+    done
+  ''; # */
+  allowedReferences = ["out"];
+}
diff --git a/pkgs/os-specific/linux/kqemu/1.3.0pre11.nix b/pkgs/os-specific/linux/kqemu/1.3.0pre11.nix
index 7b75c2a7def..6dba6ffd041 100644
--- a/pkgs/os-specific/linux/kqemu/1.3.0pre11.nix
+++ b/pkgs/os-specific/linux/kqemu/1.3.0pre11.nix
@@ -1,33 +1,26 @@
 args : with args;
-	let localDefs = builderDefs {
-		src = /* put a fetchurl here */
-		fetchurl {
-			url = http://fabrice.bellard.free.fr/qemu/kqemu-1.3.0pre11.tar.gz;
-			sha256 = "03svg2x52ziglf9r9irf6ziiz8iwa731fk1mdskwdip5jxbyy6jl";
-		};
-		buildInputs = [];
-		configureFlags = [''--prefix=$out'' ''--kernel-path=$(ls -d ${kernel}/lib/modules/*/build)''];
-	} null; /* null is a terminator for sumArgs */
-	in with localDefs;
-let 
+rec {
+  name = "kqemu-"+version;
+  src = fetchurl {
+    url = http://fabrice.bellard.free.fr/qemu/kqemu-1.3.0pre11.tar.gz;
+    sha256 = "03svg2x52ziglf9r9irf6ziiz8iwa731fk1mdskwdip5jxbyy6jl";
+  };
+
+  buildInputs = [];
+  configureFlags = [''--PREFIx=$out'' ''--kernel-path=$(ls -d ${kernel}/lib/modules/*/build)''];
   debugStep = FullDepEntry (''
   	cat config-host.mak
-  '') [minInit];
+  '') ["minInit"];
   preConfigure = FullDepEntry ('' 
-  	sed -e 's/`uname -r`/'"$(basename ${kernel}/lib/modules/*)"'/' -i install.sh
-  	sed -e '/kernel_path=/akernel_path=$out$kernel_path' -i install.sh
-	sed -e '/depmod/d' -i install.sh
-	cat install.sh
-  '') [minInit doUnpack];
-in
-stdenv.mkDerivation rec {
-	name = "kqemu-"+version;
-	builder = writeScript (name + "-builder")
-		(textClosure localDefs [preConfigure doConfigure debugStep doMakeInstall doForceShare doPropagate]);
-	meta = {
-		description = "
-		Kernel module for Qemu acceleration
-";
-		inherit src;
-	};
+    sed -e 's/`uname -r`/'"$(basename ${kernel}/lib/modules/*)"'/' -i install.sh
+    sed -e '/kernel_path=/akernel_path=$out$kernel_path' -i install.sh
+    sed -e '/depmod/d' -i install.sh
+    cat install.sh
+  '') ["minInit" "doUnpack"];
+
+  phaseNames = ["preConfigure" "doConfigure" "debugStep" "doMakeInstall"];
+
+  meta = {
+    description = " Kernel module for Qemu acceleration ";
+  }; 
 }
diff --git a/pkgs/os-specific/linux/kvm/57.nix b/pkgs/os-specific/linux/kvm/57.nix
index c7859eed178..ccbd2d353b1 100644
--- a/pkgs/os-specific/linux/kvm/57.nix
+++ b/pkgs/os-specific/linux/kvm/57.nix
@@ -10,12 +10,22 @@ stdenv.mkDerivation {
     sha256 = "016h5pf59fyz7skzsaprii2mdpxpb8hfnnr1w475qcfyy6ccr9r0";
   };
 
+  patches = [
+    # Allow setting the path to Samba through $QEMU_SMBD_COMMAND.
+    ./smbd-path.patch
+  ];
+
   configureFlags = "--with-patched-kernel --kerneldir=${kernelHeaders}";
 
   # e2fsprogs is needed for libuuid.
   buildInputs = [zlib e2fsprogs SDL alsaLib];
 
-  preConfigure = "for i in configure user/configure; do substituteInPlace $i --replace /bin/bash $shell; done";
+  preConfigure = ''
+    for i in configure user/configure; do
+      substituteInPlace $i --replace /bin/bash $shell
+    done
+    substituteInPlace libkvm/Makefile --replace kvm_para.h kvm.h # !!! quick hack
+  '';
 
   meta = {
     homepage = http://kvm.qumranet.com/;
diff --git a/pkgs/os-specific/linux/kvm/69.nix b/pkgs/os-specific/linux/kvm/69.nix
new file mode 100644
index 00000000000..b8a69894587
--- /dev/null
+++ b/pkgs/os-specific/linux/kvm/69.nix
@@ -0,0 +1,38 @@
+{stdenv, fetchurl, kernelHeaders, zlib, e2fsprogs, SDL, alsaLib, pkgconfig, rsync}:
+   
+assert stdenv.isLinux;
+   
+stdenv.mkDerivation {
+  name = "kvm-69";
+   
+  src = fetchurl {
+    url = mirror://sourceforge/kvm/kvm-69.tar.gz;
+    sha256 = "05zkzw81lk5ap99vi0jqs6lyp13gapyi1046zgjmjm19q4xzsjz4";
+  };
+
+  patches = [
+    # Allow setting the path to Samba through $QEMU_SMBD_COMMAND.
+    ./smbd-path.patch
+    # The makefile copies stuff from the kernel directory and then
+    # tries to modify the copy, but it must be made writable first.
+    ./readonly-kernel.patch
+  ];
+
+  configureFlags = "--with-patched-kernel --kerneldir=${kernelHeaders}";
+
+  # e2fsprogs is needed for libuuid.
+  # rsync is a weird dependency used for copying kernel header files.
+  buildInputs = [zlib e2fsprogs SDL alsaLib pkgconfig rsync];
+
+  preConfigure = ''
+    for i in configure user/configure; do
+      substituteInPlace $i --replace /bin/bash $shell
+    done
+    substituteInPlace libkvm/Makefile --replace kvm_para.h kvm.h # !!! quick hack
+  '';
+
+  meta = {
+    homepage = http://kvm.qumranet.com/;
+    description = "A full virtualization solution for Linux on x86 hardware containing virtualization extensions";
+  };
+}
diff --git a/pkgs/os-specific/linux/kvm/readonly-kernel.patch b/pkgs/os-specific/linux/kvm/readonly-kernel.patch
new file mode 100644
index 00000000000..54e9225d101
--- /dev/null
+++ b/pkgs/os-specific/linux/kvm/readonly-kernel.patch
@@ -0,0 +1,14 @@
+diff -rc kvm-69-orig/kernel/Makefile kvm-69/kernel/Makefile
+*** kvm-69-orig/kernel/Makefile	2008-05-12 13:30:43.000000000 +0200
+--- kvm-69/kernel/Makefile	2008-06-04 17:23:34.000000000 +0200
+***************
+*** 48,53 ****
+--- 48,54 ----
+  	     "$(LINUX)"/./include/linux/kvm*.h \
+  	     "$(LINUX)"/./include/asm-*/kvm*.h \
+               $T/
++ 	chmod -R u+w $T
+  
+  	set -e && for i in $(find $T -name '*.h'); do \
+  		$(call unifdef,$$i); done
+Only in kvm-69/kernel: Makefile~
diff --git a/pkgs/os-specific/linux/kvm/smbd-path.patch b/pkgs/os-specific/linux/kvm/smbd-path.patch
new file mode 100644
index 00000000000..45e9a4bacce
--- /dev/null
+++ b/pkgs/os-specific/linux/kvm/smbd-path.patch
@@ -0,0 +1,26 @@
+diff -rc kvm-57-orig/qemu/vl.c kvm-57/qemu/vl.c
+*** kvm-57-orig/qemu/vl.c	2007-12-18 16:57:46.000000000 +0100
+--- kvm-57/qemu/vl.c	2008-03-11 16:17:26.000000000 +0100
+***************
+*** 3865,3872 ****
+      fclose(f);
+      atexit(smb_exit);
+  
+      snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s",
+!              SMBD_COMMAND, smb_conf);
+  
+      slirp_add_exec(0, smb_cmdline, 4, 139);
+  }
+--- 3865,3875 ----
+      fclose(f);
+      atexit(smb_exit);
+  
++     char *smbd_command = getenv("QEMU_SMBD_COMMAND");
++     if (!smbd_command) smbd_command = SMBD_COMMAND;
++ 
+      snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s",
+!              smbd_command, smb_conf);
+  
+      slirp_add_exec(0, smb_cmdline, 4, 139);
+  }
+Only in kvm-57/qemu: vl.c~
diff --git a/pkgs/os-specific/linux/libcap/default.nix b/pkgs/os-specific/linux/libcap/default.nix
index e6bcdde517d..46f40167a7e 100644
--- a/pkgs/os-specific/linux/libcap/default.nix
+++ b/pkgs/os-specific/linux/libcap/default.nix
@@ -13,6 +13,6 @@ stdenv.mkDerivation {
   buildInputs = [attr];
 
   preBuild = ''
-    makeFlagsArray=(LIBDIR=$out/lib INCDIR=$out/include SBINDIR=$out/sbin MANDIR=$out/man)
+    makeFlagsArray=(LIBDIR=$out/lib INCDIR=$out/include SBINDIR=$out/sbin MANDIR=$out/man PAM_CAP=no)
   '';
 }
diff --git a/pkgs/os-specific/linux/libvolume_id/default.nix b/pkgs/os-specific/linux/libvolume_id/default.nix
index 91de928994a..3deaa7097c4 100644
--- a/pkgs/os-specific/linux/libvolume_id/default.nix
+++ b/pkgs/os-specific/linux/libvolume_id/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
    
 stdenv.mkDerivation {
-  name = "libvolume_id-0.75.0";
+  name = "libvolume_id-0.81.0";
    
   src = fetchurl {
-    url = http://www.marcuscom.com/downloads/libvolume_id-0.75.0.tar.bz2;
-    sha256 = "1n1ji2jz45ncvyv529nz8xwcz058z9z98970v9h2wwwg8ra2a1sl";
+    url = http://www.marcuscom.com/downloads/libvolume_id-0.81.0.tar.bz2;
+    sha256 = "1dpmp1kb40kb1jxj6flpi37wy789wf91dm4bax6jspd1jdc6hsrg";
   };
 
   preBuild = "
diff --git a/pkgs/os-specific/linux/module-init-tools/aggregator.nix b/pkgs/os-specific/linux/module-init-tools/aggregator.nix
index 9779efe3305..f11642b9a68 100644
--- a/pkgs/os-specific/linux/module-init-tools/aggregator.nix
+++ b/pkgs/os-specific/linux/module-init-tools/aggregator.nix
@@ -1,39 +1,28 @@
-args : with args;
-	let localDefs = builderDefs {
-		addSbinPath = true;
-		src = "";
-		buildInputs = [module_init_tools];
-		configureFlags = [];
-	} null; /* null is a terminator for sumArgs */
-	in with localDefs;
-let 
+{stdenv, module_init_tools, modules}:
 
-doCollect = FullDepEntry (''
-ensureDir $out/lib/modules
-cd $out/
-for i in $moduleSources; do 
-	cp -rfs $i/* .
-	chmod -R u+w .
-done
-rm -rf nix-support
-cd lib/modules/
-rm */modules.*
-#  linux-* will pass the new kernel version to depmod to take rather than `uname -r` (see man page)
-MODULE_DIR=$PWD/ depmod -a $(basename lib/modules/2.*)
-cd $out/
-'') [minInit addInputs defEnsureDir];
-in
-stdenv.mkDerivation rec {
-	name = "kernel-modules";
-	inherit moduleSources;
-	builder = writeScript (name + "-builder")
-		(textClosure localDefs [doCollect doForceShare doPropagate]);
-	meta = {
-		description = "
-		A directory to hold all  the modules, including those 
-		built separately from kernel. Later mentioned directories in 
-		moduleSources have higher priority.
-";
-		inherit src;
-	};
+stdenv.mkDerivation {
+  name = "kernel-modules";
+
+  buildCommand = ''
+    ensureDir $out/lib/modules
+    cd $out/
+    modules="${toString modules}"
+    for i in $modules; do 
+        cp -rfs $i/* .
+        chmod -R u+w .
+        v=$(cd $i/lib/modules && ls -d *)
+        if test -n "$version" -a "$v" != "$version"; then
+            echo "kernel version mismatch: $version versus $v (in the module paths $modules)";
+            exit 1
+        fi
+        version=$v
+    done
+    echo "kernel version is $version"
+    rm -rf nix-support
+    cd lib/modules/
+    rm */modules.*
+    #  linux-* will pass the new kernel version to depmod to take rather than `uname -r` (see man page)
+    MODULE_DIR=$PWD/ ${module_init_tools}/sbin/depmod -a $(basename lib/modules/2.*)
+    cd $out/
+  '';
 }
diff --git a/pkgs/os-specific/linux/nfs-utils/default.nix b/pkgs/os-specific/linux/nfs-utils/default.nix
index 18278ef3c34..7efdb07687f 100644
--- a/pkgs/os-specific/linux/nfs-utils/default.nix
+++ b/pkgs/os-specific/linux/nfs-utils/default.nix
@@ -1,17 +1,33 @@
-args: with args;
-stdenv.mkDerivation {
-  name = "nfs-utils-1.1.1";
+{ fetchurl, stdenv, tcpWrapper, e2fsprogs }:
+
+stdenv.mkDerivation rec {
+  name = "nfs-utils-1.1.2";
 
   src = fetchurl {
-    url = mirror://sourceforge/nfs/nfs-utils-1.1.1.tar.gz;
-    sha256 = "0aa434cv7lgbrhks0rzhwxvbk2zsa17kjwxqjrrh87zrv9d2sr1x";
+    url = "mirror://sourceforge/nfs/${name}.tar.gz";
+    sha256 = "0cs0kl18f4h8nkbnd7n3flw9krhkm3mx9sh7vz9dkvp46g0v228x";
   };
 
-  buildInputs = [kernelHeaders tcp_wrapper];
+  patches = [ ./sbindir.patch ];
+
+  # Needs `libblkid' and `libcomerr' from `e2fsprogs'.
+  buildInputs = [ tcpWrapper e2fsprogs ];
+
+  # FIXME: Currently too lazy to build the dependencies needed for NFSv4.
+  configurePhase = ''./configure --prefix=$out  \
+    --disable-gss --disable-nfsv4               \
+    --with-statedir=$out/var/lib/nfs'';
 
   meta = { 
-      description = "nfs utils";
-      homepage = http://nfs.sourceforge.net/;
-      license = "GPL2";
+    description = "Linux user-space NFS utilities";
+
+    longDescription = ''
+      This package contains various Linux user-space Network File
+      System (NFS) utilities, including RPC `mount' and `nfs'
+      daemons.
+    '';
+
+    homepage = http://nfs.sourceforge.net/;
+    license = "GPLv2";
   };
 }
diff --git a/pkgs/os-specific/linux/nfs-utils/sbindir.patch b/pkgs/os-specific/linux/nfs-utils/sbindir.patch
new file mode 100644
index 00000000000..2884b56e6d1
--- /dev/null
+++ b/pkgs/os-specific/linux/nfs-utils/sbindir.patch
@@ -0,0 +1,11 @@
+--- nfs-utils-1.1.2/utils/mount/Makefile.in	2008-03-14 18:44:42.000000000 +0100
++++ nfs-utils-1.1.2/utils/mount/Makefile.in	2008-03-30 19:30:57.000000000 +0200
+@@ -219,7 +219,7 @@ psdir = @psdir@
+ 
+ # These binaries go in /sbin (not /usr/sbin), and that cannot be
+ # overriden at config time.
+-sbindir = /sbin
++sbindir = @prefix@/sbin
+ secure_statd = @secure_statd@
+ sharedstatedir = @sharedstatedir@
+ srcdir = @srcdir@
diff --git a/pkgs/os-specific/linux/nss_ldap/default.nix b/pkgs/os-specific/linux/nss_ldap/default.nix
index afc54ef342d..34de5108164 100644
--- a/pkgs/os-specific/linux/nss_ldap/default.nix
+++ b/pkgs/os-specific/linux/nss_ldap/default.nix
@@ -9,7 +9,7 @@ stdenv.mkDerivation {
   };
 
   preInstall = ''
-    installFlagsArray=(INST_UID=$(id -u) INST_GID=$(id -g) LIBC_VERS=2.5 NSS_VERS=2)
+    installFlagsArray=(INST_UID=$(id -u) INST_GID=$(id -g) LIBC_VERS=2.5 NSS_VERS=2 NSS_LDAP_PATH_CONF=$out/etc/ldap.conf)
     substituteInPlace Makefile \
       --replace '/usr$(libdir)' $TMPDIR \
       --replace 'install-data-local:' 'install-data-local-disabled:'
diff --git a/pkgs/os-specific/linux/numactl/default.nix b/pkgs/os-specific/linux/numactl/default.nix
new file mode 100644
index 00000000000..f329db90cb2
--- /dev/null
+++ b/pkgs/os-specific/linux/numactl/default.nix
@@ -0,0 +1,26 @@
+{ fetchurl, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "numactl-1.0.2";
+  src = fetchurl {
+    url = "ftp://oss.sgi.com/www/projects/libnuma/download/${name}.tar.gz";
+    sha256 = "0hbrrh7a8cradj1xdl3wvyp9afx1hzsk90g2lkwd5pn6bniai31j";
+  };
+
+  patchPhase = ''
+    sed -i "Makefile" -es"|^ *prefix *:=.*$|prefix := $out|g"
+  '';
+
+  preInstall = ''
+    # The `install' rule expects this directory to be available.
+    ensureDir "$out/share/man/man5"
+  '';
+
+  meta = {
+    description = "Library and tools for non-uniform memory access (NUMA) machines";
+    license = [ "LGPLv2.1" # library
+                "GPLv2"    # command-line tools
+	      ];
+    homepage = http://oss.sgi.com/projects/libnuma/;
+  };
+}
diff --git a/pkgs/os-specific/linux/nvidia/default.nix b/pkgs/os-specific/linux/nvidia/default.nix
index 8f76343b74e..9ad1abd621b 100644
--- a/pkgs/os-specific/linux/nvidia/default.nix
+++ b/pkgs/os-specific/linux/nvidia/default.nix
@@ -7,14 +7,22 @@ let
 in
 
 stdenv.mkDerivation {
-  name = "nvidia-x11-${versionNumber}";
+  name = "nvidia-x11-${versionNumber}-${kernel.version}";
   
   builder = ./builder.sh;
   
-  src = fetchurl {
-    url = "http://us.download.nvidia.com/XFree86/Linux-x86/${versionNumber}/NVIDIA-Linux-x86-${versionNumber}-pkg1.run";
-    sha256 = "14r3zddrppd0zxq76dd08dlj4qqncr7fj9cnrny4f0b5d0qgrd3f";
-  };
+  src =
+    if stdenv.system == "i686-linux" then
+      fetchurl {
+        url = "http://us.download.nvidia.com/XFree86/Linux-x86/${versionNumber}/NVIDIA-Linux-x86-${versionNumber}-pkg1.run";
+       sha256 = "14r3zddrppd0zxq76dd08dlj4qqncr7fj9cnrny4f0b5d0qgrd3f";
+      }
+    else if stdenv.system == "x86_64-linux" then
+      fetchurl {
+        url = "http://us.download.nvidia.com/XFree86/Linux-x86_64/${versionNumber}/NVIDIA-Linux-x86_64-${versionNumber}-pkg2.run";
+       sha256 = "0dmgn5a0432zkhgh0d5xs2h0sq5di2iaqybrj5f1vb2ghayams1y";
+      }
+    else throw "nvidia-x11 does not support platform ${stdenv.system}";
 
   #xenPatch = ./nvidia-2.6.24-xen.patch;
 
diff --git a/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh b/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
index eb5dba48118..7ab20855bd3 100644
--- a/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
+++ b/pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
@@ -3,8 +3,9 @@ source $stdenv/setup
 ensureDir $out/lib
 
 ln -s /usr/lib/libGL.so.1 $out/lib/
+ln -s /usr/lib/libGLU.so.1 $out/lib/
 ln -s /usr/lib/libGLcore.so.1 $out/lib/
-ln -s /usr/lib/libnvidia-tls.so.1 $out/lib/
+ln -s /usr/lib/tls/libnvidia-tls.so.1 $out/lib/
 #ln -s /usr/lib/libdrm.so.2 $out/lib/
 
 for i in $neededLibs; do
diff --git a/pkgs/os-specific/linux/splashutils/default.nix b/pkgs/os-specific/linux/splashutils/1.3.nix
index 7af2f882f95..157690805f3 100644
--- a/pkgs/os-specific/linux/splashutils/default.nix
+++ b/pkgs/os-specific/linux/splashutils/1.3.nix
@@ -26,4 +26,10 @@ stdenv.mkDerivation {
   #makeFlags = "QUIET=false;
 
   installPhase = "ensureDir $out/bin; cp objs/splash_helper objs/splash_util objs/splash_util.static $out/bin";
+
+  passthru = {
+    helperName = "bin/splash_helper";
+    controlName = "bin/splash_util";
+    helperProcFile = "/proc/sys/kernel/fbsplash";
+  };
 }
diff --git a/pkgs/os-specific/linux/splashutils/1.5.nix b/pkgs/os-specific/linux/splashutils/1.5.nix
new file mode 100644
index 00000000000..7f0bce7dff9
--- /dev/null
+++ b/pkgs/os-specific/linux/splashutils/1.5.nix
@@ -0,0 +1,32 @@
+{stdenv, fetchurl, klibc, zlib, libjpeg}:
+
+stdenv.mkDerivation {
+  name = "splashutils-1.5.4.1";
+
+  src = fetchurl {
+    url = http://download.berlios.de/fbsplash/splashutils-1.5.4.1.tar.bz2;
+    sha256 = "0pwv9l6a042hhcwpi4kqdzjg7d1mrlix0fvgqqzqh93mc54z9lf7";
+  };
+
+  buildInputs = [klibc zlib libjpeg];
+  
+  dontAddPrefix = 1;
+
+  configureFlags = "--without-ttf --without-png --without-gpm --with-themedir=/etc/splash";
+
+  preConfigure = ''
+    configureFlags="$configureFlags --with-essential-prefix=$out --with-libdir=/"
+    substituteInPlace src/common.h \
+      --replace 'FBSPLASH_DIR"/sys"' '"/sys"' \
+      --replace 'FBSPLASH_DIR"/proc"' '"/proc"'
+  '';
+
+  CPP = "gcc -E";
+  CXXCPP = "g++ -E";
+
+  passthru = {
+    helperName = "sbin/fbcondecor_helper";
+    controlName = "sbin/fbcondecor_ctl";
+    helperProcFile = "/proc/sys/kernel/fbcondecor";
+  };
+}
diff --git a/pkgs/os-specific/linux/tcp-wrapper/builder.sh b/pkgs/os-specific/linux/tcp-wrapper/builder.sh
new file mode 100644
index 00000000000..fe8ad8d466e
--- /dev/null
+++ b/pkgs/os-specific/linux/tcp-wrapper/builder.sh
@@ -0,0 +1,37 @@
+source "$stdenv/setup" || exit 1
+
+# Unpack
+unpackPhase &&							\
+cd "$sourceRoot/upstream/tarballs" &&				\
+tar xzvf * &&							\
+cd tcp_wrappers_7.6 &&						\
+								\
+# Patch
+substituteInPlace "Makefile" --replace				\
+   "REAL_DAEMON_DIR=/usr/sbin" "REAL_DAEMON_DIR=$out/sbin"	\
+   --replace "/tmp" '$$TMPDIR' &&				\
+substituteInPlace "scaffold.c" --replace			\
+   'extern char *malloc();' " " &&				\
+substituteInPlace "environ.c" --replace				\
+   'extern char *malloc();' " " &&				\
+								\
+# The `linux' target doesn't work on Linux...
+echo building... &&						\
+make REAL_DAEMON_DIR="$out/sbin" freebsd &&			\
+								\
+# Install
+ensureDir "$out/sbin" &&					\
+cp safe_finger tcpd tcpdchk tcpdmatch try-from "$out/sbin" &&	\
+								\
+ensureDir "$out/lib" &&						\
+cp lib*.a "$out/lib" &&						\
+								\
+ensureDir "$out/include" &&					\
+cp *.h "$out/include" && 					\
+								\
+ensureDir "$out/man" &&						\
+for i in 3 5 8;							\
+do								\
+  ensureDir "$out/man/man$i" &&					\
+  cp *.$i "$out/man/man$i" ;					\
+done								\
diff --git a/pkgs/os-specific/linux/tcp-wrapper/default.nix b/pkgs/os-specific/linux/tcp-wrapper/default.nix
index 9c952bcabf8..d5984e649a5 100644
--- a/pkgs/os-specific/linux/tcp-wrapper/default.nix
+++ b/pkgs/os-specific/linux/tcp-wrapper/default.nix
@@ -1,26 +1,14 @@
-args: with args;
+{ fetchurl, stdenv }:
+
 stdenv.mkDerivation {
   name = "tcp-wrappers-7.6";
 
   src = fetchurl {
-    url = http://ftp.debian.org/debian/pool/main/t/tcp-wrappers/tcp-wrappers_7.6.dbs.orig.tar.gz;
+    url = mirror://debian/pool/main/t/tcp-wrappers/tcp-wrappers_7.6.dbs.orig.tar.gz;
     sha256 = "0k68ziinx6biwar5lcb9jvv0rp6b3vmj6861n75bvrz4w1piwkdp";
   };
   
-  # we need to set REAL_DAEMON_DIR somehow. I'm getting compilation errors
-  # I've managed to compile tcpd manually using 
-  # make CFLAGS='-DSYS_ERRLIST_DEFINED=1  -Dvsyslog=1' tcpd
-  # see Makefile target all for details
-
-  postUnpack="cd upstream/tarballs; tar xfz *; cd tcp_wrappers_7.6;
-    sed -i -e 's=#REAL_DAEMON_DIR=/usr/sbin=REAL_DAEMON_DIR=/usr/sbin=' Makefile
-          ";
-
-  buildPhase="
-    make CFLAGS='-DSYS_ERRLIST_DEFINED=1  -Dvsyslog=1' tcpd
-  "
-
-  buildInputs = [kernelHeaders gnused];
+  builder = ./builder.sh;
 
   # meta = ...
 }
diff --git a/pkgs/os-specific/linux/uml-utilities/builder.sh b/pkgs/os-specific/linux/uml-utilities/builder.sh
index cb89fa14bc6..003134c9832 100644
--- a/pkgs/os-specific/linux/uml-utilities/builder.sh
+++ b/pkgs/os-specific/linux/uml-utilities/builder.sh
@@ -3,11 +3,11 @@ source $stdenv/setup
 
 tar xvfj $src
 cd tools
-sed s/mconsole// < Makefile > tmp
-mv tmp Makefile
+sed -e 's/mconsole//' -e '1s/.*/TUNCTL = \$(shell [ -n tunctl ] \&\& echo tunctl)/' -i Makefile
 mkdir $out
 mkdir $out/bin
 mkdir $out/lib
 mkdir $out/lib/uml
 make BIN_DIR=$out/bin LIB_DIR=$out/lib/uml
 make BIN_DIR=$out/bin LIB_DIR=$out/lib/uml install
+[ -n $tunctl ] && [ -f $out/bin/tunctl ] || fail_no_tunctl
diff --git a/pkgs/os-specific/linux/wis-go7007/default.nix b/pkgs/os-specific/linux/wis-go7007/default.nix
index 3e35c83488a..0fa939c20c6 100644
--- a/pkgs/os-specific/linux/wis-go7007/default.nix
+++ b/pkgs/os-specific/linux/wis-go7007/default.nix
@@ -1,7 +1,7 @@
 {stdenv, fetchurl, kernel, ncurses, fxload}:
 
 stdenv.mkDerivation {
-  name = "wis-go7007-0.9.8";
+  name = "wis-go7007-0.9.8-${kernel.version}";
 
   src = fetchurl {
     url = http://gentoo.osuosl.org/distfiles/wis-go7007-linux-0.9.8.tar.bz2;
diff --git a/pkgs/os-specific/linux/wpa_supplicant/default.nix b/pkgs/os-specific/linux/wpa_supplicant/default.nix
index f58a360ac8d..584723c9b45 100644
--- a/pkgs/os-specific/linux/wpa_supplicant/default.nix
+++ b/pkgs/os-specific/linux/wpa_supplicant/default.nix
@@ -1,14 +1,15 @@
 {stdenv, fetchurl, openssl}:
 
 stdenv.mkDerivation {
-  name = "wpa_supplicant-0.5.9";
+  name = "wpa_supplicant-0.6.3";
 
   src = fetchurl {
-    url = http://hostap.epitest.fi/releases/wpa_supplicant-0.5.9.tar.gz;
-    sha256 = "1dylaiikp2jb13jbxdrl1h9b9p2lkjmzx06hpmkcpyq5c5g7p0xy";
+    url = http://hostap.epitest.fi/releases/wpa_supplicant-0.6.3.tar.gz;
+    sha256 = "f70b18243e049bbda66254388b6e94d404e747d913b8496d6e93a9c56bbf4af2";
   };
 
   preBuild = "
+    cd wpa_supplicant
     cp defconfig .config
     substituteInPlace Makefile --replace /usr/local $out
     makeFlagsArray=(ALL=\"wpa_supplicant wpa_passphrase wpa_cli\")
diff --git a/pkgs/os-specific/linux/xfsprogs/2.9.7-1.nix b/pkgs/os-specific/linux/xfsprogs/2.9.7-1.nix
new file mode 100644
index 00000000000..fc777d0dbf7
--- /dev/null
+++ b/pkgs/os-specific/linux/xfsprogs/2.9.7-1.nix
@@ -0,0 +1,25 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = ftp://oss.sgi.com/projects/xfs/cmd_tars/xfsprogs_2.9.7-1.tar.gz;
+    sha256 = "0g4pr1rv4lgc7vab18wiwrcr6jq40fs1krb2vfkgh779p7gf3il7";
+  };
+
+  buildInputs = [libtool gettext e2fsprogs];
+  configureFlags = [];
+
+  preConfigure = FullDepEntry (''
+    sp_path=$(echo $PATH | sed -e 's/:/ /g');
+    sed -e 's@/usr/bin@'"$PATH: $sp_path"'@g' -i configure
+    sed -e 's@/usr/local/bin@'"$PATH: sp_path"'@g' -i configure
+  '') ["minInit" "doUnpack" "addInputs"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"];
+      
+  name = "xfsprogs-" + version;
+  meta = {
+    description = "SGI XFS utilities";
+  };
+}
+  
diff --git a/pkgs/servers/dict/1.9.15.nix b/pkgs/servers/dict/1.9.15.nix
new file mode 100644
index 00000000000..4eb5c6cb0b3
--- /dev/null
+++ b/pkgs/servers/dict/1.9.15.nix
@@ -0,0 +1,24 @@
+args : with args; with builderDefs {src="";} null;
+	let localDefs = builderDefs (rec {
+		src = /* put a fetchurl here */
+		fetchurl {
+			url = ftp://ftp.dict.org/pub/dict/dictd-1.9.15.tar.gz;
+			sha256 = "0p41yf72l0igmshz6vxy3hm51z25600vrnb9j2jpgws4c03fqnac";
+		};
+
+		buildInputs = [flex bison which];
+		configureFlags = [ " --datadir=/var/run/current-system/share/dictd " ];
+	}) args null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "dict-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs 
+			[doConfigure doMakeInstall doForceShare doPropagate]);
+	meta = {
+		description = "
+		Dict protocol server and client.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/servers/dict/dictd-db-collector.nix b/pkgs/servers/dict/dictd-db-collector.nix
new file mode 100644
index 00000000000..299bfc8ac2f
--- /dev/null
+++ b/pkgs/servers/dict/dictd-db-collector.nix
@@ -0,0 +1,80 @@
+{stdenv, lib, dict}:
+({dictlist, allowList ? ["127.0.0.1"], denyList ? []}:
+/*
+ dictlist is a list of form 
+ [ { filename = /path/to/files/basename;
+ name = "name"; } ]
+ basename.dict.dz and basename.index should be 
+ dict files. Or look below for other options.
+ allowList is a list of IP/domain *-wildcarded strings
+ denyList is the same..
+*/
+
+let
+	link_arguments = map 
+			(x: '' "${x.filename}" '')
+			dictlist; 
+	databases = lib.concatStrings (map (x : 
+		"${x.name}	${x.filename}\n") dictlist);
+	allow = lib.concatStrings (map (x: "allow ${x}\n") allowList);
+	deny = lib.concatStrings (map (x: "deny ${x}\n") denyList);
+	accessSection = "
+		access {
+			${allow}
+			${deny}
+		}
+	";
+	installPhase = ''  
+  	ensureDir $out/share/dictd
+	cd $out/share/dictd
+	echo "${databases}" >databases.names 
+	echo "${accessSection}" > dictd.conf
+	for j in ${toString link_arguments}; do 
+		name="$(egrep '	'"$j"\$ databases.names)"
+		name=''${name%	$j}
+		if test -d "$j"; then
+			if test -d "$j"/share/dictd ; then
+				echo "Got store path $j"
+				j="$j"/share/dictd 
+			fi
+			echo "Directory reference: $j"
+			i=$(ls "$j""/"*.index)
+			i="''${i%.index}";
+		else
+			i="$j";
+		fi
+		echo "Basename is $i"
+		locale=$(cat "$(dirname "$i")"/locale)
+		base="$(basename "$i")"
+		echo "Locale is $locale"
+		export LC_ALL=$locale 
+		export LANG=$locale 
+		if test -e "$i".dict.dz; then
+			ln -s "$i".dict.dz
+		else
+			cp "$i".dict .
+			dictzip "$base".dict
+		fi
+		ln -s "$i".index .
+		dictfmt_index2word --locale $locale < "$base".index > "$base".word || true
+		dictfmt_index2suffix --locale $locale < "$base".index > "$base".suffix || true
+
+		echo "database $name {" >> dictd.conf
+		echo "  data $out/share/dictd/$base.dict.dz" >> dictd.conf
+		echo "  index $out/share/dictd/$base.index" >> dictd.conf
+		echo "  index_word $out/share/dictd/$base.word" >> dictd.conf
+		echo "  index_suffix $out/share/dictd/$base.suffix" >> dictd.conf
+		echo "}" >> dictd.conf
+	done
+  	'';
+
+in
+
+stdenv.mkDerivation {
+  name = "dictd-dbs";
+
+  phases = ["installPhase"];
+  buildInputs = [dict];
+
+  inherit installPhase;
+})
diff --git a/pkgs/servers/dict/dictd-db.nix b/pkgs/servers/dict/dictd-db.nix
new file mode 100644
index 00000000000..15503e44812
--- /dev/null
+++ b/pkgs/servers/dict/dictd-db.nix
@@ -0,0 +1,94 @@
+{ builderDefs }:
+
+let makeDictdDB = _src: _name: _subdir: _locale:
+with builderDefs {src="";} null;
+	let localDefs = builderDefs (rec {
+		src=_src;
+		doInstall = FullDepEntry (''
+			ensureDir $out/share/dictd
+			tar xf  ${src}
+			cp $(ls ./${_subdir}/*.{dict*,index} || true) $out/share/dictd 
+			echo "${_locale}" >$out/share/dictd/locale
+		'') ["minInit" "addInputs" "defEnsureDir"];
+
+		buildInputs = [];
+		configureFlags = [];
+	}) null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "dictd-db-${_name}";
+	locale = _locale;
+	dbName = _name;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs 
+			[doInstall doForceShare doPropagate]);
+	meta = {
+		description = "
+		${name} dictionary for dictd.
+";
+		inherit src;
+	};
+};
+# Probably a bug in some FreeDict release files, but easier to trivially
+# work around than report. Not that it can cause any other problems..
+makeDictdDBFreedict = _src: _name: _locale: makeDictdDB _src _name "{.,bin}" _locale;
+fetchurl = (builderDefs {src="";} null).fetchurl;
+
+in 
+
+rec {
+	nld2eng = makeDictdDBFreedict (fetchurl {
+		url = http://prdownloads.sourceforge.net/freedict/nld-eng.tar.gz;
+		sha256 = "1vhw81pphb64fzsjvpzsnnyr34ka2fxizfwilnxyjcmpn9360h07";
+	}) "nld-eng" "nl_NL";
+	eng2nld =  makeDictdDBFreedict (fetchurl {
+		url = http://downloads.sourceforge.net/freedict/eng-nld.tar.gz;
+		sha256 = "0rcg28ldykv0w2mpxc6g4rqmfs33q7pbvf68ssy1q9gpf6mz7vcl";
+	}) "eng-nld" "en_UK";
+	eng2rus = makeDictdDBFreedict (fetchurl {
+		url = http://downloads.sourceforge.net/freedict/eng-rus.tar.gz;
+		sha256 = "15409ivhww1wsfjr05083pv6mg10bak8v5pg1wkiqybk7ck61rry";
+	}) "eng-rus" "en_UK";
+	fra2eng = makeDictdDBFreedict (fetchurl {
+		url = http://downloads.sourceforge.net/freedict/fra-eng.tar.gz;
+		sha256 = "0sdd88s2zs5whiwdf3hd0s4pzzv75sdsccsrm1wxc87l3hjm85z3";
+	}) "fra-eng" "fr_FR";
+	eng2fra = makeDictdDBFreedict (fetchurl {
+		url = http://downloads.sourceforge.net/freedict/eng-fra.tar.gz;
+		sha256 = "0fi6rrnbqnhc6lq8d0nmn30zdqkibrah0mxfg27hsn9z7alwbj3m";
+	}) "eng-fra" "en_UK";
+	mueller_eng2rus_pkg = makeDictdDB (fetchurl {
+		url = http://downloads.sourceforge.net/mueller-dict/mueller-dict-3.1.tar.gz;
+		sha256 = "04r5xxznvmcb8hkxqbjgfh2gxvbdd87jnhqn5gmgvxxw53zpwfmq";
+	}) "mueller-eng-rus" "mueller-dict-*/dict" "en_UK";
+	mueller_enru_abbr = {
+		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-abbrev";
+		name = "mueller-abbr";
+		dbName = "mueller-abbr";
+		locale = "en_UK";
+	};
+	mueller_enru_base = {
+		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-base";
+		name = "mueller-base";
+		dbName = "mueller-base";
+		locale = "en_UK";
+	};
+	mueller_enru_dict = {
+		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-dict";
+		name = "mueller-dict";
+		dbName = "mueller-dict";
+		locale = "en_UK";
+	};
+	mueller_enru_geo = {
+		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-geo";
+		name = "mueller-geo";
+		dbName = "mueller-geo";
+		locale = "en_UK";
+	};
+	mueller_enru_names = {
+		outPath = "${mueller_eng2rus_pkg}/share/dictd/mueller-names";
+		name = "mueller-names";
+		dbName = "mueller-names";
+		locale = "en_UK";
+	};
+}
diff --git a/pkgs/servers/dict/freedict.nix b/pkgs/servers/dict/freedict.nix
new file mode 100644
index 00000000000..2f62525f394
--- /dev/null
+++ b/pkgs/servers/dict/freedict.nix
@@ -0,0 +1,4 @@
+	fetchurl {
+		url = http://downloads.sourceforge.net/freedict/freedict-tools-0.2.tar.bz2;
+		sha256 = "0hai4rvyrsgagvwq8ahp8iwby77wr62whkkda2pkp8l6fp9sm2gd";
+	};
diff --git a/pkgs/servers/dns/bind/9.5.0.nix b/pkgs/servers/dns/bind/9.5.0.nix
new file mode 100644
index 00000000000..9e73895d8d9
--- /dev/null
+++ b/pkgs/servers/dns/bind/9.5.0.nix
@@ -0,0 +1,19 @@
+
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftp.isc.org/isc/bind9/9.5.0/bind-9.5.0.tar.gz;
+    sha256 = "0qfxipj6v9hs9plx388ysnyvpkiamgxpsq8xqzw9hliag4nc1d7v";
+  };
+
+  buildInputs = [openssl libtool];
+  configureFlags = ["--with-libtool" "--with-openssl=${openssl}"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "bind-" + version;
+  meta = {
+    description = "ISC BIND: a domain name server";
+  };
+}
diff --git a/pkgs/servers/gpm/1.20.3pre6.nix b/pkgs/servers/gpm/1.20.3pre6.nix
new file mode 100644
index 00000000000..fd7a5a2382f
--- /dev/null
+++ b/pkgs/servers/gpm/1.20.3pre6.nix
@@ -0,0 +1,22 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://linux.schottelius.org/gpm/archives/releases-2008/gpm-1.20.3pre6.tar.lzma;
+    sha256 = "0sps9987w7daxfkbavzyi694n7ggf1wd5lh81nwka87m90q7rah7";
+  };
+
+  buildInputs = [lzma flex bison ncurses];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"];
+
+  preConfigure = FullDepEntry (''
+    sed -e 's/[$](MKDIR)/mkdir -p /' -i doc/Makefile.in
+  '') ["addInputs" "doUnpack" "minInit"];
+      
+  name = "gpm-" + version;
+  meta = {
+    description = "Mouse daemon";
+  };
+}
diff --git a/pkgs/servers/gpm/1.99.6.nix b/pkgs/servers/gpm/1.99.6.nix
new file mode 100644
index 00000000000..bb797730a14
--- /dev/null
+++ b/pkgs/servers/gpm/1.99.6.nix
@@ -0,0 +1,23 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://linux.schottelius.org/gpm/archives/gpm-1.99.6.tar.lzma;
+    sha256 = "14zxx7nx40k8b0bmwhxfyv20xrdi8cg9fxmv8ylsx661lvizqsg3";
+  };
+
+  buildInputs = [lzma flex bison ncurses];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"];
+
+  preConfigure = FullDepEntry (''
+    sed -e 's/[$](MKDIR)/mkdir -p /' -i doc/Makefile.in
+    sed -e 's/gpm2//' -i Makefile.in
+  '') ["addInputs" "doUnpack" "minInit"];
+      
+  name = "gpm-" + version;
+  meta = {
+    description = "Mouse daemon";
+  };
+}
diff --git a/pkgs/servers/http/apache-httpd/default.nix b/pkgs/servers/http/apache-httpd/default.nix
index 4e2af7ff900..4fb95f31cdc 100644
--- a/pkgs/servers/http/apache-httpd/default.nix
+++ b/pkgs/servers/http/apache-httpd/default.nix
@@ -7,7 +7,7 @@ assert db4Support -> db4 != null;
 assert expat != null && perl != null;
 
 stdenv.mkDerivation {
-  name = "apache-httpd-2.2.8x";
+  name = "apache-httpd-2.2.8";
 
   src = fetchurl {
     url = http://archive.apache.org/dist/httpd/httpd-2.2.8.tar.bz2;
diff --git a/pkgs/servers/mail/postfix/default.nix b/pkgs/servers/mail/postfix/default.nix
index f9f5f511559..cea7eaaab48 100644
--- a/pkgs/servers/mail/postfix/default.nix
+++ b/pkgs/servers/mail/postfix/default.nix
@@ -7,6 +7,27 @@ stdenv.mkDerivation {
     sha256 = "04hxpyd3h1f48fnppjwqqxbil13bcwidzpfkra2pgm7h42d9blq7";
   };
 
+  installTargets = ["non-interactive-package"];
+  installFlags = [" install_root=$out "];
+  preInstall = "sed -e '/^PATH=/d' -i postfix-install";
+  postInstall = ''
+    ensureDir $out
+    mv ut/$out/* $out/
+  '';
+
+  preBuild = ''
+    export daemon_directory=$out/libexec/postfix
+    export command_directory=$out/sbin
+    export queue_directory=/var/spool/postfix
+    export sendmail_path=$out/bin/sendmail
+    export mailq_path=$out/bin/mailq
+    export newaliases_path=$out/bin/newaliases
+    export html_directory=$out/share/postfix/doc/html
+    export manpage_directory=$out/share/man
+    export sample_directory=$out/share/postfix/doc/samples
+    export readme_directory=$out/share/postfix/doc
+  '';
+
   buildinputs = [db4];
   patches = [./postfix-2.2.9-db.patch ./postfix-2.2.9-lib.patch];
   inherit glibc;
diff --git a/pkgs/servers/monitoring/zabbix/default.nix b/pkgs/servers/monitoring/zabbix/default.nix
new file mode 100644
index 00000000000..6bc15d54abb
--- /dev/null
+++ b/pkgs/servers/monitoring/zabbix/default.nix
@@ -0,0 +1,34 @@
+{stdenv, fetchurl, enableServer ? false, postgresql ? null, curl ? null}:
+
+stdenv.mkDerivation {
+  name = "zabbix-1.4.5";
+
+  src = fetchurl {
+    url = mirror://sourceforge/zabbix/zabbix-1.4.5.tar.gz;
+    sha256 = "1ha82q6rp49rgdfmni73y60kqjy00mfr2bp10mb0gnb0k4v9ppmb";
+  };
+
+  configureFlags = "--enable-agent " +
+    (if enableServer then ''
+      --enable-server
+      --with-pgsql
+      --with-libcurl
+    '' else "");
+
+  buildInputs = stdenv.lib.optionals enableServer [postgresql curl];
+
+  postInstall = if enableServer then ''
+    ensureDir $out/share/zabbix
+    cp -prvd frontends/php $out/share/zabbix/php
+    ensureDir $out/share/zabbix/db/data
+    cp -prvd create/data/*.sql $out/share/zabbix/db/data
+    ensureDir $out/share/zabbix/db/schema
+    cp -prvd create/schema/*.sql $out/share/zabbix/db/schema
+  '' else ""; # */
+
+  meta = {
+    description = "An enterprise-class open source distributed monitoring solution";
+    homepage = http://www.zabbix.com/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/servers/network-script/builder.sh b/pkgs/servers/network-script/builder.sh
deleted file mode 100644
index 466644fe486..00000000000
--- a/pkgs/servers/network-script/builder.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-source $stdenv/setup
-
-ensureDir $out
-
-sed -e "s^@bash\@^$bash^g" \
-    -e "s^@dhcp\@^$dhcp^g" \
-    -e "s^@initscripts\@^$initscripts^g" \
-    -e "s^@nettools\@^$nettools^g" \
-    < $script > $out/control
-
-chmod +x $out/control
diff --git a/pkgs/servers/network-script/default.nix b/pkgs/servers/network-script/default.nix
deleted file mode 100644
index fa85bd3b220..00000000000
--- a/pkgs/servers/network-script/default.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{stdenv, bash, nettools, dhcp, key ? null, initscripts}:
-
-stdenv.mkDerivation {
-  name = "network-script-0.0.1";
-  server = "network";
-  nicename = "networking";
-  builder = ./builder.sh ;
-  inherit bash nettools dhcp initscripts;
-  script = [./network];
-}
diff --git a/pkgs/servers/network-script/network b/pkgs/servers/network-script/network
deleted file mode 100755
index e676ff55a04..00000000000
--- a/pkgs/servers/network-script/network
+++ /dev/null
@@ -1,66 +0,0 @@
-#!@bash@/bin/bash
-#
-# Dummy init file for network, hacketyhack!
-#
-# chkconfig: 2345 55 25
-# description: OpenSSH server daemon
-#
-# processname: sshd
-
-# source function library
-source @initscripts@/functions
-
-# pull in sysconfig settings
-#[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
-
-RETVAL=0
-prog="network"
-INTERFACE=eth0
-
-startService()
-{
-	# just do networking
-	echo -n "Starting $prog:"
-	@dhcp@/sbin/dhclient $INTERFACE
-
-	RETVAL=$?
-	echo "retval $RETVAL"
-	return $RETVAL
-}
-
-stopService()
-{
-	echo "BLAAT"
-}
-
-reload()
-{
-	start
-	stop
-}
-
-case "$1" in
-	start)
-		start
-		;;
-	stop)
-		stop
-		;;
-	restart)
-		stop
-		start
-		;;
-	reload)
-		reload
-		;;
-	status)
-		status
-		;;
-	name)
-		name
-		;;
-	*)
-		echo $"Usage: $0 {start|stop|restart|reload|status|name}"
-		RETVAL=1
-esac
-exit $RETVAL
diff --git a/pkgs/servers/portmap/default.nix b/pkgs/servers/portmap/default.nix
new file mode 100644
index 00000000000..5687475d8fd
--- /dev/null
+++ b/pkgs/servers/portmap/default.nix
@@ -0,0 +1,42 @@
+{ fetchurl, stdenv, lib, tcpWrapper
+, daemonUser, daemonUID, daemonGID }:
+
+assert daemonUser -> (!daemonUID && !daemonGID);
+
+stdenv.mkDerivation rec {
+  name = "portmap-6.0";
+  src = fetchurl {
+    url = "http://neil.brown.name/portmap/${name}.tgz";
+    sha256 = "1pj13ll4mbfwjwpn3fbg03qq9im6v2i8fcpa3ffp4viykz9j1j02";
+  };
+
+  patchPhase = ''
+    substituteInPlace "Makefile" --replace "/usr/share" "" \
+      --replace "install -o root -g root" "install"
+  '';
+
+  makeFlags =
+   lib.concatStringsSep " "
+     (lib.optional (daemonUser != false) "RPCUSER=\"${daemonUser}\""
+      ++ lib.optional (daemonUID != false) "DAEMON_UID=${toString daemonUID}"
+      ++ lib.optional (daemonGID != false) "DAEMON_GID=${toString daemonGID}");
+
+  buildInputs = [ tcpWrapper ];
+
+  installPhase = ''
+    ensureDir "$out/sbin" && ensureDir "$out/man/man8" && \
+    make install BASEDIR=$out
+  '';
+
+  meta = {
+    description = "ONC RPC portmapper";
+    longDescription = ''
+      Portmap is part of the ONC RPC software collection implementing
+      remote procedure calls (RPCs) between computer programs.  It is
+      widely used by NFS and NIS, among others.
+    '';
+
+    homepage = http://neil.brown.name/portmap/;
+    license = "BSD";
+  };
+}
diff --git a/pkgs/servers/samba/default.nix b/pkgs/servers/samba/default.nix
index 629ac2a31b8..10dc584e921 100644
--- a/pkgs/servers/samba/default.nix
+++ b/pkgs/servers/samba/default.nix
@@ -1,23 +1,34 @@
 args: with args;
 
 stdenv.mkDerivation rec {
-  name = "samba-3.0.28";
+  name = "samba-3.0.30";
 
   src = fetchurl {
-    url = "http://us1.samba.org/samba/ftp/stable/${name}.tar.gz";
-    sha256 = "13nr4mvh6vxgl7nb94qnqx3njcyd10cf4ji18srlkizpp49r5byw";
+    url = http://www.samba.org/samba/ftp/stable/samba-3.0.30.tar.gz;
+    sha256 = "0lzs53424fblg9g6z3nsan3dxi3bnn5h4zs31ji2bavai4xrsy51";
   };
 
   buildInputs = [readline pam openldap kerberos popt iniparser libunwind fam];
-  configureFlags = ''--with-pam --with-smbmount --datadir=$out/share
-  --with-aio-support ''
-  + (if (stdenv.gcc.libc != null) then "--with-libiconv=${stdenv.gcc.libc}" else "");
-  postUnpack = "sourceRoot=\$sourceRoot/source";
+
+  preConfigure = "cd source";
   
-  configFile = ./smb.conf;
-  postInstall = ''
-  rm -rf $out/var
-  ln -s /var/samba $out/var
-  cp ${configFile} $out/lib/smb.conf
+  configureFlags = ''
+    --with-pam
+    --with-smbmount
+    --with-aio-support
+    ${if (stdenv.gcc.libc != null) then "--with-libiconv=${stdenv.gcc.libc}" else ""}
   '';
+
+
+  #  --datadir=$out/share
+    
+  #postUnpack = "sourceRoot=\$sourceRoot/source";
+  
+  #configFile = ./smb.conf;
+  
+  #postInstall = ''
+  #  rm -rf $out/var
+  #  ln -s /var/samba $out/var
+  #  cp ${configFile} $out/lib/smb.conf
+  #'';
 }
diff --git a/pkgs/servers/samba/smb.conf b/pkgs/servers/samba/smb.conf
deleted file mode 100644
index c9da0d2cbb5..00000000000
--- a/pkgs/servers/samba/smb.conf
+++ /dev/null
@@ -1,271 +0,0 @@
-# This is the main Samba configuration file. You should read the
-# smb.conf(5) manual page in order to understand the options listed
-# here. Samba has a huge number of configurable options (perhaps too
-# many!) most of which are not shown in this example
-#
-# For a step to step guide on installing, configuring and using samba, 
-# read the Samba-HOWTO-Collection. This may be obtained from:
-#  http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
-#
-# Many working examples of smb.conf files can be found in the 
-# Samba-Guide which is generated daily and can be downloaded from: 
-#  http://www.samba.org/samba/docs/Samba-Guide.pdf
-#
-# Any line which starts with a ; (semi-colon) or a # (hash) 
-# is a comment and is ignored. In this example we will use a #
-# for commentry and a ; for parts of the config file that you
-# may wish to enable
-#
-# NOTE: Whenever you modify this file you should run the command "testparm"
-# to check that you have not made any basic syntactic errors. 
-#
-#======================= Global Settings =====================================
-[global]
-
-# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
-   workgroup = NIXOSGROUP
-
-# server string is the equivalent of the NT Description field
-   server string = Samba Server
-
-# Security mode. Defines in which mode Samba will operate. Possible 
-# values are share, user, server, domain and ads. Most people will want 
-# user level security. See the Samba-HOWTO-Collection for details.
-   security = user
-
-# This option is important for security. It allows you to restrict
-# connections to machines which are on your local network. The
-# following example restricts access to two C class networks and
-# the "loopback" interface. For more examples of the syntax see
-# the smb.conf man page
-;   hosts allow = 192.168.1. 192.168.2. 127.
-
-# If you want to automatically load your printer list rather
-# than setting them up individually then you'll need this
-   load printers = yes
-
-# you may wish to override the location of the printcap file
-;   printcap name = /etc/printcap
-
-# on SystemV system setting printcap name to lpstat should allow
-# you to automatically obtain a printer list from the SystemV spool
-# system
-;   printcap name = lpstat
-
-# It should not be necessary to specify the print system type unless
-# it is non-standard. Currently supported print systems include:
-# bsd, cups, sysv, plp, lprng, aix, hpux, qnx
-;   printing = cups
-
-# Uncomment this if you want a guest account, you must add this to /etc/passwd
-# otherwise the user "nobody" is used
-  guest account = smbguest
-
-# this tells Samba to use a separate log file for each machine
-# that connects
-   log file = /var/samba/sambalog/log.%m
-
-# Put a capping on the size of the log files (in Kb).
-   max log size = 50
-
-# Use password server option only with security = server
-# The argument list may include:
-#   password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]
-# or to auto-locate the domain controller/s
-#   password server = *
-;   password server = <NT-Server-Name>
-
-# Use the realm option only with security = ads
-# Specifies the Active Directory realm the host is part of
-;   realm = MY_REALM
-
-# Backend to store user information in. New installations should 
-# use either tdbsam or ldapsam. smbpasswd is available for backwards 
-# compatibility. tdbsam requires no further configuration.
-   passdb backend = tdbsam:/var/samba/passdb.tdb
-
-# Using the following line enables you to customise your configuration
-# on a per machine basis. The %m gets replaced with the netbios name
-# of the machine that is connecting.
-# Note: Consider carefully the location in the configuration file of
-#       this line.  The included file is read at that point.
-;   include = /usr/local/samba/lib/smb.conf.%m
-
-# Configure Samba to use multiple interfaces
-# If you have multiple network interfaces then you must list them
-# here. See the man page for details.
-;   interfaces = 192.168.12.2/24 192.168.13.2/24 
-
-# Browser Control Options:
-# set local master to no if you don't want Samba to become a master
-# browser on your network. Otherwise the normal election rules apply
-;   local master = no
-
-# OS Level determines the precedence of this server in master browser
-# elections. The default value should be reasonable
-;   os level = 33
-
-# Domain Master specifies Samba to be the Domain Master Browser. This
-# allows Samba to collate browse lists between subnets. Don't use this
-# if you already have a Windows NT domain controller doing this job
-;   domain master = yes 
-
-# Preferred Master causes Samba to force a local browser election on startup
-# and gives it a slightly higher chance of winning the election
-;   preferred master = yes
-
-# Enable this if you want Samba to be a domain logon server for 
-# Windows95 workstations. 
-;   domain logons = yes
-
-# if you enable domain logons then you may want a per-machine or
-# per user logon script
-# run a specific logon batch file per workstation (machine)
-;   logon script = %m.bat
-# run a specific logon batch file per username
-;   logon script = %U.bat
-
-# Where to store roving profiles (only for Win95 and WinNT)
-#        %L substitutes for this servers netbios name, %U is username
-#        You must uncomment the [Profiles] share below
-;   logon path = \\%L\Profiles\%U
-
-# Windows Internet Name Serving Support Section:
-# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
-;   wins support = yes
-
-# WINS Server - Tells the NMBD components of Samba to be a WINS Client
-#	Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
-;   wins server = w.x.y.z
-
-# WINS Proxy - Tells Samba to answer name resolution queries on
-# behalf of a non WINS capable client, for this to work there must be
-# at least one	WINS Server on the network. The default is NO.
-;   wins proxy = yes
-
-# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
-# via DNS nslookups. The default is NO.
-   dns proxy = no 
-
-# These scripts are used on a domain controller or stand-alone 
-# machine to add or delete corresponding unix accounts
-;  add user script = /usr/sbin/useradd %u
-;  add group script = /usr/sbin/groupadd %g
-;  add machine script = /usr/sbin/adduser -n -g machines -c Machine -d /dev/null -s /bin/false %u
-;  delete user script = /usr/sbin/userdel %u
-;  delete user from group script = /usr/sbin/deluser %u %g
-;  delete group script = /usr/sbin/groupdel %g
-
-
-#============================ Share Definitions ==============================
-[homes]
-   comment = Home Directories
-   browseable = yes
-   writable = yes
-
-# Un-comment the following and create the netlogon directory for Domain Logons
-; [netlogon]
-;   comment = Network Logon Service
-;   path = /usr/local/samba/lib/netlogon
-;   guest ok = yes
-;   writable = no
-;   share modes = no
-
-
-# Un-comment the following to provide a specific roving profile share
-# the default is to use the user's home directory
-;[Profiles]
-;    path = /usr/local/samba/profiles
-;    browseable = no
-;    guest ok = yes
-
-
-# NOTE: If you have a BSD-style print system there is no need to 
-# specifically define each individual printer
-[printers]
-   comment = All Printers
-   path = /usr/spool/samba
-   browseable = no
-# Set public = yes to allow user 'guest account' to print
-   guest ok = no
-   writable = no
-   printable = yes
-
-# This one is useful for people to share files
-;[tmp]
-;   comment = Temporary file space
-;   path = /tmp
-;   read only = no
-;   public = yes
-
-# A publicly accessible directory, but read only, except for people in
-# the "staff" group
-;[public]
-;   comment = Public Stuff
-;   path = /home/samba
-;   public = yes
-;   writable = yes
-;   printable = no
-;   write list = @staff
-
-# Other examples. 
-#
-# A private printer, usable only by fred. Spool data will be placed in fred's
-# home directory. Note that fred must have write access to the spool directory,
-# wherever it is.
-;[fredsprn]
-;   comment = Fred's Printer
-;   valid users = fred
-;   path = /homes/fred
-;   printer = freds_printer
-;   public = no
-;   writable = no
-;   printable = yes
-
-# A private directory, usable only by fred. Note that fred requires write
-# access to the directory.
-;[fredsdir]
-;   comment = Fred's Service
-;   path = /usr/somewhere/private
-;   valid users = fred
-;   public = no
-;   writable = yes
-;   printable = no
-
-# a service which has a different directory for each machine that connects
-# this allows you to tailor configurations to incoming machines. You could
-# also use the %U option to tailor it by user name.
-# The %m gets replaced with the machine name that is connecting.
-;[pchome]
-;  comment = PC Directories
-;  path = /usr/pc/%m
-;  public = no
-;  writable = yes
-
-# A publicly accessible directory, read/write to all users. Note that all files
-# created in the directory by users will be owned by the default user, so
-# any user with access can delete any other user's files. Obviously this
-# directory must be writable by the default user. Another user could of course
-# be specified, in which case all files would be owned by that user instead.
-;[public]
-;   path = /usr/somewhere/else/public
-;   public = yes
-;   only guest = yes
-;   writable = yes
-;   printable = no
-
-# The following two entries demonstrate how to share a directory so that two
-# users can place files there that will be owned by the specific users. In this
-# setup, the directory should be writable by both users and should have the
-# sticky bit set on it to prevent abuse. Obviously this could be extended to
-# as many users as required.
-;[myshare]
-;   comment = Mary's and Fred's stuff
-;   path = /usr/somewhere/shared
-;   valid users = mary fred
-;   public = no
-;   writable = yes
-;   printable = no
-;   create mask = 0765
-
-
diff --git a/pkgs/servers/server-scripts/generic/builder.sh b/pkgs/servers/server-scripts/generic/builder.sh
deleted file mode 100644
index 7eae08df624..00000000000
--- a/pkgs/servers/server-scripts/generic/builder.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-source $stdenv/setup
-
-ensureDir $out
-
-sed -e "s^@bash\@^$bash^g" \
-    -e "s^@sshd\@^$ssh^g" \
-    -e "s^@initscripts\@^$initscripts^g" \
-    -e "s^@coreutils\@^$coreutils^g" \
-    -e "s^@nixpkgs\@^$nixpkgs^g" \
-    -e "s^@nix\@^$nix^g" \
-    < $functions > $out/$nicename
diff --git a/pkgs/servers/server-scripts/generic/default.nix b/pkgs/servers/server-scripts/generic/default.nix
deleted file mode 100644
index 4e9022568b4..00000000000
--- a/pkgs/servers/server-scripts/generic/default.nix
+++ /dev/null
@@ -1,11 +0,0 @@
-{stdenv, bash, nix}:
-
-stdenv.mkDerivation {
-  name = "generic-server-script-0.0.1";
-  server = "generic";
-  nicename = "functions";
-  builder = ./builder.sh ;
-  functions = [./functions];
-  nixpkgs = "/nixpkgs/trunk/pkgs";
-  inherit bash nix;
-}
diff --git a/pkgs/servers/server-scripts/generic/functions b/pkgs/servers/server-scripts/generic/functions
deleted file mode 100644
index d67370388f0..00000000000
--- a/pkgs/servers/server-scripts/generic/functions
+++ /dev/null
@@ -1,117 +0,0 @@
-#! @bash@/bin/sh -e
-
-## Generic service scripts for NixOS, which provide
-## * functions to write state to files (/var/run/nix-services)
-## * functions to read state from file (/var/run/nix-services)
-## * sanity checking functions
-
-STATEDIR=/var/run/nix-services
-RCDIR=/etc/rc.d/
-NIXPKGS=@nixpkgs@
-
-## resolve $deps to real start/stop scripts first
-
-start_deps() {
-	for i in $deps; do
-		echo $i
-		name=`$i/control name`
-
-		if ! test -a "$RCDIR/$name"; then
-			echo $RCDIR/$name $i
-			@nix@/bin/nix-env -p $RCDIR/$name -i $i
-		fi
-
-		$i/control start
-
-		RETVAL=$?
-		if test $RETVAL != 0; then
-			exit $RETVAL	
-		fi
-	done
-}
-
-start_softdeps() {
-	for i in $softdeps; do
-		echo $i
-
-		name=`$i/control name`
-		if ! test -a "$RCDIR/$name"; then
-			echo $RCDIR/$name $i
-			@nix@/bin/nix-env -p $RCDIR/$name -i $i
-		fi
-
-		$i/control start
-
-		RETVAL=$?
-		if test $RETVAL != 0; then
-			continue
-		fi
-	done
-}
-
-start() {
-	# are we already running?
-	# if so, exit with code 0
-	if test -a $STATEDIR/$prog; then
-		exit 0
-	fi
-	# if not, continue
-	# launch all hard dependencies
-	start_deps
-
-	RETVAL=$?
-
-	if test $RETVAL != 0; then
-		echo $prog failed
-		exit $RETVAL
-	fi
-
-	# launch all preferred dependencies
-	echo "softdeps" $softdeps
-	start_softdeps
-	# launch our own program
-	startService
-	# if successful, then register
-
-	RETVAL=$?
-
-	if test $RETVAL != 0; then
-		echo $prog failed
-		exit $RETVAL
-	fi
-
-	register
-}
-
-stop() {
-	echo "stopping $prog"
-	# are we running? If so, then stop, otherwise, do nothing...
-	if ! test -a $STATEDIR/$prog; then
-		exit 0
-	fi
-	# stop our own program
-	stopService
-	echo "unregistering"
-	unregister
-}
-
-register() {
-	touch $STATEDIR/$prog
-}
-
-unregister() {
-	rm $STATEDIR/$prog
-}
-
-status() {
-	# are we running? If so, report
-	if test -a $STATEDIR/$prog; then
-		echo "running"
-	else
-		echo "stopped"
-	fi
-}
-
-name() {
-	echo $prog
-}
diff --git a/pkgs/servers/squid/3.head.nix b/pkgs/servers/squid/3.head.nix
new file mode 100644
index 00000000000..0159ee76c0b
--- /dev/null
+++ b/pkgs/servers/squid/3.head.nix
@@ -0,0 +1,24 @@
+args:
+( args.mkDerivationByConfiguration {
+    flagConfig = {
+      mandatory = { buildInputs = [ "perl" ]; };
+      # many options I don't know wether they should be default .. 
+    }; 
+
+    extraAttrs = co : {
+      name = "squid-3.0-stable5";
+
+      src = args.fetchurl {
+        url = http://www.squid-cache.org/Versions/v3/HEAD/squid-3.HEAD-20080424.tar.bz2;
+        sha256 = "0mqjq8112rjgn3nbpkg8iql32cnk5kiw8fmhj5gbqzbycbhaxjgz";
+      };
+
+      configureFlags = ["--enable-ipv6"];
+
+      meta = { 
+        description = "http-proxy";
+        homepage = "http://www.squid-cache.org";
+        license = "GPL2";
+      };
+  };
+} ) args
diff --git a/pkgs/servers/squid/default.nix b/pkgs/servers/squid/default.nix
index 6bf63ae027b..3ae7053f929 100644
--- a/pkgs/servers/squid/default.nix
+++ b/pkgs/servers/squid/default.nix
@@ -6,13 +6,15 @@ args:
     }; 
 
     extraAttrs = co : {
-      name = "squid-2.6-stable";
+      name = "squid-3.0-stable5";
 
       src = args.fetchurl {
-        url = http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE16.tar.bz2;
-        sha256 = "1iv21a4cl74bqzrk07l0lbzlq3n9qpd0r31fgsjv2dsabj46qc4y";
+        url = http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE5.tar.bz2;
+        sha256 = "1m4ccpjw30q9vwsycmgg9dmhly0mpznvxrch6f7dxgfzpjp26l7w";
       };
 
+      configureFlags = ["--enable-ipv6"];
+
       meta = { 
         description = "http-proxy";
         homepage = "http://www.squid-cache.org";
diff --git a/pkgs/servers/ssh-script/builder.sh b/pkgs/servers/ssh-script/builder.sh
deleted file mode 100644
index 031438d5492..00000000000
--- a/pkgs/servers/ssh-script/builder.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-source $stdenv/setup
-
-ensureDir $out
-
-sed -e "s^@bash\@^$bash^g" \
-    -e "s^@sshd\@^$ssh^g" \
-    -e "s^@initscripts\@^$initscripts^g" \
-    -e "s^@coreutils\@^$coreutils^g" \
-    -e "s^@softdeps\@^$softdeps^g" \
-    -e "s^@deps\@^$deps^g" \
-    < $script > $out/control
-
-chmod +x $out/control
diff --git a/pkgs/servers/ssh-script/default.nix b/pkgs/servers/ssh-script/default.nix
deleted file mode 100644
index 03897e26b35..00000000000
--- a/pkgs/servers/ssh-script/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{stdenv, ssh, bash, initscripts, coreutils, key ? null, syslog ? null, networking}:
-
-stdenv.mkDerivation {
-  name = "ssh-script-0.0.1";
-  nicename = "sshd";
-  server = "ssh";
-  builder = ./builder.sh ;
-  softdeps = [syslog];
-  deps = [networking];
-  inherit bash ssh initscripts coreutils;
-  script = [./sshd];
-}
diff --git a/pkgs/servers/ssh-script/sshd b/pkgs/servers/ssh-script/sshd
deleted file mode 100755
index ccce294e10c..00000000000
--- a/pkgs/servers/ssh-script/sshd
+++ /dev/null
@@ -1,163 +0,0 @@
-#!@bash@/bin/bash
-#
-# Init file for OpenSSH server daemon
-#
-# chkconfig: 2345 55 25
-# description: OpenSSH server daemon
-#
-# processname: sshd
-# config: /etc/ssh/ssh_host_key
-# config: /etc/ssh/ssh_host_key.pub
-# config: /etc/ssh/ssh_random_seed
-# config: /etc/ssh/sshd_config
-# pidfile: /var/run/sshd.pid
-
-# source function library
-source @initscripts@/functions
-
-# pull in sysconfig settings
-[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
-
-RETVAL=0
-prog="sshd"
-
-softdeps="@softdeps@"
-deps="@deps@"
-
-# Some functions to make the below more readable
-KEYGEN=@sshd@/bin/ssh-keygen
-SSHD=@sshd@/sbin/sshd
-RSA1_KEY=/etc/ssh/ssh_host_key
-RSA_KEY=/etc/ssh/ssh_host_rsa_key
-DSA_KEY=/etc/ssh/ssh_host_dsa_key
-PID_FILE=/var/run/sshd.pid
-OPTIONS="-h $DSA_KEY -h RSA_KEY -h RSA1_KEY"
-
-do_rsa1_keygen() {
-	if [ ! -s $RSA1_KEY ]; then
-		echo -n $"Generating SSH1 RSA host key: "
-		if $KEYGEN -q -t rsa1 -f $RSA1_KEY -C '' -N '' >&/dev/null; then
-			@coreutils@/bin/chmod 600 $RSA1_KEY
-			@coreutils@/bin/chmod 644 $RSA1_KEY.pub
-			success $"RSA1 key generation"
-			echo
-		else
-			failure $"RSA1 key generation"
-			echo
-			exit 1
-		fi
-	fi
-}
-
-do_rsa_keygen() {
-	if [ ! -s $RSA_KEY ]; then
-		echo -n $"Generating SSH2 RSA host key: "
-		if $KEYGEN -q -t rsa -f $RSA_KEY -C '' -N '' >&/dev/null; then
-			@coreutils@/bin/chmod 600 $RSA_KEY
-			@coreutils@/bin/chmod 644 $RSA_KEY.pub
-			success $"RSA key generation"
-			echo
-		else
-			failure $"RSA key generation"
-			echo
-			exit 1
-		fi
-	fi
-}
-
-do_dsa_keygen() {
-	if [ ! -s $DSA_KEY ]; then
-		echo -n $"Generating SSH2 DSA host key: "
-		if $KEYGEN -q -t dsa -f $DSA_KEY -C '' -N '' >&/dev/null; then
-			@coreutils@/bin/chmod 600 $DSA_KEY
-			@coreutils@/bin/chmod 644 $DSA_KEY.pub
-			success $"DSA key generation"
-			echo
-		else
-			failure $"DSA key generation"
-			echo
-			exit 1
-		fi
-	fi
-}
-
-do_restart_sanity_check()
-{
-	$SSHD -t
-	RETVAL=$?
-	if [ ! "$RETVAL" = 0 ]; then
-		failure $"Configuration file or keys are invalid"
-		echo
-	fi
-}
-
-startService()
-{
-	# Create keys if necessary
-	do_rsa1_keygen
-	do_rsa_keygen
-	do_dsa_keygen
-
-	echo -n $"Starting $prog:"
-	#@initscripts@/sbin/initlog -c "$SSHD $OPTIONS" && success || failure
-	$SSHD $OPTIONS
-	RETVAL=$?
-	[ "$RETVAL" = 0 ] && @coreutils@/bin/touch /var/lock/subsys/sshd
-	echo
-}
-
-stopService()
-{
-	echo -n $"Stopping $prog:"
-	#killproc $SSHD -TERM
-	@coreutils@/bin/kill `@coreutils@/bin/cat /var/run/sshd.pid`
-	RETVAL=$?
-	[ "$RETVAL" = 0 ] && @coreutils@/bin/rm -f /var/lock/subsys/sshd
-	echo
-}
-
-reload()
-{
-	echo -n $"Reloading $prog:"
-	killproc $SSHD -HUP
-	RETVAL=$?
-	echo
-}
-
-case "$1" in
-	start)
-		start
-		;;
-	stop)
-		stop
-		;;
-	restart)
-		stop
-		start
-		;;
-	reload)
-		reload
-		;;
-	condrestart)
-		if [ -f /var/lock/subsys/sshd ] ; then
-			do_restart_sanity_check
-			if [ "$RETVAL" = 0 ] ; then
-				stop
-				# avoid race
-				sleep 3
-				start
-			fi
-		fi
-		;;
-	status)
-		status $SSHD
-		RETVAL=$?
-		;;
-	name)
-		name
-		;;
-	*)
-		echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
-		RETVAL=1
-esac
-exit $RETVAL
diff --git a/pkgs/servers/syslog-script/builder.sh b/pkgs/servers/syslog-script/builder.sh
deleted file mode 100644
index 9c6cf385c24..00000000000
--- a/pkgs/servers/syslog-script/builder.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-source $stdenv/setup
-
-ensureDir $out
-
-sed -e "s^@bash\@^$bash^g" \
-    -e "s^@syslog\@^$syslog^g" \
-    -e "s^@nicename\@^$nicename^g" \
-    -e "s^@initscripts\@^$initscripts^g" \
-    < $script > $out/control
-
-chmod +x $out/control
diff --git a/pkgs/servers/syslog-script/default.nix b/pkgs/servers/syslog-script/default.nix
deleted file mode 100644
index c98da1e49ef..00000000000
--- a/pkgs/servers/syslog-script/default.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{stdenv, bash, syslog, initscripts}:
-
-stdenv.mkDerivation {
-  name = "syslog-script-0.0.1";
-  server = "syslog";
-  nicename = "syslog";
-  builder = ./builder.sh ;
-  inherit bash syslog initscripts;
-  script = [./syslog];
-}
diff --git a/pkgs/servers/syslog-script/syslog b/pkgs/servers/syslog-script/syslog
deleted file mode 100755
index 9a82f5eaf03..00000000000
--- a/pkgs/servers/syslog-script/syslog
+++ /dev/null
@@ -1,64 +0,0 @@
-#!@bash@/bin/bash
-#
-# Dummy init file for syslog, hacketyhack!
-#
-# chkconfig: 2345 55 25
-# description: OpenSSH server daemon
-#
-# processname: sshd
-
-# source function library
-source @initscripts@/functions
-
-# pull in sysconfig settings
-#[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
-
-RETVAL=0
-prog=@nicename@
-
-startService()
-{
-	# just do networking
-	echo -n "Starting $prog:"
-	@syslog@/usr/sbin/syslogd
-	@syslog@/usr/sbin/klogd
-}
-
-stopService()
-{
-	echo -n "Stopping $prog:"
-	kill `cat /var/run/syslogd.pid`
-	kill `cat /var/run/klogd.pid`
-}
-
-reloadService()
-{
-	stop
-	start
-}
-
-case "$1" in
-	start)
-		start
-		;;
-	stop)
-		stop
-		;;
-	restart)
-		stop
-		start
-		;;
-	reload)
-		reload
-		;;
-	status)
-		status
-		;;
-	name)
-		name
-		;;
-	*)
-		echo $"Usage: $0 {start|stop|restart|reload|status}"
-		RETVAL=1
-esac
-exit $RETVAL
diff --git a/pkgs/servers/x11/xorg/default.nix b/pkgs/servers/x11/xorg/default.nix
index ec591e29c31..ff99399bee9 100644
--- a/pkgs/servers/x11/xorg/default.nix
+++ b/pkgs/servers/x11/xorg/default.nix
@@ -1987,6 +1987,16 @@ rec {
     buildInputs = [pkgconfig fontsproto libdrm randrproto renderproto videoproto xextproto xf86driproto xf86miscproto xineramaproto xorgserver xproto ];
   }) // {inherit fontsproto libdrm randrproto renderproto videoproto xextproto xf86driproto xf86miscproto xineramaproto xorgserver xproto ;};
     
+  xf86videoati_680 = (stdenv.mkDerivation {
+    name = "xf86-video-ati-6.8.0";
+    builder = ./builder.sh;
+    src = fetchurl {
+      url = http://xorg.freedesktop.org/archive/individual/driver/xf86-video-ati-6.8.0.tar.bz2;
+      sha256 = "1fjgcrvb5f1awfd52a5h45l80mk6hqzcdvj1i71mrll57hg8aqrq";
+    };
+    buildInputs = [pkgconfig fontsproto libdrm randrproto renderproto videoproto xextproto xf86driproto xf86miscproto xineramaproto xorgserver xproto mesaHeaders glproto ];
+  }) // {inherit fontsproto libdrm randrproto renderproto videoproto xextproto xf86driproto xf86miscproto xineramaproto xorgserver xproto mesaHeaders glproto;};
+    
   xf86videochips = (stdenv.mkDerivation {
     name = "xf86-video-chips-1.1.1";
     builder = ./builder.sh;
diff --git a/pkgs/servers/xmpp/openfire/3.4.5.nix b/pkgs/servers/xmpp/openfire/3.4.5.nix
index 8fb352a9e50..e9e711332f5 100644
--- a/pkgs/servers/xmpp/openfire/3.4.5.nix
+++ b/pkgs/servers/xmpp/openfire/3.4.5.nix
@@ -12,15 +12,19 @@ args : with args; with builderDefs {src="";} null;
     installPhase = FullDepEntry (''
       sed -e 's@\(common_jvm_locations\)=.*@\1${jre}@' -i bin/openfire
       cp -r . $out
+      rm -r $out/logs
+      mv $out/conf $out/conf.inst
+      ln -s /var/log/openfire $out/logs
+      ln -s /etc/openfire $out/conf
     '') 
-    ["minInit" "doUnpack" "findInputs"];
+    ["minInit" "doUnpack" "addInputs"];
   }) null; /* null is a terminator for sumArgs */
   in with localDefs;
 stdenv.mkDerivation rec {
   name = "openfire-"+version;
   builder = writeScript (name + "-builder")
     (textClosure localDefs 
-      [ doForceShare doPropagate installPhase]);
+      [ installPhase doForceShare doPropagate]);
   meta = {
     description = "
     XMPP server in Java.
diff --git a/pkgs/stdenv/cygwin/default.nix b/pkgs/stdenv/cygwin/default.nix
index 22e223ca6cc..b1ca853c612 100644
--- a/pkgs/stdenv/cygwin/default.nix
+++ b/pkgs/stdenv/cygwin/default.nix
@@ -17,7 +17,8 @@ genericStdenv {
 
   shell = "/bin/bash";
 
-  extraAttrs = {
+  fetchurlBoot = import ../../build-support/fetchurl {
+    inherit stdenv;
     # Curl should be in /usr/bin or so.
     curl = null;
   };
diff --git a/pkgs/stdenv/freebsd/default.nix b/pkgs/stdenv/freebsd/default.nix
index 22e223ca6cc..b1ca853c612 100644
--- a/pkgs/stdenv/freebsd/default.nix
+++ b/pkgs/stdenv/freebsd/default.nix
@@ -17,7 +17,8 @@ genericStdenv {
 
   shell = "/bin/bash";
 
-  extraAttrs = {
+  fetchurlBoot = import ../../build-support/fetchurl {
+    inherit stdenv;
     # Curl should be in /usr/bin or so.
     curl = null;
   };
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 48cff5825cb..048bc179e2d 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -1,6 +1,7 @@
 { stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, shell
 , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
 , extraAttrs ? {}
+, fetchurlBoot
 }:
 
 let {
@@ -71,6 +72,8 @@ let {
         # packages don't have to do that themselves.
         lib = import ../../lib;
 
+        inherit fetchurlBoot;
+
       }
 
       # Propagate any extra attributes.  For instance, we use this to
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index ec66d5c3602..fdb7326958e 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -100,15 +100,22 @@ rec {
   # the bootstrap.
   stdenvBootFun =
     {gcc, staticGlibc, extraAttrs ? {}, extraPath ? []}:
-    
-    import ../generic {
+
+    let
+      fetchurlBoot = import ../../build-support/fetchurl {
+        stdenv = stdenvInitial;
+        inherit curl;
+      };
+    in import ../generic {
       name = "stdenv-linux-boot";
       param1 = if staticGlibc then "static" else "dynamic";
       preHook = ./scripts/prehook.sh;
       stdenv = stdenvInitial;
       shell = bootstrapTools.bash;
       initialPath = [staticTools] ++ extraPath;
-      inherit gcc extraAttrs;
+      inherit fetchurlBoot;
+      extraAttrs = extraAttrs // {fetchurl = fetchurlBoot;};
+      inherit gcc;
     };
 
 
@@ -119,7 +126,6 @@ rec {
     # Use the statically linked, downloaded glibc/gcc/binutils.
     gcc = wrapGCC {libc = staticGlibc; binutils = staticBinutils;};
     staticGlibc = true;
-    extraAttrs = {inherit curl;};
   };
   
 
@@ -142,7 +148,7 @@ rec {
   stdenvLinuxBoot2 = removeAttrs (stdenvBootFun {
     staticGlibc = false;
     gcc = wrapGCC {binutils = staticBinutils; libc = stdenvLinuxGlibc;};
-    extraAttrs = {inherit curl; glibc = stdenvLinuxGlibc;};
+    extraAttrs = {glibc = stdenvLinuxGlibc;};
   }) ["gcc" "binutils"];
 
   
@@ -171,7 +177,6 @@ rec {
       libc = stdenvLinuxGlibc;
       gcc = stdenvLinuxBoot2Pkgs.gcc.gcc;
     };
-    extraAttrs = {inherit curl;};
     extraPath = [stdenvLinuxBoot2Pkgs.replace shSymlink];
   };
 
@@ -205,8 +210,9 @@ rec {
 
     shell = stdenvLinuxBoot3Pkgs.bash + "/bin/sh";
     
+    fetchurlBoot = stdenvLinuxBoot3.fetchurlBoot;
+    
     extraAttrs = {
-      curl = stdenvLinuxBoot3Pkgs.realCurl;
       inherit (stdenvLinuxBoot2Pkgs) binutils /* gcc */ glibc;
       inherit (stdenvLinuxBoot3Pkgs)
         gzip bzip2 bash coreutils diffutils findutils gawk
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index 6358855464b..71aa638378c 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -28,7 +28,7 @@ let
 
     inherit (pkgsDiet)
       coreutils diffutils gnugrep
-      gzip bzip2 gnumake bash patch binutils;
+      gzip bzip2 gnumake bash patch binutils curl;
 
     findutils = pkgsDiet.findutils4227; # 4.2.28 is broken
       
@@ -58,8 +58,6 @@ let
       profiledCompiler = true;
     };
   
-    curl = pkgsDiet.realCurl;
-
     glibc = pkgs.glibc;
 
     # The result should not contain any references (store paths) so
diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix
index 227cb876a97..fb7d29323ee 100644
--- a/pkgs/stdenv/nix/default.nix
+++ b/pkgs/stdenv/nix/default.nix
@@ -22,7 +22,8 @@ import ../generic {
 
   shell = pkgs.bash + "/bin/sh";
 
-  extraAttrs = {
-    curl = pkgs.realCurl;
+  fetchurlBoot = import ../../build-support/fetchurl {
+    inherit stdenv;
+    curl = pkgs.curl;
   };
 }
diff --git a/pkgs/stdenv/powerpc-darwin/default.nix b/pkgs/stdenv/powerpc-darwin/default.nix
index 1fd45bddfc3..2c94234c0c2 100644
--- a/pkgs/stdenv/powerpc-darwin/default.nix
+++ b/pkgs/stdenv/powerpc-darwin/default.nix
@@ -17,7 +17,8 @@ genericStdenv {
 
   shell = "/bin/sh";
 
-  extraAttrs = {
+  fetchurlBoot = import ../../build-support/fetchurl {
+    inherit stdenv;
     # Curl should be in /usr/bin or so.
     curl = null;
   };
diff --git a/pkgs/tools/X11/keynav/default.nix b/pkgs/tools/X11/keynav/default.nix
index 0c6d90ca7f7..a3345f69bc0 100644
--- a/pkgs/tools/X11/keynav/default.nix
+++ b/pkgs/tools/X11/keynav/default.nix
@@ -11,6 +11,8 @@ stdenv.mkDerivation {
 
   buildInputs = [libX11 xextproto libXtst imake libXi libXext];
 
+  NIX_LDFLAGS=" -lXext ";
+
   installPhase = "
 	mkdir -p \$out/bin \$out/share/keynav/doc;
 	cp keynav \$out/bin; cp keynavrc \$out/share/keynav/doc
diff --git a/pkgs/tools/X11/x2vnc/1.7.2.nix b/pkgs/tools/X11/x2vnc/1.7.2.nix
new file mode 100644
index 00000000000..50dea60b890
--- /dev/null
+++ b/pkgs/tools/X11/x2vnc/1.7.2.nix
@@ -0,0 +1,28 @@
+
+args : with args; with builderDefs {src="";} null;
+	let localDefs = builderDefs (rec {
+		src = /* put a fetchurl here */
+		fetchurl {
+			url = http://fredrik.hubbe.net/x2vnc/x2vnc-1.7.2.tar.gz;
+			sha256 = "00bh9j3m6snyd2fgnzhj5vlkj9ibh69gfny9bfzlxbnivb06s1yw";
+		};
+
+		buildInputs = [libX11 xproto xextproto libXext libXrandr randrproto];
+		doCreatePrefix = FullDepEntry (''
+			ensureDir $out
+		'') ["defEnsureDir"];
+		configureFlags = [];
+	}) args null; /* null is a terminator for sumArgs */
+	in with localDefs;
+stdenv.mkDerivation rec {
+	name = "x2vnc-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs 
+			[doConfigure doCreatePrefix doMakeInstall doForceShare doPropagate]);
+	meta = {
+		description = "
+		x2vnc - program to control remote VNC server.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/tools/X11/xpra/default.nix b/pkgs/tools/X11/xpra/default.nix
new file mode 100644
index 00000000000..0691521e44c
--- /dev/null
+++ b/pkgs/tools/X11/xpra/default.nix
@@ -0,0 +1,39 @@
+{stdenv, fetchurl, pkgconfig, python, pyrex, pygtk, xlibs, gtk, makeWrapper}:
+
+stdenv.mkDerivation {
+  name = "xpra-0.0.3";
+  
+  src = fetchurl {
+    url = http://partiwm.org/static/downloads/parti-all-0.0.3.tar.gz;
+    sha256 = "17inksd4cc7mba2vfs17gz1yk3h6x6wf06pm3hcbs5scq8rr5bkp";
+  };
+
+  #src = /home/eelco/Dev/nixpkgs/parti-all-0.0.3;
+
+  buildInputs = [
+    pkgconfig python pyrex pygtk gtk makeWrapper
+    xlibs.inputproto xlibs.libXcomposite xlibs.libXdamage xlibs.libXtst
+  ];
+
+  buildPhase = ''
+    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config --cflags gtk+-2.0) $(pkg-config --cflags pygtk-2.0)"
+    NIX_LDFLAGS="$NIX_LDFLAGS -lXcomposite -lXdamage"
+    ./do-build
+  '';
+
+  installPhase = ''
+    ensureDir $out
+    cp -r install/* $out
+
+    for i in $(cd $out/bin && ls); do
+        wrapProgram $out/bin/$i \
+            --set PYTHONPATH "$out/lib/python:$(toPythonPath ${pygtk})/gtk-2.0:$PYTHONPATH" \
+            --prefix PATH : "${xlibs.xauth}/bin:${xlibs.xorgserver}/bin:${xlibs.xmodmap}/bin"
+    done
+  '';
+  
+  meta = {
+    homepage = http://partiwm.org/wiki/xpra;
+    description = "Persistent remote applications for X";
+  };
+}
diff --git a/pkgs/tools/backup/rsnapshot/default.nix b/pkgs/tools/backup/rsnapshot/default.nix
new file mode 100644
index 00000000000..c79be7cffb4
--- /dev/null
+++ b/pkgs/tools/backup/rsnapshot/default.nix
@@ -0,0 +1,23 @@
+{fetchurl, stdenv, perl, openssh, rsync, logger}:
+
+stdenv.mkDerivation rec {
+  name = "rsnapshot-1.3.0";
+  src = fetchurl {
+    url = "mirrors://sourceforge/rsnapshot/${name}.tar.gz";
+    sha256 = "19p35ycm73a8vd4ccjpah18h5jagvcr11rqca6ya87sg8k0a5h9z";
+  };
+
+  propagatedBuildInputs = [perl openssh rsync logger];
+
+  patchPhase = ''
+    substituteInPlace "Makefile.in" --replace \
+      "/usr/bin/pod2man" "${perl}/bin/pod2man"
+  '';
+
+  meta = {
+    description = ''rsnapshot is a filesystem snapshot utility for making
+                    backups of local and remote systems.'';
+    homepage = http://rsnapshot.org/;
+    license = "GPLv2+";
+  };
+}
diff --git a/pkgs/tools/graphics/ploticus/builder.sh b/pkgs/tools/graphics/ploticus/builder.sh
index c6f2d7899ba..11ff6f5a332 100644
--- a/pkgs/tools/graphics/ploticus/builder.sh
+++ b/pkgs/tools/graphics/ploticus/builder.sh
@@ -12,4 +12,29 @@ preInstall() {
 
 preInstall=preInstall
 
+postInstall() {
+  # Install the "prefabs".
+  ensureDir $out/share/ploticus/prefabs &&		\
+  cd .. &&						\
+  cp -rv prefabs/* $out/share/ploticus/prefabs
+
+  # Create a wrapper that knows where to find them.  Debian's package
+  # does something similar by patching directly the C file that looks
+  # for `$PLOTICUS_PREFABS'.
+  cat > $out/bin/ploticus <<EOF
+#! $SHELL -e
+PLOTICUS_PREFABS="$out/share/ploticus/prefabs"
+export PLOTICUS_PREFABS
+exec "$out/bin/pl" \$@
+EOF
+  chmod +x $out/bin/ploticus
+
+  # Install the man pages.
+  cp -rv man $out
+  ln -s "$out/man/man1/pl.1" "$out/man/man1/ploticus.1"
+}
+
+postInstall=postInstall
+
+
 genericBuild
diff --git a/pkgs/tools/graphics/ploticus/default.nix b/pkgs/tools/graphics/ploticus/default.nix
index 650d2ba9d3a..3efb7eab881 100644
--- a/pkgs/tools/graphics/ploticus/default.nix
+++ b/pkgs/tools/graphics/ploticus/default.nix
@@ -1,15 +1,30 @@
 {stdenv, fetchurl, zlib, libX11, libpng}:
 
 stdenv.mkDerivation {
-  name = "ploticus-2.33";
+  name = "ploticus-2.40";
 
   builder = ./builder.sh;
   src = fetchurl {
-    url = mirror://sourceforge/ploticus/pl233src.tar.gz;
-    md5 = "1e242200e7e52f7a24041c95f58f2fc1";
+    url = mirror://sourceforge/ploticus/pl240src.tar.gz;
+    sha256 = "1gwppsmfxajrpidjrplkhvq2yy35r9hmigpwjmjqv4r7dj7cnrw8";
   };
 
   buildInputs = [zlib libX11 libpng];
 
   patches = [./ploticus-install.patch];
+
+  meta = {
+    description = ''Ploticus, a non-interactive software package for
+                    producing plots and charts'';
+
+    longDescription = ''Ploticus is a free, GPL'd, non-interactive
+      software package for producing plots, charts, and graphics from
+      data.  Ploticus is good for automated or just-in-time graph
+      generation, handles date and time data nicely, and has basic
+      statistical capabilities.  It allows significant user control
+      over colors, styles, options and details.'';
+
+    license = "GPLv2+";
+    homepage = http://ploticus.sourceforge.net/;
+  };
 }
diff --git a/pkgs/tools/graphics/ploticus/ploticus-install.patch b/pkgs/tools/graphics/ploticus/ploticus-install.patch
index 5bf32bcf76d..04edbc709d0 100644
--- a/pkgs/tools/graphics/ploticus/ploticus-install.patch
+++ b/pkgs/tools/graphics/ploticus/ploticus-install.patch
@@ -1,13 +1,12 @@
-diff -ruN pl233src/src/Makefile pl233src.new/src/Makefile
---- pl233src/src/Makefile	2006-06-02 17:31:46.000000000 +0200
-+++ pl233src.new/src/Makefile	2006-08-23 18:05:50.000000000 +0200
-@@ -190,7 +190,8 @@
+--- pl240src/src/Makefile	2008-01-15 21:05:14.000000000 +0100
++++ pl240src/src/Makefile	2008-03-26 23:51:53.000000000 +0100
+@@ -131,7 +131,7 @@ ZFLAG = -DWZ
  
  
- #### If you plan to do a "make install", where do you want the executable(s) to be moved to?
--BIN = /usr/local/bin
-+#BIN = /usr/local/bin
-+BIN = $(out)/bin
+ #### If you do a "make install", where do you want the executable(s) to be moved to?
+-INSTALLBIN = /usr/local/bin
++INSTALLBIN = $(out)/bin
  
  
- #### To set a hard-coded directory for prefabs files, uncomment & edit the following.. 
+ #### For LOCALE support (non-roman alphabets & collation), uncomment the following..
+
diff --git a/pkgs/tools/misc/eProver/default.nix b/pkgs/tools/misc/eProver/default.nix
index 1649a35004f..0b21dfd78cd 100644
--- a/pkgs/tools/misc/eProver/default.nix
+++ b/pkgs/tools/misc/eProver/default.nix
@@ -9,12 +9,14 @@ stdenv.mkDerivation {
 		sha256 = "1zm1xip840hlam60kqk6xf0ikvyk7ch3ql1ac6wb68dx2l6hyhxv";
 	};
 
-  buildInputs =[which tetex];
+  buildInputs =[which texLive];
 
   preConfigure = "sed -e 's@^EXECPATH\\s.*@EXECPATH = '\$out'/bin@' -i Makefile.vars";
 
   buildPhase = "make install";
-  installCommand = "mkdir -p \$out/bin; make install-exec; make documentation ; 
+
+  # HOME=. allows to build missing TeX formats
+  installCommand = "mkdir -p \$out/bin; make install-exec; HOME=. make documentation ; 
 		mkdir -p \$out/share/doc ; cp -r DOC \$out/share/doc/EProver;
 		echo eproof -xAuto --tstp-in --tstp-out '\"\$@\"' >\$out/bin/eproof-tptp; 
 		chmod a+x \$out/bin/eproof-tptp; ";
diff --git a/pkgs/tools/misc/expect/default.nix b/pkgs/tools/misc/expect/default.nix
index 8d9b6f6311f..f17395b9ece 100644
--- a/pkgs/tools/misc/expect/default.nix
+++ b/pkgs/tools/misc/expect/default.nix
@@ -17,6 +17,10 @@ stdenv.mkDerivation {
   #  substituteInPlace exp_inter.c --replace tcl.h tclInt.h
   #'';
 
+  patchPhase = ''
+    substituteInPlace configure --replace /bin/stty "$(type -tP stty)"
+  '';
+  
   configureFlags = "--with-tcl=${tcl}/lib --with-tclinclude=${tcl}/include";
 
   meta = {
diff --git a/pkgs/tools/misc/fontforge/default.nix b/pkgs/tools/misc/fontforge/default.nix
index 314d29cb4b6..839ec49d93c 100644
--- a/pkgs/tools/misc/fontforge/default.nix
+++ b/pkgs/tools/misc/fontforge/default.nix
@@ -1,7 +1,6 @@
 { stdenv, fetchurl, gettext, freetype, zlib
 , libungif, libpng, libjpeg, libtiff, libxml2
-, libX11 ? null , lib , xproto ? null
-, libXt ? null
+, libX11 ? null, lib, xproto ? null, libXt ? null
 }:
 
 stdenv.mkDerivation {
@@ -11,19 +10,24 @@ stdenv.mkDerivation {
     url = mirror://sourceforge/fontforge/fontforge_full-20070808.tar.bz2;
     sha256 = "1b3x5djn9ifvszwmgwmn1jwl50pbq6fzvbmgx0qjg0m60m3v44nx";
   };
-
-  preConfigure = "
+    
+  configureFlags = if libX11 != null then "--with-gui=gdraw" else "";
+  
+  preConfigure = ''
     unpackFile ${freetype.src}
     freetypeSrcPath=$(echo `pwd`/freetype-*)
-    configureFlags=\"$configureFlags --with-freetype-src=$freetypeSrcPath\"
-  "
-  + (if libX11!=null then ''
-    configureFlags="$configureFlags --with-gui=gdraw";
-  '' else "");
+    configureFlags="$configureFlags --with-freetype-src=$freetypeSrcPath"
+    
+    substituteInPlace configure \
+      --replace /usr/include /no-such-path \
+      --replace /usr/lib /no-such-path \
+      --replace /usr/local /no-such-path \
+  '';
 
-  buildInputs = [gettext freetype zlib libungif libpng libjpeg libtiff libxml2]
-  ++ (lib.optional (libX11!=null) libX11)
-  ++ (lib.optional (xproto!=null) xproto)
-  ++ (lib.optional (libXt!=null) libXt)
-  ;
+  buildInputs =
+    [gettext freetype zlib libungif libpng libjpeg libtiff libxml2]
+    ++ lib.optional (libX11 != null) libX11
+    ++ lib.optional (xproto != null) xproto
+    ++ lib.optional (libXt != null) libXt
+    ;
 }
diff --git a/pkgs/tools/misc/grub/default.nix b/pkgs/tools/misc/grub/default.nix
index 9f021a66955..44c2c02b020 100644
--- a/pkgs/tools/misc/grub/default.nix
+++ b/pkgs/tools/misc/grub/default.nix
@@ -5,7 +5,7 @@ if stdenv.system == "x86_64-linux" then
 else
 
 stdenv.mkDerivation {
-  name = "grub-0.97";
+  name = "grub-0.97-patch-1.7";
   
   src = fetchurl {
     url = ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz;
@@ -14,10 +14,11 @@ stdenv.mkDerivation {
 
   # Lots of patches from Gentoo, in particular splash screen support
   # (not the fancy SUSE gfxmenu stuff though).  Also a fix for boot
-  # failures on systems with more than 2 GiB RAM.
+  # failures on systems with more than 2 GiB RAM, and for booting from
+  # ext3 filesystems with 256-byte inodes. 
   gentooPatches = fetchurl {
-    url = mirror://gentoo/distfiles/grub-0.97-patches-1.4.tar.bz2;
-    sha256 = "1nki5q1b61ahxcmnw6mq7b8ghcysri4lj7q6dx8iqixrvrpxj399";
+    url = mirror://gentoo/distfiles/grub-0.97-patches-1.7.tar.bz2;
+    sha256 = "12akcbp1a31pxzsxm01scgir0fqkk8qqqwhs44vzgs2chzzigyvd";
   };
 
   # Autoconf/automake required for the splashimage patch.
diff --git a/pkgs/tools/hddtemp/default.nix b/pkgs/tools/misc/hddtemp/default.nix
index 9f285a6cd51..9f285a6cd51 100644
--- a/pkgs/tools/hddtemp/default.nix
+++ b/pkgs/tools/misc/hddtemp/default.nix
diff --git a/pkgs/tools/misc/idutils/default.nix b/pkgs/tools/misc/idutils/default.nix
new file mode 100644
index 00000000000..0b77921e349
--- /dev/null
+++ b/pkgs/tools/misc/idutils/default.nix
@@ -0,0 +1,41 @@
+{ fetchurl, stdenv, emacs }:
+
+stdenv.mkDerivation rec {
+  name = "idutils-4.2";
+  src = fetchurl {
+    url = "mirror://gnu/idutils/${name}.tar.gz";
+    sha256 = "16gsy7vrjax2zl4galwq03l0y97d18p0pyd5cccyc4i8y3mhwx65";
+  };
+
+  buildInputs = [ emacs ];
+
+  doCheck = true;
+
+  meta = {
+    description = "GNU Idutils, a text searching utility";
+
+    longDescription = ''
+      An "ID database" is a binary file containing a list of file
+      names, a list of tokens, and a sparse matrix indicating which
+      tokens appear in which files.
+
+      With this database and some tools to query it, many
+      text-searching tasks become simpler and faster.  For example,
+      you can list all files that reference a particular `\#include'
+      file throughout a huge source hierarchy, search for all the
+      memos containing references to a project, or automatically
+      invoke an editor on all files containing references to some
+      function or variable.  Anyone with a large software project to
+      maintain, or a large set of text files to organize, can benefit
+      from the ID utilities.
+
+      Although the name `ID' is short for `identifier', the ID
+      utilities handle more than just identifiers; they also treat
+      other kinds of tokens, most notably numeric constants, and the
+      contents of certain character strings.
+    '';
+
+    homepage = http://www.gnu.org/software/idutils/;
+    license = "GPLv2+";
+  };
+}
diff --git a/pkgs/tools/misc/keychain/default.nix b/pkgs/tools/misc/keychain/default.nix
new file mode 100644
index 00000000000..54c50c15d23
--- /dev/null
+++ b/pkgs/tools/misc/keychain/default.nix
@@ -0,0 +1,24 @@
+args:
+args.stdenv.mkDerivation {
+  name = "keychain-2.6.6";
+
+  src = args.fetchurl {
+    url = http://gentoo.chem.wisc.edu/gentoo/distfiles/keychain-2.6.6.tar.bz2;
+    sha256 = "10v0hzkgrb5cazm1gk0g4ncwp8sqvfk7xfyx59cjd69kzhbbn6ic";
+  };
+
+  phases = "unpackPhase buildPhase";
+
+  buildPhase ="
+    mkdir -p \$out/bin
+    cp keychain \$out/bin
+  ";
+
+  buildInputs =(with args; []);
+
+  meta = { 
+      description = "tool starting ssh and gpg management tool";
+      homepage = "http://www.gentoo.org/proj/en/keychain/";
+      license = "GPL2";
+  };
+}
diff --git a/pkgs/tools/misc/mdbtools/0.6-pre1.nix b/pkgs/tools/misc/mdbtools/0.6-pre1.nix
new file mode 100644
index 00000000000..6217a3f7776
--- /dev/null
+++ b/pkgs/tools/misc/mdbtools/0.6-pre1.nix
@@ -0,0 +1,22 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://prdownloads.sourceforge.net/mdbtools/mdbtools-0.6pre1.tar.gz;
+    sha256 = "1lz33lmqifjszad7rl1r7rpxbziprrm5rkb27wmswyl5v98dqsbi";
+  };
+
+  buildInputs = [glib readline bison flex pkgconfig];
+  configureFlags = [];
+
+  preConfigure = FullDepEntry (''
+    sed -e 's@static \(GHashTable [*]mdb_backends;\)@\1@' -i src/libmdb/backend.c
+  '') ["doUnpack" "minInit"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"];
+      
+  name = "mdbtools-" + version;
+  meta = {
+    description = ".mdb (MS Access) format tools";
+  };
+}
diff --git a/pkgs/tools/misc/minicom/2.3.nix b/pkgs/tools/misc/minicom/2.3.nix
new file mode 100644
index 00000000000..1b9b0e62470
--- /dev/null
+++ b/pkgs/tools/misc/minicom/2.3.nix
@@ -0,0 +1,18 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://alioth.debian.org/frs/download.php/2332/minicom-2.3.tar.gz;
+    sha256 = "1ysn0crdhvwyvdlbw0ms5nq06xy2pd2glwjs53p384byl3ac7jra";
+  };
+
+  buildInputs = [ncurses];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = [ "doConfigure" "doMakeInstall"];
+      
+  name = "minicom-" + version;
+  meta = {
+    description = "Serial console";
+  };
+}
diff --git a/pkgs/tools/misc/mysql2pgsql/default.nix b/pkgs/tools/misc/mysql2pgsql/default.nix
new file mode 100644
index 00000000000..77ea33dc1e9
--- /dev/null
+++ b/pkgs/tools/misc/mysql2pgsql/default.nix
@@ -0,0 +1,27 @@
+args:
+# The homepage says this script is mature..
+args.stdenv.mkDerivation {
+  name = "mysql2pgsql-0.0.1a";
+
+  src = args.fetchurl {
+    url = http://ftp.plusline.de/ftp.postgresql.org/projects/gborg/mysql2psql/devel/mysql2psql-0.0.1a.tgz;
+    sha256 = "0dpbxf3kdvpihz9cisx6wi3zzd0cnifaqvjxavrbwm4k4sz1qamp";
+  };
+
+  phases = "unpackPhase installPhase";
+
+  buildInputs = with args; [ perl shebangfix ];
+
+  installPhase = ''
+    mkdir -p $out/bin;
+    shebangfix mysql2psql
+    chmod +x mysql2psql
+    mv {,$out/bin/}mysql2psql
+  '';
+
+  meta = { 
+      description = "converts mysql dump files to psql loadable files ";
+      homepage = http://pgfoundry.org/projects/mysql2pgsql/;
+      license = "GPL";
+  };
+}
diff --git a/pkgs/tools/misc/pinentry/default.nix b/pkgs/tools/misc/pinentry/default.nix
new file mode 100644
index 00000000000..4ee84006975
--- /dev/null
+++ b/pkgs/tools/misc/pinentry/default.nix
@@ -0,0 +1,17 @@
+args:
+args.stdenv.mkDerivation {
+  name = "pinentry-0.7.2";
+
+  src = args.fetchurl {
+    url = http://gentoo.chem.wisc.edu/gentoo/distfiles/pinentry-0.7.2.tar.gz;
+    sha256 = "0s6n5n4bxg95rmwa3mw3r49dabf8yh6fkpfi8mbl7i85dgpibnzv";
+  };
+
+  buildInputs =(with args; [glib pkgconfig x11 gtk]);
+
+  meta = { 
+      description = "input interface for passwords needed by  gnupg";
+      homepage = "don't know, gentoo lists http://www.gnupg.org/aegypten/";
+      license = "GPL2";
+  };
+}
diff --git a/pkgs/tools/misc/relfs/cvs.2007.12.01.nix b/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
index 5ae35b913ff..3f7aae91f34 100644
--- a/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
+++ b/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
@@ -5,7 +5,7 @@ args : with args;
 		cvsRoot = ":pserver:anonymous@relfs.cvs.sourceforge.net:/cvsroot/relfs";
 		module = "relfs";
 		date = "2007-12-01";
-		sha256 = "ef8e2ebfda6e43240051a7af9417092b2af50ece8b5c6c3fbd908ba91c4fe068";
+		sha256 = "39d97d0aa16b8bc953b2ef5f6308e9f9eda300c1de8a7acb6f8c8e5897c0c7b5";
 	};
 		
 		buildInputs = [ocaml fuse postgresql pcre
@@ -28,11 +28,11 @@ let build = FullDepEntry ("
 		dropdb relfs_\$1 ; 
 		rm -rf /tmp/relfs-\$1-tmp;  
 		mkdir /tmp/relfs-\$1-tmp;  
-		USER=\$1 relfs -f -s /tmp/relfs-raskin-tmp  & 
+		USER=\$1 relfs -f -s /tmp/relfs-\$1-tmp  & 
 		sleep 1 && 
 		kill -15 \${!};
 		rm -rf /tmp/relfs-\$1-tmp ; 
-		psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_raskin OWNER TO raskin; 
+		psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_\$1 OWNER TO \$1; 
 			ALTER TABLE obj OWNER TO \$1; 
 			ALTER TABLE obj_mimetype OWNER TO \$1; 
 			ALTER TABLE membership OWNER TO \$1;\"' > \$out/bin/relfs_grant;
diff --git a/pkgs/tools/misc/relfs/cvs.2008.03.05.nix b/pkgs/tools/misc/relfs/cvs.2008.03.05.nix
new file mode 100644
index 00000000000..e8d3705acc3
--- /dev/null
+++ b/pkgs/tools/misc/relfs/cvs.2008.03.05.nix
@@ -0,0 +1,53 @@
+
+args : with args;
+	let localDefs = builderDefs {
+	src = /* put a fetchurl here */
+	if args ? src then args.src else fetchcvs {
+		cvsRoot = ":pserver:anonymous@relfs.cvs.sourceforge.net:/cvsroot/relfs";
+		module = "relfs";
+		date = "2008-03-05";
+		sha256 = "949f8eff7e74ff2666cccf8a1efbfcce8d54bc41bec6ad6db8c029de7ca832a3";
+	};
+		
+		buildInputs = [ocaml fuse postgresql pcre
+			e2fsprogs gnomevfs pkgconfig GConf];
+		configureFlags = [];
+	} null; /* null is a terminator for sumArgs */
+	in with localDefs;
+let build = FullDepEntry ("
+	cd deps 
+	sed -e 's/^CPP/#&/ ; s/^# CPP=gcc/CPP=gcc/' -i Makefile.camlidl
+	make 
+	cd ../src
+	sed -e 's/NULL\\|FALSE/0/g' -i Mimetype_lib.c
+	sed -e 's@/usr/local/@'\$out/'@' -i Makefile
+	sed -e '/install:/a\\\tmkdir -p '\$out'/share' -i Makefile
+	make
+	mkdir -p \$out/bin
+	echo '
+		createuser -A -D \$1
+		dropdb relfs_\$1 ; 
+		rm -rf /tmp/relfs-\$1-tmp;  
+		mkdir /tmp/relfs-\$1-tmp;  
+		USER=\$1 relfs -f -s /tmp/relfs-\$1-tmp  & 
+		sleep 1 && 
+		kill -15 \${!};
+		rm -rf /tmp/relfs-\$1-tmp ; 
+		psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_\$1 OWNER TO \$1; 
+			ALTER TABLE obj OWNER TO \$1; 
+			ALTER TABLE obj_mimetype OWNER TO \$1; 
+			ALTER TABLE membership OWNER TO \$1;\"' > \$out/bin/relfs_grant;
+	chmod a+x \$out/bin/relfs_grant;
+") [minInit doUnpack addInputs];
+in
+stdenv.mkDerivation rec {
+	name = "relfs-"+version;
+	builder = writeScript (name + "-builder")
+		(textClosure localDefs [build doMakeInstall doForceShare doPropagate]);
+	meta = {
+		description = "
+	Relational FS over FUSE.
+";
+		inherit src;
+	};
+}
diff --git a/pkgs/tools/misc/uucp/1.07.nix b/pkgs/tools/misc/uucp/1.07.nix
new file mode 100644
index 00000000000..7ac48f39664
--- /dev/null
+++ b/pkgs/tools/misc/uucp/1.07.nix
@@ -0,0 +1,18 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftp.de.debian.org/debian/pool/main/u/uucp/uucp_1.07.orig.tar.gz;
+    sha256 = "0b5nhl9vvif1w3wdipjsk8ckw49jj1w85xw1mmqi3zbcpazia306";
+  };
+
+  buildInputs = [];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "uucp-" + version;
+  meta = {
+    description = "Unix-unix cp over serial line, also includes cu program";
+  };
+}
diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix
index d9bd241af06..a429e1c9514 100644
--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -22,8 +22,14 @@ stdenv.mkDerivation {
   CFLAGS = if stdenv ? isDietLibC then "-DHAVE_INET_NTOA_R_2_ARGS=1" else "";
   CXX = "g++";
   CXXCPP = "g++ -E";
-  
-  inherit sslSupport openssl;
+
+  passthru = {
+    inherit sslSupport openssl;
+  };
+
+  preConfigure = ''
+    substituteInPlace configure --replace /usr/bin /no-such-path
+  '';
 
   patches = [
     /* Fixes broken retry support when a timeout is used.  The
diff --git a/pkgs/tools/networking/dhcp/builder.sh b/pkgs/tools/networking/dhcp/builder.sh
index f630a4aa1a2..645d9326406 100644
--- a/pkgs/tools/networking/dhcp/builder.sh
+++ b/pkgs/tools/networking/dhcp/builder.sh
@@ -11,6 +11,10 @@ makeFlagsArray=(CLIENT_PATH='\"FAKE_PATH=/nothing\"' \
 
 configurePhase=configurePhase
 configurePhase() {
+    # Patch the header that contains absolute paths to the tools.
+    sed -i "includes/dhcpd.h" \
+	-"es|^ *#define \+_PATH_DHCLIENT_SCRIPT.*$|#define _PATH_DHCLIENT_SCRIPT \"$out/sbin/dhclient-script\"|g"
+
     ./configure
 }
 
diff --git a/pkgs/tools/networking/dhcp/default.nix b/pkgs/tools/networking/dhcp/default.nix
index 09e24e3a8b7..063dc15532b 100644
--- a/pkgs/tools/networking/dhcp/default.nix
+++ b/pkgs/tools/networking/dhcp/default.nix
@@ -1,4 +1,5 @@
-{stdenv, fetchurl, groff, nettools, coreutils, iputils, gnused, bash}:
+{ stdenv, fetchurl, groff, nettools, coreutils, iputils, gnused,
+  bash, makeWrapper }:
 
 stdenv.mkDerivation {
   name = "dhcp-3.0.6";
@@ -7,7 +8,27 @@ stdenv.mkDerivation {
     url = http://ftp.isc.org/isc/dhcp/dhcp-3.0.6.tar.gz;
     sha256 = "0k8gy3ab9kzs4qcc9apgnxi982lhggha41fkw9w1bmvmz7mv0xwz";
   };
-  buildInputs = [groff];
-  inherit nettools coreutils iputils gnused bash;
-  patches = [./resolv-without-domain.patch];
+
+  buildInputs = [ groff nettools coreutils makeWrapper ];
+
+  patches = [ ./resolv-without-domain.patch ./no-mkdir-var-run.patch ];
+
+  postInstall = ''
+    wrapProgram "$out/sbin/dhclient-script" --prefix PATH : \
+      "${nettools}/bin:${nettools}/sbin:${coreutils}/bin:${gnused}/bin"
+  '';
+
+  meta = {
+    description = "Dynamic Host Configuration Protocol (DHCP) tools";
+
+    longDescription = ''
+      ISC's Dynamic Host Configuration Protocol (DHCP) distribution
+      provides a freely redistributable reference implementation of
+      all aspects of DHCP, through a suite of DHCP tools: server,
+      client, and relay agent.
+   '';
+
+    homepage = http://www.isc.org/products/DHCP/;
+    license = "http://www.isc.org/sw/dhcp/dhcp-copyright.php";
+  };
 }
diff --git a/pkgs/tools/networking/dhcp/no-mkdir-var-run.patch b/pkgs/tools/networking/dhcp/no-mkdir-var-run.patch
new file mode 100644
index 00000000000..e8c5dc9f639
--- /dev/null
+++ b/pkgs/tools/networking/dhcp/no-mkdir-var-run.patch
@@ -0,0 +1,22 @@
+--- dhcp-3.0.6/client/Makefile.dist	2008-03-14 14:36:04.000000000 +0100
++++ dhcp-3.0.6/client/Makefile.dist	2008-03-14 14:36:06.000000000 +0100
+@@ -38,7 +38,7 @@ CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUD
+ all:	$(PROG) $(CATMANPAGES)
+ 
+ install: all
+-	for dir in $(CLIENTBINDIR) $(ETC) $(FFMANDIR) $(ADMMANDIR) $(VARDB); \
++	for dir in $(CLIENTBINDIR) $(ETC) $(FFMANDIR) $(ADMMANDIR); \
+ 	do \
+ 	  foo=""; \
+ 	  for bar in `echo $(DESTDIR)$${dir} |tr / ' '`; do \
+--- dhcp-3.0.6/server/Makefile.dist	2008-03-14 14:37:05.000000000 +0100
++++ dhcp-3.0.6/server/Makefile.dist	2008-03-14 14:37:13.000000000 +0100
+@@ -38,7 +38,7 @@ CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUD
+ all:	$(PROG) $(CATMANPAGES)
+ 
+ install: all
+-	for dir in $(BINDIR) $(ADMMANDIR) $(FFMANDIR) $(VARDB); do \
++	for dir in $(BINDIR) $(ADMMANDIR) $(FFMANDIR); do \
+ 	  foo=""; \
+ 	  for bar in `echo $(DESTDIR)$${dir} |tr / ' '`; do \
+ 	    foo=$${foo}/$$bar; \
diff --git a/pkgs/tools/networking/iodine/default.nix b/pkgs/tools/networking/iodine/default.nix
new file mode 100644
index 00000000000..9ce1731eb76
--- /dev/null
+++ b/pkgs/tools/networking/iodine/default.nix
@@ -0,0 +1 @@
+import ./iodine-0.4.1.nix
diff --git a/pkgs/tools/networking/iodine/iodine-0.4.1.nix b/pkgs/tools/networking/iodine/iodine-0.4.1.nix
new file mode 100644
index 00000000000..e20c86debe3
--- /dev/null
+++ b/pkgs/tools/networking/iodine/iodine-0.4.1.nix
@@ -0,0 +1,21 @@
+args: with args;
+stdenv.mkDerivation rec {
+  name = "iodine-0.4.1";
+
+  src = fetchurl {
+    url = "http://code.kryo.se/iodine/${name}.tar.gz";
+    sha256 = "1d0v6wbrciwd0xi9khrna956v5wy7wy1inllzrn187as358kiiv5";
+  };
+
+  buildInputs = [zlib];
+
+  patchPhase = ''sed -i "s,/sbin/ifconfig,${nettools}/sbin/ifconfig,; s,/sbin/route,${nettools}/sbin/route," src/tun.c'';
+
+  installFlags = "prefix=\${out}";
+
+  meta = {
+    homepage = http://code.kryo.se/iodine/;
+    description = "iodine lets you tunnel IPv4 data through a DNS server.";
+    license = "ISC";
+  };
+}
diff --git a/pkgs/tools/networking/lsh/default.nix b/pkgs/tools/networking/lsh/default.nix
index 087aeddf497..85e0c91a003 100644
--- a/pkgs/tools/networking/lsh/default.nix
+++ b/pkgs/tools/networking/lsh/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, gperf, guile, gmp, zlib, liboop, gnum4}:
+{stdenv, fetchurl, gperf, guile, gmp, zlib, liboop, gnum4, pam}:
 
 stdenv.mkDerivation {
   name = "lsh-2.0.4";
@@ -7,10 +7,10 @@ stdenv.mkDerivation {
     sha256 = "614b9d63e13ad3e162c82b6405d1f67713fc622a8bc11337e72949d613713091";
   };
 
-  buildInputs = [gperf guile gmp zlib liboop gnum4];
+  buildInputs = [gperf guile gmp zlib liboop gnum4 pam];
 
   meta = {
-    description = "GNU lsh, a GPL'd implementation of the SSH protocol.";
+    description = "GNU lsh, a GPL'd implementation of the SSH protocol";
     homepage = http://www.lysator.liu.se/~nisse/lsh/;
     license = "GPL";
   };
diff --git a/pkgs/tools/networking/nss-mdns/default.nix b/pkgs/tools/networking/nss-mdns/default.nix
new file mode 100644
index 00000000000..1dd430c7493
--- /dev/null
+++ b/pkgs/tools/networking/nss-mdns/default.nix
@@ -0,0 +1,37 @@
+{ fetchurl, stdenv, avahi }:
+
+stdenv.mkDerivation rec {
+  name = "nss-mdns-0.10";
+  src = fetchurl {
+    url = "http://0pointer.de/lennart/projects/nss-mdns/${name}.tar.gz";
+    sha256 = "0vgs6j0qsl0mwzh5a0m0bykr7x6bx79vnbyn0r3q289rghp3qs0y";
+  };
+
+  configureFlags = "--enable-avahi";
+
+  # Note: Although `nss-mdns' works by talking to `avahi-daemon', it
+  # doesn't depend on the Avahi libraries.  Instead, it contains
+  # hand-written D-Bus code to talk to the Avahi daemon.
+
+  buildInput = [ avahi ];
+
+  patchPhase = ''
+    substituteInPlace "src/Makefile.in"						\
+      --replace 'AVAHI_SOCKET=\"$(localstatedir)/run/avahi-daemon/socket\"'	\
+                'AVAHI_SOCKET=\"${avahi}/var/run/avahi-daemon/socket\"'
+  '';
+
+  meta = {
+    description = "The mDNS Name Service Switch (NSS) plug-in";
+    longDescription = ''
+      `nss-mdns' is a plugin for the GNU Name Service Switch (NSS)
+      functionality of the GNU C Library (glibc) providing host name
+      resolution via Multicast DNS (mDNS), effectively allowing name
+      resolution by common Unix/Linux programs in the ad-hoc mDNS
+      domain `.local'.
+    '';
+
+    homepage = http://0pointer.de/lennart/projects/nss-mdns/;
+    license = "LGPLv2+";
+  };
+}
diff --git a/pkgs/tools/networking/socat/1.6.0.0.nix b/pkgs/tools/networking/socat/1.6.0.0.nix
deleted file mode 100644
index 0ec1ac9893b..00000000000
--- a/pkgs/tools/networking/socat/1.6.0.0.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-args : with args; with builderDefs {src="";} null;
-    let localDefs = builderDefs (rec {
-        src = /* put a fetchurl here */
-        fetchurl {
-            url = http://www.dest-unreach.org/socat/download/socat-1.6.0.0.tar.bz2;
-            sha256 = "1j01iazwfr63q71cfcfzrdz8digqlg3ldhlbb72yl5mn9awr0w0m";
-        };
-        patches = [
-          (fetchurl {
-              url = http://www.dest-unreach.org/socat/contrib/socat-servicenames.patch;
-              sha256 = "1r8zd6mk257n01i34i5syxl2k6fr35nlr7bqs9sfc79irjl62z66";
-          })
-          (fetchurl {
-              url = http://www.dest-unreach.org/socat/contrib/socat-maxfds.patch.gz;
-              sha256 = "0fsn0k0qsrdbjbhj09a6kxfsxb7yhxs4cad26znd9naginsj7pxa";
-          })
-        ];
-        buildInputs = [openssl];
-        configureFlags = [];
-    }) null; /* null is a terminator for sumArgs */
-    in with localDefs;
-stdenv.mkDerivation rec {
-    name = "socat-"+version;
-    builder = writeScript (name + "-builder")
-        (textClosure localDefs 
-            [doPatch doConfigure doMakeInstall doForceShare doPropagate]);
-    meta = {
-        description = "
-        Socat, one more analogue of netcat, but not mimicking it.
-	'netcat++' (extended design, new implementation)
-";
-        homepage = "http://www.dest-unreach.org/socat/";
-	inherit src;
-    };
-}
diff --git a/pkgs/tools/networking/socat/1.6.0.1.nix b/pkgs/tools/networking/socat/1.6.0.1.nix
new file mode 100644
index 00000000000..8840d134773
--- /dev/null
+++ b/pkgs/tools/networking/socat/1.6.0.1.nix
@@ -0,0 +1,25 @@
+args : with args; 
+rec {
+  src = /* Here a fetchurl expression goes */
+  fetchurl {
+    url = http://www.dest-unreach.org/socat/download/socat-1.6.0.1.tar.bz2;
+    sha256 = "1cl7kf0rnbvjxz8vdkmdh1crd069qmz1jjw40r8bydgpn0nsh6qd";
+  };
+
+  buildInputs = [openssl];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doPatch" "doConfigure" "doMakeInstall"];
+      
+  name = "socat-" + version;
+  meta = {
+    description = "Socat - a different replacement for netcat";
+    longDesc = "
+        Socat, one more analogue of netcat, but not mimicking it.
+	'netcat++' (extended design, new implementation)
+";
+        homepage = "http://www.dest-unreach.org/socat/";
+	srcs = patches;
+  };
+}
diff --git a/pkgs/tools/networking/socat/2.0.0-b1.nix b/pkgs/tools/networking/socat/2.0.0-b1.nix
index b4c712ea9a3..4e4b626e8c3 100644
--- a/pkgs/tools/networking/socat/2.0.0-b1.nix
+++ b/pkgs/tools/networking/socat/2.0.0-b1.nix
@@ -1,26 +1,25 @@
-args : with args; with builderDefs {src="";} null;
-    let localDefs = builderDefs (rec {
-        src = /* put a fetchurl here */
+args : with args; 
+rec {
+  src = /* Here a fetchurl expression goes */
         fetchurl {
             url = http://www.dest-unreach.org/socat/download/socat-2.0.0-b1.tar.bz2;
             sha256 = "0ybd5fw22icl10r33k987rskh9gvysm1jph90a1pfdjj57cy44fk";
         };
-        
-        buildInputs = [openssl];
-        configureFlags = [];
-    }) null; /* null is a terminator for sumArgs */
-    in with localDefs;
-stdenv.mkDerivation rec {
-    name = "socat-"+version;
-    builder = writeScript (name + "-builder")
-        (textClosure localDefs 
-            [doPatch doConfigure doMakeInstall doForceShare doPropagate]);
-    meta = {
-        description = "
+
+  buildInputs = [openssl];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doPatch" "doConfigure" "doMakeInstall"];
+      
+  name = "socat-" + version;
+  meta = {
+    description = "Socat - a different replacement for netcat";
+    longDesc = "
         Socat, one more analogue of netcat, but not mimicking it.
 	'netcat++' (extended design, new implementation)
 ";
         homepage = "http://www.dest-unreach.org/socat/";
-        inherit src;
-    };
+	srcs = patches;
+  };
 }
diff --git a/pkgs/tools/networking/vpnc/builder.sh b/pkgs/tools/networking/vpnc/builder.sh
deleted file mode 100644
index ecfabe2eb5e..00000000000
--- a/pkgs/tools/networking/vpnc/builder.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-source "$stdenv/setup"
-
-tar zxvf "$src" &&
-cd vpnc-*.*
-
-cat config.c |								\
-sed "s|/etc/vpnc/vpnc-script|$out/etc/vpnc/vpnc-script|g" > ,,tmp &&	\
-mv ,,tmp config.c &&							\
-patchPhase && buildPhase && installPhase && fixupPhase && distPhase
diff --git a/pkgs/tools/networking/vpnc/default.nix b/pkgs/tools/networking/vpnc/default.nix
index 87e979330ae..dcce3bba5df 100644
--- a/pkgs/tools/networking/vpnc/default.nix
+++ b/pkgs/tools/networking/vpnc/default.nix
@@ -15,7 +15,13 @@ stdenv.mkDerivation {
 
   buildInputs = [libgcrypt perl makeWrapper];
 
-  builder = ./builder.sh;
+  preConfigure = ''
+    substituteInPlace "config.c" \
+      --replace "/etc/vpnc/vpnc-script" "$out/etc/vpnc/vpnc-script"
+
+    substituteInPlace "pcf2vpnc" \
+      --replace "/usr/bin/perl" "${perl}/bin/perl"
+  '';
 
   postInstall = ''
     for i in $out/{bin,sbin}/*
@@ -27,8 +33,8 @@ stdenv.mkDerivation {
 
   meta = {
     description = ''VPNC, a virtual private network (VPN) client
-                    for Cisco's VPN concentrators.'';
+                    for Cisco's VPN concentrators'';
     homepage = http://www.unix-ag.uni-kl.de/~massar/vpnc/;
-    license = "GPL";
+    license = "GPLv2+";
   };
 }
diff --git a/pkgs/tools/package-management/dpkg/default.nix b/pkgs/tools/package-management/dpkg/default.nix
new file mode 100644
index 00000000000..fa6af3be782
--- /dev/null
+++ b/pkgs/tools/package-management/dpkg/default.nix
@@ -0,0 +1,35 @@
+{stdenv, fetchurl, perl, zlib, bzip2}:
+
+stdenv.mkDerivation {
+  name = "dpkg-1.14.19";
+  
+  src = fetchurl {
+    url = http://ftp.de.debian.org/debian/pool/main/d/dpkg/dpkg_1.14.19.tar.gz;
+    sha256 = "11qm7kg7y472g2nki2gjdlk9xgrzblag7lcwsmdzx7jv4r1yk1sj";
+  };
+
+  configureFlags = "--without-dselect --with-admindir=/var/lib/dpkg";
+
+  preConfigure = ''
+    # Can't use substitute pending resolution of NIXPKGS-89.
+    sed -s 's^/usr/bin/perl^${perl}/bin/perl^' -i scripts/dpkg-architecture.pl
+
+    # Nice: dpkg has a circular dependency on itself.  Its configure
+    # script calls scripts/dpkg-architecture, which calls "dpkg" in
+    # $PATH.  It doesn't actually use its result, but fails if it
+    # isn't present.  So make a dummy available.
+    touch $TMPDIR/dpkg
+    chmod +x $TMPDIR/dpkg
+    PATH=$TMPDIR:$PATH
+
+    substituteInPlace src/Makefile.in --replace "install-data-local:" "disabled:"
+    substituteInPlace dpkg-split/Makefile.in --replace "install-data-local:" "disabled:"
+  '';
+
+  buildInputs = [perl zlib bzip2];
+
+  meta = {
+    description = "The Debian package manager";
+    homepage = http://wiki.debian.org/Teams/Dpkg;
+  };
+}
diff --git a/pkgs/tools/package-management/nix/custom.nix b/pkgs/tools/package-management/nix/custom.nix
index 2cff9f53d87..475a365d95b 100644
--- a/pkgs/tools/package-management/nix/custom.nix
+++ b/pkgs/tools/package-management/nix/custom.nix
@@ -10,6 +10,8 @@
 , docbook5_xsl ? null, libxslt ? null
 , docbook5 ? null, docbook_xml_dtd_43 ? null 
 , configureFlags ? []
+, lib
+, enableScripts ? []
 }:
 
 stdenv.mkDerivation {
@@ -30,12 +32,21 @@ stdenv.mkDerivation {
   	++ (if w3m != null then [w3m] else [])
   ;
 
-  inherit preConfigure;
+  preConfigure = 
+    (lib.concatMapStrings (script:
+      ''
+        sed -e '/bin_SCRIPTS/a${script} \\' -i scripts/Makefile.am
+      ''
+    ) enableScripts)
+    + preConfigure
+    + "\n./bootstrap.sh";
 
-  configureFlags = ["
+  configureFlags = ''
     --with-store-dir=${storeDir} --localstatedir=${stateDir}
     --with-aterm=${aterm} --with-bdb=${db4} --with-bzip2=${bzip2}
-    --disable-init-state"] ++ configureFlags ;
+    --disable-init-state
+    ${toString configureFlags}
+  '';
 
   meta = {
     description = "The Nix Deployment System";
diff --git a/pkgs/tools/package-management/nix/unstable.nix b/pkgs/tools/package-management/nix/unstable.nix
index bfcf3697d8a..428f1325bc8 100644
--- a/pkgs/tools/package-management/nix/unstable.nix
+++ b/pkgs/tools/package-management/nix/unstable.nix
@@ -3,14 +3,14 @@
 , stateDir ? "/nix/var"
 }:
 
-let version = "0.12pre10798"; in
+let version = "0.12pre11304"; in
 
 stdenv.mkDerivation {
   name = "nix-${version}";
   
   src = fetchurl {
-    url = "http://nix.cs.uu.nl/dist/nix/nix-${version}/nix-${version}.tar.bz2";
-    md5 = "1f3d0a72c9bf1297c2daa32e601bde82";
+    url = "http://nixos.org/releases/nix/nix-${version}-6hxl2ybs/nix-${version}.tar.bz2";
+    sha256 = "8f33687ed70d4e1453cf62c0a9c5010cc49ed787794320ef94e9ead740fd042b";
   };
 
   buildInputs = [perl curl openssl];
diff --git a/pkgs/tools/package-management/nixRepositoryManager/default.nix b/pkgs/tools/package-management/nixRepositoryManager/default.nix
index e3e20dfa913..9ac25e39bf1 100644
--- a/pkgs/tools/package-management/nixRepositoryManager/default.nix
+++ b/pkgs/tools/package-management/nixRepositoryManager/default.nix
@@ -1,34 +1,41 @@
+/*
+   repos for config file taken from all-pacakges.bleedingEdgeFetchInfo
+
+    nix-repository-manager --update <name> (for your local use only)
+
+  if you want to publish repos ask for the password (marco-oweber@gmx.de)
+      echo '{ bleedingEdgeFetchInfo = "${your_nix_pkgs_location}/pkgs/misc/bleeding-edge-fetch-info"; }' >> .nixpkgs/config.nix  
+    reinstall nix-repository-manager to recreate config
+      nix-repository-manager --publish <name> (to save on server
+*/
+
+
 args: with args; with lib;
 let 
-  repoDir = builtins.getEnv "HOME" + "/managed_repos";
   toConfigLine = name : set : 
     "[(\"name\",\"${name}\")," + ( concatStringsSep "," (map (a: "(\"${a}\",\"${__getAttr a set}\")" ) (__attrNames set)))+"]";
-  config = writeText "nix_repository_manager_config"
-        (repoDir+"\n" +
-        concatStringsSep "\n" (mapRecordFlatten toConfigLine bleeding_edge_repos));
+  nixPublishDir = getConfig [ "bleedingEdgeRepos" "bleedingEdgeFetchInfo"] "/tmp/bleeding-edge-fetch-info";
+  config = writeText "nix-repository-manager_config"
+        (bleedingEdgeRepos.managedRepoDir+"\n" +
+         nixPublishDir+"\n" +
+        concatStringsSep "\n" (mapRecordFlatten toConfigLine (bleedingEdgeRepos.repos)));
 
 in
 args.stdenv.mkDerivation {
 
-  inherit repoDir; # amend repoDir so that you know which one to take when installing bleeding edge packages 
-
-  name = "nix_repository_manager";
+  name = "nix-repository-manager";
 
-  #src = args.fetchdarcs {
-  #  url = http://mawercer.de/~marc/repos/nix_repository_manager;
-  #  md5 = "b33ba7a5b756eda00a79ba34505ea7ee";
-  #};
-  source = /pr/haskell/nix_repository_manager/nix_repository_manager.hs;
+  src = bleedingEdgeRepos.sourceByName "nix_repository_manager";
 
-  phases = "buildPhase";
+  phases = "unpackPhase buildPhase";
 
   buildPhase = "
-    s=\$out/share/nix_repository_manager
+    s=\$out/share/nix-repository-manager
     ensureDir \$out/bin \$s
-    #ghc --make nix_repository_manager.hs -o \$s/nix_repository_manager
-    ghc --make \$source -o \$s/nix_repository_manager
-    b=\$out/bin/nix_repository_manager
-    echo -e \"#!/bin/sh\\n\$s/nix_repository_manager --config ${config} \\\$@\" > \$b
+    #ghc --make nix-repository-manager.hs -o \$s/nix-repository-manager
+    ghc --make nix-repository-manager.hs -o \$s/nix-repository-manager
+    b=\$out/bin/nix-repository-manager
+    echo -e \"#!/bin/sh\\n\$s/nix-repository-manager --config ${config} \\\$@\" > \$b
     chmod +x \$b
   ";
 
@@ -36,7 +43,7 @@ args.stdenv.mkDerivation {
 
   meta = { 
       description = "makes it easy to keep some packages up to date";
-      homepage = http://mawercer.de/repos/nix_repository_manager;
-      license = "do with it what you want";
+      homepage = http://mawercer.de/repos/nix-repository-manager;
+      license = "GPL";
   };
 }
diff --git a/pkgs/tools/security/gnupg2/default.nix b/pkgs/tools/security/gnupg2/default.nix
index f6e22bec51d..b7b97ed2bab 100644
--- a/pkgs/tools/security/gnupg2/default.nix
+++ b/pkgs/tools/security/gnupg2/default.nix
@@ -1,3 +1,7 @@
+# remmeber to
+# echo "pinentry-program `which pinentry-gtk-2`" >> ~/.gnupg/gpg-agent.conf
+# and install pinentry as well
+
 args: with args;
 stdenv.mkDerivation {
   name = "gnupg-2.0.8";
diff --git a/pkgs/tools/security/metasploit/3.1.nix b/pkgs/tools/security/metasploit/3.1.nix
new file mode 100644
index 00000000000..815f0026e8e
--- /dev/null
+++ b/pkgs/tools/security/metasploit/3.1.nix
@@ -0,0 +1,31 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://www.packetstormsecurity.nl/UNIX/utilities/framework-3.1.tar.gz;
+    sha256 = "114znq9dfcyh9gcj57p3zsc0d0amlzhwidmg8qjcgxpjh28h1afx";
+  };
+
+  buildInputs = [makeWrapper];
+  configureFlags = [];
+
+  doInstall = FullDepEntry(''
+    ensureDir $out/share/msf
+    ensureDir $out/bin
+
+    cp -r * $out/share/msf
+
+    for i in $out/share/msf/msf*; do
+        makeWrapper $i $out/bin/$(basename $i) --prefix RUBYLIB : $out/share/msf/lib
+    done
+  '') ["minInit" "defEnsureDir" "doUnpack" "addInputs"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doInstall" (doPatchShebangs "$out/share/msf")];
+      
+  name = "metasploit-framework" + version;
+  meta = {
+    description = "Metasploit Framework - a collection of exploits";
+    homepage = "http://framework.metasploit.org/";
+  };
+}
+
diff --git a/pkgs/tools/security/nmap/default.nix b/pkgs/tools/security/nmap/default.nix
index 9688473de9b..808e8219486 100644
--- a/pkgs/tools/security/nmap/default.nix
+++ b/pkgs/tools/security/nmap/default.nix
@@ -1,11 +1,21 @@
-{stdenv, fetchurl, libpcap, libX11, gtk, pkgconfig}:
+{ stdenv, fetchurl, libpcap, libX11, gtk, pkgconfig
+, openssl, python, pygtk, makeWrapper, pygobject
+, pycairo, pysqlite
+}:
+  
 stdenv.mkDerivation {
-  name = "Nmap";
+  name = "nmap-4.60";
 
   src = fetchurl {
-    url = http://insecure.org/nmap/dist/nmap-4.21ALPHA4.tar.bz2;
-    md5 = "eae883e12f3640f7c52d66e0844d0ab1";
+    url = http://download.insecure.org/nmap/dist/nmap-4.60.tar.bz2;
+    sha256 = "1jhway86lmrnyzvwi24ama1vrz89f9nmln29vr92kb31aw2nl30w";
   };
 
-  buildInputs = [libpcap libX11 gtk pkgconfig];
+  postInstall =''
+    wrapProgram $out/bin/zenmap --prefix PYTHONPATH : "$(toPythonPath $out)" --prefix PYTHONPATH : "$PYTHONPATH" --prefix PYTHONPATH : $(toPythonPath ${pygtk})/gtk-2.0 --prefix PYTHONPATH : $(toPythonPath ${pygobject})/gtk-2.0 --prefix PYTHONPATH : $(toPythonPath ${pycairo})/gtk-2.0
+  '';
+
+  buildInputs = [
+    libpcap libX11 gtk pkgconfig openssl python pygtk makeWrapper pysqlite
+  ];
 }
diff --git a/pkgs/tools/system/at/default.nix b/pkgs/tools/system/at/default.nix
new file mode 100644
index 00000000000..21b35ad9b95
--- /dev/null
+++ b/pkgs/tools/system/at/default.nix
@@ -0,0 +1,31 @@
+{ fetchurl, stdenv, bison, flex, pam, ssmtp }:
+
+stdenv.mkDerivation {
+  name = "at-3.1.10.1";
+
+  src = fetchurl {
+    # Debian is apparently the last location where it can be found.
+    url = mirror://debian/pool/main/a/at/at_3.1.10.1.tar.gz;
+    sha256 = "188j6v0hq9avd9v7mhc8gdyg4wycc7lqviw4idwn0jjvwkky5428";
+  };
+
+  patches = [ ./install.patch ];
+
+  buildInputs = [ bison flex pam
+
+                  # `configure' and `atd' want the `sendmail' command.
+                  ssmtp ];
+
+  configurePhase = ''
+    export PATH="${ssmtp}/sbin:$PATH"
+    ./configure --prefix=$out --with-etcdir=/etc/at \
+                --with-jobdir=/var/spool/atjobs --with-atspool=/var/spool/atspool \
+		--with-daemon_username=atd --with-daemon_groupname=atd
+  '';
+
+  meta = {
+    description = ''The classical Unix `at' job scheduling command'';
+    license = "GPLv2+";
+    homepage = http://packages.qa.debian.org/at;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/tools/system/at/install.patch b/pkgs/tools/system/at/install.patch
new file mode 100644
index 00000000000..9db336e9bfe
--- /dev/null
+++ b/pkgs/tools/system/at/install.patch
@@ -0,0 +1,55 @@
+--- at-3.1.10.1/Makefile.in	2005-08-29 10:08:28.000000000 +0200
++++ at-3.1.10.1/Makefile.in	2008-04-01 11:05:38.000000000 +0200
+@@ -88,35 +88,28 @@ atrun: atrun.in
+ 	$(CC) -c $(CFLAGS) $(DEFS) $*.c
+ 
+ install: all
+-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(etcdir)
+-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(bindir)
+-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(sbindir)
+-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(docdir)
+-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(atdocdir)
+-	$(INSTALL) -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME) -m 755 -d $(IROOT)$(ATSPOOL_DIR) $(IROOT)$(ATJOB_DIR)
+-	chmod 1770 $(IROOT)$(ATSPOOL_DIR) $(IROOT)$(ATJOB_DIR)
+-	touch $(IROOT)$(LFILE)
+-	chmod 600 $(IROOT)$(LFILE)
+-	chown $(DAEMON_USERNAME):$(DAEMON_GROUPNAME) $(IROOT)$(LFILE)
+-	test -f $(IROOT)$(etcdir)/at.allow || test -f $(IROOT)$(etcdir)/at.deny || $(INSTALL) -o root -g $(DAEMON_GROUPNAME) -m 640 at.deny $(IROOT)$(etcdir)/
+-	$(INSTALL) -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME) -m 6755 -s at $(IROOT)$(bindir)
++	$(INSTALL) -m 755 -d $(IROOT)$(bindir)
++	$(INSTALL) -m 755 -d $(IROOT)$(sbindir)
++	$(INSTALL) -m 755 -d $(IROOT)$(docdir)
++	$(INSTALL) -m 755 -d $(IROOT)$(atdocdir)
++	$(INSTALL) -m 6755 -s at $(IROOT)$(bindir)
+ 	$(LN_S) -f at $(IROOT)$(bindir)/atq
+ 	$(LN_S) -f at $(IROOT)$(bindir)/atrm
+-	$(INSTALL) -g root -o root -m 755 batch $(IROOT)$(bindir)
+-	$(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man1dir)
+-	$(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man5dir)
+-	$(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man8dir)
+-	$(INSTALL) -g root -o root -m 755 -s atd $(IROOT)$(sbindir)
+-	$(INSTALL) -g root -o root -m 755 atrun $(IROOT)$(sbindir)
+-	$(INSTALL) -g root -o root -m 644 at.1 $(IROOT)$(man1dir)/
++	$(INSTALL) -m 755 batch $(IROOT)$(bindir)
++	$(INSTALL) -d -m 755 $(IROOT)$(man1dir)
++	$(INSTALL) -d -m 755 $(IROOT)$(man5dir)
++	$(INSTALL) -d -m 755 $(IROOT)$(man8dir)
++	$(INSTALL) -m 755 -s atd $(IROOT)$(sbindir)
++	$(INSTALL) -m 755 atrun $(IROOT)$(sbindir)
++	$(INSTALL) -m 644 at.1 $(IROOT)$(man1dir)/
+ 	cd $(IROOT)$(man1dir) && $(LN_S) -f at.1 atq.1 && $(LN_S) -f at.1 batch.1 && $(LN_S) -f at.1 atrm.1
+-	$(INSTALL) -g root -o root -m 644 atd.8 $(IROOT)$(man8dir)/
++	$(INSTALL) -m 644 atd.8 $(IROOT)$(man8dir)/
+ 	sed "s,\$${exec_prefix},$(exec_prefix),g" <atrun.8>tmpman
+-	$(INSTALL) -g root -o root -m 644 tmpman $(IROOT)$(man8dir)/atrun.8
++	$(INSTALL) -m 644 tmpman $(IROOT)$(man8dir)/atrun.8
+ 	rm -f tmpman
+-	$(INSTALL) -g root -o root -m 644 at_allow.5 $(IROOT)$(man5dir)/
++	$(INSTALL) -m 644 at_allow.5 $(IROOT)$(man5dir)/
+ 	cd $(IROOT)$(man5dir) && $(LN_S) -f at_allow.5 at_deny.5 
+-	$(INSTALL) -g root -o root -m 644 $(DOCS) $(IROOT)$(atdocdir)
++	$(INSTALL) -m 644 $(DOCS) $(IROOT)$(atdocdir)
+ 	rm -f $(IROOT)$(mandir)/cat1/at.1* $(IROOT)$(mandir)/cat1/batch.1* \
+ 		$(IROOT)$(mandir)/cat1/atq.1*
+ 	rm -f $(IROOT)$(mandir)/cat1/atd.8*
+
diff --git a/pkgs/tools/system/ddrescue/1.8.nix b/pkgs/tools/system/ddrescue/1.8.nix
new file mode 100644
index 00000000000..01d1927573b
--- /dev/null
+++ b/pkgs/tools/system/ddrescue/1.8.nix
@@ -0,0 +1,20 @@
+
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://ftp.gnu.org/gnu/ddrescue/ddrescue-1.8.tar.bz2;
+    sha256 = "080k1s4knh9baw3dxr5vqjjph6dqzkfpk0kpld0a3qc07vsxmhbz";
+  };
+
+  buildInputs = [];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doConfigure" "doMakeInstall"];
+      
+  name = "ddrescue-" + version;
+  meta = {
+    description = "GNU ddrescue - advanced dd for corrupted media";
+  };
+}
+  
diff --git a/pkgs/tools/text/cheetah-template/2.0.1.nix b/pkgs/tools/text/cheetah-template/2.0.1.nix
new file mode 100644
index 00000000000..117e0f88a8b
--- /dev/null
+++ b/pkgs/tools/text/cheetah-template/2.0.1.nix
@@ -0,0 +1,18 @@
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://downloads.sourceforge.net/cheetahtemplate/Cheetah-2.0.1.tar.gz;
+    sha256 = "134k4s5f116k23vb7wf9bynlx3gf0wwl7y0zp9ciz0q66nh1idkh";
+  };
+
+  buildInputs = [python makeWrapper];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["installPythonPackage" (makeManyWrappers ''$out/bin/*'' ''--prefix PYTHONPATH : $(toPythonPath $out)'')];
+      
+  name = "cheetah-template-" + version;
+  meta = {
+    description = "Templating engine";
+  };
+}
diff --git a/pkgs/tools/text/diffstat/default.nix b/pkgs/tools/text/diffstat/default.nix
new file mode 100644
index 00000000000..d1d366ba599
--- /dev/null
+++ b/pkgs/tools/text/diffstat/default.nix
@@ -0,0 +1,17 @@
+{fetchurl, stdenv}:
+
+stdenv.mkDerivation rec {
+  name = "diffstat-1.45";
+
+  src = fetchurl {
+    url = "ftp://invisible-island.net/diffstat/"+ name +".tgz";
+    md5 = "cfe06ffcdbeaaa2fd296db867157ef78";
+  };
+
+  meta = {
+    homepage = http://invisible-island.net/diffstat/;
+    longDescription = "diffstat reads the output of diff and displays a
+istogram of the insertions, deletions, and modifications per-file. It
+s useful for reviewing large, complex patch files.";
+  };
+}
diff --git a/pkgs/tools/text/ed/default.nix b/pkgs/tools/text/ed/default.nix
deleted file mode 100644
index 99357d86341..00000000000
--- a/pkgs/tools/text/ed/default.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{stdenv, fetchurl}: stdenv.mkDerivation {
-  name = "ed-0.9";
-  src = fetchurl {
-    url = mirror://gnu/ed/ed-0.9.tar.bz2;
-    sha256 = "1xy746g7ai9gmv6iq2x1ll8x6wy4fi9anfh7gj5ifsdnaiahgyi2";
-  };
-}
diff --git a/pkgs/tools/text/highlight/2.6.10.nix b/pkgs/tools/text/highlight/2.6.10.nix
new file mode 100644
index 00000000000..675a996445f
--- /dev/null
+++ b/pkgs/tools/text/highlight/2.6.10.nix
@@ -0,0 +1,20 @@
+
+args : with args; 
+rec {
+  src = fetchurl {
+    url = http://www.andre-simon.de/zip/highlight-2.6.10.tar.bz2;
+    sha256 = "18f2ki9pajxlp0aq4ingxj7m0cp7wlbc40xm25pnxc1yis9vlira";
+  };
+
+  buildInputs = [getopt];
+  configureFlags = [];
+  makeFlags = ["PREFIX=$out"];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doMakeInstall"];
+      
+  name = "highlight-" + version;
+  meta = {
+    description = "Source code highlighting tool";
+  };
+}
diff --git a/pkgs/tools/text/mpage/default.nix b/pkgs/tools/text/mpage/default.nix
new file mode 100644
index 00000000000..5b95c37c732
--- /dev/null
+++ b/pkgs/tools/text/mpage/default.nix
@@ -0,0 +1,28 @@
+{ fetchurl, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "mpage-2.5.6";
+  src = fetchurl {
+    url = "http://www.mesa.nl/pub/mpage/${name}.tgz";
+    sha256 = "016w9sm06sn1d2lim4p8fzl6wbmad3wigxhflsybzi7p4zy6vrjg";
+  };
+
+  patchPhase = ''
+    sed -i "Makefile" -e "s|^ *PREFIX *=.*$|PREFIX = $out|g"
+  '';
+
+  meta = {
+    description = "Mpage, many-to-one page printing utility";
+
+    longDescription = ''
+      Mpage reads plain text files or PostScript documents and prints
+      them on a PostScript printer with the text reduced in size so
+      that several pages appear on one sheet of paper.  This is useful
+      for viewing large printouts on a small amount of paper.  It uses
+      ISO 8859.1 to print 8-bit characters.
+    '';
+
+    license = "liberal";  # a non-copyleft license, see `Copyright' file
+    homepage = http://www.mesa.nl/pub/mpage/;
+  };
+}
diff --git a/pkgs/tools/typesetting/asciidoc/default.nix b/pkgs/tools/typesetting/asciidoc/default.nix
new file mode 100644
index 00000000000..ab6c9aef0ae
--- /dev/null
+++ b/pkgs/tools/typesetting/asciidoc/default.nix
@@ -0,0 +1,53 @@
+{ fetchurl, stdenv, python, bash }:
+
+stdenv.mkDerivation rec {
+  name = "asciidoc-8.2.5";
+  src = fetchurl {
+    url = "mirror://sourceforge/asciidoc/${name}.tar.gz";
+    sha256 = "1aqmii7qyhnn8pby5rlyrc3sl08br35xsdn7wpx2cy03p46pqr7a";
+  };
+
+  patchPhase = ''
+    cat "asciidoc.py" | \
+      sed -e "s,^#!/usr/bin/env python,#!${python}/bin/python,g ;
+              s,^CONF_DIR = .*$,CONF_DIR = \"$out/etc/asciidoc\",g" \
+      > ,,tmp && mv ,,tmp asciidoc.py && chmod +x asciidoc.py
+    cat "a2x" | \
+      sed -e "s,^#!/usr/bin/env bash,#!${bash},g ;
+              s,^CONF_DIR=.*$,CONF_DIR=\"$out/etc/asciidoc\",g" \
+      > ,,tmp && mv ,,tmp a2x && chmod +x a2x
+
+    cat "install.sh" | \
+      sed -e "s,^CONFDIR=.*,CONFDIR=$out/etc/asciidoc,g" \
+      > ,,tmp && mv ,,tmp install.sh
+    cat "install.sh" | \
+      sed -e "s,^BINDIR=.*,BINDIR=$out/bin,g" \
+      > ,,tmp && mv ,,tmp install.sh
+    cat "install.sh" | \
+      sed -e "s,^MANDIR=.*,MANDIR=$out/man,g" \
+      > ,,tmp && mv ,,tmp install.sh
+    cat "install.sh" | \
+      sed -e "s,^VIM_CONFDIR=.*,VIM_CONFDIR=$out/etc/vim,g" \
+      > ,,tmp && mv ,,tmp install.sh
+
+    chmod +x install.sh
+  '';
+
+  buildInputs = [ python ];
+  configurePhase = ''true'';
+  installPhase = ''
+    ensureDir $out/bin
+    ensureDir $out/etc
+    ensureDir $out/etc/vim
+    ensureDir $out/man
+    ./install.sh
+  '';
+
+  meta = {
+    description = ''AsciiDoc is a text-based document generation system.
+                    AsciiDoc input files can be translated to HTML and
+		    DocBook markups'';
+    homepage = http://www.methods.co.nz/asciidoc/;
+    license = "GPLv2+";
+  };
+}
\ No newline at end of file
diff --git a/pkgs/tools/typesetting/docbook2x/db2x_texixml-to-stdout.patch b/pkgs/tools/typesetting/docbook2x/db2x_texixml-to-stdout.patch
new file mode 100644
index 00000000000..8daa5c87a66
--- /dev/null
+++ b/pkgs/tools/typesetting/docbook2x/db2x_texixml-to-stdout.patch
@@ -0,0 +1,15 @@
+--- docbook2X-0.8.8/perl/db2x_texixml.pl	2006-04-20 05:02:31.000000000 +0200
++++ docbook2X-0.8.8/perl/db2x_texixml.pl	2008-03-12 15:36:55.000000000 +0100
+@@ -432,8 +432,12 @@ sub texi_openfile {
+                 $openstr = '>-';
+             }
+         } else {
++	    if(not $self->{options}->{'to-stdout'}) {
+             $openstr .= '> ' . shell_quote($filename);
+             print "$filename\n"
+                 if $self->{options}->{'list-files'};
++	    } else {
++		$openstr = '>-';
++	    }
+         }
+     }
diff --git a/pkgs/tools/typesetting/docbook2x/default.nix b/pkgs/tools/typesetting/docbook2x/default.nix
new file mode 100644
index 00000000000..a6e56f1c53b
--- /dev/null
+++ b/pkgs/tools/typesetting/docbook2x/default.nix
@@ -0,0 +1,53 @@
+{ fetchurl, stdenv, texinfo, perl
+, perlXMLSAX, perlXMLParser, perlXMLNamespaceSupport
+, groff, libxml2, libxslt, gnused
+, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "docbook2X-0.8.8";
+  src = fetchurl {
+    url = "mirror://sourceforge/docbook2x/${name}.tar.gz";
+    sha256 = "0ifwzk99rzjws0ixzimbvs83x6cxqk1xzmg84wa1p7bs6rypaxs0";
+  };
+
+  # This patch makes sure that `docbook2texi --to-stdout' actually
+  # writes its output to stdout instead of creating a file.
+  patches = [ ./db2x_texixml-to-stdout.patch ];
+
+  buildInputs = [ perl texinfo groff libxml2 libxslt makeWrapper
+                  perlXMLSAX perlXMLParser perlXMLNamespaceSupport ];
+
+  postConfigure = ''
+    # Broken substitution is used for `perl/config.pl', which leaves literal
+    # `$prefix' in it.
+    substituteInPlace "perl/config.pl"       \
+      --replace '${"\$" + "{prefix}"}' "$out"
+  '';
+
+  postInstall = ''
+    perlPrograms="db2x_manxml db2x_texixml db2x_xsltproc
+                  docbook2man docbook2texi";
+    for i in $perlPrograms
+    do
+      # XXX: We work around the fact that `wrapProgram' doesn't support
+      # spaces below by inserting escaped backslashes.
+      wrapProgram $out/bin/$i --prefix PERL5LIB :			\
+        "${perlXMLSAX}/lib/site_perl:${perlXMLParser}/lib/site_perl"	\
+	--prefix PERL5LIB :						\
+	"${perlXMLNamespaceSupport}/lib/site_perl"			\
+	--prefix XML_CATALOG_FILES "\ "					\
+	"$out/share/docbook2X/dtd/catalog.xml\ $out/share/docbook2X/xslt/catalog.xml"
+    done
+
+    wrapProgram $out/bin/sgml2xml-isoent --prefix PATH : \
+      "${gnused}/bin"
+  '';
+
+  meta = {
+    description = ''docbook2X is a software package that converts DocBook
+                    documents into the traditional Unix man page format
+		    and the GNU Texinfo format.'';
+    license = "MIT-style";
+    homepage = http://docbook2x.sourceforge.net/;
+  };
+}
diff --git a/pkgs/tools/typesetting/lhs2tex/builder.sh b/pkgs/tools/typesetting/lhs2tex/builder.sh
deleted file mode 100644
index a2a07d5ec11..00000000000
--- a/pkgs/tools/typesetting/lhs2tex/builder.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-source $stdenv/setup
-
-postInstall() {
-
-    ensureDir "$out/share/doc/$name"
-    cp doc/Guide2.pdf $out/share/doc/$name
-    ensureDir "$out/nix-support"
-    echo "$propagatedUserEnvPackages" > $out/nix-support/propagated-user-env-packages
-
-}
-
-postInstall=postInstall
-
-genericBuild
diff --git a/pkgs/tools/typesetting/lhs2tex/default.nix b/pkgs/tools/typesetting/lhs2tex/default.nix
index f071f67fe97..c4fe10026dd 100644
--- a/pkgs/tools/typesetting/lhs2tex/default.nix
+++ b/pkgs/tools/typesetting/lhs2tex/default.nix
@@ -3,18 +3,24 @@
 assert tetex == polytable.tetex;
 
 stdenv.mkDerivation {
-  name = "lhs2tex-1.13pre3";
-  builder = ./builder.sh;
+  name = "lhs2tex-1.13";
   
   src = fetchurl {
-    url = "http://www.cs.uu.nl/~andres/lhs2tex/lhs2tex-1.13pre3.tar.bz2";
-    sha256 = "8ddc9bd150c20c33518d747fee95577ec8f587146532cda12b8034adc847826c";
+    url = "http://people.cs.uu.nl/andres/lhs2tex/lhs2tex-1.13.tar.gz";
+    sha256 = "28282cb4afcc71785b092d358ffb33f5ec7585e50b392ae4fb6391d495a0836b";
   };
 
   buildInputs = [tetex ghc];
   propagatedBuildInputs = [polytable];
   propagatedUserEnvPackages = [polytable];
 
+  postInstall = ''
+    ensureDir "$out/share/doc/$name"
+    cp doc/Guide2.pdf $out/share/doc/$name
+    ensureDir "$out/nix-support"
+    echo "$propagatedUserEnvPackages" > $out/nix-support/propagated-user-env-packages
+  '';
+
   inherit tetex;
 }
 
diff --git a/pkgs/tools/typesetting/xmlto/default.nix b/pkgs/tools/typesetting/xmlto/default.nix
new file mode 100644
index 00000000000..0bb2338085c
--- /dev/null
+++ b/pkgs/tools/typesetting/xmlto/default.nix
@@ -0,0 +1,43 @@
+{ fetchurl, stdenv, flex, libxml2, libxslt
+, docbook_xml_dtd_42, docbook_xsl
+, glibc, bash, getopt, mktemp, findutils
+, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "xmlto-0.0.20";
+  src = fetchurl {
+    url = "http://cyberelk.net/tim/data/xmlto/stable/${name}.tar.bz2";
+    sha256 = "1s71khb0ycawhjpr19zrrqk0jac11jgwvxnajjkm2656p5qikylz";
+  };
+
+  patchPhase = ''
+    substituteInPlace "xmlto.in" \
+      --replace "/bin/bash" "${bash}/bin/bash"
+    substituteInPlace "xmlto.in" \
+      --replace "/usr/bin/locale" "${glibc}/bin/locale"
+  '';
+
+  configureFlags = ''
+    --with-mktemp=${mktemp}/bin/mktemp
+    --with-find=${findutils}/bin/find
+    --with-bash=${bash}/bin/bash
+    --with-getopt=${getopt}/bin/getopt
+  '';
+
+  # `libxml2' provides `xmllint', needed at build-time and run-time.
+  # `libxslt' provides `xsltproc', used by `xmlto' at run-time.
+  buildInputs = [ libxml2 libxslt docbook_xml_dtd_42 docbook_xsl makeWrapper ];
+
+  postInstall = ''
+    wrapProgram $out/bin/xmlto --prefix PATH : "${libxslt}/bin:${libxml2}/bin"
+  '';
+
+  meta = {
+    description = ''xmlto is a front-end to an XSL toolchain.  It chooses
+                    an appropriate stylesheet for the conversion you want
+		    and applies it using an external XSL-T processor.  It
+		    also performs any necessary post-processing.'';
+    license = "GPLv2+";
+    homepage = http://cyberelk.net/tim/software/xmlto/;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 9e2145fa498..69bc927df2e 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -29,7 +29,7 @@
 }:
 
 
-rec {
+let pkgs = rec {
 
 
   ### Symbolic names.
@@ -101,7 +101,7 @@ rec {
         };
       });
       isDietLibC = true;
-    };
+    } // {inherit fetchurl;};
 
   # Return a modified stdenv that tries to build statically linked
   # binaries.
@@ -113,7 +113,8 @@ rec {
           (if args ? configureFlags then args.configureFlags else "")
           + " --disable-shared"; # brrr...
       });
-    };
+      isStatic = true;
+    } // {inherit fetchurl;};
 
   # Applying this to an attribute set will cause nix-env to look
   # inside the set for derivations.
@@ -124,40 +125,55 @@ rec {
 
   lib = import ../lib;
 
-  annotatedDerivations = (import ../lib/annotatedDerivations.nix) { inherit lib; };
-
   # optional srcDir
-  annotatedWithSourceAndTagInfo = x : (x ? sourceWithTags);
-
-  # example arguments see annotatedGhcCabalDerivation
+  annotatedWithSourceAndTagInfo = x : (x ? passthru && x.passthru ? sourceWithTags 
+                                      || x ? meta && x.meta ? sourceWithTags );
+  # hack because passthru doesn't work the way I'd expect. Don't have time to spend on this right now
+  # passthru2 is not special and will be there in any case (but will force recompilation :(
+  sourceWithTagsFromDerivation = x : if (x ? passthru && x.passthru ? sourceWithTags ) then x.passthru.sourceWithTags
+                                     else if (x ? meta && x.meta ? sourceWithTags ) then x.meta.sourceWithTags
+                                       else null;
+
+  # createTagFiles =  [ { name  = "my_tag_name_without_suffix", tagCmd = "ctags -R . -o \$TAG_FILE"; } ]
   # tag command must create file named $TAG_FILE
-  sourceWithTagsDerivation = args: with args; 
-    let createTagFiles = (lib.maybeAttr "createTagFiles" [] args ); in
-  stdenv.mkDerivation {
+  sourceWithTagsDerivation = {name, src, srcDir ? ".", tagSuffix ? "_tags", createTagFiles ? []} :  
+    stdenv.mkDerivation {
     phases = "unpackPhase buildPhase";
-    inherit (args) src name;
-    srcDir = (lib.maybeAttr "srcDir" "." args);
+    inherit src srcDir tagSuffix;
+    name = "${name}-source-with-tags";
+    buildInputs = [ unzip ];
     # using separate tag directory so that you don't have to glob that much files when starting your editor
     # is this a good choice?
     buildPhase = "
       SRC_DEST=\$out/src/\$name
-      t=\$out/tags/\$name
-      ensureDir \$SRC_DEST \$t
+      ensureDir \$SRC_DEST
       cp -r \$srcDir \$SRC_DEST"
       + lib.defineShList "sh_list_names" (lib.catAttrs "name" createTagFiles)
       + lib.defineShList "sh_list_cmds" (lib.catAttrs "tagCmd" createTagFiles)
       + "cd \$SRC_DEST
       for a in `seq 0 \${#sh_list}`; do
-          TAG_FILE=\"\$SRC_DEST/\"\${sh_list_names[\$a]}
+          TAG_FILE=\"\$SRC_DEST/\"\${sh_list_names[\$a]}\$tagSuffix
           cmd=\"\${sh_list_cmds[\$a]}\"
           echo running tag cmd \"\$cmd\" in `pwd`
           eval \"\$cmd\";
-          ln -s \$TAG_FILE \"\$t/\"\${sh_list_names[\$a]}
        done
     ";
   };
   # example usage
-  testSourceWithTags = sourceWithTagsDerivation (ghc68_extra_libs ghcsAndLibs.ghc68).mtl.sourceWithTags;
+  #testSourceWithTags = sourceWithTagsDerivation (ghc68extraLibs ghcsAndLibs.ghc68).happs_server_darcs.passthru.sourceWithTags;
+
+  addCTaggingInfo = deriv :
+    deriv // { 
+      passthru = {
+        sourceWithTags = {
+         inherit (deriv) src;
+         name = "${deriv.name}-source-ctags";
+         createTagFiles = [
+               { inherit  (deriv) name;
+                 tagCmd = "${toString ctags}/bin/ctags --sort=yes -o \$TAG_FILE -R ."; }
+          ];
+        };
+  }; };
 
   # Return an attribute from the Nixpkgs configuration file, or
   # a default value if the attribute doesn't exist.
@@ -223,6 +239,10 @@ rec {
     meta = (if drv ? meta then drv.meta else {}) // {priority = "10";};
   };
 
+  # documentation see examples in lib at end of file or read some use cases
+  # within this file
+  # Before spending much time on investigating how this works just ask me
+  # - Marc Weber (#irc or marco-oweber@gmx.de)
   mkDerivationByConfiguration = 
     assert builtins ? isAttrs;
     { flagConfig ? {}, optionals ? [], defaults ? []
@@ -234,26 +254,31 @@ rec {
     let co = lib.chooseOptionsByFlags { inherit args flagConfig optionals defaults collectExtraPhaseActions; }; in
       args.stdenv.mkDerivation ( 
       {
-        inherit (co) configureFlags buildInputs /*flags*/;
+        inherit (co) configureFlags buildInputs propagatedBuildInputs /*flags*/;
       } // extraAttrs co  // co.pass // co.flags_prefixed );
   
 
   # Check absence of non-used options
-	checker = x: flag: opts: config: 
-		(if flag then let result=( 
-			(import ../build-support/checker) 
-			opts config); in
-			(if (result=="") then x else
-			abort ("Unknown option specified: " + result))
-		else x);
-
-	builderDefs = lib.sumArgs (import ./builder-defs.nix) {
-		inherit stringsWithDeps lib stdenv writeScript fetchurl;
-	};
-
-	stringsWithDeps = import ../lib/strings-with-deps.nix {
-		inherit stdenv lib;
-	};
+  checker = x: flag: opts: config: 
+    (if flag then let result=( 
+      (import ../build-support/checker) 
+      opts config); in
+      (if (result=="") then x else
+      abort ("Unknown option specified: " + result))
+    else x);
+
+  builderDefs = lib.sumArgs (import ./builder-defs.nix) {
+    inherit stringsWithDeps lib stdenv writeScript fetchurl;
+  };
+
+  composedArgsAndFun = f : lib.composedArgs (arg : (f arg)//{meta={function=(composedArgsAndFun f) arg;};});
+
+  builderDefsPackage = expr: composedArgsAndFun 
+    (((builderDefs null).builderDefsPackage builderDefs) expr);
+
+  stringsWithDeps = import ../lib/strings-with-deps.nix {
+    inherit stdenv lib;
+  };
 
   # Call a specific version of a Nix expression, that is,
   # `selectVersion ./foo {version = "0.1.2"; args...}' evaluates to
@@ -311,23 +336,48 @@ rec {
     inherit stdenv darcs nix;
   };
 
+  # only temporarely  / don't know yet wether it's save to switch
+  # but I have trouble getting HAppS repos
+  fetchdarcs2 = import ../build-support/fetchdarcs {
+    inherit stdenv nix;
+    darcs = darcs2;
+  };
+
   fetchsvn = import ../build-support/fetchsvn {
     inherit stdenv subversion openssh;
     sshSupport = true;
   };
 
+  fetchsvnssh = import ../build-support/fetchsvnssh {
+    inherit stdenv subversion openssh expect;
+    sshSupport = true;
+  };
+
   # TODO do some testing
   fetchhg = import ../build-support/fetchhg {
     inherit stdenv mercurial nix;
   };
 
-  # Allow the stdenv to determine fetchurl, to cater for strange
-  # requirements.
+  # `fetchurl' downloads a file from the network.  The `useFromStdenv'
+  # is there to allow stdenv to determine fetchurl.  Used during the
+  # stdenv-linux bootstrap phases to prevent lots of different curls
+  # from being built.
   fetchurl = useFromStdenv "fetchurl"
     (import ../build-support/fetchurl {
       inherit stdenv curl;
     });
 
+  # fetchurlBoot is used for curl and its dependencies in order to
+  # prevent a cyclic dependency (curl depends on curl.tar.bz2,
+  # curl.tar.bz2 depends on fetchurl, fetchurl depends on curl).  It
+  # uses the curl from the previous bootstrap phase (e.g. a statically
+  # linked curl in the case of stdenv-linux).
+  fetchurlBoot = stdenv.fetchurlBoot;
+
+  makeInitrd = {contents}: import ../build-support/kernel/make-initrd.nix {
+    inherit stdenv perl cpio contents;
+  };
+
   makeSetupHook = script: runCommand "hook" {} ''
     ensureDir $out/nix-support
     cp ${script} $out/nix-support/setup-hook
@@ -335,6 +385,11 @@ rec {
 
   makeWrapper = makeSetupHook ../build-support/make-wrapper/make-wrapper.sh;
 
+  makeModulesClosure = {kernel, rootModules, allowMissing ? false}: 
+    import ../build-support/kernel/modules-closure.nix {
+      inherit stdenv module_init_tools kernel rootModules allowMissing;
+    };
+
   # Run the shell command `buildCommand' to produce a store object
   # named `name'.  The attributes in `env' are added to the
   # environment prior to running the command.
@@ -358,6 +413,10 @@ rec {
   nukeReferences = import ../build-support/nuke-references/default.nix {
     inherit stdenv;
   };
+
+  vmTools = import ../build-support/vm/default.nix {
+    inherit pkgs;
+  };
   
 
   ### TOOLS
@@ -371,12 +430,24 @@ rec {
     inherit fetchurl stdenv zlib wxGTK;
   };
 
-  avahi = selectVersion ../development/libraries/avahi "0.6.22" {
-    inherit stdenv fetchurl pkgconfig libdaemon dbus perl perlXMLParser qt4
-      python expat;
-    inherit (gtkLibs) glib gtk;
+  at = import ../tools/system/at {
+    inherit fetchurl stdenv bison flex pam ssmtp;
   };
 
+  avahi =
+    # XXX: Versions prior to 0.6.22 did not support Qt4, so enabling
+    # Qt4 should not be permitted when using a version of Avahi older
+    # than 0.6.22, hence the default to `false'.
+    let qt4Support = getConfig [ "avahi" "qt4Support" ] false;
+    in
+      selectVersion ../development/libraries/avahi "0.6.22" {
+        inherit stdenv fetchurl pkgconfig libdaemon dbus perl perlXMLParser
+          expat lib;
+        inherit (gtkLibs) glib gtk;
+        inherit qt4Support;
+        qt4 = if qt4Support then qt4 else null;
+      };
+
   axel = import ../tools/networking/axel {
     inherit fetchurl stdenv;
   };
@@ -389,6 +460,10 @@ rec {
     inherit fetchurl stdenv flex;
   };
 
+  asciidoc = import ../tools/typesetting/asciidoc {
+    inherit fetchurl stdenv bash python;
+  };
+
   bibtextools = import ../tools/typesetting/bibtex-tools {
     inherit fetchurl stdenv aterm tetex hevea sdf strategoxt;
   };
@@ -427,6 +502,11 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  cheetahTemplate = builderDefsPackage (selectVersion ../tools/text/cheetah-template "2.0.1") {
+    inherit makeWrapper;
+    python = python25;
+  } null;
+
   chkrootkit = import ../tools/security/chkrootkit {
     inherit fetchurl stdenv;
   };
@@ -452,20 +532,33 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  curl = if stdenv ? curl then stdenv.curl else (assert false; null);
+  curl = import ../tools/networking/curl {
+    fetchurl = fetchurlBoot;
+    inherit stdenv zlib openssl;
+    zlibSupport = ! ((stdenv ? isDietLibC) || (stdenv ? isStatic));
+    sslSupport = ! ((stdenv ? isDietLibC) || (stdenv ? isStatic));
+  };
 
   curlftpfs = import ../tools/networking/curlftpfs {
     inherit fetchurl stdenv fuse curl pkgconfig zlib;
     inherit (gtkLibs) glib;
   };
 
+  ddrescueFun = builderDefsPackage (selectVersion ../tools/system/ddrescue "1.8") ;
+  ddrescue = ddrescueFun null;
+ 
   dnsmasq = import ../tools/networking/dnsmasq {
     # TODO i18n can be installed as well, implement it? 
     inherit fetchurl stdenv;
   };
 
   dhcp = import ../tools/networking/dhcp {
-    inherit fetchurl stdenv groff nettools coreutils iputils gnused bash;
+    inherit fetchurl stdenv groff nettools coreutils iputils gnused
+            bash makeWrapper;
+  };
+
+  diffstat = import ../tools/text/diffstat {
+    inherit fetchurl stdenv;
   };
 
   diffutils = useFromStdenv "diffutils"
@@ -473,24 +566,30 @@ rec {
       inherit fetchurl stdenv coreutils;
     });
 
-  dosfstoolsFun = lib.sumArgs (selectVersion ../tools/misc/dosfstools "2.11deb")
-  {
+  docbook2x = import ../tools/typesetting/docbook2x {
+    inherit fetchurl stdenv texinfo perl
+            perlXMLSAX perlXMLParser perlXMLNamespaceSupport
+            gnused groff libxml2 libxslt makeWrapper;
+  };
+
+  dosfstoolsFun = lib.sumArgs (selectVersion ../tools/misc/dosfstools "2.11deb") {
     inherit builderDefs;
   };
 
   dosfstools = dosfstoolsFun null;
 
-  ed = import ../tools/text/ed {
-    inherit fetchurl stdenv;
-  };
-
   enscript = import ../tools/text/enscript {
     inherit fetchurl stdenv;
   };
 
-  eprover = import ../tools/misc/eProver {
-    inherit fetchurl stdenv which tetex;
-  };
+  eprover = composedArgsAndFun (import ../tools/misc/eProver) {
+    inherit fetchurl stdenv which;
+    texLive = texLiveAggregationFun {
+      paths = [
+        texLive texLiveExtra
+      ];
+    } null;
+  } null;
 
   exif = import ../tools/graphics/exif {
     inherit fetchurl stdenv pkgconfig libexif popt;
@@ -505,8 +604,7 @@ rec {
   };
 
   filelight = import ../tools/system/filelight {
-    inherit fetchurl stdenv kdelibs x11 zlib 
-	perl libpng;
+    inherit fetchurl stdenv kdelibs x11 zlib perl libpng;
     qt = qt3;
   };
 
@@ -526,18 +624,19 @@ rec {
   }));
 
   finger_bsd = import ../tools/networking/bsd-finger {
-	  inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
-  fontforgeFun = lib.sumArgs (import ../tools/misc/fontforge) {
+  fontforge = import ../tools/misc/fontforge {
     inherit fetchurl stdenv gettext freetype zlib
       libungif libpng libjpeg libtiff libxml2 lib;
   };
 
-  fontforge = fontforgeFun null;
-  fontforgeX = fontforgeFun {
+  fontforgeX = import ../tools/misc/fontforge {
+    inherit fetchurl stdenv gettext freetype zlib
+      libungif libpng libjpeg libtiff libxml2 lib;
     inherit (xlibs) libX11 xproto libXt;
-  } null;
+  };
 
   gawk = useFromStdenv "gawk"
     (import ../tools/text/gawk {
@@ -545,8 +644,7 @@ rec {
     });
 
   gdmapFun = lib.sumArgs (selectVersion ../tools/system/gdmap "0.7.5") {
-    inherit stdenv fetchurl builderDefs pkgconfig libxml2
-      intltool;
+    inherit stdenv fetchurl builderDefs pkgconfig libxml2 intltool;
     inherit (gtkLibs) gtk;
   };
 
@@ -634,7 +732,7 @@ rec {
       inherit fetchurl stdenv;
     });
 
-  hddtemp = import ../tools/hddtemp {
+  hddtemp = import ../tools/misc/hddtemp {
     inherit fetchurl stdenv;
   };
 
@@ -642,18 +740,32 @@ rec {
     inherit fetchurl stdenv ocaml;
   };
 
-  /*hyppocampusFun = lib.sumArgs ( selectVersion ../tools/misc/hyppocampus "0.3rc1") {
+  highlight = builderDefsPackage (selectVersion ../tools/text/highlight "2.6.10") {
+    inherit getopt;
+  } null;
+
+  /*
+  hyppocampusFun = lib.sumArgs ( selectVersion ../tools/misc/hyppocampus "0.3rc1") {
     inherit builderDefs stdenv fetchurl libdbi libdbiDrivers fuse
       pkgconfig perl gettext dbus dbus_glib pcre libscd;
     inherit (gtkLibs) glib;
     bison = bison23;
     flex = flex2533;
-  };*/
+  };
+  */
+
+  idutils = import ../tools/misc/idutils {
+    inherit fetchurl stdenv emacs;
+  };
 
   inetutils = import ../tools/networking/inetutils {
     inherit fetchurl stdenv;
   };
 
+  iodine = import ../tools/networking/iodine {
+    inherit stdenv fetchurl zlib nettools;
+  };
+
   jdiskreport = import ../tools/misc/jdiskreport {
     inherit fetchurl stdenv unzip jdk;
   };
@@ -670,6 +782,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  keychain = import ../tools/misc/keychain {
+    inherit fetchurl stdenv;
+  };
+
   ktorrent = import ../tools/networking/p2p/ktorrent {
     inherit fetchurl stdenv pkgconfig kdelibs
       xlibs zlib libpng libjpeg perl gmp;
@@ -700,27 +816,34 @@ rec {
   };
 
   lsh = import ../tools/networking/lsh {
-    inherit stdenv fetchurl gperf guile gmp zlib liboop gnum4;
+    inherit stdenv fetchurl gperf guile gmp zlib liboop gnum4 pam;
   };
 
   man = import ../tools/misc/man {
-     inherit fetchurl stdenv groff less;
+    inherit fetchurl stdenv groff less;
   };
 
   man_db = import ../tools/misc/man-db {
-     inherit fetchurl stdenv db4 groff;
+    inherit fetchurl stdenv db4 groff;
   };
 
   memtest86 = import ../tools/misc/memtest86 {
-     inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
   mc = import ../tools/misc/mc {
-     inherit fetchurl stdenv pkgconfig ncurses shebangfix perl zip;
-     inherit (gtkLibs) glib;
-     inherit (xlibs) libX11;
+    inherit fetchurl stdenv pkgconfig ncurses shebangfix perl zip;
+    inherit (gtkLibs) glib;
+    inherit (xlibs) libX11;
   };
 
+  mdbtools = builderDefsPackage (selectVersion ../tools/misc/mdbtools "0.6-pre1") {
+    inherit readline pkgconfig;
+    inherit (gtkLibs) glib;
+    bison = bison23;
+    flex = flex2535;
+  } null;
+
   mjpegtools = import ../tools/video/mjpegtools {
     inherit fetchurl stdenv libjpeg;
     inherit (xlibs) libX11;
@@ -730,10 +853,23 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  mpage = import ../tools/text/mpage {
+    inherit fetchurl stdenv;
+  };
+
+  msfFun = builderDefsPackage (selectVersion ../tools/security/metasploit "3.1") {
+    inherit ruby makeWrapper;
+  };
+  msf = msfFun null;
+
   mssys = import ../tools/misc/mssys {
     inherit fetchurl stdenv gettext;
   };
 
+  mysql2pgsql = import ../tools/misc/mysql2pgsql {
+    inherit fetchurl stdenv perl shebangfix;
+  };
+
   nc6Fun = lib.sumArgs (selectVersion ../tools/networking/nc6 "1.0") {
     inherit builderDefs;
   };
@@ -753,15 +889,21 @@ rec {
   };
 
   nmap = import ../tools/security/nmap {
-    inherit fetchurl stdenv libpcap pkgconfig;
-	inherit (xlibs) libX11;
-	inherit (gtkLibs) gtk;
+    inherit fetchurl stdenv libpcap pkgconfig openssl
+      python pygtk makeWrapper pygobject pycairo 
+      pysqlite;
+    inherit (xlibs) libX11;
+    inherit (gtkLibs) gtk;
   };
 
   ntp = import ../tools/networking/ntp {
     inherit fetchurl stdenv libcap;
   };
 
+  nssmdns = import ../tools/networking/nss-mdns {
+    inherit fetchurl stdenv avahi;
+  };
+
   openssh = import ../tools/networking/openssh {
     inherit fetchurl stdenv zlib openssl pam perl;
     pamSupport = true;
@@ -790,6 +932,11 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  pinentry = import ../tools/misc/pinentry {
+    inherit fetchurl stdenv pkgconfig x11;
+    inherit (gnome) glib gtk;
+  };
+
   ploticus = import ../tools/graphics/ploticus {
     inherit fetchurl stdenv zlib libpng;
     inherit (xlibs) libX11;
@@ -808,12 +955,7 @@ rec {
     inherit (xlibs) libX11 libXext;
   };
 
-  realCurl = import ../tools/networking/curl {
-    inherit fetchurl stdenv zlib;
-    zlibSupport = !stdenv ? isDietLibC;
-  };
-
-  relfsFun = lib.sumArgs (selectVersion ../tools/misc/relfs "cvs.2007.12.01") {
+  relfsFun = lib.sumArgs (selectVersion ../tools/misc/relfs "cvs.2008.03.05") {
     inherit fetchcvs stdenv ocaml postgresql fuse pcre
       builderDefs e2fsprogs pkgconfig;
     inherit (gnome) gnomevfs GConf;
@@ -832,6 +974,14 @@ rec {
   };
   */
 
+  rsnapshot = import ../tools/backup/rsnapshot {
+    inherit fetchurl stdenv perl openssh rsync;
+
+    # For the `logger' command, we can use either `utillinux' or
+    # GNU Inetutils.  The latter is more portable.
+    logger = inetutils;
+  };
+
   rlwrapFun = lib.sumArgs (selectVersion ../tools/misc/rlwrap "0.28") {
     inherit builderDefs readline;
   };
@@ -885,11 +1035,9 @@ rec {
 
   smbfsFuse = smbfsFuseFun null;
 
-  socatFun = lib.sumArgs (selectVersion ../tools/networking/socat "1.6.0.0") {
-    inherit builderDefs openssl;
-  };
-
-  socat = socatFun null;
+  socat = builderDefsPackage (selectVersion ../tools/networking/socat "1.6.0.1") {
+    inherit openssl;
+  } null;
 
   sudo = import ../tools/security/sudo {
     inherit fetchurl stdenv coreutils pam;
@@ -956,8 +1104,7 @@ rec {
   };
 
   ttmkfdirFun = import ../tools/misc/ttmkfdir {
-    inherit debPackage freetype fontconfig libunwind
-      libtool;
+    inherit debPackage freetype fontconfig libunwind libtool;
     bison = bison23;
     flex = flex2534;
   };
@@ -1013,6 +1160,12 @@ rec {
     inherit pangoxsl;
   };
 
+  xmlto = import ../tools/typesetting/xmlto {
+    inherit fetchurl stdenv flex libxml2 libxslt
+            docbook_xml_dtd_42 docbook_xsl
+            glibc bash getopt mktemp findutils makeWrapper;
+  };
+
   xmltv = import ../tools/misc/xmltv {
     inherit fetchurl perl perlTermReadKey perlXMLTwig perlXMLWriter
       perlDateManip perlHTMLTree perlHTMLParser perlHTMLTagset
@@ -1087,8 +1240,7 @@ rec {
     };
 
   bigloo = import ../development/compilers/bigloo {
-    inherit fetchurl mkDerivationByConfiguration lib;
-    stdenv = overrideGCC stdenv gcc34;
+    inherit fetchurl stdenv;
   };
 
   dylan = import ../development/compilers/gwydion-dylan {
@@ -1099,8 +1251,13 @@ rec {
       };
   };
 
+  # Essential Haskell Compiler -- nix expression is work in progress
+  ehc = import ../development/compilers/ehc {
+    inherit fetchsvn stdenv coreutils m4 libtool ghc uulib uuagc llvm;
+  };
+
   fpc = import ../development/compilers/fpc {
-    inherit fetchurl stdenv gawk;
+    inherit fetchurl stdenv gawk system;
   };
 
   g77 = import ../build-support/gcc-wrapper {
@@ -1124,7 +1281,7 @@ rec {
       inherit fetchurl stdenv noSysDirs;
       langF77 = true;
       langCC = false;
-	inherit gmp mpfr;
+      inherit gmp mpfr;
     };
     inherit (stdenv.gcc) binutils libc;
     inherit stdenv;
@@ -1139,7 +1296,22 @@ rec {
       langF77 = true;
       langCC = false;
       langC = false;
-	inherit gmp mpfr;
+      inherit gmp mpfr;
+    };
+    inherit (stdenv.gcc) binutils libc;
+    inherit stdenv;
+  };
+ 
+  g77_42 = import ../build-support/gcc-wrapper {
+    name = "g77-4.2";
+    nativeTools = false;
+    nativeLibc = false;
+    gcc = import ../development/compilers/gcc-4.2/fortran.nix {
+      inherit fetchurl stdenv noSysDirs;
+      langF77 = true;
+      langCC = false;
+      langC = false;
+      inherit gmp mpfr;
     };
     inherit (stdenv.gcc) binutils libc;
     inherit stdenv;
@@ -1200,19 +1372,28 @@ rec {
      { ghcPkgUtil = ../development/libraries/haskell/generic/ghcPkgUtil.sh; }
      "mkdir -p $out/nix-support; cp $ghcPkgUtil \$out/nix-support/setup-hook;";
 
-  ghcsAndLibs = 
+  ghcsAndLibs =
     assert builtins ? listToAttrs;
     recurseIntoAttrs (import ../development/compilers/ghcs {
       inherit ghcboot fetchurl stdenv recurseIntoAttrs perl gnum4 gmp readline lib;
-      inherit ghcPkgUtil annotatedDerivations hasktags ctags;
+      inherit ghcPkgUtil hasktags ctags autoconf automake getConfig;
+      inherit (bleedingEdgeRepos) sourceByName;
+
+      # needed for install darcs ghc version
+      happy = ghc68executables.happy;
+      alex = ghc68executables.alex;
     });
 
   # creates ghc-X-wl wich adds the passed libraries to the env var GHC_PACKAGE_PATH
-  createGhcWrapper = { ghcPackagedLibs ? false, ghc, libraries, name, suffix ? "ghc_wrapper_${ghc.name}" } :
-        import ../development/compilers/ghc/createGhcWrapper {
-    inherit stdenv ghcPackagedLibs ghc name suffix libraries ghcPkgUtil
-      annotatedDerivations lib sourceWithTagsDerivation annotatedWithSourceAndTagInfo;
-    installSourceAndTags = true;
+  ghcWrapper = { ghcPackagedLibs ? false, ghc, libraries, name, suffix ? "ghc_wrapper_${ghc.name}" } :
+        import ../development/compilers/ghc/ghc-wrapper {
+    inherit ghcPackagedLibs ghc name suffix libraries ghcPkgUtil
+      lib sourceWithTagsDerivation annotatedWithSourceAndTagInfo 
+      readline ncurses stdenv;
+    inherit sourceWithTagsFromDerivation;
+    #inherit stdenv ghcPackagedLibs ghc name suffix libraries ghcPkgUtil
+    #  annotatedDerivations lib sourceWithTagsDerivation annotatedWithSourceAndTagInfo;
+    installSourceAndTags = getConfig ["haskell" "ghcWrapper" "installSourceAndTags"] false;
   };
 
 
@@ -1223,26 +1404,32 @@ rec {
   # args must contain: src name buildInputs propagatedBuildInputs
   # classic expression style.. seems to work fine
   # used now
-  # goSrc contains source directory (containing the .cabal file)
-  ghcCabalDerivation = args : null_ : with lib; with args;
-    stdenv.mkDerivation ({
-      goSrcDir = "cd ${srcDir}";
-      inherit name src propagatedBuildInputs;
+  # srcDir contains source directory (containing the .cabal file)
+  ghcCabalDerivation = args : with args;
+    let buildInputs =  (if (args ? buildInputs) then args.buildInputs else [])
+                    ++ [ ghcPkgUtil ] ++ ( if args ? pass && args.pass ? buildInputs then args.pass.buildInputs else []);
+        configure = if (args ? useLocalPkgDB) 
+                      then "nix_ghc_pkg_tool join localDb\n" +
+                            "\$CABAL_SETUP configure --package-db=localDb \$profiling \$cabalFlags"
+                      else "\$CABAL_SETUP configure --by-env=\$PACKAGE_DB \$profiling \$cabalFlags";
+    in stdenv.mkDerivation ({
+      srcDir = if (args ? srcDir) then args.srcDir else ".";
+      inherit (args) name src propagatedBuildInputs;
       phases = "unpackPhase patchPhase buildPhase";
-      buildInputs = (if (args ? buildInputs) then args.buildInputs else [])
-                    ++ [ ghcPkgUtil ];
+      profiling = if getConfig [ "ghc68" "profiling" ] false then "-p" else "";
+      cabalFlags = map lib.escapeShellArg 
+                      (getConfig [ "cabal" "flags" ] []
+                       ++ (if args ? cabalFlags then args.cabalFlags else []) );
       # TODO remove echo line
       buildPhase ="
           createEmptyPackageDatabaseAndSetupHook
           export GHC_PACKAGE_PATH
 
-          \$goSrcDir
+          cd \$srcDir
           ghc --make Setup.*hs -o setup
           CABAL_SETUP=./setup
 
-          nix_ghc_pkg_tool join local-pkg-db
-
-          \$CABAL_SETUP configure --package-db=local-pkg-db
+          " + configure +"
           \$CABAL_SETUP build
           \$CABAL_SETUP copy --destdir=\$out
           \$CABAL_SETUP register --gen-script
@@ -1256,152 +1443,50 @@ rec {
 
          echo \"\$propagatedBuildInputs\" > \"\$out/nix-support/propagated-build-inputs\"
       ";
-  } // (subsetmap id args [ "patchPhase" ])); 
-
-  # creates annotated derivation (comments see above
-  annotatedGhcCabalDerivation = args : null_ : with lib; with args;
-  rec {
-    inherit name;
-
-    #aDeps = concatLists ( catAttrs ( subsetmap id args [ "buildInputs" "propagatedBuildInputs" ] ) );
-    aDeps = []; #TODO 
-
-    aDeriv = ghcCabalDerivation (args // (annotatedDerivations.delAnnotationsFromInputs args) ) null;
+  } // ( if args ? pass then (args.pass) else {} ) // { inherit buildInputs; } );
+
+
+  ghcCabalExecutableFun = (import ../development/compilers/ghc/ghc-wrapper/ghc-cabal-executable-fun.nix){ 
+    inherit ghc68extraLibs ghcsAndLibs stdenv lib;
+    # extra packages from this top level file:
+    inherit perl;
+  };
+
+  # creates annotated derivation (comments see above)
+  addHasktagsTaggingInfo = deriv : deriv // {
+      passthru = {
+        sourceWithTags = {
+         inherit (deriv) src;
+         srcDir = if deriv ? srcDir then deriv.srcDir else ".";
+         name = deriv.name + "-src-with-tags";
+         createTagFiles = [
+               { name = "${deriv.name}_haskell";
+                 # tagCmd = "${toString ghcsAndLibs.ghc68.ghc}/bin/hasktags --ignore-close-implementation --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; }
+                 tagCmd = "${toString hasktags}/bin/hasktags-modified --ignore-close-implementation --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; }
+          ];
+       };
+    };
+  };
 
-   # annotation data
+  # this may change in the future
+  ghc68extraLibs = (import ../misc/ghc68extraLibs ) {
+    # lib like stuff
+    inherit bleedingEdgeRepos fetchurl lib addHasktagsTaggingInfo ghcCabalDerivation pkgconfig unzip zlib;
+    # used (non haskell) libraries (ffi etc)
+    inherit postgresql mysql sqlite gtkLibs gnome xlibs freetype getConfig libpng bzip2 pcre;
 
-    sourceWithTags = {
-     inherit src srcDir;
-     name = name + "-src-with-tags";
-     createTagFiles = [
-           { name = "${name}_haskell_tags";
-             # tagCmd = "${toString ghcsAndLibs.ghc68.ghc}/bin/hasktags --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; }
-             tagCmd = "${toString hasktags}/bin/hasktags-modified --ctags `find . -type f -name \"*.*hs\"`; sort tags > \$TAG_FILE"; }
-      ];
-    };
+    executables = ghc68executables;
+    wxGTK = wxGTK26;
   };
 
-  # this will change in the future 
-  # TODO enhance speed ! ?
-  ghc68_extra_libs = ghc: rec {
-      #   name (using lowercase letters everywhere because using installing packages having different capitalization is discouraged) - this way there is not that much to remember?
-
-      cabal_darcs_name = "cabal-darcs";
-
-      # introducing p here to speed things up.
-      # It merges derivations (defined below) and additional inputs. I hope that using as few nix functions as possible results in greates speed?
-      # unfortunately with x; won't work because it forces nix to evaluate all attributes of x which would lead to infinite recursion
-      pkgs = let x = ghc.core_libs // derivations; in {
-          # ghc extra packages 
-          mtl     = { name="mtl-1.1.0.0";     srcDir="libraries/mtl";    p_deps=[ x.base ]; src = ghc.extra_src; };
-          parsec  = { name="parsec-2.1.0.0";  srcDir="libraries/parsec"; p_deps=[ x.base ];       src = ghc.extra_src; };
-          network = { name="network-2.1.0.0"; srcDir="libraries/network"; p_deps=[ x.base x.parsec x.haskell98 ];       src = ghc.extra_src; };
-          regex_base = { name="regex-base-0.72.0.1"; srcDir="libraries/regex-base"; p_deps=[ x.base x.array x.bytestring x.haskell98 ]; src = ghc.extra_src; };
-          regex_posix = { name="regex-posix-0.72.0.2"; srcDir="libraries/regex-posix"; p_deps=[ x.regex_base x.haskell98 ]; src = ghc.extra_src; };
-          regex_compat = { name="regex-compat-0.71.0.1"; srcDir="libraries/regex-compat"; p_deps=[ x.base x.regex_posix x.regex_base x.haskell98 ]; src = ghc.extra_src; };
-          stm = { name="stm-2.1.1.0"; srcDir="libraries/stm"; p_deps=[ x.base x.array ]; src = ghc.extra_src; };
-          hunit = { name="HUnit-1.2.0.0"; srcDir="libraries/HUnit"; p_deps=[ x.base ]; src = ghc.extra_src; };
-          quickcheck = { name="QuickCheck-1.1.0.0"; srcDir="libraries/QuickCheck"; p_deps=[x.base x.random]; src = ghc.extra_src; };
-
-
-          # other pacakges  (hackage etc)
-          binary = rec { name = "binary-0.4.1"; p_deps = [ x.base x.bytestring x.containers x.array ];
-                           src = fetchurl { url = "http://hackage.haskell.org/packages/archive/binary/0.4.1/binary-0.4.1.tar.gz";
-                                        sha256 = "0jg5i1k5fz0xp1piaaf5bzhagqvfl3i73hlpdmgs4gc40r1q4x5v"; };
-                 };
-          # 1.13 is stable. There are more recent non stable versions
-          haxml = rec { name = "HaXml-1.13.3"; p_deps = [ x.base x.rts x.directory x.process x.pretty x.containers x.filepath x.haskell98 ];
-                       src = fetchurl { url = "http://www.haskell.org/HaXml/${name}.tar.gz";
-                                        sha256 = "08d9wy0rg9m66dd10x0zvkl74l25vxdakz7xp3j88s2gd31jp1v0"; };
-                 };
-          xhtml = rec { name = "xhtml-3000.0.2.2"; p_deps = [ x.base ];
-                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/xhtml/3000.0.2.2/xhtml-3000.0.2.2.tar.gz";
-                                        sha256 = "112mbq26ksh7r22y09h0xvm347kba3p4ns12vj5498fqqj333878"; };
-                 };
-          html = rec { name = "html-1.0.1.1"; p_deps = [ x.base ];
-                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/html/1.0.1.1/html-1.0.1.1.tar.gz";
-                                        sha256 = "10fayfm18p83zlkr9ikxlqgnzxg1ckdqaqvz6wp1xj95fy3p6yl1"; };
-                 };
-          crypto = rec { name = "crypto-4.1.0"; p_deps = [ x.base x.array x.pretty x.quickcheck x.random x.hunit ];
-                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/Crypto/4.1.0/Crypto-4.1.0.tar.gz";
-                                        sha256 = "13rbpbn6p1da6qa9m6f7dmkzdkmpnx6jiyyndzaz99nzqlrwi109"; };
-                 };
-          hslogger = rec { name = "hslogger-1.0.4"; p_deps = [ x.containers x.directory x.mtl x.network x.process];
-                       src = fetchurl { url = "http://hackage.haskell.org/packages/archive/hslogger/1.0.4/hslogger-1.0.4.tar.gz";
-                                        sha256 = "0kmz8xs1q41rg2xwk22fadyhxdg5mizhw0r4d74y43akkjwj96ar"; };
-                 };
-          parsep = { name = "parsep-0.1"; p_deps = [ x.base x.mtl x.bytestring ];
-                         src = fetchurl { url = "http://twan.home.fmf.nl/parsep/parsep-0.1.tar.gz";
-                                        sha256 = "1y5pbs5mzaa21127cixsamahlbvmqzyhzpwh6x0nznsgmg2dpc9q"; };
-                         patchPhase = "pwd; sed -i 's/fps/bytestring/' *.cabal";
-                 };
-
-        # HAPPS - Libraries
-          http_darcs = { name="http-darcs"; p_deps = [x.network x.parsec];
-                   src = fetchdarcs { url = "http://darcs.haskell.org/http/"; md5 = "4475f858cf94f4551b77963d08d7257c"; };
-                 };
-          syb_with_class_darcs = { name="syb-with-class-darcs"; p_deps = [x.template_haskell x.bytestring ];
-                   src = fetchdarcs { url = "http://happs.org/HAppS/syb-with-class"; md5 = "b42336907f7bfef8bea73bc36282d6ac"; };
-                 };
-
-        happs_data_darcs = { name="HAppS-Data-darcs"; p_deps=[ x.base x.mtl x.template_haskell x.syb_with_class_darcs x.haxml x.happs_util_darcs x.regex_compat x.bytestring x.pretty ];
-                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-Data"; md5 = "10c505dd687e9dc999cb187090af9ba7"; };
-                    };
-        happs_util_darcs = { name="HAppS-Util-darcs"; p_deps=[ x.base x.mtl x.hslogger x.template_haskell x.array x.bytestring x.old_time x.process x.directory ];
-                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-Util"; md5 = "693cb79017e522031c307ee5e59fc250"; };
-                    };
-        happs_state_darcs = { name="HAppS-State-darcs"; p_deps=[ x.base x.haxml
-                      x.mtl x.network x.stm x.template_haskell x.hslogger
-                        x.happs_util_darcs x.happs_data_darcs x.bytestring x.containers
-                        x.random x.old_time x.old_locale x.unix x.directory x.binary ];
-                      src = fetchdarcs { url = "http://happs.org/repos/HAppS-State"; 
-                                         md5 = "956e5c293b60f4a98148fedc5fa38acc"; 
-                                       };
-                    };
-        happs_plugins_darcs = { name="HAppS-plugins-darcs"; p_deps=[ x.base x.mtl x.hslogger x.happs_util_darcs x.happs_data_darcs x.happs_state_darcs ];
-                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-Util"; md5 = "693cb79017e522031c307ee5e59fc250"; };
-                    };
-        # there is no .cabal yet 
-        #happs_smtp_darcs = { name="HAppS-smtp-darcs"; p_deps=[];
-                    #src = fetchdarcs { url = "http://happs.org/repos/HAppS-smtp"; md5 = "5316917e271ea1ed8ad261080bcb47db"; };
-                    #};
-
-        happs_ixset_darcs = { name="HAppS-IxSet-darcs"; p_deps=[ x.base x.mtl
-                          x.hslogger x.happs_util_darcs x.happs_state_darcs x.happs_data_darcs
-                          x.template_haskell x.syb_with_class_darcs x.containers ];
-                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-IxSet"; 
-                                       #md5 = "fa6b24517f09aa16e972f087430967fd"; 
-                                       #tag = "0.9.2";
-                                        # no tag
-                                       md5 = "fa6b24517f09aa16e972f087430967fd"; 
-                                     };
-                    };
-        happs_server_darcs = { name="HAppS-Server-darcs"; p_deps=[x.haxml x.parsec x.mtl
-                x.network x.regex_compat x.hslogger x.happs_data_darcs
-                  x.happs_util_darcs x.happs_state_darcs x.happs_ixset_darcs x.http_darcs
-                  x.template_haskell x.xhtml x.html x.bytestring x.random
-                  x.containers x.old_time x.old_locale x.directory x.unix];
-                    src = fetchdarcs { url = "http://happs.org/repos/HAppS-HTTP"; md5 = "e1bb17eb30a39d30b8c34dffbf80edc2"; };
-                    };
-        # we need recent version of cabal (because only this supports --pkg-config propably) Thu Feb  7 14:54:07 CET 2008
-        # is be added to buildInputs automatically
-        cabal_darcs = { name=cabal_darcs_name; p_deps = with ghc.core_libs; [base rts directory process pretty containers filepath];
-                  src = fetchdarcs { url = "http://darcs.haskell.org/cabal"; md5 = "8b0bc3c7f2676ce642f98b1568794cd6"; };
-                };
-      };
-      toDerivation = attrs : with attrs;
-      # result is { mtl = <deriv>;
-        annotatedGhcCabalDerivation ({
-            inherit name src;
-            propagatedBuildInputs = p_deps ++ (lib.optional (attrs.name != cabal_darcs_name) derivations.cabal_darcs );
-            srcDir = if attrs ? srcDir then attrs.srcDir else ".";
-            patches = if attrs ? patches then attrs.patches else [];
-            # add cabal, take deps either from this list or from ghc.core_libs 
-        }//( lib.subsetmap lib.id attrs [ "patchPhase" ] )) null;
-      derivations = with lib; builtins.listToAttrs (lib.concatLists ( lib.mapRecordFlatten 
-                ( n : attrs : let d = (toDerivation attrs); in [ (nv n d) (nv attrs.name d) ] ) pkgs ) );
-    }.derivations;
 
+  # Executables compiled by this ghc68 - I'm too lazy to add them all as additional file in here
+  ghc68executables = recurseIntoAttrs (import ../misc/ghc68executables {
+    inherit ghcCabalExecutableFun fetchurl lib bleedingEdgeRepos autoconf zlib getConfig;
+    inherit X11;
+    inherit (xlibs) xmessage;
+    inherit pkgs; # passing pkgs to add the possibility for the user to add his own executables. pkgs is passed. 
+  });
 
   # the wrappers basically does one thing: It defines GHC_PACKAGE_PATH before calling ghc{i,-pkg}
   # So you can have different wrappers with different library combinations
@@ -1411,28 +1496,18 @@ rec {
   # .hi and .o files, right?
   ghcLibraryWrapper68 = 
     let ghc = ghcsAndLibs.ghc68.ghc; in
-    createGhcWrapper rec {
+    ghcWrapper rec {
       ghcPackagedLibs = true;
       name = "ghc${ghc.version}_wrapper";
       suffix = "${ghc.version}wrapper";
-      libraries = # map ( a : __getAttr a (ghc68_extra_libs ghcsAndLibs.ghc68 ) ) [ "mtl" ];
+      libraries = 
         # core_libs  distributed with this ghc version
-        #(lib.flattenAttrs ghcsAndLibs.ghc68.core_libs)
-          map ( a : __getAttr a ghcsAndLibs.ghc68.core_libs ) [ 
-            "cabal" "array" "base" "bytestring" "containers" "containers" "directory"
-            "filepath" "ghc-${ghc.version}" "haskell98" "hpc" "old_locale" "old_time"
-            "old_time" "packedstring" "pretty" "process" "random" "readline" "rts"
-            "template_haskell" "unix" "template_haskell" ]
-        # some extra libs
+        (lib.flattenAttrs ghcsAndLibs.ghc68.core_libs)
+        # (map ( a : __getAttr a ghcsAndLibs.ghc68.core_libs ) [ "cabal" "mtl" "base"  ]
 
-           ++  (lib.flattenAttrs (ghc68_extra_libs ghcsAndLibs.ghc68) );
-        # or specify the ones you want to install using this list (possible values see attributes in ghc68_extra_libs
-           #++ map ( a : __getAttr a (ghc68_extra_libs ghcsAndLibs.ghc68 ) )
-           #[ "mtl" "parsec" "cabal_darcs" "haxml" "network" "regex_base"
-           #"regex_compat" "regex_posix" "stm" "hunit" "quickcheck" "crypto"
-           #"hslogger" "http_darcs" "syb_with_class_darcs"
-           #];
-        # some additional libs
+        # some extra libs
+           ++  (lib.flattenAttrs (ghc68extraLibs ghcsAndLibs.ghc68) );
+        # ++ map ( a : __getAttr a (ghc68extraLibs ghcsAndLibs.ghc68 ) ) [ "mtl" "parsec" ... ]
       inherit ghc;
   };
 
@@ -1444,20 +1519,22 @@ rec {
   ghc = ghc68;
 
   ghc68 = import ../development/compilers/ghc-6.8 {
-    inherit fetchurl stdenv readline perl gmp ncurses;
-    m4 = gnum4;
+    inherit fetchurl stdenv readline perl gmp ncurses m4;
+    ghc = ghcboot;
+  };
+
+  ghc683snapshot = import ../development/compilers/ghc-6.8/snapshot.nix {
+    inherit fetchurl stdenv readline perl gmp ncurses m4;
     ghc = ghcboot;
   };
 
   ghc661 = import ../development/compilers/ghc-6.6.1 {
-    inherit fetchurl stdenv readline perl58 gmp ncurses;
-    m4 = gnum4;
+    inherit fetchurl stdenv readline perl58 gmp ncurses m4;
     ghc = ghcboot;
   };
 
   ghc66 = import ../development/compilers/ghc-6.6 {
-    inherit fetchurl stdenv readline perl gmp ncurses;
-    m4 = gnum4;
+    inherit fetchurl stdenv readline perl gmp ncurses m4;
     ghc = ghcboot;
   };
 
@@ -1492,6 +1569,11 @@ rec {
     inherit fetchurl stdenv ghc;
   };
 
+  ikarusFun = builderDefsPackage (selectVersion ../development/compilers/ikarus "0.0.3") {
+    inherit gmp;
+  };
+  ikarus = ikarusFun null;
+
   javafront = import ../development/compilers/java-front {
     inherit stdenv fetchurl pkgconfig;
     sdf = sdf24;
@@ -1539,6 +1621,25 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  lazarusFun = builderDefsPackage (import ../development/compilers/fpc/lazarus.nix) {
+    inherit fpc makeWrapper;
+    inherit (gtkLibs1x) gtk glib gdkpixbuf;
+    inherit (xlibs) libXi inputproto libX11 xproto libXext xextproto;
+  };
+  lazarus = lazarusFun null;
+
+  llvm = import ../development/compilers/llvm {
+    inherit fetchurl stdenv gcc flex perl libtool;
+  };
+
+  llvmGccFun = builderDefsPackage (import ../development/compilers/llvm/llvm-gcc.nix) {
+    flex=flex2535;
+    bison=bison23;
+    inherit llvm perl libtool;
+  };
+
+  llvmGCC =llvmGccFun null;
+
   mono = import ../development/compilers/mono {
     inherit fetchurl stdenv bison pkgconfig;
     inherit (gtkLibs) glib;
@@ -1552,6 +1653,18 @@ rec {
     inherit stdenv fetchurl boost zlib;
   };
 
+  monotoneViz = builderDefsPackage (selectVersion ../applications/version-management/monotone-viz "1.0.1") {
+    inherit ocaml lablgtk graphviz pkgconfig;
+    inherit (gnome) gtk libgnomecanvas glib;
+  } null;
+
+  viewMtn = builderDefsPackage (selectVersion ../applications/version-management/viewmtn "0.10")
+  {
+    inherit monotone flup cheetahTemplate highlight ctags 
+      makeWrapper graphviz which;
+    python = python25;
+  } null;
+
   nasm = import ../development/compilers/nasm {
     inherit fetchurl stdenv;
   };
@@ -1562,7 +1675,7 @@ rec {
     inherit fetchurl stdenv x11 ncurses;
   };
 
-/*
+  /*
   gcj = import ../build-support/gcc-wrapper/default2.nix {
     name = "gcj";
     nativeTools = false;
@@ -1577,7 +1690,7 @@ rec {
     inherit (stdenv.gcc) binutils libc;
     inherit stdenv;
   };
-*/
+  */
 
   opencxx = import ../development/compilers/opencxx {
     inherit fetchurl stdenv libtool;
@@ -1594,9 +1707,17 @@ rec {
     inherit fetchurl stdenv flex bison mkDerivationByConfiguration bigloo lib curl;
     # optional features
     # all features pcre, fcgi xml mysql, sqlite3, (not implemented: odbc gtk gtk2)
-    flags = ["pcre" "fcgi" "xml" "mysql"];
-    inherit mysql;
-    inherit libxml2;
+    flags = ["pcre" "xml" "mysql"];
+    inherit mysql libxml2 fcgi;
+  };
+
+  scala = import ../development/compilers/scala {
+    inherit stdenv fetchurl;
+  };
+
+  stalin = import ../development/compilers/stalin {
+    inherit stdenv fetchurl;
+    inherit (xlibs) libX11;
   };
 
   strategoLibraries = import ../development/compilers/strategoxt/libraries/stratego-libraries-0.17pre.nix {
@@ -1619,6 +1740,12 @@ rec {
     inherit fetchurl pkgconfig stdenv aterm sdf strategoxt;
   };
 
+  swiPrologFun = lib.sumArgs (selectVersion ../development/compilers/swi-prolog "5.6.51") {
+    inherit fetchurl stdenv;
+  };
+
+  swiProlog = swiPrologFun null;
+
   transformers = import ../development/compilers/transformers {
     inherit fetchurl pkgconfig sdf;
     aterm = aterm23x;
@@ -1672,13 +1799,18 @@ rec {
     inherit stdenv binutils;
   };
 
+  # prolog
+  yap = import ../development/compilers/yap {
+    inherit fetchurl stdenv;
+  };
 
+  
   ### DEVELOPMENT / INTERPRETERS
 
 
   clisp = import ../development/interpreters/clisp {
     inherit fetchurl stdenv libsigsegv gettext 
-	readline ncurses coreutils pcre zlib;
+      readline ncurses coreutils pcre zlib;
     inherit (xlibs) libX11 libXau libXt;
   };
 
@@ -1687,7 +1819,7 @@ rec {
   };
 
   guile = import ../development/interpreters/guile {
-    inherit fetchurl stdenv ncurses readline libtool gmp gawk makeWrapper;
+    inherit fetchurl stdenv readline libtool gmp gawk makeWrapper;
   };
 
   kaffe =  import ../development/interpreters/kaffe {
@@ -1704,7 +1836,7 @@ rec {
 
   octave = import ../development/interpreters/octave {
     inherit stdenv fetchurl readline ncurses perl flex;
-	g77 = g77_41;
+    g77 = g77_42;
   };
 
   perl = if !stdenv.isLinux then sysPerl else realPerl;
@@ -1720,33 +1852,43 @@ rec {
       if stdenv.isDarwin then null else unixODBC;
   };
 
-  # FIXME somehow somewhen: We need to recompile php if the ini file changes because the only way to
-  # tell the apache module where to look for this file is using a compile time flag ;-(
-  # perhaps this can be done setting php_value in apache don't have time to investigate any further ?
-  # This expression is a quick hack now. But perhaps it helps you adding the configuration flags you need?
-  php = php_unstable;
-
-  # compiling without xdebug is currenlty broken (should be easy to fix though 
-  php_unstable = (import ../development/interpreters/php_configurable) {
-   inherit stdenv mkDerivationByConfiguration autoconf automake lib;
-   # optional features
-   inherit fetchurl flex bison apacheHttpd mysql libxml2; # gettext;
-   inherit zlib;
-   flags = [ "xdebug" "mysql" "mysqli" "pdo_mysql" "libxml2" "apxs2" ];
+  php = import ../development/interpreters/php_configurable {
+    inherit
+      stdenv fetchurl lib mkDerivationByConfiguration autoconf automake
+      flex bison apacheHttpd mysql libxml2 # gettext
+      zlib curl gd postgresql;
+    flags = [
+      "xdebug" "mysql" "mysqli" "pdo_mysql" "libxml2" "apxs2" "curl"
+      "postgresql" "bcmath" "gd"
+    ];
   };
 
-  python = getVersion "python" python_alts;
+  python = python24;
 
-  python_alts = import ../development/interpreters/python {
+  python24 = import ../development/interpreters/python/2.4 {
     inherit fetchurl stdenv zlib bzip2;
   };
 
-  pyrexFun = lib.sumArgs (selectVersion ../development/interpreters/pyrex "0.9.6") {
-    inherit fetchurl stdenv stringsWithDeps lib builderDefs;
-	python = builtins.getAttr "2.5" python_alts;
+  python25Fun = lib.sumArgs (import ../development/interpreters/python/2.5) {
+    inherit fetchurl stdenv zlib bzip2 gdbm;
   };
+  
+  python25 = python25Fun {
+    db4 = if getConfig ["python" "db4Support"] false then db4 else null;
+    sqlite = if getConfig ["python" "sqlite"] false then sqlite else null;
+    readline = if getConfig ["python" "readlineSupport"] false then readline else null;
+    openssl = if getConfig ["python" "opensslSupport"] false then openssl else null;
+  } null;
+
+  pyrex = pyrex095;
 
-  pyrex = pyrexFun null;
+  pyrex095 = import ../development/interpreters/pyrex/0.9.5.nix {
+    inherit fetchurl stdenv stringsWithDeps lib builderDefs python;
+  };
+
+  pyrex096 = import ../development/interpreters/pyrex/0.9.6.nix {
+    inherit fetchurl stdenv stringsWithDeps lib builderDefs python;
+  };
 
   QiFun = lib.sumArgs (selectVersion ../development/compilers/qi "9.1") {
     inherit clisp stdenv fetchurl builderDefs unzip;
@@ -1755,13 +1897,24 @@ rec {
   Qi = QiFun null;
 
   realPerl = import ../development/interpreters/perl-5.10 {
-    inherit fetchurl stdenv;
+    fetchurl = fetchurlBoot;
+    inherit stdenv;
   };
 
   ruby = import ../development/interpreters/ruby {
-    inherit fetchurl stdenv readline ncurses;
+    inherit fetchurl stdenv readline ncurses zlib lib openssl;
+  };
+
+  rLang = import ../development/interpreters/r-lang {
+    inherit fetchurl stdenv readline perl g77_42 libpng zlib;
+		inherit (xorg) libX11 libXt;
   };
 
+  rubygemsFun = builderDefsPackage (import ../development/interpreters/ruby/gems.nix) {
+    inherit ruby makeWrapper;
+  };
+  rubygems = rubygemsFun null;
+
   spidermonkey = import ../development/interpreters/spidermonkey {
     inherit fetchurl stdenv readline;
   };
@@ -1796,6 +1949,10 @@ rec {
   };
   */
 
+  bleedingEdgeRepos = import ../development/misc/bleeding-edge-repos { 
+    inherit getConfig fetchdarcs2 fetchurl; 
+  };
+
   ecj = import ../development/eclipse/ecj {
     inherit fetchurl stdenv unzip jre ant;
   };
@@ -1805,7 +1962,7 @@ rec {
   };
 
   guileLib = import ../development/guile-modules/guile-lib {
-    inherit fetchurl stdenv guile;
+    inherit fetchurl stdenv guile texinfo;
   };
 
   windowssdk = import ../development/misc/windows-sdk {
@@ -1892,10 +2049,18 @@ rec {
     inherit fetchurl stdenv replace;
   };
 
+  cproto = import ../development/tools/misc/cproto {
+    inherit fetchurl stdenv flex bison;
+  };
+
+  dejagnu = import ../development/tools/misc/dejagnu {
+    inherit fetchurl stdenv expect makeWrapper;
+  };
+
   elfutilsFun = lib.sumArgs 
     (selectVersion ../development/tools/misc/elfutils "0.131") {
       inherit fetchurl stdenv;
-  };
+    };
 
   elfutils = elfutilsFun null;
 
@@ -1913,6 +2078,10 @@ rec {
 
   flex = flex254a;
 
+  flex2535 = import ../development/tools/parsing/flex/flex-2.5.35.nix {
+    inherit fetchurl stdenv yacc m4;
+  };
+
   flex2534 = import ../development/tools/parsing/flex/flex-2.5.34.nix {
     inherit fetchurl stdenv yacc m4;
   };
@@ -1952,13 +2121,26 @@ rec {
     inherit cabal;
   };
 
+  hsc2hs = import ../development/tools/misc/hsc2hs {
+    inherit bleedingEdgeRepos stdenv;
+    ghc = ghcsAndLibs.ghc68.ghc;
+    libs = with (ghc68extraLibs ghcsAndLibs.ghc68 // ghcsAndLibs.ghc68.core_libs); [ base directory process cabal_darcs ];
+  };
+
   guileLint = import ../development/tools/guile/guile-lint {
     inherit fetchurl stdenv guile;
   };
 
-  # happy = import ../development/tools/parsing/happy {
-  #   inherit fetchurl stdenv perl ghc;
-  # };
+  gwrap = import ../development/tools/guile/g-wrap {
+    inherit fetchurl stdenv guile libffi pkgconfig guileLib;
+    inherit (gtkLibs) glib;
+  };
+
+  /*
+  happy = import ../development/tools/parsing/happy {
+    inherit fetchurl stdenv perl ghc;
+  };
+  */
 
   happy = import ../development/tools/parsing/happy/happy-1.17.nix {
     inherit cabal perl;
@@ -2006,8 +2188,8 @@ rec {
   };
 
   ltraceFun = lib.sumArgs (selectVersion ../development/tools/misc/ltrace "0.5-3deb") {
-  	inherit fetchurl stdenv builderDefs stringsWithDeps lib;
-	elfutils = elfutilsFun {version = "0.127";} null;
+    inherit fetchurl stdenv builderDefs stringsWithDeps lib;
+    elfutils = elfutilsFun {version = "0.127";} null;
   };
 
   ltrace = ltraceFun null;
@@ -2020,11 +2202,20 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  oprofile = import ../development/tools/profiling/oprofile {
+    inherit fetchurl stdenv binutils popt;
+    inherit makeWrapper gawk which gnugrep;
+  };
+
   patchelf = useFromStdenv "patchelf"
     (import ../development/tools/misc/patchelf {
       inherit fetchurl stdenv;
     });
 
+  pmccabe = import ../development/tools/misc/pmccabe {
+    inherit fetchurl stdenv;
+  };
+
   /**
    * pkgconfig is optionally taken from the stdenv to allow bootstrapping
    * of glib and pkgconfig itself on MinGW.
@@ -2076,6 +2267,12 @@ rec {
     javaSupport = true;
   }));
 
+  sysprof = import ../development/tools/profiling/sysprof {
+    kernel = kernel_2_6_23; # FIXME: Allow the choice of a kernel
+    inherit fetchurl stdenv binutils pkgconfig;
+    inherit (gnome) gtk glib pango libglade;
+  };
+
   texinfo49 = import ../development/tools/misc/texinfo/4.9.nix {
     inherit fetchurl stdenv ncurses;
   };
@@ -2097,9 +2294,18 @@ rec {
   };
 
   valgrind = import ../development/tools/analysis/valgrind {
-    inherit fetchurl stdenv;
+    inherit fetchurl stdenv perl gdb;
   };
 
+  xxdiff = builderDefsPackage (selectVersion ../development/tools/misc/xxdiff "3.2") {
+    bison = bison23;
+    flex = flex2535;
+    qt = qt3;
+    python = python25;
+    inherit pkgconfig makeWrapper;
+    inherit (xlibs) libXext libX11;
+  } null;
+
   yacc = bison;
 
 
@@ -2119,11 +2325,10 @@ rec {
       inherit stdenv fetchurl gettext attr libtool;
     });
 
-  /*
   agg = import ../development/libraries/agg {
-    inherit fetchurl stdenv autoconf automake libtool pkgconfig;
+    inherit fetchurl stdenv autoconf automake libtool pkgconfig
+            freetype SDL;
   };
-  */
 
   apr = import ../development/libraries/apr {
     inherit fetchurl stdenv;
@@ -2175,6 +2380,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  babl = import ../development/libraries/babl {
+    inherit fetchurl stdenv;
+  };
+
   beecrypt = import ../development/libraries/beecrypt {
     inherit fetchurl stdenv m4;
   };
@@ -2231,7 +2440,7 @@ rec {
   };
 
   cppunit = import ../development/libraries/cppunit {
-	  inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
   cracklib = import ../development/libraries/cracklib {
@@ -2239,7 +2448,7 @@ rec {
   };
 
   cyrus_sasl = import ../development/libraries/cyrus-sasl {
-	  inherit fetchurl stdenv openssl db4 gettext;
+    inherit fetchurl stdenv openssl db4 gettext;
   };
 
   db4 = db45;
@@ -2274,12 +2483,12 @@ rec {
   };
 
   enchant = selectVersion ../development/libraries/enchant "1.3.0" {
-	  inherit fetchurl stdenv aspell pkgconfig;
-	  inherit (gnome) glib;
+    inherit fetchurl stdenv aspell pkgconfig;
+    inherit (gnome) glib;
   };
 
   exiv2 = import ../development/libraries/exiv2 {
-	  inherit fetchurl stdenv zlib;
+    inherit fetchurl stdenv zlib;
   };
 
   expat = import ../development/libraries/expat {
@@ -2341,8 +2550,22 @@ rec {
   fam = gamin;
 
   gamin = import ../development/libraries/gamin {
-	  inherit fetchurl stdenv python pkgconfig;
-	  inherit (gtkLibs) glib;
+    inherit fetchurl stdenv python pkgconfig;
+    inherit (gtkLibs) glib;
+  };
+
+  gdbm = import ../development/libraries/gdbm {
+    inherit fetchurl stdenv;
+  };
+
+  gegl = import ../development/libraries/gegl {
+    inherit fetchurl stdenv libpng pkgconfig babl;
+    # optional gtk+
+    glib = glib214;
+    openexr = openexr_1_6_1;
+    #  avocodec avformat librsvg
+    inherit cairo libjpeg librsvg;
+    inherit (gtkLibs) pango;
   };
 
   geos = import ../development/libraries/geos {
@@ -2376,6 +2599,12 @@ rec {
     inherit (xlibs) libXmu libXi;
   };
 
+  # don't know wether this newer version breaks anything..
+  # not replacing the existing one.
+  glib214 = import ../development/libraries/glib {
+    inherit fetchurl stdenv pkgconfig gettext;
+  };
+
   glibc = useFromStdenv "glibc"
     (import ../development/libraries/glibc-2.7 {
       inherit fetchurl stdenv kernelHeaders;
@@ -2387,6 +2616,10 @@ rec {
     inherit (gtkLibs) glib;
   };
 
+  gmm = import ../development/libraries/gmm {
+    inherit fetchurl stdenv;
+  }; 
+
   gmp = import ../development/libraries/gmp {
     inherit fetchurl stdenv m4;
   };
@@ -2412,7 +2645,8 @@ rec {
   };
 
   gnutls = import ../development/libraries/gnutls {
-    inherit fetchurl stdenv libgcrypt zlib lzo;
+    inherit fetchurl stdenv libgcrypt zlib lzo guile;
+    guileBindings = getConfig ["gnutls" "guile"] false;
   };
 
   gpgme = import ../development/libraries/gpgme {
@@ -2481,7 +2715,7 @@ rec {
   kerberos = heimdal;
 
   heimdal = import ../development/libraries/kerberos/heimdal.nix {
-	  inherit fetchurl stdenv readline db4 openssl openldap cyrus_sasl;
+    inherit fetchurl stdenv readline db4 openssl openldap cyrus_sasl;
   };
 
   hsqldb = import ../development/libraries/java/hsqldb {
@@ -2501,7 +2735,7 @@ rec {
   };
 
   ilmbase = import ../development/libraries/ilmbase {
-	  inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
   imlib = import ../development/libraries/imlib {
@@ -2514,7 +2748,7 @@ rec {
   };
 
   indilib = import ../development/libraries/indilib {
-	  inherit fetchurl stdenv cfitsio libusb zlib;
+    inherit fetchurl stdenv cfitsio libusb zlib;
   };
 
   iniparser = import ../development/libraries/iniparser {
@@ -2529,13 +2763,14 @@ rec {
   intltool = intltoolFun null;
 
   jasper = import ../development/libraries/jasper {
-	  inherit fetchurl stdenv unzip libjpeg freeglut mesa;
-	  inherit (xlibs) xproto libX11 libICE libXmu libXi libXext libXt;
+    inherit fetchurl stdenv unzip libjpeg freeglut mesa;
+    inherit (xlibs) xproto libX11 libICE libXmu libXi libXext libXt;
   };
 
   lablgtk = import ../development/libraries/lablgtk {
     inherit fetchurl stdenv ocaml pkgconfig;
     inherit (gtkLibs) gtk;
+    inherit (gnome) libgnomecanvas;
   };
 
   lcms = import ../development/libraries/lcms {
@@ -2547,6 +2782,10 @@ rec {
     inherit (xlibs) libXp libXau;
   };
 
+  lib3ds = import ../development/libraries/lib3ds {
+    inherit fetchurl stdenv unzip;
+  }; 
+
   libaal = import ../development/libraries/libaal {
     inherit fetchurl stdenv;
   };
@@ -2641,6 +2880,10 @@ rec {
 
   libextractor = libextractorFun null;
 
+  libffi = import ../development/libraries/libffi {
+    inherit fetchurl stdenv;
+  };
+
   libgcrypt = import ../development/libraries/libgcrypt {
     inherit fetchurl stdenv libgpgerror;
   };
@@ -2653,14 +2896,17 @@ rec {
     inherit fetchurl stdenv pkgconfig libusb libtool libexif libjpeg gettext;
   };
 
-  # commented out because it's using the new configuration style proposal which is unstable
-  libsamplerate = if builtins ? listToAttrs then (import ../development/libraries/libsamplerate) {
+  libQGLViewer = import ../development/libraries/libqglviewer {
+    inherit fetchurl stdenv;
+    inherit qt4;
+  };
+
+  libsamplerate = import ../development/libraries/libsamplerate {
     inherit fetchurl stdenv mkDerivationByConfiguration pkgconfig lib;
-  } else null;
+  };
 
   libgsf = import ../development/libraries/libgsf {
-    inherit fetchurl stdenv perl perlXMLParser pkgconfig libxml2 gettext bzip2
-	python;
+    inherit fetchurl stdenv perl perlXMLParser pkgconfig libxml2 gettext bzip2 python;
     inherit (gnome) glib gnomevfs libbonobo;
   };
 
@@ -2669,7 +2915,7 @@ rec {
   };
 
   libidn = import ../development/libraries/libidn {
-	  inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
   libiec61883 = import ../development/libraries/libiec61883 {
@@ -2701,6 +2947,10 @@ rec {
     inherit fetchurl stdenv pkgconfig libmowgli;
   };
 
+  libmicrohttpd = import ../development/libraries/libmicrohttpd {
+    inherit fetchurl stdenv curl;
+  };
+
   libmowgli = import ../development/libraries/libmowgli {
     inherit fetchurl stdenv;
   };
@@ -2722,8 +2972,9 @@ rec {
   };
 
   liboilFun = lib.sumArgs
-    (selectVersion ../development/libraries/liboil "0.3.12") {
+    (selectVersion ../development/libraries/liboil "0.3.13") {
     inherit fetchurl stdenv pkgconfig;
+    inherit (gtkLibs) glib;
   };
 
   liboil = liboilFun null;
@@ -2796,7 +3047,7 @@ rec {
 
   libwmf = import ../development/libraries/libwmf {
     inherit fetchurl stdenv pkgconfig imagemagick 
-	zlib libpng freetype libjpeg libxml2;
+      zlib libpng freetype libjpeg libxml2;
     inherit (gtkLibs) glib;
   };
 
@@ -2829,30 +3080,25 @@ rec {
     inherit fetchurl stdenv libxml2;
   };
 
-  libixp03 = import ../development/libraries/libixp/libixp-0.3.nix {
-    inherit fetchurl stdenv;
-  };
-
   libixp_for_wmii = lowPrio (import ../development/libraries/libixp_for_wmii {
     inherit fetchurl stdenv;
-    includeUnpack = getConfig ["stdenv" "includeUnpack"] false;
   });
 
   libzip = import ../development/libraries/libzip {
-	  inherit fetchurl stdenv zlib;
+    inherit fetchurl stdenv zlib;
   };
 
   log4cxx = import ../development/libraries/log4cxx {
-	  inherit fetchurl stdenv automake autoconf libtool cppunit libxml2 boost;
+    inherit fetchurl stdenv automake autoconf libtool cppunit libxml2 boost;
   };
 
   loudmouth = import ../development/libraries/loudmouth {
-	  inherit fetchurl stdenv libidn gnutls pkgconfig;
-	  inherit (gtkLibs) glib;
+    inherit fetchurl stdenv libidn gnutls pkgconfig;
+    inherit (gtkLibs) glib;
   };
 
   lzo = import ../development/libraries/lzo {
-	  inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
   # failed to build
@@ -2890,10 +3136,6 @@ rec {
     inherit fetchurl stdenv python;
   };
 
-  mysqlConnectorODBC = import ../development/libraries/mysql-connector-odbc {
-    inherit fetchurl stdenv mysql libtool zlib unixODBC;
-  };
-
   ncursesFun = lib.sumArgs (import ../development/libraries/ncurses) {
     inherit fetchurl stdenv;
     unicode = (system != "i686-cygwin");
@@ -2926,7 +3168,7 @@ rec {
   };
 
   openbabel = import ../development/libraries/openbabel {
-	  inherit fetchurl stdenv zlib libxml2;
+    inherit fetchurl stdenv zlib libxml2;
   };
 
   # this ctl version is needed by openexr_viewers
@@ -2936,14 +3178,15 @@ rec {
   };
 
   openexr_1_6_1 = import ../development/libraries/openexr {
-	  inherit fetchurl stdenv ilmbase zlib pkgconfig lib;
+    inherit fetchurl stdenv ilmbase zlib pkgconfig lib;
           version = "1.6.1";
           # optional features:
           inherit ctl;
   };
+  
   # This older version is needed by blender (it complains about missing half.h )
   openexr_1_4_0 = import ../development/libraries/openexr {
-	  inherit fetchurl stdenv ilmbase zlib pkgconfig lib;
+    inherit fetchurl stdenv ilmbase zlib pkgconfig lib;
           version = "1.4.0";
   };
 
@@ -2952,7 +3195,8 @@ rec {
   };
 
   openssl = import ../development/libraries/openssl {
-    inherit fetchurl stdenv perl;
+    fetchurl = fetchurlBoot;
+    inherit stdenv perl;
   };
 
   ortp = selectVersion ../development/libraries/ortp "0.13.1" {
@@ -2983,13 +3227,12 @@ rec {
     inherit fetchurl stdenv gettext libtool autoconf automake;
   };
 
-
   proj = import ../development/libraries/proj.4 {
     inherit fetchurl stdenv;
   };
 
   pth = import ../development/libraries/pth {
-	  inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
   qt3 = import ../development/libraries/qt-3 {
@@ -3000,16 +3243,13 @@ rec {
     mysqlSupport = getConfig ["qt" "mysql"] false;
   };
 
-  qt4 = getVersion "qt4" qt4_alts;
-  qt4_alts = import ../development/libraries/qt-4 {
+  qt4 = import ../development/libraries/qt-4 {
     inherit fetchurl stdenv fetchsvn zlib libjpeg libpng which mysql mesa openssl cups dbus
-	  fontconfig freetype pkgconfig libtiff;
+    fontconfig freetype pkgconfig libtiff;
     inherit (xlibs) xextproto libXft libXrender libXrandr randrproto
-	  libXmu libXinerama xineramaproto libXcursor libICE libSM libX11 libXext
-	  inputproto fixesproto libXfixes;
+    libXmu libXinerama xineramaproto libXcursor libICE libSM libX11 libXext
+    inputproto fixesproto libXfixes;
     inherit (gnome) glib;
-    openglSupport = mesaSupported;
-    mysqlSupport = true;
   };
 
   readline = readline5;
@@ -3022,7 +3262,7 @@ rec {
     inherit fetchurl stdenv ncurses;
   };
 
-# Also known as librdf, includes raptor and rasqal
+  # Also known as librdf, includes raptor and rasqal
   redland = import ../development/libraries/redland {
     inherit fetchurl stdenv openssl libxml2 pkgconfig perl postgresql sqlite
       mysql libxslt curl pcre;
@@ -3033,6 +3273,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  schroedinger = import ../development/libraries/schroedinger {
+    inherit fetchurl stdenv liboil pkgconfig;
+  };
+
   SDL = import ../development/libraries/SDL {
     inherit fetchurl stdenv x11 mesa alsaLib;
     inherit (xlibs) libXrandr;
@@ -3080,7 +3324,7 @@ rec {
 
   tapioca_qt = import ../development/libraries/tapioca-qt {
     inherit fetchsvn stdenv cmake telepathy_qt;
-	qt = qt4;
+    qt = qt4;
   };
 
   telepathy_gabble = import ../development/libraries/telepathy-gabble {
@@ -3089,12 +3333,12 @@ rec {
 
   telepathy_glib = import ../development/libraries/telepathy-glib {
     inherit fetchurl stdenv dbus_glib pkgconfig libxslt python;
-	inherit (gtkLibs) glib;
+    inherit (gtkLibs) glib;
   };
 
   telepathy_qt = import ../development/libraries/telepathy-qt {
     inherit fetchsvn stdenv cmake;
-	qt = qt4;
+    qt = qt4;
   };
 
   tkFun = lib.sumArgs (selectVersion ../development/libraries/tk "8.4.16") {
@@ -3107,6 +3351,11 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  unixODBCDrivers = recurseIntoAttrs (import ../development/libraries/unixODBCDrivers {
+    inherit fetchurl stdenv unixODBC glibc libtool openssl zlib;
+    inherit postgresql mysql sqlite;
+  });
+
   wxGTK = wxGTK26;
 
   wxGTK26 = import ../development/libraries/wxGTK-2.6 {
@@ -3125,6 +3374,10 @@ rec {
 
   wxGTK28 = wxGTK28deps null;
 
+  x264 = import ../development/libraries/x264 {
+    inherit fetchurl stdenv;
+  };
+
   Xaw3d = import ../development/libraries/Xaw3d {
     inherit fetchurl stdenv x11 bison;
     flex = flex2533;
@@ -3132,8 +3385,8 @@ rec {
   };
 
   xineLib = import ../development/libraries/xine-lib {
-	inherit fetchurl stdenv zlib x11 libdvdcss alsaLib pkgconfig mesa aalib SDL
-	  libvorbis libtheora speex;
+    inherit fetchurl stdenv zlib x11 libdvdcss alsaLib pkgconfig mesa aalib SDL
+      libvorbis libtheora speex;
     inherit (xlibs) libXv libXinerama;
   };
 
@@ -3147,7 +3400,8 @@ rec {
   };
 
   zlib = import ../development/libraries/zlib {
-    inherit fetchurl stdenv;
+    fetchurl = fetchurlBoot;
+    inherit stdenv;
   };
 
   zlibStatic = lowPrio (appendToName "static" (import ../development/libraries/zlib {
@@ -3272,6 +3526,7 @@ rec {
     inherit stdenv fetchurl;
     ghc = ghc68;
   };
+  
   cabal = cabal68;
 
   Crypto = import ../development/libraries/haskell/Crypto {
@@ -3307,10 +3562,12 @@ rec {
     inherit stdenv fetchurl unzip wxGTK ghc;
   };
 
-  # wxHaskell68 = lowPrio (appendToName "ghc68" (import ../development/libraries/haskell/wxHaskell {
-  #   inherit stdenv fetchurl unzip wxGTK;
-  #   ghc = ghc68;
-  # }));
+  /*
+  wxHaskell68 = lowPrio (appendToName "ghc68" (import ../development/libraries/haskell/wxHaskell {
+    inherit stdenv fetchurl unzip wxGTK;
+    ghc = ghc68;
+  }));
+  */
 
   X11 = import ../development/libraries/haskell/X11 {
     inherit cabal;
@@ -3326,9 +3583,38 @@ rec {
     inherit cabal zlib;
   };
 
+  
   ### DEVELOPMENT / PERL MODULES
 
 
+  perlAlgorithmAnnotate = import ../development/perl-modules/generic perl {
+    name = "Algorithm-Annotate-0.10";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/Algorithm-Annotate-0.10.tar.gz;
+      sha256 = "1y92k4nqkscfwpriv8q7c90rjfj85lvwq1k96niv2glk8d37dcf9";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlAlgorithmDiff = import ../development/perl-modules/generic perl {
+    name = "Algorithm-Diff-1.15";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/T/TY/TYEMQ/Algorithm-Diff-1.1901.zip;
+      sha256 = "0qk60fi49mpyvnfpjd2dzcmya8x3g5zfgb2hrnl7a5krn045g6i2";
+    };
+    propagatedBuildInputs = [];
+    buildInputs = [unzip];
+  };
+
+  perlAppCLI = import ../development/perl-modules/generic perl {
+    name = "App-CLI-0.07";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/App-CLI-0.07.tar.gz;
+      sha256 = "000866qsm7jck3ini69b02sgbjwp6s297lsds002r7xk2wb6fqcz";
+    };
+    propagatedBuildInputs = [perlLocaleMaketextSimple];
+  };
+
   perlArchiveZip = import ../development/perl-modules/Archive-Zip {
     inherit fetchurl perl;
   };
@@ -3345,10 +3631,46 @@ rec {
     };
   };
 
+  perlClassAccessor = import ../development/perl-modules/generic perl {
+    name = "Class-Accessor-0.31";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/K/KA/KASEI/Class-Accessor-0.31.tar.gz;
+      sha256 = "1a4v5qqdf9bipd6ba5n47mag0cmgwp97cid67i510aw96bcjrsiy";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlClassAutouse = import ../development/perl-modules/generic perl {
+    name = "Class-Autouse-1.99_02";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AD/ADAMK/Class-Autouse-1.99_02.tar.gz;
+      sha256 = "1jkhczx2flxrz154ps90fj9wcchkpmnp5sapwc0l92rpn7jpsf08";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlClassDataInheritable = import ../development/perl-modules/generic perl {
+    name = "Class-Data-Inheritable-0.08";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/T/TM/TMTM/Class-Data-Inheritable-0.08.tar.gz;
+      sha256 = "0jpi38wy5xh6p1mg2cbyjjw76vgbccqp46685r27w8hmxb7gwrwr";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlCompressZlib = import ../development/perl-modules/Compress-Zlib {
     inherit fetchurl perl;
   };
 
+  perlconstant = import ../development/perl-modules/generic perl {
+    name = "constant-1.15";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/S/SA/SAPER/constant-1.15.tar.gz;
+      sha256 = "1ygz0hd1fd3q88r6dlw14kpyh06zjprksdci7qva6skxz3261636";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlCryptPasswordMD5 = import ../development/perl-modules/generic perl {
     name = "Crypt-PasswdMD5-1.3";
     src = fetchurl {
@@ -3357,6 +3679,15 @@ rec {
     };
   };
 
+  perlDataHierarchy = import ../development/perl-modules/generic perl {
+    name = "Data-Hierarchy-0.34";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/Data-Hierarchy-0.34.tar.gz;
+      sha256 = "1vfrkygdaq0k7006i83jwavg9wgszfcyzbl9b7fp37z2acmyda5k";
+    };
+    propagatedBuildInputs = [perlTestException];
+  };
+
   perlDateManip = import ../development/perl-modules/generic perl {
     name = "DateManip-5.42a";
     src = fetchurl {
@@ -3402,6 +3733,69 @@ rec {
     };
   };
 
+  perlEncode = import ../development/perl-modules/generic perl {
+    name = "Encode-2.25";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/D/DA/DANKOGAI/Encode-2.25.tar.gz;
+      sha256 = "0prwmbg3xh1lqskianwrfrgasdfmz4kjm3qpdm27ay110jkk25ak";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlExtUtilsInstall = import ../development/perl-modules/generic perl {
+    name = "ExtUtils-Install-1.50";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/Y/YV/YVES/ExtUtils-Install-1.50.tar.gz;
+      sha256 = "18fr056fwnnhvgc646crx2p9mybf69mh5rkcphc7bbvahw9i61jy";
+    };
+    propagatedBuildInputs = [perlExtUtilsMakeMaker];
+  };
+
+  perlExtUtilsMakeMaker = import ../development/perl-modules/generic perl {
+    name = "ExtUtils-MakeMaker-6.44";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/ExtUtils-MakeMaker-6.44.tar.gz;
+      sha256 = "0zyypnlmmyp06qbfdpc14rp5rj63066mjammn6rlcqz2iil9mpcj";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlExtUtilsManifest = import ../development/perl-modules/generic perl {
+    name = "ExtUtils-Manifest-1.53";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/R/RK/RKOBES/ExtUtils-Manifest-1.53.tar.gz;
+      sha256 = "0xgfzivw0dfy29ydfjkg0c9mvlhjvlhc54s0yvbb4sxb2mdvrfkp";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlFilechdir = import ../development/perl-modules/generic perl {
+    name = "File-chdir-0.1002";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/D/DA/DAGOLDEN/File-chdir-0.1002.tar.gz;
+      sha256 = "1fc2l754bxsizli3injm4wqf8dn03iq16rmfn62l99nxpibl5k6p";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlFileTemp = import ../development/perl-modules/generic perl {
+    name = "File-Temp-0.20";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/T/TJ/TJENNESS/File-Temp-0.20.tar.gz;
+      sha256 = "0n7lr7mpdvwgznw469qdpdmac627a26wp615dkpzanc452skad4v";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlFreezeThaw = import ../development/perl-modules/generic perl {
+    name = "FreezeThaw-0.43";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/I/IL/ILYAZ/modules/FreezeThaw-0.43.tar.gz;
+      sha256 = "1qamc5aggp35xk590a4hy660f2rhc2l7j65hbyxdya9yvg7z437l";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlHTMLParser = import ../development/perl-modules/generic perl {
     name = "HTML-Parser-3.56";
     src = fetchurl {
@@ -3427,6 +3821,42 @@ rec {
     };
   };
 
+  perlI18NLangTags = import ../development/perl-modules/generic perl {
+    name = "I18N-LangTags-0.35";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/S/SB/SBURKE/I18N-LangTags-0.35.tar.gz;
+      sha256 = "0idwfi7k8l44d9akpdj6ygdz3q8zxr690m18s7w23ms9d55bh3jy";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlIODigest = import ../development/perl-modules/generic perl {
+    name = "IO-Digest-0.10";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/IO-Digest-0.10.tar.gz;
+      sha256 = "1g6ilxqv2a7spf273v7k0721c6am7pwpjrin3h5zaqxfmd312nav";
+    };
+    propagatedBuildInputs = [perlPerlIOviadynamic];
+  };
+
+  perlIOPager = import ../development/perl-modules/generic perl {
+    name = "IO-Pager-0.06.tgz";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/J/JP/JPIERCE/IO-Pager-0.06.tgz;
+      sha256 = "0r3af4gyjpy0f7bhs7hy5s7900w0yhbckb2dl3a1x5wpv7hcbkjb";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlListMoreUtils = import ../development/perl-modules/generic perl {
+    name = "List-MoreUtils-0.22";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/V/VP/VPARSEVAL/List-MoreUtils-0.22.tar.gz;
+      sha256 = "1dv21xclh6r1cyy19r34xv2w6pc1jb5pwj7b2739m78xhlk8p55l";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlLocaleGettext = import ../development/perl-modules/generic perl {
     name = "LocaleGettext-1.04";
     src = fetchurl {
@@ -3435,6 +3865,33 @@ rec {
     };
   };
 
+  perlLocaleMaketext = import ../development/perl-modules/generic perl {
+    name = "Locale-Maketext-1.13";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/F/FE/FERREIRA/Locale-Maketext-1.13.tar.gz;
+      sha256 = "0qvrhcs1f28ix3v8hcd5xr4z9s7plz4g5a4q1cjp7bs0c3w2yl6z";
+    };
+    propagatedBuildInputs = [perlI18NLangTags];
+  };
+
+  perlLocaleMaketextLexicon = import ../development/perl-modules/generic perl {
+    name = "Locale-Maketext-Lexicon-0.66";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AU/AUDREYT/Locale-Maketext-Lexicon-0.66.tar.gz;
+      sha256 = "1cd2kbcrlyjcmlr7m8kf94mm1hlr7hpv1r80a596f4ljk81f2nvd";
+    };
+    propagatedBuildInputs = [perlLocaleMaketext];
+  };
+
+  perlLocaleMaketextSimple = import ../development/perl-modules/generic perl {
+    name = "Locale-Maketext-Simple-0.18";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AU/AUDREYT/Locale-Maketext-Simple-0.18.tar.gz;
+      sha256 = "14kx7vkxyfqndy90rzavrjp2346aidyc7x5dzzdj293qf8s4q6ig";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlLWP = import ../development/perl-modules/generic perl {
     name = "libwww-perl-5.808";
     src = fetchurl {
@@ -3444,6 +3901,51 @@ rec {
     propagatedBuildInputs = [perlURI perlHTMLParser perlHTMLTagset];
   };
 
+  perlModuleBuild = import ../development/perl-modules/generic perl {
+    name = "Module-Build-0.2808";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/K/KW/KWILLIAMS/Module-Build-0.2808.tar.gz;
+      sha256 = "1h8zpf4g2n8v47l9apmdqbdgcg039g70w75hpn84m37pmqkbnj8v";
+    };
+    propagatedBuildInputs = [perlExtUtilsInstall perlExtUtilsManifest perlTestHarness];
+  };
+
+  perlPathClass = import ../development/perl-modules/generic perl {
+    name = "Path-Class-0.16";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/K/KW/KWILLIAMS/Path-Class-0.16.tar.gz;
+      sha256 = "0zisxkj58jm84fwcssmdq8g6n37s33v5h7j28m12sbkqib0h76gc";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlPerlIOeol = import ../development/perl-modules/generic perl {
+    name = "PerlIO-eol-0.14";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AU/AUDREYT/PerlIO-eol-0.14.tar.gz;
+      sha256 = "1rwj0r075jfvvd0fnzgdqldc7qdb94wwsi21rs2l6yhcv0380fs2";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlPerlIOviadynamic = import ../development/perl-modules/generic perl {
+    name = "PerlIO-via-dynamic-0.12";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/PerlIO-via-dynamic-0.12.tar.gz;
+      sha256 = "140hay9q8q9sz1fa2s57ijp5l2448fkcg7indgn6k4vc7yshmqz2";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlPerlIOviasymlink = import ../development/perl-modules/generic perl {
+    name = "PerlIO-via-symlink-0.05";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/PerlIO-via-symlink-0.05.tar.gz;
+      sha256 = "0lidddcaz9anddqrpqk4zwm550igv6amdhj86i2jjdka9b1x81s1";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlModulePluggable = import ../development/perl-modules/generic perl {
     name = "Module-Pluggable-3.5";
     src = fetchurl {
@@ -3455,6 +3957,24 @@ rec {
     ];
   };
 
+  perlPodEscapes = import ../development/perl-modules/generic perl {
+    name = "Pod-Escapes-1.04";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/S/SB/SBURKE/Pod-Escapes-1.04.tar.gz;
+      sha256 = "1wrg5dnsl785ygga7bp6qmakhjgh9n4g3jp2l85ab02r502cagig";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlPodSimple = import ../development/perl-modules/generic perl {
+    name = "Pod-Simple-3.05";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AR/ARANDAL/Pod-Simple-3.05.tar.gz;
+      sha256 = "1j0kqcvr9ykcqlkr797j1npkbggykb3p4w5ri73s8mi163lzxkqb";
+    };
+    propagatedBuildInputs = [perlconstant perlPodEscapes];
+  };
+
   perlReturnValue = import ../development/perl-modules/generic perl {
     name = "Return-Value-1.302";
     src = fetchurl {
@@ -3471,6 +3991,33 @@ rec {
     };
   };
 
+  perlSVK = import ../development/perl-modules/generic perl {
+    name = "SVK-v2.0.2";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/SVK-v2.0.2.tar.gz;
+      sha256 = "0c4m2q7cvzwh9kk1nc1vd8lkxx2kss5nd4k20dpkal4c7735jns0";
+    };
+    propagatedBuildInputs = [perlAlgorithmDiff perlAlgorithmAnnotate perlAppCLI perlClassDataInheritable perlDataHierarchy perlEncode perlFileTemp perlIODigest perlListMoreUtils perlPathClass perlPerlIOeol perlPerlIOviadynamic perlPerlIOviasymlink perlPodEscapes perlPodSimple perlSVNMirror perlTimeHiRes perlUNIVERSALrequire perlURI perlYAMLSyck perlClassAutouse perlIOPager perlLocaleMaketextLexicon perlFreezeThaw];
+  };
+
+  perlSVNMirror = import ../development/perl-modules/generic perl {
+    name = "SVN-Mirror-0.73";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/SVN-Mirror-0.73.tar.gz;
+      sha256 = "1scjaq7qjz6jlsk1c2l5q15yxf0sqbydvf22mb2xzy1bzaln0x2c";
+    };
+    propagatedBuildInputs = [perlClassAccessor perlFilechdir subversion perlURI perlTermReadKey perlTimeDate perlSVNSimple];
+  };
+
+  perlSVNSimple = import ../development/perl-modules/generic perl {
+    name = "SVN-Simple-0.27";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/C/CL/CLKAO/SVN-Simple-0.27.tar.gz;
+      sha256 = "0p7p52ja6sf4j0w3b05i0bbqi5wiambckw2m5dsr63bbmlhv4a71";
+    };
+    propagatedBuildInputs = [subversion];
+  };
+
   perlTermReadKey = import ../development/perl-modules/generic perl {
     name = "TermReadKey-2.30";
     src = fetchurl {
@@ -3479,10 +4026,73 @@ rec {
     };
   };
 
+  perlTestBuilderTester = import ../development/perl-modules/generic perl {
+    name = "Test-Builder-Tester-1.01";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/M/MA/MARKF/Test-Builder-Tester-1.01.tar.gz;
+      sha256 = "0s785j4w7rfx5b6bwzflic04vynrcp4dci4p3n8w609zrdn43g32";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlTestException = import ../development/perl-modules/generic perl {
+    name = "Test-Exception-0.27";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AD/ADIE/Test-Exception-0.27.tar.gz;
+      sha256 = "1s921j7yv2szywd1ffi6yz3ngrbq97f9dh38bvvajqnm29g1xb9j";
+    };
+    propagatedBuildInputs = [perlTestBuilderTester perlTestHarness perlTestSimple];
+  };
+
+  perlTestHarness = import ../development/perl-modules/generic perl {
+    name = "Test-Harness-3.10";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AN/ANDYA/Test-Harness-3.10.tar.gz;
+      sha256 = "1qd217yzppj1vbjhny06v8niqhz85pam996ry6bzi08z0jidr2wh";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlTestSimple = import ../development/perl-modules/generic perl {
+    name = "Test-Simple-0.80";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/Test-Simple-0.80.tar.gz;
+      sha256 = "15rzwi01q4lp5sl5n8rvghcvhfd4h4a9m86pnds16nv045irv4x0";
+    };
+    propagatedBuildInputs = [perlTestHarness];
+  };
+
+  perlTimeDate = import ../development/perl-modules/generic perl {
+    name = "TimeDate-1.16";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/TimeDate-1.16.tar.gz;
+      sha256 = "1cvcpaghn7dc14m9871sfw103g3m3a00m2mrl5iqb0mmh40yyhkr";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlTimeHiRes = import ../development/perl-modules/generic perl {
+    name = "Time-HiRes-1.9715";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/J/JH/JHI/Time-HiRes-1.9715.tar.gz;
+      sha256 = "0pgqrfkysy3mdcx5nd0x8c80lgqb7rkb3nrkii3vc576dcbpvw0i";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlFontTTF = import ../development/perl-modules/Font-TTF {
     inherit fetchurl perl;
   };
 
+  perlUNIVERSALrequire = import ../development/perl-modules/generic perl {
+    name = "UNIVERSAL-require-0.11";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/UNIVERSAL-require-0.11.tar.gz;
+      sha256 = "1rh7i3gva4m96m31g6yfhlqcabszhghbb3k3qwxbgx3mkf5s6x6i";
+    };
+    propagatedBuildInputs = [];
+  };
+
   perlURI = import ../development/perl-modules/generic perl {
     name = "URI-1.35";
     src = fetchurl {
@@ -3497,7 +4107,7 @@ rec {
       url = mirror://cpan/authors/id/T/TJ/TJMATHER/XML-DOM-1.44.tar.gz;
       sha256 = "1r0ampc88ni3sjpzr583k86076qg399arfm9xirv3cw49k3k5bzn";
     };
-#    buildInputs = [libxml2];
+    #buildInputs = [libxml2];
     propagatedBuildInputs = [perlXMLRegExp perlXMLParser perlLWP];
   };
 
@@ -3551,10 +4161,10 @@ rec {
   };
 
   perlXMLSimple = import ../development/perl-modules/generic perl {
-    name = "XML-Simple-2.14";
+    name = "XML-Simple-2.18";
     src = fetchurl {
-      url = http://nix.cs.uu.nl/dist/tarballs/XML-Simple-2.14.tar.gz;
-      md5 = "f321058271815de28d214c8efb9091f9";
+      url = mirror://cpan/authors/id/G/GR/GRANTM/XML-Simple-2.18.tar.gz;
+      sha256 = "09k8fvc9m5nd5rqq00rwm3m0wx7iwd6vx0vc947y58ydi30nfjd5";
     };
     propagatedBuildInputs = [perlXMLParser];
   };
@@ -3576,6 +4186,33 @@ rec {
     };
   };
 
+  perlXSLoader = import ../development/perl-modules/generic perl {
+    name = "XSLoader-0.08";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/S/SA/SAPER/XSLoader-0.08.tar.gz;
+      sha256 = "0mr4l3givrpyvz1kg0kap2ds8g0rza2cim9kbnjy8hi64igkixi5";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlYAML = import ../development/perl-modules/generic perl {
+    name = "YAML-0.66";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/I/IN/INGY/YAML-0.66.tar.gz;
+      sha256 = "1pcjf6y3l88ypa52mkk349jglabm53mhxda4p5awc1jl67lx3ngw";
+    };
+    propagatedBuildInputs = [];
+  };
+
+  perlYAMLSyck = import ../development/perl-modules/generic perl {
+    name = "YAML-Syck-1.04";
+    src = fetchurl {
+      url = http://search.cpan.org/CPAN/authors/id/A/AU/AUDREYT/YAML-Syck-1.04.tar.gz;
+      sha256 = "180w77rxqwrfmd2jjmrd407bf8vnpry73941g5n61ippzic5x1v3";
+    };
+    propagatedBuildInputs = [];
+  };
+
 
   ### DEVELOPMENT / PYTHON MODULES
 
@@ -3584,6 +4221,13 @@ rec {
     inherit fetchurl stdenv python db4;
   };
 
+  flup = builderDefsPackage (selectVersion ../development/python-modules/flup "r2311") 
+  (let python=python25; in 
+  {
+    inherit python;
+    setuptools = setuptools.meta.function {inherit python;} null;
+  }) null;
+
   pil = import ../development/python-modules/pil {
     inherit fetchurl stdenv python zlib libtiff libjpeg freetype;
   };
@@ -3602,7 +4246,7 @@ rec {
 
   pygame = import ../development/python-modules/pygame {
     inherit fetchurl stdenv python pkgconfig SDL SDL_image 
-	SDL_ttf;
+  SDL_ttf;
   };
 
   pygobject = import ../development/python-modules/pygobject {
@@ -3615,10 +4259,30 @@ rec {
     inherit (gtkLibs) glib gtk;
   };
 
+  pythonSip = builderDefsPackage (selectVersion ../development/python-modules/python-sip "4.7.4") {
+    python=python25;
+  } null;
+
+  pyqt = builderDefsPackage (selectVersion ../development/python-modules/pyqt "4.3.3") {
+    inherit pkgconfig pythonSip;
+    python = python25;
+    inherit (xlibs) libX11 libXext;
+    inherit (gtkLibs) glib;
+    qt = qt4;
+  } null;
+
+  pyx = import ../development/python-modules/pyx {
+    inherit fetchurl stdenv python makeWrapper;
+  };
+
   pyxml = import ../development/python-modules/pyxml {
     inherit fetchurl stdenv python makeWrapper;
   };
 
+  setuptools = builderDefsPackage (selectVersion ../development/python-modules/setuptools "0.6c8") {
+    python = python25;
+  } null;
+
   wxPython = wxPython26;
 
   wxPython26 = import ../development/python-modules/wxPython/2.6.nix {
@@ -3649,6 +4313,26 @@ rec {
     db4Support = true;
   };
 
+  bind = builderDefsPackage (selectVersion ../servers/dns/bind "9.5.0") {
+    inherit openssl libtool;
+  } null;
+
+  dictFun = lib.sumArgs (selectVersion ../servers/dict "1.9.15") {
+    inherit builderDefs which; 
+    flex=flex2534; 
+    bison=bison23;
+  };
+
+  dict = dictFun null;
+
+  dictdDBs = recurseIntoAttrs (import ../servers/dict/dictd-db.nix {
+    inherit builderDefs;
+  });
+
+  dictDBCollector = import ../servers/dict/dictd-db-collector.nix {
+    inherit stdenv lib dict;
+  };
+
   dovecot = import ../servers/mail/dovecot {
     inherit fetchurl stdenv ;
   };
@@ -3658,12 +4342,12 @@ rec {
   };
 
   fingerd_bsd = import ../servers/fingerd/bsd-fingerd {
-	  inherit fetchurl stdenv;
+    inherit fetchurl stdenv;
   };
 
   ircdHybrid = import ../servers/irc/ircd-hybrid {
-		inherit fetchurl stdenv openssl zlib;
-	};
+    inherit fetchurl stdenv openssl zlib;
+  };
 
   jboss = import ../servers/http/jboss {
     inherit fetchurl stdenv jdk5 jdk;
@@ -3685,10 +4369,25 @@ rec {
     inherit fetchurl stdenv apacheHttpd python;
   };
 
+  postfix = import ../servers/mail/postfix {
+    inherit fetchurl stdenv db4;
+    glibc = stdenv.glibc;
+  };
+
   tomcat_connectors = import ../servers/http/apache-modules/tomcat-connectors {
     inherit fetchurl stdenv apacheHttpd jdk;
   };
 
+  # This function is typically called by the NixOS Upstart job to specify the
+  # right UID/GID for `portmap'.
+  makePortmap = { daemonUser ? false, daemonGID ? false, daemonUID ? false }:
+    (import ../servers/portmap {
+       inherit fetchurl stdenv lib tcpWrapper
+               daemonUser daemonGID daemonUID;
+     });
+
+  portmap = (makePortmap);
+
   mysql4 = import ../servers/sql/mysql {
     inherit fetchurl stdenv ncurses zlib perl;
     ps = procps; /* !!! Linux only */
@@ -3730,13 +4429,17 @@ rec {
 
   samba = import ../servers/samba {
     inherit stdenv fetchurl readline openldap pam kerberos popt iniparser
-	libunwind acl fam;
+  libunwind acl fam;
   };
 
   squid = import ../servers/squid {
     inherit fetchurl stdenv mkDerivationByConfiguration perl lib;
   };
 
+  squidHead = import ../servers/squid/3.head.nix {
+    inherit fetchurl stdenv mkDerivationByConfiguration perl lib;
+  };
+
   tomcat5 = import ../servers/http/tomcat {
     inherit fetchurl stdenv jdk;
   };
@@ -3759,6 +4462,16 @@ rec {
       xkeyboard_config dbus hal;
   });
 
+  zabbixAgent = import ../servers/monitoring/zabbix {
+    inherit fetchurl stdenv;
+    enableServer = false;
+  };
+
+  zabbixServer = import ../servers/monitoring/zabbix {
+    inherit fetchurl stdenv postgresql curl;
+    enableServer = true;
+  };
+
 
   ### OS-SPECIFIC
 
@@ -3773,11 +4486,9 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  /*
   nfsUtils = import ../os-specific/linux/nfs-utils {
-   inherit fetchurl stdenv kernelHeaders tcp_wrapper;
+   inherit fetchurl stdenv tcpWrapper e2fsprogs;
   };
-  */
 
   acpi = import ../os-specific/linux/acpi {
     inherit fetchurl stdenv;
@@ -3797,17 +4508,13 @@ rec {
 
   alsaUtils = alsa.alsaUtils;
 
-  atherosFun = lib.sumArgs (selectVersion ../os-specific/linux/atheros "r3122") {
-    inherit fetchurl stdenv builderDefs;
+  blcrFun = builderDefsPackage (selectVersion ../os-specific/linux/blcr "0.6.5"){
+    inherit perl;
   };
 
-  atherosFunCurrent = kernel: atherosFun {
+  blcrFunCurrent = kernel : (blcrFun {
     inherit kernel;
-  } null;
-
-  aufs = import ../os-specific/linux/aufs {
-    inherit fetchurl stdenv kernel;
-  };
+  } null);
 
   bridge_utils = import ../os-specific/linux/bridge_utils {
     inherit fetchurl stdenv autoconf automake;
@@ -3839,11 +4546,11 @@ rec {
   };
 
   e2fsprogs = import ../os-specific/linux/e2fsprogs {
-    inherit fetchurl stdenv gettext;
+    inherit fetchurl stdenv;
   };
 
   e2fsprogsDiet = lowPrio (appendToName "diet" (import ../os-specific/linux/e2fsprogs {
-    inherit fetchurl gettext;
+    inherit fetchurl;
     stdenv = useDietLibC stdenv;
   }));
 
@@ -3851,11 +4558,6 @@ rec {
     inherit stdenv fetchurl gettext;
   };
 
-  ext3cowtools = import ../os-specific/linux/ext3cow-tools {
-    inherit stdenv fetchurl;
-    kernel_ext3cowpatched = kernel;
-  };
-
   eject = import ../os-specific/linux/eject {
     inherit fetchurl stdenv gettext;
   };
@@ -3872,6 +4574,12 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  gpm = builderDefsPackage (selectVersion ../servers/gpm "1.20.3pre6") {
+    inherit lzma ncurses;
+    bison = bison23;
+    flex = flex2535;
+  } null;
+
   hal = import ../os-specific/linux/hal {
     inherit fetchurl stdenv pkgconfig python pciutils usbutils expat
       libusb dbus dbus_glib libvolume_id perl perlXMLParser
@@ -3882,6 +4590,10 @@ rec {
   hdparm = import ../os-specific/linux/hdparm {
     inherit fetchurl stdenv;
   };
+
+  hibernate = import ../os-specific/linux/hibernate {
+    inherit fetchurl stdenv gawk;
+  };
  
   htop = import ../os-specific/linux/htop {
     inherit fetchurl stdenv ncurses;
@@ -3920,10 +4632,6 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  iwlwifi = import ../os-specific/linux/iwlwifi {
-    inherit fetchurl stdenv kernel;
-  };
-
   iwlwifi3945ucode = import ../os-specific/linux/firmware/iwlwifi-3945-ucode {
     inherit fetchurl stdenv;
   };
@@ -3932,6 +4640,16 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  jfsrecFun = builderDefsPackage (selectVersion ../os-specific/linux/jfsrec "svn-7"){
+    inherit boost;
+  };
+  jfsrec = jfsrecFun null;
+
+  jfsUtilsFun = builderDefsPackage (selectVersion ../os-specific/linux/jfsutils "1.1.12") {
+    inherit e2fsprogs;
+  };
+  jfsUtils = jfsUtilsFun null;
+
   kbd = import ../os-specific/linux/kbd {
     inherit fetchurl stdenv bison flex;
   };
@@ -3946,6 +4664,14 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  kernelHeaders_2_6_25 = import ../os-specific/linux/kernel-headers/2.6.25.4.nix {
+    inherit fetchurl stdenv;
+  };
+
+  kernelHeaders_2_6_26 = import ../os-specific/linux/kernel-headers/2.6.26-rc5.nix {
+    inherit fetchurl stdenv;
+  };
+
   kernelHeadersArm = import ../os-specific/linux/kernel-headers-cross {
     inherit fetchurl stdenv;
     cross = "arm-linux";
@@ -3961,16 +4687,12 @@ rec {
     cross = "sparc-linux";
   };
 
-  kernelscripts = import ../os-specific/linux/kernelscripts {
-    inherit stdenv module_init_tools kernel;
-    modules = [];
-  };
-
-  kernel = kernel_2_6_23;
-
-  systemKernel = (if (getConfig ["kernel" "version"] "2.6.21") == "2.6.22" then
-	kernel_2_6_22 else if (getConfig ["kernel" "version"] "2.6.21") == "2.6.23" then
-	kernel_2_6_23 else kernel);
+  /*
+  systemKernel =
+    if getConfig ["kernel" "version"] "2.6.21" == "2.6.22" then kernel_2_6_22 else
+    if getConfig ["kernel" "version"] "2.6.21" == "2.6.23" then kernel_2_6_23 else
+    kernel;
+  */
 
   kernel_2_6_20 = import ../os-specific/linux/kernel/linux-2.6.20.nix {
     inherit fetchurl stdenv perl mktemp module_init_tools;
@@ -4001,19 +4723,19 @@ rec {
     inherit fetchurl stdenv perl mktemp module_init_tools;
     kernelPatches = [
       { name = "ext3cow";
-        patch = ../os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch;
+        patch = ../os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch;
         extraConfig =  
-	"CONFIG_EXT3COW_FS=m\n" +
-	"CONFIG_EXT3COW_FS_XATTR=y\n" +
-	"CONFIG_EXT3COW_FS_POSIX_ACL=y\n" +
-	"CONFIG_EXT3COW_FS_SECURITY=y\n";
+          "CONFIG_EXT3COW_FS=m\n" +
+          "CONFIG_EXT3COW_FS_XATTR=y\n" +
+          "CONFIG_EXT3COW_FS_POSIX_ACL=y\n" +
+          "CONFIG_EXT3COW_FS_SECURITY=y\n";
       }
-      /* commented out because only acer users have need for it.. 
+      /* Commented out because only acer users have need for it.. 
          It takes quite a while to create the patch when unpacking the kernel sources only for that task
       { name = "acerhk";
         patch = kernel_module_acerhk + "/acerhk-patch.tar.bz2" ;
         extraConfig =  
-	"CONFIG_ACERHK=m\n";
+  "CONFIG_ACERHK=m\n";
       }
       */
       { name = "paravirt-nvidia";
@@ -4043,7 +4765,7 @@ rec {
     kernelPatches = [
       /*
       { name = "ext3cow";
-        patch = ../os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch;
+        patch = ../os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch;
         extraConfig =
         "CONFIG_EXT3COW_FS=m\n" +
         "CONFIG_EXT3COW_FS_XATTR=y\n" +
@@ -4082,7 +4804,7 @@ rec {
     inherit fetchurl stdenv perl mktemp module_init_tools;
     kernelPatches = [
       { name = "ext3cow";
-        patch = ../os-specific/linux/kernel/linux-2.6.21.7-ext3cow_wouter.patch;
+        patch = ../os-specific/linux/kernel/linux-2.6.20.3-ext3cow.patch;
         extraConfig =
         "CONFIG_EXT3COW_FS=m\n" +
         "CONFIG_EXT3COW_FS_XATTR=y\n" +
@@ -4114,6 +4836,28 @@ rec {
     ];
   };
 
+  kernel_2_6_25 = import ../os-specific/linux/kernel/linux-2.6.25.nix {
+    inherit fetchurl stdenv perl mktemp module_init_tools;
+    kernelPatches = [
+      { name = "fbcondecor-0.9.4-2.6.25-rc6";
+        patch = fetchurl {
+          url = http://dev.gentoo.org/~spock/projects/fbcondecor/archive/fbcondecor-0.9.4-2.6.25-rc6.patch;
+          sha256 = "1wm94n7f0qyb8xvafip15r158z5pzw7zb7q8hrgddb092c6ibmq8";
+        };
+        extraConfig = "CONFIG_FB_CON_DECOR=y";
+        features = { fbConDecor = true; };
+      }
+      { name = "sec_perm-2.6.24";
+        patch = ../os-specific/linux/kernel/sec_perm-2.6.24.patch;
+        features = { secPermPatch = true; };
+      }
+    ];
+    extraConfig =
+      lib.optional (getConfig ["kernel" "timer_stats"] false) "CONFIG_TIMER_STATS=y" ++
+      lib.optional (getConfig ["kernel" "no_irqbalance"] false) "# CONFIG_IRQBALANCE is not set" ++
+      [(getConfig ["kernel" "addConfig"] "")];
+  };
+
   kernel_2_6_23 = import ../os-specific/linux/kernel/linux-2.6.23.nix {
     inherit fetchurl stdenv perl mktemp module_init_tools;
     kernelPatches = [
@@ -4138,6 +4882,7 @@ rec {
           sha256 = "0822wwlf2dqsap5qslnnp0yl1nbvvvb76l73w2dd8zsyn0bqg3px";
         };
         extraConfig = "CONFIG_FB_SPLASH=y";
+        features = { fbSplash = true; };
       }
       /* !!! Not needed anymore for the NixOS LiveCD - we have AUFS. */
       { name = "unionfs-2.2.2";
@@ -4157,14 +4902,105 @@ rec {
       [(getConfig ["kernel" "addConfig"] "")];
   };
 
-  kqemuFun = lib.sumArgs (selectVersion ../os-specific/linux/kqemu "1.3.0pre11") {
-    inherit fetchurl stdenv builderDefs;
+  /* Kernel modules are inherently tied to a specific kernel.  So
+     rather than provide specific instances of those packages for a
+     specific kernel, we have a function that builds those packages
+     for a specific kernel.  This function can then be called for
+     whatever kernel you're using. */
+  
+  kernelPackagesFor = kernel: rec {
+
+    inherit kernel;
+
+    aufs = import ../os-specific/linux/aufs {
+      inherit fetchurl stdenv kernel;
+    };
+
+    iwlwifi = import ../os-specific/linux/iwlwifi {
+      inherit fetchurl stdenv kernel;
+    };
+
+    atheros = composedArgsAndFun (selectVersion ../os-specific/linux/atheros "0.9.4") {
+      inherit fetchurl stdenv builderDefs kernel lib;
+    } null;
+
+    nvidiaDrivers = import ../os-specific/linux/nvidia {
+      inherit stdenv fetchurl kernel xlibs gtkLibs;
+    };
+
+    wis_go7007 = import ../os-specific/linux/wis-go7007 {
+      inherit fetchurl stdenv kernel ncurses fxload;
+    };
+
+    kqemu = builderDefsPackage (selectVersion ../os-specific/linux/kqemu "1.3.0pre11") {
+      inherit kernel;
+    } null;
+
+    # Actually, klibc builds fine with the static kernelHeaders, but
+    # splashutils expects a klibc with patched headers...
+    klibc = import ../os-specific/linux/klibc {
+      inherit fetchurl stdenv perl bison mktemp kernel;
+    };
+
+    klibcShrunk = import ../os-specific/linux/klibc/shrunk.nix {
+      inherit stdenv klibc;
+    };
+
+    splashutils = 
+      if kernel.features ? fbSplash then splashutils_13 else
+      if kernel.features ? fbConDecor then splashutils_15 else
+      null;
+
+    splashutils_13 = import ../os-specific/linux/splashutils/1.3.nix {
+      inherit fetchurl stdenv klibc;
+      zlib = zlibStatic;
+      libjpeg = libjpegStatic;
+    };
+
+    splashutils_15 = import ../os-specific/linux/splashutils/1.5.nix {
+      inherit fetchurl stdenv klibc;
+      zlib = zlibStatic;
+      libjpeg = libjpegStatic;
+    };
+
+    ext3cowtools = import ../os-specific/linux/ext3cow-tools {
+      inherit stdenv fetchurl;
+      kernel_ext3cowpatched = kernel;
+    };
+
+    ov511 = import ../os-specific/linux/ov511 {
+      inherit fetchurl kernel;
+      stdenv = overrideGCC stdenv gcc34;
+    };
+
+    # State Nix
+    snix = import ../tools/package-management/snix {
+      inherit fetchurl stdenv perl curl bzip2 openssl;
+      inherit libtool automake autoconf docbook5 docbook5_xsl libxslt docbook_xml_dtd_43 w3m;
+
+      aterm = aterm242fixes;
+      db4 = db45;
+
+      bison = bison23;
+      flex = flex2533;
+
+      inherit ext3cowtools e3cfsprogs rsync;
+      ext3cow_kernel = kernel;
+    };
+
   };
 
-  # No finished expression is provided - pick your own kernel
-  kqemuFunCurrent = theKernel:  (kqemuFun { 
-    kernel = theKernel;
-  } null);
+  # Build the kernel modules for the some of the kernels.
+  kernelPackages_2_6_23 = recurseIntoAttrs (kernelPackagesFor kernel_2_6_23);
+  kernelPackages_2_6_25 = recurseIntoAttrs (kernelPackagesFor kernel_2_6_25);
+
+  # The current default kernel / kernel modules.
+  kernelPackages = kernelPackages_2_6_23;
+  #kernel = kernelPackages.kernel;
+
+  customKernel = lib.sumArgs (import ../os-specific/linux/kernel/linux.nix) {
+    inherit fetchurl stdenv perl mktemp module_init_tools lib;
+  };
 
   libselinux = import ../os-specific/linux/libselinux {
     inherit fetchurl stdenv libsepol;
@@ -4174,7 +5010,6 @@ rec {
     inherit fetchurl stdenv;
   };
 
- 
   libsexy = import ../development/libraries/libsexy {
     inherit stdenv fetchurl pkgconfig libxml2;
     inherit (gtkLibs) glib gtk pango;
@@ -4190,11 +5025,6 @@ rec {
     inherit fetchurl stdenv libxml2;
   };
 
-  klibc = import ../os-specific/linux/klibc {
-    inherit fetchurl stdenv perl bison mktemp;
-	kernel = systemKernel;
-  };
-
   kvm = kvm57;
 
   kvm12 = import ../os-specific/linux/kvm/12.nix {
@@ -4221,6 +5051,12 @@ rec {
     kernelHeaders = kernelHeaders_2_6_23;
   };
 
+  kvm69 = import ../os-specific/linux/kvm/69.nix {
+    inherit fetchurl zlib e2fsprogs SDL alsaLib pkgconfig rsync;
+    stdenv = overrideGCC stdenv gcc34;
+    kernelHeaders = kernelHeaders_2_6_26;
+  };
+
   libcap = import ../os-specific/linux/libcap {
     inherit fetchurl stdenv attr;
   };
@@ -4265,10 +5101,10 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  module_aggregation = moduleSources:  
-  import ../os-specific/linux/module-init-tools/aggregator.nix {
-    inherit fetchurl stdenv module_init_tools moduleSources builderDefs;
-  };
+  aggregateModules = modules:  
+    import ../os-specific/linux/module-init-tools/aggregator.nix {
+      inherit stdenv module_init_tools modules;
+    };
 
   modutils = import ../os-specific/linux/modutils {
     inherit fetchurl bison flex;
@@ -4286,23 +5122,19 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  nvidiaDrivers = import ../os-specific/linux/nvidia {
-    inherit stdenv fetchurl kernel xlibs gtkLibs zlib;
+  numactl = import ../os-specific/linux/numactl {
+    inherit fetchurl stdenv;
   };
 
-  gw6c = import ../os-specific/linux/gw6c {
-    inherit fetchurl stdenv nettools openssl procps;
+  gw6cFun = builderDefsPackage (selectVersion ../os-specific/linux/gw6c "5.1") {
+    inherit fetchurl stdenv nettools openssl procps iproute;
   };
+  gw6c = gw6cFun null;
 
   nss_ldap = import ../os-specific/linux/nss_ldap {
     inherit fetchurl stdenv openldap;
   };
 
-  ov511 = import ../os-specific/linux/ov511 {
-    inherit fetchurl kernel;
-    stdenv = overrideGCC stdenv gcc34;
-  };
-
   pam = import ../os-specific/linux/pam {
     inherit stdenv fetchurl cracklib flex;
   };
@@ -4364,12 +5196,6 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  splashutils = import ../os-specific/linux/splashutils {
-    inherit fetchurl stdenv klibc;
-    zlib = zlibStatic;
-    libjpeg = libjpegStatic;
-  };
-
   squashfsTools = import ../os-specific/linux/squashfs {
     inherit fetchurl stdenv zlib;
   };
@@ -4395,12 +5221,10 @@ rec {
     withoutInitTools = true;
   };
 
-  /*
-  # needed for nfs utils
-  tcp_wrapper = import ../os-specific/linux/tcp-wrapper {
-    inherit fetchurl stdenv kernelHeaders gnused;
+  # FIXME: `tcp-wrapper' is actually not OS-specific.
+  tcpWrapper = import ../os-specific/linux/tcp-wrapper {
+    inherit fetchurl stdenv;
   };
-  */
 
   udev = import ../os-specific/linux/udev {
     inherit fetchurl stdenv;
@@ -4449,14 +5273,15 @@ rec {
     inherit fetchurl stdenv;
   };
 
-  wis_go7007 = import ../os-specific/linux/wis-go7007 {
-    inherit fetchurl stdenv kernel ncurses fxload;
-  };
-
   wpa_supplicant = import ../os-specific/linux/wpa_supplicant {
     inherit fetchurl stdenv openssl;
   };
 
+  xfsProgsFun = builderDefsPackage (selectVersion ../os-specific/linux/xfsprogs "2.9.7-1"){
+    inherit libtool gettext e2fsprogs;
+  };
+  xfsProgs = xfsProgsFun null;
+
   xorg_sys_opengl = import ../os-specific/linux/opengl/xorg-sys {
     inherit stdenv xlibs expat libdrm;
   };
@@ -4494,7 +5319,7 @@ rec {
   };
 
   docbook5 = import ../data/sgml+xml/schemas/docbook-5.0 {
-    inherit fetchurl stdenv;
+    inherit fetchurl stdenv unzip;
   };
 
   docbook_xml_dtd_412 = import ../data/sgml+xml/schemas/xml-dtd/docbook/4.1.2.nix {
@@ -4538,6 +5363,16 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  libertine = builderDefsPackage (selectVersion ../data/fonts/libertine "2.7") {
+    inherit fontforge;
+  } null;
+  libertineBin = builderDefsPackage (selectVersion ../data/fonts/libertine "2.7.bin") {
+  } null;
+
+  lmodernFun = builderDefsPackage (selectVersion ../data/fonts/lmodern "1.010") {
+  };
+  lmodern = lmodernFun null;
+
   manpages = import ../data/documentation/man-pages {
      inherit fetchurl stdenv;
   };
@@ -4559,6 +5394,18 @@ rec {
     inherit fetchurl stdenv;
   };
 
+  r3rs = import ../data/documentation/rnrs/r3rs.nix {
+    inherit fetchurl stdenv texinfo;
+  };
+
+  r4rs = import ../data/documentation/rnrs/r4rs.nix {
+    inherit fetchurl stdenv texinfo;
+  };
+
+  r5rs = import ../data/documentation/rnrs/r5rs.nix {
+    inherit fetchurl stdenv texinfo;
+  };
+
   ttf_bitstream_vera = import ../data/fonts/ttf-bitstream-vera {
     inherit fetchurl stdenv;
   };
@@ -4605,8 +5452,18 @@ rec {
     inherit (xlibs) libX11 libXext;
   };
 
+  aangifte2007 = import ../applications/taxes/aangifte-2007 {
+    inherit stdenv fetchurl;
+    inherit (xlibs) libX11 libXext libSM;
+  };
+
+  abcde = import ../applications/audio/abcde {
+    inherit fetchurl stdenv libcdio cddiscid wget bash vorbisTools
+            makeWrapper;
+  };
+
   abiword = import ../applications/office/abiword {
-    inherit fetchurl stdenv pkgconfig fribidi libpng popt;
+    inherit fetchurl stdenv pkgconfig fribidi libpng popt libgsf enchant wv;
     inherit (gtkLibs) gtk;
     inherit (gnome) libglade libgnomeprint libgnomeprintui libgnomecanvas;
   };
@@ -4633,7 +5490,8 @@ rec {
 
   audacious_plugins = import ../applications/audio/audacious/plugins.nix {
     inherit fetchurl stdenv pkgconfig audacious dbus_glib gettext
-      libmad xlibs alsaLib taglib libmpcdec libogg libvorbis;
+      libmad xlibs alsaLib taglib libmpcdec libogg libvorbis
+      libcdio libcddb;
   };
 
   audacity = import ../applications/audio/audacity {
@@ -4655,9 +5513,14 @@ rec {
   };
 
   bazaar = import ../applications/version-management/bazaar {
-    inherit fetchurl stdenv python makeWrapper;
+    inherit fetchurl stdenv makeWrapper;
+    python = python25;
   };
 
+  bazaarTools = builderDefsPackage (import ../applications/version-management/bazaar/tools.nix) {
+    inherit bazaar;
+  } null;
+
   bitlbee = import ../applications/networking/instant-messengers/bitlbee {
     inherit fetchurl stdenv gnutls pkgconfig;
     inherit (gtkLibs) glib;
@@ -4677,9 +5540,9 @@ rec {
 
   blender = import ../applications/misc/blender {
     inherit stdenv cmake mesa gettext freetype SDL libtiff fetchurl glibc scons x11 lib
-      libjpeg libpng zlib /* smpeg  sdl */;
+      libjpeg libpng zlib /* smpeg sdl */;
     inherit (xlibs) inputproto libXi;
-    python = builtins.getAttr "2.5" python_alts;
+    python = python25;
     freealut = freealut_soft;
     openal = openalSoft;
     openexr = openexr_1_4_0;
@@ -4703,6 +5566,10 @@ rec {
     inherit fetchurl stdenv ncurses;
   };
 
+  cddiscid = import ../applications/audio/cd-discid {
+    inherit fetchurl stdenv;
+  };
+
   cdparanoia = cdparanoiaIII;
 
   cdparanoiaIII = import ../applications/audio/cdparanoia {
@@ -4721,8 +5588,8 @@ rec {
     xulrunnerWrapper {
       launcher = "chatzilla";
       application = import ../applications/networking/irc/chatzilla {
-          inherit fetchurl stdenv unzip;
-        };
+        inherit fetchurl stdenv unzip;
+      };
     };
 
   compiz_050 = assert mesaSupported; import ../applications/window-managers/compiz/0.5.0.nix {
@@ -4742,12 +5609,13 @@ rec {
     version = "0.6.2";
   };
 
-  compizFun = lib.sumArgs (assert mesaSupported; selectVersion ../applications/window-managers/compiz "0.6.2") {
+  compizFun = lib.sumArgs (assert mesaSupported; selectVersion ../applications/window-managers/compiz "0.7.4") {
     inherit lib builderDefs stringsWithDeps;
     inherit fetchurl stdenv pkgconfig libpng mesa perl perlXMLParser libxslt;
     inherit (xorg) libXcomposite libXfixes libXdamage libXrandr
       libXinerama libICE libSM libXrender xextproto compositeproto fixesproto
-      damageproto randrproto xineramaproto renderproto kbproto;
+      damageproto randrproto xineramaproto renderproto kbproto xproto libX11 
+      libxcb;
     inherit (gnome) startupnotification libwnck GConf;
     inherit (gtkLibs) gtk;
     inherit (gnome) libgnome libgnomeui metacity
@@ -4764,7 +5632,7 @@ rec {
   } null;
 
   compizFusion = assert mesaSupported; import ../applications/window-managers/compiz-fusion {
-    version = getConfig ["compizFusion" "version"] "0.6.0";
+    version = getConfig ["compizFusion" "version"] "0.7.4";
     inherit compiz;
     inherit stringsWithDeps lib builderDefs;
     inherit fetchurl stdenv pkgconfig libpng mesa perl perlXMLParser libxslt;
@@ -4793,12 +5661,21 @@ rec {
     inherit fetchurl stdenv emacs texinfo ctags;
   };
 
+  codeville = builderDefsPackage (selectVersion ../applications/version-management/codeville "0.8.0") {
+    python = python25;
+    inherit makeWrapper;
+  } null;
+
   cua = import ../applications/editors/emacs-modes/cua {
     inherit fetchurl stdenv;
   };
 
   cvs = import ../applications/version-management/cvs {
-    inherit fetchurl stdenv vim;
+    inherit fetchurl stdenv nano;
+  };
+
+  cvsps = import ../applications/version-management/cvsps {
+    inherit fetchurl stdenv cvs zlib;
   };
 
   cvs2svn = import ../applications/version-management/cvs2svn {
@@ -4816,20 +5693,20 @@ rec {
   };
 
   # some speed bottle necks are resolved in this version I think .. perhaps you like to try it? 
-  darcs_2_pre = import ../applications/version-management/darcs_2_pre.nix {
+  darcs2 = import ../applications/version-management/darcs/darcs-2.nix {
     inherit fetchurl stdenv zlib ncurses curl ghc;
   };
 
   dia = import ../applications/graphics/dia {
     inherit stdenv fetchurl pkgconfig perl perlXMLParser 
-	libxml2 gettext python libxml2Python docbook5 docbook_xsl 
-	libxslt;
+      libxml2 gettext python libxml2Python docbook5 docbook_xsl 
+      libxslt;
     inherit (gtkLibs) gtk glib;
   };
 
   djvulibre = import ../applications/misc/djvulibre {
     inherit stdenv fetchurl libjpeg libtiff libungif zlib
-	ghostscript libpng x11 mesa;
+      ghostscript libpng x11 mesa;
     qt = if (getConfig ["djvulibre" "qt3Frontend"] true) then qt3 else null;
     inherit (xlibs) libX11;
   };
@@ -4848,9 +5725,9 @@ rec {
   # building eclipise from source 
   # experimental tested on x86_64-linux only
   eclipse_classic_src = import ../applications/editors/eclipse/eclipse_classic.nix {
-      inherit fetchurl stdenv makeWrapper jdk unzip ant;
-      inherit (gtkLibs) gtk glib;
-      inherit (xlibs) libXtst;
+    inherit fetchurl stdenv makeWrapper jdk unzip ant;
+    inherit (gtkLibs) gtk glib;
+    inherit (xlibs) libXtst;
   };
 
   eclipse = plugins:
@@ -4865,9 +5742,13 @@ rec {
 
   eclipseSpoofax = lowPrio (appendToName "with-spoofax" (eclipse [spoofax]));
 
+  ed = import ../applications/editors/ed {
+    inherit fetchurl stdenv;
+  };
+
   elinks = import ../applications/networking/browsers/elinks {
     inherit stdenv fetchurl python perl ncurses x11 zlib openssl spidermonkey
-	guile bzip2;
+      guile bzip2;
   };
 
   emacs = emacs22;
@@ -4916,7 +5797,7 @@ rec {
   };
 
   wireshark = import ../applications/networking/sniffers/wireshark {
-    inherit fetchurl stdenv perl pkgconfig libpcap;
+    inherit fetchurl stdenv perl pkgconfig libpcap flex bison;
     inherit (gtkLibs) gtk;
   };
 
@@ -4945,7 +5826,7 @@ rec {
 
   firefox3b1Bin = lowPrio (import ../applications/networking/browsers/firefox-3/binary.nix {
     inherit fetchurl stdenv pkgconfig perl zip libjpeg libpng zlib cairo
-    	python curl coreutils freetype fontconfig;
+      python curl coreutils freetype fontconfig;
     inherit (gtkLibs) gtk atk pango glib;
     inherit (gnome) libIDL;
     inherit (xlibs) libXi libX11 libXrender libXft libXt;
@@ -4988,24 +5869,14 @@ rec {
     gtksharp = gtksharp1;
   };
 
-  pidgin = import ../applications/networking/instant-messengers/pidgin {
+  funpidgin = builderDefsPackage (selectVersion ../applications/networking/instant-messengers/funpidgin "2.4.1") {
     inherit fetchurl stdenv pkgconfig perl perlXMLParser libxml2 openssl nss
       gtkspell aspell gettext ncurses;
     GStreamer = gst_all.gstreamer;
     inherit (gtkLibs) gtk;
     inherit (gnome) startupnotification;
-    inherit (xlibs) libXScrnSaver;
-  };
-
-  pidginlatex = import ../applications/networking/instant-messengers/pidgin-plugins/pidgin-latex {
-	inherit fetchurl stdenv tetex pkgconfig ghostscript pidgin;
-	imagemagick = imagemagickBig;
-	inherit (gtkLibs) glib gtk;
-  };
-
-  pidginotr = import ../applications/networking/instant-messengers/pidgin-plugins/otr {
-	inherit fetchurl stdenv libotr pidgin;
-  };
+    inherit (xlibs) libXScrnSaver scrnsaverproto libX11 xproto kbproto;
+  } null;
 
   gimp = import ../applications/graphics/gimp {
     inherit fetchurl stdenv pkgconfig freetype fontconfig
@@ -5015,8 +5886,13 @@ rec {
   };
 
   git = import ../applications/version-management/git {
-    inherit fetchurl stdenv curl openssl zlib expat perl gettext;
-    emacs = if (getConfig ["git" "useEmacs"] true) then emacs else null;
+    inherit fetchurl stdenv curl openssl zlib expat perl gettext
+      asciidoc texinfo xmlto docbook2x
+      docbook_xsl docbook_xml_dtd_42 libxslt
+      cpio tcl tk makeWrapper subversion;
+    svnSupport = getConfig ["git" "svnSupport"] false; # for git-svn support
+    guiSupport = getConfig ["git" "guiSupport"] false;
+    perlLibs = [perlLWP perlURI perlTermReadKey subversion];
   };
 
   gkrellm = import ../applications/misc/gkrellm {
@@ -5026,9 +5902,10 @@ rec {
   };
 
   gnash = assert mesaSupported; import ../applications/video/gnash {
-    inherit fetchurl stdenv SDL SDL_mixer libogg libxml2 libjpeg mesa libpng;
+    inherit fetchurl stdenv SDL SDL_mixer libogg libxml2 libjpeg mesa libpng
+            boost freetype agg dbus curl pkgconfig x11 lib;
+    inherit (gtkLibs) glib gtk;
     GStreamer = gst_all.gstreamer;
-    inherit (xlibs) libX11 libXext libXi libXmu;
   };
 
   gocrFun = lib.sumArgs (selectVersion ../applications/graphics/gocr "0.44") {
@@ -5067,21 +5944,17 @@ rec {
     inherit (xlibs) libX11 libXft libXext libXinerama libXrandr;
   };
 
-  imagemagickFun = lib.sumArgs (selectVersion ../applications/graphics/ImageMagick "6.3.9-0" ) {
-    inherit stdenv fetchurl libtool; 
-  };
-
-  imagemagick = imagemagickFun {
-    inherit bzip2 freetype graphviz ghostscript libjpeg libpng libtiff 
-      libxml2 zlib;
+  imagemagick = import ../applications/graphics/ImageMagick {
+    inherit stdenv fetchurl bzip2 freetype graphviz ghostscript
+      libjpeg libpng libtiff libxml2 zlib libtool;
     inherit (xlibs) libX11;
-  } null;
+  };
 
-  imagemagickBig = imagemagickFun {
-    inherit bzip2 freetype graphviz ghostscript libjpeg libpng libtiff 
-      libxml2 zlib tetex librsvg;
+  imagemagickBig = import ../applications/graphics/ImageMagick {
+    inherit stdenv fetchurl bzip2 freetype graphviz ghostscript
+      libjpeg libpng libtiff libxml2 zlib tetex librsvg libtool;
     inherit (xlibs) libX11;
-  } null;
+  };
 
   inkscape = import ../applications/graphics/inkscape {
     inherit fetchurl stdenv perl perlXMLParser pkgconfig zlib
@@ -5093,8 +5966,8 @@ rec {
   };
 
   ion3 = import ../applications/window-managers/ion-3 {
-	  inherit fetchurl stdenv x11 gettext groff;
-	  lua = lua5;
+    inherit fetchurl stdenv x11 gettext groff;
+    lua = lua5;
   };
 
   irssi = import ../applications/networking/irc/irssi {
@@ -5102,7 +5975,7 @@ rec {
     inherit (gtkLibs) glib;
   };
 
-  jedit = import ../applications/jedit {
+  jedit = import ../applications/editors/jedit {
     inherit fetchurl stdenv ant;
   };
 
@@ -5110,6 +5983,11 @@ rec {
     inherit stdenv fetchurl;
   };
 
+  jwm = import ../applications/window-managers/jwm {
+    inherit fetchurl stdenv;
+    inherit (xlibs) libX11 libXext libXinerama libXpm libXft;
+  };
+
   kino = import ../applications/video/kino {
     inherit fetchurl stdenv pkgconfig libxml2 perl perlXMLParser 
       libdv libraw1394 libavc1394 libiec61883 x11 gettext cairo; /* libavformat */
@@ -5121,6 +5999,26 @@ rec {
     #  inherit ffmpeg2theora sox, vorbis-tools lame mjpegtools dvdauthor 'Q'dvdauthor growisofs mencoder;
   };
 
+  kile = import ../applications/editors/kile {
+    inherit stdenv fetchurl perl arts kdelibs zlib libpng libjpeg freetype expat;
+    inherit (xlibs) libX11 libXt libXext;
+    qt = qt3;
+  };
+
+  /*kiwixBuilderFun = lib.sumArgs (import ../applications/misc/kiwixbuilder) {
+    inherit builderDefs;
+    inherit (gnome) glib;
+    zlib = zlibStatic;
+  };
+
+  kiwixBuilder = kiwixBuilderFun null;*/
+
+  konversation = import ../applications/networking/irc/konversation {
+    inherit fetchurl stdenv perl arts kdelibs zlib libpng libjpeg expat;
+    inherit (xlibs) libX11 libXt libXext;
+    qt = qt3;
+  };
+
   kuickshow = import ../applications/graphics/kuickshow {
     inherit fetchurl stdenv kdelibs arts libpng libjpeg libtiff libungif imlib expat perl;
     inherit (xlibs) libX11 libXext libSM;
@@ -5139,6 +6037,15 @@ rec {
     inherit fetchurl stdenv builderDefs stringsWithDeps fftw ladspaH pkgconfig;
   };
 
+  ldcppFun = lib.sumArgs (selectVersion ../applications/networking/p2p/ldcpp "1.0.1") {
+    inherit builderDefs scons pkgconfig bzip2 openssl;
+    inherit (gtkLibs) gtk;
+    inherit (gnome) libglade;
+    inherit (xlibs) libX11;
+  };
+
+  ldcpp = ldcppFun null;
+
   links = import ../applications/networking/browsers/links {
     inherit fetchurl stdenv;
   };
@@ -5148,7 +6055,7 @@ rec {
   };
 
   lyx = import ../applications/misc/lyx {
-   inherit fetchurl stdenv tetex python;
+   inherit fetchurl stdenv texLive python;
    qt = qt4;
   };
 
@@ -5160,6 +6067,11 @@ rec {
     inherit fetchurl stdenv python makeWrapper;
   };
 
+  minicomFun = builderDefsPackage (selectVersion ../tools/misc/minicom "2.3") {
+    inherit ncurses;
+  };
+  minicom = minicomFun null;
+
   monodevelop = import ../applications/editors/monodevelop {
     inherit fetchurl stdenv file mono gtksourceviewsharp
             gtkmozembedsharp monodoc perl perlXMLParser pkgconfig;
@@ -5184,8 +6096,9 @@ rec {
     inherit stdenv fetchurl libao libmad libid3tag zlib;
   };
 
-  MPlayer = import ../applications/video/MPlayer {
-    inherit fetchurl stdenv freetype x11 zlib libtheora libcaca freefont_ttf libdvdnav;
+  MPlayerFun = lib.composedArgs (import ../applications/video/MPlayer) {
+    inherit fetchurl stdenv freetype x11 zlib libtheora libcaca freefont_ttf libdvdnav
+      cdparanoia;
     inherit (xlibs) libX11 libXv libXinerama libXrandr;
     alsaSupport = true;
     alsa = alsaLib;
@@ -5193,11 +6106,14 @@ rec {
     cacaSupport = true;
     xineramaSupport = true;
     randrSupport = true;
+    cddaSupport = true;
   };
 
- # commented out because it's using the new configuration style proposal which is unstable
- # should be the same as the nix expression above except support for esound :)
- /*
+  MPlayer = MPlayerFun null;
+
+  # commented out because it's using the new configuration style proposal which is unstable
+  # should be the same as the nix expression above except support for esound :)
+  /*
   MPlayer_new_config = import ../applications/video/MPlayer/newconfig.nix {
     inherit fetchurl stdenv freetype x11 zlib freefont_ttf lib;
     inherit (xlibs) libX11 xextproto;
@@ -5210,7 +6126,6 @@ rec {
   };
   */
 
-
   MPlayerPlugin = import ../applications/networking/browsers/mozilla-plugins/mplayerplug-in {
     inherit fetchurl stdenv pkgconfig firefox gettext;
     inherit (xlibs) libXpm;
@@ -5218,13 +6133,15 @@ rec {
   };
 
   # commented out because it's using the new configuration style proposal which is unstable
-  #mrxvt = import ../applications/misc/mrxvt {
-    #inherit lib fetchurl stdenv;
-    #inherit (xlibs) libXaw xproto libXt libX11 libSM libICE;
-  #};
+  /*
+  mrxvt = import ../applications/misc/mrxvt {
+    inherit lib fetchurl stdenv;
+    inherit (xlibs) libXaw xproto libXt libX11 libSM libICE;
+  };
+  */
 
   mutt = import ../applications/networking/mailreaders/mutt {
-    inherit fetchurl stdenv ncurses which openssl;
+    inherit fetchurl stdenv ncurses which openssl gdbm;
   };
 
   msmtp = import ../applications/networking/msmtp {
@@ -5283,10 +6200,43 @@ rec {
     spellChecking = false;
   };
 
+  pidgin = import ../applications/networking/instant-messengers/pidgin {
+    inherit fetchurl stdenv pkgconfig perl perlXMLParser libxml2 openssl nss
+      gtkspell aspell gettext ncurses avahi dbus dbus_glib;
+    GStreamer = gst_all.gstreamer;
+    inherit (gtkLibs) gtk;
+    inherit (gnome) startupnotification;
+    inherit (xlibs) libXScrnSaver;
+  };
+
+  pidginlatexFun = lib.sumArgs (import ../applications/networking/instant-messengers/pidgin-plugins/pidgin-latex) {
+    inherit fetchurl stdenv pkgconfig ghostscript pidgin texLive;
+    imagemagick = imagemagickBig;
+    inherit (gtkLibs) glib gtk;
+  };
+  pidginlatex = pidginlatexFun null;
+
+  pidginlatexSFFun = builderDefsPackage 
+    (import ../applications/networking/instant-messengers/pidgin-plugins/pidgin-latex/pidgin-latex-sf.nix) 
+    {
+      inherit pkgconfig pidgin texLive imagemagick which;
+      inherit (gtkLibs) glib gtk;
+    };
+  pidginlatexSF = pidginlatexSFFun null;
+
+  pidginotr = import ../applications/networking/instant-messengers/pidgin-plugins/otr {
+    inherit fetchurl stdenv libotr pidgin;
+  };
+
   pinfo = import ../applications/misc/pinfo {
     inherit fetchurl stdenv ncurses readline;
   };
 
+  pqiv = import ../applications/graphics/pqiv {
+    inherit fetchurl stdenv getopt which pkgconfig;
+    inherit (gtkLibs) gtk;
+  };
+
   # perhaps there are better apps for this task? It's how I had configured my preivous system.
   # And I don't want to rewrite all rules
   procmail = import ../applications/misc/procmail {
@@ -5299,19 +6249,14 @@ rec {
 
   pythonmagick = import ../applications/graphics/PythonMagick {
     inherit fetchurl stdenv pkgconfig imagemagick boost;
-    python = builtins.getAttr "2.5" python_alts;
+    python = python25;
   };
 
-  qemuFun = lib.sumArgs (selectVersion ../applications/virtualization/qemu "0.9.1") {
-    inherit fetchurl;
-    builderDefs = builderDefs {
-      stdenv = (overrideGCC stdenv gcc34)//{gcc=gcc34;};
-    };
-    inherit SDL zlib which;
+  qemu = import ../applications/virtualization/qemu/0.9.1.nix {
+    inherit fetchurl SDL zlib which;
+    stdenv = overrideGCC stdenv gcc34;
   };
 
-  qemu = qemuFun null;
-
   qemuImageFun = lib.sumArgs 
     (selectVersion ../applications/virtualization/qemu/linux-img "0.2") {
     inherit builderDefs fetchurl stdenv;
@@ -5319,10 +6264,14 @@ rec {
 
   qemuImage = qemuImageFun null;
 
+  quack = import ../applications/editors/emacs-modes/quack {
+    inherit fetchurl stdenv emacs;
+  };
+
   ratpoison = import ../applications/window-managers/ratpoison {
     inherit fetchurl stdenv fontconfig readline;
     inherit (xlibs) libX11 inputproto libXt libXpm libXft
-	libXtst xextproto;
+      libXtst xextproto;
   };
 
   rcs = import ../applications/version-management/rcs {
@@ -5341,6 +6290,10 @@ rec {
     libstdcpp5 = gcc33.gcc;
   };
 
+  remember = import ../applications/editors/emacs-modes/remember {
+    inherit fetchurl stdenv texinfo emacs bbdb;
+  };
+
   rsync = import ../applications/networking/sync/rsync {
     inherit fetchurl stdenv;
   };
@@ -5362,7 +6315,7 @@ rec {
 
   skype_linux = import ../applications/networking/skype {
     inherit fetchurl stdenv;
-    inherit glibc alsaLib freetype fontconfig libsigcxx gcc41;
+    inherit glibc alsaLib freetype fontconfig libsigcxx gcc;
     inherit (xlibs) libSM libICE libXi libXrender libXrandr libXfixes libXcursor 
                     libXinerama libXext libX11;
   };
@@ -5373,31 +6326,28 @@ rec {
   };
 
   sndFun = lib.sumArgs (import ../applications/audio/snd) {
-  	inherit fetchurl stdenv builderDefs stringsWithDeps lib;
-	inherit pkgconfig gmp gettext;
-	inherit (xlibs) libXpm;
-	inherit (gtkLibs) gtk glib;
+    inherit fetchurl stdenv builderDefs stringsWithDeps lib;
+    inherit pkgconfig gmp gettext;
+    inherit (xlibs) libXpm;
+    inherit (gtkLibs) gtk glib;
   };
 
   snd = sndFun {
-  	inherit guile mesa libtool;
+    inherit guile mesa libtool;
   } null;
 
-  # commented out because it's using the new configuration style proposal which is unstable
-  
-  sox = if builtins ? listToAttrs then  import ../applications/misc/audio/sox {
+  sox = import ../applications/misc/audio/sox {
     inherit fetchurl stdenv lib mkDerivationByConfiguration;
     # optional features 
     inherit alsaLib; # libao
     inherit libsndfile libogg flac libmad lame libsamplerate;
-     # Using the default nix ffmpeg I get this error when linking
-     # .libs/libsox_la-ffmpeg.o: In function `audio_decode_frame':
-     # /tmp/nix-7957-1/sox-14.0.0/src/ffmpeg.c:130: undefined reference to `avcodec_decode_audio2
-     # That's why I'v added ffmpeg_svn
+    # Using the default nix ffmpeg I get this error when linking
+    # .libs/libsox_la-ffmpeg.o: In function `audio_decode_frame':
+    # /tmp/nix-7957-1/sox-14.0.0/src/ffmpeg.c:130: undefined reference to `avcodec_decode_audio2
+    # That's why I'v added ffmpeg_svn
     ffmpeg = ffmpeg_svn;
-  } else null;
+  };
   
-
   spoofax = import ../applications/editors/eclipse/plugins/spoofax {
     inherit fetchurl stdenv;
   };
@@ -5418,12 +6368,14 @@ rec {
     bdbSupport = getConfig ["subversion" "bdbSupport"] true;
     httpServer = getConfig ["subversion" "httpServer"] false;
     sslSupport = getConfig ["subversion" "sslSupport"] true;
-	pythonBindings = getConfig ["subversion" "pythonBindings"] false;
+    pythonBindings = getConfig ["subversion" "pythonBindings"] false;
     perlBindings = getConfig ["subversion" "perlBindings"] false;
-	javahlBindings = getConfig ["subversion" "javahlBindings"] false;
+    javahlBindings = getConfig ["subversion" "javahlBindings"] false;
     compressionSupport = getConfig ["subversion" "compressionSupport"] true;
     httpd = apacheHttpd;
   };
+  
+  subversion14svnmerge = svnmergeFun subversion14;
 
   subversionWithJava = import ../applications/version-management/subversion-1.2.x {
     inherit fetchurl stdenv openssl db4 expat jdk;
@@ -5435,6 +6387,12 @@ rec {
     javahlBindings = true;
   };
 
+  svk = perlSVK;
+
+  svnmergeFun = subversion : (import ../applications/version-management/subversion-1.4.x/svnmerge.nix ) {
+    inherit subversion stdenv shebangfix python;
+  };
+
   sylpheed = import ../applications/networking/mailreaders/sylpheed {
     inherit fetchurl stdenv pkgconfig openssl gpgme;
     inherit (gtkLibs) gtk;
@@ -5444,10 +6402,15 @@ rec {
 
   # linux only by now 
   synergy = import ../applications/misc/synergy {
-    inherit fetchcvs stdenv x11;
+    inherit bleedingEdgeRepos stdenv x11;
     inherit (xlibs) xextproto libXtst inputproto;
   };
 
+  tailor = builderDefsPackage (selectVersion ../applications/version-management/tailor "0.9.31") {
+    python = python25;
+    inherit makeWrapper;
+  } null;
+
   /* does'nt work yet i686-linux only (32bit version)
   teamspeak_client = import ../applications/networking/instant-messengers/teamspeak/client.nix {
     inherit fetchurl stdenv;
@@ -5455,6 +6418,18 @@ rec {
   };
   */
 
+  taskJuggler = import ../applications/misc/taskjuggler {
+    inherit stdenv fetchurl;
+    inherit zlib libpng perl expat;
+    qt = qt3;
+
+    inherit (xlibs) libX11 libXext libSM libICE;
+
+    # KDE support is not working yet.
+    inherit kdelibs kdebase;
+    withKde = pkgs.getConfig ["taskJuggler" "kde"] false;
+  };
+
   thunderbird = import ../applications/networking/mailreaders/thunderbird-2.x {
     inherit fetchurl stdenv pkgconfig perl zip libjpeg libpng zlib cairo;
     inherit (gtkLibs) gtk;
@@ -5476,6 +6451,10 @@ rec {
     inherit (xorg) xset fontschumachermisc;
   };
 
+  uucpFun = builderDefsPackage (selectVersion ../tools/misc/uucp "1.07") {
+  };
+  uucp = uucpFun null;
+
   valknut = import ../applications/networking/p2p/valknut {
     inherit fetchurl stdenv perl x11 libxml2 libjpeg libpng openssl dclib;
     qt = qt3;
@@ -5493,14 +6472,14 @@ rec {
 
   vimHugeX = import ../applications/editors/vim {
     inherit fetchurl stdenv lib ncurses pkgconfig
-    	perl python tcl;
+      perl python tcl;
     inherit (xlibs) libX11 libXext libSM libXpm
-	libXt libXaw libXau;
+      libXt libXaw libXau;
     inherit (gtkLibs) glib gtk;
 
     # Looks like python and perl can conflict
     flags = ["hugeFeatures" "gtkGUI" "x11Support"
-    	/*"perlSupport"*/ "pythonSupport" "tclSupport"];
+      /*"perlSupport"*/ "pythonSupport" "tclSupport"];
   };
 
   vim_configurable = import ../applications/editors/vim/configurable.nix {
@@ -5537,7 +6516,7 @@ rec {
 
   vorbisTools = import ../applications/audio/vorbis-tools {
     inherit fetchurl stdenv libogg libvorbis libao pkgconfig curl glibc
-    	    speex flac;
+      speex flac;
   };
 
   w3m = import ../applications/networking/browsers/w3m {
@@ -5548,16 +6527,15 @@ rec {
 
   # I'm keen on wmiimenu only  >wmii-3.5 no longer has it... 
   wmiimenu = import ../applications/window-managers/wmii31 {
-    libixp = libixp03;
+    libixp = libixp_for_wmii;
     inherit fetchurl /* fetchhg */ stdenv gawk;
     inherit (xlibs) libX11;
-    includeUnpack = getConfig ["stdenv" "includeUnpack"] false;
   };
 
   wmiiSnap = import ../applications/window-managers/wmii {
     libixp = libixp_for_wmii;
     inherit fetchurl /* fetchhg */ stdenv gawk;
-    inherit (xlibs) libX11;
+    inherit (xlibs) libX11 xextproto libXt libXext;
     includeUnpack = getConfig ["stdenv" "includeUnpack"] false;
   };
 
@@ -5567,12 +6545,18 @@ rec {
 
   wrapFirefox = firefox: nameSuffix: import ../applications/networking/browsers/firefox-wrapper {
     inherit stdenv firefox nameSuffix;
-    plugins = []
-    ++ lib.optional (system == "i686-linux") flashplayer
-    # RealPlayer is disabled by default for legal reasons.
-    ++ lib.optional (system != "i686-linux" && getConfig ["firefox" "enableRealPlayer"] false) RealPlayer
-    ++ lib.optional (getConfig ["firefox" "enableMPlayer"] true) MPlayerPlugin
-    ++ lib.optional (supportsJDK && getConfig ["firefox" "jre"] true && jrePlugin ? mozillaPlugin) jrePlugin;
+    plugins =
+      let enableAdobeFlash = getConfig [ "firefox" "enableAdobeFlash" ] false
+            && system == "i686-linux";
+      in
+       ([]
+        ++ lib.optional (!enableAdobeFlash) gnash
+        ++ lib.optional (enableAdobeFlash)  flashplayer
+        # RealPlayer is disabled by default for legal reasons.
+        ++ lib.optional (system != "i686-linux" && getConfig ["firefox" "enableRealPlayer"] false) RealPlayer
+        ++ lib.optional (getConfig ["firefox" "enableMPlayer"] true) MPlayerPlugin
+        ++ lib.optional (supportsJDK && getConfig ["firefox" "jre"] true && jrePlugin ? mozillaPlugin) jrePlugin
+       );
   };
 
   x11vncFun = lib.sumArgs (selectVersion ../tools/X11/x11vnc "0.9.3") {
@@ -5584,6 +6568,13 @@ rec {
 
   x11vnc = x11vncFun null;
 
+  x2vncFun = lib.sumArgs (selectVersion ../tools/X11/x2vnc "1.7.2") {
+    inherit builderDefs;
+    inherit (xlibs) libX11 xproto xextproto libXext libXrandr randrproto;
+  };
+
+  x2vnc = x2vncFun null;
+
   xara = import ../applications/graphics/xara {
     inherit fetchurl stdenv autoconf automake libtool gettext cvs wxGTK
       pkgconfig libxml2 zip libpng libjpeg shebangfix perl freetype;
@@ -5611,8 +6602,8 @@ rec {
   };
 
   xineUI = import ../applications/video/xine-ui {
-	inherit fetchurl stdenv pkgconfig x11 xineLib libpng readline ncurses curl;
-	inherit (xorg) libXext libXv libXxf86vm libXtst inputproto;
+    inherit fetchurl stdenv pkgconfig x11 xineLib libpng readline ncurses curl;
+    inherit (xorg) libXext libXv libXxf86vm libXtst inputproto;
   };
 
   xmms = import ../applications/audio/xmms {
@@ -5622,17 +6613,38 @@ rec {
     stdenv = overrideGCC stdenv gcc34; # due to problems with gcc 4.x
   };
 
+  xmobar = import ../applications/misc/xmobar {
+    inherit cabal X11;
+  };
+
   xmonad = import ../applications/window-managers/xmonad {
-    inherit stdenv fetchurl ghc X11;
+    inherit cabal X11;
     inherit (xlibs) xmessage;
   };
 
+  xmonadContrib = import ../applications/window-managers/xmonad/xmonad-contrib.nix {
+    inherit cabal xmonad X11;
+  };
+
+  xneur = import ../applications/misc/xneur {
+    inherit fetchurl stdenv pkgconfig pcre libxml2 aspell; 
+    GStreamer=gst_all.gstreamer;
+    inherit (xlibs) libX11;
+    inherit (gtkLibs) glib;
+  }; 
+
   xpdf = import ../applications/misc/xpdf {
     inherit fetchurl stdenv x11 freetype t1lib;
     motif = lesstif;
     base14Fonts = "${ghostscript}/share/ghostscript/fonts";
   };
 
+  xpra = import ../tools/X11/xpra {
+    inherit stdenv fetchurl pkgconfig python pygtk xlibs makeWrapper;
+    inherit (gtkLibs) gtk;
+    pyrex = pyrex095;
+  };
+
   xscreensaverFun = lib.sumArgs (selectVersion ../applications/graphics/xscreensaver "5.04") {
     inherit stdenv fetchurl builderDefs lib pkgconfig bc perl intltool;
     inherit (xlibs) libX11 libXmu;
@@ -5658,7 +6670,7 @@ rec {
   xmacro = import ../tools/X11/xmacro {
     inherit fetchurl stdenv;
     inherit (xlibs) libX11 libXi 
-	libXtst xextproto inputproto;
+  libXtst xextproto inputproto;
   };
 
   xmove = import ../applications/misc/xmove {
@@ -5722,24 +6734,29 @@ rec {
   };
 
   fsg = import ../games/fsg {
-	inherit stdenv fetchurl pkgconfig;
-	inherit (gtkLibs) glib gtk;
-	wxGTK = wxGTK28deps {unicode = false;};
+    inherit stdenv fetchurl pkgconfig;
+    inherit (gtkLibs) glib gtk;
+    wxGTK = wxGTK28deps {unicode = false;};
   };
-	
+  
   fsgAltBuild = import ../games/fsg/alt-builder.nix {
-	inherit stdenv fetchurl;
-	wxGTK = wxGTK28deps {unicode = false;};
-	stringsWithDeps = import ../lib/strings-with-deps.nix {
-		inherit stdenv lib;
-	};
-	inherit builderDefs;
+    inherit stdenv fetchurl;
+    wxGTK = wxGTK28deps {unicode = false;};
+    stringsWithDeps = import ../lib/strings-with-deps.nix {
+      inherit stdenv lib;
+    };
+    inherit builderDefs;
   };
 
   gemrb = import ../games/gemrb {
     inherit fetchurl stdenv SDL openal freealut zlib libpng python;
   };
 
+  openttd = import ../games/openttd {
+    inherit fetchurl stdenv SDL libpng;
+    zlib = zlibStatic;
+  };
+
   quake3demo = import ../games/quake3/wrapper {
     name = "quake3-demo";
     description = "Demo of Quake 3 Arena, a classic first-person shooter";
@@ -5766,8 +6783,7 @@ rec {
 
   # You still can override by passing more arguments.
   spaceOrbitFun = lib.sumArgs (selectVersion ../games/orbit "1.01") {
-    inherit fetchurl stdenv builderDefs 
-      mesa freeglut;
+    inherit fetchurl stdenv builderDefs mesa freeglut;
     inherit (gnome) esound;
     inherit (xlibs) libXt libX11 libXmu libXi libXext;
   };
@@ -5819,14 +6835,14 @@ rec {
     inherit
       fetchurl fetchsvn zlib perl openssl pcre pkgconfig libjpeg libpng libtiff
       libxml2 libxslt libtool libusb expat freetype bzip2 cmake cluceneCore libgcrypt gnupg
-	  cppunit cyrus_sasl openldap enchant exiv2 samba nss log4cxx aspell
+      cppunit cyrus_sasl openldap enchant exiv2 samba nss log4cxx aspell
       shared_mime_info alsaLib libungif cups mesa boost gpgme gettext redland
-	  xineLib libgphoto2 djvulibre libogg flac lame libvorbis poppler readline
-	  saneBackends chmlib python libzip gmp sqlite libidn runCommand lib
-	  openbabel ocaml facile stdenv jasper fam indilib libnova
-	  libarchive dbus;
-	#flac = builtins.getAttr "1.1.2" flacAlts;
-	cdparanoia = cdparanoiaIII;
+      xineLib libgphoto2 djvulibre libogg flac lame libvorbis poppler readline
+      saneBackends chmlib python libzip gmp sqlite libidn runCommand lib
+      openbabel ocaml facile stdenv jasper fam indilib libnova
+      libarchive dbus;
+    #flac = builtins.getAttr "1.1.2" flacAlts;
+    cdparanoia = cdparanoiaIII;
     inherit (xlibs)
       inputproto kbproto scrnsaverproto xextproto xf86miscproto
       xf86vidmodeproto xineramaproto xproto libICE libX11 libXau libXcomposite
@@ -5835,7 +6851,7 @@ rec {
       libxkbfile libXinerama;
     inherit (gtkLibs) glib;
     qt = qt4;
-	bison = bison23;
+    bison = bison23;
     openexr = openexr_1_6_1 ;
   });
 
@@ -5847,6 +6863,35 @@ rec {
   };
   
 
+  ### SCIENCE/BIOLOGY
+
+  clustalw2 = import ../applications/science/biology/clustalw2 {
+    inherit fetchurl stdenv;
+  };
+
+  emboss = import ../applications/science/biology/emboss {
+    inherit fetchurl stdenv readline perl libpng zlib;
+		inherit (xorg) libX11 libXt;
+  };
+
+  mrbayes = import ../applications/science/biology/mrbayes {
+    inherit fetchurl stdenv readline;
+  };
+
+  ncbi_tools = import ../applications/science/biology/ncbi-tools {
+    inherit fetchurl stdenv cpio;
+  };
+
+  paml = import ../applications/science/biology/paml {
+    inherit fetchurl stdenv;
+  };
+
+  ### SCIENCE/LOGIC
+
+  coq = import ../applications/science/logic/coq {
+    inherit fetchurl stdenv ocaml ncurses;
+  };
+
   ### MISC
 
   atari800 = import ../misc/emulators/atari800 {
@@ -5858,7 +6903,7 @@ rec {
   };
  
   auctex = import ../misc/tex/auctex {
-    inherit stdenv fetchurl emacs tetex;
+    inherit stdenv fetchurl emacs texLive;
   };
 
   busybox = import ../misc/busybox {
@@ -5877,6 +6922,18 @@ rec {
     inherit fetchurl stdenv SDL;
   };
 
+  dpkg = import ../tools/package-management/dpkg {
+    inherit fetchurl stdenv perl zlib bzip2;
+  };
+
+  freestyle = import ../misc/freestyle {
+    inherit fetchurl freeglut qt4 libpng lib3ds libQGLViewer swig;
+    inherit (xlibs) libXi;
+    #stdenv = overrideGCC stdenv gcc41;
+    inherit stdenv;
+    python = python25;
+  };
+
   generator = import ../misc/emulators/generator {
     inherit fetchurl stdenv SDL nasm zlib bzip2 libjpeg;
     inherit (gtkLibs1x) gtk;
@@ -5893,24 +6950,26 @@ rec {
   }));
 
   # commented out because it's using the new configuration style proposal which is unstable
-  #gxemul = (import ../misc/gxemul) {
-    #inherit lib stdenv fetchurl;
-    #inherit (xlibs) libX11;
-  #};
+  /*
+  gxemul = (import ../misc/gxemul) {
+    inherit lib stdenv fetchurl;
+    inherit (xlibs) libX11;
+  };
+  */
 
   # using the new configuration style proposal which is unstable
   /*
   jackaudio = import ../misc/jackaudio {
-   inherit mkDerivationByConfiguration 
+    inherit mkDerivationByConfiguration 
            ncurses lib stdenv fetchurl;
-   flags = [ "posix_shm" "timestamps"];
+    flags = [ "posix_shm" "timestamps"];
   };
   */
  
   keynav = import ../tools/X11/keynav {
-	inherit stdenv fetchurl;
-	inherit (xlibs) libX11 xextproto libXtst 
-		imake libXi libXext;
+    inherit stdenv fetchurl;
+    inherit (xlibs) libX11 xextproto libXtst 
+    imake libXi libXext;
   };
 
   lazylist = import ../misc/tex/lazylist {
@@ -5942,11 +7001,19 @@ rec {
     db4 = db45;
   };
 
+  nixRepositoryManager = import ../tools/package-management/nixRepositoryManager {
+    inherit fetchurl stdenv bleedingEdgeRepos lib writeText getConfig;
+    ghc = ghcsAndLibs.ghc68.ghc;
+    fetchdarcs = fetchdarcs2;
+  };
+
+  /*
   nixStatic = import ../tools/package-management/nix-static {
     inherit fetchurl stdenv perl curl autoconf automake libtool;
     aterm = aterm242fixes;
     bdb = db4;
   };
+  */
 
   # The bleeding edge.
   nixUnstable = import ../tools/package-management/nix/unstable.nix {
@@ -5955,10 +7022,18 @@ rec {
     db4 = db45;
   };
 
-  nixCustomFun = src: preConfigure: configureFlags:
+  # The really bleeding edge.
+  nixNoBDB = lowPrio (nixCustomFun
+    (fetchurl {
+      url = http://nixos.org/releases/nix-no-bdb/nix-0.12pre11675-jvhinhlm/nix-0.12pre11675.tar.bz2;
+      sha256 = "1c20dd159f0f7ffb7105745426b64097f833b265604e14ff77f94da2d145d44b";
+    })
+    "" [] "");
+
+  nixCustomFun = src: preConfigure: enableScripts: configureFlags:
     import ../tools/package-management/nix/custom.nix {
       inherit fetchurl stdenv perl curl bzip2 openssl src preConfigure automake 
-        autoconf libtool configureFlags;
+        autoconf libtool configureFlags enableScripts lib;
       bison = bison23;
       flex = flex2533;
       aterm = aterm242fixes;
@@ -5967,7 +7042,7 @@ rec {
     };
 
   ntfs3g = import ../misc/ntfs-3g {
-    inherit fetchurl stdenv fuse pkgconfig;
+    inherit fetchurl stdenv fuse pkgconfig utillinux;
   };
 
   ntfsprogs = import ../misc/ntfsprogs {
@@ -5987,6 +7062,16 @@ rec {
     inherit fetchurl stdenv tetex lazylist;
   };
 
+  psiFun = builderDefsPackage 
+    (selectVersion ../applications/networking/instant-messengers/psi "0.11") 
+    {
+      inherit builderDefs zlib aspell sox openssl;
+      inherit (xlibs) xproto libX11 libSM libICE;
+      qt = qt4;
+    };
+
+  psi = psiFun null;
+
   putty = import ../applications/networking/remote/putty {
     inherit stdenv fetchurl ncurses;
     inherit (gtkLibs1x) gtk;
@@ -6002,32 +7087,15 @@ rec {
 
   saneBackends = import ../misc/sane-backends {
     inherit fetchurl stdenv libusb;
-	gt68xxFirmware = 
-		getConfig ["sane" "gt68xxFirmware"] null;
+    gt68xxFirmware = getConfig ["sane" "gt68xxFirmware"] null;
   };
 
   saneFrontends = import ../misc/sane-front {
-    inherit fetchurl stdenv pkgconfig libusb
-	saneBackends;
+    inherit fetchurl stdenv pkgconfig libusb saneBackends;
     inherit (gtkLibs) gtk;
     inherit (xlibs) libX11;
   };
 
-  # State Nix
-  snix = import ../tools/package-management/snix {
-    inherit fetchurl stdenv perl curl bzip2 openssl;
-    inherit libtool automake autoconf docbook5 docbook5_xsl libxslt docbook_xml_dtd_43 w3m;
-
-    aterm = aterm242fixes;
-    db4 = db45;
-
-    bison = bison23;
-    flex = flex2533;
-
-    inherit ext3cowtools e3cfsprogs rsync;
-    ext3cow_kernel = kernel;
-  };
-
   synaptics = import ../misc/synaptics {
     inherit fetchurl stdenv pkgconfig;
     inherit (xlibs) libX11 libXi libXext pixman xf86inputevdev;
@@ -6038,17 +7106,74 @@ rec {
     inherit fetchurl stdenv flex bison zlib libpng ncurses ed;
   };
 
-  /*tetexX11 = import ../misc/tex/tetex {
+  /*
+  tetexX11 = import ../misc/tex/tetex {
     inherit fetchurl stdenv flex bison zlib libpng ncurses ed;
     inherit (xlibs) libX11 libXext libXmu libXaw libXt libXpm;
     inherit freetype t1lib;
     builderX11 = true;
-  };*/
+  };
+  */
 
   texFunctions = import ../misc/tex/nix {
-    inherit stdenv perl tetex graphviz ghostscript;
+    inherit stdenv perl tetex graphviz ghostscript imagemagick;
   };
 
+  texLiveFun = builderDefsPackage (import ../misc/tex/texlive) {
+    inherit builderDefs zlib bzip2 ncurses libpng ed
+      gd t1lib freetype icu perl ruby;
+    inherit (xlibs) libXaw libX11 xproto libXt libXpm
+      libXmu libXext xextproto libSM libICE;
+    flex = flex2535;
+    bison = bison23;
+    ghostscript = ghostscriptX;
+  };
+
+  /* Look in configurations/misc/raskin.nix for usage example (around revisions 
+  where TeXLive was added) 
+  
+  (texLiveAggregationFun {
+    paths = [texLive texLiveExtra texLiveCMSuper 
+      texLiveBeamer
+    ];
+  } null)
+
+  You need to use texLiveAggregationFun to regenerate, say, ls-R (TeX-related file list)
+  Just installing a few packages doesn't work.
+  */
+  texLive = texLiveFun null;
+  texLiveAggregationFun = builderDefsPackage (import ../misc/tex/texlive/aggregate.nix);
+
+  texLiveContextFun = builderDefsPackage (import ../misc/tex/texlive/context.nix) {
+    inherit texLive;
+  };
+  texLiveContext = texLiveContextFun null;
+
+  texLiveExtraFun = builderDefsPackage (import ../misc/tex/texlive/extra.nix) {
+    inherit texLive;
+  };
+  texLiveExtra = texLiveExtraFun null;
+
+  texLiveCMSuperFun = builderDefsPackage (import ../misc/tex/texlive/cm-super.nix) {
+    inherit texLive;
+  };
+  texLiveCMSuper = texLiveCMSuperFun null;
+
+  texLiveLatexXColorFun = builderDefsPackage (import ../misc/tex/texlive/xcolor.nix) {
+    inherit texLive;
+  };
+  texLiveLatexXColor = texLiveLatexXColorFun null;
+
+  texLivePGFFun = builderDefsPackage (import ../misc/tex/texlive/pgf.nix) {
+    inherit texLiveLatexXColor texLive;
+  };
+  texLivePGF = texLivePGFFun null;
+
+  texLiveBeamerFun = builderDefsPackage (import ../misc/tex/texlive/beamer.nix) {
+    inherit texLiveLatexXColor texLivePGF texLive;
+  };
+  texLiveBeamer = texLiveBeamerFun null;
+
   toolbuslib = import ../development/libraries/toolbuslib {
     inherit stdenv fetchurl aterm;
   };
@@ -6066,9 +7191,11 @@ rec {
       pythonBindings = true; # Enable python bindings
     };
 
-    pysqlite = import ../development/libraries/pysqlite {
-      inherit stdenv fetchurl python sqlite;
-    };
+    inherit pysqlite;
+  };
+    
+  pysqlite = import ../development/libraries/pysqlite {
+    inherit stdenv fetchurl python sqlite;
   };
 
   wine = import ../misc/emulators/wine {
@@ -6077,12 +7204,18 @@ rec {
       fontconfig fontforge libxml2 libxslt openssl;
   };
 
+  xosd = import ../misc/xosd {
+    inherit fetchurl stdenv;
+    inherit (xlibs) libX11 libXext libXt xextproto xproto;
+  };
+
   xsane = import ../misc/xsane {
     inherit fetchurl stdenv pkgconfig libusb
-	saneBackends saneFrontends;
+      saneBackends saneFrontends;
     inherit (gtkLibs) gtk;
     inherit (xlibs) libX11;
   };
 
+  #my_env = import ../misc/my_env;
 
-}
+}; in pkgs
diff --git a/pkgs/top-level/build-for-release.nix b/pkgs/top-level/build-for-release.nix
index 6c18f40623a..3018b8bef69 100644
--- a/pkgs/top-level/build-for-release.nix
+++ b/pkgs/top-level/build-for-release.nix
@@ -78,7 +78,6 @@ let
     iana_etc
     iputils
     irssi
-    iwlwifi
     jakartaregexp
     jdkPlugin
     jetty
@@ -90,9 +89,8 @@ let
     kcachegrind
     kdebase
     keen4
-    kernel
-    klibc
     ktorrent
+    kvm
     less
     lhs2tex
     libtool
@@ -148,7 +146,6 @@ let
     sdf
     slim
     spidermonkey
-    splashutils
     ssmtp
     strace
     strategoxt
@@ -186,7 +183,6 @@ let
     xineUI
     xkeyboard_config
     xmltv
-    xmms
     xorg_sys_opengl
     xsel
     xterm
@@ -219,6 +215,13 @@ let
     gnomeutils
     metacity
     ;
+  inherit ((allPackages {system = "i686-linux";}).kernelPackages_2_6_23)
+    iwlwifi
+    kernel
+    klibc
+    splashutils
+    ;
+    kernelNew = ((allPackages {system = "i686-linux";}).kernelPackages_2_6_25).kernel;
   };
 
   x86_64LinuxPkgs = {inherit (allPackages {system = "x86_64-linux";})
@@ -234,13 +237,15 @@ let
     firefoxWrapper
     gcc
     hello
-    iwlwifi
-    kernel
     libtool
     nixUnstable
     subversion
     pan
     ;    
+  inherit ((allPackages {system = "i686-linux";}).kernelPackages_2_6_23)
+    iwlwifi
+    kernel
+    ;
   inherit ((allPackages {system = "i686-linux";}).xorg)
     xorgserver
     ;
@@ -250,6 +255,7 @@ let
     aterm
     autoconf
     #automake19x
+    curl
     docbook5
     docbook_xml_dtd_42
     docbook_xml_dtd_43
@@ -259,7 +265,6 @@ let
     libxml2
     libxslt
     nxml
-    realCurl
     subversion
     unzip
   ;};
diff --git a/pkgs/top-level/builder-defs.nix b/pkgs/top-level/builder-defs.nix
index d06ebb94103..112f6b5c2ff 100644
--- a/pkgs/top-level/builder-defs.nix
+++ b/pkgs/top-level/builder-defs.nix
@@ -3,6 +3,8 @@ args: with args; with stringsWithDeps; with lib;
 {
 	inherit writeScript; 
 
+	src = getAttr ["src"] "" args;
+
 	addSbinPath = getAttr ["addSbinPath"] false args;
 
 	forceShare = if args ? forceShare then args.forceShare else ["man" "doc" "info"];
@@ -11,10 +13,14 @@ args: with args; with stringsWithDeps; with lib;
 		(if hasSuffixHack ".tar" s then "tar"
 		else if (hasSuffixHack ".tar.gz" s) || (hasSuffixHack ".tgz" s) then "tgz" 
 		else if (hasSuffixHack ".tar.bz2" s) || (hasSuffixHack ".tbz2" s) then "tbz2"
+		else if (hasSuffixHack ".tar.lzma" s) then "tar.lzma"
 		else if (hasSuffixHack ".zip" s) || (hasSuffixHack ".ZIP" s) then "zip"
 		else if (hasSuffixHack "-cvs-export" s) then "cvs-dir"
 		else if (hasSuffixHack ".nar.bz2" s) then "narbz2"
 
+		# Mostly for manually specified directories..
+		else if (hasSuffixHack "/" s) then "dir"
+
 		# Last block - for single files!! It should be always after .tar.*
 		else if (hasSuffixHack ".bz2" s) then "plain-bz2"
 
@@ -185,6 +191,9 @@ args: with args; with stringsWithDeps; with lib;
 	" else if (archiveType s) == "tbz2" then "
 		tar xvjf '${s}'
 		cd \"\$(tar tjf '${s}' | head -1 | sed -e 's@/.*@@' )\"
+	" else if (archiveType s) == "tar.lzma" then "
+		unlzma -d -c <'${s}' | tar xv
+		cd \"\$(unlzma -d -c <'${s}' | tar t | head -1 | sed -e 's@/.*@@' )\"
 	" else if (archiveType s) == "zip" then "
 		unzip '${s}'
 		cd \"$( unzip -lqq '${s}' | tail -1 | 
@@ -193,6 +202,10 @@ args: with args; with stringsWithDeps; with lib;
 		cp -r '${s}' .
 		cd \$(basename ${s})
 		chmod u+rwX -R .
+	" else if (archiveType s) == "dir" then "
+		cp -r '${s}' .
+		cd \$(basename ${s})
+		chmod u+rwX -R .
 	" else if (archiveType s) == "narbz2" then "
 		bzip2 <${s} | nix-store --restore \$PWD/\$(basename ${s} .nar.bz2)
 		cd \$(basename ${s} .nar.bz2)
@@ -206,8 +219,10 @@ args: with args; with stringsWithDeps; with lib;
 		(if args ? goSrcDir then args.goSrcDir else "")
 	) ["minInit"];
 
+	configureCommand = getAttr ["configureCommand"] "./configure" args;
+
 	doConfigure = FullDepEntry ("
-		./configure --prefix=\"\$prefix\" ${toString configureFlags}
+		${configureCommand} --prefix=\"\$prefix\" ${toString configureFlags}
 	") ["minInit" "addInputs" "doUnpack"];
 
 	doAutotools = FullDepEntry ("
@@ -230,6 +245,16 @@ args: with args; with stringsWithDeps; with lib;
 		python setup.py install --prefix=\"\$prefix\" 
 		") ["minInit" "addInputs" "doUnpack"];
 
+	doPythonConfigure = FullDepEntry ('' 
+	  pythonVersion=$(toPythonPath "$prefix")
+	  pythonVersion=''${pythonVersion#*/lib/python}
+	  pythonVersion=''${pythonVersion%%/site-packages}
+	  ${if args ? extraPythonConfigureCommand then 
+	    args.extraPythonConfigureCommand 
+	  else ""}
+	  python configure.py -b "$prefix/bin" -d "$(toPythonPath "$prefix")" -v "$prefix/share/sip" ${toString configureFlags}
+	'') ["minInit" "addInputs" "doUnpack"]; 
+
 	doMakeInstall = FullDepEntry ("
 		make ${toString (getAttr ["makeFlags"] "" args)} "+
 			"${toString (getAttr ["installFlags"] "" args)} install") ["doMake"];
@@ -274,6 +299,23 @@ args: with args; with stringsWithDeps; with lib;
 
 	doWrap = cmd: FullDepEntry (wrapEnv cmd (getAttr ["wrappedEnv"] [] args)) ["minInit"];
 
+	makeManyWrappers = wildcard : wrapperFlags : FullDepEntry (''
+	  for i in ${wildcard}; do
+	    wrapProgram "$i" ${wrapperFlags}
+	  done
+	'') ["minInit" "addInputs" "defEnsureDir"];
+
+	wrapBinContentsPython = (makeManyWrappers 
+	  ''$out/bin/*'' 
+	  pythonWrapperArguments
+	);
+
+	pythonWrapperArguments = 
+	  (''--prefix PYTHONPATH : $(toPythonPath $out)'' +
+	  ''''${PYTHONPATH:+ --prefix PYTHONPATH : $PYTHONPATH}'');
+
+	preservePathWrapperArguments = ''''${PATH:+ --prefix PATH : $PATH }'';
+
 	doPropagate = FullDepEntry ("
 		ensureDir \$out/nix-support
 		echo '${toString (getAttr ["propagatedBuildInputs"] [] args)}' >\$out/nix-support/propagated-build-inputs
@@ -385,4 +427,93 @@ args: with args; with stringsWithDeps; with lib;
           GHC_PACKAGE_PATH=\$PACKAGE_DB ./register.sh
         " ["defCreateEmptyPackageDatabaseAndSetupHook" "defCabalSetupCmd"];
 
+	realPhaseNames = args.phaseNames ++ 
+	  ["doForceShare" "doPropagate"]
+	  ++
+	  (optional (getAttr ["alwaysFail"] false args) "doFail")
+	  ;
+
+	doFail = noDepEntry "
+	  echo 'Failing to keep builddir (and to invalidate result).'
+	  a() { return 127; } ; a ;
+	";
+        
+	extraDerivationAttrs = lib.getAttr ["extraDerivationAttrs"] {} args;
+
+	builderDefsPackage = bd: func: args: (
+	let localDefs = bd (func ((bd null) // args)) args null; in
+
+	stdenv.mkDerivation ((rec {
+	  inherit (localDefs) name;
+	  builder = writeScript (name + "-builder")
+	    (textClosure localDefs localDefs.realPhaseNames);
+	  meta = localDefs.meta // {inherit src;};
+	}) // (if localDefs ? propagatedBuildInputs then {
+	  inherit (localDefs) propagatedBuildInputs;
+	} else {}) // extraDerivationAttrs)
+	);
+
+   generateFontsFromSFD = noDepEntry(''
+   	for i in *.sfd; do
+		${args.fontforge}/bin/fontforge -c \
+			'Open($1);
+			${optionalString (args ? extraFontForgeCommands) args.extraFontForgeCommands
+			}Reencode("unicode");
+			 ${optionalString (getAttr ["createTTF"] true args) ''Generate($1:r + ".ttf");''}
+			 ${optionalString (getAttr ["createOTF"] true args) ''Generate($1:r + ".otf");''}
+			 Reencode("TeX-Base-Encoding");
+			 ${optionalString (getAttr ["createAFM"] true args) ''Generate($1:r + ".afm");''}
+			 ${optionalString (getAttr ["createPFM"] true args) ''Generate($1:r + ".pfm");''}
+			 ${optionalString (getAttr ["createPFB"] true args) ''Generate($1:r + ".pfb");''}
+			 ${optionalString (getAttr ["createMAP"] true args) ''Generate($1:r + ".map");''}
+			 ${optionalString (getAttr ["createENC"] true args) ''Generate($1:r + ".enc");''}
+			' $i; 
+	done
+   '');
+
+   installFonts = FullDepEntry (''
+   	ensureDir $out/share/fonts/truetype/public/${args.name}
+   	ensureDir $out/share/fonts/opentype/public/${args.name}
+   	ensureDir $out/share/fonts/type1/public/${args.name}
+   	ensureDir $out/share/texmf/fonts/enc/${args.name}
+   	ensureDir $out/share/texmf/fonts/map/${args.name}
+
+	cp *.ttf $out/share/fonts/truetype/public/${args.name} || echo No TrueType fonts
+	cp *.otf $out/share/fonts/opentype/public/${args.name} || echo No OpenType fonts
+   	cp *.{pfm,afm,pfb} $out/share/fonts/type1/public/${args.name} || echo No Type1 Fonts
+   	cp *.enc $out/share/texmf/fonts/enc/${args.name} || echo No fontenc data
+   	cp *.map $out/share/texmf/fonts/map/${args.name} || echo No fontmap data
+   '') ["minInit" "defEnsureDir"];
+
+   simplyShare = shareName: FullDepEntry (''
+     ensureDir $out/share
+     cp -r . $out/share/${shareName}
+   '') ["doUnpack" "defEnsureDir"];
+
+   doPatchShebangs = dir: FullDepEntry (''
+     patchShebangFun() {
+     # Rewrite all script interpreter file names (`#! /path') under the
+     # specified  directory tree to paths found in $PATH.  E.g.,
+     # /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh.
+     # Interpreters that are already in the store are left untouched.
+         echo "patching script interpreter paths"
+         local f
+         for f in $(find "${dir}" -type f -perm +0100); do
+             local oldPath=$(sed -ne '1 s,^#![ ]*\([^ ]*\).*$,\1,p' "$f")
+             if test -n "$oldPath" -a "''${oldPath:0:''${#NIX_STORE}}" != "$NIX_STORE"; then
+                 local newPath=$(type -P $(basename $oldPath) || true)
+                 if test -n "$newPath" -a "$newPath" != "$oldPath"; then
+                     echo "$f: interpreter changed from $oldPath to $newPath"
+                     sed -i "1 s,$oldPath,$newPath," "$f"
+                 fi
+             fi
+         done
+     }
+     patchShebangFun;
+   '') ["minInit"];
+
+   createPythonInstallationTarget = FullDepEntry (''
+     ensureDir $(toPythonPath $out)
+     export PYTHONPATH=$PYTHONPATH''${PYTHONPATH:+:}$(toPythonPath $out)
+   '') ["minInit" "addInputs" "defEnsureDir"];
 }) // args
diff --git a/pkgs/top-level/template-composing+config.nix b/pkgs/top-level/template-composing+config.nix
index 56d5e1fa483..7f7e55302dd 100644
--- a/pkgs/top-level/template-composing+config.nix
+++ b/pkgs/top-level/template-composing+config.nix
@@ -16,9 +16,7 @@ stdenv.mkDerivation rec {
 	builder = writeScript (name + "-builder")
 		(textClosure localDefs [(abort "Check phases") doMakeInstall doForceShare doPropagate]);
 	meta = {
-		description = "
-	${(abort "Specify description")}
-";
+		description = "${(abort "Specify description")}";
 		inherit src;
 	};
 }
diff --git a/pkgs/top-level/template-composing-builder.nix b/pkgs/top-level/template-composing-builder.nix
index 965bc082aba..14ef550e950 100644
--- a/pkgs/top-level/template-composing-builder.nix
+++ b/pkgs/top-level/template-composing-builder.nix
@@ -1,20 +1,15 @@
-args : with args; with builderDefs {src="";} null;
-	let localDefs = builderDefs (rec {
-		src = /* put a fetchurl here */
+args : with args; 
+rec {
+  src = /* Here a fetchurl expression goes */;
 
-		buildInputs = [];
-		configureFlags = [];
-	}) args null; /* null is a terminator for sumArgs */
-	in with localDefs;
-stdenv.mkDerivation rec {
-	name = "${abort "Specify name"}-"+version;
-	builder = writeScript (name + "-builder")
-		(textClosure localDefs 
-			[(abort "Specify phases - defined here or in builderDefs") doForceShare doPropagate]);
-	meta = {
-		description = "
-		${abort "Write a description"}
-";
-		inherit src;
-	};
+  buildInputs = [];
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["doMakeInstall"];
+      
+  name = "${abort "Specify name"}" + version;
+  meta = {
+    description = "${abort "Specify description"}";
+  };
 }
diff --git a/pkgs/top-level/template-debian.nix b/pkgs/top-level/template-debian.nix
index 872d1984533..80621b27c4d 100644
--- a/pkgs/top-level/template-debian.nix
+++ b/pkgs/top-level/template-debian.nix
@@ -1,10 +1,10 @@
 args: with args; with debPackage;
 debBuild ({
   src = fetchurl {
-    url = mirror://debian/(abort "Specify URL");
+    url = mirror://debian/pool/(abort "Specify URL");
   };
   patch = fetchurl {
-    url = mirror://debian/(abort "Specify URL");
+    url = mirror://debian/pool/(abort "Specify URL");
   };
   name = "${abort "Specify name"}";
   buildInputs = [];