Code/GIT

From TcosProject

Jump to: navigation, search


[edit] GIT Code

You can download all GIT code with:

git clone http://tcosproject.org/git/$$PACKAGE_NAME$$

[edit] Modules

http://tcosproject.org/cgit/cgit.cgi/

  • initramfs-tools-tcos
  • tcosmonitor
  • tcosconfig
  • tcosphpmonitor

[edit] Browse code with CGIT

http://tcosproject.org/cgit/

[edit] Build packages

First download one module and do this:

$ cd MODULE_NAME
$ make targz
$ cd ..
$ mkdir build
$ tar -zxf MODULE_NAME-x.x.x.tar.gz -C build/
$ cd build/MODULE_NAME-x.x.x
$ dpkg-buildpackage -rfakeroot -us -uc

You will obtain some deb files that can install with dpkg -i


[edit] Last changes in Repos


add .gitignore and Makefile
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: ca1dc539b2a854d1c4a759bac7a5aba696f37c73
Date: Mon, 08 Mar 2010 15:43:27 GMT
Commit diff


--- /dev/null

+++ b/.gitignore @@ -0,0 +1,8 @@ +.stage/ +binary.iso +binary.list +binary.packages +binary/ +cache/ +chroot/ +

--- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +all: + lh build + + +clean: + lh clean + + +superclean: clean

+ rm -rf .stage/ binary.* binary/ cache/ chroot/

add pt_br language and fix keyboard
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: ecfc373452bbebbc6e74ffb57292fdc614d2a50c
Date: Mon, 08 Mar 2010 14:44:35 GMT
Commit diff


--- a/config/chroot_local-hooks/configuretcos.sh

+++ b/config/chroot_local-hooks/configuretcos.sh @@ -46,5 +46,5 @@ chown root:root /etc/init.d/tcos

chmod 755 /etc/init.d/tcos

# Create symlinks for each runlevel

-# eg /etc/rc2.d/S90tcos for runlevel 2, etc -update-rc.d tcos defaults 90 10 +# eg /etc/rcS.d/S40tcos for runlevel S, etc +update-rc.d tcos start 40 S .

--- a/config/chroot_local-includes/etc/default/keyboard +++ /dev/null @@ -1,26 +0,0 @@ -# If you change any of the following variables and HAL and X are -# configured to use this file, then the changes will become visible to -# X only if HAL is restarted. In Debian you need to run -# /etc/init.d/hal restart - -# The following variables describe your keyboard and can have the same -# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options -# in /etc/X11/xorg.conf. - -if [ "$(grep -c 'keyb=es' /proc/cmdline)" = "1" ]; then -XKBMODEL="pc105" -XKBLAYOUT="es" -XKBVARIANT="" -XKBOPTIONS="lv3:ralt_switch" -else -XKBMODEL="pc104" -XKBLAYOUT="us" -XKBVARIANT="" -XKBOPTIONS="" -fi - - -# If you don't want to use the XKB layout on the console, you can -# specify an alternative keymap. Make sure it will be accessible -# before /usr is mounted. -# KMAP=/etc/console-setup/defkeymap.kmap.gz

--- a/config/chroot_local-includes/etc/init.d/tcos +++ b/config/chroot_local-includes/etc/init.d/tcos @@ -14,30 +14,34 @@ create_users() {

configure_server() {
  # configure GDM
  /usr/sbin/tcos-gdm-autologin --configure

+

  # copy tcosmonitor launcher in admin desktop
  mkdir -p /etc/skel/Desktop

- install --owner=admin --mode=755 /usr/share/applications/tcosmonitor.desktop /etc/skel/Desktop/ + install --mode=755 /usr/share/applications/tcosmonitor.desktop /etc/skel/Desktop/ + + # desktop icon + install -d --owner=admin /home/admin/Desktop

  install --owner=admin --mode=755 /usr/share/applications/tcosmonitor.desktop /home/admin/Desktop/

+ # readme file + # DNS + cat << EOF > /etc/resolv.conf +nameserver 192.168.0.254 +nameserver 8.8.8.8 +EOF

}


case "$1" in
  start)
    echo "Starting TCOS server "

- # create users - create_users - - cat << EOF > /etc/resolv.conf -nameserver 192.168.0.254 -nameserver 8.8.8.8 -EOF - # reload dnsmasq - invoke-rc.d dnsmasq restart

    # configure server
    configure_server

+ + # create users + create_users

    ;;
  stop)

- echo "Stopping TCOS server" + echo "Stopping TCOS server (nothing to stop)"

    ;;
  *)
    echo "Usage: /etc/init.d/tcos {start|stop}"

--- a/config/chroot_local-packageslists/tcos.list

+++ b/config/chroot_local-packageslists/tcos.list @@ -1,14 +1,14 @@

# sample package list for live-helper(7) with tcos, iceweasel and gnome

#include 

-bash-completion dnsutils htop binutils rsync ntfs-3g openssh-client +bash-completion dnsutils htop binutils rsync ntfs-3g openssh-client less acpid

mesa-utils

#include 
gnome-media gnome-audio evince file-roller zip unzip synaptic gdm-themes dmz-cursor-theme

# internet

-iceweasel iceweasel-l10n-es-es +iceweasel iceweasel-l10n-es-es iceweasel-l10n-pt-br

pidgin filezilla

# media

@@ -18,7 +18,8 @@ pulseaudio-module-x11 gstreamer0.10-pulseaudio pulseaudio-esound-compat

# gimp 
# openoffice.org openoffice.org-l10n-es

-openoffice.org-writer openoffice.org-calc openoffice.org-l10n-es openoffice.org-impress +openoffice.org-writer openoffice.org-calc openoffice.org-impress +openoffice.org-l10n-es openoffice.org-l10n-pt-br


# tcos

--- a/config/templates/isolinux.cfg

+++ /dev/null @@ -1,27 +0,0 @@ -menu hshift 13 -menu width 49 - -menu title Boot menu -include stdmenu.cfg - -label live - menu label TCOS Debian live (English) - kernel /live/vmlinuz - append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs - -label livees - menu label TCOS Debian live (Espaol) - kernel /live/vmlinuz - append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs locale=es_ES.UTF-8 keyb=es - - -label help - menu label ^Help - text help - Display help screens; type 'menu' at boot prompt to return to this menu - endtext - config prompt.cfg - -default /isolinux/vesamenu.c32 -prompt 0 -timeout 00

--- a/config/templates/syslinux/common/live.cfg +++ b/config/templates/syslinux/common/live.cfg @@ -1,12 +1,17 @@

label live

- menu label TCOS Debian live (English) + menu label TCOS Debian live English

	kernel /live/vmlinuz
	append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs 

label livees

- menu label TCOS Debian live (Spanish) + menu label TCOS Debian live Spanish

	kernel /live/vmlinuz

- append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs locale=es_ES.UTF-8 keyb=es + append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs locale=es_ES.UTF-8 keyb=es klayout=es kmodel=pc105 + +label livebr + menu label TCOS Debian live Brazil + kernel /live/vmlinuz

+ append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs locale=pt_BR.UTF-8 keyb=br klayout=br kmodel=abnt2

nueva prueba
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 23fdd82ae0c540ec2dfd56d2da92ca8c4be62cc5
Date: Mon, 08 Mar 2010 11:35:34 GMT
Commit diff


--- a/config/binary

+++ b/config/binary @@ -14,7 +14,8 @@ LH_BINARY_INDICES="true"

# $LH_BOOTAPPEND_LIVE: set boot parameters
# (Default: empty)

-LH_BOOTAPPEND_LIVE="quiet vga=791 splash locale=es_ES.UTF-8 keyb=es nonetworking" +#LH_BOOTAPPEND_LIVE="quiet vga=791 splash locale=es_ES.UTF-8 keyb=es nonetworking" +LH_BOOTAPPEND_LIVE="quiet vga=791 splash nonetworking"

# $LH_BOOTAPPEND_INSTALL: set boot parameters
# (Default: empty)

--- a/config/chroot_local-includes/etc/default/keyboard

+++ b/config/chroot_local-includes/etc/default/keyboard @@ -7,10 +7,18 @@

# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options
# in /etc/X11/xorg.conf.

+if [ "$(grep -c 'keyb=es' /proc/cmdline)" = "1" ]; then

XKBMODEL="pc105"
XKBLAYOUT="es"
XKBVARIANT=""
XKBOPTIONS="lv3:ralt_switch"

+else +XKBMODEL="pc104" +XKBLAYOUT="us" +XKBVARIANT="" +XKBOPTIONS="" +fi +

# If you don't want to use the XKB layout on the console, you can
# specify an alternative keymap.  Make sure it will be accessible

--- a/config/chroot_local-includes/etc/init.d/tcos

+++ b/config/chroot_local-includes/etc/init.d/tcos @@ -15,6 +15,8 @@ configure_server() {

  # configure GDM
  /usr/sbin/tcos-gdm-autologin --configure
  # copy tcosmonitor launcher in admin desktop

+ mkdir -p /etc/skel/Desktop + install --owner=admin --mode=755 /usr/share/applications/tcosmonitor.desktop /etc/skel/Desktop/

  install --owner=admin --mode=755 /usr/share/applications/tcosmonitor.desktop /home/admin/Desktop/
}


--- a/config/chroot_local-packageslists/tcos.list

+++ b/config/chroot_local-packageslists/tcos.list @@ -1,25 +1,29 @@

# sample package list for live-helper(7) with tcos, iceweasel and gnome

#include 

-dnsutils htop binutils +bash-completion dnsutils htop binutils rsync ntfs-3g openssh-client

mesa-utils

#include 

-file-roller zip unzip synaptic +gnome-media gnome-audio evince file-roller zip unzip synaptic gdm-themes dmz-cursor-theme

# internet
iceweasel iceweasel-l10n-es-es

-pidgin +pidgin filezilla

# media

+gimp

pavumeter pavucontrol paman paprefs

+pulseaudio-module-x11 gstreamer0.10-pulseaudio pulseaudio-esound-compat +

# gimp 
# openoffice.org openoffice.org-l10n-es

-openoffice.org-writer openoffice.org-impress openoffice.org-calc openoffice.org-l10n-es +openoffice.org-writer openoffice.org-calc openoffice.org-l10n-es openoffice.org-impress


# tcos
vlc dnsmasq xfs xfstt 
tcos tcos-configurator tcosmonitor tcosconfig
tcos-extra-modules-486 tcos-usplash

- +ltspfs fuse-utils +mtools dropbear p910nd genisoimage mbr syslinux

--- a/config/common +++ b/config/common @@ -25,7 +25,7 @@ LH_APT_PIPELINE=""

# $LH_APT_RECOMMENDS: set apt/aptitude recommends
# (Default: true)

-LH_APT_RECOMMENDS="true" +LH_APT_RECOMMENDS="false"

# $LH_APT_SECURE: set apt/aptitude security
# (Default: true)

@@ -97,7 +97,7 @@ LH_INCLUDES="/usr/share/live-helper/includes"

# $LH_TEMPLATES: set templates
# (Default: /usr/share/live-helper/templates)

-LH_TEMPLATES="/usr/share/live-helper/templates" +LH_TEMPLATES="config/templates"

# Live-helper options


--- /dev/null

+++ b/config/templates/isolinux.cfg @@ -0,0 +1,27 @@ +menu hshift 13 +menu width 49 + +menu title Boot menu +include stdmenu.cfg + +label live + menu label TCOS Debian live (English) + kernel /live/vmlinuz + append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs + +label livees + menu label TCOS Debian live (Espaol) + kernel /live/vmlinuz + append initrd=/live/initrd.img boot=live quiet vga=791 splash nonetworking username=admin hostname=tcos-server union=aufs locale=es_ES.UTF-8 keyb=es + + +label help + menu label ^Help + text help + Display help screens; type 'menu' at boot prompt to return to this menu + endtext + config prompt.cfg + +default /isolinux/vesamenu.c32 +prompt 0 +timeout 00

--- /dev/null +++ b/config/templates/syslinux/ca/boot.txt @@ -0,0 +1,3 @@ +{$SPLASH} + +Premeu F1 i control, i llavors el 1 per obtenir ajuda, o INTRO per fer el \ No newline at end of file

--- /dev/null +++ b/config/templates/syslinux/ca/f1.txt.install @@ -0,0 +1,26 @@ + 0fBenvingut a Debian GNU/Linux!07 09F107 + +Aix s un Debian {$LH_DISTRIBUTION} combinat live i d'installaci dins un {$LH_MEDIA}. +Fet el {$LH_DATE}. + +0fMEN DE LES AJUDES07 + +0fTECLA TEMA07 + +<09F107> Aquesta pgina, l'ndex. +<09F207> Prerequisits per installar Debian. +<09F307> Mtodes d'arrencada per a usos especials d'aquest {$LH_MEDIA}. +<09F407> Mtodes addicionals d'arrencada; mode de rescat. +<09F507> Reps dels parmetres especials d'arrencada. +<09F607> Parmetres especials per algunes mquines. +<09F707> Parmetres especials per certes controladores de discs. +<09F807> Parmetres especials pel sistema d'installaci. +<09F907> Com obtenir ajuda. +<09F1007> Copyrights i garanties. + +Per a F1-F9 premeu control amb F i llavors el nombre 1-9 +Per a F10 premeu control amb F i llavors el nombre 0 + + + +Premeu F2 a F10 per ms detalls, o INTRO per fer el \ No newline at end of file

--- /dev/null +++ b/config/templates/syslinux/ca/f1.txt.live @@ -0,0 +1,26 @@ + 0fBenvingut a Debian GNU/Linux!07 09F107 + +Aix s una Debian {$LH_DISTRIBUTION} live dins un {$LH_MEDIA}. +Fet el {$LH_DATE}. + +0fMEN DE LES AJUDES07 + +0fTECLA TEMA07 + +<09F107> Aquesta pgina, l'ndex. +<09F207> Prerequisits per installar Debian. +<09F307> Mtodes d'arrencada per a usos especials d'aquest {$LH_MEDIA} +<09F407> Mtodes addicionals d'arrencada. +<09F507> Reps dels parmetres especials d'arrencada. +<09F607> Parmetres especials per algunes mquines. +<09F707> Parmetres especials per certes controladores de discs. +<09F807> Parmetres especials pel sistema d'arrencada. +<09F907> Com obtenir ajuda. +<09F1007> Copyrights i garanties. + +Per a F1-F9 premeu control amb F i llavors el nombre 1-9 +Per a F10 premeu control amb F i llavors el nombre 0 + + + +Premeu F2 a F10 per ms detalls, o INTRO per fer el \ No newline at end of file

--- /dev/null +++ b/config/templates/syslinux/ca/f10.txt @@ -0,0 +1,24 @@ +0fCOPYRIGHTS I GARANTIES07 09F1007 + +Debian GNU/Linux t Copyright (C) 1993-2009 de Software in the Public Interest, +i altres. + +El sistema Debian GNU/Linux s pot redistribuir lliurement. Desprs de la +installaci, podeu consultar els termes exactes de distribuci de cada paquet +en el corresponent fitxer /usr/share/doc/0bnomdelpaquet07/copyright. + +Debian GNU/Linux ve sense 0fCAP MENA DE GARANTIA07, fins al punt on ho permeti +la llei aplicable. + +--- + +Aquest sistema Debian Live ha estat construt amb live-helper, versi {$LH_VERSION}. + +Ms informaci del projecte Debian Live es pot trobar a +. + + + + + +Preneu F1control i F seguit de 1 per el men d'ajuda, o INTRO per fer el \ No newline at end of file

--- /dev/null +++ b/config/templates/syslinux/ca/f2.txt.install @@ -0,0 +1,24 @@ +0fPREREQUISITS PER A USAR DEBIAN07 09F207 + +Heu de tenir un mnim de 64MB de RAM per usar aquest sistema Debian Live. + +Vegeu el Manual Live o el PUF (FAQ) per a ms informarci; tot dos disponibles +a la web de Debian Live, 0fhttp://debian-live.alioth.debian.org/07 + + +Heu de tenir al manco 32 megabytes de RAM per a usar el installador de Debian. + +Heu de tenir espai en el disc dur per a crear una nova partici de disc +de al manco 256 megabytes per a installar el sistema base. Necessitar ms +espai de disc per a installar paquets addicionals, depenent de qu desitgi fer +amb el seu sistema Debian. + +Vegeu el manual d'installaci o les PUF per a ms informaci; tot dos documents +estan a la seva disposici a la web de Debian, 0fhttp://www.debian.org/07 + +Grcies per seleccionar Debian! + + + + +Preneu F1control i F i llavors 1 per veure el men d'ajuda, o ENTER per a \ No newline at end of file

--- /dev/null +++ b/config/templates/syslinux/ca/f2.txt.live @@ -0,0 +1,24 @@ +0fPREREQUISITS PER A USAR DEBIAN07 09F207 + +Heu de tenir un mnim de 64MB de RAM per usar aquest sistema Debian Live. + +Vegeu el Manual Live o el PUF (FAQ) per a ms informarci; tot dos disponibles +a la web de Debian Live, 0fhttp://debian-live.alioth.debian.org/07 + +Grcies per seleccionar Debian! + + + + + + + + + + + + + + + +Preneu F1control i F, i llavors 1 per veure el men d'ajuda, o ENTER per a

\ No newline at end of file

xmlrpc/sh/devicesctl.sh hooks-addons/54devices: ensure LTSPFS_TOKEN is set
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 2259163de8890cdba37529bf556a51878ffa8af3
Date: Mon, 08 Mar 2010 10:33:07 GMT
Commit diff


