wok-tiny rev 94

Refresh, remove kernel*, add linux
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Oct 02 21:45:05 2015 +0200 (2015-10-02)
parents a3e929634247
children 84dee9f78001
files base-tiny/receipt base-tiny/stuff/dev/core base-tiny/stuff/dev/fd base-tiny/stuff/dev/ram base-tiny/stuff/dev/stderr base-tiny/stuff/dev/stdin base-tiny/stuff/dev/stdout base-tiny/stuff/dev/vcs base-tiny/stuff/dev/vcsa base-tiny/stuff/etc/busybox.conf base-tiny/stuff/etc/daemons.conf base-tiny/stuff/etc/fstab base-tiny/stuff/etc/group base-tiny/stuff/etc/gshadow base-tiny/stuff/etc/host.conf base-tiny/stuff/etc/hostname base-tiny/stuff/etc/hosts base-tiny/stuff/etc/inetd.conf base-tiny/stuff/etc/init.d/local.sh base-tiny/stuff/etc/init.d/network.sh base-tiny/stuff/etc/init.d/rc.functions base-tiny/stuff/etc/init.d/rc.shutdown base-tiny/stuff/etc/init.d/rcS base-tiny/stuff/etc/inittab base-tiny/stuff/etc/issue base-tiny/stuff/etc/motd base-tiny/stuff/etc/mtab base-tiny/stuff/etc/network.conf base-tiny/stuff/etc/networks base-tiny/stuff/etc/passwd base-tiny/stuff/etc/profile base-tiny/stuff/etc/rcS.conf base-tiny/stuff/etc/resolv.conf base-tiny/stuff/etc/securetty base-tiny/stuff/etc/services base-tiny/stuff/etc/shadow base-tiny/stuff/etc/shells base-tiny/stuff/etc/slitaz-release base-tiny/stuff/tmp bootloader/receipt busybox/receipt busybox/stuff/applications/pcan.desktop busybox/stuff/applications/top.desktop busybox/stuff/busybox-1.18.config busybox/stuff/udhcp.script ctorrent-dnh/receipt custom-console/receipt dropbear-without-zlib/receipt dropbear/receipt fbvnc-ssh/receipt fbvnc/receipt fbvnc/stuff/fbvnc.u fr/receipt ftp-config/receipt gpxe/receipt hardware-ibm-6272/receipt isapnptools/receipt jslinux-config/receipt jssame/receipt kernel-fb/receipt kernel-isa/receipt kernel-lguest/receipt kernel-modular/stuff/001-squashfs-decompressors-add-xz-decompressor-module.patch kernel-modular/stuff/002-squashfs-decompressors-add-boot-time-xz-support.patch kernel-modular/stuff/003-squashfs-x86-support-xz-compressed-kernel.patch kernel-modular/stuff/004-squashfs-add-xz-compression-support.patch kernel-modular/stuff/005-squashfs-add-xz-compression-configuration-option.patch kernel-modular/stuff/aufs2-2.6.36-fix.patch kernel-modular/stuff/aufs2-base.patch kernel-modular/stuff/aufs2-kbuild.patch kernel-modular/stuff/aufs2-module-2.6.36.patch kernel-modular/stuff/aufs2-standalone.patch kernel-modular/stuff/bootloader.sh kernel-modular/stuff/check_modules.sh kernel-modular/stuff/gztazmod.sh kernel-modular/stuff/linux-2.6.37-slitaz.config-i486-isa kernel-modular/stuff/linux-2.6.37-slitaz.config-i486-lguest kernel-modular/stuff/linux-2.6.37-slitaz.config-i486-modular kernel-modular/stuff/linux-diff-2.6.37.u kernel-modular/stuff/linux-freeinitrd-2.6.37.u kernel-modular/stuff/linux-header-2.6.37.u kernel-modular/stuff/linux-squashfs-lzma-2.6.34.u kernel-modular/stuff/linux-unlzma-2.6.37.u kernel-modular/stuff/list_modules.sh kernel-modular/stuff/modules-2.6.37.list kernel-usbstorage/receipt lan-config/receipt linux/receipt linux/stuff/linux-2.6.14-slitaz.config linux/stuff/list_modules.sh lpd-config/receipt lpd-spooling-config/receipt manager-fr/receipt manager/receipt module-3c509/receipt module-btrfs/receipt module-cifs/receipt module-cs89x0/receipt module-ext3/receipt module-ext4/receipt module-fat/receipt module-fuse/receipt module-hfsplus/receipt module-isofs/receipt module-lguest/receipt module-ne/receipt module-nfs/receipt module-nfsd/receipt module-reiserfs/receipt module-squashfs/receipt module-usb-storage/receipt module-vfat/receipt module-xfs/receipt ntp-config/receipt p910nd/receipt ppp-plugins-atm/receipt ppp/receipt pppdump/receipt pppstats/receipt rsync/receipt runcom/receipt tcc-arm/receipt tcc-c67/receipt tcc-common/receipt tcc-win32/receipt tcc-x86_64/receipt tcc/receipt telnet-config/receipt udhcpd-config/receipt wiki/receipt zlib/receipt
line diff
     1.1 --- a/base-tiny/receipt	Thu Jul 18 13:24:21 2013 +0000
     1.2 +++ b/base-tiny/receipt	Fri Oct 02 21:45:05 2015 +0200
     1.3 @@ -2,49 +2,19 @@
     1.4  
     1.5  PACKAGE="base-tiny"
     1.6  VERSION="1.0"
     1.7 -CATEGORY="configuration"
     1.8 +CATEGORY="misc"
     1.9  SHORT_DESC="Tiny SliTaz base configuration files"
    1.10  MAINTAINER="pascal.bellard@slitaz.org"
    1.11  LICENSE="BSD"
    1.12  WEB_SITE="http://tiny.slitaz.org/"
    1.13  AUTO_SELECTION="always"
    1.14 -CONFIG_FILES="/etc/network.conf /etc/passwd /etc/shadow \
    1.15 +CONFIG_FILES="/etc/network.conf /etc/rcS.conf /etc/passwd /etc/shadow \
    1.16  /root/.profile /etc/fstab /etc/init.d/local.sh"
    1.17  
    1.18 -# Rules to configure and make the package.
    1.19 -compile_rules()
    1.20 -{
    1.21 -	mkdir -p fs/var/lib fs/etc
    1.22 -	echo "none" > fs/var/lib/detected-modules
    1.23 -	echo "LANG=C" > fs/etc/locale.conf
    1.24 -	while read pkg file ; do
    1.25 -		if [ ! -s $pkg*/fs$file ]; then
    1.26 -			tazpkg get $pkg
    1.27 -			tazpkg extract $pkg*.tazpkg
    1.28 -		fi
    1.29 -		mkdir -p fs$(dirname $file)
    1.30 -		mv $pkg*/fs$file fs$(dirname $file) || return 1
    1.31 -	done << EOT
    1.32 -busybox			/etc/udhcpd.conf
    1.33 -busybox			/etc/inetd.conf
    1.34 -slitaz-base-files	/etc/fstab
    1.35 -slitaz-base-files	/etc/group
    1.36 -slitaz-base-files	/etc/passwd
    1.37 -slitaz-base-files	/etc/gshadow
    1.38 -slitaz-base-files	/etc/shadow
    1.39 -slitaz-boot-scripts	/etc/inittab
    1.40 -slitaz-boot-scripts	/etc/network.conf
    1.41 -slitaz-boot-scripts	/etc/init.d/local.sh
    1.42 -slitaz-boot-scripts	/etc/rcS.conf
    1.43 -EOT
    1.44 -	sed -i 's/:x:/:!:/' fs/etc/passwd
    1.45 -	sed -i 's/UDEV=.*/UDEV="no"/;s/hwconf.sh l/l/' fs/etc/rcS.conf
    1.46 -}
    1.47 -
    1.48  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.49  genpkg_rules()
    1.50  {
    1.51 -	cp -a fs/. $fs
    1.52 +	cp -a $stuff/. $fs
    1.53  }
    1.54  
    1.55  config_form()
    1.56 @@ -155,4 +125,7 @@
    1.57  	[ -n "$RC_LOCAL" ] && dos2unix >> $1/etc/init.d/local.sh <<EOT
    1.58  $RC_LOCAL
    1.59  EOT
    1.60 +	[ -s $1/modules ] && for i in $(cat $1/modules ; rm -f $1/modules); do
    1.61 +		sed -i "s/LOAD_MODULES=./&$i /" $1/etc/rcS.conf
    1.62 +	done
    1.63  }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/base-tiny/stuff/dev/core	Fri Oct 02 21:45:05 2015 +0200
     2.3 @@ -0,0 +1,1 @@
     2.4 +/proc/kcore
     2.5 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/base-tiny/stuff/dev/fd	Fri Oct 02 21:45:05 2015 +0200
     3.3 @@ -0,0 +1,1 @@
     3.4 +/proc/self/fd
     3.5 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/base-tiny/stuff/dev/ram	Fri Oct 02 21:45:05 2015 +0200
     4.3 @@ -0,0 +1,1 @@
     4.4 +ram1
     4.5 \ No newline at end of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/base-tiny/stuff/dev/stderr	Fri Oct 02 21:45:05 2015 +0200
     5.3 @@ -0,0 +1,1 @@
     5.4 +/proc/self/fd/2
     5.5 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/base-tiny/stuff/dev/stdin	Fri Oct 02 21:45:05 2015 +0200
     6.3 @@ -0,0 +1,1 @@
     6.4 +/proc/self/fd/0
     6.5 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/base-tiny/stuff/dev/stdout	Fri Oct 02 21:45:05 2015 +0200
     7.3 @@ -0,0 +1,1 @@
     7.4 +/proc/self/fd/1
     7.5 \ No newline at end of file
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/base-tiny/stuff/dev/vcs	Fri Oct 02 21:45:05 2015 +0200
     8.3 @@ -0,0 +1,1 @@
     8.4 +vcs0
     8.5 \ No newline at end of file
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/base-tiny/stuff/dev/vcsa	Fri Oct 02 21:45:05 2015 +0200
     9.3 @@ -0,0 +1,1 @@
     9.4 +vcsa0
     9.5 \ No newline at end of file
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/base-tiny/stuff/etc/busybox.conf	Fri Oct 02 21:45:05 2015 +0200
    10.3 @@ -0,0 +1,12 @@
    10.4 +# /etc/busybox.conf: SliTaz GNU/linux Busybox configuration.
    10.5 +#
    10.6 +
    10.7 +[SUID]
    10.8 +# Allow command to be run by anyone.
    10.9 +su = ssx root.root
   10.10 +passwd = ssx root.root
   10.11 +loadkmap = ssx root.root
   10.12 +mount = ssx root.root
   10.13 +reboot = ssx root.root
   10.14 +halt = ssx root.root
   10.15 +poweroff = ssx root.root
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/base-tiny/stuff/etc/daemons.conf	Fri Oct 02 21:45:05 2015 +0200
    11.3 @@ -0,0 +1,24 @@
    11.4 +# /etc/daemons.conf - Daemons options configuration file.
    11.5 +#
    11.6 +# This file is used for setting options to start daemons at boot time or from
    11.7 +# the command line (/etc/init.d/daemon-name start). Please check /etc/rcS.conf
    11.8 +# to automatically start a daemon at boot.
    11.9 +#
   11.10 +
   11.11 +# Dropbear SSH server options.
   11.12 +DROPBEAR_OPTIONS="-b /etc/dropbear/banner"
   11.13 +
   11.14 +# Cron daemon options.
   11.15 +CROND_OPTIONS="-b"
   11.16 +
   11.17 +# Domain Name Server options.
   11.18 +DNSD_OPTIONS="-d"
   11.19 +
   11.20 +# Super server options.
   11.21 +INETD_OPTIONS=""
   11.22 +
   11.23 +# Tftp daemon options.
   11.24 +TFTPD_OPTIONS="-r /boot"
   11.25 +
   11.26 +# Busybox HTTP web server options.
   11.27 +HTTPD_OPTIONS="-u www"
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/base-tiny/stuff/etc/fstab	Fri Oct 02 21:45:05 2015 +0200
    12.3 @@ -0,0 +1,6 @@
    12.4 +# /etc/fstab: Information about static filesystems.
    12.5 +#
    12.6 +proc            /proc        proc    defaults          0       0
    12.7 +sysfs           /sys         sysfs   defaults          0       0
    12.8 +devpts          /dev/pts     devpts  rw,gid=5,mode=0620 0       0
    12.9 +tmpfs           /dev/shm     tmpfs   defaults          0       0
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/base-tiny/stuff/etc/group	Fri Oct 02 21:45:05 2015 +0200
    13.3 @@ -0,0 +1,20 @@
    13.4 +root:x:0:
    13.5 +daemon:x:1:
    13.6 +bin:x:2:
    13.7 +sys:x:3:
    13.8 +adm:x:4:
    13.9 +tty:x:5:
   13.10 +disk:x:6:root
   13.11 +lp:x:7:
   13.12 +kmem:x:9:
   13.13 +wheel:x:10:root
   13.14 +floppy:x:11:
   13.15 +video:x:18:
   13.16 +cdrom:x:19:
   13.17 +audio:x:20:
   13.18 +tape:x:26:
   13.19 +www:x:80:
   13.20 +plugdev:x:83:
   13.21 +dialout:x:95:
   13.22 +nogroup:x:99:
   13.23 +users:x:100:
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/base-tiny/stuff/etc/gshadow	Fri Oct 02 21:45:05 2015 +0200
    14.3 @@ -0,0 +1,20 @@
    14.4 +root:*::
    14.5 +daemon:!::
    14.6 +bin:!::
    14.7 +sys:!::
    14.8 +adm:!::
    14.9 +tty:!::
   14.10 +disk:!::root
   14.11 +lp:!::
   14.12 +kmem:!::
   14.13 +wheel:!::root
   14.14 +floppy:!::
   14.15 +video:!::
   14.16 +cdrom:!::
   14.17 +audio:!::
   14.18 +tape:!::
   14.19 +www:!::
   14.20 +plugdev:!::
   14.21 +dialout:!::
   14.22 +nogroup:!::
   14.23 +users:!::
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/base-tiny/stuff/etc/host.conf	Fri Oct 02 21:45:05 2015 +0200
    15.3 @@ -0,0 +1,2 @@
    15.4 +order hosts,bind
    15.5 +multi on
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/base-tiny/stuff/etc/hostname	Fri Oct 02 21:45:05 2015 +0200
    16.3 @@ -0,0 +1,1 @@
    16.4 +slitaz
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/base-tiny/stuff/etc/hosts	Fri Oct 02 21:45:05 2015 +0200
    17.3 @@ -0,0 +1,1 @@
    17.4 +127.0.0.1      localhost slitaz tazpanel
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/base-tiny/stuff/etc/inetd.conf	Fri Oct 02 21:45:05 2015 +0200
    18.3 @@ -0,0 +1,34 @@
    18.4 +# Internet server configuration database
    18.5 +#
    18.6 +#
    18.7 +# If you want to disable an entry so it isn't touched during
    18.8 +# package updates just comment it out with a single '#' character.
    18.9 +#
   18.10 +# If you make changes to this file, either reboot your machine or
   18.11 +# send the inetd process a HUP signal:
   18.12 +# Do a "ps x" as root and look up the pid of inetd. Then do a
   18.13 +#     kill -HUP <pid of inetd>
   18.14 +# inetd will re-read this file whenever it gets that signal.
   18.15 +# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>
   18.16 +#
   18.17 +#:INTERNAL: Internal services
   18.18 +# It is generally considered safer to keep these off.
   18.19 +echo     stream  tcp	nowait	root	internal
   18.20 +echo     dgram   udp	wait	root	internal
   18.21 +#discard  stream  tcp	nowait	root	internal
   18.22 +#discard  dgram   udp	wait	root	internal
   18.23 +daytime  stream  tcp	nowait	root	internal
   18.24 +daytime  dgram   udp	wait	root	internal
   18.25 +#chargen  stream  tcp	nowait	root	internal
   18.26 +#chargen  dgram   udp	wait	root	internal
   18.27 +time     stream  tcp	nowait	root	internal
   18.28 +time     dgram   udp	wait	root	internal
   18.29 +
   18.30 +# These are standard services.
   18.31 +#
   18.32 +#tftp	dgram	udp	wait	root	tftpd	tftpd -r /boot
   18.33 +#systat	stream	tcp	nowait	nobody	ps
   18.34 +#netstat	stream	tcp	nowait	root	netstat	netstat	-a
   18.35 +#http	stream	tcp	nowait	root	httpd	httpd	-i -u 80:80
   18.36 +#ftp	stream	tcp	nowait	root	ftpd	ftpd	-w /home/ftp
   18.37 +#telnet	stream	tcp	nowait	root	telnetd	telnetd	-i
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/base-tiny/stuff/etc/init.d/local.sh	Fri Oct 02 21:45:05 2015 +0200
    19.3 @@ -0,0 +1,9 @@
    19.4 +#!/bin/sh
    19.5 +# /etc/init.d/local.sh - Local startup commands.
    19.6 +#
    19.7 +# All commands here will be executed at boot time.
    19.8 +#
    19.9 +. /etc/init.d/rc.functions
   19.10 +
   19.11 +echo "Starting local startup commands... "
   19.12 +
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/base-tiny/stuff/etc/init.d/network.sh	Fri Oct 02 21:45:05 2015 +0200
    20.3 @@ -0,0 +1,95 @@
    20.4 +#!/bin/sh
    20.5 +# /etc/init.d/network.sh - Network initialization boot script.
    20.6 +# Config file is: /etc/network.conf
    20.7 +#
    20.8 +. /etc/init.d/rc.functions
    20.9 +
   20.10 +if [ -z "$2" ]; then
   20.11 +	. /etc/network.conf
   20.12 +else
   20.13 +	. $2
   20.14 +fi
   20.15 +
   20.16 +boot() {
   20.17 +	# Set hostname.
   20.18 +	echo -n "Setting hostname..."
   20.19 +	hostname -F /etc/hostname
   20.20 +	status
   20.21 +
   20.22 +	# Configure loopback interface.
   20.23 +	echo -n "Configuring loopback..."
   20.24 +	ifconfig lo 127.0.0.1 up
   20.25 +	route add 127.0.0.1 lo
   20.26 +	status
   20.27 +}
   20.28 +
   20.29 +# Use ethernet
   20.30 +eth() {
   20.31 +	ifconfig $INTERFACE up
   20.32 +}
   20.33 +
   20.34 +# For a dynamic IP with DHCP.
   20.35 +dhcp() {
   20.36 +	if [ "$DHCP" = "yes" ]  ; then
   20.37 +		echo "Starting udhcpc client on: $INTERFACE..."
   20.38 +		udhcpc -b -T 1 -A 12 -i $INTERFACE -p \
   20.39 +			/var/run/udhcpc.$INTERFACE.pid
   20.40 +	fi
   20.41 +}
   20.42 +
   20.43 +# For a static IP.
   20.44 +static_ip() {
   20.45 +	if [ "$STATIC" = "yes" ] ; then
   20.46 +		echo "Configuring static IP on $INTERFACE: $IP..."
   20.47 +		ifconfig $INTERFACE $IP netmask $NETMASK up
   20.48 +		route add default gateway $GATEWAY
   20.49 +		# Multi-DNS server in $DNS_SERVER.
   20.50 +		mv /etc/resolv.conf /tmp/resolv.conf.$$
   20.51 +		for NS in $DNS_SERVER
   20.52 +		do
   20.53 +			echo "nameserver $NS" >> /etc/resolv.conf
   20.54 +		done
   20.55 +		for HELPER in /etc/ipup.d/*; do
   20.56 +			[ -x $HELPER ] && $HELPER $INTERFACE $DNS_SERVER
   20.57 +		done
   20.58 +	fi
   20.59 +}
   20.60 +
   20.61 +# Stopping everything
   20.62 +Stop() {
   20.63 +	echo "Stopping all interfaces"
   20.64 +	ifconfig $INTERFACE down
   20.65 +
   20.66 +	echo "Killing all daemons"
   20.67 +	killall udhcpc
   20.68 +}
   20.69 +
   20.70 +Start() {
   20.71 +   eth
   20.72 +   dhcp
   20.73 +   static_ip
   20.74 +}
   20.75 +
   20.76 +# looking for arguments:
   20.77 +if [ -z "$1" ]; then
   20.78 +	boot
   20.79 +	Start
   20.80 +else
   20.81 +	case $1 in
   20.82 +		start)
   20.83 +			Start ;;
   20.84 +		stop)
   20.85 +			Stop ;;
   20.86 +		restart)
   20.87 +			Stop
   20.88 +			Start ;;
   20.89 +		*)
   20.90 +			echo ""
   20.91 +			echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
   20.92 +			echo ""
   20.93 +			echo -e "	Default configuration file is \033[1m/etc/network.conf\033[0m"
   20.94 +			echo -e "	You can specify another configuration file in the second argument:"
   20.95 +			echo -e "	\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart] file.conf"
   20.96 +			echo "" ;;
   20.97 +	esac
   20.98 +fi
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/base-tiny/stuff/etc/init.d/rc.functions	Fri Oct 02 21:45:05 2015 +0200
    21.3 @@ -0,0 +1,28 @@
    21.4 +#!/bin/sh
    21.5 +# /etc/init.d/rc.functions: SliTaz boot scripts functions.
    21.6 +#
    21.7 +
    21.8 +# Status functions.
    21.9 +status() {
   21.10 +	echo -en "\\033[70G[ "
   21.11 +	if [ $? = 0 ]; then
   21.12 +		echo -en "\\033[1;32mOK"
   21.13 +	else
   21.14 +		echo -en "\\033[1;31mFailed"
   21.15 +	fi
   21.16 +	echo -e "\\033[0;39m ]"
   21.17 +}
   21.18 +
   21.19 +# Check daemon with pidfile: usage check_pidfile $PIDFILE $DAEMON
   21.20 +active_pidfile()
   21.21 +{
   21.22 +	if [ ! -e $1 ]; then
   21.23 +		return 1
   21.24 +	elif grep -qs "Name:.$(basename $2)$" \
   21.25 +			/proc/$(sed 's/[^0-9]//g' < $1 | head -n 1)/status ; then
   21.26 +		return 0
   21.27 +	else
   21.28 +		rm -f $1
   21.29 +		return 2
   21.30 +	fi
   21.31 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/base-tiny/stuff/etc/init.d/rc.shutdown	Fri Oct 02 21:45:05 2015 +0200
    22.3 @@ -0,0 +1,32 @@
    22.4 +#!/bin/sh
    22.5 +# /etc/init.d/rc.shutdown - This script is used by /etc/inittab to stop
    22.6 +# all daemons and shutdown the system.
    22.7 +#
    22.8 +. /etc/init.d/rc.functions
    22.9 +. /etc/rcS.conf
   22.10 +
   22.11 +log=/var/lib/shutdown.log
   22.12 +
   22.13 +# Bold info message with uptime
   22.14 +clear && echo "System is going down for reboot or halt." > $log
   22.15 +uptime >> $log
   22.16 +
   22.17 +# Stop all daemons started at boot time.
   22.18 +for daemon in $RUN_DAEMONS
   22.19 +do
   22.20 +	if [ -x /etc/init.d/$daemon ]; then
   22.21 +		/etc/init.d/$daemon stop >> $log
   22.22 +	fi
   22.23 +done
   22.24 +
   22.25 +# Sync all filesystems.
   22.26 +sync
   22.27 +
   22.28 +# Swap off.
   22.29 +swapoff -a
   22.30 +
   22.31 +# Kill all processes.
   22.32 +killall5
   22.33 +
   22.34 +# Umount filesystems.
   22.35 +umount -a -r 2>/dev/null
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/base-tiny/stuff/etc/init.d/rcS	Fri Oct 02 21:45:05 2015 +0200
    23.3 @@ -0,0 +1,249 @@
    23.4 +#!/bin/sh
    23.5 +# /etc/init.d/rcS - Initial boot script for SliTaz GNU/Linux.
    23.6 +# Config file is : /etc/rcS.conf
    23.7 +#
    23.8 +# rcS is the main initialization script used to check fs, mount, clean,
    23.9 +# run scripts and start daemons.
   23.10 +#
   23.11 +. /etc/init.d/rc.functions
   23.12 +. /etc/rcS.conf
   23.13 +
   23.14 +# Set TZ and boot time.
   23.15 +[ -s /etc/TZ ] && export TZ="$(cat /etc/TZ)"
   23.16 +[ "$bootdate" ] || bootdate=$(date +%s)
   23.17 +
   23.18 +case "$1" in
   23.19 +
   23.20 +readonly)
   23.21 +
   23.22 +echo "Processing /etc/init.d/rcS..."
   23.23 +
   23.24 +# Mount /proc.
   23.25 +echo -n "Mounting proc filesystem..."
   23.26 +mount proc
   23.27 +status
   23.28 +
   23.29 +if [ "$EARLY_RUN_SCRIPTS" ]; then
   23.30 +	echo "Executing early initialization scripts..."
   23.31 +	for script in $EARLY_RUN_SCRIPTS
   23.32 +	do
   23.33 +		[ -x /etc/init.d/$script ] && /etc/init.d/$script
   23.34 +	done
   23.35 +fi
   23.36 +
   23.37 +# Load all modules listed in config file.
   23.38 +if [ "$LOAD_MODULES" ]; then
   23.39 +	echo -n "Loading modules..."
   23.40 +	for mod in $LOAD_MODULES
   23.41 +	do
   23.42 +		echo -n " ${mod%%|*}"
   23.43 +		modprobe ${mod//|/ }
   23.44 +	done
   23.45 +	status
   23.46 +	[ "$KEEP_MODULES" ] || rm -rf /lib/modules
   23.47 +fi
   23.48 +
   23.49 +# Mount /sys.
   23.50 +echo -n "Mounting sys filesystem..."
   23.51 +mount sysfs
   23.52 +status
   23.53 +
   23.54 +echo -n "Updating /dev..."
   23.55 +for i in /sys/block/*/dev /sys/block/*/*/dev ; do
   23.56 +	[ -s "$i" ] || continue
   23.57 +	n=${i%/dev}
   23.58 +	n=/dev/${n##*/}
   23.59 +	[ -e $n ] && continue
   23.60 +	echo -n " ${n##*/}"
   23.61 +	mknod $n b $(sed 's/:/ /' < $i)
   23.62 +done
   23.63 +status
   23.64 +
   23.65 +# Before mounting filesystems we check fs specified in the file
   23.66 +# /etc/rcS.conf and variable $CHECK_FS.
   23.67 +if [ "$CHECK_FS" ]; then
   23.68 +	mount -o remount,ro /
   23.69 +	for i in $CHECK_FS
   23.70 +	do
   23.71 +		echo "Checking filesystem on : $i"
   23.72 +		e2fsck -p $i
   23.73 +	done
   23.74 +fi
   23.75 +
   23.76 +# Remount rootfs rw.
   23.77 +echo "Remounting rootfs read/write..."
   23.78 +mount -o remount,rw /
   23.79 +;;
   23.80 +
   23.81 +readwrite)
   23.82 +
   23.83 +# Mount filesystems in /etc/fstab.
   23.84 +echo "Mounting filesystems in fstab..."
   23.85 +mount -a
   23.86 +;;
   23.87 +
   23.88 +logged)
   23.89 +
   23.90 +# Store boot messages to log files.
   23.91 +dmesg > /var/log/dmesg.log &
   23.92 +
   23.93 +# Parse cmdline args for earlier boot options. All other boot options
   23.94 +# are in /etc/init./bootopts.sh.
   23.95 +echo -n "Searching for early boot options..."
   23.96 +for opt in $(cat /proc/cmdline)
   23.97 +do
   23.98 +	case $opt in
   23.99 +		cdrom=*)
  23.100 +			export CDROM=${opt#cdrom=} ;;
  23.101 +		modprobe=*)
  23.102 +			export MODPROBE="yes" ;;
  23.103 +		config=*)
  23.104 +			export CONFIG=${opt#config=} ;;
  23.105 +		*)
  23.106 +			continue ;;
  23.107 +	esac
  23.108 +done
  23.109 +status
  23.110 +
  23.111 +# Clean up the system.
  23.112 +if [ "$CLEAN_UP_SYSTEM" = "yes" ]; then
  23.113 +	echo -n "Cleaning up the system..."
  23.114 +	find /var/run -name "*.pid" -type f | xargs rm -f
  23.115 +	rm -rf /tmp /var/lock/*
  23.116 +	mkdir -p /tmp && chmod 1777 /tmp
  23.117 +	status
  23.118 +else
  23.119 +	echo "System clean up is disabled in /etc/rcS.conf..."
  23.120 +	echo -n "Keeping all tmp and pid files..."
  23.121 +	status
  23.122 +fi
  23.123 +
  23.124 +# Create /dev/cdrom if needed (symlink does not exist on LiveCD).
  23.125 +# Also add /dev/cdrom to fstab if entry does not exist.
  23.126 +if [  "$CDROM" ]; then
  23.127 +	DRIVE_NAME=${CDROM#/dev/}
  23.128 +else
  23.129 +	DRIVE_NAME=$(fgrep -s "drive name" /proc/sys/dev/cdrom/info | cut -f 3)
  23.130 +fi
  23.131 +if [ -n "$DRIVE_NAME" -a ! "$(readlink /dev/cdrom)" ]; then
  23.132 +	echo -n "Creating symlink : /dev/cdrom..."
  23.133 +	ln -s /dev/$DRIVE_NAME /dev/cdrom
  23.134 +	ln -s /dev/$DRIVE_NAME /dev/dvd
  23.135 +	chmod 0666 /dev/cdrom /dev/dvd /dev/$DRIVE_NAME
  23.136 +	status
  23.137 +fi
  23.138 +if ! fgrep -q "/dev/cdrom" /etc/fstab; then
  23.139 +	echo -n "Adding /dev/cdrom  to fstab..."
  23.140 +	echo '/dev/cdrom      /media/cdrom iso9660 user,ro,noauto       0       0' \
  23.141 +		>> /etc/fstab
  23.142 +	status
  23.143 +fi
  23.144 +
  23.145 +# Handle kernel cmdline parameter modprobe=<module_list>
  23.146 +if [ "$MODPROBE" ]; then
  23.147 +	MODULES=$(sed -e 's/.* modprobe=\([^ ]*\).*/\1/' -e 's/,/\n/g' < /proc/cmdline)
  23.148 +	for i in $MODULES; do
  23.149 +		echo -n "Loading kernel module $i"
  23.150 +		modprobe $i
  23.151 +		status
  23.152 +	done
  23.153 +fi
  23.154 +
  23.155 +# Handle kernel cmdline parameter config=<device>,<path> to source a
  23.156 +# disk init script
  23.157 +if [ "$CONFIG" ]; then
  23.158 +	DEVICE=${CONFIG%,*}
  23.159 +	SCRIPT=${CONFIG#*,}
  23.160 +	echo "Probing $DEVICE... "
  23.161 +	if ! mount -r $DEVICE /mnt; then
  23.162 +		if echo $DEVICE | grep -Eq "/dev/sd|UUID=|LABEL="; then
  23.163 +			USBDELAY=$(cat /sys/module/usb_storage/parameters/delay_use)
  23.164 +			USBDELAY=$((1+$USBDELAY))
  23.165 +			echo "$DEVICE is potentially a USB device: sleep for $USBDELAY seconds"
  23.166 +			sleep $USBDELAY
  23.167 +		fi
  23.168 +		if ! mount -r $DEVICE /mnt; then
  23.169 +			CONFIG=""
  23.170 +		fi
  23.171 +	fi
  23.172 +	echo -n "Source $SCRIPT from $DEVICE..."
  23.173 +	if [ "$CONFIG" ]; then
  23.174 +		. /mnt/$SCRIPT
  23.175 +		umount /mnt 2> /dev/null || true
  23.176 +	fi
  23.177 +	status
  23.178 +fi
  23.179 +
  23.180 +# Mount /proc/bus/usb.
  23.181 +if [ -d /proc/bus/usb ]; then
  23.182 +	echo -n "Mounting /proc/bus/usb filesystem..."
  23.183 +	mount -t usbfs usbfs /proc/bus/usb
  23.184 +	status
  23.185 +fi
  23.186 +
  23.187 +# Start syslogd and klogd.
  23.188 +if [ "$KERNEL_LOG_DAEMONS" = "yes" ]; then
  23.189 +	echo -n "Starting system log deamon: syslogd..."
  23.190 +	syslogd -s $SYSLOGD_ROTATED_SIZE && status
  23.191 +	echo -n "Starting kernel log daemon: klogd..."
  23.192 +	klogd && status
  23.193 +else
  23.194 +	echo "Kernel log daemons are disabled in /etc/rc.conf..."
  23.195 +fi
  23.196 +
  23.197 +[ -d /usr/share/kmap ] &&
  23.198 +echo "Load keymap $(basename /usr/share/kmap/* .kmap)" &&
  23.199 +cat /usr/share/kmap/* | loadkmap &&
  23.200 +rm -rf /usr/share/kmap
  23.201 +
  23.202 +# Start all scripts specified with $RUN_SCRIPTS.
  23.203 +echo "Executing all initialization scripts..."
  23.204 +for script in $RUN_SCRIPTS
  23.205 +do
  23.206 +	[ -x /etc/init.d/$script ] && /etc/init.d/$script
  23.207 +done
  23.208 +
  23.209 +# Re-source main config file. In Live mode, daemons list can be modified
  23.210 +# by boot options (screen=text will remove slim).
  23.211 +. /etc/rcS.conf
  23.212 +
  23.213 +# Start all daemons specified with $RUN_DAEMONS.
  23.214 +echo "Starting all daemons specified in /etc/rcS.conf..."
  23.215 +for daemon in $RUN_DAEMONS
  23.216 +do
  23.217 +	if [ -x /etc/init.d/$daemon ]; then
  23.218 +		/etc/init.d/$daemon start
  23.219 +	fi
  23.220 +done
  23.221 +
  23.222 +# Reset screen and display a bold message.
  23.223 +if [  "$MESSAGE" ]; then
  23.224 +	reset
  23.225 +	echo -e "\033[1m$MESSAGE\033[0m"
  23.226 +fi
  23.227 +
  23.228 +# Display and log boot time.
  23.229 +time=$(($(date +%s) - $bootdate))
  23.230 +echo $time > /var/log/boot-time
  23.231 +echo "SliTaz boot time: ${time}s"
  23.232 +;;
  23.233 +
  23.234 +*)
  23.235 +if [ ! -s /dev/shm/boot.log ]; then
  23.236 +	mount -t devpts devpts /dev/pts
  23.237 +	mount -t tmpfs tmpfs /dev/shm
  23.238 +fi
  23.239 +script -aqc '/etc/init.d/rcS readonly' /dev/shm/boot.log
  23.240 +mv -f /dev/shm/boot.log /boot.log
  23.241 +umount /dev/shm
  23.242 +script -aqc '/etc/init.d/rcS readwrite' /boot.log
  23.243 +last=.9
  23.244 +for i in .8 .7 .6 .5 .4 .3 .2 .1 .0 '' ; do
  23.245 +	mv -f /var/log/boot.log$i /var/log/boot.log$last 2>/dev/null
  23.246 +	last=$i
  23.247 +done
  23.248 +mv -f /boot.log /var/log/boot.log
  23.249 +script -aqc '/etc/init.d/rcS logged' /var/log/boot.log
  23.250 +;;
  23.251 +
  23.252 +esac
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/base-tiny/stuff/etc/inittab	Fri Oct 02 21:45:05 2015 +0200
    24.3 @@ -0,0 +1,16 @@
    24.4 +# /etc/inittab: init configuration for SliTaz GNU/Linux.
    24.5 +# Boot-time system configuration/initialization script.
    24.6 +#
    24.7 +::sysinit:/etc/init.d/rcS
    24.8 +
    24.9 +# /sbin/getty respawn shell invocations for selected ttys.
   24.10 +tty1::askfirst:/sbin/getty 38400 tty1
   24.11 +tty2::askfirst:/sbin/getty 38400 tty2
   24.12 +
   24.13 +# Stuff to do when restarting the init
   24.14 +# process, or before rebooting.
   24.15 +::restart:/etc/init.d/rc.shutdown
   24.16 +::restart:/init
   24.17 +::ctrlaltdel:/sbin/reboot
   24.18 +::shutdown:/etc/init.d/rc.shutdown
   24.19 +
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/base-tiny/stuff/etc/issue	Fri Oct 02 21:45:05 2015 +0200
    25.3 @@ -0,0 +1,2 @@
    25.4 +SliTaz GNU/Linux Kernel \r \l
    25.5 +
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/base-tiny/stuff/etc/motd	Fri Oct 02 21:45:05 2015 +0200
    26.3 @@ -0,0 +1,6 @@
    26.4 +
    26.5 +  Welcome to the Open Source World!
    26.6 +  
    26.7 +  SliTaz GNU/Linux is distributed in the hope that it will be useful,
    26.8 +  but with ABSOLUTELY NO WARRANTY.
    26.9 +
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/base-tiny/stuff/etc/mtab	Fri Oct 02 21:45:05 2015 +0200
    27.3 @@ -0,0 +1,1 @@
    27.4 +/proc/mounts
    27.5 \ No newline at end of file
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/base-tiny/stuff/etc/network.conf	Fri Oct 02 21:45:05 2015 +0200
    28.3 @@ -0,0 +1,24 @@
    28.4 +# /etc/network.conf: SliTaz system wide networking configuration.
    28.5 +# Config file used by: /etc/init.d/network.sh
    28.6 +#
    28.7 +
    28.8 +# Set default interface.
    28.9 +INTERFACE="eth0"
   28.10 +
   28.11 +# Dynamic IP address.
   28.12 +# Enable/disable DHCP client at boot time.
   28.13 +DHCP="no"
   28.14 +
   28.15 +# Static IP address.
   28.16 +# Enable/disable static IP at boot time.
   28.17 +STATIC="no"
   28.18 +
   28.19 +# Set IP address and netmask for a static IP.
   28.20 +IP=""
   28.21 +NETMASK=""
   28.22 +
   28.23 +# Set route gateway for a static IP.
   28.24 +GATEWAY=""
   28.25 +
   28.26 +# Set DNS server for a static IP.
   28.27 +DNS_SERVER=""
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/base-tiny/stuff/etc/networks	Fri Oct 02 21:45:05 2015 +0200
    29.3 @@ -0,0 +1,1 @@
    29.4 +localnet    127.0.0.1
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/base-tiny/stuff/etc/passwd	Fri Oct 02 21:45:05 2015 +0200
    30.3 @@ -0,0 +1,3 @@
    30.4 +root:x:0:0:Root Administrator:/root:/bin/sh
    30.5 +nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
    30.6 +www:x:80:80:Web Server User:/var/www:/bin/false
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/base-tiny/stuff/etc/profile	Fri Oct 02 21:45:05 2015 +0200
    31.3 @@ -0,0 +1,36 @@
    31.4 +# /etc/profile: System-wide .profile file for the Bourne shells
    31.5 +
    31.6 +PATH="/usr/sbin:/usr/bin:/sbin:/bin"
    31.7 +LD_LIBRARY_PATH="/usr/lib:/lib"
    31.8 +
    31.9 +# Prompt format for Ash
   31.10 +# Light green and blue colored prompt.
   31.11 +PS1='\u@\h:\w\$ '
   31.12 +
   31.13 +# Max 64M for programs (prevent memory leak crashes)
   31.14 +ulimit -d 65536
   31.15 +ulimit -m 65536
   31.16 +
   31.17 +# Screen display for X and encoding for GTK+ apps.
   31.18 +[ -n "$DISPLAY" ] || DISPLAY=:0.0
   31.19 +G_FILENAME_ENCODING=UTF-8
   31.20 +
   31.21 +# Export all variables defined above and set mask.
   31.22 +#
   31.23 +export PATH LD_LIBRARY_PATH PS1 DISPLAY G_FILENAME_ENCODING
   31.24 +umask 022
   31.25 +
   31.26 +# Locale and timezone settings.
   31.27 +#
   31.28 +if [ -s "/etc/locale.conf" ]; then
   31.29 +	. /etc/locale.conf
   31.30 +	export LANG LC_ALL
   31.31 +fi
   31.32 +if [ -s "/etc/TZ" ]; then
   31.33 +	TZ=`cat /etc/TZ`
   31.34 +	export TZ
   31.35 +fi
   31.36 +ip=$(ifconfig eth0 2> /dev/null | awk '/inet addr/ { print substr($2,6) }')
   31.37 +case "$TERM" in
   31.38 +xterm*|rxvt*) echo -ne "\033]0;$(hostname) $(cat /etc/slitaz-release) $ip\007";;
   31.39 +esac
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/base-tiny/stuff/etc/rcS.conf	Fri Oct 02 21:45:05 2015 +0200
    32.3 @@ -0,0 +1,32 @@
    32.4 +# /etc/rcS.conf - Initial boot script configuration for SliTaz GNU/Linux.
    32.5 +# Config file used by /etc/init.d/rcS
    32.6 +#
    32.7 +
    32.8 +# Clean up the system removing all tmp and pid files.
    32.9 +CLEAN_UP_SYSTEM="yes"
   32.10 +
   32.11 +# Filesystems to check integrity of at boot time. You should check the
   32.12 +# rootfs (where SliTaz is installed) and all partitions listed in
   32.13 +# /etc/fstab. Example: CHECK_FS="/dev/hda5 /dev/hdb1"
   32.14 +CHECK_FS=""
   32.15 +
   32.16 +# Start Kernel log daemons (syslogd and klogd).
   32.17 +KERNEL_LOG_DAEMONS="yes"
   32.18 +SYSLOGD_ROTATED_SIZE="60"
   32.19 +
   32.20 +# Kernel modules to automatically load at boot time
   32.21 +LOAD_MODULES=""
   32.22 +KEEP_MODULES=""
   32.23 +
   32.24 +# Initialization scripts to run at boot time. Boot order is important.
   32.25 +# Note that the local.sh script exists to let you quickly add
   32.26 +# some local startup commands.
   32.27 +RUN_SCRIPTS="network.sh local.sh"
   32.28 +EARLY_RUN_SCRIPTS=""
   32.29 +
   32.30 +# Daemons to start at boot time.
   32.31 +# Boot order is not really important.
   32.32 +RUN_DAEMONS=""
   32.33 +
   32.34 +# Pre login bold message.
   32.35 +MESSAGE="Welcome to your box."
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/base-tiny/stuff/etc/securetty	Fri Oct 02 21:45:05 2015 +0200
    33.3 @@ -0,0 +1,11 @@
    33.4 +# /etc/securetty: List of terminals on which root is allowed to login.
    33.5 +#
    33.6 +console
    33.7 +
    33.8 +# For people with serial port consoles
    33.9 +ttyS0
   33.10 +
   33.11 +# Standard consoles
   33.12 +tty1
   33.13 +tty2
   33.14 +tty3
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/base-tiny/stuff/etc/services	Fri Oct 02 21:45:05 2015 +0200
    34.3 @@ -0,0 +1,317 @@
    34.4 +# /etc/services:
    34.5 +# $Id: services,v 1.4 2000/01/23 21:03:36 notting Exp $
    34.6 +#
    34.7 +# Network services, Internet style
    34.8 +#
    34.9 +# Note that it is presently the policy of IANA to assign a single well-known
   34.10 +# port number for both TCP and UDP; hence, most entries here have two entries
   34.11 +# even if the protocol doesn't support UDP operations.
   34.12 +# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
   34.13 +# are included, only the more common ones.
   34.14 +
   34.15 +tcpmux		1/tcp				# TCP port service multiplexer
   34.16 +echo		7/tcp
   34.17 +echo		7/udp
   34.18 +discard		9/tcp		sink null
   34.19 +discard		9/udp		sink null
   34.20 +systat		11/tcp		users
   34.21 +daytime		13/tcp
   34.22 +daytime		13/udp
   34.23 +netstat		15/tcp
   34.24 +qotd		17/tcp		quote
   34.25 +msp		18/tcp				# message send protocol
   34.26 +msp		18/udp				# message send protocol
   34.27 +chargen		19/tcp		ttytst source
   34.28 +chargen		19/udp		ttytst source
   34.29 +ftp-data	20/tcp
   34.30 +ftp		21/tcp
   34.31 +fsp		21/udp		fspd
   34.32 +ssh		22/tcp				# SSH Remote Login Protocol
   34.33 +ssh		22/udp				# SSH Remote Login Protocol
   34.34 +telnet		23/tcp
   34.35 +# 24 - private
   34.36 +smtp		25/tcp		mail
   34.37 +# 26 - unassigned
   34.38 +time		37/tcp		timserver
   34.39 +time		37/udp		timserver
   34.40 +rlp		39/udp		resource	# resource location
   34.41 +nameserver	42/tcp		name		# IEN 116
   34.42 +whois		43/tcp		nicname
   34.43 +re-mail-ck	50/tcp				# Remote Mail Checking Protocol
   34.44 +re-mail-ck	50/udp				# Remote Mail Checking Protocol
   34.45 +domain		53/tcp		nameserver	# name-domain server
   34.46 +domain		53/udp		nameserver
   34.47 +mtp		57/tcp				# deprecated
   34.48 +bootps		67/tcp				# BOOTP server
   34.49 +bootps		67/udp
   34.50 +bootpc		68/tcp				# BOOTP client
   34.51 +bootpc		68/udp
   34.52 +tftp		69/udp
   34.53 +gopher		70/tcp				# Internet Gopher
   34.54 +gopher		70/udp
   34.55 +rje		77/tcp		netrjs
   34.56 +finger		79/tcp
   34.57 +www		80/tcp		http		# WorldWideWeb HTTP
   34.58 +www		80/udp				# HyperText Transfer Protocol
   34.59 +link		87/tcp		ttylink
   34.60 +kerberos	88/tcp		kerberos5 krb5	# Kerberos v5
   34.61 +kerberos	88/udp		kerberos5 krb5	# Kerberos v5
   34.62 +supdup		95/tcp
   34.63 +# 100 - reserved
   34.64 +hostnames	101/tcp		hostname	# usually from sri-nic
   34.65 +iso-tsap	102/tcp		tsap		# part of ISODE.
   34.66 +csnet-ns	105/tcp		cso-ns		# also used by CSO name server
   34.67 +csnet-ns	105/udp		cso-ns
   34.68 +# unfortunately the poppassd (Eudora) uses a port which has already
   34.69 +# been assigned to a different service. We list the poppassd as an
   34.70 +# alias here. This should work for programs asking for this service.
   34.71 +# (due to a bug in inetd the 3com-tsmux line is disabled)
   34.72 +#3com-tsmux	106/tcp		poppassd
   34.73 +#3com-tsmux	106/udp		poppassd
   34.74 +rtelnet		107/tcp				# Remote Telnet
   34.75 +rtelnet		107/udp
   34.76 +pop2		109/tcp		pop-2	postoffice	# POP version 2
   34.77 +pop2		109/udp		pop-2
   34.78 +pop3		110/tcp		pop-3		# POP version 3
   34.79 +pop3		110/udp		pop-3
   34.80 +sunrpc		111/tcp		portmapper	# RPC 4.0 portmapper TCP
   34.81 +sunrpc		111/udp		portmapper	# RPC 4.0 portmapper UDP
   34.82 +auth		113/tcp		authentication tap ident
   34.83 +sftp		115/tcp
   34.84 +uucp-path	117/tcp
   34.85 +nntp		119/tcp		readnews untp	# USENET News Transfer Protocol
   34.86 +ntp		123/tcp
   34.87 +ntp		123/udp				# Network Time Protocol
   34.88 +netbios-ns	137/tcp				# NETBIOS Name Service
   34.89 +netbios-ns	137/udp
   34.90 +netbios-dgm	138/tcp				# NETBIOS Datagram Service
   34.91 +netbios-dgm	138/udp
   34.92 +netbios-ssn	139/tcp				# NETBIOS session service
   34.93 +netbios-ssn	139/udp
   34.94 +imap2		143/tcp		imap		# Interim Mail Access Proto v2
   34.95 +imap2		143/udp		imap
   34.96 +snmp		161/udp				# Simple Net Mgmt Proto
   34.97 +snmp-trap	162/udp		snmptrap	# Traps for SNMP
   34.98 +cmip-man	163/tcp				# ISO mgmt over IP (CMOT)
   34.99 +cmip-man	163/udp
  34.100 +cmip-agent	164/tcp
  34.101 +cmip-agent	164/udp
  34.102 +xdmcp		177/tcp				# X Display Mgr. Control Proto
  34.103 +xdmcp		177/udp
  34.104 +nextstep	178/tcp		NeXTStep NextStep	# NeXTStep window
  34.105 +nextstep	178/udp		NeXTStep NextStep	# server
  34.106 +bgp		179/tcp				# Border Gateway Proto.
  34.107 +bgp		179/udp
  34.108 +prospero	191/tcp				# Cliff Neuman's Prospero
  34.109 +prospero	191/udp
  34.110 +irc		194/tcp				# Internet Relay Chat
  34.111 +irc		194/udp
  34.112 +smux		199/tcp				# SNMP Unix Multiplexer
  34.113 +smux		199/udp
  34.114 +at-rtmp		201/tcp				# AppleTalk routing
  34.115 +at-rtmp		201/udp
  34.116 +at-nbp		202/tcp				# AppleTalk name binding
  34.117 +at-nbp		202/udp
  34.118 +at-echo		204/tcp				# AppleTalk echo
  34.119 +at-echo		204/udp
  34.120 +at-zis		206/tcp				# AppleTalk zone information
  34.121 +at-zis		206/udp
  34.122 +qmtp		209/tcp				# The Quick Mail Transfer Protocol
  34.123 +qmtp		209/udp				# The Quick Mail Transfer Protocol
  34.124 +z3950		210/tcp		wais		# NISO Z39.50 database
  34.125 +z3950		210/udp		wais
  34.126 +ipx		213/tcp				# IPX
  34.127 +ipx		213/udp
  34.128 +imap3		220/tcp				# Interactive Mail Access
  34.129 +imap3		220/udp				# Protocol v3
  34.130 +rpc2portmap	369/tcp
  34.131 +rpc2portmap	369/udp				# Coda portmapper
  34.132 +codaauth2	370/tcp
  34.133 +codaauth2	370/udp				# Coda authentication server
  34.134 +ulistserv	372/tcp				# UNIX Listserv
  34.135 +ulistserv	372/udp
  34.136 +ldap            389/tcp    			# Lightweight Directory Access Protocol
  34.137 +ldap            389/udp    			# Lightweight Directory Access Protocol
  34.138 +https		443/tcp				# MCom
  34.139 +https		443/udp				# MCom
  34.140 +snpp		444/tcp				# Simple Network Paging Protocol
  34.141 +snpp		444/udp				# Simple Network Paging Protocol
  34.142 +saft		487/tcp				# Simple Asynchronous File Transfer
  34.143 +saft		487/udp				# Simple Asynchronous File Transfer
  34.144 +npmp-local	610/tcp		dqs313_qmaster	# npmp-local / DQS
  34.145 +npmp-local	610/udp		dqs313_qmaster	# npmp-local / DQS
  34.146 +npmp-gui	611/tcp		dqs313_execd	# npmp-gui / DQS
  34.147 +npmp-gui	611/udp		dqs313_execd	# npmp-gui / DQS
  34.148 +hmmp-ind	612/tcp		dqs313_intercell# HMMP Indication / DQS
  34.149 +hmmp-ind	612/udp		dqs313_intercell# HMMP Indication / DQS
  34.150 +#
  34.151 +# UNIX specific services
  34.152 +#
  34.153 +exec		512/tcp
  34.154 +biff		512/udp		comsat
  34.155 +login		513/tcp
  34.156 +who		513/udp		whod
  34.157 +shell		514/tcp		cmd		# no passwords used
  34.158 +syslog		514/udp
  34.159 +printer		515/tcp		spooler		# line printer spooler
  34.160 +talk		517/udp
  34.161 +ntalk		518/udp
  34.162 +route		520/udp		router routed	# RIP
  34.163 +timed		525/udp		timeserver
  34.164 +tempo		526/tcp		newdate
  34.165 +courier		530/tcp		rpc
  34.166 +conference	531/tcp		chat
  34.167 +netnews		532/tcp		readnews
  34.168 +netwall		533/udp				# -for emergency broadcasts
  34.169 +uucp		540/tcp		uucpd		# uucp daemon
  34.170 +afpovertcp	548/tcp				# AFP over TCP
  34.171 +afpovertcp	548/udp				# AFP over TCP
  34.172 +remotefs	556/tcp		rfs_server rfs	# Brunhoff remote filesystem
  34.173 +klogin		543/tcp				# Kerberized `rlogin' (v5)
  34.174 +kshell		544/tcp		krcmd		# Kerberized `rsh' (v5)
  34.175 +kerberos-adm	749/tcp				# Kerberos `kadmin' (v5)
  34.176 +#
  34.177 +webster		765/tcp				# Network dictionary
  34.178 +webster		765/udp
  34.179 +swat		901/tcp				# Samba Web Administration Tool
  34.180 +#
  34.181 +# From ``Assigned Numbers'':
  34.182 +#
  34.183 +#> The Registered Ports are not controlled by the IANA and on most systems
  34.184 +#> can be used by ordinary user processes or programs executed by ordinary
  34.185 +#> users.
  34.186 +#
  34.187 +#> Ports are used in the TCP [45,106] to name the ends of logical
  34.188 +#> connections which carry long term conversations.  For the purpose of
  34.189 +#> providing services to unknown callers, a service contact port is
  34.190 +#> defined.  This list specifies the port used by the server process as its
  34.191 +#> contact port.  While the IANA can not control uses of these ports it
  34.192 +#> does register or list uses of these ports as a convienence to the
  34.193 +#> community.
  34.194 +#
  34.195 +ingreslock	1524/tcp
  34.196 +ingreslock	1524/udp
  34.197 +prospero-np	1525/tcp			# Prospero non-privileged
  34.198 +prospero-np	1525/udp
  34.199 +datametrics	1645/tcp	old-radius	# datametrics / old radius entry
  34.200 +datametrics	1645/udp	old-radius	# datametrics / old radius entry
  34.201 +sa-msg-port	1646/tcp	old-radacct	# sa-msg-port / old radacct entry
  34.202 +sa-msg-port	1646/udp	old-radacct	# sa-msg-port / old radacct entry
  34.203 +radius		1812/tcp			# Radius
  34.204 +radius		1812/udp			# Radius
  34.205 +radacct		1813/tcp			# Radius Accounting
  34.206 +radacct		1813/udp			# Radius Accounting
  34.207 +cvspserver	2401/tcp			# CVS client/server operations
  34.208 +cvspserver	2401/udp			# CVS client/server operations
  34.209 +venus		2430/tcp			# codacon port
  34.210 +venus		2430/udp			# Venus callback/wbc interface
  34.211 +venus-se	2431/tcp			# tcp side effects
  34.212 +venus-se	2431/udp			# udp sftp side effect
  34.213 +codasrv		2432/tcp			# not used
  34.214 +codasrv		2432/udp			# server port
  34.215 +codasrv-se	2433/tcp			# tcp side effects
  34.216 +codasrv-se	2433/udp			# udp sftp side effect
  34.217 +mysql		3306/tcp			# MySQL
  34.218 +mysql		3306/udp			# MySQL
  34.219 +rfe		5002/tcp			# Radio Free Ethernet
  34.220 +rfe		5002/udp			# Actually uses UDP only
  34.221 +cfengine	5308/tcp			# CFengine
  34.222 +cfengine	5308/udp			# CFengine
  34.223 +bbs		7000/tcp			# BBS service
  34.224 +#
  34.225 +#
  34.226 +# Kerberos (Project Athena/MIT) services
  34.227 +# Note that these are for Kerberos v4, and are unofficial.  Sites running
  34.228 +# v4 should uncomment these and comment out the v5 entries above.
  34.229 +#
  34.230 +kerberos4	750/udp		kerberos-iv kdc	# Kerberos (server) udp
  34.231 +kerberos4	750/tcp		kerberos-iv kdc	# Kerberos (server) tcp
  34.232 +kerberos_master	751/udp				# Kerberos authentication
  34.233 +kerberos_master	751/tcp				# Kerberos authentication
  34.234 +passwd_server	752/udp				# Kerberos passwd server
  34.235 +krb_prop	754/tcp				# Kerberos slave propagation
  34.236 +krbupdate	760/tcp		kreg		# Kerberos registration
  34.237 +kpasswd		761/tcp		kpwd		# Kerberos "passwd"
  34.238 +kpop		1109/tcp			# Pop with Kerberos
  34.239 +knetd		2053/tcp			# Kerberos de-multiplexor
  34.240 +zephyr-srv	2102/udp			# Zephyr server
  34.241 +zephyr-clt	2103/udp			# Zephyr serv-hm connection
  34.242 +zephyr-hm	2104/udp			# Zephyr hostmanager
  34.243 +eklogin		2105/tcp			# Kerberos encrypted rlogin
  34.244 +#
  34.245 +# Unofficial but necessary (for NetBSD) services
  34.246 +#
  34.247 +supfilesrv	871/tcp				# SUP server
  34.248 +supfiledbg	1127/tcp			# SUP debugging
  34.249 +#
  34.250 +# Datagram Delivery Protocol services
  34.251 +#
  34.252 +rtmp		1/ddp				# Routing Table Maintenance Protocol
  34.253 +nbp		2/ddp				# Name Binding Protocol
  34.254 +echo		4/ddp				# AppleTalk Echo Protocol
  34.255 +zip		6/ddp				# Zone Information Protocol
  34.256 +#
  34.257 +# Services added for the Debian GNU/Linux distribution
  34.258 +poppassd	106/tcp				# Eudora
  34.259 +poppassd	106/udp				# Eudora
  34.260 +mailq		174/tcp				# Mailer transport queue for Zmailer
  34.261 +mailq		174/udp				# Mailer transport queue for Zmailer
  34.262 +ssmtp		465/tcp				# SMTP over SSL
  34.263 +gdomap		538/tcp				# GNUstep distributed objects
  34.264 +gdomap		538/udp				# GNUstep distributed objects
  34.265 +snews		563/tcp				# NNTP over SSL
  34.266 +ssl-ldap	636/tcp				# LDAP over SSL
  34.267 +omirr		808/tcp		omirrd		# online mirror
  34.268 +omirr		808/udp		omirrd		# online mirror
  34.269 +rsync		873/tcp				# rsync
  34.270 +rsync		873/udp				# rsync
  34.271 +simap	 	993/tcp				# IMAP over SSL
  34.272 +spop3		995/tcp				# POP-3 over SSL
  34.273 +socks		1080/tcp			# socks proxy server
  34.274 +socks		1080/udp			# socks proxy server
  34.275 +rmtcfg		1236/tcp			# Gracilis Packeten remote config server
  34.276 +xtel		1313/tcp			# french minitel
  34.277 +support		1529/tcp			# GNATS
  34.278 +cfinger		2003/tcp			# GNU Finger
  34.279 +ninstall	2150/tcp			# ninstall service
  34.280 +ninstall	2150/udp			# ninstall service
  34.281 +afbackup	2988/tcp			# Afbackup system
  34.282 +afbackup	2988/udp			# Afbackup system
  34.283 +icp		3130/tcp			# Internet Cache Protocol (Squid)
  34.284 +icp		3130/udp			# Internet Cache Protocol (Squid)
  34.285 +postgres	5432/tcp			# POSTGRES
  34.286 +postgres	5432/udp			# POSTGRES
  34.287 +fax		4557/tcp			# FAX transmission service        (old)
  34.288 +hylafax		4559/tcp			# HylaFAX client-server protocol  (new)
  34.289 +noclog		5354/tcp			# noclogd with TCP (nocol)
  34.290 +noclog		5354/udp			# noclogd with UDP (nocol)
  34.291 +hostmon		5355/tcp			# hostmon uses TCP (nocol)
  34.292 +hostmon		5355/udp			# hostmon uses TCP (nocol)
  34.293 +ircd		6667/tcp			# Internet Relay Chat
  34.294 +ircd		6667/udp			# Internet Relay Chat
  34.295 +webcache	8080/tcp			# WWW caching service
  34.296 +webcache	8080/udp			# WWW caching service
  34.297 +tproxy		8081/tcp			# Transparent Proxy
  34.298 +tproxy		8081/udp			# Transparent Proxy
  34.299 +mandelspawn	9359/udp	mandelbrot	# network mandelbrot
  34.300 +amanda		10080/udp			# amanda backup services
  34.301 +kamanda		10081/tcp			# amanda backup services (Kerberos)
  34.302 +kamanda		10081/udp			# amanda backup services (Kerberos)
  34.303 +amandaidx	10082/tcp			# amanda backup services
  34.304 +amidxtape	10083/tcp			# amanda backup services
  34.305 +isdnlog		20011/tcp			# isdn logging system
  34.306 +isdnlog		20011/udp			# isdn logging system
  34.307 +vboxd		20012/tcp			# voice box system
  34.308 +vboxd		20012/udp			# voice box system
  34.309 +binkp		24554/tcp			# Binkley
  34.310 +binkp		24554/udp			# Binkley
  34.311 +asp		27374/tcp			# Address Search Protocol
  34.312 +asp		27374/udp			# Address Search Protocol
  34.313 +tfido		60177/tcp			# Ifmail
  34.314 +tfido		60177/udp			# Ifmail
  34.315 +fido		60179/tcp			# Ifmail
  34.316 +fido		60179/udp			# Ifmail
  34.317 +
  34.318 +# Local services
  34.319 +
  34.320 +linuxconf	98/tcp
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/base-tiny/stuff/etc/shadow	Fri Oct 02 21:45:05 2015 +0200
    35.3 @@ -0,0 +1,3 @@
    35.4 +root:$1$EbR327ag$7NFmnOi7JQc5/lG0JLiU8/:13525:0:99999:7:::
    35.5 +nobody:*:13509:0:99999:7:::
    35.6 +www:*:13509:0:99999:7:::
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/base-tiny/stuff/etc/shells	Fri Oct 02 21:45:05 2015 +0200
    36.3 @@ -0,0 +1,5 @@
    36.4 +# /etc/shells: Valid login shells.
    36.5 +/bin/sh
    36.6 +/bin/ash
    36.7 +/bin/bash
    36.8 +/bin/hush
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/base-tiny/stuff/etc/slitaz-release	Fri Oct 02 21:45:05 2015 +0200
    37.3 @@ -0,0 +1,1 @@
    37.4 +4.0-tiny
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/base-tiny/stuff/tmp	Fri Oct 02 21:45:05 2015 +0200
    38.3 @@ -0,0 +1,1 @@
    38.4 +var/tmp
    38.5 \ No newline at end of file
    39.1 --- a/bootloader/receipt	Thu Jul 18 13:24:21 2013 +0000
    39.2 +++ b/bootloader/receipt	Fri Oct 02 21:45:05 2015 +0200
    39.3 @@ -12,5 +12,5 @@
    39.4  # Rules to gen a SliTaz package suitable for Tazpkg.
    39.5  genpkg_rules()
    39.6  {
    39.7 -	cp -a stuff/. $fs
    39.8 +	cp -a $stuff/. $fs
    39.9  }
    40.1 --- a/busybox/receipt	Thu Jul 18 13:24:21 2013 +0000
    40.2 +++ b/busybox/receipt	Fri Oct 02 21:45:05 2015 +0200
    40.3 @@ -13,6 +13,7 @@
    40.4  WEB_SITE="http://www.busybox.net/"
    40.5  WGET_URL="http://www.busybox.net/downloads/$TARBALL"
    40.6  CONFIG_FILES="/etc/dnsd.conf /etc/inetd.conf /etc/udhcpd.conf /etc/resolv.conf"
    40.7 +AUTO_SELECTION="never"
    40.8  
    40.9  apply_bb_patchs()
   40.10  {
   40.11 @@ -20,7 +21,7 @@
   40.12      while read file; do
   40.13      	[ -f done.$file ] && continue
   40.14      	echo "Apply $file..."
   40.15 -    	patch -p1 < ../stuff/$PACKAGE-${VERSION%.*}-$file || return 1
   40.16 +    	patch -p1 < $stuff/$PACKAGE-${VERSION%.*}-$file || return 1
   40.17  	touch done.$file
   40.18      done <<EOT
   40.19  tar.u
   40.20 @@ -31,23 +32,11 @@
   40.21  cmdline.u
   40.22  conspy.u
   40.23  EOT
   40.24 -    cp ../stuff/$PACKAGE-${VERSION%.*}.config .config
   40.25 +    cp $stuff/$PACKAGE-${VERSION%.*}.config .config
   40.26      var="CONFIG_CROSS_COMPILER_PREFIX"
   40.27      sed -i "s/.*$var.*/$var=\"uclibc-$TARGET-\"/" .config
   40.28  }
   40.29  
   40.30 -# Rules to compile & install the temporary toolchain.
   40.31 -cook_tmp_toolchain()
   40.32 -{
   40.33 -    { apply_bb_patchs && 
   40.34 -    make oldconfig &&
   40.35 -    make &&
   40.36 -    make CONFIG_PREFIX=/tools install
   40.37 -    } || return 1
   40.38 -    echo "Chmod 4755 on busybox binary..."
   40.39 -    chmod 4755 /tools/bin/busybox
   40.40 -}
   40.41 -
   40.42  # Rules to configure and make the package.
   40.43  compile_rules()
   40.44  {
   40.45 @@ -58,53 +47,7 @@
   40.46      } || return 1
   40.47      echo "Chmod 4755 on busybox binary..."
   40.48      chmod 4755 _install/bin/busybox
   40.49 -}
   40.50 -
   40.51 -# Rules to gen a SliTaz package suitable for Tazpkg.
   40.52 -genpkg_rules()
   40.53 -{
   40.54 -    cp -a $src/_install/* $fs
   40.55 -    rm -f $fs/bin/bbconfig $fs/usr/bin/ar
   40.56 -    mkdir -p $fs/etc/init.d
   40.57 -    # Busybox config files.
   40.58 -    cp stuff/busybox.conf $fs/etc
   40.59 -    chmod 600 $fs/etc/busybox.conf
   40.60 -    cp stuff/dnsd.conf $fs/etc
   40.61 -    cp stuff/udhcpd.conf $fs/etc
   40.62 -    touch $fs/etc/resolv.conf
   40.63 -    cp stuff/inetd.conf $fs/etc
   40.64 -    cp stuff/daemon $fs/etc/init.d
   40.65 -    for i in crond dnsd ftpd httpd inetd klogd ntpd syslogd telnetd tftpd \
   40.66 -	     udhcpd zcip ; do
   40.67 -	grep -qi config_$i=y $src/.config &&
   40.68 -	ln -s daemon $fs/etc/init.d/$i
   40.69 -    done
   40.70 -    ln -s bin/busybox $fs/init
   40.71 -    rm $fs/linuxrc
   40.72 -    mkdir -p $fs/etc/modprobe.d
   40.73 -    # Udhcpc stuff.
   40.74 -    mkdir -p $fs/usr/share/udhcpc
   40.75 -    cp stuff/udhcp.script $fs/usr/share/udhcpc/default.script
   40.76 -    chmod +x $fs/usr/share/udhcpc/default.script
   40.77 -    # ZeroConf stuff.
   40.78 -    cp stuff/zcip.script $fs/etc
   40.79 -    # Httpd stuff.
   40.80 -    cp stuff/httpd_helper.sh $fs/usr/bin
   40.81 -    chmod +x $fs/usr/bin/httpd_helper.sh
   40.82 -    # .desktop stuff
   40.83 -    mkdir -p $fs/usr/share
   40.84 -    cp -a stuff/applications $fs/usr/share
   40.85 -    # prepare rootfs.cpio for kernel-* packages
   40.86 -    mkdir -p $src/rootfs/lib
   40.87 -    cp -a $fs/. $src/rootfs/.
   40.88 -    cd $src
   40.89 -    for i in slitaz-base-files slitaz-boot-scripts ; do
   40.90 -    	tazpkg get $i
   40.91 -    	tazpkg extract $i*.tazpkg
   40.92 -    	cp -a $i*/fs/. rootfs/.
   40.93 -    	grep -qs ^post_install $i*/receipt || continue
   40.94 -    	( . $i*/receipt ; post_install rootfs )
   40.95 -    done
   40.96 +    mkdir -p rootfs/lib
   40.97      LD_LIBRARY_PATH=/usr/share/uclibc-cross-compiler-$TARGET/lib \
   40.98  	uclibc-$TARGET-ldd busybox 2> /dev/null | \
   40.99  	awk '/=>/ { print $3 }' | while read file ; do
  40.100 @@ -120,17 +63,60 @@
  40.101  	done
  40.102      done
  40.103      chown 0.0 rootfs/lib/*
  40.104 -    sed -i 's/UDEV=.*/UDEV="no"/;s/hwconf.sh l/l/' rootfs/etc/rcS.conf
  40.105 -    rm -rf rootfs/tmp rootfs/var/games rootfs/var/cache \
  40.106 -	rootfs/bin/bootlog rootfs/etc/modprobe.d rootfs/home \
  40.107 -	rootfs/sbin/mktazdevs.sh rootfs/usr/bin/man \
  40.108 -	rootfs/usr/share/applications rootfs/sys rootfs/usr/bin/ldd \
  40.109 -	rootfs/etc/nsswitch.conf rootfs/etc/zcip.script \
  40.110 -	rootfs/etc/udhcpd.conf rootfs/etc/inetd.conf \
  40.111 -	rootfs/usr/lib rootfs/usr/games rootfs/usr/share/doc \
  40.112 -	rootfs/usr/local rootfs/var/lock rootfs/var/spool rootfs/media
  40.113 +}
  40.114 +
  40.115 +# Rules to gen a SliTaz package suitable for Tazpkg.
  40.116 +genpkg_rules()
  40.117 +{
  40.118 +	cp -a $WOK/base-tiny/stuff/. $fs/
  40.119 +    cp -a $src/_install/bin/busybox $fs/bin
  40.120 +    for i in /bin/sh /bin/login /bin/getty /bin/false \
  40.121 +    	     /sbin/getty /sbin/reboot; do
  40.122 +	ln $fs/bin/busybox $fs$i
  40.123 +    done
  40.124 +    mkdir -p $fs/etc/init.d
  40.125 +    # Busybox config files.
  40.126 +    cp $stuff/busybox.conf $fs/etc
  40.127 +    chmod 600 $fs/etc/busybox.conf
  40.128 +    #cp $stuff/dnsd.conf $fs/etc
  40.129 +    #cp $stuff/udhcpd.conf $fs/etc
  40.130 +    touch $fs/etc/resolv.conf
  40.131 +    cp $stuff/inetd.conf $fs/etc
  40.132 +    cp $stuff/daemon $fs/etc/init.d
  40.133 +    for i in crond dnsd ftpd httpd inetd klogd ntpd syslogd telnetd tftpd \
  40.134 +	     udhcpd zcip ; do
  40.135 +	grep -qi config_$i=y $src/.config &&
  40.136 +	ln -s daemon $fs/etc/init.d/$i
  40.137 +    done
  40.138 +    #rm $fs/linuxrc
  40.139 +    #mkdir -p $fs/etc/modprobe.d
  40.140 +    # Udhcpc stuff.
  40.141 +    mkdir -p $fs/usr/share/udhcpc
  40.142 +    cp $stuff/udhcp.script $fs/usr/share/udhcpc/default.script
  40.143 +    chmod +x $fs/usr/share/udhcpc/default.script
  40.144 +    # ZeroConf stuff.
  40.145 +    #cp $stuff/zcip.script $fs/etc
  40.146 +    # Httpd stuff.
  40.147 +    #cp $stuff/httpd_helper.sh $fs/usr/bin
  40.148 +    #chmod +x $fs/usr/bin/httpd_helper.sh
  40.149 +    # .desktop stuff
  40.150 +    mkdir -p $fs/usr/share
  40.151 +    #cp -a $stuff/applications $fs/usr/share
  40.152 +    # prepare rootfs.cpio for kernel-* packages
  40.153 +    mkdir -p $src/rootfs/lib
  40.154 +    cp -a $fs/. $src/rootfs/.
  40.155 +    cd $src
  40.156 +    false &&
  40.157 +    for i in slitaz-base-files slitaz-boot-scripts ; do
  40.158 +    	tazpkg get $i
  40.159 +    	tazpkg extract $i*.tazpkg
  40.160 +    	cp -a $i*/fs/. rootfs/.
  40.161 +    	grep -qs ^post_install $i*/receipt || continue
  40.162 +    	( . $i*/receipt ; post_install rootfs )
  40.163 +    done
  40.164  	
  40.165 -    ln -s var/tmp rootfs/tmp
  40.166 +    ln rootfs/bin/busybox rootfs/init
  40.167 +    #ln -s var/tmp rootfs/tmp
  40.168  
  40.169      ( cd rootfs ; find | cpio -o -H newc ) > rootfs.cpio
  40.170      du -h rootfs.cpio
    41.1 --- a/busybox/stuff/applications/pcan.desktop	Thu Jul 18 13:24:21 2013 +0000
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,8 +0,0 @@
    41.4 -[Desktop Entry]
    41.5 -Encoding=UTF-8
    41.6 -Name=Local ports scan
    41.7 -Name[zh_CN]=本地端口扫描
    41.8 -Exec=xterm -hold -e 'pscan localhost'
    41.9 -Icon=other.png
   41.10 -Type=Application
   41.11 -Categories=Network;
    42.1 --- a/busybox/stuff/applications/top.desktop	Thu Jul 18 13:24:21 2013 +0000
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,10 +0,0 @@
    42.4 -[Desktop Entry]
    42.5 -Encoding=UTF-8
    42.6 -Name=Top Processes Viewer
    42.7 -Name[zh_CN]=进程管理器
    42.8 -Type=Application
    42.9 -Comment=Show System Processes
   42.10 -Exec=xterm -e top
   42.11 -Icon=other.png
   42.12 -Categories=ConsoleOnly;System;Application;
   42.13 -GenericName=Process Viewer
    43.1 --- a/busybox/stuff/busybox-1.18.config	Thu Jul 18 13:24:21 2013 +0000
    43.2 +++ b/busybox/stuff/busybox-1.18.config	Fri Oct 02 21:45:05 2015 +0200
    43.3 @@ -46,8 +46,8 @@
    43.4  # CONFIG_FEATURE_SUID_CONFIG is not set
    43.5  # CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
    43.6  # CONFIG_SELINUX is not set
    43.7 -# CONFIG_FEATURE_PREFER_APPLETS is not set
    43.8 -CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
    43.9 +CONFIG_FEATURE_PREFER_APPLETS=y
   43.10 +CONFIG_BUSYBOX_EXEC_PATH="/bin/busybox"
   43.11  CONFIG_FEATURE_SYSLOG=y
   43.12  # CONFIG_FEATURE_HAVE_RPC is not set
   43.13  
   43.14 @@ -77,8 +77,8 @@
   43.15  #
   43.16  # Installation Options ("make install" behavior)
   43.17  #
   43.18 -CONFIG_INSTALL_APPLET_SYMLINKS=y
   43.19 -# CONFIG_INSTALL_APPLET_HARDLINKS is not set
   43.20 +# CONFIG_INSTALL_APPLET_SYMLINKS is not set
   43.21 +CONFIG_INSTALL_APPLET_HARDLINKS=y
   43.22  # CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
   43.23  # CONFIG_INSTALL_APPLET_DONT is not set
   43.24  # CONFIG_INSTALL_SH_APPLET_SYMLINK is not set
   43.25 @@ -967,7 +967,7 @@
   43.26  CONFIG_SH_MATH_SUPPORT=y
   43.27  # CONFIG_SH_MATH_SUPPORT_64 is not set
   43.28  CONFIG_FEATURE_SH_EXTRA_QUIET=y
   43.29 -# CONFIG_FEATURE_SH_STANDALONE is not set
   43.30 +CONFIG_FEATURE_SH_STANDALONE=y
   43.31  # CONFIG_FEATURE_SH_NOFORK is not set
   43.32  
   43.33  #
    44.1 --- a/busybox/stuff/udhcp.script	Thu Jul 18 13:24:21 2013 +0000
    44.2 +++ b/busybox/stuff/udhcp.script	Fri Oct 02 21:45:05 2015 +0200
    44.3 @@ -1,7 +1,5 @@
    44.4  #!/bin/sh
    44.5  
    44.6 -# udhcpc script edited by Tim Riker <Tim@Rikers.org>
    44.7 -
    44.8  [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
    44.9  
   44.10  [ "$subnet" == "255.255.255.255" ] && subnet="255.255.0.0" # qemu weirdness
   44.11 @@ -14,14 +12,12 @@
   44.12  		/sbin/ifconfig $interface 0.0.0.0
   44.13  		for i in /etc/ipdown.d/*; do
   44.14  			[ -x $i ] && $i $interface
   44.15 -		done
   44.16 -		;;
   44.17 +		done ;;
   44.18  
   44.19  	renew|bound)
   44.20  		/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
   44.21  
   44.22 -		if [ -n "$router" ] ; then
   44.23 -			echo "deleting routers"
   44.24 +		if [ "$router" ] ; then
   44.25  			while route del default gw 0.0.0.0 dev $interface ; do
   44.26  				:
   44.27  			done
   44.28 @@ -32,16 +28,14 @@
   44.29  			done
   44.30  		fi
   44.31  
   44.32 -		echo -n > $RESOLV_CONF
   44.33 -		[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
   44.34 +		rm -f $RESOLV_CONF
   44.35 +		[ "$domain" ] && echo search $domain >> $RESOLV_CONF
   44.36  		for i in $dns ; do
   44.37 -			echo adding dns $i
   44.38 -			echo nameserver $i >> $RESOLV_CONF
   44.39 -		done
   44.40 +			echo nameserver $i
   44.41 +		done >> $RESOLV_CONF
   44.42  		[ "$1" == "bound" ] && for i in /etc/ipup.d/*; do
   44.43  			[ -x $i ] && $i $interface $ip $dns
   44.44 -		done
   44.45 -		;;
   44.46 +		done ;;
   44.47  esac
   44.48  
   44.49  exit 0
    45.1 --- a/ctorrent-dnh/receipt	Thu Jul 18 13:24:21 2013 +0000
    45.2 +++ b/ctorrent-dnh/receipt	Fri Oct 02 21:45:05 2015 +0200
    45.3 @@ -15,20 +15,18 @@
    45.4  # Rules to configure and make the package.
    45.5  compile_rules()
    45.6  {
    45.7 -	mv ${PACKAGE}$VERSION $PACKAGE-$VERSION 2>/dev/null
    45.8 -	cd $src
    45.9  	./configure \
   45.10  		--prefix=/usr \
   45.11  		--with-ssl=no \
   45.12  		--host=$TARGET-pc-linux-gnu \
   45.13  		CC=uclibc-$TARGET-cc &&
   45.14 -	make
   45.15 -	make DESTDIR=$PWD/_pkg install
   45.16 +	make &&
   45.17 +	make DESTDIR=$DESTDIR install
   45.18  }
   45.19  
   45.20  # Rules to gen a SliTaz package suitable for Tazpkg.
   45.21  genpkg_rules()
   45.22  {
   45.23  	mkdir -p $fs/usr
   45.24 -	cp -a $_pkg/usr/bin $fs/usr
   45.25 +	cp -a $install/usr/bin $fs/usr
   45.26  }
    46.1 --- a/custom-console/receipt	Thu Jul 18 13:24:21 2013 +0000
    46.2 +++ b/custom-console/receipt	Fri Oct 02 21:45:05 2015 +0200
    46.3 @@ -2,7 +2,7 @@
    46.4  
    46.5  PACKAGE="custom-console"
    46.6  VERSION="1.0"
    46.7 -CATEGORY="configuration"
    46.8 +CATEGORY="meta"
    46.9  SHORT_DESC="Configure a custom console"
   46.10  MAINTAINER="pascal.bellard@slitaz.org"
   46.11  LICENSE="BSD"
    47.1 --- a/dropbear-without-zlib/receipt	Thu Jul 18 13:24:21 2013 +0000
    47.2 +++ b/dropbear-without-zlib/receipt	Fri Oct 02 21:45:05 2015 +0200
    47.3 @@ -24,20 +24,19 @@
    47.4  	local i
    47.5  	local DROPBEARS
    47.6  	DROPBEARS="dbclient scp"
    47.7 -	cd $src
    47.8  	sed -i  -e 's|/usr/X11R6/bin/xauth|/usr/bin/xauth|' \
    47.9  		-e 's|/usr/libexec/sftp-server|/usr/sbin/sftp-server|' \
   47.10  		options.h
   47.11  	./configure --prefix=/usr --without-pam --host=$TARGET-pc-linux-gnu \
   47.12  		--disable-zlib CC=uclibc-$TARGET-cc &&
   47.13  	make PROGRAMS="dropbear $DROPBEARS" MULTI=1 &&
   47.14 -	install -d -m 755 $PWD/_pkg/usr/sbin &&
   47.15 -	install -m 755 dropbearmulti $PWD/_pkg/usr/sbin/dropbear &&
   47.16 -	chown root $PWD/_pkg/usr/sbin/dropbear &&
   47.17 -	chgrp 0 $PWD/_pkg/usr/sbin/dropbear &&
   47.18 -	install -d -m 755 $PWD/_pkg/usr/bin &&
   47.19 +	install -d -m 755 $DESTDIR/usr/sbin &&
   47.20 +	install -m 755 dropbearmulti $DESTDIR/usr/sbin/dropbear &&
   47.21 +	chown root $DESTDIR/usr/sbin/dropbear &&
   47.22 +	chgrp 0 $DESTDIR/usr/sbin/dropbear &&
   47.23 +	install -d -m 755 $DESTDIR/usr/bin &&
   47.24  	for i in $DROPBEARS ssh; do
   47.25 -		ln -s ../sbin/dropbear $PWD/_pkg/usr/bin/$i
   47.26 +		ln -s ../sbin/dropbear $DESTDIR/usr/bin/$i
   47.27  	done
   47.28  }
   47.29  
   47.30 @@ -45,8 +44,8 @@
   47.31  genpkg_rules()
   47.32  {
   47.33  	mkdir -p $fs/usr $fs/etc/init.d $fs/etc/dropbear
   47.34 -	cp -a $_pkg/usr/bin $fs/usr
   47.35 -	cp -a $_pkg/usr/sbin $fs/usr
   47.36 +	cp -a $install/usr/bin $fs/usr
   47.37 +	cp -a $install/usr/sbin $fs/usr
   47.38  	ln -s daemon $fs/etc/init.d/dropbear
   47.39  	cat > $fs/etc/dropbear/banner <<EOT
   47.40  
    48.1 --- a/dropbear/receipt	Thu Jul 18 13:24:21 2013 +0000
    48.2 +++ b/dropbear/receipt	Fri Oct 02 21:45:05 2015 +0200
    48.3 @@ -9,7 +9,7 @@
    48.4  TARBALL="$PACKAGE-$VERSION.tar.gz"
    48.5  DEPENDS="libutil zlib"
    48.6  [ -n "$TARGET" ] || TARGET="i486"
    48.7 -BUILD_DEPENDS="uclibc-cross-compiler-$TARGET"
    48.8 +BUILD_DEPENDS="uclibc-cross-compiler-$TARGET zlib-dev"
    48.9  SUGGESTED="sftp-server"
   48.10  WEB_SITE="http://matt.ucc.asn.au/dropbear/dropbear.html"
   48.11  WGET_URL="http://matt.ucc.asn.au/dropbear/releases/$TARBALL"
   48.12 @@ -23,20 +23,22 @@
   48.13  	local i
   48.14  	local DROPBEARS
   48.15  	DROPBEARS="dbclient scp"
   48.16 -	cd $src
   48.17  	sed -i  -e 's|/usr/X11R6/bin/xauth|/usr/bin/xauth|' \
   48.18  		-e 's|/usr/libexec/sftp-server|/usr/sbin/sftp-server|' \
   48.19  		options.h
   48.20 +	[ -d $WOK/zlib/taz ] || cook zlib
   48.21 +	ln -s $WOK/zlib/taz/*/fs/usr/lib/* /usr/share/uclibc-cross-compiler-$TARGET/lib/ 2> /dev/null
   48.22 +	ln -s /usr/include/z*.h /usr/share/uclibc-cross-compiler-$TARGET/include/ 2> /dev/null
   48.23  	./configure --prefix=/usr --without-pam --host=$TARGET-pc-linux-gnu \
   48.24  		CC=uclibc-$TARGET-cc &&
   48.25  	make PROGRAMS="dropbear $DROPBEARS" MULTI=1 &&
   48.26 -	install -d -m 755 $PWD/_pkg/usr/sbin &&
   48.27 -	install -m 755 dropbearmulti $PWD/_pkg/usr/sbin/dropbear &&
   48.28 -	chown root $PWD/_pkg/usr/sbin/dropbear &&
   48.29 -	chgrp 0 $PWD/_pkg/usr/sbin/dropbear &&
   48.30 -	install -d -m 755 $PWD/_pkg/usr/bin &&
   48.31 +	install -d -m 755 $DESTDIR/usr/sbin &&
   48.32 +	install -m 755 dropbearmulti $DESTDIR/usr/sbin/dropbear &&
   48.33 +	chown root $DESTDIR/usr/sbin/dropbear &&
   48.34 +	chgrp 0 $DESTDIR/usr/sbin/dropbear &&
   48.35 +	install -d -m 755 $DESTDIR/usr/bin &&
   48.36  	for i in $DROPBEARS ssh; do
   48.37 -		ln -s ../sbin/dropbear $PWD/_pkg/usr/bin/$i
   48.38 +		ln -s ../sbin/dropbear $DESTDIR/usr/bin/$i
   48.39  	done
   48.40  }
   48.41  
   48.42 @@ -44,8 +46,8 @@
   48.43  genpkg_rules()
   48.44  {
   48.45  	mkdir -p $fs/usr $fs/etc/init.d $fs/etc/dropbear
   48.46 -	cp -a $_pkg/usr/bin $fs/usr
   48.47 -	cp -a $_pkg/usr/sbin $fs/usr
   48.48 +	cp -a $install/usr/bin $fs/usr
   48.49 +	cp -a $install/usr/sbin $fs/usr
   48.50  	ln -s daemon $fs/etc/init.d/dropbear
   48.51  	cat > $fs/etc/dropbear/banner <<EOT
   48.52  
    49.1 --- a/fbvnc-ssh/receipt	Thu Jul 18 13:24:21 2013 +0000
    49.2 +++ b/fbvnc-ssh/receipt	Fri Oct 02 21:45:05 2015 +0200
    49.3 @@ -2,7 +2,7 @@
    49.4  
    49.5  PACKAGE="fbvnc-ssh"
    49.6  VERSION="1.0"
    49.7 -CATEGORY="network"
    49.8 +CATEGORY="meta"
    49.9  SHORT_DESC="VNC client in frame buffer within a SSH tunnel."
   49.10  MAINTAINER="pascal.bellard@slitaz.org"
   49.11  LICENSE="BSD"
    50.1 --- a/fbvnc/receipt	Thu Jul 18 13:24:21 2013 +0000
    50.2 +++ b/fbvnc/receipt	Fri Oct 02 21:45:05 2015 +0200
    50.3 @@ -1,28 +1,22 @@
    50.4  # SliTaz package receipt.
    50.5  
    50.6  PACKAGE="fbvnc"
    50.7 -VERSION="20110416"
    50.8 +VERSION="20130314"
    50.9  CATEGORY="network"
   50.10  SHORT_DESC="VNC client in frame buffer."
   50.11  MAINTAINER="pascal.bellard@slitaz.org"
   50.12  LICENSE="GPL2"
   50.13  WEB_SITE="http://repo.or.cz/w/fbvnc.git"
   50.14 -TARBALL="$PACKAGE-$VERSION.tar.gz"
   50.15 +TARBALL="$PACKAGE-$VERSION.tar.bz2"
   50.16 +WGET_URL="git|git://repo.or.cz/fbvnc.git"
   50.17  [ -n "$TARGET" ] || TARGET="i486"
   50.18 -BUILD_DEPENDS="uclibc-cross-compiler-$TARGET"
   50.19 +BUILD_DEPENDS="uclibc-cross-compiler-$TARGET git bzip2"
   50.20  DEPENDS="base-tiny"
   50.21  
   50.22  # Rules to configure and make the package.
   50.23  compile_rules()
   50.24  {
   50.25 -	[ -s $SOURCES_REPOSITORY/$TARBALL ] || 
   50.26 -	  wget -O $SOURCES_REPOSITORY/$TARBALL \
   50.27 -	   $WEB_SITE/snapshot/e42bc02b14b3331e7c7f45c6b42179d0af99ed7b.tar.gz
   50.28 -	tar xzf $SOURCES_REPOSITORY/$TARBALL
   50.29 -	mv $PACKAGE $src
   50.30 -	cd $src
   50.31  	sed -i "s/^CC.*/CC = uclibc-$TARGET-gcc/;s/^LDFLAGS.*/& -s/" Makefile
   50.32 -	patch -p0 < ../stuff/fbvnc.u &&
   50.33  	make
   50.34  }
   50.35  
    51.1 --- a/fbvnc/stuff/fbvnc.u	Thu Jul 18 13:24:21 2013 +0000
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,612 +0,0 @@
    51.4 ---- draw.h
    51.5 -+++ draw.h
    51.6 -@@ -15,5 +15,11 @@
    51.7 - void fb_cmap(void);
    51.8 - 
    51.9 - /* helper functions */
   51.10 -+struct rgb_conv {
   51.11 -+	int rshl, gshl;
   51.12 -+	int rskp, gskp, bskp;
   51.13 -+	int rmax, gmax, bmax;
   51.14 -+};
   51.15 -+void fill_rgb_conv(int mode, struct rgb_conv *s);
   51.16 - void fb_set(int r, int c, void *mem, int len);
   51.17 - unsigned fb_val(int r, int g, int b);
   51.18 ---- draw.c
   51.19 -+++ draw.c
   51.20 -@@ -10,14 +10,13 @@
   51.21 - 
   51.22 - #define MIN(a, b)	((a) < (b) ? (a) : (b))
   51.23 - #define MAX(a, b)	((a) > (b) ? (a) : (b))
   51.24 --#define NLEVELS		(1 << 8)
   51.25 -+#define NLEVELS		(1 << 16)
   51.26 - 
   51.27 - static int fd;
   51.28 - static void *fb;
   51.29 - static struct fb_var_screeninfo vinfo;
   51.30 - static struct fb_fix_screeninfo finfo;
   51.31 --static int bpp;
   51.32 --static int nr, ng, nb;
   51.33 -+static int bytes_per_pixel;
   51.34 - 
   51.35 - static int fb_len(void)
   51.36 - {
   51.37 -@@ -28,10 +27,12 @@
   51.38 - {
   51.39 - 	static unsigned short red[NLEVELS], green[NLEVELS], blue[NLEVELS];
   51.40 - 	struct fb_cmap cmap;
   51.41 -+
   51.42 - 	if (finfo.visual == FB_VISUAL_TRUECOLOR)
   51.43 - 		return;
   51.44 -+
   51.45 - 	cmap.start = 0;
   51.46 --	cmap.len = MAX(nr, MAX(ng, nb));
   51.47 -+	cmap.len = NLEVELS;
   51.48 - 	cmap.red = red;
   51.49 - 	cmap.green = green;
   51.50 - 	cmap.blue = blue;
   51.51 -@@ -41,24 +42,39 @@
   51.52 - 
   51.53 - void fb_cmap(void)
   51.54 - {
   51.55 --	unsigned short red[NLEVELS], green[NLEVELS], blue[NLEVELS];
   51.56 -+	struct fb_bitfield *color[3] = {
   51.57 -+		&vinfo.blue, &vinfo.green, &vinfo.red
   51.58 -+	};
   51.59 -+	int eye_sensibility[3] = { 2, 0, 1 }; // higher=red, blue, lower=green
   51.60 - 	struct fb_cmap cmap;
   51.61 --	int i;
   51.62 -+	unsigned short map[3][NLEVELS];
   51.63 -+	int i, j, n, offset;
   51.64 -+
   51.65 - 	if (finfo.visual == FB_VISUAL_TRUECOLOR)
   51.66 - 		return;
   51.67 - 
   51.68 --	for (i = 0; i < nr; i++)
   51.69 --		red[i] = (65535 / (nr - 1)) * i;
   51.70 --	for (i = 0; i < ng; i++)
   51.71 --		green[i] = (65535 / (ng - 1)) * i;
   51.72 --	for (i = 0; i < nb; i++)
   51.73 --		blue[i] = (65535 / (nb - 1)) * i;
   51.74 --
   51.75 -+	for (i = 0, n = vinfo.bits_per_pixel; i < 3; i++) {
   51.76 -+		n -= color[eye_sensibility[i]]->length = n / (3 - i);
   51.77 -+	}
   51.78 -+	n = (1 << vinfo.bits_per_pixel);
   51.79 -+	if (n > NLEVELS)
   51.80 -+		n = NLEVELS;
   51.81 -+	for (i = offset = 0; i < 3; i++) {
   51.82 -+		int length = color[i]->length;
   51.83 -+		color[i]->offset = offset;
   51.84 -+		for (j = 0; j < n; j++) {
   51.85 -+			int k = (j >> offset) << (16 - length);
   51.86 -+			if (k == (0xFFFF << (16 - length)))
   51.87 -+				k = 0xFFFF;
   51.88 -+			map[i][j] = k;
   51.89 -+		}
   51.90 -+		offset += length;
   51.91 -+	}
   51.92 - 	cmap.start = 0;
   51.93 --	cmap.len = MAX(nr, MAX(ng, nb));
   51.94 --	cmap.red = red;
   51.95 --	cmap.green = green;
   51.96 --	cmap.blue = blue;
   51.97 -+	cmap.len = n;
   51.98 -+	cmap.red = map[2];
   51.99 -+	cmap.green = map[1];
  51.100 -+	cmap.blue = map[0];
  51.101 - 	cmap.transp = NULL;
  51.102 - 
  51.103 - 	ioctl(fd, FBIOPUTCMAP, &cmap);
  51.104 -@@ -66,25 +82,26 @@
  51.105 - 
  51.106 - unsigned fb_mode(void)
  51.107 - {
  51.108 --	return (bpp << 16) | (vinfo.red.length << 8) |
  51.109 -+	return (bytes_per_pixel << 16) | (vinfo.red.length << 8) |
  51.110 - 		(vinfo.green.length << 4) | (vinfo.blue.length);
  51.111 - }
  51.112 - 
  51.113 - int fb_init(void)
  51.114 - {
  51.115 -+	int err = 1;
  51.116 - 	fd = open(FBDEV_PATH, O_RDWR);
  51.117 - 	if (fd == -1)
  51.118 - 		goto failed;
  51.119 -+	err++;
  51.120 - 	if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1)
  51.121 - 		goto failed;
  51.122 -+	err++;
  51.123 - 	if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1)
  51.124 - 		goto failed;
  51.125 - 	fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
  51.126 --	bpp = (vinfo.bits_per_pixel + 7) >> 3;
  51.127 --	nr = 1 << vinfo.red.length;
  51.128 --	ng = 1 << vinfo.blue.length;
  51.129 --	nb = 1 << vinfo.green.length;
  51.130 -+	bytes_per_pixel = (vinfo.bits_per_pixel + 7) >> 3;
  51.131 - 	fb = mmap(NULL, fb_len(), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  51.132 -+	err++;
  51.133 - 	if (fb == MAP_FAILED)
  51.134 - 		goto failed;
  51.135 - 	fb_cmap_save(1);
  51.136 -@@ -93,7 +110,7 @@
  51.137 - failed:
  51.138 - 	perror("fb_init()");
  51.139 - 	close(fd);
  51.140 --	return 1;
  51.141 -+	return err;
  51.142 - }
  51.143 - 
  51.144 - void fb_free(void)
  51.145 -@@ -120,19 +137,30 @@
  51.146 - 
  51.147 - void fb_set(int r, int c, void *mem, int len)
  51.148 - {
  51.149 --	memcpy(fb_mem(r) + (c + vinfo.xoffset) * bpp, mem, len * bpp);
  51.150 -+	memcpy(fb_mem(r) + (c + vinfo.xoffset) * bytes_per_pixel,
  51.151 -+		mem, len * bytes_per_pixel);
  51.152 - }
  51.153 - 
  51.154 -+void fill_rgb_conv(int mode, struct rgb_conv *s)
  51.155 -+{
  51.156 -+	int bits;
  51.157 -+
  51.158 -+	bits = mode & 0xF;  mode >>= 4;
  51.159 -+	s->rshl = s->gshl = bits;
  51.160 -+	s->bskp = 8 - bits; s->bmax = (1 << bits) -1;
  51.161 -+	bits = mode & 0xF;  mode >>= 4;
  51.162 -+	s->rshl += bits;
  51.163 -+	s->gskp = 8 - bits; s->gmax = (1 << bits) -1;
  51.164 -+	bits = mode & 0xF;
  51.165 -+	s->rskp = 8 - bits; s->rmax = (1 << bits) -1;
  51.166 -+}
  51.167 -+
  51.168 - unsigned fb_val(int r, int g, int b)
  51.169 - {
  51.170 --	switch (fb_mode() & 0x0fff) {
  51.171 --	default:
  51.172 --		fprintf(stderr, "fb_val: unknown fb_mode()\n");
  51.173 --	case 0x0888:
  51.174 --		return (r << 16) | (g << 8) | b;
  51.175 --	case 0x0565:
  51.176 --		return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
  51.177 --	case 0x0233:
  51.178 --		return ((r >> 6) << 6) | ((g >> 5) << 3) | (b >> 5);
  51.179 --	}
  51.180 -+	static struct rgb_conv c;
  51.181 -+	
  51.182 -+	if (c.rshl == 0)
  51.183 -+		fill_rgb_conv(fb_mode(), &c);
  51.184 -+	return ((r >> c.rskp) << c.rshl) | ((g >> c.gskp) << c.gshl) 
  51.185 -+					 | (b >> c.bskp);
  51.186 - }
  51.187 ---- fbvnc.c
  51.188 -+++ fbvnc.c
  51.189 -@@ -36,13 +36,15 @@
  51.190 - 
  51.191 - #define VNC_PORT		"5900"
  51.192 - 
  51.193 --#define MAXRES			(1 << 21)
  51.194 --#define MIN(a, b)		((a) < (b) ? (a) : (b))
  51.195 -+#define MAXRES			(1 << 12)
  51.196 - 
  51.197 - static int cols, rows;
  51.198 -+static int srv_cols, srv_rows;
  51.199 -+static int or, oc;
  51.200 - static int mr, mc;		/* mouse position */
  51.201 - 
  51.202 - static char buf[MAXRES];
  51.203 -+#define MAXPIX		(MAXRES/sizeof(fbval_t))
  51.204 - 
  51.205 - static int vnc_connect(char *addr, char *port)
  51.206 - {
  51.207 -@@ -61,22 +63,26 @@
  51.208 - 
  51.209 - 	if (connect(fd, addrinfo->ai_addr, addrinfo->ai_addrlen) == -1) {
  51.210 - 		close(fd);
  51.211 --		freeaddrinfo(addrinfo);
  51.212 --		return -1;
  51.213 -+		fd = -2;
  51.214 - 	}
  51.215 - 	freeaddrinfo(addrinfo);
  51.216 - 	return fd;
  51.217 - }
  51.218 - 
  51.219 -+static int bpp, vnc_mode;
  51.220 -+static struct rgb_conv format;
  51.221 - static int vnc_init(int fd)
  51.222 - {
  51.223 --	char vncver[] = "RFB 003.003\n";
  51.224 -+	static int vncfmt[] = { 0x40888, 0x20565, 0x10233, 0 };
  51.225 -+	char vncver[12];
  51.226 -+	int i;
  51.227 -+
  51.228 - 	struct vnc_client_init clientinit;
  51.229 - 	struct vnc_server_init serverinit;
  51.230 - 	struct vnc_client_pixelfmt pixfmt_cmd;
  51.231 - 	int connstat = VNC_CONN_FAILED;
  51.232 - 
  51.233 --	write(fd, vncver, 12);
  51.234 -+	write(fd, "RFB 003.003\n", 12);
  51.235 - 	read(fd, vncver, 12);
  51.236 - 
  51.237 - 	read(fd, &connstat, sizeof(connstat));
  51.238 -@@ -88,68 +94,78 @@
  51.239 - 	write(fd, &clientinit, sizeof(clientinit));
  51.240 - 	read(fd, &serverinit, sizeof(serverinit));
  51.241 - 
  51.242 --	if (fb_init())
  51.243 --		return -1;
  51.244 --	if (FBM_BPP(fb_mode()) != sizeof(fbval_t)) {
  51.245 --		fprintf(stderr, "fbvnc: fbval_t doesn't match fb depth\n");
  51.246 --		exit(1);
  51.247 --	}
  51.248 --	cols = MIN(ntohs(serverinit.w), fb_cols());
  51.249 --	rows = MIN(ntohs(serverinit.h), fb_rows());
  51.250 -+	i = fb_init();
  51.251 -+	if (i)
  51.252 -+		return -1 - i;
  51.253 -+	srv_cols = ntohs(serverinit.w);
  51.254 -+	srv_rows = ntohs(serverinit.h);
  51.255 -+	cols = MIN(srv_cols, fb_cols());
  51.256 -+	rows = MIN(srv_rows, fb_rows());
  51.257 - 	mr = rows / 2;
  51.258 - 	mc = cols / 2;
  51.259 -+	or = oc = 0;
  51.260 - 
  51.261 - 	read(fd, buf, ntohl(serverinit.len));
  51.262 - 	pixfmt_cmd.type = VNC_CLIENT_PIXFMT;
  51.263 --	pixfmt_cmd.format.bpp = 8;
  51.264 --	pixfmt_cmd.format.depth = 8;
  51.265 - 	pixfmt_cmd.format.bigendian = 0;
  51.266 - 	pixfmt_cmd.format.truecolor = 1;
  51.267 - 
  51.268 --	pixfmt_cmd.format.rmax = htons(3);
  51.269 --	pixfmt_cmd.format.gmax = htons(7);
  51.270 --	pixfmt_cmd.format.bmax = htons(7);
  51.271 --	pixfmt_cmd.format.rshl = 0;
  51.272 --	pixfmt_cmd.format.gshl = 2;
  51.273 --	pixfmt_cmd.format.bshl = 5;
  51.274 -+	if (bpp < 1)
  51.275 -+	  	bpp = FBM_BPP(fb_mode());
  51.276 -+	if (bpp >= 3)
  51.277 -+		bpp = 4;
  51.278 -+	for (i = 0; bpp <= FBM_BPP(vncfmt[i]); i++)
  51.279 -+		vnc_mode = vncfmt[i];
  51.280 -+	bpp = FBM_BPP(vnc_mode);
  51.281 -+	pixfmt_cmd.format.bpp =
  51.282 -+	pixfmt_cmd.format.depth = bpp << 3;
  51.283 - 
  51.284 -+	fill_rgb_conv(FBM_COLORS(vnc_mode), &format);
  51.285 -+	pixfmt_cmd.format.rmax = htons(format.rmax);
  51.286 -+	pixfmt_cmd.format.gmax = htons(format.gmax);
  51.287 -+	pixfmt_cmd.format.bmax = htons(format.bmax);
  51.288 -+	pixfmt_cmd.format.rshl = format.rshl;
  51.289 -+	pixfmt_cmd.format.gshl = format.gshl;
  51.290 -+	pixfmt_cmd.format.bshl = 0;
  51.291 - 	write(fd, &pixfmt_cmd, sizeof(pixfmt_cmd));
  51.292 - 	return fd;
  51.293 - }
  51.294 - 
  51.295 --static int vnc_free(void)
  51.296 -+static void vnc_free(void)
  51.297 - {
  51.298 - 	fb_free();
  51.299 --	return 0;
  51.300 - }
  51.301 - 
  51.302 --static int vnc_refresh(int fd, int inc)
  51.303 -+static void vnc_refresh(int fd, int inc)
  51.304 - {
  51.305 - 	struct vnc_client_fbup fbup_req;
  51.306 - 	fbup_req.type = VNC_CLIENT_FBUP;
  51.307 - 	fbup_req.inc = inc;
  51.308 --	fbup_req.x = htons(0);
  51.309 --	fbup_req.y = htons(0);
  51.310 --	fbup_req.w = htons(cols);
  51.311 --	fbup_req.h = htons(rows);
  51.312 -+	fbup_req.x = htons(oc);
  51.313 -+	fbup_req.y = htons(or);
  51.314 -+	fbup_req.w = htons(oc + cols);
  51.315 -+	fbup_req.h = htons(or + rows);
  51.316 - 	write(fd, &fbup_req, sizeof(fbup_req));
  51.317 --	return 0;
  51.318 - }
  51.319 - 
  51.320 --static void drawfb(char *s, int x, int y, int w, int h)
  51.321 -+static void drawfb(char *s, int x, int y, int w)
  51.322 - {
  51.323 --	fbval_t slice[1 << 14];
  51.324 --	int i, j;
  51.325 --	for (i = 0; i < h; i++) {
  51.326 --		for (j = 0; j < w; j++) {
  51.327 --			int c = *(unsigned char *) &s[i * w + j];
  51.328 --			int r = (c & 0x3) << 6;
  51.329 --			int g = ((c >> 2) & 0x7) << 5;
  51.330 --			int b = ((c >> 5) & 0x7) << 5;
  51.331 --			slice[j] = FB_VAL(r, g, b);
  51.332 -+	int mode = fb_mode();
  51.333 -+	if (mode != vnc_mode) {
  51.334 -+		fbval_t slice[MAXRES];
  51.335 -+		unsigned char *byte = (unsigned char *) slice;
  51.336 -+		int j;
  51.337 -+		int fb_bpp = FBM_BPP(mode);
  51.338 -+		for (j = 0; j < w; j++, byte += fb_bpp, s += bpp) {
  51.339 -+			fbval_t c = * (fbval_t *) s;
  51.340 -+			int r = ((c >> format.rshl) & format.rmax) << format.rskp;
  51.341 -+			int g = ((c >> format.gshl) & format.gmax) << format.gskp;
  51.342 -+			int b = (c & format.bmax) << format.bskp;
  51.343 -+			* (fbval_t *) byte = FB_VAL(r, g, b);
  51.344 - 		}
  51.345 --		fb_set(y + i, x, slice, w);
  51.346 -+		s = (void *) slice;
  51.347 - 	}
  51.348 -+	fb_set(y, x, s, w);
  51.349 - }
  51.350 - 
  51.351 - static void xread(int fd, void *buf, int len)
  51.352 -@@ -159,54 +175,84 @@
  51.353 - 	while (nr < len && (n = read(fd, buf + nr, len - nr)) > 0)
  51.354 - 		nr += n;
  51.355 - 	if (nr < len) {
  51.356 --		printf("partial vnc read!\n");
  51.357 --		exit(1);
  51.358 -+		fprintf(stderr,"partial vnc read!\n");
  51.359 -+		exit(99);
  51.360 - 	}
  51.361 - }
  51.362 - 
  51.363 -+static void skip(int fd, int len)
  51.364 -+{
  51.365 -+	int n;
  51.366 -+	while (len > 0 && (n = read(fd, buf, MIN(len, sizeof(buf)))) > 0)
  51.367 -+		len -= n;
  51.368 -+}
  51.369 -+
  51.370 - static int vnc_event(int fd)
  51.371 - {
  51.372 - 	struct vnc_rect uprect;
  51.373 --	char msg[1 << 12];
  51.374 --	struct vnc_server_fbup *fbup = (void *) msg;
  51.375 --	struct vnc_server_cuttext *cuttext = (void *) msg;
  51.376 --	struct vnc_server_colormap *colormap = (void *) msg;
  51.377 --	int j;
  51.378 --	int n;
  51.379 -+	union {
  51.380 -+		struct vnc_server_fbup fbup;
  51.381 -+		struct vnc_server_cuttext cuttext;
  51.382 -+		struct vnc_server_colormap colormap;
  51.383 -+	} msg;
  51.384 -+	int j, n;
  51.385 - 
  51.386 --	if (read(fd, msg, 1) != 1)
  51.387 -+	if (read(fd, &msg.fbup.type, 1) != 1)
  51.388 - 		return -1;
  51.389 --	switch (msg[0]) {
  51.390 -+	switch (msg.fbup.type) {
  51.391 - 	case VNC_SERVER_FBUP:
  51.392 --		xread(fd, msg + 1, sizeof(*fbup) - 1);
  51.393 --		n = ntohs(fbup->n);
  51.394 -+		xread(fd, &msg.fbup.pad, sizeof(msg.fbup) - 1);
  51.395 -+		n = ntohs(msg.fbup.n);
  51.396 - 		for (j = 0; j < n; j++) {
  51.397 --			int x, y, w, h;
  51.398 -+			int x, y, w, h, l, i;
  51.399 - 			xread(fd, &uprect, sizeof(uprect));
  51.400 -+			if (uprect.enc != 0) {
  51.401 -+				fprintf(stderr,"Encoding not RAW: %d\n",
  51.402 -+					ntohl(uprect.enc));
  51.403 -+				return -1;
  51.404 -+			}
  51.405 - 			x = ntohs(uprect.x);
  51.406 - 			y = ntohs(uprect.y);
  51.407 - 			w = ntohs(uprect.w);
  51.408 - 			h = ntohs(uprect.h);
  51.409 --			if (x >= cols || x + w > cols)
  51.410 --				return -1;
  51.411 --			if (y >= rows || y + h > rows)
  51.412 --				return -1;
  51.413 --			xread(fd, buf, w * h);
  51.414 --			drawfb(buf, x, y, w, h);
  51.415 -+			x -= oc;
  51.416 -+			y -= or;
  51.417 -+			i = 0;
  51.418 -+			l = MIN(w, cols - x);
  51.419 -+			if (x < 0) {
  51.420 -+				l = MIN(w + x, cols);
  51.421 -+				i = MIN(w, -x);
  51.422 -+				x = 0;
  51.423 -+			}
  51.424 -+			if (l < 0)
  51.425 -+				l = 0;
  51.426 -+			for (; h--; y++) {
  51.427 -+				int n = l;
  51.428 -+				int xj = x;
  51.429 -+				skip(fd, i * bpp);
  51.430 -+				while (n > 0) {
  51.431 -+					int j = MIN(n, MAXPIX);
  51.432 -+					xread(fd, buf, j * bpp);
  51.433 -+					if (y >= 0 && y < rows)
  51.434 -+						drawfb(buf, xj, y, j);
  51.435 -+					xj += j; n -= j;
  51.436 -+				}
  51.437 -+				skip(fd, (w - l - i) * bpp);
  51.438 -+			}
  51.439 - 		}
  51.440 - 		break;
  51.441 - 	case VNC_SERVER_BELL:
  51.442 - 		break;
  51.443 - 	case VNC_SERVER_CUTTEXT:
  51.444 --		xread(fd, msg + 1, sizeof(*cuttext) - 1);
  51.445 --		xread(fd, buf, ntohl(cuttext->len));
  51.446 -+		xread(fd, &msg.cuttext.pad1, sizeof(msg.cuttext) - 1);
  51.447 -+		skip(fd, ntohl(msg.cuttext.len));
  51.448 - 		break;
  51.449 - 	case VNC_SERVER_COLORMAP:
  51.450 --		xread(fd, msg + 1, sizeof(*colormap) - 1);
  51.451 --		xread(fd, buf, ntohs(colormap->n) * 3 * 2);
  51.452 -+		xread(fd, &msg.colormap.pad, sizeof(msg.colormap) - 1);
  51.453 -+		skip(fd, ntohs(msg.colormap.n) * 3 * 2);
  51.454 - 		break;
  51.455 - 	default:
  51.456 --		fprintf(stderr, "unknown vnc msg: %d\n", msg[0]);
  51.457 -+		fprintf(stderr, "unknown vnc msg: %d\n", msg.fbup.type);
  51.458 - 		return -1;
  51.459 - 	}
  51.460 - 	return 0;
  51.461 -@@ -217,12 +263,31 @@
  51.462 - 	char ie[3];
  51.463 - 	struct vnc_client_ratevent me = {VNC_CLIENT_RATEVENT};
  51.464 - 	int mask = 0;
  51.465 -+	int refresh = 2;
  51.466 - 	if (read(ratfd, &ie, sizeof(ie)) != 3)
  51.467 - 		return -1;
  51.468 - 	mc += ie[1];
  51.469 - 	mr -= ie[2];
  51.470 --	mc = MAX(0, MIN(cols - 1, mc));
  51.471 --	mr = MAX(0, MIN(rows - 1, mr));
  51.472 -+	if (mc < oc) {
  51.473 -+		if ((oc -= cols / 5) < 0)
  51.474 -+			oc = 0;
  51.475 -+	}
  51.476 -+	else if (mc >= oc + cols && oc + cols < srv_cols) {
  51.477 -+		if ((oc += cols / 5) > srv_cols - cols)
  51.478 -+			oc = srv_cols - cols;
  51.479 -+	}
  51.480 -+	else refresh--;
  51.481 -+	if (mr < or) {
  51.482 -+		if ((or -= rows / 5) < 0)
  51.483 -+			or = 0;
  51.484 -+	}
  51.485 -+	else if (mr >= or + rows && or + rows < srv_rows) {
  51.486 -+		if ((or += rows / 5) > srv_rows - rows)
  51.487 -+			or = srv_rows - rows;
  51.488 -+	}
  51.489 -+	else refresh--;
  51.490 -+	mc = MAX(oc, MIN(oc + cols - 1, mc));
  51.491 -+	mr = MAX(or, MIN(or + rows - 1, mr));
  51.492 - 	if (ie[0] & 0x01)
  51.493 - 		mask |= VNC_BUTTON1_MASK;
  51.494 - 	if (ie[0] & 0x04)
  51.495 -@@ -233,6 +298,8 @@
  51.496 - 	me.x = htons(mc);
  51.497 - 	me.mask = mask;
  51.498 - 	write(fd, &me, sizeof(me));
  51.499 -+	if (refresh)
  51.500 -+		vnc_refresh(fd, 0);
  51.501 - 	return 0;
  51.502 - }
  51.503 - 
  51.504 -@@ -292,12 +359,11 @@
  51.505 - 			k = 0xff0d;
  51.506 - 			break;
  51.507 - 		case 0x0c:	/* ^L: redraw */
  51.508 --			if (vnc_refresh(fd, 0))
  51.509 --				return -1;
  51.510 -+			vnc_refresh(fd, 0);
  51.511 - 		default:
  51.512 - 			k = (unsigned char) key[i];
  51.513 - 		}
  51.514 --		if (k >= 'A' && k <= 'Z' || strchr(":\"<>?{}|+_()*&^%$#@!~", k))
  51.515 -+		if ((k >= 'A' && k <= 'Z') || strchr(":\"<>?{}|+_()*&^%$#@!~", k))
  51.516 - 			mod[nmod++] = 0xffe1;
  51.517 - 		if (k >= 1 && k <= 26) {
  51.518 - 			k = 'a' + k - 1;
  51.519 -@@ -339,40 +405,42 @@
  51.520 - 	write(STDIN_FILENO, show, strlen(show));
  51.521 - }
  51.522 - 
  51.523 --static void mainloop(int vnc_fd, int kbd_fd, int rat_fd)
  51.524 -+static int mainloop(int vnc_fd, int kbd_fd, int rat_fd)
  51.525 - {
  51.526 - 	struct pollfd ufds[3];
  51.527 - 	int pending = 0;
  51.528 - 	int err;
  51.529 - 	ufds[0].fd = kbd_fd;
  51.530 --	ufds[0].events = POLLIN;
  51.531 - 	ufds[1].fd = vnc_fd;
  51.532 --	ufds[1].events = POLLIN;
  51.533 - 	ufds[2].fd = rat_fd;
  51.534 -+	ufds[0].events =
  51.535 -+	ufds[1].events =
  51.536 - 	ufds[2].events = POLLIN;
  51.537 --	if (vnc_refresh(vnc_fd, 0))
  51.538 --		return;
  51.539 -+	vnc_refresh(vnc_fd, 0);
  51.540 - 	while (1) {
  51.541 - 		err = poll(ufds, 3, 500);
  51.542 - 		if (err == -1 && errno != EINTR)
  51.543 - 			break;
  51.544 - 		if (!err)
  51.545 - 			continue;
  51.546 -+		err = -2;
  51.547 - 		if (ufds[0].revents & POLLIN)
  51.548 - 			if (kbd_event(vnc_fd, kbd_fd) == -1)
  51.549 - 				break;
  51.550 -+		err--;
  51.551 - 		if (ufds[1].revents & POLLIN) {
  51.552 - 			if (vnc_event(vnc_fd) == -1)
  51.553 - 				break;
  51.554 - 			pending = 0;
  51.555 - 		}
  51.556 -+		err--;
  51.557 - 		if (ufds[2].revents & POLLIN)
  51.558 - 			if (rat_event(vnc_fd, rat_fd) == -1)
  51.559 - 				break;
  51.560 - 		if (!pending++)
  51.561 --			if (vnc_refresh(vnc_fd, 1))
  51.562 --				break;
  51.563 -+			vnc_refresh(vnc_fd, 1);
  51.564 - 	}
  51.565 -+	return err;
  51.566 - }
  51.567 - 
  51.568 - int main(int argc, char * argv[])
  51.569 -@@ -380,27 +448,38 @@
  51.570 - 	char *port = VNC_PORT;
  51.571 - 	char *host = "127.0.0.1";
  51.572 - 	struct termios ti;
  51.573 --	int vnc_fd, rat_fd;
  51.574 -+	int vnc_fd, rat_fd, status;
  51.575 -+	
  51.576 -+	if (argc < 2) {
  51.577 -+		fprintf(stderr, "Usage : fbvnc [-bpp bits] server [port]\n");
  51.578 -+		return 0;
  51.579 -+  	}
  51.580 -+  	if (*argv[1] == '-' && argc >= 3) {
  51.581 -+  		argc -= 2; argv += 2;
  51.582 -+  		bpp = atoi(argv[0]) >> 3;
  51.583 -+  	} 
  51.584 - 	if (argc >= 2)
  51.585 - 		host = argv[1];
  51.586 - 	if (argc >= 3)
  51.587 - 		port = argv[2];
  51.588 --	if ((vnc_fd = vnc_connect(host, port)) == -1) {
  51.589 --		fprintf(stderr, "could not connect!\n");
  51.590 -+	if ((vnc_fd = vnc_connect(host, port)) < 0) {
  51.591 -+		fprintf(stderr, "could not connect! %s %s : %d\n",
  51.592 -+			host,port,vnc_fd);
  51.593 - 		return 1;
  51.594 - 	}
  51.595 --	if (vnc_init(vnc_fd) == -1) {
  51.596 --		fprintf(stderr, "vnc init failed!\n");
  51.597 --		return 1;
  51.598 -+	status = vnc_init(vnc_fd);
  51.599 -+	if (status < 0) {
  51.600 -+		fprintf(stderr, "vnc init failed! %d\n", status);
  51.601 -+		return 2;
  51.602 - 	}
  51.603 - 	term_setup(&ti);
  51.604 - 	rat_fd = open("/dev/input/mice", O_RDONLY);
  51.605 - 
  51.606 --	mainloop(vnc_fd, 0, rat_fd);
  51.607 -+	status = mainloop(vnc_fd, 0, rat_fd);
  51.608 - 
  51.609 - 	term_cleanup(&ti);
  51.610 - 	vnc_free();
  51.611 - 	close(vnc_fd);
  51.612 - 	close(rat_fd);
  51.613 --	return 0;
  51.614 -+	return 2 - status;
  51.615 - }
    52.1 --- a/fr/receipt	Thu Jul 18 13:24:21 2013 +0000
    52.2 +++ b/fr/receipt	Fri Oct 02 21:45:05 2015 +0200
    52.3 @@ -2,7 +2,7 @@
    52.4  
    52.5  PACKAGE="fr"
    52.6  VERSION="1.0"
    52.7 -CATEGORY="configuration"
    52.8 +CATEGORY="meta"
    52.9  SHORT_DESC="FR keyboard and locales"
   52.10  MAINTAINER="pascal.bellard@slitaz.org"
   52.11  LICENSE="GPL2"
   52.12 @@ -12,10 +12,9 @@
   52.13  # Rules to configure and make the package.
   52.14  compile_rules()
   52.15  {
   52.16 -	mkdir -p fs/etc
   52.17 -	echo "Europe/Paris" > fs/etc/TZ
   52.18 -	echo "fr-latin1" > fs/etc/keymap.conf
   52.19 -	cat > fs/etc/locale.conf <<EOT
   52.20 +	mkdir -p $DESTDIR/etc
   52.21 +	echo "Europe/Paris" > $DESTDIR/etc/TZ
   52.22 +	cat > $DESTDIR/etc/locale.conf <<EOT
   52.23  LANG=fr_FR
   52.24  LC_ALL=fr_FR
   52.25  EOT
   52.26 @@ -24,8 +23,8 @@
   52.27  			tazpkg get $pkg
   52.28  			tazpkg extract $pkg*.tazpkg
   52.29  		fi
   52.30 -		mkdir -p fs$(dirname $file)
   52.31 -		mv $pkg*/fs$file fs$(dirname $file) || return 1
   52.32 +		mkdir -p $DESTDIR$(dirname $file)
   52.33 +		mv $pkg*/fs$file $DESTDIR$(dirname $file) || return 1
   52.34  	done << EOT
   52.35  kbd-busybox	/usr/share/kmap/fr-latin1.kmap
   52.36  EOT
   52.37 @@ -34,5 +33,5 @@
   52.38  # Rules to gen a SliTaz package suitable for Tazpkg.
   52.39  genpkg_rules()
   52.40  {
   52.41 -	cp -a fs/. $fs
   52.42 +	cp -a $install/. $fs
   52.43  }
    53.1 --- a/ftp-config/receipt	Thu Jul 18 13:24:21 2013 +0000
    53.2 +++ b/ftp-config/receipt	Fri Oct 02 21:45:05 2015 +0200
    53.3 @@ -2,7 +2,7 @@
    53.4  
    53.5  PACKAGE="ftp-config"
    53.6  VERSION="1.0"
    53.7 -CATEGORY="configuration"
    53.8 +CATEGORY="meta"
    53.9  SHORT_DESC="File transport protocol server configuration"
   53.10  MAINTAINER="pascal.bellard@slitaz.org"
   53.11  LICENSE="BSD"
    54.1 --- a/gpxe/receipt	Thu Jul 18 13:24:21 2013 +0000
    54.2 +++ b/gpxe/receipt	Fri Oct 02 21:45:05 2015 +0200
    54.3 @@ -18,8 +18,8 @@
    54.4  			tazpkg get $pkg
    54.5  			tazpkg extract $pkg*.tazpkg
    54.6  		fi
    54.7 -		mkdir -p fs$(dirname $file)
    54.8 -		mv $pkg*/fs$file fs$(dirname $file) || return 1
    54.9 +		mkdir -p $DESTDIR$(dirname $file)
   54.10 +		mv $pkg*/fs$file $DESTDIR$(dirname $file) || return 1
   54.11  	done << EOT
   54.12  gpxe-pxe	/usr/share/boot/gpxe.pxe
   54.13  EOT
   54.14 @@ -28,7 +28,7 @@
   54.15  # Rules to gen a SliTaz package suitable for Tazpkg.
   54.16  genpkg_rules()
   54.17  {
   54.18 -	cp -a fs/. $fs
   54.19 +	cp -a $install/. $fs
   54.20  }
   54.21  
   54.22  post_install()
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/hardware-ibm-6272/receipt	Fri Oct 02 21:45:05 2015 +0200
    55.3 @@ -0,0 +1,64 @@
    55.4 +# SliTaz package receipt.
    55.5 +
    55.6 +PACKAGE="hardware-ibm-6272"
    55.7 +VERSION="1.0"
    55.8 +CATEGORY="meta"
    55.9 +MAINTAINER="devel@slitaz.org"
   55.10 +LICENSE="BSD"
   55.11 +SHORT_DESC="IBM 300GL 6272/6282 (P75-233 ISA/PCI/USB/ETH desktop) hardware support"
   55.12 +WEB_SITE="http://www.slitaz.org/"
   55.13 +
   55.14 +DEPENDS="isapnptools module-cs89x0"
   55.15 +SUGGESTED="module-usb-storage"
   55.16 +
   55.17 +# Post message when installing.
   55.18 +post_install()
   55.19 +{
   55.20 +	[ -s $1/etc/init.d/pnp.sh ] || cat > $1/etc/init.d/pnp.sh <<EOT
   55.21 +#!/bin/sh
   55.22 +
   55.23 +. /etc/init.d/rc.functions
   55.24 +EOT
   55.25 +	chmod +x $fs/etc/init.d/pnp.sh
   55.26 +	cat >> $1/etc/init.d/pnp.sh <<EOT
   55.27 +
   55.28 +echo -n "Switching on isa pnp ethernet card "
   55.29 +for io in \$(seq 360 -10 250); do for irq in IRQ_CS89X0_LIST; do
   55.30 +pnpdump | awk "BEGIN {s=0} \\
   55.31 +/CONFIGURE CSC6040/ {s=1} { \\
   55.32 +  if (s==0) print; \\
   55.33 +  else if (/INT 0/) print \\"(INT 0 (IRQ \$irq (MODE +E)))\\"; \\
   55.34 +  else if (/IO 0/) print \\"(IO 0 (SIZE 16) (BASE 0x0\$io) (CHECK))\\"; \\
   55.35 +  else if (/ACT Y/) { s=0; print \\"(ACT Y)\\"} \\
   55.36 +  else print \\
   55.37 +}" > /etc/isapnp.conf
   55.38 +if isapnp /etc/isapnp.conf > /dev/null 2>&1 ; then
   55.39 +  modprobe cs89x0 io=0x\$io irq=\$irq > /dev/null 2>&1
   55.40 +  break 2
   55.41 +fi
   55.42 +done ; done
   55.43 +status
   55.44 +EOT
   55.45 +	grep pnp.sh $1/etc/rcS.conf ||
   55.46 +	sed -i 's/EARLY_RUN_SCRIPTS="/&pnp.sh /' $1/etc/rcS.conf
   55.47 +	list=""
   55.48 +	for i in $IRQ_CS89X0_LIST ; do
   55.49 +		case " 15 12 11 10 9 7 6 5 4 3 " in
   55.50 +		*\ $i\ *)	list="$list $i "
   55.51 +		esac
   55.52 +	done
   55.53 +	sed -i "s/IRQ_CS89X0_LIST/${list:-15 12 11 10}/" $1/etc/init.d/pnp.sh
   55.54 +	sed -i 's/cs89x0[^ "]* //' $1/etc/rcS.conf
   55.55 +}
   55.56 +
   55.57 +config_form()
   55.58 +{
   55.59 +	cat <<EOT
   55.60 +<table>
   55.61 +<tr>
   55.62 +<td>Allowed IRQ for the Ethernet driver cs89x0</td>
   55.63 +<td><input type="text" name="IRQ_CS89X0_LIST" value="${IRQ_LIST:-15 12 11 10 9 7 6 5 4 3}" /></td>
   55.64 +</tr>
   55.65 +</table>
   55.66 +EOT
   55.67 +}
    56.1 --- a/isapnptools/receipt	Thu Jul 18 13:24:21 2013 +0000
    56.2 +++ b/isapnptools/receipt	Fri Oct 02 21:45:05 2015 +0200
    56.3 @@ -10,13 +10,11 @@
    56.4  BUILD_DEPENDS="uclibc-cross-compiler-$TARGET"
    56.5  TARBALL="$PACKAGE-$VERSION.tgz"
    56.6  WEB_SITE="http://www.roestock.demon.co.uk/isapnptools/"
    56.7 -WGET_URL="ftp://metalab.unc.edu/pub/Linux/system/hardware/$TARBALL"
    56.8 +WGET_URL="http://mirror.slitaz.org/sources/packages/i/$TARBALL"
    56.9  
   56.10  # Rules to configure and make the package.
   56.11  compile_rules()
   56.12  {
   56.13 -	cd $src
   56.14 -
   56.15  	# Fix cross tools prefix...
   56.16  	export PATH=$PWD:$PATH
   56.17  	PREFIX=$TARGET-uclibc-gnu
   56.18 @@ -30,12 +28,12 @@
   56.19  		--prefix=/usr --bindir=/bin \
   56.20  		--libexecdir=/usr/bin --mandir=/usr/share/man
   56.21  	make &&
   56.22 -	make DESTDIR=$PWD/_pkg install
   56.23 +	make DESTDIR=$DESTDIR install
   56.24  }
   56.25  
   56.26  # Rules to gen a SliTaz package suitable for Tazpkg.
   56.27  genpkg_rules()
   56.28  {
   56.29  	# move /usr/sbin/* /sbin to use pnptools *before* mounting /usr
   56.30 -	cp -a $_pkg/usr/sbin $fs
   56.31 +	cp -a $install/usr/sbin $fs
   56.32  }
    57.1 --- a/jslinux-config/receipt	Thu Jul 18 13:24:21 2013 +0000
    57.2 +++ b/jslinux-config/receipt	Fri Oct 02 21:45:05 2015 +0200
    57.3 @@ -2,22 +2,16 @@
    57.4  
    57.5  PACKAGE="jslinux-config"
    57.6  VERSION="1.0"
    57.7 -CATEGORY="configuration"
    57.8 +CATEGORY="meta"
    57.9  SHORT_DESC="Tiny SliTaz configuration files for jslinux"
   57.10  MAINTAINER="pascal.bellard@slitaz.org"
   57.11  LICENSE="BSD"
   57.12  WEB_SITE="http://tiny.slitaz.org/"
   57.13  DEPENDS="custom-console"
   57.14  
   57.15 -# Rules to configure and make the package.
   57.16 -compile_rules()
   57.17 -{
   57.18 -	mkdir -p fs/dev
   57.19 -	mkmod -m 660 fs/dev/clipboard c 10 231
   57.20 -}
   57.21 -
   57.22  # Rules to gen a SliTaz package suitable for Tazpkg.
   57.23  genpkg_rules()
   57.24  {
   57.25 -	cp -a fs/. $fs
   57.26 +	mkdir -p $fs/dev
   57.27 +	mknod -m 660 $fs/dev/clipboard c 10 231
   57.28  }
    58.1 --- a/jssame/receipt	Thu Jul 18 13:24:21 2013 +0000
    58.2 +++ b/jssame/receipt	Fri Oct 02 21:45:05 2015 +0200
    58.3 @@ -11,8 +11,7 @@
    58.4  # Rules to gen a SliTaz package suitable for Tazpkg.
    58.5  genpkg_rules()
    58.6  {
    58.7 -	mkdir $fs/var/www/same
    58.8 +	mkdir -p $fs/var/www/same
    58.9  	cp -a $stuff/index.html $fs/var/www/same
   58.10  	chown -R 80.80 $fs/var/www/same
   58.11  }
   58.12 -
    59.1 --- a/kernel-fb/receipt	Thu Jul 18 13:24:21 2013 +0000
    59.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.3 @@ -1,20 +0,0 @@
    59.4 -# SliTaz package receipt.
    59.5 -
    59.6 -PACKAGE="kernel-fb"
    59.7 -VERSION="2.6.37"
    59.8 -CATEGORY="base-system"
    59.9 -SHORT_DESC="Kernel i386 with mouses, video frame buffers and some ethernet cards, but no disk."
   59.10 -MAINTAINER="devel@slitaz.org"
   59.11 -LICENSE="GPL2"
   59.12 -WEB_SITE="http://www.kernel.org/"
   59.13 -WANTED="kernel-modular"
   59.14 -
   59.15 -# Rules to gen a SliTaz package suitable for Tazpkg.
   59.16 -genpkg_rules()
   59.17 -{
   59.18 -    mkdir $fs/boot
   59.19 -    cp -a $WOK/kernel-modular/linux-$VERSION/$PACKAGE $fs/boot/bzImage
   59.20 -    cp -a $WOK/kernel-modular/linux-$VERSION/System.map-${PACKAGE#kernel-} $fs/boot/System.map
   59.21 -    cp -a $WOK/kernel-modular/linux-$VERSION/config-${PACKAGE#kernel-} $fs/boot/config
   59.22 -    cp -a $WOK/kernel-modular/linux-$VERSION/config-busybox $fs/boot
   59.23 -}
    60.1 --- a/kernel-isa/receipt	Thu Jul 18 13:24:21 2013 +0000
    60.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.3 @@ -1,21 +0,0 @@
    60.4 -# SliTaz package receipt.
    60.5 -
    60.6 -PACKAGE="kernel-isa"
    60.7 -VERSION="2.6.37"
    60.8 -CATEGORY="base-system"
    60.9 -SHORT_DESC="Kernel i386 with ppp, ne2k-isa, 3c509, ide and ext3"
   60.10 -MAINTAINER="devel@slitaz.org"
   60.11 -LICENSE="GPL2"
   60.12 -WEB_SITE="http://www.kernel.org/"
   60.13 -WANTED="kernel-modular"
   60.14 -
   60.15 -# Rules to gen a SliTaz package suitable for Tazpkg.
   60.16 -genpkg_rules()
   60.17 -{
   60.18 -    mkdir $fs/boot
   60.19 -    cp -a $WOK/kernel-modular/linux-$VERSION/$PACKAGE $fs/boot/bzImage
   60.20 -    cp -a $WOK/kernel-modular/linux-$VERSION/System.map-${PACKAGE#kernel-} $fs/boot/System.map
   60.21 -    cp -a $WOK/kernel-modular/linux-$VERSION/config-${PACKAGE#kernel-} $fs/boot/config
   60.22 -    cp -a $WOK/kernel-modular/linux-$VERSION/config-busybox $fs/boot
   60.23 -}
   60.24 -
    61.1 --- a/kernel-lguest/receipt	Thu Jul 18 13:24:21 2013 +0000
    61.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.3 @@ -1,20 +0,0 @@
    61.4 -# SliTaz package receipt.
    61.5 -
    61.6 -PACKAGE="kernel-lguest"
    61.7 -VERSION="2.6.37"
    61.8 -CATEGORY="base-system"
    61.9 -SHORT_DESC="Kernel i686 with ext3 and virtual drivers for ethernet and disk"
   61.10 -MAINTAINER="devel@slitaz.org"
   61.11 -LICENSE="GPL2"
   61.12 -WEB_SITE="http://www.kernel.org/"
   61.13 -WANTED="kernel-modular"
   61.14 -
   61.15 -# Rules to gen a SliTaz package suitable for Tazpkg.
   61.16 -genpkg_rules()
   61.17 -{
   61.18 -    mkdir $fs/boot
   61.19 -    cp -a $WOK/kernel-modular/linux-$VERSION/$PACKAGE $fs/boot/bzImage
   61.20 -    cp -a $WOK/kernel-modular/linux-$VERSION/System.map-${PACKAGE#kernel-} $fs/boot/System.map
   61.21 -    cp -a $WOK/kernel-modular/linux-$VERSION/config-${PACKAGE#kernel-} $fs/boot/config
   61.22 -    cp -a $WOK/kernel-modular/linux-$VERSION/config-busybox $fs/boot
   61.23 -}
    62.1 --- a/kernel-modular/stuff/001-squashfs-decompressors-add-xz-decompressor-module.patch	Thu Jul 18 13:24:21 2013 +0000
    62.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.3 @@ -1,3934 +0,0 @@
    62.4 -From: Lasse Collin <lasse.collin@tukaani.org>
    62.5 -Date: Thu, 2 Dec 2010 19:14:19 +0000 (+0200)
    62.6 -Subject: Decompressors: Add XZ decompressor module
    62.7 -X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fpkl%2Fsquashfs-xz.git;a=commitdiff_plain;h=3dbc3fe7878e53b43064a12d4ab31ca4c18ce85f
    62.8 -
    62.9 -Decompressors: Add XZ decompressor module
   62.10 -
   62.11 -In userspace, the .lzma format has become mostly a legacy
   62.12 -file format that got superseded by the .xz format. Similarly,
   62.13 -LZMA Utils was superseded by XZ Utils.
   62.14 -
   62.15 -These patches add support for XZ decompression into
   62.16 -the kernel. Most of the code is as is from XZ Embedded
   62.17 -<http://tukaani.org/xz/embedded.html>. It was written for
   62.18 -the Linux kernel but is usable in other projects too.
   62.19 -
   62.20 -Advantages of XZ over the current LZMA code in the kernel:
   62.21 -  - Nice API that can be used by other kernel modules; it's
   62.22 -    not limited to kernel, initramfs, and initrd decompression.
   62.23 -  - Integrity check support (CRC32)
   62.24 -  - BCJ filters improve compression of executable code on
   62.25 -    certain architectures. These together with LZMA2 can
   62.26 -    produce a few percent smaller kernel or Squashfs images
   62.27 -    than plain LZMA without making the decompression slower.
   62.28 -
   62.29 -This patch: Add the main decompression code (xz_dec), testing
   62.30 -module (xz_dec_test), wrapper script (xz_wrap.sh) for the xz
   62.31 -command line tool, and documentation. The xz_dec module is
   62.32 -enough to have a usable XZ decompressor e.g. for Squashfs.
   62.33 -
   62.34 -Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
   62.35 ----
   62.36 -
   62.37 -diff --git a/Documentation/xz.txt b/Documentation/xz.txt
   62.38 -new file mode 100644
   62.39 -index 0000000..68329ac
   62.40 ---- /dev/null
   62.41 -+++ b/Documentation/xz.txt
   62.42 -@@ -0,0 +1,122 @@
   62.43 -+
   62.44 -+XZ data compression in Linux
   62.45 -+============================
   62.46 -+
   62.47 -+Introduction
   62.48 -+
   62.49 -+    XZ is a general purpose data compression format with high compression
   62.50 -+    ratio and relatively fast decompression. The primary compression
   62.51 -+    algorithm (filter) is LZMA2. Additional filters can be used to improve
   62.52 -+    compression ratio even further. E.g. Branch/Call/Jump (BCJ) filters
   62.53 -+    improve compression ratio of executable data.
   62.54 -+
   62.55 -+    The XZ decompressor in Linux is called XZ Embedded. It supports
   62.56 -+    the LZMA2 filter and optionally also BCJ filters. CRC32 is supported
   62.57 -+    for integrity checking. The home page of XZ Embedded is at
   62.58 -+    <http://tukaani.org/xz/embedded.html>, where you can find the
   62.59 -+    latest version and also information about using the code outside
   62.60 -+    the Linux kernel.
   62.61 -+
   62.62 -+    For userspace, XZ Utils provide a zlib-like compression library
   62.63 -+    and a gzip-like command line tool. XZ Utils can be downloaded from
   62.64 -+    <http://tukaani.org/xz/>.
   62.65 -+
   62.66 -+XZ related components in the kernel
   62.67 -+
   62.68 -+    The xz_dec module provides XZ decompressor with single-call (buffer
   62.69 -+    to buffer) and multi-call (stateful) APIs. The usage of the xz_dec
   62.70 -+    module is documented in include/linux/xz.h.
   62.71 -+
   62.72 -+    The xz_dec_test module is for testing xz_dec. xz_dec_test is not
   62.73 -+    useful unless you are hacking the XZ decompressor. xz_dec_test
   62.74 -+    allocates a char device major dynamically to which one can write
   62.75 -+    .xz files from userspace. The decompressed output is thrown away.
   62.76 -+    Keep an eye on dmesg to see diagnostics printed by xz_dec_test.
   62.77 -+    See the xz_dec_test source code for the details.
   62.78 -+
   62.79 -+    For decompressing the kernel image, initramfs, and initrd, there
   62.80 -+    is a wrapper function in lib/decompress_unxz.c. Its API is the
   62.81 -+    same as in other decompress_*.c files, which is defined in
   62.82 -+    include/linux/decompress/generic.h.
   62.83 -+
   62.84 -+    scripts/xz_wrap.sh is a wrapper for the xz command line tool found
   62.85 -+    from XZ Utils. The wrapper sets compression options to values suitable
   62.86 -+    for compressing the kernel image.
   62.87 -+
   62.88 -+    For kernel makefiles, two commands are provided for use with
   62.89 -+    $(call if_needed). The kernel image should be compressed with
   62.90 -+    $(call if_needed,xzkern) which will use a BCJ filter and a big LZMA2
   62.91 -+    dictionary. It will also append a four-byte trailer containing the
   62.92 -+    uncompressed size of the file, which is needed by the boot code.
   62.93 -+    Other things should be compressed with $(call if_needed,xzmisc)
   62.94 -+    which will use no BCJ filter and 1 MiB LZMA2 dictionary.
   62.95 -+
   62.96 -+Notes on compression options
   62.97 -+
   62.98 -+    Since the XZ Embedded supports only streams with no integrity check or
   62.99 -+    CRC32, make sure that you don't use some other integrity check type
  62.100 -+    when encoding files that are supposed to be decoded by the kernel. With
  62.101 -+    liblzma, you need to use either LZMA_CHECK_NONE or LZMA_CHECK_CRC32
  62.102 -+    when encoding. With the xz command line tool, use --check=none or
  62.103 -+    --check=crc32.
  62.104 -+
  62.105 -+    Using CRC32 is strongly recommended unless there is some other layer
  62.106 -+    which will verify the integrity of the uncompressed data anyway.
  62.107 -+    Double checking the integrity would probably be waste of CPU cycles.
  62.108 -+    Note that the headers will always have a CRC32 which will be validated
  62.109 -+    by the decoder; you can only change the integrity check type (or
  62.110 -+    disable it) for the actual uncompressed data.
  62.111 -+
  62.112 -+    In userspace, LZMA2 is typically used with dictionary sizes of several
  62.113 -+    megabytes. The decoder needs to have the dictionary in RAM, thus big
  62.114 -+    dictionaries cannot be used for files that are intended to be decoded
  62.115 -+    by the kernel. 1 MiB is probably the maximum reasonable dictionary
  62.116 -+    size for in-kernel use (maybe more is OK for initramfs). The presets
  62.117 -+    in XZ Utils may not be optimal when creating files for the kernel,
  62.118 -+    so don't hesitate to use custom settings. Example:
  62.119 -+
  62.120 -+        xz --check=crc32 --lzma2=dict=512KiB inputfile
  62.121 -+
  62.122 -+    An exception to above dictionary size limitation is when the decoder
  62.123 -+    is used in single-call mode. Decompressing the kernel itself is an
  62.124 -+    example of this situation. In single-call mode, the memory usage
  62.125 -+    doesn't depend on the dictionary size, and it is perfectly fine to
  62.126 -+    use a big dictionary: for maximum compression, the dictionary should
  62.127 -+    be at least as big as the uncompressed data itself.
  62.128 -+
  62.129 -+Future plans
  62.130 -+
  62.131 -+    Creating a limited XZ encoder may be considered if people think it is
  62.132 -+    useful. LZMA2 is slower to compress than e.g. Deflate or LZO even at
  62.133 -+    the fastest settings, so it isn't clear if LZMA2 encoder is wanted
  62.134 -+    into the kernel.
  62.135 -+
  62.136 -+    Support for limited random-access reading is planned for the
  62.137 -+    decompression code. I don't know if it could have any use in the
  62.138 -+    kernel, but I know that it would be useful in some embedded projects
  62.139 -+    outside the Linux kernel.
  62.140 -+
  62.141 -+Conformance to the .xz file format specification
  62.142 -+
  62.143 -+    There are a couple of corner cases where things have been simplified
  62.144 -+    at expense of detecting errors as early as possible. These should not
  62.145 -+    matter in practice all, since they don't cause security issues. But
  62.146 -+    it is good to know this if testing the code e.g. with the test files
  62.147 -+    from XZ Utils.
  62.148 -+
  62.149 -+Reporting bugs
  62.150 -+
  62.151 -+    Before reporting a bug, please check that it's not fixed already
  62.152 -+    at upstream. See <http://tukaani.org/xz/embedded.html> to get the
  62.153 -+    latest code.
  62.154 -+
  62.155 -+    Report bugs to <lasse.collin@tukaani.org> or visit #tukaani on
  62.156 -+    Freenode and talk to Larhzu. I don't actively read LKML or other
  62.157 -+    kernel-related mailing lists, so if there's something I should know,
  62.158 -+    you should email to me personally or use IRC.
  62.159 -+
  62.160 -+    Don't bother Igor Pavlov with questions about the XZ implementation
  62.161 -+    in the kernel or about XZ Utils. While these two implementations
  62.162 -+    include essential code that is directly based on Igor Pavlov's code,
  62.163 -+    these implementations aren't maintained nor supported by him.
  62.164 -+
  62.165 -diff --git a/include/linux/xz.h b/include/linux/xz.h
  62.166 -new file mode 100644
  62.167 -index 0000000..64cffa6
  62.168 ---- /dev/null
  62.169 -+++ b/include/linux/xz.h
  62.170 -@@ -0,0 +1,264 @@
  62.171 -+/*
  62.172 -+ * XZ decompressor
  62.173 -+ *
  62.174 -+ * Authors: Lasse Collin <lasse.collin@tukaani.org>
  62.175 -+ *          Igor Pavlov <http://7-zip.org/>
  62.176 -+ *
  62.177 -+ * This file has been put into the public domain.
  62.178 -+ * You can do whatever you want with this file.
  62.179 -+ */
  62.180 -+
  62.181 -+#ifndef XZ_H
  62.182 -+#define XZ_H
  62.183 -+
  62.184 -+#ifdef __KERNEL__
  62.185 -+#	include <linux/stddef.h>
  62.186 -+#	include <linux/types.h>
  62.187 -+#else
  62.188 -+#	include <stddef.h>
  62.189 -+#	include <stdint.h>
  62.190 -+#endif
  62.191 -+
  62.192 -+/* In Linux, this is used to make extern functions static when needed. */
  62.193 -+#ifndef XZ_EXTERN
  62.194 -+#	define XZ_EXTERN extern
  62.195 -+#endif
  62.196 -+
  62.197 -+/**
  62.198 -+ * enum xz_mode - Operation mode
  62.199 -+ *
  62.200 -+ * @XZ_SINGLE:              Single-call mode. This uses less RAM than
  62.201 -+ *                          than multi-call modes, because the LZMA2
  62.202 -+ *                          dictionary doesn't need to be allocated as
  62.203 -+ *                          part of the decoder state. All required data
  62.204 -+ *                          structures are allocated at initialization,
  62.205 -+ *                          so xz_dec_run() cannot return XZ_MEM_ERROR.
  62.206 -+ * @XZ_PREALLOC:            Multi-call mode with preallocated LZMA2
  62.207 -+ *                          dictionary buffer. All data structures are
  62.208 -+ *                          allocated at initialization, so xz_dec_run()
  62.209 -+ *                          cannot return XZ_MEM_ERROR.
  62.210 -+ * @XZ_DYNALLOC:            Multi-call mode. The LZMA2 dictionary is
  62.211 -+ *                          allocated once the required size has been
  62.212 -+ *                          parsed from the stream headers. If the
  62.213 -+ *                          allocation fails, xz_dec_run() will return
  62.214 -+ *                          XZ_MEM_ERROR.
  62.215 -+ *
  62.216 -+ * It is possible to enable support only for a subset of the above
  62.217 -+ * modes at compile time by defining XZ_DEC_SINGLE, XZ_DEC_PREALLOC,
  62.218 -+ * or XZ_DEC_DYNALLOC. The xz_dec kernel module is always compiled
  62.219 -+ * with support for all operation modes, but the preboot code may
  62.220 -+ * be built with fewer features to minimize code size.
  62.221 -+ */
  62.222 -+enum xz_mode {
  62.223 -+	XZ_SINGLE,
  62.224 -+	XZ_PREALLOC,
  62.225 -+	XZ_DYNALLOC
  62.226 -+};
  62.227 -+
  62.228 -+/**
  62.229 -+ * enum xz_ret - Return codes
  62.230 -+ * @XZ_OK:                  Everything is OK so far. More input or more
  62.231 -+ *                          output space is required to continue. This
  62.232 -+ *                          return code is possible only in multi-call mode
  62.233 -+ *                          (XZ_PREALLOC or XZ_DYNALLOC).
  62.234 -+ * @XZ_STREAM_END:          Operation finished successfully.
  62.235 -+ * @XZ_UNSUPPORTED_CHECK:   Integrity check type is not supported. Decoding
  62.236 -+ *                          is still possible in multi-call mode by simply
  62.237 -+ *                          calling xz_dec_run() again.
  62.238 -+ *                          Note that this return value is used only if
  62.239 -+ *                          XZ_DEC_ANY_CHECK was defined at build time,
  62.240 -+ *                          which is not used in the kernel. Unsupported
  62.241 -+ *                          check types return XZ_OPTIONS_ERROR if
  62.242 -+ *                          XZ_DEC_ANY_CHECK was not defined at build time.
  62.243 -+ * @XZ_MEM_ERROR:           Allocating memory failed. This return code is
  62.244 -+ *                          possible only if the decoder was initialized
  62.245 -+ *                          with XZ_DYNALLOC. The amount of memory that was
  62.246 -+ *                          tried to be allocated was no more than the
  62.247 -+ *                          dict_max argument given to xz_dec_init().
  62.248 -+ * @XZ_MEMLIMIT_ERROR:      A bigger LZMA2 dictionary would be needed than
  62.249 -+ *                          allowed by the dict_max argument given to
  62.250 -+ *                          xz_dec_init(). This return value is possible
  62.251 -+ *                          only in multi-call mode (XZ_PREALLOC or
  62.252 -+ *                          XZ_DYNALLOC); the single-call mode (XZ_SINGLE)
  62.253 -+ *                          ignores the dict_max argument.
  62.254 -+ * @XZ_FORMAT_ERROR:        File format was not recognized (wrong magic
  62.255 -+ *                          bytes).
  62.256 -+ * @XZ_OPTIONS_ERROR:       This implementation doesn't support the requested
  62.257 -+ *                          compression options. In the decoder this means
  62.258 -+ *                          that the header CRC32 matches, but the header
  62.259 -+ *                          itself specifies something that we don't support.
  62.260 -+ * @XZ_DATA_ERROR:          Compressed data is corrupt.
  62.261 -+ * @XZ_BUF_ERROR:           Cannot make any progress. Details are slightly
  62.262 -+ *                          different between multi-call and single-call
  62.263 -+ *                          mode; more information below.
  62.264 -+ *
  62.265 -+ * In multi-call mode, XZ_BUF_ERROR is returned when two consecutive calls
  62.266 -+ * to XZ code cannot consume any input and cannot produce any new output.
  62.267 -+ * This happens when there is no new input available, or the output buffer
  62.268 -+ * is full while at least one output byte is still pending. Assuming your
  62.269 -+ * code is not buggy, you can get this error only when decoding a compressed
  62.270 -+ * stream that is truncated or otherwise corrupt.
  62.271 -+ *
  62.272 -+ * In single-call mode, XZ_BUF_ERROR is returned only when the output buffer
  62.273 -+ * is too small or the compressed input is corrupt in a way that makes the
  62.274 -+ * decoder produce more output than the caller expected. When it is
  62.275 -+ * (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR
  62.276 -+ * is used instead of XZ_BUF_ERROR.
  62.277 -+ */
  62.278 -+enum xz_ret {
  62.279 -+	XZ_OK,
  62.280 -+	XZ_STREAM_END,
  62.281 -+	XZ_UNSUPPORTED_CHECK,
  62.282 -+	XZ_MEM_ERROR,
  62.283 -+	XZ_MEMLIMIT_ERROR,
  62.284 -+	XZ_FORMAT_ERROR,
  62.285 -+	XZ_OPTIONS_ERROR,
  62.286 -+	XZ_DATA_ERROR,
  62.287 -+	XZ_BUF_ERROR
  62.288 -+};
  62.289 -+
  62.290 -+/**
  62.291 -+ * struct xz_buf - Passing input and output buffers to XZ code
  62.292 -+ * @in:         Beginning of the input buffer. This may be NULL if and only
  62.293 -+ *              if in_pos is equal to in_size.
  62.294 -+ * @in_pos:     Current position in the input buffer. This must not exceed
  62.295 -+ *              in_size.
  62.296 -+ * @in_size:    Size of the input buffer
  62.297 -+ * @out:        Beginning of the output buffer. This may be NULL if and only
  62.298 -+ *              if out_pos is equal to out_size.
  62.299 -+ * @out_pos:    Current position in the output buffer. This must not exceed
  62.300 -+ *              out_size.
  62.301 -+ * @out_size:   Size of the output buffer
  62.302 -+ *
  62.303 -+ * Only the contents of the output buffer from out[out_pos] onward, and
  62.304 -+ * the variables in_pos and out_pos are modified by the XZ code.
  62.305 -+ */
  62.306 -+struct xz_buf {
  62.307 -+	const uint8_t *in;
  62.308 -+	size_t in_pos;
  62.309 -+	size_t in_size;
  62.310 -+
  62.311 -+	uint8_t *out;
  62.312 -+	size_t out_pos;
  62.313 -+	size_t out_size;
  62.314 -+};
  62.315 -+
  62.316 -+/**
  62.317 -+ * struct xz_dec - Opaque type to hold the XZ decoder state
  62.318 -+ */
  62.319 -+struct xz_dec;
  62.320 -+
  62.321 -+/**
  62.322 -+ * xz_dec_init() - Allocate and initialize a XZ decoder state
  62.323 -+ * @mode:       Operation mode
  62.324 -+ * @dict_max:   Maximum size of the LZMA2 dictionary (history buffer) for
  62.325 -+ *              multi-call decoding. This is ignored in single-call mode
  62.326 -+ *              (mode == XZ_SINGLE). LZMA2 dictionary is always 2^n bytes
  62.327 -+ *              or 2^n + 2^(n-1) bytes (the latter sizes are less common
  62.328 -+ *              in practice), so other values for dict_max don't make sense.
  62.329 -+ *              In the kernel, dictionary sizes of 64 KiB, 128 KiB, 256 KiB,
  62.330 -+ *              512 KiB, and 1 MiB are probably the only reasonable values,
  62.331 -+ *              except for kernel and initramfs images where a bigger
  62.332 -+ *              dictionary can be fine and useful.
  62.333 -+ *
  62.334 -+ * Single-call mode (XZ_SINGLE): xz_dec_run() decodes the whole stream at
  62.335 -+ * once. The caller must provide enough output space or the decoding will
  62.336 -+ * fail. The output space is used as the dictionary buffer, which is why
  62.337 -+ * there is no need to allocate the dictionary as part of the decoder's
  62.338 -+ * internal state.
  62.339 -+ *
  62.340 -+ * Because the output buffer is used as the workspace, streams encoded using
  62.341 -+ * a big dictionary are not a problem in single-call mode. It is enough that
  62.342 -+ * the output buffer is big enough to hold the actual uncompressed data; it
  62.343 -+ * can be smaller than the dictionary size stored in the stream headers.
  62.344 -+ *
  62.345 -+ * Multi-call mode with preallocated dictionary (XZ_PREALLOC): dict_max bytes
  62.346 -+ * of memory is preallocated for the LZMA2 dictionary. This way there is no
  62.347 -+ * risk that xz_dec_run() could run out of memory, since xz_dec_run() will
  62.348 -+ * never allocate any memory. Instead, if the preallocated dictionary is too
  62.349 -+ * small for decoding the given input stream, xz_dec_run() will return
  62.350 -+ * XZ_MEMLIMIT_ERROR. Thus, it is important to know what kind of data will be
  62.351 -+ * decoded to avoid allocating excessive amount of memory for the dictionary.
  62.352 -+ *
  62.353 -+ * Multi-call mode with dynamically allocated dictionary (XZ_DYNALLOC):
  62.354 -+ * dict_max specifies the maximum allowed dictionary size that xz_dec_run()
  62.355 -+ * may allocate once it has parsed the dictionary size from the stream
  62.356 -+ * headers. This way excessive allocations can be avoided while still
  62.357 -+ * limiting the maximum memory usage to a sane value to prevent running the
  62.358 -+ * system out of memory when decompressing streams from untrusted sources.
  62.359 -+ *
  62.360 -+ * On success, xz_dec_init() returns a pointer to struct xz_dec, which is
  62.361 -+ * ready to be used with xz_dec_run(). If memory allocation fails,
  62.362 -+ * xz_dec_init() returns NULL.
  62.363 -+ */
  62.364 -+XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max);
  62.365 -+
  62.366 -+/**
  62.367 -+ * xz_dec_run() - Run the XZ decoder
  62.368 -+ * @s:          Decoder state allocated using xz_dec_init()
  62.369 -+ * @b:          Input and output buffers
  62.370 -+ *
  62.371 -+ * The possible return values depend on build options and operation mode.
  62.372 -+ * See enum xz_ret for details.
  62.373 -+ *
  62.374 -+ * Note that if an error occurs in single-call mode (return value is not
  62.375 -+ * XZ_STREAM_END), b->in_pos and b->out_pos are not modified and the
  62.376 -+ * contents of the output buffer from b->out[b->out_pos] onward are
  62.377 -+ * undefined. This is true even after XZ_BUF_ERROR, because with some filter
  62.378 -+ * chains, there may be a second pass over the output buffer, and this pass
  62.379 -+ * cannot be properly done if the output buffer is truncated. Thus, you
  62.380 -+ * cannot give the single-call decoder a too small buffer and then expect to
  62.381 -+ * get that amount valid data from the beginning of the stream. You must use
  62.382 -+ * the multi-call decoder if you don't want to uncompress the whole stream.
  62.383 -+ */
  62.384 -+XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b);
  62.385 -+
  62.386 -+/**
  62.387 -+ * xz_dec_reset() - Reset an already allocated decoder state
  62.388 -+ * @s:          Decoder state allocated using xz_dec_init()
  62.389 -+ *
  62.390 -+ * This function can be used to reset the multi-call decoder state without
  62.391 -+ * freeing and reallocating memory with xz_dec_end() and xz_dec_init().
  62.392 -+ *
  62.393 -+ * In single-call mode, xz_dec_reset() is always called in the beginning of
  62.394 -+ * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in
  62.395 -+ * multi-call mode.
  62.396 -+ */
  62.397 -+XZ_EXTERN void xz_dec_reset(struct xz_dec *s);
  62.398 -+
  62.399 -+/**
  62.400 -+ * xz_dec_end() - Free the memory allocated for the decoder state
  62.401 -+ * @s:          Decoder state allocated using xz_dec_init(). If s is NULL,
  62.402 -+ *              this function does nothing.
  62.403 -+ */
  62.404 -+XZ_EXTERN void xz_dec_end(struct xz_dec *s);
  62.405 -+
  62.406 -+/*
  62.407 -+ * Standalone build (userspace build or in-kernel build for boot time use)
  62.408 -+ * needs a CRC32 implementation. For normal in-kernel use, kernel's own
  62.409 -+ * CRC32 module is used instead, and users of this module don't need to
  62.410 -+ * care about the functions below.
  62.411 -+ */
  62.412 -+#ifndef XZ_INTERNAL_CRC32
  62.413 -+#	ifdef __KERNEL__
  62.414 -+#		define XZ_INTERNAL_CRC32 0
  62.415 -+#	else
  62.416 -+#		define XZ_INTERNAL_CRC32 1
  62.417 -+#	endif
  62.418 -+#endif
  62.419 -+
  62.420 -+#if XZ_INTERNAL_CRC32
  62.421 -+/*
  62.422 -+ * This must be called before any other xz_* function to initialize
  62.423 -+ * the CRC32 lookup table.
  62.424 -+ */
  62.425 -+XZ_EXTERN void xz_crc32_init(void);
  62.426 -+
  62.427 -+/*
  62.428 -+ * Update CRC32 value using the polynomial from IEEE-802.3. To start a new
  62.429 -+ * calculation, the third argument must be zero. To continue the calculation,
  62.430 -+ * the previously returned value is passed as the third argument.
  62.431 -+ */
  62.432 -+XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc);
  62.433 -+#endif
  62.434 -+#endif
  62.435 -diff --git a/lib/Kconfig b/lib/Kconfig
  62.436 -index fa9bf2c..6090314 100644
  62.437 ---- a/lib/Kconfig
  62.438 -+++ b/lib/Kconfig
  62.439 -@@ -106,6 +106,8 @@ config LZO_COMPRESS
  62.440 - config LZO_DECOMPRESS
  62.441 - 	tristate
  62.442 - 
  62.443 -+source "lib/xz/Kconfig"
  62.444 -+
  62.445 - #
  62.446 - # These all provide a common interface (hence the apparent duplication with
  62.447 - # ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
  62.448 -diff --git a/lib/Makefile b/lib/Makefile
  62.449 -index e6a3763..f2f98dd 100644
  62.450 ---- a/lib/Makefile
  62.451 -+++ b/lib/Makefile
  62.452 -@@ -69,6 +69,7 @@ obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
  62.453 - obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
  62.454 - obj-$(CONFIG_LZO_COMPRESS) += lzo/
  62.455 - obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
  62.456 -+obj-$(CONFIG_XZ_DEC) += xz/
  62.457 - obj-$(CONFIG_RAID6_PQ) += raid6/
  62.458 - 
  62.459 - lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
  62.460 -diff --git a/lib/xz/Kconfig b/lib/xz/Kconfig
  62.461 -new file mode 100644
  62.462 -index 0000000..e3b6e18
  62.463 ---- /dev/null
  62.464 -+++ b/lib/xz/Kconfig
  62.465 -@@ -0,0 +1,59 @@
  62.466 -+config XZ_DEC
  62.467 -+	tristate "XZ decompression support"
  62.468 -+	select CRC32
  62.469 -+	help
  62.470 -+	  LZMA2 compression algorithm and BCJ filters are supported using
  62.471 -+	  the .xz file format as the container. For integrity checking,
  62.472 -+	  CRC32 is supported. See Documentation/xz.txt for more information.
  62.473 -+
  62.474 -+config XZ_DEC_X86
  62.475 -+	bool "x86 BCJ filter decoder" if EMBEDDED
  62.476 -+	default y
  62.477 -+	depends on XZ_DEC
  62.478 -+	select XZ_DEC_BCJ
  62.479 -+
  62.480 -+config XZ_DEC_POWERPC
  62.481 -+	bool "PowerPC BCJ filter decoder" if EMBEDDED
  62.482 -+	default y
  62.483 -+	depends on XZ_DEC
  62.484 -+	select XZ_DEC_BCJ
  62.485 -+
  62.486 -+config XZ_DEC_IA64
  62.487 -+	bool "IA-64 BCJ filter decoder" if EMBEDDED
  62.488 -+	default y
  62.489 -+	depends on XZ_DEC
  62.490 -+	select XZ_DEC_BCJ
  62.491 -+
  62.492 -+config XZ_DEC_ARM
  62.493 -+	bool "ARM BCJ filter decoder" if EMBEDDED
  62.494 -+	default y
  62.495 -+	depends on XZ_DEC
  62.496 -+	select XZ_DEC_BCJ
  62.497 -+
  62.498 -+config XZ_DEC_ARMTHUMB
  62.499 -+	bool "ARM-Thumb BCJ filter decoder" if EMBEDDED
  62.500 -+	default y
  62.501 -+	depends on XZ_DEC
  62.502 -+	select XZ_DEC_BCJ
  62.503 -+
  62.504 -+config XZ_DEC_SPARC
  62.505 -+	bool "SPARC BCJ filter decoder" if EMBEDDED
  62.506 -+	default y
  62.507 -+	depends on XZ_DEC
  62.508 -+	select XZ_DEC_BCJ
  62.509 -+
  62.510 -+config XZ_DEC_BCJ
  62.511 -+	bool
  62.512 -+	default n
  62.513 -+
  62.514 -+config XZ_DEC_TEST
  62.515 -+	tristate "XZ decompressor tester"
  62.516 -+	default n
  62.517 -+	depends on XZ_DEC
  62.518 -+	help
  62.519 -+	  This allows passing .xz files to the in-kernel XZ decoder via
  62.520 -+	  a character special file. It calculates CRC32 of the decompressed
  62.521 -+	  data and writes diagnostics to the system log.
  62.522 -+
  62.523 -+	  Unless you are developing the XZ decoder, you don't need this
  62.524 -+	  and should say N.
  62.525 -diff --git a/lib/xz/Makefile b/lib/xz/Makefile
  62.526 -new file mode 100644
  62.527 -index 0000000..a7fa769
  62.528 ---- /dev/null
  62.529 -+++ b/lib/xz/Makefile
  62.530 -@@ -0,0 +1,5 @@
  62.531 -+obj-$(CONFIG_XZ_DEC) += xz_dec.o
  62.532 -+xz_dec-y := xz_dec_syms.o xz_dec_stream.o xz_dec_lzma2.o
  62.533 -+xz_dec-$(CONFIG_XZ_DEC_BCJ) += xz_dec_bcj.o
  62.534 -+
  62.535 -+obj-$(CONFIG_XZ_DEC_TEST) += xz_dec_test.o
  62.536 -diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
  62.537 -new file mode 100644
  62.538 -index 0000000..34532d1
  62.539 ---- /dev/null
  62.540 -+++ b/lib/xz/xz_crc32.c
  62.541 -@@ -0,0 +1,59 @@
  62.542 -+/*
  62.543 -+ * CRC32 using the polynomial from IEEE-802.3
  62.544 -+ *
  62.545 -+ * Authors: Lasse Collin <lasse.collin@tukaani.org>
  62.546 -+ *          Igor Pavlov <http://7-zip.org/>
  62.547 -+ *
  62.548 -+ * This file has been put into the public domain.
  62.549 -+ * You can do whatever you want with this file.
  62.550 -+ */
  62.551 -+
  62.552 -+/*
  62.553 -+ * This is not the fastest implementation, but it is pretty compact.
  62.554 -+ * The fastest versions of xz_crc32() on modern CPUs without hardware
  62.555 -+ * accelerated CRC instruction are 3-5 times as fast as this version,
  62.556 -+ * but they are bigger and use more memory for the lookup table.
  62.557 -+ */
  62.558 -+
  62.559 -+#include "xz_private.h"
  62.560 -+
  62.561 -+/*
  62.562 -+ * STATIC_RW_DATA is used in the pre-boot environment on some architectures.
  62.563 -+ * See <linux/decompress/mm.h> for details.
  62.564 -+ */
  62.565 -+#ifndef STATIC_RW_DATA
  62.566 -+#	define STATIC_RW_DATA static
  62.567 -+#endif
  62.568 -+
  62.569 -+STATIC_RW_DATA uint32_t xz_crc32_table[256];
  62.570 -+
  62.571 -+XZ_EXTERN void xz_crc32_init(void)
  62.572 -+{
  62.573 -+	const uint32_t poly = 0xEDB88320;
  62.574 -+
  62.575 -+	uint32_t i;
  62.576 -+	uint32_t j;
  62.577 -+	uint32_t r;
  62.578 -+
  62.579 -+	for (i = 0; i < 256; ++i) {
  62.580 -+		r = i;
  62.581 -+		for (j = 0; j < 8; ++j)
  62.582 -+			r = (r >> 1) ^ (poly & ~((r & 1) - 1));
  62.583 -+
  62.584 -+		xz_crc32_table[i] = r;
  62.585 -+	}
  62.586 -+
  62.587 -+	return;
  62.588 -+}
  62.589 -+
  62.590 -+XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
  62.591 -+{
  62.592 -+	crc = ~crc;
  62.593 -+
  62.594 -+	while (size != 0) {
  62.595 -+		crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
  62.596 -+		--size;
  62.597 -+	}
  62.598 -+
  62.599 -+	return ~crc;
  62.600 -+}
  62.601 -diff --git a/lib/xz/xz_dec_bcj.c b/lib/xz/xz_dec_bcj.c
  62.602 -new file mode 100644
  62.603 -index 0000000..e51e255
  62.604 ---- /dev/null
  62.605 -+++ b/lib/xz/xz_dec_bcj.c
  62.606 -@@ -0,0 +1,561 @@
  62.607 -+/*
  62.608 -+ * Branch/Call/Jump (BCJ) filter decoders
  62.609 -+ *
  62.610 -+ * Authors: Lasse Collin <lasse.collin@tukaani.org>
  62.611 -+ *          Igor Pavlov <http://7-zip.org/>
  62.612 -+ *
  62.613 -+ * This file has been put into the public domain.
  62.614 -+ * You can do whatever you want with this file.
  62.615 -+ */
  62.616 -+
  62.617 -+#include "xz_private.h"
  62.618 -+
  62.619 -+/*
  62.620 -+ * The rest of the file is inside this ifdef. It makes things a little more
  62.621 -+ * convenient when building without support for any BCJ filters.
  62.622 -+ */
  62.623 -+#ifdef XZ_DEC_BCJ
  62.624 -+
  62.625 -+struct xz_dec_bcj {
  62.626 -+	/* Type of the BCJ filter being used */
  62.627 -+	enum {
  62.628 -+		BCJ_X86 = 4,        /* x86 or x86-64 */
  62.629 -+		BCJ_POWERPC = 5,    /* Big endian only */
  62.630 -+		BCJ_IA64 = 6,       /* Big or little endian */
  62.631 -+		BCJ_ARM = 7,        /* Little endian only */
  62.632 -+		BCJ_ARMTHUMB = 8,   /* Little endian only */
  62.633 -+		BCJ_SPARC = 9       /* Big or little endian */
  62.634 -+	} type;
  62.635 -+
  62.636 -+	/*
  62.637 -+	 * Return value of the next filter in the chain. We need to preserve
  62.638 -+	 * this information across calls, because we must not call the next
  62.639 -+	 * filter anymore once it has returned XZ_STREAM_END.
  62.640 -+	 */
  62.641 -+	enum xz_ret ret;
  62.642 -+
  62.643 -+	/* True if we are operating in single-call mode. */
  62.644 -+	bool single_call;
  62.645 -+
  62.646 -+	/*
  62.647 -+	 * Absolute position relative to the beginning of the uncompressed
  62.648 -+	 * data (in a single .xz Block). We care only about the lowest 32
  62.649 -+	 * bits so this doesn't need to be uint64_t even with big files.
  62.650 -+	 */
  62.651 -+	uint32_t pos;
  62.652 -+
  62.653 -+	/* x86 filter state */
  62.654 -+	uint32_t x86_prev_mask;
  62.655 -+
  62.656 -+	/* Temporary space to hold the variables from struct xz_buf */
  62.657 -+	uint8_t *out;
  62.658 -+	size_t out_pos;
  62.659 -+	size_t out_size;
  62.660 -+
  62.661 -+	struct {
  62.662 -+		/* Amount of already filtered data in the beginning of buf */
  62.663 -+		size_t filtered;
  62.664 -+
  62.665 -+		/* Total amount of data currently stored in buf  */
  62.666 -+		size_t size;
  62.667 -+
  62.668 -+		/*
  62.669 -+		 * Buffer to hold a mix of filtered and unfiltered data. This
  62.670 -+		 * needs to be big enough to hold Alignment + 2 * Look-ahead:
  62.671 -+		 *
  62.672 -+		 * Type         Alignment   Look-ahead
  62.673 -+		 * x86              1           4
  62.674 -+		 * PowerPC          4           0
  62.675 -+		 * IA-64           16           0
  62.676 -+		 * ARM              4           0
  62.677 -+		 * ARM-Thumb        2           2
  62.678 -+		 * SPARC            4           0
  62.679 -+		 */
  62.680 -+		uint8_t buf[16];
  62.681 -+	} temp;
  62.682 -+};
  62.683 -+
  62.684 -+#ifdef XZ_DEC_X86
  62.685 -+/*
  62.686 -+ * This is used to test the most significant byte of a memory address
  62.687 -+ * in an x86 instruction.
  62.688 -+ */
  62.689 -+static inline int bcj_x86_test_msbyte(uint8_t b)
  62.690 -+{
  62.691 -+	return b == 0x00 || b == 0xFF;
  62.692 -+}
  62.693 -+
  62.694 -+static size_t bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
  62.695 -+{
  62.696 -+	static const bool mask_to_allowed_status[8]
  62.697 -+		= { true, true, true, false, true, false, false, false };
  62.698 -+
  62.699 -+	static const uint8_t mask_to_bit_num[8] = { 0, 1, 2, 2, 3, 3, 3, 3 };
  62.700 -+
  62.701 -+	size_t i;
  62.702 -+	size_t prev_pos = (size_t)-1;
  62.703 -+	uint32_t prev_mask = s->x86_prev_mask;
  62.704 -+	uint32_t src;
  62.705 -+	uint32_t dest;
  62.706 -+	uint32_t j;
  62.707 -+	uint8_t b;
  62.708 -+
  62.709 -+	if (size <= 4)
  62.710 -+		return 0;
  62.711 -+
  62.712 -+	size -= 4;
  62.713 -+	for (i = 0; i < size; ++i) {
  62.714 -+		if ((buf[i] & 0xFE) != 0xE8)
  62.715 -+			continue;
  62.716 -+
  62.717 -+		prev_pos = i - prev_pos;
  62.718 -+		if (prev_pos > 3) {
  62.719 -+			prev_mask = 0;
  62.720 -+		} else {
  62.721 -+			prev_mask = (prev_mask << (prev_pos - 1)) & 7;
  62.722 -+			if (prev_mask != 0) {
  62.723 -+				b = buf[i + 4 - mask_to_bit_num[prev_mask]];
  62.724 -+				if (!mask_to_allowed_status[prev_mask]
  62.725 -+						|| bcj_x86_test_msbyte(b)) {
  62.726 -+					prev_pos = i;
  62.727 -+					prev_mask = (prev_mask << 1) | 1;
  62.728 -+					continue;
  62.729 -+				}
  62.730 -+			}
  62.731 -+		}
  62.732 -+
  62.733 -+		prev_pos = i;
  62.734 -+
  62.735 -+		if (bcj_x86_test_msbyte(buf[i + 4])) {
  62.736 -+			src = get_unaligned_le32(buf + i + 1);
  62.737 -+			while (true) {
  62.738 -+				dest = src - (s->pos + (uint32_t)i + 5);
  62.739 -+				if (prev_mask == 0)
  62.740 -+					break;
  62.741 -+
  62.742 -+				j = mask_to_bit_num[prev_mask] * 8;
  62.743 -+				b = (uint8_t)(dest >> (24 - j));
  62.744 -+				if (!bcj_x86_test_msbyte(b))
  62.745 -+					break;
  62.746 -+
  62.747 -+				src = dest ^ (((uint32_t)1 << (32 - j)) - 1);
  62.748 -+			}
  62.749 -+
  62.750 -+			dest &= 0x01FFFFFF;
  62.751 -+			dest |= (uint32_t)0 - (dest & 0x01000000);
  62.752 -+			put_unaligned_le32(dest, buf + i + 1);
  62.753 -+			i += 4;
  62.754 -+		} else {
  62.755 -+			prev_mask = (prev_mask << 1) | 1;
  62.756 -+		}
  62.757 -+	}
  62.758 -+
  62.759 -+	prev_pos = i - prev_pos;
  62.760 -+	s->x86_prev_mask = prev_pos > 3 ? 0 : prev_mask << (prev_pos - 1);
  62.761 -+	return i;
  62.762 -+}
  62.763 -+#endif
  62.764 -+
  62.765 -+#ifdef XZ_DEC_POWERPC
  62.766 -+static size_t bcj_powerpc(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
  62.767 -+{
  62.768 -+	size_t i;
  62.769 -+	uint32_t instr;
  62.770 -+
  62.771 -+	for (i = 0; i + 4 <= size; i += 4) {
  62.772 -+		instr = get_unaligned_be32(buf + i);
  62.773 -+		if ((instr & 0xFC000003) == 0x48000001) {
  62.774 -+			instr &= 0x03FFFFFC;
  62.775 -+			instr -= s->pos + (uint32_t)i;
  62.776 -+			instr &= 0x03FFFFFC;
  62.777 -+			instr |= 0x48000001;
  62.778 -+			put_unaligned_be32(instr, buf + i);
  62.779 -+		}
  62.780 -+	}
  62.781 -+
  62.782 -+	return i;
  62.783 -+}
  62.784 -+#endif
  62.785 -+
  62.786 -+#ifdef XZ_DEC_IA64
  62.787 -+static size_t bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
  62.788 -+{
  62.789 -+	static const uint8_t branch_table[32] = {
  62.790 -+		0, 0, 0, 0, 0, 0, 0, 0,
  62.791 -+		0, 0, 0, 0, 0, 0, 0, 0,
  62.792 -+		4, 4, 6, 6, 0, 0, 7, 7,
  62.793 -+		4, 4, 0, 0, 4, 4, 0, 0
  62.794 -+	};
  62.795 -+
  62.796 -+	/*
  62.797 -+	 * The local variables take a little bit stack space, but it's less
  62.798 -+	 * than what LZMA2 decoder takes, so it doesn't make sense to reduce
  62.799 -+	 * stack usage here without doing that for the LZMA2 decoder too.
  62.800 -+	 */
  62.801 -+
  62.802 -+	/* Loop counters */
  62.803 -+	size_t i;
  62.804 -+	size_t j;
  62.805 -+
  62.806 -+	/* Instruction slot (0, 1, or 2) in the 128-bit instruction word */
  62.807 -+	uint32_t slot;
  62.808 -+
  62.809 -+	/* Bitwise offset of the instruction indicated by slot */
  62.810 -+	uint32_t bit_pos;
  62.811 -+
  62.812 -+	/* bit_pos split into byte and bit parts */
  62.813 -+	uint32_t byte_pos;
  62.814 -+	uint32_t bit_res;
  62.815 -+
  62.816 -+	/* Address part of an instruction */
  62.817 -+	uint32_t addr;
  62.818 -+
  62.819 -+	/* Mask used to detect which instructions to convert */
  62.820 -+	uint32_t mask;
  62.821 -+
  62.822 -+	/* 41-bit instruction stored somewhere in the lowest 48 bits */
  62.823 -+	uint64_t instr;
  62.824 -+
  62.825 -+	/* Instruction normalized with bit_res for easier manipulation */
  62.826 -+	uint64_t norm;
  62.827 -+
  62.828 -+	for (i = 0; i + 16 <= size; i += 16) {
  62.829 -+		mask = branch_table[buf[i] & 0x1F];
  62.830 -+		for (slot = 0, bit_pos = 5; slot < 3; ++slot, bit_pos += 41) {
  62.831 -+			if (((mask >> slot) & 1) == 0)
  62.832 -+				continue;
  62.833 -+
  62.834 -+			byte_pos = bit_pos >> 3;
  62.835 -+			bit_res = bit_pos & 7;
  62.836 -+			instr = 0;
  62.837 -+			for (j = 0; j < 6; ++j)
  62.838 -+				instr |= (uint64_t)(buf[i + j + byte_pos])
  62.839 -+						<< (8 * j);
  62.840 -+
  62.841 -+			norm = instr >> bit_res;
  62.842 -+
  62.843 -+			if (((norm >> 37) & 0x0F) == 0x05
  62.844 -+					&& ((norm >> 9) & 0x07) == 0) {
  62.845 -+				addr = (norm >> 13) & 0x0FFFFF;
  62.846 -+				addr |= ((uint32_t)(norm >> 36) & 1) << 20;
  62.847 -+				addr <<= 4;
  62.848 -+				addr -= s->pos + (uint32_t)i;
  62.849 -+				addr >>= 4;
  62.850 -+
  62.851 -+				norm &= ~((uint64_t)0x8FFFFF << 13);
  62.852 -+				norm |= (uint64_t)(addr & 0x0FFFFF) << 13;
  62.853 -+				norm |= (uint64_t)(addr & 0x100000)
  62.854 -+						<< (36 - 20);
  62.855 -+
  62.856 -+				instr &= (1 << bit_res) - 1;
  62.857 -+				instr |= norm << bit_res;
  62.858 -+
  62.859 -+				for (j = 0; j < 6; j++)
  62.860 -+					buf[i + j + byte_pos]
  62.861 -+						= (uint8_t)(instr >> (8 * j));
  62.862 -+			}
  62.863 -+		}
  62.864 -+	}
  62.865 -+
  62.866 -+	return i;
  62.867 -+}
  62.868 -+#endif
  62.869 -+
  62.870 -+#ifdef XZ_DEC_ARM
  62.871 -+static size_t bcj_arm(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
  62.872 -+{
  62.873 -+	size_t i;
  62.874 -+	uint32_t addr;
  62.875 -+
  62.876 -+	for (i = 0; i + 4 <= size; i += 4) {
  62.877 -+		if (buf[i + 3] == 0xEB) {
  62.878 -+			addr = (uint32_t)buf[i] | ((uint32_t)buf[i + 1] << 8)
  62.879 -+					| ((uint32_t)buf[i + 2] << 16);
  62.880 -+			addr <<= 2;
  62.881 -+			addr -= s->pos + (uint32_t)i + 8;
  62.882 -+			addr >>= 2;
  62.883 -+			buf[i] = (uint8_t)addr;
  62.884 -+			buf[i + 1] = (uint8_t)(addr >> 8);
  62.885 -+			buf[i + 2] = (uint8_t)(addr >> 16);
  62.886 -+		}
  62.887 -+	}
  62.888 -+
  62.889 -+	return i;
  62.890 -+}
  62.891 -+#endif
  62.892 -+
  62.893 -+#ifdef XZ_DEC_ARMTHUMB
  62.894 -+static size_t bcj_armthumb(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
  62.895 -+{
  62.896 -+	size_t i;
  62.897 -+	uint32_t addr;
  62.898 -+
  62.899 -+	for (i = 0; i + 4 <= size; i += 2) {
  62.900 -+		if ((buf[i + 1] & 0xF8) == 0xF0
  62.901 -+				&& (buf[i + 3] & 0xF8) == 0xF8) {
  62.902 -+			addr = (((uint32_t)buf[i + 1] & 0x07) << 19)
  62.903 -+					| ((uint32_t)buf[i] << 11)
  62.904 -+					| (((uint32_t)buf[i + 3] & 0x07) << 8)
  62.905 -+					| (uint32_t)buf[i + 2];
  62.906 -+			addr <<= 1;
  62.907 -+			addr -= s->pos + (uint32_t)i + 4;
  62.908 -+			addr >>= 1;
  62.909 -+			buf[i + 1] = (uint8_t)(0xF0 | ((addr >> 19) & 0x07));
  62.910 -+			buf[i] = (uint8_t)(addr >> 11);
  62.911 -+			buf[i + 3] = (uint8_t)(0xF8 | ((addr >> 8) & 0x07));
  62.912 -+			buf[i + 2] = (uint8_t)addr;
  62.913 -+			i += 2;
  62.914 -+		}
  62.915 -+	}
  62.916 -+
  62.917 -+	return i;
  62.918 -+}
  62.919 -+#endif
  62.920 -+
  62.921 -+#ifdef XZ_DEC_SPARC
  62.922 -+static size_t bcj_sparc(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
  62.923 -+{
  62.924 -+	size_t i;
  62.925 -+	uint32_t instr;
  62.926 -+
  62.927 -+	for (i = 0; i + 4 <= size; i += 4) {
  62.928 -+		instr = get_unaligned_be32(buf + i);
  62.929 -+		if ((instr >> 22) == 0x100 || (instr >> 22) == 0x1FF) {
  62.930 -+			instr <<= 2;
  62.931 -+			instr -= s->pos + (uint32_t)i;
  62.932 -+			instr >>= 2;
  62.933 -+			instr = ((uint32_t)0x40000000 - (instr & 0x400000))
  62.934 -+					| 0x40000000 | (instr & 0x3FFFFF);
  62.935 -+			put_unaligned_be32(instr, buf + i);
  62.936 -+		}
  62.937 -+	}
  62.938 -+
  62.939 -+	return i;
  62.940 -+}
  62.941 -+#endif
  62.942 -+
  62.943 -+/*
  62.944 -+ * Apply the selected BCJ filter. Update *pos and s->pos to match the amount
  62.945 -+ * of data that got filtered.
  62.946 -+ *
  62.947 -+ * NOTE: This is implemented as a switch statement to avoid using function
  62.948 -+ * pointers, which could be problematic in the kernel boot code, which must
  62.949 -+ * avoid pointers to static data (at least on x86).
  62.950 -+ */
  62.951 -+static void bcj_apply(struct xz_dec_bcj *s,
  62.952 -+		      uint8_t *buf, size_t *pos, size_t size)
  62.953 -+{
  62.954 -+	size_t filtered;
  62.955 -+
  62.956 -+	buf += *pos;
  62.957 -+	size -= *pos;
  62.958 -+
  62.959 -+	switch (s->type) {
  62.960 -+#ifdef XZ_DEC_X86
  62.961 -+	case BCJ_X86:
  62.962 -+		filtered = bcj_x86(s, buf, size);
  62.963 -+		break;
  62.964 -+#endif
  62.965 -+#ifdef XZ_DEC_POWERPC
  62.966 -+	case BCJ_POWERPC:
  62.967 -+		filtered = bcj_powerpc(s, buf, size);
  62.968 -+		break;
  62.969 -+#endif
  62.970 -+#ifdef XZ_DEC_IA64
  62.971 -+	case BCJ_IA64:
  62.972 -+		filtered = bcj_ia64(s, buf, size);
  62.973 -+		break;
  62.974 -+#endif
  62.975 -+#ifdef XZ_DEC_ARM
  62.976 -+	case BCJ_ARM:
  62.977 -+		filtered = bcj_arm(s, buf, size);
  62.978 -+		break;
  62.979 -+#endif
  62.980 -+#ifdef XZ_DEC_ARMTHUMB
  62.981 -+	case BCJ_ARMTHUMB:
  62.982 -+		filtered = bcj_armthumb(s, buf, size);
  62.983 -+		break;
  62.984 -+#endif
  62.985 -+#ifdef XZ_DEC_SPARC
  62.986 -+	case BCJ_SPARC:
  62.987 -+		filtered = bcj_sparc(s, buf, size);
  62.988 -+		break;
  62.989 -+#endif
  62.990 -+	default:
  62.991 -+		/* Never reached but silence compiler warnings. */
  62.992 -+		filtered = 0;
  62.993 -+		break;
  62.994 -+	}
  62.995 -+
  62.996 -+	*pos += filtered;
  62.997 -+	s->pos += filtered;
  62.998 -+}
  62.999 -+
 62.1000 -+/*
 62.1001 -+ * Flush pending filtered data from temp to the output buffer.
 62.1002 -+ * Move the remaining mixture of possibly filtered and unfiltered
 62.1003 -+ * data to the beginning of temp.
 62.1004 -+ */
 62.1005 -+static void bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b)
 62.1006 -+{
 62.1007 -+	size_t copy_size;
 62.1008 -+
 62.1009 -+	copy_size = min_t(size_t, s->temp.filtered, b->out_size - b->out_pos);
 62.1010 -+	memcpy(b->out + b->out_pos, s->temp.buf, copy_size);
 62.1011 -+	b->out_pos += copy_size;
 62.1012 -+
 62.1013 -+	s->temp.filtered -= copy_size;
 62.1014 -+	s->temp.size -= copy_size;
 62.1015 -+	memmove(s->temp.buf, s->temp.buf + copy_size, s->temp.size);
 62.1016 -+}
 62.1017 -+
 62.1018 -+/*
 62.1019 -+ * The BCJ filter functions are primitive in sense that they process the
 62.1020 -+ * data in chunks of 1-16 bytes. To hide this issue, this function does
 62.1021 -+ * some buffering.
 62.1022 -+ */
 62.1023 -+XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
 62.1024 -+				     struct xz_dec_lzma2 *lzma2,
 62.1025 -+				     struct xz_buf *b)
 62.1026 -+{
 62.1027 -+	size_t out_start;
 62.1028 -+
 62.1029 -+	/*
 62.1030 -+	 * Flush pending already filtered data to the output buffer. Return
 62.1031 -+	 * immediatelly if we couldn't flush everything, or if the next
 62.1032 -+	 * filter in the chain had already returned XZ_STREAM_END.
 62.1033 -+	 */
 62.1034 -+	if (s->temp.filtered > 0) {
 62.1035 -+		bcj_flush(s, b);
 62.1036 -+		if (s->temp.filtered > 0)
 62.1037 -+			return XZ_OK;
 62.1038 -+
 62.1039 -+		if (s->ret == XZ_STREAM_END)
 62.1040 -+			return XZ_STREAM_END;
 62.1041 -+	}
 62.1042 -+
 62.1043 -+	/*
 62.1044 -+	 * If we have more output space than what is currently pending in
 62.1045 -+	 * temp, copy the unfiltered data from temp to the output buffer
 62.1046 -+	 * and try to fill the output buffer by decoding more data from the
 62.1047 -+	 * next filter in the chain. Apply the BCJ filter on the new data
 62.1048 -+	 * in the output buffer. If everything cannot be filtered, copy it
 62.1049 -+	 * to temp and rewind the output buffer position accordingly.
 62.1050 -+	 */
 62.1051 -+	if (s->temp.size < b->out_size - b->out_pos) {
 62.1052 -+		out_start = b->out_pos;
 62.1053 -+		memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
 62.1054 -+		b->out_pos += s->temp.size;
 62.1055 -+
 62.1056 -+		s->ret = xz_dec_lzma2_run(lzma2, b);
 62.1057 -+		if (s->ret != XZ_STREAM_END
 62.1058 -+				&& (s->ret != XZ_OK || s->single_call))
 62.1059 -+			return s->ret;
 62.1060 -+
 62.1061 -+		bcj_apply(s, b->out, &out_start, b->out_pos);
 62.1062 -+
 62.1063 -+		/*
 62.1064 -+		 * As an exception, if the next filter returned XZ_STREAM_END,
 62.1065 -+		 * we can do that too, since the last few bytes that remain
 62.1066 -+		 * unfiltered are meant to remain unfiltered.
 62.1067 -+		 */
 62.1068 -+		if (s->ret == XZ_STREAM_END)
 62.1069 -+			return XZ_STREAM_END;
 62.1070 -+
 62.1071 -+		s->temp.size = b->out_pos - out_start;
 62.1072 -+		b->out_pos -= s->temp.size;
 62.1073 -+		memcpy(s->temp.buf, b->out + b->out_pos, s->temp.size);
 62.1074 -+	}
 62.1075 -+
 62.1076 -+	/*
 62.1077 -+	 * If we have unfiltered data in temp, try to fill by decoding more
 62.1078 -+	 * data from the next filter. Apply the BCJ filter on temp. Then we
 62.1079 -+	 * hopefully can fill the actual output buffer by copying filtered
 62.1080 -+	 * data from temp. A mix of filtered and unfiltered data may be left
 62.1081 -+	 * in temp; it will be taken care on the next call to this function.
 62.1082 -+	 */
 62.1083 -+	if (s->temp.size > 0) {
 62.1084 -+		/* Make b->out{,_pos,_size} temporarily point to s->temp. */
 62.1085 -+		s->out = b->out;
 62.1086 -+		s->out_pos = b->out_pos;
 62.1087 -+		s->out_size = b->out_size;
 62.1088 -+		b->out = s->temp.buf;
 62.1089 -+		b->out_pos = s->temp.size;
 62.1090 -+		b->out_size = sizeof(s->temp.buf);
 62.1091 -+
 62.1092 -+		s->ret = xz_dec_lzma2_run(lzma2, b);
 62.1093 -+
 62.1094 -+		s->temp.size = b->out_pos;
 62.1095 -+		b->out = s->out;
 62.1096 -+		b->out_pos = s->out_pos;
 62.1097 -+		b->out_size = s->out_size;
 62.1098 -+
 62.1099 -+		if (s->ret != XZ_OK && s->ret != XZ_STREAM_END)
 62.1100 -+			return s->ret;
 62.1101 -+
 62.1102 -+		bcj_apply(s, s->temp.buf, &s->temp.filtered, s->temp.size);
 62.1103 -+
 62.1104 -+		/*
 62.1105 -+		 * If the next filter returned XZ_STREAM_END, we mark that
 62.1106 -+		 * everything is filtered, since the last unfiltered bytes
 62.1107 -+		 * of the stream are meant to be left as is.
 62.1108 -+		 */
 62.1109 -+		if (s->ret == XZ_STREAM_END)
 62.1110 -+			s->temp.filtered = s->temp.size;
 62.1111 -+
 62.1112 -+		bcj_flush(s, b);
 62.1113 -+		if (s->temp.filtered > 0)
 62.1114 -+			return XZ_OK;
 62.1115 -+	}
 62.1116 -+
 62.1117 -+	return s->ret;
 62.1118 -+}
 62.1119 -+
 62.1120 -+XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call)
 62.1121 -+{
 62.1122 -+	struct xz_dec_bcj *s = kmalloc(sizeof(*s), GFP_KERNEL);
 62.1123 -+	if (s != NULL)
 62.1124 -+		s->single_call = single_call;
 62.1125 -+
 62.1126 -+	return s;
 62.1127 -+}
 62.1128 -+
 62.1129 -+XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id)
 62.1130 -+{
 62.1131 -+	switch (id) {
 62.1132 -+#ifdef XZ_DEC_X86
 62.1133 -+	case BCJ_X86:
 62.1134 -+#endif
 62.1135 -+#ifdef XZ_DEC_POWERPC
 62.1136 -+	case BCJ_POWERPC:
 62.1137 -+#endif
 62.1138 -+#ifdef XZ_DEC_IA64
 62.1139 -+	case BCJ_IA64:
 62.1140 -+#endif
 62.1141 -+#ifdef XZ_DEC_ARM
 62.1142 -+	case BCJ_ARM:
 62.1143 -+#endif
 62.1144 -+#ifdef XZ_DEC_ARMTHUMB
 62.1145 -+	case BCJ_ARMTHUMB:
 62.1146 -+#endif
 62.1147 -+#ifdef XZ_DEC_SPARC
 62.1148 -+	case BCJ_SPARC:
 62.1149 -+#endif
 62.1150 -+		break;
 62.1151 -+
 62.1152 -+	default:
 62.1153 -+		/* Unsupported Filter ID */
 62.1154 -+		return XZ_OPTIONS_ERROR;
 62.1155 -+	}
 62.1156 -+
 62.1157 -+	s->type = id;
 62.1158 -+	s->ret = XZ_OK;
 62.1159 -+	s->pos = 0;
 62.1160 -+	s->x86_prev_mask = 0;
 62.1161 -+	s->temp.filtered = 0;
 62.1162 -+	s->temp.size = 0;
 62.1163 -+
 62.1164 -+	return XZ_OK;
 62.1165 -+}
 62.1166 -+
 62.1167 -+#endif
 62.1168 -diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c
 62.1169 -new file mode 100644
 62.1170 -index 0000000..ea5fa4f
 62.1171 ---- /dev/null
 62.1172 -+++ b/lib/xz/xz_dec_lzma2.c
 62.1173 -@@ -0,0 +1,1171 @@
 62.1174 -+/*
 62.1175 -+ * LZMA2 decoder
 62.1176 -+ *
 62.1177 -+ * Authors: Lasse Collin <lasse.collin@tukaani.org>
 62.1178 -+ *          Igor Pavlov <http://7-zip.org/>
 62.1179 -+ *
 62.1180 -+ * This file has been put into the public domain.
 62.1181 -+ * You can do whatever you want with this file.
 62.1182 -+ */
 62.1183 -+
 62.1184 -+#include "xz_private.h"
 62.1185 -+#include "xz_lzma2.h"
 62.1186 -+
 62.1187 -+/*
 62.1188 -+ * Range decoder initialization eats the first five bytes of each LZMA chunk.
 62.1189 -+ */
 62.1190 -+#define RC_INIT_BYTES 5
 62.1191 -+
 62.1192 -+/*
 62.1193 -+ * Minimum number of usable input buffer to safely decode one LZMA symbol.
 62.1194 -+ * The worst case is that we decode 22 bits using probabilities and 26
 62.1195 -+ * direct bits. This may decode at maximum of 20 bytes of input. However,
 62.1196 -+ * lzma_main() does an extra normalization before returning, thus we
 62.1197 -+ * need to put 21 here.
 62.1198 -+ */
 62.1199 -+#define LZMA_IN_REQUIRED 21
 62.1200 -+
 62.1201 -+/*
 62.1202 -+ * Dictionary (history buffer)
 62.1203 -+ *
 62.1204 -+ * These are always true:
 62.1205 -+ *    start <= pos <= full <= end
 62.1206 -+ *    pos <= limit <= end
 62.1207 -+ *
 62.1208 -+ * In multi-call mode, also these are true:
 62.1209 -+ *    end == size
 62.1210 -+ *    size <= size_max
 62.1211 -+ *    allocated <= size
 62.1212 -+ *
 62.1213 -+ * Most of these variables are size_t to support single-call mode,
 62.1214 -+ * in which the dictionary variables address the actual output
 62.1215 -+ * buffer directly.
 62.1216 -+ */
 62.1217 -+struct dictionary {
 62.1218 -+	/* Beginning of the history buffer */
 62.1219 -+	uint8_t *buf;
 62.1220 -+
 62.1221 -+	/* Old position in buf (before decoding more data) */
 62.1222 -+	size_t start;
 62.1223 -+
 62.1224 -+	/* Position in buf */
 62.1225 -+	size_t pos;
 62.1226 -+
 62.1227 -+	/*
 62.1228 -+	 * How full dictionary is. This is used to detect corrupt input that
 62.1229 -+	 * would read beyond the beginning of the uncompressed stream.
 62.1230 -+	 */
 62.1231 -+	size_t full;
 62.1232 -+
 62.1233 -+	/* Write limit; we don't write to buf[limit] or later bytes. */
 62.1234 -+	size_t limit;
 62.1235 -+
 62.1236 -+	/*
 62.1237 -+	 * End of the dictionary buffer. In multi-call mode, this is
 62.1238 -+	 * the same as the dictionary size. In single-call mode, this
 62.1239 -+	 * indicates the size of the output buffer.
 62.1240 -+	 */
 62.1241 -+	size_t end;
 62.1242 -+
 62.1243 -+	/*
 62.1244 -+	 * Size of the dictionary as specified in Block Header. This is used
 62.1245 -+	 * together with "full" to detect corrupt input that would make us
 62.1246 -+	 * read beyond the beginning of the uncompressed stream.
 62.1247 -+	 */
 62.1248 -+	uint32_t size;
 62.1249 -+
 62.1250 -+	/*
 62.1251 -+	 * Maximum allowed dictionary size in multi-call mode.
 62.1252 -+	 * This is ignored in single-call mode.
 62.1253 -+	 */
 62.1254 -+	uint32_t size_max;
 62.1255 -+
 62.1256 -+	/*
 62.1257 -+	 * Amount of memory currently allocated for the dictionary.
 62.1258 -+	 * This is used only with XZ_DYNALLOC. (With XZ_PREALLOC,
 62.1259 -+	 * size_max is always the same as the allocated size.)
 62.1260 -+	 */
 62.1261 -+	uint32_t allocated;
 62.1262 -+
 62.1263 -+	/* Operation mode */
 62.1264 -+	enum xz_mode mode;
 62.1265 -+};
 62.1266 -+
 62.1267 -+/* Range decoder */
 62.1268 -+struct rc_dec {
 62.1269 -+	uint32_t range;
 62.1270 -+	uint32_t code;
 62.1271 -+
 62.1272 -+	/*
 62.1273 -+	 * Number of initializing bytes remaining to be read
 62.1274 -+	 * by rc_read_init().
 62.1275 -+	 */
 62.1276 -+	uint32_t init_bytes_left;
 62.1277 -+
 62.1278 -+	/*
 62.1279 -+	 * Buffer from which we read our input. It can be either
 62.1280 -+	 * temp.buf or the caller-provided input buffer.
 62.1281 -+	 */
 62.1282 -+	const uint8_t *in;
 62.1283 -+	size_t in_pos;
 62.1284 -+	size_t in_limit;
 62.1285 -+};
 62.1286 -+
 62.1287 -+/* Probabilities for a length decoder. */
 62.1288 -+struct lzma_len_dec {
 62.1289 -+	/* Probability of match length being at least 10 */
 62.1290 -+	uint16_t choice;
 62.1291 -+
 62.1292 -+	/* Probability of match length being at least 18 */
 62.1293 -+	uint16_t choice2;
 62.1294 -+
 62.1295 -+	/* Probabilities for match lengths 2-9 */
 62.1296 -+	uint16_t low[POS_STATES_MAX][LEN_LOW_SYMBOLS];
 62.1297 -+
 62.1298 -+	/* Probabilities for match lengths 10-17 */
 62.1299 -+	uint16_t mid[POS_STATES_MAX][LEN_MID_SYMBOLS];
 62.1300 -+
 62.1301 -+	/* Probabilities for match lengths 18-273 */
 62.1302 -+	uint16_t high[LEN_HIGH_SYMBOLS];
 62.1303 -+};
 62.1304 -+
 62.1305 -+struct lzma_dec {
 62.1306 -+	/* Distances of latest four matches */
 62.1307 -+	uint32_t rep0;
 62.1308 -+	uint32_t rep1;
 62.1309 -+	uint32_t rep2;
 62.1310 -+	uint32_t rep3;
 62.1311 -+
 62.1312 -+	/* Types of the most recently seen LZMA symbols */
 62.1313 -+	enum lzma_state state;
 62.1314 -+
 62.1315 -+	/*
 62.1316 -+	 * Length of a match. This is updated so that dict_repeat can
 62.1317 -+	 * be called again to finish repeating the whole match.
 62.1318 -+	 */
 62.1319 -+	uint32_t len;
 62.1320 -+
 62.1321 -+	/*
 62.1322 -+	 * LZMA properties or related bit masks (number of literal
 62.1323 -+	 * context bits, a mask dervied from the number of literal
 62.1324 -+	 * position bits, and a mask dervied from the number
 62.1325 -+	 * position bits)
 62.1326 -+	 */
 62.1327 -+	uint32_t lc;
 62.1328 -+	uint32_t literal_pos_mask; /* (1 << lp) - 1 */
 62.1329 -+	uint32_t pos_mask;         /* (1 << pb) - 1 */
 62.1330 -+
 62.1331 -+	/* If 1, it's a match. Otherwise it's a single 8-bit literal. */
 62.1332 -+	uint16_t is_match[STATES][POS_STATES_MAX];
 62.1333 -+
 62.1334 -+	/* If 1, it's a repeated match. The distance is one of rep0 .. rep3. */
 62.1335 -+	uint16_t is_rep[STATES];
 62.1336 -+
 62.1337 -+	/*
 62.1338 -+	 * If 0, distance of a repeated match is rep0.
 62.1339 -+	 * Otherwise check is_rep1.
 62.1340 -+	 */
 62.1341 -+	uint16_t is_rep0[STATES];
 62.1342 -+
 62.1343 -+	/*
 62.1344 -+	 * If 0, distance of a repeated match is rep1.
 62.1345 -+	 * Otherwise check is_rep2.
 62.1346 -+	 */
 62.1347 -+	uint16_t is_rep1[STATES];
 62.1348 -+
 62.1349 -+	/* If 0, distance of a repeated match is rep2. Otherwise it is rep3. */
 62.1350 -+	uint16_t is_rep2[STATES];
 62.1351 -+
 62.1352 -+	/*
 62.1353 -+	 * If 1, the repeated match has length of one byte. Otherwise
 62.1354 -+	 * the length is decoded from rep_len_decoder.
 62.1355 -+	 */
 62.1356 -+	uint16_t is_rep0_long[STATES][POS_STATES_MAX];
 62.1357 -+
 62.1358 -+	/*
 62.1359 -+	 * Probability tree for the highest two bits of the match
 62.1360 -+	 * distance. There is a separate probability tree for match
 62.1361 -+	 * lengths of 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273].
 62.1362 -+	 */
 62.1363 -+	uint16_t dist_slot[DIST_STATES][DIST_SLOTS];
 62.1364 -+
 62.1365 -+	/*
 62.1366 -+	 * Probility trees for additional bits for match distance
 62.1367 -+	 * when the distance is in the range [4, 127].
 62.1368 -+	 */
 62.1369 -+	uint16_t dist_special[FULL_DISTANCES - DIST_MODEL_END];
 62.1370 -+
 62.1371 -+	/*
 62.1372 -+	 * Probability tree for the lowest four bits of a match
 62.1373 -+	 * distance that is equal to or greater than 128.
 62.1374 -+	 */
 62.1375 -+	uint16_t dist_align[ALIGN_SIZE];
 62.1376 -+
 62.1377 -+	/* Length of a normal match */
 62.1378 -+	struct lzma_len_dec match_len_dec;
 62.1379 -+
 62.1380 -+	/* Length of a repeated match */
 62.1381 -+	struct lzma_len_dec rep_len_dec;
 62.1382 -+
 62.1383 -+	/* Probabilities of literals */
 62.1384 -+	uint16_t literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
 62.1385 -+};
 62.1386 -+
 62.1387 -+struct lzma2_dec {
 62.1388 -+	/* Position in xz_dec_lzma2_run(). */
 62.1389 -+	enum lzma2_seq {
 62.1390 -+		SEQ_CONTROL,
 62.1391 -+		SEQ_UNCOMPRESSED_1,
 62.1392 -+		SEQ_UNCOMPRESSED_2,
 62.1393 -+		SEQ_COMPRESSED_0,
 62.1394 -+		SEQ_COMPRESSED_1,
 62.1395 -+		SEQ_PROPERTIES,
 62.1396 -+		SEQ_LZMA_PREPARE,
 62.1397 -+		SEQ_LZMA_RUN,
 62.1398 -+		SEQ_COPY
 62.1399 -+	} sequence;
 62.1400 -+
 62.1401 -+	/* Next position after decoding the compressed size of the chunk. */
 62.1402 -+	enum lzma2_seq next_sequence;
 62.1403 -+
 62.1404 -+	/* Uncompressed size of LZMA chunk (2 MiB at maximum) */
 62.1405 -+	uint32_t uncompressed;
 62.1406 -+
 62.1407 -+	/*
 62.1408 -+	 * Compressed size of LZMA chunk or compressed/uncompressed
 62.1409 -+	 * size of uncompressed chunk (64 KiB at maximum)
 62.1410 -+	 */
 62.1411 -+	uint32_t compressed;
 62.1412 -+
 62.1413 -+	/*
 62.1414 -+	 * True if dictionary reset is needed. This is false before
 62.1415 -+	 * the first chunk (LZMA or uncompressed).
 62.1416 -+	 */
 62.1417 -+	bool need_dict_reset;
 62.1418 -+
 62.1419 -+	/*
 62.1420 -+	 * True if new LZMA properties are needed. This is false
 62.1421 -+	 * before the first LZMA chunk.
 62.1422 -+	 */
 62.1423 -+	bool need_props;
 62.1424 -+};
 62.1425 -+
 62.1426 -+struct xz_dec_lzma2 {
 62.1427 -+	/*
 62.1428 -+	 * The order below is important on x86 to reduce code size and
 62.1429 -+	 * it shouldn't hurt on other platforms. Everything up to and
 62.1430 -+	 * including lzma.pos_mask are in the first 128 bytes on x86-32,
 62.1431 -+	 * which allows using smaller instructions to access those
 62.1432 -+	 * variables. On x86-64, fewer variables fit into the first 128
 62.1433 -+	 * bytes, but this is still the best order without sacrificing
 62.1434 -+	 * the readability by splitting the structures.
 62.1435 -+	 */
 62.1436 -+	struct rc_dec rc;
 62.1437 -+	struct dictionary dict;
 62.1438 -+	struct lzma2_dec lzma2;
 62.1439 -+	struct lzma_dec lzma;
 62.1440 -+
 62.1441 -+	/*
 62.1442 -+	 * Temporary buffer which holds small number of input bytes between
 62.1443 -+	 * decoder calls. See lzma2_lzma() for details.
 62.1444 -+	 */
 62.1445 -+	struct {
 62.1446 -+		uint32_t size;
 62.1447 -+		uint8_t buf[3 * LZMA_IN_REQUIRED];
 62.1448 -+	} temp;
 62.1449 -+};
 62.1450 -+
 62.1451 -+/**************
 62.1452 -+ * Dictionary *
 62.1453 -+ **************/
 62.1454 -+
 62.1455 -+/*
 62.1456 -+ * Reset the dictionary state. When in single-call mode, set up the beginning
 62.1457 -+ * of the dictionary to point to the actual output buffer.
 62.1458 -+ */
 62.1459 -+static void dict_reset(struct dictionary *dict, struct xz_buf *b)
 62.1460 -+{
 62.1461 -+	if (DEC_IS_SINGLE(dict->mode)) {
 62.1462 -+		dict->buf = b->out + b->out_pos;
 62.1463 -+		dict->end = b->out_size - b->out_pos;
 62.1464 -+	}
 62.1465 -+
 62.1466 -+	dict->start = 0;
 62.1467 -+	dict->pos = 0;
 62.1468 -+	dict->limit = 0;
 62.1469 -+	dict->full = 0;
 62.1470 -+}
 62.1471 -+
 62.1472 -+/* Set dictionary write limit */
 62.1473 -+static void dict_limit(struct dictionary *dict, size_t out_max)
 62.1474 -+{
 62.1475 -+	if (dict->end - dict->pos <= out_max)
 62.1476 -+		dict->limit = dict->end;
 62.1477 -+	else
 62.1478 -+		dict->limit = dict->pos + out_max;
 62.1479 -+}
 62.1480 -+
 62.1481 -+/* Return true if at least one byte can be written into the dictionary. */
 62.1482 -+static inline bool dict_has_space(const struct dictionary *dict)
 62.1483 -+{
 62.1484 -+	return dict->pos < dict->limit;
 62.1485 -+}
 62.1486 -+
 62.1487 -+/*
 62.1488 -+ * Get a byte from the dictionary at the given distance. The distance is
 62.1489 -+ * assumed to valid, or as a special case, zero when the dictionary is
 62.1490 -+ * still empty. This special case is needed for single-call decoding to
 62.1491 -+ * avoid writing a '\0' to the end of the destination buffer.
 62.1492 -+ */
 62.1493 -+static inline uint32_t dict_get(const struct dictionary *dict, uint32_t dist)
 62.1494 -+{
 62.1495 -+	size_t offset = dict->pos - dist - 1;
 62.1496 -+
 62.1497 -+	if (dist >= dict->pos)
 62.1498 -+		offset += dict->end;
 62.1499 -+
 62.1500 -+	return dict->full > 0 ? dict->buf[offset] : 0;
 62.1501 -+}
 62.1502 -+
 62.1503 -+/*
 62.1504 -+ * Put one byte into the dictionary. It is assumed that there is space for it.
 62.1505 -+ */
 62.1506 -+static inline void dict_put(struct dictionary *dict, uint8_t byte)
 62.1507 -+{
 62.1508 -+	dict->buf[dict->pos++] = byte;
 62.1509 -+
 62.1510 -+	if (dict->full < dict->pos)
 62.1511 -+		dict->full = dict->pos;
 62.1512 -+}
 62.1513 -+
 62.1514 -+/*
 62.1515 -+ * Repeat given number of bytes from the given distance. If the distance is
 62.1516 -+ * invalid, false is returned. On success, true is returned and *len is
 62.1517 -+ * updated to indicate how many bytes were left to be repeated.
 62.1518 -+ */
 62.1519 -+static bool dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist)
 62.1520 -+{
 62.1521 -+	size_t back;
 62.1522 -+	uint32_t left;
 62.1523 -+
 62.1524 -+	if (dist >= dict->full || dist >= dict->size)
 62.1525 -+		return false;
 62.1526 -+
 62.1527 -+	left = min_t(size_t, dict->limit - dict->pos, *len);
 62.1528 -+	*len -= left;
 62.1529 -+
 62.1530 -+	back = dict->pos - dist - 1;
 62.1531 -+	if (dist >= dict->pos)
 62.1532 -+		back += dict->end;
 62.1533 -+
 62.1534 -+	do {
 62.1535 -+		dict->buf[dict->pos++] = dict->buf[back++];
 62.1536 -+		if (back == dict->end)
 62.1537 -+			back = 0;
 62.1538 -+	} while (--left > 0);
 62.1539 -+
 62.1540 -+	if (dict->full < dict->pos)
 62.1541 -+		dict->full = dict->pos;
 62.1542 -+
 62.1543 -+	return true;
 62.1544 -+}
 62.1545 -+
 62.1546 -+/* Copy uncompressed data as is from input to dictionary and output buffers. */
 62.1547 -+static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
 62.1548 -+			      uint32_t *left)
 62.1549 -+{
 62.1550 -+	size_t copy_size;
 62.1551 -+
 62.1552 -+	while (*left > 0 && b->in_pos < b->in_size
 62.1553 -+			&& b->out_pos < b->out_size) {
 62.1554 -+		copy_size = min(b->in_size - b->in_pos,
 62.1555 -+				b->out_size - b->out_pos);
 62.1556 -+		if (copy_size > dict->end - dict->pos)
 62.1557 -+			copy_size = dict->end - dict->pos;
 62.1558 -+		if (copy_size > *left)
 62.1559 -+			copy_size = *left;
 62.1560 -+
 62.1561 -+		*left -= copy_size;
 62.1562 -+
 62.1563 -+		memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
 62.1564 -+		dict->pos += copy_size;
 62.1565 -+
 62.1566 -+		if (dict->full < dict->pos)
 62.1567 -+			dict->full = dict->pos;
 62.1568 -+
 62.1569 -+		if (DEC_IS_MULTI(dict->mode)) {
 62.1570 -+			if (dict->pos == dict->end)
 62.1571 -+				dict->pos = 0;
 62.1572 -+
 62.1573 -+			memcpy(b->out + b->out_pos, b->in + b->in_pos,
 62.1574 -+					copy_size);
 62.1575 -+		}
 62.1576 -+
 62.1577 -+		dict->start = dict->pos;
 62.1578 -+
 62.1579 -+		b->out_pos += copy_size;
 62.1580 -+		b->in_pos += copy_size;
 62.1581 -+	}
 62.1582 -+}
 62.1583 -+
 62.1584 -+/*
 62.1585 -+ * Flush pending data from dictionary to b->out. It is assumed that there is
 62.1586 -+ * enough space in b->out. This is guaranteed because caller uses dict_limit()
 62.1587 -+ * before decoding data into the dictionary.
 62.1588 -+ */
 62.1589 -+static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)
 62.1590 -+{
 62.1591 -+	size_t copy_size = dict->pos - dict->start;
 62.1592 -+
 62.1593 -+	if (DEC_IS_MULTI(dict->mode)) {
 62.1594 -+		if (dict->pos == dict->end)
 62.1595 -+			dict->pos = 0;
 62.1596 -+
 62.1597 -+		memcpy(b->out + b->out_pos, dict->buf + dict->start,
 62.1598 -+				copy_size);
 62.1599 -+	}
 62.1600 -+
 62.1601 -+	dict->start = dict->pos;
 62.1602 -+	b->out_pos += copy_size;
 62.1603 -+	return copy_size;
 62.1604 -+}
 62.1605 -+
 62.1606 -+/*****************
 62.1607 -+ * Range decoder *
 62.1608 -+ *****************/
 62.1609 -+
 62.1610 -+/* Reset the range decoder. */
 62.1611 -+static void rc_reset(struct rc_dec *rc)
 62.1612 -+{
 62.1613 -+	rc->range = (uint32_t)-1;
 62.1614 -+	rc->code = 0;
 62.1615 -+	rc->init_bytes_left = RC_INIT_BYTES;
 62.1616 -+}
 62.1617 -+
 62.1618 -+/*
 62.1619 -+ * Read the first five initial bytes into rc->code if they haven't been
 62.1620 -+ * read already. (Yes, the first byte gets completely ignored.)
 62.1621 -+ */
 62.1622 -+static bool rc_read_init(struct rc_dec *rc, struct xz_buf *b)
 62.1623 -+{
 62.1624 -+	while (rc->init_bytes_left > 0) {
 62.1625 -+		if (b->in_pos == b->in_size)
 62.1626 -+			return false;
 62.1627 -+
 62.1628 -+		rc->code = (rc->code << 8) + b->in[b->in_pos++];
 62.1629 -+		--rc->init_bytes_left;
 62.1630 -+	}
 62.1631 -+
 62.1632 -+	return true;
 62.1633 -+}
 62.1634 -+
 62.1635 -+/* Return true if there may not be enough input for the next decoding loop. */
 62.1636 -+static inline bool rc_limit_exceeded(const struct rc_dec *rc)
 62.1637 -+{
 62.1638 -+	return rc->in_pos > rc->in_limit;
 62.1639 -+}
 62.1640 -+
 62.1641 -+/*
 62.1642 -+ * Return true if it is possible (from point of view of range decoder) that
 62.1643 -+ * we have reached the end of the LZMA chunk.
 62.1644 -+ */
 62.1645 -+static inline bool rc_is_finished(const struct rc_dec *rc)
 62.1646 -+{
 62.1647 -+	return rc->code == 0;
 62.1648 -+}
 62.1649 -+
 62.1650 -+/* Read the next input byte if needed. */
 62.1651 -+static __always_inline void rc_normalize(struct rc_dec *rc)
 62.1652 -+{
 62.1653 -+	if (rc->range < RC_TOP_VALUE) {
 62.1654 -+		rc->range <<= RC_SHIFT_BITS;
 62.1655 -+		rc->code = (rc->code << RC_SHIFT_BITS) + rc->in[rc->in_pos++];
 62.1656 -+	}
 62.1657 -+}
 62.1658 -+
 62.1659 -+/*
 62.1660 -+ * Decode one bit. In some versions, this function has been splitted in three
 62.1661 -+ * functions so that the compiler is supposed to be able to more easily avoid
 62.1662 -+ * an extra branch. In this particular version of the LZMA decoder, this
 62.1663 -+ * doesn't seem to be a good idea (tested with GCC 3.3.6, 3.4.6, and 4.3.3
 62.1664 -+ * on x86). Using a non-splitted version results in nicer looking code too.
 62.1665 -+ *
 62.1666 -+ * NOTE: This must return an int. Do not make it return a bool or the speed
 62.1667 -+ * of the code generated by GCC 3.x decreases 10-15 %. (GCC 4.3 doesn't care,
 62.1668 -+ * and it generates 10-20 % faster code than GCC 3.x from this file anyway.)
 62.1669 -+ */
 62.1670 -+static __always_inline int rc_bit(struct rc_dec *rc, uint16_t *prob)
 62.1671 -+{
 62.1672 -+	uint32_t bound;
 62.1673 -+	int bit;
 62.1674 -+
 62.1675 -+	rc_normalize(rc);
 62.1676 -+	bound = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) * *prob;
 62.1677 -+	if (rc->code < bound) {
 62.1678 -+		rc->range = bound;
 62.1679 -+		*prob += (RC_BIT_MODEL_TOTAL - *prob) >> RC_MOVE_BITS;
 62.1680 -+		bit = 0;
 62.1681 -+	} else {
 62.1682 -+		rc->range -= bound;
 62.1683 -+		rc->code -= bound;
 62.1684 -+		*prob -= *prob >> RC_MOVE_BITS;
 62.1685 -+		bit = 1;
 62.1686 -+	}
 62.1687 -+
 62.1688 -+	return bit;
 62.1689 -+}
 62.1690 -+
 62.1691 -+/* Decode a bittree starting from the most significant bit. */
 62.1692 -+static __always_inline uint32_t rc_bittree(struct rc_dec *rc,
 62.1693 -+					   uint16_t *probs, uint32_t limit)
 62.1694 -+{
 62.1695 -+	uint32_t symbol = 1;
 62.1696 -+
 62.1697 -+	do {
 62.1698 -+		if (rc_bit(rc, &probs[symbol]))
 62.1699 -+			symbol = (symbol << 1) + 1;
 62.1700 -+		else
 62.1701 -+			symbol <<= 1;
 62.1702 -+	} while (symbol < limit);
 62.1703 -+
 62.1704 -+	return symbol;
 62.1705 -+}
 62.1706 -+
 62.1707 -+/* Decode a bittree starting from the least significant bit. */
 62.1708 -+static __always_inline void rc_bittree_reverse(struct rc_dec *rc,
 62.1709 -+					       uint16_t *probs,
 62.1710 -+					       uint32_t *dest, uint32_t limit)
 62.1711 -+{
 62.1712 -+	uint32_t symbol = 1;
 62.1713 -+	uint32_t i = 0;
 62.1714 -+
 62.1715 -+	do {
 62.1716 -+		if (rc_bit(rc, &probs[symbol])) {
 62.1717 -+			symbol = (symbol << 1) + 1;
 62.1718 -+			*dest += 1 << i;
 62.1719 -+		} else {
 62.1720 -+			symbol <<= 1;
 62.1721 -+		}
 62.1722 -+	} while (++i < limit);
 62.1723 -+}
 62.1724 -+
 62.1725 -+/* Decode direct bits (fixed fifty-fifty probability) */
 62.1726 -+static inline void rc_direct(struct rc_dec *rc, uint32_t *dest, uint32_t limit)
 62.1727 -+{
 62.1728 -+	uint32_t mask;
 62.1729 -+
 62.1730 -+	do {
 62.1731 -+		rc_normalize(rc);
 62.1732 -+		rc->range >>= 1;
 62.1733 -+		rc->code -= rc->range;
 62.1734 -+		mask = (uint32_t)0 - (rc->code >> 31);
 62.1735 -+		rc->code += rc->range & mask;
 62.1736 -+		*dest = (*dest << 1) + (mask + 1);
 62.1737 -+	} while (--limit > 0);
 62.1738 -+}
 62.1739 -+
 62.1740 -+/********
 62.1741 -+ * LZMA *
 62.1742 -+ ********/
 62.1743 -+
 62.1744 -+/* Get pointer to literal coder probability array. */
 62.1745 -+static uint16_t *lzma_literal_probs(struct xz_dec_lzma2 *s)
 62.1746 -+{
 62.1747 -+	uint32_t prev_byte = dict_get(&s->dict, 0);
 62.1748 -+	uint32_t low = prev_byte >> (8 - s->lzma.lc);
 62.1749 -+	uint32_t high = (s->dict.pos & s->lzma.literal_pos_mask) << s->lzma.lc;
 62.1750 -+	return s->lzma.literal[low + high];
 62.1751 -+}
 62.1752 -+
 62.1753 -+/* Decode a literal (one 8-bit byte) */
 62.1754 -+static void lzma_literal(struct xz_dec_lzma2 *s)
 62.1755 -+{
 62.1756 -+	uint16_t *probs;
 62.1757 -+	uint32_t symbol;
 62.1758 -+	uint32_t match_byte;
 62.1759 -+	uint32_t match_bit;
 62.1760 -+	uint32_t offset;
 62.1761 -+	uint32_t i;
 62.1762 -+
 62.1763 -+	probs = lzma_literal_probs(s);
 62.1764 -+
 62.1765 -+	if (lzma_state_is_literal(s->lzma.state)) {
 62.1766 -+		symbol = rc_bittree(&s->rc, probs, 0x100);
 62.1767 -+	} else {
 62.1768 -+		symbol = 1;
 62.1769 -+		match_byte = dict_get(&s->dict, s->lzma.rep0) << 1;
 62.1770 -+		offset = 0x100;
 62.1771 -+
 62.1772 -+		do {
 62.1773 -+			match_bit = match_byte & offset;
 62.1774 -+			match_byte <<= 1;
 62.1775 -+			i = offset + match_bit + symbol;
 62.1776 -+
 62.1777 -+			if (rc_bit(&s->rc, &probs[i])) {
 62.1778 -+				symbol = (symbol << 1) + 1;
 62.1779 -+				offset &= match_bit;
 62.1780 -+			} else {
 62.1781 -+				symbol <<= 1;
 62.1782 -+				offset &= ~match_bit;
 62.1783 -+			}
 62.1784 -+		} while (symbol < 0x100);
 62.1785 -+	}
 62.1786 -+
 62.1787 -+	dict_put(&s->dict, (uint8_t)symbol);
 62.1788 -+	lzma_state_literal(&s->lzma.state);
 62.1789 -+}
 62.1790 -+
 62.1791 -+/* Decode the length of the match into s->lzma.len. */
 62.1792 -+static void lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l,
 62.1793 -+		     uint32_t pos_state)
 62.1794 -+{
 62.1795 -+	uint16_t *probs;
 62.1796 -+	uint32_t limit;
 62.1797 -+
 62.1798 -+	if (!rc_bit(&s->rc, &l->choice)) {
 62.1799 -+		probs = l->low[pos_state];
 62.1800 -+		limit = LEN_LOW_SYMBOLS;
 62.1801 -+		s->lzma.len = MATCH_LEN_MIN;
 62.1802 -+	} else {
 62.1803 -+		if (!rc_bit(&s->rc, &l->choice2)) {
 62.1804 -+			probs = l->mid[pos_state];
 62.1805 -+			limit = LEN_MID_SYMBOLS;
 62.1806 -+			s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS;
 62.1807 -+		} else {
 62.1808 -+			probs = l->high;
 62.1809 -+			limit = LEN_HIGH_SYMBOLS;
 62.1810 -+			s->lzma.len = MATCH_LEN_MIN + LEN_LOW_SYMBOLS
 62.1811 -+					+ LEN_MID_SYMBOLS;
 62.1812 -+		}
 62.1813 -+	}
 62.1814 -+
 62.1815 -+	s->lzma.len += rc_bittree(&s->rc, probs, limit) - limit;
 62.1816 -+}
 62.1817 -+
 62.1818 -+/* Decode a match. The distance will be stored in s->lzma.rep0. */
 62.1819 -+static void lzma_match(struct xz_dec_lzma2 *s, uint32_t pos_state)
 62.1820 -+{
 62.1821 -+	uint16_t *probs;
 62.1822 -+	uint32_t dist_slot;
 62.1823 -+	uint32_t limit;
 62.1824 -+
 62.1825 -+	lzma_state_match(&s->lzma.state);
 62.1826 -+
 62.1827 -+	s->lzma.rep3 = s->lzma.rep2;
 62.1828 -+	s->lzma.rep2 = s->lzma.rep1;
 62.1829 -+	s->lzma.rep1 = s->lzma.rep0;
 62.1830 -+
 62.1831 -+	lzma_len(s, &s->lzma.match_len_dec, pos_state);
 62.1832 -+
 62.1833 -+	probs = s->lzma.dist_slot[lzma_get_dist_state(s->lzma.len)];
 62.1834 -+	dist_slot = rc_bittree(&s->rc, probs, DIST_SLOTS) - DIST_SLOTS;
 62.1835 -+
 62.1836 -+	if (dist_slot < DIST_MODEL_START) {
 62.1837 -+		s->lzma.rep0 = dist_slot;
 62.1838 -+	} else {
 62.1839 -+		limit = (dist_slot >> 1) - 1;
 62.1840 -+		s->lzma.rep0 = 2 + (dist_slot & 1);
 62.1841 -+
 62.1842 -+		if (dist_slot < DIST_MODEL_END) {
 62.1843 -+			s->lzma.rep0 <<= limit;
 62.1844 -+			probs = s->lzma.dist_special + s->lzma.rep0
 62.1845 -+					- dist_slot - 1;
 62.1846 -+			rc_bittree_reverse(&s->rc, probs,
 62.1847 -+					&s->lzma.rep0, limit);
 62.1848 -+		} else {
 62.1849 -+			rc_direct(&s->rc, &s->lzma.rep0, limit - ALIGN_BITS);
 62.1850 -+			s->lzma.rep0 <<= ALIGN_BITS;
 62.1851 -+			rc_bittree_reverse(&s->rc, s->lzma.dist_align,
 62.1852 -+					&s->lzma.rep0, ALIGN_BITS);
 62.1853 -+		}
 62.1854 -+	}
 62.1855 -+}
 62.1856 -+
 62.1857 -+/*
 62.1858 -+ * Decode a repeated match. The distance is one of the four most recently
 62.1859 -+ * seen matches. The distance will be stored in s->lzma.rep0.
 62.1860 -+ */
 62.1861 -+static void lzma_rep_match(struct xz_dec_lzma2 *s, uint32_t pos_state)
 62.1862 -+{
 62.1863 -+	uint32_t tmp;
 62.1864 -+
 62.1865 -+	if (!rc_bit(&s->rc, &s->lzma.is_rep0[s->lzma.state])) {
 62.1866 -+		if (!rc_bit(&s->rc, &s->lzma.is_rep0_long[
 62.1867 -+				s->lzma.state][pos_state])) {
 62.1868 -+			lzma_state_short_rep(&s->lzma.state);
 62.1869 -+			s->lzma.len = 1;
 62.1870 -+			return;
 62.1871 -+		}
 62.1872 -+	} else {
 62.1873 -+		if (!rc_bit(&s->rc, &s->lzma.is_rep1[s->lzma.state])) {
 62.1874 -+			tmp = s->lzma.rep1;
 62.1875 -+		} else {
 62.1876 -+			if (!rc_bit(&s->rc, &s->lzma.is_rep2[s->lzma.state])) {
 62.1877 -+				tmp = s->lzma.rep2;
 62.1878 -+			} else {
 62.1879 -+				tmp = s->lzma.rep3;
 62.1880 -+				s->lzma.rep3 = s->lzma.rep2;
 62.1881 -+			}
 62.1882 -+
 62.1883 -+			s->lzma.rep2 = s->lzma.rep1;
 62.1884 -+		}
 62.1885 -+
 62.1886 -+		s->lzma.rep1 = s->lzma.rep0;
 62.1887 -+		s->lzma.rep0 = tmp;
 62.1888 -+	}
 62.1889 -+
 62.1890 -+	lzma_state_long_rep(&s->lzma.state);
 62.1891 -+	lzma_len(s, &s->lzma.rep_len_dec, pos_state);
 62.1892 -+}
 62.1893 -+
 62.1894 -+/* LZMA decoder core */
 62.1895 -+static bool lzma_main(struct xz_dec_lzma2 *s)
 62.1896 -+{
 62.1897 -+	uint32_t pos_state;
 62.1898 -+
 62.1899 -+	/*
 62.1900 -+	 * If the dictionary was reached during the previous call, try to
 62.1901 -+	 * finish the possibly pending repeat in the dictionary.
 62.1902 -+	 */
 62.1903 -+	if (dict_has_space(&s->dict) && s->lzma.len > 0)
 62.1904 -+		dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0);
 62.1905 -+
 62.1906 -+	/*
 62.1907 -+	 * Decode more LZMA symbols. One iteration may consume up to
 62.1908 -+	 * LZMA_IN_REQUIRED - 1 bytes.
 62.1909 -+	 */
 62.1910 -+	while (dict_has_space(&s->dict) && !rc_limit_exceeded(&s->rc)) {
 62.1911 -+		pos_state = s->dict.pos & s->lzma.pos_mask;
 62.1912 -+
 62.1913 -+		if (!rc_bit(&s->rc, &s->lzma.is_match[
 62.1914 -+				s->lzma.state][pos_state])) {
 62.1915 -+			lzma_literal(s);
 62.1916 -+		} else {
 62.1917 -+			if (rc_bit(&s->rc, &s->lzma.is_rep[s->lzma.state]))
 62.1918 -+				lzma_rep_match(s, pos_state);
 62.1919 -+			else
 62.1920 -+				lzma_match(s, pos_state);
 62.1921 -+
 62.1922 -+			if (!dict_repeat(&s->dict, &s->lzma.len, s->lzma.rep0))
 62.1923 -+				return false;
 62.1924 -+		}
 62.1925 -+	}
 62.1926 -+
 62.1927 -+	/*
 62.1928 -+	 * Having the range decoder always normalized when we are outside
 62.1929 -+	 * this function makes it easier to correctly handle end of the chunk.
 62.1930 -+	 */
 62.1931 -+	rc_normalize(&s->rc);
 62.1932 -+
 62.1933 -+	return true;
 62.1934 -+}
 62.1935 -+
 62.1936 -+/*
 62.1937 -+ * Reset the LZMA decoder and range decoder state. Dictionary is nore reset
 62.1938 -+ * here, because LZMA state may be reset without resetting the dictionary.
 62.1939 -+ */
 62.1940 -+static void lzma_reset(struct xz_dec_lzma2 *s)
 62.1941 -+{
 62.1942 -+	uint16_t *probs;
 62.1943 -+	size_t i;
 62.1944 -+
 62.1945 -+	s->lzma.state = STATE_LIT_LIT;
 62.1946 -+	s->lzma.rep0 = 0;
 62.1947 -+	s->lzma.rep1 = 0;
 62.1948 -+	s->lzma.rep2 = 0;
 62.1949 -+	s->lzma.rep3 = 0;
 62.1950 -+
 62.1951 -+	/*
 62.1952 -+	 * All probabilities are initialized to the same value. This hack
 62.1953 -+	 * makes the code smaller by avoiding a separate loop for each
 62.1954 -+	 * probability array.
 62.1955 -+	 *
 62.1956 -+	 * This could be optimized so that only that part of literal
 62.1957 -+	 * probabilities that are actually required. In the common case
 62.1958 -+	 * we would write 12 KiB less.
 62.1959 -+	 */
 62.1960 -+	probs = s->lzma.is_match[0];
 62.1961 -+	for (i = 0; i < PROBS_TOTAL; ++i)
 62.1962 -+		probs[i] = RC_BIT_MODEL_TOTAL / 2;
 62.1963 -+
 62.1964 -+	rc_reset(&s->rc);
 62.1965 -+}
 62.1966 -+
 62.1967 -+/*
 62.1968 -+ * Decode and validate LZMA properties (lc/lp/pb) and calculate the bit masks
 62.1969 -+ * from the decoded lp and pb values. On success, the LZMA decoder state is
 62.1970 -+ * reset and true is returned.
 62.1971 -+ */
 62.1972 -+static bool lzma_props(struct xz_dec_lzma2 *s, uint8_t props)
 62.1973 -+{
 62.1974 -+	if (props > (4 * 5 + 4) * 9 + 8)
 62.1975 -+		return false;
 62.1976 -+
 62.1977 -+	s->lzma.pos_mask = 0;
 62.1978 -+	while (props >= 9 * 5) {
 62.1979 -+		props -= 9 * 5;
 62.1980 -+		++s->lzma.pos_mask;
 62.1981 -+	}
 62.1982 -+
 62.1983 -+	s->lzma.pos_mask = (1 << s->lzma.pos_mask) - 1;
 62.1984 -+
 62.1985 -+	s->lzma.literal_pos_mask = 0;
 62.1986 -+	while (props >= 9) {
 62.1987 -+		props -= 9;
 62.1988 -+		++s->lzma.literal_pos_mask;
 62.1989 -+	}
 62.1990 -+
 62.1991 -+	s->lzma.lc = props;
 62.1992 -+
 62.1993 -+	if (s->lzma.lc + s->lzma.literal_pos_mask > 4)
 62.1994 -+		return false;
 62.1995 -+
 62.1996 -+	s->lzma.literal_pos_mask = (1 << s->lzma.literal_pos_mask) - 1;
 62.1997 -+
 62.1998 -+	lzma_reset(s);
 62.1999 -+
 62.2000 -+	return true;
 62.2001 -+}
 62.2002 -+
 62.2003 -+/*********
 62.2004 -+ * LZMA2 *
 62.2005 -+ *********/
 62.2006 -+
 62.2007 -+/*
 62.2008 -+ * The LZMA decoder assumes that if the input limit (s->rc.in_limit) hasn't
 62.2009 -+ * been exceeded, it is safe to read up to LZMA_IN_REQUIRED bytes. This
 62.2010 -+ * wrapper function takes care of making the LZMA decoder's assumption safe.
 62.2011 -+ *
 62.2012 -+ * As long as there is plenty of input left to be decoded in the current LZMA
 62.2013 -+ * chunk, we decode directly from the caller-supplied input buffer until
 62.2014 -+ * there's LZMA_IN_REQUIRED bytes left. Those remaining bytes are copied into
 62.2015 -+ * s->temp.buf, which (hopefully) gets filled on the next call to this
 62.2016 -+ * function. We decode a few bytes from the temporary buffer so that we can
 62.2017 -+ * continue decoding from the caller-supplied input buffer again.
 62.2018 -+ */
 62.2019 -+static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
 62.2020 -+{
 62.2021 -+	size_t in_avail;
 62.2022 -+	uint32_t tmp;
 62.2023 -+
 62.2024 -+	in_avail = b->in_size - b->in_pos;
 62.2025 -+	if (s->temp.size > 0 || s->lzma2.compressed == 0) {
 62.2026 -+		tmp = 2 * LZMA_IN_REQUIRED - s->temp.size;
 62.2027 -+		if (tmp > s->lzma2.compressed - s->temp.size)
 62.2028 -+			tmp = s->lzma2.compressed - s->temp.size;
 62.2029 -+		if (tmp > in_avail)
 62.2030 -+			tmp = in_avail;
 62.2031 -+
 62.2032 -+		memcpy(s->temp.buf + s->temp.size, b->in + b->in_pos, tmp);
 62.2033 -+
 62.2034 -+		if (s->temp.size + tmp == s->lzma2.compressed) {
 62.2035 -+			memzero(s->temp.buf + s->temp.size + tmp,
 62.2036 -+					sizeof(s->temp.buf)
 62.2037 -+						- s->temp.size - tmp);
 62.2038 -+			s->rc.in_limit = s->temp.size + tmp;
 62.2039 -+		} else if (s->temp.size + tmp < LZMA_IN_REQUIRED) {
 62.2040 -+			s->temp.size += tmp;
 62.2041 -+			b->in_pos += tmp;
 62.2042 -+			return true;
 62.2043 -+		} else {
 62.2044 -+			s->rc.in_limit = s->temp.size + tmp - LZMA_IN_REQUIRED;
 62.2045 -+		}
 62.2046 -+
 62.2047 -+		s->rc.in = s->temp.buf;
 62.2048 -+		s->rc.in_pos = 0;
 62.2049 -+
 62.2050 -+		if (!lzma_main(s) || s->rc.in_pos > s->temp.size + tmp)
 62.2051 -+			return false;
 62.2052 -+
 62.2053 -+		s->lzma2.compressed -= s->rc.in_pos;
 62.2054 -+
 62.2055 -+		if (s->rc.in_pos < s->temp.size) {
 62.2056 -+			s->temp.size -= s->rc.in_pos;
 62.2057 -+			memmove(s->temp.buf, s->temp.buf + s->rc.in_pos,
 62.2058 -+					s->temp.size);
 62.2059 -+			return true;
 62.2060 -+		}
 62.2061 -+
 62.2062 -+		b->in_pos += s->rc.in_pos - s->temp.size;
 62.2063 -+		s->temp.size = 0;
 62.2064 -+	}
 62.2065 -+
 62.2066 -+	in_avail = b->in_size - b->in_pos;
 62.2067 -+	if (in_avail >= LZMA_IN_REQUIRED) {
 62.2068 -+		s->rc.in = b->in;
 62.2069 -+		s->rc.in_pos = b->in_pos;
 62.2070 -+
 62.2071 -+		if (in_avail >= s->lzma2.compressed + LZMA_IN_REQUIRED)
 62.2072 -+			s->rc.in_limit = b->in_pos + s->lzma2.compressed;
 62.2073 -+		else
 62.2074 -+			s->rc.in_limit = b->in_size - LZMA_IN_REQUIRED;
 62.2075 -+
 62.2076 -+		if (!lzma_main(s))
 62.2077 -+			return false;
 62.2078 -+
 62.2079 -+		in_avail = s->rc.in_pos - b->in_pos;
 62.2080 -+		if (in_avail > s->lzma2.compressed)
 62.2081 -+			return false;
 62.2082 -+
 62.2083 -+		s->lzma2.compressed -= in_avail;
 62.2084 -+		b->in_pos = s->rc.in_pos;
 62.2085 -+	}
 62.2086 -+
 62.2087 -+	in_avail = b->in_size - b->in_pos;
 62.2088 -+	if (in_avail < LZMA_IN_REQUIRED) {
 62.2089 -+		if (in_avail > s->lzma2.compressed)
 62.2090 -+			in_avail = s->lzma2.compressed;
 62.2091 -+
 62.2092 -+		memcpy(s->temp.buf, b->in + b->in_pos, in_avail);
 62.2093 -+		s->temp.size = in_avail;
 62.2094 -+		b->in_pos += in_avail;
 62.2095 -+	}
 62.2096 -+
 62.2097 -+	return true;
 62.2098 -+}
 62.2099 -+
 62.2100 -+/*
 62.2101 -+ * Take care of the LZMA2 control layer, and forward the job of actual LZMA
 62.2102 -+ * decoding or copying of uncompressed chunks to other functions.
 62.2103 -+ */
 62.2104 -+XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
 62.2105 -+				       struct xz_buf *b)
 62.2106 -+{
 62.2107 -+	uint32_t tmp;
 62.2108 -+
 62.2109 -+	while (b->in_pos < b->in_size || s->lzma2.sequence == SEQ_LZMA_RUN) {
 62.2110 -+		switch (s->lzma2.sequence) {
 62.2111 -+		case SEQ_CONTROL:
 62.2112 -+			/*
 62.2113 -+			 * LZMA2 control byte
 62.2114 -+			 *
 62.2115 -+			 * Exact values:
 62.2116 -+			 *   0x00   End marker
 62.2117 -+			 *   0x01   Dictionary reset followed by
 62.2118 -+			 *          an uncompressed chunk
 62.2119 -+			 *   0x02   Uncompressed chunk (no dictionary reset)
 62.2120 -+			 *
 62.2121 -+			 * Highest three bits (s->control & 0xE0):
 62.2122 -+			 *   0xE0   Dictionary reset, new properties and state
 62.2123 -+			 *          reset, followed by LZMA compressed chunk
 62.2124 -+			 *   0xC0   New properties and state reset, followed
 62.2125 -+			 *          by LZMA compressed chunk (no dictionary
 62.2126 -+			 *          reset)
 62.2127 -+			 *   0xA0   State reset using old properties,
 62.2128 -+			 *          followed by LZMA compressed chunk (no
 62.2129 -+			 *          dictionary reset)
 62.2130 -+			 *   0x80   LZMA chunk (no dictionary or state reset)
 62.2131 -+			 *
 62.2132 -+			 * For LZMA compressed chunks, the lowest five bits
 62.2133 -+			 * (s->control & 1F) are the highest bits of the
 62.2134 -+			 * uncompressed size (bits 16-20).
 62.2135 -+			 *
 62.2136 -+			 * A new LZMA2 stream must begin with a dictionary
 62.2137 -+			 * reset. The first LZMA chunk must set new
 62.2138 -+			 * properties and reset the LZMA state.
 62.2139 -+			 *
 62.2140 -+			 * Values that don't match anything described above
 62.2141 -+			 * are invalid and we return XZ_DATA_ERROR.
 62.2142 -+			 */
 62.2143 -+			tmp = b->in[b->in_pos++];
 62.2144 -+
 62.2145 -+			if (tmp >= 0xE0 || tmp == 0x01) {
 62.2146 -+				s->lzma2.need_props = true;
 62.2147 -+				s->lzma2.need_dict_reset = false;
 62.2148 -+				dict_reset(&s->dict, b);
 62.2149 -+			} else if (s->lzma2.need_dict_reset) {
 62.2150 -+				return XZ_DATA_ERROR;
 62.2151 -+			}
 62.2152 -+
 62.2153 -+			if (tmp >= 0x80) {
 62.2154 -+				s->lzma2.uncompressed = (tmp & 0x1F) << 16;
 62.2155 -+				s->lzma2.sequence = SEQ_UNCOMPRESSED_1;
 62.2156 -+
 62.2157 -+				if (tmp >= 0xC0) {
 62.2158 -+					/*
 62.2159 -+					 * When there are new properties,
 62.2160 -+					 * state reset is done at
 62.2161 -+					 * SEQ_PROPERTIES.
 62.2162 -+					 */
 62.2163 -+					s->lzma2.need_props = false;
 62.2164 -+					s->lzma2.next_sequence
 62.2165 -+							= SEQ_PROPERTIES;
 62.2166 -+
 62.2167 -+				} else if (s->lzma2.need_props) {
 62.2168 -+					return XZ_DATA_ERROR;
 62.2169 -+
 62.2170 -+				} else {
 62.2171 -+					s->lzma2.next_sequence
 62.2172 -+							= SEQ_LZMA_PREPARE;
 62.2173 -+					if (tmp >= 0xA0)
 62.2174 -+						lzma_reset(s);
 62.2175 -+				}
 62.2176 -+			} else {
 62.2177 -+				if (tmp == 0x00)
 62.2178 -+					return XZ_STREAM_END;
 62.2179 -+
 62.2180 -+				if (tmp > 0x02)
 62.2181 -+					return XZ_DATA_ERROR;
 62.2182 -+
 62.2183 -+				s->lzma2.sequence = SEQ_COMPRESSED_0;
 62.2184 -+				s->lzma2.next_sequence = SEQ_COPY;
 62.2185 -+			}
 62.2186 -+
 62.2187 -+			break;
 62.2188 -+
 62.2189 -+		case SEQ_UNCOMPRESSED_1:
 62.2190 -+			s->lzma2.uncompressed
 62.2191 -+					+= (uint32_t)b->in[b->in_pos++] << 8;
 62.2192 -+			s->lzma2.sequence = SEQ_UNCOMPRESSED_2;
 62.2193 -+			break;
 62.2194 -+
 62.2195 -+		case SEQ_UNCOMPRESSED_2:
 62.2196 -+			s->lzma2.uncompressed
 62.2197 -+					+= (uint32_t)b->in[b->in_pos++] + 1;
 62.2198 -+			s->lzma2.sequence = SEQ_COMPRESSED_0;
 62.2199 -+			break;
 62.2200 -+
 62.2201 -+		case SEQ_COMPRESSED_0:
 62.2202 -+			s->lzma2.compressed
 62.2203 -+					= (uint32_t)b->in[b->in_pos++] << 8;
 62.2204 -+			s->lzma2.sequence = SEQ_COMPRESSED_1;
 62.2205 -+			break;
 62.2206 -+
 62.2207 -+		case SEQ_COMPRESSED_1:
 62.2208 -+			s->lzma2.compressed
 62.2209 -+					+= (uint32_t)b->in[b->in_pos++] + 1;
 62.2210 -+			s->lzma2.sequence = s->lzma2.next_sequence;
 62.2211 -+			break;
 62.2212 -+
 62.2213 -+		case SEQ_PROPERTIES:
 62.2214 -+			if (!lzma_props(s, b->in[b->in_pos++]))
 62.2215 -+				return XZ_DATA_ERROR;
 62.2216 -+
 62.2217 -+			s->lzma2.sequence = SEQ_LZMA_PREPARE;
 62.2218 -+
 62.2219 -+		case SEQ_LZMA_PREPARE:
 62.2220 -+			if (s->lzma2.compressed < RC_INIT_BYTES)
 62.2221 -+				return XZ_DATA_ERROR;
 62.2222 -+
 62.2223 -+			if (!rc_read_init(&s->rc, b))
 62.2224 -+				return XZ_OK;
 62.2225 -+
 62.2226 -+			s->lzma2.compressed -= RC_INIT_BYTES;
 62.2227 -+			s->lzma2.sequence = SEQ_LZMA_RUN;
 62.2228 -+
 62.2229 -+		case SEQ_LZMA_RUN:
 62.2230 -+			/*
 62.2231 -+			 * Set dictionary limit to indicate how much we want
 62.2232 -+			 * to be encoded at maximum. Decode new data into the
 62.2233 -+			 * dictionary. Flush the new data from dictionary to
 62.2234 -+			 * b->out. Check if we finished decoding this chunk.
 62.2235 -+			 * In case the dictionary got full but we didn't fill
 62.2236 -+			 * the output buffer yet, we may run this loop
 62.2237 -+			 * multiple times without changing s->lzma2.sequence.
 62.2238 -+			 */
 62.2239 -+			dict_limit(&s->dict, min_t(size_t,
 62.2240 -+					b->out_size - b->out_pos,
 62.2241 -+					s->lzma2.uncompressed));
 62.2242 -+			if (!lzma2_lzma(s, b))
 62.2243 -+				return XZ_DATA_ERROR;
 62.2244 -+
 62.2245 -+			s->lzma2.uncompressed -= dict_flush(&s->dict, b);
 62.2246 -+
 62.2247 -+			if (s->lzma2.uncompressed == 0) {
 62.2248 -+				if (s->lzma2.compressed > 0 || s->lzma.len > 0
 62.2249 -+						|| !rc_is_finished(&s->rc))
 62.2250 -+					return XZ_DATA_ERROR;
 62.2251 -+
 62.2252 -+				rc_reset(&s->rc);
 62.2253 -+				s->lzma2.sequence = SEQ_CONTROL;
 62.2254 -+
 62.2255 -+			} else if (b->out_pos == b->out_size
 62.2256 -+					|| (b->in_pos == b->in_size
 62.2257 -+						&& s->temp.size
 62.2258 -+						< s->lzma2.compressed)) {
 62.2259 -+				return XZ_OK;
 62.2260 -+			}
 62.2261 -+
 62.2262 -+			break;
 62.2263 -+
 62.2264 -+		case SEQ_COPY:
 62.2265 -+			dict_uncompressed(&s->dict, b, &s->lzma2.compressed);
 62.2266 -+			if (s->lzma2.compressed > 0)
 62.2267 -+				return XZ_OK;
 62.2268 -+
 62.2269 -+			s->lzma2.sequence = SEQ_CONTROL;
 62.2270 -+			break;
 62.2271 -+		}
 62.2272 -+	}
 62.2273 -+
 62.2274 -+	return XZ_OK;
 62.2275 -+}
 62.2276 -+
 62.2277 -+XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
 62.2278 -+						   uint32_t dict_max)
 62.2279 -+{
 62.2280 -+	struct xz_dec_lzma2 *s = kmalloc(sizeof(*s), GFP_KERNEL);
 62.2281 -+	if (s == NULL)
 62.2282 -+		return NULL;
 62.2283 -+
 62.2284 -+	s->dict.mode = mode;
 62.2285 -+	s->dict.size_max = dict_max;
 62.2286 -+
 62.2287 -+	if (DEC_IS_PREALLOC(mode)) {
 62.2288 -+		s->dict.buf = vmalloc(dict_max);
 62.2289 -+		if (s->dict.buf == NULL) {
 62.2290 -+			kfree(s);
 62.2291 -+			return NULL;
 62.2292 -+		}
 62.2293 -+	} else if (DEC_IS_DYNALLOC(mode)) {
 62.2294 -+		s->dict.buf = NULL;
 62.2295 -+		s->dict.allocated = 0;
 62.2296 -+	}
 62.2297 -+
 62.2298 -+	return s;
 62.2299 -+}
 62.2300 -+
 62.2301 -+XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
 62.2302 -+{
 62.2303 -+	/* This limits dictionary size to 3 GiB to keep parsing simpler. */
 62.2304 -+	if (props > 39)
 62.2305 -+		return XZ_OPTIONS_ERROR;
 62.2306 -+
 62.2307 -+	s->dict.size = 2 + (props & 1);
 62.2308 -+	s->dict.size <<= (props >> 1) + 11;
 62.2309 -+
 62.2310 -+	if (DEC_IS_MULTI(s->dict.mode)) {
 62.2311 -+		if (s->dict.size > s->dict.size_max)
 62.2312 -+			return XZ_MEMLIMIT_ERROR;
 62.2313 -+
 62.2314 -+		s->dict.end = s->dict.size;
 62.2315 -+
 62.2316 -+		if (DEC_IS_DYNALLOC(s->dict.mode)) {
 62.2317 -+			if (s->dict.allocated < s->dict.size) {
 62.2318 -+				vfree(s->dict.buf);
 62.2319 -+				s->dict.buf = vmalloc(s->dict.size);
 62.2320 -+				if (s->dict.buf == NULL) {
 62.2321 -+					s->dict.allocated = 0;
 62.2322 -+					return XZ_MEM_ERROR;
 62.2323 -+				}
 62.2324 -+			}
 62.2325 -+		}
 62.2326 -+	}
 62.2327 -+
 62.2328 -+	s->lzma.len = 0;
 62.2329 -+
 62.2330 -+	s->lzma2.sequence = SEQ_CONTROL;
 62.2331 -+	s->lzma2.need_dict_reset = true;
 62.2332 -+
 62.2333 -+	s->temp.size = 0;
 62.2334 -+
 62.2335 -+	return XZ_OK;
 62.2336 -+}
 62.2337 -+
 62.2338 -+XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s)
 62.2339 -+{
 62.2340 -+	if (DEC_IS_MULTI(s->dict.mode))
 62.2341 -+		vfree(s->dict.buf);
 62.2342 -+
 62.2343 -+	kfree(s);
 62.2344 -+}
 62.2345 -diff --git a/lib/xz/xz_dec_stream.c b/lib/xz/xz_dec_stream.c
 62.2346 -new file mode 100644
 62.2347 -index 0000000..ac809b1
 62.2348 ---- /dev/null
 62.2349 -+++ b/lib/xz/xz_dec_stream.c
 62.2350 -@@ -0,0 +1,821 @@
 62.2351 -+/*
 62.2352 -+ * .xz Stream decoder
 62.2353 -+ *
 62.2354 -+ * Author: Lasse Collin <lasse.collin@tukaani.org>
 62.2355 -+ *
 62.2356 -+ * This file has been put into the public domain.
 62.2357 -+ * You can do whatever you want with this file.
 62.2358 -+ */
 62.2359 -+
 62.2360 -+#include "xz_private.h"
 62.2361 -+#include "xz_stream.h"
 62.2362 -+
 62.2363 -+/* Hash used to validate the Index field */
 62.2364 -+struct xz_dec_hash {
 62.2365 -+	vli_type unpadded;
 62.2366 -+	vli_type uncompressed;
 62.2367 -+	uint32_t crc32;
 62.2368 -+};
 62.2369 -+
 62.2370 -+struct xz_dec {
 62.2371 -+	/* Position in dec_main() */
 62.2372 -+	enum {
 62.2373 -+		SEQ_STREAM_HEADER,
 62.2374 -+		SEQ_BLOCK_START,
 62.2375 -+		SEQ_BLOCK_HEADER,
 62.2376 -+		SEQ_BLOCK_UNCOMPRESS,
 62.2377 -+		SEQ_BLOCK_PADDING,
 62.2378 -+		SEQ_BLOCK_CHECK,
 62.2379 -+		SEQ_INDEX,
 62.2380 -+		SEQ_INDEX_PADDING,
 62.2381 -+		SEQ_INDEX_CRC32,
 62.2382 -+		SEQ_STREAM_FOOTER
 62.2383 -+	} sequence;
 62.2384 -+
 62.2385 -+	/* Position in variable-length integers and Check fields */
 62.2386 -+	uint32_t pos;
 62.2387 -+
 62.2388 -+	/* Variable-length integer decoded by dec_vli() */
 62.2389 -+	vli_type vli;
 62.2390 -+
 62.2391 -+	/* Saved in_pos and out_pos */
 62.2392 -+	size_t in_start;
 62.2393 -+	size_t out_start;
 62.2394 -+
 62.2395 -+	/* CRC32 value in Block or Index */
 62.2396 -+	uint32_t crc32;
 62.2397 -+
 62.2398 -+	/* Type of the integrity check calculated from uncompressed data */
 62.2399 -+	enum xz_check check_type;
 62.2400 -+
 62.2401 -+	/* Operation mode */
 62.2402 -+	enum xz_mode mode;
 62.2403 -+
 62.2404 -+	/*
 62.2405 -+	 * True if the next call to xz_dec_run() is allowed to return
 62.2406 -+	 * XZ_BUF_ERROR.
 62.2407 -+	 */
 62.2408 -+	bool allow_buf_error;
 62.2409 -+
 62.2410 -+	/* Information stored in Block Header */
 62.2411 -+	struct {
 62.2412 -+		/*
 62.2413 -+		 * Value stored in the Compressed Size field, or
 62.2414 -+		 * VLI_UNKNOWN if Compressed Size is not present.
 62.2415 -+		 */
 62.2416 -+		vli_type compressed;
 62.2417 -+
 62.2418 -+		/*
 62.2419 -+		 * Value stored in the Uncompressed Size field, or
 62.2420 -+		 * VLI_UNKNOWN if Uncompressed Size is not present.
 62.2421 -+		 */
 62.2422 -+		vli_type uncompressed;
 62.2423 -+
 62.2424 -+		/* Size of the Block Header field */
 62.2425 -+		uint32_t size;
 62.2426 -+	} block_header;
 62.2427 -+
 62.2428 -+	/* Information collected when decoding Blocks */
 62.2429 -+	struct {
 62.2430 -+		/* Observed compressed size of the current Block */
 62.2431 -+		vli_type compressed;
 62.2432 -+
 62.2433 -+		/* Observed uncompressed size of the current Block */
 62.2434 -+		vli_type uncompressed;
 62.2435 -+
 62.2436 -+		/* Number of Blocks decoded so far */
 62.2437 -+		vli_type count;
 62.2438 -+
 62.2439 -+		/*
 62.2440 -+		 * Hash calculated from the Block sizes. This is used to
 62.2441 -+		 * validate the Index field.
 62.2442 -+		 */
 62.2443 -+		struct xz_dec_hash hash;
 62.2444 -+	} block;
 62.2445 -+
 62.2446 -+	/* Variables needed when verifying the Index field */
 62.2447 -+	struct {
 62.2448 -+		/* Position in dec_index() */
 62.2449 -+		enum {
 62.2450 -+			SEQ_INDEX_COUNT,
 62.2451 -+			SEQ_INDEX_UNPADDED,
 62.2452 -+			SEQ_INDEX_UNCOMPRESSED
 62.2453 -+		} sequence;
 62.2454 -+
 62.2455 -+		/* Size of the Index in bytes */
 62.2456 -+		vli_type size;
 62.2457 -+
 62.2458 -+		/* Number of Records (matches block.count in valid files) */
 62.2459 -+		vli_type count;
 62.2460 -+
 62.2461 -+		/*
 62.2462 -+		 * Hash calculated from the Records (matches block.hash in
 62.2463 -+		 * valid files).
 62.2464 -+		 */
 62.2465 -+		struct xz_dec_hash hash;
 62.2466 -+	} index;
 62.2467 -+
 62.2468 -+	/*
 62.2469 -+	 * Temporary buffer needed to hold Stream Header, Block Header,
 62.2470 -+	 * and Stream Footer. The Block Header is the biggest (1 KiB)
 62.2471 -+	 * so we reserve space according to that. buf[] has to be aligned
 62.2472 -+	 * to a multiple of four bytes; the size_t variables before it
 62.2473 -+	 * should guarantee this.
 62.2474 -+	 */
 62.2475 -+	struct {
 62.2476 -+		size_t pos;
 62.2477 -+		size_t size;
 62.2478 -+		uint8_t buf[1024];
 62.2479 -+	} temp;
 62.2480 -+
 62.2481 -+	struct xz_dec_lzma2 *lzma2;
 62.2482 -+
 62.2483 -+#ifdef XZ_DEC_BCJ
 62.2484 -+	struct xz_dec_bcj *bcj;
 62.2485 -+	bool bcj_active;
 62.2486 -+#endif
 62.2487 -+};
 62.2488 -+
 62.2489 -+#ifdef XZ_DEC_ANY_CHECK
 62.2490 -+/* Sizes of the Check field with different Check IDs */
 62.2491 -+static const uint8_t check_sizes[16] = {
 62.2492 -+	0,
 62.2493 -+	4, 4, 4,
 62.2494 -+	8, 8, 8,
 62.2495 -+	16, 16, 16,
 62.2496 -+	32, 32, 32,
 62.2497 -+	64, 64, 64
 62.2498 -+};
 62.2499 -+#endif
 62.2500 -+
 62.2501 -+/*
 62.2502 -+ * Fill s->temp by copying data starting from b->in[b->in_pos]. Caller
 62.2503 -+ * must have set s->temp.pos to indicate how much data we are supposed
 62.2504 -+ * to copy into s->temp.buf. Return true once s->temp.pos has reached
 62.2505 -+ * s->temp.size.
 62.2506 -+ */
 62.2507 -+static bool fill_temp(struct xz_dec *s, struct xz_buf *b)
 62.2508 -+{
 62.2509 -+	size_t copy_size = min_t(size_t,
 62.2510 -+			b->in_size - b->in_pos, s->temp.size - s->temp.pos);
 62.2511 -+
 62.2512 -+	memcpy(s->temp.buf + s->temp.pos, b->in + b->in_pos, copy_size);
 62.2513 -+	b->in_pos += copy_size;
 62.2514 -+	s->temp.pos += copy_size;
 62.2515 -+
 62.2516 -+	if (s->temp.pos == s->temp.size) {
 62.2517 -+		s->temp.pos = 0;
 62.2518 -+		return true;
 62.2519 -+	}
 62.2520 -+
 62.2521 -+	return false;
 62.2522 -+}
 62.2523 -+
 62.2524 -+/* Decode a variable-length integer (little-endian base-128 encoding) */
 62.2525 -+static enum xz_ret dec_vli(struct xz_dec *s, const uint8_t *in,
 62.2526 -+			   size_t *in_pos, size_t in_size)
 62.2527 -+{
 62.2528 -+	uint8_t byte;
 62.2529 -+
 62.2530 -+	if (s->pos == 0)
 62.2531 -+		s->vli = 0;
 62.2532 -+
 62.2533 -+	while (*in_pos < in_size) {
 62.2534 -+		byte = in[*in_pos];
 62.2535 -+		++*in_pos;
 62.2536 -+
 62.2537 -+		s->vli |= (vli_type)(byte & 0x7F) << s->pos;
 62.2538 -+
 62.2539 -+		if ((byte & 0x80) == 0) {
 62.2540 -+			/* Don't allow non-minimal encodings. */
 62.2541 -+			if (byte == 0 && s->pos != 0)
 62.2542 -+				return XZ_DATA_ERROR;
 62.2543 -+
 62.2544 -+			s->pos = 0;
 62.2545 -+			return XZ_STREAM_END;
 62.2546 -+		}
 62.2547 -+
 62.2548 -+		s->pos += 7;
 62.2549 -+		if (s->pos == 7 * VLI_BYTES_MAX)
 62.2550 -+			return XZ_DATA_ERROR;
 62.2551 -+	}
 62.2552 -+
 62.2553 -+	return XZ_OK;
 62.2554 -+}
 62.2555 -+
 62.2556 -+/*
 62.2557 -+ * Decode the Compressed Data field from a Block. Update and validate
 62.2558 -+ * the observed compressed and uncompressed sizes of the Block so that
 62.2559 -+ * they don't exceed the values possibly stored in the Block Header
 62.2560 -+ * (validation assumes that no integer overflow occurs, since vli_type
 62.2561 -+ * is normally uint64_t). Update the CRC32 if presence of the CRC32
 62.2562 -+ * field was indicated in Stream Header.
 62.2563 -+ *
 62.2564 -+ * Once the decoding is finished, validate that the observed sizes match
 62.2565 -+ * the sizes possibly stored in the Block Header. Update the hash and
 62.2566 -+ * Block count, which are later used to validate the Index field.
 62.2567 -+ */
 62.2568 -+static enum xz_ret dec_block(struct xz_dec *s, struct xz_buf *b)
 62.2569 -+{
 62.2570 -+	enum xz_ret ret;
 62.2571 -+
 62.2572 -+	s->in_start = b->in_pos;
 62.2573 -+	s->out_start = b->out_pos;
 62.2574 -+
 62.2575 -+#ifdef XZ_DEC_BCJ
 62.2576 -+	if (s->bcj_active)
 62.2577 -+		ret = xz_dec_bcj_run(s->bcj, s->lzma2, b);
 62.2578 -+	else
 62.2579 -+#endif
 62.2580 -+		ret = xz_dec_lzma2_run(s->lzma2, b);
 62.2581 -+
 62.2582 -+	s->block.compressed += b->in_pos - s->in_start;
 62.2583 -+	s->block.uncompressed += b->out_pos - s->out_start;
 62.2584 -+
 62.2585 -+	/*
 62.2586 -+	 * There is no need to separately check for VLI_UNKNOWN, since
 62.2587 -+	 * the observed sizes are always smaller than VLI_UNKNOWN.
 62.2588 -+	 */
 62.2589 -+	if (s->block.compressed > s->block_header.compressed
 62.2590 -+			|| s->block.uncompressed
 62.2591 -+				> s->block_header.uncompressed)
 62.2592 -+		return XZ_DATA_ERROR;
 62.2593 -+
 62.2594 -+	if (s->check_type == XZ_CHECK_CRC32)
 62.2595 -+		s->crc32 = xz_crc32(b->out + s->out_start,
 62.2596 -+				b->out_pos - s->out_start, s->crc32);
 62.2597 -+
 62.2598 -+	if (ret == XZ_STREAM_END) {
 62.2599 -+		if (s->block_header.compressed != VLI_UNKNOWN
 62.2600 -+				&& s->block_header.compressed
 62.2601 -+					!= s->block.compressed)
 62.2602 -+			return XZ_DATA_ERROR;
 62.2603 -+
 62.2604 -+		if (s->block_header.uncompressed != VLI_UNKNOWN
 62.2605 -+				&& s->block_header.uncompressed
 62.2606 -+					!= s->block.uncompressed)
 62.2607 -+			return XZ_DATA_ERROR;
 62.2608 -+
 62.2609 -+		s->block.hash.unpadded += s->block_header.size
 62.2610 -+				+ s->block.compressed;
 62.2611 -+
 62.2612 -+#ifdef XZ_DEC_ANY_CHECK
 62.2613 -+		s->block.hash.unpadded += check_sizes[s->check_type];
 62.2614 -+#else
 62.2615 -+		if (s->check_type == XZ_CHECK_CRC32)
 62.2616 -+			s->block.hash.unpadded += 4;
 62.2617 -+#endif
 62.2618 -+
 62.2619 -+		s->block.hash.uncompressed += s->block.uncompressed;
 62.2620 -+		s->block.hash.crc32 = xz_crc32(
 62.2621 -+				(const uint8_t *)&s->block.hash,
 62.2622 -+				sizeof(s->block.hash), s->block.hash.crc32);
 62.2623 -+
 62.2624 -+		++s->block.count;
 62.2625 -+	}
 62.2626 -+
 62.2627 -+	return ret;
 62.2628 -+}
 62.2629 -+
 62.2630 -+/* Update the Index size and the CRC32 value. */
 62.2631 -+static void index_update(struct xz_dec *s, const struct xz_buf *b)
 62.2632 -+{
 62.2633 -+	size_t in_used = b->in_pos - s->in_start;
 62.2634 -+	s->index.size += in_used;
 62.2635 -+	s->crc32 = xz_crc32(b->in + s->in_start, in_used, s->crc32);
 62.2636 -+}
 62.2637 -+
 62.2638 -+/*
 62.2639 -+ * Decode the Number of Records, Unpadded Size, and Uncompressed Size
 62.2640 -+ * fields from the Index field. That is, Index Padding and CRC32 are not
 62.2641 -+ * decoded by this function.
 62.2642 -+ *
 62.2643 -+ * This can return XZ_OK (more input needed), XZ_STREAM_END (everything
 62.2644 -+ * successfully decoded), or XZ_DATA_ERROR (input is corrupt).
 62.2645 -+ */
 62.2646 -+static enum xz_ret dec_index(struct xz_dec *s, struct xz_buf *b)
 62.2647 -+{
 62.2648 -+	enum xz_ret ret;
 62.2649 -+
 62.2650 -+	do {
 62.2651 -+		ret = dec_vli(s, b->in, &b->in_pos, b->in_size);
 62.2652 -+		if (ret != XZ_STREAM_END) {
 62.2653 -+			index_update(s, b);
 62.2654 -+			return ret;
 62.2655 -+		}
 62.2656 -+
 62.2657 -+		switch (s->index.sequence) {
 62.2658 -+		case SEQ_INDEX_COUNT:
 62.2659 -+			s->index.count = s->vli;
 62.2660 -+
 62.2661 -+			/*
 62.2662 -+			 * Validate that the Number of Records field
 62.2663 -+			 * indicates the same number of Records as
 62.2664 -+			 * there were Blocks in the Stream.
 62.2665 -+			 */
 62.2666 -+			if (s->index.count != s->block.count)
 62.2667 -+				return XZ_DATA_ERROR;
 62.2668 -+
 62.2669 -+			s->index.sequence = SEQ_INDEX_UNPADDED;
 62.2670 -+			break;
 62.2671 -+
 62.2672 -+		case SEQ_INDEX_UNPADDED:
 62.2673 -+			s->index.hash.unpadded += s->vli;
 62.2674 -+			s->index.sequence = SEQ_INDEX_UNCOMPRESSED;
 62.2675 -+			break;
 62.2676 -+
 62.2677 -+		case SEQ_INDEX_UNCOMPRESSED:
 62.2678 -+			s->index.hash.uncompressed += s->vli;
 62.2679 -+			s->index.hash.crc32 = xz_crc32(
 62.2680 -+					(const uint8_t *)&s->index.hash,
 62.2681 -+					sizeof(s->index.hash),
 62.2682 -+					s->index.hash.crc32);
 62.2683 -+			--s->index.count;
 62.2684 -+			s->index.sequence = SEQ_INDEX_UNPADDED;
 62.2685 -+			break;
 62.2686 -+		}
 62.2687 -+	} while (s->index.count > 0);
 62.2688 -+
 62.2689 -+	return XZ_STREAM_END;
 62.2690 -+}
 62.2691 -+
 62.2692 -+/*
 62.2693 -+ * Validate that the next four input bytes match the value of s->crc32.
 62.2694 -+ * s->pos must be zero when starting to validate the first byte.
 62.2695 -+ */
 62.2696 -+static enum xz_ret crc32_validate(struct xz_dec *s, struct xz_buf *b)
 62.2697 -+{
 62.2698 -+	do {
 62.2699 -+		if (b->in_pos == b->in_size)
 62.2700 -+			return XZ_OK;
 62.2701 -+
 62.2702 -+		if (((s->crc32 >> s->pos) & 0xFF) != b->in[b->in_pos++])
 62.2703 -+			return XZ_DATA_ERROR;
 62.2704 -+
 62.2705 -+		s->pos += 8;
 62.2706 -+
 62.2707 -+	} while (s->pos < 32);
 62.2708 -+
 62.2709 -+	s->crc32 = 0;
 62.2710 -+	s->pos = 0;
 62.2711 -+
 62.2712 -+	return XZ_STREAM_END;
 62.2713 -+}
 62.2714 -+
 62.2715 -+#ifdef XZ_DEC_ANY_CHECK
 62.2716 -+/*
 62.2717 -+ * Skip over the Check field when the Check ID is not supported.
 62.2718 -+ * Returns true once the whole Check field has been skipped over.
 62.2719 -+ */
 62.2720 -+static bool check_skip(struct xz_dec *s, struct xz_buf *b)
 62.2721 -+{
 62.2722 -+	while (s->pos < check_sizes[s->check_type]) {
 62.2723 -+		if (b->in_pos == b->in_size)
 62.2724 -+			return false;
 62.2725 -+
 62.2726 -+		++b->in_pos;
 62.2727 -+		++s->pos;
 62.2728 -+	}
 62.2729 -+
 62.2730 -+	s->pos = 0;
 62.2731 -+
 62.2732 -+	return true;
 62.2733 -+}
 62.2734 -+#endif
 62.2735 -+
 62.2736 -+/* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */
 62.2737 -+static enum xz_ret dec_stream_header(struct xz_dec *s)
 62.2738 -+{
 62.2739 -+	if (!memeq(s->temp.buf, HEADER_MAGIC, HEADER_MAGIC_SIZE))
 62.2740 -+		return XZ_FORMAT_ERROR;
 62.2741 -+
 62.2742 -+	if (xz_crc32(s->temp.buf + HEADER_MAGIC_SIZE, 2, 0)
 62.2743 -+			!= get_le32(s->temp.buf + HEADER_MAGIC_SIZE + 2))
 62.2744 -+		return XZ_DATA_ERROR;
 62.2745 -+
 62.2746 -+	if (s->temp.buf[HEADER_MAGIC_SIZE] != 0)
 62.2747 -+		return XZ_OPTIONS_ERROR;
 62.2748 -+
 62.2749 -+	/*
 62.2750 -+	 * Of integrity checks, we support only none (Check ID = 0) and
 62.2751 -+	 * CRC32 (Check ID = 1). However, if XZ_DEC_ANY_CHECK is defined,
 62.2752 -+	 * we will accept other check types too, but then the check won't
 62.2753 -+	 * be verified and a warning (XZ_UNSUPPORTED_CHECK) will be given.
 62.2754 -+	 */
 62.2755 -+	s->check_type = s->temp.buf[HEADER_MAGIC_SIZE + 1];
 62.2756 -+
 62.2757 -+#ifdef XZ_DEC_ANY_CHECK
 62.2758 -+	if (s->check_type > XZ_CHECK_MAX)
 62.2759 -+		return XZ_OPTIONS_ERROR;
 62.2760 -+
 62.2761 -+	if (s->check_type > XZ_CHECK_CRC32)
 62.2762 -+		return XZ_UNSUPPORTED_CHECK;
 62.2763 -+#else
 62.2764 -+	if (s->check_type > XZ_CHECK_CRC32)
 62.2765 -+		return XZ_OPTIONS_ERROR;
 62.2766 -+#endif
 62.2767 -+
 62.2768 -+	return XZ_OK;
 62.2769 -+}
 62.2770 -+
 62.2771 -+/* Decode the Stream Footer field (the last 12 bytes of the .xz Stream) */
 62.2772 -+static enum xz_ret dec_stream_footer(struct xz_dec *s)
 62.2773 -+{
 62.2774 -+	if (!memeq(s->temp.buf + 10, FOOTER_MAGIC, FOOTER_MAGIC_SIZE))
 62.2775 -+		return XZ_DATA_ERROR;
 62.2776 -+
 62.2777 -+	if (xz_crc32(s->temp.buf + 4, 6, 0) != get_le32(s->temp.buf))
 62.2778 -+		return XZ_DATA_ERROR;
 62.2779 -+
 62.2780 -+	/*
 62.2781 -+	 * Validate Backward Size. Note that we never added the size of the
 62.2782 -+	 * Index CRC32 field to s->index.size, thus we use s->index.size / 4
 62.2783 -+	 * instead of s->index.size / 4 - 1.
 62.2784 -+	 */
 62.2785 -+	if ((s->index.size >> 2) != get_le32(s->temp.buf + 4))
 62.2786 -+		return XZ_DATA_ERROR;
 62.2787 -+
 62.2788 -+	if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->check_type)
 62.2789 -+		return XZ_DATA_ERROR;
 62.2790 -+
 62.2791 -+	/*
 62.2792 -+	 * Use XZ_STREAM_END instead of XZ_OK to be more convenient
 62.2793 -+	 * for the caller.
 62.2794 -+	 */
 62.2795 -+	return XZ_STREAM_END;
 62.2796 -+}
 62.2797 -+
 62.2798 -+/* Decode the Block Header and initialize the filter chain. */
 62.2799 -+static enum xz_ret dec_block_header(struct xz_dec *s)
 62.2800 -+{
 62.2801 -+	enum xz_ret ret;
 62.2802 -+
 62.2803 -+	/*
 62.2804 -+	 * Validate the CRC32. We know that the temp buffer is at least
 62.2805 -+	 * eight bytes so this is safe.
 62.2806 -+	 */
 62.2807 -+	s->temp.size -= 4;
 62.2808 -+	if (xz_crc32(s->temp.buf, s->temp.size, 0)
 62.2809 -+			!= get_le32(s->temp.buf + s->temp.size))
 62.2810 -+		return XZ_DATA_ERROR;
 62.2811 -+
 62.2812 -+	s->temp.pos = 2;
 62.2813 -+
 62.2814 -+	/*
 62.2815 -+	 * Catch unsupported Block Flags. We support only one or two filters
 62.2816 -+	 * in the chain, so we catch that with the same test.
 62.2817 -+	 */
 62.2818 -+#ifdef XZ_DEC_BCJ
 62.2819 -+	if (s->temp.buf[1] & 0x3E)
 62.2820 -+#else
 62.2821 -+	if (s->temp.buf[1] & 0x3F)
 62.2822 -+#endif
 62.2823 -+		return XZ_OPTIONS_ERROR;
 62.2824 -+
 62.2825 -+	/* Compressed Size */
 62.2826 -+	if (s->temp.buf[1] & 0x40) {
 62.2827 -+		if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
 62.2828 -+					!= XZ_STREAM_END)
 62.2829 -+			return XZ_DATA_ERROR;
 62.2830 -+
 62.2831 -+		s->block_header.compressed = s->vli;
 62.2832 -+	} else {
 62.2833 -+		s->block_header.compressed = VLI_UNKNOWN;
 62.2834 -+	}
 62.2835 -+
 62.2836 -+	/* Uncompressed Size */
 62.2837 -+	if (s->temp.buf[1] & 0x80) {
 62.2838 -+		if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
 62.2839 -+				!= XZ_STREAM_END)
 62.2840 -+			return XZ_DATA_ERROR;
 62.2841 -+
 62.2842 -+		s->block_header.uncompressed = s->vli;
 62.2843 -+	} else {
 62.2844 -+		s->block_header.uncompressed = VLI_UNKNOWN;
 62.2845 -+	}
 62.2846 -+
 62.2847 -+#ifdef XZ_DEC_BCJ
 62.2848 -+	/* If there are two filters, the first one must be a BCJ filter. */
 62.2849 -+	s->bcj_active = s->temp.buf[1] & 0x01;
 62.2850 -+	if (s->bcj_active) {
 62.2851 -+		if (s->temp.size - s->temp.pos < 2)
 62.2852 -+			return XZ_OPTIONS_ERROR;
 62.2853 -+
 62.2854 -+		ret = xz_dec_bcj_reset(s->bcj, s->temp.buf[s->temp.pos++]);
 62.2855 -+		if (ret != XZ_OK)
 62.2856 -+			return ret;
 62.2857 -+
 62.2858 -+		/*
 62.2859 -+		 * We don't support custom start offset,
 62.2860 -+		 * so Size of Properties must be zero.
 62.2861 -+		 */
 62.2862 -+		if (s->temp.buf[s->temp.pos++] != 0x00)
 62.2863 -+			return XZ_OPTIONS_ERROR;
 62.2864 -+	}
 62.2865 -+#endif
 62.2866 -+
 62.2867 -+	/* Valid Filter Flags always take at least two bytes. */
 62.2868 -+	if (s->temp.size - s->temp.pos < 2)
 62.2869 -+		return XZ_DATA_ERROR;
 62.2870 -+
 62.2871 -+	/* Filter ID = LZMA2 */
 62.2872 -+	if (s->temp.buf[s->temp.pos++] != 0x21)
 62.2873 -+		return XZ_OPTIONS_ERROR;
 62.2874 -+
 62.2875 -+	/* Size of Properties = 1-byte Filter Properties */
 62.2876 -+	if (s->temp.buf[s->temp.pos++] != 0x01)
 62.2877 -+		return XZ_OPTIONS_ERROR;
 62.2878 -+
 62.2879 -+	/* Filter Properties contains LZMA2 dictionary size. */
 62.2880 -+	if (s->temp.size - s->temp.pos < 1)
 62.2881 -+		return XZ_DATA_ERROR;
 62.2882 -+
 62.2883 -+	ret = xz_dec_lzma2_reset(s->lzma2, s->temp.buf[s->temp.pos++]);
 62.2884 -+	if (ret != XZ_OK)
 62.2885 -+		return ret;
 62.2886 -+
 62.2887 -+	/* The rest must be Header Padding. */
 62.2888 -+	while (s->temp.pos < s->temp.size)
 62.2889 -+		if (s->temp.buf[s->temp.pos++] != 0x00)
 62.2890 -+			return XZ_OPTIONS_ERROR;
 62.2891 -+
 62.2892 -+	s->temp.pos = 0;
 62.2893 -+	s->block.compressed = 0;
 62.2894 -+	s->block.uncompressed = 0;
 62.2895 -+
 62.2896 -+	return XZ_OK;
 62.2897 -+}
 62.2898 -+
 62.2899 -+static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 62.2900 -+{
 62.2901 -+	enum xz_ret ret;
 62.2902 -+
 62.2903 -+	/*
 62.2904 -+	 * Store the start position for the case when we are in the middle
 62.2905 -+	 * of the Index field.
 62.2906 -+	 */
 62.2907 -+	s->in_start = b->in_pos;
 62.2908 -+
 62.2909 -+	while (true) {
 62.2910 -+		switch (s->sequence) {
 62.2911 -+		case SEQ_STREAM_HEADER:
 62.2912 -+			/*
 62.2913 -+			 * Stream Header is copied to s->temp, and then
 62.2914 -+			 * decoded from there. This way if the caller
 62.2915 -+			 * gives us only little input at a time, we can
 62.2916 -+			 * still keep the Stream Header decoding code
 62.2917 -+			 * simple. Similar approach is used in many places
 62.2918 -+			 * in this file.
 62.2919 -+			 */
 62.2920 -+			if (!fill_temp(s, b))
 62.2921 -+				return XZ_OK;
 62.2922 -+
 62.2923 -+			/*
 62.2924 -+			 * If dec_stream_header() returns
 62.2925 -+			 * XZ_UNSUPPORTED_CHECK, it is still possible
 62.2926 -+			 * to continue decoding if working in multi-call
 62.2927 -+			 * mode. Thus, update s->sequence before calling
 62.2928 -+			 * dec_stream_header().
 62.2929 -+			 */
 62.2930 -+			s->sequence = SEQ_BLOCK_START;
 62.2931 -+
 62.2932 -+			ret = dec_stream_header(s);
 62.2933 -+			if (ret != XZ_OK)
 62.2934 -+				return ret;
 62.2935 -+
 62.2936 -+		case SEQ_BLOCK_START:
 62.2937 -+			/* We need one byte of input to continue. */
 62.2938 -+			if (b->in_pos == b->in_size)
 62.2939 -+				return XZ_OK;
 62.2940 -+
 62.2941 -+			/* See if this is the beginning of the Index field. */
 62.2942 -+			if (b->in[b->in_pos] == 0) {
 62.2943 -+				s->in_start = b->in_pos++;
 62.2944 -+				s->sequence = SEQ_INDEX;
 62.2945 -+				break;
 62.2946 -+			}
 62.2947 -+
 62.2948 -+			/*
 62.2949 -+			 * Calculate the size of the Block Header and
 62.2950 -+			 * prepare to decode it.
 62.2951 -+			 */
 62.2952 -+			s->block_header.size
 62.2953 -+				= ((uint32_t)b->in[b->in_pos] + 1) * 4;
 62.2954 -+
 62.2955 -+			s->temp.size = s->block_header.size;
 62.2956 -+			s->temp.pos = 0;
 62.2957 -+			s->sequence = SEQ_BLOCK_HEADER;
 62.2958 -+
 62.2959 -+		case SEQ_BLOCK_HEADER:
 62.2960 -+			if (!fill_temp(s, b))
 62.2961 -+				return XZ_OK;
 62.2962 -+
 62.2963 -+			ret = dec_block_header(s);
 62.2964 -+			if (ret != XZ_OK)
 62.2965 -+				return ret;
 62.2966 -+
 62.2967 -+			s->sequence = SEQ_BLOCK_UNCOMPRESS;
 62.2968 -+
 62.2969 -+		case SEQ_BLOCK_UNCOMPRESS:
 62.2970 -+			ret = dec_block(s, b);
 62.2971 -+			if (ret != XZ_STREAM_END)
 62.2972 -+				return ret;
 62.2973 -+
 62.2974 -+			s->sequence = SEQ_BLOCK_PADDING;
 62.2975 -+
 62.2976 -+		case SEQ_BLOCK_PADDING:
 62.2977 -+			/*
 62.2978 -+			 * Size of Compressed Data + Block Padding
 62.2979 -+			 * must be a multiple of four. We don't need
 62.2980 -+			 * s->block.compressed for anything else
 62.2981 -+			 * anymore, so we use it here to test the size
 62.2982 -+			 * of the Block Padding field.
 62.2983 -+			 */
 62.2984 -+			while (s->block.compressed & 3) {
 62.2985 -+				if (b->in_pos == b->in_size)
 62.2986 -+					return XZ_OK;
 62.2987 -+
 62.2988 -+				if (b->in[b->in_pos++] != 0)
 62.2989 -+					return XZ_DATA_ERROR;
 62.2990 -+
 62.2991 -+				++s->block.compressed;
 62.2992 -+			}
 62.2993 -+
 62.2994 -+			s->sequence = SEQ_BLOCK_CHECK;
 62.2995 -+
 62.2996 -+		case SEQ_BLOCK_CHECK:
 62.2997 -+			if (s->check_type == XZ_CHECK_CRC32) {
 62.2998 -+				ret = crc32_validate(s, b);
 62.2999 -+				if (ret != XZ_STREAM_END)
 62.3000 -+					return ret;
 62.3001 -+			}
 62.3002 -+#ifdef XZ_DEC_ANY_CHECK
 62.3003 -+			else if (!check_skip(s, b)) {
 62.3004 -+				return XZ_OK;
 62.3005 -+			}
 62.3006 -+#endif
 62.3007 -+
 62.3008 -+			s->sequence = SEQ_BLOCK_START;
 62.3009 -+			break;
 62.3010 -+
 62.3011 -+		case SEQ_INDEX:
 62.3012 -+			ret = dec_index(s, b);
 62.3013 -+			if (ret != XZ_STREAM_END)
 62.3014 -+				return ret;
 62.3015 -+
 62.3016 -+			s->sequence = SEQ_INDEX_PADDING;
 62.3017 -+
 62.3018 -+		case SEQ_INDEX_PADDING:
 62.3019 -+			while ((s->index.size + (b->in_pos - s->in_start))
 62.3020 -+					& 3) {
 62.3021 -+				if (b->in_pos == b->in_size) {
 62.3022 -+					index_update(s, b);
 62.3023 -+					return XZ_OK;
 62.3024 -+				}
 62.3025 -+
 62.3026 -+				if (b->in[b->in_pos++] != 0)
 62.3027 -+					return XZ_DATA_ERROR;
 62.3028 -+			}
 62.3029 -+
 62.3030 -+			/* Finish the CRC32 value and Index size. */
 62.3031 -+			index_update(s, b);
 62.3032 -+
 62.3033 -+			/* Compare the hashes to validate the Index field. */
 62.3034 -+			if (!memeq(&s->block.hash, &s->index.hash,
 62.3035 -+					sizeof(s->block.hash)))
 62.3036 -+				return XZ_DATA_ERROR;
 62.3037 -+
 62.3038 -+			s->sequence = SEQ_INDEX_CRC32;
 62.3039 -+
 62.3040 -+		case SEQ_INDEX_CRC32:
 62.3041 -+			ret = crc32_validate(s, b);
 62.3042 -+			if (ret != XZ_STREAM_END)
 62.3043 -+				return ret;
 62.3044 -+
 62.3045 -+			s->temp.size = STREAM_HEADER_SIZE;
 62.3046 -+			s->sequence = SEQ_STREAM_FOOTER;
 62.3047 -+
 62.3048 -+		case SEQ_STREAM_FOOTER:
 62.3049 -+			if (!fill_temp(s, b))
 62.3050 -+				return XZ_OK;
 62.3051 -+
 62.3052 -+			return dec_stream_footer(s);
 62.3053 -+		}
 62.3054 -+	}
 62.3055 -+
 62.3056 -+	/* Never reached */
 62.3057 -+}
 62.3058 -+
 62.3059 -+/*
 62.3060 -+ * xz_dec_run() is a wrapper for dec_main() to handle some special cases in
 62.3061 -+ * multi-call and single-call decoding.
 62.3062 -+ *
 62.3063 -+ * In multi-call mode, we must return XZ_BUF_ERROR when it seems clear that we
 62.3064 -+ * are not going to make any progress anymore. This is to prevent the caller
 62.3065 -+ * from calling us infinitely when the input file is truncated or otherwise
 62.3066 -+ * corrupt. Since zlib-style API allows that the caller fills the input buffer
 62.3067 -+ * only when the decoder doesn't produce any new output, we have to be careful
 62.3068 -+ * to avoid returning XZ_BUF_ERROR too easily: XZ_BUF_ERROR is returned only
 62.3069 -+ * after the second consecutive call to xz_dec_run() that makes no progress.
 62.3070 -+ *
 62.3071 -+ * In single-call mode, if we couldn't decode everything and no error
 62.3072 -+ * occurred, either the input is truncated or the output buffer is too small.
 62.3073 -+ * Since we know that the last input byte never produces any output, we know
 62.3074 -+ * that if all the input was consumed and decoding wasn't finished, the file
 62.3075 -+ * must be corrupt. Otherwise the output buffer has to be too small or the
 62.3076 -+ * file is corrupt in a way that decoding it produces too big output.
 62.3077 -+ *
 62.3078 -+ * If single-call decoding fails, we reset b->in_pos and b->out_pos back to
 62.3079 -+ * their original values. This is because with some filter chains there won't
 62.3080 -+ * be any valid uncompressed data in the output buffer unless the decoding
 62.3081 -+ * actually succeeds (that's the price to pay of using the output buffer as
 62.3082 -+ * the workspace).
 62.3083 -+ */
 62.3084 -+XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b)
 62.3085 -+{
 62.3086 -+	size_t in_start;
 62.3087 -+	size_t out_start;
 62.3088 -+	enum xz_ret ret;
 62.3089 -+
 62.3090 -+	if (DEC_IS_SINGLE(s->mode))
 62.3091 -+		xz_dec_reset(s);
 62.3092 -+
 62.3093 -+	in_start = b->in_pos;
 62.3094 -+	out_start = b->out_pos;
 62.3095 -+	ret = dec_main(s, b);
 62.3096 -+
 62.3097 -+	if (DEC_IS_SINGLE(s->mode)) {
 62.3098 -+		if (ret == XZ_OK)
 62.3099 -+			ret = b->in_pos == b->in_size
 62.3100 -+					? XZ_DATA_ERROR : XZ_BUF_ERROR;
 62.3101 -+
 62.3102 -+		if (ret != XZ_STREAM_END) {
 62.3103 -+			b->in_pos = in_start;
 62.3104 -+			b->out_pos = out_start;
 62.3105 -+		}
 62.3106 -+
 62.3107 -+	} else if (ret == XZ_OK && in_start == b->in_pos
 62.3108 -+			&& out_start == b->out_pos) {
 62.3109 -+		if (s->allow_buf_error)
 62.3110 -+			ret = XZ_BUF_ERROR;
 62.3111 -+
 62.3112 -+		s->allow_buf_error = true;
 62.3113 -+	} else {
 62.3114 -+		s->allow_buf_error = false;
 62.3115 -+	}
 62.3116 -+
 62.3117 -+	return ret;
 62.3118 -+}
 62.3119 -+
 62.3120 -+XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max)
 62.3121 -+{
 62.3122 -+	struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL);
 62.3123 -+	if (s == NULL)
 62.3124 -+		return NULL;
 62.3125 -+
 62.3126 -+	s->mode = mode;
 62.3127 -+
 62.3128 -+#ifdef XZ_DEC_BCJ
 62.3129 -+	s->bcj = xz_dec_bcj_create(DEC_IS_SINGLE(mode));
 62.3130 -+	if (s->bcj == NULL)
 62.3131 -+		goto error_bcj;
 62.3132 -+#endif
 62.3133 -+
 62.3134 -+	s->lzma2 = xz_dec_lzma2_create(mode, dict_max);
 62.3135 -+	if (s->lzma2 == NULL)
 62.3136 -+		goto error_lzma2;
 62.3137 -+
 62.3138 -+	xz_dec_reset(s);
 62.3139 -+	return s;
 62.3140 -+
 62.3141 -+error_lzma2:
 62.3142 -+#ifdef XZ_DEC_BCJ
 62.3143 -+	xz_dec_bcj_end(s->bcj);
 62.3144 -+error_bcj:
 62.3145 -+#endif
 62.3146 -+	kfree(s);
 62.3147 -+	return NULL;
 62.3148 -+}
 62.3149 -+
 62.3150 -+XZ_EXTERN void xz_dec_reset(struct xz_dec *s)
 62.3151 -+{
 62.3152 -+	s->sequence = SEQ_STREAM_HEADER;
 62.3153 -+	s->allow_buf_error = false;
 62.3154 -+	s->pos = 0;
 62.3155 -+	s->crc32 = 0;
 62.3156 -+	memzero(&s->block, sizeof(s->block));
 62.3157 -+	memzero(&s->index, sizeof(s->index));
 62.3158 -+	s->temp.pos = 0;
 62.3159 -+	s->temp.size = STREAM_HEADER_SIZE;
 62.3160 -+}
 62.3161 -+
 62.3162 -+XZ_EXTERN void xz_dec_end(struct xz_dec *s)
 62.3163 -+{
 62.3164 -+	if (s != NULL) {
 62.3165 -+		xz_dec_lzma2_end(s->lzma2);
 62.3166 -+#ifdef XZ_DEC_BCJ
 62.3167 -+		xz_dec_bcj_end(s->bcj);
 62.3168 -+#endif
 62.3169 -+		kfree(s);
 62.3170 -+	}
 62.3171 -+}
 62.3172 -diff --git a/lib/xz/xz_dec_syms.c b/lib/xz/xz_dec_syms.c
 62.3173 -new file mode 100644
 62.3174 -index 0000000..32eb3c0
 62.3175 ---- /dev/null
 62.3176 -+++ b/lib/xz/xz_dec_syms.c
 62.3177 -@@ -0,0 +1,26 @@
 62.3178 -+/*
 62.3179 -+ * XZ decoder module information
 62.3180 -+ *
 62.3181 -+ * Author: Lasse Collin <lasse.collin@tukaani.org>
 62.3182 -+ *
 62.3183 -+ * This file has been put into the public domain.
 62.3184 -+ * You can do whatever you want with this file.
 62.3185 -+ */
 62.3186 -+
 62.3187 -+#include <linux/module.h>
 62.3188 -+#include <linux/xz.h>
 62.3189 -+
 62.3190 -+EXPORT_SYMBOL(xz_dec_init);
 62.3191 -+EXPORT_SYMBOL(xz_dec_reset);
 62.3192 -+EXPORT_SYMBOL(xz_dec_run);
 62.3193 -+EXPORT_SYMBOL(xz_dec_end);
 62.3194 -+
 62.3195 -+MODULE_DESCRIPTION("XZ decompressor");
 62.3196 -+MODULE_VERSION("1.0");
 62.3197 -+MODULE_AUTHOR("Lasse Collin <lasse.collin@tukaani.org> and Igor Pavlov");
 62.3198 -+
 62.3199 -+/*
 62.3200 -+ * This code is in the public domain, but in Linux it's simplest to just
 62.3201 -+ * say it's GPL and consider the authors as the copyright holders.
 62.3202 -+ */
 62.3203 -+MODULE_LICENSE("GPL");
 62.3204 -diff --git a/lib/xz/xz_dec_test.c b/lib/xz/xz_dec_test.c
 62.3205 -new file mode 100644
 62.3206 -index 0000000..da28a19
 62.3207 ---- /dev/null
 62.3208 -+++ b/lib/xz/xz_dec_test.c
 62.3209 -@@ -0,0 +1,220 @@
 62.3210 -+/*
 62.3211 -+ * XZ decoder tester
 62.3212 -+ *
 62.3213 -+ * Author: Lasse Collin <lasse.collin@tukaani.org>
 62.3214 -+ *
 62.3215 -+ * This file has been put into the public domain.
 62.3216 -+ * You can do whatever you want with this file.
 62.3217 -+ */
 62.3218 -+
 62.3219 -+#include <linux/kernel.h>
 62.3220 -+#include <linux/module.h>
 62.3221 -+#include <linux/fs.h>
 62.3222 -+#include <linux/uaccess.h>
 62.3223 -+#include <linux/crc32.h>
 62.3224 -+#include <linux/xz.h>
 62.3225 -+
 62.3226 -+/* Maximum supported dictionary size */
 62.3227 -+#define DICT_MAX (1 << 20)
 62.3228 -+
 62.3229 -+/* Device name to pass to register_chrdev(). */
 62.3230 -+#define DEVICE_NAME "xz_dec_test"
 62.3231 -+
 62.3232 -+/* Dynamically allocated device major number */
 62.3233 -+static int device_major;
 62.3234 -+
 62.3235 -+/*
 62.3236 -+ * We reuse the same decoder state, and thus can decode only one
 62.3237 -+ * file at a time.
 62.3238 -+ */
 62.3239 -+static bool device_is_open;
 62.3240 -+
 62.3241 -+/* XZ decoder state */
 62.3242 -+static struct xz_dec *state;
 62.3243 -+
 62.3244 -+/*
 62.3245 -+ * Return value of xz_dec_run(). We need to avoid calling xz_dec_run() after
 62.3246 -+ * it has returned XZ_STREAM_END, so we make this static.
 62.3247 -+ */
 62.3248 -+static enum xz_ret ret;
 62.3249 -+
 62.3250 -+/*
 62.3251 -+ * Input and output buffers. The input buffer is used as a temporary safe
 62.3252 -+ * place for the data coming from the userspace.
 62.3253 -+ */
 62.3254 -+static uint8_t buffer_in[1024];
 62.3255 -+static uint8_t buffer_out[1024];
 62.3256 -+
 62.3257 -+/*
 62.3258 -+ * Structure to pass the input and output buffers to the XZ decoder.
 62.3259 -+ * A few of the fields are never modified so we initialize them here.
 62.3260 -+ */
 62.3261 -+static struct xz_buf buffers = {
 62.3262 -+	.in = buffer_in,
 62.3263 -+	.out = buffer_out,
 62.3264 -+	.out_size = sizeof(buffer_out)
 62.3265 -+};
 62.3266 -+
 62.3267 -+/*
 62.3268 -+ * CRC32 of uncompressed data. This is used to give the user a simple way
 62.3269 -+ * to check that the decoder produces correct output.
 62.3270 -+ */
 62.3271 -+static uint32_t crc;
 62.3272 -+
 62.3273 -+static int xz_dec_test_open(struct inode *i, struct file *f)
 62.3274 -+{
 62.3275 -+	if (device_is_open)
 62.3276 -+		return -EBUSY;
 62.3277 -+
 62.3278 -+	device_is_open = true;
 62.3279 -+
 62.3280 -+	xz_dec_reset(state);
 62.3281 -+	ret = XZ_OK;
 62.3282 -+	crc = 0xFFFFFFFF;
 62.3283 -+
 62.3284 -+	buffers.in_pos = 0;
 62.3285 -+	buffers.in_size = 0;
 62.3286 -+	buffers.out_pos = 0;
 62.3287 -+
 62.3288 -+	printk(KERN_INFO DEVICE_NAME ": opened\n");
 62.3289 -+	return 0;
 62.3290 -+}
 62.3291 -+
 62.3292 -+static int xz_dec_test_release(struct inode *i, struct file *f)
 62.3293 -+{
 62.3294 -+	device_is_open = false;
 62.3295 -+
 62.3296 -+	if (ret == XZ_OK)
 62.3297 -+		printk(KERN_INFO DEVICE_NAME ": input was truncated\n");
 62.3298 -+
 62.3299 -+	printk(KERN_INFO DEVICE_NAME ": closed\n");
 62.3300 -+	return 0;
 62.3301 -+}
 62.3302 -+
 62.3303 -+/*
 62.3304 -+ * Decode the data given to us from the userspace. CRC32 of the uncompressed
 62.3305 -+ * data is calculated and is printed at the end of successful decoding. The
 62.3306 -+ * uncompressed data isn't stored anywhere for further use.
 62.3307 -+ *
 62.3308 -+ * The .xz file must have exactly one Stream and no Stream Padding. The data
 62.3309 -+ * after the first Stream is considered to be garbage.
 62.3310 -+ */
 62.3311 -+static ssize_t xz_dec_test_write(struct file *file, const char __user *buf,
 62.3312 -+				 size_t size, loff_t *pos)
 62.3313 -+{
 62.3314 -+	size_t remaining;
 62.3315 -+
 62.3316 -+	if (ret != XZ_OK) {
 62.3317 -+		if (size > 0)
 62.3318 -+			printk(KERN_INFO DEVICE_NAME ": %zu bytes of "
 62.3319 -+					"garbage at the end of the file\n",
 62.3320 -+					size);
 62.3321 -+
 62.3322 -+		return -ENOSPC;
 62.3323 -+	}
 62.3324 -+
 62.3325 -+	printk(KERN_INFO DEVICE_NAME ": decoding %zu bytes of input\n",
 62.3326 -+			size);
 62.3327 -+
 62.3328 -+	remaining = size;
 62.3329 -+	while ((remaining > 0 || buffers.out_pos == buffers.out_size)
 62.3330 -+			&& ret == XZ_OK) {
 62.3331 -+		if (buffers.in_pos == buffers.in_size) {
 62.3332 -+			buffers.in_pos = 0;
 62.3333 -+			buffers.in_size = min(remaining, sizeof(buffer_in));
 62.3334 -+			if (copy_from_user(buffer_in, buf, buffers.in_size))
 62.3335 -+				return -EFAULT;
 62.3336 -+
 62.3337 -+			buf += buffers.in_size;
 62.3338 -+			remaining -= buffers.in_size;
 62.3339 -+		}
 62.3340 -+
 62.3341 -+		buffers.out_pos = 0;
 62.3342 -+		ret = xz_dec_run(state, &buffers);
 62.3343 -+		crc = crc32(crc, buffer_out, buffers.out_pos);
 62.3344 -+	}
 62.3345 -+
 62.3346 -+	switch (ret) {
 62.3347 -+	case XZ_OK:
 62.3348 -+		printk(KERN_INFO DEVICE_NAME ": XZ_OK\n");
 62.3349 -+		return size;
 62.3350 -+
 62.3351 -+	case XZ_STREAM_END:
 62.3352 -+		printk(KERN_INFO DEVICE_NAME ": XZ_STREAM_END, "
 62.3353 -+				"CRC32 = 0x%08X\n", ~crc);
 62.3354 -+		return size - remaining - (buffers.in_size - buffers.in_pos);
 62.3355 -+
 62.3356 -+	case XZ_MEMLIMIT_ERROR:
 62.3357 -+		printk(KERN_INFO DEVICE_NAME ": XZ_MEMLIMIT_ERROR\n");
 62.3358 -+		break;
 62.3359 -+
 62.3360 -+	case XZ_FORMAT_ERROR:
 62.3361 -+		printk(KERN_INFO DEVICE_NAME ": XZ_FORMAT_ERROR\n");
 62.3362 -+		break;
 62.3363 -+
 62.3364 -+	case XZ_OPTIONS_ERROR:
 62.3365 -+		printk(KERN_INFO DEVICE_NAME ": XZ_OPTIONS_ERROR\n");
 62.3366 -+		break;
 62.3367 -+
 62.3368 -+	case XZ_DATA_ERROR:
 62.3369 -+		printk(KERN_INFO DEVICE_NAME ": XZ_DATA_ERROR\n");
 62.3370 -+		break;
 62.3371 -+
 62.3372 -+	case XZ_BUF_ERROR:
 62.3373 -+		printk(KERN_INFO DEVICE_NAME ": XZ_BUF_ERROR\n");
 62.3374 -+		break;
 62.3375 -+
 62.3376 -+	default:
 62.3377 -+		printk(KERN_INFO DEVICE_NAME ": Bug detected!\n");
 62.3378 -+		break;
 62.3379 -+	}
 62.3380 -+
 62.3381 -+	return -EIO;
 62.3382 -+}
 62.3383 -+
 62.3384 -+/* Allocate the XZ decoder state and register the character device. */
 62.3385 -+static int __init xz_dec_test_init(void)
 62.3386 -+{
 62.3387 -+	static const struct file_operations fileops = {
 62.3388 -+		.owner = THIS_MODULE,
 62.3389 -+		.open = &xz_dec_test_open,
 62.3390 -+		.release = &xz_dec_test_release,
 62.3391 -+		.write = &xz_dec_test_write
 62.3392 -+	};
 62.3393 -+
 62.3394 -+	state = xz_dec_init(XZ_PREALLOC, DICT_MAX);
 62.3395 -+	if (state == NULL)
 62.3396 -+		return -ENOMEM;
 62.3397 -+
 62.3398 -+	device_major = register_chrdev(0, DEVICE_NAME, &fileops);
 62.3399 -+	if (device_major < 0) {
 62.3400 -+		xz_dec_end(state);
 62.3401 -+		return device_major;
 62.3402 -+	}
 62.3403 -+
 62.3404 -+	printk(KERN_INFO DEVICE_NAME ": module loaded\n");
 62.3405 -+	printk(KERN_INFO DEVICE_NAME ": Create a device node with "
 62.3406 -+			"'mknod " DEVICE_NAME " c %d 0' and write .xz files "
 62.3407 -+			"to it.\n", device_major);
 62.3408 -+	return 0;
 62.3409 -+}
 62.3410 -+
 62.3411 -+static void __exit xz_dec_test_exit(void)
 62.3412 -+{
 62.3413 -+	unregister_chrdev(device_major, DEVICE_NAME);
 62.3414 -+	xz_dec_end(state);
 62.3415 -+	printk(KERN_INFO DEVICE_NAME ": module unloaded\n");
 62.3416 -+}
 62.3417 -+
 62.3418 -+module_init(xz_dec_test_init);
 62.3419 -+module_exit(xz_dec_test_exit);
 62.3420 -+
 62.3421 -+MODULE_DESCRIPTION("XZ decompressor tester");
 62.3422 -+MODULE_VERSION("1.0");
 62.3423 -+MODULE_AUTHOR("Lasse Collin <lasse.collin@tukaani.org>");
 62.3424 -+
 62.3425 -+/*
 62.3426 -+ * This code is in the public domain, but in Linux it's simplest to just
 62.3427 -+ * say it's GPL and consider the authors as the copyright holders.
 62.3428 -+ */
 62.3429 -+MODULE_LICENSE("GPL");
 62.3430 -diff --git a/lib/xz/xz_lzma2.h b/lib/xz/xz_lzma2.h
 62.3431 -new file mode 100644
 62.3432 -index 0000000..071d67b
 62.3433 ---- /dev/null
 62.3434 -+++ b/lib/xz/xz_lzma2.h
 62.3435 -@@ -0,0 +1,204 @@
 62.3436 -+/*
 62.3437 -+ * LZMA2 definitions
 62.3438 -+ *
 62.3439 -+ * Authors: Lasse Collin <lasse.collin@tukaani.org>
 62.3440 -+ *          Igor Pavlov <http://7-zip.org/>
 62.3441 -+ *
 62.3442 -+ * This file has been put into the public domain.
 62.3443 -+ * You can do whatever you want with this file.
 62.3444 -+ */
 62.3445 -+
 62.3446 -+#ifndef XZ_LZMA2_H
 62.3447 -+#define XZ_LZMA2_H
 62.3448 -+
 62.3449 -+/* Range coder constants */
 62.3450 -+#define RC_SHIFT_BITS 8
 62.3451 -+#define RC_TOP_BITS 24
 62.3452 -+#define RC_TOP_VALUE (1 << RC_TOP_BITS)
 62.3453 -+#define RC_BIT_MODEL_TOTAL_BITS 11
 62.3454 -+#define RC_BIT_MODEL_TOTAL (1 << RC_BIT_MODEL_TOTAL_BITS)
 62.3455 -+#define RC_MOVE_BITS 5
 62.3456 -+
 62.3457 -+/*
 62.3458 -+ * Maximum number of position states. A position state is the lowest pb
 62.3459 -+ * number of bits of the current uncompressed offset. In some places there
 62.3460 -+ * are different sets of probabilities for different position states.
 62.3461 -+ */
 62.3462 -+#define POS_STATES_MAX (1 << 4)
 62.3463 -+
 62.3464 -+/*
 62.3465 -+ * This enum is used to track which LZMA symbols have occurred most recently
 62.3466 -+ * and in which order. This information is used to predict the next symbol.
 62.3467 -+ *
 62.3468 -+ * Symbols:
 62.3469 -+ *  - Literal: One 8-bit byte
 62.3470 -+ *  - Match: Repeat a chunk of data at some distance
 62.3471 -+ *  - Long repeat: Multi-byte match at a recently seen distance
 62.3472 -+ *  - Short repeat: One-byte repeat at a recently seen distance
 62.3473 -+ *
 62.3474 -+ * The symbol names are in from STATE_oldest_older_previous. REP means
 62.3475 -+ * either short or long repeated match, and NONLIT means any non-literal.
 62.3476 -+ */
 62.3477 -+enum lzma_state {
 62.3478 -+	STATE_LIT_LIT,
 62.3479 -+	STATE_MATCH_LIT_LIT,
 62.3480 -+	STATE_REP_LIT_LIT,
 62.3481 -+	STATE_SHORTREP_LIT_LIT,
 62.3482 -+	STATE_MATCH_LIT,
 62.3483 -+	STATE_REP_LIT,
 62.3484 -+	STATE_SHORTREP_LIT,
 62.3485 -+	STATE_LIT_MATCH,
 62.3486 -+	STATE_LIT_LONGREP,
 62.3487 -+	STATE_LIT_SHORTREP,
 62.3488 -+	STATE_NONLIT_MATCH,
 62.3489 -+	STATE_NONLIT_REP
 62.3490 -+};
 62.3491 -+
 62.3492 -+/* Total number of states */
 62.3493 -+#define STATES 12
 62.3494 -+
 62.3495 -+/* The lowest 7 states indicate that the previous state was a literal. */
 62.3496 -+#define LIT_STATES 7
 62.3497 -+
 62.3498 -+/* Indicate that the latest symbol was a literal. */
 62.3499 -+static inline void lzma_state_literal(enum lzma_state *state)
 62.3500 -+{
 62.3501 -+	if (*state <= STATE_SHORTREP_LIT_LIT)
 62.3502 -+		*state = STATE_LIT_LIT;
 62.3503 -+	else if (*state <= STATE_LIT_SHORTREP)
 62.3504 -+		*state -= 3;
 62.3505 -+	else
 62.3506 -+		*state -= 6;
 62.3507 -+}
 62.3508 -+
 62.3509 -+/* Indicate that the latest symbol was a match. */
 62.3510 -+static inline void lzma_state_match(enum lzma_state *state)
 62.3511 -+{
 62.3512 -+	*state = *state < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH;
 62.3513 -+}
 62.3514 -+
 62.3515 -+/* Indicate that the latest state was a long repeated match. */
 62.3516 -+static inline void lzma_state_long_rep(enum lzma_state *state)
 62.3517 -+{
 62.3518 -+	*state = *state < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP;
 62.3519 -+}
 62.3520 -+
 62.3521 -+/* Indicate that the latest symbol was a short match. */
 62.3522 -+static inline void lzma_state_short_rep(enum lzma_state *state)
 62.3523 -+{
 62.3524 -+	*state = *state < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP;
 62.3525 -+}
 62.3526 -+
 62.3527 -+/* Test if the previous symbol was a literal. */
 62.3528 -+static inline bool lzma_state_is_literal(enum lzma_state state)
 62.3529 -+{
 62.3530 -+	return state < LIT_STATES;
 62.3531 -+}
 62.3532 -+
 62.3533 -+/* Each literal coder is divided in three sections:
 62.3534 -+ *   - 0x001-0x0FF: Without match byte
 62.3535 -+ *   - 0x101-0x1FF: With match byte; match bit is 0
 62.3536 -+ *   - 0x201-0x2FF: With match byte; match bit is 1
 62.3537 -+ *
 62.3538 -+ * Match byte is used when the previous LZMA symbol was something else than
 62.3539 -+ * a literal (that is, it was some kind of match).
 62.3540 -+ */
 62.3541 -+#define LITERAL_CODER_SIZE 0x300
 62.3542 -+
 62.3543 -+/* Maximum number of literal coders */
 62.3544 -+#define LITERAL_CODERS_MAX (1 << 4)
 62.3545 -+
 62.3546 -+/* Minimum length of a match is two bytes. */
 62.3547 -+#define MATCH_LEN_MIN 2
 62.3548 -+
 62.3549 -+/* Match length is encoded with 4, 5, or 10 bits.
 62.3550 -+ *
 62.3551 -+ * Length   Bits
 62.3552 -+ *  2-9      4 = Choice=0 + 3 bits
 62.3553 -+ * 10-17     5 = Choice=1 + Choice2=0 + 3 bits
 62.3554 -+ * 18-273   10 = Choice=1 + Choice2=1 + 8 bits
 62.3555 -+ */
 62.3556 -+#define LEN_LOW_BITS 3
 62.3557 -+#define LEN_LOW_SYMBOLS (1 << LEN_LOW_BITS)
 62.3558 -+#define LEN_MID_BITS 3
 62.3559 -+#define LEN_MID_SYMBOLS (1 << LEN_MID_BITS)
 62.3560 -+#define LEN_HIGH_BITS 8
 62.3561 -+#define LEN_HIGH_SYMBOLS (1 << LEN_HIGH_BITS)
 62.3562 -+#define LEN_SYMBOLS (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS)
 62.3563 -+
 62.3564 -+/*
 62.3565 -+ * Maximum length of a match is 273 which is a result of the encoding
 62.3566 -+ * described above.
 62.3567 -+ */
 62.3568 -+#define MATCH_LEN_MAX (MATCH_LEN_MIN + LEN_SYMBOLS - 1)
 62.3569 -+
 62.3570 -+/*
 62.3571 -+ * Different sets of probabilities are used for match distances that have
 62.3572 -+ * very short match length: Lengths of 2, 3, and 4 bytes have a separate
 62.3573 -+ * set of probabilities for each length. The matches with longer length
 62.3574 -+ * use a shared set of probabilities.
 62.3575 -+ */
 62.3576 -+#define DIST_STATES 4
 62.3577 -+
 62.3578 -+/*
 62.3579 -+ * Get the index of the appropriate probability array for decoding
 62.3580 -+ * the distance slot.
 62.3581 -+ */
 62.3582 -+static inline uint32_t lzma_get_dist_state(uint32_t len)
 62.3583 -+{
 62.3584 -+	return len < DIST_STATES + MATCH_LEN_MIN
 62.3585 -+			? len - MATCH_LEN_MIN : DIST_STATES - 1;
 62.3586 -+}
 62.3587 -+
 62.3588 -+/*
 62.3589 -+ * The highest two bits of a 32-bit match distance are encoded using six bits.
 62.3590 -+ * This six-bit value is called a distance slot. This way encoding a 32-bit
 62.3591 -+ * value takes 6-36 bits, larger values taking more bits.
 62.3592 -+ */
 62.3593 -+#define DIST_SLOT_BITS 6
 62.3594 -+#define DIST_SLOTS (1 << DIST_SLOT_BITS)
 62.3595 -+
 62.3596 -+/* Match distances up to 127 are fully encoded using probabilities. Since
 62.3597 -+ * the highest two bits (distance slot) are always encoded using six bits,
 62.3598 -+ * the distances 0-3 don't need any additional bits to encode, since the
 62.3599 -+ * distance slot itself is the same as the actual distance. DIST_MODEL_START
 62.3600 -+ * indicates the first distance slot where at least one additional bit is
 62.3601 -+ * needed.
 62.3602 -+ */
 62.3603 -+#define DIST_MODEL_START 4
 62.3604 -+
 62.3605 -+/*
 62.3606 -+ * Match distances greater than 127 are encoded in three pieces:
 62.3607 -+ *   - distance slot: the highest two bits
 62.3608 -+ *   - direct bits: 2-26 bits below the highest two bits
 62.3609 -+ *   - alignment bits: four lowest bits
 62.3610 -+ *
 62.3611 -+ * Direct bits don't use any probabilities.
 62.3612 -+ *
 62.3613 -+ * The distance slot value of 14 is for distances 128-191.
 62.3614 -+ */
 62.3615 -+#define DIST_MODEL_END 14
 62.3616 -+
 62.3617 -+/* Distance slots that indicate a distance <= 127. */
 62.3618 -+#define FULL_DISTANCES_BITS (DIST_MODEL_END / 2)
 62.3619 -+#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS)
 62.3620 -+
 62.3621 -+/*
 62.3622 -+ * For match distances greater than 127, only the highest two bits and the
 62.3623 -+ * lowest four bits (alignment) is encoded using probabilities.
 62.3624 -+ */
 62.3625 -+#define ALIGN_BITS 4
 62.3626 -+#define ALIGN_SIZE (1 << ALIGN_BITS)
 62.3627 -+#define ALIGN_MASK (ALIGN_SIZE - 1)
 62.3628 -+
 62.3629 -+/* Total number of all probability variables */
 62.3630 -+#define PROBS_TOTAL (1846 + LITERAL_CODERS_MAX * LITERAL_CODER_SIZE)
 62.3631 -+
 62.3632 -+/*
 62.3633 -+ * LZMA remembers the four most recent match distances. Reusing these
 62.3634 -+ * distances tends to take less space than re-encoding the actual
 62.3635 -+ * distance value.
 62.3636 -+ */
 62.3637 -+#define REPS 4
 62.3638 -+
 62.3639 -+#endif
 62.3640 -diff --git a/lib/xz/xz_private.h b/lib/xz/xz_private.h
 62.3641 -new file mode 100644
 62.3642 -index 0000000..a65633e
 62.3643 ---- /dev/null
 62.3644 -+++ b/lib/xz/xz_private.h
 62.3645 -@@ -0,0 +1,156 @@
 62.3646 -+/*
 62.3647 -+ * Private includes and definitions
 62.3648 -+ *
 62.3649 -+ * Author: Lasse Collin <lasse.collin@tukaani.org>
 62.3650 -+ *
 62.3651 -+ * This file has been put into the public domain.
 62.3652 -+ * You can do whatever you want with this file.
 62.3653 -+ */
 62.3654 -+
 62.3655 -+#ifndef XZ_PRIVATE_H
 62.3656 -+#define XZ_PRIVATE_H
 62.3657 -+
 62.3658 -+#ifdef __KERNEL__
 62.3659 -+#	include <linux/xz.h>
 62.3660 -+#	include <asm/byteorder.h>
 62.3661 -+#	include <asm/unaligned.h>
 62.3662 -+	/* XZ_PREBOOT may be defined only via decompress_unxz.c. */
 62.3663 -+#	ifndef XZ_PREBOOT
 62.3664 -+#		include <linux/slab.h>
 62.3665 -+#		include <linux/vmalloc.h>
 62.3666 -+#		include <linux/string.h>
 62.3667 -+#		ifdef CONFIG_XZ_DEC_X86
 62.3668 -+#			define XZ_DEC_X86
 62.3669 -+#		endif
 62.3670 -+#		ifdef CONFIG_XZ_DEC_POWERPC
 62.3671 -+#			define XZ_DEC_POWERPC
 62.3672 -+#		endif
 62.3673 -+#		ifdef CONFIG_XZ_DEC_IA64
 62.3674 -+#			define XZ_DEC_IA64
 62.3675 -+#		endif
 62.3676 -+#		ifdef CONFIG_XZ_DEC_ARM
 62.3677 -+#			define XZ_DEC_ARM
 62.3678 -+#		endif
 62.3679 -+#		ifdef CONFIG_XZ_DEC_ARMTHUMB
 62.3680 -+#			define XZ_DEC_ARMTHUMB
 62.3681 -+#		endif
 62.3682 -+#		ifdef CONFIG_XZ_DEC_SPARC
 62.3683 -+#			define XZ_DEC_SPARC
 62.3684 -+#		endif
 62.3685 -+#		define memeq(a, b, size) (memcmp(a, b, size) == 0)
 62.3686 -+#		define memzero(buf, size) memset(buf, 0, size)
 62.3687 -+#	endif
 62.3688 -+#	define get_le32(p) le32_to_cpup((const uint32_t *)(p))
 62.3689 -+#else
 62.3690 -+	/*
 62.3691 -+	 * For userspace builds, use a separate header to define the required
 62.3692 -+	 * macros and functions. This makes it easier to adapt the code into
 62.3693 -+	 * different environments and avoids clutter in the Linux kernel tree.
 62.3694 -+	 */
 62.3695 -+#	include "xz_config.h"
 62.3696 -+#endif
 62.3697 -+
 62.3698 -+/* If no specific decoding mode is requested, enable support for all modes. */
 62.3699 -+#if !defined(XZ_DEC_SINGLE) && !defined(XZ_DEC_PREALLOC) \
 62.3700 -+		&& !defined(XZ_DEC_DYNALLOC)
 62.3701 -+#	define XZ_DEC_SINGLE
 62.3702 -+#	define XZ_DEC_PREALLOC
 62.3703 -+#	define XZ_DEC_DYNALLOC
 62.3704 -+#endif
 62.3705 -+
 62.3706 -+/*
 62.3707 -+ * The DEC_IS_foo(mode) macros are used in "if" statements. If only some
 62.3708 -+ * of the supported modes are enabled, these macros will evaluate to true or
 62.3709 -+ * false at compile time and thus allow the compiler to omit unneeded code.
 62.3710 -+ */
 62.3711 -+#ifdef XZ_DEC_SINGLE
 62.3712 -+#	define DEC_IS_SINGLE(mode) ((mode) == XZ_SINGLE)
 62.3713 -+#else
 62.3714 -+#	define DEC_IS_SINGLE(mode) (false)
 62.3715 -+#endif
 62.3716 -+
 62.3717 -+#ifdef XZ_DEC_PREALLOC
 62.3718 -+#	define DEC_IS_PREALLOC(mode) ((mode) == XZ_PREALLOC)
 62.3719 -+#else
 62.3720 -+#	define DEC_IS_PREALLOC(mode) (false)
 62.3721 -+#endif
 62.3722 -+
 62.3723 -+#ifdef XZ_DEC_DYNALLOC
 62.3724 -+#	define DEC_IS_DYNALLOC(mode) ((mode) == XZ_DYNALLOC)
 62.3725 -+#else
 62.3726 -+#	define DEC_IS_DYNALLOC(mode) (false)
 62.3727 -+#endif
 62.3728 -+
 62.3729 -+#if !defined(XZ_DEC_SINGLE)
 62.3730 -+#	define DEC_IS_MULTI(mode) (true)
 62.3731 -+#elif defined(XZ_DEC_PREALLOC) || defined(XZ_DEC_DYNALLOC)
 62.3732 -+#	define DEC_IS_MULTI(mode) ((mode) != XZ_SINGLE)
 62.3733 -+#else
 62.3734 -+#	define DEC_IS_MULTI(mode) (false)
 62.3735 -+#endif
 62.3736 -+
 62.3737 -+/*
 62.3738 -+ * If any of the BCJ filter decoders are wanted, define XZ_DEC_BCJ.
 62.3739 -+ * XZ_DEC_BCJ is used to enable generic support for BCJ decoders.
 62.3740 -+ */
 62.3741 -+#ifndef XZ_DEC_BCJ
 62.3742 -+#	if defined(XZ_DEC_X86) || defined(XZ_DEC_POWERPC) \
 62.3743 -+			|| defined(XZ_DEC_IA64) || defined(XZ_DEC_ARM) \
 62.3744 -+			|| defined(XZ_DEC_ARM) || defined(XZ_DEC_ARMTHUMB) \
 62.3745 -+			|| defined(XZ_DEC_SPARC)
 62.3746 -+#		define XZ_DEC_BCJ
 62.3747 -+#	endif
 62.3748 -+#endif
 62.3749 -+
 62.3750 -+/*
 62.3751 -+ * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
 62.3752 -+ * before calling xz_dec_lzma2_run().
 62.3753 -+ */
 62.3754 -+XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
 62.3755 -+						   uint32_t dict_max);
 62.3756 -+
 62.3757 -+/*
 62.3758 -+ * Decode the LZMA2 properties (one byte) and reset the decoder. Return
 62.3759 -+ * XZ_OK on success, XZ_MEMLIMIT_ERROR if the preallocated dictionary is not
 62.3760 -+ * big enough, and XZ_OPTIONS_ERROR if props indicates something that this
 62.3761 -+ * decoder doesn't support.
 62.3762 -+ */
 62.3763 -+XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s,
 62.3764 -+					 uint8_t props);
 62.3765 -+
 62.3766 -+/* Decode raw LZMA2 stream from b->in to b->out. */
 62.3767 -+XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
 62.3768 -+				       struct xz_buf *b);
 62.3769 -+
 62.3770 -+/* Free the memory allocated for the LZMA2 decoder. */
 62.3771 -+XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
 62.3772 -+
 62.3773 -+#ifdef XZ_DEC_BCJ
 62.3774 -+/*
 62.3775 -+ * Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before
 62.3776 -+ * calling xz_dec_bcj_run().
 62.3777 -+ */
 62.3778 -+XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call);
 62.3779 -+
 62.3780 -+/*
 62.3781 -+ * Decode the Filter ID of a BCJ filter. This implementation doesn't
 62.3782 -+ * support custom start offsets, so no decoding of Filter Properties
 62.3783 -+ * is needed. Returns XZ_OK if the given Filter ID is supported.
 62.3784 -+ * Otherwise XZ_OPTIONS_ERROR is returned.
 62.3785 -+ */
 62.3786 -+XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id);
 62.3787 -+
 62.3788 -+/*
 62.3789 -+ * Decode raw BCJ + LZMA2 stream. This must be used only if there actually is
 62.3790 -+ * a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run()
 62.3791 -+ * must be called directly.
 62.3792 -+ */
 62.3793 -+XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
 62.3794 -+				     struct xz_dec_lzma2 *lzma2,
 62.3795 -+				     struct xz_buf *b);
 62.3796 -+
 62.3797 -+/* Free the memory allocated for the BCJ filters. */
 62.3798 -+#define xz_dec_bcj_end(s) kfree(s)
 62.3799 -+#endif
 62.3800 -+
 62.3801 -+#endif
 62.3802 -diff --git a/lib/xz/xz_stream.h b/lib/xz/xz_stream.h
 62.3803 -new file mode 100644
 62.3804 -index 0000000..66cb5a7
 62.3805 ---- /dev/null
 62.3806 -+++ b/lib/xz/xz_stream.h
 62.3807 -@@ -0,0 +1,62 @@
 62.3808 -+/*
 62.3809 -+ * Definitions for handling the .xz file format
 62.3810 -+ *
 62.3811 -+ * Author: Lasse Collin <lasse.collin@tukaani.org>
 62.3812 -+ *
 62.3813 -+ * This file has been put into the public domain.
 62.3814 -+ * You can do whatever you want with this file.
 62.3815 -+ */
 62.3816 -+
 62.3817 -+#ifndef XZ_STREAM_H
 62.3818 -+#define XZ_STREAM_H
 62.3819 -+
 62.3820 -+#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32
 62.3821 -+#	include <linux/crc32.h>
 62.3822 -+#	undef crc32
 62.3823 -+#	define xz_crc32(buf, size, crc) \
 62.3824 -+		(~crc32_le(~(uint32_t)(crc), buf, size))
 62.3825 -+#endif
 62.3826 -+
 62.3827 -+/*
 62.3828 -+ * See the .xz file format specification at
 62.3829 -+ * http://tukaani.org/xz/xz-file-format.txt
 62.3830 -+ * to understand the container format.
 62.3831 -+ */
 62.3832 -+
 62.3833 -+#define STREAM_HEADER_SIZE 12
 62.3834 -+
 62.3835 -+#define HEADER_MAGIC "\3757zXZ"
 62.3836 -+#define HEADER_MAGIC_SIZE 6
 62.3837 -+
 62.3838 -+#define FOOTER_MAGIC "YZ"
 62.3839 -+#define FOOTER_MAGIC_SIZE 2
 62.3840 -+
 62.3841 -+/*
 62.3842 -+ * Variable-length integer can hold a 63-bit unsigned integer or a special
 62.3843 -+ * value indicating that the value is unknown.
 62.3844 -+ *
 62.3845 -+ * Experimental: vli_type can be defined to uint32_t to save a few bytes
 62.3846 -+ * in code size (no effect on speed). Doing so limits the uncompressed and
 62.3847 -+ * compressed size of the file to less than 256 MiB and may also weaken
 62.3848 -+ * error detection slightly.
 62.3849 -+ */
 62.3850 -+typedef uint64_t vli_type;
 62.3851 -+
 62.3852 -+#define VLI_MAX ((vli_type)-1 / 2)
 62.3853 -+#define VLI_UNKNOWN ((vli_type)-1)
 62.3854 -+
 62.3855 -+/* Maximum encoded size of a VLI */
 62.3856 -+#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
 62.3857 -+
 62.3858 -+/* Integrity Check types */
 62.3859 -+enum xz_check {
 62.3860 -+	XZ_CHECK_NONE = 0,
 62.3861 -+	XZ_CHECK_CRC32 = 1,
 62.3862 -+	XZ_CHECK_CRC64 = 4,
 62.3863 -+	XZ_CHECK_SHA256 = 10
 62.3864 -+};
 62.3865 -+
 62.3866 -+/* Maximum possible Check ID */
 62.3867 -+#define XZ_CHECK_MAX 15
 62.3868 -+
 62.3869 -+#endif
 62.3870 -diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
 62.3871 -index 54fd1b7..b862007 100644
 62.3872 ---- a/scripts/Makefile.lib
 62.3873 -+++ b/scripts/Makefile.lib
 62.3874 -@@ -246,6 +246,34 @@ cmd_lzo = (cat $(filter-out FORCE,$^) | \
 62.3875 - 	lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
 62.3876 - 	(rm -f $@ ; false)
 62.3877 - 
 62.3878 -+# XZ
 62.3879 -+# ---------------------------------------------------------------------------
 62.3880 -+# Use xzkern to compress the kernel image and xzmisc to compress other things.
 62.3881 -+#
 62.3882 -+# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
 62.3883 -+# of the kernel decompressor. A BCJ filter is used if it is available for
 62.3884 -+# the target architecture. xzkern also appends uncompressed size of the data
 62.3885 -+# using size_append. The .xz format has the size information available at
 62.3886 -+# the end of the file too, but it's in more complex format and it's good to
 62.3887 -+# avoid changing the part of the boot code that reads the uncompressed size.
 62.3888 -+# Note that the bytes added by size_append will make the xz tool think that
 62.3889 -+# the file is corrupt. This is expected.
 62.3890 -+#
 62.3891 -+# xzmisc doesn't use size_append, so it can be used to create normal .xz
 62.3892 -+# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
 62.3893 -+# big dictionary would increase the memory usage too much in the multi-call
 62.3894 -+# decompression mode. A BCJ filter isn't used either.
 62.3895 -+quiet_cmd_xzkern = XZKERN  $@
 62.3896 -+cmd_xzkern = (cat $(filter-out FORCE,$^) | \
 62.3897 -+	sh $(srctree)/scripts/xz_wrap.sh && \
 62.3898 -+	$(call size_append, $(filter-out FORCE,$^))) > $@ || \
 62.3899 -+	(rm -f $@ ; false)
 62.3900 -+
 62.3901 -+quiet_cmd_xzmisc = XZMISC  $@
 62.3902 -+cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
 62.3903 -+	xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
 62.3904 -+	(rm -f $@ ; false)
 62.3905 -+
 62.3906 - # misc stuff
 62.3907 - # ---------------------------------------------------------------------------
 62.3908 - quote:="
 62.3909 -diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
 62.3910 -new file mode 100644
 62.3911 -index 0000000..17a5798
 62.3912 ---- /dev/null
 62.3913 -+++ b/scripts/xz_wrap.sh
 62.3914 -@@ -0,0 +1,23 @@
 62.3915 -+#!/bin/sh
 62.3916 -+#
 62.3917 -+# This is a wrapper for xz to compress the kernel image using appropriate
 62.3918 -+# compression options depending on the architecture.
 62.3919 -+#
 62.3920 -+# Author: Lasse Collin <lasse.collin@tukaani.org>
 62.3921 -+#
 62.3922 -+# This file has been put into the public domain.
 62.3923 -+# You can do whatever you want with this file.
 62.3924 -+#
 62.3925 -+
 62.3926 -+BCJ=
 62.3927 -+LZMA2OPTS=
 62.3928 -+
 62.3929 -+case $ARCH in
 62.3930 -+	x86|x86_64)     BCJ=--x86 ;;
 62.3931 -+	powerpc)        BCJ=--powerpc ;;
 62.3932 -+	ia64)           BCJ=--ia64; LZMA2OPTS=pb=4 ;;
 62.3933 -+	arm)            BCJ=--arm ;;
 62.3934 -+	sparc)          BCJ=--sparc ;;
 62.3935 -+esac
 62.3936 -+
 62.3937 -+exec xz --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB
    63.1 --- a/kernel-modular/stuff/002-squashfs-decompressors-add-boot-time-xz-support.patch	Thu Jul 18 13:24:21 2013 +0000
    63.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.3 @@ -1,638 +0,0 @@
    63.4 -From: Lasse Collin <lasse.collin@tukaani.org>
    63.5 -Date: Thu, 2 Dec 2010 19:14:37 +0000 (+0200)
    63.6 -Subject: Decompressors: Add boot-time XZ support
    63.7 -X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fpkl%2Fsquashfs-xz.git;a=commitdiff_plain;h=c64bc9a229b46db75d7761601dd8ca25385a7780
    63.8 -
    63.9 -Decompressors: Add boot-time XZ support
   63.10 -
   63.11 -This implements the API defined in <linux/decompress/generic.h>
   63.12 -which is used for kernel, initramfs, and initrd decompression.
   63.13 -This patch together with the first patch is enough for
   63.14 -XZ-compressed initramfs and initrd; XZ-compressed kernel will
   63.15 -need arch-specific changes.
   63.16 -
   63.17 -In contrast to other initramfs compression methods, support for
   63.18 -XZ-compressed initramfs is not enabled by default in usr/Kconfig.
   63.19 -This is primarily due to the Kconfig options of the xz_dec
   63.20 -module. It can be good to require that xz_dec is enabled
   63.21 -separately so the user can select only the BCJ filters he needs
   63.22 -when EMBEDDED=y.
   63.23 -
   63.24 -The buffering requirements described in decompress_unxz.c are
   63.25 -stricter than with gzip, so the relevant changes should be done
   63.26 -to the arch-specific code when adding support for XZ-compressed
   63.27 -kernel. Similarly, the heap size in arch-specific pre-boot code
   63.28 -may need to be increased (30 KiB is enough).
   63.29 -
   63.30 -The XZ decompressor needs memmove(), memeq() (memcmp() == 0),
   63.31 -and memzero() (memset(ptr, 0, size)), which aren't available in
   63.32 -all arch-specific pre-boot environments. I'm including simple
   63.33 -versions in decompress_unxz.c, but a cleaner solution would
   63.34 -naturally be nicer.
   63.35 -
   63.36 -Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
   63.37 ----
   63.38 -
   63.39 -diff --git a/include/linux/decompress/unxz.h b/include/linux/decompress/unxz.h
   63.40 -new file mode 100644
   63.41 -index 0000000..41728fc
   63.42 ---- /dev/null
   63.43 -+++ b/include/linux/decompress/unxz.h
   63.44 -@@ -0,0 +1,19 @@
   63.45 -+/*
   63.46 -+ * Wrapper for decompressing XZ-compressed kernel, initramfs, and initrd
   63.47 -+ *
   63.48 -+ * Author: Lasse Collin <lasse.collin@tukaani.org>
   63.49 -+ *
   63.50 -+ * This file has been put into the public domain.
   63.51 -+ * You can do whatever you want with this file.
   63.52 -+ */
   63.53 -+
   63.54 -+#ifndef DECOMPRESS_UNXZ_H
   63.55 -+#define DECOMPRESS_UNXZ_H
   63.56 -+
   63.57 -+int unxz(unsigned char *in, int in_size,
   63.58 -+	 int (*fill)(void *dest, unsigned int size),
   63.59 -+	 int (*flush)(void *src, unsigned int size),
   63.60 -+	 unsigned char *out, int *in_used,
   63.61 -+	 void (*error)(char *x));
   63.62 -+
   63.63 -+#endif
   63.64 -diff --git a/init/Kconfig b/init/Kconfig
   63.65 -index 2de5b1c..d9fbb0f 100644
   63.66 ---- a/init/Kconfig
   63.67 -+++ b/init/Kconfig
   63.68 -@@ -123,13 +123,16 @@ config HAVE_KERNEL_BZIP2
   63.69 - config HAVE_KERNEL_LZMA
   63.70 - 	bool
   63.71 - 
   63.72 -+config HAVE_KERNEL_XZ
   63.73 -+	bool
   63.74 -+
   63.75 - config HAVE_KERNEL_LZO
   63.76 - 	bool
   63.77 - 
   63.78 - choice
   63.79 - 	prompt "Kernel compression mode"
   63.80 - 	default KERNEL_GZIP
   63.81 --	depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_LZO
   63.82 -+	depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO
   63.83 - 	help
   63.84 - 	  The linux kernel is a kind of self-extracting executable.
   63.85 - 	  Several compression algorithms are available, which differ
   63.86 -@@ -174,6 +177,21 @@ config KERNEL_LZMA
   63.87 - 	  two. Compression is slowest.	The kernel size is about 33%
   63.88 - 	  smaller with LZMA in comparison to gzip.
   63.89 - 
   63.90 -+config KERNEL_XZ
   63.91 -+	bool "XZ"
   63.92 -+	depends on HAVE_KERNEL_XZ
   63.93 -+	help
   63.94 -+	  XZ uses the LZMA2 algorithm and instruction set specific
   63.95 -+	  BCJ filters which can improve compression ratio of executable
   63.96 -+	  code. The size of the kernel is about 30% smaller with XZ in
   63.97 -+	  comparison to gzip. On architectures for which there is a BCJ
   63.98 -+	  filter (i386, x86_64, ARM, IA-64, PowerPC, and SPARC), XZ
   63.99 -+	  will create a few percent smaller kernel than plain LZMA.
  63.100 -+
  63.101 -+	  The speed is about the same as with LZMA: The decompression
  63.102 -+	  speed of XZ is better than that of bzip2 but worse than gzip
  63.103 -+	  and LZO. Compression is slow.
  63.104 -+
  63.105 - config KERNEL_LZO
  63.106 - 	bool "LZO"
  63.107 - 	depends on HAVE_KERNEL_LZO
  63.108 -diff --git a/lib/Kconfig b/lib/Kconfig
  63.109 -index 6090314..45960e1 100644
  63.110 ---- a/lib/Kconfig
  63.111 -+++ b/lib/Kconfig
  63.112 -@@ -122,6 +122,9 @@ config DECOMPRESS_BZIP2
  63.113 - config DECOMPRESS_LZMA
  63.114 - 	tristate
  63.115 - 
  63.116 -+config DECOMPRESS_XZ
  63.117 -+	tristate
  63.118 -+
  63.119 - config DECOMPRESS_LZO
  63.120 - 	select LZO_DECOMPRESS
  63.121 - 	tristate
  63.122 -diff --git a/lib/Makefile b/lib/Makefile
  63.123 -index f2f98dd..06e3d8a 100644
  63.124 ---- a/lib/Makefile
  63.125 -+++ b/lib/Makefile
  63.126 -@@ -75,6 +75,7 @@ obj-$(CONFIG_RAID6_PQ) += raid6/
  63.127 - lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
  63.128 - lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
  63.129 - lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
  63.130 -+lib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
  63.131 - lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
  63.132 - 
  63.133 - obj-$(CONFIG_TEXTSEARCH) += textsearch.o
  63.134 -diff --git a/lib/decompress.c b/lib/decompress.c
  63.135 -index a760681..3d766b7 100644
  63.136 ---- a/lib/decompress.c
  63.137 -+++ b/lib/decompress.c
  63.138 -@@ -8,6 +8,7 @@
  63.139 - 
  63.140 - #include <linux/decompress/bunzip2.h>
  63.141 - #include <linux/decompress/unlzma.h>
  63.142 -+#include <linux/decompress/unxz.h>
  63.143 - #include <linux/decompress/inflate.h>
  63.144 - #include <linux/decompress/unlzo.h>
  63.145 - 
  63.146 -@@ -23,6 +24,9 @@
  63.147 - #ifndef CONFIG_DECOMPRESS_LZMA
  63.148 - # define unlzma NULL
  63.149 - #endif
  63.150 -+#ifndef CONFIG_DECOMPRESS_XZ
  63.151 -+# define unxz NULL
  63.152 -+#endif
  63.153 - #ifndef CONFIG_DECOMPRESS_LZO
  63.154 - # define unlzo NULL
  63.155 - #endif
  63.156 -@@ -36,6 +40,7 @@ static const struct compress_format {
  63.157 - 	{ {037, 0236}, "gzip", gunzip },
  63.158 - 	{ {0x42, 0x5a}, "bzip2", bunzip2 },
  63.159 - 	{ {0x5d, 0x00}, "lzma", unlzma },
  63.160 -+	{ {0xfd, 0x37}, "xz", unxz },
  63.161 - 	{ {0x89, 0x4c}, "lzo", unlzo },
  63.162 - 	{ {0, 0}, NULL, NULL }
  63.163 - };
  63.164 -diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
  63.165 -new file mode 100644
  63.166 -index 0000000..cecd23d
  63.167 ---- /dev/null
  63.168 -+++ b/lib/decompress_unxz.c
  63.169 -@@ -0,0 +1,397 @@
  63.170 -+/*
  63.171 -+ * Wrapper for decompressing XZ-compressed kernel, initramfs, and initrd
  63.172 -+ *
  63.173 -+ * Author: Lasse Collin <lasse.collin@tukaani.org>
  63.174 -+ *
  63.175 -+ * This file has been put into the public domain.
  63.176 -+ * You can do whatever you want with this file.
  63.177 -+ */
  63.178 -+
  63.179 -+/*
  63.180 -+ * Important notes about in-place decompression
  63.181 -+ *
  63.182 -+ * At least on x86, the kernel is decompressed in place: the compressed data
  63.183 -+ * is placed to the end of the output buffer, and the decompressor overwrites
  63.184 -+ * most of the compressed data. There must be enough safety margin to
  63.185 -+ * guarantee that the write position is always behind the read position.
  63.186 -+ *
  63.187 -+ * The safety margin for XZ with LZMA2 or BCJ+LZMA2 is calculated below.
  63.188 -+ * Note that the margin with XZ is bigger than with Deflate (gzip)!
  63.189 -+ *
  63.190 -+ * The worst case for in-place decompression is that the beginning of
  63.191 -+ * the file is compressed extremely well, and the rest of the file is
  63.192 -+ * uncompressible. Thus, we must look for worst-case expansion when the
  63.193 -+ * compressor is encoding uncompressible data.
  63.194 -+ *
  63.195 -+ * The structure of the .xz file in case of a compresed kernel is as follows.
  63.196 -+ * Sizes (as bytes) of the fields are in parenthesis.
  63.197 -+ *
  63.198 -+ *    Stream Header (12)
  63.199 -+ *    Block Header:
  63.200 -+ *      Block Header (8-12)
  63.201 -+ *      Compressed Data (N)
  63.202 -+ *      Block Padding (0-3)
  63.203 -+ *      CRC32 (4)
  63.204 -+ *    Index (8-20)
  63.205 -+ *    Stream Footer (12)
  63.206 -+ *
  63.207 -+ * Normally there is exactly one Block, but let's assume that there are
  63.208 -+ * 2-4 Blocks just in case. Because Stream Header and also Block Header
  63.209 -+ * of the first Block don't make the decompressor produce any uncompressed
  63.210 -+ * data, we can ignore them from our calculations. Block Headers of possible
  63.211 -+ * additional Blocks have to be taken into account still. With these
  63.212 -+ * assumptions, it is safe to assume that the total header overhead is
  63.213 -+ * less than 128 bytes.
  63.214 -+ *
  63.215 -+ * Compressed Data contains LZMA2 or BCJ+LZMA2 encoded data. Since BCJ
  63.216 -+ * doesn't change the size of the data, it is enough to calculate the
  63.217 -+ * safety margin for LZMA2.
  63.218 -+ *
  63.219 -+ * LZMA2 stores the data in chunks. Each chunk has a header whose size is
  63.220 -+ * a maximum of 6 bytes, but to get round 2^n numbers, let's assume that
  63.221 -+ * the maximum chunk header size is 8 bytes. After the chunk header, there
  63.222 -+ * may be up to 64 KiB of actual payload in the chunk. Often the payload is
  63.223 -+ * quite a bit smaller though; to be safe, let's assume that an average
  63.224 -+ * chunk has only 32 KiB of payload.
  63.225 -+ *
  63.226 -+ * The maximum uncompressed size of the payload is 2 MiB. The minimum
  63.227 -+ * uncompressed size of the payload is in practice never less than the
  63.228 -+ * payload size itself. The LZMA2 format would allow uncompressed size
  63.229 -+ * to be less than the payload size, but no sane compressor creates such
  63.230 -+ * files. LZMA2 supports storing uncompressible data in uncompressed form,
  63.231 -+ * so there's never a need to create payloads whose uncompressed size is
  63.232 -+ * smaller than the compressed size.
  63.233 -+ *
  63.234 -+ * The assumption, that the uncompressed size of the payload is never
  63.235 -+ * smaller than the payload itself, is valid only when talking about
  63.236 -+ * the payload as a whole. It is possible that the payload has parts where
  63.237 -+ * the decompressor consumes more input than it produces output. Calculating
  63.238 -+ * the worst case for this would be tricky. Instead of trying to do that,
  63.239 -+ * let's simply make sure that the decompressor never overwrites any bytes
  63.240 -+ * of the payload which it is currently reading.
  63.241 -+ *
  63.242 -+ * Now we have enough information to calculate the safety margin. We need
  63.243 -+ *   - 128 bytes for the .xz file format headers;
  63.244 -+ *   - 8 bytes per every 32 KiB of uncompressed size (one LZMA2 chunk header
  63.245 -+ *     per chunk, each chunk having average payload size of 32 KiB); and
  63.246 -+ *   - 64 KiB (biggest possible LZMA2 chunk payload size) to make sure that
  63.247 -+ *     the decompressor never overwrites anything from the LZMA2 chunk
  63.248 -+ *     payload it is currently reading.
  63.249 -+ *
  63.250 -+ * We get the following formula:
  63.251 -+ *
  63.252 -+ *    safety_margin = 128 + uncompressed_size * 8 / 32768 + 65536
  63.253 -+ *                  = 128 + (uncompressed_size >> 12) + 65536
  63.254 -+ *
  63.255 -+ * For comparision, according to arch/x86/boot/compressed/misc.c, the
  63.256 -+ * equivalent formula for Deflate is this:
  63.257 -+ *
  63.258 -+ *    safety_margin = 18 + (uncompressed_size >> 12) + 32768
  63.259 -+ *
  63.260 -+ * Thus, when updating Deflate-only in-place kernel decompressor to
  63.261 -+ * support XZ, the fixed overhead has to be increased from 18+32768 bytes
  63.262 -+ * to 128+65536 bytes.
  63.263 -+ */
  63.264 -+
  63.265 -+/*
  63.266 -+ * STATIC is defined to "static" if we are being built for kernel
  63.267 -+ * decompression (pre-boot code). <linux/decompress/mm.h> will define
  63.268 -+ * STATIC to empty if it wasn't already defined. Since we will need to
  63.269 -+ * know later if we are being used for kernel decompression, we define
  63.270 -+ * XZ_PREBOOT here.
  63.271 -+ */
  63.272 -+#ifdef STATIC
  63.273 -+#	define XZ_PREBOOT
  63.274 -+#endif
  63.275 -+#ifdef __KERNEL__
  63.276 -+#	include <linux/decompress/mm.h>
  63.277 -+#endif
  63.278 -+#define XZ_EXTERN STATIC
  63.279 -+
  63.280 -+#ifndef XZ_PREBOOT
  63.281 -+#	include <linux/slab.h>
  63.282 -+#	include <linux/xz.h>
  63.283 -+#else
  63.284 -+/*
  63.285 -+ * Use the internal CRC32 code instead of kernel's CRC32 module, which
  63.286 -+ * is not available in early phase of booting.
  63.287 -+ */
  63.288 -+#define XZ_INTERNAL_CRC32 1
  63.289 -+
  63.290 -+/*
  63.291 -+ * For boot time use, we enable only the BCJ filter of the current
  63.292 -+ * architecture or none if no BCJ filter is available for the architecture.
  63.293 -+ */
  63.294 -+#ifdef CONFIG_X86
  63.295 -+#	define XZ_DEC_X86
  63.296 -+#endif
  63.297 -+#ifdef CONFIG_PPC
  63.298 -+#	define XZ_DEC_POWERPC
  63.299 -+#endif
  63.300 -+#ifdef CONFIG_ARM
  63.301 -+#	define XZ_DEC_ARM
  63.302 -+#endif
  63.303 -+#ifdef CONFIG_IA64
  63.304 -+#	define XZ_DEC_IA64
  63.305 -+#endif
  63.306 -+#ifdef CONFIG_SPARC
  63.307 -+#	define XZ_DEC_SPARC
  63.308 -+#endif
  63.309 -+
  63.310 -+/*
  63.311 -+ * This will get the basic headers so that memeq() and others
  63.312 -+ * can be defined.
  63.313 -+ */
  63.314 -+#include "xz/xz_private.h"
  63.315 -+
  63.316 -+/*
  63.317 -+ * Replace the normal allocation functions with the versions from
  63.318 -+ * <linux/decompress/mm.h>. vfree() needs to support vfree(NULL)
  63.319 -+ * when XZ_DYNALLOC is used, but the pre-boot free() doesn't support it.
  63.320 -+ * Workaround it here because the other decompressors don't need it.
  63.321 -+ */
  63.322 -+#undef kmalloc
  63.323 -+#undef kfree
  63.324 -+#undef vmalloc
  63.325 -+#undef vfree
  63.326 -+#define kmalloc(size, flags) malloc(size)
  63.327 -+#define kfree(ptr) free(ptr)
  63.328 -+#define vmalloc(size) malloc(size)
  63.329 -+#define vfree(ptr) do { if (ptr != NULL) free(ptr); } while (0)
  63.330 -+
  63.331 -+/*
  63.332 -+ * FIXME: Not all basic memory functions are provided in architecture-specific
  63.333 -+ * files (yet). We define our own versions here for now, but this should be
  63.334 -+ * only a temporary solution.
  63.335 -+ *
  63.336 -+ * memeq and memzero are not used much and any remotely sane implementation
  63.337 -+ * is fast enough. memcpy/memmove speed matters in multi-call mode, but
  63.338 -+ * the kernel image is decompressed in single-call mode, in which only
  63.339 -+ * memcpy speed can matter and only if there is a lot of uncompressible data
  63.340 -+ * (LZMA2 stores uncompressible chunks in uncompressed form). Thus, the
  63.341 -+ * functions below should just be kept small; it's probably not worth
  63.342 -+ * optimizing for speed.
  63.343 -+ */
  63.344 -+
  63.345 -+#ifndef memeq
  63.346 -+static bool memeq(const void *a, const void *b, size_t size)
  63.347 -+{
  63.348 -+	const uint8_t *x = a;
  63.349 -+	const uint8_t *y = b;
  63.350 -+	size_t i;
  63.351 -+
  63.352 -+	for (i = 0; i < size; ++i)
  63.353 -+		if (x[i] != y[i])
  63.354 -+			return false;
  63.355 -+
  63.356 -+	return true;
  63.357 -+}
  63.358 -+#endif
  63.359 -+
  63.360 -+#ifndef memzero
  63.361 -+static void memzero(void *buf, size_t size)
  63.362 -+{
  63.363 -+	uint8_t *b = buf;
  63.364 -+	uint8_t *e = b + size;
  63.365 -+
  63.366 -+	while (b != e)
  63.367 -+		*b++ = '\0';
  63.368 -+}
  63.369 -+#endif
  63.370 -+
  63.371 -+#ifndef memmove
  63.372 -+/* Not static to avoid a conflict with the prototype in the Linux headers. */
  63.373 -+void *memmove(void *dest, const void *src, size_t size)
  63.374 -+{
  63.375 -+	uint8_t *d = dest;
  63.376 -+	const uint8_t *s = src;
  63.377 -+	size_t i;
  63.378 -+
  63.379 -+	if (d < s) {
  63.380 -+		for (i = 0; i < size; ++i)
  63.381 -+			d[i] = s[i];
  63.382 -+	} else if (d > s) {
  63.383 -+		i = size;
  63.384 -+		while (i-- > 0)
  63.385 -+			d[i] = s[i];
  63.386 -+	}
  63.387 -+
  63.388 -+	return dest;
  63.389 -+}
  63.390 -+#endif
  63.391 -+
  63.392 -+/*
  63.393 -+ * Since we need memmove anyway, would use it as memcpy too.
  63.394 -+ * Commented out for now to avoid breaking things.
  63.395 -+ */
  63.396 -+/*
  63.397 -+#ifndef memcpy
  63.398 -+#	define memcpy memmove
  63.399 -+#endif
  63.400 -+*/
  63.401 -+
  63.402 -+#include "xz/xz_crc32.c"
  63.403 -+#include "xz/xz_dec_stream.c"
  63.404 -+#include "xz/xz_dec_lzma2.c"
  63.405 -+#include "xz/xz_dec_bcj.c"
  63.406 -+
  63.407 -+#endif /* XZ_PREBOOT */
  63.408 -+
  63.409 -+/* Size of the input and output buffers in multi-call mode */
  63.410 -+#define XZ_IOBUF_SIZE 4096
  63.411 -+
  63.412 -+/*
  63.413 -+ * This function implements the API defined in <linux/decompress/generic.h>.
  63.414 -+ *
  63.415 -+ * This wrapper will automatically choose single-call or multi-call mode
  63.416 -+ * of the native XZ decoder API. The single-call mode can be used only when
  63.417 -+ * both input and output buffers are available as a single chunk, i.e. when
  63.418 -+ * fill() and flush() won't be used.
  63.419 -+ */
  63.420 -+STATIC int INIT unxz(unsigned char *in, int in_size,
  63.421 -+		     int (*fill)(void *dest, unsigned int size),
  63.422 -+		     int (*flush)(void *src, unsigned int size),
  63.423 -+		     unsigned char *out, int *in_used,
  63.424 -+		     void (*error)(char *x))
  63.425 -+{
  63.426 -+	struct xz_buf b;
  63.427 -+	struct xz_dec *s;
  63.428 -+	enum xz_ret ret;
  63.429 -+	bool must_free_in = false;
  63.430 -+
  63.431 -+#if XZ_INTERNAL_CRC32
  63.432 -+	xz_crc32_init();
  63.433 -+#endif
  63.434 -+
  63.435 -+	if (in_used != NULL)
  63.436 -+		*in_used = 0;
  63.437 -+
  63.438 -+	if (fill == NULL && flush == NULL)
  63.439 -+		s = xz_dec_init(XZ_SINGLE, 0);
  63.440 -+	else
  63.441 -+		s = xz_dec_init(XZ_DYNALLOC, (uint32_t)-1);
  63.442 -+
  63.443 -+	if (s == NULL)
  63.444 -+		goto error_alloc_state;
  63.445 -+
  63.446 -+	if (flush == NULL) {
  63.447 -+		b.out = out;
  63.448 -+		b.out_size = (size_t)-1;
  63.449 -+	} else {
  63.450 -+		b.out_size = XZ_IOBUF_SIZE;
  63.451 -+		b.out = malloc(XZ_IOBUF_SIZE);
  63.452 -+		if (b.out == NULL)
  63.453 -+			goto error_alloc_out;
  63.454 -+	}
  63.455 -+
  63.456 -+	if (in == NULL) {
  63.457 -+		must_free_in = true;
  63.458 -+		in = malloc(XZ_IOBUF_SIZE);
  63.459 -+		if (in == NULL)
  63.460 -+			goto error_alloc_in;
  63.461 -+	}
  63.462 -+
  63.463 -+	b.in = in;
  63.464 -+	b.in_pos = 0;
  63.465 -+	b.in_size = in_size;
  63.466 -+	b.out_pos = 0;
  63.467 -+
  63.468 -+	if (fill == NULL && flush == NULL) {
  63.469 -+		ret = xz_dec_run(s, &b);
  63.470 -+	} else {
  63.471 -+		do {
  63.472 -+			if (b.in_pos == b.in_size && fill != NULL) {
  63.473 -+				if (in_used != NULL)
  63.474 -+					*in_used += b.in_pos;
  63.475 -+
  63.476 -+				b.in_pos = 0;
  63.477 -+
  63.478 -+				in_size = fill(in, XZ_IOBUF_SIZE);
  63.479 -+				if (in_size < 0) {
  63.480 -+					/*
  63.481 -+					 * This isn't an optimal error code
  63.482 -+					 * but it probably isn't worth making
  63.483 -+					 * a new one either.
  63.484 -+					 */
  63.485 -+					ret = XZ_BUF_ERROR;
  63.486 -+					break;
  63.487 -+				}
  63.488 -+
  63.489 -+				b.in_size = in_size;
  63.490 -+			}
  63.491 -+
  63.492 -+			ret = xz_dec_run(s, &b);
  63.493 -+
  63.494 -+			if (flush != NULL && (b.out_pos == b.out_size
  63.495 -+					|| (ret != XZ_OK && b.out_pos > 0))) {
  63.496 -+				/*
  63.497 -+				 * Setting ret here may hide an error
  63.498 -+				 * returned by xz_dec_run(), but probably
  63.499 -+				 * it's not too bad.
  63.500 -+				 */
  63.501 -+				if (flush(b.out, b.out_pos) != (int)b.out_pos)
  63.502 -+					ret = XZ_BUF_ERROR;
  63.503 -+
  63.504 -+				b.out_pos = 0;
  63.505 -+			}
  63.506 -+		} while (ret == XZ_OK);
  63.507 -+
  63.508 -+		if (must_free_in)
  63.509 -+			free(in);
  63.510 -+
  63.511 -+		if (flush != NULL)
  63.512 -+			free(b.out);
  63.513 -+	}
  63.514 -+
  63.515 -+	if (in_used != NULL)
  63.516 -+		*in_used += b.in_pos;
  63.517 -+
  63.518 -+	xz_dec_end(s);
  63.519 -+
  63.520 -+	switch (ret) {
  63.521 -+	case XZ_STREAM_END:
  63.522 -+		return 0;
  63.523 -+
  63.524 -+	case XZ_MEM_ERROR:
  63.525 -+		/* This can occur only in multi-call mode. */
  63.526 -+		error("XZ decompressor ran out of memory");
  63.527 -+		break;
  63.528 -+
  63.529 -+	case XZ_FORMAT_ERROR:
  63.530 -+		error("Input is not in the XZ format (wrong magic bytes)");
  63.531 -+		break;
  63.532 -+
  63.533 -+	case XZ_OPTIONS_ERROR:
  63.534 -+		error("Input was encoded with settings that are not "
  63.535 -+				"supported by this XZ decoder");
  63.536 -+		break;
  63.537 -+
  63.538 -+	case XZ_DATA_ERROR:
  63.539 -+	case XZ_BUF_ERROR:
  63.540 -+		error("XZ-compressed data is corrupt");
  63.541 -+		break;
  63.542 -+
  63.543 -+	default:
  63.544 -+		error("Bug in the XZ decompressor");
  63.545 -+		break;
  63.546 -+	}
  63.547 -+
  63.548 -+	return -1;
  63.549 -+
  63.550 -+error_alloc_in:
  63.551 -+	if (flush != NULL)
  63.552 -+		free(b.out);
  63.553 -+
  63.554 -+error_alloc_out:
  63.555 -+	xz_dec_end(s);
  63.556 -+
  63.557 -+error_alloc_state:
  63.558 -+	error("XZ decompressor ran out of memory");
  63.559 -+	return -1;
  63.560 -+}
  63.561 -+
  63.562 -+/*
  63.563 -+ * This macro is used by architecture-specific files to decompress
  63.564 -+ * the kernel image.
  63.565 -+ */
  63.566 -+#define decompress unxz
  63.567 -diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
  63.568 -index 5958fff..55caecd 100644
  63.569 ---- a/scripts/gen_initramfs_list.sh
  63.570 -+++ b/scripts/gen_initramfs_list.sh
  63.571 -@@ -243,6 +243,8 @@ case "$arg" in
  63.572 - 		echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f"
  63.573 - 		echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f"
  63.574 - 		echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f"
  63.575 -+		echo "$output_file" | grep -q "\.xz$" && \
  63.576 -+				compr="xz --check=crc32 --lzma2=dict=1MiB"
  63.577 - 		echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f"
  63.578 - 		echo "$output_file" | grep -q "\.cpio$" && compr="cat"
  63.579 - 		shift
  63.580 -diff --git a/usr/Kconfig b/usr/Kconfig
  63.581 -index e2721f5..9f51a29 100644
  63.582 ---- a/usr/Kconfig
  63.583 -+++ b/usr/Kconfig
  63.584 -@@ -72,6 +72,18 @@ config RD_LZMA
  63.585 - 	  Support loading of a LZMA encoded initial ramdisk or cpio buffer
  63.586 - 	  If unsure, say N.
  63.587 - 
  63.588 -+config RD_XZ
  63.589 -+	bool "Support initial ramdisks compressed using XZ"
  63.590 -+	depends on BLK_DEV_INITRD && XZ_DEC=y
  63.591 -+	select DECOMPRESS_XZ
  63.592 -+	help
  63.593 -+	  Support loading of a XZ encoded initial ramdisk or cpio buffer.
  63.594 -+
  63.595 -+	  If this option is inactive, say Y to "XZ decompression support"
  63.596 -+	  under "Library routines" first.
  63.597 -+
  63.598 -+	  If unsure, say N.
  63.599 -+
  63.600 - config RD_LZO
  63.601 - 	bool "Support initial ramdisks compressed using LZO" if EMBEDDED
  63.602 - 	default !EMBEDDED
  63.603 -@@ -139,6 +151,15 @@ config INITRAMFS_COMPRESSION_LZMA
  63.604 - 	  three. Compression is slowest. The initramfs size is about 33%
  63.605 - 	  smaller with LZMA in comparison to gzip.
  63.606 - 
  63.607 -+config INITRAMFS_COMPRESSION_XZ
  63.608 -+	bool "XZ"
  63.609 -+	depends on RD_XZ
  63.610 -+	help
  63.611 -+	  XZ uses the LZMA2 algorithm. The initramfs size is about 30%
  63.612 -+	  smaller with XZ in comparison to gzip. Decompression speed
  63.613 -+	  is better than that of bzip2 but worse than gzip and LZO.
  63.614 -+	  Compression is slow.
  63.615 -+
  63.616 - config INITRAMFS_COMPRESSION_LZO
  63.617 - 	bool "LZO"
  63.618 - 	depends on RD_LZO
  63.619 -diff --git a/usr/Makefile b/usr/Makefile
  63.620 -index 6b4b6da..5845a13 100644
  63.621 ---- a/usr/Makefile
  63.622 -+++ b/usr/Makefile
  63.623 -@@ -15,6 +15,9 @@ suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2)  = .bz2
  63.624 - # Lzma
  63.625 - suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA)   = .lzma
  63.626 - 
  63.627 -+# XZ
  63.628 -+suffix_$(CONFIG_INITRAMFS_COMPRESSION_XZ)     = .xz
  63.629 -+
  63.630 - # Lzo
  63.631 - suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO)   = .lzo
  63.632 - 
  63.633 -@@ -48,7 +51,7 @@ endif
  63.634 - quiet_cmd_initfs = GEN     $@
  63.635 -       cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
  63.636 - 
  63.637 --targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.lzo initramfs_data.cpio
  63.638 -+targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.xz initramfs_data.cpio.lzo initramfs_data.cpio
  63.639 - # do not try to update files included in initramfs
  63.640 - $(deps_initramfs): ;
  63.641 - 
    64.1 --- a/kernel-modular/stuff/003-squashfs-x86-support-xz-compressed-kernel.patch	Thu Jul 18 13:24:21 2013 +0000
    64.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.3 @@ -1,128 +0,0 @@
    64.4 -From: Lasse Collin <lasse.collin@tukaani.org>
    64.5 -Date: Thu, 2 Dec 2010 19:14:57 +0000 (+0200)
    64.6 -Subject: x86: Support XZ-compressed kernel
    64.7 -X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fpkl%2Fsquashfs-xz.git;a=commitdiff_plain;h=d4ad78414e5312126127b1f88cdaf8584af3eef1
    64.8 -
    64.9 -x86: Support XZ-compressed kernel
   64.10 -
   64.11 -This integrates the XZ decompression code to the x86
   64.12 -pre-boot code.
   64.13 -
   64.14 -mkpiggy.c is updated to reserve about 32 KiB more buffer safety
   64.15 -margin for kernel decompression. It is done unconditionally for
   64.16 -all decompressors to keep the code simpler.
   64.17 -
   64.18 -The XZ decompressor needs around 30 KiB of heap, so the heap size
   64.19 -is increased to 32 KiB on both x86-32 and x86-64.
   64.20 -
   64.21 -Documentation/x86/boot.txt is updated to list the XZ magic number.
   64.22 -
   64.23 -With the x86 BCJ filter in XZ, XZ-compressed x86 kernel tends to be
   64.24 -a few percent smaller than the equivalent LZMA-compressed kernel.
   64.25 -
   64.26 -Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
   64.27 ----
   64.28 -
   64.29 -diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
   64.30 -index 30b43e1..3988cde 100644
   64.31 ---- a/Documentation/x86/boot.txt
   64.32 -+++ b/Documentation/x86/boot.txt
   64.33 -@@ -621,9 +621,9 @@ Protocol:	2.08+
   64.34 -   The payload may be compressed. The format of both the compressed and
   64.35 -   uncompressed data should be determined using the standard magic
   64.36 -   numbers.  The currently supported compression formats are gzip
   64.37 --  (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A) and LZMA
   64.38 --  (magic number 5D 00).  The uncompressed payload is currently always ELF
   64.39 --  (magic number 7F 45 4C 46).
   64.40 -+  (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), LZMA
   64.41 -+  (magic number 5D 00), and XZ (magic number FD 37).  The uncompressed
   64.42 -+  payload is currently always ELF (magic number 7F 45 4C 46).
   64.43 -   
   64.44 - Field name:	payload_length
   64.45 - Type:		read
   64.46 -diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
   64.47 -index cea0cd9..f3db0d7 100644
   64.48 ---- a/arch/x86/Kconfig
   64.49 -+++ b/arch/x86/Kconfig
   64.50 -@@ -51,6 +51,7 @@ config X86
   64.51 - 	select HAVE_KERNEL_GZIP
   64.52 - 	select HAVE_KERNEL_BZIP2
   64.53 - 	select HAVE_KERNEL_LZMA
   64.54 -+	select HAVE_KERNEL_XZ
   64.55 - 	select HAVE_KERNEL_LZO
   64.56 - 	select HAVE_HW_BREAKPOINT
   64.57 - 	select HAVE_MIXED_BREAKPOINTS_REGS
   64.58 -diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
   64.59 -index 0c22955..09664ef 100644
   64.60 ---- a/arch/x86/boot/compressed/Makefile
   64.61 -+++ b/arch/x86/boot/compressed/Makefile
   64.62 -@@ -4,7 +4,7 @@
   64.63 - # create a compressed vmlinux image from the original vmlinux
   64.64 - #
   64.65 - 
   64.66 --targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.lzo head_$(BITS).o misc.o string.o cmdline.o early_serial_console.o piggy.o
   64.67 -+targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo head_$(BITS).o misc.o string.o cmdline.o early_serial_console.o piggy.o
   64.68 - 
   64.69 - KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
   64.70 - KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
   64.71 -@@ -49,12 +49,15 @@ $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
   64.72 - 	$(call if_changed,bzip2)
   64.73 - $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
   64.74 - 	$(call if_changed,lzma)
   64.75 -+$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
   64.76 -+	$(call if_changed,xzkern)
   64.77 - $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
   64.78 - 	$(call if_changed,lzo)
   64.79 - 
   64.80 - suffix-$(CONFIG_KERNEL_GZIP)	:= gz
   64.81 - suffix-$(CONFIG_KERNEL_BZIP2)	:= bz2
   64.82 - suffix-$(CONFIG_KERNEL_LZMA)	:= lzma
   64.83 -+suffix-$(CONFIG_KERNEL_XZ)	:= xz
   64.84 - suffix-$(CONFIG_KERNEL_LZO) 	:= lzo
   64.85 - 
   64.86 - quiet_cmd_mkpiggy = MKPIGGY $@
   64.87 -diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
   64.88 -index 8f7bef8..6d4cab7 100644
   64.89 ---- a/arch/x86/boot/compressed/misc.c
   64.90 -+++ b/arch/x86/boot/compressed/misc.c
   64.91 -@@ -139,6 +139,10 @@ static int lines, cols;
   64.92 - #include "../../../../lib/decompress_unlzma.c"
   64.93 - #endif
   64.94 - 
   64.95 -+#ifdef CONFIG_KERNEL_XZ
   64.96 -+#include "../../../../lib/decompress_unxz.c"
   64.97 -+#endif
   64.98 -+
   64.99 - #ifdef CONFIG_KERNEL_LZO
  64.100 - #include "../../../../lib/decompress_unlzo.c"
  64.101 - #endif
  64.102 -diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c
  64.103 -index 5c22812..646aa78 100644
  64.104 ---- a/arch/x86/boot/compressed/mkpiggy.c
  64.105 -+++ b/arch/x86/boot/compressed/mkpiggy.c
  64.106 -@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
  64.107 - 
  64.108 - 	offs = (olen > ilen) ? olen - ilen : 0;
  64.109 - 	offs += olen >> 12;	/* Add 8 bytes for each 32K block */
  64.110 --	offs += 32*1024 + 18;	/* Add 32K + 18 bytes slack */
  64.111 -+	offs += 64*1024 + 128;	/* Add 64K + 128 bytes slack */
  64.112 - 	offs = (offs+4095) & ~4095; /* Round to a 4K boundary */
  64.113 - 
  64.114 - 	printf(".section \".rodata..compressed\",\"a\",@progbits\n");
  64.115 -diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
  64.116 -index 3b62ab5..5e1a2ee 100644
  64.117 ---- a/arch/x86/include/asm/boot.h
  64.118 -+++ b/arch/x86/include/asm/boot.h
  64.119 -@@ -32,11 +32,7 @@
  64.120 - #define BOOT_HEAP_SIZE             0x400000
  64.121 - #else /* !CONFIG_KERNEL_BZIP2 */
  64.122 - 
  64.123 --#ifdef CONFIG_X86_64
  64.124 --#define BOOT_HEAP_SIZE	0x7000
  64.125 --#else
  64.126 --#define BOOT_HEAP_SIZE	0x4000
  64.127 --#endif
  64.128 -+#define BOOT_HEAP_SIZE	0x8000
  64.129 - 
  64.130 - #endif /* !CONFIG_KERNEL_BZIP2 */
  64.131 - 
    65.1 --- a/kernel-modular/stuff/004-squashfs-add-xz-compression-support.patch	Thu Jul 18 13:24:21 2013 +0000
    65.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.3 @@ -1,183 +0,0 @@
    65.4 -From: Phillip Lougher <phillip@lougher.demon.co.uk>
    65.5 -Date: Thu, 9 Dec 2010 02:02:29 +0000 (+0000)
    65.6 -Subject: Squashfs: add XZ compression support
    65.7 -X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fpkl%2Fsquashfs-xz.git;a=commitdiff_plain;h=d3e6969b9ff1f3a3c6bf3da71433c77046aa80e4
    65.8 -
    65.9 -Squashfs: add XZ compression support
   65.10 -
   65.11 -Add XZ decompressor wrapper code.
   65.12 -
   65.13 -Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
   65.14 ----
   65.15 -
   65.16 -diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h
   65.17 -index c5137fc..39533fe 100644
   65.18 ---- a/fs/squashfs/squashfs_fs.h
   65.19 -+++ b/fs/squashfs/squashfs_fs.h
   65.20 -@@ -238,6 +238,7 @@ struct meta_index {
   65.21 - #define ZLIB_COMPRESSION	1
   65.22 - #define LZMA_COMPRESSION	2
   65.23 - #define LZO_COMPRESSION		3
   65.24 -+#define XZ_COMPRESSION		4
   65.25 - 
   65.26 - struct squashfs_super_block {
   65.27 - 	__le32			s_magic;
   65.28 -diff --git a/fs/squashfs/xz_wrapper.c b/fs/squashfs/xz_wrapper.c
   65.29 -new file mode 100644
   65.30 -index 0000000..053fe35
   65.31 ---- /dev/null
   65.32 -+++ b/fs/squashfs/xz_wrapper.c
   65.33 -@@ -0,0 +1,153 @@
   65.34 -+/*
   65.35 -+ * Squashfs - a compressed read only filesystem for Linux
   65.36 -+ *
   65.37 -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
   65.38 -+ * Phillip Lougher <phillip@lougher.demon.co.uk>
   65.39 -+ *
   65.40 -+ * This program is free software; you can redistribute it and/or
   65.41 -+ * modify it under the terms of the GNU General Public License
   65.42 -+ * as published by the Free Software Foundation; either version 2,
   65.43 -+ * or (at your option) any later version.
   65.44 -+ *
   65.45 -+ * This program is distributed in the hope that it will be useful,
   65.46 -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
   65.47 -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   65.48 -+ * GNU General Public License for more details.
   65.49 -+ *
   65.50 -+ * You should have received a copy of the GNU General Public License
   65.51 -+ * along with this program; if not, write to the Free Software
   65.52 -+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   65.53 -+ *
   65.54 -+ * xz_wrapper.c
   65.55 -+ */
   65.56 -+
   65.57 -+
   65.58 -+#include <linux/mutex.h>
   65.59 -+#include <linux/buffer_head.h>
   65.60 -+#include <linux/slab.h>
   65.61 -+#include <linux/xz.h>
   65.62 -+
   65.63 -+#include "squashfs_fs.h"
   65.64 -+#include "squashfs_fs_sb.h"
   65.65 -+#include "squashfs_fs_i.h"
   65.66 -+#include "squashfs.h"
   65.67 -+#include "decompressor.h"
   65.68 -+
   65.69 -+struct squashfs_xz {
   65.70 -+	struct xz_dec *state;
   65.71 -+	struct xz_buf buf;
   65.72 -+};
   65.73 -+
   65.74 -+static void *squashfs_xz_init(struct squashfs_sb_info *msblk)
   65.75 -+{
   65.76 -+        int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
   65.77 -+
   65.78 -+        struct squashfs_xz *stream = kmalloc(sizeof(*stream), GFP_KERNEL);
   65.79 -+        if (stream == NULL)
   65.80 -+                goto failed;
   65.81 -+	stream->state = xz_dec_init(XZ_PREALLOC, block_size);
   65.82 -+	if (stream->state == NULL)
   65.83 -+		goto failed;
   65.84 -+
   65.85 -+	return stream;
   65.86 -+
   65.87 -+failed:
   65.88 -+	ERROR("Failed to allocate xz workspace\n");
   65.89 -+	kfree(stream);
   65.90 -+	return NULL;
   65.91 -+}
   65.92 -+
   65.93 -+
   65.94 -+static void squashfs_xz_free(void *strm)
   65.95 -+{
   65.96 -+	struct squashfs_xz *stream = strm;
   65.97 -+
   65.98 -+	if (stream) {
   65.99 -+		xz_dec_end(stream->state);
  65.100 -+		kfree(stream);
  65.101 -+	}
  65.102 -+}
  65.103 -+
  65.104 -+
  65.105 -+static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void **buffer,
  65.106 -+	struct buffer_head **bh, int b, int offset, int length, int srclength,
  65.107 -+	int pages)
  65.108 -+{
  65.109 -+	enum xz_ret xz_err;
  65.110 -+	int avail, total = 0, k = 0, page = 0;
  65.111 -+	struct squashfs_xz *stream = msblk->stream;
  65.112 -+
  65.113 -+	mutex_lock(&msblk->read_data_mutex);
  65.114 -+
  65.115 -+	xz_dec_reset(stream->state);
  65.116 -+	stream->buf.in_pos = 0;
  65.117 -+	stream->buf.in_size = 0;
  65.118 -+	stream->buf.out_pos = 0;
  65.119 -+	stream->buf.out_size = PAGE_CACHE_SIZE;
  65.120 -+	stream->buf.out = buffer[page++];
  65.121 -+
  65.122 -+	do {
  65.123 -+		if (stream->buf.in_pos == stream->buf.in_size && k < b) {
  65.124 -+			avail = min(length, msblk->devblksize - offset);
  65.125 -+			length -= avail;
  65.126 -+			wait_on_buffer(bh[k]);
  65.127 -+			if (!buffer_uptodate(bh[k]))
  65.128 -+				goto release_mutex;
  65.129 -+
  65.130 -+			if (avail == 0) {
  65.131 -+				offset = 0;
  65.132 -+				put_bh(bh[k++]);
  65.133 -+				continue;
  65.134 -+			}
  65.135 -+
  65.136 -+			stream->buf.in = bh[k]->b_data + offset;
  65.137 -+			stream->buf.in_size = avail;
  65.138 -+			stream->buf.in_pos = 0;
  65.139 -+			offset = 0;
  65.140 -+		}
  65.141 -+
  65.142 -+		if (stream->buf.out_pos == stream->buf.out_size
  65.143 -+							&& page < pages) {
  65.144 -+			stream->buf.out = buffer[page++];
  65.145 -+			stream->buf.out_pos = 0;
  65.146 -+			total += PAGE_CACHE_SIZE;
  65.147 -+		}
  65.148 -+
  65.149 -+		xz_err = xz_dec_run(stream->state, &stream->buf);
  65.150 -+
  65.151 -+		if (stream->buf.in_pos == stream->buf.in_size && k < b)
  65.152 -+			put_bh(bh[k++]);
  65.153 -+	} while (xz_err == XZ_OK);
  65.154 -+
  65.155 -+	if (xz_err != XZ_STREAM_END) {
  65.156 -+		ERROR("xz_dec_run error, data probably corrupt\n");
  65.157 -+		goto release_mutex;
  65.158 -+	}
  65.159 -+
  65.160 -+	if (k < b) {
  65.161 -+		ERROR("xz_uncompress error, input remaining\n");
  65.162 -+		goto release_mutex;
  65.163 -+	}
  65.164 -+
  65.165 -+	total += stream->buf.out_pos;
  65.166 -+	mutex_unlock(&msblk->read_data_mutex);
  65.167 -+	return total;
  65.168 -+
  65.169 -+release_mutex:
  65.170 -+	mutex_unlock(&msblk->read_data_mutex);
  65.171 -+
  65.172 -+	for (; k < b; k++)
  65.173 -+		put_bh(bh[k]);
  65.174 -+
  65.175 -+	return -EIO;
  65.176 -+}
  65.177 -+
  65.178 -+const struct squashfs_decompressor squashfs_xz_comp_ops = {
  65.179 -+	.init = squashfs_xz_init,
  65.180 -+	.free = squashfs_xz_free,
  65.181 -+	.decompress = squashfs_xz_uncompress,
  65.182 -+	.id = XZ_COMPRESSION,
  65.183 -+	.name = "xz",
  65.184 -+	.supported = 1
  65.185 -+};
  65.186 -+
    66.1 --- a/kernel-modular/stuff/005-squashfs-add-xz-compression-configuration-option.patch	Thu Jul 18 13:24:21 2013 +0000
    66.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.3 @@ -1,86 +0,0 @@
    66.4 -From: Phillip Lougher <phillip@lougher.demon.co.uk>
    66.5 -Date: Thu, 9 Dec 2010 02:08:31 +0000 (+0000)
    66.6 -Subject: Squashfs: Add XZ compression configuration option
    66.7 -X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fpkl%2Fsquashfs-xz.git;a=commitdiff_plain;h=e23d468968e608de27328888240de27d7582ad52
    66.8 -
    66.9 -Squashfs: Add XZ compression configuration option
   66.10 -
   66.11 -Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
   66.12 ----
   66.13 -
   66.14 -diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
   66.15 -index e5f63da..e96d99a 100644
   66.16 ---- a/fs/squashfs/Kconfig
   66.17 -+++ b/fs/squashfs/Kconfig
   66.18 -@@ -53,6 +53,22 @@ config SQUASHFS_LZO
   66.19 - 
   66.20 - 	  If unsure, say N.
   66.21 - 
   66.22 -+config SQUASHFS_XZ
   66.23 -+	bool "Include support for XZ compressed file systems"
   66.24 -+	depends on SQUASHFS
   66.25 -+	default n
   66.26 -+	select XZ_DEC
   66.27 -+	help
   66.28 -+	  Saying Y here includes support for reading Squashfs file systems
   66.29 -+	  compressed with XZ compresssion.  XZ gives better compression than
   66.30 -+	  the default zlib compression, at the expense of greater CPU and
   66.31 -+	  memory overhead.
   66.32 -+
   66.33 -+	  XZ is not the standard compression used in Squashfs and so most
   66.34 -+	  file systems will be readable without selecting this option.
   66.35 -+
   66.36 -+	  If unsure, say N.
   66.37 -+
   66.38 - config SQUASHFS_EMBEDDED
   66.39 - 	bool "Additional option for memory-constrained systems"
   66.40 - 	depends on SQUASHFS
   66.41 -diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
   66.42 -index 7672bac..cecf2be 100644
   66.43 ---- a/fs/squashfs/Makefile
   66.44 -+++ b/fs/squashfs/Makefile
   66.45 -@@ -7,3 +7,4 @@ squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
   66.46 - squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
   66.47 - squashfs-$(CONFIG_SQUASHFS_XATTR) += xattr.o xattr_id.o
   66.48 - squashfs-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
   66.49 -+squashfs-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
   66.50 -diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c
   66.51 -index 24af9ce..ac333b8 100644
   66.52 ---- a/fs/squashfs/decompressor.c
   66.53 -+++ b/fs/squashfs/decompressor.c
   66.54 -@@ -46,6 +46,12 @@ static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = {
   66.55 - };
   66.56 - #endif
   66.57 - 
   66.58 -+#ifndef CONFIG_SQUASHFS_XZ
   66.59 -+static const struct squashfs_decompressor squashfs_xz_unsupported_comp_ops = {
   66.60 -+	NULL, NULL, NULL, XZ_COMPRESSION, "xz", 0
   66.61 -+};
   66.62 -+#endif
   66.63 -+
   66.64 - static const struct squashfs_decompressor squashfs_unknown_comp_ops = {
   66.65 - 	NULL, NULL, NULL, 0, "unknown", 0
   66.66 - };
   66.67 -@@ -58,6 +64,11 @@ static const struct squashfs_decompressor *decompressor[] = {
   66.68 - #else
   66.69 - 	&squashfs_lzo_unsupported_comp_ops,
   66.70 - #endif
   66.71 -+#ifdef CONFIG_SQUASHFS_XZ
   66.72 -+	&squashfs_xz_comp_ops,
   66.73 -+#else
   66.74 -+	&squashfs_xz_unsupported_comp_ops,
   66.75 -+#endif
   66.76 - 	&squashfs_unknown_comp_ops
   66.77 - };
   66.78 - 
   66.79 -diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
   66.80 -index 5d45569..1096e2e 100644
   66.81 ---- a/fs/squashfs/squashfs.h
   66.82 -+++ b/fs/squashfs/squashfs.h
   66.83 -@@ -107,3 +107,6 @@ extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
   66.84 - 
   66.85 - /* lzo_wrapper.c */
   66.86 - extern const struct squashfs_decompressor squashfs_lzo_comp_ops;
   66.87 -+
   66.88 -+/* xz_wrapper.c */
   66.89 -+extern const struct squashfs_decompressor squashfs_xz_comp_ops;
    67.1 --- a/kernel-modular/stuff/aufs2-2.6.36-fix.patch	Thu Jul 18 13:24:21 2013 +0000
    67.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.3 @@ -1,130 +0,0 @@
    67.4 -diff --git a/fs/file_table.c b/fs/file_table.c
    67.5 -index a04bdd8..fbf8908 100644
    67.6 ---- a/fs/file_table.c
    67.7 -+++ b/fs/file_table.c
    67.8 -@@ -20,7 +20,6 @@
    67.9 - #include <linux/cdev.h>
   67.10 - #include <linux/fsnotify.h>
   67.11 - #include <linux/sysctl.h>
   67.12 --#include <linux/lglock.h>
   67.13 - #include <linux/percpu_counter.h>
   67.14 - #include <linux/percpu.h>
   67.15 - #include <linux/ima.h>
   67.16 -@@ -34,7 +33,6 @@ struct files_stat_struct files_stat = {
   67.17 - 	.max_files = NR_FILE
   67.18 - };
   67.19 - 
   67.20 --DECLARE_LGLOCK(files_lglock);
   67.21 - DEFINE_LGLOCK(files_lglock);
   67.22 - 
   67.23 - /* SLAB cache for file structures */
   67.24 -@@ -394,37 +392,6 @@ void file_sb_list_del(struct file *file)
   67.25 - 	}
   67.26 - }
   67.27 - 
   67.28 --#ifdef CONFIG_SMP
   67.29 --
   67.30 --/*
   67.31 -- * These macros iterate all files on all CPUs for a given superblock.
   67.32 -- * files_lglock must be held globally.
   67.33 -- */
   67.34 --#define do_file_list_for_each_entry(__sb, __file)		\
   67.35 --{								\
   67.36 --	int i;							\
   67.37 --	for_each_possible_cpu(i) {				\
   67.38 --		struct list_head *list;				\
   67.39 --		list = per_cpu_ptr((__sb)->s_files, i);		\
   67.40 --		list_for_each_entry((__file), list, f_u.fu_list)
   67.41 --
   67.42 --#define while_file_list_for_each_entry				\
   67.43 --	}							\
   67.44 --}
   67.45 --
   67.46 --#else
   67.47 --
   67.48 --#define do_file_list_for_each_entry(__sb, __file)		\
   67.49 --{								\
   67.50 --	struct list_head *list;					\
   67.51 --	list = &(sb)->s_files;					\
   67.52 --	list_for_each_entry((__file), list, f_u.fu_list)
   67.53 --
   67.54 --#define while_file_list_for_each_entry				\
   67.55 --}
   67.56 --
   67.57 --#endif
   67.58 --
   67.59 - int fs_may_remount_ro(struct super_block *sb)
   67.60 - {
   67.61 - 	struct file *file;
   67.62 -diff --git a/fs/statfs.c b/fs/statfs.c
   67.63 -index 30ea8c8..9025c98 100644
   67.64 ---- a/fs/statfs.c
   67.65 -+++ b/fs/statfs.c
   67.66 -@@ -61,6 +61,7 @@ int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
   67.67 - 		buf->f_frsize = buf->f_bsize;
   67.68 - 	return retval;
   67.69 - }
   67.70 -+EXPORT_SYMBOL(statfs_by_dentry);
   67.71 - 
   67.72 - int vfs_statfs(struct path *path, struct kstatfs *buf)
   67.73 - {
   67.74 -diff --git a/include/linux/fs.h b/include/linux/fs.h
   67.75 -index 63d069b..741d296 100644
   67.76 ---- a/include/linux/fs.h
   67.77 -+++ b/include/linux/fs.h
   67.78 -@@ -9,6 +9,7 @@
   67.79 - #include <linux/limits.h>
   67.80 - #include <linux/ioctl.h>
   67.81 - #include <linux/blk_types.h>
   67.82 -+#include <linux/lglock.h>
   67.83 - 
   67.84 - /*
   67.85 -  * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
   67.86 -@@ -1814,6 +1815,7 @@ extern struct vfsmount *collect_mounts(struct path *);
   67.87 - extern void drop_collected_mounts(struct vfsmount *);
   67.88 - extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
   67.89 - 			  struct vfsmount *);
   67.90 -+extern int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf);
   67.91 - extern int vfs_statfs(struct path *, struct kstatfs *);
   67.92 - extern int statfs_by_dentry(struct dentry *, struct kstatfs *);
   67.93 - extern int freeze_super(struct super_block *super);
   67.94 -@@ -2481,5 +2483,39 @@ int __init get_filesystem_list(char *buf);
   67.95 - #define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \
   67.96 - 					    (flag & FMODE_NONOTIFY)))
   67.97 - 
   67.98 -+
   67.99 -+DECLARE_LGLOCK(files_lglock);
  67.100 -+
  67.101 -+#ifdef CONFIG_SMP
  67.102 -+
  67.103 -+/*
  67.104 -+ * These macros iterate all files on all CPUs for a given superblock.
  67.105 -+ * files_lglock must be held globally.
  67.106 -+ */
  67.107 -+#define do_file_list_for_each_entry(__sb, __file)		\
  67.108 -+{								\
  67.109 -+	int i;							\
  67.110 -+	for_each_possible_cpu(i) {				\
  67.111 -+		struct list_head *list;				\
  67.112 -+		list = per_cpu_ptr((__sb)->s_files, i);		\
  67.113 -+		list_for_each_entry((__file), list, f_u.fu_list)
  67.114 -+
  67.115 -+#define while_file_list_for_each_entry				\
  67.116 -+	}							\
  67.117 -+}
  67.118 -+
  67.119 -+#else
  67.120 -+
  67.121 -+#define do_file_list_for_each_entry(__sb, __file)		\
  67.122 -+{								\
  67.123 -+	struct list_head *list;					\
  67.124 -+	list = &(sb)->s_files;					\
  67.125 -+	list_for_each_entry((__file), list, f_u.fu_list)
  67.126 -+
  67.127 -+#define while_file_list_for_each_entry				\
  67.128 -+}
  67.129 -+
  67.130 -+#endif
  67.131 -+
  67.132 - #endif /* __KERNEL__ */
  67.133 - #endif /* _LINUX_FS_H */
    68.1 --- a/kernel-modular/stuff/aufs2-base.patch	Thu Jul 18 13:24:21 2013 +0000
    68.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.3 @@ -1,78 +0,0 @@
    68.4 -aufs2.1 base patch for linux-2.6.37
    68.5 -
    68.6 -diff --git a/fs/namei.c b/fs/namei.c
    68.7 -index 4ff7ca5..a8c583f 100644
    68.8 ---- a/fs/namei.c
    68.9 -+++ b/fs/namei.c
   68.10 -@@ -1161,12 +1161,12 @@ out:
   68.11 -  * needs parent already locked. Doesn't follow mounts.
   68.12 -  * SMP-safe.
   68.13 -  */
   68.14 --static struct dentry *lookup_hash(struct nameidata *nd)
   68.15 -+struct dentry *lookup_hash(struct nameidata *nd)
   68.16 - {
   68.17 - 	return __lookup_hash(&nd->last, nd->path.dentry, nd);
   68.18 - }
   68.19 - 
   68.20 --static int __lookup_one_len(const char *name, struct qstr *this,
   68.21 -+int __lookup_one_len(const char *name, struct qstr *this,
   68.22 - 		struct dentry *base, int len)
   68.23 - {
   68.24 - 	unsigned long hash;
   68.25 -diff --git a/fs/splice.c b/fs/splice.c
   68.26 -index ce2f025..ff0ae69 100644
   68.27 ---- a/fs/splice.c
   68.28 -+++ b/fs/splice.c
   68.29 -@@ -1092,8 +1092,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
   68.30 - /*
   68.31 -  * Attempt to initiate a splice from pipe to file.
   68.32 -  */
   68.33 --static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
   68.34 --			   loff_t *ppos, size_t len, unsigned int flags)
   68.35 -+long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
   68.36 -+		    loff_t *ppos, size_t len, unsigned int flags)
   68.37 - {
   68.38 - 	ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
   68.39 - 				loff_t *, size_t, unsigned int);
   68.40 -@@ -1120,9 +1120,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
   68.41 - /*
   68.42 -  * Attempt to initiate a splice from a file to a pipe.
   68.43 -  */
   68.44 --static long do_splice_to(struct file *in, loff_t *ppos,
   68.45 --			 struct pipe_inode_info *pipe, size_t len,
   68.46 --			 unsigned int flags)
   68.47 -+long do_splice_to(struct file *in, loff_t *ppos,
   68.48 -+		  struct pipe_inode_info *pipe, size_t len,
   68.49 -+		  unsigned int flags)
   68.50 - {
   68.51 - 	ssize_t (*splice_read)(struct file *, loff_t *,
   68.52 - 			       struct pipe_inode_info *, size_t, unsigned int);
   68.53 -diff --git a/include/linux/namei.h b/include/linux/namei.h
   68.54 -index 05b441d..91bc74e 100644
   68.55 ---- a/include/linux/namei.h
   68.56 -+++ b/include/linux/namei.h
   68.57 -@@ -73,6 +73,9 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
   68.58 - extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
   68.59 - 		int (*open)(struct inode *, struct file *));
   68.60 - 
   68.61 -+extern struct dentry *lookup_hash(struct nameidata *nd);
   68.62 -+extern int __lookup_one_len(const char *name, struct qstr *this,
   68.63 -+			    struct dentry *base, int len);
   68.64 - extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
   68.65 - 
   68.66 - extern int follow_down(struct path *);
   68.67 -diff --git a/include/linux/splice.h b/include/linux/splice.h
   68.68 -index 997c3b4..be9a153 100644
   68.69 ---- a/include/linux/splice.h
   68.70 -+++ b/include/linux/splice.h
   68.71 -@@ -89,4 +89,10 @@ extern int splice_grow_spd(struct pipe_inode_info *, struct splice_pipe_desc *);
   68.72 - extern void splice_shrink_spd(struct pipe_inode_info *,
   68.73 - 				struct splice_pipe_desc *);
   68.74 - 
   68.75 -+extern long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
   68.76 -+			   loff_t *ppos, size_t len, unsigned int flags);
   68.77 -+extern long do_splice_to(struct file *in, loff_t *ppos,
   68.78 -+			 struct pipe_inode_info *pipe, size_t len,
   68.79 -+			 unsigned int flags);
   68.80 -+
   68.81 - #endif
    69.1 --- a/kernel-modular/stuff/aufs2-kbuild.patch	Thu Jul 18 13:24:21 2013 +0000
    69.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.3 @@ -1,35 +0,0 @@
    69.4 -aufs2.1 kbuild patch for linux-2.6.37
    69.5 -
    69.6 -diff --git a/fs/Kconfig b/fs/Kconfig
    69.7 -index 771f457..bb1a52f 100644
    69.8 ---- a/fs/Kconfig
    69.9 -+++ b/fs/Kconfig
   69.10 -@@ -191,6 +191,7 @@ source "fs/romfs/Kconfig"
   69.11 - source "fs/sysv/Kconfig"
   69.12 - source "fs/ufs/Kconfig"
   69.13 - source "fs/exofs/Kconfig"
   69.14 -+source "fs/aufs/Kconfig"
   69.15 - 
   69.16 - endif # MISC_FILESYSTEMS
   69.17 - 
   69.18 -diff --git a/fs/Makefile b/fs/Makefile
   69.19 -index a7f7cef..95dd4d3 100644
   69.20 ---- a/fs/Makefile
   69.21 -+++ b/fs/Makefile
   69.22 -@@ -121,3 +121,4 @@ obj-$(CONFIG_BTRFS_FS)		+= btrfs/
   69.23 - obj-$(CONFIG_GFS2_FS)           += gfs2/
   69.24 - obj-$(CONFIG_EXOFS_FS)          += exofs/
   69.25 - obj-$(CONFIG_CEPH_FS)		+= ceph/
   69.26 -+obj-$(CONFIG_AUFS_FS)           += aufs/
   69.27 -diff --git a/include/linux/Kbuild b/include/linux/Kbuild
   69.28 -index 97319a8..7ebb4b4 100644
   69.29 ---- a/include/linux/Kbuild
   69.30 -+++ b/include/linux/Kbuild
   69.31 -@@ -60,6 +60,7 @@ header-y += atmppp.h
   69.32 - header-y += atmsap.h
   69.33 - header-y += atmsvc.h
   69.34 - header-y += audit.h
   69.35 -+header-y += aufs_type.h
   69.36 - header-y += auto_fs.h
   69.37 - header-y += auto_fs4.h
   69.38 - header-y += auxvec.h
    70.1 --- a/kernel-modular/stuff/aufs2-module-2.6.36.patch	Thu Jul 18 13:24:21 2013 +0000
    70.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.3 @@ -1,47 +0,0 @@
    70.4 -diff --git a/ubuntu/aufs/branch.c b/ubuntu/aufs/branch.c
    70.5 -index cd4463c..ff6b158 100644
    70.6 ---- a/fs/aufs/branch.c
    70.7 -+++ b/fs/aufs/branch.c
    70.8 -@@ -22,6 +22,8 @@
    70.9 - 
   70.10 - #include <linux/file.h>
   70.11 - #include <linux/statfs.h>
   70.12 -+#include <linux/lglock.h>
   70.13 -+#include <linux/percpu.h>
   70.14 - #include "aufs.h"
   70.15 - 
   70.16 - /*
   70.17 -@@ -851,7 +853,8 @@ static int au_br_mod_files_ro(struct super_block *sb, aufs_bindex_t bindex)
   70.18 - 		goto out;
   70.19 - 
   70.20 - 	/* no need file_list_lock() since sbinfo is locked? defered? */
   70.21 --	list_for_each_entry(file, &sb->s_files, f_u.fu_list) {
   70.22 -+        lg_global_lock(files_lglock);
   70.23 -+	do_file_list_for_each_entry(sb, file) {
   70.24 - 		if (special_file(file->f_dentry->d_inode->i_mode))
   70.25 - 			continue;
   70.26 - 
   70.27 -@@ -861,6 +864,7 @@ static int au_br_mod_files_ro(struct super_block *sb, aufs_bindex_t bindex)
   70.28 - 			err = -EBUSY;
   70.29 - 			FiMustNoWaiters(file);
   70.30 - 			fi_read_unlock(file);
   70.31 -+			lg_global_unlock(files_lglock);
   70.32 - 			goto out_free;
   70.33 - 		}
   70.34 - 
   70.35 -@@ -889,10 +893,13 @@ static int au_br_mod_files_ro(struct super_block *sb, aufs_bindex_t bindex)
   70.36 - 			if (p) {
   70.37 - 				a = p;
   70.38 - 				a[n++] = hf;
   70.39 --			} else
   70.40 -+			} else {
   70.41 -+				lg_global_unlock(files_lglock);
   70.42 - 				goto out_free;
   70.43 -+			}
   70.44 - 		}
   70.45 --	}
   70.46 -+	} while_file_list_for_each_entry;
   70.47 -+	lg_global_unlock(files_lglock);
   70.48 - 
   70.49 - 	err = 0;
   70.50 - 	if (n)
    71.1 --- a/kernel-modular/stuff/aufs2-standalone.patch	Thu Jul 18 13:24:21 2013 +0000
    71.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.3 @@ -1,289 +0,0 @@
    71.4 -aufs2.1 standalone patch for linux-2.6.37
    71.5 -
    71.6 -diff --git a/fs/file_table.c b/fs/file_table.c
    71.7 -index c3dee38..f529e4d 100644
    71.8 ---- a/fs/file_table.c
    71.9 -+++ b/fs/file_table.c
   71.10 -@@ -393,6 +393,8 @@ void file_sb_list_del(struct file *file)
   71.11 - 	}
   71.12 - }
   71.13 - 
   71.14 -+EXPORT_SYMBOL(file_sb_list_del);
   71.15 -+
   71.16 - #ifdef CONFIG_SMP
   71.17 - 
   71.18 - /*
   71.19 -diff --git a/fs/inode.c b/fs/inode.c
   71.20 -index ae2727a..2c8071a 100644
   71.21 ---- a/fs/inode.c
   71.22 -+++ b/fs/inode.c
   71.23 -@@ -82,6 +82,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
   71.24 -  * the i_state of an inode while it is in use..
   71.25 -  */
   71.26 - DEFINE_SPINLOCK(inode_lock);
   71.27 -+EXPORT_SYMBOL(inode_lock);
   71.28 - 
   71.29 - /*
   71.30 -  * iprune_sem provides exclusion between the kswapd or try_to_free_pages
   71.31 -diff --git a/fs/namei.c b/fs/namei.c
   71.32 -index a8c583f..b020c45 100644
   71.33 ---- a/fs/namei.c
   71.34 -+++ b/fs/namei.c
   71.35 -@@ -347,6 +347,7 @@ int deny_write_access(struct file * file)
   71.36 - 
   71.37 - 	return 0;
   71.38 - }
   71.39 -+EXPORT_SYMBOL(deny_write_access);
   71.40 - 
   71.41 - /**
   71.42 -  * path_get - get a reference to a path
   71.43 -@@ -1165,6 +1166,7 @@ struct dentry *lookup_hash(struct nameidata *nd)
   71.44 - {
   71.45 - 	return __lookup_hash(&nd->last, nd->path.dentry, nd);
   71.46 - }
   71.47 -+EXPORT_SYMBOL(lookup_hash);
   71.48 - 
   71.49 - int __lookup_one_len(const char *name, struct qstr *this,
   71.50 - 		struct dentry *base, int len)
   71.51 -@@ -1187,6 +1189,7 @@ int __lookup_one_len(const char *name, struct qstr *this,
   71.52 - 	this->hash = end_name_hash(hash);
   71.53 - 	return 0;
   71.54 - }
   71.55 -+EXPORT_SYMBOL(__lookup_one_len);
   71.56 - 
   71.57 - /**
   71.58 -  * lookup_one_len - filesystem helper to lookup single pathname component
   71.59 -diff --git a/fs/namespace.c b/fs/namespace.c
   71.60 -index 3dbfc07..3998762 100644
   71.61 ---- a/fs/namespace.c
   71.62 -+++ b/fs/namespace.c
   71.63 -@@ -1321,6 +1321,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
   71.64 - 	}
   71.65 - 	return 0;
   71.66 - }
   71.67 -+EXPORT_SYMBOL(iterate_mounts);
   71.68 - 
   71.69 - static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end)
   71.70 - {
   71.71 -diff --git a/fs/notify/group.c b/fs/notify/group.c
   71.72 -index d309f38..f0e9568 100644
   71.73 ---- a/fs/notify/group.c
   71.74 -+++ b/fs/notify/group.c
   71.75 -@@ -22,6 +22,7 @@
   71.76 - #include <linux/srcu.h>
   71.77 - #include <linux/rculist.h>
   71.78 - #include <linux/wait.h>
   71.79 -+#include <linux/module.h>
   71.80 - 
   71.81 - #include <linux/fsnotify_backend.h>
   71.82 - #include "fsnotify.h"
   71.83 -@@ -70,6 +71,7 @@ void fsnotify_put_group(struct fsnotify_group *group)
   71.84 - 	if (atomic_dec_and_test(&group->refcnt))
   71.85 - 		fsnotify_destroy_group(group);
   71.86 - }
   71.87 -+EXPORT_SYMBOL(fsnotify_put_group);
   71.88 - 
   71.89 - /*
   71.90 -  * Create a new fsnotify_group and hold a reference for the group returned.
   71.91 -@@ -102,3 +104,4 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
   71.92 - 
   71.93 - 	return group;
   71.94 - }
   71.95 -+EXPORT_SYMBOL(fsnotify_alloc_group);
   71.96 -diff --git a/fs/notify/mark.c b/fs/notify/mark.c
   71.97 -index 325185e..adede09 100644
   71.98 ---- a/fs/notify/mark.c
   71.99 -+++ b/fs/notify/mark.c
  71.100 -@@ -113,6 +113,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
  71.101 - 	if (atomic_dec_and_test(&mark->refcnt))
  71.102 - 		mark->free_mark(mark);
  71.103 - }
  71.104 -+EXPORT_SYMBOL(fsnotify_put_mark);
  71.105 - 
  71.106 - /*
  71.107 -  * Any time a mark is getting freed we end up here.
  71.108 -@@ -190,6 +191,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
  71.109 - 	if (unlikely(atomic_dec_and_test(&group->num_marks)))
  71.110 - 		fsnotify_final_destroy_group(group);
  71.111 - }
  71.112 -+EXPORT_SYMBOL(fsnotify_destroy_mark);
  71.113 - 
  71.114 - void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask)
  71.115 - {
  71.116 -@@ -277,6 +279,7 @@ err:
  71.117 - 
  71.118 - 	return ret;
  71.119 - }
  71.120 -+EXPORT_SYMBOL(fsnotify_add_mark);
  71.121 - 
  71.122 - /*
  71.123 -  * clear any marks in a group in which mark->flags & flags is true
  71.124 -@@ -332,6 +335,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
  71.125 - 	atomic_set(&mark->refcnt, 1);
  71.126 - 	mark->free_mark = free_mark;
  71.127 - }
  71.128 -+EXPORT_SYMBOL(fsnotify_init_mark);
  71.129 - 
  71.130 - static int fsnotify_mark_destroy(void *ignored)
  71.131 - {
  71.132 -diff --git a/fs/open.c b/fs/open.c
  71.133 -index 4197b9e..912817a 100644
  71.134 ---- a/fs/open.c
  71.135 -+++ b/fs/open.c
  71.136 -@@ -60,6 +60,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
  71.137 - 	mutex_unlock(&dentry->d_inode->i_mutex);
  71.138 - 	return ret;
  71.139 - }
  71.140 -+EXPORT_SYMBOL(do_truncate);
  71.141 - 
  71.142 - static long do_sys_truncate(const char __user *pathname, loff_t length)
  71.143 - {
  71.144 -diff --git a/fs/splice.c b/fs/splice.c
  71.145 -index ff0ae69..1c9e9b0 100644
  71.146 ---- a/fs/splice.c
  71.147 -+++ b/fs/splice.c
  71.148 -@@ -1116,6 +1116,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
  71.149 - 
  71.150 - 	return splice_write(pipe, out, ppos, len, flags);
  71.151 - }
  71.152 -+EXPORT_SYMBOL(do_splice_from);
  71.153 - 
  71.154 - /*
  71.155 -  * Attempt to initiate a splice from a file to a pipe.
  71.156 -@@ -1142,6 +1143,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
  71.157 - 
  71.158 - 	return splice_read(in, ppos, pipe, len, flags);
  71.159 - }
  71.160 -+EXPORT_SYMBOL(do_splice_to);
  71.161 - 
  71.162 - /**
  71.163 -  * splice_direct_to_actor - splices data directly between two non-pipes
  71.164 -diff --git a/security/commoncap.c b/security/commoncap.c
  71.165 -index 64c2ed9..e58b5d8 100644
  71.166 ---- a/security/commoncap.c
  71.167 -+++ b/security/commoncap.c
  71.168 -@@ -929,3 +929,4 @@ int cap_file_mmap(struct file *file, unsigned long reqprot,
  71.169 - 	}
  71.170 - 	return ret;
  71.171 - }
  71.172 -+EXPORT_SYMBOL(cap_file_mmap);
  71.173 -diff --git a/security/device_cgroup.c b/security/device_cgroup.c
  71.174 -index 8d9c48f..29108aa 100644
  71.175 ---- a/security/device_cgroup.c
  71.176 -+++ b/security/device_cgroup.c
  71.177 -@@ -515,6 +515,7 @@ found:
  71.178 - 
  71.179 - 	return -EPERM;
  71.180 - }
  71.181 -+EXPORT_SYMBOL(devcgroup_inode_permission);
  71.182 - 
  71.183 - int devcgroup_inode_mknod(int mode, dev_t dev)
  71.184 - {
  71.185 -diff --git a/security/security.c b/security/security.c
  71.186 -index 1b798d3..3b7d2ca 100644
  71.187 ---- a/security/security.c
  71.188 -+++ b/security/security.c
  71.189 -@@ -360,6 +360,7 @@ int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode)
  71.190 - 		return 0;
  71.191 - 	return security_ops->path_mkdir(dir, dentry, mode);
  71.192 - }
  71.193 -+EXPORT_SYMBOL(security_path_mkdir);
  71.194 - 
  71.195 - int security_path_rmdir(struct path *dir, struct dentry *dentry)
  71.196 - {
  71.197 -@@ -367,6 +368,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)
  71.198 - 		return 0;
  71.199 - 	return security_ops->path_rmdir(dir, dentry);
  71.200 - }
  71.201 -+EXPORT_SYMBOL(security_path_rmdir);
  71.202 - 
  71.203 - int security_path_unlink(struct path *dir, struct dentry *dentry)
  71.204 - {
  71.205 -@@ -374,6 +376,7 @@ int security_path_unlink(struct path *dir, struct dentry *dentry)
  71.206 - 		return 0;
  71.207 - 	return security_ops->path_unlink(dir, dentry);
  71.208 - }
  71.209 -+EXPORT_SYMBOL(security_path_unlink);
  71.210 - 
  71.211 - int security_path_symlink(struct path *dir, struct dentry *dentry,
  71.212 - 			  const char *old_name)
  71.213 -@@ -382,6 +385,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
  71.214 - 		return 0;
  71.215 - 	return security_ops->path_symlink(dir, dentry, old_name);
  71.216 - }
  71.217 -+EXPORT_SYMBOL(security_path_symlink);
  71.218 - 
  71.219 - int security_path_link(struct dentry *old_dentry, struct path *new_dir,
  71.220 - 		       struct dentry *new_dentry)
  71.221 -@@ -390,6 +394,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
  71.222 - 		return 0;
  71.223 - 	return security_ops->path_link(old_dentry, new_dir, new_dentry);
  71.224 - }
  71.225 -+EXPORT_SYMBOL(security_path_link);
  71.226 - 
  71.227 - int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
  71.228 - 			 struct path *new_dir, struct dentry *new_dentry)
  71.229 -@@ -400,6 +405,7 @@ int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
  71.230 - 	return security_ops->path_rename(old_dir, old_dentry, new_dir,
  71.231 - 					 new_dentry);
  71.232 - }
  71.233 -+EXPORT_SYMBOL(security_path_rename);
  71.234 - 
  71.235 - int security_path_truncate(struct path *path)
  71.236 - {
  71.237 -@@ -407,6 +413,7 @@ int security_path_truncate(struct path *path)
  71.238 - 		return 0;
  71.239 - 	return security_ops->path_truncate(path);
  71.240 - }
  71.241 -+EXPORT_SYMBOL(security_path_truncate);
  71.242 - 
  71.243 - int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
  71.244 - 			mode_t mode)
  71.245 -@@ -415,6 +422,7 @@ int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
  71.246 - 		return 0;
  71.247 - 	return security_ops->path_chmod(dentry, mnt, mode);
  71.248 - }
  71.249 -+EXPORT_SYMBOL(security_path_chmod);
  71.250 - 
  71.251 - int security_path_chown(struct path *path, uid_t uid, gid_t gid)
  71.252 - {
  71.253 -@@ -422,6 +430,7 @@ int security_path_chown(struct path *path, uid_t uid, gid_t gid)
  71.254 - 		return 0;
  71.255 - 	return security_ops->path_chown(path, uid, gid);
  71.256 - }
  71.257 -+EXPORT_SYMBOL(security_path_chown);
  71.258 - 
  71.259 - int security_path_chroot(struct path *path)
  71.260 - {
  71.261 -@@ -498,6 +507,7 @@ int security_inode_readlink(struct dentry *dentry)
  71.262 - 		return 0;
  71.263 - 	return security_ops->inode_readlink(dentry);
  71.264 - }
  71.265 -+EXPORT_SYMBOL(security_inode_readlink);
  71.266 - 
  71.267 - int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd)
  71.268 - {
  71.269 -@@ -512,6 +522,7 @@ int security_inode_permission(struct inode *inode, int mask)
  71.270 - 		return 0;
  71.271 - 	return security_ops->inode_permission(inode, mask);
  71.272 - }
  71.273 -+EXPORT_SYMBOL(security_inode_permission);
  71.274 - 
  71.275 - int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
  71.276 - {
  71.277 -@@ -611,6 +622,7 @@ int security_file_permission(struct file *file, int mask)
  71.278 - 
  71.279 - 	return fsnotify_perm(file, mask);
  71.280 - }
  71.281 -+EXPORT_SYMBOL(security_file_permission);
  71.282 - 
  71.283 - int security_file_alloc(struct file *file)
  71.284 - {
  71.285 -@@ -638,6 +650,7 @@ int security_file_mmap(struct file *file, unsigned long reqprot,
  71.286 - 		return ret;
  71.287 - 	return ima_file_mmap(file, prot);
  71.288 - }
  71.289 -+EXPORT_SYMBOL(security_file_mmap);
  71.290 - 
  71.291 - int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
  71.292 - 			    unsigned long prot)
    72.1 --- a/kernel-modular/stuff/bootloader.sh	Thu Jul 18 13:24:21 2013 +0000
    72.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.3 @@ -1,218 +0,0 @@
    72.4 -#!/bin/sh
    72.5 -#
    72.6 -# This script creates a floppy image set from a linux bzImage and can merge
    72.7 -# a cmdline and/or one or more initramfs.
    72.8 -# The total size can not exceed 15M because INT 15H function 87H limitations.
    72.9 -#
   72.10 -# (C) 2009 Pascal Bellard - GNU General Public License v3.
   72.11 -
   72.12 -usage()
   72.13 -{
   72.14 -cat <<EOT
   72.15 -Usage: $0 bzImage [--prefix image_prefix] [--cmdline 'args']
   72.16 -       [--rdev device] [--video mode] [--flags rootflags] [--tracks cnt]
   72.17 -       [--format 1440|1680|1920|2880 ] [--initrd initrdfile]...
   72.18 -
   72.19 -Default values: --format 1440 --tracks 80 --prefix floppy.
   72.20 -
   72.21 -Example:
   72.22 -$0 /boot/vmlinuz-2.6.30.6 --rdev /dev/ram0 --video -3 --cmdline 'rw lang=fr_FR kmap=fr-latin1 laptop autologin' --initrd /boot/rootfs.gz --initrd ./myconfig.gz
   72.23 -EOT
   72.24 -exit 1
   72.25 -}
   72.26 -
   72.27 -KERNEL=""
   72.28 -INITRD=""
   72.29 -CMDLINE=""
   72.30 -PREFIX="floppy."
   72.31 -FORMAT="1440"
   72.32 -RDEV=""
   72.33 -VIDEO=""
   72.34 -FLAGS=""
   72.35 -TRACKS=""
   72.36 -DEBUG=""
   72.37 -while [ -n "$1" ]; do
   72.38 -	case "$1" in
   72.39 -	--c*|-c*)  CMDLINE="$2"; shift;;
   72.40 -	--i*|-i*)  INITRD="$INITRD $2"; shift;;
   72.41 -	--p*|-p*)  PREFIX="$2"; shift;;
   72.42 -	--fo*|-f*) FORMAT="$2"; shift;;
   72.43 -	--fl*)     FLAGS="$2"; shift;;	# 1 read-only, 0 read-write
   72.44 -	--r*|-r*)  RDEV="$2"; shift;;	# /dev/???
   72.45 -	--v*|-v*)  VIDEO="$2"; shift;;	# -3 .. n
   72.46 -	--t*|-t*)  TRACKS="$2"; shift;; # likely 81 .. 84
   72.47 -	--debug)   DEBUG="1";;
   72.48 -	*) KERNEL="$1";;
   72.49 -	esac
   72.50 -	shift
   72.51 -done
   72.52 -[ -n "$KERNEL" -a -f "$KERNEL" ] || usage
   72.53 -if [ -n "$TRACKS" ]; then
   72.54 -	if [ $(( $FORMAT % $TRACKS )) -ne 0 ]; then
   72.55 -		echo "Invalid track count for format $FORMAT."
   72.56 -		usage
   72.57 -	fi
   72.58 -fi
   72.59 -
   72.60 -# write a 16 bits data
   72.61 -# usage: store16 offset data16 file
   72.62 -store16()
   72.63 -{
   72.64 -	echo $(( $2 + 0x10000 )) | \
   72.65 -		awk '{ printf "\\\\x%02X\\\\x%02X",$1%256,($1/256)%256 }' | \
   72.66 -		xargs echo -en | \
   72.67 -	dd bs=2 conv=notrunc of=$3 seek=$(( $1 / 2 )) 2> /dev/null
   72.68 -	[ -n "$DEBUG" ] && printf "store16(%04X) = %04X\n" $1 $2 1>&2
   72.69 -}
   72.70 -
   72.71 -# write a 32 bits data
   72.72 -# usage: storelong offset data32 file
   72.73 -storelong()
   72.74 -{
   72.75 -	echo $2 | awk '{ printf "\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X",
   72.76 -		 $1%256,($1/256)%256,($1/256/256)%256,($1/256/256/256)%256 }' | \
   72.77 -		xargs echo -en | \
   72.78 -		dd bs=4 conv=notrunc of=$3 seek=$(( $1 / 4 )) 2> /dev/null
   72.79 -	[ -n "$DEBUG" ] && printf "storelong(%04X) = %08X\n" $1 $2 1>&2
   72.80 -}
   72.81 -
   72.82 -# read a 32 bits data
   72.83 -# usage: getlong offset file
   72.84 -getlong()
   72.85 -{
   72.86 -	dd if=$2 bs=1 skip=$(( $1 )) count=4 2> /dev/null | \
   72.87 -		hexdump -e '"" 1/4 "%d" "\n"'
   72.88 -}
   72.89 -
   72.90 -floppyset()
   72.91 -{
   72.92 -	# bzImage offsets
   72.93 -	CylinderCount=496
   72.94 -	SetupSzOfs=497
   72.95 -	FlagsOfs=498
   72.96 -	SyssizeOfs=500
   72.97 -	VideoModeOfs=506
   72.98 -	RootDevOfs=508
   72.99 -	CodeAdrOfs=0x214
  72.100 -	RamfsAdrOfs=0x218
  72.101 -	RamfsLenOfs=0x21C
  72.102 -	ArgPtrOfs=0x228
  72.103 -
  72.104 -	# boot+setup address
  72.105 -	SetupBase=0x90000
  72.106 -
  72.107 -	stacktop=0x9E00
  72.108 -
  72.109 -	bs=/tmp/bs$$
  72.110 -
  72.111 -	# Get and patch boot sector
  72.112 -	# See  http://hg.slitaz.org/wok/raw-file/711d076b277c/linux/stuff/linux-header-2.6.34.u
  72.113 -	dd if=$KERNEL bs=512 count=1 of=$bs 2> /dev/null
  72.114 -	uudecode <<EOT | dd of=$bs conv=notrunc 2> /dev/null
  72.115 -begin-base64 644 -
  72.116 -/L+6nWgAkAcGF4n8McC5HQDzq1sfD6mg8X1ABlfFd3ixBvOlZWaPR3gGH8ZF
  72.117 -+D/6l1hB6DQBvgACA3QO6HYBWwseKAJ0LFNH6AoBXuhmAbAgzRCwCM0QTuhl
  72.118 -ATwIdAOIBK05NigCdPDoPgE8CnXgiHz+ieb/TBD/TBi/9AGBTRz/gMdFMACc
  72.119 -sBCxBUi0k4lEHLABiUQUmGaY0+BIZgMFZtPoaAAQB7+AACn4nHMCAccx21BW
  72.120 -6J4AXrkAgLSH/kQczRVYnXfcoRoCvxwCsQk4RBxyuJPNE+oAACCQsEYoyL7b
  72.121 -AejSAF3rI4D5E3IEOMF3a4D+AnIEOOZ3bGCB/QAGdCoGUlFTlrQCULEGtQTB
  72.122 -xQSwDyHoBJAnFEAn6IwA/s117LAgzRDitOiWAJjNE2FSUCjIdwKwAZg5+HIC
  72.123 -ifhQtALNE5VeWFpyoJVBjuGAxwJPdFFOdfSM4ZU4wXVFiMj+xrEBOOZ1O4j0
  72.124 -/sW2AID9UHIwOi7wAXIqtQBgvt4B/kQMU+gxAFvoOAB1FlKYzRO4AQLNE1rQ
  72.125 -1Dpk/nXqRgjkdeVh64sWB7AxLAO0DrsHAM0QPA1088OwDejv/6wIwHX4w79s
  72.126 -BLFbZQINuA0BZToNdArNFnT0mM0Wju9Hw1g6AEluc2VydCBkaXNrIDEuBw0A
  72.127 -AA==
  72.128 -====
  72.129 -EOT
  72.130 -
  72.131 -	# Get setup
  72.132 -	setupsz=$(getlong $SetupSzOfs $bs)
  72.133 -	setupszb=$(( $setupsz & 255 ))
  72.134 -	dd if=$KERNEL bs=512 skip=1 count=$setupszb 2> /dev/null >> $bs
  72.135 -
  72.136 -	if [ -n "$TRACKS" ]; then
  72.137 -		[ -n "$DEBUG" ] && echo -n "--tracks " 1>&2
  72.138 -		n=$(getlong $CylinderCount $bs)
  72.139 -		store16 $CylinderCount $(( ($n & -256) + $TRACKS )) $bs
  72.140 -	fi
  72.141 -	if [ -n "$FLAGS" ]; then
  72.142 -		[ -n "$DEBUG" ] && echo -n "--flags " 1>&2
  72.143 -		store16 $FlagsOfs $FLAGS $bs
  72.144 -	fi
  72.145 -	if [ -n "$VIDEO" ]; then
  72.146 -		[ -n "$DEBUG" ] && echo -n "--video " 1>&2
  72.147 -		store16 $VideoModeOfs $VIDEO $bs
  72.148 -	fi
  72.149 -	if [ -n "$RDEV" ]; then
  72.150 -		[ -n "$DEBUG" ] && echo -n "--rdev " 1>&2
  72.151 -		n=$(stat -c '0x%02t%02T' $RDEV 2> /dev/null)
  72.152 -		[ -n "$n" ] || n=$RDEV
  72.153 -		store16 $RootDevOfs $n $bs
  72.154 -	fi
  72.155 -
  72.156 -	# Store cmdline after setup
  72.157 -	if [ -n "$CMDLINE" ]; then
  72.158 -		[ -n "$DEBUG" ] && echo -n "--cmdline '$CMDLINE' " 1>&2
  72.159 -		echo -n "$CMDLINE" | dd bs=512 count=1 conv=sync 2> /dev/null >> $bs
  72.160 -		storelong $ArgPtrOfs $(( $SetupBase + $stacktop )) $bs
  72.161 -	fi
  72.162 -
  72.163 -	# Compute initramfs size
  72.164 -	initrdlen=0
  72.165 -	padding=0
  72.166 -	for i in $( echo $INITRD | sed 's/,/ /' ); do
  72.167 -		[ -s "$i" ] || continue
  72.168 -		[ -n "$DEBUG" ] && echo "--initrd $i " 1>&2
  72.169 -		initrdlen=$(( $initrdlen + $padding ))
  72.170 -		padding=$(stat -c %s $i)
  72.171 -		initrdlen=$(( $initrdlen + $padding ))
  72.172 -		padding=$(( 4096 - ($padding & 4095) ))
  72.173 -		[ $padding -eq 4096 ] && padding=0
  72.174 -	done
  72.175 -	Ksize=$(( $(getlong $SyssizeOfs $bs)*16 ))
  72.176 -	Kpad=$(( (($Ksize+4095)/4096)*4096 - Ksize ))
  72.177 -	if [ $initrdlen -ne 0 ]; then
  72.178 -		[ -n "$DEBUG" ] && echo "initrdlen = $initrdlen " 1>&2
  72.179 -		Kbase=$(getlong $CodeAdrOfs $bs)
  72.180 -		storelong $RamfsAdrOfs \
  72.181 -			$(( (0x1000000 - $initrdlen) & 0xFFFF0000 )) $bs
  72.182 -		storelong $RamfsLenOfs $(( ($initrdlen + 3) & -4 )) $bs
  72.183 -	fi
  72.184 -
  72.185 -	# Output boot sector + setup + cmdline
  72.186 -	dd if=$bs 2> /dev/null
  72.187 -
  72.188 -	# Output kernel code
  72.189 -	dd if=$KERNEL bs=512 skip=$(( $setupszb + 1 )) 2> /dev/null
  72.190 -
  72.191 -	# Pad to next sector
  72.192 -	Kpad=$(( 512 - ($(stat -c %s $KERNEL) & 511) ))
  72.193 -	[ $Kpad -eq 512 ] || dd if=/dev/zero bs=1 count=$Kpad 2> /dev/null
  72.194 -
  72.195 -	# Output initramfs
  72.196 -	padding=0
  72.197 -	for i in $( echo $INITRD | sed 's/,/ /' ); do
  72.198 -		[ -s "$i" ] || continue
  72.199 -		[ $padding -ne 0 ] && dd if=/dev/zero bs=1 count=$padding 2> /dev/null
  72.200 -		dd if=$i 2> /dev/null
  72.201 -		padding=$(( 4 - ($(stat -c %s $i) & 3) ))
  72.202 -		[ $padding -eq 4 ] && padding=0
  72.203 -	done
  72.204 -
  72.205 -	# Cleanup
  72.206 -	rm -f $bs
  72.207 -}
  72.208 -
  72.209 -if [ "$FORMAT" == "0" ]; then # unsplitted
  72.210 -	floppyset > $PREFIX
  72.211 -	exit
  72.212 -fi
  72.213 -floppyset | split -b ${FORMAT}k /dev/stdin floppy$$
  72.214 -i=1
  72.215 -ls floppy$$* | while read file ; do
  72.216 -	output=$PREFIX$(printf "%03d" $i)
  72.217 -	cat $file /dev/zero | dd bs=1k count=$FORMAT conv=sync of=$output 2> /dev/null
  72.218 -	echo $output
  72.219 -	rm -f $file
  72.220 -	i=$(( $i + 1 ))
  72.221 -done
    73.1 --- a/kernel-modular/stuff/check_modules.sh	Thu Jul 18 13:24:21 2013 +0000
    73.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.3 @@ -1,51 +0,0 @@
    73.4 -#!/bin/sh
    73.5 -# Echo any module in kernel .config that's not added to one of linux-* pkgs
    73.6 -# (c) SliTaz - GNU General Public License.
    73.7 -# 20090618 <jozee@slitaz.org> 
    73.8 -# 20100528 <pankso@slitaz.org>
    73.9 -#
   73.10 -. /etc/tazwok.conf
   73.11 -VERSION=`grep  ^VERSION= $WOK/linux/receipt | cut -d "=" -f2 | sed -e 's/"//g'`
   73.12 -src="$WOK/linux/linux-$VERSION"
   73.13 -
   73.14 -cd $src
   73.15 -mkdir -p ../stuff/tmp
   73.16 -rm -f ../stuff/tmp/*
   73.17 -
   73.18 -echo -e "\nChecking for modules selected in .config but not in linux-* pkgs"
   73.19 -echo "======================================================================"
   73.20 -
   73.21 -# create a packaged modules list
   73.22 -cat ../stuff/modules-"$VERSION".list >> ../stuff/tmp/pkgs-modules-"$VERSION".list 
   73.23 -
   73.24 -for i in $(cd $WOK; ls -d linux-*)
   73.25 -do
   73.26 -	tazpath="taz/$i-$VERSION"
   73.27 -	for j in $(cat $WOK/$i/$tazpath/files.list | grep ".ko.gz")
   73.28 -	do
   73.29 -		basename $j >> ../stuff/tmp/pkgs-modules-"$VERSION".list	
   73.30 -	done 	
   73.31 -done
   73.32 -# get the original list in .config
   73.33 -for i in $(find $_pkg -iname "*.ko.gz") 
   73.34 -do
   73.35 -	basename $i >> ../stuff/tmp/originial-"$VERSION".list
   73.36 -done
   73.37 -# compare original .config and pkged modules
   73.38 -for i in $(cat ../stuff/tmp/originial-$VERSION.list)   
   73.39 -do		
   73.40 -	if ! grep -qs "$i" ../stuff/tmp/pkgs-modules-"$VERSION".list ; then 
   73.41 -		modpath=`find $_pkg -iname "$i"`
   73.42 -		echo "Orphan module: $i"
   73.43 -		echo "$i : $modpath" >> ../stuff/tmp/unpackaged-modules-"$VERSION".list
   73.44 -	fi
   73.45 -done
   73.46 -if [ -f ../stuff/tmp/unpackaged-modules-"$VERSION".list ]; then
   73.47 -	echo "======================================================================"
   73.48 -	echo -e "Check linux/stuff/tmp/unpackaged-modules-$VERSION.list for mod path\n"
   73.49 -else
   73.50 -	echo -e "\nAll modules are packaged\n"
   73.51 -	echo "======================================================================"
   73.52 -	echo ""
   73.53 -	rm -rf ../stuff/tmp
   73.54 -fi
    74.1 --- a/kernel-modular/stuff/gztazmod.sh	Thu Jul 18 13:24:21 2013 +0000
    74.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.3 @@ -1,67 +0,0 @@
    74.4 -#!/bin/sh
    74.5 -# gztazmod.sh: Compress Linux kernel modules for SliTaz GNU/Linux.
    74.6 -# 2007/10/04 <pankso@slitaz.org> - GNU General Public License.
    74.7 -#
    74.8 -
    74.9 -# We do our work in the kernel version modules directory.
   74.10 -if [ -z "$1" ] ; then
   74.11 -  echo ""
   74.12 -  echo -e "\033[1musage:\033[0m `basename $0` path/to/kernel-version"
   74.13 -  echo ""
   74.14 -  exit 1
   74.15 -fi
   74.16 -
   74.17 -if [ ! -r "$1" ] ; then
   74.18 -  echo ""
   74.19 -  echo -e "Error : $1 does not exist."
   74.20 -  echo ""
   74.21 -  exit 1
   74.22 -fi
   74.23 -
   74.24 -cd $1
   74.25 -
   74.26 -# Status functions.
   74.27 -status()
   74.28 -{
   74.29 -	local CHECK=$?
   74.30 -	echo -en "\\033[70G[ "
   74.31 -	if [ $CHECK = 0 ]; then
   74.32 -		echo -en "\\033[1;33mOK"
   74.33 -	else
   74.34 -		echo -en "\\033[1;31mFailed"
   74.35 -	fi
   74.36 -	echo -e "\\033[0;39m ]"
   74.37 -}
   74.38 -
   74.39 -# Script start.
   74.40 -echo ""
   74.41 -echo "Starting gztazmod.sh to build compressed kernel modules... "
   74.42 -echo ""
   74.43 -
   74.44 -# Find all modules.
   74.45 -echo -n "Searching all modules to compress them... "
   74.46 -find . -name "*.ko" -exec lzma e '{}' '{}'.gz \; 2> /dev/null
   74.47 -status
   74.48 -find . -name "*.ko" -exec rm '{}' \;
   74.49 -
   74.50 -# Build a new temporary modules.dep.
   74.51 -echo -n "Building tmp.dep... "
   74.52 -sed 's/\.ko.gz/.ko/g' modules.dep > tmp.dep
   74.53 -sed -i 's/\.ko.gz/.ko/g' tmp.dep
   74.54 -sed -i 's/\.ko/.ko.gz/g' tmp.dep
   74.55 -status
   74.56 -
   74.57 -# Destroy original modules.dep
   74.58 -echo -n "Destroying modules.dep... "
   74.59 -rm modules.dep
   74.60 -status
   74.61 -
   74.62 -# Remove tmp.dep to modules.dep.
   74.63 -echo -n "Removing tmp.dep to modules.dep... "
   74.64 -mv tmp.dep modules.dep
   74.65 -status
   74.66 -
   74.67 -# Script end.
   74.68 -echo ""
   74.69 -echo "Kernel modules `basename $1` are ready."
   74.70 -echo ""
    75.1 --- a/kernel-modular/stuff/linux-2.6.37-slitaz.config-i486-isa	Thu Jul 18 13:24:21 2013 +0000
    75.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.3 @@ -1,920 +0,0 @@
    75.4 -#
    75.5 -# Automatically generated make config: don't edit
    75.6 -# Linux/i386 2.6.37 Kernel Configuration
    75.7 -# Tue May  3 12:16:19 2011
    75.8 -#
    75.9 -# CONFIG_64BIT is not set
   75.10 -CONFIG_X86_32=y
   75.11 -# CONFIG_X86_64 is not set
   75.12 -CONFIG_X86=y
   75.13 -CONFIG_INSTRUCTION_DECODER=y
   75.14 -CONFIG_OUTPUT_FORMAT="elf32-i386"
   75.15 -CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
   75.16 -CONFIG_GENERIC_CMOS_UPDATE=y
   75.17 -CONFIG_CLOCKSOURCE_WATCHDOG=y
   75.18 -CONFIG_GENERIC_CLOCKEVENTS=y
   75.19 -CONFIG_LOCKDEP_SUPPORT=y
   75.20 -CONFIG_STACKTRACE_SUPPORT=y
   75.21 -CONFIG_HAVE_LATENCYTOP_SUPPORT=y
   75.22 -CONFIG_MMU=y
   75.23 -CONFIG_ZONE_DMA=y
   75.24 -# CONFIG_NEED_DMA_MAP_STATE is not set
   75.25 -CONFIG_NEED_SG_DMA_LENGTH=y
   75.26 -CONFIG_GENERIC_ISA_DMA=y
   75.27 -CONFIG_GENERIC_IOMAP=y
   75.28 -CONFIG_GENERIC_HWEIGHT=y
   75.29 -CONFIG_ARCH_MAY_HAVE_PC_FDC=y
   75.30 -CONFIG_RWSEM_GENERIC_SPINLOCK=y
   75.31 -# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
   75.32 -CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
   75.33 -CONFIG_GENERIC_CALIBRATE_DELAY=y
   75.34 -# CONFIG_GENERIC_TIME_VSYSCALL is not set
   75.35 -CONFIG_ARCH_HAS_CPU_RELAX=y
   75.36 -CONFIG_ARCH_HAS_DEFAULT_IDLE=y
   75.37 -CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
   75.38 -CONFIG_HAVE_SETUP_PER_CPU_AREA=y
   75.39 -CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
   75.40 -CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
   75.41 -# CONFIG_HAVE_CPUMASK_OF_CPU_MAP is not set
   75.42 -CONFIG_ARCH_HIBERNATION_POSSIBLE=y
   75.43 -CONFIG_ARCH_SUSPEND_POSSIBLE=y
   75.44 -# CONFIG_ZONE_DMA32 is not set
   75.45 -CONFIG_ARCH_POPULATES_NODE_MAP=y
   75.46 -# CONFIG_AUDIT_ARCH is not set
   75.47 -CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
   75.48 -CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
   75.49 -CONFIG_X86_32_LAZY_GS=y
   75.50 -CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-ecx -fcall-saved-edx"
   75.51 -CONFIG_KTIME_SCALAR=y
   75.52 -CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
   75.53 -CONFIG_CONSTRUCTORS=y
   75.54 -CONFIG_HAVE_IRQ_WORK=y
   75.55 -CONFIG_IRQ_WORK=y
   75.56 -
   75.57 -#
   75.58 -# General setup
   75.59 -#
   75.60 -CONFIG_EXPERIMENTAL=y
   75.61 -CONFIG_BROKEN_ON_SMP=y
   75.62 -CONFIG_INIT_ENV_ARG_LIMIT=32
   75.63 -CONFIG_CROSS_COMPILE=""
   75.64 -CONFIG_LOCALVERSION="-slitaz"
   75.65 -# CONFIG_LOCALVERSION_AUTO is not set
   75.66 -CONFIG_HAVE_KERNEL_GZIP=y
   75.67 -CONFIG_HAVE_KERNEL_BZIP2=y
   75.68 -CONFIG_HAVE_KERNEL_LZMA=y
   75.69 -CONFIG_HAVE_KERNEL_XZ=y
   75.70 -CONFIG_HAVE_KERNEL_LZO=y
   75.71 -# CONFIG_KERNEL_GZIP is not set
   75.72 -# CONFIG_KERNEL_BZIP2 is not set
   75.73 -CONFIG_KERNEL_LZMA=y
   75.74 -# CONFIG_KERNEL_XZ is not set
   75.75 -# CONFIG_KERNEL_LZO is not set
   75.76 -# CONFIG_SWAP is not set
   75.77 -CONFIG_SYSVIPC=y
   75.78 -CONFIG_SYSVIPC_SYSCTL=y
   75.79 -# CONFIG_POSIX_MQUEUE is not set
   75.80 -# CONFIG_BSD_PROCESS_ACCT is not set
   75.81 -# CONFIG_TASKSTATS is not set
   75.82 -# CONFIG_AUDIT is not set
   75.83 -CONFIG_HAVE_GENERIC_HARDIRQS=y
   75.84 -
   75.85 -#
   75.86 -# IRQ subsystem
   75.87 -#
   75.88 -CONFIG_GENERIC_HARDIRQS=y
   75.89 -CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
   75.90 -# CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED is not set
   75.91 -CONFIG_HAVE_SPARSE_IRQ=y
   75.92 -CONFIG_GENERIC_IRQ_PROBE=y
   75.93 -# CONFIG_GENERIC_PENDING_IRQ is not set
   75.94 -# CONFIG_AUTO_IRQ_AFFINITY is not set
   75.95 -# CONFIG_IRQ_PER_CPU is not set
   75.96 -# CONFIG_HARDIRQS_SW_RESEND is not set
   75.97 -# CONFIG_SPARSE_IRQ is not set
   75.98 -
   75.99 -#
  75.100 -# RCU Subsystem
  75.101 -#
  75.102 -CONFIG_TINY_RCU=y
  75.103 -# CONFIG_PREEMPT_RCU is not set
  75.104 -# CONFIG_TREE_RCU_TRACE is not set
  75.105 -# CONFIG_IKCONFIG is not set
  75.106 -CONFIG_LOG_BUF_SHIFT=12
  75.107 -CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
  75.108 -# CONFIG_NAMESPACES is not set
  75.109 -# CONFIG_RELAY is not set
  75.110 -CONFIG_BLK_DEV_INITRD=y
  75.111 -CONFIG_INITRAMFS_SOURCE="rootfs.cpio"
  75.112 -CONFIG_INITRAMFS_ROOT_UID=0
  75.113 -CONFIG_INITRAMFS_ROOT_GID=0
  75.114 -# CONFIG_RD_GZIP is not set
  75.115 -# CONFIG_RD_BZIP2 is not set
  75.116 -CONFIG_RD_LZMA=y
  75.117 -# CONFIG_RD_LZO is not set
  75.118 -CONFIG_INITRAMFS_COMPRESSION_NONE=y
  75.119 -# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set
  75.120 -CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  75.121 -CONFIG_SYSCTL=y
  75.122 -CONFIG_ANON_INODES=y
  75.123 -CONFIG_EMBEDDED=y
  75.124 -# CONFIG_UID16 is not set
  75.125 -# CONFIG_SYSCTL_SYSCALL is not set
  75.126 -# CONFIG_KALLSYMS is not set
  75.127 -# CONFIG_HOTPLUG is not set
  75.128 -CONFIG_PRINTK=y
  75.129 -# CONFIG_BUG is not set
  75.130 -# CONFIG_ELF_CORE is not set
  75.131 -CONFIG_PCSPKR_PLATFORM=y
  75.132 -# CONFIG_BASE_FULL is not set
  75.133 -CONFIG_FUTEX=y
  75.134 -# CONFIG_EPOLL is not set
  75.135 -# CONFIG_SIGNALFD is not set
  75.136 -# CONFIG_TIMERFD is not set
  75.137 -# CONFIG_EVENTFD is not set
  75.138 -# CONFIG_SHMEM is not set
  75.139 -# CONFIG_AIO is not set
  75.140 -CONFIG_HAVE_PERF_EVENTS=y
  75.141 -
  75.142 -#
  75.143 -# Kernel Performance Events And Counters
  75.144 -#
  75.145 -CONFIG_PERF_EVENTS=y
  75.146 -# CONFIG_PERF_COUNTERS is not set
  75.147 -# CONFIG_VM_EVENT_COUNTERS is not set
  75.148 -CONFIG_COMPAT_BRK=y
  75.149 -# CONFIG_SLAB is not set
  75.150 -# CONFIG_SLUB is not set
  75.151 -CONFIG_SLOB=y
  75.152 -# CONFIG_PROFILING is not set
  75.153 -CONFIG_HAVE_OPROFILE=y
  75.154 -# CONFIG_JUMP_LABEL is not set
  75.155 -CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
  75.156 -CONFIG_HAVE_IOREMAP_PROT=y
  75.157 -CONFIG_HAVE_KPROBES=y
  75.158 -CONFIG_HAVE_KRETPROBES=y
  75.159 -CONFIG_HAVE_OPTPROBES=y
  75.160 -CONFIG_HAVE_ARCH_TRACEHOOK=y
  75.161 -CONFIG_HAVE_DMA_ATTRS=y
  75.162 -CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
  75.163 -CONFIG_HAVE_DMA_API_DEBUG=y
  75.164 -CONFIG_HAVE_HW_BREAKPOINT=y
  75.165 -CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y
  75.166 -CONFIG_HAVE_USER_RETURN_NOTIFIER=y
  75.167 -CONFIG_HAVE_PERF_EVENTS_NMI=y
  75.168 -CONFIG_HAVE_ARCH_JUMP_LABEL=y
  75.169 -
  75.170 -#
  75.171 -# GCOV-based kernel profiling
  75.172 -#
  75.173 -CONFIG_HAVE_GENERIC_DMA_COHERENT=y
  75.174 -CONFIG_RT_MUTEXES=y
  75.175 -CONFIG_BASE_SMALL=1
  75.176 -# CONFIG_MODULES is not set
  75.177 -CONFIG_BLOCK=y
  75.178 -# CONFIG_LBDAF is not set
  75.179 -# CONFIG_BLK_DEV_BSG is not set
  75.180 -# CONFIG_BLK_DEV_INTEGRITY is not set
  75.181 -
  75.182 -#
  75.183 -# IO Schedulers
  75.184 -#
  75.185 -CONFIG_IOSCHED_NOOP=y
  75.186 -# CONFIG_IOSCHED_DEADLINE is not set
  75.187 -# CONFIG_IOSCHED_CFQ is not set
  75.188 -CONFIG_DEFAULT_NOOP=y
  75.189 -CONFIG_DEFAULT_IOSCHED="noop"
  75.190 -# CONFIG_INLINE_SPIN_TRYLOCK is not set
  75.191 -# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
  75.192 -# CONFIG_INLINE_SPIN_LOCK is not set
  75.193 -# CONFIG_INLINE_SPIN_LOCK_BH is not set
  75.194 -# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
  75.195 -# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
  75.196 -CONFIG_INLINE_SPIN_UNLOCK=y
  75.197 -# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
  75.198 -CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
  75.199 -# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
  75.200 -# CONFIG_INLINE_READ_TRYLOCK is not set
  75.201 -# CONFIG_INLINE_READ_LOCK is not set
  75.202 -# CONFIG_INLINE_READ_LOCK_BH is not set
  75.203 -# CONFIG_INLINE_READ_LOCK_IRQ is not set
  75.204 -# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
  75.205 -CONFIG_INLINE_READ_UNLOCK=y
  75.206 -# CONFIG_INLINE_READ_UNLOCK_BH is not set
  75.207 -CONFIG_INLINE_READ_UNLOCK_IRQ=y
  75.208 -# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
  75.209 -# CONFIG_INLINE_WRITE_TRYLOCK is not set
  75.210 -# CONFIG_INLINE_WRITE_LOCK is not set
  75.211 -# CONFIG_INLINE_WRITE_LOCK_BH is not set
  75.212 -# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
  75.213 -# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
  75.214 -CONFIG_INLINE_WRITE_UNLOCK=y
  75.215 -# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
  75.216 -CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
  75.217 -# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
  75.218 -# CONFIG_MUTEX_SPIN_ON_OWNER is not set
  75.219 -# CONFIG_FREEZER is not set
  75.220 -
  75.221 -#
  75.222 -# Processor type and features
  75.223 -#
  75.224 -# CONFIG_NO_HZ is not set
  75.225 -# CONFIG_HIGH_RES_TIMERS is not set
  75.226 -CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
  75.227 -# CONFIG_SMP is not set
  75.228 -# CONFIG_X86_EXTENDED_PLATFORM is not set
  75.229 -CONFIG_SCHED_OMIT_FRAME_POINTER=y
  75.230 -# CONFIG_PARAVIRT_GUEST is not set
  75.231 -CONFIG_NO_BOOTMEM=y
  75.232 -# CONFIG_MEMTEST is not set
  75.233 -CONFIG_M386=y
  75.234 -# CONFIG_M486 is not set
  75.235 -# CONFIG_M586 is not set
  75.236 -# CONFIG_M586TSC is not set
  75.237 -# CONFIG_M586MMX is not set
  75.238 -# CONFIG_M686 is not set
  75.239 -# CONFIG_MPENTIUMII is not set
  75.240 -# CONFIG_MPENTIUMIII is not set
  75.241 -# CONFIG_MPENTIUMM is not set
  75.242 -# CONFIG_MPENTIUM4 is not set
  75.243 -# CONFIG_MK6 is not set
  75.244 -# CONFIG_MK7 is not set
  75.245 -# CONFIG_MK8 is not set
  75.246 -# CONFIG_MCRUSOE is not set
  75.247 -# CONFIG_MEFFICEON is not set
  75.248 -# CONFIG_MWINCHIPC6 is not set
  75.249 -# CONFIG_MWINCHIP3D is not set
  75.250 -# CONFIG_MGEODEGX1 is not set
  75.251 -# CONFIG_MGEODE_LX is not set
  75.252 -# CONFIG_MCYRIXIII is not set
  75.253 -# CONFIG_MVIAC3_2 is not set
  75.254 -# CONFIG_MVIAC7 is not set
  75.255 -# CONFIG_MCORE2 is not set
  75.256 -# CONFIG_MATOM is not set
  75.257 -# CONFIG_X86_GENERIC is not set
  75.258 -CONFIG_X86_CPU=y
  75.259 -CONFIG_X86_INTERNODE_CACHE_SHIFT=4
  75.260 -# CONFIG_X86_CMPXCHG is not set
  75.261 -CONFIG_X86_L1_CACHE_SHIFT=4
  75.262 -# CONFIG_X86_PPRO_FENCE is not set
  75.263 -CONFIG_X86_F00F_BUG=y
  75.264 -CONFIG_X86_INVD_BUG=y
  75.265 -CONFIG_X86_MINIMUM_CPU_FAMILY=3
  75.266 -# CONFIG_PROCESSOR_SELECT is not set
  75.267 -CONFIG_CPU_SUP_INTEL=y
  75.268 -CONFIG_CPU_SUP_CYRIX_32=y
  75.269 -CONFIG_CPU_SUP_AMD=y
  75.270 -CONFIG_CPU_SUP_CENTAUR=y
  75.271 -CONFIG_CPU_SUP_TRANSMETA_32=y
  75.272 -CONFIG_CPU_SUP_UMC_32=y
  75.273 -# CONFIG_HPET_TIMER is not set
  75.274 -# CONFIG_DMI is not set
  75.275 -# CONFIG_IOMMU_HELPER is not set
  75.276 -# CONFIG_IOMMU_API is not set
  75.277 -CONFIG_NR_CPUS=1
  75.278 -# CONFIG_IRQ_TIME_ACCOUNTING is not set
  75.279 -CONFIG_PREEMPT_NONE=y
  75.280 -# CONFIG_PREEMPT_VOLUNTARY is not set
  75.281 -# CONFIG_PREEMPT is not set
  75.282 -# CONFIG_X86_UP_APIC is not set
  75.283 -# CONFIG_X86_MCE is not set
  75.284 -# CONFIG_VM86 is not set
  75.285 -# CONFIG_TOSHIBA is not set
  75.286 -# CONFIG_I8K is not set
  75.287 -# CONFIG_X86_REBOOTFIXUPS is not set
  75.288 -# CONFIG_MICROCODE is not set
  75.289 -# CONFIG_X86_MSR is not set
  75.290 -# CONFIG_X86_CPUID is not set
  75.291 -CONFIG_NOHIGHMEM=y
  75.292 -# CONFIG_HIGHMEM4G is not set
  75.293 -CONFIG_VMSPLIT_3G=y
  75.294 -# CONFIG_VMSPLIT_3G_OPT is not set
  75.295 -# CONFIG_VMSPLIT_2G is not set
  75.296 -# CONFIG_VMSPLIT_2G_OPT is not set
  75.297 -# CONFIG_VMSPLIT_1G is not set
  75.298 -CONFIG_PAGE_OFFSET=0xC0000000
  75.299 -# CONFIG_X86_PAE is not set
  75.300 -# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
  75.301 -# CONFIG_ARCH_DMA_ADDR_T_64BIT is not set
  75.302 -CONFIG_ARCH_FLATMEM_ENABLE=y
  75.303 -CONFIG_ARCH_SPARSEMEM_ENABLE=y
  75.304 -CONFIG_ARCH_SELECT_MEMORY_MODEL=y
  75.305 -CONFIG_ILLEGAL_POINTER_VALUE=0
  75.306 -CONFIG_SELECT_MEMORY_MODEL=y
  75.307 -CONFIG_FLATMEM_MANUAL=y
  75.308 -# CONFIG_SPARSEMEM_MANUAL is not set
  75.309 -CONFIG_FLATMEM=y
  75.310 -CONFIG_FLAT_NODE_MEM_MAP=y
  75.311 -CONFIG_SPARSEMEM_STATIC=y
  75.312 -CONFIG_HAVE_MEMBLOCK=y
  75.313 -CONFIG_PAGEFLAGS_EXTENDED=y
  75.314 -CONFIG_SPLIT_PTLOCK_CPUS=4
  75.315 -# CONFIG_PHYS_ADDR_T_64BIT is not set
  75.316 -CONFIG_ZONE_DMA_FLAG=1
  75.317 -CONFIG_BOUNCE=y
  75.318 -CONFIG_VIRT_TO_BUS=y
  75.319 -# CONFIG_KSM is not set
  75.320 -CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
  75.321 -CONFIG_NEED_PER_CPU_KM=y
  75.322 -# CONFIG_X86_CHECK_BIOS_CORRUPTION is not set
  75.323 -CONFIG_X86_RESERVE_LOW=64
  75.324 -CONFIG_MATH_EMULATION=y
  75.325 -# CONFIG_MTRR is not set
  75.326 -# CONFIG_SECCOMP is not set
  75.327 -# CONFIG_CC_STACKPROTECTOR is not set
  75.328 -CONFIG_HZ_100=y
  75.329 -# CONFIG_HZ_250 is not set
  75.330 -# CONFIG_HZ_300 is not set
  75.331 -# CONFIG_HZ_1000 is not set
  75.332 -CONFIG_HZ=100
  75.333 -# CONFIG_SCHED_HRTICK is not set
  75.334 -# CONFIG_KEXEC is not set
  75.335 -CONFIG_PHYSICAL_START=0x100000
  75.336 -# CONFIG_RELOCATABLE is not set
  75.337 -CONFIG_PHYSICAL_ALIGN=0x100000
  75.338 -# CONFIG_COMPAT_VDSO is not set
  75.339 -# CONFIG_CMDLINE_BOOL is not set
  75.340 -
  75.341 -#
  75.342 -# Power management and ACPI options
  75.343 -#
  75.344 -# CONFIG_PM is not set
  75.345 -# CONFIG_SFI is not set
  75.346 -
  75.347 -#
  75.348 -# CPU Frequency scaling
  75.349 -#
  75.350 -# CONFIG_CPU_FREQ is not set
  75.351 -# CONFIG_CPU_IDLE is not set
  75.352 -
  75.353 -#
  75.354 -# Bus options (PCI etc.)
  75.355 -#
  75.356 -# CONFIG_PCI is not set
  75.357 -# CONFIG_ARCH_SUPPORTS_MSI is not set
  75.358 -CONFIG_ISA_DMA_API=y
  75.359 -CONFIG_ISA=y
  75.360 -# CONFIG_EISA is not set
  75.361 -# CONFIG_MCA is not set
  75.362 -# CONFIG_SCx200 is not set
  75.363 -# CONFIG_OLPC is not set
  75.364 -# CONFIG_OLPC_OPENFIRMWARE is not set
  75.365 -
  75.366 -#
  75.367 -# Executable file formats / Emulations
  75.368 -#
  75.369 -CONFIG_BINFMT_ELF=y
  75.370 -CONFIG_HAVE_AOUT=y
  75.371 -# CONFIG_BINFMT_AOUT is not set
  75.372 -# CONFIG_BINFMT_MISC is not set
  75.373 -CONFIG_HAVE_ATOMIC_IOMAP=y
  75.374 -CONFIG_HAVE_TEXT_POKE_SMP=y
  75.375 -CONFIG_NET=y
  75.376 -
  75.377 -#
  75.378 -# Networking options
  75.379 -#
  75.380 -CONFIG_PACKET=y
  75.381 -CONFIG_UNIX=y
  75.382 -# CONFIG_NET_KEY is not set
  75.383 -CONFIG_INET=y
  75.384 -# CONFIG_IP_MULTICAST is not set
  75.385 -# CONFIG_IP_ADVANCED_ROUTER is not set
  75.386 -CONFIG_IP_FIB_HASH=y
  75.387 -# CONFIG_IP_PNP is not set
  75.388 -# CONFIG_NET_IPIP is not set
  75.389 -# CONFIG_NET_IPGRE_DEMUX is not set
  75.390 -# CONFIG_ARPD is not set
  75.391 -# CONFIG_SYN_COOKIES is not set
  75.392 -# CONFIG_INET_AH is not set
  75.393 -# CONFIG_INET_ESP is not set
  75.394 -# CONFIG_INET_IPCOMP is not set
  75.395 -# CONFIG_INET_XFRM_TUNNEL is not set
  75.396 -# CONFIG_INET_TUNNEL is not set
  75.397 -# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
  75.398 -# CONFIG_INET_XFRM_MODE_TUNNEL is not set
  75.399 -# CONFIG_INET_XFRM_MODE_BEET is not set
  75.400 -# CONFIG_INET_LRO is not set
  75.401 -# CONFIG_INET_DIAG is not set
  75.402 -# CONFIG_TCP_CONG_ADVANCED is not set
  75.403 -CONFIG_TCP_CONG_CUBIC=y
  75.404 -CONFIG_DEFAULT_TCP_CONG="cubic"
  75.405 -# CONFIG_TCP_MD5SIG is not set
  75.406 -# CONFIG_IPV6 is not set
  75.407 -# CONFIG_NETWORK_SECMARK is not set
  75.408 -# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
  75.409 -# CONFIG_NETFILTER is not set
  75.410 -# CONFIG_IP_DCCP is not set
  75.411 -# CONFIG_IP_SCTP is not set
  75.412 -# CONFIG_RDS is not set
  75.413 -# CONFIG_TIPC is not set
  75.414 -# CONFIG_ATM is not set
  75.415 -# CONFIG_L2TP is not set
  75.416 -# CONFIG_BRIDGE is not set
  75.417 -# CONFIG_NET_DSA is not set
  75.418 -# CONFIG_VLAN_8021Q is not set
  75.419 -# CONFIG_DECNET is not set
  75.420 -# CONFIG_LLC2 is not set
  75.421 -# CONFIG_IPX is not set
  75.422 -# CONFIG_ATALK is not set
  75.423 -# CONFIG_X25 is not set
  75.424 -# CONFIG_LAPB is not set
  75.425 -# CONFIG_ECONET is not set
  75.426 -# CONFIG_WAN_ROUTER is not set
  75.427 -# CONFIG_PHONET is not set
  75.428 -# CONFIG_IEEE802154 is not set
  75.429 -# CONFIG_NET_SCHED is not set
  75.430 -# CONFIG_DCB is not set
  75.431 -
  75.432 -#
  75.433 -# Network testing
  75.434 -#
  75.435 -# CONFIG_NET_PKTGEN is not set
  75.436 -# CONFIG_HAMRADIO is not set
  75.437 -# CONFIG_CAN is not set
  75.438 -# CONFIG_IRDA is not set
  75.439 -# CONFIG_BT is not set
  75.440 -# CONFIG_AF_RXRPC is not set
  75.441 -# CONFIG_WIRELESS is not set
  75.442 -# CONFIG_WIMAX is not set
  75.443 -# CONFIG_RFKILL is not set
  75.444 -# CONFIG_NET_9P is not set
  75.445 -# CONFIG_CAIF is not set
  75.446 -# CONFIG_CEPH_LIB is not set
  75.447 -
  75.448 -#
  75.449 -# Device Drivers
  75.450 -#
  75.451 -
  75.452 -#
  75.453 -# Generic Driver Options
  75.454 -#
  75.455 -CONFIG_STANDALONE=y
  75.456 -CONFIG_PREVENT_FIRMWARE_BUILD=y
  75.457 -CONFIG_FW_LOADER=y
  75.458 -CONFIG_FIRMWARE_IN_KERNEL=y
  75.459 -CONFIG_EXTRA_FIRMWARE=""
  75.460 -# CONFIG_SYS_HYPERVISOR is not set
  75.461 -# CONFIG_CONNECTOR is not set
  75.462 -# CONFIG_MTD is not set
  75.463 -# CONFIG_PARPORT is not set
  75.464 -# CONFIG_PNP is not set
  75.465 -CONFIG_BLK_DEV=y
  75.466 -CONFIG_BLK_DEV_FD=y
  75.467 -# CONFIG_BLK_DEV_XD is not set
  75.468 -# CONFIG_BLK_DEV_COW_COMMON is not set
  75.469 -# CONFIG_BLK_DEV_LOOP is not set
  75.470 -
  75.471 -#
  75.472 -# DRBD disabled because PROC_FS, INET or CONNECTOR not selected
  75.473 -#
  75.474 -# CONFIG_BLK_DEV_NBD is not set
  75.475 -# CONFIG_BLK_DEV_RAM is not set
  75.476 -# CONFIG_CDROM_PKTCDVD is not set
  75.477 -# CONFIG_ATA_OVER_ETH is not set
  75.478 -# CONFIG_BLK_DEV_HD is not set
  75.479 -# CONFIG_BLK_DEV_RBD is not set
  75.480 -# CONFIG_MISC_DEVICES is not set
  75.481 -CONFIG_HAVE_IDE=y
  75.482 -CONFIG_IDE=y
  75.483 -
  75.484 -#
  75.485 -# Please see Documentation/ide/ide.txt for help/info on IDE drives
  75.486 -#
  75.487 -# CONFIG_BLK_DEV_IDE_SATA is not set
  75.488 -# CONFIG_IDE_GD is not set
  75.489 -# CONFIG_BLK_DEV_IDECD is not set
  75.490 -# CONFIG_BLK_DEV_IDETAPE is not set
  75.491 -# CONFIG_IDE_TASK_IOCTL is not set
  75.492 -# CONFIG_IDE_PROC_FS is not set
  75.493 -
  75.494 -#
  75.495 -# IDE chipset support/bugfixes
  75.496 -#
  75.497 -CONFIG_IDE_GENERIC=y
  75.498 -# CONFIG_BLK_DEV_PLATFORM is not set
  75.499 -# CONFIG_BLK_DEV_CMD640 is not set
  75.500 -
  75.501 -#
  75.502 -# Other IDE chipsets support
  75.503 -#
  75.504 -
  75.505 -#
  75.506 -# Note: most of these also require special kernel boot parameters
  75.507 -#
  75.508 -# CONFIG_BLK_DEV_4DRIVES is not set
  75.509 -# CONFIG_BLK_DEV_ALI14XX is not set
  75.510 -# CONFIG_BLK_DEV_DTC2278 is not set
  75.511 -# CONFIG_BLK_DEV_HT6560B is not set
  75.512 -# CONFIG_BLK_DEV_QD65XX is not set
  75.513 -# CONFIG_BLK_DEV_UMC8672 is not set
  75.514 -# CONFIG_BLK_DEV_IDEDMA is not set
  75.515 -
  75.516 -#
  75.517 -# SCSI device support
  75.518 -#
  75.519 -CONFIG_SCSI_MOD=y
  75.520 -# CONFIG_RAID_ATTRS is not set
  75.521 -# CONFIG_SCSI is not set
  75.522 -# CONFIG_SCSI_DMA is not set
  75.523 -# CONFIG_SCSI_NETLINK is not set
  75.524 -# CONFIG_ATA is not set
  75.525 -# CONFIG_MD is not set
  75.526 -# CONFIG_MACINTOSH_DRIVERS is not set
  75.527 -CONFIG_NETDEVICES=y
  75.528 -# CONFIG_DUMMY is not set
  75.529 -# CONFIG_BONDING is not set
  75.530 -# CONFIG_MACVLAN is not set
  75.531 -# CONFIG_EQUALIZER is not set
  75.532 -# CONFIG_TUN is not set
  75.533 -# CONFIG_VETH is not set
  75.534 -# CONFIG_ARCNET is not set
  75.535 -# CONFIG_MII is not set
  75.536 -# CONFIG_PHYLIB is not set
  75.537 -CONFIG_NET_ETHERNET=y
  75.538 -CONFIG_NET_VENDOR_3COM=y
  75.539 -# CONFIG_EL1 is not set
  75.540 -# CONFIG_EL2 is not set
  75.541 -# CONFIG_ELPLUS is not set
  75.542 -# CONFIG_EL16 is not set
  75.543 -CONFIG_EL3=y
  75.544 -# CONFIG_3C515 is not set
  75.545 -# CONFIG_LANCE is not set
  75.546 -# CONFIG_NET_VENDOR_SMC is not set
  75.547 -# CONFIG_ETHOC is not set
  75.548 -# CONFIG_NET_VENDOR_RACAL is not set
  75.549 -# CONFIG_DNET is not set
  75.550 -# CONFIG_AT1700 is not set
  75.551 -# CONFIG_DEPCA is not set
  75.552 -# CONFIG_HP100 is not set
  75.553 -CONFIG_NET_ISA=y
  75.554 -# CONFIG_E2100 is not set
  75.555 -# CONFIG_EWRK3 is not set
  75.556 -# CONFIG_EEXPRESS is not set
  75.557 -# CONFIG_EEXPRESS_PRO is not set
  75.558 -# CONFIG_HPLAN_PLUS is not set
  75.559 -# CONFIG_HPLAN is not set
  75.560 -# CONFIG_LP486E is not set
  75.561 -# CONFIG_ETH16I is not set
  75.562 -CONFIG_NE2000=y
  75.563 -# CONFIG_ZNET is not set
  75.564 -# CONFIG_SEEQ8005 is not set
  75.565 -# CONFIG_IBM_NEW_EMAC_ZMII is not set
  75.566 -# CONFIG_IBM_NEW_EMAC_RGMII is not set
  75.567 -# CONFIG_IBM_NEW_EMAC_TAH is not set
  75.568 -# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
  75.569 -# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
  75.570 -# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
  75.571 -# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
  75.572 -# CONFIG_NET_PCI is not set
  75.573 -# CONFIG_B44 is not set
  75.574 -# CONFIG_CS89x0 is not set
  75.575 -# CONFIG_KS8851_MLL is not set
  75.576 -# CONFIG_NETDEV_1000 is not set
  75.577 -# CONFIG_NETDEV_10000 is not set
  75.578 -# CONFIG_TR is not set
  75.579 -# CONFIG_WLAN is not set
  75.580 -
  75.581 -#
  75.582 -# Enable WiMAX (Networking options) to see the WiMAX drivers
  75.583 -#
  75.584 -# CONFIG_WAN is not set
  75.585 -
  75.586 -#
  75.587 -# CAIF transport drivers
  75.588 -#
  75.589 -CONFIG_PPP=y
  75.590 -# CONFIG_PPP_MULTILINK is not set
  75.591 -# CONFIG_PPP_FILTER is not set
  75.592 -CONFIG_PPP_ASYNC=y
  75.593 -# CONFIG_PPP_SYNC_TTY is not set
  75.594 -CONFIG_PPP_DEFLATE=y
  75.595 -# CONFIG_PPP_BSDCOMP is not set
  75.596 -# CONFIG_PPP_MPPE is not set
  75.597 -CONFIG_PPPOE=y
  75.598 -# CONFIG_SLIP is not set
  75.599 -CONFIG_SLHC=y
  75.600 -# CONFIG_NETCONSOLE is not set
  75.601 -# CONFIG_NETPOLL is not set
  75.602 -# CONFIG_NET_POLL_CONTROLLER is not set
  75.603 -# CONFIG_ISDN is not set
  75.604 -# CONFIG_PHONE is not set
  75.605 -
  75.606 -#
  75.607 -# Input device support
  75.608 -#
  75.609 -CONFIG_INPUT=y
  75.610 -# CONFIG_INPUT_FF_MEMLESS is not set
  75.611 -# CONFIG_INPUT_POLLDEV is not set
  75.612 -# CONFIG_INPUT_SPARSEKMAP is not set
  75.613 -
  75.614 -#
  75.615 -# Userland interfaces
  75.616 -#
  75.617 -# CONFIG_INPUT_MOUSEDEV is not set
  75.618 -# CONFIG_INPUT_JOYDEV is not set
  75.619 -# CONFIG_INPUT_EVDEV is not set
  75.620 -# CONFIG_INPUT_EVBUG is not set
  75.621 -
  75.622 -#
  75.623 -# Input Device Drivers
  75.624 -#
  75.625 -CONFIG_INPUT_KEYBOARD=y
  75.626 -CONFIG_KEYBOARD_ATKBD=y
  75.627 -# CONFIG_KEYBOARD_LKKBD is not set
  75.628 -# CONFIG_KEYBOARD_NEWTON is not set
  75.629 -# CONFIG_KEYBOARD_OPENCORES is not set
  75.630 -# CONFIG_KEYBOARD_STOWAWAY is not set
  75.631 -# CONFIG_KEYBOARD_SUNKBD is not set
  75.632 -# CONFIG_KEYBOARD_XTKBD is not set
  75.633 -# CONFIG_INPUT_MOUSE is not set
  75.634 -# CONFIG_INPUT_JOYSTICK is not set
  75.635 -# CONFIG_INPUT_TABLET is not set
  75.636 -# CONFIG_INPUT_TOUCHSCREEN is not set
  75.637 -# CONFIG_INPUT_MISC is not set
  75.638 -
  75.639 -#
  75.640 -# Hardware I/O ports
  75.641 -#
  75.642 -CONFIG_SERIO=y
  75.643 -CONFIG_SERIO_I8042=y
  75.644 -# CONFIG_SERIO_SERPORT is not set
  75.645 -# CONFIG_SERIO_CT82C710 is not set
  75.646 -CONFIG_SERIO_LIBPS2=y
  75.647 -# CONFIG_SERIO_RAW is not set
  75.648 -# CONFIG_SERIO_ALTERA_PS2 is not set
  75.649 -# CONFIG_SERIO_PS2MULT is not set
  75.650 -# CONFIG_GAMEPORT is not set
  75.651 -
  75.652 -#
  75.653 -# Character devices
  75.654 -#
  75.655 -CONFIG_VT=y
  75.656 -CONFIG_CONSOLE_TRANSLATIONS=y
  75.657 -CONFIG_VT_CONSOLE=y
  75.658 -CONFIG_HW_CONSOLE=y
  75.659 -# CONFIG_VT_HW_CONSOLE_BINDING is not set
  75.660 -# CONFIG_DEVKMEM is not set
  75.661 -# CONFIG_SERIAL_NONSTANDARD is not set
  75.662 -# CONFIG_N_GSM is not set
  75.663 -
  75.664 -#
  75.665 -# Serial drivers
  75.666 -#
  75.667 -CONFIG_SERIAL_8250=y
  75.668 -# CONFIG_SERIAL_8250_CONSOLE is not set
  75.669 -CONFIG_FIX_EARLYCON_MEM=y
  75.670 -CONFIG_SERIAL_8250_NR_UARTS=2
  75.671 -CONFIG_SERIAL_8250_RUNTIME_UARTS=2
  75.672 -# CONFIG_SERIAL_8250_EXTENDED is not set
  75.673 -
  75.674 -#
  75.675 -# Non-8250 serial port support
  75.676 -#
  75.677 -CONFIG_SERIAL_CORE=y
  75.678 -# CONFIG_SERIAL_TIMBERDALE is not set
  75.679 -# CONFIG_SERIAL_ALTERA_JTAGUART is not set
  75.680 -# CONFIG_SERIAL_ALTERA_UART is not set
  75.681 -CONFIG_UNIX98_PTYS=y
  75.682 -# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
  75.683 -# CONFIG_LEGACY_PTYS is not set
  75.684 -# CONFIG_TTY_PRINTK is not set
  75.685 -# CONFIG_IPMI_HANDLER is not set
  75.686 -# CONFIG_HW_RANDOM is not set
  75.687 -# CONFIG_NVRAM is not set
  75.688 -# CONFIG_RTC is not set
  75.689 -# CONFIG_GEN_RTC is not set
  75.690 -# CONFIG_DTLK is not set
  75.691 -# CONFIG_R3964 is not set
  75.692 -# CONFIG_MWAVE is not set
  75.693 -# CONFIG_PC8736x_GPIO is not set
  75.694 -# CONFIG_NSC_GPIO is not set
  75.695 -# CONFIG_CS5535_GPIO is not set
  75.696 -# CONFIG_RAW_DRIVER is not set
  75.697 -# CONFIG_HANGCHECK_TIMER is not set
  75.698 -# CONFIG_TCG_TPM is not set
  75.699 -# CONFIG_TELCLOCK is not set
  75.700 -CONFIG_DEVPORT=y
  75.701 -# CONFIG_RAMOOPS is not set
  75.702 -# CONFIG_I2C is not set
  75.703 -# CONFIG_SPI is not set
  75.704 -
  75.705 -#
  75.706 -# PPS support
  75.707 -#
  75.708 -# CONFIG_PPS is not set
  75.709 -CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
  75.710 -# CONFIG_GPIOLIB is not set
  75.711 -# CONFIG_W1 is not set
  75.712 -# CONFIG_POWER_SUPPLY is not set
  75.713 -# CONFIG_HWMON is not set
  75.714 -# CONFIG_THERMAL is not set
  75.715 -# CONFIG_WATCHDOG is not set
  75.716 -CONFIG_SSB_POSSIBLE=y
  75.717 -
  75.718 -#
  75.719 -# Sonics Silicon Backplane
  75.720 -#
  75.721 -# CONFIG_SSB is not set
  75.722 -# CONFIG_MFD_SUPPORT is not set
  75.723 -# CONFIG_REGULATOR is not set
  75.724 -# CONFIG_MEDIA_SUPPORT is not set
  75.725 -
  75.726 -#
  75.727 -# Graphics support
  75.728 -#
  75.729 -# CONFIG_DRM is not set
  75.730 -# CONFIG_VGASTATE is not set
  75.731 -# CONFIG_VIDEO_OUTPUT_CONTROL is not set
  75.732 -# CONFIG_FB is not set
  75.733 -# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
  75.734 -
  75.735 -#
  75.736 -# Display device support
  75.737 -#
  75.738 -# CONFIG_DISPLAY_SUPPORT is not set
  75.739 -
  75.740 -#
  75.741 -# Console display driver support
  75.742 -#
  75.743 -CONFIG_VGA_CONSOLE=y
  75.744 -# CONFIG_VGACON_SOFT_SCROLLBACK is not set
  75.745 -# CONFIG_MDA_CONSOLE is not set
  75.746 -CONFIG_DUMMY_CONSOLE=y
  75.747 -# CONFIG_SOUND is not set
  75.748 -# CONFIG_HID_SUPPORT is not set
  75.749 -# CONFIG_USB_SUPPORT is not set
  75.750 -# CONFIG_MMC is not set
  75.751 -# CONFIG_MEMSTICK is not set
  75.752 -# CONFIG_NEW_LEDS is not set
  75.753 -# CONFIG_ACCESSIBILITY is not set
  75.754 -# CONFIG_EDAC is not set
  75.755 -# CONFIG_RTC_CLASS is not set
  75.756 -# CONFIG_DMADEVICES is not set
  75.757 -# CONFIG_AUXDISPLAY is not set
  75.758 -# CONFIG_UIO is not set
  75.759 -# CONFIG_STAGING is not set
  75.760 -# CONFIG_X86_PLATFORM_DEVICES is not set
  75.761 -
  75.762 -#
  75.763 -# Firmware Drivers
  75.764 -#
  75.765 -# CONFIG_EDD is not set
  75.766 -# CONFIG_FIRMWARE_MEMMAP is not set
  75.767 -# CONFIG_DELL_RBU is not set
  75.768 -# CONFIG_DCDBAS is not set
  75.769 -# CONFIG_ISCSI_IBFT_FIND is not set
  75.770 -
  75.771 -#
  75.772 -# File systems
  75.773 -#
  75.774 -# CONFIG_EXT2_FS is not set
  75.775 -CONFIG_EXT3_FS=y
  75.776 -# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
  75.777 -# CONFIG_EXT3_FS_XATTR is not set
  75.778 -# CONFIG_EXT4_FS is not set
  75.779 -CONFIG_JBD=y
  75.780 -# CONFIG_REISERFS_FS is not set
  75.781 -# CONFIG_JFS_FS is not set
  75.782 -# CONFIG_FS_POSIX_ACL is not set
  75.783 -# CONFIG_XFS_FS is not set
  75.784 -# CONFIG_BTRFS_FS is not set
  75.785 -# CONFIG_NILFS2_FS is not set
  75.786 -CONFIG_FILE_LOCKING=y
  75.787 -# CONFIG_FSNOTIFY is not set
  75.788 -# CONFIG_DNOTIFY is not set
  75.789 -# CONFIG_INOTIFY_USER is not set
  75.790 -# CONFIG_FANOTIFY is not set
  75.791 -# CONFIG_QUOTA is not set
  75.792 -# CONFIG_QUOTACTL is not set
  75.793 -# CONFIG_AUTOFS4_FS is not set
  75.794 -# CONFIG_FUSE_FS is not set
  75.795 -
  75.796 -#
  75.797 -# Caches
  75.798 -#
  75.799 -# CONFIG_FSCACHE is not set
  75.800 -
  75.801 -#
  75.802 -# CD-ROM/DVD Filesystems
  75.803 -#
  75.804 -# CONFIG_ISO9660_FS is not set
  75.805 -# CONFIG_UDF_FS is not set
  75.806 -
  75.807 -#
  75.808 -# DOS/FAT/NT Filesystems
  75.809 -#
  75.810 -# CONFIG_MSDOS_FS is not set
  75.811 -# CONFIG_VFAT_FS is not set
  75.812 -# CONFIG_NTFS_FS is not set
  75.813 -
  75.814 -#
  75.815 -# Pseudo filesystems
  75.816 -#
  75.817 -CONFIG_PROC_FS=y
  75.818 -# CONFIG_PROC_KCORE is not set
  75.819 -CONFIG_PROC_SYSCTL=y
  75.820 -# CONFIG_PROC_PAGE_MONITOR is not set
  75.821 -# CONFIG_SYSFS is not set
  75.822 -# CONFIG_HUGETLBFS is not set
  75.823 -# CONFIG_HUGETLB_PAGE is not set
  75.824 -# CONFIG_MISC_FILESYSTEMS is not set
  75.825 -# CONFIG_NETWORK_FILESYSTEMS is not set
  75.826 -
  75.827 -#
  75.828 -# Partition Types
  75.829 -#
  75.830 -# CONFIG_PARTITION_ADVANCED is not set
  75.831 -CONFIG_MSDOS_PARTITION=y
  75.832 -# CONFIG_NLS is not set
  75.833 -
  75.834 -#
  75.835 -# Kernel hacking
  75.836 -#
  75.837 -CONFIG_TRACE_IRQFLAGS_SUPPORT=y
  75.838 -# CONFIG_PRINTK_TIME is not set
  75.839 -# CONFIG_ENABLE_WARN_DEPRECATED is not set
  75.840 -# CONFIG_ENABLE_MUST_CHECK is not set
  75.841 -CONFIG_FRAME_WARN=1024
  75.842 -# CONFIG_MAGIC_SYSRQ is not set
  75.843 -# CONFIG_STRIP_ASM_SYMS is not set
  75.844 -# CONFIG_UNUSED_SYMBOLS is not set
  75.845 -# CONFIG_DEBUG_FS is not set
  75.846 -# CONFIG_HEADERS_CHECK is not set
  75.847 -# CONFIG_DEBUG_KERNEL is not set
  75.848 -# CONFIG_HARDLOCKUP_DETECTOR is not set
  75.849 -CONFIG_BKL=y
  75.850 -# CONFIG_SPARSE_RCU_POINTER is not set
  75.851 -# CONFIG_DEBUG_MEMORY_INIT is not set
  75.852 -CONFIG_ARCH_WANT_FRAME_POINTERS=y
  75.853 -# CONFIG_FRAME_POINTER is not set
  75.854 -# CONFIG_SYSCTL_SYSCALL_CHECK is not set
  75.855 -CONFIG_USER_STACKTRACE_SUPPORT=y
  75.856 -CONFIG_HAVE_FUNCTION_TRACER=y
  75.857 -CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
  75.858 -CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST=y
  75.859 -CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
  75.860 -CONFIG_HAVE_DYNAMIC_FTRACE=y
  75.861 -CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
  75.862 -CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
  75.863 -CONFIG_HAVE_C_RECORDMCOUNT=y
  75.864 -CONFIG_TRACING_SUPPORT=y
  75.865 -# CONFIG_FTRACE is not set
  75.866 -# CONFIG_DMA_API_DEBUG is not set
  75.867 -# CONFIG_ATOMIC64_SELFTEST is not set
  75.868 -# CONFIG_SAMPLES is not set
  75.869 -CONFIG_HAVE_ARCH_KGDB=y
  75.870 -CONFIG_HAVE_ARCH_KMEMCHECK=y
  75.871 -# CONFIG_STRICT_DEVMEM is not set
  75.872 -# CONFIG_X86_VERBOSE_BOOTUP is not set
  75.873 -# CONFIG_EARLY_PRINTK is not set
  75.874 -# CONFIG_DOUBLEFAULT is not set
  75.875 -# CONFIG_IOMMU_STRESS is not set
  75.876 -CONFIG_HAVE_MMIOTRACE_SUPPORT=y
  75.877 -CONFIG_IO_DELAY_TYPE_0X80=0
  75.878 -CONFIG_IO_DELAY_TYPE_0XED=1
  75.879 -CONFIG_IO_DELAY_TYPE_UDELAY=2
  75.880 -CONFIG_IO_DELAY_TYPE_NONE=3
  75.881 -CONFIG_IO_DELAY_0X80=y
  75.882 -# CONFIG_IO_DELAY_0XED is not set
  75.883 -# CONFIG_IO_DELAY_UDELAY is not set
  75.884 -# CONFIG_IO_DELAY_NONE is not set
  75.885 -CONFIG_DEFAULT_IO_DELAY_TYPE=0
  75.886 -CONFIG_OPTIMIZE_INLINING=y
  75.887 -
  75.888 -#
  75.889 -# Security options
  75.890 -#
  75.891 -# CONFIG_KEYS is not set
  75.892 -# CONFIG_SECURITY_DMESG_RESTRICT is not set
  75.893 -# CONFIG_SECURITYFS is not set
  75.894 -CONFIG_DEFAULT_SECURITY_DAC=y
  75.895 -CONFIG_DEFAULT_SECURITY=""
  75.896 -# CONFIG_CRYPTO is not set
  75.897 -CONFIG_HAVE_KVM=y
  75.898 -# CONFIG_VIRTUALIZATION is not set
  75.899 -# CONFIG_BINARY_PRINTF is not set
  75.900 -
  75.901 -#
  75.902 -# Library routines
  75.903 -#
  75.904 -CONFIG_BITREVERSE=y
  75.905 -CONFIG_GENERIC_FIND_FIRST_BIT=y
  75.906 -CONFIG_GENERIC_FIND_NEXT_BIT=y
  75.907 -CONFIG_GENERIC_FIND_LAST_BIT=y
  75.908 -CONFIG_CRC_CCITT=y
  75.909 -# CONFIG_CRC16 is not set
  75.910 -# CONFIG_CRC_T10DIF is not set
  75.911 -# CONFIG_CRC_ITU_T is not set
  75.912 -CONFIG_CRC32=y
  75.913 -# CONFIG_CRC7 is not set
  75.914 -# CONFIG_LIBCRC32C is not set
  75.915 -CONFIG_ZLIB_INFLATE=y
  75.916 -CONFIG_ZLIB_DEFLATE=y
  75.917 -# CONFIG_XZ_DEC is not set
  75.918 -# CONFIG_XZ_DEC_BCJ is not set
  75.919 -CONFIG_DECOMPRESS_LZMA=y
  75.920 -CONFIG_HAS_IOMEM=y
  75.921 -CONFIG_HAS_IOPORT=y
  75.922 -CONFIG_HAS_DMA=y
  75.923 -CONFIG_NLATTR=y
    76.1 --- a/kernel-modular/stuff/linux-2.6.37-slitaz.config-i486-lguest	Thu Jul 18 13:24:21 2013 +0000
    76.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.3 @@ -1,854 +0,0 @@
    76.4 -#
    76.5 -# Automatically generated make config: don't edit
    76.6 -# Linux/i386 2.6.37 Kernel Configuration
    76.7 -# Tue May  3 12:17:51 2011
    76.8 -#
    76.9 -# CONFIG_64BIT is not set
   76.10 -CONFIG_X86_32=y
   76.11 -# CONFIG_X86_64 is not set
   76.12 -CONFIG_X86=y
   76.13 -CONFIG_INSTRUCTION_DECODER=y
   76.14 -CONFIG_OUTPUT_FORMAT="elf32-i386"
   76.15 -CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
   76.16 -CONFIG_GENERIC_CMOS_UPDATE=y
   76.17 -CONFIG_CLOCKSOURCE_WATCHDOG=y
   76.18 -CONFIG_GENERIC_CLOCKEVENTS=y
   76.19 -CONFIG_LOCKDEP_SUPPORT=y
   76.20 -CONFIG_STACKTRACE_SUPPORT=y
   76.21 -CONFIG_HAVE_LATENCYTOP_SUPPORT=y
   76.22 -CONFIG_MMU=y
   76.23 -CONFIG_ZONE_DMA=y
   76.24 -# CONFIG_NEED_DMA_MAP_STATE is not set
   76.25 -CONFIG_NEED_SG_DMA_LENGTH=y
   76.26 -CONFIG_GENERIC_ISA_DMA=y
   76.27 -CONFIG_GENERIC_IOMAP=y
   76.28 -CONFIG_GENERIC_HWEIGHT=y
   76.29 -CONFIG_ARCH_MAY_HAVE_PC_FDC=y
   76.30 -# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
   76.31 -CONFIG_RWSEM_XCHGADD_ALGORITHM=y
   76.32 -CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
   76.33 -CONFIG_GENERIC_CALIBRATE_DELAY=y
   76.34 -# CONFIG_GENERIC_TIME_VSYSCALL is not set
   76.35 -CONFIG_ARCH_HAS_CPU_RELAX=y
   76.36 -CONFIG_ARCH_HAS_DEFAULT_IDLE=y
   76.37 -CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
   76.38 -CONFIG_HAVE_SETUP_PER_CPU_AREA=y
   76.39 -CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
   76.40 -CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
   76.41 -# CONFIG_HAVE_CPUMASK_OF_CPU_MAP is not set
   76.42 -CONFIG_ARCH_HIBERNATION_POSSIBLE=y
   76.43 -CONFIG_ARCH_SUSPEND_POSSIBLE=y
   76.44 -# CONFIG_ZONE_DMA32 is not set
   76.45 -CONFIG_ARCH_POPULATES_NODE_MAP=y
   76.46 -# CONFIG_AUDIT_ARCH is not set
   76.47 -CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
   76.48 -CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
   76.49 -CONFIG_X86_32_LAZY_GS=y
   76.50 -CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-ecx -fcall-saved-edx"
   76.51 -CONFIG_KTIME_SCALAR=y
   76.52 -CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
   76.53 -CONFIG_CONSTRUCTORS=y
   76.54 -CONFIG_HAVE_IRQ_WORK=y
   76.55 -CONFIG_IRQ_WORK=y
   76.56 -
   76.57 -#
   76.58 -# General setup
   76.59 -#
   76.60 -CONFIG_EXPERIMENTAL=y
   76.61 -CONFIG_BROKEN_ON_SMP=y
   76.62 -CONFIG_INIT_ENV_ARG_LIMIT=32
   76.63 -CONFIG_CROSS_COMPILE=""
   76.64 -CONFIG_LOCALVERSION="-slitaz"
   76.65 -# CONFIG_LOCALVERSION_AUTO is not set
   76.66 -CONFIG_HAVE_KERNEL_GZIP=y
   76.67 -CONFIG_HAVE_KERNEL_BZIP2=y
   76.68 -CONFIG_HAVE_KERNEL_LZMA=y
   76.69 -CONFIG_HAVE_KERNEL_XZ=y
   76.70 -CONFIG_HAVE_KERNEL_LZO=y
   76.71 -# CONFIG_KERNEL_GZIP is not set
   76.72 -# CONFIG_KERNEL_BZIP2 is not set
   76.73 -CONFIG_KERNEL_LZMA=y
   76.74 -# CONFIG_KERNEL_XZ is not set
   76.75 -# CONFIG_KERNEL_LZO is not set
   76.76 -# CONFIG_SWAP is not set
   76.77 -CONFIG_SYSVIPC=y
   76.78 -CONFIG_SYSVIPC_SYSCTL=y
   76.79 -# CONFIG_POSIX_MQUEUE is not set
   76.80 -# CONFIG_BSD_PROCESS_ACCT is not set
   76.81 -# CONFIG_TASKSTATS is not set
   76.82 -# CONFIG_AUDIT is not set
   76.83 -CONFIG_HAVE_GENERIC_HARDIRQS=y
   76.84 -
   76.85 -#
   76.86 -# IRQ subsystem
   76.87 -#
   76.88 -CONFIG_GENERIC_HARDIRQS=y
   76.89 -CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
   76.90 -# CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED is not set
   76.91 -CONFIG_HAVE_SPARSE_IRQ=y
   76.92 -CONFIG_GENERIC_IRQ_PROBE=y
   76.93 -# CONFIG_GENERIC_PENDING_IRQ is not set
   76.94 -# CONFIG_AUTO_IRQ_AFFINITY is not set
   76.95 -# CONFIG_IRQ_PER_CPU is not set
   76.96 -# CONFIG_HARDIRQS_SW_RESEND is not set
   76.97 -# CONFIG_SPARSE_IRQ is not set
   76.98 -
   76.99 -#
  76.100 -# RCU Subsystem
  76.101 -#
  76.102 -CONFIG_TINY_RCU=y
  76.103 -# CONFIG_PREEMPT_RCU is not set
  76.104 -# CONFIG_TREE_RCU_TRACE is not set
  76.105 -# CONFIG_IKCONFIG is not set
  76.106 -CONFIG_LOG_BUF_SHIFT=12
  76.107 -CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
  76.108 -# CONFIG_NAMESPACES is not set
  76.109 -# CONFIG_RELAY is not set
  76.110 -CONFIG_BLK_DEV_INITRD=y
  76.111 -CONFIG_INITRAMFS_SOURCE="rootfs.cpio"
  76.112 -CONFIG_INITRAMFS_ROOT_UID=0
  76.113 -CONFIG_INITRAMFS_ROOT_GID=0
  76.114 -# CONFIG_RD_GZIP is not set
  76.115 -# CONFIG_RD_BZIP2 is not set
  76.116 -CONFIG_RD_LZMA=y
  76.117 -# CONFIG_RD_LZO is not set
  76.118 -CONFIG_INITRAMFS_COMPRESSION_NONE=y
  76.119 -# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set
  76.120 -CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  76.121 -CONFIG_SYSCTL=y
  76.122 -CONFIG_ANON_INODES=y
  76.123 -CONFIG_EMBEDDED=y
  76.124 -# CONFIG_UID16 is not set
  76.125 -# CONFIG_SYSCTL_SYSCALL is not set
  76.126 -# CONFIG_KALLSYMS is not set
  76.127 -# CONFIG_HOTPLUG is not set
  76.128 -CONFIG_PRINTK=y
  76.129 -# CONFIG_BUG is not set
  76.130 -# CONFIG_ELF_CORE is not set
  76.131 -CONFIG_PCSPKR_PLATFORM=y
  76.132 -# CONFIG_BASE_FULL is not set
  76.133 -CONFIG_FUTEX=y
  76.134 -# CONFIG_EPOLL is not set
  76.135 -# CONFIG_SIGNALFD is not set
  76.136 -# CONFIG_TIMERFD is not set
  76.137 -# CONFIG_EVENTFD is not set
  76.138 -# CONFIG_SHMEM is not set
  76.139 -# CONFIG_AIO is not set
  76.140 -CONFIG_HAVE_PERF_EVENTS=y
  76.141 -
  76.142 -#
  76.143 -# Kernel Performance Events And Counters
  76.144 -#
  76.145 -CONFIG_PERF_EVENTS=y
  76.146 -# CONFIG_PERF_COUNTERS is not set
  76.147 -# CONFIG_VM_EVENT_COUNTERS is not set
  76.148 -CONFIG_COMPAT_BRK=y
  76.149 -# CONFIG_SLAB is not set
  76.150 -# CONFIG_SLUB is not set
  76.151 -CONFIG_SLOB=y
  76.152 -# CONFIG_PROFILING is not set
  76.153 -CONFIG_HAVE_OPROFILE=y
  76.154 -# CONFIG_JUMP_LABEL is not set
  76.155 -CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
  76.156 -CONFIG_HAVE_IOREMAP_PROT=y
  76.157 -CONFIG_HAVE_KPROBES=y
  76.158 -CONFIG_HAVE_KRETPROBES=y
  76.159 -CONFIG_HAVE_OPTPROBES=y
  76.160 -CONFIG_HAVE_ARCH_TRACEHOOK=y
  76.161 -CONFIG_HAVE_DMA_ATTRS=y
  76.162 -CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
  76.163 -CONFIG_HAVE_DMA_API_DEBUG=y
  76.164 -CONFIG_HAVE_HW_BREAKPOINT=y
  76.165 -CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y
  76.166 -CONFIG_HAVE_USER_RETURN_NOTIFIER=y
  76.167 -CONFIG_HAVE_PERF_EVENTS_NMI=y
  76.168 -CONFIG_HAVE_ARCH_JUMP_LABEL=y
  76.169 -
  76.170 -#
  76.171 -# GCOV-based kernel profiling
  76.172 -#
  76.173 -CONFIG_HAVE_GENERIC_DMA_COHERENT=y
  76.174 -CONFIG_RT_MUTEXES=y
  76.175 -CONFIG_BASE_SMALL=1
  76.176 -# CONFIG_MODULES is not set
  76.177 -CONFIG_BLOCK=y
  76.178 -# CONFIG_LBDAF is not set
  76.179 -# CONFIG_BLK_DEV_BSG is not set
  76.180 -# CONFIG_BLK_DEV_INTEGRITY is not set
  76.181 -
  76.182 -#
  76.183 -# IO Schedulers
  76.184 -#
  76.185 -CONFIG_IOSCHED_NOOP=y
  76.186 -# CONFIG_IOSCHED_DEADLINE is not set
  76.187 -# CONFIG_IOSCHED_CFQ is not set
  76.188 -CONFIG_DEFAULT_NOOP=y
  76.189 -CONFIG_DEFAULT_IOSCHED="noop"
  76.190 -# CONFIG_INLINE_SPIN_TRYLOCK is not set
  76.191 -# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
  76.192 -# CONFIG_INLINE_SPIN_LOCK is not set
  76.193 -# CONFIG_INLINE_SPIN_LOCK_BH is not set
  76.194 -# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
  76.195 -# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
  76.196 -CONFIG_INLINE_SPIN_UNLOCK=y
  76.197 -# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
  76.198 -CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
  76.199 -# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
  76.200 -# CONFIG_INLINE_READ_TRYLOCK is not set
  76.201 -# CONFIG_INLINE_READ_LOCK is not set
  76.202 -# CONFIG_INLINE_READ_LOCK_BH is not set
  76.203 -# CONFIG_INLINE_READ_LOCK_IRQ is not set
  76.204 -# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
  76.205 -CONFIG_INLINE_READ_UNLOCK=y
  76.206 -# CONFIG_INLINE_READ_UNLOCK_BH is not set
  76.207 -CONFIG_INLINE_READ_UNLOCK_IRQ=y
  76.208 -# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
  76.209 -# CONFIG_INLINE_WRITE_TRYLOCK is not set
  76.210 -# CONFIG_INLINE_WRITE_LOCK is not set
  76.211 -# CONFIG_INLINE_WRITE_LOCK_BH is not set
  76.212 -# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
  76.213 -# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
  76.214 -CONFIG_INLINE_WRITE_UNLOCK=y
  76.215 -# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
  76.216 -CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
  76.217 -# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
  76.218 -# CONFIG_MUTEX_SPIN_ON_OWNER is not set
  76.219 -# CONFIG_FREEZER is not set
  76.220 -
  76.221 -#
  76.222 -# Processor type and features
  76.223 -#
  76.224 -CONFIG_TICK_ONESHOT=y
  76.225 -CONFIG_NO_HZ=y
  76.226 -# CONFIG_HIGH_RES_TIMERS is not set
  76.227 -CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
  76.228 -# CONFIG_SMP is not set
  76.229 -# CONFIG_X86_EXTENDED_PLATFORM is not set
  76.230 -CONFIG_SCHED_OMIT_FRAME_POINTER=y
  76.231 -CONFIG_PARAVIRT_GUEST=y
  76.232 -# CONFIG_XEN_PRIVILEGED_GUEST is not set
  76.233 -CONFIG_KVM_CLOCK=y
  76.234 -CONFIG_KVM_GUEST=y
  76.235 -CONFIG_LGUEST_GUEST=y
  76.236 -CONFIG_PARAVIRT=y
  76.237 -CONFIG_PARAVIRT_CLOCK=y
  76.238 -CONFIG_NO_BOOTMEM=y
  76.239 -# CONFIG_MEMTEST is not set
  76.240 -# CONFIG_M386 is not set
  76.241 -# CONFIG_M486 is not set
  76.242 -# CONFIG_M586 is not set
  76.243 -# CONFIG_M586TSC is not set
  76.244 -# CONFIG_M586MMX is not set
  76.245 -# CONFIG_M686 is not set
  76.246 -# CONFIG_MPENTIUMII is not set
  76.247 -CONFIG_MPENTIUMIII=y
  76.248 -# CONFIG_MPENTIUMM is not set
  76.249 -# CONFIG_MPENTIUM4 is not set
  76.250 -# CONFIG_MK6 is not set
  76.251 -# CONFIG_MK7 is not set
  76.252 -# CONFIG_MK8 is not set
  76.253 -# CONFIG_MCRUSOE is not set
  76.254 -# CONFIG_MEFFICEON is not set
  76.255 -# CONFIG_MWINCHIPC6 is not set
  76.256 -# CONFIG_MWINCHIP3D is not set
  76.257 -# CONFIG_MGEODEGX1 is not set
  76.258 -# CONFIG_MGEODE_LX is not set
  76.259 -# CONFIG_MCYRIXIII is not set
  76.260 -# CONFIG_MVIAC3_2 is not set
  76.261 -# CONFIG_MVIAC7 is not set
  76.262 -# CONFIG_MCORE2 is not set
  76.263 -# CONFIG_MATOM is not set
  76.264 -CONFIG_X86_GENERIC=y
  76.265 -CONFIG_X86_CPU=y
  76.266 -CONFIG_X86_INTERNODE_CACHE_SHIFT=6
  76.267 -CONFIG_X86_CMPXCHG=y
  76.268 -CONFIG_X86_L1_CACHE_SHIFT=6
  76.269 -CONFIG_X86_XADD=y
  76.270 -CONFIG_X86_WP_WORKS_OK=y
  76.271 -CONFIG_X86_INVLPG=y
  76.272 -CONFIG_X86_BSWAP=y
  76.273 -CONFIG_X86_POPAD_OK=y
  76.274 -CONFIG_X86_INTEL_USERCOPY=y
  76.275 -CONFIG_X86_USE_PPRO_CHECKSUM=y
  76.276 -CONFIG_X86_TSC=y
  76.277 -CONFIG_X86_CMPXCHG64=y
  76.278 -CONFIG_X86_CMOV=y
  76.279 -CONFIG_X86_MINIMUM_CPU_FAMILY=5
  76.280 -CONFIG_X86_DEBUGCTLMSR=y
  76.281 -# CONFIG_PROCESSOR_SELECT is not set
  76.282 -CONFIG_CPU_SUP_INTEL=y
  76.283 -CONFIG_CPU_SUP_CYRIX_32=y
  76.284 -CONFIG_CPU_SUP_AMD=y
  76.285 -CONFIG_CPU_SUP_CENTAUR=y
  76.286 -CONFIG_CPU_SUP_TRANSMETA_32=y
  76.287 -CONFIG_CPU_SUP_UMC_32=y
  76.288 -# CONFIG_HPET_TIMER is not set
  76.289 -# CONFIG_DMI is not set
  76.290 -# CONFIG_IOMMU_HELPER is not set
  76.291 -# CONFIG_IOMMU_API is not set
  76.292 -CONFIG_NR_CPUS=1
  76.293 -# CONFIG_IRQ_TIME_ACCOUNTING is not set
  76.294 -CONFIG_PREEMPT_NONE=y
  76.295 -# CONFIG_PREEMPT_VOLUNTARY is not set
  76.296 -# CONFIG_PREEMPT is not set
  76.297 -# CONFIG_X86_UP_APIC is not set
  76.298 -# CONFIG_X86_MCE is not set
  76.299 -# CONFIG_VM86 is not set
  76.300 -# CONFIG_TOSHIBA is not set
  76.301 -# CONFIG_I8K is not set
  76.302 -# CONFIG_X86_REBOOTFIXUPS is not set
  76.303 -# CONFIG_MICROCODE is not set
  76.304 -# CONFIG_X86_MSR is not set
  76.305 -# CONFIG_X86_CPUID is not set
  76.306 -CONFIG_NOHIGHMEM=y
  76.307 -# CONFIG_HIGHMEM4G is not set
  76.308 -# CONFIG_HIGHMEM64G is not set
  76.309 -CONFIG_VMSPLIT_3G=y
  76.310 -# CONFIG_VMSPLIT_3G_OPT is not set
  76.311 -# CONFIG_VMSPLIT_2G is not set
  76.312 -# CONFIG_VMSPLIT_2G_OPT is not set
  76.313 -# CONFIG_VMSPLIT_1G is not set
  76.314 -CONFIG_PAGE_OFFSET=0xC0000000
  76.315 -# CONFIG_X86_PAE is not set
  76.316 -# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
  76.317 -# CONFIG_ARCH_DMA_ADDR_T_64BIT is not set
  76.318 -CONFIG_ARCH_FLATMEM_ENABLE=y
  76.319 -CONFIG_ARCH_SPARSEMEM_ENABLE=y
  76.320 -CONFIG_ARCH_SELECT_MEMORY_MODEL=y
  76.321 -CONFIG_ILLEGAL_POINTER_VALUE=0
  76.322 -CONFIG_SELECT_MEMORY_MODEL=y
  76.323 -CONFIG_FLATMEM_MANUAL=y
  76.324 -# CONFIG_SPARSEMEM_MANUAL is not set
  76.325 -CONFIG_FLATMEM=y
  76.326 -CONFIG_FLAT_NODE_MEM_MAP=y
  76.327 -CONFIG_SPARSEMEM_STATIC=y
  76.328 -CONFIG_HAVE_MEMBLOCK=y
  76.329 -CONFIG_PAGEFLAGS_EXTENDED=y
  76.330 -CONFIG_SPLIT_PTLOCK_CPUS=4
  76.331 -# CONFIG_PHYS_ADDR_T_64BIT is not set
  76.332 -CONFIG_ZONE_DMA_FLAG=1
  76.333 -CONFIG_BOUNCE=y
  76.334 -CONFIG_VIRT_TO_BUS=y
  76.335 -# CONFIG_KSM is not set
  76.336 -CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
  76.337 -CONFIG_NEED_PER_CPU_KM=y
  76.338 -# CONFIG_X86_CHECK_BIOS_CORRUPTION is not set
  76.339 -CONFIG_X86_RESERVE_LOW=64
  76.340 -# CONFIG_MATH_EMULATION is not set
  76.341 -# CONFIG_MTRR is not set
  76.342 -# CONFIG_SECCOMP is not set
  76.343 -# CONFIG_CC_STACKPROTECTOR is not set
  76.344 -CONFIG_HZ_100=y
  76.345 -# CONFIG_HZ_250 is not set
  76.346 -# CONFIG_HZ_300 is not set
  76.347 -# CONFIG_HZ_1000 is not set
  76.348 -CONFIG_HZ=100
  76.349 -# CONFIG_SCHED_HRTICK is not set
  76.350 -# CONFIG_KEXEC is not set
  76.351 -CONFIG_PHYSICAL_START=0x100000
  76.352 -# CONFIG_RELOCATABLE is not set
  76.353 -CONFIG_PHYSICAL_ALIGN=0x100000
  76.354 -# CONFIG_COMPAT_VDSO is not set
  76.355 -# CONFIG_CMDLINE_BOOL is not set
  76.356 -
  76.357 -#
  76.358 -# Power management and ACPI options
  76.359 -#
  76.360 -# CONFIG_PM is not set
  76.361 -# CONFIG_SFI is not set
  76.362 -
  76.363 -#
  76.364 -# CPU Frequency scaling
  76.365 -#
  76.366 -# CONFIG_CPU_FREQ is not set
  76.367 -# CONFIG_CPU_IDLE is not set
  76.368 -
  76.369 -#
  76.370 -# Bus options (PCI etc.)
  76.371 -#
  76.372 -# CONFIG_PCI is not set
  76.373 -# CONFIG_ARCH_SUPPORTS_MSI is not set
  76.374 -CONFIG_ISA_DMA_API=y
  76.375 -# CONFIG_ISA is not set
  76.376 -# CONFIG_MCA is not set
  76.377 -# CONFIG_SCx200 is not set
  76.378 -# CONFIG_OLPC is not set
  76.379 -# CONFIG_OLPC_OPENFIRMWARE is not set
  76.380 -
  76.381 -#
  76.382 -# Executable file formats / Emulations
  76.383 -#
  76.384 -CONFIG_BINFMT_ELF=y
  76.385 -CONFIG_HAVE_AOUT=y
  76.386 -# CONFIG_BINFMT_AOUT is not set
  76.387 -# CONFIG_BINFMT_MISC is not set
  76.388 -CONFIG_HAVE_ATOMIC_IOMAP=y
  76.389 -CONFIG_HAVE_TEXT_POKE_SMP=y
  76.390 -CONFIG_NET=y
  76.391 -
  76.392 -#
  76.393 -# Networking options
  76.394 -#
  76.395 -CONFIG_PACKET=y
  76.396 -CONFIG_UNIX=y
  76.397 -# CONFIG_NET_KEY is not set
  76.398 -CONFIG_INET=y
  76.399 -# CONFIG_IP_MULTICAST is not set
  76.400 -# CONFIG_IP_ADVANCED_ROUTER is not set
  76.401 -CONFIG_IP_FIB_HASH=y
  76.402 -# CONFIG_IP_PNP is not set
  76.403 -# CONFIG_NET_IPIP is not set
  76.404 -# CONFIG_NET_IPGRE_DEMUX is not set
  76.405 -# CONFIG_ARPD is not set
  76.406 -# CONFIG_SYN_COOKIES is not set
  76.407 -# CONFIG_INET_AH is not set
  76.408 -# CONFIG_INET_ESP is not set
  76.409 -# CONFIG_INET_IPCOMP is not set
  76.410 -# CONFIG_INET_XFRM_TUNNEL is not