Support BtrFS embedding.

* grub-core/fs/btrfs.c (grub_btrfs_embed) [GRUB_UTIL]: New function.
	(grub_btrfs_fs) [GRUB_UTIL]: Set embed.
	* include/grub/fs.h (grub_fs) [GRUB_UTIL]: New field embed.
	* util/grub-setup.c (setup): Use fs embedding if available.
	Add additional sanity check.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-11-05 14:47:25 +01:00
parent 455377d93d
commit c7ba4f6984
4 changed files with 74 additions and 7 deletions

View file

@ -408,29 +408,44 @@ setup (const char *dir,
free (tmp_img);
if (! dest_partmap)
if (! dest_partmap && ! fs)
{
grub_util_warn (_("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea."));
goto unable_to_embed;
}
if (multiple_partmaps || fs)
if (multiple_partmaps || (dest_partmap && fs))
{
grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
goto unable_to_embed;
}
if (!dest_partmap->embed)
if (dest_partmap && !dest_partmap->embed)
{
grub_util_warn ("Partition style '%s' doesn't support embeding",
dest_partmap->name);
goto unable_to_embed;
}
if (fs && !fs->embed)
{
grub_util_warn ("File system '%s' doesn't support embeding",
fs->name);
goto unable_to_embed;
}
nsec = core_sectors;
err = dest_partmap->embed (dest_dev->disk, &nsec,
GRUB_EMBED_PCBIOS, &sectors);
if (nsec > 2 * core_sectors)
nsec = 2 * core_sectors;
if (dest_partmap)
err = dest_partmap->embed (dest_dev->disk, &nsec,
GRUB_EMBED_PCBIOS, &sectors);
else
err = fs->embed (dest_dev, &nsec,
GRUB_EMBED_PCBIOS, &sectors);
if (!err && nsec < core_sectors)
{
err = grub_error (GRUB_ERR_OUT_OF_RANGE,
"Your embedding area is unusually small. "
"core.img won't fit in it.");
}
if (err)
{
@ -439,6 +454,9 @@ setup (const char *dir,
goto unable_to_embed;
}
if (nsec > 2 * core_sectors)
nsec = 2 * core_sectors;
/* Clean out the blocklists. */
block = first_block;
while (block->len)