/* gptsync.c - fill the mbr based on gpt entries */
/* XXX: I don't know what to do if sector size isn't 512 bytes */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <grub/msdos_partition.h>
#include <grub/partition.h>
GRUB_MOD_LICENSE ("GPLv3+");
/* Convert a LBA address to a CHS address in the INT 13 format. */
/* Taken from grub1. */
/* XXX: use hardcoded geometry of C = 1024, H = 255, S = 63.
Is it a problem?
*/
static void
{
{
return;
}
}
static grub_err_t
{
int numactive = 0;
if (argc < 1)
if (argc > 4)
"in hybrid MBR");
{
}
else
if (! dev)
return grub_errno;
{
}
/* Read the protective MBR. */
{
return grub_errno;
}
/* Check if it is valid. */
{
}
/* Make sure the MBR is a protective MBR and not a normal MBR. */
{
}
int i;
for (i = 1; i < argc; i++)
{
if (! separator)
if (separator)
{
*separator = 0;
}
if (separator)
if (! partition)
{
}
{
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"only partitions residing in the first 2TB "
"can be present in hybrid MBR");
}
else
{
/* Unknown filesystem isn't fatal. */
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
{
fs = 0;
}
/* FIXME: detect FAT16. */
else
/* FIXME: detect more types. */
}
if (csep == '+')
{
numactive++;
if (numactive == 2)
{
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"only one partition can be active");
}
}
}
for (; i < 4; i++)
/* The protective partition. */
if (first_sector > 0xffffffff)
first_sector = 0xffffffff;
else
first_sector--;
lba_to_chs (1,
{
return grub_errno;
}
return GRUB_ERR_NONE;
}
{
(void) mod; /* To stop warning. */
N_("DEVICE [PARTITION[+/-[TYPE]]] ..."),
N_("Fill hybrid MBR of GPT drive DEVICE. "
"Specified partitions will be a part "
"of hybrid MBR. Up to 3 partitions are "
"allowed. TYPE is an MBR type. "
"+ means that partition is active. "
"Only one partition can be active."));
}
{
}