--- a/hooks-addons/54devices

+++ b/hooks-addons/54devices @@ -21,21 +21,22 @@ create_launcher() {

#!/bin/sh
# wait for Xorg

+export DISPLAY=:0 +export XAUTHORITY=/root/.Xauthority +

if [ "\$1" != "now" ]; then

- time1=2 -else - time1=0 + sleep 2

fi

-sleep \$time1 +echo "ltspfs-set-xprop::waitforX"

waitforX

# wait until Xorg is complety started

-sleep \$time1 -echo "ltspfs-set-xprop::setting xprop value" +if [ "\$1" != "now" ]; then + sleep 5 +fi

-export DISPLAY=:0 -export XAUTHORITY=/root/.Xauthority +echo "ltspfs-set-xprop::setting xprop value"

echo "xprop -root -f LTSPFS_TOKEN 8s -set LTSPFS_TOKEN \$(cat /var/run/ltspfs_token)"
xprop -root -f LTSPFS_TOKEN 8s -set LTSPFS_TOKEN \$(cat /var/run/ltspfs_token)


--- a/xmlrpc/sh/devicesctl.sh

+++ b/xmlrpc/sh/devicesctl.sh @@ -115,7 +115,10 @@ fi


if [ "$1" = "--mount" ]; then

- [ -x /bin/ltspfs-set-xprop ] && /bin/ltspfs-set-xprop now 2>&1 >> /tmp/initramfs.debug + export DISPLAY=:0 + if [ "$(xprop -root | grep -c LTSPFS)" = "0" ]; then + [ -x /bin/ltspfs-set-xprop ] && /bin/ltspfs-set-xprop now >> /tmp/initramfs.debug 2>&1 + fi

  if [ "$2" != "" ]; then
      mnt=$(basename $2)
if [ $(grep -c /mnt/$mnt /proc/mounts) != 0 ]; then

first version of TCOS Debian live CD
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 2df49932f7c1a8112768e3be80cd87a18d718479
Date: Mon, 08 Mar 2010 00:20:45 GMT
Commit diff


--- a/config/binary

+++ b/config/binary @@ -14,7 +14,7 @@ LH_BINARY_INDICES="true"

# $LH_BOOTAPPEND_LIVE: set boot parameters
# (Default: empty)

-LH_BOOTAPPEND_LIVE="quiet vga=791 splash locale=es_ES.UTF-8 keyb=es" +LH_BOOTAPPEND_LIVE="quiet vga=791 splash locale=es_ES.UTF-8 keyb=es nonetworking"

# $LH_BOOTAPPEND_INSTALL: set boot parameters
# (Default: empty)

@@ -63,7 +63,7 @@ LH_HOSTNAME="tcos-server"

# $LH_ISO_APPLICATION: set iso author
# (Default: Debian Live)

-LH_ISO_APPLICATION="Debian Live" +LH_ISO_APPLICATION="TCOS Debian Live"

# $LH_ISO_PREPARER: set iso preparer
# (Default: live-helper 2.0~a8-1; http://packages.qa.debian.org/live-helper)

@@ -143,7 +143,7 @@ LH_SYSLINUX_MENU="true"

# $LH_SYSLINUX_MENU_LIVE_ENTRY: set text to be used on the menu for live entries
# (Default: Live)

-LH_SYSLINUX_MENU_LIVE_ENTRY="Live" +LH_SYSLINUX_MENU_LIVE_ENTRY="TCOS"

# $LH_SYSLINUX_MENU_LIVE_FAILSAFE_ENTRY: set text to be used on the menu for live entries (failsafe ones)
# (Default: )

--- a/config/chroot

+++ b/config/chroot @@ -42,7 +42,7 @@ LH_LINUX_PACKAGES="linux-image-2.6"

# $LH_PACKAGES: set packages to install
# (Default: empty)

-LH_PACKAGES="" +LH_PACKAGES="squashfs-tools"

# $LH_PACKAGES_LISTS: set package list to install
# (Default: standard)

--- /dev/null

+++ b/config/chroot_local-includes/etc/asound.conf @@ -0,0 +1,7 @@ +pcm.!default { + type pulse +} +ctl.!default { + type pulse +} +

--- a/config/chroot_local-includes/etc/init.d/tcos +++ b/config/chroot_local-includes/etc/init.d/tcos @@ -7,15 +7,32 @@ create_users() {

   adduser --disabled-password --gecos "tcos${i}" "tcos${i}" > /dev/null 2>&1
   adduser "tcos${i}" fuse >/dev/null 2>&1
   echo "tcos${i}:tcos${i}" | chpasswd --md5 > /dev/null 2>&1

- + echo "192.168.0.${i} tcos${i}" >> /etc/hosts

 done
}

+configure_server() { + # configure GDM + /usr/sbin/tcos-gdm-autologin --configure + # copy tcosmonitor launcher in admin desktop + install --owner=admin --mode=755 /usr/share/applications/tcosmonitor.desktop /home/admin/Desktop/ +} + +

case "$1" in
  start)
    echo "Starting TCOS server "
    # create users
    create_users

+ + cat << EOF > /etc/resolv.conf +nameserver 192.168.0.254 +nameserver 8.8.8.8 +EOF + # reload dnsmasq + invoke-rc.d dnsmasq restart + # configure server + configure_server

    ;;
  stop)
    echo "Stopping TCOS server"

--- /dev/null

+++ b/config/chroot_local-includes/etc/resolv.conf.real @@ -0,0 +1,2 @@ +nameserver 8.8.8.8 +nameserver 4.4.4.4

--- a/config/chroot_local-packageslists/tcos.list +++ b/config/chroot_local-packageslists/tcos.list @@ -1,17 +1,25 @@

# sample package list for live-helper(7) with tcos, iceweasel and gnome

#include 

+dnsutils htop binutils

mesa-utils

#include 

+file-roller zip unzip synaptic

-# Mozilla +# internet

iceweasel iceweasel-l10n-es-es

+pidgin + +# media +pavumeter pavucontrol paman paprefs +# gimp +# openoffice.org openoffice.org-l10n-es +openoffice.org-writer openoffice.org-impress openoffice.org-calc openoffice.org-l10n-es +

# tcos

-vlc dnsmasq binutils xfs xfstt +vlc dnsmasq xfs xfstt

tcos tcos-configurator tcosmonitor tcosconfig
tcos-extra-modules-486 tcos-usplash

-# media

-pavumeter pavucontrol paman paprefs

first version
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 9bed38779a233f61c2c492b25dc458323a0db456
Date: Sun, 07 Mar 2010 21:47:44 GMT
Commit diff


--- /dev/null

+++ b/config/binary @@ -0,0 +1,158 @@ +# config/binary - options for live-helper(7), binary stage + +# $LH_BINARY_FILESYSTEM: set image filesystem +# (Default: fat16) +LH_BINARY_FILESYSTEM="fat16" + +# $LH_BINARY_IMAGES: set image type +# (Default: iso) +LH_BINARY_IMAGES="iso" + +# $LH_BINARY_INDICES: set apt/aptitude generic indices +# (Default: true) +LH_BINARY_INDICES="true" + +# $LH_BOOTAPPEND_LIVE: set boot parameters +# (Default: empty) +LH_BOOTAPPEND_LIVE="quiet vga=791 splash locale=es_ES.UTF-8 keyb=es" + +# $LH_BOOTAPPEND_INSTALL: set boot parameters +# (Default: empty) +LH_BOOTAPPEND_INSTALL="" + +# $LH_BOOTLOADER: set bootloader +# (Default: syslinux) +LH_BOOTLOADER="syslinux" + +# $LH_CHECKSUMS: set checksums +# (Default: true) +LH_CHECKSUMS="true" + +# ${LH_CHROOT_BUILD: control if we build binary images chrooted +# (Default: true) +# DO NEVER, *NEVER*, *N*E*V*E*R* SET THIS OPTION to false. +LH_CHROOT_BUILD="true" + +# $LH_DEBIAN_INSTALLER: set debian-installer +# (Default: false) +LH_DEBIAN_INSTALLER="false" + +# $LH_DEBIAN_INSTALLER_DISTRIBUTION: set debian-installer suite +# (Default: empty) +LH_DEBIAN_INSTALLER_DISTRIBUTION="lenny" + +# $LH_DEBIAN_INSTALLER_PRESEEDFILE: set debian-installer preseed filename/url +# (Default: ) +LH_DEBIAN_INSTALLER_PRESEEDFILE="" + +# $LH_DEBIAN_INSTALLER_GUI: toggle use of GUI debian-installer +# (Default: true) +LH_DEBIAN_INSTALLER_GUI="true" + +# $LH_ENCRYPTION: set encryption +# (Default: false) +LH_ENCRYPTION="false" + +# $LH_GRUB_SPLASH: set custom grub splash +# (Default: empty) +LH_GRUB_SPLASH="" + +# $LH_HOSTNAME: set hostname +# (Default: tcos-server) +LH_HOSTNAME="tcos-server" + +# $LH_ISO_APPLICATION: set iso author +# (Default: Debian Live) +LH_ISO_APPLICATION="Debian Live" + +# $LH_ISO_PREPARER: set iso preparer +# (Default: live-helper 2.0~a8-1; http://packages.qa.debian.org/live-helper) +LH_ISO_PREPARER="live-helper 2.0~a8-1; http://packages.qa.debian.org/live-helper" + +# $LH_ISO_PUBLISHER: set iso publisher +# (Default: Debian Live project; http://debian-live.alioth.debian.org/; debian-live@lists.debian.org) +LH_ISO_PUBLISHER="Debian Live project; http://debian-live.alioth.debian.org/; debian-live@lists.debian.org" + +# $LH_ISO_VOLUME: set iso volume (max 32 chars) +# (Default: Debian TCOS 20100307-17:57) +LH_ISO_VOLUME="Debian TCOS 20100307-17:57" + +# $LH_JFFS2_ERASEBLOCK: set jffs2 eraseblock size +# (Default: unset) +LH_JFFS2_ERASEBLOCK="" + +# $LH_MEMTEST: set memtest +# (Default: memtest86+) +LH_MEMTEST="memtest86+" + +# $LH_WIN32_LOADER: set win32-loader +# (Default: false) +LH_WIN32_LOADER="false" + +# $LH_NET_ROOT_FILESYSTEM: set netboot filesystem +# (Default: nfs) +LH_NET_ROOT_FILESYSTEM="nfs" + +# $LH_NET_ROOT_MOUNTOPTIONS: set nfsopts +# (Default: empty) +LH_NET_ROOT_MOUNTOPTIONS="" + +# $LH_NET_ROOT_PATH: set netboot server directory +# (Default: /srv/debian-live) +LH_NET_ROOT_PATH="/srv/debian-live" + +# $LH_NET_ROOT_SERVER: set netboot server address +# (Default: 192.168.1.1) +LH_NET_ROOT_SERVER="192.168.1.1" + +# $LH_NET_COW_FILESYSTEM: set net client cow filesystem +# (Default: nfs) +LH_NET_COW_FILESYSTEM="nfs" + +# $LH_NET_COW_MOUNTOPTIONS: set cow mount options +# (Default: empty) +LH_NET_COW_MOUNTOPTIONS="" + +# $LH_NET_COW_PATH: set cow directory +# (Default: ) +LH_NET_COW_PATH="" + +# $LH_NET_COW_SERVER: set cow server +# (Default: ) +LH_NET_COW_SERVER="" + +# $LH_NET_TARBALL: set net tarball +# (Default: gzip) +LH_NET_TARBALL="gzip" + +# $LH_SYSLINUX_SPLASH: set custom syslinux splash +# (Default: empty) +LH_SYSLINUX_SPLASH="" + +# $LH_SYSLINUX_TIMEOUT: set custom syslinux timeout in seconds +# (Default: 0) +LH_SYSLINUX_TIMEOUT="0" + +# $LH_SYSLINUX_CFG: set custom syslinux configuration file +# (Default: empty) +LH_SYSLINUX_CFG="" + +# $LH_SYSLINUX_MENU: set syslinux menu +# (Default: true) +LH_SYSLINUX_MENU="true" + +# $LH_SYSLINUX_MENU_LIVE_ENTRY: set text to be used on the menu for live entries +# (Default: Live) +LH_SYSLINUX_MENU_LIVE_ENTRY="Live" + +# $LH_SYSLINUX_MENU_LIVE_FAILSAFE_ENTRY: set text to be used on the menu for live entries (failsafe ones) +# (Default: ) +LH_SYSLINUX_MENU_LIVE_FAILSAFE_ENTRY="" + +# $LH_SYSLINUX_MENU_MEMTEST_ENTRY: set text to be used on the menu for memtest entry +# (Default: Memory test) +LH_SYSLINUX_MENU_MEMTEST_ENTRY="Memory test" + +# $LH_USERNAME: set username +# (Default: admin) +LH_USERNAME="admin"

--- /dev/null +++ b/config/bootstrap @@ -0,0 +1,53 @@ +# config/bootstrap - options for live-helper(7), bootstrap stage + +# $LH_ARCHITECTURE: select chroot architecture +# (Default: autodetected) +LH_ARCHITECTURE="i386" + +# $LH_BOOTSTRAP_CONFIG: set distribution config directory +# (Default: empty) +LH_BOOTSTRAP_CONFIG="" + +# $LH_BOOTSTRAP_INCLUDE: include packages on base +# (Default: empty) +LH_BOOTSTRAP_INCLUDE="" + +# $LH_BOOTSTRAP_EXCLUDE: exclude packages on base +# (Default: empty) +LH_BOOTSTRAP_EXCLUDE="" + +# $LH_BOOTSTRAP_FLAVOUR: select flavour to use +# (Default: empty) +LH_BOOTSTRAP_FLAVOUR="" + +# $LH_BOOTSTRAP_KEYRING: set distribution keyring +# (Default: empty) +LH_BOOTSTRAP_KEYRING="" + +# $LH_DISTRIBUTION: select distribution to use +# (Default: sid) +LH_DISTRIBUTION="sid" + +# $LH_MIRROR_BOOTSTRAP: set mirror to bootstrap from +# (Default: http://ftp.fi.debian.org/debian/) +LH_MIRROR_BOOTSTRAP="http://ftp.fi.debian.org/debian/" + +# $LH_MIRROR_CHROOT: set mirror to fetch packages from +# (Default: http://ftp.fi.debian.org/debian/) +LH_MIRROR_CHROOT="http://ftp.fi.debian.org/debian/" + +# $LH_MIRROR_CHROOT_SECURITY: set security mirror to fetch packages from +# (Default: http://security.debian.org/) +LH_MIRROR_CHROOT_SECURITY="http://security.debian.org/" + +# $LH_MIRROR_BINARY: set mirror which ends up in the image +# (Default: http://ftp.fi.debian.org/debian/) +LH_MIRROR_BINARY="http://ftp.fi.debian.org/debian/" + +# $LH_MIRROR_BINARY_SECURITY: set security mirror which ends up in the image +# (Default: http://security.debian.org/) +LH_MIRROR_BINARY_SECURITY="http://security.debian.org/" + +# $LH_ARCHIVE_AREAS: select archive areas to use +# (Default: main) +LH_ARCHIVE_AREAS="main"

--- /dev/null +++ b/config/chroot @@ -0,0 +1,65 @@ +# config/chroot - options for live-helper(7), chroot stage + +# $LH_CHROOT_FILESYSTEM: set chroot filesystem +# (Default: squashfs) +LH_CHROOT_FILESYSTEM="squashfs" + +# $LH_UNION_FILESYSTEM: set union filesystem +# (Default: aufs) +LH_UNION_FILESYSTEM="aufs" + +# $LH_VIRTUAL_ROOT_SIZE: set virtual-hdd filesystem size +# (Default: 10000) +LH_VIRTUAL_ROOT_SIZE="10000" + +# $LH_EXPOSED_ROOT: expose root as read only +# (Default: false) +LH_EXPOSED_ROOT="false" + +# $LH_HOOKS: set hook commands +# (Default: empty) +LH_HOOKS="" + +# $LH_INTERACTIVE: set interactive build +# (Default: false) +LH_INTERACTIVE="false" + +# $LH_KEYRING_PACKAGES: set keyring packages +# (Default: empty) +LH_KEYRING_PACKAGES="debian-archive-keyring" + +# $LH_LANGUAGE: set language to use +# (Default: empty) +LH_LANGUAGE="es" + +# $LH_LINUX_FLAVOURS: set kernel flavour to use +# (Default: autodetected) +LH_LINUX_FLAVOURS="486 686" + +# $LH_LINUX_PACKAGES: set kernel packages to use +# (Default: autodetected) +LH_LINUX_PACKAGES="linux-image-2.6" + +# $LH_PACKAGES: set packages to install +# (Default: empty) +LH_PACKAGES="" + +# $LH_PACKAGES_LISTS: set package list to install +# (Default: standard) +LH_PACKAGES_LISTS="standard" + +# $LH_TASKS: set tasks to install +# (Default: empty) +LH_TASKS="" + +# $LH_SECURITY: enable security updates +# (Default: false) +LH_SECURITY="false" + +# $LH_SYMLINKS: enable symlink convertion +# (Default: false) +LH_SYMLINKS="false" + +# $LH_SYSVINIT: enable sysvinit +# (Default: false) +LH_SYSVINIT="false"

