--- grub2-1.97~beta4.orig/debian/grub-common.init +++ grub2-1.97~beta4/debian/grub-common.init @@ -0,0 +1,42 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: grub-common +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Record successful boot for GRUB +# Description: GRUB displays the boot menu at the next boot if it +# believes that the previous boot failed. This script +# informs it that the system booted successfully. +### END INIT INFO + +which grub-editenv >/dev/null 2>&1 || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +case $1 in + start|restart|force-reload) + [ "$VERBOSE" != no ] && log_action_msg "Recording successful boot for GRUB" + [ -s /boot/grub/grubenv ] || rm -f /boot/grub/grubenv + mkdir -p /boot/grub + grub-editenv /boot/grub/grubenv unset recordfail + [ "$VERBOSE" != no ] && log_end_msg $? + ;; + stop) + ;; + status) + exit 0 + ;; + *) + echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +exit 0 --- grub2-1.97~beta4.orig/debian/grub-rescue-pc.install +++ grub2-1.97~beta4/debian/grub-rescue-pc.install @@ -0,0 +1,2 @@ +build/grub-rescue-pc/grub-rescue-floppy.img usr/lib/grub-rescue +build/grub-rescue-pc/grub-rescue-cdrom.iso usr/lib/grub-rescue --- grub2-1.97~beta4.orig/debian/docs.in +++ grub2-1.97~beta4/debian/docs.in @@ -0,0 +1,3 @@ +build-tree/*/NEWS +build-tree/*/README +build-tree/*/TODO --- grub2-1.97~beta4.orig/debian/grub-firmware-qemu_grub.cfg +++ grub2-1.97~beta4/debian/grub-firmware-qemu_grub.cfg @@ -0,0 +1,37 @@ +set default=0 +set fallback=1 +set timeout=10 + +menuentry "Search & load /boot/multiboot.img" { + search -s -f /boot/multiboot.img + if multiboot /boot/multiboot.img ; then + boot + fi + unset timeout +} + +# For separate /boot partition. +menuentry "Search & load /multiboot.img" { + search -s -f /multiboot.img + if multiboot /multiboot.img ; then + boot + fi + unset timeout +} + +menuentry "Search & source /boot/grub/grub.cfg" { + search -s -f /boot/grub/grub.cfg + source /boot/grub/grub.cfg + unset timeout +} + +# For separate /boot partition. +menuentry "Search & source /grub/grub.cfg" { + search -s -f /grub/grub.cfg + source /grub/grub.cfg + unset timeout +} + +menuentry "Reboot" { + reboot +} --- grub2-1.97~beta4.orig/debian/grub-pc.install.in +++ grub2-1.97~beta4/debian/grub-pc.install.in @@ -0,0 +1,3 @@ +debian/legacy/update-grub usr/lib/grub-legacy +debian/legacy/grub-set-default usr/lib/grub-legacy +debian/legacy/upgrade-from-grub-legacy usr/sbin --- grub2-1.97~beta4.orig/debian/compat +++ grub2-1.97~beta4/debian/compat @@ -0,0 +1 @@ +7 --- grub2-1.97~beta4.orig/debian/grub-firmware-qemu.install +++ grub2-1.97~beta4/debian/grub-firmware-qemu.install @@ -0,0 +1 @@ +build/grub-firmware-qemu/grub.bin usr/share/qemu --- grub2-1.97~beta4.orig/debian/grub-common.pm-sleep +++ grub2-1.97~beta4/debian/grub-common.pm-sleep @@ -0,0 +1,11 @@ +#!/bin/sh + +# Tell grub that resume was succesfull + +case "$1" in + thaw) + [ -s /boot/grub/grubenv ] || rm -f /boot/grub/grubenv + mkdir -p /boot/grub + grub-editenv /boot/grub/grubenv unset recordfail + ;; +esac --- grub2-1.97~beta4.orig/debian/grub-rescue-pc.README.Debian +++ grub2-1.97~beta4/debian/grub-rescue-pc.README.Debian @@ -0,0 +1,16 @@ +grub-rescue-pc +~~~~~~~~~~~~~~ + +How to test the images with qemu: + + qemu -fda /usr/lib/grub-rescue/grub-rescue-floppy.img + + qemu -cdrom /usr/lib/grub-rescue/grub-rescue-cdrom.iso + +How to write the images to bootable media: + + sudo dd if=/usr/lib/grub-rescue/grub-rescue-floppy.img of=/dev/fd0 bs=32k + + sudo wodim /usr/lib/grub-rescue/grub-rescue-cdrom.iso + # or just use your favourite CD burning program + --- grub2-1.97~beta4.orig/debian/config.in +++ grub2-1.97~beta4/debian/config.in @@ -0,0 +1,69 @@ +#!/bin/sh -e + +case `dpkg --print-architecture` in + kfreebsd-*) + # No migration from GRUB Legacy, no Linux cmdline + exit 0 + ;; +esac + +. /usr/share/debconf/confmodule + +priority=high + +case @PACKAGE@ in + grub-pc) + if test -e /boot/grub/stage2 && test -e /boot/grub/menu.lst && ! test -e /boot/grub/core.img ; then + + db_input high grub-pc/chainload_from_menu.lst || true + + db_get grub-pc/kopt_extracted || true + # this check ensures we only do this once + if [ "$RET" = "false" ] ; then + kopt=`sed -ne "s/^# kopt=//p" /boot/grub/menu.lst | tr -s " " "\n" | grep -vx "\(ro\|root=[^ ]*\)" | paste -s -d ' '` || true + db_set grub2/linux_cmdline "${kopt}" || true + db_set grub-pc/kopt_extracted true || true + if [ "${kopt}" = "" ] ; then + # something smells bad. give user a chance to correct it. + priority=high + else + # if we got something from menu.lst, it must be correct? + priority=medium + fi + timeout=`sed -ne "s/^timeout[[:space:]][[:space:]]*//p" /boot/grub/menu.lst` || true + if [ "${timeout}" != "" ]; then + db_set grub-pc/timeout "${timeout}" || true + fi + if grep -q '^hiddenmenu\([[:space:]]\|$\)' /boot/grub/menu.lst; then + db_set grub-pc/hidden_timeout true || true + else + db_set grub-pc/hidden_timeout false || true + fi + fi + fi + ;; +esac + +if test -e /etc/default/grub ; then + . /etc/default/grub + + db_set grub2/linux_cmdline "$GRUB_CMDLINE_LINUX" + db_set grub2/linux_cmdline_default "$GRUB_CMDLINE_LINUX_DEFAULT" + + case @PACKAGE@ in + grub-pc) + if [ "${GRUB_TIMEOUT}" != "" ]; then + db_set grub-pc/timeout "$GRUB_TIMEOUT" + fi + if [ "${GRUB_HIDDEN_TIMEOUT}" != "" ]; then + db_set grub-pc/hidden_timeout true + elif egrep -q '^#?[[:space:]]*GRUB_HIDDEN_TIMEOUT=' /etc/default/grub; then + db_set grub-pc/hidden_timeout false + fi + ;; + esac +fi + +db_input ${priority} grub2/linux_cmdline || true +db_input ${priority} grub2/linux_cmdline_default || true +db_go --- grub2-1.97~beta4.orig/debian/update-grub2.8 +++ grub2-1.97~beta4/debian/update-grub2.8 @@ -0,0 +1,16 @@ +.\" Copyright 2009 Felix Zielcke +.\" Lincensed under GPL3+ +.TH UPDATE-GRUB2 "8" "April 2009" +.SH NAME +update-grub2 \- stub for update-grub +.SH SYNOPSIS +.B update-grub2 +.SH DESCRIPTION +.B update-grub2 +is a stub for running +.B update-grub +which itself is a stub for running +.B grub-mkconfig -o /boot/grub/grub.cfg +to generate a grub2 config file. +.SH "SEE ALSO" +.BR update-grub (8), grub-mkconfig (8) --- grub2-1.97~beta4.orig/debian/grub2.dirs +++ grub2-1.97~beta4/debian/grub2.dirs @@ -0,0 +1 @@ +usr/share/bug/grub2 --- grub2-1.97~beta4.orig/debian/control +++ grub2-1.97~beta4/debian/control @@ -0,0 +1,198 @@ +Source: grub2 +Section: admin +Priority: extra +Maintainer: Ubuntu Core Developers +XSBC-Original-Maintainer: GRUB Maintainers +Uploaders: Robert Millan , Felix Zielcke , Jordi Mallach +DM-Upload-Allowed: yes +Build-Depends: cdbs, + debhelper (>= 7), + patchutils, + autoconf, + ruby, + bison, + po-debconf, + help2man, + texinfo, + gcc-4.4-multilib [sparc], + libncurses5-dev, + genisoimage [i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia], + bf-utf-source, + libfreetype6-dev, + gcc-4.4, +Build-Conflicts: autoconf2.13 +Standards-Version: 3.8.3 +Homepage: http://www.gnu.org/software/grub/grub-2.en.html +Vcs-Svn: svn://svn.debian.org/svn/pkg-grub/grub2/trunk/ +Vcs-Browser: http://svn.debian.org/viewsvn/pkg-grub/grub2/ + + +Package: grub2 +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia powerpc sparc +Depends: grub-pc [i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia] | grub-ieee1275 [powerpc sparc], ${misc:Depends} +Description: GRand Unified Bootloader, version 2 (dummy package) + This is a dummy transitional package to handle GRUB 2 upgrades. It can be + safely removed. + +Package: grub-linuxbios +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia +Depends: grub-coreboot (= ${binary:Version}), ${misc:Depends} +Description: GRand Unified Bootloader, version 2 (dummy package) + This is a dummy transitional package that depends on grub-coreboot. + +Package: grub-efi +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia +Depends: ${misc:Depends}, grub-efi-ia32 [i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 lpia], grub-efi-amd64 [amd64 kfreebsd-amd64] +Description: GRand Unified Bootloader, version 2 (dummy package) + This is a dummy transitional package that depends on either grub-efi-ia32 or + grub-efi-amd64, depending on the architecture. + + +Package: grub-common +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia powerpc sparc +Depends: ${shlibs:Depends}, base-files (>= 4.0.1~), lsb-base (>= 3.0-6), ${misc:Depends} +Replaces: grub-pc (<< 1.96+20080831-1), grub-ieee1275 (<< 1.96+20080831-1), grub-efi (<< 1.96+20080831-1), grub-coreboot (<< 1.96+20080831-1), grub-linuxbios (<< 1.96+20080831-1) +Recommends: os-prober (>= 1.33) +Suggests: multiboot-doc [i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia], grub-emu +# See bugs #435983 and #455746 +Conflicts: mdadm (<< 2.6.7-2), grub-doc (<< 0.97-32), grub-legacy-doc (<< 0.97-59) +Description: GRand Unified Bootloader, version 2 (common files) + This package contains common files shared by the distinct flavours of GRUB. + +Package: grub-emu +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia powerpc sparc +Depends: ${shlibs:Depends}, base-files (>= 4.0.1~), ${misc:Depends} +Replaces: grub-common (<= 1.97~beta3-1) +Description: GRand Unified Bootloader, version 2 (emulated version) + This package contains grub-emu, an emulated version of GRUB. It is only + provided for debugging purposes. + +Package: grub-pc +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia +Depends: ${shlibs:Depends}, ${misc:Depends}, grub-common (= ${binary:Version}), ucf +Replaces: grub, grub-legacy, grub2 (<< ${source:Version}), grub-common (<< 1.97~beta1-1ubuntu4), grub-common (= ${binary:Version}), grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-ieee1275 +Conflicts: grub (<< 0.97-54), grub-legacy, desktop-base (= 4.0.5), grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-ieee1275 +Suggests: desktop-base (>= 4.0.6), genisoimage +Description: GRand Unified Bootloader, version 2 (PC/BIOS version) + GRUB is a portable, powerful bootloader. This version of GRUB is based on a + cleaner design than its predecessors, and provides the following new features: + . + - Scripting in grub.cfg using BASH-like syntax. + - Support for modern partition maps such as GPT. + - Modular generation of grub.cfg via update-grub. Packages providing GRUB + add-ons can plug in their own script rules and trigger updates by invoking + update-grub2. + - VESA-based graphical mode with background image support and complete 24-bit + color set. + - Support for extended charsets. Users can write UTF-8 text to their menu + entries. + . + This package contains a version of GRUB that has been built for use with + traditional PC/BIOS architecture. + +Package: grub-rescue-pc +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia +Depends: base-files (>= 4.0.1~), ${misc:Depends} +Description: GRUB bootable rescue images, version 2 (PC/BIOS version) + This package contains two GRUB rescue images that have been built for use with + traditional PC/BIOS architecture: + . + - grub-rescue-floppy.img: floppy image. + - grub-rescue-cdrom.iso: El Torito CDROM image. + +Package: grub-coreboot +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 +Depends: ${shlibs:Depends}, grub-common (= ${binary:Version}), ${misc:Depends}, ucf +Replaces: grub-legacy, grub2 (<< ${source:Version}), grub-common (<< 1.97~beta1-1ubuntu4), grub-efi-amd64, grub-efi-ia32, grub-pc, grub-ieee1275 +Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-efi-ia32, grub-pc, grub-ieee1275 +Suggests: os-prober +Description: GRand Unified Bootloader, version 2 (Coreboot version) + GRUB is a portable, powerful bootloader. This version of GRUB is based on a + cleaner design than its predecessors, and provides the following new features: + . + - Scripting in grub.cfg using BASH-like syntax. + - Support for modern partition maps such as GPT. + - Modular generation of grub.cfg via update-grub. Packages providing GRUB + add-ons can plug in their own script rules and trigger updates by invoking + update-grub2. + . + This package contains a version of GRUB that has been built for use with + platforms running the Coreboot firmware. + +Package: grub-efi-ia32 +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia +Depends: ${shlibs:Depends}, grub-common (= ${binary:Version}), ${misc:Depends}, ucf +Replaces: grub, grub-legacy, grub2 (<< ${source:Version}), grub-common (<< 1.97~beta1-1ubuntu4), grub-efi, grub-efi-amd64, grub-pc, grub-coreboot, grub-ieee1275 +Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-pc, grub-coreboot, grub-ieee1275 +Suggests: os-prober, efibootmgr +Description: GRand Unified Bootloader, version 2 (EFI-IA32 version) + GRUB is a portable, powerful bootloader. This version of GRUB is based on a + cleaner design than its predecessors, and provides the following new features: + . + - Scripting in grub.cfg using BASH-like syntax. + - Support for modern partition maps such as GPT. + - Modular generation of grub.cfg via update-grub. Packages providing GRUB + add-ons can plug in their own script rules and trigger updates by invoking + update-grub2. + . + This package contains a version of GRUB that has been built for use with + EFI-IA32 architecture, such as the one provided by Intel Macs (that is, unless + a BIOS interface has been activated). + +Package: grub-efi-amd64 +Architecture: i386 kopensolaris-i386 amd64 kfreebsd-amd64 +Depends: ${shlibs:Depends}, grub-common (= ${binary:Version}), ${misc:Depends}, ucf +Replaces: grub, grub-legacy, grub2 (<< ${source:Version}), grub-common (<< 1.97~beta1-1ubuntu4), grub-pc, grub-efi-ia32, grub-coreboot, grub-ieee1275 +Conflicts: grub, grub-legacy, grub-efi-ia32, grub-coreboot, grub-ieee1275 +Suggests: os-prober, efibootmgr +Description: GRand Unified Bootloader, version 2 (EFI-AMD64 version) + GRUB is a portable, powerful bootloader. This version of GRUB is based on a + cleaner design than its predecessors, and provides the following new features: + . + - Scripting in grub.cfg using BASH-like syntax. + - Support for modern partition maps such as GPT. + - Modular generation of grub.cfg via update-grub. Packages providing GRUB + add-ons can plug in their own script rules and trigger updates by invoking + update-grub2. + . + This package contains a version of GRUB that has been built for use with + EFI-AMD64 architecture, such as the one provided by Intel Macs (that is, unless + a BIOS interface has been activated). + +Package: grub-ieee1275 +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia powerpc sparc +Depends: ${shlibs:Depends}, grub-common (= ${binary:Version}), + powerpc-ibm-utils [powerpc], powerpc-utils [powerpc], bc [powerpc], ${misc:Depends}, ucf +Replaces: grub-legacy, grub2 (<< ${source:Version}), grub-common (<< 1.97~beta1-1ubuntu4), grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-pc +Conflicts: grub (<< 0.97-54), grub-legacy, grub-efi-amd64, grub-efi-ia32, grub-coreboot, grub-pc +Suggests: os-prober, genisoimage +Description: GRand Unified Bootloader, version 2 (Open Firmware version) + GRUB is a portable, powerful bootloader. This version of GRUB is based on a + cleaner design than its predecessors, and provides the following new features: + . + - Scripting in grub.cfg using BASH-like syntax. + - Support for modern partition maps such as GPT. + - Modular generation of grub.cfg via update-grub. Packages providing GRUB + add-ons can plug in their own script rules and trigger updates by invoking + update-grub2. + . + This package contains a version of GRUB that has been built for use with + Open Firmware implementations. + +Package: grub-firmware-qemu +Architecture: i386 kfreebsd-i386 hurd-i386 kopensolaris-i386 amd64 kfreebsd-amd64 lpia +Depends: base-files (>= 4.0.1~), ${misc:Depends} +Recommends: qemu +Enhances: qemu +Description: GRUB firmware image for QEMU + This package contains a binary of GRUB that has been built for use as + firmware for QEMU. It can be used as a replacement for the standard + PC BIOS provided by the bochsbios package (bios.bin). + . + In order to make QEMU use this firmware, simply add `-bios grub.bin' when + invoking it. + . + This package behaves in the same way as GRUB for coreboot, but doesn't + contain any code from coreboot itself, and is only suitable for QEMU. If + you want to install GRUB as firmware on real hardware, you need to use the + grub-coreboot package, and manually combine that with coreboot. --- grub2-1.97~beta4.orig/debian/postinst.in +++ grub2-1.97~beta4/debian/postinst.in @@ -0,0 +1,130 @@ +#!/bin/bash -e + +merge_debconf_into_conf() +{ + local tmpfile; tmpfile="$1" + local setting; setting="$2" + local template; template="$3" + + db_get "$template" + local value; value="$(echo "$RET" | sed -e 's,[$`"\],\\&,g; s,[\@],\\&,g')" + if grep -q "^${setting}=" "$tmpfile"; then + sed -i -re "s@^(${setting}=).*@\1\"${value}\"@" "$tmpfile" + else + echo >> "$tmpfile" + echo "${setting}=\"${value}\"" >> "$tmpfile" + fi +} + +case "$1" in + configure) + . /usr/share/debconf/confmodule + + case @PACKAGE@ in + grub-pc) + + if grep -q "[= ]/sbin/update-grub" /etc/kernel-img.conf 2> /dev/null ; then + echo -e "\n/etc/kernel-img.conf still contains /sbin/update-grub in the hooks." >&2 + echo -e "Running sed over it to remove the /sbin/ prefix.\n" >&2 + sed -i /etc/kernel-img.conf -e "s,\(.*\) */sbin/update-grub$,\1 update-grub,g" + fi + mkdir -p /boot/grub + + if test -e /boot/grub/device.map && ! test -e /boot/grub/core.img ; then + # Looks like your device.map was generated by GRUB Legacy, which + # used to generate broken device.map (see #422851). Avoid the risk + # by regenerating it. + grub-mkdevicemap --no-floppy + fi + ;; + esac + + tmp_default_grub="$(mktemp "/tmp/grub.XXXXXXXXXX")" + trap "rm -f ${tmp_default_grub}" EXIT + cp -p /usr/share/grub/default/grub ${tmp_default_grub} + + merge_debconf_into_conf "$tmp_default_grub" GRUB_CMDLINE_LINUX grub2/linux_cmdline + merge_debconf_into_conf "$tmp_default_grub" GRUB_CMDLINE_LINUX_DEFAULT grub2/linux_cmdline_default + + case @PACKAGE@ in + grub-pc) + merge_debconf_into_conf "$tmp_default_grub" GRUB_TIMEOUT grub-pc/timeout + db_get grub-pc/hidden_timeout + if [ "$RET" = false ]; then + sed -i -e 's/^GRUB_HIDDEN_TIMEOUT=/#&/' "$tmp_default_grub" + fi + ;; + esac + + ucf --three-way --debconf-ok --sum-file=/usr/share/grub/default/grub.md5sum ${tmp_default_grub} /etc/default/grub + package="$(ucfq --with-colons /etc/default/grub | cut -d : -f 2)" + if echo $package | grep -q "^grub-" ; then + ucfr --force @PACKAGE@ /etc/default/grub + else + ucfr @PACKAGE@ /etc/default/grub + fi + + case @PACKAGE@ in + grub-pc) + + if test -e /boot/grub/stage2 && test -e /boot/grub/menu.lst && ! test -e /boot/grub/core.img ; then + db_get grub-pc/chainload_from_menu.lst + if $RET ; then + # Create core.img (but do not risk writing to MBR). + echo "Generating core.img" >&2 + grub-install --no-floppy --grub-setup=/bin/true "(hd0)" > /dev/null + + # Update menu.lst to reflect that: + # - core.img is present now + # - core.img has to be the first option + echo "Saving menu.lst backup in /boot/grub/menu.lst_backup_by_grub2_postinst" >&2 + cp /boot/grub/menu.lst{,_backup_by_grub2_postinst} + echo "Running update-grub Legacy to hook our core.img in it" >&2 + LET_US_TRY_GRUB_2=true /usr/lib/grub-legacy/update-grub 2>&1 | sed -e "s/^/ /g" >&2 + # We just hooked GRUB 2 in menu.lst; then also generate grub.cfg. + touch /boot/grub/grub.cfg + fi + else + db_subst grub-pc/install_devices CHOICES `grub-mkdevicemap -m - | sed -e "/^(fd[0-9]\+)/d;s,.*\t,,g" | tr '\n' ',' | sed -e 's/,$//g;s/,/, /g'` + db_input high grub-pc/install_devices || true + db_go + db_get grub-pc/install_devices + for i in `echo $RET | sed -e 's/,/ /g'` ; do + if grub-install --no-floppy $i ; then + # We just installed GRUB 2; then also generate grub.cfg. + touch /boot/grub/grub.cfg + fi + done + fi + + # /boot/grub/ has more chances of being accessible by GRUB + if test -e /boot/grub/grub.cfg ; then + for i in /usr/share/grub/unicode.pf2 /usr/share/images/desktop-base/moreblue-orbit-grub.png ; do + if test -e $i ; then + cp $i /boot/grub/ + fi + done + fi + + ;; + esac + + # If grub.cfg has been generated, update it. + if test -e /boot/grub/grub.cfg ; then + update-grub + fi + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 --- grub2-1.97~beta4.orig/debian/grub-common.preinst +++ grub2-1.97~beta4/debian/grub-common.preinst @@ -0,0 +1,31 @@ +#!/bin/bash -e + +case "$1" in + install|upgrade) + + if [ -n "$2" ] && dpkg --compare-versions $2 lt 1.96+20090521-1 ; then + if [ -f /etc/grub.d/10_hurd ] && [[ `dpkg --print-architecture` != hurd-* ]] ; then + rm /etc/grub.d/10_hurd + fi + if [ -f /etc/grub.d/10_freebsd ] && [[ `dpkg --print-architecture` != kfreebsd-* ]] ; then + rm /etc/grub.d/10_freebsd + fi + if [ -f /etc/grub.d/10_linux ] && ( [[ `dpkg --print-architecture` = hurd-* ]] || [[ `dpkg --print-architecture` = kfreebsd-* ]] ) ; then + rm /etc/grub.d/10_linux + fi + fi + ;; + abort-upgrade) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 --- grub2-1.97~beta4.orig/debian/grub-common.dirs +++ grub2-1.97~beta4/debian/grub-common.dirs @@ -0,0 +1,2 @@ +usr/sbin +etc/pm/sleep.d --- grub2-1.97~beta4.orig/debian/grub-firmware-qemu.dirs +++ grub2-1.97~beta4/debian/grub-firmware-qemu.dirs @@ -0,0 +1 @@ +usr/share/qemu --- grub2-1.97~beta4.orig/debian/examples.in +++ grub2-1.97~beta4/debian/examples.in @@ -0,0 +1 @@ +docs/grub.cfg --- grub2-1.97~beta4.orig/debian/update-grub.8 +++ grub2-1.97~beta4/debian/update-grub.8 @@ -0,0 +1,14 @@ +.\" Copyright 2009 Felix Zielcke +.\" Lincensed under GPL3+ +.TH UPDATE-GRUB "8" "April 2009" +.SH NAME +update-grub \- stub for grub-mkconfig +.SH SYNOPSIS +.B update-grub +.SH DESCRIPTION +.B update-grub +is a stub for running +.B grub-mkconfig -o /boot/grub/grub.cfg +to generate a grub2 config file. +.SH "SEE ALSO" +.BR grub-mkconfig (8) --- grub2-1.97~beta4.orig/debian/grub-pc.dirs.in +++ grub2-1.97~beta4/debian/grub-pc.dirs.in @@ -0,0 +1 @@ +usr/lib/grub-legacy --- grub2-1.97~beta4.orig/debian/grub-pc.templates.in +++ grub2-1.97~beta4/debian/grub-pc.templates.in @@ -0,0 +1,65 @@ + +# This file is concatenated. Do not delete the newline above. + +Template: grub-pc/chainload_from_menu.lst +Type: boolean +Default: true +_Description: Chainload from menu.lst? + GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub. + . + In order to replace the Legacy version of GRUB in your system, it is + recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 + from your existing GRUB Legacy setup. This step may be automaticaly + performed now. + . + It's recommended that you accept chainloading GRUB 2 from menu.lst, and + verify that your new GRUB 2 setup is functional for you, before you install + it directly to your MBR (Master Boot Record). + . + In either case, whenever you want GRUB 2 to be loaded directly from MBR, + you can do so by issuing (as root) the following command: + . + upgrade-from-grub-legacy + +Template: grub-pc/install_devices +Type: multiselect +Choices: ${CHOICES} +# Intentionally not marked for translations yet; will do after a review period +Description: GRUB install devices: + The grub-pc package is being upgraded. This menu allows you to select which + devices you'd like grub-install to be automatically run for, if any. + . + It is recommended that you do this in most situations, to prevent the installed + GRUB from getting out of sync with other components such as grub.cfg or with + newer Linux images it will have to load. + . + If you're unsure which drive is designated as boot drive by your BIOS, it is + often a good idea to install GRUB to all of them. + . + Note: It is possible to install GRUB to partition boot records as well. + However, this forces GRUB to use the blocklist mechanism, which makes it + less reliable, and therefore is not recommended. + +Template: grub-pc/postrm_purge_boot_grub +Type: boolean +Default: false +# This should get reviewed before it can be translated +Description: Remove GRUB 2 from /boot/grub? + Do you want to have all GRUB 2 files removed from /boot/grub? + . + Your system would be then unbootable if you don't install another bootloader. + +Template: grub-pc/kopt_extracted +Type: boolean +Default: false +Description: for internal use + +Template: grub-pc/timeout +Type: string +Default: 10 +Description: GRUB timeout + +Template: grub-pc/hidden_timeout +Type: boolean +Default: true +Description: Hide the GRUB timeout --- grub2-1.97~beta4.orig/debian/copyright +++ grub2-1.97~beta4/debian/copyright @@ -0,0 +1,24 @@ +Name: GNU GRUB +Source: http://www.gnu.org/software/grub/grub-2.en.html + +Files: * +Copyright: 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc +License: GPL-3+ + +Files: debian/* +Copyright: 2003, 2004, 2005, 2006, 2007, 2008, 2009, Robert Millan + 2005, 2006, 2007, Otavio Salvador + 2008, 2009, Felix Zielcke + 2009, Jordi Mallach +License: GPL-3+ + +Files: debian/grub-extras/* +Copyright: Nathan Coulson + 2003, 2007 Free Software Foundation, Inc + 2003 NIIBE Yutaka +License: GPL-3+ + +License: GPL-3+ + On Debian systems the full text of the GNU General Public + License can be found in the `/usr/share/common-licenses/GPL' + file. --- grub2-1.97~beta4.orig/debian/grub-common.install +++ grub2-1.97~beta4/debian/grub-common.install @@ -0,0 +1 @@ +debian/presubj usr/share/bug/grub-common --- grub2-1.97~beta4.orig/debian/manpages.in +++ grub2-1.97~beta4/debian/manpages.in @@ -0,0 +1,3 @@ +debian/update-grub.8 +debian/update-grub2.8 + --- grub2-1.97~beta4.orig/debian/script +++ grub2-1.97~beta4/debian/script @@ -0,0 +1,30 @@ +#!/bin/bash -e + +if test -e /boot/grub/setup_left_core_image_in_filesystem ; then + echo -e "\n*********************** WARNING grub-setup left core.img in filesystem" >&3 +fi + +for i in /proc/mounts ; do + if test -e $i ; then + echo -e "\n*********************** BEGIN $i" >&3 + grep ^/dev/ $i >&3 + echo "*********************** END $i" >&3 + fi +done + +for i in /boot/grub/{device.map,grub.cfg} ; do + if ! test -e $i ; then + continue + fi + echo -e "\n*********************** BEGIN $i" >&3 + if test -r $i ; then + sed $i -e "s/.*password.*/### PASSWORD LINE REMOVED ###/g" >&3 + else + echo "$i is not readable by you. Please enter your root password." + echo "Any password line in it gets removed." + su root -c "sed $i -e 's/.*password.*/### PASSWORD LINE REMOVED ###/g'" >&3 + fi + echo "*********************** END $i" >&3 +done + +exit 0 --- grub2-1.97~beta4.orig/debian/grub-rescue-pc.dirs +++ grub2-1.97~beta4/debian/grub-rescue-pc.dirs @@ -0,0 +1 @@ +usr/lib/grub-rescue --- grub2-1.97~beta4.orig/debian/templates.in +++ grub2-1.97~beta4/debian/templates.in @@ -0,0 +1,29 @@ +Template: grub2/linux_cmdline +Type: string +_Description: Linux command line: + The following Linux command line was extracted from /etc/default/grub or the + `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is correct, + and modify it if necessary. + +Template: grub2/linux_cmdline_default +Type: string +Default: quiet splash +_Description: Linux default command line: + The following string will be used as Linux parameters for the default menu + entry but not for the recovery mode. + +# still unused +Template: grub2/kfreebsd_cmdline +Type: string +_Description: kFreeBSD command line: + The following kFreeBSD command line was extracted from /etc/default/grub or the + `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is correct, + and modify it if necessary. + +# still unused +Template: grub2/kfreebsd_cmdline_default +Type: string +Default: quiet +_Description: kFreeBSD default command line: + The following string will be used as kFreeBSD parameters for the default menu + entry but not for the recovery mode. --- grub2-1.97~beta4.orig/debian/dirs.in +++ grub2-1.97~beta4/debian/dirs.in @@ -0,0 +1,4 @@ +usr/bin +usr/sbin +usr/share/grub +usr/share/bug/@PACKAGE@ --- grub2-1.97~beta4.orig/debian/update-grub2 +++ grub2-1.97~beta4/debian/update-grub2 @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec update-grub "$@" --- grub2-1.97~beta4.orig/debian/NEWS +++ grub2-1.97~beta4/debian/NEWS @@ -0,0 +1,12 @@ +grub2 (1.96+20090609-1) experimental; urgency=low + + Before this version, grub-efi was 32bit on i386 and 64bit on amd64. + However, EFI can be 32bit even if you have a 64bit CPU, like in the + first MacBook models with Core 2 Duo released in late 2006. Thus, + grub-efi has been split into grub-efi-amd64 and grub-efi-ia32 which are + available on both amd64 and i386. + + If you've experienced problems trying to load grub.efi, please try + again using the package that doesn't match your CPU's architecture. + + -- Felix Zielcke Tue, 09 Jun 2009 19:21:15 +0200 --- grub2-1.97~beta4.orig/debian/update-grub +++ grub2-1.97~beta4/debian/update-grub @@ -0,0 +1,2 @@ +#!/bin/sh -e +exec grub-mkconfig -o /boot/grub/grub.cfg "$@" --- grub2-1.97~beta4.orig/debian/postrm.in +++ grub2-1.97~beta4/debian/postrm.in @@ -0,0 +1,45 @@ +#!/bin/bash -e + +case "$1" in + purge) + rm -f /etc/default/grub + + if which ucf >/dev/null ; then + ucf --purge /etc/default/grub + fi + if which ucfr >/dev/null ; then + ucfr --purge @PACKAGE@ /etc/default/grub + fi + + case @PACKAGE@ in + grub-pc) + # debconf could have been purged + if [ -e /usr/share/debconf/confmodule ] ; then + . /usr/share/debconf/confmodule + fi + + db_input high grub-pc/postrm_purge_boot_grub || true + db_go || true + db_get grub-pc/purge_boot_grub || true + if [ "$RET" = "true" ] ; then + rm -f /boot/grub/{grub.cfg,ascii.pf2,unicode.pf2,moreblue-orbit-grub.png,*.mod,*.lst,*.img,efiemu32.o,efiemu64.o} || true + rmdir --ignore-fail-on-non-empty /boot/grub || true + fi + ;; + esac + + ;; + remove|upgrade|failed-upgrade|abort-upgrade|abort-install) + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 --- grub2-1.97~beta4.orig/debian/grub-pc.prerm +++ grub2-1.97~beta4/debian/grub-pc.prerm @@ -0,0 +1,27 @@ +#!/bin/bash -e + +case "$1" in + remove|deconfigure) + . /usr/share/debconf/confmodule + db_get grub-pc/chainload_from_menu.lst + if $RET && test -e /boot/grub/menu.lst ; then + echo "Saving menu.lst backup in /boot/grub/menu.lst_backup_by_grub2_prerm" >&2 + cp /boot/grub/menu.lst{,_backup_by_grub2_prerm} + echo "Running update-grub Legacy to remove our core.img in it" >&2 + /usr/lib/grub-legacy/update-grub 2>&1 | sed -e "s/^/ /g" >&2 + fi + ;; + failed-upgrade|upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 --- grub2-1.97~beta4.orig/debian/changelog +++ grub2-1.97~beta4/debian/changelog @@ -0,0 +1,2355 @@ +grub2 (1.97~beta4-1ubuntu4.1) karmic-security; urgency=low + + * SECURITY UPDATE: fix password validation when using password-based + authentication + - debian/patches/970_security_fix_password_validation.diff: update + grub_auth_strcmp() to use grub_strcmp() and add a small added delay. + Also update grub_auth_check_authentication() to add a delay if + authentication does not succeed. + - CVE-2009-4128 + + -- Jamie Strandboge Mon, 07 Dec 2009 14:15:58 -0600 + +grub2 (1.97~beta4-1ubuntu4) karmic-proposed; urgency=low + + * New patch, 969_os_prober_separate_boot, fixes wrong kernel/initrd + pathnames and wrong partition UUID/GRUB path when generating menuentries + from os-prober output of a detected system with a separate /boot; thanks + Colin Watson; LP: #462961. + + -- Loïc Minier Thu, 29 Oct 2009 02:30:35 +0000 + +grub2 (1.97~beta4-1ubuntu3) karmic; urgency=low + + * Backport from Debian (Felix Zielcke): + - Add a build dependency on texinfo (LP: #453442). + * debian/patches/968_raid_virtio.diff: Handle RAID devices containing + virtio components (LP: #457687). + + -- Colin Watson Fri, 23 Oct 2009 21:58:13 +0100 + +grub2 (1.97~beta4-1ubuntu2) karmic; urgency=low + + * debian/patches/967_no_mmx_sse.diff: Build with -mno-mmx -mno-sse + -mno-sse2 on i386/lpia, since otherwise lpia is unbootable (LP: + #444562). + + -- Colin Watson Fri, 16 Oct 2009 16:31:12 +0100 + +grub2 (1.97~beta4-1ubuntu1) karmic; urgency=low + + * Resynchronise with Debian. Remaining changes: + + debian/default/grub: + - Adjust for default Ubuntu boot options. + - Use GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + - Default to hiding the menu; holding down Shift at boot will show it. + + debian/templates.in: + - Change default value of grub2/linux_cmdline_default to "quiet + splash". + + debian/config.in, debian/postinst.in, debian/grub-pc.templates.in: + - Migrate timeout settings from menu.lst. + + debian/grub.d/05_debian_theme: + - Set a monochromatic theme for Ubuntu. + + debian/legacy/update-grub: + - Apply Ubuntu branding: title, recovery mode, quiet option, and tweak + how memtest86+ is displayed. + - Use UUIDs where appropriate. + + debian/control: + - Conflict with grub (<< 0.97-54) as well as grub-legacy. + + debian/patches/03_ubuntu_grub_standards: + - Remove GNU/Linux from default string. + + debian/patches/10_crashkernel.patch: + - Add crashkernel= options if kdump and makedumpfile are available. + + debian/patches/951_quick_boot.diff: + - If other operating systems are installed, then automatically unhide + the menu. + - Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus if + available to check whether Shift is pressed. If it is, show the + menu, otherwise boot immediately. If keystatus is not available, + then fall back to a short delay interruptible with Escape. + + debian/patches/952_sleep_shift.diff: + - Allow Shift to interrupt 'sleep --interruptible'. + + debian/patches/954_normal_quiet.diff: + - Don't display introductory message about line editing unless we're + actually offering a shell prompt. Don't clear the screen just before + booting if we never drew the menu in the first place. + + debian/patches/955_really_quiet.diff: + - Remove some verbose messages printed before reading the + configuration file. + + debian/patches/956_linux_quiet.diff: + - If the environment variable "quiet" is set to something other than + 0, suppress progress messages as the kernel and initrd load. Set + this for non-recovery kernel menu entries. + + debian/patches/957_savedefault.diff, debian/rules: + - Add GRUB_DEFAULT=saved, as well as grub-set-default and grub-reboot + utilities. Provides functionality essentially equivalent to GRUB + Legacy's savedefault. + + debian/patches/959_loopback_root.diff: + - Keep the loopback file open so that subsequent changes to the "root" + environment variable don't affect it. + + debian/patches/961_handle_loopback.diff: + - Change prepare_grub_to_access_device to handle filesystems + loop-mounted on file images. + + debian/patches/963_linux_no_loopmount.diff: + - Ignore devices loop-mounted from files in 10_linux. + + debian/patches/965_failed_boot_menu.diff, debian/grub-common.init, + debian/rules: + - Show the boot menu if the previous boot failed, that is if it failed + to get to the end of one of the normal runlevels. + * debian/patches/957_savedefault.diff, + debian/patches/965_failed_boot_menu.diff: Silently ignore zero-sized + environment blocks (thanks, Felix Zielcke; LP: #439784). + * debian/grub-common.pm-sleep, debian/grub-common.dirs, debian/rules: + Record a successful boot on resume from hibernate (thanks, Maxim + Levitsky; LP: #447725). + * debian/postinst.in: Fix backslash-escaping in merge_debconf_into_conf + (LP: #448413). + * debian/patches/966_mkconfig_probe_option.diff: Backport upstream patch + to make the grub-install --grub-probe option work, which is useful for + vm-builder. + + -- Colin Watson Wed, 14 Oct 2009 12:07:42 +0100 + +grub2 (1.97~beta4-1) unstable; urgency=low + + * New upstream beta release. + + [ Felix Zielcke ] + * Change the Recommends: os-prober to (>= 1.33). + * patches/907_grub.cfg_400.diff: Really add it. Somehow it was a 0 byte file. + (Closes: #547409) + * Convert newlines back to spaces when parsing kopt from + GRUB Legacy's menu.lst, before giving the value to Debconf. + Thanks to Colin Watson. (Closes: #547649) + * Ship the info docs in grub-common. (Closes: #484074) + * Remove generated /usr/share/info/dir* files. + * Update the presubj bug file and also install it for grub-common. + + [ Robert Millan ] + * Enable ZFS and 915resolution in grub-extras (now requires explicit + switch). + * grub-common conflicts with grub-doc (<< 0.97-32) and grub-legacy-doc + (<< 0.97-59). + * Move grub-emu to a separate package. + + [ Updated translations ] + * Japanese (ja.po) by Hideki Yamane. (Closes: #549599) + + -- Robert Millan Mon, 05 Oct 2009 20:03:04 +0200 + +grub2 (1.97~beta3-1ubuntu8) karmic; urgency=low + + [ Colin Watson ] + * debian/control: Conflict with grub (<< 0.97-54) as well as grub-legacy + (see LP #410886). + * debian/grub-common.init: Create /boot/grub if it doesn't exist, to avoid + noise on fresh installations. + + [ Tormod Volden ] + * debian/grub-common.init: do not call log_end_msg if not VERBOSE + (LP: #440879) + + -- Colin Watson Tue, 06 Oct 2009 23:32:54 +0100 + +grub2 (1.97~beta3-1ubuntu7) karmic; urgency=low + + * debian/grub-common.init: /boot/grub/grubenv sometimes seems to end up + zero-sized for some reason. If it is, just delete it (LP: #439784). + + -- Colin Watson Sun, 04 Oct 2009 21:52:10 +0100 + +grub2 (1.97~beta3-1ubuntu6) karmic; urgency=low + + * debian/patches/965_failed_boot_menu.diff, debian/grub-common.init, + debian/rules: Show the boot menu if the previous boot failed, that is if + it failed to get to the end of one of the normal runlevels. + + -- Colin Watson Mon, 28 Sep 2009 09:29:34 +0100 + +grub2 (1.97~beta3-1ubuntu5) karmic; urgency=low + + * debian/patches/957_savedefault.diff: Quote the value assigned to + 'default', in case it contains spaces (LP: #431179). + * debian/patches/964_os-prober_errors.diff: Don't throw away errors from + os-prober; it makes things hard to debug. + + -- Colin Watson Fri, 18 Sep 2009 18:47:06 +0100 + +grub2 (1.97~beta3-1ubuntu4) karmic; urgency=low + + * debian/patches/963_linux_no_loopmount.diff: Ignore devices loop-mounted + from files in 10_linux. + + -- Colin Watson Wed, 16 Sep 2009 17:46:10 +0100 + +grub2 (1.97~beta3-1ubuntu3) karmic; urgency=low + + * debian/patches/962_os-prober_windows_7.diff: Cope with Windows 7 in + os-prober output. + + -- Colin Watson Tue, 15 Sep 2009 06:48:13 +0100 + +grub2 (1.97~beta3-1ubuntu2) karmic; urgency=low + + * debian/config.in: Fix logic if GRUB_HIDDEN_TIMEOUT is entirely missing + from /etc/default/grub. + * debian/patches/961_handle_loopback.diff: Change + prepare_grub_to_access_device to handle filesystems loop-mounted on file + images. + + -- Colin Watson Tue, 15 Sep 2009 00:34:11 +0100 + +grub2 (1.97~beta3-1ubuntu1) karmic; urgency=low + + * Resynchronise with Debian. Remaining changes: + + debian/default/grub: + - Adjust for default Ubuntu boot options. + - Use GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + - Default to hiding the menu; holding down Shift at boot will show it. + + debian/templates.in: + - Change default value of grub2/linux_cmdline_default to "quiet + splash". + + debian/config.in, debian/postinst.in, debian/grub-pc.templates.in: + - Migrate timeout settings from menu.lst. + + debian/grub.d/05_debian_theme: + - Set a monochromatic theme for Ubuntu. + + debian/legacy/update-grub: + - Apply Ubuntu branding: title, recovery mode, quiet option, and tweak + how memtest86+ is displayed. + - Use UUIDs where appropriate. + + debian/patches/03_ubuntu_grub_standards: + - Remove GNU/Linux from default string. + + debian/patches/10_crashkernel.patch: + - Add crashkernel= options if kdump and makedumpfile are available. + + debian/patches/951_quick_boot.diff: + - If other operating systems are installed, then automatically unhide + the menu. + - Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus if + available to check whether Shift is pressed. If it is, show the + menu, otherwise boot immediately. If keystatus is not available, + then fall back to a short delay interruptible with Escape. + + debian/patches/952_sleep_shift.diff: + - Allow Shift to interrupt 'sleep --interruptible'. + + debian/patches/954_normal_quiet.diff: + - Don't display introductory message about line editing unless we're + actually offering a shell prompt. Don't clear the screen just before + booting if we never drew the menu in the first place. + + debian/patches/955_really_quiet.diff: + - Remove some verbose messages printed before reading the + configuration file. + + debian/patches/956_linux_quiet.diff: + - If the environment variable "quiet" is set to something other than + 0, suppress progress messages as the kernel and initrd load. Set + this for non-recovery kernel menu entries. + + debian/patches/957_savedefault.diff, debian/rules: + - Add GRUB_DEFAULT=saved, as well as grub-set-default and grub-reboot + utilities. Provides functionality essentially equivalent to GRUB + Legacy's savedefault. + + debian/patches/959_loopback_root.diff: + - Keep the loopback file open so that subsequent changes to the "root" + environment variable don't affect it. + * debian/patches/960_test_invalid_fs.diff: Fix test crash if loopback + device does not contain a filesystem. + + -- Colin Watson Mon, 14 Sep 2009 10:52:59 +0100 + +grub2 (1.97~beta3-1) unstable; urgency=high + + * New upstream beta release. + - Make it more clear how to use /etc/grub.d/40_custom. (Closes: #545153) + - fix a serious memory corruption in the graphical subsystem. + (Closes: #545364, #544155, #544639, #544822, LP: #424503) + - patches/003_grub_probe_segfault.diff: Remove (merged). + + * Change the watch file so upstream beta releases are recognized. + * Include /etc/default/grub in bug reports. + * Recommend os-prober (>= 1.32). (Closes: #491872) + * Change the gcc-multilib [sparc] build dependency to gcc-4.4-multilib + [sparc]. + * patches/907_grub.cfg_400.diff: New patch to make grub.cfg again mode + 444 if it does not contain a password line. + * Use `su' in the bug reporting script to read grub.cfg in case the user + is not allowed to read it. + * Readd grub-pc/kopt-extracted template. + + [ Updated translations ] + * Brazilian Portuguese (pt_BR.po) by Flamarion Jorge. + * Japanese (ja.po) by Hideki Yamane. (Closes: #545331) + * Spanish (es.po) by Francisco Javier Cuadrado. (Closes: #545566) + * Italian (it.po) by Luca Monducci. (Closes: #546035) + + -- Felix Zielcke Sat, 12 Sep 2009 15:28:20 +0200 + +grub2 (1.97~beta2-2ubuntu2) karmic; urgency=low + + * debian/patches/951_quick_boot.diff: Only do the hidden-timeout checks if + timeout is not already set to -1 (i.e. show menu, no timeout). + * debian/patches/954_normal_quiet.diff: Don't clear the screen just before + booting if we never drew the menu in the first place. + * debian/patches/955_really_quiet.diff: Remove "Booting" message; it turns + out to be hard to suppress any other way. + * debian/patches/956_linux_quiet.diff: Don't try to suppress "Booting" + based on the value of "quiet", as the menu entry commands aren't run + until after this message. + * debian/patches/958_ntfs_64bit.diff: Handle 64-bit file sizes in NTFS. + * debian/patches/959_loopback_root.diff: Keep the loopback file open so + that subsequent changes to the "root" environment variable don't affect + it. + * debian/config.in, debian/postinst.in, debian/grub-pc.templates.in: + Migrate timeout settings from menu.lst (LP: #386789). + * debian/grub-pc.templates.in: Add grub-pc/kopt_extracted template. + + -- Colin Watson Fri, 11 Sep 2009 15:40:38 +0100 + +grub2 (1.97~beta2-2ubuntu1) karmic; urgency=low + + * Resynchronise with Debian. Remaining changes: + + debian/control: + - Recommend rather than Suggest os-prober. + + debian/default/grub: + - Adjust for default Ubuntu boot options. + - Use GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + - Default to hiding the menu; holding down Shift at boot will show it. + + debian/templates.in: + - Change default value of grub2/linux_cmdline_default to "quiet + splash". + + debian/grub.d/05_debian_theme: + - Set a monochromatic theme for Ubuntu. + + debian/legacy/update-grub: + - Apply Ubuntu branding: title, recovery mode, quiet option, and tweak + how memtest86+ is displayed. + - Use UUIDs where appropriate. + + debian/patches/03_ubuntu_grub_standards: + - Remove GNU/Linux from default string. + + debian/patches/10_crashkernel.patch: + - Add crashkernel= options if kdump and makedumpfile are available. + + debian/patches/951_quick_boot.diff: + - If other operating systems are installed, then automatically unhide + the menu. + - Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus if + available to check whether Shift is pressed. If it is, show the + menu, otherwise boot immediately. If keystatus is not available, + then fall back to a short delay interruptible with Escape. + + debian/patches/952_sleep_shift.diff: + - Allow Shift to interrupt 'sleep --interruptible'. + + debian/patches/954_normal_quiet.diff: + - Don't display introductory message about line editing unless we're + actually offering a shell prompt. + + debian/patches/955_really_quiet.diff: + - Remove some verbose messages printed before reading the + configuration file. + + debian/patches/956_linux_quiet.diff: + - If the environment variable "quiet" is set to something other than + 0, suppress progress messages as the kernel and initrd load. Set + this for non-recovery kernel menu entries. + + debian/patches/957_savedefault.diff, debian/rules: + - Add GRUB_DEFAULT=saved, as well as grub-set-default and grub-reboot + utilities. Provides functionality essentially equivalent to GRUB + Legacy's savedefault. + * Drop 953_no_eh_frame.diff, merged upstream. + + -- Colin Watson Mon, 07 Sep 2009 13:33:12 +0100 + +grub2 (1.97~beta2-2) unstable; urgency=low + + [ Updated translations ] + * Dutch (nl.po) by Paul Gevers. (Closes: #545050) + + [ Felix Zielcke ] + * Move GRUB Legacy's grub-set-default to /usr/lib/grub-legacy in + preparation for GRUB 2's grub-set-default. + * Remove password lines in bug script. + + [ Robert Millan ] + * Do not conflict with `grub' dummy package (this prevented upgrades). + * patches/003_grub_probe_segfault.diff: Disable file test codepath, which + wasn't normally used before. + + -- Felix Zielcke Sat, 05 Sep 2009 00:27:22 +0200 + +grub2 (1.97~beta2-1) unstable; urgency=low + + * New upstream beta release. + - Fix loading of FreeBSD modules. (Closes: #544305) + + [ Updated translations ] + * French (fr.po) by Christian Perrier. (Closes: #544320) + * Czech (cs.po) by Miroslav Kure. (Closes: #544327) + * Belarusian (be.po) by Hleb Rubanau. + * Arabic (ar.po) by Ossama M. Khayat. + * Catalan (ca.po) by Juan Andrés Gimeno Crespo. + * Russian (ru.po) by Yuri Kozlov. (Closes: #544730) + * Swedish (sv.po) by Martin Ågren. (Closes: #544759) + * Brazilian Portuguese (pt_BR.po) by Flamarion Jorge. (Closes: #544810) + * German (de.po) by Helge Kreutzmann. (Closes: #544912) + + [ Robert Millan ] + * Build with GCC 4.4. + + -- Robert Millan Fri, 04 Sep 2009 14:40:20 +0200 + +grub2 (1.97~beta1-1ubuntu4) karmic; urgency=low + + * Move grub-reboot and grub-set-default to grub-$platform, since + grub-common is also used by GRUB Legacy (LP: #424425). + + -- Colin Watson Fri, 04 Sep 2009 17:54:10 +0100 + +grub2 (1.97~beta1-1ubuntu3) karmic; urgency=low + + * Restore legacy version of grub-set-default, now moved to + /usr/lib/grub-legacy. + + -- Colin Watson Fri, 04 Sep 2009 15:35:19 +0100 + +grub2 (1.97~beta1-1ubuntu2) karmic; urgency=low + + * debian/patches/953_no_eh_frame.diff: Build with -fno-dwarf2-cfi-asm to + stop gcc-4.4 generating .eh_frame sections that cause core.img to be too + big to embed in some common cases (LP: #423412). + * debian/patches/954_normal_quiet.diff: Don't display introductory message + about line editing unless we're actually offering a shell prompt. + * debian/patches/955_really_quiet.diff: Remove some verbose messages + printed before reading the configuration file. In some ways this is + awkward because it makes debugging harder, but it's a requirement for a + smooth-looking boot process; we may be able to do better in future (LP: + #386922). + * debian/patches/956_linux_quiet.diff: If the environment variable "quiet" + is set to something other than 0, suppress progress messages as the + kernel and initrd load. Set this for non-recovery kernel menu entries + (LP: #386922). + * debian/patches/957_savedefault.diff: Add GRUB_DEFAULT=saved, as well as + grub-set-default and grub-reboot utilities. Provides functionality + essentially equivalent to GRUB Legacy's savedefault (LP: #216178). + * debian/rules, debian/grub-pc.install.in: Install grub-reboot and + grub-set-default only in grub-common. + * Add tag information to old Ubuntu patches. + + -- Colin Watson Fri, 04 Sep 2009 15:02:36 +0100 + +grub2 (1.97~beta1-1ubuntu1) karmic; urgency=low + + * Resynchronise with Debian. Remaining changes: + + debian/control: + - Recommend rather than Suggest os-prober. + + debian/default/grub: + - Adjust for default Ubuntu boot options. + - Use GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + - Default to hiding the menu; holding down Shift at boot will show it. + + debian/templates.in: + - Change default value of grub2/linux_cmdline_default to "quiet + splash". + + debian/grub.d/05_debian_theme: + - Set a monochromatic theme for Ubuntu. + + debian/legacy/update-grub: + - Apply Ubuntu branding: title, recovery mode, quiet option, and tweak + how memtest86+ is displayed. + - Use UUIDs where appropriate. + + debian/patches/03_ubuntu_grub_standards: + - Remove GNU/Linux from default string. + + debian/patches/10_crashkernel.patch: + - Add crashkernel= options if kdump and makedumpfile are available. + + debian/patches/951_quick_boot.diff: + - If other operating systems are installed, then automatically unhide + the menu. + - Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus if + available to check whether Shift is pressed. If it is, show the + menu, otherwise boot immediately. If keystatus is not available, + then fall back to a short delay interruptible with Escape. + + debian/patches/952_sleep_shift.diff: + - Allow Shift to interrupt 'sleep --interruptible'. + * Drop 950_getkeystatus.diff, merged upstream. + + -- Colin Watson Tue, 01 Sep 2009 17:37:19 +0100 + +grub2 (1.97~beta1-1) unstable; urgency=low + + * New upstream beta release. + + [ Updated translations ] + * German (de.po) by Helge Kreutzmann. (Closes: #544261) + * Asturian (ast.po) by Marcos. + * Georgian (ka.po) by Aiet Kolkhi. + + [ Robert Millan ] + * Merge config, templates, postinst, postrm, dirs and install files + into a single source. + * Disable Linux-specific strings on GNU/kFreeBSD. Enable translations + in grub2/linux_cmdline_default. Add grub2/kfreebsd_* strings (still + unused). + + -- Felix Zielcke Sun, 30 Aug 2009 18:01:40 +0200 + +grub2 (1.96+20090829-1) unstable; urgency=low + + * New SVN snapshot. + - Fix filesystem mapping on GNU/kFreeBSD. (Closes: #543950) + + * New grub-extras SVN snapshot. + - Add 915resolution support to the GMA500 (poulsbo) graphics chipset. + Thanks to Pedro Bulach Gapski. (Closes: #543917) + + * Use `cp -p' to copy /usr/share/grub/default/grub to the temporary + file to preverse permissions. + * Remove also efiemu files from /boot/grub on purge if requested. + * Check that GRUB_CMDLINE_LINUX and GRUB_CMDLINUX_LINUX_DEFAULT is at + the start of line in *.postinst. + * Don't check that $GRUB_CMDLINE_LINUX{,DEFAULT} are non empty strings + in *.config. + * Add empty GRUB_CMDLINE_LINUX to /usr/share/grub/default/grub. + * Factorise the editing of the temporary file. Thanks to Martin F + Krafft. + * Read in /etc/default/grub in *.config files. + + [ Updated translations ] + * French (fr.po) by Christian Perrier. (Closes: #544023) + * Russian (ru.po) by Yuri Kozlov. (Closes: #544077) + * Italian (it.po) by Luca Monducci. (Closes: #544200) + + -- Felix Zielcke Sat, 29 Aug 2009 17:01:17 +0200 + +grub2 (1.96+20090826-3ubuntu3) karmic; urgency=low + + * 951_quick_boot.diff: Always initialise timeout from GRUB_TIMEOUT, + otherwise there'll be no timeout when other operating systems are + installed. + + -- Colin Watson Thu, 27 Aug 2009 14:13:03 +0100 + +grub2 (1.96+20090826-3ubuntu2) karmic; urgency=low + + * 952_sleep_shift.patch: New patch. Allow Shift to interrupt 'sleep + --interruptible', for consistency with the quick-boot scheme. + * debian/*.templates: Change default value of grub2/linux_cmdline_default + to 'quiet splash', to match debian/default/grub. + + -- Colin Watson Thu, 27 Aug 2009 11:29:24 +0100 + +grub2 (1.96+20090826-3ubuntu1) karmic; urgency=low + + * Resynchronise with Debian (LP: #413151). Remaining changes: + + debian/control: + - Recommend rather than Suggest os-prober. + + debian/default/grub: + - Adjust for default Ubuntu boot options. + - Use GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + - Default to hiding the menu with a three-second timeout. Pressing + Escape during this time will show the menu. + + debian/grub.d/05_debian_theme: + - Set a monochromatic theme for Ubuntu. + + debian/legacy/update-grub: + - Apply Ubuntu branding: title, recovery mode, quiet option, and tweak + how memtest86+ is displayed. + - Use UUIDs where appropriate. + + debian/patches/03_ubuntu_grub_standards: + - Remove GNU/Linux from default string. + + debian/patches/10_crashkernel.patch: + - add crashkernel= options if kdump and makedumpfile + is available (part of the kernel-crashdump spec) + * Drop 950_hidden_timeout.diff, merged upstream. + * Drop 951_gfxpayload_keep.diff. It doesn't make as much sense as I + thought, and it needs better kernel support anyway. + * 950_getkeystatus.diff: New patch. Add getkeystatus terminal method, and + add a new keystatus command to query it. + * 951_quick_boot.diff: New patch: + - If other operating systems are installed, then automatically unhide + the menu (LP: #411584). + - Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus if + available to check whether Shift is pressed. If it is, show the menu, + otherwise boot immediately. If keystatus is not available, then fall + back to a short delay interruptible with Escape. + * debian/default/grub: Adjust defaults to match new quick-boot code. + + -- Colin Watson Thu, 27 Aug 2009 00:35:22 +0100 + +grub2 (1.96+20090826-3) unstable; urgency=low + + * Add missing quotes in grub-pc.config and *.postinst. + + -- Felix Zielcke Wed, 26 Aug 2009 19:14:23 +0200 + +grub2 (1.96+20090826-2) unstable; urgency=low + + * Really use the correct templates in grub-pc.config. ARGS. + + -- Felix Zielcke Wed, 26 Aug 2009 14:10:41 +0200 + +grub2 (1.96+20090826-1) unstable; urgency=low + + * New SVN snapshot. + + * Use the right templates in grub-pc.config. (Closes: #543615) + + -- Felix Zielcke Wed, 26 Aug 2009 11:00:36 +0200 + +grub2 (1.96+20090825-1) unstable; urgency=low + + * New SVN snapshot. + - Enable gfxterm only if there's a suitable video backend and don't + print an error if not. (Closes: #520846) + + [ Felix Zielcke ] + * Copy unicode.pf2 instead of ascii.pf2 to /boot/grub in grub-pc + postinst (Closes: #542314). + * Update Standards version to 3.8.3. + * Use DEB_HOST_ARCH_CPU for the generation of the lintian overrides. + * Fix calling the grub-pc/postrm_purge_boot_grub template in + grub-pc.postinst. + * Handle GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT via + debconf. Thanks to Martin F. Krafft and Colin Watson for idea and + hints. + * Use ucfr --force when /etc/default/grub is registered to a grub-* package. + * Use #!/bin/sh in *.config and fix a small bashism in grub-pc.config. + + [ Robert Millan ] + * patches/907_terminal_output_workaround.diff: Remove. It seems that + it wasn't really necessary. + * grub-pc.postinst: Avoid printing an error if /etc/kernel-img.conf + doesn't exist, because it is misleading. We simply refrain from + fixing it and move along. + * grub-pc.postinst: Don't schedule generation of grub.cfg via "grub-install" + code path unless we actually run grub-install. + * grub-pc.postinst: Only copy unicode.pf2 and moreblue-orbit-grub.png when + /boot/grub/grub.cfg is scheduled to be generated. + * legacy/upgrade-from-grub-legacy: Reset grub-pc/install_devices. + Thanks Colin Watson. (Closes: #541230) + + -- Felix Zielcke Tue, 25 Aug 2009 21:45:24 +0200 + +grub2 (1.96+20090808-1) unstable; urgency=low + + * New SVN snapshot. + - Fix XFS with inode size different then 256. (Closes: #528761) + - Add support for multiple LVM metadata areas. (LP: #408580) + - patches/008_dac_palette_width.diff: Remove. (merged) + - Prefer unicode over ascii font. (LP: #352034) + + [ Felix Zielcke ] + * Fix the generation of the lintian override for efiemu64.o. + * Remove the Conflicts dmsetup. + * Use ?= for setting DEB_HOST_ARCH. + * Document GRUB_DISABLE_LINUX_RECOVERY in /etc/default/grub. + (Closes: #476536 LP: #190207) + * Add docs/grub.cfg to examples. + * patches/01_uuids_and_lvm_dont_play_along_nicely.diff: Updated to + also disable UUIDs on LVM over RAID. + * Add a debconf prompt to remove all grub2 files from /boot/grub on + purge. (Closes: #527068, #470400) + * Move the Suggests: os-prober from grub-pc to grub-common. + * patches/901_dpkg_version_comparison.diff: Updated. + * Update the Replaces on grub-common for the other packages to (<< + 1.96+20080831-1). (Closes: #540492) + + [ Robert Millan ] + * Reorganize grub-pc.{config,postinst} logic. The idea being that if there's + no trace of GRUB Legacy, the grub-pc/install_devices template will be + shown even if this is the first install. + * When setting grub-pc/install_devices, obtain input dynamically from + grub-mkdevicemap (rather than devices.map). (Closes: #535525) + * Add a note to grub-pc/install_devices template that it's also possible + to install GRUB to a partition boot record. + * patches/002_grub.d_freebsd.in.diff: New patch. Reimplement + 10_freebsd.in to handle multiple kernel versions & acpi.ko. + + -- Robert Millan Mon, 10 Aug 2009 18:49:52 +0200 + +grub2 (1.96+20090725-1ubuntu2) karmic; urgency=low + + * 950_hidden_timeout.diff: New patch. Add GRUB_HIDDEN_TIMEOUT support. + Move the timeout setting to the end so that the sleep comes after + terminal setup. + * debian/default/grub: Default to hiding the menu with a three-second + timeout. Pressing Escape during this time will show the menu. + grub-installer will unhide it if other operating systems are installed. + * debian/grub.d/05_debian_theme: Set a monochromatic theme for Ubuntu. + * 951_gfxpayload_keep.diff: New patch. If gfxpayload starts with "keep" or + if GRUB_ASSUME_LINUX_HAS_FB_SUPPORT is defined, then tell Linux to use + the current video mode. + + -- Colin Watson Mon, 10 Aug 2009 13:08:21 +0100 + +grub2 (1.96+20090725-1ubuntu1) karmic; urgency=low + + * New upstream version. + + Fixes offering Windows (LP: #402795) + + Fixes Vista/Win7 fails to boot (LP: #402154) + + Fixes installation onto VFAT (LP: #401971) + * Merge from debian unstable, remaining changes: + + debian/control: + - Depend on rather than Suggest os-prober; Ubuntu version does not + suffer from the mount problem that prevents Debian from marking this + Depends. + + debian/default/grub: + - Adjust for default Ubuntu boot options. + - Use new GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + + debian/legacy/update-grub: + - Apply Ubuntu branding: title, recovery mode, quiet option, and tweak + how memtest86+ is displayed. + - Use UUIDs where appropriate. + + debian/patches/03_ubuntu_grub_standards: + - Remove GNU/Linux from default string. + + debian/patches/10_crashkernel.patch: + - add crashkernel= options if kdump and makedumpfile + is available (part of the kernel-crashdump spec) + * Update 10_crashkernel.patch for changes upstream. + * Drop 999_os-prober_drivemap_root.diff, upstream. + + -- Mario Limonciello Thu, 30 Jul 2009 12:41:19 -0500 + +grub2 (1.96+20090725-1) unstable; urgency=high + + * New SVN snapshot. + - Don't add drivemap call with Windows Vista/7. It breaks Win 7. + (LP: #402154) + + [ Felix Zielcke ] + * Don't build grub-efi-amd64 on hurd-i386. + * Change DEB_BUILD_ARCH to DEB_HOST_ARCH in the check for sparc. + * Don't add the lintian override for kernel.img for sparc and grub-pc. + * Add a lintian override for binary-from-other-architecture for + grub-efi-amd64 and grub-pc on i386. + * Use wildcards in the lintian overrides. + * Add a Conflicts/Replaces for all packages except grub-common. + (Closes: #538177) + + [ Robert Millan ] + * 008_dac_palette_width.diff: New patch. Fix blank screen when booting + Linux with vga= parameter set to a packed color mode (<= 8-bit). + (Closes: #535026) + * Set urgency=high because #535026 affects 1.96+20090709-1 which is in + testing now. + * patches/907_terminal_output_workaround.diff: Work around recent regression + with terminal_output command (not critical, just breaks gfxterm). + + -- Robert Millan Sat, 25 Jul 2009 19:00:53 +0200 + +grub2 (1.96+20090721-4) unstable; urgency=low + + * Place grub-ofpathname only in grub-common. (Closes: #537999) + + -- Felix Zielcke Wed, 22 Jul 2009 13:38:24 +0200 + +grub2 (1.96+20090721-3) unstable; urgency=low + + * Don't strip kernel.img on sparc. + * Suggest efibootmgr on grub-efi-{amd64,ia32}. + * Pass --disable-grub-fstest to configure. (Closes: #537897) + + -- Felix Zielcke Tue, 21 Jul 2009 21:46:01 +0200 + +grub2 (1.96+20090721-2) unstable; urgency=low + + * Add back Conflicts/Replaces grub. + + -- Felix Zielcke Tue, 21 Jul 2009 11:24:45 +0200 + +grub2 (1.96+20090721-1) unstable; urgency=low + + * New SVN snapshot. + + * Change License of my update-grub(8) and update-grub2(8) manpages to + GPL3+ to match new copyright file. + * Merge from Ubuntu: Don't build grub-efi-amd64 on lpia. + * Don't pass `--enable-efiemu' to configure. On kfreebsd-i386 it won't + compile and it should be now auto detected if it's compilable. + (Closes: #536783) + * Don't build grub-efi-amd64 on kfreebsd-i386. It lacks 64bit compiler + support. + * Rename the lintian override for kernel.elf to kernel.img. + * Strip kernel.img not kernel.elf, but not in the case of grub-pc. + * Rename the Conflicts/Replaces grub to grub-legacy. (Closes: #537824) + + -- Felix Zielcke Tue, 21 Jul 2009 10:50:20 +0200 + +grub2 (1.96+20090709-1) unstable; urgency=low + + * New SVN snapshot. + + * control (Build-Depends): Add gcc-multilib [sparc]. + * copyright: Rewrite using DEP-5 format. + * Merge grub-extras into the package, and integrate it with GRUB's + build system. + - patches/906_grub_extras.diff + - rules + - copyright + + -- Robert Millan Thu, 09 Jul 2009 00:26:49 +0200 + +grub2 (1.96+20090702-1) unstable; urgency=low + + * New SVN snapshot. + * rules: Remove duplicated files in sparc64-ieee1275 port. + * rules: Comment out -DGRUB_ASSUME_LINUX_HAS_FB_SUPPORT=1 setting. We'll + re-evaluate using it when it's more mature. (Closes: #535026). + + -- Robert Millan Thu, 02 Jul 2009 13:23:51 +0200 + +grub2 (1.96+20090629-1) unstable; urgency=low + + * New SVN snapshot. + - Misc fixes in Linux loader. + + * control (grub-firmware-qemu): Make it buildable only on i386/amd64. + * control: Add sparc (grub-ieee1275), remove remnants of ppc64. + * rules: Include all modules in grub-firmware-qemu build. + + -- Robert Millan Mon, 29 Jun 2009 19:22:37 +0200 + +grub2 (1.96+20090628-1) unstable; urgency=low + + * New SVN snapshot. + * Re-enable QEMU port. + + -- Robert Millan Sun, 28 Jun 2009 01:11:10 +0200 + +grub2 (1.96+20090627-2) unstable; urgency=low + + * Disable QEMU port untill it goes through NEW. + * Upload to unstable. + + -- Robert Millan Sat, 27 Jun 2009 18:40:17 +0200 + +grub2 (1.96+20090627-1) experimental; urgency=low + + * New SVN snapshot. + - Fix parsing of --output in grub-mkconfig. (Closes: #532956) + + [ Felix Zielcke ] + * Use ucfr --force in grub-ieee1275.postinst in case we're upgrading + from previous version. It registered /etc/default/grub wrongly with + package iee1275. + * Drop the build dependency on libc6-dev-i386. + * Remove ppc64 from the Architectures. It's totally dead. + * Add a note to /etc/default/grub that update-grub needs to be run to + update grub.cfg. (Closes: #533026) + * Fix the svn-snapshot rule. + * Update Standards version to 3.8.2. No changes needed. + + [ Robert Millan ] + * legacy/upgrade-from-grub-legacy: Invoke grub-pc.postinst directly rather + than dpkg-reconfigure. Since we pretend we're upgrading, it will DTRT. + * Add grub-firmware-qemu package. + - patches/008_qemu.diff: QEMU port (patch from upstream). + - control (grub-firmware-qemu): New package. + - rules: Add grub-firmware-qemu targets. + - debian/grub-firmware-qemu.dirs + - debian/grub-firmware-qemu.install + * patches/906_revert_to_linux16.diff: Remove, now that gfxpayload is + supported. + + -- Robert Millan Sat, 27 Jun 2009 00:46:23 +0200 + +grub2 (1.96+20090611-1ubuntu4) karmic; urgency=low + + * debian/patches/10_crashkernel.diff: + - make crashkernel= commandline appear before the other options + to workaround a bug in the crashkernel parser + (http://lists.infradead.org/pipermail/kexec/2009-July/003444.html) + + -- Michael Vogt Thu, 16 Jul 2009 11:37:05 +0200 + +grub2 (1.96+20090611-1ubuntu3) karmic; urgency=low + + * Drop os-prober to a Recommends at Felix Zielcke's suggestion. + * Don't build grub-efi-amd64 on lpia for the moment, since we don't seem + to have sufficient compiler support. + + -- Colin Watson Wed, 08 Jul 2009 16:25:58 +0100 + +grub2 (1.96+20090611-1ubuntu2) karmic; urgency=low + + * 10_crashkernel.patch: + - add crashkernel= options if kdump and makedumpfile + is available (part of the kernel-crashdump spec) + + -- Michael Vogt Wed, 24 Jun 2009 10:19:57 +0200 + +grub2 (1.96+20090611-1ubuntu1) karmic; urgency=low + + * Resynchronise with Debian. Remaining changes: + + debian/control: + - Depend on rather than Suggest os-prober; Ubuntu version does not + suffer from the mount problem that prevents Debian from marking this + Depends. + + debian/default/grub: + - Adjust for default Ubuntu boot options. + - Use new GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + + debian/legacy/update-grub: + - Apply Ubuntu branding: title, recovery mode, quiet option, and tweak + how memtest86+ is displayed. + - Use UUIDs where appropriate. + + debian/patches/03_ubuntu_grub_standards: + - Remove GNU/Linux from default string. + * debian/patches/999_os-prober_drivemap_root.diff: + - Backport r2333 from upstream to fix chain-loading of operating systems + detected by os-prober. + + -- Colin Watson Wed, 17 Jun 2009 12:05:47 +0100 + +grub2 (1.96+20090611-1) experimental; urgency=low + + * New SVN snapshot. + + * Append .diff to patches/01_uuids_and_lvm_dont_play_along_nicely so + it gets really applied. + * Drop completely the build dependency on gcc-multilib. + * Instead of arborting in the preinst if /etc/kernel-img.conf still + contains /sbin/update-grub, change the file with sed. Policy allows + thisi, because it's not a conffile, according to Colin Watson. + * Change /etc/default/grub to an ucf managed file instead of dpkg + conffile. + + -- Felix Zielcke Fri, 12 Jun 2009 11:46:24 +0200 + +grub2 (1.96+20090609-1) experimental; urgency=low + + * New SVN snapshot. + - Fix variable parsing inside strings. (Closes: #486180) + - Add `true' command. (Closes: #530736) + + [ Robert Millan ] + * Split grub-efi in grub-efi-ia32 and grub-efi-amd64, both available + on i386 and amd64. (Closes: #524756) + * Add kopensolaris-i386 to arch list. + + [ Felix Zielcke ] + * Add a NEWS entry about the grub-efi split. + * Drop the build dependency on gcc-multilib for all *i386. + * Change upgrade-from-grub-legacy to use `dpkg-reconfigure grub-pc' to + install grub2 into MBR. + + [ New translations ] + * Catalan (ca.po) by Jordi Mallach. + + [ Updated translations ] + * Spanish (es.po) by Francisco Javier Cuadrado. (Closes: #532407) + + -- Jordi Mallach Tue, 09 Jun 2009 19:21:15 +0200 + +grub2 (1.96+20090603-1) unstable; urgency=low + + * New SVN snapshot. + + * Abort the install of grub-pc if /etc/kernel-img.conf still contains + /sbin/update-grub (Closes: #500631). + + -- Felix Zielcke Wed, 03 Jun 2009 20:01:11 +0200 + +grub2 (1.96+20090602-1) unstable; urgency=low + + * New SVN snapshot. + + [ Felix Zielcke ] + * Skip floopies in the grub-install debconf prompt in grub-pc postinst. + Patch by Fabian Greffrath. (Closes: #530848) + + [ Robert Millan ] + * Change Vcs-Browser field to viewsvn. + + [ Felix Zielcke ] + * Change Vcs-Svn field to point to the trunk. (Closes: #531391) + * patches/01_uuids_and_lvm_dont_play_along_nicely: New patch. + On Debian root=UUID= with lvm still doestn't work so disable it. + (Closes: #530357) + * Remove Otavio Salvador from Uploaders with his permission. + * add grub-pc.preinst + + -- Felix Zielcke Wed, 03 Jun 2009 14:42:11 +0200 + +grub2 (1.96+20090523-1ubuntu1) karmic; urgency=low + + [ Colin Watson ] + * Resynchronise with Debian. Remaining changes: + + debian/control: + - Depend on rather than Suggest os-prober; Ubuntu version does not + suffer from the mount problem that prevents Debian from marking this + Depends. + + debian/default/grub + - Adjust for default Ubuntu boot options. + - Use new GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + + debian/patches/03_ubuntu_grub_standards + - Remove GNU/Linux from default string. + * debian/legacy/update-grub: Apply Ubuntu branding: title, recovery mode, + quiet option, and tweak how memtest86+ is displayed. + + [ Andy Whitcroft ] + * debian/legacy/update-grub: fix generation to use the uuid command for + the root specifier when the groot is a UUID. Use the same test as is + used in the 'grub' package. LP: #376879 + + -- Colin Watson Thu, 04 Jun 2009 11:20:12 +0100 + +grub2 (1.96+20090523-1) unstable; urgency=low + + * New SVN snapshot. + - Add drivemap command, similar to grub-legacy's map command. + (Closes: 503630) + - Export GRUB_TERMINAL_INPUT in grub-mkconfig. (Closes: #526741) + + [ Robert Millan ] + * rules: Set GRUB_ASSUME_LINUX_HAS_FB_SUPPORT=1 in CFLAGS. + * patches/905_setup_force.diff: Relax blocklist warnings. + * patches/906_revert_to_linux16.diff: Keep using linux16 for now. + + [ Felix Zielcke ] + * patches/07_core_in_fs.diff: Updated. + * Remove /etc/grub.d/10_hurd on non-Hurd systems in the grub-common + preinst. Likewise for 10_freebsd for non kFreebsd and 10_linux on + kFreebsd and Hurd. (Closes: #523777) + + -- Felix Zielcke Sat, 23 May 2009 20:05:10 +0200 + +grub2 (1.96+20090504-1) experimental; urgency=low + + * New SVN snapshot. + - Add support for parttool command, which can be used to hide partitions. + (Closes: #505905) + - Fix a segfault with LVM on RAID. (Closes: #520637) + - Add support for char devices on (k)FreeBSD. (Closes: #521292) + - patches/08_powerpc-ieee1275_build_fix.patch: Remove (merged). + + [ Updated translations ] + * Basque (eu.po) by Piarres Beobide. (Closes: #522457) + * German (de.po) by Helge Kreutzmann. (Closes: #522815) + + [ Robert Millan ] + * Update my email address. + * Remove 04_uuids_and_abstraction_dont_play_along_nicely.diff now that + bugs #435983 and #455746 in mdadm and dmsetup have been fixed. + + [ Felix Zielcke ] + * Place new grub-dumpbios in grub-common. + * Add lpia to the archictectures to reduce the ubuntu delta. + * Add a manpage for the update-grub and update-grub2 stubs, written by + me. (Closes: #523876) + * Suggest genisoimage on grub-pc and grub-ieee1275, because grub-mkrescue + needs it to create a cd image. (Closes: #525845) + * Add a dependency on $(AUTOGEN_FILES) for the configure/grub-common target, + this is needed now that upstream removed the autogenerated files from SVN. + * Add `--enable-efiemu to' `./configure' flags. + * Add a build dependency on gcc-multilib for i386. + * Drop alternate build dependency on gcc-4.1 (<< 4.1.2). + + -- Felix Zielcke Mon, 04 May 2009 21:01:22 +0200 + +grub2 (1.96+20090402-1) experimental; urgency=low + + * New SVN snapshot. + - Fix regression in disk/raid.c. (Closes: #521897, #514338) + - Fix handling of filename string lengths in HFS. + (Really closes: #516458). + * Add myself to Uploaders. + * Add patch 08_powerpc-ieee1275_build_fix.patch to fix powerpc-ieee1275 + builds which were lacking header files for kernel_elf_HEADERS. Thanks + Vladimir Serbinenko. + + -- Jordi Mallach Fri, 03 Apr 2009 20:58:37 +0200 + +grub2 (1.96+20090401-1) experimental; urgency=low + + [ Felix Zielcke ] + * New SVN snapshot. + - Pass grub's gfxterm mode to Linux kernel. (Closes: #519506) + - Fix ext4 extents on powerpc. (Closes: #520286) + + [ Robert Millan ] + * Remove grub-of transitional package (Lenny had grub-ieee1275 already). + * Fix kopt parsing in grub-pc.config. Thanks Marcus Obst. (Closes: #514837) + * Add debconf template to automatically run grub-install during upgrades + (prior user confirmation). (Closes: #514705) + + -- Robert Millan Wed, 01 Apr 2009 01:19:45 +0200 + +grub2 (1.96+20090317-1) unstable; urgency=low + + * New SVN snapshot. + - Fix loading of files with underscore in HFS. (Closes: #516458) + + * Update Standards version to 3.8.1. No changes needed. + + [ Updated translations ] + * Brazilian Portuguese (pt_BR.po) by Flamarion Jorge. (Closes: #519417) + + -- Felix Zielcke Tue, 17 Mar 2009 14:42:10 +0100 + +grub2 (1.96+20090309-1) unstable; urgency=low + + * New SVN snapshot. + + -- Felix Zielcke Mon, 09 Mar 2009 10:03:13 +0100 + +grub2 (1.96+20090307-1) unstable; urgency=low + + * New SVN snapshot. + - Add support for /dev/md/dNNpNN mdraid devices. (Closes: #509960) + - Add new PF2 fontengine. (Closes: #510344) + - Avoid mounting ext2 partitions with backward-incompatible features. + (Closes: #502333) + - Try to avoid false positives with FAT. (Closes: #514263) + + [ Felix Zielcke ] + * Remove build-dependency on unifont package and add one for bf-utf-source + package and libfreetype6-dev + * grub-pc.postinst: Copy new ascii.pf2 instead of old ascii.pff to /boot/grub. + * Add `--enable-grub-mkfont' to configure flags. + * Put new grub-mkfont in grub-common package. + * Add a dependency for ${misc:Depends} to all packages to make lintian a bit + more happy. + * Detect when grub-setup leaves core.img in filesystem, and include that + info in bug report templates. + - debian/patches/07_core_in_fs.diff + - debian/script + * Add myself to Uploads and add `DM-Upload-Allowed: yes' tag. + + [ Updated translations ] + * Asturian (ast.po) by Marcos Alvarez Costales. (Closes: #511144) + * Traditional Chinese (zh_TW.po) by Tetralet. (Closes: #513918) + * Belarusian (be.po) by Pavel Piatruk. (Closes: #516243) + + -- Felix Zielcke Sat, 07 Mar 2009 11:54:43 +0100 + +grub2 (1.96+20081201-1) experimental; urgency=low + + * New SVN snapshot. + + -- Robert Millan Mon, 1 Dec 2008 00:07:31 +0100 + +grub2 (1.96+20081120-1) experimental; urgency=low + + * New SVN snapshot. + + * Update to new debian theme. + - grub-pc.postinst: Switch to moreblue-orbit-grub.png. + - grub.d/05_debian_theme: Likewise. + * grub.d/05_debian_theme: + - Update to use new grub-mkconfig_lib instead of the deprecated + update-grub_lib. + - Update to check if `GRUB_TERMINAL_OUTPUT' is `gfxterm' instead of + `GRUB_TERMINAL'. + + [ Updated translations ] + * Romanien (ro.po) by Eddy Petrișor. (Closes: #506039) + + -- Felix Zielcke Thu, 20 Nov 2008 20:25:56 +0100 + +grub2 (1.96+20081108-1) experimental; urgency=low + + * New SVN snapshot. + - Add support for /dev/md/N style mdraid devices. (Closes: #475585) + - Handle LVM dash escaping. (Closes: #464215) + - Use case insensitive match in NTFS. (Closes: #497889) + - Use hd%d drive names in grub-mkdevicemap for all architectures. + (Closes: #465365) + - Handle LVM circular metadata. (Closes: #462835, #502953) + - Fix NULL dereference and failure paths in LVM. Thanks Guillem Jover. + (Closes: #500482) + - Provides GRUB header files (only in grub-common). + + [ Updated translations ] + * Dutch (nl.po) by Paul Gevers. (Closes: #500514) + * French (fr.po) by Christian Perrier. (Closes: #503708) + * Georgian (ka.po) by Aiet Kolkhi. (Closes: #503715) + * Czech (cs.po) by Miroslav Kure. (Closes: #503809) + * German (de.po) by Helge Kreutzmann. (Closes: #503841) + * Japanese (ja.po) by Hideki Yamane. (Closes: #503869) + * Italian (it.po) by Luca Monducci. (Closes: #504076) + * Swedish (sv.po) by Martin Ågren. (Closes: #504207) + * Arabic (ar.po) by Ossama Khayat. (Closes: #504254) + * Portuguese (pt.po) by Miguel Figueiredo. (Closes: #504280) + * Russian (ru.po) by Yuri Kozlov. (Closes: #504324) + * Finnish (fi.po) by Esko Arajärvi. (Closes: #504310) + * Basque (eu.po) by Piarres Beobide. (Closes: #504466) + * Dutch (nl.po) by Paul Gevers. (Closes: #504683) + + [ Felix Zielcke ] + * patches/01_grub_legacy_0_based_partitions.diff: Rename to + * patches/903_grub_legacy_0_based_partitions.diff: this and adapt for + s/biosdisk.c/hostdisk.c/ rename upstream. + * patches/03_disable_floppies.diff + patches/904_disable_floppies.diff: Likewise. + * update-grub has been renamed to grub-mkconfig, so provide a stub for + compatibility. + * Make grub-pc/linux_cmdline debconf template translatable. (Closes: #503478) + * Remove ro.po and ta.po. They don't contain a single translated + message. + + [ Robert Millan ] + * control: Make grub-common dependency = ${binary:Version}. + * default/grub: Set GRUB_CMDLINE_LINUX=quiet to syncronize with + default D-I settings. + + -- Robert Millan Sat, 8 Nov 2008 13:54:10 +0100 + +grub2 (1.96+20080831-1) experimental; urgency=low + + * New SVN snapshot. + - patches/00_fix_double_prefix.diff: Remove (merged). (Closes: #487565) + - patches/00_getline.diff: Remove (merged). (Closes: #493289) + - Handle errors in RAID/LVM scan routine (rather than letting the upper + layer cope with them). (Closes: #494501, #495049) + - patches/901_linux_coreboot.diff: Remove (replaced). + - Add support for GFXMODE variable (Closes: #493106) + - Skips /dev/.* in grub-probe. (Closes: #486624) + - RAID code has various fixes. (Closes: #496573) + - Buffered file read is now used to read the background image faster. + (Closes: #490584) + + * We are already using LZMA, because upstream includes it's own lzma encoder, + so drop completely the liblzo handling in control and rules files. + + [ Felix Zielcke ] + * Remove the 1.95 partition numbering transition debconf warning + from grub2 package and removed it from all languages (*.po). + (Closes: #493744) + * Add a comment for the new GFXMODE in default/grub. + * debian/rules: + - Remove 2 ./configure options which it didn't understand. + - New grub-mkelfimage belongs to grub-common. + * debian/control: + - Change debhelper compat level to 7 and build depend on it >= 7. + - Remove ${misc:Depend} dependency on all packages except grub-pc which is + the only one using debconf. + - Replace deprecated ${Source-Version} with ${source:Version} for << + dependency and with ${build:Version} for = ones. + - Remove versioned dependency of Build-Depends patchutils and cdbs, + because etch has newer versions then the one used. + - Remove dpkg-dev completely from Build-Depends because it's + build-essentail and a non versioned dependency results in a lintian error. + - Remove Conflict/Replaces pupa, it has been removed from Debian 2004. + - Change build-dependency of unifont-bin to unifont (>= 1:5.1.20080820), + it's the new package containing unifont.hex and that version to avoid + licensing problems (Closes: #496061) + - Remove Jason Thomas from Uploaders with his permission. + * Preserve arguments in update-grub2 stub. (Closes: #496610) + + [ Updated translations ] + * Japanese (ja.po) by Hideki Yamane (Closes: #493347) + + [ Robert Millan ] + * Move a few files to grub-common and remove them from the arch- + specific packages. + * patches/02_old_linux_version_comparison.diff: Replace with ... + * patches/901_dpkg_version_comparison.diff: ... this. + Use dpkg --compare-versions in update-grub. (Closes: #494158) + * patches/03_disable_floppies.diff: Free .drive struct member when skipping + floppy drives. (Closes: #496040) + * patches/902_boot_blocklist_hack.diff: Support separate /boot when using + blocklists. (Closes: #496820, #489287, #494589) + + -- Robert Millan Sun, 31 Aug 2008 18:40:09 +0200 + +grub2 (1.96+20080730-1) experimental; urgency=low + + * New SVN snapshot. + - patches/00_fix_overflow.diff: Remove (merged). + - patches/00_uuid_boot.diff: Remove (merged). + - patches/00_raid_duped_disks.diff: Remove (merged). + - patches/00_xfs.diff: Remove (merged). + - patches/00_strengthen_apple_partmap_check.diff: Remove (merged). + - patches/00_skip_dev_dm.diff: Remove (merged). + + * patches/901_linux_coreboot.diff: Implements Linux load on Coreboot + (patch from Coresystems). + + * grub-linuxbios -> grub-coreboot rename again. + + -- Robert Millan Wed, 30 Jul 2008 22:12:07 +0200 + +grub2 (1.96+20080724-12ubuntu2) jaunty; urgency=low + + * Build for lpia. + + -- Colin Watson Wed, 25 Feb 2009 18:28:37 +0000 + +grub2 (1.96+20080724-12ubuntu1) jaunty; urgency=low + + * Merge from Debian Unstable (LP: #298872, LP: #256578). + Remaining Ubuntu changes: + + debian/control: + - Depend on rather than Suggest os-prober; Ubuntu version does not + suffer from the mount problem that prevents Debian from marking this + Depends. + + debian/default/grub + - Adjust for default Ubuntu boot options. + - Use new GRUB_CMDLINE_LINUX_DEFAULT option to set "quiet splash" for + default items only. These options won't be set in single user mode. + + debian/patches/03_ubuntu_grub_standards + - Remove GNU/Linux from default string. + * New upstream snapshot includes ext4 extents support (LP: #294763) + * Debian patch 02_dpkg_version_comparison.diff fixes kernel ordering + (LP: #215513) + * debian/patches/04_uuids_and_abstraction_dont_play_along_nicely: + + Drop. Ubuntu's mdadm and lvm properly populate /dev/disk/by-uuid, so + this workaround is unnecessary. + * debian/changelog: + + Drop duplicated 1.96+20080203-1ubuntu2 and 1.96+20080203-1ubuntu1 + entries. We only really need them in there once! + * Drop debian/patches/04_convert_root_uuid: + - GRUB2 upstream now uses UUIDs when possible. + + -- Christopher James Halse Rogers Mon, 17 Nov 2008 10:06:18 +1100 + +grub2 (1.96+20080724-4) unstable; urgency=high + + * patches/00_fix_overflow.diff: fix overflow with a big grub.cfg. + (Closes: #473543) + + -- Felix Zielcke Tue, 29 Jul 2008 17:10:59 +0200 + +grub2 (1.96+20080724-3) unstable; urgency=low + + [ Felix Zielcke ] + * changed dependency for debconf to also support debconf-2.0. (Closes: #492543) + * patches/00_xfs.diff: Fix "out of partition" error with XFS. + (Closes: #436943) + + [ Robert Millan ] + * patches/00_raid_duped_disks.diff: Do not abort when two RAID disks with + the same number are found. (Closes: #492656) + * patches/00_strengthen_apple_partmap_check.diff: Be more strict when probing + for Apple partition maps (this prevents false positives on i386-pc + installs). (Closes: #475718) + + -- Robert Millan Tue, 29 Jul 2008 00:48:01 +0200 + +grub2 (1.96+20080724-2) unstable; urgency=high + + [ Felix Zielcke ] + * fixed lintian override for kernel.elf + * debian/rules: changed cvs targets to use svn + + [ Robert Millan ] + * patches/00_skip_dev_dm.diff: Skip /dev/dm-[0-9] devices also (implicitly) + for RAID. (Closes: #491977) + * patches/00_uuid_boot.diff: Fix cross-disk installs by using UUIDs. + (Closes: #492204) + + -- Robert Millan Sat, 26 Jul 2008 01:06:07 +0200 + +grub2 (1.96+20080724-1) unstable; urgency=high + + * New SVN snapshot. + - Support for ext4dev extents. + - patches/00_speed_up_font_load.diff: Remove (merged). + + [ Felix Zielcke ] + * upgrade-from-grub-legacy now calls update-grub if grub.cfg doestn't exist + and prints a big warning if it failed. + * Update Standards version to 3.8.0. No changes need. + * Added Build-Dep for po-debconf and a lintian override, to make it happy. + + [ Updated translations ] + * Swedish (sv.po) by Martin Ågren (Closes: #492056) + + [ Robert Millan ] + * Revert r844. grub-coreboot is stuck on NEW, and it was too early + for branching. + + -- Robert Millan Thu, 24 Jul 2008 13:27:53 +0200 + +grub2 (1.96+20080717-1) experimental; urgency=low + + * New SVN snapshot. + - Provides LZMA support (not yet used in the package). + - Fix grub-mkrescue manpage generation. (Closes: #489440) + + * Rename grub-linuxbios to grub-coreboot (and leave a dummy grub-linuxbios + package to handle upgrades). + + [ Updated translations ] + * Spanish (es.po) by Maria Germana Oliveira Blazetic (Closes: #489877) + * Portuguese (pt.po) by Ricardo Silva (Closes: #489807) + + -- Robert Millan Sat, 12 Jul 2008 17:47:09 +0200 + +grub2 (1.96+20080704-2) unstable; urgency=high + + * patches/02_old_linux_version_comparison.diff: Set interpreter to /bin/bash. + (Closes: #489426, #489446) + + -- Robert Millan Mon, 7 Jul 2008 15:17:58 +0200 + +grub2 (1.96+20080704-1) unstable; urgency=high + + * New SVN snapshot. + * default/grub: Add commented example to disable graphical terminal. + * Use substvars to support linking with liblzo1. + * Bring 03_disable_floppies.diff to pre-r805 state. (Closes: #488375) + * patches/02_old_linux_version_comparison.diff: New patch. Steal version + comparison code from GRUB Legacy's update-grub. (Closes: #464086, #489133) + * patches/00_speed_up_font_load.diff: New patch. Generate font files with + only the needed characters. (Closes: #476479, #477083) + + -- Robert Millan Fri, 4 Jul 2008 21:39:07 +0200 + +grub2 (1.96+20080626-1) unstable; urgency=high + + * New CVS snapshot. + - Avoids passing UUID to Linux when not using initrd. (Closes: #484228) + - patches/04_uuids_and_abstraction_dont_play_along_nicely.diff: Resync. + + -- Robert Millan Thu, 26 Jun 2008 16:43:48 +0200 + +grub2 (1.96+20080621-1) unstable; urgency=high + + * Urgency set to "high" because of #482688. + * New CVS snapshot. + - Fix module load hook in prepare_grub_to_access_device(). + (Closes: #486804) + - Call prepare_grub_to_access_device() before accessing devices, never + afterwards. (Closes: #487198) + * grub.d/05_debian_theme: Prefer /boot/grub over /usr for image + loading, since chances are it's less LVMed. + + -- Robert Millan Sat, 21 Jun 2008 15:52:48 +0200 + +grub2 (1.96+20080617-1) unstable; urgency=low + + * New CVS snapshot. + - Supports IDA block devices. (Closes: #483858) + - Fixes some problems in ext2/ext3. (Closes: #485068, #485065) + - Uses EUID instead of UID in update-grub. (Closes: #486043, #486039, + #486040, #486041). + - Fixes incomplete I2O device support. Thanks Sven Mueller. + (Closes: #486505) + - Fixes recent regressions in fs/ext2.c. (Closes: #485279) + - Only use UUIDs when requested device is not the same as the one + providing /boot. (Closes: #486119) + - patches/02_libgcc_powerpc_hack.diff: Remove. Probably not needed + anymore. + - patches/04_uuids_and_abstraction_dont_play_along_nicely.diff: Update. + * patches/06_olpc_prefix_hack.diff: Hardcode prefix to (sd,1) on OLPC. + * Refurbish 03_disable_floppy_support_in_util_biosdisk.diff into + 03_disable_floppies.diff. + + -- Robert Millan Tue, 17 Jun 2008 01:07:52 +0200 + +grub2 (1.96+20080601-2) unstable; urgency=low + + * 04_run_grub_mkdevicemap_when_grub_probe_fails.diff: Remove. Argueably + makes grub-probe unreliable and is quite annoying. + * 04_uuids_and_abstraction_dont_play_along_nicely.diff: New patch. Disable + UUID parameter to Linux when LVM or dmRAID is in use. (Closes: #484228) + This is a workaround for bug #484297 in udev. + + -- Robert Millan Tue, 3 Jun 2008 16:29:53 +0200 + +grub2 (1.96+20080601-1) unstable; urgency=low + + * New CVS snapshot. + - patches/06_backward_compat_in_uuid_support.diff: Merged. + - Fixes NULL pointer dereference in biosdisk.c. (Closes: #483895, #483900) + - Extends UUID support for XFS and ReiserFS. + + -- Robert Millan Sun, 1 Jun 2008 15:44:08 +0200 + +grub2 (1.96+20080531-1) unstable; urgency=low + + * New CVS snapshot. + - Work around BIOS bug affecting keyboard on macbooks. (Closes: #482860) + - Adjust grub.d/05_debian_theme to use the new UUID-compatible API. + - default/grub: Add commented GRUB_DISABLE_LINUX_UUID variable. + - patches/06_backward_compat_in_uuid_support.diff: New. Make update-grub + generate code that is compatible with older GRUB installs. + - util/biosdisk.c no longer complains about duplicated device.map entries. + (Closes: #481236) + + [ Updated translations ] + * Galician (gl.po) by Jacobo Tarrio (Closes: #480977) + + -- Robert Millan Sat, 31 May 2008 00:02:54 +0200 + +grub2 (1.96+20080512-1ubuntu2) intrepid; urgency=low + + [ Onkar Shinde ] + * debian/patches: + - Add 03_ubuntu_grub_standards to remove GNU/Linux from the + default string. (LP: #192955) Don't show splash screen or quiet mode + in single user mode. + - Add 04_convert_root_uuid.diff to default to using UUIDs + on new GRUB2 installations. (LP: #192956) + * debian/control: + - Move os-prober to 'Depends' since Ubuntu version does not suffer from + the mount problem in Debian version. 'os-prober' is needed for probing + other operating systems. (LP: #214642) + * Other bugs fixed - LP: #219580 + + [ Mario Limonciello ] + * Add items from missed merge bug (LP: #234288) + + -- Onkar Shinde Fri, 23 May 2008 14:28:36 +0530 + +grub2 (1.96+20080512-1ubuntu1) intrepid; urgency=low + + * Merge from debian unstable, remaining changes: + - Adjust debian/default/grub for default Ubuntu boot options. + + -- Mario Limonciello Tue, 27 May 2008 11:32:41 -0500 + +grub2 (1.96+20080512-1) unstable; urgency=low + + * New CVS snapshot. + - Adds support for default-only Linux cmdline options. (Closes: #460843) + - Supports Xen virtual block devices. (Closes: #456777) + - Supports Virtio block devices. (Closes: #479056) + - Supports CCISS block devices. (Closes: #479735) + - Fixes handling of more LVM abnormal conditions. (Closes: #474343, + #474931, #477175) + + * Switch to liblzo2 now that it's GPLv3-compatible. (Closes: #466375) + * grub-pc.postinst: Escape \ and / in cmdline sed invokation. + (Closes: #479279) + + [ Updated translations ] + * Italian (it.po) by Luca Monducci (Closes: #480740) + + -- Robert Millan Mon, 12 May 2008 17:46:38 +0200 + +grub2 (1.96+20080429-1) unstable; urgency=high + + * New CVS snapshot. + - Includes sample grub.cfg file; we use it for grub-rescue-pc. + (Closes: #478324) + * grub-common: Upgrade Replaces to << 1.96+20080426-3. (Closes: #478224, + #478353, #478144) + + [ Updated translations ] + * French (fr.po) by Christian Perrier (Closes: #471291) + + -- Robert Millan Tue, 29 Apr 2008 13:27:52 +0200 + +grub2 (1.96+20080426-1) unstable; urgency=high + + * New CVS snapshot. + - Fixes syntax error when setting GRUB_PRELOAD_MODULES. (Closes: #476517) + * Move os-prober to Suggests, to avoid trouble with #476184. + (Closes: #476684) + * patches/04_run_grub_mkdevicemap_when_grub_probe_fails.diff: New patch, + does what its name says. (Closes: #467127) + - Also move grub-mkdevicemap from grub-pc to grub-common, so that GRUB + Legacy can use it. + + [ Updated translations ] + * Basque (eu.po) by Piarres Beobide (Closes: #476708) + + -- Robert Millan Sat, 26 Apr 2008 20:06:55 +0200 + +grub2 (1.96+20080413-1) unstable; urgency=high + + * New CVS snapshot. + - Provides 30_os-prober update-grub add-on. Thanks Fabian Greffrath. + (Closes: #461442) + - Improves robustness when handling LVM. + (Closes: #474931, #474343) + * patches/03_disable_floppy_support_in_util_biosdisk.diff: New. Does + what its name says. (Closes: #475177) + + -- Robert Millan Sun, 13 Apr 2008 13:53:28 +0200 + +grub2 (1.96+20080408-1) unstable; urgency=low + + * New CVS snapshot. + - grub-probe skips non-existant devices when processing device.map. + (Closes: #473209) + * control: Fix syntax error. + + [ Updated translations ] + * Finnish (fi.po) by Esko Arajärvi (Closes: #468641) + + -- Robert Millan Tue, 8 Apr 2008 15:45:25 +0200 + +grub2 (1.96+20080228-1) unstable; urgency=low + + * New CVS snapshot. + * Split grub-probe into grub-common package. Make all flavours depend on it. + (Closes: #241972) + * Suggest multiboot-doc. + * patches/01_grub_legacy_0_based_partitions.diff: New patch. Add a hack that + tells grub-probe you want 0-based partition count + (GRUB_LEGACY_0_BASED_PARTITIONS variable) + * Stop depending on lsb-release (too heavy! we don't need python in base). + Instead of assuming it's there, try calling it and otherwise just echo + Debian. + + -- Robert Millan Thu, 28 Feb 2008 16:43:40 +0100 + +grub2 (1.96+20080219-3) unstable; urgency=low + + * default/grub: Use lsb_release to support Debian derivatives. + (Closes: #466561) + * grub.d/05_debian_theme: Only setup background image when a reader for it + is present in /boot/grub. (Closes: #467111) + + [ Updated translations ] + * Russian (ru.po) by Yuri Kozlov (Closes: #467181) + + -- Robert Millan Sun, 24 Feb 2008 15:39:50 +0100 + +grub2 (1.96+20080219-2) unstable; urgency=high + + * grub-pc.postinst: Create /boot/grub if it doesn't exist. + + -- Robert Millan Wed, 20 Feb 2008 07:15:14 +0100 + +grub2 (1.96+20080219-1) unstable; urgency=high + + * New CVS snapshot. + - Improves GPT support, allowing it to work without blocklists. + + -- Robert Millan Tue, 19 Feb 2008 15:05:10 +0100 + +grub2 (1.96+20080216-1) unstable; urgency=high + + * New CVS snapshot. + - Fixes offset calculation issue when installing on GPT (urgency set + to high because of this). + * Fix Vcs-Browser tag. Thanks James. (Closes: #465697) + * Only process grub-pc/linux_cmdline if /boot/grub/menu.lst exists. + (Closes: #465708) + + [ Updated translations ] + * French (fr.po) by Christian Perrier (Closes: #465706) + + -- Robert Millan Sat, 16 Feb 2008 23:30:55 +0100 + +grub2 (1.96+20080213-1) unstable; urgency=low + + * New CVS snapshot. + - Failure to read one device in a RAID-1 array no longer causes boot + to fail (so long as there's a member that works). (Closes: #426341) + * script: For /proc/mounts, only report lines that start with /dev/. + * Add new upgrade-from-grub-legacy script for the user to complete the upgrade + process from GRUB Legacy, and advertise it prominently in menu.lst. + (Closes: #464912) + * Add a hack to support gfxterm / background_image on systems where /usr + isn't accessible. (Closes: #464911, #463144) + - grub-pc.postinst + - grub.d/05_debian_theme + * Fix a pair of spelling mistakes in debconf. (Closes: #465296) + * Migrate kopt from menu.lst. (Closes: #461164, #464918) + + [ Updated translations ] + * Portuguese (pt.po) by Ricardo Silva (Closes: #465137) + * German (de.po) by Helge Kreutzmann (Closes: #465295) + + -- Robert Millan Wed, 13 Feb 2008 16:37:13 +0100 + +grub2 (1.96+20080210-1) unstable; urgency=high + + * New CVS snapshot. + - Errors that cause GRUB to enter rescue mode are displayed now. + (Closes: #425149) + - Build LVM/RAID modules into a few commands that were missing them + (notably, grub-setup). (Closes: #465033) + * Fix license violation (incompatibility between GRUB and LZO2). + (Closes: #465056) + - Urgency set to high. + - control: Move liblzo2-dev from Build-Depends to Build-Conflicts + (leaving liblzo-dev as the only option). + + -- Robert Millan Sun, 10 Feb 2008 17:09:15 +0100 + +grub2 (1.96+20080209-1) unstable; urgency=low + + * New CVS snapshot. + - Fix a root device setting issue in grub-setup. (Closes: #463391) + - Fix partmap detection under LVM/RAID. + - Add scripting commands that would allow user to implement hiddenmenu-like + functionality (http://grub.enbug.org/Hiddenmenu). + - Provide manpages for grub-setup, grub-emu, grub-mkimage and others. + (Closes: #333516, #372890) + * Fix a pair of spelling errors in debconf templates. Thanks Christian + Perrier. (Closes: #464133) + * Run debconf-updatepo. (Closes: #463918) + * Lower base-files versioned dependency to >= 4.0.1~bpo40+1. + + -- Robert Millan Sat, 9 Feb 2008 13:43:49 +0100 + +grub2 (1.96+20080203-1ubuntu2) hardy; urgency=low + + * Update 03_ubuntu_grub_standards. + - Don't show splash screen or quiet mode in single user mode. + + -- Mario Limonciello Wed, 05 Mar 2008 19:05:04 -0600 + +grub2 (1.96+20080203-1ubuntu1) hardy; urgency=low + + * debian/default/grub + - Show lsb_release rather than statically displaying "Debian" (LP: #192955) + - Include Ubuntu specific "quiet splash" on default grub command line. + (LP: #193024) + * debian/patches: + - Add 03_ubuntu_grub_standards to remove GNU/Linux from the + default string. (LP: #192955) + - Add 04_convert_root_uuid.diff to default to using UUIDs + on new GRUB2 installations. (LP: #192956) + * debian/control: + - Update maintainer per XSBC-Original-Maintainer spec. + + -- Mario Limonciello Mon, 18 Feb 2008 14:05:06 -0600 + +grub2 (1.96+20080203-1) unstable; urgency=low + + * New CVS snapshot (and release, but we skipped that ;-)) + - patches/01_regparm.diff: Delete. + - Improved XFS support. + - util/grub.d/00_header.in: Add runtime error detection (for gfxterm). + - Fixes problem when chainloading to Vista. + * Fix po-debconf errors. Thanks Thomas Huriaux. (Closes: #402972) + * grub.d/05_debian_theme: + - Add runtime error detection. + - Detect/Enable PNG background when it is present. + * control (grub-ieee1275): Remove versioned dependency on powerpc-ibm-utils. + + -- Robert Millan Sun, 3 Feb 2008 19:31:23 +0100 + +grub2 (1.95+20080201-1) unstable; urgency=low + + * New CVS snapshot. + * presubj: Improve notice. + * patches/01_regparm.diff: Fix CPU context corruption affecting fs/xfs.c. + (Closes: #463081, #419766, #462159) + * patches/02_libgcc_powerpc_hack.diff: Fix FTBFS on powerpc. (Closes: #457491) + * patches/disable_xfs.diff: Actually remove this time... + + -- Robert Millan Fri, 1 Feb 2008 17:06:00 +0100 + +grub2 (1.95+20080128-1) unstable; urgency=low + + * New CVS snapshot. + - Fixes bogus CLAIM problems on Apple firmware. (Closes: #449135, #422729) + - grub-probe performs sanity checks to make sure our filesystem drivers + are usable. (Closes: #462449) + - patches/disable_ata.diff: Remove. ATA module isn't auto-loaded in + rescue floppies now. + - patches/disable_xfs.diff: Remove. See above (about grub-probe). + * Bring back grub-emu; it can help a lot with debugging feedback. + - control + - rules + + -- Robert Millan Mon, 28 Jan 2008 00:01:11 +0100 + +grub2 (1.95+20080116-2) unstable; urgency=low + + * grub.d/05_debian_theme: Enable swirlish beauty. + * rules: Obtain debian/legacy/update-grub dynamicaly from GRUB Legacy svn. + + -- Robert Millan Sat, 19 Jan 2008 13:16:18 +0100 + +grub2 (1.95+20080116-1) unstable; urgency=low + + * New CVS snapshot. + - update-grub ignores stale *.dpkg-* files. (Closes: #422708, #424223) + - LVM/RAID now working properly (except when it affects /boot). + (Closes: #425666) + - Fixes flickery in timeout message. (Closes: #437275) + * grub-pc.postinst: Use `--no-floppy' whenever possible. Die, floppies, + die! + * Resync with latest version of GRUB Legacy's update-grub. This time, + using the $LET_US_TRY_GRUB_2 hack to reuse the same script both for + addition of core.img and its removal. + * grub-*.install: Add update-grub2 stub. Packages providing /etc/grub.d/ + scripts should invoke update-grub2 in both postinst and postrm (whenever + it is found, of course). + * control: Reorganize a bit, including a complete rewrite of the + package descriptions. + * control (grub-ieee1275): Enable for i386/amd64. + + -- Robert Millan Wed, 16 Jan 2008 15:00:54 +0100 + +grub2 (1.95+20080107-1) unstable; urgency=low + + * New CVS snapshot. + - Supports ReiserFS. (Closes: #430742) + - patches/disable_ata.diff: Resync. + + -- Robert Millan Mon, 7 Jan 2008 12:46:39 +0100 + +grub2 (1.95+20080105-2) unstable; urgency=low + + * grub-pc.postinst: Fix covered assumption that menu.lst exists. + (Closes: #459247) + * copyright: Fix copyright/license reference. + + -- Robert Millan Sun, 6 Jan 2008 18:02:28 +0100 + +grub2 (1.95+20080105-1) unstable; urgency=low + + * New CVS snapshot. + - Fixes install on non-devfs systems with devfs-style paths (ouch). + (Closes: #450709). + - Fixes boot of "Linux" zImages (including memtest86+). (Closes: #436113). + - Corrects usage message in grub-setup. (Closes: #458600). + - patches/menu_color.diff: Remove. Made obsolete by `menu_color_normal' + and `menu_color_highlight' variables. Add/install grub.d/05_debian_theme + to make use of them. + * Reestructure grub-pc.postinst. Notably: + - Do not touch menu.lst unless user has confirmed it (via debconf). + (Closes: #459247) + - When we do, keep a backup in /boot/grub/menu.lst_backup_by_grub2_postinst. + + -- Robert Millan Sat, 5 Jan 2008 17:55:37 +0100 + +grub2 (1.95+20080101-1) unstable; urgency=low + + * New CVS snapshot. + - patches/disable_xfs.diff: Rewrite in a way that won't collide with + upstream changes so often. + - unifont.hex now processed by upstream. + - rules: Disable build of unifont.pff. + - *.install: Remove build/unifont.pff line. + - patches/menu_color.diff: Change menu color to our traditional blue theme. + * Support new dpkg fields (Homepage, Vcs-Svn, Vcs-Browser). + * patches/disable_ata.diff: Prevent ATA module from being built on i386-pc. + + -- Robert Millan Tue, 1 Jan 2008 19:45:30 +0100 + +grub2 (1.95+20071101-1) unstable; urgency=low + + * New CVS snapshot. + - patches/linuxbios.diff: Remove (supported in upstream now). + + -- Robert Millan Thu, 1 Nov 2007 13:18:51 +0100 + +grub2 (1.95+20071004-2) unstable; urgency=low + + * Rename debian/grub-of.* to debian/grub-ieee1275.*. + * Add debian/grub-linuxbios.{postinst,dirs,install}. + * rules: Fix/Overrride lintian warnings (unstripped-binary-or-object). + * Remove grub-linuxbios.postinst. + + -- Robert Millan Wed, 10 Oct 2007 23:56:35 +0200 + +grub2 (1.95+20071004-1) unstable; urgency=low + + * New CVS snapshot. + * Add grub-linuxbios package. + - patches/linuxbios.diff + - control + - rules + * Rename grub-of to grub-ieee1275 to match with upstream conventions. + - control + - rules + + -- Robert Millan Thu, 4 Oct 2007 14:42:30 +0200 + +grub2 (1.95+20070829-1) unstable; urgency=low + + * New CVS snapshot. + - Includes fix for parallel builds. + * rules: Append -j flag to $(MAKE) to take advantage of >1 processors. + * Add reference to /usr/share/common-licenses. + - debian/copyright + - debian/control (all packages): Add base-files (>= 4.0.1) dependency. + + -- Robert Millan Sat, 1 Sep 2007 19:00:22 +0200 + +grub2 (1.95+20070828-2) unstable; urgency=low + + * control (grub-of): Make depends on powerpc-ibm-utils versioned as + >= 1.0.6 (older versions don't have -a flag). + + -- Robert Millan Tue, 28 Aug 2007 23:32:32 +0200 + +grub2 (1.95+20070828-1) unstable; urgency=low + + * New CVS snapshot. + - Adds ntfs support. + - Fixes a pair of issues indirectly breaking grub-probe on powerpc. + (Closes: #431488) + - patches/disable_xfs.diff: Resync. + - copyright: License upgraded to GPLv3. + * control (grub-of Depends): Add powerpc-utils (for nvsetenv) and bc. + + -- Robert Millan Tue, 28 Aug 2007 21:24:14 +0200 + +grub2 (1.95+20070626-1) unstable; urgency=low + + * New CVS snapshot. + - More fixes to cope with unreadable /. (Closes: #427289) + - update-grub supports multiple terminals. + * control (Build-Depends): Add genisoimage. + * patches/partmap_fallback.diff: Remove. It didn't archieve anything as + it also needs support for proper identification of raid / lvm (this is + being worked on). + * patches/disable_xfs.diff: Disable xfs in grub-probe. + * grub-rescue-pc.README.Debian: New. Explain how to use the rescue + images. + + -- Robert Millan Tue, 26 Jun 2007 08:39:14 +0200 + +grub2 (1.95+20070614-1) unstable; urgency=low + + * New CVS snapshot. + - update-grub is tollerant to unreadable / (as long as /boot is + accessible). (Closes: #427289) + * grub-pc.postinst: Generate new grub.cfg when menu.lst exists. + * New package grub-rescue-pc. + - control: Add it. + - README.Debian.in: Remove obsolete documentation. + - rules: Build rescue images using grub-mkrescue. + - grub-rescue-pc.dirs: Prepare their directory. + - grub-rescue-pc.install: Install them. + * legacy/update-grub: Fix core.img detection on separate /boot. + + -- Robert Millan Thu, 14 Jun 2007 08:17:21 +0200 + +grub2 (1.95+20070604-1) unstable; urgency=low + + * New CVS snapshot. + - patches/grub_probe_for_everyone.diff: Remove (merged). + - update-grub exports user-defined GRUB_CMDLINE_LINUX. (Closes: #425453) + - Fix those nasty powerpc bugs. (Closes: #422729) + + -- Robert Millan Mon, 4 Jun 2007 21:30:55 +0200 + +grub2 (1.95+20070520-1) unstable; urgency=low + + * New CVS snapshot. + - LVM / RAID fixes. (Closes: #423648, #381150) + - Fix memory management bug. (Closes: #423409) + - patches/efi.diff: Remove (merged). + - patches/grub_probe_for_everyone.diff: Use the new paths for + util/grub-probe.c, util/biosdisk.c, util/getroot.c. Enable + grub-mkdevicemap. (Closes: #424985) + * legacy/update-grub: Get rid of all grub-set-default calls. (Closes: #425054) + * grub-{pc,efi,of}.postinst: Only run update-grub if grub.cfg already exists. + * grub-pc.postinst: Only run GRUB Legacy compat stuff if menu.lst is found. + * patches/partmap_fallback.diff: New. Implement fallback "pc gpt" for partmap + detection failures. (Closes: #423022) + * control: Update XS-Vcs-* fields. Thanks Sam Morris . + (Closes: #425146) + * grub-{pc,efi,of}.{dirs,postinst}: Move unifont.pff to /usr/share/grub. + + -- Robert Millan Sun, 20 May 2007 11:13:03 +0200 + +grub2 (1.95+20070515-1) unstable; urgency=low + + * New CVS snapshot. + - Fix assumptions about /, /boot and /boot/grub being the same device. + (Closes: #423268, #422459) + - Proper sorting of Linux images. (Closes: #422580) + - update-grub lets /etc/default/grub override its variables now. + (Closes: #423649) + - update-grub mentions /etc/default/grub in the grub.cfg header. + (Closes: #423651) + - update-grub sets 800x600x16 as the default gfxmode. (Closes: #422794) + - update-grub runs grub-mkdevicemap before attempting to use grub-probe + (part of #423217) + + [ Otavio Salvador ] + * Add support to DEB_BUILD_OPTIONS=noopt. Thanks to Sam Morris + for the patch. (Closes: #423005) + * Add Robert Millan as uploader. + * Change build-dependency from liblzo-dev to liblzo2-dev. (Closes: #423358) + + [ Robert Millan ] + * grub-pc.postinst: + - Remove /boot/grub/device.map before running grub-install. + (Closes: #422851) + - Always run update-grub after grub-install. (part of #423217) + - Use grub-mkdevicemap instead of removing device.map, since update-grub + needs it but grub-install is not run unconditionaly. + - Redirect grub-install invocation to /dev/null, since it can mislead + users into thinking that MBR was overwritten. (part of #423217) + * default/grub: Stop exporting the variables (update-grub does that now). + * Misc EFI fixes, including new grub-install. + - patches/efi.diff: New. + - patches/grub_probe_for_everyone.diff: Move some bits to efi.diff. + - grub-efi.install: Stop installing dummy grub-install. + - grub-install: Remove. + * grub-pc.postinst: Avoid generating core.img when menu.lst is not present, + to avoid duplicated work (this is specialy important for d-i). (part of + #423217). + * See multiple references above. (Closes: #423217) + * grub-{pc,efi,of}.{dirs,install}: Install presubj in the right directory + to make it work again (oops). + * Add reportbug script to gather debugging information. (Closes: #423218) + - script: New. + - grub-{pc,efi,of}.install: Install it. + * Install the reportbug scripts for grub2 too, since users might still use + it for bugfiling. + - grub2.dirs + - grub2.install + * Fix some lintian warnings. + - control (grub2): Depend on debconf. + - README.Debian.in: Fix mispell. + - grub2.templates: Remove extra dot. + + -- Robert Millan Tue, 15 May 2007 22:08:53 +0200 + +grub2 (1.95+20070507-1) unstable; urgency=low + + [ Robert Millan ] + * New CVS snapshot. + - patches/build_neq_src.diff: Remove (merged). + * Fix debhelper files to ensure each package gets the right thing. + * Enable gfxterm/unifont support. + * On grub-pc, if there's no core.img setup, create one (but do not + risk writing to MBR). + * On grub-pc, if menu.lst is found, regenerate it to include our + core.img. + + [ Otavio Salvador ] + * Move debian/update-grub to debian/legacy/update-grub otherwise the + source gets messy. + + -- Otavio Salvador Mon, 07 May 2007 18:48:14 -0300 + +grub2 (1.95+20070505.1-3) unstable; urgency=low + + * Split postinst into grub2.postinst (with the transition warning) and + postinst.in, with update-grub invocation for grub-{pc,efi,of}. + - postinst.in + - grub2.postinst + - rules + + -- Robert Millan Sun, 6 May 2007 01:20:04 +0200 + +grub2 (1.95+20070505.1-2) unstable; urgency=low + + * Add EFI build of GRUB. + - control: Restructure to provide 3 packages: grub-pc (x86), + grub-efi (x86) and grub-of (powerpc). + - rules: Handle a separate build for each package. + - patches/build_neq_src.diff: Fix builddir == srcdir assumptions. + - patches/grub_probe_for_everyone.diff: New (superceds + powerpc_probe.diff). Enable grub-probe on powerpc and i386-efi. + - grub-install: Dummy informational grub-install for EFI. + - grub-efi.install: Installs it. + + -- Robert Millan Sun, 6 May 2007 00:23:56 +0200 + +grub2 (1.95+20070505.1-1) unstable; urgency=low + + * New CVS snapshot. + * patches/powerpc_probe.diff: Add partmap/gpt.c to grub-probe. + * control (Architecture): Temporarily disable powerpc. Sorry, but runtime + is currently broken and we don't have the hardware to debug it. Will be + re-enabled in next upload. + + -- Robert Millan Sat, 5 May 2007 21:52:49 +0200 + +grub2 (1.95+20070505-1) unstable; urgency=low + + * New CVS snapshot. + - Improved grub.cfg parser. (Closes: #381215) + - patches/fix-grub-install.diff: Remove (merged). + - control (Build-Depends): Remove libncurses5-dev (no longer needed). + - provides update-grub2. (Closes: #419151) + - Supports GPT in PC/BIOS systems. (Closes: #409073) + * control (Build-Depends): Add gcc-multilib to fix FTBFS. + * control (Description): Make it less scary, and more informative. + * postinst: Run update-grub to ensure the latest improvements always are + applied. + * patches/powerpc_probe.diff: Attempt at making grub-probe build/install + on powerpc (and hopefuly update-grub). + + -- Robert Millan Sat, 5 May 2007 01:49:07 +0200 + +grub2 (1.95-5) unstable; urgency=low + + * Fix FTBFS on kFreeBSD. Thanks to Aurelien Jarno + by providing the patch. Closes: #416408 + + -- Otavio Salvador Fri, 30 Mar 2007 19:20:48 -0300 + +grub2 (1.95-4) unstable; urgency=low + + * Fix powerpc grub-install binary path. Closes: #402838 + + -- Otavio Salvador Thu, 22 Mar 2007 23:45:56 -0300 + +grub2 (1.95-3) unstable; urgency=low + + [ Christian Perrier ] + * Switch to po-debconf for debconf templates. Closes: #402972 + * Depend on ${misc:Depends} and not "debconf" to allow cdebconf to be used + * Debconf translations: + - French + - Czech. Closes: #413327 + - Galician. Closes: #413323 + - Swedish. Closes: #413325 + - Portuguese. Closes: #413332 + - German. Closes: #413365 + - Tamil. Closes: #413478 + - Russian. Closes: #413542 + - Italian. Closes: #413904 + - Romanian. Closes: #414443 + + -- Otavio Salvador Tue, 20 Mar 2007 23:46:38 -0300 + +grub2 (1.95-2) unstable; urgency=low + + [ Robert Millan ] + * update-grub: Fix for Xen hypervisor entries, thanks Aaron Schrab. + (Closes: #394706) + * Transition to new numbering scheme for partitions. (Closes: #395019) + - update-grub: Don't substract 1 when converting partition device names to + grub drives. + - Add debconf warning explaining the situation. + * Rewrite Architecture line back to hardcoded list :(. (Closes: #398060) + + -- Otavio Salvador Mon, 11 Dec 2006 05:08:41 -0200 + +grub2 (1.95-1) unstable; urgency=low + + * New upstream release. + - patches/03_revert_partition_numbering.diff: Delete (obsoleted). + + -- Robert Millan Sat, 14 Oct 2006 21:19:21 +0200 + +grub2 (1.94+20061003-1) unstable; urgency=high + + * New CVS snapshot. + + [ Otavio Salvador ] + * Change debhelper compatibility mode to 5: + - debian/compat: setted to 5; + * control (Build-Depends): Add lib32ncurses5-dev for ppc64. + Closes: #389873 + * Set urgency=high since it's experimental stuff and tagged likewise. It + also solved a serious bug on PowerPC that leave users with a black + screen. + + [ Robert Millan ] + * control (Depends): Add powerpc-ibm-utils for powerpc/ppc64. + (Closes: #372186) + + -- Otavio Salvador Tue, 3 Oct 2006 16:49:32 -0300 + +grub2 (1.94+20060926-1) unstable; urgency=high + + * New CVS snapshot. + - Command-line editting fix (Closes: #381214). + - Fixes runtime breakage on amd64 (not in BTS). + - Delete a few patches (merged). + + [ Robert Millan ] + * Set urgency=high. Might seem like a rush, but it can't possibly be worse than + 1.94-5 (broken on systems that use udev, broken on amd64...). + * Pure ppc64 support. + - control (Architecture): Add any-ppc64. + - control (Build-Depends): Add libc6-dev-powerpc [ppc64]. + * rules: Remove moddep.lst install command (no longer needed). + * patches/03_revert_partition_numbering.diff: New. Revert a commit that + broke grub-probefs. + * Add bug template to encourage sending upstream stuff directly to + upstream. + - presubj: New. + + [ Otavio Salvador ] + * Add XS-X-Vcs-Svn on control file and point it to our current svn + repository. + * Add cvs-snapshot to rules. + + -- Otavio Salvador Tue, 26 Sep 2006 16:14:36 -0300 + +grub2 (1.94-6) unstable; urgency=low + + [ Robert Millan ] + * update-grub: Set interpreter to /bin/bash to cope with non-POSIX + extensions. (mentioned in #361929) + * patches/03_avoid_recursing_into_dot_static.diff: New. Avoid recursing into + dotdirs (e.g. ".static"). + * patches/04_mkdevicemap_dont_assume_floppies.diff: New. Don't assume + /dev/fd0 exists when generating device.map. + + -- Otavio Salvador Thu, 14 Sep 2006 16:07:30 -0300 + +grub2 (1.94-5) unstable; urgency=low + + [ Robert Millan ] + * control (Build-Depends): s/any-amd64/amd64 kfreebsd-amd64/g (this seems to + confuse buildds). + * 02_not_remove_menu_lst.patch: New patch. Skip menu.lst removal in + grub-install. (Closes: #372934) + + -- Otavio Salvador Sun, 20 Aug 2006 12:02:13 -0300 + +grub2 (1.94-4) unstable; urgency=low + + [ Otavio Salvador ] + * 01_fix_amd64_building.patch: dropped since it now supports amd64 + native building. + * Remove convert_kernel26 usage since it's not necessary anymore and due + initramfs-tools changes it's bug too. + + [ Robert Millan ] + * Fork update-grub from grub legacy, and tweak a few commands in output to + make it work for grub2. + * Update README.Debian.in with more recent (and easier) install instructions. + * Add grub to Conflicts/Replaces. Too many commands with the same name, + even if they don't use the same path yet (but will likely do in the + future, see #361929). + * Get rid of control.in, which I introduced in 0.6+20040805-1 and turned out + to be an endless source of problems (and forbidden by policy as well). + * Fix FTBFS on amd64. Really closes: #372548. + + -- Otavio Salvador Fri, 18 Aug 2006 15:38:25 -0300 + +grub2 (1.94-3) unstable; urgency=low + + * Fix FTBFS in amd64. Closes: 372548 + + -- Otavio Salvador Sat, 10 Jun 2006 19:57:01 -0300 + +grub2 (1.94-2) unstable; urgency=low + + * Update grub images paths in README.Debian + * 01_fix_grub-install.patch: add to fix a problem with PowerPC + installation. Refs: #371069 + * Fix FTBFS in amd64. Closes: #370803 + + -- Otavio Salvador Fri, 9 Jun 2006 09:29:40 -0300 + +grub2 (1.94-1) unstable; urgency=low + + * New upstream release. + - Fix powerpc building. Closes: #370259 + - 01_fix_grub-install.patch: merged upstream. + - Moved modules to /usr/lib/grub since they are architecture + dependent. + * Leave CDBS set debhelper compatibility level. + * Allow amd64 build to happen. Closes: #364956 + * Enforce building in 32bits while running in x86_64 machines. + * Update Standards version to 3.7.2. No changes need. + + -- Otavio Salvador Mon, 5 Jun 2006 12:49:09 -0300 + +grub2 (1.93-1) unstable; urgency=low + + * New upstream release. + - Added support to PowerPC. Closes: #357853 + - 01_fix_grub-install.patch: rediff. + * Update Standards version to 3.6.2. No changes need. + * Start to use new dpkg architecture definition. Closes: #360134 + + -- Otavio Salvador Sat, 1 Apr 2006 10:07:17 -0300 + +grub2 (1.92-2) unstable; urgency=low + + * Add bison on build-depends field. Closes: #346178 + * Add more fixes in 01_fix_grub-install.patch. Closes: #346177 + + -- Otavio Salvador Fri, 6 Jan 2006 09:48:08 -0200 + +grub2 (1.92-1) unstable; urgency=low + + * New upstream release. + - Add support for GPT partition table format. + - Add a new command "play" to play an audio file on PC. + - Add support for Linux/ADFS partition table format. + - Add support for BASH-like scripting. + - Add support for Apple HFS+ filesystems. + * 01_fix_grub-install.patch: Added. Fix grub-install to use + /bin/grub-mkimage instead of /sbin/grub-mkimage. Closes: #338824 + * Do not use CDBS tarball mode anymore. Closes: #344272 + + -- Otavio Salvador Thu, 5 Jan 2006 15:20:40 -0200 + +grub2 (1.91-0) unstable; urgency=low + + * New upstream release. Closes: #331211 + * debian/watch: added. + * debian/control.in, debian/control: Add libncurses5-dev in + Build-Depends. Closes: #304638 + * Remove Robert Millan as uploader; + * Add myself as uploader; + + -- Otavio Salvador Sat, 12 Nov 2005 16:35:18 -0200 + +grub2 (0.6+20050203-2) unstable; urgency=low + + * Disable for powerpc. Reportedly it fails to boot. + + -- Robert Millan Fri, 4 Feb 2005 01:52:09 +0100 + +grub2 (0.6+20050203-1) unstable; urgency=low + + * New upstream snapshot. + * Install moddep.lst properly in a cpu-independant way. (Closes: #264115) + * Use cdbs debian/control autogeneration. + - Set DEB_AUTO_UPDATE_DEBIAN_CONTROL = yes. + - Move control to control.in. + - Add a @cdbs@ tag and replace Architecture with Cpu/System. + * control.in (Build-Depends): Add ruby. + + -- Robert Millan Thu, 3 Feb 2005 22:33:39 +0100 + +grub2 (0.6+20040805-1) unstable; urgency=low + + * New upstream snapshot. + * Uploading to unstable so that powerpc users can be blessed by GRUB too. + * Use type-handling to generate dpkg arch list. + - control.in + - rules + + -- Robert Millan Thu, 5 Aug 2004 20:50:16 +0200 + +grub2 (0.6+20040502-1) experimental; urgency=low + + * New upstream snapshot. + - Fix FTBFS on powerpc. + + -- Robert Millan Sun, 2 May 2004 18:16:29 +0200 + +grub2 (0.6+20040429-1) experimental; urgency=low + + * New upstream snapshot. + - control (Architecture): Add powerpc. + + -- Robert Millan Thu, 29 Apr 2004 20:41:31 +0200 + +grub2 (0.6+20031125-1) experimental; urgency=low + + * New upstream snapshot. + - patches/multiboot.diff: Nuked. + - install,docs: Update directory name. + * control (Maintainer): Set to pkg-grub-devel mailing list. + * control (Uploaders): Add myself. + * control (Architecture): Add freebsd-i386 and netbsd-i386. + + -- Robert Millan Tue, 25 Nov 2003 23:48:18 +0100 + +grub2 (0.6+20031114-1) experimental; urgency=low + + * New upstream snapshot. + - README.Debian: s/fat/ext2/g (We now have ext2fs support). + * Add multiboot support, thanks to Jeroen Dekkers for his patch. + - patches/multiboot.diff: New. + - control (Architecture): Add hurd-i386 (which needed multiboot). + * Rename package to grub2 (to follow upstream tendency). + - control: Ditto. + - README.Debian: Likewise. + * Switch to tarball mode. + - rules: Ditto. + - docs: Prefix paths in order to workaround dh_installdocs bug. + - install: Likewise, but not because of bug (should be in rules, actualy). + * Fix FTBFS. (Closes: #213868) + - control (Build-Depends): Add autoconf. + - control (Build-Conflicts): Add autoconf2.13. + + -- Robert Millan Fri, 14 Nov 2003 13:16:12 +0100 + +pupa (0.6+20031008-1) experimental; urgency=low + + * New upstream snapshot. + * Uploading to experimental. + * debian/control: Add Jason Thomas to Uploaders. + + -- Robert Millan Wed, 8 Oct 2003 13:22:50 +0000 + +pupa (0.6+20030915-1) unstable; urgency=low + + * Initial Release. (Closes: #211030) + + -- Robert Millan Mon, 15 Sep 2003 14:58:42 +0000 --- grub2-1.97~beta4.orig/debian/grub2.install +++ grub2-1.97~beta4/debian/grub2.install @@ -0,0 +1,2 @@ +debian/presubj usr/share/bug/grub2 +debian/script usr/share/bug/grub2 --- grub2-1.97~beta4.orig/debian/install.in +++ grub2-1.97~beta4/debian/install.in @@ -0,0 +1,6 @@ +debian/presubj usr/share/bug/@PACKAGE@ +debian/script usr/share/bug/@PACKAGE@ +debian/default usr/share/grub +debian/grub.d etc +debian/update-grub2 usr/sbin +debian/update-grub usr/sbin --- grub2-1.97~beta4.orig/debian/presubj +++ grub2-1.97~beta4/debian/presubj @@ -0,0 +1,23 @@ + +MAKE SURE YOU ARE RUNNING THE LATEST VERSION + +The grub packages never updates the installed version of GRUB +automatically, except if you choose a device in the debconf prompt +`GRUB install devices', which is currently only implemented for grub-pc. + +Because of this, you need to make sure you're running the LATEST VERSION of +GRUB before you report a bug. Use grub-install to update it, and then check +if the bug still applies. Debugging problems we already fixed makes us waste +valuable time, so please try to avoid it. + +IMPORTANT NOTE WHEN SUBMITING PATCHES + +Like many other FSF projects, GRUB upstream has specific requisites for +accepting patches with regard to copyright assignment. If you're going to +submit a patch, it is likely that it will only be accepted in upstream if you're +willing to submit your paperwork as well. + +Because of this, we want to avoid diverging from upstream by adding patches to +the debian package unless we know the copyright issues can be sorted out. We +encourage you to submit your work to upstream directly by sending a mail to the +GRUB maintainers . --- grub2-1.97~beta4.orig/debian/watch +++ grub2-1.97~beta4/debian/watch @@ -0,0 +1,2 @@ +version=3 +ftp://alpha.gnu.org/gnu/grub/grub-([a-z0-9.~]+).tar.gz debian uupdate --- grub2-1.97~beta4.orig/debian/rules +++ grub2-1.97~beta4/debian/rules @@ -0,0 +1,185 @@ +#!/usr/bin/make -f + +SHELL := bash +package := grub2 + +DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null) + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/simple-patchsys.mk + +CFLAGS := -g -Wall + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +CC := gcc-4.4 + +# grub-extras components +export enable_zfs := yes +export enable_915resolution := yes + +CONFIGURE = CC=$(CC) \ + $(CURDIR)/configure --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --includedir="\$${prefix}/include" \ + --mandir="\$${prefix}/share/man" --infodir="\$${prefix}/share/info" --sysconfdir=/etc --localstatedir=/var \ + --libexecdir="\$${prefix}/lib/$(package)" --srcdir=$(CURDIR) \ + --enable-grub-emu --enable-grub-mkfont --disable-grub-fstest + +DEB_UPDATE_RCD_PARAMS_grub-common += start 99 2 3 4 5 . + +AUTOGEN_FILES = configure config.h.in conf/*.mk +AUTOGEN_DEB_FILES = docs examples manpages config templates postinst postrm dirs install + +$(AUTOGEN_FILES): autogen.sh configure.ac conf/*.rmk + ./autogen.sh + +configure/grub-pc configure/grub-ieee1275 configure/grub-coreboot:: $(AUTOGEN_FILES) + mkdir -p $(subst configure/,build/,$@) + cd $(subst configure/,build/,$@) && $(CONFIGURE) --with-platform=$(subst configure/grub-,,$@) + +# This name scheme leaves room for things like ia64 or amd32 someday +configure/grub-efi-ia32:: $(AUTOGEN_FILES) + mkdir -p $(subst configure/,build/,$@) + cd $(subst configure/,build/,$@) && $(CONFIGURE) --with-platform=efi --target=i386-pe --program-prefix="" +configure/grub-efi-amd64:: $(AUTOGEN_FILES) + mkdir -p $(subst configure/,build/,$@) + cd $(subst configure/,build/,$@) && $(CONFIGURE) --with-platform=efi --target=amd64-pe --program-prefix="" + +configure/grub-firmware-qemu:: $(AUTOGEN_FILES) + mkdir -p $(subst configure/,build/,$@) + cd $(subst configure/,build/,$@) && $(CONFIGURE) --with-platform=qemu + +configure/grub-common configure/grub-emu:: $(AUTOGEN_FILES) + mkdir -p $(subst configure/,build/,$@) + cd $(subst configure/,build/,$@) && $(CONFIGURE) + +build/grub-common build/grub-pc build/grub-efi-ia32 build/grub-efi-amd64 build/grub-ieee1275 build/grub-coreboot:: + $(MAKE) -C $@ + +build/grub-emu:: + $(MAKE) -C $@ grub-emu + +build/grub-rescue-pc:: build/grub-pc + mkdir -p $@ + mkdir -p $@/rescue-disk/boot/grub + cp docs/grub.cfg $@/rescue-disk/boot/grub/ + $(CURDIR)/build/grub-pc/grub-mkrescue \ + --pkglibdir=$(CURDIR)/build/grub-pc \ + --grub-mkimage=$(CURDIR)/build/grub-pc/grub-mkimage \ + --overlay=$@/rescue-disk/ \ + --image-type=floppy \ + $(CURDIR)/$@/grub-rescue-floppy.img + $(CURDIR)/build/grub-pc/grub-mkrescue \ + --pkglibdir=$(CURDIR)/build/grub-pc \ + --grub-mkimage=$(CURDIR)/build/grub-pc/grub-mkimage \ + --overlay=$@/rescue-disk/ \ + --image-type=cdrom \ + $(CURDIR)/$@/grub-rescue-cdrom.iso + +build/grub-firmware-qemu:: + $(MAKE) -C $@ + grub_dir=`mktemp -d` ; \ + grub_memdisk=`mktemp` ; \ + mkdir -p $${grub_dir}/boot/grub ; \ + cp debian/grub-firmware-qemu_grub.cfg $${grub_dir}/boot/grub/grub.cfg ; \ + tar -cf - -C $${grub_dir} boot > $${grub_memdisk} ; \ + $(CURDIR)/$@/grub-mkimage \ + -d $(CURDIR)/$@ \ + $(CURDIR)/$@/*.mod \ + -m $${grub_memdisk} \ + -o $(CURDIR)/$@/grub.bin + +install/grub-emu:: + mkdir -p $(CURDIR)/debian/$(subst install/,,$@)/usr/sbin + install -m755 build/grub-emu/grub-emu $(CURDIR)/debian/$(subst install/,,$@)/usr/sbin/grub-emu + +install/grub-pc install/grub-efi-ia32 install/grub-efi-amd64 install/grub-ieee1275 install/grub-coreboot:: + $(MAKE) -C $(subst install/,build/,$@) install DESTDIR=$(CURDIR)/debian/$(subst install/,,$@)/ + + # shipped with grub-common + rm -rf $(CURDIR)/debian/$(subst install/,,$@)/etc/grub.d + rm -f $(CURDIR)/debian/$(subst install/,,$@)/usr/{sbin,share/man/man8}/{grub-dumpbios,grub-probe,grub-emu,grub-mkconfig,grub-mkdevicemap,grub-ofpathname}{,.8} + rm -f $(CURDIR)/debian/$(subst install/,,$@)/usr/{bin,share/man/man1}/{grub-mkelfimage,grub-mkfont,grub-editenv}{,.1} + rm -f $(CURDIR)/debian/$(subst install/,,$@)/usr/lib/grub/{grub-mkconfig_lib,update-grub_lib} + rm -rf $(CURDIR)/debian/$(subst install/,,$@)/usr/share/{grub,info}/ + rm -rf $(CURDIR)/debian/$(subst install/,,$@)/usr/include + + for i in $(AUTOGEN_DEB_FILES) ; do \ + sed debian/$$i.in \ + -e "s/@PACKAGE@/$(subst install/,,$@)/g" \ + > debian/$(subst install/,,$@).$$i ; \ + done + + # grub-pc is a bit special. It includes a few overlays for autogen files. + if [ "$@" = "install/grub-pc" ] ; then \ + for i in templates install dirs ; do \ + cat debian/grub-pc.$$i.in >> debian/grub-pc.$$i ; \ + done ; \ + fi + + if [ "$@" != "install/grub-pc" ] && [ "$(DEB_HOST_ARCH_CPU)" != "sparc" ] ; then \ + i=$(CURDIR)/debian/$(subst install/,,$@)/usr/lib/grub/*/kernel.img ; if test -e $$i ; then strip -s $$i ; fi \ + fi + + mkdir -p $(CURDIR)/debian/$(subst install/,,$@)/usr/share/lintian/overrides + echo "$(subst install/,,$@): unstripped-binary-or-object *.mod" \ + >> $(CURDIR)/debian/$(subst install/,,$@)/usr/share/lintian/overrides/$(subst install/,,$@) + if [ "$@" != "install/grub-pc" ] && [ "$(DEB_HOST_ARCH_CPU)" != "sparc" ] ; then \ + cd $(CURDIR)/debian/$(subst install/,,$@) && find ./usr/lib/grub -name kernel.img \ + | sed -e "s%.*%$(subst install/,,$@): statically-linked-binary &%g" \ + >> $(CURDIR)/debian/$(subst install/,,$@)/usr/share/lintian/overrides/$(subst install/,,$@) ; \ + fi + if [ "$@" = "install/grub-efi-amd64" ] && [ "$(DEB_HOST_ARCH_CPU)" = "i386" ] ; then \ + echo "$(subst install/,,$@): binary-from-other-architecture *.mod" \ + >> $(CURDIR)/debian/$(subst install/,,$@)/usr/share/lintian/overrides/$(subst install/,,$@) ; \ + fi + if [ "$@" = "install/grub-pc" ] && [ "$(DEB_HOST_ARCH_CPU)" = "i386" ] ; then \ + echo "$(subst install/,,$@): binary-from-other-architecture *efiemu64.o" \ + >> $(CURDIR)/debian/$(subst install/,,$@)/usr/share/lintian/overrides/$(subst install/,,$@) ; \ + fi + +install/grub-common:: + $(MAKE) -C $(subst install/,build/,$@) install DESTDIR=$(CURDIR)/debian/$(subst install/,,$@)/ + rm -rf $(CURDIR)/debian/$(subst install/,,$@)/usr/lib/grub/{i386,powerpc,sparc64}-* + rm -f $(CURDIR)/debian/$(subst install/,,$@)/usr/{sbin,share/man/man8}/{update-grub,grub-install,grub-setup,grub-emu,grub-reboot,grub-set-default}{,.8} + rm -f $(CURDIR)/debian/$(subst install/,,$@)/usr/{bin,share/man/man1}/grub-{mkimage,mkrescue}{,.1} + rm -f $(CURDIR)/debian/$(subst install/,,$@)/usr/share/info/dir* + install -m 0755 debian/grub-common.pm-sleep $(CURDIR)/debian/$(subst install/,,$@)/etc/pm/sleep.d/10_grub-common + +clean:: debian/legacy/update-grub debian/grub-extras + chmod +x debian/{script,grub.d/*,legacy/*} + for i in $(AUTOGEN_DEB_FILES) ; do \ + rm -f debian/grub-{pc,efi-*,ieee1275,coreboot}.$$i ; \ + done + -rm -rf build + + # make sure PO files are always up-to-date + debconf-updatepo + +debian/legacy/update-grub: + @echo "Missing $@. Try: \"svn cat svn://svn.debian.org/pkg-grub/grub/trunk/debian/update-grub > $@\"" + exit 1 + +debian/grub-extras: + @echo "Missing $@. Try: \"svn export svn://svn.sv.nongnu.org/grub-extras/trunk $@\"" + exit 1 + +# Grab fixes from SVN using our version as reference. +svn-sync: + svn co svn://svn.sv.gnu.org/grub/trunk/grub2 grub2-svn; \ + UVERSION=$$(dpkg-parsechangelog | grep Version \ + | sed 's,Version: ,,g;s,-[0-9]*$$,,g;s,\.,_,g'); \ + cd grub2-svn && \ + svn diff -uN -r release_$$UVERSION -r HEAD > ../debian/patches/00_svn-sync.patch; \ + cd .. && rm -rf grub2-svn + +svn-snapshot: + UVERSION=$$(dpkg-parsechangelog | grep Version \ + | sed 's,Version: ,,g;s,-[0-9]*$$,,g'); \ + svn co svn://svn.sv.gnu.org/grub/trunk/grub2 grub2-$$UVERSION; \ + tar -czf grub2_$$UVERSION.orig.tar.gz grub2-$$UVERSION; \ + rm -rf grub2-$$UVERSION; \ + mv grub2_$$UVERSION.orig.tar.gz ../tarballs/ --- grub2-1.97~beta4.orig/debian/grub-extras/COPYING +++ grub2-1.97~beta4/debian/grub-extras/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. --- grub2-1.97~beta4.orig/debian/grub-extras/README +++ grub2-1.97~beta4/debian/grub-extras/README @@ -0,0 +1,19 @@ + +grub-extras is meant to be used as an overlay on grub2 source tree. + +Build instructions: + + - Copy grub-extras in a subdirectory of your grub2 checkout. + For example, "grub-extras". + + - Adjust autogen.sh to process grub-extras/conf/*.rmk files. + + - Adjust Makefile.in to include the grub-extras/conf/*.mk file + corresponding to your architecture. + Also export GRUB_EXTRAS variable, it should point to the top + level of your grub-extras directory. + + - Export enable_* variables for the components you want + (e.g. enable_zfs=yes). + + - Build GRUB as usual. --- grub2-1.97~beta4.orig/debian/grub-extras/commands/zfsinfo.c +++ grub2-1.97~beta4/debian/grub-extras/commands/zfsinfo.c @@ -0,0 +1,420 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2008 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static inline void +print_tabs (int n) +{ + int i; + + for (i = 0; i < n; i++) + grub_printf (" "); +} + +static grub_err_t +print_state (char *nvlist, int tab) +{ + grub_uint64_t ival; + int isok = 1; + + print_tabs (tab); + grub_printf ("State: "); + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_REMOVED, &ival)) + { + grub_printf ("removed "); + isok = 0; + } + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) + { + grub_printf ("faulted "); + isok = 0; + } + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_OFFLINE, &ival)) + { + grub_printf ("offline "); + isok = 0; + } + + if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival)) + grub_printf ("degraded "); + + if (isok) + grub_printf ("online"); + grub_printf ("\n"); + + return GRUB_ERR_NONE; +} + +static grub_err_t +print_vdev_info (char *nvlist, int tab) +{ + char *type = 0; + + type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE); + + if (!type) + { + print_tabs (tab); + grub_printf ("Incorrect VDEV: no type available\n"); + return grub_errno; + } + + if (grub_strcmp (type, VDEV_TYPE_DISK) == 0) + { + char *bootpath = 0; + char *path = 0; + char *devid = 0; + + print_tabs (tab); + grub_printf ("Leaf VDEV\n"); + + print_state (nvlist, tab); + + bootpath = + grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_PHYS_PATH); + print_tabs (tab); + if (!bootpath) + grub_printf ("Bootpath: unavailable\n"); + else + grub_printf ("Bootpath: %s\n", bootpath); + + path = grub_zfs_nvlist_lookup_string (nvlist, "path"); + print_tabs (tab); + if (!path) + grub_printf ("Path: unavailable\n"); + else + grub_printf ("Path: %s\n", path); + + devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID); + print_tabs (tab); + if (!devid) + grub_printf ("Devid: unavailable\n"); + else + grub_printf ("Devid: %s\n", devid); + grub_free (bootpath); + grub_free (devid); + grub_free (path); + return GRUB_ERR_NONE; + } + + if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0) + { + int nelm, i; + + nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm + (nvlist, ZPOOL_CONFIG_CHILDREN); + + print_tabs (tab); + if (nelm <= 0) + { + grub_printf ("Incorrect mirror VDEV\n"); + return GRUB_ERR_NONE; + } + grub_printf ("Mirror VDEV with %d children\n", nelm); + print_state (nvlist, tab); + + for (i = 0; i < nelm; i++) + { + char *child; + + child = grub_zfs_nvlist_lookup_nvlist_array + (nvlist, ZPOOL_CONFIG_CHILDREN, i); + + print_tabs (tab); + if (!child) + { + grub_printf ("Mirror VDEV element %d isn't correct\n", i); + continue; + } + + grub_printf ("Mirror VDEV element %d:\n", i); + print_vdev_info (child, tab + 1); + + grub_free (child); + } + } + + print_tabs (tab); + grub_printf ("Unknown VDEV type: %s\n", type); + + return GRUB_ERR_NONE; +} + +static grub_err_t +get_bootpath (char *nvlist, char **bootpath, char **devid) +{ + char *type = 0; + + type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE); + + if (!type) + return grub_errno; + + if (grub_strcmp (type, VDEV_TYPE_DISK) == 0) + { + *bootpath = grub_zfs_nvlist_lookup_string (nvlist, + ZPOOL_CONFIG_PHYS_PATH); + *devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID); + if (!*bootpath || !*devid) + { + grub_free (*bootpath); + grub_free (*devid); + *bootpath = 0; + *devid = 0; + } + return GRUB_ERR_NONE; + } + + if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0) + { + int nelm, i; + + nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm + (nvlist, ZPOOL_CONFIG_CHILDREN); + + for (i = 0; i < nelm; i++) + { + char *child; + + child = grub_zfs_nvlist_lookup_nvlist_array (nvlist, + ZPOOL_CONFIG_CHILDREN, + i); + + get_bootpath (child, bootpath, devid); + + grub_free (child); + + if (*bootpath && *devid) + return GRUB_ERR_NONE; + } + } + + return GRUB_ERR_NONE; +} + +static char *poolstates[] = { + [POOL_STATE_ACTIVE] = "active", + [POOL_STATE_EXPORTED] = "exported", + [POOL_STATE_DESTROYED] = "destroyed", + [POOL_STATE_SPARE] = "reserved for hot spare", + [POOL_STATE_L2CACHE] = "level 2 ARC device", + [POOL_STATE_UNINITIALIZED] = "uninitialized", + [POOL_STATE_UNAVAIL] = "unavailable", + [POOL_STATE_POTENTIALLY_ACTIVE] = "potentially active" +}; + +static grub_err_t +grub_cmd_zfsinfo (grub_command_t cmd __attribute__ ((unused)), int argc, + char **args) +{ + grub_device_t dev; + char *devname; + grub_err_t err; + char *nvlist = 0; + char *nv = 0; + char *poolname; + grub_uint64_t guid; + grub_uint64_t pool_state; + int found; + + if (argc < 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required"); + + if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')') + { + devname = grub_strdup (args[0] + 1); + if (devname) + devname[grub_strlen (devname) - 1] = 0; + } + else + devname = grub_strdup (args[0]); + if (!devname) + return grub_errno; + + dev = grub_device_open (devname); + grub_free (devname); + if (!dev) + return grub_errno; + + err = grub_zfs_fetch_nvlist (dev, &nvlist); + + grub_device_close (dev); + + if (err) + return err; + + poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME); + if (!poolname) + grub_printf ("Pool name: unavailable\n"); + else + grub_printf ("Pool name: %s\n", poolname); + + found = + grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_GUID, &guid); + if (!found) + grub_printf ("Pool GUID: unavailable\n"); + else + grub_printf ("Pool GUID: %016llx\n", (long long unsigned) guid); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE, + &pool_state); + if (!found) + grub_printf ("Unable to retrieve pool state\n"); + else if (pool_state >= ARRAY_SIZE (poolstates)) + grub_printf ("Unrecognized pool state\n"); + else + grub_printf ("Pool state: %s\n", poolstates[pool_state]); + + nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); + + if (!nv) + grub_printf ("No vdev tree available\n"); + else + print_vdev_info (nv, 1); + + grub_free (nv); + grub_free (nvlist); + + return GRUB_ERR_NONE; +} + +static grub_err_t +grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc, + char **args) +{ + grub_device_t dev; + char *devname; + grub_err_t err; + char *nvlist = 0; + char *nv = 0; + char *bootpath = 0, *devid = 0; + char *fsname; + char *bootfs; + char *poolname; + grub_uint64_t mdnobj; + + if (argc < 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "filesystem name required"); + + devname = grub_file_get_device_name (args[0]); + if (grub_errno) + return grub_errno; + + dev = grub_device_open (devname); + grub_free (devname); + if (!dev) + return grub_errno; + + err = grub_zfs_fetch_nvlist (dev, &nvlist); + + fsname = grub_strchr (args[0], ')'); + if (fsname) + fsname++; + else + fsname = args[0]; + + if (!err) + err = grub_zfs_getmdnobj (dev, fsname, &mdnobj); + + grub_device_close (dev); + + if (err) + return err; + + poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME); + if (!poolname) + { + if (!grub_errno) + grub_error (GRUB_ERR_BAD_FS, "No poolname found"); + return grub_errno; + } + + nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); + + if (nv) + get_bootpath (nv, &bootpath, &devid); + + grub_free (nv); + grub_free (nvlist); + + if (bootpath && devid) + { + bootfs = grub_malloc + (sizeof ("zfs-bootfs=/XXXXXXXXXXXXXXXXXXXXXXXX bootpath= diskdevid=") + + grub_strlen (bootpath) + grub_strlen (devid) + + grub_strlen (poolname)); + if (!bootfs) + return grub_errno; + grub_sprintf (bootfs, "zfs-bootfs=%s/%llu bootpath=%s diskdevid=%s", + poolname, (unsigned long long) mdnobj, bootpath, devid); + } + else + { + bootfs = grub_malloc + (sizeof ("zfs-bootfs=/XXXXXXXXXXXXXXXXXXXXXXXX") + + grub_strlen (poolname)); + if (!bootfs) + return grub_errno; + grub_sprintf (bootfs, "zfs-bootfs=%s/%llu", + poolname, (unsigned long long) mdnobj); + } + if (argc >= 2) + grub_env_set (args[1], bootfs); + else + grub_printf ("%s\n", bootfs); + + grub_free (bootfs); + grub_free (poolname); + grub_free (bootpath); + grub_free (devid); + + return GRUB_ERR_NONE; +} + + +static grub_command_t cmd_info, cmd_bootfs; + +GRUB_MOD_INIT (zfsinfo) +{ + cmd_info = grub_register_command ("zfsinfo", grub_cmd_zfsinfo, + "zfsinfo DEVICE", + "Print ZFS info about DEVICE."); + cmd_bootfs = grub_register_command ("zfs-bootfs", grub_cmd_zfs_bootfs, + "zfs-bootfs FILESYSTEM [VARIABLE]", + "Print ZFS-BOOTFSOBJ or set it to VARIABLE"); +} + +GRUB_MOD_FINI (zfsinfo) +{ + grub_unregister_command (cmd_info); + grub_unregister_command (cmd_bootfs); +} --- grub2-1.97~beta4.orig/debian/grub-extras/commands/i386/915resolution.c +++ grub2-1.97~beta4/debian/grub-extras/commands/i386/915resolution.c @@ -0,0 +1,970 @@ +/* 915resolution - Utility to change vbemodes on the intel + * integrated video chipset */ + +/* + * Based on Nathan Coulson's http://nathancoulson.com/proj/eee/grub-1.96-915resolution-0.5.2-3.patch + * Oct 10, 2008, Released as 915 + * Oct 10, 2008, Updated to include support for 945GM thanks to Scot Doyle + */ + +/* Copied from 915 resolution created by steve tomjenovic + * 915 resolution was in the public domain. + * + * All I have done, was make the above program run within + * the grub2 environment. + * + * Some of the checks are still commented, as I did not find + * easy replacement for memmem. + * + * Slightly edited by Nathan Coulson (conathan@gmail.com) + */ + +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003,2007 Free Software Foundation, Inc. + * Copyright (C) 2003 NIIBE Yutaka + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + + +/* 915 resolution by steve tomljenovic + * + * This was tested only on Sony VGN-FS550. Use at your own risk + * + * This code is based on the techniques used in : + * + * - 855patch. Many thanks to Christian Zietz (czietz gmx net) + * for demonstrating how to shadow the VBIOS into system RAM + * and then modify it. + * + * - 1280patch by Andrew Tipton (andrewtipton null li). + * + * - 855resolution by Alain Poirier + * + * This source code is into the public domain. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define printf grub_printf +#define malloc grub_malloc +#define free grub_free +#define strcmp grub_strcmp +#define fprintf(stream,template,args...) grub_printf(template, ## args) +#define strtol(x,y,z) grub_strtoul(x,y,z) +#define atoi(x) grub_strtoul(x,NULL,10) +#define assert(x) 0 /* FIXME */ +#define memset grub_memset +#define outl grub_outl +#define outb grub_outb +#define inl grub_inl +#define inb grub_inb + +#define NEW(a) ((a *)(malloc(sizeof(a)))) +#define FREE(a) (free(a)) + +#define VBIOS_START 0xc0000 +#define VBIOS_SIZE 0x10000 + +#define VBIOS_FILE "/dev/mem" + +#define FALSE 0 +#define TRUE 1 + +#define MODE_TABLE_OFFSET_845G 617 + +#define VERSION "0.5.3" + +#define ATI_SIGNATURE1 "ATI MOBILITY RADEON" +#define ATI_SIGNATURE2 "ATI Technologies Inc" +#define NVIDIA_SIGNATURE "NVIDIA Corp" +#define INTEL_SIGNATURE "Intel Corp" + +typedef unsigned char * address; +typedef unsigned char byte; +typedef unsigned short word; +typedef unsigned char boolean; +typedef unsigned int cardinal; + +typedef enum { + CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G, CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME, + CT_946GZ, CT_G965, CT_Q965, CT_965GM, CT_G33, CT_Q33, CT_Q35, CT_500GMA +} chipset_type; + +char * chipset_type_names[] = { + "UNKNOWN", "830", "845G", "855GM", "865G", "915G", "915GM", "945G", "945GM", "945GME", + "946GZ", "G965", "Q965", "965GM", "G33", "Q33", "Q35", "500GMA" +}; + +typedef enum { + BT_UNKWN, BT_1, BT_2, BT_3 +} bios_type; + +char * bios_type_names[] = {"UNKNOWN", "TYPE 1", "TYPE 2", "TYPE 3"}; + +int freqs[] = { 60, 75, 85 }; + +typedef struct { + byte mode; + byte bits_per_pixel; + word resolution; + byte unknown; +} __attribute__((packed)) vbios_mode; + +typedef struct { + byte unknow1[2]; + byte x1; + byte x_total; + byte x2; + byte y1; + byte y_total; + byte y2; +} __attribute__((packed)) vbios_resolution_type1; + +typedef struct { + unsigned long clock; + + word x1; + word htotal; + word x2; + word hblank; + word hsyncstart; + word hsyncend; + + word y1; + word vtotal; + word y2; + word vblank; + word vsyncstart; + word vsyncend; +} __attribute__((packed)) vbios_modeline_type2; + +typedef struct { + byte xchars; + byte ychars; + byte unknown[4]; + + vbios_modeline_type2 modelines[]; +} __attribute__((packed)) vbios_resolution_type2; + +typedef struct { + unsigned long clock; + + word x1; + word htotal; + word x2; + word hblank; + word hsyncstart; + word hsyncend; + + word y1; + word vtotal; + word y2; + word vblank; + word vsyncstart; + word vsyncend; + + word timing_h; + word timing_v; + + byte unknown[6]; +} __attribute__((packed)) vbios_modeline_type3; + +typedef struct { + unsigned char unknown[6]; + + vbios_modeline_type3 modelines[]; +} __attribute__((packed)) vbios_resolution_type3; + + +typedef struct { + cardinal chipset_id; + chipset_type chipset; + bios_type bios; + + int bios_fd; + address bios_ptr; + + vbios_mode * mode_table; + cardinal mode_table_size; + + byte b1, b2; + + boolean unlocked; +} vbios_map; + + +cardinal get_chipset_id(void) { + outl(0x80000000, 0xcf8); + return inl(0xcfc); +} + +chipset_type get_chipset(cardinal id) { + chipset_type type; + + switch (id) { + case 0x35758086: + type = CT_830; + break; + + case 0x25608086: + type = CT_845G; + break; + + case 0x35808086: + type = CT_855GM; + break; + + case 0x25708086: + type = CT_865G; + break; + + case 0x25808086: + type = CT_915G; + break; + + case 0x25908086: + type = CT_915GM; + break; + + case 0x27708086: + type = CT_945G; + break; + + case 0x27a08086: + type = CT_945GM; + break; + + case 0x27ac8086: + type = CT_945GME; + break; + + case 0x29708086: + type = CT_946GZ; + break; + + case 0x29a08086: + type = CT_G965; + break; + + case 0x29908086: + type = CT_Q965; + break; + + case 0x2a008086: + type = CT_965GM; + break; + + case 0x29c08086: + type = CT_G33; + break; + + case 0x29b08086: + type = CT_Q35; + break; + + case 0x29d08086: + type = CT_Q33; + break; + + case 0x81008086: + type = CT_500GMA; + break; + + default: + type = CT_UNKWN; + break; + } + + return type; +} + + +vbios_resolution_type1 * map_type1_resolution(vbios_map * map, word res) { + vbios_resolution_type1 * ptr = ((vbios_resolution_type1*)(map->bios_ptr + res)); + return ptr; +} + +vbios_resolution_type2 * map_type2_resolution(vbios_map * map, word res) { + vbios_resolution_type2 * ptr = ((vbios_resolution_type2*)(map->bios_ptr + res)); + return ptr; +} + +vbios_resolution_type3 * map_type3_resolution(vbios_map * map, word res) { + vbios_resolution_type3 * ptr = ((vbios_resolution_type3*)(map->bios_ptr + res)); + return ptr; +} + + +boolean detect_bios_type(vbios_map * map, boolean modeline, int entry_size) { + int i; + short int r1, r2; + + r1 = r2 = 32000; + + for (i=0; i < map->mode_table_size; i++) { + if (map->mode_table[i].resolution <= r1) { + r1 = map->mode_table[i].resolution; + } + else { + if (map->mode_table[i].resolution <= r2) { + r2 = map->mode_table[i].resolution; + } + } + + /*printf("r1 = %d r2 = %d\n", r1, r2);*/ + } + + return (r2-r1-6) % entry_size == 0; +} + + +void close_vbios(vbios_map * map); + + +vbios_map * open_vbios(chipset_type forced_chipset) { + vbios_map * map = NEW(vbios_map); + memset (map, 0, sizeof(vbios_map)); + + /* + * Determine chipset + */ + + if (forced_chipset == CT_UNKWN) { + map->chipset_id = get_chipset_id(); + + map->chipset = get_chipset(map->chipset_id); + } + else if (forced_chipset != CT_UNKWN) { + map->chipset = forced_chipset; + } + else { + map->chipset = CT_915GM; + } + + /* + * Map the video bios to memory + */ + + map->bios_ptr=(char*)VBIOS_START; + +#if 0 + /* + * check if we have ATI Radeon + */ + + if (memmem(map->bios_ptr, VBIOS_SIZE, ATI_SIGNATURE1, strlen(ATI_SIGNATURE1)) || + memmem(map->bios_ptr, VBIOS_SIZE, ATI_SIGNATURE2, strlen(ATI_SIGNATURE2)) ) { + fprintf(stderr, "ATI chipset detected. 915resolution only works with Intel 800/900 series graphic chipsets.\n"); + close(map->bios_fd); + exit(2); + } + + /* + * check if we have NVIDIA + */ + + if (memmem(map->bios_ptr, VBIOS_SIZE, NVIDIA_SIGNATURE, strlen(NVIDIA_SIGNATURE))) { + fprintf(stderr, "NVIDIA chipset detected. 915resolution only works with Intel 800/900 series graphic chipsets.\n"); + close(map->bios_fd); + exit(2); + } + + /* + * check if we have Intel + */ + + if (map->chipset == CT_UNKWN && memmem(map->bios_ptr, VBIOS_SIZE, INTEL_SIGNATURE, strlen(INTEL_SIGNATURE))) { + fprintf(stderr, "Intel chipset detected. However, 915resolution was unable to determine the chipset type.\n"); + + fprintf(stderr, "Chipset Id: %x\n", map->chipset_id); + + fprintf(stderr, "Please report this problem to stomljen@yahoo.com\n"); + + close_vbios(map); + exit(2); + } +#endif + + /* + * check for others + */ + + if (map->chipset == CT_UNKWN) { + fprintf(stderr, "Unknown chipset type and unrecognized bios.\n"); + fprintf(stderr, "915resolution only works with Intel 800/900 series graphic chipsets.\n"); + + fprintf(stderr, "Chipset Id: %x\n", map->chipset_id); + close_vbios(map); + return 0; + } + + /* + * Figure out where the mode table is + */ + + { + address p = map->bios_ptr + 16; + address limit = map->bios_ptr + VBIOS_SIZE - (3 * sizeof(vbios_mode)); + + while (p < limit && map->mode_table == 0) { + vbios_mode * mode_ptr = (vbios_mode *) p; + + if (((mode_ptr[0].mode & 0xf0) == 0x30) && ((mode_ptr[1].mode & 0xf0) == 0x30) && + ((mode_ptr[2].mode & 0xf0) == 0x30) && ((mode_ptr[3].mode & 0xf0) == 0x30)) { + + map->mode_table = mode_ptr; + } + + p++; + } + + if (map->mode_table == 0) { + fprintf(stderr, "Unable to locate the mode table.\n"); + fprintf(stderr, "Please run the program 'dump_bios' as root and\n"); + fprintf(stderr, "email the file 'vbios.dmp' to stomljen@yahoo.com.\n"); + + fprintf(stderr, "Chipset: %s\n", chipset_type_names[map->chipset]); + close_vbios(map); + return 0; + } + } + + /* + * Determine size of mode table + */ + + { + vbios_mode * mode_ptr = map->mode_table; + + while (mode_ptr->mode != 0xff) { + map->mode_table_size++; + mode_ptr++; + } + } + + /* + * Figure out what type of bios we have + * order of detection is important + */ + + if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3))) { + map->bios = BT_3; + } + else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2))) { + map->bios = BT_2; + } + else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1))) { + map->bios = BT_1; + } + else { + fprintf(stderr, "Unable to determine bios type.\n"); + fprintf(stderr, "Please run the program 'dump_bios' as root and\n"); + fprintf(stderr, "email the file 'vbios.dmp' to stomljen@yahoo.com.\n"); + + fprintf(stderr, "Chipset: %s\n", chipset_type_names[map->chipset]); + fprintf(stderr, "Mode Table Offset: $C0000 + $%x\n", ((cardinal)map->mode_table) - ((cardinal)map->bios_ptr)); + fprintf(stderr, "Mode Table Entries: %u\n", map->mode_table_size); + return 0; + } + + return map; +} + +void close_vbios(vbios_map * map) { + assert(!map->unlocked); + + FREE(map); +} + +void unlock_vbios(vbios_map * map) { + + assert(!map->unlocked); + + map->unlocked = TRUE; + + switch (map->chipset) { + case CT_UNKWN: + break; + case CT_830: + case CT_855GM: + outl(0x8000005a, 0xcf8); + map->b1 = inb(0xcfe); + + outl(0x8000005a, 0xcf8); + outb(0x33, 0xcfe); + break; + case CT_845G: + case CT_865G: + case CT_915G: + case CT_915GM: + case CT_945G: + case CT_945GM: + case CT_946GZ: + case CT_G965: + case CT_Q965: + case CT_965GM: + case CT_G33: + case CT_Q35: + case CT_Q33: + case CT_500GMA: + outl(0x80000090, 0xcf8); + map->b1 = inb(0xcfd); + map->b2 = inb(0xcfe); + + outl(0x80000090, 0xcf8); + outb(0x33, 0xcfd); + outb(0x33, 0xcfe); + break; + } + +#if DEBUG + { + cardinal t = inl(0xcfc); + printf("unlock PAM: (0x%08x)\n", t); + } +#endif +} + +void relock_vbios(vbios_map * map) { + + assert(map->unlocked); + map->unlocked = FALSE; + + switch (map->chipset) { + case CT_UNKWN: + break; + case CT_830: + case CT_855GM: + outl(0x8000005a, 0xcf8); + outb(map->b1, 0xcfe); + break; + case CT_845G: + case CT_865G: + case CT_915G: + case CT_915GM: + case CT_945G: + case CT_945GM: + case CT_945GME: + case CT_946GZ: + case CT_G965: + case CT_Q965: + case CT_965GM: + case CT_G33: + case CT_Q35: + case CT_Q33: + case CT_500GMA: + outl(0x80000090, 0xcf8); + outb(map->b1, 0xcfd); + outb(map->b2, 0xcfe); + break; + } + +#if DEBUG + { + cardinal t = inl(0xcfc); + printf("relock PAM: (0x%08x)\n", t); + } +#endif +} + + +void list_modes(vbios_map *map, cardinal raw) { + cardinal i, x, y; + + for (i=0; i < map->mode_table_size; i++) { + switch(map->bios) { + case BT_1: + { + vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution); + + x = ((((cardinal) res->x2) & 0xf0) << 4) | res->x1; + y = ((((cardinal) res->y2) & 0xf0) << 4) | res->y1; + + if (x != 0 && y != 0) { + printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel); + } + + if (raw) + { + printf("Mode %02x (raw) :\n\t%02x %02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n", map->mode_table[i].mode, res->unknow1[0],res->unknow1[1], res->x1,res->x_total,res->x2,res->y1,res->y_total,res->y2); + } + + } + break; + case BT_2: + { + vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution); + + x = res->modelines[0].x1+1; + y = res->modelines[0].y1+1; + + if (x != 0 && y != 0) { + printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel); + } + } + break; + case BT_3: + { + vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution); + + x = res->modelines[0].x1+1; + y = res->modelines[0].y1+1; + + if (x != 0 && y != 0) { + printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel); + } + } + break; + case BT_UNKWN: + break; + } + } +} + +static void gtf_timings(int x, int y, int freq, + unsigned long *clock, + word *hsyncstart, word *hsyncend, word *hblank, + word *vsyncstart, word *vsyncend, word *vblank) +{ + int hbl, vbl, vfreq; + + vbl = y + (y+1)/(20000.0/(11*freq) - 1) + 1.5; + vfreq = vbl * freq; + hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) / + (70.0 + 300000.0 / vfreq) / 16.0 + 0.5); + + *vsyncstart = y; + *vsyncend = y + 3; + *vblank = vbl - 1; + *hsyncstart = x + hbl / 2 - (x + hbl + 50) / 100 * 8 - 1; + *hsyncend = x + hbl / 2 - 1; + *hblank = x + hbl - 1; + *clock = (x + hbl) * vfreq / 1000; +} + +void set_mode(vbios_map * map, cardinal mode, cardinal x, cardinal y, cardinal bp, cardinal htotal, cardinal vtotal) { + int xprev, yprev; + cardinal i, j; + + for (i=0; i < map->mode_table_size; i++) { + if (map->mode_table[i].mode == mode) { + switch(map->bios) { + case BT_1: + { + vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution); + + if (bp) { + map->mode_table[i].bits_per_pixel = bp; + } + + res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0); + res->x1 = (x & 0xff); + + res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0); + res->y1 = (y & 0xff); + if (htotal) + res->x_total = ((htotal-x) & 0xff); + + if (vtotal) + res->y_total = ((vtotal-y) & 0xff); + } + break; + case BT_2: + { + vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution); + + res->xchars = x / 8; + res->ychars = y / 16 - 1; + xprev = res->modelines[0].x1; + yprev = res->modelines[0].y1; + + for(j=0; j < 3; j++) { + vbios_modeline_type2 * modeline = &res->modelines[j]; + + if (modeline->x1 == xprev && modeline->y1 == yprev) { + modeline->x1 = modeline->x2 = x-1; + modeline->y1 = modeline->y2 = y-1; + + gtf_timings(x, y, freqs[j], &modeline->clock, + &modeline->hsyncstart, &modeline->hsyncend, + &modeline->hblank, &modeline->vsyncstart, + &modeline->vsyncend, &modeline->vblank); + + if (htotal) + modeline->htotal = htotal; + else + modeline->htotal = modeline->hblank; + + if (vtotal) + modeline->vtotal = vtotal; + else + modeline->vtotal = modeline->vblank; + } + } + } + break; + case BT_3: + { + vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution); + + xprev = res->modelines[0].x1; + yprev = res->modelines[0].y1; + + for (j=0; j < 3; j++) { + vbios_modeline_type3 * modeline = &res->modelines[j]; + + if (modeline->x1 == xprev && modeline->y1 == yprev) { + modeline->x1 = modeline->x2 = x-1; + modeline->y1 = modeline->y2 = y-1; + + gtf_timings(x, y, freqs[j], &modeline->clock, + &modeline->hsyncstart, &modeline->hsyncend, + &modeline->hblank, &modeline->vsyncstart, + &modeline->vsyncend, &modeline->vblank); + if (htotal) + modeline->htotal = htotal; + else + modeline->htotal = modeline->hblank; + if (vtotal) + modeline->vtotal = vtotal; + else + modeline->vtotal = modeline->vblank; + + modeline->timing_h = y-1; + modeline->timing_v = x-1; + } + } + } + break; + case BT_UNKWN: + break; + } + } + } +} + +void display_map_info(vbios_map * map) { + printf("Chipset: %s\n", chipset_type_names[map->chipset]); + printf("BIOS: %s\n", bios_type_names[map->bios]); + + printf("Mode Table Offset: $C0000 + $%x\n", ((cardinal)map->mode_table) - ((cardinal)map->bios_ptr)); + printf("Mode Table Entries: %u\n", map->mode_table_size); +} + + +int parse_args(int argc, char *argv[], chipset_type *forced_chipset, cardinal *list, cardinal *mode, cardinal *x, cardinal *y, cardinal *bp, cardinal *raw, cardinal *htotal, cardinal *vtotal) { + cardinal index = 0; + + *list = *mode = *x = *y = *raw = *htotal = *vtotal = 0; + + *forced_chipset = CT_UNKWN; + + + if ((argc > index) && !strcmp(argv[index], "-c")) { + index++; + + if(argc<=index) { + return 0; + } + + if (!strcmp(argv[index], "845")) { + *forced_chipset = CT_845G; + } + else if (!strcmp(argv[index], "855")) { + *forced_chipset = CT_855GM; + } + else if (!strcmp(argv[index], "865")) { + *forced_chipset = CT_865G; + } + else if (!strcmp(argv[index], "915G")) { + *forced_chipset = CT_915G; + } + else if (!strcmp(argv[index], "915GM")) { + *forced_chipset = CT_915GM; + } + else if (!strcmp(argv[index], "945G")) { + *forced_chipset = CT_945G; + } + else if (!strcmp(argv[index], "945GM")) { + *forced_chipset = CT_945GM; + } + else if (!strcmp(argv[index], "945GME")) { + *forced_chipset = CT_945GME; + } + else if (!strcmp(argv[index], "946GZ")) { + *forced_chipset = CT_946GZ; + } + else if (!strcmp(argv[index], "G965")) { + *forced_chipset = CT_G965; + } + else if (!strcmp(argv[index], "Q965")) { + *forced_chipset = CT_Q965; + } + else if (!strcmp(argv[index], "965GM")) { + *forced_chipset = CT_965GM; + } + else if (!strcmp(argv[index], "G33")) { + *forced_chipset = CT_G33; + } + else if (!strcmp(argv[index], "Q35")) { + *forced_chipset = CT_Q35; + } + else if (!strcmp(argv[index], "Q33")) { + *forced_chipset = CT_Q33; + } + else if (!strcmp(argv[index], "500GMA")) { + *forced_chipset = CT_500GMA; + } + else { + *forced_chipset = CT_UNKWN; + } + + index++; + + if (argc<=index) { + return 0; + } + } + + if ((argc > index) && !strcmp(argv[index], "-l")) { + *list = 1; + index++; + + if(argc<=index) { + return 0; + } + } + + if ((argc > index) && !strcmp(argv[index], "-r")) { + *raw = 1; + index++; + + if(argc<=index) { + return 0; + } + } + + if (argc-index < 3 || argc-index > 6) { + return -1; + } + + *mode = (cardinal) strtol(argv[index], NULL, 16); + *x = (cardinal)atoi(argv[index+1]); + *y = (cardinal)atoi(argv[index+2]); + + + if (argc-index > 3) { + *bp = (cardinal)atoi(argv[index+3]); + } + else { + *bp = 0; + } + + if (argc-index > 4) { + *htotal = (cardinal)atoi(argv[index+4]); + } + else { + *htotal = 0; + } + + if (argc-index > 5) { + *vtotal = (cardinal)atoi(argv[index+5]); + } + else { + *vtotal = 0; + } + + return 0; +} + +static void usage() { + printf("Usage: 915resolution [-c chipset] [-l] [mode X Y] [bits/pixel] [htotal] [vtotal]\n"); + printf(" Set the resolution to XxY for a video mode\n"); + printf(" Bits per pixel are optional. htotal/vtotal settings are additionally optional.\n"); + printf(" Options:\n"); + printf(" -c force chipset type (THIS IS USED FOR DEBUG PURPOSES)\n"); + printf(" -l display the modes found in the video BIOS\n"); + printf(" -r display the modes found in the video BIOS in raw mode (THIS IS USED FOR DEBUG PURPOSES)\n"); +} + +int main (int argc, char *argv[]) +{ + vbios_map * map; + cardinal list, mode, x, y, bp, raw, htotal, vtotal; + chipset_type forced_chipset; + + printf("Intel 800/900 Series VBIOS Hack : version %s\n\n", VERSION); + + if (parse_args(argc, argv, &forced_chipset, &list, &mode, &x, &y, &bp, &raw, &htotal, &vtotal) == -1) { + usage(); + return 2; + } + + map = open_vbios(forced_chipset); + display_map_info(map); + + printf("\n"); + + if (list) { + list_modes(map, raw); + } + + if (mode!=0 && x!=0 && y!=0) { + unlock_vbios(map); + + set_mode(map, mode, x, y, bp, htotal, vtotal); + + relock_vbios(map); + + printf("Patch mode %02x to resolution %dx%d complete\n", mode, x, y); + + if (list) { + list_modes(map, raw); + } + } + + close_vbios(map); + + return 0; +} + + + + + +static grub_err_t +grub_cmd_915resolution (struct grub_arg_list *state __attribute__ ((unused)), int argc, char *argv[]) +{ + return main (argc, argv); +} + +GRUB_MOD_INIT(915resolution) +{ + (void)mod; /* To stop warning. */ + grub_register_extcmd ("915resolution", grub_cmd_915resolution, GRUB_COMMAND_FLAG_BOTH, + "915resolution", "Intel VBE editor", 0); +} + +GRUB_MOD_FINI(915resolution) +{ + grub_unregister_command ("915resolution"); +} --- grub2-1.97~beta4.orig/debian/grub-extras/fs/zfs_lzjb.c +++ grub2-1.97~beta4/debian/grub-extras/fs/zfs_lzjb.c @@ -0,0 +1,95 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2007 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MATCH_BITS 6 +#define MATCH_MIN 3 +#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1) + +/* + * Decompression Entry - lzjb + */ +#ifndef NBBY +#define NBBY 8 +#endif + +grub_err_t +lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len, + grub_size_t d_len); + +grub_err_t +lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len, + grub_size_t d_len) +{ + grub_uint8_t *src = s_start; + grub_uint8_t *dst = d_start; + grub_uint8_t *d_end = (grub_uint8_t *) d_start + d_len; + grub_uint8_t *s_end = (grub_uint8_t *) s_start + s_len; + grub_uint8_t *cpy, copymap = 0; + int copymask = 1 << (NBBY - 1); + + while (dst < d_end && src < s_end) + { + if ((copymask <<= 1) == (1 << NBBY)) + { + copymask = 1; + copymap = *src++; + } + if (src >= s_end) + return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed"); + if (copymap & copymask) + { + int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN; + int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK; + src += 2; + cpy = dst - offset; + if (src > s_end || cpy < (grub_uint8_t *) d_start) + return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed"); + while (--mlen >= 0 && dst < d_end) + *dst++ = *cpy++; + } + else + *dst++ = *src++; + } + if (dst < d_end) + return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed"); + return GRUB_ERR_NONE; +} --- grub2-1.97~beta4.orig/debian/grub-extras/fs/zfs_sha256.c +++ grub2-1.97~beta4/debian/grub-extras/fs/zfs_sha256.c @@ -0,0 +1,145 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2007 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * SHA-256 checksum, as specified in FIPS 180-2, available at: + * http://csrc.nist.gov/cryptval + * + * This is a very compact implementation of SHA-256. + * It is designed to be simple and portable, not to be fast. + */ + +/* + * The literal definitions according to FIPS180-2 would be: + * + * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) + * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) + * + * We use logical equivalents which require one less op. + */ +#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) +#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s))) +#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22)) +#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25)) +#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3)) +#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10)) + +static const grub_uint32_t SHA256_K[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; + +static void +SHA256Transform(grub_uint32_t *H, const grub_uint8_t *cp) +{ + grub_uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; + + for (t = 0; t < 16; t++, cp += 4) + W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; + + for (t = 16; t < 64; t++) + W[t] = sigma1(W[t - 2]) + W[t - 7] + + sigma0(W[t - 15]) + W[t - 16]; + + a = H[0]; b = H[1]; c = H[2]; d = H[3]; + e = H[4]; f = H[5]; g = H[6]; h = H[7]; + + for (t = 0; t < 64; t++) { + T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; + T2 = SIGMA0(a) + Maj(a, b, c); + h = g; g = f; f = e; e = d + T1; + d = c; c = b; b = a; a = T1 + T2; + } + + H[0] += a; H[1] += b; H[2] += c; H[3] += d; + H[4] += e; H[5] += f; H[6] += g; H[7] += h; +} + +void +zio_checksum_SHA256(const void *buf, grub_uint64_t size, + grub_zfs_endian_t endian, zio_cksum_t *zcp) +{ + grub_uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + grub_uint8_t pad[128]; + unsigned padsize = size & 63; + unsigned i; + + for (i = 0; i < size - padsize; i += 64) + SHA256Transform(H, (grub_uint8_t *)buf + i); + + for (i = 0; i < padsize; i++) + pad[i] = ((grub_uint8_t *)buf)[i]; + + for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) + pad[padsize] = 0; + + for (i = 0; i < 8; i++) + pad[padsize++] = (size << 3) >> (56 - 8 * i); + + for (i = 0; i < padsize; i += 64) + SHA256Transform(H, pad + i); + + zcp->zc_word[0] = grub_cpu_to_zfs64 ((grub_uint64_t)H[0] << 32 | H[1], + endian); + zcp->zc_word[1] = grub_cpu_to_zfs64 ((grub_uint64_t)H[2] << 32 | H[3], + endian); + zcp->zc_word[2] = grub_cpu_to_zfs64 ((grub_uint64_t)H[4] << 32 | H[5], + endian); + zcp->zc_word[3] = grub_cpu_to_zfs64 ((grub_uint64_t)H[6] << 32 | H[7], + endian); +} --- grub2-1.97~beta4.orig/debian/grub-extras/fs/zfs.c +++ grub2-1.97~beta4/debian/grub-extras/fs/zfs.c @@ -0,0 +1,2483 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2008 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * The zfs plug-in routines for GRUB are: + * + * zfs_mount() - locates a valid uberblock of the root pool and reads + * in its MOS at the memory address MOS. + * + * zfs_open() - locates a plain file object by following the MOS + * and places its dnode at the memory address DNODE. + * + * zfs_read() - read in the data blocks pointed by the DNODE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ZPOOL_PROP_BOOTFS "bootfs" + +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) + +/* + * For nvlist manipulation. (from nvpair.h) + */ +#define NV_ENCODE_NATIVE 0 +#define NV_ENCODE_XDR 1 +#define NV_BIG_ENDIAN 0 +#define NV_LITTLE_ENDIAN 1 +#define DATA_TYPE_UINT64 8 +#define DATA_TYPE_STRING 9 +#define DATA_TYPE_NVLIST 19 +#define DATA_TYPE_NVLIST_ARRAY 20 + +#ifndef GRUB_UTIL +static grub_dl_t my_mod; +#endif + +#define P2PHASE(x, align) ((x) & ((align) - 1)) +#define DVA_OFFSET_TO_PHYS_SECTOR(offset) \ + ((offset + VDEV_LABEL_START_SIZE) >> SPA_MINBLOCKSHIFT) + +/* + * FAT ZAP data structures + */ +#define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */ +#define ZAP_HASH_IDX(hash, n) (((n) == 0) ? 0 : ((hash) >> (64 - (n)))) +#define CHAIN_END 0xffff /* end of the chunk chain */ + +/* + * The amount of space within the chunk available for the array is: + * chunk size - space for type (1) - space for next pointer (2) + */ +#define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3) + +#define ZAP_LEAF_HASH_SHIFT(bs) (bs - 5) +#define ZAP_LEAF_HASH_NUMENTRIES(bs) (1 << ZAP_LEAF_HASH_SHIFT(bs)) +#define LEAF_HASH(bs, h) \ + ((ZAP_LEAF_HASH_NUMENTRIES(bs)-1) & \ + ((h) >> (64 - ZAP_LEAF_HASH_SHIFT(bs)-l->l_hdr.lh_prefix_len))) + +/* + * The amount of space available for chunks is: + * block size shift - hash entry size (2) * number of hash + * entries - header space (2*chunksize) + */ +#define ZAP_LEAF_NUMCHUNKS(bs) \ + (((1<l_hash + ZAP_LEAF_HASH_NUMENTRIES(bs)))[idx] +#define ZAP_LEAF_ENTRY(l, bs, idx) (&ZAP_LEAF_CHUNK(l, bs, idx).l_entry) + + +/* + * Decompression Entry - lzjb + */ +#ifndef NBBY +#define NBBY 8 +#endif + +extern grub_err_t lzjb_decompress (void *, void *, grub_size_t, grub_size_t); + +typedef grub_err_t zfs_decomp_func_t (void *s_start, void *d_start, + grub_size_t s_len, grub_size_t d_len); +typedef struct decomp_entry +{ + char *name; + zfs_decomp_func_t *decomp_func; +} decomp_entry_t; + +typedef struct dnode_end +{ + dnode_phys_t dn; + grub_zfs_endian_t endian; +} dnode_end_t; + +struct grub_zfs_data +{ + /* cache for a file block of the currently zfs_open()-ed file */ + char *file_buf; + grub_uint64_t file_start; + grub_uint64_t file_end; + + /* cache for a dnode block */ + dnode_phys_t *dnode_buf; + dnode_phys_t *dnode_mdn; + grub_uint64_t dnode_start; + grub_uint64_t dnode_end; + grub_zfs_endian_t dnode_endian; + + uberblock_t current_uberblock; + grub_disk_t disk; + + dnode_end_t mos; + dnode_end_t mdn; + dnode_end_t dnode; + + grub_disk_addr_t vdev_phys_sector; +}; + +decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = { + {"inherit", 0}, /* ZIO_COMPRESS_INHERIT */ + {"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */ + {"off", 0}, /* ZIO_COMPRESS_OFF */ + {"lzjb", lzjb_decompress}, /* ZIO_COMPRESS_LZJB */ + {"empty", 0} /* ZIO_COMPRESS_EMPTY */ +}; + +static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, + void *buf, struct grub_zfs_data *data); + +/* + * Our own version of log2(). Same thing as highbit()-1. + */ +static int +zfs_log2 (grub_uint64_t num) +{ + int i = 0; + + while (num > 1) + { + i++; + num = num >> 1; + } + + return (i); +} + +/* Checksum Functions */ +static void +zio_checksum_off (const void *buf __attribute__ ((unused)), + grub_uint64_t size __attribute__ ((unused)), + grub_zfs_endian_t endian __attribute__ ((unused)), + zio_cksum_t * zcp) +{ + ZIO_SET_CHECKSUM (zcp, 0, 0, 0, 0); +} + +/* Checksum Table and Values */ +zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = { + {NULL, 0, 0, "inherit"}, + {NULL, 0, 0, "on"}, + {zio_checksum_off, 0, 0, "off"}, + {zio_checksum_SHA256, 1, 1, "label"}, + {zio_checksum_SHA256, 1, 1, "gang_header"}, + {fletcher_2, 0, 1, "zilog"}, + {fletcher_2, 0, 0, "fletcher2"}, + {fletcher_4, 1, 0, "fletcher4"}, + {zio_checksum_SHA256, 1, 0, "SHA256"}, +}; + +/* + * zio_checksum_verify: Provides support for checksum verification. + * + * Fletcher2, Fletcher4, and SHA256 are supported. + * + */ +static grub_err_t +zio_checksum_verify (zio_cksum_t zc, grub_uint32_t checksum, + grub_zfs_endian_t endian, char *buf, int size) +{ + zio_block_tail_t *zbt = (zio_block_tail_t *) (buf + size) - 1; + zio_checksum_info_t *ci = &zio_checksum_table[checksum]; + zio_cksum_t actual_cksum, expected_cksum; + + if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func == NULL) + { + grub_dprintf ("zfs", "unknown checksum function %d\n", checksum); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "unknown checksum function %d", checksum); + } + + if (ci->ci_zbt) + { + expected_cksum = zbt->zbt_cksum; + zbt->zbt_cksum = zc; + ci->ci_func (buf, size, endian, &actual_cksum); + zbt->zbt_cksum = expected_cksum; + zc = expected_cksum; + } + else + ci->ci_func (buf, size, endian, &actual_cksum); + + if ((actual_cksum.zc_word[0] != zc.zc_word[0]) + || (actual_cksum.zc_word[1] != zc.zc_word[1]) + || (actual_cksum.zc_word[2] != zc.zc_word[2]) + || (actual_cksum.zc_word[3] != zc.zc_word[3])) + { + grub_dprintf ("zfs", "checksum %d verification failed\n", checksum); + grub_dprintf ("zfs", "actual checksum %16llx %16llx %16llx %16llx\n", + (unsigned long long) actual_cksum.zc_word[0], + (unsigned long long) actual_cksum.zc_word[1], + (unsigned long long) actual_cksum.zc_word[2], + (unsigned long long) actual_cksum.zc_word[3]); + grub_dprintf ("zfs", "expected checksum %16llx %16llx %16llx %16llx\n", + (unsigned long long) zc.zc_word[0], + (unsigned long long) zc.zc_word[1], + (unsigned long long) zc.zc_word[2], + (unsigned long long) zc.zc_word[3]); + return grub_error (GRUB_ERR_BAD_FS, "checksum verification failed"); + } + + return GRUB_ERR_NONE; +} + +/* + * vdev_uberblock_compare takes two uberblock structures and returns an integer + * indicating the more recent of the two. + * Return Value = 1 if ub2 is more recent + * Return Value = -1 if ub1 is more recent + * The most recent uberblock is determined using its transaction number and + * timestamp. The uberblock with the highest transaction number is + * considered "newer". If the transaction numbers of the two blocks match, the + * timestamps are compared to determine the "newer" of the two. + */ +static int +vdev_uberblock_compare (uberblock_t * ub1, uberblock_t * ub2) +{ + grub_zfs_endian_t ub1_endian, ub2_endian; + if (grub_zfs_to_cpu64 (ub1->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC) + ub1_endian = LITTLE_ENDIAN; + else + ub1_endian = BIG_ENDIAN; + if (grub_zfs_to_cpu64 (ub2->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC) + ub2_endian = LITTLE_ENDIAN; + else + ub2_endian = BIG_ENDIAN; + + if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) + < grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian)) + return (-1); + if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) + > grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian)) + return (1); + + if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) + < grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian)) + return (-1); + if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) + > grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian)) + return (1); + + return (0); +} + +/* + * Three pieces of information are needed to verify an uberblock: the magic + * number, the version number, and the checksum. + * + * Currently Implemented: version number, magic number + * Need to Implement: checksum + * + */ +static grub_err_t +uberblock_verify (uberblock_phys_t * ub, int offset) +{ + uberblock_t *uber = &ub->ubp_uberblock; + grub_err_t err; + grub_zfs_endian_t endian = UNKNOWN_ENDIAN; + zio_cksum_t zc; + + if (grub_zfs_to_cpu64 (uber->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC + && grub_zfs_to_cpu64 (uber->ub_version, LITTLE_ENDIAN) > 0 + && grub_zfs_to_cpu64 (uber->ub_version, LITTLE_ENDIAN) <= SPA_VERSION) + endian = LITTLE_ENDIAN; + + if (grub_zfs_to_cpu64 (uber->ub_magic, BIG_ENDIAN) == UBERBLOCK_MAGIC + && grub_zfs_to_cpu64 (uber->ub_version, BIG_ENDIAN) > 0 + && grub_zfs_to_cpu64 (uber->ub_version, BIG_ENDIAN) <= SPA_VERSION) + endian = BIG_ENDIAN; + + if (endian == UNKNOWN_ENDIAN) + return grub_error (GRUB_ERR_BAD_FS, "invalid uberblock magic"); + + grub_memset (&zc, 0, sizeof (zc)); + + zc.zc_word[0] = grub_cpu_to_zfs64 (offset, endian); + err = zio_checksum_verify (zc, ZIO_CHECKSUM_LABEL, endian, + (char *) ub, UBERBLOCK_SIZE); + + return err; +} + +/* + * Find the best uberblock. + * Return: + * Success - Pointer to the best uberblock. + * Failure - NULL + */ +static uberblock_phys_t * +find_bestub (uberblock_phys_t * ub_array, grub_disk_addr_t sector) +{ + uberblock_phys_t *ubbest = NULL; + int i; + grub_disk_addr_t offset; + grub_err_t err = GRUB_ERR_NONE; + + for (i = 0; i < (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT); i++) + { + offset = (sector << SPA_MINBLOCKSHIFT) + VDEV_PHYS_SIZE + + (i << VDEV_UBERBLOCK_SHIFT); + + err = uberblock_verify (&ub_array[i], offset); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + if (ubbest == NULL + || vdev_uberblock_compare (&(ub_array[i].ubp_uberblock), + &(ubbest->ubp_uberblock)) > 0) + ubbest = &ub_array[i]; + } + if (!ubbest) + grub_errno = err; + + return (ubbest); +} + +static inline grub_size_t +get_psize (blkptr_t * bp, grub_zfs_endian_t endian) +{ + return ((((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) >> 16) & 0xffff) + 1) + << SPA_MINBLOCKSHIFT); +} + +static grub_uint64_t +dva_get_offset (dva_t * dva, grub_zfs_endian_t endian) +{ + grub_dprintf ("zfs", "dva=%llx, %llx\n", + (unsigned long long) dva->dva_word[0], + (unsigned long long) dva->dva_word[1]); + return grub_zfs_to_cpu64 ((dva)->dva_word[1], + endian) << SPA_MINBLOCKSHIFT; +} + + +/* + * Read a block of data based on the gang block address dva, + * and put its data in buf. + * + */ +static grub_err_t +zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf, + struct grub_zfs_data *data) +{ + zio_gbh_phys_t *zio_gb; + grub_uint64_t offset, sector; + unsigned i; + grub_err_t err; + zio_cksum_t zc; + + grub_memset (&zc, 0, sizeof (zc)); + + zio_gb = grub_malloc (SPA_GANGBLOCKSIZE); + if (!zio_gb) + return grub_errno; + grub_dprintf ("zfs", endian == LITTLE_ENDIAN ? "little-endian gang\n" + :"big-endian gang\n"); + offset = dva_get_offset (dva, endian); + sector = DVA_OFFSET_TO_PHYS_SECTOR (offset); + grub_dprintf ("zfs", "offset=%llx\n", (unsigned long long) offset); + + /* read in the gang block header */ + err = grub_disk_read (data->disk, sector, 0, SPA_GANGBLOCKSIZE, + (char *) zio_gb); + if (err) + { + grub_free (zio_gb); + return err; + } + + /* XXX */ + /* self checksuming the gang block header */ + ZIO_SET_CHECKSUM (&zc, DVA_GET_VDEV (dva), + dva_get_offset (dva, endian), bp->blk_birth, 0); + err = zio_checksum_verify (zc, ZIO_CHECKSUM_GANG_HEADER, endian, + (char *) zio_gb, SPA_GANGBLOCKSIZE); + if (err) + { + grub_free (zio_gb); + return err; + } + + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + + for (i = 0; i < SPA_GBH_NBLKPTRS; i++) + { + if (zio_gb->zg_blkptr[i].blk_birth == 0) + continue; + + err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data); + if (err) + { + grub_free (zio_gb); + return err; + } + buf = (char *) buf + get_psize (&zio_gb->zg_blkptr[i], endian); + } + grub_free (zio_gb); + return GRUB_ERR_NONE; +} + +/* + * Read in a block of raw data to buf. + */ +static grub_err_t +zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf, + struct grub_zfs_data *data) +{ + int i, psize; + grub_err_t err = GRUB_ERR_NONE; + + psize = get_psize (bp, endian); + + /* pick a good dva from the block pointer */ + for (i = 0; i < SPA_DVAS_PER_BP; i++) + { + grub_uint64_t offset, sector; + + if (bp->blk_dva[i].dva_word[0] == 0 && bp->blk_dva[i].dva_word[1] == 0) + continue; + + if ((grub_zfs_to_cpu64 (bp->blk_dva[i].dva_word[1], endian)>>63) & 1) + err = zio_read_gang (bp, endian, &bp->blk_dva[i], buf, data); + else + { + /* read in a data block */ + offset = dva_get_offset (&bp->blk_dva[i], endian); + sector = DVA_OFFSET_TO_PHYS_SECTOR (offset); + err = grub_disk_read (data->disk, sector, 0, psize, buf); + } + if (!err) + return GRUB_ERR_NONE; + grub_errno = GRUB_ERR_NONE; + } + + if (!err) + err = grub_error (GRUB_ERR_BAD_FS, "couldn't find a valid DVA"); + grub_errno = err; + + return err; +} + +/* + * Read in a block of data, verify its checksum, decompress if needed, + * and put the uncompressed data in buf. + */ +static grub_err_t +zio_read (blkptr_t * bp, grub_zfs_endian_t endian, void **buf, + grub_size_t *size, struct grub_zfs_data *data) +{ + grub_size_t lsize, psize; + int comp; + char *compbuf; + grub_err_t err; + zio_cksum_t zc = bp->blk_cksum; + grub_uint32_t checksum; + + checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff; + comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0xff; + lsize = (BP_IS_HOLE(bp) ? 0 : + (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) + << SPA_MINBLOCKSHIFT)); + psize = get_psize (bp, endian); + + if (size) + *size = lsize; + + if ((unsigned int) comp >= ZIO_COMPRESS_FUNCTIONS || + (comp != ZIO_COMPRESS_OFF && decomp_table[comp].decomp_func == NULL)) + { + grub_dprintf ("zfs", "comp=%d\n", comp); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "compression algorithm not supported\n"); + } + + if (comp != ZIO_COMPRESS_OFF) + { + compbuf = grub_malloc (psize); + if (! compbuf) + return grub_errno; + } + else + compbuf = *buf = grub_malloc (lsize); + + grub_dprintf ("zfs", "endian = %d\n", endian); + err = zio_read_data (bp, endian, compbuf, data); + if (err) + { + grub_free (compbuf); + return err; + } + + err = zio_checksum_verify (zc, checksum, endian, compbuf, psize); + if (err) + { + grub_dprintf ("zfs", "incorrect checksum\n"); + grub_free (compbuf); + return err; + } + + if (comp != ZIO_COMPRESS_OFF) + { + *buf = grub_malloc (lsize); + err = decomp_table[comp].decomp_func (compbuf, *buf, psize, lsize); + grub_free (compbuf); + if (err) + return err; + } + + return GRUB_ERR_NONE; +} + +/* + * Get the block from a block id. + * push the block onto the stack. + * + */ +static grub_err_t +dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, + grub_zfs_endian_t *endian_out, struct grub_zfs_data *data) +{ + int idx, level; + blkptr_t *bp_array = dn->dn.dn_blkptr; + int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT; + blkptr_t *bp, *tmpbuf = 0; + grub_zfs_endian_t endian; + grub_err_t err = GRUB_ERR_NONE; + + bp = grub_malloc (sizeof (blkptr_t)); + if (!bp) + return grub_errno; + + endian = dn->endian; + for (level = dn->dn.dn_nlevels - 1; level >= 0; level--) + { + grub_dprintf ("zfs", "endian = %d\n", endian); + idx = (blkid >> (epbs * level)) & ((1 << epbs) - 1); + *bp = bp_array[idx]; + if (bp_array != dn->dn.dn_blkptr) + { + grub_free (bp_array); + bp_array = 0; + } + + if (BP_IS_HOLE (bp)) + { + grub_size_t size = grub_zfs_to_cpu16 (dn->dn.dn_datablkszsec, + dn->endian) + << SPA_MINBLOCKSHIFT; + *buf = grub_malloc (size); + if (*buf) + { + err = grub_errno; + break; + } + grub_memset (*buf, 0, size); + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + break; + } + if (level == 0) + { + grub_dprintf ("zfs", "endian = %d\n", endian); + err = zio_read (bp, endian, buf, 0, data); + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + break; + } + grub_dprintf ("zfs", "endian = %d\n", endian); + err = zio_read (bp, endian, (void **) &tmpbuf, 0, data); + endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1; + if (err) + break; + bp_array = tmpbuf; + } + if (bp_array != dn->dn.dn_blkptr) + grub_free (bp_array); + if (endian_out) + *endian_out = endian; + + grub_free (bp); + return err; +} + +/* + * mzap_lookup: Looks up property described by "name" and returns the value + * in "value". + */ +static grub_err_t +mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, + int objsize, char *name, grub_uint64_t * value) +{ + int i, chunks; + mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; + + chunks = objsize / MZAP_ENT_LEN - 1; + for (i = 0; i < chunks; i++) + { + if (grub_strcmp (mzap_ent[i].mze_name, name) == 0) + { + *value = grub_zfs_to_cpu64 (mzap_ent[i].mze_value, endian); + return GRUB_ERR_NONE; + } + } + + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "couldn't find %s", name); +} + +static int +mzap_iterate (mzap_phys_t * zapobj, grub_zfs_endian_t endian, int objsize, + int NESTED_FUNC_ATTR (*hook) (const char *name, + grub_uint64_t val)) +{ + int i, chunks; + mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; + + chunks = objsize / MZAP_ENT_LEN - 1; + for (i = 0; i < chunks; i++) + { + grub_dprintf ("zfs", "zap: name = %s, value = %llx, cd = %x\n", + mzap_ent[i].mze_name, (long long)mzap_ent[i].mze_value, + (int)mzap_ent[i].mze_cd); + if (hook (mzap_ent[i].mze_name, + grub_zfs_to_cpu64 (mzap_ent[i].mze_value, endian))) + return 1; + } + + return 0; +} + +static grub_uint64_t +zap_hash (grub_uint64_t salt, const char *name) +{ + static grub_uint64_t table[256]; + const grub_uint8_t *cp; + grub_uint8_t c; + grub_uint64_t crc = salt; + + if (table[128] == 0) + { + grub_uint64_t *ct; + int i, j; + for (i = 0; i < 256; i++) + { + for (ct = table + i, *ct = i, j = 8; j > 0; j--) + *ct = (*ct >> 1) ^ (-(*ct & 1) & ZFS_CRC64_POLY); + } + } + + for (cp = (const grub_uint8_t *) name; (c = *cp) != '\0'; cp++) + crc = (crc >> 8) ^ table[(crc ^ c) & 0xFF]; + + /* + * Only use 28 bits, since we need 4 bits in the cookie for the + * collision differentiator. We MUST use the high bits, since + * those are the onces that we first pay attention to when + * chosing the bucket. + */ + crc &= ~((1ULL << (64 - ZAP_HASHBITS)) - 1); + + return (crc); +} + +/* + * Only to be used on 8-bit arrays. + * array_len is actual len in bytes (not encoded le_value_length). + * buf is null-terminated. + */ +/* XXX */ +static int +zap_leaf_array_equal (zap_leaf_phys_t * l, grub_zfs_endian_t endian, + int blksft, int chunk, int array_len, const char *buf) +{ + int bseen = 0; + + while (bseen < array_len) + { + struct zap_leaf_array *la = &ZAP_LEAF_CHUNK (l, blksft, chunk).l_array; + int toread = MIN (array_len - bseen, ZAP_LEAF_ARRAY_BYTES); + + if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft)) + return (0); + + if (grub_memcmp (la->la_array, buf + bseen, toread) != 0) + break; + chunk = grub_zfs_to_cpu16 (la->la_next, endian); + bseen += toread; + } + return (bseen == array_len); +} + +/* XXX */ +static grub_err_t +zap_leaf_array_get (zap_leaf_phys_t * l, grub_zfs_endian_t endian, int blksft, + int chunk, int array_len, char *buf) +{ + int bseen = 0; + + while (bseen < array_len) + { + struct zap_leaf_array *la = &ZAP_LEAF_CHUNK (l, blksft, chunk).l_array; + int toread = MIN (array_len - bseen, ZAP_LEAF_ARRAY_BYTES); + + if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft)) + /* Don't use grub_error because this error is to be ignored. */ + return GRUB_ERR_BAD_FS; + + grub_memcpy (buf + bseen,la->la_array, toread); + chunk = grub_zfs_to_cpu16 (la->la_next, endian); + bseen += toread; + } + return GRUB_ERR_NONE; +} + + +/* + * Given a zap_leaf_phys_t, walk thru the zap leaf chunks to get the + * value for the property "name". + * + */ +/* XXX */ +static grub_err_t +zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian, + int blksft, grub_uint64_t h, + const char *name, grub_uint64_t * value) +{ + grub_uint16_t chunk; + struct zap_leaf_entry *le; + + /* Verify if this is a valid leaf block */ + if (grub_zfs_to_cpu64 (l->l_hdr.lh_block_type, endian) != ZBT_LEAF) + return grub_error (GRUB_ERR_BAD_FS, "invalid leaf type"); + if (grub_zfs_to_cpu32 (l->l_hdr.lh_magic, endian) != ZAP_LEAF_MAGIC) + return grub_error (GRUB_ERR_BAD_FS, "invalid leaf magic"); + + for (chunk = grub_zfs_to_cpu16 (l->l_hash[LEAF_HASH (blksft, h)], endian); + chunk != CHAIN_END; chunk = le->le_next) + { + + if (chunk >= ZAP_LEAF_NUMCHUNKS (blksft)) + return grub_error (GRUB_ERR_BAD_FS, "invalid chunk number"); + + le = ZAP_LEAF_ENTRY (l, blksft, chunk); + + /* Verify the chunk entry */ + if (le->le_type != ZAP_CHUNK_ENTRY) + return grub_error (GRUB_ERR_BAD_FS, "invalid chunk entry"); + + if (grub_zfs_to_cpu64 (le->le_hash,endian) != h) + continue; + + grub_dprintf ("zfs", "fzap: length %d\n", (int) le->le_name_length); + + if (zap_leaf_array_equal (l, endian, blksft, + grub_zfs_to_cpu16 (le->le_name_chunk,endian), + grub_zfs_to_cpu16 (le->le_name_length, endian), + name)) + { + struct zap_leaf_array *la; + grub_uint8_t *ip; + + if (le->le_int_size != 8 || le->le_value_length != 1) + return grub_error (GRUB_ERR_BAD_FS, "invalid leaf chunk entry"); + + /* get the uint64_t property value */ + la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk).l_array; + ip = la->la_array; + + *value = grub_be_to_cpu64 (*(grub_uint64_t *)la->la_array); + + return GRUB_ERR_NONE; + } + } + + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "couldn't find %s", name); +} + +/* + * Fat ZAP lookup + * + */ +/* XXX */ +static grub_err_t +fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, + char *name, grub_uint64_t * value, struct grub_zfs_data *data) +{ + zap_leaf_phys_t *l; + grub_uint64_t hash, idx, blkid; + int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + zap_dnode->endian) << DNODE_SHIFT); + grub_err_t err; + grub_zfs_endian_t leafendian; + + /* Verify if this is a fat zap header block */ + if (zap->zap_magic != (grub_uint64_t) ZAP_MAGIC) + return grub_error (GRUB_ERR_BAD_FS, "bad ZAP magic"); + + if (zap->zap_salt == 0) + return grub_error (GRUB_ERR_BAD_FS, "bad ZAP salt"); + hash = zap_hash (zap->zap_salt, name); + + /* get block id from index */ + if (zap->zap_ptrtbl.zt_numblks != 0) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "external pointer tables not supported"); + idx = ZAP_HASH_IDX (hash, zap->zap_ptrtbl.zt_shift); + blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))]; + + /* Get the leaf block */ + if ((1U << blksft) < sizeof (zap_leaf_phys_t)) + return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small"); + err = dmu_read (zap_dnode, blkid, (void **) &l, &leafendian, data); + if (err) + return err; + + err = zap_leaf_lookup (l, leafendian, blksft, hash, name, value); + grub_free (l); + return err; +} + +/* XXX */ +static int +fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, + int NESTED_FUNC_ATTR (*hook) (const char *name, + grub_uint64_t val), + struct grub_zfs_data *data) +{ + zap_leaf_phys_t *l; + grub_uint64_t idx, blkid; + grub_uint16_t chunk; + int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + zap_dnode->endian) << DNODE_SHIFT); + grub_err_t err; + grub_zfs_endian_t endian; + + /* Verify if this is a fat zap header block */ + if (zap->zap_magic != (grub_uint64_t) ZAP_MAGIC) + { + grub_error (GRUB_ERR_BAD_FS, "bad ZAP magic"); + return 0; + } + + /* get block id from index */ + if (zap->zap_ptrtbl.zt_numblks != 0) + { + grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "external pointer tables not supported"); + return 0; + } + /* Get the leaf block */ + if ((1U << blksft) < sizeof (zap_leaf_phys_t)) + { + grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small"); + return 0; + } + for (idx = 0; idx < zap->zap_ptrtbl.zt_numblks; idx++) + { + blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))]; + + err = dmu_read (zap_dnode, blkid, (void **) &l, &endian, data); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + + /* Verify if this is a valid leaf block */ + if (grub_zfs_to_cpu64 (l->l_hdr.lh_block_type, endian) != ZBT_LEAF) + { + grub_free (l); + continue; + } + if (grub_zfs_to_cpu32 (l->l_hdr.lh_magic, endian) != ZAP_LEAF_MAGIC) + { + grub_free (l); + continue; + } + + for (chunk = 0; chunk < ZAP_LEAF_NUMCHUNKS (blksft); chunk++) + { + char *buf; + struct zap_leaf_array *la; + struct zap_leaf_entry *le; + grub_uint64_t val; + le = ZAP_LEAF_ENTRY (l, blksft, chunk); + + /* Verify the chunk entry */ + if (le->le_type != ZAP_CHUNK_ENTRY) + continue; + + buf = grub_malloc (grub_zfs_to_cpu16 (le->le_name_length, endian) + + 1); + if (zap_leaf_array_get (l, endian, blksft, le->le_name_chunk, + le->le_name_length, buf)) + { + grub_free (buf); + continue; + } + buf[le->le_name_length] = 0; + + if (le->le_int_size != 8 + || grub_zfs_to_cpu16 (le->le_value_length, endian) != 1) + continue; + + /* get the uint64_t property value */ + la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk).l_array; + val = grub_be_to_cpu64 (*(grub_uint64_t *)la->la_array); + if (hook (buf, val)) + return 1; + grub_free (buf); + } + } + return 0; +} + + +/* + * Read in the data of a zap object and find the value for a matching + * property name. + * + */ +static grub_err_t +zap_lookup (dnode_end_t * zap_dnode, char *name, grub_uint64_t * val, + struct grub_zfs_data *data) +{ + grub_uint64_t block_type; + int size; + void *zapbuf; + grub_err_t err; + grub_zfs_endian_t endian; + + grub_dprintf ("zfs", "looking for '%s'\n", name); + + /* Read in the first block of the zap object data. */ + size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + zap_dnode->endian) << SPA_MINBLOCKSHIFT; + err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data); + if (err) + return err; + block_type = grub_zfs_to_cpu64 (*((grub_uint64_t *) zapbuf), endian); + + grub_dprintf ("zfs", "zap read\n"); + + if (block_type == ZBT_MICRO) + { + grub_dprintf ("zfs", "micro zap\n"); + err = (mzap_lookup (zapbuf, endian, size, name, val)); + grub_dprintf ("zfs", "returned %d\n", err); + grub_free (zapbuf); + return err; + } + else if (block_type == ZBT_HEADER) + { + grub_dprintf ("zfs", "fat zap\n"); + /* this is a fat zap */ + err = (fzap_lookup (zap_dnode, zapbuf, name, val, data)); + grub_dprintf ("zfs", "returned %d\n", err); + grub_free (zapbuf); + return err; + } + + return grub_error (GRUB_ERR_BAD_FS, "unknown ZAP type"); +} + +static int +zap_iterate (dnode_end_t * zap_dnode, + int NESTED_FUNC_ATTR (*hook) (const char *name, grub_uint64_t val), + struct grub_zfs_data *data) +{ + grub_uint64_t block_type; + int size; + void *zapbuf; + grub_err_t err; + int ret; + grub_zfs_endian_t endian; + + /* Read in the first block of the zap object data. */ + size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, zap_dnode->endian) << SPA_MINBLOCKSHIFT; + err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data); + if (err) + return 0; + block_type = grub_zfs_to_cpu64 (*((grub_uint64_t *) zapbuf), endian); + + grub_dprintf ("zfs", "zap read\n"); + + if (block_type == ZBT_MICRO) + { + grub_dprintf ("zfs", "micro zap\n"); + ret = mzap_iterate (zapbuf, endian, size, hook); + grub_free (zapbuf); + return ret; + } + else if (block_type == ZBT_HEADER) + { + grub_dprintf ("zfs", "fat zap\n"); + /* this is a fat zap */ + ret = fzap_iterate (zap_dnode, zapbuf, hook, data); + grub_free (zapbuf); + return ret; + } + grub_error (GRUB_ERR_BAD_FS, "unknown ZAP type"); + return 0; +} + + +/* + * Get the dnode of an object number from the metadnode of an object set. + * + * Input + * mdn - metadnode to get the object dnode + * objnum - object number for the object dnode + * buf - data buffer that holds the returning dnode + */ +static grub_err_t +dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, + dnode_end_t * buf, struct grub_zfs_data *data) +{ + grub_uint64_t blkid, blksz; /* the block id this object dnode is in */ + int epbs; /* shift of number of dnodes in a block */ + int idx; /* index within a block */ + dnode_phys_t *dnbuf; + grub_err_t err; + grub_zfs_endian_t endian; + + blksz = grub_zfs_to_cpu16 (mdn->dn.dn_datablkszsec, + mdn->endian) << SPA_MINBLOCKSHIFT; + epbs = zfs_log2 (blksz) - DNODE_SHIFT; + blkid = objnum >> epbs; + idx = objnum & ((1 << epbs) - 1); + + if (data->dnode_buf != NULL && grub_memcmp (data->dnode_mdn, mdn, + sizeof (*mdn)) == 0 + && objnum >= data->dnode_start && objnum < data->dnode_end) + { + grub_memmove (&(buf->dn), &(data->dnode_buf)[idx], DNODE_SIZE); + buf->endian = data->dnode_endian; + if (type && buf->dn.dn_type != type) + return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); + return GRUB_ERR_NONE; + } + + grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian, + (unsigned long long) blkid); + err = dmu_read (mdn, blkid, (void **) &dnbuf, &endian, data); + if (err) + return err; + grub_dprintf ("zfs", "alive\n"); + + grub_free (data->dnode_buf); + grub_free (data->dnode_mdn); + data->dnode_mdn = grub_malloc (sizeof (*mdn)); + if (! data->dnode_mdn) + { + grub_errno = GRUB_ERR_NONE; + data->dnode_buf = 0; + } + else + { + grub_memcpy (data->dnode_mdn, mdn, sizeof (*mdn)); + data->dnode_buf = dnbuf; + data->dnode_start = blkid << epbs; + data->dnode_end = (blkid + 1) << epbs; + data->dnode_endian = endian; + } + + grub_memmove (&(buf->dn), &dnbuf[idx], DNODE_SIZE); + buf->endian = endian; + if (type && buf->dn.dn_type != type) + return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); + + return GRUB_ERR_NONE; +} + +/* + * Get the file dnode for a given file name where mdn is the meta dnode + * for this ZFS object set. When found, place the file dnode in dn. + * The 'path' argument will be mangled. + * + */ +static grub_err_t +dnode_get_path (dnode_end_t * mdn, const char *path_in, dnode_end_t * dn, + struct grub_zfs_data *data) +{ + grub_uint64_t objnum, version; + char *cname, ch; + grub_err_t err = GRUB_ERR_NONE; + char *path, *path_buf; + struct dnode_chain + { + struct dnode_chain *next; + dnode_end_t dn; + }; + struct dnode_chain *dnode_path = 0, *dn_new, *root; + + dn_new = grub_malloc (sizeof (*dn_new)); + if (! dn_new) + return grub_errno; + dn_new->next = 0; + dnode_path = root = dn_new; + + err = dnode_get (mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, + &(dnode_path->dn), data); + if (err) + { + grub_free (dn_new); + return err; + } + + err = zap_lookup (&(dnode_path->dn), ZPL_VERSION_STR, &version, data); + if (err) + { + grub_free (dn_new); + return err; + } + if (version > ZPL_VERSION) + { + grub_free (dn_new); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "too new ZPL version"); + } + + err = zap_lookup (&(dnode_path->dn), ZFS_ROOT_OBJ, &objnum, data); + if (err) + { + grub_free (dn_new); + return err; + } + + err = dnode_get (mdn, objnum, 0, &(dnode_path->dn), data); + if (err) + { + grub_free (dn_new); + return err; + } + + path = path_buf = grub_strdup (path_in); + if (!path_buf) + { + grub_free (dn_new); + return grub_errno; + } + + while (1) + { + /* skip leading slashes */ + while (*path == '/') + path++; + if (!*path) + break; + /* get the next component name */ + cname = path; + while (*path && *path != '/') + path++; + /* Skip dot. */ + if (cname + 1 == path && cname[0] == '.') + continue; + /* Handle double dot. */ + if (cname + 2 == path && cname[0] == '.' && cname[1] == '.') + { + if (dn_new->next) + { + dn_new = dnode_path; + dnode_path = dn_new->next; + grub_free (dn_new); + } + else + { + err = grub_error (GRUB_ERR_FILE_NOT_FOUND, + "can't resolve .."); + break; + } + continue; + } + + ch = *path; + *path = 0; /* ensure null termination */ + + if (dnode_path->dn.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS) + { + grub_free (path_buf); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); + } + err = zap_lookup (&(dnode_path->dn), cname, &objnum, data); + if (err) + break; + + dn_new = grub_malloc (sizeof (*dn_new)); + if (! dn_new) + { + err = grub_errno; + break; + } + dn_new->next = dnode_path; + dnode_path = dn_new; + + objnum = ZFS_DIRENT_OBJ (objnum); + err = dnode_get (mdn, objnum, 0, &(dnode_path->dn), data); + if (err) + break; + + *path = ch; + if (((grub_zfs_to_cpu64(((znode_phys_t *) &dnode_path->dn.dn.dn_bonus)->zp_mode, dnode_path->dn.endian) >> 12) & 0xf) == 0xa && ch) + { + char *oldpath = path, *oldpathbuf = path_buf; + path = path_buf + = grub_malloc (sizeof (dnode_path->dn.dn.dn_bonus) + - sizeof (znode_phys_t) + grub_strlen (oldpath) + 1); + if (!path_buf) + { + grub_free (oldpathbuf); + return grub_errno; + } + grub_memcpy (path, + (char *) &dnode_path->dn.dn.dn_bonus[sizeof (znode_phys_t)], + sizeof (dnode_path->dn.dn.dn_bonus) - sizeof (znode_phys_t)); + path [sizeof (dnode_path->dn.dn.dn_bonus) - sizeof (znode_phys_t)] = 0; + grub_memcpy (path + grub_strlen (path), oldpath, + grub_strlen (oldpath) + 1); + + grub_free (oldpathbuf); + if (path[0] != '/') + { + dn_new = dnode_path; + dnode_path = dn_new->next; + grub_free (dn_new); + } + else while (dnode_path != root) + { + dn_new = dnode_path; + dnode_path = dn_new->next; + grub_free (dn_new); + } + } + } + + if (!err) + grub_memcpy (dn, &(dnode_path->dn), sizeof (*dn)); + + while (dnode_path) + { + dn_new = dnode_path->next; + grub_free (dnode_path); + dnode_path = dn_new; + } + grub_free (path_buf); + return err; +} + +#if 0 +/* + * Get the default 'bootfs' property value from the rootpool. + * + */ +static grub_err_t +get_default_bootfsobj (dnode_phys_t * mosmdn, grub_uint64_t * obj, + struct grub_zfs_data *data) +{ + grub_uint64_t objnum = 0; + dnode_phys_t *dn; + if (!dn) + return grub_errno; + + if ((grub_errno = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT, + DMU_OT_OBJECT_DIRECTORY, dn, data))) + { + grub_free (dn); + return (grub_errno); + } + + /* + * find the object number for 'pool_props', and get the dnode + * of the 'pool_props'. + */ + if (zap_lookup (dn, DMU_POOL_PROPS, &objnum, data)) + { + grub_free (dn); + return (GRUB_ERR_BAD_FS); + } + if ((grub_errno = dnode_get (mosmdn, objnum, DMU_OT_POOL_PROPS, dn, data))) + { + grub_free (dn); + return (grub_errno); + } + if (zap_lookup (dn, ZPOOL_PROP_BOOTFS, &objnum, data)) + { + grub_free (dn); + return (GRUB_ERR_BAD_FS); + } + + if (!objnum) + { + grub_free (dn); + return (GRUB_ERR_BAD_FS); + } + + *obj = objnum; + return (0); +} +#endif +/* + * Given a MOS metadnode, get the metadnode of a given filesystem name (fsname), + * e.g. pool/rootfs, or a given object number (obj), e.g. the object number + * of pool/rootfs. + * + * If no fsname and no obj are given, return the DSL_DIR metadnode. + * If fsname is given, return its metadnode and its matching object number. + * If only obj is given, return the metadnode for this object number. + * + */ +static grub_err_t +get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, + dnode_end_t * mdn, struct grub_zfs_data *data) +{ + grub_uint64_t objnum; + grub_err_t err; + + grub_dprintf ("zfs", "endian = %d\n", mosmdn->endian); + + err = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT, + DMU_OT_OBJECT_DIRECTORY, mdn, data); + if (err) + return err; + + grub_dprintf ("zfs", "alive\n"); + + err = zap_lookup (mdn, DMU_POOL_ROOT_DATASET, &objnum, data); + if (err) + return err; + + grub_dprintf ("zfs", "alive\n"); + + err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + if (err) + return err; + + grub_dprintf ("zfs", "alive\n"); + + while (*fsname) + { + grub_uint64_t childobj; + char *cname, ch; + + while (*fsname == '/') + fsname++; + + if (! *fsname || *fsname == '@') + break; + + cname = fsname; + while (*fsname && !grub_isspace (*fsname) && *fsname != '/') + fsname++; + ch = *fsname; + *fsname = 0; + + childobj = grub_zfs_to_cpu64(((dsl_dir_phys_t *) &(mdn->dn.dn_bonus))->dd_child_dir_zapobj, mdn->endian); + err = dnode_get (mosmdn, childobj, + DMU_OT_DSL_DIR_CHILD_MAP, mdn, data); + if (err) + return err; + + err = zap_lookup (mdn, cname, &objnum, data); + if (err) + return err; + + err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + if (err) + return err; + + *fsname = ch; + } + return GRUB_ERR_NONE; +} + +static grub_err_t +make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) +{ + objset_phys_t *osp; + blkptr_t *bp; + grub_size_t ospsize; + grub_err_t err; + + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + bp = &((dsl_dataset_phys_t *) &(mdn->dn.dn_bonus))->ds_bp; + err = zio_read (bp, mdn->endian, (void **) &osp, &ospsize, data); + if (err) + return err; + if (ospsize < sizeof (objset_phys_t)) + { + grub_free (osp); + return grub_error (GRUB_ERR_BAD_FS, "too small osp"); + } + + mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1; + grub_memmove ((char *) &(mdn->dn), (char *) &osp->os_meta_dnode, DNODE_SIZE); + grub_free (osp); + return GRUB_ERR_NONE; +} + +static grub_err_t +dnode_get_fullpath (const char *fullpath, dnode_end_t * mdn, + grub_uint64_t *mdnobj, dnode_end_t * dn, int *isfs, + struct grub_zfs_data *data) +{ + char *fsname, *snapname; + const char *ptr_at, *filename; + grub_uint64_t headobj; + grub_err_t err; + + ptr_at = grub_strchr (fullpath, '@'); + if (! ptr_at) + { + *isfs = 1; + filename = 0; + snapname = 0; + fsname = grub_strdup (fullpath); + } + else + { + const char *ptr_slash = grub_strchr (ptr_at, '/'); + + *isfs = 0; + fsname = grub_malloc (ptr_at - fullpath + 1); + if (!fsname) + return grub_errno; + grub_memcpy (fsname, fullpath, ptr_at - fullpath); + fsname[ptr_at - fullpath] = 0; + if (ptr_at[1] && ptr_at[1] != '/') + { + snapname = grub_malloc (ptr_slash - ptr_at); + if (!snapname) + { + grub_free (fsname); + return grub_errno; + } + grub_memcpy (snapname, ptr_at + 1, ptr_slash - ptr_at - 1); + snapname[ptr_slash - ptr_at - 1] = 0; + } + else + snapname = 0; + if (ptr_slash) + filename = ptr_slash; + else + filename = "/"; + grub_dprintf ("zfs", "fsname = '%s' snapname='%s' filename = '%s'\n", + fsname, snapname, filename); + } + grub_dprintf ("zfs", "alive\n"); + err = get_filesystem_dnode (&(data->mos), fsname, dn, data); + if (err) + { + grub_free (fsname); + grub_free (snapname); + return err; + } + + grub_dprintf ("zfs", "alive\n"); + + headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) &(dn->dn.dn_bonus))->dd_head_dataset_obj, dn->endian); + + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, mdn, data); + if (err) + { + grub_free (fsname); + grub_free (snapname); + return err; + } + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + if (snapname) + { + grub_uint64_t snapobj; + + snapobj = grub_zfs_to_cpu64 (((dsl_dataset_phys_t *) &(mdn->dn.dn_bonus))->ds_snapnames_zapobj, mdn->endian); + + err = dnode_get (&(data->mos), snapobj, + DMU_OT_DSL_DS_SNAP_MAP, mdn, data); + if (!err) + err = zap_lookup (mdn, snapname, &headobj, data); + if (!err) + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, mdn, data); + if (err) + { + grub_free (fsname); + grub_free (snapname); + return err; + } + } + + if (mdnobj) + *mdnobj = headobj; + + make_mdn (mdn, data); + + grub_dprintf ("zfs", "endian = %d\n", mdn->endian); + + if (*isfs) + { + grub_free (fsname); + grub_free (snapname); + return GRUB_ERR_NONE; + } + err = dnode_get_path (mdn, filename, dn, data); + grub_free (fsname); + grub_free (snapname); + return err; +} + +/* + * For a given XDR packed nvlist, verify the first 4 bytes and move on. + * + * An XDR packed nvlist is encoded as (comments from nvs_xdr_create) : + * + * encoding method/host endian (4 bytes) + * nvl_version (4 bytes) + * nvl_nvflag (4 bytes) + * encoded nvpairs: + * encoded size of the nvpair (4 bytes) + * decoded size of the nvpair (4 bytes) + * name string size (4 bytes) + * name string data (sizeof(NV_ALIGN4(string)) + * data type (4 bytes) + * # of elements in the nvpair (4 bytes) + * data + * 2 zero's for the last nvpair + * (end of the entire list) (8 bytes) + * + */ + +static int +nvlist_find_value (char *nvlist, char *name, int valtype, char **val, + grub_size_t *size_out, grub_size_t *nelm_out) +{ + int name_len, type, encode_size; + char *nvpair, *nvp_name; + + /* Verify if the 1st and 2nd byte in the nvlist are valid. */ + /* NOTE: independently of what endianness header announces all + subsequent values are big-endian. */ + if (nvlist[0] != NV_ENCODE_XDR || (nvlist[1] != NV_LITTLE_ENDIAN + && nvlist[1] != NV_BIG_ENDIAN)) + { + grub_dprintf ("zfs", "incorrect nvlist header\n"); + grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); + return 0; + } + + /* skip the header, nvl_version, and nvl_nvflag */ + nvlist = nvlist + 4 * 3; + /* + * Loop thru the nvpair list + * The XDR representation of an integer is in big-endian byte order. + */ + while ((encode_size = grub_be_to_cpu32 (*(grub_uint32_t *) nvlist))) + { + int nelm; + + nvpair = nvlist + 4 * 2; /* skip the encode/decode size */ + + name_len = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + nvpair += 4; + + nvp_name = nvpair; + nvpair = nvpair + ((name_len + 3) & ~3); /* align */ + + type = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + nvpair += 4; + + nelm = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + if (nelm < 1) + return grub_error (GRUB_ERR_BAD_FS, "empty nvpair"); + + nvpair += 4; + + if ((grub_strncmp (nvp_name, name, name_len) == 0) && type == valtype) + { + *val = nvpair; + *size_out = encode_size; + if (nelm_out) + *nelm_out = nelm; + return 1; + } + + nvlist += encode_size; /* goto the next nvpair */ + } + return 0; +} + +int +grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name, grub_uint64_t * out) +{ + char *nvpair; + grub_size_t size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_UINT64, &nvpair, &size, 0); + if (!found) + return 0; + if (size < sizeof (grub_uint64_t)) + { + grub_error (GRUB_ERR_BAD_FS, "invalid uint64"); + return 0; + } + + *out = grub_be_to_cpu64 (*(grub_uint64_t *) nvpair); + return 1; +} + +char * +grub_zfs_nvlist_lookup_string (char *nvlist, char *name) +{ + char *nvpair; + char *ret; + grub_size_t slen; + grub_size_t size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_STRING, &nvpair, &size, 0); + if (!found) + return 0; + if (size < 4) + { + grub_error (GRUB_ERR_BAD_FS, "invalid string"); + return 0; + } + slen = grub_be_to_cpu32 (*(grub_uint32_t *) nvpair); + if (slen > size - 4) + slen = size - 4; + ret = grub_malloc (slen + 1); + if (!ret) + return 0; + grub_memcpy (ret, nvpair + 4, slen); + ret[slen] = 0; + return ret; +} + +char * +grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name) +{ + char *nvpair; + char *ret; + grub_size_t size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, + &size, 0); + if (!found) + return 0; + ret = grub_zalloc (size + 3 * sizeof (grub_uint32_t)); + if (!ret) + return 0; + grub_memcpy (ret, nvlist, sizeof (grub_uint32_t)); + + grub_memcpy (ret + sizeof (grub_uint32_t), nvpair, size); + return ret; +} + +int +grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name) +{ + char *nvpair; + grub_size_t nelm, size; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, + &size, &nelm); + if (! found) + return -1; + return nelm; +} + +char * +grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name, + grub_size_t index) +{ + char *nvpair, *nvpairptr; + int found; + char *ret; + grub_size_t size; + unsigned i; + grub_size_t nelm; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, + &size, &nelm); + if (!found) + return 0; + if (index >= nelm) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, "trying to lookup past nvlist array"); + return 0; + } + + nvpairptr = nvpair; + + for (i = 0; i < index; i++) + { + grub_uint32_t encode_size; + + /* skip the header, nvl_version, and nvl_nvflag */ + nvpairptr = nvpairptr + 4 * 2; + + while (nvpairptr < nvpair + size + && (encode_size = grub_be_to_cpu32 (*(grub_uint32_t *) nvpairptr))) + nvlist += encode_size; /* goto the next nvpair */ + + nvlist = nvlist + 4 * 2; /* skip the ending 2 zeros - 8 bytes */ + } + + if (nvpairptr >= nvpair + size + || nvpairptr + grub_be_to_cpu32 (*(grub_uint32_t *) (nvpairptr + 4 * 2)) + >= nvpair + size) + { + grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist array"); + return 0; + } + + ret = grub_zalloc (grub_be_to_cpu32 (*(grub_uint32_t *) (nvpairptr + 4 * 2)) + + 3 * sizeof (grub_uint32_t)); + if (!ret) + return 0; + grub_memcpy (ret, nvlist, sizeof (grub_uint32_t)); + + grub_memcpy (ret + sizeof (grub_uint32_t), nvpairptr, size); + return ret; +} + +static grub_err_t +zfs_fetch_nvlist (struct grub_zfs_data * data, char **nvlist) +{ + grub_err_t err; + + *nvlist = grub_malloc (VDEV_PHYS_SIZE); + /* Read in the vdev name-value pair list (112K). */ + err = grub_disk_read (data->disk, data->vdev_phys_sector, 0, + VDEV_PHYS_SIZE, *nvlist); + if (err) + { + grub_free (*nvlist); + *nvlist = 0; + return err; + } + return GRUB_ERR_NONE; +} + +/* + * Check the disk label information and retrieve needed vdev name-value pairs. + * + */ +static grub_err_t +check_pool_label (struct grub_zfs_data *data) +{ + grub_uint64_t pool_state, txg = 0; + char *nvlist; +#if 0 + char *nv; +#endif + grub_uint64_t diskguid; + grub_uint64_t version; + int found; + grub_err_t err; + + err = zfs_fetch_nvlist (data, &nvlist); + if (err) + return err; + + grub_dprintf ("zfs", "check 2 passed\n"); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE, + &pool_state); + if (! found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_POOL_STATE " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 3 passed\n"); + + if (pool_state == POOL_STATE_DESTROYED) + { + grub_free (nvlist); + return grub_error (GRUB_ERR_BAD_FS, "zpool is marked as destroyed"); + } + grub_dprintf ("zfs", "check 4 passed\n"); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_TXG, &txg); + if (!found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_POOL_TXG " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 6 passed\n"); + + /* not an active device */ + if (txg == 0) + { + grub_free (nvlist); + return grub_error (GRUB_ERR_BAD_FS, "zpool isn't active"); + } + grub_dprintf ("zfs", "check 7 passed\n"); + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_VERSION, + &version); + if (! found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_VERSION " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 8 passed\n"); + + if (version > SPA_VERSION) + { + grub_free (nvlist); + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "too new version %llu > %llu", + (unsigned long long) version, + (unsigned long long) SPA_VERSION); + } + grub_dprintf ("zfs", "check 9 passed\n"); +#if 0 + if (nvlist_lookup_value (nvlist, ZPOOL_CONFIG_VDEV_TREE, &nv, + DATA_TYPE_NVLIST, NULL)) + { + grub_free (vdev); + return (GRUB_ERR_BAD_FS); + } + grub_dprintf ("zfs", "check 10 passed\n"); +#endif + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_GUID, &diskguid); + if (! found) + { + grub_free (nvlist); + if (! grub_errno) + grub_error (GRUB_ERR_BAD_FS, ZPOOL_CONFIG_GUID " not found"); + return grub_errno; + } + grub_dprintf ("zfs", "check 11 passed\n"); + + grub_free (nvlist); + + return GRUB_ERR_NONE; +} + +static void +zfs_unmount (struct grub_zfs_data *data) +{ + grub_free (data->dnode_buf); + grub_free (data->dnode_mdn); + grub_free (data->file_buf); + grub_free (data); +} + +/* + * zfs_mount() locates a valid uberblock of the root pool and read in its MOS + * to the memory address MOS. + * + */ +static struct grub_zfs_data * +zfs_mount (grub_device_t dev) +{ + struct grub_zfs_data *data = 0; + int label = 0; + uberblock_phys_t *ub_array, *ubbest = NULL; + vdev_boot_header_t *bh; + objset_phys_t *osp = 0; + grub_size_t ospsize; + grub_err_t err; + int vdevnum; + + if (! dev->disk) + { + grub_error (GRUB_ERR_BAD_DEVICE, "not a disk"); + return 0; + } + + data = grub_malloc (sizeof (*data)); + if (!data) + return 0; + grub_memset (data, 0, sizeof (*data)); +#if 0 + /* if it's our first time here, zero the best uberblock out */ + if (data->best_drive == 0 && data->best_part == 0 && find_best_root) + grub_memset (¤t_uberblock, 0, sizeof (uberblock_t)); +#endif + + data->disk = dev->disk; + + ub_array = grub_malloc (VDEV_UBERBLOCK_RING); + if (!ub_array) + { + zfs_unmount (data); + return 0; + } + + bh = grub_malloc (VDEV_BOOT_HEADER_SIZE); + if (!bh) + { + zfs_unmount (data); + grub_free (ub_array); + return 0; + } + + vdevnum = VDEV_LABELS; + + /* Don't check back labels on CDROM. */ + if (! data->disk->partition + && data->disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID + && data->disk->id >= 0xc0) + vdevnum = VDEV_LABELS / 2; + + for (label = 0; ubbest == NULL && label < vdevnum; label++) + { + grub_zfs_endian_t ub_endian = UNKNOWN_ENDIAN; + grub_dprintf ("zfs", "label %d\n", label); + + data->vdev_phys_sector + = label * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT) + + ((VDEV_SKIP_SIZE + VDEV_BOOT_HEADER_SIZE) >> SPA_MINBLOCKSHIFT) + + (label < VDEV_LABELS / 2 ? 0 : grub_disk_get_size (dev->disk) + - VDEV_LABELS * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT)); + + /* Read in the uberblock ring (128K). */ + err = grub_disk_read (data->disk, data->vdev_phys_sector + + (VDEV_PHYS_SIZE >> SPA_MINBLOCKSHIFT), + 0, VDEV_UBERBLOCK_RING, (char *) ub_array); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } + grub_dprintf ("zfs", "label ok %d\n", label); + + ubbest = find_bestub (ub_array, data->vdev_phys_sector); + if (!ubbest) + { + grub_dprintf ("zfs", "No uberblock found\n"); + grub_errno = GRUB_ERR_NONE; + continue; + } + ub_endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_magic, + LITTLE_ENDIAN) == UBERBLOCK_MAGIC + ? LITTLE_ENDIAN : BIG_ENDIAN); + err = zio_read (&ubbest->ubp_uberblock.ub_rootbp, + ub_endian, + (void **) &osp, &ospsize, data); + if (err) + { + grub_dprintf ("zfs", "couldn't zio_read\n"); + grub_errno = GRUB_ERR_NONE; + continue; + } + + if (ospsize < sizeof (objset_phys_t)) + { + grub_dprintf ("zfs", "osp too small\n"); + grub_free (osp); + continue; + } + grub_dprintf ("zfs", "ubbest %p\n", ubbest); + + err = check_pool_label (data); + if (err) + { + grub_errno = GRUB_ERR_NONE; + continue; + } +#if 0 + if (find_best_root && + vdev_uberblock_compare (&ubbest->ubp_uberblock, + &(current_uberblock)) <= 0) + continue; +#endif + /* Got the MOS. Save it at the memory addr MOS. */ + grub_memmove (&(data->mos.dn), &osp->os_meta_dnode, DNODE_SIZE); + data->mos.endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_rootbp.blk_prop, ub_endian) >> 63) & 1; + grub_memmove (&(data->current_uberblock), + &ubbest->ubp_uberblock, sizeof (uberblock_t)); + grub_free (ub_array); + grub_free (bh); + grub_free (osp); + return data; + } + grub_error (GRUB_ERR_BAD_FS, "couldn't find a valid label"); + zfs_unmount (data); + grub_free (ub_array); + grub_free (bh); + grub_free (osp); + + return 0; +} + +grub_err_t +grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist) +{ + struct grub_zfs_data *zfs; + grub_err_t err; + + zfs = zfs_mount (dev); + if (!zfs) + return grub_errno; + err = zfs_fetch_nvlist (zfs, nvlist); + zfs_unmount (zfs); + return err; +} + +static grub_err_t +zfs_label (grub_device_t device, char **label) +{ + char *nvlist; + grub_err_t err; + struct grub_zfs_data *data; + + data = zfs_mount (device); + if (! data) + return grub_errno; + + err = zfs_fetch_nvlist (data, &nvlist); + if (err) + { + zfs_unmount (data); + return err; + } + + *label = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME); + grub_free (nvlist); + zfs_unmount (data); + return grub_errno; +} + +static grub_err_t +zfs_uuid (grub_device_t device, char **uuid) +{ + char *nvlist; + int found; + struct grub_zfs_data *data; + grub_uint64_t guid; + grub_err_t err; + + *uuid = 0; + + data = zfs_mount (device); + if (! data) + return grub_errno; + + err = zfs_fetch_nvlist (data, &nvlist); + if (err) + { + zfs_unmount (data); + return err; + } + + found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_GUID, &guid); + if (! found) + return grub_errno; + grub_free (nvlist); + *uuid = grub_malloc (16 + sizeof ('\0')); + if (! *uuid) + return grub_errno; + grub_sprintf (*uuid, "%016llx", (long long unsigned) guid); + zfs_unmount (data); + return GRUB_ERR_NONE; +} + +/* + * zfs_open() locates a file in the rootpool by following the + * MOS and places the dnode of the file in the memory address DNODE. + */ +static grub_err_t +grub_zfs_open (struct grub_file *file, const char *fsfilename) +{ + struct grub_zfs_data *data; + grub_err_t err; + int isfs; + + data = zfs_mount (file->device); + if (! data) + return grub_errno; + + err = dnode_get_fullpath (fsfilename, &(data->mdn), 0, + &(data->dnode), &isfs, data); + if (err) + { + zfs_unmount (data); + return err; + } + + if (isfs) + { + zfs_unmount (data); + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "Missing @ or / separator"); + } + + /* We found the dnode for this file. Verify if it is a plain file. */ + if (data->dnode.dn.dn_type != DMU_OT_PLAIN_FILE_CONTENTS) + { + zfs_unmount (data); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a file"); + } + + /* get the file size and set the file position to 0 */ + file->data = data; + file->offset = 0; + file->size = grub_zfs_to_cpu64 (((znode_phys_t *) &(data->dnode.dn.dn_bonus))->zp_size, data->dnode.endian); + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + + return GRUB_ERR_NONE; +} + +static grub_ssize_t +grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) +{ + struct grub_zfs_data *data = (struct grub_zfs_data *) file->data; + int blksz, movesize; + grub_size_t length; + grub_size_t read; + grub_err_t err; + + if (data->file_buf == NULL) + { + data->file_buf = grub_malloc (SPA_MAXBLOCKSIZE); + if (!data->file_buf) + return -1; + data->file_start = data->file_end = 0; + } + + /* + * If offset is in memory, move it into the buffer provided and return. + */ + if (file->offset >= data->file_start + && file->offset + len <= data->file_end) + { + grub_memmove (buf, data->file_buf + file->offset - data->file_start, + len); + return len; + } + + blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec, + data->dnode.endian) << SPA_MINBLOCKSHIFT; + + /* + * Entire Dnode is too big to fit into the space available. We + * will need to read it in chunks. This could be optimized to + * read in as large a chunk as there is space available, but for + * now, this only reads in one data block at a time. + */ + length = len; + read = 0; + while (length) + { + /* + * Find requested blkid and the offset within that block. + */ + grub_uint64_t blkid = grub_divmod64 (file->offset + read, blksz, 0); + grub_free (data->file_buf); + data->file_buf = 0; + + err = dmu_read (&(data->dnode), blkid, (void **) &(data->file_buf), + 0, data); + if (err) + return -1; + + data->file_start = blkid * blksz; + data->file_end = data->file_start + blksz; + + movesize = MIN (length, data->file_end - (int) file->offset - read); + + grub_memmove (buf, data->file_buf + file->offset + read + - data->file_start, movesize); + buf += movesize; + length -= movesize; + read += movesize; + } + + return len; +} + +static grub_err_t +grub_zfs_close (grub_file_t file) +{ + zfs_unmount ((struct grub_zfs_data *) file->data); + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + return GRUB_ERR_NONE; +} + +grub_err_t +grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename, + grub_uint64_t *mdnobj) +{ + struct grub_zfs_data *data; + grub_err_t err; + int isfs; + + data = zfs_mount (dev); + if (! data) + return grub_errno; + + err = dnode_get_fullpath (fsfilename, &(data->mdn), mdnobj, + &(data->dnode), &isfs, data); + zfs_unmount (data); + return err; +} + +static void +fill_fs_info (struct grub_dirhook_info *info, + dnode_end_t mdn, struct grub_zfs_data *data) +{ + grub_err_t err; + dnode_end_t dn; + grub_uint64_t objnum; + grub_uint64_t headobj; + + grub_memset (info, 0, sizeof (*info)); + + info->dir = 1; + + if (mdn.dn.dn_type == DMU_OT_DSL_DIR) + { + headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) &(mdn.dn.dn_bonus))->dd_head_dataset_obj, mdn.endian); + + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &mdn, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + } + make_mdn (&mdn, data); + err = dnode_get (&mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, + &dn, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + + err = zap_lookup (&dn, ZFS_ROOT_OBJ, &objnum, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + + err = dnode_get (&mdn, objnum, 0, &dn, data); + if (err) + { + grub_dprintf ("zfs", "failed here\n"); + return; + } + + info->mtimeset = 1; + info->mtime = grub_zfs_to_cpu64 (((znode_phys_t *) &dn.dn.dn_bonus)->zp_mtime[0], dn.endian); + return; +} + +static grub_err_t +grub_zfs_dir (grub_device_t device, const char *path, + int (*hook) (const char *, const struct grub_dirhook_info *)) +{ + struct grub_zfs_data *data; + grub_err_t err; + int isfs; + auto int NESTED_FUNC_ATTR iterate_zap (const char *name, grub_uint64_t val); + auto int NESTED_FUNC_ATTR iterate_zap_fs (const char *name, + grub_uint64_t val); + auto int NESTED_FUNC_ATTR iterate_zap_snap (const char *name, + grub_uint64_t val); + + int NESTED_FUNC_ATTR iterate_zap (const char *name, grub_uint64_t val) + { + struct grub_dirhook_info info; + dnode_end_t dn; + grub_memset (&info, 0, sizeof (info)); + + dnode_get (&(data->mdn), val, 0, &dn, data); + info.mtimeset = 1; + info.mtime = grub_zfs_to_cpu64 (((znode_phys_t *) &dn.dn.dn_bonus)->zp_mtime[0], dn.endian); + info.dir = (dn.dn.dn_type == DMU_OT_DIRECTORY_CONTENTS); + grub_dprintf ("zfs", "type=%d, name=%s\n", + (int)dn.dn.dn_type, (char *)name); + return hook (name, &info); + } + + int NESTED_FUNC_ATTR iterate_zap_fs (const char *name, grub_uint64_t val) + { + struct grub_dirhook_info info; + dnode_end_t mdn; + err = dnode_get (&(data->mos), val, 0, &mdn, data); + if (err) + return 0; + if (mdn.dn.dn_type != DMU_OT_DSL_DIR) + return 0; + + fill_fs_info (&info, mdn, data); + return hook (name, &info); + } + int NESTED_FUNC_ATTR iterate_zap_snap (const char *name, grub_uint64_t val) + { + struct grub_dirhook_info info; + char *name2; + int ret; + dnode_end_t mdn; + + err = dnode_get (&(data->mos), val, 0, &mdn, data); + if (err) + return 0; + + if (mdn.dn.dn_type != DMU_OT_DSL_DATASET) + return 0; + + fill_fs_info (&info, mdn, data); + + name2 = grub_malloc (grub_strlen (name) + 2); + name2[0] = '@'; + grub_memcpy (name2 + 1, name, grub_strlen (name) + 1); + ret = hook (name2, &info); + grub_free (name2); + return ret; + } + + data = zfs_mount (device); + if (! data) + return grub_errno; + err = dnode_get_fullpath (path, &(data->mdn), 0, &(data->dnode), &isfs, data); + if (err) + { + zfs_unmount (data); + return err; + } + if (isfs) + { + grub_uint64_t childobj, headobj; + grub_uint64_t snapobj; + dnode_end_t dn; + struct grub_dirhook_info info; + + fill_fs_info (&info, data->dnode, data); + hook ("@", &info); + + childobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) &(data->dnode.dn.dn_bonus))->dd_child_dir_zapobj, data->dnode.endian); + headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) &(data->dnode.dn.dn_bonus))->dd_head_dataset_obj, data->dnode.endian); + err = dnode_get (&(data->mos), childobj, + DMU_OT_DSL_DIR_CHILD_MAP, &dn, data); + if (err) + { + zfs_unmount (data); + return err; + } + + zap_iterate (&dn, iterate_zap_fs, data); + + err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &dn, data); + if (err) + { + zfs_unmount (data); + return err; + } + + snapobj = grub_zfs_to_cpu64 (((dsl_dataset_phys_t *) &dn.dn.dn_bonus)->ds_snapnames_zapobj, dn.endian); + + err = dnode_get (&(data->mos), snapobj, + DMU_OT_DSL_DS_SNAP_MAP, &dn, data); + if (err) + { + zfs_unmount (data); + return err; + } + + zap_iterate (&dn, iterate_zap_snap, data); + } + else + { + if (data->dnode.dn.dn_type != DMU_OT_DIRECTORY_CONTENTS) + { + zfs_unmount (data); + return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); + } + zap_iterate (&(data->dnode), iterate_zap, data); + } + zfs_unmount (data); + return grub_errno; +} + +static struct grub_fs grub_zfs_fs = { + .name = "zfs", + .dir = grub_zfs_dir, + .open = grub_zfs_open, + .read = grub_zfs_read, + .close = grub_zfs_close, + .label = zfs_label, + .uuid = zfs_uuid, + .mtime = 0, + .next = 0 +}; + +GRUB_MOD_INIT (zfs) +{ + grub_fs_register (&grub_zfs_fs); +#ifndef GRUB_UTIL + my_mod = mod; +#endif +} + +GRUB_MOD_FINI (zfs) +{ + grub_fs_unregister (&grub_zfs_fs); +} --- grub2-1.97~beta4.orig/debian/grub-extras/fs/zfs_fletcher.c +++ grub2-1.97~beta4/debian/grub-extras/fs/zfs_fletcher.c @@ -0,0 +1,86 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2007 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void +fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, + zio_cksum_t *zcp) +{ + const grub_uint64_t *ip = buf; + const grub_uint64_t *ipend = ip + (size / sizeof (grub_uint64_t)); + grub_uint64_t a0, b0, a1, b1; + + for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) + { + a0 += grub_zfs_to_cpu64 (ip[0], endian); + a1 += grub_zfs_to_cpu64 (ip[1], endian); + b0 += a0; + b1 += a1; + } + + zcp->zc_word[0] = grub_cpu_to_zfs64 (a0, endian); + zcp->zc_word[1] = grub_cpu_to_zfs64 (a1, endian); + zcp->zc_word[2] = grub_cpu_to_zfs64 (b0, endian); + zcp->zc_word[3] = grub_cpu_to_zfs64 (b1, endian); +} + +void +fletcher_4 (const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, + zio_cksum_t *zcp) +{ + const grub_uint32_t *ip = buf; + const grub_uint32_t *ipend = ip + (size / sizeof (grub_uint32_t)); + grub_uint64_t a, b, c, d; + + for (a = b = c = d = 0; ip < ipend; ip++) + { + a += grub_zfs_to_cpu32 (ip[0], endian);; + b += a; + c += b; + d += c; + } + + zcp->zc_word[0] = grub_cpu_to_zfs64 (a, endian); + zcp->zc_word[1] = grub_cpu_to_zfs64 (b, endian); + zcp->zc_word[2] = grub_cpu_to_zfs64 (c, endian); + zcp->zc_word[3] = grub_cpu_to_zfs64 (d, endian); +} + --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/zfs_acl.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/zfs_acl.h @@ -0,0 +1,60 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_ZFS_ACL_H +#define _SYS_FS_ZFS_ACL_H + +#ifndef _UID_T +#define _UID_T +typedef unsigned int uid_t; /* UID type */ +#endif /* _UID_T */ + +typedef struct zfs_oldace { + grub_uint32_t z_fuid; /* "who" */ + grub_uint32_t z_access_mask; /* access mask */ + grub_uint16_t z_flags; /* flags, i.e inheritance */ + grub_uint16_t z_type; /* type of entry allow/deny */ +} zfs_oldace_t; + +#define ACE_SLOT_CNT 6 + +typedef struct zfs_znode_acl_v0 { + grub_uint64_t z_acl_extern_obj; /* ext acl pieces */ + grub_uint32_t z_acl_count; /* Number of ACEs */ + grub_uint16_t z_acl_version; /* acl version */ + grub_uint16_t z_acl_pad; /* pad */ + zfs_oldace_t z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */ +} zfs_znode_acl_v0_t; + +#define ZFS_ACE_SPACE (sizeof (zfs_oldace_t) * ACE_SLOT_CNT) + +typedef struct zfs_znode_acl { + grub_uint64_t z_acl_extern_obj; /* ext acl pieces */ + grub_uint32_t z_acl_size; /* Number of bytes in ACL */ + grub_uint16_t z_acl_version; /* acl version */ + grub_uint16_t z_acl_count; /* ace count */ + grub_uint8_t z_ace_data[ZFS_ACE_SPACE]; /* space for embedded ACEs */ +} zfs_znode_acl_t; + + +#endif /* _SYS_FS_ZFS_ACL_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/vdev_impl.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/vdev_impl.h @@ -0,0 +1,70 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_VDEV_IMPL_H +#define _SYS_VDEV_IMPL_H + +#define VDEV_SKIP_SIZE (8 << 10) +#define VDEV_BOOT_HEADER_SIZE (8 << 10) +#define VDEV_PHYS_SIZE (112 << 10) +#define VDEV_UBERBLOCK_RING (128 << 10) + +/* ZFS boot block */ +#define VDEV_BOOT_MAGIC 0x2f5b007b10cULL +#define VDEV_BOOT_VERSION 1 /* version number */ + +typedef struct vdev_boot_header { + grub_uint64_t vb_magic; /* VDEV_BOOT_MAGIC */ + grub_uint64_t vb_version; /* VDEV_BOOT_VERSION */ + grub_uint64_t vb_offset; /* start offset (bytes) */ + grub_uint64_t vb_size; /* size (bytes) */ + char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (grub_uint64_t)]; +} vdev_boot_header_t; + +typedef struct vdev_phys { + char vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_block_tail_t)]; + zio_block_tail_t vp_zbt; +} vdev_phys_t; + +typedef struct vdev_label { + char vl_pad[VDEV_SKIP_SIZE]; /* 8K */ + vdev_boot_header_t vl_boot_header; /* 8K */ + vdev_phys_t vl_vdev_phys; /* 112K */ + char vl_uberblock[VDEV_UBERBLOCK_RING]; /* 128K */ +} vdev_label_t; /* 256K total */ + +/* + * Size and offset of embedded boot loader region on each label. + * The total size of the first two labels plus the boot area is 4MB. + */ +#define VDEV_BOOT_OFFSET (2 * sizeof (vdev_label_t)) +#define VDEV_BOOT_SIZE (7ULL << 19) /* 3.5M */ + +/* + * Size of label regions at the start and end of each leaf device. + */ +#define VDEV_LABEL_START_SIZE (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE) +#define VDEV_LABEL_END_SIZE (2 * sizeof (vdev_label_t)) +#define VDEV_LABELS 4 + +#endif /* _SYS_VDEV_IMPL_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/dmu_objset.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/dmu_objset.h @@ -0,0 +1,37 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DMU_OBJSET_H +#define _SYS_DMU_OBJSET_H + +#include + +typedef struct objset_phys { + dnode_phys_t os_meta_dnode; + zil_header_t os_zil_header; + grub_uint64_t os_type; + char os_pad[1024 - sizeof (dnode_phys_t) - sizeof (zil_header_t) - + sizeof (grub_uint64_t)]; +} objset_phys_t; + +#endif /* _SYS_DMU_OBJSET_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/dnode.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/dnode.h @@ -0,0 +1,78 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DNODE_H +#define _SYS_DNODE_H + +#include + +/* + * Fixed constants. + */ +#define DNODE_SHIFT 9 /* 512 bytes */ +#define DN_MIN_INDBLKSHIFT 10 /* 1k */ +#define DN_MAX_INDBLKSHIFT 14 /* 16k */ +#define DNODE_BLOCK_SHIFT 14 /* 16k */ +#define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ +#define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ +#define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */ + +/* + * Derived constants. + */ +#define DNODE_SIZE (1 << DNODE_SHIFT) +#define DN_MAX_NBLKPTR ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT) +#define DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT)) +#define DN_MAX_OBJECT (1ULL << DN_MAX_OBJECT_SHIFT) + +#define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT) +#define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT) +#define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT) + +#define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \ + (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t)))) + +typedef struct dnode_phys { + grub_uint8_t dn_type; /* dmu_object_type_t */ + grub_uint8_t dn_indblkshift; /* ln2(indirect block size) */ + grub_uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */ + grub_uint8_t dn_nblkptr; /* length of dn_blkptr */ + grub_uint8_t dn_bonustype; /* type of data in bonus buffer */ + grub_uint8_t dn_checksum; /* ZIO_CHECKSUM type */ + grub_uint8_t dn_compress; /* ZIO_COMPRESS type */ + grub_uint8_t dn_flags; /* DNODE_FLAG_* */ + grub_uint16_t dn_datablkszsec; /* data block size in 512b sectors */ + grub_uint16_t dn_bonuslen; /* length of dn_bonus */ + grub_uint8_t dn_pad2[4]; + + /* accounting is protected by dn_dirty_mtx */ + grub_uint64_t dn_maxblkid; /* largest allocated block ID */ + grub_uint64_t dn_used; /* bytes (or sectors) of disk space */ + + grub_uint64_t dn_pad3[4]; + + blkptr_t dn_blkptr[1]; + grub_uint8_t dn_bonus[DN_MAX_BONUSLEN]; +} dnode_phys_t; + +#endif /* _SYS_DNODE_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/zap_leaf.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/zap_leaf.h @@ -0,0 +1,100 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZAP_LEAF_H +#define _SYS_ZAP_LEAF_H + +#define ZAP_LEAF_MAGIC 0x2AB1EAF + +/* chunk size = 24 bytes */ +#define ZAP_LEAF_CHUNKSIZE 24 + +/* + * The amount of space within the chunk available for the array is: + * chunk size - space for type (1) - space for next pointer (2) + */ +#define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3) + +typedef enum zap_chunk_type { + ZAP_CHUNK_FREE = 253, + ZAP_CHUNK_ENTRY = 252, + ZAP_CHUNK_ARRAY = 251, + ZAP_CHUNK_TYPE_MAX = 250 +} zap_chunk_type_t; + +/* + * TAKE NOTE: + * If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified. + */ +typedef struct zap_leaf_phys { + struct zap_leaf_header { + grub_uint64_t lh_block_type; /* ZBT_LEAF */ + grub_uint64_t lh_pad1; + grub_uint64_t lh_prefix; /* hash prefix of this leaf */ + grub_uint32_t lh_magic; /* ZAP_LEAF_MAGIC */ + grub_uint16_t lh_nfree; /* number free chunks */ + grub_uint16_t lh_nentries; /* number of entries */ + grub_uint16_t lh_prefix_len; /* num bits used to id this */ + +/* above is accessable to zap, below is zap_leaf private */ + + grub_uint16_t lh_freelist; /* chunk head of free list */ + grub_uint8_t lh_pad2[12]; + } l_hdr; /* 2 24-byte chunks */ + + /* + * The header is followed by a hash table with + * ZAP_LEAF_HASH_NUMENTRIES(zap) entries. The hash table is + * followed by an array of ZAP_LEAF_NUMCHUNKS(zap) + * zap_leaf_chunk structures. These structures are accessed + * with the ZAP_LEAF_CHUNK() macro. + */ + + grub_uint16_t l_hash[1]; +} zap_leaf_phys_t; + +typedef union zap_leaf_chunk { + struct zap_leaf_entry { + grub_uint8_t le_type; /* always ZAP_CHUNK_ENTRY */ + grub_uint8_t le_int_size; /* size of ints */ + grub_uint16_t le_next; /* next entry in hash chain */ + grub_uint16_t le_name_chunk; /* first chunk of the name */ + grub_uint16_t le_name_length; /* bytes in name, incl null */ + grub_uint16_t le_value_chunk; /* first chunk of the value */ + grub_uint16_t le_value_length; /* value length in ints */ + grub_uint32_t le_cd; /* collision differentiator */ + grub_uint64_t le_hash; /* hash value of the name */ + } l_entry; + struct zap_leaf_array { + grub_uint8_t la_type; /* always ZAP_CHUNK_ARRAY */ + grub_uint8_t la_array[ZAP_LEAF_ARRAY_BYTES]; + grub_uint16_t la_next; /* next blk or CHAIN_END */ + } l_array; + struct zap_leaf_free { + grub_uint8_t lf_type; /* always ZAP_CHUNK_FREE */ + grub_uint8_t lf_pad[ZAP_LEAF_ARRAY_BYTES]; + grub_uint16_t lf_next; /* next in free list, or CHAIN_END */ + } l_free; +} zap_leaf_chunk_t; + +#endif /* _SYS_ZAP_LEAF_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/zap_impl.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/zap_impl.h @@ -0,0 +1,110 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZAP_IMPL_H +#define _SYS_ZAP_IMPL_H + +#define ZAP_MAGIC 0x2F52AB2ABULL + +#define ZAP_HASHBITS 28 +#define MZAP_ENT_LEN 64 +#define MZAP_NAME_LEN (MZAP_ENT_LEN - 8 - 4 - 2) +#define MZAP_MAX_BLKSHIFT SPA_MAXBLOCKSHIFT +#define MZAP_MAX_BLKSZ (1 << MZAP_MAX_BLKSHIFT) + +typedef struct mzap_ent_phys { + grub_uint64_t mze_value; + grub_uint32_t mze_cd; + grub_uint16_t mze_pad; /* in case we want to chain them someday */ + char mze_name[MZAP_NAME_LEN]; +} mzap_ent_phys_t; + +typedef struct mzap_phys { + grub_uint64_t mz_block_type; /* ZBT_MICRO */ + grub_uint64_t mz_salt; + grub_uint64_t mz_pad[6]; + mzap_ent_phys_t mz_chunk[1]; + /* actually variable size depending on block size */ +} mzap_phys_t; + +/* + * The (fat) zap is stored in one object. It is an array of + * 1<= 6] [zap_leaf_t] [ptrtbl] ... + * + */ + +#define ZBT_LEAF ((1ULL << 63) + 0) +#define ZBT_HEADER ((1ULL << 63) + 1) +#define ZBT_MICRO ((1ULL << 63) + 3) +/* any other values are ptrtbl blocks */ + +/* + * the embedded pointer table takes up half a block: + * block size / entry size (2^3) / 2 + */ +#define ZAP_EMBEDDED_PTRTBL_SHIFT(zap) (FZAP_BLOCK_SHIFT(zap) - 3 - 1) + +/* + * The embedded pointer table starts half-way through the block. Since + * the pointer table itself is half the block, it starts at (64-bit) + * word number (1<zap_f.zap_phys) \ + [(idx) + (1< + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Use is subject to license terms. + */ + +#ifndef GRUB_ZFS_HEADER +#define GRUB_ZFS_HEADER 1 + +#include +#include + +/* + * On-disk version number. + */ +#define SPA_VERSION 14ULL + +/* + * The following are configuration names used in the nvlist describing a pool's + * configuration. + */ +#define ZPOOL_CONFIG_VERSION "version" +#define ZPOOL_CONFIG_POOL_NAME "name" +#define ZPOOL_CONFIG_POOL_STATE "state" +#define ZPOOL_CONFIG_POOL_TXG "txg" +#define ZPOOL_CONFIG_POOL_GUID "pool_guid" +#define ZPOOL_CONFIG_CREATE_TXG "create_txg" +#define ZPOOL_CONFIG_TOP_GUID "top_guid" +#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" +#define ZPOOL_CONFIG_TYPE "type" +#define ZPOOL_CONFIG_CHILDREN "children" +#define ZPOOL_CONFIG_ID "id" +#define ZPOOL_CONFIG_GUID "guid" +#define ZPOOL_CONFIG_PATH "path" +#define ZPOOL_CONFIG_DEVID "devid" +#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" +#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" +#define ZPOOL_CONFIG_ASHIFT "ashift" +#define ZPOOL_CONFIG_ASIZE "asize" +#define ZPOOL_CONFIG_DTL "DTL" +#define ZPOOL_CONFIG_STATS "stats" +#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" +#define ZPOOL_CONFIG_ERRCOUNT "error_count" +#define ZPOOL_CONFIG_NOT_PRESENT "not_present" +#define ZPOOL_CONFIG_SPARES "spares" +#define ZPOOL_CONFIG_IS_SPARE "is_spare" +#define ZPOOL_CONFIG_NPARITY "nparity" +#define ZPOOL_CONFIG_PHYS_PATH "phys_path" +#define ZPOOL_CONFIG_L2CACHE "l2cache" +/* + * The persistent vdev state is stored as separate values rather than a single + * 'vdev_state' entry. This is because a device can be in multiple states, such + * as offline and degraded. + */ +#define ZPOOL_CONFIG_OFFLINE "offline" +#define ZPOOL_CONFIG_FAULTED "faulted" +#define ZPOOL_CONFIG_DEGRADED "degraded" +#define ZPOOL_CONFIG_REMOVED "removed" + +#define VDEV_TYPE_ROOT "root" +#define VDEV_TYPE_MIRROR "mirror" +#define VDEV_TYPE_REPLACING "replacing" +#define VDEV_TYPE_RAIDZ "raidz" +#define VDEV_TYPE_DISK "disk" +#define VDEV_TYPE_FILE "file" +#define VDEV_TYPE_MISSING "missing" +#define VDEV_TYPE_SPARE "spare" +#define VDEV_TYPE_L2CACHE "l2cache" + +/* + * pool state. The following states are written to disk as part of the normal + * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining + * states are software abstractions used at various levels to communicate pool + * state. + */ +typedef enum pool_state { + POOL_STATE_ACTIVE = 0, /* In active use */ + POOL_STATE_EXPORTED, /* Explicitly exported */ + POOL_STATE_DESTROYED, /* Explicitly destroyed */ + POOL_STATE_SPARE, /* Reserved for hot spare use */ + POOL_STATE_L2CACHE, /* Level 2 ARC device */ + POOL_STATE_UNINITIALIZED, /* Internal spa_t state */ + POOL_STATE_UNAVAIL, /* Internal libzfs state */ + POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */ +} pool_state_t; + +struct grub_zfs_data; + +grub_err_t grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist); +grub_err_t grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename, + grub_uint64_t *mdnobj); + +char *grub_zfs_nvlist_lookup_string (char *nvlist, char *name); +char *grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name); +int grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name, + grub_uint64_t *out); +char *grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name, + grub_size_t index); +int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name); + +#endif /* ! GRUB_ZFS_HEADER */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/dsl_dataset.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/dsl_dataset.h @@ -0,0 +1,53 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DSL_DATASET_H +#define _SYS_DSL_DATASET_H + +typedef struct dsl_dataset_phys { + grub_uint64_t ds_dir_obj; + grub_uint64_t ds_prev_snap_obj; + grub_uint64_t ds_prev_snap_txg; + grub_uint64_t ds_next_snap_obj; + grub_uint64_t ds_snapnames_zapobj; /* zap obj of snaps; ==0 for snaps */ + grub_uint64_t ds_num_children; /* clone/snap children; ==0 for head */ + grub_uint64_t ds_creation_time; /* seconds since 1970 */ + grub_uint64_t ds_creation_txg; + grub_uint64_t ds_deadlist_obj; + grub_uint64_t ds_used_bytes; + grub_uint64_t ds_compressed_bytes; + grub_uint64_t ds_uncompressed_bytes; + grub_uint64_t ds_unique_bytes; /* only relevant to snapshots */ + /* + * The ds_fsid_guid is a 56-bit ID that can change to avoid + * collisions. The ds_guid is a 64-bit ID that will never + * change, so there is a small probability that it will collide. + */ + grub_uint64_t ds_fsid_guid; + grub_uint64_t ds_guid; + grub_uint64_t ds_flags; + blkptr_t ds_bp; + grub_uint64_t ds_pad[8]; /* pad out to 320 bytes for good measure */ +} dsl_dataset_phys_t; + +#endif /* _SYS_DSL_DATASET_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/dsl_dir.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/dsl_dir.h @@ -0,0 +1,49 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_DSL_DIR_H +#define _SYS_DSL_DIR_H + +typedef struct dsl_dir_phys { + grub_uint64_t dd_creation_time; /* not actually used */ + grub_uint64_t dd_head_dataset_obj; + grub_uint64_t dd_parent_obj; + grub_uint64_t dd_clone_parent_obj; + grub_uint64_t dd_child_dir_zapobj; + /* + * how much space our children are accounting for; for leaf + * datasets, == physical space used by fs + snaps + */ + grub_uint64_t dd_used_bytes; + grub_uint64_t dd_compressed_bytes; + grub_uint64_t dd_uncompressed_bytes; + /* Administrative quota setting */ + grub_uint64_t dd_quota; + /* Administrative reservation setting */ + grub_uint64_t dd_reserved; + grub_uint64_t dd_props_zapobj; + grub_uint64_t dd_deleg_zapobj; /* dataset permissions */ + grub_uint64_t dd_pad[20]; /* pad out to 256 bytes for good measure */ +} dsl_dir_phys_t; + +#endif /* _SYS_DSL_DIR_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/zfs_znode.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/zfs_znode.h @@ -0,0 +1,70 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_FS_ZFS_ZNODE_H +#define _SYS_FS_ZFS_ZNODE_H + +#include + +#define MASTER_NODE_OBJ 1 +#define ZFS_ROOT_OBJ "ROOT" +#define ZPL_VERSION_STR "VERSION" + +#define ZPL_VERSION 3ULL + +#define ZFS_DIRENT_OBJ(de) BF64_GET(de, 0, 48) + +/* + * This is the persistent portion of the znode. It is stored + * in the "bonus buffer" of the file. Short symbolic links + * are also stored in the bonus buffer. + */ +typedef struct znode_phys { + grub_uint64_t zp_atime[2]; /* 0 - last file access time */ + grub_uint64_t zp_mtime[2]; /* 16 - last file modification time */ + grub_uint64_t zp_ctime[2]; /* 32 - last file change time */ + grub_uint64_t zp_crtime[2]; /* 48 - creation time */ + grub_uint64_t zp_gen; /* 64 - generation (txg of creation) */ + grub_uint64_t zp_mode; /* 72 - file mode bits */ + grub_uint64_t zp_size; /* 80 - size of file */ + grub_uint64_t zp_parent; /* 88 - directory parent (`..') */ + grub_uint64_t zp_links; /* 96 - number of links to file */ + grub_uint64_t zp_xattr; /* 104 - DMU object for xattrs */ + grub_uint64_t zp_rdev; /* 112 - dev_t for VBLK & VCHR files */ + grub_uint64_t zp_flags; /* 120 - persistent flags */ + grub_uint64_t zp_uid; /* 128 - file owner */ + grub_uint64_t zp_gid; /* 136 - owning group */ + grub_uint64_t zp_pad[4]; /* 144 - future */ + zfs_znode_acl_t zp_acl; /* 176 - 263 ACL */ + /* + * Data may pad out any remaining bytes in the znode buffer, eg: + * + * |<---------------------- dnode_phys (512) ------------------------>| + * |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->| + * |<---- znode (264) ---->|<---- data (56) ---->| + * + * At present, we only use this space to store symbolic links. + */ +} znode_phys_t; + +#endif /* _SYS_FS_ZFS_ZNODE_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/spa.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/spa.h @@ -0,0 +1,281 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * Copyright 2007 Sun Microsystems, Inc. + * Copyright (C) 2009 Vladimir Serbinenko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef GRUB_ZFS_SPA_HEADER +#define GRUB_ZFS_SPA_HEADER 1 + +typedef enum grub_zfs_endian + { + UNKNOWN_ENDIAN = -2, + LITTLE_ENDIAN = -1, + BIG_ENDIAN = 0 + } grub_zfs_endian_t; + +#define grub_zfs_to_cpu16(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu16(x) \ + : grub_le_to_cpu16(x)) +#define grub_cpu_to_zfs16(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be16(x) \ + : grub_cpu_to_le16(x)) + +#define grub_zfs_to_cpu32(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu32(x) \ + : grub_le_to_cpu32(x)) +#define grub_cpu_to_zfs32(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be32(x) \ + : grub_cpu_to_le32(x)) + +#define grub_zfs_to_cpu64(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu64(x) \ + : grub_le_to_cpu64(x)) +#define grub_cpu_to_zfs64(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be64(x) \ + : grub_cpu_to_le64(x)) + +/* + * General-purpose 32-bit and 64-bit bitfield encodings. + */ +#define BF32_DECODE(x, low, len) P2PHASE((x) >> (low), 1U << (len)) +#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len)) +#define BF32_ENCODE(x, low, len) (P2PHASE((x), 1U << (len)) << (low)) +#define BF64_ENCODE(x, low, len) (P2PHASE((x), 1ULL << (len)) << (low)) + +#define BF32_GET(x, low, len) BF32_DECODE(x, low, len) +#define BF64_GET(x, low, len) BF64_DECODE(x, low, len) + +#define BF32_SET(x, low, len, val) \ + ((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len)) +#define BF64_SET(x, low, len, val) \ + ((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len)) + +#define BF32_GET_SB(x, low, len, shift, bias) \ + ((BF32_GET(x, low, len) + (bias)) << (shift)) +#define BF64_GET_SB(x, low, len, shift, bias) \ + ((BF64_GET(x, low, len) + (bias)) << (shift)) + +#define BF32_SET_SB(x, low, len, shift, bias, val) \ + BF32_SET(x, low, len, ((val) >> (shift)) - (bias)) +#define BF64_SET_SB(x, low, len, shift, bias, val) \ + BF64_SET(x, low, len, ((val) >> (shift)) - (bias)) + +/* + * We currently support nine block sizes, from 512 bytes to 128K. + * We could go higher, but the benefits are near-zero and the cost + * of COWing a giant block to modify one byte would become excessive. + */ +#define SPA_MINBLOCKSHIFT 9 +#define SPA_MAXBLOCKSHIFT 17 +#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) +#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) + +#define SPA_BLOCKSIZES (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1) + +/* + * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB. + * The ASIZE encoding should be at least 64 times larger (6 more bits) + * to support up to 4-way RAID-Z mirror mode with worst-case gang block + * overhead, three DVAs per bp, plus one more bit in case we do anything + * else that expands the ASIZE. + */ +#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */ +#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */ +#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */ + +/* + * All SPA data is represented by 128-bit data virtual addresses (DVAs). + * The members of the dva_t should be considered opaque outside the SPA. + */ +typedef struct dva { + grub_uint64_t dva_word[2]; +} dva_t; + +/* + * Each block has a 256-bit checksum -- strong enough for cryptographic hashes. + */ +typedef struct zio_cksum { + grub_uint64_t zc_word[4]; +} zio_cksum_t; + +/* + * Each block is described by its DVAs, time of birth, checksum, etc. + * The word-by-word, bit-by-bit layout of the blkptr is as follows: + * + * 64 56 48 40 32 24 16 8 0 + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 0 | vdev1 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 1 |G| offset1 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 2 | vdev2 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 3 |G| offset2 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 4 | vdev3 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 5 |G| offset3 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 6 |E| lvl | type | cksum | comp | PSIZE | LSIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 7 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 8 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 9 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * a | birth txg | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * b | fill count | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * c | checksum[0] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * d | checksum[1] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * e | checksum[2] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * f | checksum[3] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * + * Legend: + * + * vdev virtual device ID + * offset offset into virtual device + * LSIZE logical size + * PSIZE physical size (after compression) + * ASIZE allocated size (including RAID-Z parity and gang block headers) + * GRID RAID-Z layout information (reserved for future use) + * cksum checksum function + * comp compression function + * G gang block indicator + * E endianness + * type DMU object type + * lvl level of indirection + * birth txg transaction group in which the block was born + * fill count number of non-zero blocks under this bp + * checksum[4] 256-bit checksum of the data this bp describes + */ +typedef struct blkptr { + dva_t blk_dva[3]; /* 128-bit Data Virtual Address */ + grub_uint64_t blk_prop; /* size, compression, type, etc */ + grub_uint64_t blk_pad[3]; /* Extra space for the future */ + grub_uint64_t blk_birth; /* transaction group at birth */ + grub_uint64_t blk_fill; /* fill count */ + zio_cksum_t blk_cksum; /* 256-bit checksum */ +} blkptr_t; + +#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */ +#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */ + +/* + * Macros to get and set fields in a bp or DVA. + */ +#define DVA_GET_ASIZE(dva) \ + BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0) +#define DVA_SET_ASIZE(dva, x) \ + BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x) + +#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8) +#define DVA_SET_GRID(dva, x) BF64_SET((dva)->dva_word[0], 24, 8, x) + +#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32) +#define DVA_SET_VDEV(dva, x) BF64_SET((dva)->dva_word[0], 32, 32, x) + +#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1) +#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x) + +#define BP_GET_LSIZE(bp) \ + (BP_IS_HOLE(bp) ? 0 : \ + BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)) +#define BP_SET_LSIZE(bp, x) \ + BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x) + +#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8) +#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x) + +#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8) +#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x) + +#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8) +#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x) + +#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5) +#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x) + +#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1)) +#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x) + +#define BP_GET_ASIZE(bp) \ + (DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ + DVA_GET_ASIZE(&(bp)->blk_dva[2])) + +#define BP_GET_UCSIZE(bp) \ + ((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \ + BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp)); + +#define BP_GET_NDVAS(bp) \ + (!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \ + !!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ + !!DVA_GET_ASIZE(&(bp)->blk_dva[2])) + +#define BP_COUNT_GANG(bp) \ + (DVA_GET_GANG(&(bp)->blk_dva[0]) + \ + DVA_GET_GANG(&(bp)->blk_dva[1]) + \ + DVA_GET_GANG(&(bp)->blk_dva[2])) + +#define DVA_EQUAL(dva1, dva2) \ + ((dva1)->dva_word[1] == (dva2)->dva_word[1] && \ + (dva1)->dva_word[0] == (dva2)->dva_word[0]) + +#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \ + (0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \ + ((zc1).zc_word[1] - (zc2).zc_word[1]) | \ + ((zc1).zc_word[2] - (zc2).zc_word[2]) | \ + ((zc1).zc_word[3] - (zc2).zc_word[3]))) + + +#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0) + +#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \ +{ \ + (zcp)->zc_word[0] = w0; \ + (zcp)->zc_word[1] = w1; \ + (zcp)->zc_word[2] = w2; \ + (zcp)->zc_word[3] = w3; \ +} + +#define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) +#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) +#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0) +#define BP_IS_OLDER(bp, txg) (!BP_IS_HOLE(bp) && (bp)->blk_birth < (txg)) + +#define BP_ZERO(bp) \ +{ \ + (bp)->blk_dva[0].dva_word[0] = 0; \ + (bp)->blk_dva[0].dva_word[1] = 0; \ + (bp)->blk_dva[1].dva_word[0] = 0; \ + (bp)->blk_dva[1].dva_word[1] = 0; \ + (bp)->blk_dva[2].dva_word[0] = 0; \ + (bp)->blk_dva[2].dva_word[1] = 0; \ + (bp)->blk_prop = 0; \ + (bp)->blk_pad[0] = 0; \ + (bp)->blk_pad[1] = 0; \ + (bp)->blk_pad[2] = 0; \ + (bp)->blk_birth = 0; \ + (bp)->blk_fill = 0; \ + ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \ +} + +#define BP_SPRINTF_LEN 320 + +#endif /* ! GRUB_ZFS_SPA_HEADER */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/zil.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/zil.h @@ -0,0 +1,51 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZIL_H +#define _SYS_ZIL_H + +/* + * Intent log format: + * + * Each objset has its own intent log. The log header (zil_header_t) + * for objset N's intent log is kept in the Nth object of the SPA's + * intent_log objset. The log header points to a chain of log blocks, + * each of which contains log records (i.e., transactions) followed by + * a log block trailer (zil_trailer_t). The format of a log record + * depends on the record (or transaction) type, but all records begin + * with a common structure that defines the type, length, and txg. + */ + +/* + * Intent log header - this on disk structure holds fields to manage + * the log. All fields are 64 bit to easily handle cross architectures. + */ +typedef struct zil_header { + grub_uint64_t zh_claim_txg; /* txg in which log blocks were claimed */ + grub_uint64_t zh_replay_seq; /* highest replayed sequence number */ + blkptr_t zh_log; /* log chain */ + grub_uint64_t zh_claim_seq; /* highest claimed sequence number */ + grub_uint64_t zh_pad[5]; +} zil_header_t; + +#endif /* _SYS_ZIL_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/zio.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/zio.h @@ -0,0 +1,83 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ZIO_H +#define _ZIO_H + +#include + +#define ZBT_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */ + +typedef struct zio_block_tail { + grub_uint64_t zbt_magic; /* for validation, endianness */ + zio_cksum_t zbt_cksum; /* 256-bit checksum */ +} zio_block_tail_t; + +/* + * Gang block headers are self-checksumming and contain an array + * of block pointers. + */ +#define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE +#define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \ + sizeof (zio_block_tail_t)) / sizeof (blkptr_t)) +#define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \ + sizeof (zio_block_tail_t) - \ + (SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\ + sizeof (grub_uint64_t)) + +#define ZIO_GET_IOSIZE(zio) \ + (BP_IS_GANG((zio)->io_bp) ? \ + SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp)) + +typedef struct zio_gbh { + blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS]; + grub_uint64_t zg_filler[SPA_GBH_FILLER]; + zio_block_tail_t zg_tail; +} zio_gbh_phys_t; + +enum zio_checksum { + ZIO_CHECKSUM_INHERIT = 0, + ZIO_CHECKSUM_ON, + ZIO_CHECKSUM_OFF, + ZIO_CHECKSUM_LABEL, + ZIO_CHECKSUM_GANG_HEADER, + ZIO_CHECKSUM_ZILOG, + ZIO_CHECKSUM_FLETCHER_2, + ZIO_CHECKSUM_FLETCHER_4, + ZIO_CHECKSUM_SHA256, + ZIO_CHECKSUM_FUNCTIONS +}; + +#define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2 +#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON + +enum zio_compress { + ZIO_COMPRESS_INHERIT = 0, + ZIO_COMPRESS_ON, + ZIO_COMPRESS_OFF, + ZIO_COMPRESS_LZJB, + ZIO_COMPRESS_EMPTY, + ZIO_COMPRESS_FUNCTIONS +}; + +#endif /* _ZIO_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/zio_checksum.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/zio_checksum.h @@ -0,0 +1,50 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_ZIO_CHECKSUM_H +#define _SYS_ZIO_CHECKSUM_H + +/* + * Signature for checksum functions. + */ +typedef void zio_checksum_t(const void *data, grub_uint64_t size, + grub_zfs_endian_t endian, zio_cksum_t *zcp); + +/* + * Information about each checksum function. + */ +typedef struct zio_checksum_info { + zio_checksum_t *ci_func; /* checksum function for each byteorder */ + int ci_correctable; /* number of correctable bits */ + int ci_zbt; /* uses zio block tail? */ + char *ci_name; /* descriptive name */ +} zio_checksum_info_t; + +extern void zio_checksum_SHA256 (const void *, grub_uint64_t, + grub_zfs_endian_t endian, zio_cksum_t *); +extern void fletcher_2 (const void *, grub_uint64_t, grub_zfs_endian_t endian, + zio_cksum_t *); +extern void fletcher_4 (const void *, grub_uint64_t, grub_zfs_endian_t endian, + zio_cksum_t *); + +#endif /* _SYS_ZIO_CHECKSUM_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/include/grub/zfs/uberblock_impl.h +++ grub2-1.97~beta4/debian/grub-extras/include/grub/zfs/uberblock_impl.h @@ -0,0 +1,61 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_UBERBLOCK_IMPL_H +#define _SYS_UBERBLOCK_IMPL_H + +/* + * The uberblock version is incremented whenever an incompatible on-disk + * format change is made to the SPA, DMU, or ZAP. + * + * Note: the first two fields should never be moved. When a storage pool + * is opened, the uberblock must be read off the disk before the version + * can be checked. If the ub_version field is moved, we may not detect + * version mismatch. If the ub_magic field is moved, applications that + * expect the magic number in the first word won't work. + */ +#define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */ +#define UBERBLOCK_SHIFT 10 /* up to 1K */ + +typedef struct uberblock { + grub_uint64_t ub_magic; /* UBERBLOCK_MAGIC */ + grub_uint64_t ub_version; /* ZFS_VERSION */ + grub_uint64_t ub_txg; /* txg of last sync */ + grub_uint64_t ub_guid_sum; /* sum of all vdev guids */ + grub_uint64_t ub_timestamp; /* UTC time of last sync */ + blkptr_t ub_rootbp; /* MOS objset_phys_t */ +} uberblock_t; + +#define UBERBLOCK_SIZE (1ULL << UBERBLOCK_SHIFT) +#define VDEV_UBERBLOCK_SHIFT UBERBLOCK_SHIFT + +/* XXX Uberblock_phys_t is no longer in the kernel zfs */ +typedef struct uberblock_phys { + uberblock_t ubp_uberblock; + char ubp_pad[UBERBLOCK_SIZE - sizeof (uberblock_t) - + sizeof (zio_block_tail_t)]; + zio_block_tail_t ubp_zbt; +} uberblock_phys_t; + + +#endif /* _SYS_UBERBLOCK_IMPL_H */ --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/llimits.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/llimits.h @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + +#if 0 +#include +#include +#endif + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (int)(INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lfunc.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lfunc.c @@ -0,0 +1,174 @@ +/* +** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->c.isC = 1; + c->c.env = e; + c->c.nupvalues = cast_byte(nelems); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = e; + c->l.nupvalues = cast_byte(nelems); + while (nelems--) c->l.upvals[nelems] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = luaM_new(L, UpVal); + luaC_link(L, obj2gco(uv), LUA_TUPVAL); + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, obj2gco(p))) /* is it dead? */ + changewhite(obj2gco(p)); /* ressurect it */ + return p; + } + pp = &p->next; + } + uv = luaM_new(L, UpVal); /* not found: create a new one */ + uv->tt = LUA_TUPVAL; + uv->marked = luaC_white(g); + uv->v = level; /* current value lives in the stack */ + uv->next = *pp; /* chain it in the proper position */ + *pp = obj2gco(uv); + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); + setobj(L, &uv->u.value, uv->v); + uv->v = &uv->u.value; /* now current value lives here */ + luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = luaM_new(L, Proto); + luaC_link(L, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode, Instruction); + luaM_freearray(L, f->p, f->sizep, Proto *); + luaM_freearray(L, f->k, f->sizek, TValue); + luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); + luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); + luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_free(L, f); +} + + +void luaF_freeclosure (lua_State *L, Closure *c) { + int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : + sizeLclosure(c->l.nupvalues); + luaM_freemem(L, c, size); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lparser.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lparser.c @@ -0,0 +1,1340 @@ +/* +** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + +#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) + +#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int breaklist; /* list of jumps out of this loop */ + lu_byte nactvar; /* # active locals outside the breakable structure */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isbreakable; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void chunk (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +static void error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +} + + +static void errorlimit (FuncState *fs, int limit, const char *what) { + const char *msg = (fs->f->linedefined == 0) ? + luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : + luaO_pushfstring(fs->L, "function at line %d has more than %d %s", + fs->f->linedefined, limit, what); + luaX_lexerror(fs->ls, msg, 0); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + LUA_QS " expected (to close " LUA_QS " at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.s.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname(LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "too many local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +#define new_localvarliteral(ls,v,n) \ + new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) + + +static void new_localvar (LexState *ls, TString *name, int n) { + FuncState *fs = ls->fs; + luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); + fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + } +} + + +static void removevars (LexState *ls, int tolevel) { + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar).endpc = fs->pc; +} + + +static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { + int i; + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + for (i=0; inups; i++) { + if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { + lua_assert(f->upvalues[i] == name); + return i; + } + } + /* new one */ + luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); + luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, + TString *, MAX_INT, ""); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; + f->upvalues[f->nups] = name; + luaC_objbarrier(fs->L, f, name); + lua_assert(v->k == VLOCAL || v->k == VUPVAL); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); + return f->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (n == getlocvar(fs, i).varname) + return i; + } + return -1; /* not found */ +} + + +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl && bl->nactvar > level) bl = bl->previous; + if (bl) bl->upval = 1; +} + + +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) { /* no more levels? */ + init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ + return VGLOBAL; + } + else { + int v = searchvar(fs, n); /* look up at current level */ + if (v >= 0) { + init_exp(var, VLOCAL, v); + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found at current level; try upper one */ + if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) + return VGLOBAL; + var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ + var->k = VUPVAL; /* upvalue in this level */ + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VGLOBAL) + var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { + bl->breaklist = NO_JUMP; + bl->isbreakable = isbreakable; + bl->nactvar = fs->nactvar; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + fs->bl = bl->previous; + removevars(fs->ls, bl->nactvar); + if (bl->upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + /* a block either controls scope or breaks (never both) */ + lua_assert(!bl->isbreakable || !bl->upval); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + luaK_patchtohere(fs, bl->breaklist); +} + + +static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizep; + int i; + luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + f->p[fs->np++] = func->f; + luaC_objbarrier(ls->L, f, func->f); + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + for (i=0; if->nups; i++) { + OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); + } +} + + +static void open_func (LexState *ls, FuncState *fs) { + lua_State *L = ls->L; + Proto *f = luaF_newproto(L); + fs->f = f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + fs->L = L; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = -1; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->bl = NULL; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L, 0, 0); + /* anchor table of constants and prototype (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + setptvalue2s(L, L->top, f); + incr_top(L); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + removevars(ls, 0); + luaK_ret(fs, 0, 0); /* final return */ + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); + f->sizeupvalues = f->nups; + lua_assert(luaG_checkcode(f)); + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + L->top -= 2; /* remove table and prototype from the stack */ + /* last token read was anchored in defunct function; must reanchor it */ + if (fs) anchor_token(ls); +} + + +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + struct LexState lexstate; + struct FuncState funcstate; + lexstate.buff = buff; + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); + open_func(&lexstate, &funcstate); + funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ + luaX_next(&lexstate); /* read first token */ + chunk(&lexstate); + check(&lexstate, TK_EOS); + close_func(&lexstate); + lua_assert(funcstate.prev == NULL); + lua_assert(funcstate.f->nups == 0); + lua_assert(lexstate.fs == NULL); + return funcstate.f; +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +static void field (LexState *ls, expdesc *v) { + /* field -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyreg(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + expr(ls, &cc->v); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> ?? */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + switch(ls->t.token) { + case TK_NAME: { /* may be listfields or recfields */ + luaX_lookahead(ls); + if (ls->lookahead.token != '=') /* expression? */ + listfield(ls, &cc); + else + recfield(ls, &cc); + break; + } + case '[': { /* constructor_item -> recfield */ + recfield(ls, &cc); + break; + } + default: { /* constructor_part -> listfield */ + listfield(ls, &cc); + break; + } + } + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls), nparams++); + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); +#if defined(LUA_COMPAT_VARARG) + /* use `arg' as default name */ + new_localvarliteral(ls, "arg", nparams++); + f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; +#endif + f->is_vararg |= VARARG_ISVARARG; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int needself, int line) { + /* body -> `(' parlist `)' chunk END */ + FuncState new_fs; + open_func(ls, &new_fs); + new_fs.f->linedefined = line; + checknext(ls, '('); + if (needself) { + new_localvarliteral(ls, "self", 0); + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + chunk(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + close_func(ls); + pushclosure(ls, &new_fs, e); +} + + +static int explist1 (LexState *ls, expdesc *v) { + /* explist1 -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + int line = ls->linenumber; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist1 ] `)' */ + if (line != ls->lastline) + luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist1(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + return; + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.s.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void prefixexp (LexState *ls, expdesc *v) { + /* prefixexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + return; + } + } +} + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> + prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + prefixexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* field */ + field(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyreg(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | + constructor | FUNCTION body | primaryexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + primaryexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ + {10, 9}, {5, 4}, /* power and concat (right associative) */ + {3, 3}, {3, 3}, /* equality and inequality */ + {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ + {2, 2}, {1, 1} /* logical (and/or) */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static int block_follow (int token) { + switch (token) { + case TK_ELSE: case TK_ELSEIF: case TK_END: + case TK_UNTIL: case TK_EOS: + return 1; + default: return 0; + } +} + + +static void block (LexState *ls) { + /* block -> chunk */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + chunk(ls); + lua_assert(bl.breaklist == NO_JUMP); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to a local variable, the local variable +** is needed in a previous assignment (to a table). If so, save original +** local value in a safe place and use this safe copy in the previous +** assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + } + if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, + "syntax error"); + if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + primaryexp(ls, &nv.v); + if (nv.v.k == VLOCAL) + check_conflict(ls, lh, &nv.v); + luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, + "variables in assignment"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist1 */ + int nexps; + checknext(ls, '='); + nexps = explist1(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void breakstat (LexState *ls) { + FuncState *fs = ls->fs; + BlockCnt *bl = fs->bl; + int upval = 0; + while (bl && !bl->isbreakable) { + upval |= bl->upval; + bl = bl->previous; + } + if (!bl) + luaX_syntaxerror(ls, "no loop to break"); + if (upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_patchlist(fs, luaK_jump(fs), whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + chunk(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (!bl2.upval) { /* no upvalues? */ + leaveblock(fs); /* finish scope */ + luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ + } + else { /* complete semantics when there are upvalues */ + breakstat(ls); /* if condition then break */ + luaK_patchtohere(ls->fs, condexit); /* else... */ + leaveblock(fs); /* finish scope... */ + luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ + } + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int k; + expr(ls, &e); + k = e.k; + luaK_exp2nextreg(ls->fs, &e); + return k; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : + luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); + luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ + luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)", 0); + new_localvarliteral(ls, "(for limit)", 1); + new_localvarliteral(ls, "(for step)", 2); + new_localvar(ls, varname, 3); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist1 forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 0; + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)", nvars++); + new_localvarliteral(ls, "(for state)", nvars++); + new_localvarliteral(ls, "(for control)", nvars++); + /* create declared variables */ + new_localvar(ls, indexname, nvars++); + while (testnext(ls, ',')) + new_localvar(ls, str_checkname(ls), nvars++); + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist1(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static int test_then_block (LexState *ls) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + int condexit; + luaX_next(ls); /* skip IF or ELSEIF */ + condexit = cond(ls); + checknext(ls, TK_THEN); + block(ls); /* `then' part */ + return condexit; +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int flist; + int escapelist = NO_JUMP; + flist = test_then_block(ls); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + flist = test_then_block(ls); /* ELSEIF cond THEN block */ + } + if (ls->t.token == TK_ELSE) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + block(ls); /* `else' part */ + } + else + luaK_concat(fs, &escapelist, flist); + luaK_patchtohere(fs, escapelist); + check_match(ls, TK_END, TK_IF, line); +} + + +static void localfunc (LexState *ls) { + expdesc v, b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls), 0); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); + adjustlocalvars(ls, 1); + body(ls, &b, 0, ls->linenumber); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls), nvars++); + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist1(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {field} [`:' NAME] */ + int needself = 0; + singlevar(ls, v); + while (ls->t.token == '.') + field(ls, v); + if (ls->t.token == ':') { + needself = 1; + field(ls, v); + } + return needself; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int needself; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + needself = funcname(ls, &v); + body(ls, &b, needself, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + primaryexp(ls, &v.v); + if (v.v.k == VCALL) /* stat -> func */ + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + else { /* stat -> assignment */ + v.prev = NULL; + assignment(ls, &v, 1); + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN explist */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + luaX_next(ls); /* skip RETURN */ + if (block_follow(ls->t.token) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist1(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); +} + + +static int statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + switch (ls->t.token) { + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + return 0; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + return 0; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + return 0; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + return 0; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + return 0; + } + case TK_FUNCTION: { + funcstat(ls, line); /* stat -> funcstat */ + return 0; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + return 0; + } + case TK_RETURN: { /* stat -> retstat */ + retstat(ls); + return 1; /* must be last statement */ + } + case TK_BREAK: { /* stat -> breakstat */ + luaX_next(ls); /* skip BREAK */ + breakstat(ls); + return 1; /* must be last statement */ + } + default: { + exprstat(ls); + return 0; /* to avoid warnings */ + } + } +} + + +static void chunk (LexState *ls) { + /* chunk -> { stat [`;'] } */ + int islast = 0; + enterlevel(ls); + while (!islast && !block_follow(ls->t.token)) { + islast = statement(ls); + testnext(ls, ';'); + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + } + leavelevel(ls); +} + +/* }====================================================================== */ --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ltm.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ltm.h @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lvm.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lvm.c @@ -0,0 +1,764 @@ +/* +** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#endif + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + lua_number2str(s, n); + setsvalue2s(L, obj, luaS_new(L, s)); + return 1; + } +} + + +static void traceexec (lua_State *L, const Instruction *pc) { + lu_byte mask = L->hookmask; + const Instruction *oldpc = L->savedpc; + L->savedpc = pc; + if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { + resethookcount(L); + luaD_callhook(L, LUA_HOOKCOUNT, -1); + } + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(L->ci)->l.p; + int npc = pcRel(pc, p); + int newline = getline(p, npc); + /* call linehook when enter a new function, when jump back (loop), + or when enter a new line */ + if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) + luaD_callhook(L, LUA_HOOKLINE, newline); + } +} + + +static void callTMres (lua_State *L, StkId res, const TValue *f, + const TValue *p1, const TValue *p2) { + ptrdiff_t result = savestack(L, res); + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + luaD_checkstack(L, 3); + L->top += 3; + luaD_call(L, L->top - 3, 1); + res = restorestack(L, result); + L->top--; + setobjs2s(L, res, L->top); +} + + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, const TValue *p3) { + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + setobj2s(L, L->top+3, p3); /* 3th argument */ + luaD_checkstack(L, 4); + L->top += 4; + luaD_call(L, L->top - 4, 0); +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + if (!ttisnil(oldval) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ + setobj2t(L, oldval, val); + luaC_barriert(L, h, val); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTMres(L, res, tm, p1, p2); + return 1; +} + + +static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + const TValue *tm1 = luaT_gettmbyobj(L, p1, event); + const TValue *tm2; + if (ttisnil(tm1)) return -1; /* no metamethod? */ + tm2 = luaT_gettmbyobj(L, p2, event); + if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ + return -1; + callTMres(L, L->top, tm1, p1, p2); + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numlt(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + return luaG_ordererror(L, l, r); +} + + +static int lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numle(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ + return !res; + return luaG_ordererror(L, l, r); +} + + +int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttype(t1) == ttype(t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, + TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTMres(L, L->top, tm, t1, t2); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total, int last) { + do { + StkId top = L->base + last + 1; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { + /* at least two string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (n = 1; n < total && tostring(L, top-n-1); n++) { + size_t l = tsvalue(top-n-1)->len; + if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + for (i=n; i>0; i--) { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l); + tl += l; + } + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got `n' strings to create 1 new */ + last -= n-1; + } while (total > 1); /* repeat until only 1 result left */ +} + + +static void Arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number nb = nvalue(b), nc = nvalue(c); + switch (op) { + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; + default: lua_assert(0); break; + } + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#define runtime_check(L, c) { if (!(c)) break; } + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) + + +#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} + + +#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(nb, nc)); \ + } \ + else \ + Protect(Arith(L, ra, rb, rc, tm)); \ + } + + + +void luaV_execute (lua_State *L, int nexeccalls) { + LClosure *cl; + StkId base; + TValue *k; + const Instruction *pc; + reentry: /* entry point */ + lua_assert(isLua(L->ci)); + pc = L->savedpc; + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; + /* main loop of interpreter */ + for (;;) { + const Instruction i = *pc++; + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + traceexec(L, pc); + if (L->status == LUA_YIELD) { /* did hook yield? */ + L->savedpc = pc - 1; + return; + } + base = L->base; + } + /* warning!! several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == L->base && L->base == L->ci->base); + lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); + lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); + switch (GET_OPCODE(i)) { + case OP_MOVE: { + setobjs2s(L, ra, RB(i)); + continue; + } + case OP_LOADK: { + setobj2s(L, ra, KBx(i)); + continue; + } + case OP_LOADBOOL: { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ + continue; + } + case OP_LOADNIL: { + TValue *rb = RB(i); + do { + setnilvalue(rb--); + } while (rb >= ra); + continue; + } + case OP_GETUPVAL: { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + continue; + } + case OP_GETGLOBAL: { + TValue g; + TValue *rb = KBx(i); + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(rb)); + Protect(luaV_gettable(L, &g, rb, ra)); + continue; + } + case OP_GETTABLE: { + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + continue; + } + case OP_SETGLOBAL: { + TValue g; + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(KBx(i))); + Protect(luaV_settable(L, &g, KBx(i), ra)); + continue; + } + case OP_SETUPVAL: { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + continue; + } + case OP_SETTABLE: { + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + continue; + } + case OP_NEWTABLE: { + int b = GETARG_B(i); + int c = GETARG_C(i); + sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); + Protect(luaC_checkGC(L)); + continue; + } + case OP_SELF: { + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + continue; + } + case OP_ADD: { + arith_op(luai_numadd, TM_ADD); + continue; + } + case OP_SUB: { + arith_op(luai_numsub, TM_SUB); + continue; + } + case OP_MUL: { + arith_op(luai_nummul, TM_MUL); + continue; + } + case OP_DIV: { + arith_op(luai_numdiv, TM_DIV); + continue; + } + case OP_MOD: { + arith_op(luai_nummod, TM_MOD); + continue; + } + case OP_POW: { + arith_op(luai_numpow, TM_POW); + continue; + } + case OP_UNM: { + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(nb)); + } + else { + Protect(Arith(L, ra, rb, rb, TM_UNM)); + } + continue; + } + case OP_NOT: { + int res = l_isfalse(RB(i)); /* next assignment may change this value */ + setbvalue(ra, res); + continue; + } + case OP_LEN: { + const TValue *rb = RB(i); + switch (ttype(rb)) { + case LUA_TTABLE: { + setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); + break; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + break; + } + default: { /* try metamethod */ + Protect( + if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + luaG_typeerror(L, rb, "get length of"); + ) + } + } + continue; + } + case OP_CONCAT: { + int b = GETARG_B(i); + int c = GETARG_C(i); + Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); + setobjs2s(L, RA(i), base+b); + continue; + } + case OP_JMP: { + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_EQ: { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (equalobj(L, rb, rc) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LT: { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LE: { + Protect( + if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_TEST: { + if (l_isfalse(ra) != GETARG_C(i)) + dojump(L, pc, GETARG_sBx(*pc)); + pc++; + continue; + } + case OP_TESTSET: { + TValue *rb = RB(i); + if (l_isfalse(rb) != GETARG_C(i)) { + setobjs2s(L, ra, rb); + dojump(L, pc, GETARG_sBx(*pc)); + } + pc++; + continue; + } + case OP_CALL: { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + switch (luaD_precall(L, ra, nresults)) { + case PCRLUA: { + nexeccalls++; + goto reentry; /* restart luaV_execute over new Lua function */ + } + case PCRC: { + /* it was a C function (`precall' called it); adjust results */ + if (nresults >= 0) L->top = L->ci->top; + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_TAILCALL: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + switch (luaD_precall(L, ra, LUA_MULTRET)) { + case PCRLUA: { + /* tail call: put new frame in place of previous one */ + CallInfo *ci = L->ci - 1; /* previous frame */ + int aux; + StkId func = ci->func; + StkId pfunc = (ci+1)->func; /* previous function index */ + if (L->openupval) luaF_close(L, ci->base); + L->base = ci->base = ci->func + ((ci+1)->base - pfunc); + for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ + setobjs2s(L, func+aux, pfunc+aux); + ci->top = L->top = func+aux; /* correct top */ + lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); + ci->savedpc = L->savedpc; + ci->tailcalls++; /* one more call lost */ + L->ci--; /* remove new frame */ + goto reentry; + } + case PCRC: { /* it was a C function (`precall' called it) */ + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_RETURN: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (L->openupval) luaF_close(L, base); + L->savedpc = pc; + b = luaD_poscall(L, ra); + if (--nexeccalls == 0) /* was previous function running `here'? */ + return; /* no: return */ + else { /* yes: continue its execution */ + if (b) L->top = L->ci->top; + lua_assert(isLua(L->ci)); + lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); + goto reentry; + } + } + case OP_FORLOOP: { + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + dojump(L, pc, GETARG_sBx(i)); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + continue; + } + case OP_FORPREP: { + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + L->savedpc = pc; /* next steps may throw errors */ + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_TFORLOOP: { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb+3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = L->ci->top; + cb = RA(i) + 3; /* previous call may change the stack */ + if (!ttisnil(cb)) { /* continue loop? */ + setobjs2s(L, cb-1, cb); /* save control variable */ + dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + } + pc++; + continue; + } + case OP_SETLIST: { + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) { + n = cast_int(L->top - ra) - 1; + L->top = L->ci->top; + } + if (c == 0) c = cast_int(*pc++); + runtime_check(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-alloc it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + setobj2t(L, luaH_setnum(L, h, last--), val); + luaC_barriert(L, h, val); + } + continue; + } + case OP_CLOSE: { + luaF_close(L, ra); + continue; + } + case OP_CLOSURE: { + Proto *p; + Closure *ncl; + int nup, j; + p = cl->p->p[GETARG_Bx(i)]; + nup = p->nups; + ncl = luaF_newLclosure(L, nup, cl->env); + ncl->l.p = p; + for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; + else { + lua_assert(GET_OPCODE(*pc) == OP_MOVE); + ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); + } + } + setclvalue(L, ra, ncl); + Protect(luaC_checkGC(L)); + continue; + } + case OP_VARARG: { + int b = GETARG_B(i) - 1; + int j; + CallInfo *ci = L->ci; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; + if (b == LUA_MULTRET) { + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + b = n; + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, ci->base - n + j); + } + else { + setnilvalue(ra + j); + } + } + continue; + } + } + } +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lcode.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lcode.c @@ -0,0 +1,848 @@ +/* +** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "ltable.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } + } + } + } + luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.s.info); +} + + +static int addk (FuncState *fs, TValue *k, TValue *v) { + lua_State *L = fs->L; + TValue *idx = luaH_set(L, fs->h, k); + Proto *f = fs->f; + int oldsize = f->sizek; + if (ttisnumber(idx)) { + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); + } + else { /* constant not found; create a new entry */ + setnvalue(idx, cast_num(fs->nk)); + luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[fs->nk], v); + luaC_barrier(L, f, v); + return fs->nk++; + } +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setnvalue(&o, r); + return addk(fs, &o, &o); +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.s.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + case VGLOBAL: { + e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + freereg(fs, e->u.s.aux); + freereg(fs, e->u.s.info); + e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + break; + } + case VKNUM: { + luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.s.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ + if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.s.info); /* put value on it */ + return e->u.s.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.s.info; +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VKNUM: + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ + e->u.s.info = (e->k == VNIL) ? nilK(fs) : + (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : + boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.s.info); + } + else break; + } + case VK: { + if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ + return RKASK(e->u.s.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.s.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); + break; + } + case VGLOBAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + break; + } + case VINDEXED: { + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int func; + luaK_exp2anyreg(fs, e); + freeexp(fs, e); + func = fs->freereg; + luaK_reserveregs(fs, 2); + luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); + freeexp(fs, key); + e->u.s.info = func; + e->k = VNONRELOC; +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.s.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + case VFALSE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + invertjump(fs, e); + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +static void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + case VTRUE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + t->u.s.aux = luaK_exp2RK(fs, k); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number v1, v2, r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + v1 = e1->u.nval; + v2 = e2->u.nval; + switch (op) { + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; + case OP_DIV: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_numdiv(v1, v2); break; + case OP_MOD: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; + case OP_LEN: return 0; /* no constant folding for 'len' */ + default: lua_assert(0); r = 0; break; + } + if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, OP_UNM, e, &e2); + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); +#if 0 + *e1 = *e2; +#else + memcpy (e1, e2, sizeof (*e1)); +#endif + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); +#if 0 + *e1 = *e2; +#else + memcpy (e1, e2, sizeof (*e1)); +#endif + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.s.info); + e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2); + } + break; + } + case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; + case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; + case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; + case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; + case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; + case OPR_POW: codearith(fs, OP_POW, e1, e2); break; + case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; + case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; + case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; + case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; + case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; + case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +static int luaK_code (FuncState *fs, Instruction i, int line) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "code size overflow"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "code size overflow"); + f->lineinfo[fs->pc] = line; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + } + fs->freereg = base + 1; /* free registers with list values */ +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ldblib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ldblib.c @@ -0,0 +1,398 @@ +/* +** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#endif + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_pushboolean(L, lua_setmetatable(L, 1)); + return 1; +} + + +static int db_getfenv (lua_State *L) { + lua_getfenv(L, 1); + return 1; +} + + +static int db_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + if (lua_setfenv(L, 1) == 0) + luaL_error(L, LUA_QL("setfenv") + " cannot change environment of given object"); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) + settabsi(L, "nups", ar.nups); + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushlightuserdata(L, L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static void gethooktable (lua_State *L) { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_createtable(L, 0, 1); + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); + } +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_pop(L, 1); /* remove hook table */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int db_errorfb (lua_State *L) { + int level; + int firstpart = 1; /* still before eventual `...' */ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (lua_isnumber(L, arg+2)) { + level = (int)lua_tointeger(L, arg+2); + lua_pop(L, 1); + } + else + level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ + if (lua_gettop(L) == arg) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L1, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L1, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L) - arg); + } + lua_concat(L, lua_gettop(L) - arg); + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getfenv", db_getfenv}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"setfenv", db_setfenv}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_register(L, LUA_DBLIBNAME, dblib); + return 1; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ltable.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ltable.c @@ -0,0 +1,594 @@ +/* +** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#if 0 +#include +#include +#endif + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "ltable.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT > 26 +#define MAXBITS 26 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +/* +** number of ints inside a lua_Number +*/ +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) + + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {{NULL}, LUA_TNIL}, /* value */ + {{{NULL}, LUA_TNIL, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + unsigned int a[numints]; + int i; + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); + memcpy(a, &n, sizeof(a)); + for (i = 1; i < numints; i++) a[0] += a[i]; + return hashmod(t, a[0]); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TSTRING: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signalled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaO_rawequalObj(key2tval(n), key) || + (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && + gcvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + } while (n); + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + return 0; /* to avoid warnings */ + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(key2tval(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +static void resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) + setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + } + if (nold != dummynode) + luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = (t->node == dummynode) ? 0 : sizenode(t); + resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L, int narray, int nhash) { + Table *t = luaM_new(L, Table); + luaC_link(L, obj2gco(t), LUA_TTABLE); + t->metatable = NULL; + t->flags = cast_byte(~0); + /* temporary values (kept only if some malloc fails) */ + t->array = NULL; + t->sizearray = 0; + t->lsizenode = 0; + t->node = cast(Node *, dummynode); + setarrayvector(L, t, narray); + setnodevector(L, t, nhash); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (t->node != dummynode) + luaM_freearray(L, t->node, sizenode(t), Node); + luaM_freearray(L, t->array, t->sizearray, TValue); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree-- > t->node) { + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +static TValue *newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || mp == dummynode) { + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + return luaH_set(L, t, key); /* re-insert key into grown table */ + } + lua_assert(n != dummynode); + othern = mainposition(t, key2tval(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ +#if 0 + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ +#else + memcpy (n, mp, sizeof (*n)); +#endif + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; + luaC_barriert(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getnum (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaO_rawequalObj(key2tval(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + t->flags = 0; + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + luaG_runerror(L, "table index is NaN"); + return newkey(L, t, key); + } +} + + +TValue *luaH_setnum (lua_State *L, Table *t, int key) { + const TValue *p = luaH_getnum(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + return newkey(L, t, &k); + } +} + + +TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { + const TValue *p = luaH_getstr(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setsvalue(L, &k, key); + return newkey(L, t, &k); + } +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getnum(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getnum(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getnum(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (t->node == dummynode) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return n == dummynode; } + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ltable.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ltable.h @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lstrlib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lstrlib.c @@ -0,0 +1,870 @@ +/* +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#include +#include +#endif + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, l); + return 1; +} + + +static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); + ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + while (l--) luaL_addchar(&b, s[l]); + luaL_pushresult(&b); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi <= 0) posi = 1; + if ((size_t)pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case L_ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+l2); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static int gfind_nodef (lua_State *L) { + return luaL_error(L, LUA_QL("string.gfind") " was renamed to " + LUA_QL("string.gmatch")); +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) + luaL_addchar(b, news[i]); + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, srcl+1); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + break; + } + case '\r': { + luaL_addlstring(b, "\\r", 2); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_addchar(b, *s); + break; + } + } + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +static void addintlen (char *form) { + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + + +static int str_format (lua_State *L) { + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + arg++; + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + sprintf(buff, form, (int)luaL_checknumber(L, arg)); + break; + } + case 'd': case 'i': { + addintlen(form); + sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + addintlen(form); + sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, (double)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + continue; /* skip the 'addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gfind", gfind_nodef}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); /* set string metatable */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* string library... */ + lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_register(L, LUA_STRLIBNAME, strlib); +#if defined(LUA_COMPAT_GFIND) + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + createmetatable(L); + return 1; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lfunc.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lfunc.h @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ldebug.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ldebug.c @@ -0,0 +1,638 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#endif + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (lua_State *L, CallInfo *ci) { + if (!isLua(ci)) return -1; /* function is not a Lua function? */ + if (ci == L->ci) + ci->savedpc = L->savedpc; + return pcRel(ci->savedpc, ci_func(ci)->l.p); +} + + +static int currentline (lua_State *L, CallInfo *ci) { + int pc = currentpc(L, ci); + if (pc < 0) + return -1; /* only active lua functions have current-line information */ + else + return getline(ci_func(ci)->l.p, pc); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + lua_lock(L); + for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + level--; + if (f_isLua(ci)) /* Lua function? */ + level -= ci->tailcalls; /* skip lost tail calls */ + } + if (level == 0 && ci > L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = cast_int(ci - L->base_ci); + } + else if (level < 0) { /* level is of a lost tail call? */ + status = 1; + ar->i_ci = 0; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static Proto *getluaproto (CallInfo *ci) { + return (isLua(ci) ? ci_func(ci)->l.p : NULL); +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n) { + const char *name; + Proto *fp = getluaproto(ci); + if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) + return name; /* is a local variable in a Lua function */ + else { + StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; + if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + return "(*temporary)"; + else + return NULL; + } +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + luaA_pushobject(L, ci->base + (n - 1)); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + setobjs2s(L, ci->base + (n - 1), L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (cl->c.isC) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + ar->source = getstr(cl->l.p->source); + ar->linedefined = cl->l.p->linedefined; + ar->lastlinedefined = cl->l.p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void info_tailcall (lua_Debug *ar) { + ar->name = ar->namewhat = ""; + ar->what = "tail"; + ar->lastlinedefined = ar->linedefined = ar->currentline = -1; + ar->source = "=(tail call)"; + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + ar->nups = 0; +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (f == NULL || f->c.isC) { + setnilvalue(L->top); + } + else { + Table *t = luaH_new(L, 0, 0); + int *lineinfo = f->l.p->lineinfo; + int i; + for (i=0; il.p->sizelineinfo; i++) + setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); + sethvalue(L, L->top, t); + } + incr_top(L); +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + if (f == NULL) { + info_tailcall(ar); + return status; + } + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci) ? currentline(L, ci) : -1; + break; + } + case 'u': { + ar->nups = f->c.nupvalues; + break; + } + case 'n': { + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *f = NULL; + CallInfo *ci = NULL; + lua_lock(L); + if (*what == '>') { + StkId func = L->top - 1; + luai_apicheck(L, ttisfunction(func)); + what++; /* skip the '>' */ + f = clvalue(func); + L->top--; /* pop function */ + } + else if (ar->i_ci != 0) { /* no tail call? */ + ci = L->base_ci + ar->i_ci; + lua_assert(ttisfunction(ci->func)); + f = clvalue(ci->func); + } + status = auxgetinfo(L, what, ar, f, ci); + if (strchr(what, 'f')) { + if (f == NULL) setnilvalue(L->top); + else setclvalue(L, L->top, f); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, f); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution and code checker +** ======================================================= +*/ + +#define check(x) if (!(x)) return 0; + +#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) + +#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) + + + +static int precheck (const Proto *pt) { + check(pt->maxstacksize <= MAXSTACK); + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || + (pt->is_vararg & VARARG_HASARG)); + check(pt->sizeupvalues <= pt->nups); + check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + return 1; +} + + +#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) + +int luaG_checkopenop (Instruction i) { + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_RETURN: + case OP_SETLIST: { + check(GETARG_B(i) == 0); + return 1; + } + default: return 0; /* invalid instruction after an open call */ + } +} + + +static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { + switch (mode) { + case OpArgN: check(r == 0); break; + case OpArgU: break; + case OpArgR: checkreg(pt, r); break; + case OpArgK: + check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); + break; + } + return 1; +} + + +static Instruction symbexec (const Proto *pt, int lastpc, int reg) { + int pc; + int last; /* stores position of last instruction that changed `reg' */ + last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ + check(precheck(pt)); + for (pc = 0; pc < lastpc; pc++) { + Instruction i = pt->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + int b = 0; + int c = 0; + check(op < NUM_OPCODES); + checkreg(pt, a); + switch (getOpMode(op)) { + case iABC: { + b = GETARG_B(i); + c = GETARG_C(i); + check(checkArgMode(pt, b, getBMode(op))); + check(checkArgMode(pt, c, getCMode(op))); + break; + } + case iABx: { + b = GETARG_Bx(i); + if (getBMode(op) == OpArgK) check(b < pt->sizek); + break; + } + case iAsBx: { + b = GETARG_sBx(i); + if (getBMode(op) == OpArgR) { + int dest = pc+1+b; + check(0 <= dest && dest < pt->sizecode); + if (dest > 0) { + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); + } + } + break; + } + } + if (testAMode(op)) { + if (a == reg) last = pc; /* change register `a' */ + } + if (testTMode(op)) { + check(pc+2 < pt->sizecode); /* check skip */ + check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); + } + switch (op) { + case OP_LOADBOOL: { + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } + break; + } + case OP_LOADNIL: { + if (a <= reg && reg <= b) + last = pc; /* set registers from `a' to `b' */ + break; + } + case OP_GETUPVAL: + case OP_SETUPVAL: { + check(b < pt->nups); + break; + } + case OP_GETGLOBAL: + case OP_SETGLOBAL: { + check(ttisstring(&pt->k[b])); + break; + } + case OP_SELF: { + checkreg(pt, a+1); + if (reg == a+1) last = pc; + break; + } + case OP_CONCAT: { + check(b < c); /* at least two operands */ + break; + } + case OP_TFORLOOP: { + check(c >= 1); /* at least one result (control variable) */ + checkreg(pt, a+2+c); /* space for results */ + if (reg >= a+2) last = pc; /* affect all regs above its base */ + break; + } + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); + /* go through */ + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ + if (reg != NO_REG && pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (b != 0) { + checkreg(pt, a+b-1); + } + c--; /* c = num. returns */ + if (c == LUA_MULTRET) { + check(checkopenop(pt, pc)); + } + else if (c != 0) + checkreg(pt, a+c-1); + if (reg >= a) last = pc; /* affect all registers above base */ + break; + } + case OP_RETURN: { + b--; /* b = num. returns */ + if (b > 0) checkreg(pt, a+b-1); + break; + } + case OP_SETLIST: { + if (b > 0) checkreg(pt, a + b); + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } + break; + } + case OP_CLOSURE: { + int nup, j; + check(b < pt->sizep); + nup = pt->p[b]->nups; + check(pc + nup < pt->sizecode); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); + check(op1 == OP_GETUPVAL || op1 == OP_MOVE); + } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ + break; + } + case OP_VARARG: { + check((pt->is_vararg & VARARG_ISVARARG) && + !(pt->is_vararg & VARARG_NEEDSARG)); + b--; + if (b == LUA_MULTRET) check(checkopenop(pt, pc)); + checkreg(pt, a+b-1); + break; + } + default: break; + } + } + return pt->code[last]; +} + +#undef check +#undef checkjump +#undef checkreg + +/* }====================================================== */ + + +int luaG_checkcode (const Proto *pt) { + return (symbexec(pt, pt->sizecode, NO_REG) != 0); +} + + +static const char *kname (Proto *p, int c) { + if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) + return svalue(&p->k[INDEXK(c)]); + else + return "?"; +} + + +static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, + const char **name) { + if (isLua(ci)) { /* a Lua function? */ + Proto *p = ci_func(ci)->l.p; + int pc = currentpc(L, ci); + Instruction i; + *name = luaF_getlocalname(p, stackpos+1, pc); + if (*name) /* is a local? */ + return "local"; + i = symbexec(p, pc, stackpos); /* try symbolic execution */ + lua_assert(pc != -1); + switch (GET_OPCODE(i)) { + case OP_GETGLOBAL: { + int g = GETARG_Bx(i); /* global index */ + lua_assert(ttisstring(&p->k[g])); + *name = svalue(&p->k[g]); + return "global"; + } + case OP_MOVE: { + int a = GETARG_A(i); + int b = GETARG_B(i); /* move from `b' to `a' */ + if (b < a) + return getobjname(L, ci, b, name); /* get name for `b' */ + break; + } + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "field"; + } + case OP_GETUPVAL: { + int u = GETARG_B(i); /* upvalue index */ + *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + return "upvalue"; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "method"; + } + default: break; + } + } + return NULL; /* no useful name found */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + Instruction i; + if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) + return NULL; /* calling function is not Lua (or is unknown) */ + ci--; /* calling function */ + i = ci_func(ci)->l.p->code[currentpc(L, ci)]; + if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || + GET_OPCODE(i) == OP_TFORLOOP) + return getobjname(L, ci, GETARG_A(i), name); + else + return NULL; /* no useful name can be found */ +} + + +/* only ANSI way to check whether a pointer points to an array */ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *name = NULL; + const char *t = luaT_typenames[ttype(o)]; + const char *kind = (isinstack(L->ci, o)) ? + getobjname(L, L->ci, cast_int(o - L->base), &name) : + NULL; + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + luaG_typeerror(L, p1, "concatenate"); +} + + +void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_typenames[ttype(p1)]; + const char *t2 = luaT_typenames[ttype(p2)]; + if (t1[2] == t2[2]) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(L, ci); + luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +void luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ldump.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ldump.c @@ -0,0 +1,164 @@ +/* +** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL || getstr(s)==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size,D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttype(o),D); + switch (ttype(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: + lua_assert(0); /* cannot happen */ + break; + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],f->source,D); +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i],D); +} + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +{ + DumpString((f->source==p || D->strip) ? NULL : f->source,D); + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->nups,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + char h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,NULL,&D); + return D.status; +} --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lauxlib.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lauxlib.h @@ -0,0 +1,175 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + +#if 0 +#include +#include +#endif + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lgc.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lgc.c @@ -0,0 +1,713 @@ +/* +** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + + +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) + +#define makewhite(g,x) \ + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + +#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) + +#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) + + +#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) +#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) + + +#define KEYWEAK bitmask(KEYWEAKBIT) +#define VALUEWEAK bitmask(VALUEWEAKBIT) + + + +#define markvalue(g,o) { checkconsistency(o); \ + if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + + +#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) + + +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (iscollectable(gkey(n))) + setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ +} + + +static void reallymarkobject (global_State *g, GCObject *o) { + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + switch (o->gch.tt) { + case LUA_TSTRING: { + return; + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + gray2black(o); /* udata are never gray */ + if (mt) markobject(g, mt); + markobject(g, gco2u(o)->env); + return; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v == &uv->u.value) /* closed? */ + gray2black(o); /* open upvalues are never black */ + return; + } + case LUA_TFUNCTION: { + gco2cl(o)->c.gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTABLE: { + gco2h(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + break; + } + default: lua_assert(0); + } +} + + +static void marktmu (global_State *g) { + GCObject *u = g->tmudata; + if (u) { + do { + u = u->gch.next; + makewhite(g, u); /* may be marked, if left from previous GC */ + reallymarkobject(g, u); + } while (u != g->tmudata); + } +} + + +/* move `dead' udata that need finalization to list `tmudata' */ +size_t luaC_separateudata (lua_State *L, int all) { + global_State *g = G(L); + size_t deadmem = 0; + GCObject **p = &g->mainthread->next; + GCObject *curr; + while ((curr = *p) != NULL) { + if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) + p = &curr->gch.next; /* don't bother with them */ + else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { + markfinalized(gco2u(curr)); /* don't need finalization */ + p = &curr->gch.next; + } + else { /* must call its gc method */ + deadmem += sizeudata(gco2u(curr)); + markfinalized(gco2u(curr)); + *p = curr->gch.next; + /* link `curr' at the end of `tmudata' list */ + if (g->tmudata == NULL) /* list is empty? */ + g->tmudata = curr->gch.next = curr; /* creates a circular list */ + else { + curr->gch.next = g->tmudata->gch.next; + g->tmudata->gch.next = curr; + g->tmudata = curr; + } + } + } + return deadmem; +} + + +static int traversetable (global_State *g, Table *h) { + int i; + int weakkey = 0; + int weakvalue = 0; + const TValue *mode; + if (h->metatable) + markobject(g, h->metatable); + mode = gfasttm(g, h->metatable, TM_MODE); + if (mode && ttisstring(mode)) { /* is there a weak mode? */ + weakkey = (strchr(svalue(mode), 'k') != NULL); + weakvalue = (strchr(svalue(mode), 'v') != NULL); + if (weakkey || weakvalue) { /* is really weak? */ + h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); + h->gclist = g->weak; /* must be cleared after GC, ... */ + g->weak = obj2gco(h); /* ... so put in the appropriate list */ + } + } + if (weakkey && weakvalue) return 1; + if (!weakvalue) { + i = h->sizearray; + while (i--) + markvalue(g, &h->array[i]); + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); + if (ttisnil(gval(n))) + removeentry(n); /* remove empty entries */ + else { + lua_assert(!ttisnil(gkey(n))); + if (!weakkey) markvalue(g, gkey(n)); + if (!weakvalue) markvalue(g, gval(n)); + } + } + return weakkey || weakvalue; +} + + +/* +** All marks are conditional because a GC may happen while the +** prototype is still being created +*/ +static void traverseproto (global_State *g, Proto *f) { + int i; + if (f->source) stringmark(f->source); + for (i=0; isizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i=0; isizeupvalues; i++) { /* mark upvalue names */ + if (f->upvalues[i]) + stringmark(f->upvalues[i]); + } + for (i=0; isizep; i++) { /* mark nested protos */ + if (f->p[i]) + markobject(g, f->p[i]); + } + for (i=0; isizelocvars; i++) { /* mark local-variable names */ + if (f->locvars[i].varname) + stringmark(f->locvars[i].varname); + } +} + + + +static void traverseclosure (global_State *g, Closure *cl) { + markobject(g, cl->c.env); + if (cl->c.isC) { + int i; + for (i=0; ic.nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->c.upvalue[i]); + } + else { + int i; + lua_assert(cl->l.nupvalues == cl->l.p->nups); + markobject(g, cl->l.p); + for (i=0; il.nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->l.upvals[i]); + } +} + + +static void checkstacksizes (lua_State *L, StkId max) { + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ + if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ + return; /* do not touch the stacks */ + if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) + luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ + condhardstacktests(luaD_reallocCI(L, ci_used + 1)); + if (4*s_used < L->stacksize && + 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) + luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ + condhardstacktests(luaD_reallocstack(L, s_used)); +} + + +static void traversestack (global_State *g, lua_State *l) { + StkId o, lim; + CallInfo *ci; + markvalue(g, gt(l)); + lim = l->top; + for (ci = l->base_ci; ci <= l->ci; ci++) { + lua_assert(ci->top <= l->stack_last); + if (lim < ci->top) lim = ci->top; + } + for (o = l->stack; o < l->top; o++) + markvalue(g, o); + for (; o <= lim; o++) + setnilvalue(o); + checkstacksizes(l, lim); +} + + +/* +** traverse one gray object, turning it to black. +** Returns `quantity' traversed. +*/ +static l_mem propagatemark (global_State *g) { + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->gch.tt) { + case LUA_TTABLE: { + Table *h = gco2h(o); + g->gray = h->gclist; + if (traversetable(g, h)) /* table is weak? */ + black2gray(o); /* keep it gray */ + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); + } + case LUA_TFUNCTION: { + Closure *cl = gco2cl(o); + g->gray = cl->c.gclist; + traverseclosure(g, cl); + return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : + sizeLclosure(cl->l.nupvalues); + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; + th->gclist = g->grayagain; + g->grayagain = o; + black2gray(o); + traversestack(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->size_ci; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; + traverseproto(g, p); + return sizeof(Proto) + sizeof(Instruction) * p->sizecode + + sizeof(Proto *) * p->sizep + + sizeof(TValue) * p->sizek + + sizeof(int) * p->sizelineinfo + + sizeof(LocVar) * p->sizelocvars + + sizeof(TString *) * p->sizeupvalues; + } + default: lua_assert(0); return 0; + } +} + + +static size_t propagateall (global_State *g) { + size_t m = 0; + while (g->gray) m += propagatemark(g); + return m; +} + + +/* +** The next function tells whether a key or value can be cleared from +** a weak table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for userdata +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (const TValue *o, int iskey) { + if (!iscollectable(o)) return 0; + if (ttisstring(o)) { + stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + return iswhite(gcvalue(o)) || + (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); +} + + +/* +** clear collected entries from weaktables +*/ +static void cleartable (GCObject *l) { + while (l) { + Table *h = gco2h(l); + int i = h->sizearray; + lua_assert(testbit(h->marked, VALUEWEAKBIT) || + testbit(h->marked, KEYWEAKBIT)); + if (testbit(h->marked, VALUEWEAKBIT)) { + while (i--) { + TValue *o = &h->array[i]; + if (iscleared(o, 0)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + if (!ttisnil(gval(n)) && /* non-empty entry? */ + (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* remove entry from table */ + } + } + l = h->gclist; + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->gch.tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2h(o)); break; + case LUA_TTHREAD: { + lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); + luaE_freethread(L, gco2th(o)); + break; + } + case LUA_TSTRING: { + G(L)->strt.nuse--; + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + case LUA_TUSERDATA: { + luaM_freemem(L, o, sizeudata(gco2u(o))); + break; + } + default: lua_assert(0); + } +} + + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) + + +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + GCObject *curr; + global_State *g = G(L); + int deadmask = otherwhite(g); + while ((curr = *p) != NULL && count-- > 0) { + if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ + sweepwholelist(L, &gco2th(curr)->openupval); + if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ + lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); + makewhite(g, curr); /* make it white (for next cycle) */ + p = &curr->gch.next; + } + else { /* must erase `curr' */ + lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); + *p = curr->gch.next; + if (curr == g->rootgc) /* is the first element of the list? */ + g->rootgc = curr->gch.next; /* adjust first */ + freeobj(L, curr); + } + } + return p; +} + + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + /* check size of string hash */ + if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && + g->strt.size > MINSTRTABSIZE*2) + luaS_resize(L, g->strt.size/2); /* table is too big */ + /* check size of buffer */ + if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ + size_t newsize = luaZ_sizebuffer(&g->buff) / 2; + luaZ_resizebuffer(L, &g->buff, newsize); + } +} + + +static void GCTM (lua_State *L) { + global_State *g = G(L); + GCObject *o = g->tmudata->gch.next; /* get first element */ + Udata *udata = rawgco2u(o); + const TValue *tm; + /* remove udata from `tmudata' */ + if (o == g->tmudata) /* last element? */ + g->tmudata = NULL; + else + g->tmudata->gch.next = udata->uv.next; + udata->uv.next = g->mainthread->next; /* return it to `root' list */ + g->mainthread->next = o; + makewhite(g, o); + tm = fasttm(L, udata->uv.metatable, TM_GC); + if (tm != NULL) { + lu_byte oldah = L->allowhook; + lu_mem oldt = g->GCthreshold; + L->allowhook = 0; /* stop debug hooks during GC tag method */ + g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ + setobj2s(L, L->top, tm); + setuvalue(L, L->top+1, udata); + L->top += 2; + luaD_call(L, L->top - 2, 0); + L->allowhook = oldah; /* restore hooks */ + g->GCthreshold = oldt; /* restore threshold */ + } +} + + +/* +** Call all GC tag methods +*/ +void luaC_callGCTM (lua_State *L) { + while (G(L)->tmudata) + GCTM(L); +} + + +void luaC_freeall (lua_State *L) { + global_State *g = G(L); + int i; + g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ + sweepwholelist(L, &g->rootgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); +} + + +static void markmt (global_State *g) { + int i; + for (i=0; imt[i]) markobject(g, g->mt[i]); +} + + +/* mark root set */ +static void markroot (lua_State *L) { + global_State *g = G(L); + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + markobject(g, g->mainthread); + /* make global table be traversed before main stack */ + markvalue(g, gt(g->mainthread)); + markvalue(g, registry(L)); + markmt(g); + g->gcstate = GCSpropagate; +} + + +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +static void atomic (lua_State *L) { + global_State *g = G(L); + size_t udsize; /* total size of userdata to be finalized */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + /* traverse objects cautch by write barrier and by 'remarkupvals' */ + propagateall(g); + /* remark weak tables */ + g->gray = g->weak; + g->weak = NULL; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + markmt(g); /* mark basic metatables (again) */ + propagateall(g); + /* remark gray again */ + g->gray = g->grayagain; + g->grayagain = NULL; + propagateall(g); + udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ + marktmu(g); /* mark `preserved' userdata */ + udsize += propagateall(g); /* remark, to propagate `preserveness' */ + cleartable(g->weak); /* remove collected objects from weak tables */ + /* flip current white */ + g->currentwhite = cast_byte(otherwhite(g)); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gcstate = GCSsweepstring; + g->estimate = g->totalbytes - udsize; /* first estimate */ +} + + +static l_mem singlestep (lua_State *L) { + global_State *g = G(L); + /*lua_checkmemory(L);*/ + switch (g->gcstate) { + case GCSpause: { + markroot(L); /* start a new collection */ + return 0; + } + case GCSpropagate: { + if (g->gray) + return propagatemark(g); + else { /* no more `gray' objects */ + atomic(L); /* finish mark phase */ + return 0; + } + } + case GCSsweepstring: { + lu_mem old = g->totalbytes; + sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); + if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ + g->gcstate = GCSsweep; /* end sweep-string phase */ + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPCOST; + } + case GCSsweep: { + lu_mem old = g->totalbytes; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (*g->sweepgc == NULL) { /* nothing more to sweep? */ + checkSizes(L); + g->gcstate = GCSfinalize; /* end sweep phase */ + } + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: { + if (g->tmudata) { + GCTM(L); + if (g->estimate > GCFINALIZECOST) + g->estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } + else { + g->gcstate = GCSpause; /* end collection */ + g->gcdept = 0; + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; + if (lim == 0) + lim = (MAX_LUMEM-1)/2; /* no limit */ + g->gcdept += g->totalbytes - g->GCthreshold; + do { + lim -= singlestep(L); + if (g->gcstate == GCSpause) + break; + } while (lim > 0); + if (g->gcstate != GCSpause) { + if (g->gcdept < GCSTEPSIZE) + g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ + else { + g->gcdept -= GCSTEPSIZE; + g->GCthreshold = g->totalbytes; + } + } + else { + lua_assert(g->totalbytes >= g->estimate); + setthreshold(g); + } +} + + +void luaC_fullgc (lua_State *L) { + global_State *g = G(L); + if (g->gcstate <= GCSpropagate) { + /* reset sweep marks to sweep all elements (returning them to white) */ + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + /* reset other collector lists */ + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->gcstate = GCSsweepstring; + } + lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); + /* finish any pending sweep phase */ + while (g->gcstate != GCSfinalize) { + lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); + singlestep(L); + } + markroot(L); + while (g->gcstate != GCSpause) { + singlestep(L); + } + setthreshold(g); +} + + +void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + lua_assert(ttype(&o->gch) != LUA_TTABLE); + /* must keep invariant? */ + if (g->gcstate == GCSpropagate) + reallymarkobject(g, v); /* restore invariant */ + else /* don't mind */ + makewhite(g, o); /* mark as white just to avoid other barriers */ +} + + +void luaC_barrierback (lua_State *L, Table *t) { + global_State *g = G(L); + GCObject *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + black2gray(o); /* make table gray (again) */ + t->gclist = g->grayagain; + g->grayagain = o; +} + + +void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { + global_State *g = G(L); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + + +void luaC_linkupval (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = obj2gco(uv); + o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ + g->rootgc = o; + if (isgray(o)) { + if (g->gcstate == GCSpropagate) { + gray2black(o); /* closed upvalues need barrier */ + luaC_barrier(L, uv, uv->v); + } + else { /* sweep phase: sweep it (turning it into white) */ + makewhite(g, o); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + } + } +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/loslib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/loslib.c @@ -0,0 +1,243 @@ +/* +** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int os_pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static int os_execute (lua_State *L) { + lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); + return 1; +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return os_pushresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return os_pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) + res = (int)lua_tointeger(L, -1); + else { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); +} + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_os (lua_State *L) { + luaL_register(L, LUA_OSLIBNAME, syslib); + return 1; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lstate.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lstate.c @@ -0,0 +1,213 @@ +/* +** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) +#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + lua_State l; + global_State g; +} LG; + + + +static void stack_init (lua_State *L1, lua_State *L) { + /* initialize CallInfo array */ + L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); + L1->ci = L1->base_ci; + L1->size_ci = BASIC_CI_SIZE; + L1->end_ci = L1->base_ci + L1->size_ci - 1; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); + L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; + L1->top = L1->stack; + L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; + /* initialize first ci */ + L1->ci->func = L1->top; + setnilvalue(L1->top++); /* `function' entry for this `ci' */ + L1->base = L1->ci->base = L1->top; + L1->ci->top = L1->top + LUA_MINSTACK; +} + + +static void freestack (lua_State *L, lua_State *L1) { + luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); + luaM_freearray(L, L1->stack, L1->stacksize, TValue); +} + + +/* +** open parts that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ + sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + luaS_fix(luaS_newliteral(L, MEMERRMSG)); + g->GCthreshold = 4*g->totalbytes; +} + + +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->size_ci = 0; + L->nCcalls = L->baseCcalls = 0; + L->status = 0; + L->base_ci = L->ci = NULL; + L->savedpc = NULL; + L->errfunc = 0; + setnilvalue(gt(L)); +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeall(L); /* collect all objects */ + lua_assert(g->rootgc == obj2gco(L)); + lua_assert(g->strt.nuse == 0); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaZ_freebuffer(L, &g->buff); + freestack(L, L); + lua_assert(g->totalbytes == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); +} + + +lua_State *luaE_newthread (lua_State *L) { + lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); + luaC_link(L, obj2gco(L1), LUA_TTHREAD); + preinit_state(L1, G(L)); + stack_init(L1, L); /* init stack */ + setobj2n(L, gt(L1), gt(L)); /* share table of globals */ + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L1); + freestack(L, L1); + luaM_freemem(L, fromstate(L1), state_size(lua_State)); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + void *l = (*f)(ud, NULL, 0, state_size(LG)); + if (l == NULL) return NULL; + L = tostate(l); + g = &((LG *)L)->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->GCthreshold = 0; /* mark it as unfinished state */ + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(registry(L)); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->gcstate = GCSpause; + g->rootgc = obj2gco(L); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->tmudata = NULL; + g->totalbytes = sizeof(LG); + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + g->gcdept = 0; + for (i=0; imt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +static void callallgcTM (lua_State *L, void *ud) { + UNUSED(ud); + luaC_callGCTM(L); /* call GC metamethods for all udata */ +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ + L->errfunc = 0; /* no error function during GC metamethods */ + do { /* repeat until no more errors */ + L->ci = L->base_ci; + L->base = L->top = L->ci->base; + L->nCcalls = L->baseCcalls = 0; + } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); + lua_assert(G(L)->tmudata == NULL); + luai_userstateclose(L); + close_state(L); +} --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lstring.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lstring.c @@ -0,0 +1,112 @@ +/* +** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + + +void luaS_resize (lua_State *L, int newsize) { + GCObject **newhash; + stringtable *tb; + int i; + if (G(L)->gcstate == GCSsweepstring) + return; /* cannot resize during GC traverse */ + newhash = luaM_newvector(L, newsize, GCObject *); + tb = &G(L)->strt; + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + while (p) { /* for each node in the list */ + GCObject *next = p->gch.next; /* save next */ + unsigned int h = gco2ts(p)->hash; + int h1 = lmod(h, newsize); /* new position */ + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); + p->gch.next = newhash[h1]; /* chain it */ + newhash[h1] = p; + p = next; + } + } + luaM_freearray(L, tb->hash, tb->size, TString *); + tb->size = newsize; + tb->hash = newhash; +} + + +static TString *newlstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + TString *ts; + stringtable *tb; + if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.marked = luaC_white(G(L)); + ts->tsv.tt = LUA_TSTRING; + ts->tsv.reserved = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + tb = &G(L)->strt; + h = lmod(h, tb->size); + ts->tsv.next = tb->hash[h]; /* chain new entry */ + tb->hash[h] = obj2gco(ts); + tb->nuse++; + if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + return ts; +} + + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = cast(unsigned int, l); /* seed */ + size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t l1; + for (l1=l; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + o != NULL; + o = o->gch.next) { + TString *ts = rawgco2ts(o); + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + /* string may be dead */ + if (isdead(G(L), o)) changewhite(o); + return ts; + } + } + return newlstr(L, str, l, h); /* not found */ +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); + u->uv.marked = luaC_white(G(L)); /* is not finalized */ + u->uv.tt = LUA_TUSERDATA; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + /* chain it on udata list (after main thread) */ + u->uv.next = G(L)->mainthread->next; + G(L)->mainthread->next = obj2gco(u); + return u; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/grub_lib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/grub_lib.c @@ -0,0 +1,438 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "grub_lib.h" + +#include +#include +#include +#include +#include +#include + +static int +save_errno (lua_State *state) +{ + int saved_errno; + + saved_errno = grub_errno; + grub_errno = 0; + + lua_pushinteger (state, saved_errno); + lua_setfield (state, LUA_GLOBALSINDEX, "grub_errno"); + + if (saved_errno) + lua_pushstring (state, grub_errmsg); + else + lua_pushnil (state); + + lua_setfield (state, LUA_GLOBALSINDEX, "grub_errmsg"); + + return saved_errno; +} + +static int +push_result (lua_State *state) +{ + lua_pushinteger (state, save_errno (state)); + return 1; +} + +static int +grub_lua_run (lua_State *state) +{ + int n; + char **args; + const char *s; + + s = luaL_checkstring (state, 1); + if ((! grub_parser_split_cmdline (s, 0, &n, &args)) + && (n >= 0)) + { + grub_command_t cmd; + + cmd = grub_command_find (args[0]); + if (cmd) + (cmd->func) (cmd, n, &args[1]); + else + grub_error (GRUB_ERR_FILE_NOT_FOUND, "command not found"); + + grub_free (args[0]); + grub_free (args); + } + + return push_result (state); +} + +static int +grub_lua_getenv (lua_State *state) +{ + int n, i; + + n = lua_gettop (state); + for (i = 1; i <= n; i++) + { + const char *name, *value; + + name = luaL_checkstring (state, i); + value = grub_env_get (name); + if (value) + lua_pushstring (state, value); + else + lua_pushnil (state); + } + + return n; +} + +static int +grub_lua_setenv (lua_State *state) +{ + const char *name, *value; + + name = luaL_checkstring (state, 1); + value = luaL_checkstring (state, 2); + + if (name[0]) + grub_env_set (name, value); + + return 0; +} + +static int +grub_lua_enum_device (lua_State *state) +{ + auto int enum_device (const char *name); + int enum_device (const char *name) + { + int result; + grub_device_t dev; + + result = 0; + dev = grub_device_open (name); + if (dev) + { + grub_fs_t fs; + + fs = grub_fs_probe (dev); + if (fs) + { + lua_pushvalue (state, 1); + lua_pushstring (state, name); + lua_pushstring (state, fs->name); + if (! fs->uuid) + lua_pushnil (state); + else + { + int err; + char *uuid; + + err = fs->uuid (dev, &uuid); + if (err) + { + grub_errno = 0; + lua_pushnil (state); + } + else + { + lua_pushstring (state, uuid); + grub_free (uuid); + } + } + + lua_call (state, 3, 1); + result = lua_tointeger (state, -1); + lua_pop (state, 1); + } + else + grub_errno = 0; + grub_device_close (dev); + } + else + grub_errno = 0; + + return result; + } + + luaL_checktype (state, 1, LUA_TFUNCTION); + grub_device_iterate (enum_device); + return push_result (state); +} + +static int +grub_lua_enum_file (lua_State *state) +{ + char *device_name; + const char *arg; + grub_device_t dev; + + auto int enum_file (const char *name, const struct grub_dirhook_info *info); + int enum_file (const char *name, const struct grub_dirhook_info *info) + { + int result; + + lua_pushvalue (state, 1); + lua_pushstring (state, name); + lua_pushinteger (state, info->dir != 0); + lua_call (state, 2, 1); + result = lua_tointeger (state, -1); + lua_pop (state, 1); + + return result; + } + + luaL_checktype (state, 1, LUA_TFUNCTION); + arg = luaL_checkstring (state, 2); + device_name = grub_file_get_device_name (arg); + dev = grub_device_open (device_name); + if (dev) + { + grub_fs_t fs; + const char *path; + + fs = grub_fs_probe (dev); + path = grub_strchr (arg, ')'); + if (! path) + path = arg; + else + path++; + + if (fs) + { + (fs->dir) (dev, path, enum_file); + } + + grub_device_close (dev); + } + + grub_free (device_name); + + return push_result (state); +} + +static int +grub_lua_file_open (lua_State *state) +{ + grub_file_t file; + const char *name; + + name = luaL_checkstring (state, 1); + file = grub_file_open (name); + save_errno (state); + + if (! file) + return 0; + + lua_pushlightuserdata (state, file); + return 1; +} + +static int +grub_lua_file_close (lua_State *state) +{ + grub_file_t file; + + luaL_checktype (state, 1, LUA_TLIGHTUSERDATA); + file = lua_touserdata (state, 1); + grub_file_close (file); + + return push_result (state); +} + +static int +grub_lua_file_seek (lua_State *state) +{ + grub_file_t file; + grub_off_t offset; + + luaL_checktype (state, 1, LUA_TLIGHTUSERDATA); + file = lua_touserdata (state, 1); + offset = luaL_checkinteger (state, 2); + + offset = grub_file_seek (file, offset); + save_errno (state); + + lua_pushinteger (state, offset); + return 1; +} + +static int +grub_lua_file_read (lua_State *state) +{ + grub_file_t file; + luaL_Buffer b; + int n; + + luaL_checktype (state, 1, LUA_TLIGHTUSERDATA); + file = lua_touserdata (state, 1); + n = luaL_checkinteger (state, 2); + + luaL_buffinit (state, &b); + while (n) + { + char *p; + int nr; + + nr = (n > LUAL_BUFFERSIZE) ? LUAL_BUFFERSIZE : n; + p = luaL_prepbuffer (&b); + + nr = grub_file_read (file, p, nr); + if (nr <= 0) + break; + + luaL_addsize (&b, nr); + n -= nr; + } + + save_errno (state); + luaL_pushresult (&b); + return 1; +} + +static int +grub_lua_file_getline (lua_State *state) +{ + grub_file_t file; + char *line; + + luaL_checktype (state, 1, LUA_TLIGHTUSERDATA); + file = lua_touserdata (state, 1); + + line = grub_file_getline (file); + save_errno (state); + + if (! line) + return 0; + + lua_pushstring (state, line); + grub_free (line); + return 1; +} + +static int +grub_lua_file_getsize (lua_State *state) +{ + grub_file_t file; + + luaL_checktype (state, 1, LUA_TLIGHTUSERDATA); + file = lua_touserdata (state, 1); + + lua_pushinteger (state, file->size); + return 1; +} + +static int +grub_lua_file_getpos (lua_State *state) +{ + grub_file_t file; + + luaL_checktype (state, 1, LUA_TLIGHTUSERDATA); + file = lua_touserdata (state, 1); + + lua_pushinteger (state, file->offset); + return 1; +} + +static int +grub_lua_file_eof (lua_State *state) +{ + grub_file_t file; + + luaL_checktype (state, 1, LUA_TLIGHTUSERDATA); + file = lua_touserdata (state, 1); + + lua_pushboolean (state, file->offset >= file->size); + return 1; +} + +static int +grub_lua_file_exist (lua_State *state) +{ + grub_file_t file; + const char *name; + int result; + + result = 0; + name = luaL_checkstring (state, 1); + file = grub_file_open (name); + if (file) + { + result++; + grub_file_close (file); + } + else + grub_errno = 0; + + lua_pushboolean (state, result); + return 1; +} + +static int +grub_lua_add_menu (lua_State *state) +{ + int n; + const char *source; + + source = luaL_checklstring (state, 1, 0); + n = lua_gettop (state) - 1; + if (n > 0) + { + const char *args[sizeof (char *) * n]; + char *p; + int i; + + for (i = 0; i < n; i++) + args[i] = luaL_checkstring (state, 2 + i); + + p = grub_strdup (source); + if (! p) + return push_result (state); + + grub_normal_add_menu_entry (n, args, p); + } + else + { + lua_pushstring (state, "not enough parameter"); + lua_error (state); + } + + return push_result (state); +} + +luaL_Reg grub_lua_lib[] = + { + {"run", grub_lua_run}, + {"getenv", grub_lua_getenv}, + {"setenv", grub_lua_setenv}, + {"enum_device", grub_lua_enum_device}, + {"enum_file", grub_lua_enum_file}, + {"file_open", grub_lua_file_open}, + {"file_close", grub_lua_file_close}, + {"file_seek", grub_lua_file_seek}, + {"file_read", grub_lua_file_read}, + {"file_getline", grub_lua_file_getline}, + {"file_getsize", grub_lua_file_getsize}, + {"file_getpos", grub_lua_file_getpos}, + {"file_eof", grub_lua_file_eof}, + {"file_exist", grub_lua_file_exist}, + {"add_menu", grub_lua_add_menu}, + {0, 0} + }; --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lua.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lua.h @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lundump.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lundump.c @@ -0,0 +1,229 @@ +/* +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +#ifdef LUAC_TRUST_BINARIES +#define IF(c,s) +#define error(S,s) +#else +#define IF(c,s) if (c) error(S,s) + +static void error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} +#endif + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + size_t r=luaZ_read(S->Z,b,size); + IF (r!=0, "unexpected end"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + IF (x<0, "bad integer"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static Proto* LoadFunction(LoadState* S, TString* p); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)!=0); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: + error(S,"bad constant"); + break; + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=LoadFunction(S,f->source); +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,TString*); + f->sizeupvalues=n; + for (i=0; iupvalues[i]=NULL; + for (i=0; iupvalues[i]=LoadString(S); +} + +static Proto* LoadFunction(LoadState* S, TString* p) +{ + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); + setptvalue2s(S->L,S->L->top,f); incr_top(S->L); + f->source=LoadString(S); if (f->source==NULL) f->source=p; + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->nups=LoadByte(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadDebug(S,f); + IF (!luaG_checkcode(f), "bad code"); + S->L->top--; + S->L->nCcalls--; + return f; +} + +static void LoadHeader(LoadState* S) +{ + char h[LUAC_HEADERSIZE]; + char s[LUAC_HEADERSIZE]; + luaU_header(h); + LoadBlock(S,s,LUAC_HEADERSIZE); + IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); +} + +/* +** load precompiled chunk +*/ +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + return LoadFunction(&S,luaS_newliteral(L,"=?")); +} + +/* +* make header +*/ +void luaU_header (char* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); + h+=sizeof(LUA_SIGNATURE)-1; + *h++=(char)LUAC_VERSION; + *h++=(char)LUAC_FORMAT; + *h++=(char)*(char*)&x; /* endianness */ + *h++=(char)sizeof(int); + *h++=(char)sizeof(size_t); + *h++=(char)sizeof(Instruction); + *h++=(char)sizeof(lua_Number); + *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ +} --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lgc.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lgc.h @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/linit.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/linit.c @@ -0,0 +1,38 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, +// {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, +// {LUA_IOLIBNAME, luaopen_io}, +// {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, +// {LUA_MATHLIBNAME, luaopen_math}, +// {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lmem.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lmem.h @@ -0,0 +1,50 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + +#if 0 +#include +#endif + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ltablib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ltablib.c @@ -0,0 +1,288 @@ +/* +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i <= n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushinteger(L, i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } + return 0; +} + + +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} + + +static int getn (lua_State *L) { + lua_pushinteger(L, aux_getn(L, 1)); + return 1; +} + + +static int setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); +#ifndef luaL_setn + luaL_setn(L, 1, luaL_checkint(L, 2)); +#else + luaL_error(L, LUA_QL("setn") " is obsolete"); +#endif + lua_pushvalue(L, 1); + return 1; +} + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + luaL_setn(L, 1, e); /* new size */ + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** Lua ensures that (ptr == NULL) iff (osize == 0). +** +** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL). +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *errormsg) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, errormsg); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +void *luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); + return NULL; /* to avoid warnings */ +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + block = (*g->frealloc)(g->ud, block, osize, nsize); + if (block == NULL && nsize > 0) + luaD_throw(L, LUA_ERRMEM); + lua_assert((nsize == 0) == (block == NULL)); + g->totalbytes = (g->totalbytes - osize) + nsize; + return block; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/grub_lua.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/grub_lua.h @@ -0,0 +1,114 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_LUA_HEADER +#define GRUB_LUA_HEADER 1 + +#include +#include +#include +#include +#include + +#define INT_MAX GRUB_LONG_MAX +#define UCHAR_MAX 255 +#define SHRT_MAX 32767 + +#undef UNUSED +#define UNUSED (void) + +#define memcpy grub_memcpy +#define memcmp grub_memcmp +#define strcpy grub_strcpy +#define strstr grub_strstr +#define strchr grub_strchr +#define strlen grub_strlen +#define strtoul grub_strtoul +#define strtod(s,e) grub_strtoul(s,e,0) +#define sprintf grub_sprintf +#define strncpy grub_strncpy +#define strcat grub_strcat +#define strncat grub_strncat +#define strcoll grub_strcmp +#define strcmp grub_strcmp +#define tolower grub_tolower +#define toupper grub_toupper + +#define malloc grub_malloc +#define realloc grub_realloc +#define free grub_free + +#define exit(a) grub_exit() +#define jmp_buf grub_jmp_buf +#define setjmp grub_setjmp +#define longjmp grub_longjmp + +#define fputs(s,f) grub_printf("%s", s) + +#define isdigit grub_isdigit +#define isalpha grub_isalpha +#define isspace grub_isspace + +static inline int +isalnum (int c) +{ + return (isalpha (c) || isdigit (c)); +} + +static inline int +iscntrl (int c) +{ + return ((c <= 0x1f) || (c == 0x7f)); +} + +static inline int +isupper (int c) +{ + return ((c >= 'A') && (c <= 'Z')); +} + +static inline int +islower (int c) +{ + return ((c >= 'a') && (c <= 'z')); +} + +static inline int +ispunct (int c) +{ + return ((! isspace (c)) && (! isalnum (c))); +} + +static inline int +isxdigit (int c) +{ + return (isdigit (c) || ((c >= 'a') && (c <= 'f')) || + ((c >= 'A') && (c <= 'F'))); +} + +static inline int +abs (int c) +{ + return (c >= 0) ? : -c; +} + +int strcspn (const char *s1, const char *s2); +char *strpbrk (const char *s1, const char *s2); +void *memchr (const void *s, int c, size_t n); + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ldo.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ldo.h @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lstate.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lstate.h @@ -0,0 +1,169 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lbaselib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lbaselib.c @@ -0,0 +1,652 @@ +/* +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#include +#endif + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L, int opt) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L, 1); + if (lua_iscfunction(L, -1)) /* is a C function? */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + else + lua_getfenv(L, -1); + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L, 0); + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { + /* change environment of current thread */ + lua_pushthread(L); + lua_insert(L, -2); + lua_setfenv(L, -2); + return 0; + } + else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + luaL_error(L, + LUA_QL("setfenv") " cannot change environment of given object"); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushinteger(L, lua_getgccount(L)); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; + int o = luaL_checkoption(L, 1, "collect", opts); + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, optsnum[o], ex); + switch (optsnum[o]) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushnumber(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 0 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushinteger(L, 0); /* and initial value */ + return 3; +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)ud; /* to avoid warnings */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + *size = 0; + return NULL; + } + else if (lua_isstring(L, -1)) { + lua_replace(L, 3); /* save string in a reserved stack slot */ + return lua_tolstring(L, 3, size); + } + else luaL_error(L, "reader function must return a string"); + return NULL; /* to avoid warnings */ +} + + +static int luaB_load (lua_State *L) { + int status; + const char *cname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ + status = lua_load(L, generic_reader, NULL, cname); + return load_aux(L, status); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + break; + case LUA_TSTRING: + lua_pushvalue(L, 1); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); + break; + } + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"gcinfo", luaB_gcinfo}, + {"getfenv", luaB_getfenv}, + {"getmetatable", luaB_getmetatable}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, + {"loadstring", luaB_loadstring}, + {"next", luaB_next}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setfenv", luaB_setfenv}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"unpack", luaB_unpack}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +#define CO_RUN 0 /* running */ +#define CO_SUS 1 /* suspended */ +#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ +#define CO_DEAD 3 + +static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + +static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status = costatus(L, co); + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + if (status != CO_SUS) { + lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + lua_setlevel(L, co); + status = lua_resume(co, narg); + if (status == 0 || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_corunning (lua_State *L) { + if (lua_pushthread(L)) + lua_pushnil(L); /* main thread is not a coroutine */ + return 1; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + +/* }====================================================== */ + + +static void auxopen (lua_State *L, const char *name, + lua_CFunction f, lua_CFunction u) { + lua_pushcfunction(L, u); + lua_pushcclosure(L, f, 1); + lua_setfield(L, -2, name); +} + + +static void base_open (lua_State *L) { + /* set global _G */ + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setglobal(L, "_G"); + /* open lib into global table */ + luaL_register(L, "_G", base_funcs); + lua_pushliteral(L, LUA_VERSION); + lua_setglobal(L, "_VERSION"); /* set global _VERSION */ + /* `ipairs' and `pairs' need auxliliary functions as upvalues */ + auxopen(L, "ipairs", luaB_ipairs, ipairsaux); + auxopen(L, "pairs", luaB_pairs, luaB_next); + /* `newproxy' needs a weaktable as upvalue */ + lua_createtable(L, 0, 1); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_setglobal(L, "newproxy"); /* set global `newproxy' */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_register(L, LUA_COLIBNAME, co_funcs); + return 2; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/llex.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/llex.c @@ -0,0 +1,467 @@ +/* +** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#endif + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", + "", "", "", "", + NULL +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (b->n + 1 > b->buffsize) { + size_t newsize; + if (b->buffsize >= MAX_SIZET/2) + luaX_lexerror(ls, "lexical element too long", 0); + newsize = b->buffsize * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[b->n++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + } +} + + +#define MAXSRC 80 + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : + luaO_pushfstring(ls->L, "%c", token); + } + else + return luaX_tokens[token-FIRST_RESERVED]; +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaZ_buffer(ls->buff); + default: + return luaX_token2str(ls, token); + } +} + + +void luaX_lexerror (LexState *ls, const char *msg, int token) { + char buff[MAXSRC]; + luaO_chunkid(buff, getstr(ls->source), MAXSRC); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +void luaX_syntaxerror (LexState *ls, const char *msg) { + luaX_lexerror(ls, msg, ls->t.token); +} + + +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TString *ts = luaS_newlstr(L, str, l); + TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ + if (ttisnil(o)) + setbvalue(o, 1); /* make sure `str' will not be collected */ + return ts; +} + + +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { + ls->decpoint = '.'; + ls->L = L; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ + next(ls); /* read first char */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (!strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + /* format error: try to update decimal point separator */ +#if 0 + struct lconv *cv = localeconv(); + char old = ls->decpoint; + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); +#else + char old = ls->decpoint; + ls->decpoint = '.'; +#endif + buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + luaX_lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + lua_assert(isdigit(ls->current)); + do { + save_and_next(ls); + } while (isdigit(ls->current) || ls->current == '.'); + if (check_next(ls, "Ee")) /* `E'? */ + check_next(ls, "+-"); /* optional exponent sign */ + while (isalnum(ls->current) || ls->current == '_') + save_and_next(ls); + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int cont = 0; + (void)(cont); /* avoid warnings when `cont' is not used */ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ +#if defined(LUA_COMPAT_LSTR) + case '[': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `[' */ + cont++; +#if LUA_COMPAT_LSTR == 1 + if (sep == 0) + luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); +#endif + } + break; + } +#endif + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ +#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 + cont--; + if (sep == 0 && cont >= 0) break; +#endif + goto endloop; + } + break; + } + case '\n': + case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); + while (ls->current != del) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, "unfinished string", TK_EOS); + continue; /* to avoid warnings */ + case '\n': + case '\r': + luaX_lexerror(ls, "unfinished string", TK_STRING); + continue; /* to avoid warnings */ + case '\\': { + int c; + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case '\n': /* go through */ + case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case EOZ: continue; /* will raise an error next loop */ + default: { + if (!isdigit(ls->current)) + save_and_next(ls); /* handles \\, \", \', and \? */ + else { /* \xxx */ + int i = 0; + c = 0; + do { + c = 10*c + (ls->current-'0'); + next(ls); + } while (++i<3 && isdigit(ls->current)); + if (c > UCHAR_MAX) + luaX_lexerror(ls, "escape sequence too large", TK_STRING); + save(ls, c); + } + continue; + } + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': + case '\r': { + inclinenumber(ls); + continue; + } + case '-': { + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + luaZ_resetbuffer(ls->buff); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); + continue; + } + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case '"': + case '\'': { + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* ... */ + else return TK_CONCAT; /* .. */ + } + else if (!isdigit(ls->current)) return '.'; + else { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + } + case EOZ: { + return TK_EOS; + } + default: { + if (isspace(ls->current)) { + lua_assert(!currIsNewline(ls)); + next(ls); + continue; + } + else if (isdigit(ls->current)) { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + else if (isalpha(ls->current) || ls->current == '_') { + /* identifier or reserved word */ + TString *ts; + do { + save_and_next(ls); + } while (isalnum(ls->current) || ls->current == '_'); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + if (ts->tsv.reserved > 0) /* reserved word? */ + return ts->tsv.reserved - 1 + FIRST_RESERVED; + else { + seminfo->ts = ts; + return TK_NAME; + } + } + else { + int c = ls->current; + next(ls); + return c; /* single-char tokens (+ - / ...) */ + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +void luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lundump.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lundump.h @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lobject.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lobject.c @@ -0,0 +1,216 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#include +#include +#endif + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* expoent */ + while (x >= 16) { + x = (x+1) >> 1; + e++; + } + if (x < 8) return x; + else return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 31; + if (e == 0) return x; + else return ((x & 7)+8) << (e - 1); +} + + +int luaO_log2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = -1; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; + +} + + +int luaO_rawequalObj (const TValue *t1, const TValue *t2) { + if (ttype(t1) != ttype(t2)) return 0; + else switch (ttype(t1)) { + case LUA_TNIL: + return 1; + case LUA_TNUMBER: + return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: + return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ + case LUA_TLIGHTUSERDATA: + return pvalue(t1) == pvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } +} + + +int luaO_str2d (const char *s, lua_Number *result) { + char *endptr; + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ + *result = cast_num(strtoul(s, &endptr, 16)); + if (*endptr == '\0') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '\0') return 0; /* invalid trailing characters? */ + return 1; +} + + + +static void pushstr (lua_State *L, const char *str) { + setsvalue2s(L, L->top, luaS_new(L, str)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 1; + pushstr(L, ""); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s); + break; + } + case 'c': { + char buff[2]; + buff[0] = cast(char, va_arg(argp, int)); + buff[1] = '\0'; + pushstr(L, buff); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff); + break; + } + case '%': { + pushstr(L, "%"); + break; + } + default: { + char buff[3]; + buff[0] = '%'; + buff[1] = *(e+1); + buff[2] = '\0'; + pushstr(L, buff); + break; + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); + L->top -= n; + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + if (*source == '=') { + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ + } + else { /* out = "source", or "...source" */ + if (*source == '@') { + size_t l; + source++; /* skip the `@' */ + bufflen -= sizeof(" '...' "); + l = strlen(source); + strcpy(out, ""); + if (l > bufflen) { + source += (l-bufflen); /* get last part of file name */ + strcat(out, "..."); + } + strcat(out, source); + } + else { /* out = [string "string"] */ + size_t len = strcspn(source, "\n\r"); /* stop at first newline */ + bufflen -= sizeof(" [string \"...\"] "); + if (len > bufflen) len = bufflen; + strcpy(out, "[string \""); + if (source[len] != '\0') { /* must truncate? */ + strncat(out, source, len); + strcat(out, "..."); + } + else + strcat(out, source); + strcat(out, "\"]"); + } + } +} --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ldebug.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ldebug.h @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/llex.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/llex.h @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ldo.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ldo.c @@ -0,0 +1,519 @@ +/* +** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#endif + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { + setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + case LUA_ERRSYNTAX: + case LUA_ERRRUN: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +static void restore_stack_limit (lua_State *L) { + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ + int inuse = cast_int(L->ci - L->base_ci); + if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ + luaD_reallocCI(L, LUAI_MAXCALLS); + } +} + + +static void resetstack (lua_State *L, int status) { + L->ci = L->base_ci; + L->base = L->ci->base; + luaF_close(L, L->base); /* close eventual pending closures */ + luaD_seterrorobj(L, status, L->base); + L->nCcalls = L->baseCcalls; + L->allowhook = 1; + restore_stack_limit(L); + L->errfunc = 0; + L->errorJmp = NULL; +} + + +void luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { + L->errorJmp->status = errcode; + LUAI_THROW(L, L->errorJmp); + } + else { + L->status = cast_byte(errcode); + if (G(L)->panic) { + resetstack(L, errcode); + lua_unlock(L); + G(L)->panic(L); + } + exit(EXIT_FAILURE); + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + struct lua_longjmp lj; + lj.status = 0; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack+newsize; + correctstack(L, oldstack); +} + + +void luaD_reallocCI (lua_State *L, int newsize) { + CallInfo *oldci = L->base_ci; + luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); + L->size_ci = newsize; + L->ci = (L->ci - oldci) + L->base_ci; + L->end_ci = L->base_ci + L->size_ci - 1; +} + + +void luaD_growstack (lua_State *L, int n) { + if (n <= L->stacksize) /* double size is enough? */ + luaD_reallocstack(L, 2*L->stacksize); + else + luaD_reallocstack(L, L->stacksize + n); +} + + +static CallInfo *growCI (lua_State *L) { + if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + luaD_throw(L, LUA_ERRERR); + else { + luaD_reallocCI(L, 2*L->size_ci); + if (L->size_ci > LUAI_MAXCALLS) + luaG_runerror(L, "stack overflow"); + } + return ++L->ci; +} + + +void luaD_callhook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, L->ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + if (event == LUA_HOOKTAILRET) + ar.i_ci = 0; /* tail call; no debug information about it */ + else + ar.i_ci = cast_int(L->ci - L->base_ci); + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + L->ci->top = L->top + LUA_MINSTACK; + lua_assert(L->ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + L->ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + } +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + Table *htab = NULL; + StkId base, fixed; + for (; actual < nfixargs; ++actual) + setnilvalue(L->top++); +#if defined(LUA_COMPAT_VARARG) + if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ + int nvar = actual - nfixargs; /* number of extra arguments */ + lua_assert(p->is_vararg & VARARG_HASARG); + luaC_checkGC(L); + htab = luaH_new(L, nvar, 1); /* create `arg' table */ + for (i=0; itop - nvar + i); + /* store counter in field `n' */ + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); + } +#endif + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed+i); + setnilvalue(fixed+i); + } + /* add `arg' parameter */ + if (htab) { + sethvalue(L, L->top++, htab); + lua_assert(iswhite(obj2gco(htab))); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define inc_ci(L) \ + ((L->ci == L->end_ci) ? growCI(L) : \ + (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) + + +int luaD_precall (lua_State *L, StkId func, int nresults) { + LClosure *cl; + ptrdiff_t funcr; + if (!ttisfunction(func)) /* `func' is not a function? */ + func = tryfuncTM(L, func); /* check the `function' tag method */ + funcr = savestack(L, func); + cl = &clvalue(func)->l; + L->ci->savedpc = L->savedpc; + if (!cl->isC) { /* Lua function? prepare its call */ + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; + if (L->top > base + p->numparams) + L->top = base + p->numparams; + } + else { /* vararg function */ + int nargs = cast_int(L->top - func) - 1; + base = adjust_varargs(L, p, nargs); + func = restorestack(L, funcr); /* previous call may change the stack */ + } + ci = inc_ci(L); /* now `enter' new function */ + ci->func = func; + L->base = ci->base = base; + ci->top = L->base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + L->savedpc = p->code; /* starting point */ + ci->tailcalls = 0; + ci->nresults = nresults; + for (st = L->top; st < ci->top; st++) + setnilvalue(st); + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) { + L->savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_callhook(L, LUA_HOOKCALL, -1); + L->savedpc--; /* correct 'pc' */ + } + return PCRLUA; + } + else { /* if is a C function, call it */ + CallInfo *ci; + int n; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = inc_ci(L); /* now `enter' new function */ + ci->func = restorestack(L, funcr); + L->base = ci->base = ci->func + 1; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->nresults = nresults; + if (L->hookmask & LUA_MASKCALL) + luaD_callhook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*curr_func(L)->c.f)(L); /* do the actual call */ + lua_lock(L); + if (n < 0) /* yielding? */ + return PCRYIELD; + else { + luaD_poscall(L, L->top - n); + return PCRC; + } + } +} + + +static StkId callrethooks (lua_State *L, StkId firstResult) { + ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ + luaD_callhook(L, LUA_HOOKRET, -1); + if (f_isLua(L->ci)) { /* Lua function? */ + while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ + luaD_callhook(L, LUA_HOOKTAILRET, -1); + } + return restorestack(L, fr); +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci; + if (L->hookmask & LUA_MASKRET) + firstResult = callrethooks(L, firstResult); + ci = L->ci--; + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->base = (ci - 1)->base; /* restore base */ + L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ + luaV_execute(L, 1); /* call it */ + L->nCcalls--; + luaC_checkGC(L); +} + + +static void resume (lua_State *L, void *ud) { + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (L->status == 0) { /* start coroutine? */ + lua_assert(ci == L->base_ci && firstArg > L->base); + if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) + return; + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = 0; + if (!f_isLua(ci)) { /* `common' yield? */ + /* finish interrupted execution of `OP_CALL' */ + lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || + GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); + if (luaD_poscall(L, firstArg)) /* complete it... */ + L->top = L->ci->top; /* and correct top if not multiple results */ + } + else /* yielded inside a hook: just continue its execution */ + L->base = L->ci->base; + } + luaV_execute(L, cast_int(L->ci - L->base_ci)); +} + + +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L, L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +LUA_API int lua_resume (lua_State *L, int nargs) { + int status; + lua_lock(L); + if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + return resume_error(L, "cannot resume non-suspended coroutine"); + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow"); + luai_userstateresume(L, nargs); + lua_assert(L->errfunc == 0); + L->baseCcalls = ++L->nCcalls; + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status != 0) { /* error? */ + L->status = cast_byte(status); /* mark thread as `dead' */ + luaD_seterrorobj(L, status, L->top); + L->ci->top = L->top; + } + else { + lua_assert(L->nCcalls == L->baseCcalls); + status = L->status; + } + --L->nCcalls; + lua_unlock(L); + return status; +} + + +LUA_API int lua_yield (lua_State *L, int nresults) { + luai_userstateyield(L, nresults); + lua_lock(L); + if (L->nCcalls > L->baseCcalls) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + L->base = L->top - nresults; /* protect stack slots below */ + L->status = LUA_YIELD; + lua_unlock(L); + return -1; +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + unsigned short oldnCcalls = L->nCcalls; + ptrdiff_t old_ci = saveci(L, L->ci); + lu_byte old_allowhooks = L->allowhook; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != 0) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close eventual pending closures */ + luaD_seterrorobj(L, status, oldtop); + L->nCcalls = oldnCcalls; + L->ci = restoreci(L, old_ci); + L->base = L->ci->base; + L->savedpc = L->ci->savedpc; + L->allowhook = old_allowhooks; + restore_stack_limit(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* buffer to be used by the scanner */ + const char *name; +}; + +static void f_parser (lua_State *L, void *ud) { + int i; + Proto *tf; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = luaZ_lookahead(p->z); + luaC_checkGC(L); + tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, + &p->buff, p->name); + cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); + cl->l.p = tf; + for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ + cl->l.upvals[i] = luaF_newupval(L); + setclvalue(L, L->top, cl); + incr_top(L); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { + struct SParser p; + int status; + p.z = z; p.name = name; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + return status; +} + + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lmathlib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lmathlib.c @@ -0,0 +1,263 @@ +/* +** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + double ip; + double fp = modf(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_register(L, LUA_MATHLIBNAME, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/liolib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/liolib.c @@ -0,0 +1,553 @@ +/* +** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +#define IO_INPUT 1 +#define IO_OUTPUT 2 + + +static const char *const fnames[] = {"input", "output"}; + + +static int pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static void fileerror (lua_State *L, int arg, const char *filename) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, arg, lua_tostring(L, -1)); +} + + +#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + + +static int io_type (lua_State *L) { + void *ud; + luaL_checkany(L, 1); + ud = lua_touserdata(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + lua_pushnil(L); /* not a file */ + else if (*((FILE **)ud) == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L) { + FILE **f = tofilep(L); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, LUA_FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = lua_pclose(L, *p); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = (fclose(*p) == 0); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +static int aux_close (lua_State *L) { + lua_getfenv(L, 1); + lua_getfield(L, -1, "__close"); + return (lua_tocfunction(L, -1))(L); +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); + tofile(L); /* make sure argument is a file */ + return aux_close(L); +} + + +static int io_gc (lua_State *L) { + FILE *f = *tofilep(L); + /* ignore closed files */ + if (f != NULL) + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + FILE *f = *tofilep(L); + if (f == NULL) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", f); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +/* +** this function has a separated environment, which defines the +** correct __close for 'popen' files +*/ +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = lua_popen(L, filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, int findex) { + FILE *f; + lua_rawgeti(L, LUA_ENVIRONINDEX, findex); + f = *(FILE **)lua_touserdata(L, -1); + if (f == NULL) + luaL_error(L, "standard %s file is closed", fnames[findex - 1]); + return f; +} + + +static int g_iofile (lua_State *L, int f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) + fileerror(L, 1, filename); + } + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawseti(L, LUA_ENVIRONINDEX, f); + } + /* return current value */ + lua_rawgeti(L, LUA_ENVIRONINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int toclose) { + lua_pushvalue(L, idx); + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 2); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + /* will iterate over default input */ + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + if (*pf == NULL) + fileerror(L, 1, filename); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else return 0; /* read fails */ +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_objlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return pushresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); + int sucess; + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + sucess = read_line(L, f); + if (ferror(f)) + return luaL_error(L, "%s", strerror(errno)); + if (sucess) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + long offset = luaL_optlong(L, 3, 0); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L)) == 0, NULL); +} + + +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_register(L, NULL, flib); /* file methods */ +} + + +static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { + *newfile(L) = f; + if (k > 0) { + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_ENVIRONINDEX, k); + } + lua_pushvalue(L, -2); /* copy environment */ + lua_setfenv(L, -2); /* set it */ + lua_setfield(L, -3, fname); +} + + +static void newfenv (lua_State *L, lua_CFunction cls) { + lua_createtable(L, 0, 1); + lua_pushcfunction(L, cls); + lua_setfield(L, -2, "__close"); +} + + +LUALIB_API int luaopen_io (lua_State *L) { + createmeta(L); + /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ + newfenv(L, io_fclose); + lua_replace(L, LUA_ENVIRONINDEX); + /* open library */ + luaL_register(L, LUA_IOLIBNAME, iolib); + /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, 0, "stderr"); + lua_pop(L, 1); /* pop environment for default files */ + lua_getfield(L, -1, "popen"); + newfenv(L, io_pclose); /* create environment for 'popen' */ + lua_setfenv(L, -2); /* set fenv for 'popen' */ + lua_pop(L, 1); /* pop 'popen' */ + return 1; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lzio.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lzio.c @@ -0,0 +1,83 @@ +/* +** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** a generic input stream interface +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) return EOZ; + z->n = size - 1; + z->p = buff; + return char2int(*(z->p++)); +} + + +int luaZ_lookahead (ZIO *z) { + if (z->n == 0) { + if (luaZ_fill(z) == EOZ) + return EOZ; + else { + z->n++; /* luaZ_fill removed first byte; put back it */ + z->p--; + } + } + return char2int(*z->p); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (luaZ_lookahead(z) == EOZ) + return n; /* return number of missing bytes */ + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lauxlib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lauxlib.c @@ -0,0 +1,668 @@ +/* +** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#include +#include +#include +#endif + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + } + luaL_typerror(L, ud, tname); /* else error */ + return NULL; /* to avoid warnings */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +#if 0 + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + /* skip eventual `#!...' */ + while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + +#else +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + (void) L; + (void) filename; + + return LUA_ERRFILE; +} + +#endif + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ +#if 0 + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); +#else + grub_fatal ("PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); +#endif + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/luaconf.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/luaconf.h @@ -0,0 +1,811 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#if 0 +#include +#include +#endif + +#include "grub_lua.h" + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if 0 +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif +#endif + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" ".\\?51.dll;" LUA_CDIR"?.dll;" LUA_CDIR"?51.dll;" LUA_CDIR"clibs\\?.dll;" LUA_CDIR"clibs\\?51.dll;" LUA_CDIR"loadall.dll;" LUA_CDIR"clibs\\loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" "./lib?51.so;" LUA_CDIR"?.so;" LUA_CDIR"lib?51.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#if 0 +#define LUAL_BUFFERSIZE BUFSIZ +#else +#define LUAL_BUFFERSIZE 512 +#endif + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#if 0 +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double +#else + +#define LUA_NUMBER int +#define LUAI_UACNUMBER int + +#endif + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#if 0 +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#else +#define LUA_NUMBER_SCAN "%d" +#define LUA_NUMBER_FMT "%d" +#endif +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#if 0 +#include +#endif +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#if 0 +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#else + +#define luai_nummod(a,b) ((a) % (b)) + +static inline LUA_NUMBER +luai_numpow (LUA_NUMBER a, LUA_NUMBER b) +{ + LUA_NUMBER c; + + c = 1; + while (b > 0) + { + c *= a; + b--; + } + + return c; +} + +#endif +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +#if 0 +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if 0 +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif +#endif + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lstring.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lstring.h @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lobject.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lobject.h @@ -0,0 +1,380 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lapi.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lapi.c @@ -0,0 +1,1088 @@ +/* +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#include +#include +#include +#endif + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" + "$Authors: " LUA_AUTHORS " $\n" + "$URL: www.lua.org $\n"; + + + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) + +#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) + +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} + + + +static TValue *index2adr (lua_State *L, int idx) { + if (idx > 0) { + TValue *o = L->base + (idx - 1); + api_check(L, idx <= L->ci->top - L->base); + if (o >= L->top) return cast(TValue *, luaO_nilobject); + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } + else switch (idx) { /* pseudo-indices */ + case LUA_REGISTRYINDEX: return registry(L); + case LUA_ENVIRONINDEX: { + Closure *func = curr_func(L); + sethvalue(L, &L->env, func->c.env); + return &L->env; + } + case LUA_GLOBALSINDEX: return gt(L); + default: { + Closure *func = curr_func(L); + idx = LUA_GLOBALSINDEX - idx; + return (idx <= func->c.nupvalues) + ? &func->c.upvalue[idx-1] + : cast(TValue *, luaO_nilobject); + } + } +} + + +static Table *getcurrenv (lua_State *L) { + if (L->ci == L->base_ci) /* no enclosing function? */ + return hvalue(gt(L)); /* use global table as environment */ + else { + Closure *func = curr_func(L); + return func->c.env; + } +} + + +void luaA_pushobject (lua_State *L, const TValue *o) { + setobj2s(L, L->top, o); + api_incr_top(L); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res = 1; + lua_lock(L); + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) + res = 0; /* stack overflow */ + else if (size > 0) { + luaD_checkstack(L, size); + if (L->ci->top < L->top + size) + L->ci->top = L->top + size; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + api_check(from, to->ci->top - to->top >= n); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = luaE_newthread(L); + setthvalue(L, L->top, L1); + api_incr_top(L); + lua_unlock(L); + luai_userstatethread(L, L1); + return L1; +} + + + +/* +** basic stack manipulation +*/ + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - L->base); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - L->base); + while (L->top < L->base + idx) + setnilvalue(L->top++); + L->top = L->base + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + StkId o; + lua_lock(L); + /* explicit test for incompatible code */ + if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) + luaG_runerror(L, "no calling environment"); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (idx == LUA_ENVIRONINDEX) { + Closure *func = curr_func(L); + api_check(L, ttistable(L->top - 1)); + func->c.env = hvalue(L->top - 1); + luaC_barrier(L, func, L->top - 1); + } + else { + setobj(L, o, L->top - 1); + if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ + luaC_barrier(L, curr_func(L), L->top - 1); + } + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2adr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return iscfunction(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2adr(L, index1); + StkId o2 = index2adr(L, index2); + return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaO_rawequalObj(o1, o2); +} + + +LUA_API int lua_equal (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); + lua_unlock(L); + return i; +} + + +LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaV_lessthan(L, o1, o2); + lua_unlock(L); + return i; +} + + + +LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) + return nvalue(o); + else + return 0; +} + + +LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + return res; + } + else + return 0; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2adr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2adr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_objlen (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + case LUA_TNUMBER: { + size_t l; + lua_lock(L); /* `luaV_tostring' may create a new string */ + l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); + lua_unlock(L); + return l; + } + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TFUNCTION: return clvalue(o); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { + lua_lock(L); + luaC_checkGC(L); + setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) + lua_pushnil(L); + else + lua_pushlstring(L, s, strlen(s)); +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + Closure *cl; + lua_lock(L); + luaC_checkGC(L); + api_checknelems(L, n); + cl = luaF_newCclosure(L, n, getcurrenv(L)); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top+n); + setclvalue(L, L->top, cl); + lua_assert(iswhite(obj2gco(cl))); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + lua_lock(L); + luaC_checkGC(L); + sethvalue(L, L->top, luaH_new(L, narray, nrec)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2adr(L, objindex); + switch (ttype(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttype(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getfenv (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + switch (ttype(o)) { + case LUA_TFUNCTION: + sethvalue(L, L->top, clvalue(o)->c.env); + break; + case LUA_TUSERDATA: + sethvalue(L, L->top, uvalue(o)->env); + break; + case LUA_TTHREAD: + setobj2s(L, L->top, gt(thvalue(o))); + break; + default: + setnilvalue(L->top); + break; + } + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + luaC_barriert(L, hvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); + luaC_barriert(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2adr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1)); + mt = hvalue(L->top - 1); + } + switch (ttype(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarriert(L, hvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrier(L, rawuvalue(obj), mt); + break; + } + default: { + G(L)->mt[ttype(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API int lua_setfenv (lua_State *L, int idx) { + StkId o; + int res = 1; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttistable(L->top - 1)); + switch (ttype(o)) { + case LUA_TFUNCTION: + clvalue(o)->c.env = hvalue(L->top - 1); + break; + case LUA_TUSERDATA: + uvalue(o)->env = hvalue(L->top - 1); + break; + case LUA_TTHREAD: + sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); + break; + default: + res = 0; + break; + } + if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + L->top--; + lua_unlock(L); + return res; +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define adjustresults(L,nres) \ + { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) + + +LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + StkId func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + luaD_call(L, func, nresults); + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2adr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + c.nresults = nresults; + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +/* +** Execute a protected C call. +*/ +struct CCallS { /* data to `f_Ccall' */ + lua_CFunction func; + void *ud; +}; + + +static void f_Ccall (lua_State *L, void *ud) { + struct CCallS *c = cast(struct CCallS *, ud); + Closure *cl; + cl = luaF_newCclosure(L, 0, getcurrenv(L)); + cl->c.f = c->func; + setclvalue(L, L->top, cl); /* push function */ + api_incr_top(L); + setpvalue(L->top, c->ud); /* push only argument */ + api_incr_top(L); + luaD_call(L, L->top - 2, 0); +} + + +LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { + struct CCallS c; + int status; + lua_lock(L); + c.func = func; + c.ud = ud; + status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname); + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->GCthreshold = MAX_LUMEM; + break; + } + case LUA_GCRESTART: { + g->GCthreshold = g->totalbytes; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(g->totalbytes >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(g->totalbytes & 0x3ff); + break; + } + case LUA_GCSTEP: { + lu_mem a = (cast(lu_mem, data) << 10); + if (a <= g->totalbytes) + g->GCthreshold = g->totalbytes - a; + else + g->GCthreshold = 0; + while (g->GCthreshold <= g->totalbytes) { + luaC_step(L); + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); + L->top -= (n-1); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, getcurrenv(L)); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val) { + Closure *f; + if (!ttisfunction(fi)) return NULL; + f = clvalue(fi); + if (f->c.isC) { + if (!(1 <= n && n <= f->c.nupvalues)) return NULL; + *val = &f->c.upvalue[n-1]; + return ""; + } + else { + Proto *p = f->l.p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->l.upvals[n-1]->v; + return getstr(p->upvalues[n-1]); + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + lua_lock(L); + name = aux_upvalue(index2adr(L, funcindex), n, &val); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + StkId fi; + lua_lock(L); + fi = index2adr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, clvalue(fi), L->top); + } + lua_unlock(L); + return name; +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lzio.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lzio.h @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/ltm.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/ltm.c @@ -0,0 +1,76 @@ +/* +** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#if 0 +#include +#endif + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +const char *const luaT_typenames[] = { + "nil", "boolean", "userdata", "number", + "string", "table", "function", "userdata", "thread", + "proto", "upval" +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__len", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttype(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lopcodes.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lopcodes.c @@ -0,0 +1,102 @@ +/* +** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETGLOBAL", + "GETTABLE", + "SETGLOBAL", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORLOOP", + "SETLIST", + "CLOSE", + "CLOSURE", + "VARARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ +}; + --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lopcodes.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lopcodes.h @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lualib.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lcode.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lcode.h @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/grub_main.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/grub_main.c @@ -0,0 +1,209 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +#include "grub_lib.h" + +#include +#include + +static const char * +scan_str (const char *s1, const char *s2) +{ + while (*s1) + { + const char *p = s2; + + while (*p) + { + if (*s1 == *p) + return s1; + p++; + } + + s1++; + } + + return s1; +} + +int +strcspn (const char *s1, const char *s2) +{ + const char *r; + + r = scan_str (s1, s2); + return r - s1; +} + +char * +strpbrk (const char *s1, const char *s2) +{ + const char *r; + + r = scan_str (s1, s2); + return (*r) ? (char *) r : 0; +} + +void * +memchr (const void *s, int c, size_t n) +{ + const unsigned char *p = s; + + while (n) + { + if (*p == c) + return (void *) p; + + n--; + p++; + } + + return 0; +} + +static lua_State *state; + +/* Call `grub_error' to report a Lua error. The error message string must be + on the top of the Lua stack (at index -1). The error message is popped off + the Lua stack before this function returns. */ +static void +handle_lua_error (const char *error_type) +{ + const char *error_msg; + error_msg = lua_tostring (state, -1); + if (error_msg == NULL) + error_msg = "(error message not a string)"; + grub_error (GRUB_ERR_BAD_ARGUMENT, "%s: %s", error_type, error_msg); + /* Pop the error message. */ + lua_pop (state, 1); +} + +static grub_err_t +grub_lua_parse_line (char *line, grub_reader_getline_t getline) +{ + int r; + char *old_line = 0; + + lua_settop(state, 0); + while (1) + { + r = luaL_loadbuffer (state, line, grub_strlen (line), "=grub"); + if (! r) + { + /* No error: Execute the statement. */ + r = lua_pcall (state, 0, 0, 0); + if (r) + { + handle_lua_error ("Lua"); + break; + } + else + { + grub_free (old_line); + return grub_errno; + } + } + + if (r == LUA_ERRSYNTAX) + { + /* Check whether the syntax error is a result of an incomplete + statement. If it is, then try to complete the statement by + reading more lines. */ + size_t lmsg; + const char *msg = lua_tolstring (state, -1, &lmsg); + const char *tp = msg + lmsg - (sizeof (LUA_QL ("")) - 1); + if (grub_strstr (msg, LUA_QL ("")) == tp) + { + char *n, *t; + int len; + + /* Discard the error message. */ + lua_pop (state, 1); + /* Try to read another line to complete the statement. */ + if ((getline (&n, 1)) || (! n)) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, "incomplete command"); + break; + } + + /* More input was available: Add it to the current statement + contents. */ + len = grub_strlen (line); + t = grub_malloc (len + grub_strlen (n) + 2); + if (! t) + break; + + grub_strcpy (t, line); + t[len] = '\n'; + grub_strcpy (t + len + 1, n); + grub_free (old_line); + line = old_line = t; + /* Try again to execute the statement now that more input has + been appended. */ + continue; + } + /* The syntax error was not the result of an incomplete line. */ + handle_lua_error ("Lua syntax error"); + } + else + { + /* Handle errors other than syntax errors (out of memory, etc.). */ + handle_lua_error ("Lua parser failed"); + } + + break; + } + + grub_free (old_line); + lua_gc (state, LUA_GCCOLLECT, 0); + + return grub_errno; +} + +static struct grub_parser grub_lua_parser = + { + .name = "lua", + .parse_line = grub_lua_parse_line + }; + +GRUB_MOD_INIT(lua) +{ + (void) mod; + + state = lua_open (); + if (state) + { + lua_gc (state, LUA_GCSTOP, 0); + luaL_openlibs (state); + luaL_register (state, "grub", grub_lua_lib); + lua_gc (state, LUA_GCRESTART, 0); + grub_parser_register ("lua", &grub_lua_parser); + } +} + +GRUB_MOD_FINI(lua) +{ + if (state) + { + grub_parser_unregister (&grub_lua_parser); + lua_close (state); + } +} --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/grub_lib.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/grub_lib.h @@ -0,0 +1,24 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_LUA_LIB_HEADER +#define GRUB_LUA_LIB_HEADER 1 + +extern luaL_Reg grub_lua_lib[]; + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/loadlib.c +++ grub2-1.97~beta4/debian/grub-extras/script/lua/loadlib.c @@ -0,0 +1,665 @@ +/* +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Darwin (Mac OS X), an +** implementation for Windows, and a stub for other systems. +*/ + + +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +#define LIBPREFIX "LOADLIB: " + +#define POF LUA_POF +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_DL_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + void *lib = dlopen(path, RTLD_NOW); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +#undef setprogdir + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HINSTANCE)lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DYLD) +/* +** {====================================================================== +** Native Mac OS X / Darwin Implementation +** ======================================================================= +*/ + +#include + + +/* Mac appends a `_' before C function names */ +#undef POF +#define POF "_" LUA_POF + + +static void pusherror (lua_State *L) { + const char *err_str; + const char *err_file; + NSLinkEditErrors err; + int err_num; + NSLinkEditError(&err, &err_num, &err_file, &err_str); + lua_pushstring(L, err_str); +} + + +static const char *errorfromcode (NSObjectFileImageReturnCode ret) { + switch (ret) { + case NSObjectFileImageInappropriateFile: + return "file is not a bundle"; + case NSObjectFileImageArch: + return "library is for wrong CPU type"; + case NSObjectFileImageFormat: + return "bad format"; + case NSObjectFileImageAccess: + return "cannot access file"; + case NSObjectFileImageFailure: + default: + return "unable to load library"; + } +} + + +static void ll_unloadlib (void *lib) { + NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); +} + + +static void *ll_load (lua_State *L, const char *path) { + NSObjectFileImage img; + NSObjectFileImageReturnCode ret; + /* this would be a rare case, but prevents crashing if it happens */ + if(!_dyld_present()) { + lua_pushliteral(L, "dyld not present"); + return NULL; + } + ret = NSCreateObjectFileImageFromFile(path, &img); + if (ret == NSObjectFileImageSuccess) { + NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(img); + if (mod == NULL) pusherror(L); + return mod; + } + lua_pushstring(L, errorfromcode(ret)); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); + if (nss == NULL) { + lua_pushfstring(L, "symbol " LUA_QS " not found", sym); + return NULL; + } + return (lua_CFunction)NSAddressOfSymbol(nss); +} + +/* }====================================================== */ + + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)lib; /* to avoid warnings */ +} + + +static void *ll_load (lua_State *L, const char *path) { + (void)path; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)lib; (void)sym; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + + +static void **ll_register (lua_State *L, const char *path) { + void **plib; + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(const void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + + +/* +** __gc tag method: calls library's `ll_unloadlib' function with the lib +** handle +*/ +static int gctm (lua_State *L) { + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path); + if (*reg == NULL) + return ERRLIB; /* unable to load library */ + else { + lua_CFunction f = ll_sym(L, *reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); + return 0; /* return function */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname) { + const char *path; + name = luaL_gsub(L, name, ".", LUA_DIRSEP); + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + lua_pushliteral(L, ""); /* error accumulator */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename; + filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ + } + return NULL; /* not found */ +} + + +static void loaderror (lua_State *L, const char *filename) { + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int loader_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +static int loader_C (lua_State *L) { + const char *funcname; + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static int loader_Croot (lua_State *L) { + const char *funcname; + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + + +static int loader_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i=1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ + + +static void setfenv (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + return luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + + +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + +static void setpath (lua_State *L, const char *fieldname, const char *envname, + const char *def) { + const char *path = getenv(envname); + if (path == NULL) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"seeall", ll_seeall}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { + {"module", ll_module}, + {"require", ll_require}, + {NULL, NULL} +}; + + +static const lua_CFunction loaders[] = + {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; + + +LUALIB_API int luaopen_package (lua_State *L) { + int i; + /* create new type _LOADLIB */ + luaL_newmetatable(L, "_LOADLIB"); + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); + /* create `package' table */ + luaL_register(L, LUA_LOADLIBNAME, pk_funcs); +#if defined(LUA_COMPAT_LOADLIB) + lua_getfield(L, -1, "loadlib"); + lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); +#endif + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + /* create `loaders' table */ + lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); + /* fill it with pre-defined loaders */ + for (i=0; loaders[i] != NULL; i++) { + lua_pushcfunction(L, loaders[i]); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + lua_newtable(L); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ + lua_pop(L, 1); + return 1; /* return 'package' table */ +} --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lapi.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lapi.h @@ -0,0 +1,16 @@ +/* +** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "lobject.h" + + +LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lparser.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lparser.h @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/script/lua/lvm.h +++ grub2-1.97~beta4/debian/grub-extras/script/lua/lvm.h @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif --- grub2-1.97~beta4.orig/debian/grub-extras/conf/common.rmk +++ grub2-1.97~beta4/debian/grub-extras/conf/common.rmk @@ -0,0 +1,39 @@ +# -*- makefile -*- + +COMMON_CFLAGS += -I$(GRUB_EXTRAS)/include + +ifneq (, $(enable_zfs)) + +pkglib_MODULES += zfs.mod +zfs_mod_SOURCES = $(GRUB_EXTRAS)/fs/zfs.c $(GRUB_EXTRAS)/fs/zfs_lzjb.c $(GRUB_EXTRAS)/fs/zfs_sha256.c $(GRUB_EXTRAS)/fs/zfs_fletcher.c +zfs_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error +zfs_mod_LDFLAGS = $(COMMON_LDFLAGS) + +pkglib_MODULES += zfsinfo.mod +zfsinfo_mod_SOURCES = $(GRUB_EXTRAS)/commands/zfsinfo.c +zfsinfo_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error +zfsinfo_mod_LDFLAGS = $(COMMON_LDFLAGS) + +endif + + +ifneq (, $(enable_lua)) + +pkglib_MODULES += lua.mod +lua_mod_SOURCES = $(GRUB_EXTRAS)/script/lua/lapi.c $(GRUB_EXTRAS)/script/lua/lcode.c $(GRUB_EXTRAS)/script/lua/ldebug.c \ + $(GRUB_EXTRAS)/script/lua/ldo.c $(GRUB_EXTRAS)/script/lua/ldump.c $(GRUB_EXTRAS)/script/lua/lfunc.c \ + $(GRUB_EXTRAS)/script/lua/lgc.c $(GRUB_EXTRAS)/script/lua/llex.c $(GRUB_EXTRAS)/script/lua/lmem.c \ + $(GRUB_EXTRAS)/script/lua/lobject.c $(GRUB_EXTRAS)/script/lua/lopcodes.c $(GRUB_EXTRAS)/script/lua/lparser.c \ + $(GRUB_EXTRAS)/script/lua/lstate.c $(GRUB_EXTRAS)/script/lua/lstring.c $(GRUB_EXTRAS)/script/lua/ltable.c \ + $(GRUB_EXTRAS)/script/lua/ltm.c $(GRUB_EXTRAS)/script/lua/lundump.c $(GRUB_EXTRAS)/script/lua/lvm.c \ + $(GRUB_EXTRAS)/script/lua/lzio.c $(GRUB_EXTRAS)/script/lua/lauxlib.c $(GRUB_EXTRAS)/script/lua/lbaselib.c \ + $(GRUB_EXTRAS)/script/lua/linit.c $(GRUB_EXTRAS)/script/lua/ltablib.c $(GRUB_EXTRAS)/script/lua/lstrlib.c \ + $(GRUB_EXTRAS)/script/lua/grub_main.c $(GRUB_EXTRAS)/script/lua/grub_lib.c +lua_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error +lua_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# Extra libraries for lua +# script/lua/lmathlib.c script/lua/loslib.c script/lua/liolib.c +# script/lua/ldblib.c script/lua/loadlib.c + +endif --- grub2-1.97~beta4.orig/debian/grub-extras/conf/i386-pc.rmk +++ grub2-1.97~beta4/debian/grub-extras/conf/i386-pc.rmk @@ -0,0 +1,12 @@ +# -*- makefile -*- + +include $(GRUB_EXTRAS)/conf/common.mk + +ifneq (, $(enable_915resolution)) + +pkglib_MODULES += 915resolution.mod +915resolution_mod_SOURCES = $(GRUB_EXTRAS)/commands/i386/915resolution.c +915resolution_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error +915resolution_mod_LDFLAGS = $(COMMON_LDFLAGS) + +endif --- grub2-1.97~beta4.orig/debian/grub-extras/util/osdetect.lua +++ grub2-1.97~beta4/debian/grub-extras/util/osdetect.lua @@ -0,0 +1,111 @@ +#!lua +-- +-- Copyright (C) 2009 Free Software Foundation, Inc. +-- +-- GRUB is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- GRUB is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GRUB. If not, see . +-- + +function enum_device (device, fs, uuid) + local root + local title + local source + local kernels = {} + local kernel_num = 0 + + local function enum_file (name) + local version + + version = string.match (name, "vmlinuz%-(.*)") + if (version ~= nil) then + table.insert (kernels, version) + kernel_num = kernel_num + 1 + end + end + + local function sort_kernel (first, second) + local a1, a2, a3, a4, b1, b2, b3, b4 + + a1, a2, a3, a4 = string.match (first, "(%d+)%.?(%d*).?(%d*)%-?(%d*)") + b1, b2, b3, b4 = string.match (second, "(%d+)%.?(%d*).?(%d*)%-?(%d*)") + return (a1 > b1) or (a2 > b2) or (a3 > b3) or (a4 < b4); + end + + root = "(" .. device .. ")/" + source = "root (" .. device .. ")\nchainloader +1" + title = nil + if (grub.file_exist (root .. "bootmgr") and + grub.file_exist (root .. "boot/bcd")) then + title = "Windows Vista bootmgr" + elseif (grub.file_exist (root .. "ntldr") and + grub.file_exist (root .. "ntdetect.com") and + grub.file_exist (root .. "boot.ini")) then + title = "Windows NT/2000/XP loader" + elseif (grub.file_exist (root .. "windows/win.com")) then + title = "Windows 98/ME" + elseif (grub.file_exist (root .. "io.sys") and + grub.file_exist (root .. "command.com")) then + title = "MS-DOS" + elseif (grub.file_exist (root .. "kernel.sys")) then + title = "FreeDOS" + elseif (grub.file_exist (root .. "boot/loader") and + grub.file_exist (root .. "boot/device.hints")) then + source = "root (" .. device .. ")\nfreebsd /boot/loader" .. + "\nfreebsd_loadenv /boot/device.hints" + title = "FreeBSD" + else + grub.enum_file (enum_file, root .. "boot") + if kernel_num ~= 0 then + table.sort (kernels, sort_kernel) + for i = 1, kernel_num do + local initrd + + title = "Linux " .. kernels[i] + source = "root (" .. device .. + ")\nlinux /boot/vmlinuz-" .. kernels[i] .. + " root=UUID=" .. uuid .. " ro" + + if grub.file_exist (root .. "boot/initrd-" .. + kernels[i] .. ".img") then + initrd = "\ninitrd /boot/initrd-" .. kernels[i] .. ".img" + elseif grub.file_exist (root .. "boot/initrd.img-" .. kernels[i]) then + initrd = "\ninitrd /boot/initrd.img-" .. kernels[i] + elseif grub.file_exist (root .. "boot/initrd-" .. kernels[i]) then + initrd = "\ninitrd /boot/initrd-" .. kernels[i] + else + initrd = "" + end + + grub.add_menu (source .. initrd, title) + grub.add_menu (source .. " single" .. initrd, + title .. " (single-user mode)") + end + return 0 + end + end + + if title == nil then + local partition = string.match (device, ".*,(%d+)") + + if (partition ~= nil) and (tonumber (partition) > 4) then + return 0 + end + + title = "Other OS" + end + + grub.add_menu (source, title) + return 0 +end + +grub.enum_device (enum_device) --- grub2-1.97~beta4.orig/debian/grub.d/05_debian_theme +++ grub2-1.97~beta4/debian/grub.d/05_debian_theme @@ -0,0 +1,51 @@ +#!/bin/bash -e + +source /usr/lib/grub/grub-mkconfig_lib + +set_mono_theme() +{ + cat << EOF +set menu_color_normal=white/black +set menu_color_highlight=black/white +EOF +} + +# check for usable backgrounds +use_bg=false +if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then + for i in {/boot/grub,/usr/share/images/desktop-base}/moreblue-orbit-grub.{png,tga} ; do + if is_path_readable_by_grub $i ; then + bg=$i + case ${bg} in + *.png) reader=png ;; + *.tga) reader=tga ;; + *.jpg|*.jpeg) reader=jpeg ;; + esac + if test -e /boot/grub/${reader}.mod ; then + echo "Found Debian background: `basename ${bg}`" >&2 + use_bg=true + break + fi + fi + done +fi + +# set the background if possible +if ${use_bg} ; then + prepare_grub_to_access_device `${grub_probe} --target=device ${bg}` + cat << EOF +insmod ${reader} +if background_image `make_system_path_relative_to_its_root ${bg}` ; then + set color_normal=black/black + set color_highlight=magenta/black +else +EOF +fi + +# otherwise, set a monochromatic theme for Ubuntu +if ${use_bg} ; then + set_mono_theme | sed -e "s/^/ /g" + echo "fi" +else + set_mono_theme +fi --- grub2-1.97~beta4.orig/debian/po/fi.po +++ grub2-1.97~beta4/debian/po/fi.po @@ -0,0 +1,146 @@ +msgid "" +msgstr "" +"Project-Id-Version: grub2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2008-11-02 20:36+0200\n" +"Last-Translator: Esko Arajärvi \n" +"Language-Team: Finnish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Finnish\n" +"X-Poedit-Country: FINLAND\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Ladataanko ketjutettuna tiedostosta menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"GRUBin päivityskomentosarjat ovat löytäneet vanhoja GRUB-asetuksia " +"tiedostosta /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Järjestelmässä olevan vanhan GRUB-version korvaamiseksi on suositeltavaa " +"muokata tiedostoa /boot/grub/menu.lst siten, että GRUB 2 ladataan olemassa " +"olevista vanhoista GRUB-asetuksista. Tämä voidaan tehdä automaattisesti nyt." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"On suositeltavaa, että hyväksyt GRUB 2:n ketjutetun lataamisen tiedostosta " +"menu.lst ja varmistat, että uudet GRUB 2 -asetukset toimivat, ennen kuin " +"asennat ne pääkäynnistyslohkoon (MBR)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Kun haluat asentaa GRUB 2:n latautumaan suoraan pääkäynnistyslohkosta, voit " +"joka tapauksessa tehdä sen ajamalla pääkäyttäjänä seuraavan komennon:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linuxin komentorivi:" + +#. Type: string +#. Description +#: ../templates.in:1001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"GRUB Legacyn tiedoston menu.lst parametrista ”kopt” löydettiin seuraava " +"Linuxin komentorivi. Varmista, että se on oikea ja muuta sitä tarvittaessa." + +#. Type: string +#. Description +#: ../templates.in:2001 +#, fuzzy +#| msgid "Linux command line:" +msgid "Linux default command line:" +msgstr "Linuxin komentorivi:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD command line:" +msgstr "Linuxin komentorivi:" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"GRUB Legacyn tiedoston menu.lst parametrista ”kopt” löydettiin seuraava " +"Linuxin komentorivi. Varmista, että se on oikea ja muuta sitä tarvittaessa." + +#. Type: string +#. Description +#: ../templates.in:4001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD default command line:" +msgstr "Linuxin komentorivi:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" --- grub2-1.97~beta4.orig/debian/po/nl.po +++ grub2-1.97~beta4/debian/po/nl.po @@ -0,0 +1,141 @@ +# translation of grub2.pot to Dutch +# Copyright (C) 2008-2009 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the grub2 package. +# +# Paul Gevers , 2008-2009. +msgid "" +msgstr "" +"Project-Id-Version: grub2_1.96+20099829_nl\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-09-01 22:46+0100\n" +"Last-Translator: Paul Gevers \n" +"Language-Team: Dutch \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Doorschakelen vanuit menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"GRUB's opwaardeerscripts hebben een oude-stijl GRUB opstelling in /boot/grub " +"gedetecteerd." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Om de oude-stijl versie van GRUB op uw systeem te vervangen wordt het " +"aangeraden om het /boot/grub/menu.lst bestand zo te laten aanpassen dat naar " +"GRUB2 wordt doorgeschakeld (chainloading) vanuit uw bestaande oude-stijl " +"GRUB opstelling. Deze stap kan nu automatisch worden uitgevoerd." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"U wordt aangeraden om het doorschakelen van GRUB2 vanuit menu.lst te " +"accepteren, en daarna te verifiëren dat uw nieuwe GRUB2 opstelling werkt " +"voordat u het in de MBR (Master Boot Record) installeert." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Waar u ook voor kiest, als u GRUB2 direct in de MBR wilt laden kunt u dat " +"doen door het volgende commando uit te voeren (met beheerdersrechten (root)):" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linux-commandoregel:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"De volgende Linux-commandoregel is gebaseerd op /etc/default/grub of op de " +"'kopt'-parameter gevonden in het menu.lst bestand van de oude-stijl GRUB. " +"Wilt u deze op correctheid controleren en indien nodig aanpassen?" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Standaard Linux-commandoregel:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"De volgende regel zal, behalve in de herstelmodus, gebruikt worden voor de " +"Linux parameters in de standaard menuoptie." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "kFreeBSD-commandoregel:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"De volgende kFreeBSD-commandoregel is gebaseerd /etc/default/grub of op de " +"'kopt'-parameter gevonden in het menu.lst bestand van de oude-stijl GRUB. " +"Wilt u deze op correctheid controleren en indien nodig aanpassen?" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Standaard kFreeBSD-commandoregel:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"De volgende regel zal, behalve in de herstelmodus, gebruikt worden voor de " +"kFreeBSD parameters in de standaard menuoptie." --- grub2-1.97~beta4.orig/debian/po/ar.po +++ grub2-1.97~beta4/debian/po/ar.po @@ -0,0 +1,138 @@ +# translation of grub.ar.po to Arabic +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Ossama M. Khayat , 2008, 2009. +msgid "" +msgstr "" +"Project-Id-Version: grub.ar\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-31 13:11+0300\n" +"Last-Translator: Ossama M. Khayat \n" +"Language-Team: Arabic \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "تفعيل التحميل التسلسلي من menu.lst؟" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "عثرت بريمجيات ترقية GRUB على إعداد سابق في /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"لتستبدل النسخة السابقة من GRUB في نظامك، يُستحسن تعديل الملف /boot/grub/menu." +"lst لتحميل GRUB 2 تسلسلياً من إعداد GRUB السابق. ويمكن تنفيذ هذه الخطوة " +"تلقائياً الآن." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"يُستحسن أن تقبل التحميل التسلسلي لمدير الإقلاع GRUB من خلال الملف menu.lst، " +"وتحقق من أن إعداد GRUB 2 صالح لاستخدامك، قبل أن تُبّته مباشرة على سجل الإقلاع " +"الرئيسي MBR الخاص بك." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"في أي من الحالتين، متى ما أردت تحميل GRUB 2 مباشرة من سجل الإقلاع الرئيسي " +"MBR، يمكنك ذلك بإصدار الأمر التالي كمُستخدم root:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "سطر أوامر لينكس:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"سطر أوامر لينكس التالي تم استخراجه من /etc/default/grub أو\n" +"مُعطى `kopt' في ملف menu.lst الخاص بحزمة GRUB القديمة. رجاءً تحقق من\n" +"صحته وقم بتعديله إن كانت هناك ضرورة." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "سطر أوامر لينكس الافتراضي:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"سيتم استخدام سلسلة الحروف التالية كمُعطيات لتشغيل النظام لمُدخل القائمة\n" +"الافتراضي ولكن ليس لوضع الإنقاذ." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "سطر أوامر KFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"سطر أوامر KFreeBSD التالي تم استخراجه من /etc/default/grub أو\n" +"مُعطى `kopt' في ملف menu.lst الخاص بحزمة GRUB القديمة. رجاءً تحقق من صحته وقم " +"بتعديله إن كانت هناك ضرورة." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "سطر أوامر KFreeBSD الافتراضي:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"سيتم استخدام النص التالي كمُعطى KFreeBSD لمُدخل القائمة\n" +"الافتراضي ولكن ليس لوضع الإنقاذ." --- grub2-1.97~beta4.orig/debian/po/zh_TW.po +++ grub2-1.97~beta4/debian/po/zh_TW.po @@ -0,0 +1,140 @@ +# Copyright (C) 2009 Tetralet +# This file is distributed under the same license as the grub2 package. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-02-02 12:05+0800\n" +"Last-Translator: Tetralet \n" +"Language-Team: Debian-user in Chinese [Big5] \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "?????? menu.list ? chainload ???" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "GRUB ?????? /boot/grub ???? GRUB ? Legacy ???" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"?????????? Legacy ?? GRUB,????? /boot/grub/menu.lst ?????? GRUB Legacy ???? " +"chainload ????? GRUB 2??????????????" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"???? GRUB 2 ??? MBR(??????)??,??????? menu.lst ??? chainload ????? GRUB " +"2,?????? GRUB 2 ?????????" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "??????????,???? GRUB 2 ??? MBR ??????,???(? root ??)???????:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linux ???:" + +#. Type: string +#. Description +#: ../templates.in:1001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"??? Linux ????? `kopt' ??? GRUB Legacy ? menu.lst ???????????????,??????????" + +#. Type: string +#. Description +#: ../templates.in:2001 +#, fuzzy +#| msgid "Linux command line:" +msgid "Linux default command line:" +msgstr "Linux ???:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD command line:" +msgstr "Linux ???:" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"??? Linux ????? `kopt' ??? GRUB Legacy ? menu.lst ???????????????,??????????" + +#. Type: string +#. Description +#: ../templates.in:4001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD default command line:" +msgstr "Linux ???:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" --- grub2-1.97~beta4.orig/debian/po/fr.po +++ grub2-1.97~beta4/debian/po/fr.po @@ -0,0 +1,144 @@ +# translation of fr.po to French +# Translation of grub2 debconf templates to French +# Copyright (C) 2008 Christian Perrier +# This file is distributed under the same license as the grub2 package. +# +# Christian Perrier , 2007, 2008, 2009. +msgid "" +msgstr "" +"Project-Id-Version: fr\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 15:58+0200\n" +"Last-Translator: Christian Perrier \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Faut-il enchaîner le chargement depuis menu.lst ?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "Une installation standard de GRUB a été détectée dans /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Afin de remplacer cette installation, il est recommandé de modifier /boot/" +"grub/menu.lst pour enchaîner le chargement de GRUB 2 depuis l'installation " +"standard de GRUB (« chainload »). Veuillez choisir si vous souhaitez " +"effectuer cette modification." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Il est recommandé de choisir cette option pour pouvoir confirmer le bon " +"fonctionnement de GRUB 2 avant de l'installer directement sur le secteur " +"d'amorçage (MBR : « Master Boot Record »)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Dans tous les cas, pour charger GRUB 2 directement depuis le secteur " +"d'amorçage, vous devrez utiliser la commande suivante avec les privilèges du " +"superutilisateur :" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Ligne de commande de Linux :" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La ligne de commande de Linux suivante a été récupérée via le fichier /etc/" +"default/grub ou le paramètre « kopt » du fichier menu.lst utilisé par la " +"version originelle de GRUB. Veuillez contrôler qu'elle est correcte et la " +"modifier si nécessaire." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Ligne de commande par défaut de Linux :" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"Les paramètres indiqués seront utilisés pour le noyau Linux de l'entrée de " +"menu par défaut mais pas pour le mode de secours." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Ligne de commande de kFreeBSD :" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La ligne de commande de kFreeBSD suivante a été récupérée via le fichier /" +"etc/default/grub ou le paramètre « kopt » du fichier menu.lst utilisé par la " +"version originelle de GRUB. Veuillez contrôler qu'elle est correcte et la " +"modifier si nécessaire." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Ligne de commande par défaut de kFreeBSD :" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"Les paramètres indiqués seront utilisés pour le noyau kFreeBSD de l'entrée " +"de menu par défaut mais pas pour le mode de secours." --- grub2-1.97~beta4.orig/debian/po/de.po +++ grub2-1.97~beta4/debian/po/de.po @@ -0,0 +1,140 @@ +# Translation of grub2 debconf templates to German +# Copyright (C) Helge Kreutzmann , 2007-2009. +# This file is distributed under the same license as the grub2 package. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2 1.96+20090829-2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 21:42+0200\n" +"Last-Translator: Helge Kreutzmann \n" +"Language-Team: de \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Chainload (Kettenladen) aus menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Die Upgrade-Skripte von GRUB haben eine GRUB Legacy-Installation in /boot/" +"grub erkannt." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Um die Legacy-Version von GRUB auf Ihrem System zu ersetzen, wird empfohlen, " +"dass /boot/grub/menu.lst angepasst wird, so dass GRUB 2 aus Ihrer " +"existierenden GRUB Legacy-Einrichtung heraus geladen wird. Dieser Schritt " +"kann jetzt automatisch vollzogen werden." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Es wird empfohlen, dass Sie dem Chainloading von GRUB 2 aus der menu.lst " +"zustimmen und berprfen, dass die GRUB 2-Installation fr Sie " +"funktioniert, bevor Sie diese direkt in Ihren MBR (Master Boot Record) " +"installieren." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Auf jeden Fall knnen Sie den folgenden Befehl (als root) eingeben, wenn Sie " +"mchten, dass GRUB 2 direkt vom MBR geladen wird:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linux-Kommandozeile:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Die folgende Linux-Kommandozeile wurde aus /etc/default/grub oder dem " +"Parameter kopt in GRUB Legacys menu.lst extrahiert. Bitte berprfen Sie, " +"ob diese korrekt ist und passen Sie sie falls notwendig an." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Linux Standard-Kommandozeile:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"Die folgende Zeichenkette wird als Linux-Parameter fr den " +"Standardmeneintrag, nicht aber fr den Rettungsmodus verwandt." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "kFreeBSD-Kommandozeile:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Die folgende kFreeBSD-Kommandozeile wurde aus /etc/default/grub oder dem " +"Parameter kopt in GRUB Legacys menu.lst extrahiert. Bitte berprfen Sie, " +"ob diese korrekt ist und passen Sie sie falls notwendig an." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "kFreeBSD Standard-Kommandozeile:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"Die folgende Zeichenkette wird als kFreeBSD-Parameter fr den " +"Standardmeneintrag, nicht aber fr den Rettungsmodus verwandt." --- grub2-1.97~beta4.orig/debian/po/ast.po +++ grub2-1.97~beta4/debian/po/ast.po @@ -0,0 +1,140 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 15:50+0100\n" +"Last-Translator: Marcos \n" +"Language-Team: Asturian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "¿Cadena de carga dende menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"El scripts d'actualización GRUB detectó una configuración GRUB Legacy en /" +"boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Col fin de camudar la versión Legacy de GRUB nel to sistema, ye recomendable " +"que /boot/grub/menu.lst seya axustáu a la cadena de carga GRUB 2 dende la to " +"configuración Legacy GRUB existente. Esti pasu puede ser fechu " +"automáticamente agora." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Ye recomendable que aceptes la cadena de carga GRUB 2 dende'l menu.lst, y " +"compruebes que la to nueva configuración de GRUB 2 ye funcional pa ti, " +"anantes de que lo instales directamente nel to MBR (Master Boot Record)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"En cualisquier casu, cuando quieras que GRUB 2 seya cargáu directamente " +"dende'l MBR, puedes facelo col siguiente comandu (como root):" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linia comandos Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La siguiente llinia de comandu Linux fue estrayía dende /etc/default/grub o " +"del parámetru `kopt' nel menú Legacy GRUB menu.lst. Por favor, comprueba que " +"ye correuto, y modificalo si ye necesario." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Linia comandos por defeutu de Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"La siguiente cadena será usada como parámetros Linux pa la entrada del menú " +"por defeutu, pero non pal mou recuperación." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Linia comandos kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La siguiente llinia de comandu kFreeBSD fue estrayía dende /etc/default/grub " +"o del parámetru `kopt' nel menú Legacy GRUB menu.lst. Por favor, comprueba " +"que ye correuto, y modificalo si ye necesario." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Llínia comandos por defeutu kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"La siguiente cadena será usada cómo parametros kFreeBSD pa la entrada del " +"menú por defeutu, pero non pal mou recuperación." --- grub2-1.97~beta4.orig/debian/po/sv.po +++ grub2-1.97~beta4/debian/po/sv.po @@ -0,0 +1,143 @@ +# translation of grub2_sv.po to Swedish +# Swedish translation for grub2. +# Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +# This file is distributed under the same license as the grub2 package. +# +# Daniel Nylander , 2007. +# Martin Ågren , 2008, 2009. +msgid "" +msgstr "" +"Project-Id-Version: grub2_sv\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-09-02 20:53+0200\n" +"Last-Translator: Martin Ågren \n" +"Language-Team: Swedish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Kedjeladda från menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"GRUB:s uppgraderingsskript har upptäckt en gammal GRUB-inställning i /boot/" +"grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Om du vill ersätta den gamla versionen av GRUB i systemet, rekommenderas " +"att /boot/grub/menu.lst justeras till att kedjeladda GRUB 2 från din " +"existerande, gamla GRUB-inställning. Detta steg kan nu utföras automatiskt." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Det rekommenderas att GRUB 2 kedjeladdas från menu.lst så att det kan " +"säkerställas att den nya GRUB 2-inställningen fungerar innan den installeras " +"direkt till huvudstartsektorn." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"När GRUB 2 ska laddas direkt från huvudstartsektorn, kan detta åstadkommas " +"genom att (som root) köra följande kommando:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Kommandorad för Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Följande Linux-kommandorad hämtades från /etc/default/grub eller 'kopt'-" +"parametern i gamla GRUB:s menu.lst. Verifiera att den är korrekt och " +"modifiera den om nödvändigt." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Standardkommandorad för Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"Följande sträng kommer användas som Linux-parametrar för standardmenyvalet " +"men inte för återhämtningsläge (eng. recovery)." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Kommandorad för kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Följande kFreeBSD-kommandorad hämtades från /etc/default/grub eller 'kopt'-" +"parametern i gamla GRUB:s menu.lst. Verifiera att den är korrekt och " +"modifiera den om nödvändigt." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Standardkommandorad för kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"Följande sträng kommer användas som Linux-parametrar för standardmenyvalet " +"men inte för återhämtningsläge (eng. recovery)." --- grub2-1.97~beta4.orig/debian/po/be.po +++ grub2-1.97~beta4/debian/po/be.po @@ -0,0 +1,178 @@ +# Belarusian translation of grub2 templates +# Copyright (C) 2009 respective translators (see below) +# This file is distributed under the same license as the grub2 package. +# Hleb Rubanau , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: be\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-31 10:50+0200\n" +"Last-Translator: Hleb Rubanau \n" +"Language-Team: Debian Belarusian (Official spelling) \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Ланцуговая загрузка з menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Скрыпты абнаўлення GRUB выявілі папярэднюю версію GRUB, усталяваную ў /boot/" +"grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Каб замяніць папярэднюю версію GRUB у Вашай сістэме, раім выправіць файл /" +"boot/grub/menu.lst такім чынам, каб GRUB 2 загружаўся праз механізм " +"ланцуговай загрузкі (chainload) з існуючай папярэдняй версіі GRUB. Зараз " +"можна зрабіць гэтую наладку аўтаматычна. " + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Раім абраць опцыю ланцуговай загрузкі GRUB 2 з menu.lst, каб праверыць, ці " +"прыдатны для Вас нанова ўсталяваны GRUB 2, перад тым як усталёўваць яго " +"непасрэдна ў галоўны загрузачны запіс (MBR, Master Boot Record)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Калі ж Вы хочаце, каб GRUB 2 запускаўся непасрэдна з MBR, дастаткова " +"запусціць з правамі карыстальніка root наступную каманду:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "update-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Радок камандаў для ядра Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Гэты радок камандаў для ядра Linux узяты з файлу /etc/default/grub або з " +"параметру `kopt' у файле наладак (menu.lst) папярэдняй версіі GRUB. Калі " +"ласка, пераканайцеся, што каманды запісаныя правільна, або папраўце іх, калі " +"трэба." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Прадвызначаны радок камандаў для ядра Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"Наступны радок будзе выкарыстаны ў якасці параметраў ядра Linux для " +"прадвызначанага пункту меню (але не для рэжыму аднаўлення)." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Радок камандаў для ядра kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Гэты радок камандаў для kFreeBSD узяты з файлу /etc/default/grub або з " +"параметру `kopt' у файле наладак (menu.lst) папярэдняй версіі GRUB. Калі " +"ласка, пераканайцеся, што каманды запісаныя правільна, або папраўце іх, калі " +"трэба." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Прадвызначаны радок камандаў для ядра kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"Наступны радок будзе выкарыстаны ў якасці параметраў ядра kFreeBSD для " +"прадвызначанага пункту меню (але не для рэжыму аднаўлення)." + +#~ msgid "GRUB 1.95 numbering scheme transition" +#~ msgstr "Змена схемы нумарацыі GRUB 1.95" + +#~ msgid "" +#~ "As of version 1.95, GRUB 2 has changed its numbering scheme. Partitions " +#~ "are now counted starting from 1 rather than 0. This is to make it " +#~ "consistent with device names of Linux and the other kernels used in " +#~ "Debian. For example, when using Linux as the kernel, \"(hd0,1)\" refers " +#~ "to the same partition as the /dev/sda1 device node." +#~ msgstr "" +#~ "Схема нумарацыі ў GRUB 2 змянілася ў параўнанні з версіяй 1.95 . Зараз " +#~ "падзелы дыску адлічваюцца пачынаючы з 1 замест 0. Гэта зроблена, каб " +#~ "адпавядаць назвам прыладаў у Linux і іншых ядрах, якія выкарыстоўваюцца ў " +#~ "Debian. Напрыклад, калі ў якасці ядра выкарыстоўваецца Linux, радок " +#~ "\"(hd0,1)\" датычыцца таго самага падзелу дыску, як і файл прылады /dev/" +#~ "sda1." + +#~ msgid "" +#~ "Because of this, there's a chance your system becomes unbootable if " +#~ "update-grub(8) is run before GRUB is updated, generating a grub.cfg file " +#~ "that your installed GRUB won't yet be able to parse correctly. To ensure " +#~ "your system will be able to boot, you have to:" +#~ msgstr "" +#~ "З гэтай прычыны Ваша сістэма можа стаць няздольнай да загрузкі, калі " +#~ "праграма update-grub(8), запушчаная да абнаўлення GRUB, стварыла файл " +#~ "grub.cfg, які немагчыма карэктна апрацаваць усталяваным GRUB. Каб " +#~ "пераканацца, што Ваша сістэма здольная да загрузкі, варта: " + +#~ msgid "" +#~ " - Reinstall GRUB (typically, by running grub-install).\n" +#~ " - Rerun update-grub to generate a new grub.cfg." +#~ msgstr "" +#~ " - Пераўсталяваць GRUB (звычайна, праз запуск grub-install).\n" +#~ " - Перазапусціць update-grub, каб стварыць новы grub.cfg." --- grub2-1.97~beta4.orig/debian/po/ru.po +++ grub2-1.97~beta4/debian/po/ru.po @@ -0,0 +1,144 @@ +# translation of ru.po to Russian +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Yuri Kozlov , 2007, 2008. +# Yuri Kozlov , 2009. +msgid "" +msgstr "" +"Project-Id-Version: grub2 1.96+1.96+20090829-2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 19:10+0400\n" +"Last-Translator: Yuri Kozlov \n" +"Language-Team: Russian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" +"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Включить загрузку по цепочке (chainload) в menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Сценарии обновления обнаружили установку GRUB предыдущего поколения в /boot/" +"grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Чтобы заменить в системе версию GRUB предыдущего поколения, рекомендуется " +"исправить /boot/grub/menu.lst так, чтобы GRUB 2 загружался по цепочке из " +"существующей установки GRUB предыдущего поколения. Это может быть сделано " +"автоматически прямо сейчас." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Рекомендуется ответить утвердительно и проверить, что новая настройка GRUB 2 " +"работает так как нужно, перед тем как устанавливать её непосредственно в MBR " +"(главную загрузочную запись)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"В любом случае, если вы хотите, чтобы GRUB 2 загружался непосредственно из " +"MBR, выполните следующую команду (имея права суперпользователя):" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Строка команд Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Представленная ниже строка команд Linux была извлечена из /etc/default/grub " +"или параметра `kopt' старого файла GRUB menu.lst. Проверьте, что всё " +"правильно, или измените её, если требуется." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Строка команд Linux по умолчанию:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"Данная строка будет использоваться в качестве параметров Linux в меню в " +"записи по умолчанию, кроме режима восстановления." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Строка команд kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Представленная ниже строка команд kFreeBSD была извлечена из /etc/default/" +"grub или параметра `kopt' старого файла GRUB menu.lst. Проверьте, что всё " +"правильно, или измените её, если требуется." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Строка команд kFreeBSD по умолчанию:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"Данная строка будет использоваться в качестве параметров kFreeBSD в меню в " +"записи по умолчанию, кроме режима восстановления." --- grub2-1.97~beta4.orig/debian/po/templates.pot +++ grub2-1.97~beta4/debian/po/templates.pot @@ -0,0 +1,120 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" --- grub2-1.97~beta4.orig/debian/po/es.po +++ grub2-1.97~beta4/debian/po/es.po @@ -0,0 +1,202 @@ +# grub2 po-debconf translation to Spanish +# Copyright (C) 2007, 2009 Software in the Public Interest +# This file is distributed under the same license as the grub2 package. +# +# Changes: +# - Initial translation +# Maria Germana Oliveira Blazetic, 2007 +# +# - Updates +# Gary Ariel Sandi Vigabriel , 2009 +# Francisco Javier Cuadrado , 2009 +# +# Traductores, si no conocen el formato PO, merece la pena leer la +# documentación de gettext, especialmente las secciones dedicadas a este +# formato, por ejemplo ejecutando: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Equipo de traducción al español, por favor lean antes de traducir +# los siguientes documentos: +# +# - El proyecto de traducción de Debian al español +# http://www.debian.org/intl/spanish/ +# especialmente las notas y normas de traducción en +# http://www.debian.org/intl/spanish/notas +# +# - La guía de traducción de po's de debconf: +# /usr/share/doc/po-debconf/README-trans +# o http://www.debian.org/intl/l10n/po-debconf/README-trans +# +msgid "" +msgstr "" +"Project-Id-Version: grub2 1.96+20090829-2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 19:42+0100\n" +"Last-Translator: Francisco Javier Cuadrado \n" +"Language-Team: Debian l10n Spanish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "¿Desea realizar la carga en cadena desde el archivo «menu.lst»?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Los scripts de actualización han detectado en «/boot/grub» una configuración " +"heredada de una versión anterior de GRUB." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Para reemplazar la versión anterior de GRUB en el sistema, se recomienda que " +"se configure «/boot/grub/menu.lst» para que cargue en cadena GRUB 2 a partir " +"de la configuración heredada de GRUB. Este paso se debería hacer de forma " +"automática." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Antes de instalar GRUB 2 directamente en el MBR («Master Boot Record») se " +"recomienda que acepte cargarlo en cadena desde el archivo «menu.lst» y que " +"verifique que puede utilizar la nueva configuración de GRUB 2." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"En cualquier caso, cuando quiera que GRUB 2 se cargue directamente desde el " +"MBR, puede hacerlo ejecutando (como usuario «root») la siguiente orden:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linea de órdenes de Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La siguiente linea de órdenes de Linux se extrajo del archivo «/etc/default/" +"grub» o del parámetro «kopt» en el archivo «menu.lst» de la versión anterior " +"de GRUB. Por favor, compruebe que esto es correcto y modifíquelo si es " +"necesario." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Linea de órdenes predeterminada de Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"La siguiente cadena se utilizará como parámetros de Linux para la entrada " +"predeterminada del menú pero no para el modo de recuperación." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Linea de órdenes de kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La siguiente linea de órdenes de kFreeBSD se extrajo del archivo «/etc/" +"default/grub» o del parámetro «kopt» en el archivo «menu.lst» de la versión " +"anterior de GRUB. Por favor, compruebe que esto es correcto y modifíquelo si " +"es necesario." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Linea de órdenes predeterminada de kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"La siguiente cadena se utilizará como parámetros de kFreeBSD para la entrada " +"predeterminada del menú pero no para el modo de recuperación." + +#~ msgid "GRUB 1.95 numbering scheme transition" +#~ msgstr "Esquema de transición numérica de GRUB 1.95" + +#~ msgid "" +#~ "As of version 1.95, GRUB 2 has changed its numbering scheme. Partitions " +#~ "are now counted starting from 1 rather than 0. This is to make it " +#~ "consistent with device names of Linux and the other kernels used in " +#~ "Debian. For example, when using Linux as the kernel, \"(hd0,1)\" refers " +#~ "to the same partition as the /dev/sda1 device node." +#~ msgstr "" +#~ "GRUB 2 ha cambiado el esquema de numeración, como en la versión 1.95. " +#~ "Ahora las particiones comienzan en el número 1 en vez de en el número 0. " +#~ "Esto sirve para hacerlo consistente con los nombres de dispositivos de " +#~ "Linux y otros núcleos que se usan en Debian. Por ejemplo, cuando se usa " +#~ "Linux como núcleo, «(hd0, 1)» se refiere a la misma partición que el " +#~ "dispositivo «/dev/sda1»." + +#~ msgid "" +#~ "Because of this, there's a chance your system becomes unbootable if " +#~ "update-grub(8) is run before GRUB is updated, generating a grub.cfg file " +#~ "that your installed GRUB won't yet be able to parse correctly. To ensure " +#~ "your system will be able to boot, you have to:" +#~ msgstr "" +#~ "Por este motivo, existe la posibilidad de que su sistema no sea capaz de " +#~ "arrancar si se ejecuta update-grub(8) antes de actualizar GRUB, ya que se " +#~ "generaría un archivo «grub.cfg» que la versión instalada de GRUB no podría " +#~ "leer correctamente. Para asegurarse de que el sistema arrancará, debe:" + +#~ msgid "" +#~ " - Reinstall GRUB (typically, by running grub-install).\n" +#~ " - Rerun update-grub to generate a new grub.cfg." +#~ msgstr "" +#~ " - Reinstalar GRUB (normalmente, ejecutando grub-install).\n" +#~ "- Volver a ejecutar update-grub para generar un nuevo archivo «grub.cfg»." --- grub2-1.97~beta4.orig/debian/po/ka.po +++ grub2-1.97~beta4/debian/po/ka.po @@ -0,0 +1,143 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 18:05+0400\n" +"Last-Translator: Aiet Kolkhi \n" +"Language-Team: Georgian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: georgian\n" +"X-Poedit-Country: GEORGIA\n" +"X-Poedit-SourceCharset: utf-8\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "გსურთ Chainload ჩატვირთვა menu.lst-დან?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"GRUB-ის განახლების სკრიფტები GRUB-ის ძველ ინსტალაციას გადააწყდა /boot/grub " +"მდებარეობაში." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"იმისათვის, რომ თქვენს სისტემაზე ჩანაცვლდეს ძველი GRUB-ის ინსტალაცია, " +"სასურველია /boot/grub/menu.lst ჩასწორდეს, რომ შეასრულოს GRUB 2-ის chainload " +"ჩატვირთვა თქვენი არსებული GRUB-ის ძველი ინსტალაციიდან. ეს საფეხური " +"შესაძლებელია ახლა შესრულდეს ავტომატურად." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"სასურველია მიიღოთ menu.lst-დან GRUB 2-ის chainload მეთოდით ჩატვირთვა, ასევე " +"გადაამოწმოთ, რომ თქვენი ახალი GRUB 2-ის ინსტალაცია ფუნქციონირებდეს, სანამ " +"მას პირდაპირ Master Boot Record (MBR)-ში ჩაწერდეთ." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"ნებისმიერ შემთხვევაში, როდესაც მოისურვებთ GRUB 2 პირდაპირ MBR-დან " +"ჩაიტვირთოს, ამისათვის გაუშვით შემდეგი ბრძანება (root პრივილეგიებით):" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "ლინუქსის ბრძანების სტრიქონი:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"ლინუქსის შემდეგი ბრძანება მოძიებულ იქნა /etc/default/grub-დან ან `kopt' " +"პარამეტრიდან ძველი GRUB-ის menu.lst-ში. გადაამოწმეთ, რომ იგი სწორია, ან " +"შეცვალეთ შესაბამისად." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "ლინუქსის სტანდარტული ბრძანების სტრიქონი:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"შემდეგი სტრიქონი გამოყენებულ იქნება როგორც ლინუქსის პარამეტრები მენიუს " +"სტანდარტული შენატანისათვის, მაგრამ არა აღდგენის რეჟიმისათვის." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "kFreeBSD ბრძანების სტრიქონი:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"შემდეგი kFreeBSD-ის ბრძანების სტრიქონი ამოღებულ იქნა /etc/default/grub-დან " +"ან `kopt' პარამეტრიდან ძველი GRUB-ის menu.lst-ში. გადაამოწმეთ, რომ იგი " +"სწორია, ან შეცვალეთ შესაბამისად." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "kFreeBSD-ის სტანდარტული ბრძანების სტრიქონი:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"შემდეგი სტრიქონი გამოყენებულ იქნება როგორც kFreeBSD-ს პარამეტრები მენიუს " +"სტანდარტული შენატანისათვის, მაგრამ არა აღდგენის რეჟიმისათვის." --- grub2-1.97~beta4.orig/debian/po/eu.po +++ grub2-1.97~beta4/debian/po/eu.po @@ -0,0 +1,152 @@ +# translation of eu.po to Basque +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Piarres Beobide , 2008. +# Iñaki Larrañaga Murgoitio , 2008, 2009. +msgid "" +msgstr "" +"Project-Id-Version: eu\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-04-04 14:29+0200\n" +"Last-Translator: Iñaki Larrañaga Murgoitio \n" +"Language-Team: Basque \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Kargatu menu.lst fitxategitik?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"GRUB eguneratzeko skriptek GRUB zahar baten konfigurazioa aurkitu dute /boot/" +"grub-en." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"GRUB zaharraren bertsioa behar bezala ordezkatzeko, gomendagarria da /boot/" +"grub/menu.lst doitzea GRUB 2 dagoeneko instalaturik duzun GRUB zaharraren " +"bidez kargatzeko. Urrats hau automatikoki egin daiteke orain." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Gomendagarria da GRUB 2 menu.lst bidez kargatzea onartzea, GRUB 2 " +"konfigurazioak zure beharrak betetzen dituela egiatzatzeko MBR-ran (Master " +"Boot Record) zuzenean instalatu aurretik." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Edozein kasutan, GRUB 2 zuzenean MBR-tik kargatzea nahi duzunean exekutatu " +"honako komandoa (root gisa):" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linux-eko komando-lerroa:" + +#. Type: string +#. Description +#: ../templates.in:1001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Linux-eko komando-lerro hau GRUB zaharraren menu.lst fitxategiko 'kopt' " +"parametrotik atera da. Egiaztatu zuzena dela, eta eraldatu behar izanez gero." + +#. Type: string +#. Description +#: ../templates.in:2001 +#, fuzzy +#| msgid "Linux command line:" +msgid "Linux default command line:" +msgstr "Linux-eko komando-lerroa:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD command line:" +msgstr "Linux-eko komando-lerroa:" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Linux-eko komando-lerro hau GRUB zaharraren menu.lst fitxategiko 'kopt' " +"parametrotik atera da. Egiaztatu zuzena dela, eta eraldatu behar izanez gero." + +#. Type: string +#. Description +#: ../templates.in:4001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD default command line:" +msgstr "Linux-eko komando-lerroa:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" --- grub2-1.97~beta4.orig/debian/po/pt.po +++ grub2-1.97~beta4/debian/po/pt.po @@ -0,0 +1,154 @@ +# Portuguese translation for grub2's debconf messages +# Copyright (C) 2007 Miguel Figueiredo +# This file is distributed under the same license as the grub2 package. +# Miguel Figueiredo , 2007. +# Ricardo Silva , 2008. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2 1.96+20081005-1\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2008-11-02 11:07+0000\n" +"Last-Translator: Ricardo Silva \n" +"Language-Team: Portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Carregar a partir do menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Os scripts de actualização do GRUB detectaram uma configuração do GRUB " +"Legacy em /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Para substituir a versão Legacy do GRUB no seu sistema, é recomendado que o /" +"boot/grub/menu.lst seja ajustado para carregar o GRUB 2 a partir da sua " +"configuração do GRUB Legacy existente. Este passo pode ser executado agora " +"automaticamente." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"É recomendado que aceite carregar o GRUB 2 a partir do menu.lst, e verifique " +"que a sua nova configuração do GRUB 2 está funcional, antes de o instalar " +"directamente no seu MBR (Master Boot Record)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Em qualquer dos casos, quando quiser que o GRUB 2 seja carregado " +"directamente a partir do MBR, pode fazê-lo correndo o seguinte comando (como " +"root):" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linha de comandos do Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"A linha de comandos do Linux que se segue foi obtida a partir do parâmetro " +"`kopt' no ficheiro menu.lst do GRUB Legacy. Por favor verifique que ela está " +"correcta, e modifique-a se necessário." + +#. Type: string +#. Description +#: ../templates.in:2001 +#, fuzzy +#| msgid "Linux command line:" +msgid "Linux default command line:" +msgstr "Linha de comandos do Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD command line:" +msgstr "Linha de comandos do Linux:" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"A linha de comandos do Linux que se segue foi obtida a partir do parâmetro " +"`kopt' no ficheiro menu.lst do GRUB Legacy. Por favor verifique que ela está " +"correcta, e modifique-a se necessário." + +#. Type: string +#. Description +#: ../templates.in:4001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD default command line:" +msgstr "Linha de comandos do Linux:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" --- grub2-1.97~beta4.orig/debian/po/cs.po +++ grub2-1.97~beta4/debian/po/cs.po @@ -0,0 +1,141 @@ +# Czech translation of grub2 debconf messages. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the grub2 package. +# Miroslav Kure , 2008, 2009 +# +msgid "" +msgstr "" +"Project-Id-Version: grub2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 18:47+0200\n" +"Last-Translator: Miroslav Kure \n" +"Language-Team: Czech \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Zavést přes menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Aktualizační skripty GRUBu rozpoznaly v /boot/grub nastavení pro předchozí " +"verzi GRUBu (tzv. GRUB Legacy)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Abyste na svém systému nahradili zastaralou verzi GRUBu, je doporučeno " +"upravit /boot/grub/menu.lst tak, aby zavedl GRUB 2 pomocí stávajícího GRUB " +"Legacy. Tento krok je nyní možné provést automaticky." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Před instalací GRUBu 2 přímo do MBR (Master Boot Record) se doporučuje " +"nejprve vyzkoušet zavedení GRUBu 2 skrze menu.lst a teprve po ověření, že " +"vše funguje očekávaným způsobem, zkusit instalaci do MBR." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Až se rozhodnete zavádět GRUB 2 přímo z MBR, stačí jako uživatel root " +"spustit příkaz:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Parametry pro Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Následující řádka s parametry pro Linux byla získána ze starého souboru menu." +"lst z parametru „kopt“ nebo ze souboru /etc/default/grub. Zkontrolujte " +"prosím, zda jsou parametry v pořádku a případně je upravte do požadované " +"podoby." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Výchozí parametry pro Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"Následující parametry pro Linux se použijí pro výchozí položku menu, ale ne " +"pro záchranný režim." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Parametry pro kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Následující řádka s parametry pro kFreeBSD byla získána ze starého souboru " +"menu.lst z parametru „kopt“ nebo ze souboru /etc/default/grub. Zkontrolujte " +"prosím, zda jsou parametry v pořádku a případně je upravte do požadované " +"podoby." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Výchozí parametry pro kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"Následující parametry pro kFreeBSD se použijí pro výchozí položku menu, ale " +"ne pro záchranný režim." --- grub2-1.97~beta4.orig/debian/po/ja.po +++ grub2-1.97~beta4/debian/po/ja.po @@ -0,0 +1,138 @@ +# Copyright (C) 2008-2009 GRUB Maintainers +# This file is distributed under the same license as the grub2 package. +# Hideki Yamane (Debian-JP) , 2008-2009. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2 1.96+20080724-4\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-10-05 02:07+0900\n" +"Last-Translator: Hideki Yamane (Debian-JP) \n" +"Language-Team: Japanese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "menu.lst から続けて起動 (チェーンロード)しますか?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"GRUB のアップグレードプログラムは GRUB Legacy の設定が /boot/grub にあるのを" +"検出しました。" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"システム中に存在している以前のバージョンの GRUB を置き換えるためには、/boot/" +"grub/menu.lst にある GRUB Legacy の設定を使って GRUB2 をチェーンロードするよ" +"うに調整するのがお勧めです。この作業は自動的に実行されます。" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"MBR (マスタブートレコード) に直接インストールする前に、GRUB 2 が menu.lst か" +"らチェーンロードするように設定し、新しい GRUB 2 の設定が動作するかどうかを確" +"認する事をお勧めします。" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"いずれにせよ、GRUB 2 を MBR から直接起動したくなった時いつでも (root にて) 以" +"下のコマンドを入力することで対応できます:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linux コマンド:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"以下の Linux のコマンドラインは /etc/default/grub か GRUB Legacy の menu.lst " +"上の「kopt」パラメータから取得されています。これが正しいものであるかを確認し" +"て、必要であれば修正してください。" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Linux デフォルトコマンドライン:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"以下の文字列はリカバリーモードではない通常のメニューエントリでの Linux パラ" +"メータとして使われます。" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "kFreeBSD コマンドライン:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"以下の kFreeBSD のコマンドラインは /etc/default/grub か GRUB Legacy の menu." +"lst 上の「kopt」パラメータから取得されています。これが正しいものであるかを確" +"認して、必要であれば修正してください。" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "kFreeBSD デフォルトコマンドライン:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"以下の文字列はリカバリーモードではない通常のメニューエントリでの kFreeBSD パ" +"ラメータとして使われます。" --- grub2-1.97~beta4.orig/debian/po/gl.po +++ grub2-1.97~beta4/debian/po/gl.po @@ -0,0 +1,128 @@ +# Galician translation of grub2's debconf templates +# This file is distributed under the same license as the grub2 package. +# Jacobo Tarrio , 2007, 2008. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2008-05-28 17:15+0100\n" +"Last-Translator: Jacobo Tarrio \n" +"Language-Team: Galician \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "¿Cargar en cadea desde menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Os scripts de actualización de GRUB detectaron unha configuración do GRUB " +"antigo en /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Para substituír a versión antiga de GRUB do sistema, recoméndase axustar /" +"boot/grub/menu.lst para cargar GRUB 2 en cadea desde a configuración " +"existente do GRUB antigo. Pódese realizar este paso automaticamente agora." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Recoméndase que acepte cargar en cadea GRUB 2 desde menu.lst, e que " +"verifique que a nova configuración de GRUB 2 funciona para vostede, antes de " +"instalalo directamente no MBR (rexistro mestre de inicio)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"En calquera caso, cando queira cargar GRUB 2 directamente desde o MBR, pode " +"facelo executando (coma administrador) a seguinte orde:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" --- grub2-1.97~beta4.orig/debian/po/it.po +++ grub2-1.97~beta4/debian/po/it.po @@ -0,0 +1,140 @@ +# Italian (it) translation of debconf templates for grub2 +# This file is distributed under the same license as the grub2 package. +# Luca Monducci , 2007-2009. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2 1.96+20090829-2 italian debconf templates\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-09-04 10:37+0200\n" +"Last-Translator: Luca Monducci \n" +"Language-Team: Italian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Effettuare il caricamento in cascata da menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Gli script di aggiornamento hanno rilevato una configurazione del vecchio " +"GRUB in /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Per sostituire la vecchia versione di GRUB sul proprio sistema, si " +"raccomanda di correggere il file /boot/grub/menu.lst in modo da caricare " +"GRUB 2 in cascata dalla versione di GRUB esistente. Questa modifica può " +"essere effettuata automaticamente adesso." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Si raccomanda di accettare il caricamento in cascata di GRUB 2 da menu.lst e " +"di verificare che la nuova configurazione di GRUB 2 sia adatta alle proprie " +"necessità prima di procedere con l'installazione diretta sul MBR (Master " +"Boot Record)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"In ogni caso, per caricare GRUB 2 direttamente dal MBR, è necessario " +"eseguire (da root) il seguente comando:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Riga di comando Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La seguente riga di comando Linux è stata estratta da /etc/default/grub " +"oppure dal parametro \"kopt\" presente nel file menu.lst del vecchio GRUB. " +"Controllare che sia corretta e modificarla se necessario." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Riga di comando Linux predefinita:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"Questa stringa verrà usata come parametri per Linux nella voce di menu " +"predefinita ma non nella modalità di ripristino." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Riga di comando kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La seguente riga di comando kFreeBSD è stata estratta da /etc/default/grub " +"oppure dal parametro \"kopt\" presente nel file menu.lst del vecchio GRUB. " +"Controllare che sia corretta e modificarla se necessario." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Riga di comando kFreeBSD predefinita:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"Questa stringa verrà usata come parametri per kFreeBSD nella voce di menu " +"predefinita ma non nella modalità di ripristino." --- grub2-1.97~beta4.orig/debian/po/ca.po +++ grub2-1.97~beta4/debian/po/ca.po @@ -0,0 +1,146 @@ +# translation of ca.po to catalan +# Catalan translation of grub2's debconf messages +# Copyright © 2009 Free Software Foundation, Inc. +# This file is distributed under the same license as the grub2 package. +# +# Jordi Mallach , 2009. +# Juan Andrés Gimeno Crespo , 2009. +msgid "" +msgstr "" +"Project-Id-Version: ca\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-09-02 18:12+0200\n" +"Last-Translator: Juan Andrés Gimeno Crespo \n" +"Language-Team: catalan \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Voleu carregar en cadena des del menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Els scripts d'actualització del GRUB han detectat una configuració del GRUB " +"Legacy en /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"A l'hora de reemplaçar la versió Legacy del GRUB que hi ha al sistema, és " +"recomanable que es modifique /boot/grub/menu.lst per a carregar el GRUB 2 en " +"cadena des de la vostra configuració del GRUB Legacy existent. Aquest pas es " +"pot dur a terme ara." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"És recomanable que accepteu la càrrega en cadena del GRUB 2 des del menu." +"lst, per a verificar que la nova configuració del GRUB 2 funciona " +"correctament, abans de que l'instal·leu directament al vostre registre " +"mestre d'arrencada (MBR)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"En qualsevol cas, quan vulgueu que es carregue el GRUB 2 directament des de " +"l'MBR, podeu fer-ho executant (com a root) l'ordre següent:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Línia d'ordres de Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La següent línia d'ordres de Linux ha sigut extreta de /etc/default/grub o " +"del paràmetre «kopt» del fitxer menu.lst del GRUB Legacy. Per favor verifique " +"que és correcta, i modifiqueu-la si és necessari." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Línia d'ordres de Linux per defecte:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"La següent cadena serà usada com a paràmetre Linux per al menú d'entrada per " +"defecte però no per al mode de recuperació." + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD command line:" +msgstr "Línia d'ordres de Linux:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"La següent línia d'ordres de kFreeBSD ha sigut extreta de /etc/default/grub " +"o del paràmetre «kopt» del fitxer menu.lst del GRUB Legacy. Per favor " +"verifique que és correcta, i modifiqueu-la si és necessari." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Línia d'ordres de kFreeBSD per defecte:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"La següent cadena serà usada com a paràmetre kFreeBSD per al menú d'entrada " +"per defecte però no per al mode de recuperació." --- grub2-1.97~beta4.orig/debian/po/ro.po +++ grub2-1.97~beta4/debian/po/ro.po @@ -0,0 +1,191 @@ +# translation of ro.po to Romanian +# Romanian translations for grub package +# Traducerea în limba română pentru pachetul grub. +# Copyright (C) 2007 THE grub'S COPYRIGHT HOLDER +# This file is distributed under the same license as the grub package. +# +# Eddy Petrișor , 2007,2008. +msgid "" +msgstr "" +"Project-Id-Version: ro\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2008-11-13 10:41+0200\n" +"Last-Translator: Eddy Petrișor \n" +"Language-Team: Romanian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < " +"20)) ? 1 : 2;\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Încărcare înlănțuită din menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Scripturile de înnoire ale lui GRUB au detectat în /boot/grub o configurație " +"pentru vechiul GRUB." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"Pentru a înlocui vechea versiune a lui GRUB, se recomandă modificarea lui /" +"boot/grub/menu.lst astfel încât GRUB 2 sa fie încărcat prin înlănțuire din " +"vechea configurare. Acest pas poate fi făcut chiar acum în mod automat." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"Este recomandat să acceptați înlănțuirea lui GRUB 2 din menu.lst și să " +"verificați că noua configurație pentru GRUB 2 funcționează, înainte de a o " +"instala în înregistrarea „Master Boot” (MBR)." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Oricum, atunci când veți dori ca GRUB 2 sa fie încărcat direct din MBR, " +"puteți rula (ca root) comanda următoare:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linia de comandă Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Această linie de comandă Linux a fost extrasă din parametrul „kopt” din " +"fișierul menu.lst al vechiului GRUB. Verificați corectitudinea acesteia și " +"corectați-o, dacă este nevoie." + +#. Type: string +#. Description +#: ../templates.in:2001 +#, fuzzy +#| msgid "Linux command line:" +msgid "Linux default command line:" +msgstr "Linia de comandă Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD command line:" +msgstr "Linia de comandă Linux:" + +#. Type: string +#. Description +#: ../templates.in:3001 +#, fuzzy +#| msgid "" +#| "The following Linux command line was extracted from the `kopt' parameter " +#| "in GRUB Legacy's menu.lst. Please verify that it is correct, and modify " +#| "it if necessary." +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"Această linie de comandă Linux a fost extrasă din parametrul „kopt” din " +"fișierul menu.lst al vechiului GRUB. Verificați corectitudinea acesteia și " +"corectați-o, dacă este nevoie." + +#. Type: string +#. Description +#: ../templates.in:4001 +#, fuzzy +#| msgid "Linux command line:" +msgid "kFreeBSD default command line:" +msgstr "Linia de comandă Linux:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" + +#~ msgid "GRUB 1.95 numbering scheme transition" +#~ msgstr "Tranziția la schema de numerotare pentru GRUB 1.95" + +#~ msgid "" +#~ "As of version 1.95, GRUB 2 has changed its numbering scheme. Partitions " +#~ "are now counted starting from 1 rather than 0. This is to make it " +#~ "consistent with device names of Linux and the other kernels used in " +#~ "Debian. For example, when using Linux as the kernel, \"(hd0,1)\" refers " +#~ "to the same partition as the /dev/sda1 device node." +#~ msgstr "" +#~ "Începând cu versiunea 1.95, GRUB 2 și-a schimbat schema de numerotare. " +#~ "Partițiile sunt acum numerotate începând de la 1 (în loc de 0). Acest " +#~ "lucru este consecvent cu numele de dispozitive ale Linux-ului și a altor " +#~ "nuclee folosite în Debian. De exemplu, când se folosește nucleul Linux, " +#~ "„(hd0,1)” se referă la aceiași partiție ca și nodul de dispozitiv /dev/" +#~ "sda1." + +#~ msgid "" +#~ "Because of this, there's a chance your system becomes unbootable if " +#~ "update-grub(8) is run before GRUB is updated, generating a grub.cfg file " +#~ "that your installed GRUB won't yet be able to parse correctly. To ensure " +#~ "your system will be able to boot, you have to:" +#~ msgstr "" +#~ "De aceea, există riscul ca sistemul să nu mai pornească dacă update-grub" +#~ "(8) este rulat înainte ca GRUB să fie actualizat, generând astfel un " +#~ "fișier grub.cfg pe care GRUB-ul instalat nu-l va putea încă analiza " +#~ "corect. Pentru a vă asigura că sistemul va putea porni, va trebui să:" + +#~ msgid "" +#~ " - Reinstall GRUB (typically, by running grub-install).\n" +#~ " - Rerun update-grub to generate a new grub.cfg." +#~ msgstr "" +#~ " - Reinstalați GRUB (în mod normal, prin rularea lui grub-install).\n" +#~ " - Rulați din nou update-grub pentru a genera un nou grub.cfg." --- grub2-1.97~beta4.orig/debian/po/pt_BR.po +++ grub2-1.97~beta4/debian/po/pt_BR.po @@ -0,0 +1,178 @@ +# grub2 Brazilian Portuguese translation +# Copyright (C) 2009 THE grub2'S COPYRIGHT HOLDER +# This file is distributed under the same license as the grub2 package. +# Flamarion Jorge , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: grub2 1.96\n" +"Report-Msgid-Bugs-To: grub2@packages.debian.org\n" +"POT-Creation-Date: 2009-08-30 17:54+0200\n" +"PO-Revision-Date: 2009-08-30 20:45-0300\n" +"Last-Translator: Flamarion Jorge \n" +"Language-Team: Brazilian Portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"pt_BR utf-8\n" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "Chainload from menu.lst?" +msgstr "Carregar em cadeia a partir do menu.lst?" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "GRUB upgrade scripts have detected a GRUB Legacy setup in /boot/grub." +msgstr "" +"Os scripts de atualização do GRUB detectaram uma configuração do GRUB Legado " +"em /boot/grub." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In order to replace the Legacy version of GRUB in your system, it is " +"recommended that /boot/grub/menu.lst is adjusted to chainload GRUB 2 from " +"your existing GRUB Legacy setup. This step may be automaticaly performed " +"now." +msgstr "" +"A fim de substituir a versão Legada do GRUB no seu sistema, é recomendável " +"que o /boot/grub/menu.lst seja ajustado para carregar em cadeia o GRUB 2 a " +"partir da sua configuração existente do GRUB Legado. Este passo pode ser " +"executado automaticamente agora." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"It's recommended that you accept chainloading GRUB 2 from menu.lst, and " +"verify that your new GRUB 2 setup is functional for you, before you install " +"it directly to your MBR (Master Boot Record)." +msgstr "" +"É recomendado que você aceite o carregamento em cadeia do GRUB 2 a partir do " +"menu.lst, e verifique que sua nova configuração do GRUB 2 está funcional " +"para você, antes de instalá-lo diretamente no seu MBR (\"Master Boot Record" +"\")." + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "" +"In either case, whenever you want GRUB 2 to be loaded directly from MBR, you " +"can do so by issuing (as root) the following command:" +msgstr "" +"Em todo caso, sempre que você quiser que o GRUB 2 seja carregado diretamente " +"do MBR, você pode fazê-lo (como root) através do seguinte comando:" + +#. Type: boolean +#. Description +#: ../grub-pc.templates.in:2001 +msgid "upgrade-from-grub-legacy" +msgstr "upgrade-from-grub-legacy" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "Linux command line:" +msgstr "Linha de comando Linux:" + +#. Type: string +#. Description +#: ../templates.in:1001 +msgid "" +"The following Linux command line was extracted from /etc/default/grub or the " +"`kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"A linha de comando Linux a seguir foi extraída de /etc/default/grub ou do " +"parâmetro `kopt' do menu.lst do Grub Legado. Por favor, verifique se ela " +"está correta, e modifique-a se necessário." + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "Linux default command line:" +msgstr "Linha de comando padrão Linux:" + +#. Type: string +#. Description +#: ../templates.in:2001 +msgid "" +"The following string will be used as Linux parameters for the default menu " +"entry but not for the recovery mode." +msgstr "" +"A seguinte string será usada como um parâmetro Linux para a entrada no menu " +"padrão, mas não para o modo de recuperação." + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "kFreeBSD command line:" +msgstr "Linha de comando kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:3001 +msgid "" +"The following kFreeBSD command line was extracted from /etc/default/grub or " +"the `kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is " +"correct, and modify it if necessary." +msgstr "" +"A linha de comando kFreeBSD a seguir foi extraída de /etc/default/grub ou do " +"parâmetro `kopt' do menu.lst do Grub Legado. Por favor, verifique se ela " +"está correta, e modifique-a se necessário." + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "kFreeBSD default command line:" +msgstr "Linha de comando padrão kFreeBSD:" + +#. Type: string +#. Description +#: ../templates.in:4001 +msgid "" +"The following string will be used as kFreeBSD parameters for the default " +"menu entry but not for the recovery mode." +msgstr "" +"A seguinte string será usada como um parâmetro kFreeBSD para a entrada no " +"menu padrão, mas não para o modo de recuperação." + +#~ msgid "GRUB 1.95 numbering scheme transition" +#~ msgstr "Transição do esquema de numeração do GRUB 1.95" + +#~ msgid "" +#~ "As of version 1.95, GRUB 2 has changed its numbering scheme. Partitions " +#~ "are now counted starting from 1 rather than 0. This is to make it " +#~ "consistent with device names of Linux and the other kernels used in " +#~ "Debian. For example, when using Linux as the kernel, \"(hd0,1)\" refers " +#~ "to the same partition as the /dev/sda1 device node." +#~ msgstr "" +#~ "A partir da versão 1.95, o GRUB 2 mudou seu esquema de numeração. Agora " +#~ "partições são contadas a partir de 1 em vez de 0. Isto é para torná-lo " +#~ "consistente com nomes de dispositivos do Linux e de outros kernels usados " +#~ "no Debian. Por exemplo, quando se usa o Linux como kernel, \"(hd0,1)\" se " +#~ "refere à mesma partição que o nó de dispositivo /dev/sda1." + +#~ msgid "" +#~ "Because of this, there's a chance your system becomes unbootable if " +#~ "update-grub(8) is run before GRUB is updated, generating a grub.cfg file " +#~ "that your installed GRUB won't yet be able to parse correctly. To ensure " +#~ "your system will be able to boot, you have to:" +#~ msgstr "" +#~ "Por causa disso, existe uma chance de seu sistema tornar-se não " +#~ "inicializável se o update-grub(8) for executado antes do GRUB ser " +#~ "atualizado, gerando um arquivo grub.cfg que o GRUB instalado ainda não " +#~ "será capaz de analisar corretamente. Para garantir que seu sistema será " +#~ "capaz de inicializar, você tem que:" + +#~ msgid "" +#~ " - Reinstall GRUB (typically, by running grub-install).\n" +#~ " - Rerun update-grub to generate a new grub.cfg." +#~ msgstr "" +#~ " - Reinstalar o GRUB (tipicamente, executando grub-install).\n" +#~ " - Re-executar update-grub para gerar um novo grub.cfg." --- grub2-1.97~beta4.orig/debian/po/POTFILES.in +++ grub2-1.97~beta4/debian/po/POTFILES.in @@ -0,0 +1,2 @@ +[type: gettext/rfc822deb] grub-pc.templates.in +[type: gettext/rfc822deb] templates.in --- grub2-1.97~beta4.orig/debian/patches/959_loopback_root.diff +++ grub2-1.97~beta4/debian/patches/959_loopback_root.diff @@ -0,0 +1,139 @@ +Upstream: http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00210.html +Description: If you set root after running loopback, any attempts to open + files on the loopback device resolve the loopback file name relative to the + *new* root, not the root at the time loopback was invoked, and so the above + recurses until it runs out of stack. This causes problems for Wubi. I think + it's fairly clear that only the root that was in place when you ran + loopback should be relevant to the loopback file name. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta2/disk/loopback.c grub2-1.97~beta2.new/disk/loopback.c +--- grub2-1.97~beta2/disk/loopback.c 2009-06-10 22:04:23.000000000 +0100 ++++ grub2-1.97~beta2.new/disk/loopback.c 2009-09-10 21:42:56.000000000 +0100 +@@ -28,6 +28,7 @@ + { + char *devname; + char *filename; ++ grub_file_t file; + int has_partitions; + struct grub_loopback *next; + }; +@@ -61,6 +62,7 @@ + /* Remove the device from the list. */ + *prev = dev->next; + ++ grub_file_close (dev->file); + grub_free (dev->devname); + grub_free (dev->filename); + grub_free (dev); +@@ -90,9 +92,6 @@ + if (! file) + return grub_errno; + +- /* Close the file, the only reason for opening it is validation. */ +- grub_file_close (file); +- + /* First try to replace the old device. */ + for (newdev = loopback_list; newdev; newdev = newdev->next) + if (grub_strcmp (newdev->devname, args[0]) == 0) +@@ -102,10 +101,12 @@ + { + char *newname = grub_strdup (args[1]); + if (! newname) +- return grub_errno; ++ goto fail; + + grub_free (newdev->filename); + newdev->filename = newname; ++ grub_file_close (newdev->file); ++ newdev->file = file; + + /* Set has_partitions when `--partitions' was used. */ + newdev->has_partitions = state[1].set; +@@ -116,13 +117,13 @@ + /* Unable to replace it, make a new entry. */ + newdev = grub_malloc (sizeof (struct grub_loopback)); + if (! newdev) +- return grub_errno; ++ goto fail; + + newdev->devname = grub_strdup (args[0]); + if (! newdev->devname) + { + grub_free (newdev); +- return grub_errno; ++ goto fail; + } + + newdev->filename = grub_strdup (args[1]); +@@ -130,9 +131,11 @@ + { + grub_free (newdev->devname); + grub_free (newdev); +- return grub_errno; ++ goto fail; + } + ++ newdev->file = file; ++ + /* Set has_partitions when `--partitions' was used. */ + newdev->has_partitions = state[1].set; + +@@ -141,6 +144,10 @@ + loopback_list = newdev; + + return 0; ++ ++fail: ++ grub_file_close (file); ++ return grub_errno; + } + + +@@ -159,7 +166,6 @@ + static grub_err_t + grub_loopback_open (const char *name, grub_disk_t disk) + { +- grub_file_t file; + struct grub_loopback *dev; + + for (dev = loopback_list; dev; dev = dev->next) +@@ -169,29 +175,17 @@ + if (! dev) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device"); + +- file = grub_file_open (dev->filename); +- if (! file) +- return grub_errno; +- + /* Use the filesize for the disk size, round up to a complete sector. */ +- disk->total_sectors = ((file->size + GRUB_DISK_SECTOR_SIZE - 1) ++ disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1) + / GRUB_DISK_SECTOR_SIZE); + disk->id = (unsigned long) dev; + + disk->has_partitions = dev->has_partitions; +- disk->data = file; ++ disk->data = dev->file; + + return 0; + } + +-static void +-grub_loopback_close (grub_disk_t disk) +-{ +- grub_file_t file = (grub_file_t) disk->data; +- +- grub_file_close (file); +-} +- + static grub_err_t + grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector, + grub_size_t size, char *buf) +@@ -233,7 +227,6 @@ + .id = GRUB_DISK_DEVICE_LOOPBACK_ID, + .iterate = grub_loopback_iterate, + .open = grub_loopback_open, +- .close = grub_loopback_close, + .read = grub_loopback_read, + .write = grub_loopback_write, + .next = 0 --- grub2-1.97~beta4.orig/debian/patches/963_linux_no_loopmount.diff +++ grub2-1.97~beta4/debian/patches/963_linux_no_loopmount.diff @@ -0,0 +1,20 @@ +Ubuntu: needed for Wubi +Description: Ignore devices loop-mounted from files in 10_linux. +UbuntuSpecific: Not inherently, but perhaps we should integrate 10_lupin + properly instead. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta3/util/grub.d/10_linux.in grub2-1.97~beta3.new/util/grub.d/10_linux.in +--- grub2-1.97~beta3/util/grub.d/10_linux.in 2009-09-16 17:41:06.000000000 +0100 ++++ grub2-1.97~beta3.new/util/grub.d/10_linux.in 2009-09-16 17:44:52.000000000 +0100 +@@ -32,6 +32,11 @@ + case ${GRUB_DEVICE} in + /dev/loop/*|/dev/loop[0-9]) + GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` ++ # We can't cope with devices loop-mounted from files here. ++ case ${GRUB_DEVICE} in ++ /dev/*) ;; ++ *) exit 0 ;; ++ esac + ;; + esac + --- grub2-1.97~beta4.orig/debian/patches/966_mkconfig_probe_option.diff +++ grub2-1.97~beta4/debian/patches/966_mkconfig_probe_option.diff @@ -0,0 +1,50 @@ +Upstream: Backport of r2624. +Description: grub-install: Source ${libdir}/grub/grub-mkconfig_lib before + option processing, in order that the --grub-probe option will work. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/i386/pc/grub-install.in grub2-1.97~beta4.new/util/i386/pc/grub-install.in +--- grub2-1.97~beta4/util/i386/pc/grub-install.in 2009-10-14 11:56:16.000000000 +0100 ++++ grub2-1.97~beta4.new/util/i386/pc/grub-install.in 2009-10-14 12:05:27.000000000 +0100 +@@ -31,6 +31,9 @@ + platform=@platform@ + pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` + ++# for make_system_path_relative_to_its_root() ++. ${libdir}/grub/grub-mkconfig_lib ++ + grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` + if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then + grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` +@@ -145,9 +148,6 @@ + # added by debian patch + setup_force="--force" + +-# for make_system_path_relative_to_its_root() +-. ${libdir}/grub/grub-mkconfig_lib +- + if test "x$install_device" = x; then + echo "install_device not specified." 1>&2 + usage +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/sparc64/ieee1275/grub-install.in grub2-1.97~beta4.new/util/sparc64/ieee1275/grub-install.in +--- grub2-1.97~beta4/util/sparc64/ieee1275/grub-install.in 2009-10-14 11:56:16.000000000 +0100 ++++ grub2-1.97~beta4.new/util/sparc64/ieee1275/grub-install.in 2009-10-14 12:05:27.000000000 +0100 +@@ -31,6 +31,9 @@ + platform=@platform@ + pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` + ++# for make_system_path_relative_to_its_root() ++. ${libdir}/grub/grub-mkconfig_lib ++ + grub_setup=${sbindir}/`echo grub-setup | sed ${transform}` + grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` + grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` +@@ -118,9 +121,6 @@ + esac + done + +-# for make_system_path_relative_to_its_root() +-. ${libdir}/grub/grub-mkconfig_lib +- + if test "x$install_device" = x; then + echo "install_device not specified." 1>&2 + usage --- grub2-1.97~beta4.orig/debian/patches/002_grub.d_freebsd.in.diff +++ grub2-1.97~beta4/debian/patches/002_grub.d_freebsd.in.diff @@ -0,0 +1,128 @@ + +This patch is unreadable because it's an overhaul of the whole file, +it is now derived from 10_linux.in. + +Index: util/grub.d/10_freebsd.in +=================================================================== +--- util/grub.d/10_freebsd.in (revision 2546) ++++ util/grub.d/10_freebsd.in (working copy) +@@ -1,7 +1,7 @@ + #! /bin/sh -e + + # grub-mkconfig helper script. +-# Copyright (C) 2008,2009 Free Software Foundation, Inc. ++# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. + # + # GRUB is free software: you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by +@@ -26,51 +26,77 @@ + *) OS="FreeBSD" ;; + esac + +-if test -e /boot/device.hints ; then +- devices=/boot/device.hints +-fi +- +-if test -e /boot/kernel/kernel ; then +- kfreebsd=/boot/kernel/kernel +-fi +-if test -e /boot/kernel/kernel.gz ; then +- kfreebsd=/boot/kernel/kernel.gz +-fi +- +-if [ "x$kfreebsd" != "x" ] ; then +- echo "Found kernel of FreeBSD: $kfreebsd" >&2 +- +- kfreebsd_basename=`basename $kfreebsd` +- kfreebsd_dirname=`dirname $kfreebsd` +- kfreebsd_rel_dirname=`make_system_path_relative_to_its_root $kfreebsd_dirname` +- +- if [ x"$devices" != "x" ] ; then +- devices_basename=`basename $devices` +- devices_dirname=`dirname $devices` +- devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname` +- fi +- +- case ${GRUB_FS} in +- ufs1 | ufs2) kfreebsd_fs=ufs ;; +- *) kfreebsd_fs=${GRUB_FS} ;; +- esac +- ++kfreebsd_entry () ++{ + cat << EOF +-menuentry "${OS}" { ++menuentry "$1" { + EOF + prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" + cat << EOF +- freebsd ${kfreebsd_rel_dirname}/${kfreebsd_basename} ++ freebsd ${rel_dirname}/${basename} + EOF + +- if [ x"$devices" != "x" ] ; then ++ if test -n "${devices}" ; then + cat << EOF + freebsd_loadenv ${devices_rel_dirname}/${devices_basename} + EOF + fi ++ ++ if test -n "${acpi_ko}" ; then ++ cat << EOF ++ freebsd_module_elf ${acpi_ko_rel_dirname}/${acpi_ko_basename} ++EOF ++ fi ++ + cat << EOF + set FreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${GRUB_DEVICE} + set FreeBSD.vfs.root.mountfrom.options=rw + } + EOF +-fi ++} ++ ++list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do ++ if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi ++ done` ++ ++while [ "x$list" != "x" ] ; do ++ kfreebsd=`version_find_latest $list` ++ echo "Found kernel of FreeBSD: $kfreebsd" >&2 ++ basename=`basename $kfreebsd` ++ dirname=`dirname $kfreebsd` ++ rel_dirname=`make_system_path_relative_to_its_root $dirname` ++ ++ if [ -f /boot/device.hints ] ; then ++ devices=/boot/device.hints ++ devices_basename=`basename $devices` ++ devices_dirname=`dirname $devices` ++ devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname` ++ fi ++ ++ case ${GRUB_FS} in ++ ufs1 | ufs2) kfreebsd_fs=ufs ;; ++ *) kfreebsd_fs=${GRUB_FS} ;; ++ esac ++ ++ version=`echo $basename | sed -e "s,^[^0-9]*-,,g;s/\.gz$//g"` ++ alt_version=`echo $version | sed -e "s,\.old$,,g"` ++ ++ acpi_ko= ++ for i in "/lib/modules/${version}/acpi.ko" "/lib/modules/${alt_version}/acpi.ko" \ ++ "/boot/kernel/acpi.ko"; do ++ if test -e "$i" ; then ++ acpi_ko="$i" ++ break ++ fi ++ done ++ if test -n "${acpi_ko}" ; then ++ echo "Found ACPI module: ${acpi_ko}" >&2 ++ acpi_ko_basename=`basename ${acpi_ko}` ++ acpi_ko_dirname=`dirname ${acpi_ko}` ++ acpi_ko_rel_dirname=`make_system_path_relative_to_its_root $acpi_ko_dirname` ++ fi ++ ++ kfreebsd_entry "${OS}, kFreeBSD ${version}" ++ ++ list=`echo $list | tr ' ' '\n' | grep -vx $kfreebsd | tr '\n' ' '` ++done --- grub2-1.97~beta4.orig/debian/patches/951_quick_boot.diff +++ grub2-1.97~beta4/debian/patches/951_quick_boot.diff @@ -0,0 +1,112 @@ +Description: If other operating systems are installed, then automatically + unhide the menu. Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus + if available to check whether Shift is pressed. If it is, show the menu, + otherwise boot immediately. If keystatus is not available, then fall back + to a short delay interruptible with Escape. +UbuntuSpecific: May or may not remain Ubuntu-specific, although this is not + obviously wanted upstream. It implements a requirement of + https://wiki.ubuntu.com/DesktopExperienceTeam/KarmicBootExperienceDesignSpec#Bootloader. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/00_header.in grub2-1.97~beta4.new/util/grub.d/00_header.in +--- grub2-1.97~beta4/util/grub.d/00_header.in 2009-08-25 20:42:56.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/00_header.in 2009-10-12 11:58:44.000000000 +0100 +@@ -100,19 +100,6 @@ + ;; + esac + +-if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then +- if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then +- verbose= +- else +- verbose=" --verbose" +- fi +- cat << EOF +-if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then +- set timeout=${GRUB_TIMEOUT} +-fi +-EOF +-else +- cat << EOF ++cat << EOF + set timeout=${GRUB_TIMEOUT} + EOF +-fi +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/30_os-prober.in grub2-1.97~beta4.new/util/grub.d/30_os-prober.in +--- grub2-1.97~beta4/util/grub.d/30_os-prober.in 2009-09-19 15:15:00.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/30_os-prober.in 2009-10-12 11:59:28.000000000 +0100 +@@ -22,18 +22,61 @@ + + . ${libdir}/grub/grub-mkconfig_lib + ++found_other_os= ++ ++adjust_timeout () { ++ if [ "x${found_other_os}" = "x" ] ; then ++ if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then ++ if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then ++ verbose= ++ else ++ verbose=" --verbose" ++ fi ++ ++ if [ "x${GRUB_HIDDEN_TIMEOUT}" = "x0" ] ; then ++ cat < /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then + # missing os-prober and/or linux-boot-prober ++ adjust_timeout + exit 0 + fi + + OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`" + if [ -z "${OSPROBED}" ] ; then + # empty os-prober output, nothing doing ++ adjust_timeout + exit 0 + fi + +@@ -48,6 +91,7 @@ + fi + + echo "Found ${LONGNAME} on ${DEVICE}" >&2 ++ found_other_os=1 + + case ${BOOT} in + chain) +@@ -159,3 +203,5 @@ + ;; + esac + done ++ ++adjust_timeout --- grub2-1.97~beta4.orig/debian/patches/969_os_prober_separate_boot.patch +++ grub2-1.97~beta4/debian/patches/969_os_prober_separate_boot.patch @@ -0,0 +1,20 @@ +--- grub2-1.97~beta4/util/grub.d/30_os-prober.in 2009-10-29 11:43:17.358148442 +0000 ++++ grub2-1.97~beta4.new/util/grub.d/30_os-prober.in 2009-10-29 11:44:55.546922498 +0000 +@@ -132,11 +132,16 @@ + LLABEL="${LONGNAME}" + fi + ++ if [ "${LROOT}" != "${LBOOT}" ]; then ++ LKERNEL="${LKERNEL#/boot}" ++ LINITRD="${LINITRD#/boot}" ++ fi ++ + cat << EOF + menuentry "${LLABEL} (on ${DEVICE})" { + EOF + save_default_entry | sed -e "s/^/\t/" +- prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" ++ prepare_grub_to_access_device ${LBOOT} | sed -e "s/^/\t/" + cat << EOF + linux ${LKERNEL} ${LPARAMS} + EOF --- grub2-1.97~beta4.orig/debian/patches/957_savedefault.diff +++ grub2-1.97~beta4/debian/patches/957_savedefault.diff @@ -0,0 +1,508 @@ +Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/216178 +Upstream: http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00040.html + and thread +Description: Add GRUB_DEFAULT=saved, as well as grub-set-default and + grub-reboot utilities. Provides functionality essentially equivalent to + GRUB Legacy's savedefault. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/conf/common.rmk grub2-1.97~beta4.new/conf/common.rmk +--- grub2-1.97~beta4/conf/common.rmk 2009-09-26 12:48:55.000000000 +0100 ++++ grub2-1.97~beta4.new/conf/common.rmk 2009-10-12 12:07:43.000000000 +0100 +@@ -168,6 +168,20 @@ + sbin_SCRIPTS += grub-dumpbios + CLEANFILES += grub-dumpbios + ++# For grub-set-default. ++grub-set-default: util/grub-set-default.in config.status ++ ./config.status --file=$@:$< ++ chmod +x $@ ++sbin_SCRIPTS += grub-set-default ++CLEANFILES += grub-set-default ++ ++# For grub-reboot. ++grub-reboot: util/grub-reboot.in config.status ++ ./config.status --file=$@:$< ++ chmod +x $@ ++sbin_SCRIPTS += grub-reboot ++CLEANFILES += grub-reboot ++ + # Filing systems. + pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \ + ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \ +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/normal/menu.c grub2-1.97~beta4.new/normal/menu.c +--- grub2-1.97~beta4/normal/menu.c 2009-08-25 00:55:06.000000000 +0100 ++++ grub2-1.97~beta4.new/normal/menu.c 2009-10-12 12:07:43.000000000 +0100 +@@ -137,6 +137,8 @@ + return; + } + ++ grub_env_set ("chosen", entry->title); ++ + grub_parser_execute ((char *) entry->sourcecode); + + if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ()) +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/normal/menu_text.c grub2-1.97~beta4.new/normal/menu_text.c +--- grub2-1.97~beta4/normal/menu_text.c 2009-10-12 12:07:42.000000000 +0100 ++++ grub2-1.97~beta4.new/normal/menu_text.c 2009-10-12 12:07:43.000000000 +0100 +@@ -237,7 +237,7 @@ + + /* Get the entry number from the variable NAME. */ + static int +-get_entry_number (const char *name) ++get_entry_number (grub_menu_t menu, const char *name) + { + char *val; + int entry; +@@ -250,6 +250,28 @@ + + entry = (int) grub_strtoul (val, 0, 0); + ++ if (grub_errno == GRUB_ERR_BAD_NUMBER) ++ { ++ /* See if the variable matches the title of a menu entry. */ ++ grub_menu_entry_t e = menu->entry_list; ++ int i; ++ ++ grub_errno = GRUB_ERR_NONE; ++ ++ for (i = 0; e; i++) ++ { ++ if (grub_strcmp (e->title, val) == 0) ++ { ++ entry = i; ++ break; ++ } ++ e = e->next; ++ } ++ ++ if (! e) ++ entry = -1; ++ } ++ + if (grub_errno != GRUB_ERR_NONE) + { + grub_errno = GRUB_ERR_NONE; +@@ -291,7 +313,7 @@ + + first = 0; + +- default_entry = get_entry_number ("default"); ++ default_entry = get_entry_number (menu, "default"); + + /* If DEFAULT_ENTRY is not within the menu entries, fall back to + the first entry. */ +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub-mkconfig_lib.in grub2-1.97~beta4.new/util/grub-mkconfig_lib.in +--- grub2-1.97~beta4/util/grub-mkconfig_lib.in 2009-10-12 12:07:41.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub-mkconfig_lib.in 2009-10-12 12:07:43.000000000 +0100 +@@ -130,6 +130,14 @@ + echo ${drive}${relative_path} + } + ++save_default_entry () ++{ ++ if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then ++ echo 'saved_entry=${chosen}' ++ echo 'save_env saved_entry' ++ fi ++} ++ + prepare_grub_to_access_device () + { + device=$1 +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub-reboot.in grub2-1.97~beta4.new/util/grub-reboot.in +--- grub2-1.97~beta4/util/grub-reboot.in 1970-01-01 01:00:00.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub-reboot.in 2009-10-12 12:07:43.000000000 +0100 +@@ -0,0 +1,104 @@ ++#! /bin/sh ++# ++# Set a default boot entry for GRUB, for the next boot only. ++# Copyright (C) 2004,2009 Free Software Foundation, Inc. ++# ++# GRUB is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++# ++# GRUB is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GRUB. If not, see . ++ ++# Initialize some variables. ++transform="@program_transform_name@" ++ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++bindir=@bindir@ ++ ++grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` ++rootdir= ++ ++# Usage: usage ++# Print the usage. ++usage () { ++ cat <. ++EOF ++} ++ ++# Check the arguments. ++for option in "$@"; do ++ case "$option" in ++ -h | --help) ++ usage ++ exit 0 ;; ++ -v | --version) ++ echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" ++ exit 0 ;; ++ --root-directory=*) ++ rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; ++ -*) ++ echo "Unrecognized option \`$option'" 1>&2 ++ usage ++ exit 1 ++ ;; ++ *) ++ if test "x$entry" != x; then ++ echo "More than one entry?" 1>&2 ++ usage ++ exit 1 ++ fi ++ entry="${option}" ;; ++ esac ++done ++ ++if test "x$entry" = x; then ++ echo "entry not specified." 1>&2 ++ usage ++ exit 1 ++fi ++ ++# Initialize these directories here, since ROOTDIR was initialized. ++case "$host_os" in ++netbsd* | openbsd*) ++ # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub ++ # instead of /boot/grub. ++ grub_prefix=`echo /grub | sed ${transform}` ++ bootdir=${rootdir} ++ ;; ++*) ++ # Use /boot/grub by default. ++ bootdir=${rootdir}/boot ++ ;; ++esac ++ ++grubdir=${bootdir}/`echo grub | sed ${transform}` ++ ++prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'` ++if [ "$prev_saved_entry" ]; then ++ $grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry" ++else ++ $grub_editenv ${grubdir}/grubenv unset prev_saved_entry ++fi ++$grub_editenv ${grubdir}/grubenv set saved_entry="$entry" ++ ++# Bye. ++exit 0 +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub-set-default.in grub2-1.97~beta4.new/util/grub-set-default.in +--- grub2-1.97~beta4/util/grub-set-default.in 1970-01-01 01:00:00.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub-set-default.in 2009-10-12 12:07:43.000000000 +0100 +@@ -0,0 +1,99 @@ ++#! /bin/sh ++# ++# Set a default boot entry for GRUB. ++# Copyright (C) 2004,2009 Free Software Foundation, Inc. ++# ++# GRUB is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++# ++# GRUB is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GRUB. If not, see . ++ ++# Initialize some variables. ++transform="@program_transform_name@" ++ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++bindir=@bindir@ ++ ++grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` ++rootdir= ++ ++# Usage: usage ++# Print the usage. ++usage () { ++ cat <. ++EOF ++} ++ ++# Check the arguments. ++for option in "$@"; do ++ case "$option" in ++ -h | --help) ++ usage ++ exit 0 ;; ++ -v | --version) ++ echo "grub-install (GNU GRUB ${PACKAGE_VERSION})" ++ exit 0 ;; ++ --root-directory=*) ++ rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; ++ -*) ++ echo "Unrecognized option \`$option'" 1>&2 ++ usage ++ exit 1 ++ ;; ++ *) ++ if test "x$entry" != x; then ++ echo "More than one entry?" 1>&2 ++ usage ++ exit 1 ++ fi ++ entry="${option}" ;; ++ esac ++done ++ ++if test "x$entry" = x; then ++ echo "entry not specified." 1>&2 ++ usage ++ exit 1 ++fi ++ ++# Initialize these directories here, since ROOTDIR was initialized. ++case "$host_os" in ++netbsd* | openbsd*) ++ # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub ++ # instead of /boot/grub. ++ grub_prefix=`echo /grub | sed ${transform}` ++ bootdir=${rootdir} ++ ;; ++*) ++ # Use /boot/grub by default. ++ bootdir=${rootdir}/boot ++ ;; ++esac ++ ++grubdir=${bootdir}/`echo grub | sed ${transform}` ++ ++$grub_editenv ${grubdir}/grubenv unset prev_saved_entry ++$grub_editenv ${grubdir}/grubenv set saved_entry="$entry" ++ ++# Bye. ++exit 0 +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/00_header.in grub2-1.97~beta4.new/util/grub.d/00_header.in +--- grub2-1.97~beta4/util/grub.d/00_header.in 2009-10-12 12:07:42.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/00_header.in 2009-10-12 12:10:55.000000000 +0100 +@@ -32,11 +32,22 @@ + done + + if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi ++if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi + if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi + if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi + + cat << EOF +-set default=${GRUB_DEFAULT} ++if [ -s /boot/grub/grubenv ]; then ++ have_grubenv=true ++ load_env ++fi ++set default="${GRUB_DEFAULT}" ++if [ \${prev_saved_entry} ]; then ++ saved_entry=\${prev_saved_entry} ++ save_env saved_entry ++ prev_saved_entry= ++ save_env prev_saved_entry ++fi + EOF + + case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/10_freebsd.in grub2-1.97~beta4.new/util/grub.d/10_freebsd.in +--- grub2-1.97~beta4/util/grub.d/10_freebsd.in 2009-10-12 12:07:41.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/10_freebsd.in 2009-10-12 12:07:43.000000000 +0100 +@@ -31,6 +31,7 @@ + cat << EOF + menuentry "$1" { + EOF ++ save_default_entry | sed -e "s/^/\t/" + prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" + cat << EOF + freebsd ${rel_dirname}/${basename} +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/10_hurd.in grub2-1.97~beta4.new/util/grub.d/10_hurd.in +--- grub2-1.97~beta4/util/grub.d/10_hurd.in 2009-08-08 18:59:19.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/10_hurd.in 2009-10-12 12:07:43.000000000 +0100 +@@ -71,6 +71,7 @@ + cat << EOF + menuentry "${OS}" { + EOF ++save_default_entry | sed -e "s/^/\t/" + prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/" + cat << EOF + multiboot ${kernel} root=device:${GRUB_DEVICE} +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/10_linux.in grub2-1.97~beta4.new/util/grub.d/10_linux.in +--- grub2-1.97~beta4/util/grub.d/10_linux.in 2009-10-12 12:07:42.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/10_linux.in 2009-10-12 12:07:43.000000000 +0100 +@@ -58,6 +58,7 @@ + set quiet=1 + EOF + fi ++ save_default_entry | sed -e "s/^/\t/" + prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" + cat << EOF + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2 +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/10_windows.in grub2-1.97~beta4.new/util/grub.d/10_windows.in +--- grub2-1.97~beta4/util/grub.d/10_windows.in 2009-08-08 18:59:19.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/10_windows.in 2009-10-12 12:07:43.000000000 +0100 +@@ -73,6 +73,7 @@ + menuentry "$OS" { + EOF + ++ save_default_entry | sed -e 's,^,\t,' + prepare_grub_to_access_device "$dev" | sed 's,^,\t,' + + cat << EOF +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/30_os-prober.in grub2-1.97~beta4.new/util/grub.d/30_os-prober.in +--- grub2-1.97~beta4/util/grub.d/30_os-prober.in 2009-10-12 12:07:42.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/30_os-prober.in 2009-10-12 12:07:43.000000000 +0100 +@@ -99,6 +99,7 @@ + cat << EOF + menuentry "${LONGNAME} (on ${DEVICE})" { + EOF ++ save_default_entry | sed -e "s/^/\t/" + prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" + + case ${LONGNAME} in +@@ -134,6 +135,7 @@ + cat << EOF + menuentry "${LLABEL} (on ${DEVICE})" { + EOF ++ save_default_entry | sed -e "s/^/\t/" + prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" + cat << EOF + linux ${LKERNEL} ${LPARAMS} +@@ -153,6 +155,7 @@ + cat << EOF + menuentry "${LONGNAME} (on ${DEVICE})" { + EOF ++ save_default_entry | sed -e "s/^/\t/" + prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" + cat << EOF + insmod vbe +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/i386/efi/grub-install.in grub2-1.97~beta4.new/util/i386/efi/grub-install.in +--- grub2-1.97~beta4/util/i386/efi/grub-install.in 2009-08-24 00:40:29.000000000 +0100 ++++ grub2-1.97~beta4.new/util/i386/efi/grub-install.in 2009-10-12 12:07:43.000000000 +0100 +@@ -34,6 +34,7 @@ + grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` + grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` + grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` ++grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` + rootdir= + grub_prefix=`echo /boot/grub | sed ${transform}` + modules= +@@ -178,6 +179,10 @@ + cp -f $file ${grubdir} || exit 1 + done + ++if ! test -f ${grubdir}/grubenv; then ++ $grub_editenv ${grubdir}/grubenv create ++fi ++ + # Create the core image. First, auto-detect the filesystem module. + fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}` + if test "x$fs_module" = xfat; then :; else +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/i386/pc/grub-install.in grub2-1.97~beta4.new/util/i386/pc/grub-install.in +--- grub2-1.97~beta4/util/i386/pc/grub-install.in 2009-10-12 12:07:41.000000000 +0100 ++++ grub2-1.97~beta4.new/util/i386/pc/grub-install.in 2009-10-12 12:07:43.000000000 +0100 +@@ -39,6 +39,7 @@ + fi + grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` + grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` ++grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` + rootdir= + grub_prefix=`echo /boot/grub | sed ${transform}` + modules= +@@ -250,6 +251,10 @@ + done + fi + ++if ! test -f ${grubdir}/grubenv; then ++ $grub_editenv ${grubdir}/grubenv create ++fi ++ + # Write device to a variable so we don't have to traverse /dev every time. + grub_device=`$grub_probe --target=device ${grubdir}` + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/ieee1275/grub-install.in grub2-1.97~beta4.new/util/ieee1275/grub-install.in +--- grub2-1.97~beta4/util/ieee1275/grub-install.in 2008-08-14 19:59:33.000000000 +0100 ++++ grub2-1.97~beta4.new/util/ieee1275/grub-install.in 2009-10-12 12:07:43.000000000 +0100 +@@ -37,6 +37,7 @@ + grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}` + grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` + grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` ++grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` + rootdir= + grub_prefix=`echo /boot/grub | sed ${transform}` + modules= +@@ -163,6 +164,10 @@ + cp -f $file ${grubdir} || exit 1 + done + ++if ! test -f ${grubdir}/grubenv; then ++ $grub_editenv ${grubdir}/grubenv create ++fi ++ + # Create the core image. First, auto-detect the filesystem module. + fs_module=`$grub_probe --target=fs --device-map=${device_map} ${grubdir}` + if test "x$fs_module" = x -a "x$modules" = x; then +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/sparc64/ieee1275/grub-install.in grub2-1.97~beta4.new/util/sparc64/ieee1275/grub-install.in +--- grub2-1.97~beta4/util/sparc64/ieee1275/grub-install.in 2009-08-24 00:40:29.000000000 +0100 ++++ grub2-1.97~beta4.new/util/sparc64/ieee1275/grub-install.in 2009-10-12 12:07:43.000000000 +0100 +@@ -35,6 +35,7 @@ + grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` + grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` + grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` ++grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}` + rootdir= + grub_prefix=`echo /boot/grub | sed ${transform}` + modules= +@@ -206,6 +207,10 @@ + cp -f $file ${grubdir} || exit 1 + done + ++if ! test -f ${grubdir}/grubenv; then ++ $grub_editenv ${grubdir}/grubenv create ++fi ++ + # Write device to a variable so we don't have to traverse /dev every time. + grub_device=`$grub_probe --target=device ${grubdir}` + --- grub2-1.97~beta4.orig/debian/patches/952_sleep_shift.diff +++ grub2-1.97~beta4/debian/patches/952_sleep_shift.diff @@ -0,0 +1,41 @@ +Upstream: http://lists.gnu.org/archive/html/grub-devel/2009-08/msg00694.html + (in part; see thread) +Description: Allow Shift to interrupt 'sleep --interruptible'. +UbuntuSpecific: Upstream would like to consider this at more length. See + http://lists.gnu.org/archive/html/grub-devel/2009-08/msg00718.html, and the + rest of the thread for context. + +diff -Nur -x '*.orig' -x '*~' grub2-1.96+20090826/commands/sleep.c grub2-1.96+20090826.new/commands/sleep.c +--- grub2-1.96+20090826/commands/sleep.c 2009-08-26 10:01:15.000000000 +0100 ++++ grub2-1.96+20090826.new/commands/sleep.c 2009-08-27 10:02:35.000000000 +0100 +@@ -43,6 +43,20 @@ + grub_printf ("%d ", n); + } + ++static int ++grub_check_keyboard (void) ++{ ++ int mods = grub_getkeystatus (); ++ if (mods >= 0 && (mods & GRUB_TERM_STATUS_SHIFT) != 0) ++ return 1; ++ ++ if (grub_checkkey () >= 0 && ++ GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC) ++ return 1; ++ ++ return 0; ++} ++ + /* Based on grub_millisleep() from kern/generic/millisleep.c. */ + static int + grub_interruptible_millisleep (grub_uint32_t ms) +@@ -52,8 +66,7 @@ + start = grub_get_time_ms (); + + while (grub_get_time_ms () - start < ms) +- if (grub_checkkey () >= 0 && +- GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC) ++ if (grub_check_keyboard ()) + return 1; + + return 0; --- grub2-1.97~beta4.orig/debian/patches/904_disable_floppies.diff +++ grub2-1.97~beta4/debian/patches/904_disable_floppies.diff @@ -0,0 +1,28 @@ + +Author: Robert Millan + +An ugly kludge. Should this be merged upstream? + +Index: util/hostdisk.c +=================================================================== +--- util/hostdisk.c (revision 1832) ++++ util/hostdisk.c (working copy) +@@ -544,6 +544,18 @@ + continue; + } + ++ if (! strncmp (p, "/dev/fd", sizeof ("/dev/fd") - 1)) ++ { ++ char *q = p + sizeof ("/dev/fd") - 1; ++ if (*q >= '0' && *q <= '9') ++ { ++ free (map[drive].drive); ++ map[drive].drive = NULL; ++ grub_util_info ("`%s' looks like a floppy drive, skipping", p); ++ continue; ++ } ++ } ++ + #ifdef __linux__ + /* On Linux, the devfs uses symbolic links horribly, and that + confuses the interface very much, so use realpath to expand --- grub2-1.97~beta4.orig/debian/patches/905_setup_force.diff +++ grub2-1.97~beta4/debian/patches/905_setup_force.diff @@ -0,0 +1,24 @@ + +Upstream wanted grub-setup to require --force when blocklists are to be +used. However, this is not suitable for debian because we have to maintain +backward-compatibility. + +To make things worse, since the Lenny release D-I creates a broken setup +on GPT, where blocklists become the _only_ option. When this is fixed, we +could contemplate removing this patch and instead just pass --force whenever +calling grub-install from postinst. + +Index: util/i386/pc/grub-install.in +=================================================================== +--- util/i386/pc/grub-install.in (revision 2202) ++++ util/i386/pc/grub-install.in (working copy) +@@ -124,6 +124,9 @@ + esac + done + ++# added by debian patch ++setup_force="--force" ++ + # for make_system_path_relative_to_its_root() + . ${libdir}/grub/grub-mkconfig_lib + --- grub2-1.97~beta4.orig/debian/patches/07_core_in_fs.diff +++ grub2-1.97~beta4/debian/patches/07_core_in_fs.diff @@ -0,0 +1,31 @@ +Index: util/i386/pc/grub-setup.c +=================================================================== +--- util/i386/pc/grub-setup.c (revision 2220) ++++ util/i386/pc/grub-setup.c (working copy) +@@ -53,6 +53,7 @@ static const grub_gpt_part_type_t grub_g + + #define DEFAULT_BOOT_FILE "boot.img" + #define DEFAULT_CORE_FILE "core.img" ++#define CORE_IMG_IN_FS "setup_left_core_image_in_filesystem" + + /* This is the blocklist used in the diskboot image. */ + struct boot_blocklist +@@ -388,6 +389,8 @@ setup (const char *dir, + boot_img)) + grub_util_error ("%s", grub_errmsg); + ++ unlink (DEFAULT_DIRECTORY "/" CORE_IMG_IN_FS); ++ + goto finish; + + unable_to_embed: +@@ -402,6 +405,9 @@ unable_to_embed: + if (! force) + grub_util_error ("If you really want blocklists, use --force."); + ++ fp = fopen (DEFAULT_DIRECTORY "/" CORE_IMG_IN_FS, "w"); ++ fclose (fp); ++ + /* Make sure that GRUB reads the identical image as the OS. */ + tmp_img = xmalloc (core_size); + core_path_dev = grub_util_get_path (dir, core_file); --- grub2-1.97~beta4.orig/debian/patches/968_raid_virtio.diff +++ grub2-1.97~beta4/debian/patches/968_raid_virtio.diff @@ -0,0 +1,158 @@ +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/include/grub/util/getroot.h grub2-1.97~beta4.new/include/grub/util/getroot.h +--- grub2-1.97~beta4/include/grub/util/getroot.h 2009-04-11 10:40:39.000000000 +0100 ++++ grub2-1.97~beta4.new/include/grub/util/getroot.h 2009-10-23 20:55:25.000000000 +0100 +@@ -19,12 +19,15 @@ + #ifndef GRUB_UTIL_GETROOT_HEADER + #define GRUB_UTIL_GETROOT_HEADER 1 + ++#include ++ + enum grub_dev_abstraction_types { + GRUB_DEV_ABSTRACTION_NONE, + GRUB_DEV_ABSTRACTION_LVM, + GRUB_DEV_ABSTRACTION_RAID, + }; + ++char *grub_find_device (const char *dir, dev_t dev); + char *grub_guess_root_device (const char *dir); + char *grub_get_prefix (const char *dir); + int grub_util_get_dev_abstraction (const char *os_dev); +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/getroot.c grub2-1.97~beta4.new/util/getroot.c +--- grub2-1.97~beta4/util/getroot.c 2009-07-20 21:03:18.000000000 +0100 ++++ grub2-1.97~beta4.new/util/getroot.c 2009-10-23 20:55:25.000000000 +0100 +@@ -172,8 +172,8 @@ + + #ifdef __MINGW32__ + +-static char * +-find_root_device (const char *dir __attribute__ ((unused)), ++char * ++grub_find_device (const char *dir __attribute__ ((unused)), + dev_t dev __attribute__ ((unused))) + { + return 0; +@@ -181,13 +181,22 @@ + + #elif ! defined(__CYGWIN__) + +-static char * +-find_root_device (const char *dir, dev_t dev) ++char * ++grub_find_device (const char *dir, dev_t dev) + { + DIR *dp; + char *saved_cwd; + struct dirent *ent; + ++ if (! dir) ++ { ++#ifdef __CYGWIN__ ++ return NULL; ++#else ++ dir = "/dev"; ++#endif ++ } ++ + dp = opendir (dir); + if (! dp) + return 0; +@@ -225,7 +234,7 @@ + /* Find it recursively. */ + char *res; + +- res = find_root_device (ent->d_name, dev); ++ res = grub_find_device (ent->d_name, dev); + + if (res) + { +@@ -328,8 +337,8 @@ + return serial; + } + +-static char * +-find_cygwin_root_device (const char *path, dev_t dev) ++char * ++grub_find_device (const char *path, dev_t dev) + { + /* No root device for /cygdrive. */ + if (dev == (DEV_CYGDRIVE_MAJOR << 16)) +@@ -350,7 +359,7 @@ + + /* Cygwin returns the partition serial number in stat.st_dev. + This is never identical to the device number of the emulated +- /dev/sdXN device, so above find_root_device () does not work. ++ /dev/sdXN device, so above grub_find_device () does not work. + Search the partition with the same serial in boot sector instead. */ + char devpath[sizeof ("/dev/sda15") + 13]; /* Size + Paranoia. */ + int d; +@@ -386,12 +395,12 @@ + + #ifdef __CYGWIN__ + /* Cygwin specific function. */ +- os_dev = find_cygwin_root_device (dir, st.st_dev); ++ os_dev = grub_find_device (dir, st.st_dev); + + #else + + /* This might be truly slow, but is there any better way? */ +- os_dev = find_root_device ("/dev", st.st_dev); ++ os_dev = grub_find_device ("/dev", st.st_dev); + #endif + + return os_dev; +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/raid.c grub2-1.97~beta4.new/util/raid.c +--- grub2-1.97~beta4/util/raid.c 2009-06-10 22:04:23.000000000 +0100 ++++ grub2-1.97~beta4.new/util/raid.c 2009-10-23 20:56:17.000000000 +0100 +@@ -21,40 +21,19 @@ + #ifdef __linux__ + #include + #include ++#include + + #include + #include + #include + #include ++#include + + #include + #include + #include + #include + +-static char * +-grub_util_getdiskname (int major, int minor) +-{ +- char *name = xmalloc (15); +- +- if (major == LOOP_MAJOR) +- sprintf (name, "/dev/loop%d", minor); +- else if (major == IDE0_MAJOR) +- sprintf (name, "/dev/hd%c", 'a' + minor / 64); +- else if (major == IDE1_MAJOR) +- sprintf (name, "/dev/hd%c", 'c' + minor / 64); +- else if (major == IDE2_MAJOR) +- sprintf (name, "/dev/hd%c", 'e' + minor / 64); +- else if (major == IDE3_MAJOR) +- sprintf (name, "/dev/hd%c", 'g' + minor / 64); +- else if (major == SCSI_DISK0_MAJOR) +- sprintf (name, "/dev/sd%c", 'a' + minor / 16); +- else +- grub_util_error ("Unknown device number: %d, %d", major, minor); +- +- return name; +-} +- + char ** + grub_util_raid_getmembers (char *name) + { +@@ -99,7 +78,8 @@ + + if (disk.state & (1 << MD_DISK_ACTIVE)) + { +- devicelist[j] = grub_util_getdiskname (disk.major, disk.minor); ++ devicelist[j] = grub_find_device (NULL, ++ makedev (disk.major, disk.minor)); + j++; + } + } --- grub2-1.97~beta4.orig/debian/patches/903_grub_legacy_0_based_partitions.diff +++ grub2-1.97~beta4/debian/patches/903_grub_legacy_0_based_partitions.diff @@ -0,0 +1,11 @@ +--- util/hostdisk.c 2008-02-11 16:47:35.000000000 +0100 ++++ util/hostdisk.c 2008-02-28 17:00:20.000000000 +0100 +@@ -584,7 +584,7 @@ + sprintf (p, (drive & 0x80) ? "hd%d" : "fd%d", drive & ~0x80); + + if (dos_part >= 0) +- sprintf (p + strlen (p), ",%d", dos_part + 1); ++ sprintf (p + strlen (p), ",%d", dos_part + (getenv ("GRUB_LEGACY_0_BASED_PARTITIONS") ? 0 : 1)); + + if (bsd_part >= 0) + sprintf (p + strlen (p), ",%c", bsd_part + 'a'); --- grub2-1.97~beta4.orig/debian/patches/954_normal_quiet.diff +++ grub2-1.97~beta4/debian/patches/954_normal_quiet.diff @@ -0,0 +1,68 @@ +Upstream: http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00056.html +Description: Don't display introductory message about line editing unless + we're actually offering a shell prompt. Also, don't clear the screen just + before booting if we never drew the menu in the first place. +UbuntuSpecific: The line editing change is believed to be a workaround for a + different bug. We'll go with this for now, but will drop this in favour of + a better fix upstream if somebody figures out what that is. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta2/normal/main.c grub2-1.97~beta2.new/normal/main.c +--- grub2-1.97~beta2/normal/main.c 2009-09-09 17:19:13.000000000 +0100 ++++ grub2-1.97~beta2.new/normal/main.c 2009-09-09 17:19:20.000000000 +0100 +@@ -503,7 +503,7 @@ + } + + static grub_err_t +-grub_normal_reader_init (void) ++grub_normal_display_intro (void) + { + grub_normal_init_page (); + grub_setcursor (1); +@@ -524,6 +524,13 @@ + { + grub_parser_t parser = grub_parser_get_current (); + char prompt[8 + grub_strlen (parser->name)]; ++ static int displayed_intro; ++ ++ if (! displayed_intro) ++ { ++ grub_normal_display_intro (); ++ displayed_intro = 1; ++ } + + grub_sprintf (prompt, "%s:%s> ", parser->name, (cont) ? "" : "grub"); + +@@ -547,7 +554,6 @@ + static struct grub_reader grub_normal_reader = + { + .name = "normal", +- .init = grub_normal_reader_init, + .read_line = grub_normal_read_line + }; + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta2/normal/menu_text.c grub2-1.97~beta2.new/normal/menu_text.c +--- grub2-1.97~beta2/normal/menu_text.c 2009-09-09 17:19:13.000000000 +0100 ++++ grub2-1.97~beta2.new/normal/menu_text.c 2009-09-09 17:21:36.000000000 +0100 +@@ -561,6 +561,7 @@ + int boot_entry; + grub_menu_entry_t e; + int auto_boot; ++ int initial_timeout = grub_menu_get_timeout (); + + boot_entry = run_menu (menu, nested, &auto_boot); + if (boot_entry < 0) +@@ -570,8 +571,12 @@ + if (! e) + continue; /* Menu is empty. */ + +- grub_cls (); +- grub_setcursor (1); ++ /* Only clear the screen if we drew the menu in the first place. */ ++ if (initial_timeout != 0) ++ { ++ grub_cls (); ++ grub_setcursor (1); ++ } + + if (auto_boot) + { --- grub2-1.97~beta4.orig/debian/patches/03_ubuntu_grub_standards.diff +++ grub2-1.97~beta4/debian/patches/03_ubuntu_grub_standards.diff @@ -0,0 +1,15 @@ +Description: Remove GNU/Linux from default distributor string. +UbuntuSpecific: We call it "Ubuntu", not "Ubuntu GNU/Linux". + +diff -Nur -x '*.orig' -x '*~' grub2-1.96+20080724/util/grub.d/10_linux.in grub2-1.96+20080724.new/util/grub.d/10_linux.in +--- grub2-1.96+20080724/util/grub.d/10_linux.in 2008-06-26 17:03:26.000000000 +1000 ++++ grub2-1.96+20080724.new/util/grub.d/10_linux.in 2008-11-17 11:25:53.000000000 +1100 +@@ -24,7 +24,7 @@ + if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then + OS=GNU/Linux + else +- OS="${GRUB_DISTRIBUTOR} GNU/Linux" ++ OS="${GRUB_DISTRIBUTOR}" + fi + + # loop-AES arranges things so that /dev/loop/X can be our root device, but --- grub2-1.97~beta4.orig/debian/patches/967_no_mmx_sse.diff +++ grub2-1.97~beta4/debian/patches/967_no_mmx_sse.diff @@ -0,0 +1,24 @@ +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/configure grub2-1.97~beta4.new/configure +--- grub2-1.97~beta4/configure 2009-10-05 18:59:12.000000000 +0100 ++++ grub2-1.97~beta4.new/configure 2009-10-16 15:29:39.000000000 +0100 +@@ -6388,6 +6388,8 @@ + else + TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" + fi ++ ++ TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2" + fi + + # By default, GCC 4.4 generates .eh_frame sections containing unwind +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/configure.ac grub2-1.97~beta4.new/configure.ac +--- grub2-1.97~beta4/configure.ac 2009-10-05 18:56:33.000000000 +0100 ++++ grub2-1.97~beta4.new/configure.ac 2009-10-16 15:29:39.000000000 +0100 +@@ -252,6 +252,8 @@ + else + TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" + fi ++ ++ TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2" + fi + + # By default, GCC 4.4 generates .eh_frame sections containing unwind --- grub2-1.97~beta4.orig/debian/patches/965_failed_boot_menu.diff +++ grub2-1.97~beta4/debian/patches/965_failed_boot_menu.diff @@ -0,0 +1,26 @@ +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/00_header.in grub2-1.97~beta4.new/util/grub.d/00_header.in +--- grub2-1.97~beta4/util/grub.d/00_header.in 2009-10-12 12:11:21.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/00_header.in 2009-10-12 12:11:22.000000000 +0100 +@@ -112,5 +112,9 @@ + esac + + cat << EOF +-set timeout=${GRUB_TIMEOUT} ++if [ \${recordfail} = 1 ]; then ++ set timeout=-1 ++else ++ set timeout=${GRUB_TIMEOUT} ++fi + EOF +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/util/grub.d/10_linux.in grub2-1.97~beta4.new/util/grub.d/10_linux.in +--- grub2-1.97~beta4/util/grub.d/10_linux.in 2009-10-12 12:11:21.000000000 +0100 ++++ grub2-1.97~beta4.new/util/grub.d/10_linux.in 2009-10-12 12:12:11.000000000 +0100 +@@ -57,6 +57,8 @@ + { + cat << EOF + menuentry "$1" { ++ recordfail=1 ++ if [ -n \${have_grubenv} ]; then save_env recordfail; fi + EOF + if [ "x$3" = "xquiet" ]; then + cat << EOF --- grub2-1.97~beta4.orig/debian/patches/06_olpc_prefix_hack.diff +++ grub2-1.97~beta4/debian/patches/06_olpc_prefix_hack.diff @@ -0,0 +1,50 @@ + +This sucks, but it's better than what OFW was giving us. + +Index: kern/ieee1275/init.c +=================================================================== +--- kern/ieee1275/init.c (revision 2615) ++++ kern/ieee1275/init.c (working copy) +@@ -53,6 +53,7 @@ + grub_ieee1275_exit (); + } + ++#ifndef __i386__ + /* Translate an OF filesystem path (separated by backslashes), into a GRUB + path (separated by forward slashes). */ + static void +@@ -67,13 +68,16 @@ + backslash = grub_strchr (filepath, '\\'); + } + } ++#endif + + void + grub_machine_set_prefix (void) + { ++#ifndef __i386__ + char bootpath[64]; /* XXX check length */ + char *filename; + char *prefix; ++#endif + + if (grub_env_get ("prefix")) + /* We already set prefix in grub_machine_init(). */ +@@ -86,6 +90,9 @@ + return; + } + ++#ifdef __i386__ ++ grub_env_set ("prefix", "(sd,1)/"); ++#else + if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", &bootpath, + sizeof (bootpath), 0)) + { +@@ -123,6 +130,7 @@ + + grub_free (filename); + grub_free (prefix); ++#endif + } + + /* Claim some available memory in the first /memory node. */ --- grub2-1.97~beta4.orig/debian/patches/955_really_quiet.diff +++ grub2-1.97~beta4/debian/patches/955_really_quiet.diff @@ -0,0 +1,49 @@ +Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/386922 +Description: Remove some verbose messages printed before reading the + configuration file. In some ways this is awkward because it makes debugging + harder, but it's a requirement for a smooth-looking boot process; we may be + able to do better in future. +UbuntuSpecific: Removes status messages that are arguably useful for + debugging; we think it looks tidier, but upstream isn't interested. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/kern/main.c grub2-1.97~beta4.new/kern/main.c +--- grub2-1.97~beta4/kern/main.c 2009-06-10 22:04:23.000000000 +0100 ++++ grub2-1.97~beta4.new/kern/main.c 2009-10-12 13:14:45.000000000 +0100 +@@ -152,11 +152,6 @@ + /* First of all, initialize the machine. */ + grub_machine_init (); + +- /* Hello. */ +- grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); +- grub_printf ("Welcome to GRUB!\n\n"); +- grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); +- + /* Load pre-loaded modules and free the space. */ + grub_register_exported_symbols (); + grub_load_modules (); +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/kern/rescue_reader.c grub2-1.97~beta4.new/kern/rescue_reader.c +--- grub2-1.97~beta4/kern/rescue_reader.c 2009-05-02 20:49:34.000000000 +0100 ++++ grub2-1.97~beta4.new/kern/rescue_reader.c 2009-10-12 13:14:45.000000000 +0100 +@@ -29,7 +29,6 @@ + static grub_err_t + grub_rescue_init (void) + { +- grub_printf ("Entering rescue mode...\n"); + return 0; + } + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/normal/menu_text.c grub2-1.97~beta4.new/normal/menu_text.c +--- grub2-1.97~beta4/normal/menu_text.c 2009-10-12 13:14:43.000000000 +0100 ++++ grub2-1.97~beta4.new/normal/menu_text.c 2009-10-13 11:14:19.000000000 +0100 +@@ -513,10 +513,9 @@ + + /* Callback invoked immediately before a menu entry is executed. */ + static void +-notify_booting (grub_menu_entry_t entry, ++notify_booting (grub_menu_entry_t entry __attribute__((unused)), + void *userdata __attribute__((unused))) + { +- grub_printf (" Booting \'%s\'\n\n", entry->title); + } + + /* Callback invoked when a default menu entry executed because of a timeout --- grub2-1.97~beta4.orig/debian/patches/01_uuids_and_lvm_dont_play_along_nicely.diff +++ grub2-1.97~beta4/debian/patches/01_uuids_and_lvm_dont_play_along_nicely.diff @@ -0,0 +1,14 @@ +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index c2da413..cbd9d6b 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -36,7 +36,8 @@ case ${GRUB_DEVICE} in + esac + + if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ +- || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then ++ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ ++ || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then + LINUX_ROOT_DEVICE=${GRUB_DEVICE} + else + LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} --- grub2-1.97~beta4.orig/debian/patches/901_dpkg_version_comparison.diff +++ grub2-1.97~beta4/debian/patches/901_dpkg_version_comparison.diff @@ -0,0 +1,24 @@ +Index: util/grub-mkconfig_lib.in +=================================================================== +--- util/grub-mkconfig_lib.in (revision 2482) ++++ util/grub-mkconfig_lib.in (working copy) +@@ -185,8 +185,8 @@ version_test_numeric () + + version_test_gt () + { +- local a=`echo $1 | sed -e "s/[^-]*-//"` +- local b=`echo $2 | sed -e "s/[^-]*-//"` ++ local a=`echo $1 | sed -e "s/[^-]*-//;s/[._-]\(pre\|rc\|test\|git\|old\)/~\1/g"` ++ local b=`echo $2 | sed -e "s/[^-]*-//;s/[._-]\(pre\|rc\|test\|git\|old\)/~\1/g"` + local cmp=gt + if [ "x$b" = "x" ] ; then + return 0 +@@ -196,7 +196,7 @@ version_test_gt () + *.old:*) a=`echo -n $a | sed -e s/\.old$//` ; cmp=gt ;; + *:*.old) b=`echo -n $b | sed -e s/\.old$//` ; cmp=ge ;; + esac +- version_test_numeric $a $cmp $b ++ dpkg --compare-versions "$a" $cmp "$b" + return $? + } + --- grub2-1.97~beta4.orig/debian/patches/05_insmod_in_rescue_disks.diff +++ grub2-1.97~beta4/debian/patches/05_insmod_in_rescue_disks.diff @@ -0,0 +1,13 @@ +--- ../grub2/docs/grub.cfg 2008-04-29 14:17:33.000000000 +0200 ++++ docs/grub.cfg 2008-04-29 14:52:22.000000000 +0200 +@@ -2,6 +2,10 @@ + # Sample GRUB configuration file + # + ++insmod biosdisk ++insmod pc ++insmod gpt ++ + # Boot automatically after 30 secs. + set timeout=30 + --- grub2-1.97~beta4.orig/debian/patches/10_crashkernel.patch +++ grub2-1.97~beta4/debian/patches/10_crashkernel.patch @@ -0,0 +1,30 @@ +Description: Add crashkernel= options if kdump and makedumpfile are + available. See + https://blueprints.launchpad.net/ubuntu/+spec/foundations-karmic-linux-kernel-crash-dump. +UbuntuSpecific: Ubuntu kernel crash handling; requires several other fairly + distribution-specific pieces to work properly. + +diff -Nur -x '*.orig' -x '*~' grub2-1.96+20090725-1ubuntu1/util/grub.d/10_linux.in grub2-1.96+20090725-1ubuntu1.new/util/grub.d/10_linux.in +--- grub2-1.96+20090725-1ubuntu1/util/grub.d/10_linux.in 2009-07-30 12:29:50.000000000 -0500 ++++ grub2-1.96+20090725-1ubuntu1.new/util/grub.d/10_linux.in 2009-07-30 12:30:44.000000000 -0500 +@@ -42,6 +42,11 @@ + LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} + fi + ++# add crashkernel option if we have the required tools ++if [ -x "/usr/bin/makedumpfile" ] && [ -x "/sbin/kexec" ]; then ++ GRUB_CMDLINE_EXTRA="$GRUB_CMDLINE_EXTRA crashkernel=384M-2G:64M,2G-:128M" ++fi ++ + linux_entry () + { + cat << EOF +@@ -92,7 +97,7 @@ + fi + + linux_entry "${OS}, Linux ${version}" \ +- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" + if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then + linux_entry "${OS}, Linux ${version} (recovery mode)" \ + "single ${GRUB_CMDLINE_LINUX}" --- grub2-1.97~beta4.orig/debian/patches/907_grub.cfg_400.diff +++ grub2-1.97~beta4/debian/patches/907_grub.cfg_400.diff @@ -0,0 +1,15 @@ +Index: util/grub-mkconfig.in +=================================================================== +--- util/grub-mkconfig.in (revision 2598) ++++ util/grub-mkconfig.in (working copy) +@@ -261,6 +261,10 @@ for i in ${grub_mkconfig_dir}/* ; do + esac + done + ++if [ "x${grub_cfg}" != "x" ] && ! grep -q "^password " ${grub_cfg}.new ; then ++ chmod 444 ${grub_cfg}.new || true ++fi ++ + if test "x${grub_cfg}" != "x" ; then + # none of the children aborted with error, install the new grub.cfg + mv -f ${grub_cfg}.new ${grub_cfg} --- grub2-1.97~beta4.orig/debian/patches/961_handle_loopback.diff +++ grub2-1.97~beta4/debian/patches/961_handle_loopback.diff @@ -0,0 +1,45 @@ +Ubuntu: needed for Wubi +Description: Change prepare_grub_to_access_device to handle filesystems + loop-mounted on file images. +UbuntuSpecific: Not inherently. losetup and /proc/mounts are Linux-specific, + though, so we might need to refine this before sending it upstream. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta3/util/grub-mkconfig_lib.in grub2-1.97~beta3.new/util/grub-mkconfig_lib.in +--- grub2-1.97~beta3/util/grub-mkconfig_lib.in 2009-09-15 00:23:50.000000000 +0100 ++++ grub2-1.97~beta3.new/util/grub-mkconfig_lib.in 2009-09-15 00:31:31.000000000 +0100 +@@ -142,6 +142,20 @@ + { + device=$1 + ++ loop_file= ++ case ${device} in ++ /dev/loop/*|/dev/loop[0-9]) ++ loop_file=`losetup ${device} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` ++ case $loop_file in ++ /dev/*) ;; ++ *) ++ loop_device=${device} ++ device=`${grub_probe} --target=device "${loop_file}"` ++ ;; ++ esac ++ ;; ++ esac ++ + # Abstraction modules aren't auto-loaded. + abstraction="`${grub_probe} --device ${device} --target=abstraction`" + for module in ${abstraction} ; do +@@ -159,6 +173,14 @@ + if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then + echo "search --no-floppy --fs-uuid --set ${fs_uuid}" + fi ++ ++ if [ "x${loop_file}" != x ]; then ++ loop_mountpoint="$(awk '"'${loop_file}'" ~ "^"$2 && $2 != "/" { print $2 }' /proc/mounts | tail -n1)" ++ if [ "x${loop_mountpoint}" != x ]; then ++ echo "loopback loop0 ${loop_file#$loop_mountpoint}" ++ echo "set root=(loop0)" ++ fi ++ fi + } + + grub_file_is_not_garbage () --- grub2-1.97~beta4.orig/debian/patches/956_linux_quiet.diff +++ grub2-1.97~beta4/debian/patches/956_linux_quiet.diff @@ -0,0 +1,76 @@ +Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/386922 +Upstream: not yet, but probably can and should be +Description: If the environment variable "quiet" is set to something other + than 1, suppress progress messages as the kernel and initrd load. Set this + for non-recovery kernel menu entries. + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta1/loader/i386/linux.c grub2-1.97~beta1.new/loader/i386/linux.c +--- grub2-1.97~beta1/loader/i386/linux.c 2009-08-30 17:02:11.000000000 +0100 ++++ grub2-1.97~beta1.new/loader/i386/linux.c 2009-09-03 21:23:22.000000000 +0100 +@@ -571,6 +571,7 @@ + grub_ssize_t len; + int i; + char *dest; ++ char *quiet; + + grub_dl_ref (my_mod); + +@@ -685,8 +686,10 @@ + + grub_file_seek (file, real_size + GRUB_DISK_SECTOR_SIZE); + +- grub_printf (" [Linux-bzImage, setup=0x%x, size=0x%x]\n", +- (unsigned) real_size, (unsigned) prot_size); ++ quiet = grub_env_get ("quiet"); ++ if (!quiet || *quiet == '0') ++ grub_printf (" [Linux-bzImage, setup=0x%x, size=0x%x]\n", ++ (unsigned) real_size, (unsigned) prot_size); + + /* Look for memory size and video mode specified on the command line. */ + linux_mem_size = 0; +@@ -867,6 +870,7 @@ + grub_addr_t addr_min, addr_max; + grub_addr_t addr; + struct linux_kernel_header *lh; ++ char *quiet; + + if (argc == 0) + { +@@ -936,8 +940,10 @@ + goto fail; + } + +- grub_printf (" [Initrd, addr=0x%x, size=0x%x]\n", +- (unsigned) addr, (unsigned) size); ++ quiet = grub_env_get ("quiet"); ++ if (!quiet || *quiet == '0') ++ grub_printf (" [Initrd, addr=0x%x, size=0x%x]\n", ++ (unsigned) addr, (unsigned) size); + + lh->ramdisk_image = addr; + lh->ramdisk_size = size; +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta1/util/grub.d/10_linux.in grub2-1.97~beta1.new/util/grub.d/10_linux.in +--- grub2-1.97~beta1/util/grub.d/10_linux.in 2009-09-03 21:23:13.000000000 +0100 ++++ grub2-1.97~beta1.new/util/grub.d/10_linux.in 2009-09-03 21:23:22.000000000 +0100 +@@ -53,6 +53,11 @@ + cat << EOF + menuentry "$1" { + EOF ++ if [ "x$3" = "xquiet" ]; then ++ cat << EOF ++ set quiet=1 ++EOF ++ fi + prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" + cat << EOF + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2 +@@ -98,7 +103,8 @@ + fi + + linux_entry "${OS}, Linux ${version}" \ +- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \ ++ quiet + if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then + linux_entry "${OS}, Linux ${version} (recovery mode)" \ + "single ${GRUB_CMDLINE_LINUX}" --- grub2-1.97~beta4.orig/debian/patches/970_security_fix_password_validation.diff +++ grub2-1.97~beta4/debian/patches/970_security_fix_password_validation.diff @@ -0,0 +1,99 @@ +Description: properly validate grub password (CVE-2009-4128) +Author: Robert Millan +Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=555195 +Bug-Ubuntu: https://launchpad.net/bugs/478806 + +diff -Nur -x '*.orig' -x '*~' grub2-1.97~beta4/normal/auth.c grub2-1.97~beta4.new/normal/auth.c +--- grub2-1.97~beta4/normal/auth.c 2009-08-25 03:11:50.000000000 -0500 ++++ grub2-1.97~beta4.new/normal/auth.c 2009-12-07 14:11:18.928076599 -0600 +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + struct grub_auth_user + { +@@ -35,17 +36,19 @@ + struct grub_auth_user *users = NULL; + + int +-grub_auth_strcmp (const char *user_input, const char *template) ++grub_auth_strcmp (const char *s1, const char *s2) + { +- int ok = 1; +- const char *ptr1, *ptr2; +- for (ptr1 = user_input, ptr2 = template; *ptr1; ptr1++) +- if (*ptr1 == (ptr2 ? *ptr2 : ptr1[1]) && ok && ptr2 != NULL) +- ptr2++; +- else +- ok = 0; ++ int ret; ++ grub_uint64_t end; + +- return !ok; ++ end = grub_get_time_ms () + 100; ++ ret = grub_strcmp (s1, s2); ++ ++ /* This prevents an attacker from deriving information about the ++ password from the time it took to execute this function. */ ++ while (grub_get_time_ms () < end); ++ ++ return ret; + } + + static int +@@ -208,6 +211,7 @@ + char login[1024]; + struct grub_auth_user *cur = NULL; + grub_err_t err; ++ static unsigned long punishment_delay = 1; + + auto int hook (grub_list_t item); + int hook (grub_list_t item) +@@ -228,11 +232,14 @@ + grub_memset (login, 0, sizeof (login)); + + if (is_authenticated (userlist)) +- return GRUB_ERR_NONE; ++ { ++ punishment_delay = 1; ++ return GRUB_ERR_NONE; ++ } + + if (!grub_cmdline_get ("Enter username: ", login, sizeof (login) - 1, + 0, 0, 0)) +- return GRUB_ACCESS_DENIED; ++ goto access_denied; + + grub_list_iterate (GRUB_AS_LIST (users), hook); + +@@ -242,15 +249,25 @@ + + /* No users present at all. */ + if (!cur) +- return GRUB_ACCESS_DENIED; ++ goto access_denied; + + /* Display any of available authentication schemes. */ + err = cur->callback (login, 0); + +- return GRUB_ACCESS_DENIED; ++ goto access_denied; + } + err = cur->callback (login, cur->arg); + if (is_authenticated (userlist)) +- return GRUB_ERR_NONE; ++ { ++ punishment_delay = 1; ++ return GRUB_ERR_NONE; ++ } ++ ++ access_denied: ++ grub_sleep (punishment_delay); ++ ++ if (punishment_delay < GRUB_ULONG_MAX / 2) ++ punishment_delay *= 2; ++ + return GRUB_ACCESS_DENIED; + } --- grub2-1.97~beta4.orig/debian/patches/906_grub_extras.diff +++ grub2-1.97~beta4/debian/patches/906_grub_extras.diff @@ -0,0 +1,26 @@ +Index: Makefile.in +=================================================================== +--- Makefile.in (revision 2402) ++++ Makefile.in (working copy) +@@ -143,6 +143,8 @@ + fi + + include $(srcdir)/conf/$(target_cpu)-$(platform).mk ++GRUB_EXTRAS=$(srcdir)/debian/grub-extras ++-include $(GRUB_EXTRAS)/conf/$(target_cpu)-$(platform).mk + + ### General targets. + +Index: autogen.sh +=================================================================== +--- autogen.sh (revision 2402) ++++ autogen.sh (working copy) +@@ -5,7 +5,7 @@ + autoconf + autoheader + echo timestamp > stamp-h.in +-for rmk in conf/*.rmk; do ++for rmk in conf/*.rmk debian/grub-extras/conf/*.rmk; do + ruby genmk.rb < $rmk > `echo $rmk | sed 's/\.rmk$/.mk/'` + done + ./gendistlist.sh > DISTLIST --- grub2-1.97~beta4.orig/debian/patches/902_boot_blocklist_hack.diff +++ grub2-1.97~beta4/debian/patches/902_boot_blocklist_hack.diff @@ -0,0 +1,20 @@ +Index: util/i386/pc/grub-setup.c +=================================================================== +--- util/i386/pc/grub-setup.c (revision 1836) ++++ util/i386/pc/grub-setup.c (working copy) +@@ -383,6 +383,15 @@ + grub_disk_cache_invalidate_all (); + + file = grub_file_open (core_path_dev); ++ ++ if (grub_errno == GRUB_ERR_FILE_NOT_FOUND) ++ { ++ /* Clean the previous grub_errno */ ++ grub_errno = GRUB_ERR_NONE; ++ strcpy (core_path_dev, "/grub/core.img"); ++ file = grub_file_open (core_path_dev); ++ } ++ + if (file) + { + if (grub_file_size (file) != core_size) --- grub2-1.97~beta4.orig/debian/default/grub.md5sum +++ grub2-1.97~beta4/debian/default/grub.md5sum @@ -0,0 +1,2 @@ +dfad90339e4227d432636ed7d4483744 experimental_1.96+20081129-1 +e916b60d7de71969dd7bad5a809fb9dc lenny_1.96+20080724-16 --- grub2-1.97~beta4.orig/debian/default/grub +++ grub2-1.97~beta4/debian/default/grub @@ -0,0 +1,24 @@ +# If you change this file, run 'update-grub' afterwards to update +# /boot/grub/grub.cfg. + +GRUB_DEFAULT=0 +GRUB_HIDDEN_TIMEOUT=0 +GRUB_HIDDEN_TIMEOUT_QUIET=true +GRUB_TIMEOUT=10 +GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" +GRUB_CMDLINE_LINUX="" + +# Uncomment to disable graphical terminal (grub-pc only) +#GRUB_TERMINAL=console + +# The resolution used on graphical terminal +# note that you can use only modes which your graphic card supports via VBE +# you can see them in real GRUB with the command `vbeinfo' +#GRUB_GFXMODE=640x480 + +# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux +#GRUB_DISABLE_LINUX_UUID=true + +# Uncomment to disable generation of recovery mode menu entrys +#GRUB_DISABLE_LINUX_RECOVERY="true" --- grub2-1.97~beta4.orig/debian/legacy/upgrade-from-grub-legacy +++ grub2-1.97~beta4/debian/legacy/upgrade-from-grub-legacy @@ -0,0 +1,38 @@ +#!/bin/bash -e + +if test ! -f /boot/grub/core.img ; then + echo -e "\ncore.img doestn't exist, trying to create it.\n" >&2 + grub-install --no-floppy --grub-setup=/bin/true "(hd0)" > /dev/null +fi + +echo RESET grub-pc/install_devices | debconf-communicate + +# Pretend we're upgrading grub-pc. This will make our postinst DTRT. +/var/lib/dpkg/info/grub-pc.postinst configure dummy-version + +if test ! -f /boot/grub/grub.cfg ; then + echo -e "\nCalling update-grub to generate grub.cfg\n" >&2 + update-grub || cat << EOF +Failed to generate /boot/grub/grub.cfg but GRUB2 has been already installed to +your MBR. +THIS MEANS YOU HAVE CURRENTLY AN UNBOOTABLE SYSTEM. +Either fix the error from update-grub and run $0 again +or install old grub again and run grub-install from it to have again +grub-legacy in your MBR. +EOF +fi + +# These never contain any valuable information, and they aren't useful for +# boot anymore, since we just overwrote MBR/PBR. +rm -f /boot/grub/{{xfs,reiserfs,e2fs,fat,jfs,minix}_stage1_5,stage{1,2}} + +cat << EOF + +GRUB Legacy has been removed, but its configuration files have been preserved, +since this script cannot determine if they contain valuable information. If +you would like to remove the configuration files as well, use the following +command: + + rm -f /boot/grub/menu.lst* + +EOF --- grub2-1.97~beta4.orig/debian/legacy/grub-set-default +++ grub2-1.97~beta4/debian/legacy/grub-set-default @@ -0,0 +1,141 @@ +#! /bin/sh + +# Set a default boot entry for GRUB +# Copyright (C) 2004 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Initialize some variables. +PACKAGE=grub +VERSION=0.97 + +rootdir= +entry= + +# Usage: usage +# Print the usage. +usage () { + cat <. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "grub-set-default (GNU GRUB ${VERSION})" + exit 0 ;; + --root-directory=*) + rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + if test "x$entry" != x; then + echo "More than one entries?" 1>&2 + usage + exit 1 + fi + # We don't care about what the user specified actually. + entry="${option}" ;; + esac +done + +if test "x$entry" = x; then + echo "entry not specified." 1>&2 + usage + exit 1 +fi + +find_grub_dir () +{ + echo -n "Searching for GRUB installation directory ... " >&2 + + for d in $grub_dirs ; do + if [ -d "$d" ] ; then + grub_dir="$d" + break + fi + done + + if [ -z "$grub_dir" ] ; then + abort "No GRUB directory found.\n###" + else + echo "found: $grub_dir" >&2 + fi + + echo $grub_dir +} + +grub_dirs="/boot/grub /boot/boot/grub" + +# Determine the GRUB directory. This is different among OSes. +# if rootdir has been informed use it or find grubdir otherwise +if [ -n "${rootdir}" ]; then + grubdir=${rootdir}/boot/grub + if test -d ${grubdir}; then + : + else + grubdir=${rootdir}/grub + if test -d ${grubdir}; then + : + else + echo "No GRUB directory found under ${rootdir}/" 1>&2 + exit 1 + fi + fi +else + grubdir=$(find_grub_dir) +fi + +file=${grubdir}/default +if test -f ${file}; then + chmod 0600 ${file} + rm -f ${file} +fi +cat < $file +$entry +# +# +# +# +# +# +# +# +# +# +# WARNING: If you want to edit this file directly, do not remove any line +# from this file, including this warning. Using \`grub-set-default\' is +# strongly recommended. +EOF + +# Bye. +exit 0 --- grub2-1.97~beta4.orig/debian/legacy/update-grub +++ grub2-1.97~beta4/debian/legacy/update-grub @@ -0,0 +1,1094 @@ +#!/bin/bash +# +# Insert a list of installed kernels in a grub config file +# Copyright 2001 Wichert Akkerman +# Copyright (C) 2007,2008 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . +# +# Contributors: +# Jason Thomas +# David B.Harris +# Marc Haber +# Crispin Flowerday + +# Abort on errors +set -e + +host_os=`uname -s | tr '[A-Z]' '[a-z]'` + +abort() { + message=$@ + + echo >&2 + echo -e "$message" >&2 + echo >&2 + exit 1 +} + +find_grub_dir () +{ + echo -n "Searching for GRUB installation directory ... " >&2 + + for d in /boot/grub /boot/boot/grub ; do + if [ -d "$d" ] ; then + grub_dir="$d" + break + fi + done + + if [ -z "$grub_dir" ] ; then + abort "No GRUB directory found.\n To create a template run 'mkdir /boot/grub' first.\n To install grub, install it manually or try the 'grub-install' command.\n ### Warning, grub-install is used to change your MBR. ###" + else + echo "found: $grub_dir" >&2 + fi + + echo $grub_dir +} + +# This function was borrowed from grub2/util/update-grub_lib.in +make_system_path_relative_to_its_root () +{ + path=$1 + # abort if file doesn't exist + if test -e $path ; then : ;else + return 1 + fi + + # canonicalize + if path=`readlink -f $path` ; then : ; else + return 1 + fi + + # if not a directory, climb up to the directory containing it + if test -d $path ; then + dir=$path + else + dir=`echo $path | sed -e "s,/[^/]*$,,g"` + fi + + num=`stat -c %d $dir` + + # this loop sets $dir to the root directory of the filesystem we're inspecting + while : ; do + parent=`readlink -f $dir/..` + if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else + # $parent is another filesystem; we found it. + break + fi + if [ "x$dir" = "x/" ] ; then + # / is our root. + break + fi + dir=$parent + done + + # This function never prints trailing slashes (so that its output can be + # appended a slash unconditionally). Each slash in $dir is considered a + # preceding slash, and therefore the root directory is an empty string. + if [ "$dir" = "/" ] ; then + dir="" + fi + + echo $path | sed -e "s,^$dir,,g" +} + +# The grub installation directory +grub_dir=$(find_grub_dir) + +# Full path to the device.map +device_map=$grub_dir/device.map + +find_device () +{ + if ! test -e ${device_map} ; then + echo quit | grub --batch --no-floppy --device-map=${device_map} > /dev/null + fi + grub-probe --device-map=${device_map} -t device $1 2> /dev/null +} + +# Usage: convert_raid1 os_device +# Checks if os_device is a software raid1. +# If so, converts to first physical device in array. +convert_raid1 () +{ + case $1 in + /dev/md[0-9] | /dev/md/[0-9]) + : ;; # Continue + *) + return 1 ;; + esac + + [ -x /sbin/mdadm ] || return 1 + + # Check that the raid device is raid1 + raidlevel=$(mdadm -D -b $1 | grep "^ARRAY" | \ + sed "s/^.*level=//" | cut -d" " -f1) + [ "$raidlevel" = "raid1" ] || return 1 + + # Take only the first device that makes up the raid + raiddev=$(mdadm -D $1 | grep -A1 "Number" | grep "dev" \ + | sed "s/^.*\(\/dev\/.*\)$/\1/") + [ -n "$raiddev" ] || return 1 + + echo $raiddev + return 0 +} + +# Usage: convert os_device +# Convert an OS device to the corresponding GRUB drive. +convert () { + if ! test -e ${device_map} ; then + echo quit | grub --batch --no-floppy --device-map=${device_map} > /dev/null + fi + GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe --device-map=${device_map} -t drive -d "$1" 2> /dev/null || { + echo "warning: grub-probe can't find drive for $1." >&2 + tmp_map=$(mktemp -t device.map.XXXXXXXX) + grub-mkdevicemap --device-map=${tmp_map} --no-floppy >/dev/null 2>&1 || true + GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe --device-map=${tmp_map} -t drive -d "$1" || { + rm -f ${tmp_map} + return 1 + } + echo "Please check ${device_map}, you might have to regenerate it with grub-mkdevicemap." >&2 + rm -f ${tmp_map} + } +} + +# Usage: convert_default os_device +# Convert an OS device to the corresponding GRUB drive. +convert_default () { + # Check if device is software raid1 array + if tmp_dev=$(convert_raid1 $1 2>/dev/null) ; then + : # Use device returned by convert_raid1 + else + tmp_dev=$1 + fi + + convert $tmp_dev +} + +## Configuration Options + +# Full path to the menu.lst +menu_file_basename=menu.lst +menu_file=$grub_dir/$menu_file_basename + +# Full path to the default file +default_file_basename=default +default_file=$grub_dir/$default_file_basename + +# the device for the / filesystem +root_device=$(find_device "/") + +# loop-AES arranges things so that /dev/loop/X can be our root device, but +# the initrds that Linux uses don't like that. +case ${root_device} in + /dev/loop/*|/dev/loop[0-9]) + root_device=`losetup ${root_device} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` + ;; +esac + +# the device for the /boot filesystem +boot_device=$(find_device "/boot") + +# where grub looks for the kernels at boot time +kernel_dir=`make_system_path_relative_to_its_root /boot` + +# the "-t abstraction" check is a workaround untill #484297 is fixed +if abstraction=`grub-probe -t abstraction --device ${root_device} 2> /dev/null` && [ "$abstraction" = "" ] && \ + root_uuid=`grub-probe --device-map=${device_map} --device ${root_device} --target=fs_uuid 2> /dev/null` && \ + test -e "/dev/disk/by-uuid/${root_uuid}" ; then + linux_root_device=UUID=${root_uuid} +else + linux_root_device=${root_device} +fi + +# Default kernel options, overidden by the kopt statement in the menufile. +kopt="root=$linux_root_device ro" + +# Title +title=$(lsb_release --short --description 2>/dev/null) || title="Ubuntu" + +# should update-grub remember the default entry +updatedefaultentry="false" + +# Drive(in GRUB terms) where the kernel is located. Overridden by the +# groot statement in menufile. +grub_root_device=$(convert_default "$boot_device") + +# should grub create the alternative boot options in the menu + alternative="true" + +# should grub lock the alternative boot options in the menu + lockalternative="false" + +# additional options to use with the default boot option, but not with the +# alternatives + defoptions="quiet splash" + +# should grub lock the old kernels + lockold="false" + +# Xen hypervisor options to use with the default Xen boot option + xenhopt="" + +# Xen Linux kernel options to use with the default Xen boot option + xenkopt="console=tty0" + +# options to use with the alternative boot options + altoptions="(recovery mode) single" + +# controls howmany kernels are listed in the config file, +# this does not include the alternative kernels + howmany="all" + +# should grub create a memtest86 entry + memtest86="true" + +# should grub add "savedefault" to default boot options + savedefault="false" + +# stores the command line arguments + command_line_arguments=$1 + +# does this version of grub support the quiet option? +if [ -f ${grub_dir}/installed-version ] && dpkg --compare-versions `cat ${grub_dir}/installed-version` ge 0.97-11ubuntu4; then + supports_quiet=true +else + supports_quiet=false +fi + +# read user configuration +if test -f "/etc/default/grub" ; then + . /etc/default/grub +fi + +# Default options to use in a new config file. This will only be used if $menu_file +# doesn't already exist. Only edit the lines between the two "EOF"s. The others are +# part of the script. +newtemplate=$(tempfile) +cat > "$newtemplate" <&2 +if [ -f "$default_file" ] ; then + echo "found: $default_file" >&2 +else + echo "Generating $default_file file and setting the default boot entry to 0" >&2 + if [ -f /usr/lib/grub-legacy/grub-set-default ] ; then + /usr/lib/grub-legacy/grub-set-default $1 + else + grub-set-default $1 + fi +fi + +# Make sure we use the standard sorting order +LC_COLLATE=C +# Magic markers we use +start="### BEGIN AUTOMAGIC KERNELS LIST" +end="### END DEBIAN AUTOMAGIC KERNELS LIST" + +startopt="## ## Start Default Options ##" +endopt="## ## End Default Options ##" + +# Extract options from config file +ExtractMenuOpt() +{ + opt=$1 + + sed -ne "/^$start\$/,/^$end\$/ { + /^$startopt\$/,/^$endopt\$/ { + /^# $opt=/ { + s/^# $opt=\(.*\)\$/\1/ + p + } + } + }" $menu +} + +GetMenuOpts() +{ + opt=$1 + + sed -ne "/^$start\$/,/^$end\$/ { + /^$startopt\$/,/^$endopt\$/ { + /^# $opt=/ { + p + } + } + }" $menu +} + +ExtractMenuOpts() +{ + opt=$1 + + GetMenuOpts $opt | sed "s/^# $opt=\(.*\)\$/\1=\"\2\"/" +} + +GetMenuOpt() +{ + opt=$1 + value=$2 + + [ -z "$(GetMenuOpts "$opt")" ] || value=$(ExtractMenuOpt "$opt") + + echo $value +} + +# Compares two version strings A and B +# Returns -1 if AB +# This compares version numbers of the form +# 2.4.14.2 > 2.4.14 +# 2.4.14random = 2.4.14-random > 2.4.14-ac10 > 2.4.14 > 2.4.14-pre2 > +# 2.4.14-pre1 > 2.4.13-ac99 +CompareVersions() +{ + local a=`echo $1 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\)/~\1/g"` + local b=`echo $2 | sed -e "s,.*/vmlinu[zx]-,,g;s/[._-]\(pre\|rc\|test\|git\)/~\1/g"` + if [ "$a" = "$b" ] ; then + echo 0 + elif dpkg --compare-versions "$a" gt "$b" ; then + echo 1 + else + echo -1 + fi +} + +# looks in the directory specified for an initrd image with the version specified +FindInitrdName() +{ + # strip trailing slashes + directory=$(echo $1 | sed -e 's#/*$##') + version=$2 + + # initrd + # initrd.img + # initrd-lvm + # .*.gz + + initrdName="" + names="initrd initrd.img initrd-lvm" + compressed="gz" + + for n in $names ; do + # make sure we haven't already found it + if [ -z "$initrdName" ] ; then + if [ -f "$directory/$n$version" ] ; then + initrdName="$n$version" + break + else + for c in $compressed ; do + if [ -f "$directory/$n$version.$c" ] ; then + initrdName="$n$version.$c" + break + fi + done + fi + else + break + fi + done + + # return the result + echo $initrdName +} + +FindXenHypervisorVersions () +{ + version=$1 + + if [ -f "/var/lib/linux-image-$version/xen-versions" ]; then + ret="$(cat /var/lib/linux-image-$version/xen-versions)" + fi + + echo $ret +} + +get_kernel_opt() +{ + kernel_version=$1 + + version=$(echo $kernel_version | sed 's/^[^0-9]*//') + version=$(echo $version | sed 's/[-\+\.]/_/g') + if [ -n "$version" ] ; then + while [ -n "$version" ] ; do + currentOpt="$(eval "echo \${kopt_$version}")" + if [ -n "$currentOpt" ] ; then + break + fi + version=$(echo $version | sed 's/_\?[^_]*$//') + done + fi + + if [ -z "$currentOpt" ] ; then + currentOpt=$kopt + fi + + echo $currentOpt +} + +write_kernel_entry() +{ + local kernel_version; kernel_version=$1; shift + local recovery_desc; recovery_desc=$1; shift + local lock_alternative; lock_alternative=$1; shift + local grub_root_device; grub_root_device=$1; shift + local kernel; kernel=$1; shift + local kernel_options; kernel_options=$1; shift + local recovery_suffix; recovery_suffix=$1; shift + local initrd; initrd=$1; shift + local savedefault; savedefault=$1; shift + local lockold; lockold=$1; shift + local hypervisor + if [ -n "$1" ]; then + # Hypervisor. + hypervisor=$1; shift + local hypervisor_image; hypervisor_image=$1; shift + local hypervisor_version; hypervisor_version=$1; shift + local hypervisor_options; hypervisor_options=$1; shift + fi + + local grub_root_type + case "$grub_root_device" in + [^A-Za-z0-9]*) grub_root_type='root' ;; + *) grub_root_type='uuid' ;; + esac + + echo -n "title " >> $buffer + + if [ -n "$hypervisor" ]; then + echo -n "$hypervisor $hypervisor_version / " >> $buffer + fi + + echo -n "$title" >> $buffer + if [ -n "$kernel_version" ]; then + echo -n ", " >> $buffer + # memtest86 is not strictly a kernel + if ! echo "$kernel_version" | grep -q ^memtest86; then + echo -n "kernel " >> $buffer + fi + echo -n "$kernel_version" >> $buffer + fi + if [ -n "$recovery_desc" ]; then + echo -n " $recovery_desc" >> $buffer + fi + echo >> $buffer + + # lock the alternative options + if test x"$lock_alternative" = x"true" ; then + echo "lock" >> $buffer + fi + # lock the old entries + if test x"$lockold" = x"true" ; then + echo "lock" >> $buffer + fi + + echo "$grub_root_type $grub_root_device" >> $buffer + + echo -n "kernel " >> $buffer + if [ -n "$hypervisor" ]; then + echo -n "$hypervisor_image" >> $buffer + if [ -n "$hypervisor_options" ]; then + echo -n " $hypervisor_options" >> $buffer + fi + echo >> $buffer + echo -n "module " >> $buffer + fi + echo -n "$kernel" >> $buffer + if [ -n "$kernel_options" ]; then + echo -n " $kernel_options" >> $buffer + fi + if [ -n "$recovery_desc" ]; then + echo -n " $recovery_suffix" >> $buffer + fi + echo >> $buffer + + if [ -n "$initrd" ]; then + if [ -n "$hypervisor" ]; then + echo -n "module " >> $buffer + else + echo -n "initrd " >> $buffer + fi + echo "$initrd" >> $buffer + fi + + if [ ! -n "$recovery_desc" -a x"$supports_quiet" = x"true" ]; then + echo "quiet" >> $buffer + fi + + if test x"$savedefault" = x"true" ; then + echo "savedefault" >> $buffer + fi + echo >> $buffer +} + + +echo -n "Testing for an existing GRUB $menu_file_basename file ... " >&2 + +# Test if our menu file exists +if [ -f "$menu_file" ] ; then + menu="$menu_file" + rm -f $newtemplate + unset newtemplate + echo "found: $menu_file" >&2 + cp -f "$menu_file" "$menu_file~" +else + # if not ask user if they want us to create one + menu="$menu_file" + echo >&2 + echo >&2 + if [ "-y" = "$command_line_arguments" ] ; then + echo "Warning: ignoring deprecated -y option." >&2 + fi + echo >&2 + echo "Generating $menu_file" >&2 + cat "$newtemplate" > $menu_file + rm -f $newtemplate + unset newtemplate +fi + +# Extract the kernel options to use +kopt=$(GetMenuOpt "kopt" "$kopt") + +# Set the kernel 2.6 option only for fresh install +test -z "$(GetMenuOpt "kopt" "")" && kopt_2_6="root=$linux_root_device ro" + +# Extract options for specific kernels +opts="$(ExtractMenuOpts "\(kopt_[[:alnum:]_]\+\)")" +test -z "$opts" || eval "$opts" +CustomKopts=$(GetMenuOpts "\(kopt_[[:alnum:]_]\+\)") + +# Extract the grub root +grub_root_device=$(GetMenuOpt "groot" "$grub_root_device") + +# Extract the old recovery value +alternative=$(GetMenuOpt "recovery" "$alternative") + +# Extract the alternative value +alternative=$(GetMenuOpt "alternative" "$alternative") + +# Extract the lockalternative value +lockalternative=$(GetMenuOpt "lockalternative" "$lockalternative") + +# Extract the additional default options +defoptions=$(GetMenuOpt "defoptions" "$defoptions") + +# Extract the lockold value +lockold=$(GetMenuOpt "lockold" "$lockold") + +# Extract Xen hypervisor options +xenhopt=$(GetMenuOpt "xenhopt" "$xenhopt") + +# Extract Xen Linux kernel options +xenkopt=$(GetMenuOpt "xenkopt" "$xenkopt") + +# Extract the howmany value +howmany=$(GetMenuOpt "howmany" "$howmany") + +# Extract the memtest86 value +memtest86=$(GetMenuOpt "memtest86" "$memtest86") + + +# Extract the updatedefaultentry option +updatedefaultentry=$(GetMenuOpt "updatedefaultentry" "$updatedefaultentry") + +# Extract the savedefault option +savedefault=$(GetMenuOpt "savedefault" "$savedefault") + +# Generate the menu options we want to insert +buffer=$(tempfile) +echo $start >> $buffer +echo "## lines between the AUTOMAGIC KERNELS LIST markers will be modified" >> $buffer +echo "## by the debian update-grub script except for the default options below" >> $buffer +echo >> $buffer +echo "## DO NOT UNCOMMENT THEM, Just edit them to your needs" >> $buffer +echo >> $buffer +echo "## ## Start Default Options ##" >> $buffer + +echo "## default kernel options" >> $buffer +echo "## default kernel options for automagic boot options" >> $buffer +echo "## If you want special options for specific kernels use kopt_x_y_z" >> $buffer +echo "## where x.y.z is kernel version. Minor versions can be omitted." >> $buffer +echo "## e.g. kopt=root=/dev/hda1 ro" >> $buffer +echo "## kopt_2_6_8=root=/dev/hdc1 ro" >> $buffer +echo "## kopt_2_6_8_2_686=root=/dev/hdc2 ro" >> $buffer +echo "# kopt=$kopt" >> $buffer +if [ -n "$CustomKopts" ] ; then + echo "$CustomKopts" >> $buffer +elif [ -n "$kopt_2_6" ] && [ "$kopt" != "$kopt_2_6" ]; then + echo "# kopt_2_6=$kopt_2_6" >> $buffer +fi +echo >> $buffer + +echo "## default grub root device" >> $buffer +echo "## e.g. groot=(hd0,0)" >> $buffer +echo "# groot=$grub_root_device" >> $buffer +echo >> $buffer + +echo "## should update-grub create alternative automagic boot options" >> $buffer +echo "## e.g. alternative=true" >> $buffer +echo "## alternative=false" >> $buffer +echo "# alternative=$alternative" >> $buffer +echo >> $buffer + +echo "## should update-grub lock alternative automagic boot options" >> $buffer +echo "## e.g. lockalternative=true" >> $buffer +echo "## lockalternative=false" >> $buffer +echo "# lockalternative=$lockalternative" >> $buffer +echo >> $buffer + +echo "## additional options to use with the default boot option, but not with the" >> $buffer +echo "## alternatives" >> $buffer +echo "## e.g. defoptions=vga=791 resume=/dev/hda5" >> $buffer +echo "# defoptions=$defoptions" >> $buffer +echo >> $buffer + +echo "## should update-grub lock old automagic boot options" >> $buffer +echo "## e.g. lockold=false" >> $buffer +echo "## lockold=true" >> $buffer +echo "# lockold=$lockold" >> $buffer +echo >> $buffer + +echo "## Xen hypervisor options to use with the default Xen boot option" >> $buffer +echo "# xenhopt=$xenhopt" >> $buffer +echo >> $buffer + +echo "## Xen Linux kernel options to use with the default Xen boot option" >> $buffer +echo "# xenkopt=$xenkopt" >> $buffer +echo >> $buffer + +echo "## altoption boot targets option" >> $buffer +echo "## multiple altoptions lines are allowed" >> $buffer +echo "## e.g. altoptions=(extra menu suffix) extra boot options" >> $buffer +echo "## altoptions=(recovery) single" >> $buffer + +if ! grep -q "^# altoptions" $menu ; then + echo "# altoptions=$altoptions" >> $buffer +else + grep "^# altoptions" $menu >> $buffer +fi +echo >> $buffer + +echo "## controls how many kernels should be put into the $menu_file_basename" >> $buffer +echo "## only counts the first occurence of a kernel, not the" >> $buffer +echo "## alternative kernel options" >> $buffer +echo "## e.g. howmany=all" >> $buffer +echo "## howmany=7" >> $buffer +echo "# howmany=$howmany" >> $buffer +echo >> $buffer + + +echo "## should update-grub create memtest86 boot option" >> $buffer +echo "## e.g. memtest86=true" >> $buffer +echo "## memtest86=false" >> $buffer +echo "# memtest86=$memtest86" >> $buffer +echo >> $buffer + +echo "## should update-grub adjust the value of the default booted system" >> $buffer +echo "## can be true or false" >> $buffer +echo "# updatedefaultentry=$updatedefaultentry" >> $buffer +echo >> $buffer + +echo "## should update-grub add savedefault to the default options" >> $buffer +echo "## can be true or false" >> $buffer +echo "# savedefault=$savedefault" >> $buffer +echo >> $buffer + +echo "## ## End Default Options ##" >> $buffer +echo >> $buffer + +echo -n "Searching for splash image ... " >&2 +current_splash=`grep '^splashimage=' ${menu_file} || true` +grub_dir_rel=`make_system_path_relative_to_its_root $grub_dir` +splashimage_path="splashimage=${grub_root_device}/${grub_dir_rel##${kernel_dir}}/splash.xpm.gz" +if [ `sed -e "/^$start/,/^$end/d" $menu_file | grep -c '^splashimage='` != "0" ] ; then + #checks for splashscreen defined outside the autoupdated part + splashimage=$(grep '^splashimage=' ${menu_file}) + echo "found: ${splashimage##*=}" >&2 + echo >&2 +elif [ -f "${grub_dir}/splash.xpm.gz" ] && [ "$current_splash" = "" ]; then + echo "found: /boot/grub/splash.xpm.gz" >&2 + echo "$splashimage_path" >> $buffer + echo >> $buffer +elif [ -f "${grub_dir}/splash.xpm.gz" ] && [ "$current_splash" = "$splashimage_path" ]; then + echo "found: /boot/grub/splash.xpm.gz" >&2 + echo "$splashimage_path" >> $buffer + echo >> $buffer +elif [ "$current_splash" != "" ] && [ "$current_splash" != "$splashimage_path" ]; then + echo "found but preserving previous setting: $(grep '^splashimage=' ${menu_file})" >&2 + echo "$current_splash" >> $buffer + echo >> $buffer +else + echo "none found, skipping ..." >&2 +fi + +xen0Kernels="" +# First kernels with xen0 support. +for ver in `grep -l CONFIG_XEN=y /boot/config* | sed -e s%/boot/config-%%`; do + if ! grep -q CONFIG_XEN_PRIVILEGED_GUEST=y /boot/config-$ver ; then + continue + fi + # ver is a kernel version + kern="/boot/vmlinuz-$ver" + if [ -r $kern ] ; then + newerKernels="" + for i in $xen0Kernels ; do + res=$(CompareVersions "$kern" "$i") + if [ "$kern" != "" ] && [ "$res" -gt 0 ] ; then + newerKernels="$newerKernels $kern $i" + kern="" + else + newerKernels="$newerKernels $i" + fi + done + if [ "$kern" != "" ] ; then + newerKernels="$newerKernels $kern" + fi + xen0Kernels="$newerKernels" + fi +done + +sortedKernels="" +for kern in $(/bin/ls -1vr /boot | grep -v "dpkg-*" | grep "^vmlinuz-") ; do + kern="/boot/$kern" + newerKernels="" + for i in $sortedKernels ; do + res=$(CompareVersions "$kern" "$i") + if [ "$kern" != "" ] && [ "$res" -gt 0 ] ; then + newerKernels="$newerKernels $kern $i" + kern="" + else + newerKernels="$newerKernels $i" + fi + done + if [ "$kern" != "" ] ; then + newerKernels="$newerKernels $kern" + fi + sortedKernels="$newerKernels" +done + +if test -f "/boot/vmlinuz.old" ; then + sortedKernels="/boot/vmlinuz.old $sortedKernels" +fi +if test -f "/boot/vmlinuz" ; then + sortedKernels="/boot/vmlinuz $sortedKernels" +fi + +hypervisors="" +for hyp in /boot/xen-*.gz; do + if [ ! -h "$hyp" ] && [ -f "$hyp" ]; then + hypervisors="$hypervisors `basename "$hyp"`" + fi +done + +#Finding the value the default line +use_grub_set_default="false" +if test "$updatedefaultentry" = "true" ; then + defaultEntryNumber=$(sed -ne 's/^[[:blank:]]*default[[:blank:]]*\(.*\).*/\1/p' $menu) + + if [ "$defaultEntryNumber" = "saved" ] ; then + defaultEntryNumber=$(sed 'q' "$grub_dir/default") + use_grub_set_default="true" + fi + + if test -n "$defaultEntryNumber"; then + defaultEntryNumberPlusOne=$(expr $defaultEntryNumber \+ 1); + defaultEntry=$(grep "^[[:blank:]]*title" $menu | sed -ne "${defaultEntryNumberPlusOne}p" | sed -ne ";s/^[[:blank:]]*title[[:blank:]]*//p") + defaultEntry=$(echo $defaultEntry | sed -e "s/[[:blank:]]*$//") # don't trust trailing blanks + else + notChangeDefault="yes" + fi +else + notChangeDefault="yes" +fi + +## heres where we start writing out the kernel entries +counter=0 + +case "$grub_root_device" in +[^A-Za-z0-9]*) grub_root_type='root' ;; +*) grub_root_type='uuid' ;; +esac + +grub2name="${kernel_dir}/grub/core.img" +if [ "$LET_US_TRY_GRUB_2" = "true" ] \ + && test -f /boot/grub/core.img ; then + echo "Found GRUB 2: $grub2name" >&2 + cat >> $buffer << EOF +title Chainload into GRUB 2 +$grub_root_type $grub_root_device +kernel $grub2name + +title `echo ───────────────────────────────────────────────────────────────────── | iconv -f utf-8 -t cp437` +root + +title When you have verified GRUB 2 works, you can use this command to +root + +title complete the upgrade: upgrade-from-grub-legacy +root + +title `echo ───────────────────────────────────────────────────────────────────── | iconv -f utf-8 -t cp437` +root + +EOF +fi + + +# Xen entries first. +for kern in $xen0Kernels ; do + if test ! x"$howmany" = x"all" ; then + if [ $counter -gt $howmany ] ; then + break + fi + fi + + kernelName=$(basename $kern) + kernelVersion=$(echo $kernelName | sed -e 's/vmlinuz//') + + initrdName=$(FindInitrdName "/boot" "$kernelVersion") + initrd="" + + kernel=$kernel_dir/$kernelName + if [ -n "$initrdName" ] ; then + initrd=$kernel_dir/$initrdName + fi + + kernelVersion=$(echo $kernelVersion | sed -e 's/^-//') + currentOpt=$(get_kernel_opt $kernelVersion) + + hypervisorVersions=$(FindXenHypervisorVersions "$kernelVersion") + + found= + for hypervisorVersion in $hypervisorVersions; do + hypervisor="$kernel_dir/xen-$hypervisorVersion.gz" + if [ -e "$hypervisor" ]; then + found=1 + + echo "Found Xen hypervisor $hypervisorVersion, kernel: $kernel" >&2 + + write_kernel_entry "$kernelVersion" '' '' "$grub_root_device" \ + "$kernel" "$currentOpt $xenkopt" '' "$initrd" "$savedefault" '' \ + Xen "$hypervisor" "$hypervisorVersion" "$xenhopt" + counter=$(($counter + 1)) + fi + done + + if [ -z $found ]; then + for hypervisor in $hypervisors; do + hypVersion=`basename "$hypervisor" .gz | sed s%xen-%%` + + echo "Found Xen hypervisor $hypVersion, kernel: $kernel" >&2 + + write_kernel_entry "$kernelVersion" '' '' "$grub_root_device" \ + "$kernel" "$currentOpt $xenkopt" '' "$initrd" "$savedefault" '' \ + Xen "$kernel_dir/$hypervisor" "$hypVersion" "$xenhopt" + counter=$(($counter + 1)) + done + fi +done + +for kern in $sortedKernels ; do + counter=$(($counter + 1)) + if test ! x"$howmany" = x"all" ; then + if [ $counter -gt $howmany ] ; then + break + fi + fi + kernelName=$(basename $kern) + kernelVersion=$(echo $kernelName | sed -e 's/vmlinuz//') + initrdName=$(FindInitrdName "/boot" "$kernelVersion") + initrd="" + + kernel=$kernel_dir/$kernelName + if [ -n "$initrdName" ] ; then + initrd=$kernel_dir/$initrdName + fi + + echo "Found kernel: $kernel" >&2 + + if [ "$kernelName" = "vmlinuz" ]; then + if [ -L "/boot/$kernelName" ]; then + kernelVersion=`readlink -f "/boot/$kernelName"` + kernelVersion=$(echo $kernelVersion | sed -e 's/.*vmlinuz-//') + kernelVersion="$kernelVersion Default" + else + kernelVersion="Default" + fi + fi + if [ "$kernelName" = "vmlinuz.old" ]; then + if [ -L "/boot/$kernelName" ]; then + kernelVersion=`readlink -f "/boot/$kernelName"` + kernelVersion=$(echo $kernelVersion | sed -e 's/.*vmlinuz-//') + kernelVersion="$kernelVersion Previous" + else + kernelVersion="Previous" + fi + fi + kernelVersion=$(echo $kernelVersion | sed -e 's/^-//') + + currentOpt=$(get_kernel_opt $kernelVersion) + + do_lockold=$lockold + # do not lockold for the first entry + [ $counter -eq 1 ] && do_lockold=false + + write_kernel_entry "$kernelVersion" "" "" "$grub_root_device" "$kernel" \ + "$currentOpt $defoptions" "" "$initrd" "$savedefault" "$do_lockold" + + # insert the alternative boot options + if test ! x"$alternative" = x"false" ; then + # for each altoptions line do this stuff + sed -ne 's/# altoptions=\(.*\)/\1/p' $buffer | while read line; do + descr=$(echo $line | sed -ne 's/\(([^)]*)\)[[:space:]]\(.*\)/\1/p') + suffix=$(echo $line | sed -ne 's/\(([^)]*)\)[[:space:]]\(.*\)/\2/p') + + test x"$lockalternative" = x"true" && do_lockold=false + write_kernel_entry "$kernelVersion" "$descr" "$lockalternative" \ + "$grub_root_device" "$kernel" "$currentOpt" "$suffix" "$initrd" \ + "$savedefault" "$do_lockold" + + done + fi +done + +memtest86names="memtest86 memtest86+" + +if test ! x"$memtest86" = x"false" ; then + for name in $memtest86names ; do + if test -f "/boot/$name.bin" ; then + kernelVersion="$name" + kernel="$kernel_dir/$name.bin" + currentOpt= + initrd= + + echo "Found kernel: $kernel" >&2 + + write_kernel_entry "$kernelVersion" "" "" "$grub_root_device" \ + "$kernel" "$currentOpt" "" "$initrd" "false" "" + fi + done +fi + +echo $end >> $buffer + +echo -n "Updating $menu ... " >&2 +# Insert the new options into the menu +if ! grep -q "^$start" $menu ; then + cat $buffer >> $menu + rm -f $buffer +else + umask 077 + sed -e "/^$start/,/^$end/{ + /^$start/r $buffer + d + } + " $menu > $menu.new + cat $menu.new > $menu + rm -f $buffer $menu.new +fi + +# Function to update the default value +set_default_value() { + if [ "$use_grub_set_default" = "true" ] ; then + if [ -f /usr/lib/grub-legacy/grub-set-default ] ; then + /usr/lib/grub-legacy/grub-set-default $1 + else + grub-set-default $1 + fi + else + value="$1" + newmenu=$(tempfile) + sed -e "s/^[[:blank:]]*default[[:blank:]]*[[:digit:]]*\(.*\)/default ${value}\1/;b" $menu > $newmenu + cat $newmenu > $menu + rm -f $newmenu + unset newmenu + fi +} + +#Updating the default number +if [ "$LET_US_TRY_GRUB_2" = "true" ] && test -f /boot/grub/core.img ; then + set_default_value "0" +elif test -z "$notChangeDefault"; then + newDefaultNumberPlusOne=$(grep "^[[:blank:]]*title[[:blank:]]*" $menu | grep -n "${defaultEntry}" | cut -f1 -d ":" | sed -ne "1p") + if test -z "$newDefaultNumberPlusOne"; then + echo "Previous default entry removed, resetting to 0">&2 + set_default_value "0" + elif test -z "$defaultEntry"; then + echo "Value of default value matches no entry, resetting to 0" >&2 + set_default_value "0" + else + if test "$newDefaultNumberPlusOne" = "1"; then + newDefaultNumber="0" + else + newDefaultNumber=$(expr $newDefaultNumberPlusOne - 1) + fi + echo "Updating the default booting kernel">&2 + set_default_value "$newDefaultNumber" + fi +fi + +echo "done" >&2 +echo >&2