From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NSWbW-0000I1-G5 for mharc-grub-devel@gnu.org; Wed, 06 Jan 2010 09:11:18 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSWbT-0000EZ-Tm for grub-devel@gnu.org; Wed, 06 Jan 2010 09:11:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSWbO-000059-5x for grub-devel@gnu.org; Wed, 06 Jan 2010 09:11:15 -0500 Received: from [199.232.76.173] (port=41108 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSWbO-00004y-17 for grub-devel@gnu.org; Wed, 06 Jan 2010 09:11:10 -0500 Received: from xvm-190-8.ghst.net ([217.70.190.8]:42402 helo=aybabtu.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSWbM-0007pb-DP for grub-devel@gnu.org; Wed, 06 Jan 2010 09:11:09 -0500 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1NSWHJ-0003no-QV; Wed, 06 Jan 2010 14:50:26 +0100 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1NSWHI-0000cK-VH; Wed, 06 Jan 2010 14:50:24 +0100 Date: Wed, 6 Jan 2010 14:50:24 +0100 From: Robert Millan To: Zhu Yi Message-ID: <20100106135024.GA2360@thorin> References: <1262769004-21960-1-git-send-email-yi.zhu@intel.com> <1262769004-21960-2-git-send-email-yi.zhu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1262769004-21960-2-git-send-email-yi.zhu@intel.com> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: grub-devel@gnu.org, Zhu Yi Subject: Re: [PATCH 2/2] Add grub-install --restore option X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jan 2010 14:11:16 -0000 Hi, On Wed, Jan 06, 2010 at 05:10:04PM +0800, Zhu Yi wrote: > diff --git a/util/i386/pc/grub-install.in b/util/i386/pc/grub-install.in > index 8a06213..4d0043e 100644 > --- a/util/i386/pc/grub-install.in > +++ b/util/i386/pc/grub-install.in > @@ -51,6 +51,7 @@ no_floppy= > force_lba= > recheck=no > debug=no > +restore= > > if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then > disk_module=biosdisk > @@ -77,6 +78,7 @@ Install GRUB on your drive. > --no-floppy do not probe any floppy drive > --recheck probe a device map even if it already exists > --force install even if problems are detected > + --restore restore the previous boot sectors > EOF > if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then > cat < @@ -129,6 +131,10 @@ for option in "$@"; do > debug=yes ;; > -f | --force) > setup_force="--force" ;; > + --restore) > + restore="$grub_prefix/bootsectors.bak" ;; > + --restore=*) > + restore=`echo "$option" | sed 's/--restore=//'` ;; > -*) > echo "Unrecognized option \`$option'" 1>&2 > usage > @@ -203,6 +209,29 @@ else > exit 1 > fi > > +if test -f "$restore"; then > + if test `stat -c%s $restore` -eq 512; then > + dd if=$restore of=$install_device bs=512 count=1 > + exit 0 > + fi > + start=`od -j92 -N8 -An -td8 $grubdir/boot.img` > + > + # Synaty check > + if test $((`stat -c%s $restore` - $start * 512)) -ne \ > + `stat -c%s $grubdir/core.img`; then > + echo "Error: $restore doesn't match core.img, restore aborted." > + exit 1 > + fi > + > + # Restore > + dd if=$restore of=$install_device bs=512 count=1 > /dev/null 2>&1 > + dd if=$restore of=$install_device skip=512 seek=`expr $start \* 512` \ > + bs=1 > /dev/null 2>&1 > + rm -f $restore > + echo "Restore boot sectors from $restore successfully" > + exit 0 > +fi Please don't add this to grub-install. This kind of highly BIOS-specific logic would suit much better in grub-setup. -- Robert Millan "Be the change you want to see in the world" -- Gandhi