--- /dev/null +++ b/config/chroot_local-hooks/configuretcos.sh @@ -0,0 +1,50 @@ +#!/bin/sh + + + +echo "I: Buiding TCOS images ..." + +if [ ! -e /etc/tcos/templates/tcosconfig.conf ]; then +echo "I: Creating /etc/tcos/templates/tcosconfig.conf..." +cat << EOF > /etc/tcos/templates/tcosconfig.conf +# file generated by tcosconfig on Wed Dec 23 13:48:01 2009 +TEMPLATE_DESCRIPTION="Plantilla generada por tcosconfig" + + +# conf based on template +TCOS_BASED_TEMPLATE=tcos.conf.all +TCOS_KERNEL="2.6.32-2-486" +TCOS_COMPCACHE=1 +TCOS_COMPCACHE_PERCENT=25 + + +#end of template + +EOF +fi + +gentcos -tftp -size + + +echo "I: disable dropbear" +update-rc.d -f dropbear remove +echo "NO_START=1" >> /etc/default/dropbear + +if [ -f /etc/X11/fs/config ]; then + echo "I: configuring XFS" + sed -i 's/no-listen/#no-listen/g' /etc/X11/fs/config +fi + +if [ -f /etc/default/xfstt ]; then + echo "I: configuring XFSTT" + echo 'LISTEN_TCP="yes"' >> /etc/default/xfstt +fi + + +# Make the init script executable +chown root:root /etc/init.d/tcos +chmod 755 /etc/init.d/tcos + +# Create symlinks for each runlevel +# eg /etc/rc2.d/S90tcos for runlevel 2, etc +update-rc.d tcos defaults 90 10

--- /dev/null +++ b/config/chroot_local-includes/etc/default/keyboard @@ -0,0 +1,18 @@ +# If you change any of the following variables and HAL and X are +# configured to use this file, then the changes will become visible to +# X only if HAL is restarted. In Debian you need to run +# /etc/init.d/hal restart + +# The following variables describe your keyboard and can have the same +# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options +# in /etc/X11/xorg.conf. + +XKBMODEL="pc105" +XKBLAYOUT="es" +XKBVARIANT="" +XKBOPTIONS="lv3:ralt_switch" + +# If you don't want to use the XKB layout on the console, you can +# specify an alternative keymap. Make sure it will be accessible +# before /usr is mounted. +# KMAP=/etc/console-setup/defkeymap.kmap.gz

--- /dev/null +++ b/config/chroot_local-includes/etc/dnsmasq.conf @@ -0,0 +1,17 @@ +# dnsmasq.conf for TCOS + +resolv-file=/etc/resolv.conf.real +listen-address=192.168.0.254,127.0.0.1 + +dhcp-range=192.168.0.10,192.168.0.30,12h +dhcp-option=option:router,192.168.0.1 +dhcp-option=option:dns-server,192.168.0.254,192.168.0.1 +dhcp-boot=/tcos/pxelinux.0,192.168.0.254,192.168.0.254 + +enable-tftp +tftp-root=/var/lib/tftpboot +dhcp-authoritative + +#log-dhcp +#log-queries +

--- /dev/null +++ b/config/chroot_local-includes/etc/init.d/tcos @@ -0,0 +1,29 @@ +#! /bin/sh +# /etc/init.d/tcos +# + +create_users() { + for i in $(seq 10 30); do + adduser --disabled-password --gecos "tcos${i}" "tcos${i}" > /dev/null 2>&1 + adduser "tcos${i}" fuse >/dev/null 2>&1 + echo "tcos${i}:tcos${i}" | chpasswd --md5 > /dev/null 2>&1 + + done +} + +case "$1" in + start) + echo "Starting TCOS server " + # create users + create_users +  ;; + stop) + echo "Stopping TCOS server" +  ;; + *) + echo "Usage: /etc/init.d/tcos {start|stop}" + exit 0 +  ;; +esac + +exit 0

--- /dev/null +++ b/config/chroot_local-includes/etc/network/interfaces @@ -0,0 +1,13 @@ +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +# The loopback network interface +auto lo +iface lo inet loopback + +# The primary network interface +auto eth0 +iface eth0 inet static + address 192.168.0.254 + netmask 255.255.255.0 + gateway 192.168.0.1

--- /dev/null +++ b/config/chroot_local-packageslists/tcos.list @@ -0,0 +1,17 @@ +# sample package list for live-helper(7) with tcos, iceweasel and gnome + +#include +mesa-utils + +#include + +# Mozilla +iceweasel iceweasel-l10n-es-es + +# tcos +vlc dnsmasq binutils xfs xfstt +tcos tcos-configurator tcosmonitor tcosconfig +tcos-extra-modules-486 tcos-usplash + +# media +pavumeter pavucontrol paman paprefs

--- /dev/null +++ b/config/chroot_sources/tcos.binary @@ -0,0 +1 @@ +deb http://www.tcosproject.org unstable main experimental

--- /dev/null +++ b/config/chroot_sources/tcos.binary.gpg @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.2 (GNU/Linux) + +mQGiBEKxrYkRBACOGrDcsqdeW36hwmxi4dn2U8BGafRlGOHxAd1Hryw7Q4pWI8xK +z5ZhAYAnXxrfw+83dGM+bHI2tcP+EIQ3SgQsOtzVh1LJ/Gixr4bkTqFYqQ4wO8S0 +AmhI5MSIV3k0pGf45RpZNtFqrm17ge892dqRr3nMRNAiWzwOhf3/nQK/fwCg1Si7 +xweJebKityAbWubjEQyXAhUD/08MCyuBuAVO8+cQzbHs248oy/SkOrx9fYjqJ4sP +6N1Do2onNMjvxypB1uQvjnhvNu7LkGjRumhADUOjQ7iXPcqO5EOc4iT2lg3gCxJ9 +GmbLDCupIZq7avz2gNaBFPONi6eq9K1kRK/W1VDWGflBtw3C5iU1w5HIUg6NcC8p +HNypA/4/QWHpL2Txy7oquP4pggar86cwye2Wq7cYJFq/MLSj6kob8ItqDTXg0uGh +omgQVRWGgOLvmLKvziBxwh5ZWcuKWFAsfBJepBi03MdnP4kOsPml8tjZlBehagsj +hOoO+fWruHe4mvoN+y4w8wBG7AEZ2EuH+CO9RoZLP+jVORHPdbQ1TWFyaW8gSXpx +dWllcmRvIChtYXJpb2RlYmlhbikgPG1hcmlvZGViaWFuQGdtYWlsLmNvbT6IXgQT +EQIAHgUCQrGtiQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIXgAAKCRB8e40sf3dB+9B3 +AJ9tQzsxQGKr0wHNZPhbxDYKpFSNywCfQNhCHldepKPt6CU8U3c5TzTi1qm5Ag0E +QrGtoxAIAKDj4pLKvm/7bNuVNxv7Y8PqseeRdUhONaVYIIFjuZYfgEE5MVgi56Zb +NYMo78IvzONWM7OlwnIXSZ8TqC6wA58U0649bLOI7sSB1Ckq4tTup1KUR+zUwZKo +ncKjmj1t69jEU7KPVT/RBsjyL1Pl1WbkG6YUNxAeHJOf0L07Zz7MKIgsczfZnxie +PdbDpaYaMnJNzV3IzPfH5LfnNVgIRZ4wXF2lf+ZmzsWkhOVbv9mPNfaZAf33oGjG +cW5ylVRW1IlHX0HEo4csoiAJh9nYPoKja4NrgNY+U1oxuCT8tQ+6HmZHbqrSMpvK +bZOC+VB3UVT+GbQU2JdzqDbSSkExRu8AAwcH/16b7+22tndZnNONrShgslJTOi6I +4ZGJnerc1y8nzd7j0R5cviIu3Hvf9w1k8Lc3SZDMvwiW9gMepzUwK6vEfJNg/M7M +sjpQE5cqfQv6wOGDCI33NYbhcZBWAKsjRwVlQRphnQJVDxJ4av/P9lvD1VvbT7XY +UYNDsdXEqVhastq9ivVmLmb3qChdXVjZovzsX9XiLBFqh4CiycsM4k8I0i9YP2KJ +lGq5f35V3A8Cm6jxLB+qxyTY/aYcRp9GLbhArEusJY3gLyWgP/GBfi0xItA9ix8J +SXPedCJMcEqo4pzauRFuxK4aeyDj4RNb6XvKsVM6KHUEZ1hwICFx84q7hiyISQQY +EQIACQUCQrGtowIbDAAKCRB8e40sf3dB+6zyAKCCKSaLr8EfdE85b0rHkBIjNf/K +XACgs+X/QVkh+sQ44hA7nST5C493NrE= +=G2Au +-----END PGP PUBLIC KEY BLOCK-----

--- /dev/null +++ b/config/chroot_sources/tcos.chroot @@ -0,0 +1 @@

+deb http://www.tcosproject.org unstable main experimental

add support of hardy
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: d818164b82033fed111ea2797676b269da5b1868
Date: Tue, 02 Mar 2010 14:55:04 GMT
Commit diff


--- a/debian/get.compcache.dir.sh

+++ b/debian/get.compcache.dir.sh @@ -6,6 +6,9 @@ case $DIST in

    *lenny*)
        echo "debian/compcache.old/"
        ;;

+ *hardy*) + echo "debian/compcache.old/" +  ;;

    *)
echo "./"

add Ubuntu lucid
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: b662273ea308d731a6d0e6451f1821e3eadcf35c
Date: Tue, 02 Mar 2010 14:34:49 GMT
Commit diff


--- a/common.mk

+++ b/common.mk @@ -31,6 +31,8 @@ USPLASH_intrepid=0.5

USPLASH_jaunty=0.5

USPLASH_karmic=0.5

+ +USPLASH_lucid=0.5

##################################

fixes for Debian Lenny and Ubuntu Hardy
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: a0befff9fa58c1e3e9d867cb6c2fa4624d1e2cee
Date: Tue, 02 Mar 2010 14:33:48 GMT
Commit diff


--- a/build.py

+++ b/build.py @@ -167,7 +167,7 @@ class Builder:

        if modname == "aufs":
            sh("cd build/%s/modules/%s && make -C %s M=%s/build/%s/modules/%s modules" %(kversion, modname, KDIR+kversion, CURDIR, kversion, modname))
        else:

