From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LXFNJ-00052c-Mu for mharc-grub-devel@gnu.org; Wed, 11 Feb 2009 08:43:37 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LXFNI-00050R-FZ for grub-devel@gnu.org; Wed, 11 Feb 2009 08:43:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LXFNH-0004yK-0I for grub-devel@gnu.org; Wed, 11 Feb 2009 08:43:35 -0500 Received: from [199.232.76.173] (port=51727 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LXFNG-0004xs-Os for grub-devel@gnu.org; Wed, 11 Feb 2009 08:43:34 -0500 Received: from fg-out-1718.google.com ([72.14.220.152]:9274) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LXFNG-0006DD-5N for grub-devel@gnu.org; Wed, 11 Feb 2009 08:43:34 -0500 Received: by fg-out-1718.google.com with SMTP id l27so66305fgb.30 for ; Wed, 11 Feb 2009 05:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=NgwxhHbiqpXeYsXy5m5hicw+JV+Hi+eeR8nBkmNglNI=; b=Rh2y3OfuxP4VvAm7qrxP/S+tpeXpMXd+rY5A2Q3M+6cIu4XnQ2hDeVthCwbLxotcnx GSPLOZHl2SZQOP0G1mVo5gtOAmxTIWQFTIiQqR0lwfIqWjCSlj1F3zm7BkYIC2oQh2Qz zoxjO0lBc1bgvHdIhWBGNv6D9r4S2N2m9CI24= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=xmOOfea8uHpiSz13/fLG/mhjx5QqJFqtrgR7C/fmvSy+aM+/Z6Eg0Ca4W5Cjglqe2O PgCr6DjM0Zh+qnjlfxN4HELOrurJcUDYdOHCxcKJ5Lkx49AtQ7LpGxE8ARD2ci406QQB og0UdP3XibUMuWj3H3o/Uw0GzRhL7nbYEAiXY= Received: by 10.86.59.18 with SMTP id h18mr644533fga.45.1234359813134; Wed, 11 Feb 2009 05:43:33 -0800 (PST) Received: from ?192.168.1.25? (230-40.1-85.cust.bluewin.ch [85.1.40.230]) by mx.google.com with ESMTPS id l12sm599341fgb.1.2009.02.11.05.43.31 (version=SSLv3 cipher=RC4-MD5); Wed, 11 Feb 2009 05:43:32 -0800 (PST) Message-ID: <4992D603.9030105@gmail.com> Date: Wed, 11 Feb 2009 14:43:31 +0100 From: phcoder User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: The development of GRUB 2 Content-Type: multipart/mixed; boundary="------------050309030908050600060401" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] make partition active X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2009 13:43:36 -0000 This is a multi-part message in MIME format. --------------050309030908050600060401 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Here's the patch to add a replacement for old "makeactive" command New syntax is activate PARTITION E.g. activate hd0,1 Regards Vladimir 'phcoder' Serbinenko --------------050309030908050600060401 Content-Type: text/x-diff; name="activate.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="activate.patch" Index: ChangeLog =================================================================== --- ChangeLog (revision 1989) +++ ChangeLog (working copy) @@ -1,3 +1,11 @@ +2009-02-11 Vladimir Serbinenko + + New command: "activate" replacement for makeactive of grub1 + + * commands/i386/pc/activate.c: new file + * conf/i386-pc.rmk: new module activate.mod + add commands/i386/pc/activate.c to grub-emu sources + 2009-02-11 Robert Millan * util/grub.d/00_header.in: Update old reference to `font' command. Index: conf/i386-pc.rmk =================================================================== --- conf/i386-pc.rmk (revision 1989) +++ conf/i386-pc.rmk (working copy) @@ -145,4 +145,4 @@ \ disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \ disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \ - grub_emu_init.c + grub_emu_init.c commands/i386/pc/activate.c grub_emu_LDFLAGS = $(LIBCURSES) ifeq ($(enable_grub_emu_usb), yes) @@ -171,3 +170,3 @@ vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \ ata.mod vga.mod memdisk.mod pci.mod lspci.mod \ aout.mod _bsd.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \ datehook.mod lsmmap.mod \ - usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod + usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod activate.mod +# For activate.mod. +activate_mod_SOURCES = commands/i386/pc/activate.c +activate_mod_CFLAGS = $(COMMON_CFLAGS) +activate_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For biosdisk.mod. biosdisk_mod_SOURCES = disk/i386/pc/biosdisk.c biosdisk_mod_CFLAGS = $(COMMON_CFLAGS) Index: commands/i386/pc/activate.c =================================================================== --- commands/i386/pc/activate.c (revision 0) +++ commands/i386/pc/activate.c (revision 0) @@ -0,0 +1,114 @@ +/* activate.c - activate pc partition */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003 Free Software Foundation, Inc. + * Copyright (C) 2003 NIIBE Yutaka + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static grub_err_t +grub_cmd_activate (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) +{ + + grub_device_t dev; + struct grub_pc_partition_mbr mbr; + grub_partition_t part; + + int i, index; + + if (argc > 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments"); + + if (!argc) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "too few arguments"); + + dev = grub_device_open (args[0]); + + if (!dev) + return grub_errno; + + if (!dev->disk) + { + grub_device_close (dev); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a disk"); + } + + if (!dev->disk->partition) + { + grub_device_close (dev); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a partition"); + } + + if (grub_strcmp (dev->disk->partition->partmap->name, "pc_partition_map")) + { + grub_device_close (dev); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a pc partition"); + } + + if (dev->disk->partition->offset) + { + grub_device_close (dev); + return grub_error (GRUB_ERR_BAD_ARGUMENT, "not a primary partition"); + } + + index = dev->disk->partition->index; + part = dev->disk->partition; + dev->disk->partition = 0; + + /* Read the MBR. */ + if (grub_disk_read (dev->disk, 0, 0, sizeof (mbr), (char *) &mbr)) + { + dev->disk->partition = part; + grub_device_close (dev); + return grub_errno; + } + + for (i = 0; i < 4; i++) + mbr.entries[i].flag = 0x0; + + mbr.entries[index].flag = 0x80; + + /* Write the MBR. */ + grub_disk_write (dev->disk, 0, 0, sizeof (mbr), (char *) &mbr); + dev->disk->partition = part; + grub_device_close (dev); + return grub_errno; + +} + +GRUB_MOD_INIT(activate) +{ + (void)mod; /* To stop warning. */ + grub_register_command ("activate", grub_cmd_activate, GRUB_COMMAND_FLAG_BOTH, + "activate PARTITION", "set active flag to PARTITION", 0); +} + +GRUB_MOD_FINI(activate) +{ + grub_unregister_command ("activate"); +} --------------050309030908050600060401--