/* sunpc.c - Read SUN PC style partition tables. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2006,2007,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/partition.h>
#ifdef GRUB_UTIL
#include <grub/msdos_partition.h>
#endif
GRUB_MOD_LICENSE ("GPLv3+");
{
} __attribute__ ((packed));
struct grub_sun_pc_block
{
} __attribute__ ((packed));
/* Verify checksum (true=ok). */
static int
{
pos++)
return ! sum;
}
static grub_err_t
const struct grub_sun_pc_partition_descriptor *sunpc_partition))
{
union
{
} block;
int partnum;
if (! p)
return grub_errno;
p->partmap = &grub_sun_pc_partition_map;
if (err)
{
grub_free (p);
return err;
}
{
grub_free (p);
return grub_error (GRUB_ERR_BAD_PART_TABLE,
"not a sun_pc partition table");
}
{
grub_free (p);
}
/* Maybe another error value would be better, because partition
table _is_ recognized but invalid. */
{
#ifdef __sun__
/*
* Don't check for V_UNASSIGNED - There is a bug in Solaris 11 where
* VTOCs will be created with the root slice marked as unassigned.
*/
#else
#endif
continue;
if (p->len)
{
}
}
grub_free (p);
return grub_errno;
}
static grub_err_t
{
/*
* Wrap generic hooks so we can just call up to
* sun_pc_partition_map_iterate_extended, above
*/
const grub_partition_t p,
const struct grub_sun_pc_partition_descriptor *sp);
const grub_partition_t p,
const struct grub_sun_pc_partition_descriptor *sp
__attribute__ ((unused)))
{
}
}
#ifdef GRUB_UTIL
static grub_err_t
{
unsigned i;
const grub_partition_t p,
const struct grub_sun_pc_partition_descriptor *sp);
const grub_partition_t p,
const struct grub_sun_pc_partition_descriptor *sp)
{
{
{
/*
* This partition is invalid since its span is beyond the
* containing msdos partition parent.
*/
grub_util_warn("While looking for a suitable sunpc embedding "
"area, sunpc partition %d (size 0x%llx) is being ignored "
"because it exceeds the size of its containing msdos "
if (overlap_firstindex_ignore == -1)
if (p->number != overlap_firstindex_ignore)
return 0;
}
if ((partlen < usablestart) ||
{
grub_dprintf("sunpc",
"Found a sunpc embedding area in sunpc partition %d"
", but it is too small (size=0x%llx). Ignoring.\n",
if (overlap_firstindex_ignore == -1)
if (p->number != overlap_firstindex_ignore)
return 0;
}
if (p->number != overlap_firstindex_ignore &&
overlap_firstindex_ignore != -1)
"overlapping sunpc partitions %d and %d\n",
if (overlap_firstindex == -1)
overlap_firstindex = p->number;
if (p->number != overlap_firstindex)
grub_util_warn("Overlapping sunpc partitions detected (partitions "
"%d and %d). The sunpc partition table is misconfigured "
"and should be repaired as soon as possible to avoid data "
if (foundbootslice == 1)
return 0;
foundbootslice = 1;
else if (found == 1)
return 0;
found = 1;
if (partlen > MAX_NON_BOOTSLICE_BLOCKS)
{
/* Needs revision for sector sizes other than 512 */
}
else
partlen_clamped = 0;
grub_memcpy (bootslicepart, p, sizeof (*p));
}
return 0;
}
if (embed_type != GRUB_EMBED_PCBIOS)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"SUNPC curently supports only PC-BIOS embedding");
return grub_error (GRUB_ERR_BAD_DEVICE,
"sunpc_partition_map_embed: No disk partition");
/* save the partition */
/* we are called either with sx partition or pX partition */
/* save the parent */
{
/* disk->partition corresponds to a primary or logical partition p[1-N] */
}
{
/* disk->partition corresponds to a vtoc slice sX */
}
else
{
/* this is not our partition XXX what to return here*/
return grub_error (GRUB_ERR_BAD_DEVICE,
"sunpc_partition_map_embed: Not a Solaris partition");
}
if (bootslicepart == NULL)
{
"boot slice partition");
}
{
if (err)
return err;
return grub_error (GRUB_ERR_BAD_DEVICE,
"Could not find a suitable boot slice,"
" embedding won't be possible!");
}
if (partlen_clamped != 0)
grub_util_warn("The slice containing the embedding area had a length of "
"0x%llx blocks. Only a maximum of 0x%llx blocks from this"
" slice will be used.\n",
(unsigned long long)partlen_clamped,
(unsigned long long)MAX_NON_BOOTSLICE_BLOCKS);
if (!*sectors) {
}
for (i = 0; i < *nsectors; i++)
(*sectors)[i] = usablestart + i;
return GRUB_ERR_NONE;
}
#endif
/* Partition map type. */
{
.name = "sunpc",
#ifdef GRUB_UTIL
#endif
};
{
}
{
}