- sh("cd build/%s/modules/%s && make KDIR=%s KVER=%s" %(kversion, modname, KDIR+kversion, kversion)) + sh("cd build/%s/modules/%s && make KDIR=%s KVER=%s KVERS=%s" %(kversion, modname, KDIR+kversion, kversion, kversion))

    def installmodule(self, modname, kversion):
        """

@@ -185,9 +185,9 @@ class Builder:

            f.write("\n\ninstall:")
            f.write("\n\tinstall -D -m 0644 aufs.ko $(DESTDIR)/lib/modules/$(KVER)/kernel/fs/aufs/aufs.ko")
            f.close()

- make="make KVER=%s M=%s/build/%s/modules/aufs DESTDIR=%s install" %(kversion,CURDIR,kversion,destdir) + make="make KVER=%s KVERS=%s M=%s/build/%s/modules/aufs DESTDIR=%s install" %(kversion,kversion,CURDIR,kversion,destdir)

        else:

- make="make KDIR=%s KVER=%s DESTDIR=%s install" %(KDIR+kversion, kversion, destdir) + make="make KDIR=%s KVER=%s KVERS=%s DESTDIR=%s install" %(KDIR+kversion, kversion, kversion, destdir)

        cmd="cd build/%s/modules/%s && " %(kversion, modname) + make
        #print cmd
        sh( cmd , canfail=True)

--- a/common.mk

+++ b/common.mk @@ -32,7 +32,7 @@ KERNEL_gutsy=2.6.22-16-generic 2.6.22-16-386 2.6.22-16-server

TCOS_MODULES_gutsy="aufs etc2300-modules sis7019-alsa-backport cdfs"

KERNEL_hardy=2.6.24-24-generic 2.6.24-24-386 2.6.24-24-server

-TCOS_MODULES_hardy="aufs etc2300-modules sis7019-alsa-backport cdfs lzma" +TCOS_MODULES_hardy="aufs etc2300-modules sis7019-alsa-backport cdfs lzma compcache"

KERNEL_max=2.6.24-24-generic 2.6.24-24-386 2.6.24-24-server
TCOS_MODULES_max="aufs etc2300-modules sis7019-alsa-backport cdfs lzma"

@@ -41,9 +41,9 @@ KERNEL_intrepid=2.6.27-17-generic 2.6.27-17-server

TCOS_MODULES_intrepid="aufs etc2300-modules cdfs lzma"

KERNEL_jaunty=2.6.28-18-generic 2.6.28-18-server

-TCOS_MODULES_jaunty="sis7019-alsa-backport compcache cdfs" +TCOS_MODULES_jaunty="compcache cdfs"

-KERNEL_karmic=2.6.31-19-generic 2.6.31-19-server +KERNEL_karmic=2.6.31-15-generic 2.6.31-16-generic 2.6.31-17-generic 2.6.31-19-generic

TCOS_MODULES_karmic="compcache cdfs"

KERNEL_lucid=2.6.32-14-generic 2.6.32-14-server

--- a/patches/compcache.patch

+++ b/patches/compcache.patch @@ -1,8 +1,22 @@ ---- build/modules/compcache.orig/Makefile 2010-02-26 11:50:59.000000000 +0100 -+++ build/modules/compcache/Makefile 2010-02-26 14:57:50.000000000 +0100 -@@ -14,3 +14,8 @@ +--- build/modules/compcache.orig/Makefile 2010-02-26 14:36:21.000000000 +0100 ++++ build/modules/compcache/Makefile 2010-02-26 17:43:22.000000000 +0100 +@@ -1,4 +1,4 @@ +-KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build" ++KDIR ?= "/lib/modules/$(KVER)/build" + + XVM = sub-projects/allocators/xvmalloc-kmod + EXTRA_CFLAGS := -DCONFIG_RAMZSWAP_STATS \ +@@ -8,9 +8,14 @@ + ramzswap-objs := ramzswap_drv.o $(XVM)/xvmalloc.o + + all: +- make -C $(KERNEL_BUILD_PATH) M=$(CURDIR) modules ++ make -C $(KDIR) M=$(CURDIR) modules + +

 clean:

- make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean +- make -C $(KERNEL_BUILD_PATH) M=$(CURDIR) clean ++ make -C $(KDIR) M=$(CURDIR) clean

 	@rm -rf *.ko
+
+

new version 0.6.2-3
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: e677570ba1188df8822907e31f94ab8f5a5cae90
Date: Tue, 02 Mar 2010 13:41:21 GMT
Commit diff


--- a/debian/changelog

+++ b/debian/changelog @@ -1,3 +1,9 @@ +compcache (0.6.2-3) unstable; urgency=low + + * Add compcache-0.5.4 in debian/ dir to compile in old versions (Debian lenny) + + -- Mario Izquierdo (mariodebian) Tue, 02 Mar 2010 14:40:35 +0100 +

compcache (0.6.2-2) unstable; urgency=low

* Change Makefile PWD => CURDIR

more fixed for debian lenny compcache
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 4962a6e97d20137c076fdc8c1cc95d83d7e6b334
Date: Tue, 02 Mar 2010 13:35:38 GMT
Commit diff


--- a/debian/compcache.old/Makefile

+++ b/debian/compcache.old/Makefile @@ -1,4 +1,5 @@ -KDIR ?= "/lib/modules/$(KVER)/build" +KVERS ?= $(shell uname -r) +KDIR ?= "/lib/modules/$(KVERS)/build"

XVM = sub-projects/allocators/xvmalloc-kmod
EXTRA_CFLAGS	:=	-DCONFIG_BLK_DEV_RAMZSWAP_STATS	\

@@ -10,17 +11,20 @@ obj-m += $(XVM)/xvmalloc.o \

all:
	make -C $(KDIR) M=$(CURDIR)/$(XVM) modules

+ @ln -s sub-projects/allocators/xvmalloc-kmod/xvmalloc.h ./

	make -C $(KDIR) M=$(CURDIR) modules
	@ln -sf $(XVM)/xvmalloc.ko

+ @rm -f xvmalloc.h

clean:
	make -C $(KDIR) M=$(CURDIR) clean
	make -C $(KDIR) M=$(CURDIR)/$(XVM) clean
	@rm -rf *.ko

+ @rm -f xvmalloc.h


install:

- install -d install -d $(DESTDIR)/lib/modules/$(KVER)/updates/compcache - install -m 644 sub-projects/allocators/xvmalloc-kmod/xvmalloc.ko $(DESTDIR)/lib/modules/$(KVER)/updates/compcache/ - install -m 644 ramzswap.ko $(DESTDIR)/lib/modules/$(KVER)/updates/compcache/ + install -d install -d $(DESTDIR)/lib/modules/$(KVERS)/updates/compcache + install -m 644 sub-projects/allocators/xvmalloc-kmod/xvmalloc.ko $(DESTDIR)/lib/modules/$(KVERS)/updates/compcache/ + install -m 644 ramzswap.ko $(DESTDIR)/lib/modules/$(KVERS)/updates/compcache/



--- a/debian/compcache.old/sub-projects/allocators/xvmalloc-kmod/Makefile

+++ b/debian/compcache.old/sub-projects/allocators/xvmalloc-kmod/Makefile @@ -1,13 +1,14 @@ +KVERS ?= $(shell uname -r)

EXTRA_CFLAGS	:=	-g -O2 -Wall

-KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build" +KDIR ?= "/lib/modules/$(KVERS)/build"

obj-m		+=	xvmalloc.o

all:

- make -C $(KERNEL_BUILD_PATH) M=$(PWD) modules + make -C $(KDIR) M=$(CURDIR) modules

clean:

- make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean + make -C $(KDIR) M=$(CURDIR) clean

	@$(RM) -rf *.o *~ *.c.gcov *.gcda *.gcno cscope.* tags

xref:

--- a/debian/rules

+++ b/debian/rules @@ -77,7 +77,7 @@ build-arch: configure-stamp build-arch-stamp

build-arch-stamp: 
	dh_testdir

- make -C sub-projects/rzscontrol + (test -d sub-projects/rzscontrol && make -C sub-projects/rzscontrol) || true

	touch $@

@@ -96,6 +96,9 @@ binary-modules:

	# Install the module
	cp ramzswap.ko debian/$(PKGNAME)/lib/modules/$(KVERS)/updates/compcache

+ test -f sub-projects/allocators/xvmalloc-kmod/xvmalloc.ko && \ + cp sub-projects/allocators/xvmalloc-kmod/xvmalloc.ko \ + debian/$(PKGNAME)/lib/modules/$(KVERS)/updates/compcache

	dh_installdocs
	dh_installchangelogs

@@ -120,7 +123,7 @@ clean:

	rm -f build-arch-stamp build-indep-stamp configure-stamp

#	$(MAKE) clean

- $(MAKE) -C sub-projects/rzscontrol clean + (test -d sub-projects/rzscontrol && $(MAKE) -C sub-projects/rzscontrol clean) || true

dh_clean

add old compcache 0.5.4 to compile in Debian lenny
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: e5d959b2b6d032e6d62d907c798a331b843cb930
Date: Tue, 02 Mar 2010 12:10:06 GMT
Commit diff


--- /dev/null

+++ b/debian/compcache.old/Changelog @@ -0,0 +1,87 @@ +version 0.5.4 (8/10/2009) + - Add swap notifier patch (see README for details) + - Remove swap 'discard' support. Notifiers make them redundant. + - Fix crashes on ARM + +version 0.5.3 (8/4/2009) + - Major cleanups. + - Rename module: compcache.ko -> ramzswap.ko + - Rename params: backing_dev -> backing_swap + - Updated use_compcache.sh script with detailed + documentation on parameters. + - LZO de/compress modules are no longer packaged + with compcache. Most distros now include these. + +version 0.5.2 (11/3/2009) + - Can forward incompressible pages to physical swap disk. + - New module params: + - memlimit_kb + - disksize_kb + - backing_dev + See use_compcache.sh for documentation on these params. + - Modified use_compcache.sh script to handle new params. + - Detect zero-filled pages and don't allocate any memory + for them. + +version 0.5.1 (22/1/2009) + - Fix crash on x86 systems with higmem (mem > ~1G). + This required minor changes to atomic (un)map functions (see Issue #20). + +version 0.5 (16/1/2009) + - Fix crash in case compcache init fails. + +version 0.5pre4 (10/1/2009) + - Support discarding pages for freed swap blocks (requires 2.6.28-git14). + This feature will be disabled if compiled for older kernel. + - Mark ramzswap as "solid-state" block device (requires 2.6.26-git14). + - Fixed incorrect stats reporting in /proc/compcache (some + new stats added too). + +version 0.5pre3 (5/1/2009) + - Use kmap_atomic() in xvMalloc. This fixes issue #19 + - Remove xvMapPage() and xvUnmapMap() from xvMalloc. + +version 0.5pre2 (28/10/2008) + - Alloc full page for uncompressible pages instead + of returning I/O error. + - Warn users when using ramzswap > (2 x RAM size) + +version 0.5pre1 (15/10/2008) + - Replaced TLSF with xvMalloc memory allocator + http://code.google.com/p/compcache/wiki/xvMalloc + +version 0.4 (13/8/2008) + - Enable debug and stats option for compcache and tlsf by default + proc nodes: /proc/{tlsfinfo,compcache} + - Fix crash when reading /proc/tlsfinfo + - Lots of cleanups: clean compile on x64 + +version 0.3 (17/3/2008) + - Fix spurious swap read failures + - Better swap request filtering + - Swap device again renamed to /dev/ramzswap0 + This is to prevent Ubuntu installer from presenting + this device as possible installation target (see Issue #5) + - use_compcache.sh script now waits for disk node to be created + instead of arbitrary sleep (see Issue #6). + - Modified scripts: use_compcache.sh and unuse_compcache.sh + to now use new device name (compcache0 -> ramzswap0). + +version 0.2 (3/3/2008) + - Fixed bug on systems with highmem + - Better filtering-out of non-swap requests + - Export statistics through proc nodes: + - /proc/compcache + - /proc/tlsfinfo + - Debug and Statistics support for allocator + and compcache can now be individually turned + on/off by setting DEBUG, STATS to 0/1 in + respective header files + - Swap device now renamed to /dev/compcache0 + - Added scripts: use_compcache.sh and unuse_compcache.sh + See README for usage + - Default compcache size set to 25% of RAM + - Lots of code cleanups + - Updated README + - Created Changelog :) +

--- /dev/null +++ b/debian/compcache.old/Makefile @@ -0,0 +1,26 @@ +KDIR ?= "/lib/modules/$(KVER)/build" + +XVM = sub-projects/allocators/xvmalloc-kmod +EXTRA_CFLAGS := -DCONFIG_BLK_DEV_RAMZSWAP_STATS \ + -I$(CURDIR)/$(XVM) \ + -g -Wall + +obj-m += $(XVM)/xvmalloc.o \ + ramzswap.o + +all: + make -C $(KDIR) M=$(CURDIR)/$(XVM) modules + make -C $(KDIR) M=$(CURDIR) modules + @ln -sf $(XVM)/xvmalloc.ko + +clean: + make -C $(KDIR) M=$(CURDIR) clean + make -C $(KDIR) M=$(CURDIR)/$(XVM) clean + @rm -rf *.ko + + +install: + install -d install -d $(DESTDIR)/lib/modules/$(KVER)/updates/compcache + install -m 644 sub-projects/allocators/xvmalloc-kmod/xvmalloc.ko $(DESTDIR)/lib/modules/$(KVER)/updates/compcache/ + install -m 644 ramzswap.ko $(DESTDIR)/lib/modules/$(KVER)/updates/compcache/ +

--- /dev/null +++ b/debian/compcache.old/README @@ -0,0 +1,60 @@ +ramzswap: Compressed RAM based swap device +------------------------------------------- + +Project home: http://compcache.googlecode.com + +* Introduction +This is a RAM based block device which acts as swap disk. +Pages swapped to this device are compressed and stored in +memory itself. See project home for use cases, performance +numbers and lot more. + +Detailed documentation can also be found at: +http://code.google.com/p/compcache/wiki/CompilingAndUsing + + * Optional (HIGHLY RECOMMENDED): + * Apply patch found in the source directory + (patch_swap_notifier_generic_2.6.xx.diff) and just compile the kernel + as usual -- currently, patch is against 2.6.25 but it should apply to + slightly older/newer kernels too. This will enable 'swap free notify' + feature. This allows kernel to send callback to ramzswap as soon as a + swap slot becomes free. So, we can immediately free memory allocated + for this page, eliminating any stale data in (compressed) memory. This + patch is available only for compcache-0.5.4 or higher. + * Uncomment '#define CONFIG_SWAP_NOTIFIERS' in compat.h before compiling + compcache against this patched kernel. Otherwise, this swap notify + callback will not be used. +* Compiling + - Run 'make': this will compile all modules against your kernel. + + - Following kernel modules are created: + - xvmalloc.ko + - ramzswap.ko + +* Using + - Following scipts are included + - use_ramzswap.sh [] [] + This loads all required modules and sets up swap device. + NOTE: script contains detailed documentation on parameters. + + - unuse_ramzswap.sh + Unloads all modules and turns off ramzswap swap device. + +* Common Problems + - If you get lots of compile errors, make sure you have package for + kernel source installed. For e.g., on Fedora its 'kernel-devel' package. + + - If (un)use_ramzswap scripts fail to work, refer to wiki: + http://code.google.com/p/compcache/wiki/CompilingAndUsing + +* Notes + - Statistics are exported via /proc/ramzswap + +Please consider using Issue Tracker: +http://code.google.com/p/compcache/issues/list +for reporting any bugs/feature requests. + +Cheers! +Nitin Gupta +EMail: ngupta at vflare dot org +

--- /dev/null +++ b/debian/compcache.old/compat.h @@ -0,0 +1,32 @@ +#ifndef _RAMZSWAP_COMPAT_H_ +#define _RAMZSWAP_COMPAT_H_ + +#include version.h> + +* Uncomment this if you are using swap free notify patch */ +//#define CONFIG_SWAP_NOTIFIERS + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) +#define BIO_IO_ERROR(bio) bio_io_error(bio, PAGE_SIZE) +#define BIO_ENDIO(bio, error) bio_endio(bio, PAGE_SIZE, error) +#else +#define BIO_IO_ERROR(bio) bio_io_error(bio) +#define BIO_ENDIO(bio, error) bio_endio(bio, error) +#endif + +#ifndef pr_err +#define pr_err(fmt, arg...) \ + printk(KERN_ERR fmt, ##arg) +#endif + +#ifndef pr_warning +#define pr_warning(fmt, arg...) \ + printk(KERN_WARNING fmt, ##arg) +#endif + +#ifndef pr_info +#define pr_info(fmt, arg...) \ + printk(KERN_ERR fmt, ##arg) +#endif + +#endif

--- /dev/null +++ b/debian/compcache.old/ramzswap.c @@ -0,0 +1,1135 @@ +/* + * Compressed RAM based swap device + * + * Copyright (C) 2008, 2009 Nitin Gupta + * + * This RAM based block device acts as swap disk. + * Pages swapped to this device are compressed and + * stored in memory. + * + * Released under the terms of GNU General Public License Version 2.0 + * + * Project home: http://compcache.googlecode.com + */ + +#include module.h> +#include kernel.h> +#include bitops.h> +#include blkdev.h> +#include buffer_head.h> +#include device.h> +#include genhd.h> +#include highmem.h> +#include lzo.h> +#include mutex.h> +#include proc_fs.h> +#include string.h> +#include swap.h> +#include swapops.h> +#include vmalloc.h> + +#include "compat.h" +#include "ramzswap.h" + +* Globals */ +static struct ramzswap rzs; +static struct ramzswap_stats stats; +/* + * Pages that compress to larger than this size are + * forwarded to backing swap, if present or stored + * uncompressed in memory otherwise. + */ +static unsigned int MAX_CPAGE_SIZE; + +/* Module params (documentation at end) */ +static unsigned long disksize_kb; +static unsigned long memlimit_kb; +static char *backing_swap; + +static int __init ramzswap_init(void); +static struct block_device_operations ramzswap_devops = { + .owner = THIS_MODULE, +}; + +static int test_flag(u32 index, enum rzs_pageflags flag) +{ + return rzs.table[index].flags & BIT(flag); +} + +static void set_flag(u32 index, enum rzs_pageflags flag) +{ + rzs.table[index].flags |= BIT(flag); +} + +static void clear_flag(u32 index, enum rzs_pageflags flag) +{ + rzs.table[index].flags &= ~BIT(flag); +} + +static int page_zero_filled(void *ptr) +{ + u32 pos; + u64 *page; + + page = (u64 *)ptr; + + for (pos = 0; pos != PAGE_SIZE / sizeof(*page); pos++) { + if (page[pos]) + return 0; + } + + return 1; +} + +/* + * Given pair, provide a dereferencable pointer. + */ +static void *get_ptr_atomic(u32 pagenum, u16 offset, enum km_type type) +{ + unsigned char *page; + + page = kmap_atomic(pfn_to_page(pagenum), type); + return page + offset; +} + +static void put_ptr_atomic(void *ptr, enum km_type type) +{ + kunmap_atomic(ptr, type); +} + +static void ramzswap_flush_dcache_page(struct page *page) +{ +#ifdef CONFIG_ARM + int flag = 0; + /* + * Ugly hack to get flush_dcache_page() work on ARM. + * page_mapping(page) == NULL after clearing this swap cache flag. + * Without clearing this flag, flush_dcache_page() will simply set + * "PG_dcache_dirty" bit and return. + */ + if (PageSwapCache(page)) { + flag = 1; + ClearPageSwapCache(page); + } +#endif + flush_dcache_page(page); +#ifdef CONFIG_ARM + if (flag) + SetPageSwapCache(page); +#endif +} + +#if defined(STATS) +static struct proc_dir_entry *proc; + +static int proc_ramzswap_read(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len; + size_t succ_writes, mem_used; + unsigned int good_compress_perc = 0, no_compress_perc = 0; + + mem_used = xv_get_total_size_bytes(rzs.mem_pool) + + (stats.pages_expand << PAGE_SHIFT); + + if (off > 0) { + *eof = 1; + return 0; + } + +#define K(x) ((x) >> 10) + /* Basic stats */ + len = sprintf(page, + "DiskSize: %8zu kB\n", + (size_t)(K(rzs.disksize))); + + if (rzs.backing_swap) { + /* This must always be less than ComprDataSize */ + len += sprintf(page + len, + "MemLimit: %8zu kB\n", + K(rzs.memlimit)); + } + + succ_writes = stats.num_writes - stats.failed_writes; + + if (succ_writes && stats.pages_stored) { + good_compress_perc = stats.good_compress * 100 + / stats.pages_stored; + no_compress_perc = stats.pages_expand * 100 + / stats.pages_stored; + } + + /* Extended stats */ + len += sprintf(page + len, + "NumReads: %8llu\n" + "NumWrites: %8llu\n" + "FailedReads: %8llu\n" + "FailedWrites: %8llu\n" + "InvalidIO: %8llu\n" + "NotifyFree: %8llu\n" + "ZeroPages: %8u\n" + "GoodCompress: %8u %%\n" + "NoCompress: %8u %%\n" + "PagesStored: %8u\n" + "PagesUsed: %8zu\n" + "OrigDataSize: %8zu kB\n" + "ComprDataSize: %8zu kB\n" + "MemUsedTotal: %8zu kB\n", + stats.num_reads, + stats.num_writes, + stats.failed_reads, + stats.failed_writes, + stats.invalid_io, + stats.notify_free, + stats.pages_zero, + good_compress_perc, + no_compress_perc, + stats.pages_stored, + mem_used >> PAGE_SHIFT, + (size_t)(K(stats.pages_stored << PAGE_SHIFT)), + (size_t)(K(stats.compr_size)), + (size_t)(K(mem_used))); + + if (rzs.backing_swap) { + /* This must always be less than ComprDataSize */ + len += sprintf(page + len, + "BDevNumReads: %8llu\n" + "BDevNumWrites: %8llu\n", + stats.bdev_num_reads, + stats.bdev_num_writes); + } + + return len; +} +#endif /* STATS */ + +/* + * Check if value of backing_swap module param is sane. + * Claim this device and set ramzswap size equal to + * size of this block device. + */ +static int setup_backing_swap(void) +{ + int error = 0; + struct inode *inode; + struct file *swap_file; + struct address_space *mapping; + struct block_device *bdev = NULL; + + if (backing_swap == NULL) { + pr_debug(C "backing_swap param not given\n"); + goto out; + } + + pr_info(C "Using backing swap device: %s\n", backing_swap); + + swap_file = filp_open(backing_swap, O_RDWR | O_LARGEFILE, 0); + if (IS_ERR(swap_file)) { + pr_err(C "Error opening backing device: %s\n", backing_swap); + error = -EINVAL; + goto out; + } + + mapping = swap_file->f_mapping; + inode = mapping->host; + + if (S_ISBLK(inode->i_mode)) { + bdev = I_BDEV(inode); + error = bd_claim(bdev, ramzswap_init); + if (error < 0) { + bdev = NULL; + goto bad_param; + } + rzs.old_block_size = block_size(bdev); + error = set_blocksize(bdev, PAGE_SIZE); + if (error < 0) + goto bad_param; + } else { + /* TODO: support for regular file as backing swap */ + pr_info(C "%s is not a block device.\n", backing_swap); + error = -EINVAL; + goto out; + } + + rzs.swap_file = swap_file; + rzs.backing_swap = bdev; + rzs.disksize = i_size_read(inode); + BUG_ON(!rzs.disksize); + + return 0; + +bad_param: + if (bdev) { + set_blocksize(bdev, rzs.old_block_size); + bd_release(bdev); + } + filp_close(swap_file, NULL); + +out: + rzs.backing_swap = NULL; + return error; +} + +/* + * Check if request is within bounds and page aligned. + */ +static inline int valid_swap_request(struct bio *bio) +{ + if (unlikely( + (bio->bi_sector >= (rzs.disksize >> SECTOR_SHIFT)) || + (bio->bi_sector & (SECTORS_PER_PAGE - 1)) || + (bio->bi_vcnt != 1) || + (bio->bi_size != PAGE_SIZE) || + (bio->bi_io_vec[0].bv_offset != 0))) { + + return 0; + } + + /* swap request is valid */ + return 1; +} + +static void ramzswap_free_page(size_t index) +{ + u32 clen; + void *obj; + + u32 pagenum = rzs.table[index].pagenum; + u32 offset = rzs.table[index].offset; + + if (unlikely(!pagenum)) { + if (test_flag(index, RZS_ZERO)) { + clear_flag(index, RZS_ZERO); + stat_dec(stats.pages_zero); + } + return; + } + + if (unlikely(test_flag(index, RZS_UNCOMPRESSED))) { + clen = PAGE_SIZE; + __free_page(pfn_to_page(pagenum)); + clear_flag(index, RZS_UNCOMPRESSED); + stat_dec(stats.pages_expand); + goto out; + } + + obj = get_ptr_atomic(pagenum, offset, KM_USER0); + clen = xv_get_object_size(obj) - sizeof(struct zobj_header); + put_ptr_atomic(obj, KM_USER0); + + xv_free(rzs.mem_pool, pagenum, offset); + stat_dec_if_less(stats.good_compress, clen, PAGE_SIZE / 2 + 1); + +out: + stats.compr_size -= clen; + stat_dec(stats.pages_stored); + + rzs.table[index].pagenum = 0; + rzs.table[index].offset = 0; +} + +#ifdef CONFIG_SWAP_FREE_NOTIFY +/* + * callback function called when swap_map[offset] == 0 + * i.e page at this swap offset is no longer used + */ +static void ramzswap_free_notify(unsigned long index) +{ + if (rzs.table[index].pagenum) { + ramzswap_free_page(index); + stat_inc(rzs.stats.notify_free); + } +} +#endif + +int handle_zero_page(struct bio *bio) +{ + void *user_mem; + struct page *page = bio->bi_io_vec[0].bv_page; + + user_mem = get_ptr_atomic(page_to_pfn(page), 0, KM_USER0); + memset(user_mem, 0, PAGE_SIZE); + put_ptr_atomic(user_mem, KM_USER0); + + ramzswap_flush_dcache_page(page); + + set_bit(BIO_UPTODATE, &bio-;>bi_flags); + BIO_ENDIO(bio, 0); + return 0; +} + +int handle_uncompressed_page(struct bio *bio) +{ + u32 index; + struct page *page; + unsigned char *user_mem, *cmem; + + page = bio->bi_io_vec[0].bv_page; + index = bio->bi_sector >>SECTORS_PER_PAGE_SHIFT; + + user_mem = get_ptr_atomic(page_to_pfn(page), 0, KM_USER0); + cmem = get_ptr_atomic(rzs.table[index].pagenum, + rzs.table[index].offset, KM_USER1); + + memcpy(user_mem, cmem, PAGE_SIZE); + put_ptr_atomic(user_mem, KM_USER0); + put_ptr_atomic(cmem, KM_USER1); + + ramzswap_flush_dcache_page(page); + + set_bit(BIO_UPTODATE, &bio-;>bi_flags); + BIO_ENDIO(bio, 0); + return 0; +} + + +/* + * Called when request page is not present in ramzswap. + * Its either in backing swap device (if present) or + * this is an attempt to read before any previous write + * to this location - this happens due to readahead when + * swap device is read from user-space (e.g. during swapon) + */ +int handle_ramzswap_fault(struct bio *bio) +{ + void *user_mem; + struct page *page = bio->bi_io_vec[0].bv_page; + + /* + * Always forward such requests to backing swap + * device (if present) + */ + if (rzs.backing_swap) { + stat_dec(stats.num_reads); + stat_inc(stats.bdev_num_reads); + bio->bi_bdev = rzs.backing_swap; + return 1; + } + + /* + * Its unlikely event in case backing dev is + * not present + */ + pr_debug(C "Read before write on swap device: " + "sector=%lu, size=%u, offset=%u\n", + (ulong)(bio->bi_sector), bio->bi_size, + bio->bi_io_vec[0].bv_offset); + user_mem = kmap(page); + memset(user_mem, 0, PAGE_SIZE); + kunmap(page); + + set_bit(BIO_UPTODATE, &bio-;>bi_flags); + BIO_ENDIO(bio, 0); + return 0; +} + +#ifdef CONFIG_SWAP_NOTIFIERS +static int ramzswap_slot_free_notify(struct notifier_block *self, + unsigned long index, void *swap_file) +{ + ramzswap_free_page(index); + stat_inc(stats.notify_free); + return 0; +} + +static struct notifier_block ramzswap_slot_free_nb = { + .notifier_call = ramzswap_slot_free_notify +}; + +static int ramzswap_swapon_notify(struct notifier_block *self, + unsigned long swap_id, void *swap_file) +{ + int ret; + struct block_device *bdev; + struct inode *inode; + + inode = ((struct file *)swap_file)->f_mapping->host; + bdev = I_BDEV(inode); + if ((struct ramzswap *)(bdev->bd_disk->private_data) != &rzs;) + return 0; + + ret = register_swap_event_notifier(&ramzswap;_slot_free_nb, + SWAP_EVENT_SLOT_FREE, swap_id); + if (ret) + pr_err("Error registering swap free notifier\n"); + return ret; +} + +static int ramzswap_swapoff_notify(struct notifier_block *self, + unsigned long swap_id, void *swap_file) +{ + struct block_device *bdev; + struct inode *inode; + + inode = ((struct file *)swap_file)->f_mapping->host; + bdev = I_BDEV(inode); + if ((struct ramzswap *)(bdev->bd_disk->private_data) != &rzs;) + return 0; + + unregister_swap_event_notifier(&ramzswap;_slot_free_nb, + SWAP_EVENT_SLOT_FREE, swap_id); + return 0; +} + +static struct notifier_block ramzswap_swapon_nb = { + .notifier_call = ramzswap_swapon_notify +}; + +static struct notifier_block ramzswap_swapoff_nb = { + .notifier_call = ramzswap_swapoff_notify +}; +#endif + +int ramzswap_read(struct bio *bio) +{ + int ret; + u32 index; + size_t clen; + struct page *page; + struct zobj_header *zheader; + unsigned char *user_mem, *cmem; + + stat_inc(stats.num_reads); + + page = bio->bi_io_vec[0].bv_page; + index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT; + + if (test_flag(index, RZS_ZERO)) + return handle_zero_page(bio); + + /* Requested page is not present in compressed area */ + if (!rzs.table[index].pagenum) + return handle_ramzswap_fault(bio); + + /* Page is stored uncompressed since its incompressible */ + if (unlikely(test_flag(index, RZS_UNCOMPRESSED))) + return handle_uncompressed_page(bio); + + user_mem = get_ptr_atomic(page_to_pfn(page), 0, KM_USER0); + clen = PAGE_SIZE; + + cmem = get_ptr_atomic(rzs.table[index].pagenum, + rzs.table[index].offset, KM_USER1); + + ret = lzo1x_decompress_safe( + cmem + sizeof(*zheader), + xv_get_object_size(cmem) - sizeof(*zheader), + user_mem, &clen;); + + put_ptr_atomic(user_mem, KM_USER0); + put_ptr_atomic(cmem, KM_USER1); + + /* should NEVER happen */ + if (unlikely(ret != LZO_E_OK)) { + pr_err(C "Decompression failed! err=%d, page=%u\n", + ret, index); + stat_inc(stats.failed_reads); + goto out; + } + + ramzswap_flush_dcache_page(page); + + set_bit(BIO_UPTODATE, &bio-;>bi_flags); + BIO_ENDIO(bio, 0); + return 0; + +out: + BIO_IO_ERROR(bio); + return 0; +} + +int ramzswap_write(struct bio *bio) +{ + int ret, fwd_write_request = 0; + u32 offset; + size_t clen, index; + struct zobj_header *zheader; + struct page *page, *page_store; + unsigned char *user_mem, *cmem, *src; + + stat_inc(stats.num_writes); + + page = bio->bi_io_vec[0].bv_page; + index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT; + + src = rzs.compress_buffer; + + /* + * System swaps to same sector again when the stored page + * is no longer referenced by any process. So, its now safe + * to free the memory that was allocated for this page. + */ + if (rzs.table[index].pagenum) + ramzswap_free_page(index); + + /* + * No memory ia allocated for zero filled pages. + * Simply clear zero page flag. + */ + if (test_flag(index, RZS_ZERO)) { + stat_dec(stats.pages_zero); + clear_flag(index, RZS_ZERO); + } + + mutex_lock(&rzs.lock;); + + user_mem = get_ptr_atomic(page_to_pfn(page), 0, KM_USER0); + if (page_zero_filled(user_mem)) { + put_ptr_atomic(user_mem, KM_USER0); + mutex_unlock(&rzs.lock;); + stat_inc(stats.pages_zero); + set_flag(index, RZS_ZERO); + + set_bit(BIO_UPTODATE, &bio-;>bi_flags); + BIO_ENDIO(bio, 0); + return 0; + } + + if (rzs.backing_swap && + (stats.compr_size > rzs.memlimit - PAGE_SIZE)) { + put_ptr_atomic(user_mem, KM_USER0); + mutex_unlock(&rzs.lock;); + fwd_write_request = 1; + goto out; + } + + ret = lzo1x_1_compress(user_mem, PAGE_SIZE, src, &clen;, + rzs.compress_workmem); + + put_ptr_atomic(user_mem, KM_USER0); + + if (unlikely(ret != LZO_E_OK)) { + mutex_unlock(&rzs.lock;); + pr_err(C "Compression failed! err=%d\n", ret); + stat_inc(stats.failed_writes); + goto out; + } + + /* + * Page is incompressible. Forward it to backing swap + * if present. Otherwise, store it as-is (uncompressed) + * since we do not want to return too many swap write + * errors which has side effect of hanging the system. + */ + if (unlikely(clen > MAX_CPAGE_SIZE)) { + if (rzs.backing_swap) { + mutex_unlock(&rzs.lock;); + fwd_write_request = 1; + goto out; + } + + clen = PAGE_SIZE; + page_store = alloc_page(GFP_NOIO | __GFP_HIGHMEM); + if (unlikely(!page_store)) { + mutex_unlock(&rzs.lock;); + stat_inc(stats.failed_writes); + goto out; + } + + offset = 0; + set_flag(index, RZS_UNCOMPRESSED); + stat_inc(stats.pages_expand); + rzs.table[index].pagenum = page_to_pfn(page_store); + src = get_ptr_atomic(page_to_pfn(page), 0, KM_USER0); + goto memstore; + } + + if (xv_malloc(rzs.mem_pool, clen + sizeof(*zheader), + &rzs.table;[index].pagenum, &offset;, + GFP_NOIO | __GFP_HIGHMEM)) { + mutex_unlock(&rzs.lock;); + pr_info(C "Error allocating memory for compressed " + "page: %zu, size=%zu\n", index, clen); + stat_inc(stats.failed_writes); + if (rzs.backing_swap) + fwd_write_request = 1; + goto out; + } + +memstore: + rzs.table[index].offset = offset; + + cmem = get_ptr_atomic(rzs.table[index].pagenum, + rzs.table[index].offset, KM_USER1); + +#if 0 + /* Back-reference needed for memory defragmentation */ + if (!test_flag(index, RZS_UNCOMPRESSED)) { + zheader = (struct zobj_header *)cmem; + zheader->table_idx = index; + cmem += sizeof(*zheader); + } +#endif + + memcpy(cmem, src, clen); + + put_ptr_atomic(cmem, KM_USER1); + if (unlikely(test_flag(index, RZS_UNCOMPRESSED))) + put_ptr_atomic(src, KM_USER0); + + /* Update stats */ + stats.compr_size += clen; + stat_inc(stats.pages_stored); + stat_inc_if_less(stats.good_compress, clen, PAGE_SIZE / 2 + 1); + + mutex_unlock(&rzs.lock;); + + set_bit(BIO_UPTODATE, &bio-;>bi_flags); + BIO_ENDIO(bio, 0); + return 0; + +out: + if (fwd_write_request) { + stat_inc(stats.bdev_num_writes); + bio->bi_bdev = rzs.backing_swap; + return 1; + } + + BIO_IO_ERROR(bio); + return 0; +} + +/* + * Handler function for all ramzswap I/O requests. + */ +static int ramzswap_make_request(struct request_queue *queue, struct bio *bio) +{ + int ret = 0; + + if (!valid_swap_request(bio)) { + stat_inc(stats.invalid_io); + BIO_IO_ERROR(bio); + return 0; + } + + switch (bio_data_dir(bio)) { + case READ: + ret = ramzswap_read(bio); + break; + + case WRITE: + ret = ramzswap_write(bio); + break; + } + + return ret; +} + +/* + * Swap header (1st page of swap device) contains information + * to indentify it as a swap partition. Prepare such a header + * for ramzswap device (ramzswap0) so that swapon can identify + * it as swap partition. In case backing swap device is provided, + * copy its swap header. + */ +static int setup_swap_header(union swap_header *s) +{ + int ret = 0; + struct page *page; + struct address_space *mapping; + union swap_header *backing_swap_header; + + /* + * There is no backing swap device. Create a swap header + * that is acceptable by swapon. + */ + if (rzs.backing_swap == NULL) { + s->info.version = 1; + s->info.last_page = (rzs.disksize >> PAGE_SHIFT) - 1; + s->info.nr_badpages = 0; + memcpy(s->magic.magic, "SWAPSPACE2", 10); + return 0; + } + + /* + * We have a backing swap device. Copy its swap header + * to ramzswap device header. If this header contains + * invalid information (backing device not a swap + * partition, etc.), swapon will fail for ramzswap + * which is correct behavior - we don't want to swap + * over filesystem partition! + */ + + /* Read the backing swap header (code from sys_swapon) */ + mapping = rzs.swap_file->f_mapping; + if (!mapping->a_ops->readpage) { + ret = -EINVAL; + goto out; + } + + page = read_mapping_page(mapping, 0, rzs.swap_file); + if (IS_ERR(page)) { + ret = PTR_ERR(page); + goto out; + } + + backing_swap_header = kmap(page); + memcpy(s, backing_swap_header, sizeof(*s)); + if (s->info.nr_badpages) { + pr_info("Cannot use backing swap with bad pages (%u)\n", + s->info.nr_badpages); + ret = -EINVAL; + } + /* + * ramzswap disksize equals number of usable pages in backing + * swap. Set last_page in swap header to match this disksize + * ('last_page' means 0-based index of last usable swap page). + */ + s->info.last_page = (rzs.disksize >> PAGE_SHIFT) - 1; + kunmap(page); + +out: + return ret; +} + +static void ramzswap_set_disksize(size_t totalram_bytes) +{ + rzs.disksize = disksize_kb << 10; + + if (!disksize_kb) { + pr_info(C + "disk size not provided. You can use disksize_kb module " + "param to specify size.\nUsing default: (%u%% of RAM).\n", + DEFAULT_DISKSIZE_PERC_RAM + ); + rzs.disksize = DEFAULT_DISKSIZE_PERC_RAM * + (totalram_bytes / 100); + } + + if (disksize_kb > 2 * (totalram_bytes >> 10)) { + pr_info(C + "There is little point creating a ramzswap of greater than " + "twice the size of memory since we expect a 2:1 compression " + "ratio. Note that ramzswap uses about 0.1%% of the size of " + "the swap device when not in use so a huge ramzswap is " + "wasteful.\n" + "\tMemory Size: %zu kB\n" + "\tSize you selected: %lu kB\n" + "Continuing anyway ...\n", + totalram_bytes >> 10, disksize_kb + ); + } + + rzs.disksize &= PAGE_MASK; + pr_info(C "disk size set to %zu kB\n", rzs.disksize >> 10); +} + +/* + * memlimit cannot be greater than backing disk size. + */ +static void ramzswap_set_memlimit(size_t totalram_bytes) +{ + int memlimit_valid = 1; + rzs.memlimit = memlimit_kb << 10; + + if (!rzs.memlimit) { + pr_info(C "memory limit not set. You can use " + "memlimit_kb module param to specify limit."); + memlimit_valid = 0; + } + + if (rzs.memlimit > rzs.disksize) { + pr_info(C "memory limit cannot be greater than " + "disksize: limit=%zu, disksize=%zu", + rzs.memlimit, rzs.disksize); + memlimit_valid = 0; + } + + if (!memlimit_valid) { + size_t mempart, disksize; + pr_info(C "\nUsing default: MIN[(%u%% of RAM), " + "(backing disk size)].\n", + DEFAULT_MEMLIMIT_PERC_RAM); + mempart = DEFAULT_MEMLIMIT_PERC_RAM * (totalram_bytes / 100); + disksize = rzs.disksize; + rzs.memlimit = mempart > disksize ? disksize : mempart; + } + + if (rzs.memlimit > totalram_bytes / 2) { + pr_info(C + "Its not advisable setting limit more than half of " + "size of memory since we expect a 2:1 compression ratio. " + "Limit represents amount of *compressed* data we can keep " + "in memory!\n" + "\tMemory Size: %zu kB\n" + "\tLimit you selected: %lu kB\n" + "Continuing anyway ...\n", + totalram_bytes >> 10, memlimit_kb + ); + } + + rzs.memlimit &= PAGE_MASK; + BUG_ON(!rzs.memlimit); + + pr_info(C "memory limit set to %zu kB\n", rzs.memlimit >> 10); +} + +static int __init ramzswap_init(void) +{ + int ret; + size_t num_pages, totalram_bytes; + struct page *page; + void *swap_header; + + mutex_init(&rzs.lock;); + + ret = setup_backing_swap(); + if (ret) + goto fail; + + totalram_bytes = totalram_pages << PAGE_SHIFT; + + if (rzs.backing_swap) + ramzswap_set_memlimit(totalram_bytes); + else + ramzswap_set_disksize(totalram_bytes); + + rzs.compress_workmem = kmalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); + if (rzs.compress_workmem == NULL) { + pr_err(C "Error allocating compressor working memory\n"); + ret = -ENOMEM; + goto fail; + } + + rzs.compress_buffer = kmalloc(2 * PAGE_SIZE, GFP_KERNEL); + if (rzs.compress_buffer == NULL) { + pr_err(C "Error allocating compressor buffer space\n"); + ret = -ENOMEM; + goto fail; + } + + num_pages = rzs.disksize >> PAGE_SHIFT; + rzs.table = vmalloc(num_pages * sizeof(*rzs.table)); + if (rzs.table == NULL) { + pr_err(C "Error allocating ramzswap address table\n"); + ret = -ENOMEM; + goto fail; + } + memset(rzs.table, 0, num_pages * sizeof(*rzs.table)); + + page = alloc_page(__GFP_ZERO); + if (page == NULL) { + pr_err(C "Error allocating swap header page\n"); + ret = -ENOMEM; + goto fail; + } + rzs.table[0].pagenum = page_to_pfn(page); + set_flag(0, RZS_UNCOMPRESSED); + + swap_header = kmap(page); + ret = setup_swap_header((union swap_header *)(swap_header)); + kunmap(page); + if (ret) { + pr_err(C "Error setting swap header\n"); + goto fail; + } + + rzs.disk = alloc_disk(1); + if (rzs.disk == NULL) { + pr_err(C "Error allocating disk structure\n"); + ret = -ENOMEM; + goto fail; + } + + rzs.disk->first_minor = 0; + rzs.disk->fops = &ramzswap;_devops; + /* + * It is named like this to prevent distro installers + * from offering ramzswap as installation target. They + * seem to ignore all devices beginning with 'ram' + */ + strcpy(rzs.disk->disk_name, "ramzswap0"); + + rzs.disk->major = register_blkdev(0, rzs.disk->disk_name); + if (rzs.disk->major < 0) { + pr_err(C "Cannot register block device\n"); + ret = -EFAULT; + goto fail; + } + + rzs.disk->queue = blk_alloc_queue(GFP_KERNEL); + if (rzs.disk->queue == NULL) { + pr_err(C "Cannot register disk queue\n"); + ret = -EFAULT; + goto fail; + } + + rzs.disk->private_data = &rzs; + set_capacity(rzs.disk, rzs.disksize >> SECTOR_SHIFT); + blk_queue_make_request(rzs.disk->queue, ramzswap_make_request); + + add_disk(rzs.disk); + + rzs.mem_pool = xv_create_pool(); + if (!rzs.mem_pool) { + pr_err(C "Error creating memory pool\n"); + ret = -ENOMEM; + goto fail; + } + +#if defined(STATS) + proc = create_proc_entry("ramzswap", S_IRUGO, NULL); + if (proc) + proc->read_proc = &proc;_ramzswap_read; + else { + ret = -ENOMEM; + pr_warning(C "Error creating proc entry\n"); + goto fail; + } +#endif + + /* + * Pages that compress to size greater than this are forwarded + * to physical swap disk (if backing dev is provided) + */ + if (rzs.backing_swap) + MAX_CPAGE_SIZE = MAX_CPAGE_SIZE_BDEV; + else + MAX_CPAGE_SIZE = MAX_CPAGE_SIZE_NOBDEV; + + pr_debug(C "Max compressed page size: %u bytes\n", MAX_CPAGE_SIZE); + +#ifdef CONFIG_SWAP_NOTIFIERS + ret = register_swap_event_notifier(&ramzswap;_swapon_nb, + SWAP_EVENT_SWAPON, 0); + if (ret) { + pr_err("Error registering swapon notifier\n"); + goto fail; + } + + ret = register_swap_event_notifier(&ramzswap;_swapoff_nb, + SWAP_EVENT_SWAPOFF, 0); + if (ret) { + unregister_swap_event_notifier(&ramzswap;_swapoff_nb, + SWAP_EVENT_SWAPON, 0); + pr_err("Error registering swapoff notifier\n"); + goto fail; + } +#endif + + pr_debug(C "Initialization done!\n"); + return 0; + +fail: + if (rzs.disk != NULL) { + if (rzs.disk->major > 0) + unregister_blkdev(rzs.disk->major, rzs.disk->disk_name); + del_gendisk(rzs.disk); + } + + if (rzs.table && rzs.table[0].pagenum) + __free_page(pfn_to_page(rzs.table[0].pagenum)); + kfree(rzs.compress_workmem); + kfree(rzs.compress_buffer); + vfree(rzs.table); + xv_destroy_pool(rzs.mem_pool); +#if defined(STATS) + if (proc) + remove_proc_entry("ramzswap", proc->parent); +#endif + pr_err(C "Initialization failed: err=%d\n", ret); + return ret; +} + +static void __exit ramzswap_exit(void) +{ + size_t index, num_pages; + num_pages = rzs.disksize >> PAGE_SHIFT; + +#ifdef CONFIG_SWAP_NOTIFIERS + unregister_swap_event_notifier(&ramzswap;_swapon_nb, + SWAP_EVENT_SWAPON, 0); + unregister_swap_event_notifier(&ramzswap;_swapoff_nb, + SWAP_EVENT_SWAPOFF, 0); +#endif + + unregister_blkdev(rzs.disk->major, rzs.disk->disk_name); + del_gendisk(rzs.disk); + + /* Close backing swap device (if present) */ + if (rzs.backing_swap) { + set_blocksize(rzs.backing_swap, rzs.old_block_size); + bd_release(rzs.backing_swap); + filp_close(rzs.swap_file, NULL); + } + + __free_page(pfn_to_page(rzs.table[0].pagenum)); + kfree(rzs.compress_workmem); + kfree(rzs.compress_buffer); + + /* Free all pages that are still in ramzswap */ + for (index = 1; index < num_pages; index++) { + u32 pagenum, offset; + + pagenum = rzs.table[index].pagenum; + offset = rzs.table[index].offset; + + if (!pagenum) + continue; + + if (unlikely(test_flag(index, RZS_UNCOMPRESSED))) + __free_page(pfn_to_page(pagenum)); + else + xv_free(rzs.mem_pool, pagenum, offset); + } + + vfree(rzs.table); + xv_destroy_pool(rzs.mem_pool); + +#if defined(STATS) + remove_proc_entry("ramzswap", proc->parent); +#endif + pr_debug(C "cleanup done!\n"); +} + +/* + * This param is applicable only when there is no backing swap device. + * We ignore this param in case backing dev is provided since then its + * always equal to size of the backing swap device. + * + * This size refers to amount of (uncompressed) data it can hold. + * For e.g. disksize_kb=1024 means it can hold 1024kb worth of + * uncompressed data even if this data compresses to just, say, 100kb. + * + * Default value is used if this param is missing or 0 (if its applicable). + * Default: [DEFAULT_DISKSIZE_PERC_RAM]% of RAM + */ +module_param(disksize_kb, ulong, 0); +MODULE_PARM_DESC(disksize_kb, "ramzswap device size (kB)"); + +/* + * This param is applicable only when backing swap device is provided. + * This refers to limit on amount of (compressed) data it can hold in + * memory. Note that total amount of memory used (MemUsedTotal) can + * exceed this memlimit since that includes memory wastage due to + * fragmentation and metadata overhead. + * + * Any additional data beyond this limit is forwarded to backing + * swap device. TODO: allow changing memlimit at runtime. + * + * Default value is used if this param is missing or 0 (if its applicable). + * Default: MIN([DEFAULT_MEMLIMIT_PERC_RAM]% of RAM, Backing Device Size) + */ +module_param(memlimit_kb, ulong, 0); +MODULE_PARM_DESC(memlimit_kb, "ramzswap memory limit (kB)"); + +/* + * This is block device to be used as backing store for ramzswap. + * When pages more than memlimit_kb as swapped to ramzswap, we store + * any additional pages in this device. We may also move some pages + * from ramzswap to this device in case system is really low on + * memory (TODO). + * + * This device is not directly visible to kernel as a swap device + * (/proc/swaps will only show /dev/ramzswap0 and not this device). + * Managing this backing device is the job of ramzswap module. + */ +module_param(backing_swap, charp, 0); +MODULE_PARM_DESC(backing_swap, "Backing swap partition"); + +module_init(ramzswap_init); +module_exit(ramzswap_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Nitin Gupta "); +MODULE_DESCRIPTION("Compressed RAM Based Swap Device");

--- /dev/null +++ b/debian/compcache.old/ramzswap.h @@ -0,0 +1,160 @@ +/* + * Compressed RAM based swap device + * + * Copyright (C) 2008, 2009 Nitin Gupta + * + * This RAM based block device acts as swap disk. + * Pages swapped to this device are compressed and + * stored in memory. + * + * Released under the terms of GNU General Public License Version 2.0 + * + * Project home: http://compcache.googlecode.com + */ + +#ifndef _RAMZSWAP_H_ +#define _RAMZSWAP_H_ + +#include "xvmalloc.h" + +/* + * Stored at beginning of each compressed object. + * + * It stores back-reference to table entry which points to this + * object. This is required to support memory defragmentation or + * migrating compressed pages to backing swap disk. + */ +struct zobj_header { +#if 0 + u32 table_idx; +#endif +}; + +/*-- Configurable parameters */ + +/* Default ramzswap disk size: 25% of total RAM */ +#define DEFAULT_DISKSIZE_PERC_RAM 25 +#define DEFAULT_MEMLIMIT_PERC_RAM 15 + +/* + * Max compressed page size when backing device is provided. + * Pages that compress to size greater than this are sent to + * physical swap disk. + */ +#define MAX_CPAGE_SIZE_BDEV (PAGE_SIZE / 2) + +/* + * Max compressed page size when there is no backing dev. + * Pages that compress to size greater than this are stored + * uncompressed in memory. + */ +#define MAX_CPAGE_SIZE_NOBDEV (PAGE_SIZE / 4 * 3) + +/* + * NOTE: MAX_CPAGE_SIZE_{BDEV,NOBDEV} sizes must be + * less than or equal to: + * XV_MAX_ALLOC_SIZE - sizeof(struct zobj_header) + * since otherwise xvMalloc would always return failure. + */ + +/*-- End of configurable params */ + +#define SECTOR_SHIFT 9 +#define SECTOR_SIZE (1 << SECTOR_SHIFT) +#define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) +#define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT) + +/* Message prefix */ +#define C "ramzswap: " + +/* Debugging and Stats */ +#define NOP do { } while (0) + +#if defined(CONFIG_BLK_DEV_RAMZSWAP_STATS) +#define STATS +#endif + +#if defined(STATS) +#define stat_inc(stat) ((stat)++) +#define stat_dec(stat) ((stat)--) +#define stat_inc_if_less(stat, val1, val2) \ + ((stat) += ((val1) < (val2) ? 1 : 0)) +#define stat_dec_if_less(stat, val1, val2) \ + ((stat) -= ((val1) < (val2) ? 1 : 0)) +#else /* STATS */ +#define stat_inc(x) NOP +#define stat_dec(x) NOP +#define stat_inc_if_less(x, v1, v2) NOP +#define stat_dec_if_less(x, v1, v2) NOP +#endif /* STATS */ + +/* Flags for ramzswap pages (table[page_no].flags) */ +enum rzs_pageflags { + /* Page is stored uncompressed */ + RZS_UNCOMPRESSED, + + /* Page consists entirely of zeros */ + RZS_ZERO, + + __NR_RZS_PAGEFLAGS, +}; + +/*-- Data structures */ + +/* Indexed by page no. */ +struct table { + u32 pagenum; + u16 offset; + u8 count; /* object ref count (not yet used) */ + u8 flags; +}; + +struct ramzswap { + struct xv_pool *mem_pool; + void *compress_workmem; + void *compress_buffer; + struct table *table; + struct mutex lock; + struct gendisk *disk; + /* + * This is limit on compressed data size (stats.compr_size) + * Its applicable only when backing swap device is present. + */ + size_t memlimit; /* bytes */ + /* + * This is limit on amount of *uncompressed* worth of data + * we can hold. When backing swap device is provided, it is + * set equal to device size. + */ + size_t disksize; /* bytes */ + + /* backing swap device info */ + struct block_device *backing_swap; + struct file *swap_file; + int old_block_size; + int init_notify_callback; +}; + +struct ramzswap_stats { + /* basic stats */ + size_t compr_size; /* compressed size of pages stored - + * needed to enforce memlimit */ + /* more stats */ +#if defined(STATS) + u64 num_reads; /* failed + successful */ + u64 num_writes; /* --do-- */ + u64 failed_reads; /* can happen when memory is too low */ + u64 failed_writes; /* should NEVER! happen */ + u64 invalid_io; /* non-swap I/O requests */ + u64 notify_free; /* no. of pages freed by swap free notifier */ + u32 pages_zero; /* no. of zero filled pages */ + u32 pages_stored; /* no. of pages currently stored */ + u32 good_compress; /* no. of pages with compression ratio<=50% */ + u32 pages_expand; /* no. of incompressible pages */ + u64 bdev_num_reads; /* no. of reads on backing dev */ + u64 bdev_num_writes; /* no. of writes on backing dev */ +#endif +}; +/*-- */ + +#endif

--- /dev/null +++ b/debian/compcache.old/sub-projects/allocators/xvmalloc-kmod/Makefile @@ -0,0 +1,16 @@ +EXTRA_CFLAGS := -g -O2 -Wall +KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build" + +obj-m += xvmalloc.o + +all: + make -C $(KERNEL_BUILD_PATH) M=$(PWD) modules + +clean: + make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean + @$(RM) -rf *.o *~ *.c.gcov *.gcda *.gcno cscope.* tags + +xref: + @cscope -bkqRv + @ctags -R +

--- /dev/null +++ b/debian/compcache.old/sub-projects/allocators/xvmalloc-kmod/compat.h @@ -0,0 +1,4 @@ +#ifndef _XVMALLOC_COMPAT_H_ +#define _XVMALLOC_COMPAT_H_ + +#endif

--- /dev/null +++ b/debian/compcache.old/sub-projects/allocators/xvmalloc-kmod/xvmalloc.c @@ -0,0 +1,557 @@ +/* + * xvmalloc memory allocator + * + * Copyright (C) 2008, 2009 Nitin Gupta + * + * This code is released using a dual license strategy: BSD/GPL + * You can choose the licence that better fits your requirements. + * + * Released under the terms of 3-clause BSD License + * Released under the terms of GNU General Public License Version 2.0 + */ + +#include module.h> +#include kernel.h> +#include bitops.h> +#include errno.h> +#include highmem.h> +#include init.h> +#include string.h> +#include slab.h> + +#include "compat.h" +#include "xvmalloc.h" +#include "xvmalloc_int.h" + +static void stat_inc(u64 *value) +{ + *value = *value + 1; +} + +static void stat_dec(u64 *value) +{ + *value = *value - 1; +} + +static int test_flag(struct block_header *block, enum blockflags flag) +{ + return block->prev & BIT(flag); +} + +static void set_flag(struct block_header *block, enum blockflags flag) +{ + block->prev |= BIT(flag); +} + +static void clear_flag(struct block_header *block, enum blockflags flag) +{ + block->prev &= ~BIT(flag); +} + +/* + * Given pair, provide a derefrencable pointer. + * This is called from xv_malloc/xv_free path, so it needs to be fast. + */ +static void *get_ptr_atomic(u32 pagenum, u16 offset, enum km_type type) +{ + unsigned char *base; + + base = kmap_atomic(pfn_to_page(pagenum), type); + return base + offset; +} + +static void put_ptr_atomic(void *ptr, enum km_type type) +{ + kunmap_atomic(ptr, type); +} + +static u32 get_blockprev(struct block_header *block) +{ + return block->prev & PREV_MASK; +} + +static void set_blockprev(struct block_header *block, u16 new_offset) +{ + block->prev = new_offset | (block->prev & FLAGS_MASK); +} + +static struct block_header *BLOCK_NEXT(struct block_header *block) +{ + return (struct block_header *)((char *)block + block->size + XV_ALIGN); +} + +/* + * Get index of free list containing blocks of maximum size + * which is less than or equal to given size. + */ +static u32 get_index_for_insert(u32 size) +{ + if (unlikely(size > XV_MAX_ALLOC_SIZE)) + size = XV_MAX_ALLOC_SIZE; + size &= ~FL_DELTA_MASK; + return (size - XV_MIN_ALLOC_SIZE) >> FL_DELTA_SHIFT; +} + +/* + * Get index of free list having blocks of size greater than + * or equal to requested size. + */ +static u32 get_index(u32 size) +{ + if (unlikely(size < XV_MIN_ALLOC_SIZE)) + size = XV_MIN_ALLOC_SIZE; + size = ALIGN(size, FL_DELTA); + return (size - XV_MIN_ALLOC_SIZE) >> FL_DELTA_SHIFT; +} + +/* + * Allocate a memory page. Called when a pool needs to grow. + */ +static u32 xv_alloc_page(gfp_t flags) +{ + struct page *page; + + page = alloc_page(flags); + if (unlikely(!page)) + return 0; + + return page_to_pfn(page); +} + +/* + * Called when all objects in a page are freed. + */ +static void xv_free_page(u32 pagenum) +{ + __free_page(pfn_to_page(pagenum)); +} + +/** + * find_block - find block of at least given size + * @pool: memory pool to search from + * @size: size of block required + * @pagenum: page no. containing required block + * @offset: offset within the page where block is located. + * + * Searches two level bitmap to locate block of at least + * the given size. If such a block is found, it provides + * to identify this block and returns index + * in freelist where we found this block. + * Otherwise, returns 0 and params are not touched. + */ +static u32 find_block(struct xv_pool *pool, u32 size, + u32 *pagenum, u32 *offset) +{ + ulong flbitmap, slbitmap; + u32 flindex, slindex, slbitstart; + + /* There are no free blocks in this pool */ + if (!pool->flbitmap) + return 0; + + /* Get freelist index correspoding to this size */ + slindex = get_index(size); + slbitmap = pool->slbitmap[slindex / BITS_PER_LONG]; + slbitstart = slindex % BITS_PER_LONG; + + /* + * If freelist is not empty at this index, we found the + * block - head of this list. This is approximate best-fit match. + */ + if (test_bit(slbitstart, &slbitmap;)) { + *pagenum = pool->freelist[slindex].pagenum; + *offset = pool->freelist[slindex].offset; + return slindex; + } + + /* + * No best-fit found. Search a bit further in bitmap for a free block. + * Second level bitmap consists of series of 32-bit chunks. Search + * further in the chunk where we expected a best-fit, starting from + * index location found above. + */ + slbitstart++; + slbitmap >>= slbitstart; + + /* Skip this search if we were already at end of this bitmap chunk */ + if ((slbitstart != BITS_PER_LONG) && slbitmap) { + slindex += __ffs(slbitmap) + 1; + *pagenum = pool->freelist[slindex].pagenum; + *offset = pool->freelist[slindex].offset; + return slindex; + } + + /* Now do a full two-level bitmap search to find next nearest fit */ + flindex = slindex / BITS_PER_LONG; + + flbitmap = (pool->flbitmap) >> (flindex + 1); + if (!flbitmap) + return 0; + + flindex += __ffs(flbitmap) + 1; + slbitmap = pool->slbitmap[flindex]; + slindex = (flindex * BITS_PER_LONG) + __ffs(slbitmap); + *pagenum = pool->freelist[slindex].pagenum; + *offset = pool->freelist[slindex].offset; + + return slindex; +} + +/* + * Insert block at in freelist of given pool. + * freelist used depends on block size. + */ +static void insert_block(struct xv_pool *pool, u32 pagenum, u32 offset, + struct block_header *block) +{ + u32 flindex, slindex; + struct block_header *nextblock; + + slindex = get_index_for_insert(block->size); + flindex = slindex / BITS_PER_LONG; + + block->link.prev_pagenum = 0; + block->link.prev_offset = 0; + block->link.next_pagenum = pool->freelist[slindex].pagenum; + block->link.next_offset = pool->freelist[slindex].offset; + pool->freelist[slindex].pagenum = pagenum; + pool->freelist[slindex].offset = offset; + + if (block->link.next_pagenum) { + nextblock = get_ptr_atomic(block->link.next_pagenum, + block->link.next_offset, KM_USER1); + nextblock->link.prev_pagenum = pagenum; + nextblock->link.prev_offset = offset; + put_ptr_atomic(nextblock, KM_USER1); + } + + __set_bit(slindex % BITS_PER_LONG, &pool-;>slbitmap[flindex]); + __set_bit(flindex, &pool-;>flbitmap); +} + +/* + * Remove block from head of freelist. Index 'slindex' identifies the freelist. + */ +static void remove_block_head(struct xv_pool *pool, + struct block_header *block, u32 slindex) +{ + struct block_header *tmpblock; + u32 flindex = slindex / BITS_PER_LONG; + + pool->freelist[slindex].pagenum = block->link.next_pagenum; + pool->freelist[slindex].offset = block->link.next_offset; + block->link.prev_pagenum = 0; + block->link.prev_offset = 0; + + if (!pool->freelist[slindex].pagenum) { + __clear_bit(slindex % BITS_PER_LONG, &pool-;>slbitmap[flindex]); + if (!pool->slbitmap[flindex]) + __clear_bit(flindex, &pool-;>flbitmap); + } else { + /* + * DEBUG ONLY: We need not reinitialize freelist head previous + * pointer to 0 - we never depend on its value. But just for + * sanity, lets do it. + */ + tmpblock = get_ptr_atomic(pool->freelist[slindex].pagenum, + pool->freelist[slindex].offset, KM_USER1); + tmpblock->link.prev_pagenum = 0; + tmpblock->link.prev_offset = 0; + put_ptr_atomic(tmpblock, KM_USER1); + } +} + +/* + * Remove block from freelist. Index 'slindex' identifies the freelist. + */ +static void remove_block(struct xv_pool *pool, u32 pagenum, u32 offset, + struct block_header *block, u32 slindex) +{ + u32 flindex; + struct block_header *tmpblock; + + if (pool->freelist[slindex].pagenum == pagenum + && pool->freelist[slindex].offset == offset) { + remove_block_head(pool, block, slindex); + return; + } + + flindex = slindex / BITS_PER_LONG; + + if (block->link.prev_pagenum) { + tmpblock = get_ptr_atomic(block->link.prev_pagenum, + block->link.prev_offset, KM_USER1); + tmpblock->link.next_pagenum = block->link.next_pagenum; + tmpblock->link.next_offset = block->link.next_offset; + put_ptr_atomic(tmpblock, KM_USER1); + } + + if (block->link.next_pagenum) { + tmpblock = get_ptr_atomic(block->link.next_pagenum, + block->link.next_offset, KM_USER1); + tmpblock->link.prev_pagenum = block->link.prev_pagenum; + tmpblock->link.prev_offset = block->link.prev_offset; + put_ptr_atomic(tmpblock, KM_USER1); + } + + return; +} + +/* + * Allocate a page and add it freelist of given pool. + */ +static int grow_pool(struct xv_pool *pool, gfp_t flags) +{ + u32 pagenum; + struct block_header *block; + + pagenum = xv_alloc_page(flags); + if (unlikely(!pagenum)) + return -ENOMEM; + + stat_inc(&pool-;>total_pages); + + spin_lock(&pool-;>lock); + block = get_ptr_atomic(pagenum, 0, KM_USER0); + + block->size = PAGE_SIZE - XV_ALIGN; + set_flag(block, BLOCK_FREE); + clear_flag(block, PREV_FREE); + set_blockprev(block, 0); + + insert_block(pool, pagenum, 0, block); + + put_ptr_atomic(block, KM_USER0); + spin_unlock(&pool-;>lock); + + return 0; +} + +/* + * Create a memory pool. Allocates freelist, bitmaps and other + * per-pool metadata. + */ +struct xv_pool *xv_create_pool(void) +{ + u32 ovhd_size; + struct xv_pool *pool; + + ovhd_size = roundup(sizeof(*pool), PAGE_SIZE); + pool = kzalloc(ovhd_size, GFP_KERNEL); + if (!pool) + return NULL; + + spin_lock_init(&pool-;>lock); + + return pool; +} +EXPORT_SYMBOL_GPL(xv_create_pool); + +void xv_destroy_pool(struct xv_pool *pool) +{ + kfree(pool); +} +EXPORT_SYMBOL_GPL(xv_destroy_pool); + +/** + * xv_malloc - Allocate block of given size from pool. + * @pool: pool to allocate from + * @size: size of block to allocate + * @pagenum: page no. that holds the object + * @offset: location of object within pagenum + * + * On success, identifies block allocated + * and 0 is returned. On failure, is set to + * 0 and -ENOMEM is returned. + * + * Allocation requests with size > XV_MAX_ALLOC_SIZE will fail. + */ +int xv_malloc(struct xv_pool *pool, u32 size, u32 *pagenum, u32 *offset, + gfp_t flags) +{ + int error; + u32 index, tmpsize, origsize, tmpoffset; + struct block_header *block, *tmpblock; + + *pagenum = 0; + *offset = 0; + origsize = size; + + if (unlikely(!size || size > XV_MAX_ALLOC_SIZE)) + return -ENOMEM; + + size = ALIGN(size, XV_ALIGN); + + spin_lock(&pool-;>lock); + + index = find_block(pool, size, pagenum, offset); + + if (!*pagenum) { + spin_unlock(&pool-;>lock); + if (flags & GFP_NOWAIT) + return -ENOMEM; + error = grow_pool(pool, flags); + if (unlikely(error)) + return -ENOMEM; + + spin_lock(&pool-;>lock); + index = find_block(pool, size, pagenum, offset); + } + + if (!*pagenum) { + spin_unlock(&pool-;>lock); + return -ENOMEM; + } + + block = get_ptr_atomic(*pagenum, *offset, KM_USER0); + + remove_block_head(pool, block, index); + + /* Split the block if required */ + tmpoffset = *offset + size + XV_ALIGN; + tmpsize = block->size - size; + tmpblock = (struct block_header *)((char *)block + size + XV_ALIGN); + if (tmpsize) { + tmpblock->size = tmpsize - XV_ALIGN; + set_flag(tmpblock, BLOCK_FREE); + clear_flag(tmpblock, PREV_FREE); + + set_blockprev(tmpblock, *offset); + if (tmpblock->size >= XV_MIN_ALLOC_SIZE) + insert_block(pool, *pagenum, tmpoffset, tmpblock); + + if (tmpoffset + XV_ALIGN + tmpblock->size != PAGE_SIZE) { + tmpblock = BLOCK_NEXT(tmpblock); + set_blockprev(tmpblock, tmpoffset); + } + } else { + /* This block is exact fit */ + if (tmpoffset != PAGE_SIZE) + clear_flag(tmpblock, PREV_FREE); + } + + block->size = origsize; + clear_flag(block, BLOCK_FREE); + + put_ptr_atomic(block, KM_USER0); + spin_unlock(&pool-;>lock); + + *offset += XV_ALIGN; + + return 0; +} +EXPORT_SYMBOL_GPL(xv_malloc); + +/* + * Free block identified with + */ +void xv_free(struct xv_pool *pool, u32 pagenum, u32 offset) +{ + void *page; + struct block_header *block, *tmpblock; + + offset -= XV_ALIGN; + + spin_lock(&pool-;>lock); + + page = get_ptr_atomic(pagenum, 0, KM_USER0); + block = (struct block_header *)((char *)page + offset); + + /* Catch double free bugs */ + BUG_ON(test_flag(block, BLOCK_FREE)); + + block->size = ALIGN(block->size, XV_ALIGN); + + tmpblock = BLOCK_NEXT(block); + if (offset + block->size + XV_ALIGN == PAGE_SIZE) + tmpblock = NULL; + + /* Merge next block if its free */ + if (tmpblock && test_flag(tmpblock, BLOCK_FREE)) { + /* + * Blocks smaller than XV_MIN_ALLOC_SIZE + * are not inserted in any free list. + */ + if (tmpblock->size >= XV_MIN_ALLOC_SIZE) { + remove_block(pool, pagenum, + offset + block->size + XV_ALIGN, tmpblock, + get_index_for_insert(tmpblock->size)); + } + block->size += tmpblock->size + XV_ALIGN; + } + + /* Merge previous block if its free */ + if (test_flag(block, PREV_FREE)) { + tmpblock = (struct block_header *)((char *)(page) + + get_blockprev(block)); + offset = offset - tmpblock->size - XV_ALIGN; + + if (tmpblock->size >= XV_MIN_ALLOC_SIZE) + remove_block(pool, pagenum, offset, tmpblock, + get_index_for_insert(tmpblock->size)); + + tmpblock->size += block->size + XV_ALIGN; + block = tmpblock; + } + + /* No used objects in this page. Free it. */ + if (block->size == PAGE_SIZE - XV_ALIGN) { + put_ptr_atomic(page, KM_USER0); + spin_unlock(&pool-;>lock); + + xv_free_page(pagenum); + stat_dec(&pool-;>total_pages); + return; + } + + set_flag(block, BLOCK_FREE); + if (block->size >= XV_MIN_ALLOC_SIZE) + insert_block(pool, pagenum, offset, block); + + if (offset + block->size + XV_ALIGN != PAGE_SIZE) { + tmpblock = BLOCK_NEXT(block); + set_flag(tmpblock, PREV_FREE); + set_blockprev(tmpblock, offset); + } + + put_ptr_atomic(page, KM_USER0); + spin_unlock(&pool-;>lock); + + return; +} +EXPORT_SYMBOL_GPL(xv_free); + +u32 xv_get_object_size(void *obj) +{ + struct block_header *blk; + + blk = (struct block_header *)((char *)(obj) - XV_ALIGN); + return blk->size; +} +EXPORT_SYMBOL_GPL(xv_get_object_size); + +/* + * Returns total memory used by allocator (userdata + metadata) + */ +u64 xv_get_total_size_bytes(struct xv_pool *pool) +{ + return pool->total_pages << PAGE_SHIFT; +} +EXPORT_SYMBOL_GPL(xv_get_total_size_bytes); + +static int __init xv_malloc_init(void) +{ + return 0; +} + +static void __exit xv_malloc_exit(void) +{ + return; +} + +module_init(xv_malloc_init); +module_exit(xv_malloc_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Nitin Gupta "); +MODULE_DESCRIPTION("xvmalloc memory allocator");

--- /dev/null +++ b/debian/compcache.old/sub-projects/allocators/xvmalloc-kmod/xvmalloc.h @@ -0,0 +1,30 @@ +/* + * xvmalloc memory allocator + * + * Copyright (C) 2008, 2009 Nitin Gupta + * + * This code is released using a dual license strategy: BSD/GPL + * You can choose the licence that better fits your requirements. + * + * Released under the terms of 3-clause BSD License + * Released under the terms of GNU General Public License Version 2.0 + */ + +#ifndef _XVMALLOC_H_ +#define _XVMALLOC_H_ + +#include types.h> + +struct xv_pool; + +struct xv_pool *xv_create_pool(void); +void xv_destroy_pool(struct xv_pool *pool); + +int xv_malloc(struct xv_pool *pool, u32 size, u32 *pagenum, u32 *offset, + gfp_t flags); +void xv_free(struct xv_pool *pool, u32 pagenum, u32 offset); + +u32 xv_get_object_size(void *obj); +u64 xv_get_total_size_bytes(struct xv_pool *pool); + +#endif
>
--- /dev/null +++ b/debian/compcache.old/sub-projects/allocators/xvmalloc-kmod/xvmalloc_int.h @@ -0,0 +1,86 @@ +/* + * xvmalloc memory allocator + * + * Copyright (C) 2008, 2009 Nitin Gupta + * + * This code is released using a dual license strategy: BSD/GPL + * You can choose the licence that better fits your requirements. + * + * Released under the terms of 3-clause BSD License + * Released under the terms of GNU General Public License Version 2.0 + */ + +#ifndef _XVMALLOC_INT_H_ +#define _XVMALLOC_INT_H_ + +#include kernel.h> +#include types.h> + +/* User configurable params */ + +/* This must be greater than sizeof(LinkFree) */ +#define XV_MIN_ALLOC_SIZE 32 +#define XV_MAX_ALLOC_SIZE (PAGE_SIZE - XV_ALIGN) + +/* Must be power of two */ +#define XV_ALIGN_SHIFT 2 +#define XV_ALIGN (1 << XV_ALIGN_SHIFT) +#define XV_ALIGN_MASK (XV_ALIGN - 1) + +/* Free lists are separated by FL_DELTA bytes */ +#define FL_DELTA_SHIFT 3 +#define FL_DELTA (1 << FL_DELTA_SHIFT) +#define FL_DELTA_MASK (FL_DELTA - 1) +#define NUM_FREE_LISTS ((XV_MAX_ALLOC_SIZE - XV_MIN_ALLOC_SIZE) \ + / FL_DELTA + 1) + +#define MAX_FLI DIV_ROUND_UP(NUM_FREE_LISTS, BITS_PER_LONG) + +/* End of user params */ + +enum blockflags { + BLOCK_FREE, + PREV_FREE, + __NR_BLOCKFLAGS, +}; + +#define FLAGS_MASK XV_ALIGN_MASK +#define PREV_MASK (~FLAGS_MASK) + +struct freelist_entry { + u32 pagenum; + u16 offset; + u16 pad; +}; + +struct link_free { + u32 prev_pagenum; + u32 next_pagenum; + u16 prev_offset; + u16 next_offset; +}; + +struct block_header { + union { + /* This common header must be ALIGN bytes */ + u8 common[XV_ALIGN]; + struct { + u16 size; + u16 prev; + }; + }; + struct link_free link; +}; + +struct xv_pool { + ulong flbitmap; + ulong slbitmap[MAX_FLI]; + spinlock_t lock; + + struct freelist_entry freelist[NUM_FREE_LISTS]; + + /* stats */ + u64 total_pages; +}; + +#endif

--- /dev/null +++ b/debian/get.compcache.dir.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +DIST=$(dpkg-parsechangelog | awk '/^Version/ {print $2}') + +case $DIST in + *lenny*) + echo "debian/compcache.old/" +  ;; + + *) + echo "./" +  ;; +esac + + +#KMID=$(echo "$1" | awk -F"-" '{print $1}' | awk -F"." '{print int($3)}') +# +#if [ $KMID -gt 28 ]; then +# echo "./" +#else +# echo "debian/compcache.old/"

+#fi

release 0.89.55
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 752150c7538ab42ca6072e204fb762aa426c2107
Date: Fri, 26 Feb 2010 16:36:53 GMT
Commit diff


--- a/debian/changelog

+++ b/debian/changelog @@ -1,3 +1,17 @@ +initramfs-tools-tcos (0.89.55) unstable; urgency=low + + * fix dolar escape in openchrome start script + * bin/tryXorg.sh: configure fonts servers xfs and xfstt + * tmixer/tmixer-alsa.c: Fix hidden channels, only hide enumerates + (alsa 1.0.22) + * Add support for compcache (ramzswap) + * hooks-addons/05compcache: Show info when compcache is enabled + * scripts/tcos-bottom/10ldconfig: don't show errors in ldconfig + * tnc/tcos-net-controller.c: change ip_by_eth function + * hooks-addons/05compcache: fix TOTAL_RAM + + -- Mario Izquierdo (mariodebian) Fri, 26 Feb 2010 17:36:05 +0100 +

initramfs-tools-tcos (0.89.54) unstable; urgency=low

* remove backup of tcos.conf

hooks-addons/05compcache: fix TOTAL_RAM
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 8f55a28d1cc4a3907055b7bcc804dd53360d60e1
Date: Fri, 26 Feb 2010 16:35:30 GMT
Commit diff


--- a/hooks-addons/05compcache

+++ b/hooks-addons/05compcache @@ -27,7 +27,7 @@ cat << EOF > $DESTDIR/scripts/init-top/compcache


# find total amount of available ram

-TOTAL_RAM=\$(awk '/MemTotal/ {print \$1}' /proc/meminfo) +TOTAL_RAM=\$(grep MemTotal /proc/meminfo |tr -d ': [A-Z][a-z]')

# Do not use compcache if we have more than 256M
if [ "\${TOTAL_RAM}" -gt 262144 ]; then

tnc/tcos-net-controller.c: change ip_by_eth function
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 5096710130153cd1fc3b8891b5706354ba7af317
Date: Fri, 26 Feb 2010 16:34:57 GMT
Commit diff


--- a/tnc/tcos-net-controller.c

+++ b/tnc/tcos-net-controller.c @@ -35,6 +35,8 @@

#include ioctl.h>
#include inet.h>
#include route.h>

+#include +#include

#define GROUP "tcos"
#define IPTABLES "sbin/iptables"

@@ -59,6 +61,10 @@ int getgroups(int size, gid_t list[]);

/* int strcmp(const char *str1, const char *str2); */
char *strtok( char *str1, const char *str2 );

+int getnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, + char *serv, size_t servlen, int flags); +

#define MAXTOKENS       256
#define MAXLINE         1024     /* fgets buff */
#define MINLEN          3        /* skip lines shorter as */

@@ -395,24 +401,32 @@ add_iptables_user(char **args) {

char 
*ip_by_eth(char *dev) {

+ struct ifaddrs *ifaddr, *ifa; + int family, s; + static char host[255]="error";

- struct sockaddr_in *sin; - struct ifreq ifr; - int fd; - - - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - return "error"; - - strcpy( ifr.ifr_name, dev ); + if (getifaddrs(&ifaddr;) == -1) { + perror("getifaddrs"); + return host; + }

- if (ioctl( fd, SIOCGIFADDR, &ifr; ) == 0) { - sin = (struct sockaddr_in *)&ifr.ifr;_addr; - close( fd ); - return inet_ntoa( sin->sin_addr ); - } - return "error"; + for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { + family = ifa->ifa_addr->sa_family; + if( strcmp( dev, ifa->ifa_name) == 0 ) { + if (family == AF_INET) { + s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), + host, 255, NULL, 0, 1); + if (s != 0) { + return "error"; + } + /*fprintf(stderr, "iface=%s ip=%s\n", ifa->ifa_name, host);*/ + return host; + } + } + }

+ freeifaddrs(ifaddr); + return host;

}

int 

@@ -523,6 +537,10 @@ int main(int argc, char **argv) {

        printf("ok");
     }
  }

+ else if ( strcmp( argv[1], "ip") == 0 && argc == 3) { + /*fprintf(stderr, "ip_by_eth(%s)=%s\n", argv[2], ip_by_eth(argv[2]));*/ + printf("%s\n", ip_by_eth(argv[2])); + }

  else {
    fprintf(stderr, "ERROR => Bad command line arguments\n");
    fprintf(stderr, "tnc :: tcos-net-controller usage\n");

@@ -531,6 +549,7 @@ int main(int argc, char **argv) {

    fprintf(stderr, "\t tnc route-add ip-multicast netmask ethX\n");
    fprintf(stderr, "\t tnc route-del ip-multicast netmask ethX\n");
    fprintf(stderr, "\t tnc status username\n");

+ fprintf(stderr, "\t tnc ip [iface]\n\n");

    return(1);
  }

@@ -551,6 +570,9 @@ void create_route(struct rtentry *p, char **args) {

    sinmask.sin_family = AF_INET;

    sindst.sin_addr.s_addr = inet_addr( args[2] );

+ if ( strcmp( ip_by_eth(args[4]), "error") == 0 ) { + return; + }

    singw.sin_addr.s_addr = inet_addr( ip_by_eth(args[4]) );
sinmask.sin_addr.s_addr = inet_addr( args[3] );

Add compcache modules and update kernels
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: f7f74912312fcbb9dc09a66b976d08d423fe6a11
Date: Fri, 26 Feb 2010 14:52:05 GMT
Commit diff


--- a/common.mk

+++ b/common.mk @@ -17,13 +17,13 @@ KERNEL_etch=2.6.18-6-486 2.6.18-6-686 2.6.18-6-k7 2.6.24-etchnhalf.1-486 2.6.24-

TCOS_MODULES_etch="unionfs squashfs sis7019-alsa-backport cdfs"

KERNEL_lenny=2.6.26-2-486 2.6.26-2-686 2.6.26-2-686-bigmem

-TCOS_MODULES_lenny="unionfs-tcos squashfs lzma aufs cdfs" +TCOS_MODULES_lenny="compcache unionfs-tcos squashfs lzma aufs cdfs"

-KERNEL_testing=2.6.29-2-486 2.6.29-2-686 2.6.29-2-686-bigmem -TCOS_MODULES_testing="aufs cdfs" +KERNEL_testing=2.6.32-trunk-486 2.6.32-trunk-686 +TCOS_MODULES_testing="cdfs compcache"

-KERNEL_unstable=2.6.30-2-486 2.6.30-2-686 2.6.30-2-686-bigmem -TCOS_MODULES_unstable="aufs cdfs" +KERNEL_unstable=2.6.32-2-486 2.6.32-2-686 +TCOS_MODULES_unstable="cdfs compcache"

KERNEL_experimental=2.6.26-1-486 2.6.26-1-686
TCOS_MODULES_experimental="unionfs squashfs lzma aufs sis7019 cdfs"

@@ -37,9 +37,15 @@ TCOS_MODULES_hardy="aufs etc2300-modules sis7019-alsa-backport cdfs lzma"

KERNEL_max=2.6.24-24-generic 2.6.24-24-386 2.6.24-24-server
TCOS_MODULES_max="aufs etc2300-modules sis7019-alsa-backport cdfs lzma"

-KERNEL_intrepid=2.6.27-11-generic 2.6.27-11-server +KERNEL_intrepid=2.6.27-17-generic 2.6.27-17-server

TCOS_MODULES_intrepid="aufs etc2300-modules cdfs lzma"

-KERNEL_jaunty=2.6.28-15-generic 2.6.28-15-server -TCOS_MODULES_jaunty="sis7019-alsa-backport cdfs" +KERNEL_jaunty=2.6.28-18-generic 2.6.28-18-server +TCOS_MODULES_jaunty="sis7019-alsa-backport compcache cdfs" + +KERNEL_karmic=2.6.31-19-generic 2.6.31-19-server +TCOS_MODULES_karmic="compcache cdfs" + +KERNEL_lucid=2.6.32-14-generic 2.6.32-14-server +TCOS_MODULES_lucid="cdfs compcache"



--- a/debian/changelog

+++ b/debian/changelog @@ -1,3 +1,9 @@ +tcos-extra-modules (0.41) unstable; urgency=low + + * Add compcache modules + + -- Mario Izquierdo (mariodebian) Fri, 26 Feb 2010 14:48:44 +0100 +

tcos-extra-modules (0.40) unstable; urgency=low

  * Debian unstable:

--- /dev/null

+++ b/patches/compcache.patch @@ -0,0 +1,11 @@ +--- build/modules/compcache.orig/Makefile 2010-02-26 11:50:59.000000000 +0100 ++++ build/modules/compcache/Makefile 2010-02-26 14:57:50.000000000 +0100 +@@ -14,3 +14,8 @@ + clean: + make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean + @rm -rf *.ko ++ ++ ++install: ++ install -d $(DESTDIR)/lib/modules/$(KVER)/updates/compcache

++ install -m 0644 ramzswap.ko $(DESTDIR)/lib/modules/$(KVER)/updates/compcache/

compcache (0.6.2-2)
* Change Makefile PWD => CURDIR
* debian/rules: don't clean modules
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: c62e065ee11f41bb194987a2cd49d574f0963db2
Date: Fri, 26 Feb 2010 13:32:38 GMT
Commit diff


--- a/Makefile

+++ b/Makefile @@ -8,13 +8,13 @@ obj-m += ramzswap.o

ramzswap-objs	:=	ramzswap_drv.o $(XVM)/xvmalloc.o

all:

- make -C $(KERNEL_BUILD_PATH) M=$(PWD) modules + make -C $(KERNEL_BUILD_PATH) M=$(CURDIR) modules

	make -C sub-projects/rzscontrol

doc:
	make -C sub-projects/rzscontrol doc

clean:

- make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean + make -C $(KERNEL_BUILD_PATH) M=$(CURDIR) clean

	make -C sub-projects/rzscontrol clean
	@rm -rf *.ko

--- a/debian/changelog

+++ b/debian/changelog @@ -1,3 +1,10 @@ +compcache (0.6.2-2) unstable; urgency=low + + * Change Makefile PWD => CURDIR + * debian/rules: don't clean modules + + -- Mario Izquierdo (mariodebian) Fri, 26 Feb 2010 14:31:31 +0100 +

compcache (0.6.2-1) unstable; urgency=low

  * Initial release

--- a/debian/rules

+++ b/debian/rules @@ -116,7 +116,8 @@ clean:

	dh_testdir
	rm -f build-arch-stamp build-indep-stamp configure-stamp

- $(MAKE) clean +# $(MAKE) clean + $(MAKE) -C sub-projects/rzscontrol clean

dh_clean

Merge branch 'master' of tcosproject.org:tcosmonitor
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: c1b08075e2c712c39a7bde45adbbfebc50db5339
Date: Fri, 26 Feb 2010 13:19:04 GMT
Commit diff


--- a/tcos-devices-ng.py

+++ b/tcos-devices-ng.py @@ -290,7 +290,7 @@ class TcosDevicesNG:

            print "tcos-devices-ng: TCOS_DISABLE_USB or TCOS_DISABLE_IDE enabled, exiting..."
            sys.exit(0)

- def get_desktop_patch(self): + def get_desktop_path(self):

        desktop=self.common.exe_cmd("/usr/lib/tcos/rsync-controller", verbose=1, background=False, lines=0, cthreads=0)
        if not os.path.isdir(desktop):
            desktop=os.path.expanduser("~/Desktop")

@@ -607,7 +607,7 @@ class TcosDevicesNG:


    def get_local_mountpoint(self, data):

- desktop=self.get_desktop_patch() + desktop=self.get_desktop_path()

        #fslabel=self.get_value(data, "ID_FS_LABEL")
        #fsvendor=self.get_value(data, "ID_VENDOR")

@@ -666,7 +666,7 @@ class TcosDevicesNG:

    def floppy(self, action):
        action=action[0]
        print_debug("floppy call %s" %action)

- desktop=self.get_desktop_patch() + desktop=self.get_desktop_path()

        if self.mntconf.has_key("fd0"):
            local_mount_point=os.path.join(desktop, self.mntconf['fd0'] )

@@ -694,7 +694,7 @@ class TcosDevicesNG:

    def cdrom(self, *args):
        action=args[0][0]
        cdrom_device=args[0][1]

- desktop=self.get_desktop_patch() + desktop=self.get_desktop_path()

        if self.mntconf.has_key(cdrom_device):
            local_mount_point=os.path.join(desktop, self.mntconf[cdrom_device] )

@@ -734,7 +734,7 @@ class TcosDevicesNG:

    def hdd(self, *args):
        action=args[0][0]
        hdd_device=args[0][1]

- desktop=self.get_desktop_patch() + desktop=self.get_desktop_path()

        if self.mntconf.has_key(hdd_device):
            local_mount_point=os.path.join(desktop, self.mntconf[hdd_device] )

@@ -828,7 +828,7 @@ class TcosDevicesNG:

            ###############################################
            # We can have only a cdrom connected without cd inserted
            if fstype != "":

- desktop=self.get_desktop_patch() + desktop=self.get_desktop_path()

                if self.mntconf.has_key(devid):
                    local_mount_point=os.path.join(desktop, self.mntconf[devid] )

@@ -859,7 +859,7 @@ class TcosDevicesNG:

                fstype=""
            else:
                fstype=data['ID_FS_TYPE']

- desktop=self.get_desktop_patch() + desktop=self.get_desktop_path()

            if self.mntconf.has_key(devid):
                local_mount_point=os.path.join(desktop, self.mntconf[devid] )

@@ -1354,22 +1354,27 @@ class TcosDevicesNG:

    def get_desktop(self):    
        is_gnome=self.common.exe_cmd("ps ux |grep gnome-panel  |grep -c -v grep", verbose=1, background=False, lines=0, cthreads=0  )

- is_kde = self.common.exe_cmd("ps ux |grep startkde |grep -c -v grep", verbose=1, background=False, lines=0, cthreads=0 ) + is_kde = self.common.exe_cmd("ps ux |grep -e startkde -e kwin |grep -c -v grep", verbose=1, background=False, lines=0, cthreads=0 )

        is_xfce= self.common.exe_cmd("ps ux |grep xfce4-panel  |grep -c -v grep", verbose=1, background=False, lines=0, cthreads=0  )

- if int(is_gnome) > 0: - return "gnome" - elif int(is_kde) > 0: - return "kde" - elif int(is_xfce) > 0: - return "xfce4" - else: + try: + if int(is_gnome) > 0: + return "gnome" + elif int(is_kde) > 0: + return "kde" + elif int(is_xfce) > 0: + return "xfce4" + except Exception, e: + print_debug("Can't read desktop type, error: %s"%e)

            return ""

    def launch_desktop_filemanager(self, path=""):
        if self.desktop == "gnome":
            cmd="nautilus %s" %(path)
        elif self.desktop == "kde":

- cmd="konqueror %s" %(path) + if os.path.isfile("/usr/bin/dolphin"): + cmd="dolphin %s" %(path) + else: + cmd="konqueror %s" %(path)

        elif self.desktop == "xfce4":
            cmd="Thunar %s" %(path)
        else:

@@ -1413,7 +1418,7 @@ class TcosDevicesNG:


- +

if __name__ == "__main__":
    
    # init app

@@ -1431,6 +1436,9 @@ if __name__ == "__main__":

            app.udev_daemon()
            time.sleep(3)
        except KeyboardInterrupt:

+ print "Get KeyboardInterrupt (udev loop), existing..." + app.quitting=True + app.mainloop.quit()

            break
        
    # join gui thread    

--- a/tcosmonitor/TcosCommon.py

+++ b/tcosmonitor/TcosCommon.py @@ -74,7 +74,11 @@ class TcosCommon:

            pass
            
    def exe_cmd(self, cmd, verbose=1, background=False, lines=0, cthreads=1):

- self.p = Popen(cmd, shell=True, bufsize=0, stdout=PIPE, stderr=STDOUT, close_fds=True) + try: + self.p = Popen(cmd, shell=True, bufsize=0, stdout=PIPE, stderr=STDOUT, close_fds=True) + except Exception, e: + print_debug("Exception in subprocess cmd(%s), error='%s'"%(cmd,e)) + return None

        if self.main.config.GetVar("threadscontrol") == 1 and cthreads == 1:
            try:

@@ -96,7 +100,13 @@ class TcosCommon:

        stdout = self.p.stdout
        if lines == 1:
            return stdout

- for line in stdout.readlines(): + try: + result=stdout.readlines() + except Exception, e: + print_debug("Exception in subprocess::readlines() cmd(%s), error='%s'"%(cmd,e)) + return None + + for line in result:

            if line != '\n':
                line=line.replace('\n', '')
output.append(line)

scripts/tcos-bottom/10ldconfig: don't show errors in ldconfig
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 5656d7d9cd3192725e45619c829b5e8dc771c7b7
Date: Fri, 26 Feb 2010 12:34:56 GMT
Commit diff


--- a/scripts/tcos-bottom/10ldconfig

+++ b/scripts/tcos-bottom/10ldconfig @@ -14,7 +14,7 @@ maybe_break ldconfig

# update lib cache
log_begin_msg "Updating lib cache"

- /usr/sbin/ldconfig & >> /tmp/initramfs.debug 2>&1 + /usr/sbin/ldconfig >> /tmp/initramfs.debug 2>&1 &

log_end_msg $?

# needed for ssh login

tcos-devices-ng.py: stop app using Ctrl+C quiting mainloop
===================================
Author: Mario Izquierdo (mariodebian)
GIT id: 3eeaf5fe4f96fc567a5d5939c86667066b201fb5
Date: Wed, 27 Jan 2010 16:42:00 GMT
Commit diff


--- a/tcos-devices-ng.py

+++ b/tcos-devices-ng.py @@ -1436,6 +1436,9 @@ if __name__ == "__main__":

            app.udev_daemon()
            time.sleep(3)
        except KeyboardInterrupt:

+ print "Get KeyboardInterrupt (udev loop), existing..." + app.quitting=True + app.mainloop.quit()

            break
        
# join gui thread