remove all trailing whitespace
This commit is contained in:
parent
d2d4966571
commit
b39f9d20a9
222 changed files with 3286 additions and 3286 deletions
|
@ -110,7 +110,7 @@ setup (const char *dir,
|
|||
FILE *fp;
|
||||
struct { grub_uint64_t start; grub_uint64_t end; } embed_region;
|
||||
embed_region.start = embed_region.end = ~0UL;
|
||||
|
||||
|
||||
auto void NESTED_FUNC_ATTR save_first_sector (grub_disk_addr_t sector, unsigned offset,
|
||||
unsigned length);
|
||||
auto void NESTED_FUNC_ATTR save_blocklists (grub_disk_addr_t sector, unsigned offset,
|
||||
|
@ -122,44 +122,44 @@ setup (const char *dir,
|
|||
const grub_partition_t p)
|
||||
{
|
||||
struct grub_pc_partition *pcdata = p->data;
|
||||
|
||||
|
||||
/* There's always an embed region, and it starts right after the MBR. */
|
||||
embed_region.start = 1;
|
||||
|
||||
|
||||
/* For its end offset, include as many dummy partitions as we can. */
|
||||
if (! grub_pc_partition_is_empty (pcdata->dos_type)
|
||||
&& ! grub_pc_partition_is_bsd (pcdata->dos_type)
|
||||
&& embed_region.end > p->start)
|
||||
embed_region.end = p->start;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
auto int NESTED_FUNC_ATTR find_usable_region_gpt (grub_disk_t disk,
|
||||
const grub_partition_t p);
|
||||
int NESTED_FUNC_ATTR find_usable_region_gpt (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p)
|
||||
{
|
||||
struct grub_gpt_partentry *gptdata = p->data;
|
||||
|
||||
|
||||
/* If there's an embed region, it is in a dedicated partition. */
|
||||
if (! memcmp (&gptdata->type, &grub_gpt_partition_type_bios_boot, 16))
|
||||
{
|
||||
embed_region.start = p->start;
|
||||
embed_region.end = p->start + p->len;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void NESTED_FUNC_ATTR save_first_sector (grub_disk_addr_t sector, unsigned offset,
|
||||
unsigned length)
|
||||
{
|
||||
grub_util_info ("the first sector is <%llu,%u,%u>",
|
||||
sector, offset, length);
|
||||
|
||||
|
||||
if (offset != 0 || length != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("The first sector of the core file is not sector-aligned");
|
||||
|
||||
|
@ -173,7 +173,7 @@ setup (const char *dir,
|
|||
|
||||
grub_util_info ("saving <%llu,%u,%u> with the segment 0x%x",
|
||||
sector, offset, length, (unsigned) current_segment);
|
||||
|
||||
|
||||
if (offset != 0 || last_length != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("Non-sector-aligned data is found in the core file");
|
||||
|
||||
|
@ -191,11 +191,11 @@ setup (const char *dir,
|
|||
if (block->len)
|
||||
grub_util_error ("The sectors of the core file are too fragmented");
|
||||
}
|
||||
|
||||
|
||||
last_length = length;
|
||||
current_segment += GRUB_DISK_SECTOR_SIZE >> 4;
|
||||
}
|
||||
|
||||
|
||||
/* Read the boot image by the OS service. */
|
||||
boot_path = grub_util_get_path (dir, boot_file);
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
|
@ -212,7 +212,7 @@ setup (const char *dir,
|
|||
+ GRUB_BOOT_MACHINE_KERNEL_SECTOR);
|
||||
boot_drive_check = (grub_uint16_t *) (boot_img
|
||||
+ GRUB_BOOT_MACHINE_DRIVE_CHECK);
|
||||
|
||||
|
||||
core_path = grub_util_get_path (dir, core_file);
|
||||
core_size = grub_util_get_image_size (core_path);
|
||||
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||
|
@ -221,7 +221,7 @@ setup (const char *dir,
|
|||
grub_util_error ("The size of `%s' is too small", core_path);
|
||||
else if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("The size of `%s' is too large", core_path);
|
||||
|
||||
|
||||
core_img = grub_util_read_image (core_path);
|
||||
|
||||
/* Have FIRST_BLOCK to point to the first blocklist. */
|
||||
|
@ -264,7 +264,7 @@ setup (const char *dir,
|
|||
GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
|
||||
|
||||
free (tmp_img);
|
||||
|
||||
|
||||
/* If DEST_DRIVE is a hard disk, enable the workaround, which is
|
||||
for buggy BIOSes which don't pass boot drive correctly. Instead,
|
||||
they pass 0x00 or 0x01 even when booted from 0x80. */
|
||||
|
@ -304,7 +304,7 @@ setup (const char *dir,
|
|||
dos_part = grub_le_to_cpu32 (*install_dos_part);
|
||||
bsd_part = grub_le_to_cpu32 (*install_bsd_part);
|
||||
}
|
||||
|
||||
|
||||
grub_util_info ("dos partition is %d, bsd partition is %d",
|
||||
dos_part, bsd_part);
|
||||
|
||||
|
@ -319,7 +319,7 @@ setup (const char *dir,
|
|||
grub_util_warn ("Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea.");
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
|
||||
/* Unlike root_dev, with dest_dev we're interested in the partition map even
|
||||
if dest_dev itself is a whole disk. */
|
||||
auto int NESTED_FUNC_ATTR identify_partmap (grub_disk_t disk,
|
||||
|
@ -331,7 +331,7 @@ setup (const char *dir,
|
|||
return 1;
|
||||
}
|
||||
grub_partition_iterate (dest_dev->disk, identify_partmap);
|
||||
|
||||
|
||||
grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "pc_partition_map") ?
|
||||
find_usable_region_gpt : find_usable_region_msdos));
|
||||
if (embed_region.end == embed_region.start)
|
||||
|
@ -356,69 +356,69 @@ setup (const char *dir,
|
|||
|
||||
|
||||
grub_util_info ("will embed the core image at sector 0x%llx", embed_region.start);
|
||||
|
||||
|
||||
*install_dos_part = grub_cpu_to_le32 (dos_part);
|
||||
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
|
||||
|
||||
|
||||
/* The first blocklist contains the whole sectors. */
|
||||
first_block->start = grub_cpu_to_le64 (embed_region.start + 1);
|
||||
first_block->len = grub_cpu_to_le16 (core_sectors - 1);
|
||||
first_block->segment
|
||||
= grub_cpu_to_le16 (GRUB_BOOT_MACHINE_KERNEL_SEG
|
||||
+ (GRUB_DISK_SECTOR_SIZE >> 4));
|
||||
|
||||
|
||||
/* Make sure that the second blocklist is a terminator. */
|
||||
block = first_block - 1;
|
||||
block->start = 0;
|
||||
block->len = 0;
|
||||
block->segment = 0;
|
||||
|
||||
|
||||
/* Write the core image onto the disk. */
|
||||
if (grub_disk_write (dest_dev->disk, embed_region.start, 0, core_size, core_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
|
||||
/* FIXME: can this be skipped? */
|
||||
*boot_drive = 0xFF;
|
||||
*root_drive = 0xFF;
|
||||
|
||||
|
||||
*kernel_sector = grub_cpu_to_le64 (embed_region.start);
|
||||
|
||||
|
||||
/* Write the boot image onto the disk. */
|
||||
if (grub_disk_write (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE,
|
||||
boot_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
|
||||
goto finish;
|
||||
|
||||
|
||||
unable_to_embed:
|
||||
|
||||
|
||||
if (must_embed)
|
||||
grub_util_error ("Embedding is not possible, but this is required when "
|
||||
"the root device is on a RAID array or LVM volume.");
|
||||
|
||||
|
||||
grub_util_warn ("Embedding is not possible. GRUB can only be installed in this "
|
||||
"setup by using blocklists. However, blocklists are UNRELIABLE and "
|
||||
"its use is discouraged.");
|
||||
if (! force)
|
||||
grub_util_error ("If you really want blocklists, use --force.");
|
||||
|
||||
|
||||
/* Make sure that GRUB reads the identical image as the OS. */
|
||||
tmp_img = xmalloc (core_size);
|
||||
core_path_dev = grub_util_get_path (dir, core_file);
|
||||
|
||||
|
||||
/* It is a Good Thing to sync two times. */
|
||||
sync ();
|
||||
sync ();
|
||||
|
||||
#define MAX_TRIES 5
|
||||
|
||||
|
||||
for (i = 0; i < MAX_TRIES; i++)
|
||||
{
|
||||
grub_util_info ("attempting to read the core image `%s' from GRUB%s",
|
||||
core_path_dev, (i == 0) ? "" : " again");
|
||||
|
||||
|
||||
grub_disk_cache_invalidate_all ();
|
||||
|
||||
|
||||
file = grub_file_open (core_path_dev);
|
||||
if (file)
|
||||
{
|
||||
|
@ -434,7 +434,7 @@ unable_to_embed:
|
|||
#if 0
|
||||
FILE *dump;
|
||||
FILE *dump2;
|
||||
|
||||
|
||||
dump = fopen ("dump.img", "wb");
|
||||
if (dump)
|
||||
{
|
||||
|
@ -448,8 +448,8 @@ unable_to_embed:
|
|||
fwrite (core_img, 1, core_size, dump2);
|
||||
fclose (dump2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
grub_util_info ("succeeded in opening the core image but the data is different");
|
||||
}
|
||||
else
|
||||
|
@ -465,7 +465,7 @@ unable_to_embed:
|
|||
|
||||
if (grub_errno)
|
||||
grub_util_info ("error message = %s", grub_errmsg);
|
||||
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
sync ();
|
||||
sleep (1);
|
||||
|
@ -483,16 +483,16 @@ unable_to_embed:
|
|||
block->segment = 0;
|
||||
|
||||
block--;
|
||||
|
||||
|
||||
if ((char *) block <= core_img)
|
||||
grub_util_error ("No terminator in the core image");
|
||||
}
|
||||
|
||||
|
||||
/* Now read the core image to determine where the sectors are. */
|
||||
file = grub_file_open (core_path_dev);
|
||||
if (! file)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
|
||||
file->read_hook = save_first_sector;
|
||||
if (grub_file_read (file, tmp_img, GRUB_DISK_SECTOR_SIZE)
|
||||
!= GRUB_DISK_SECTOR_SIZE)
|
||||
|
@ -505,10 +505,10 @@ unable_to_embed:
|
|||
grub_util_error ("Failed to read the rest sectors of the core image");
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
|
||||
free (core_path_dev);
|
||||
free (tmp_img);
|
||||
|
||||
|
||||
*kernel_sector = grub_cpu_to_le64 (first_sector);
|
||||
|
||||
/* FIXME: can this be skipped? */
|
||||
|
@ -535,7 +535,7 @@ unable_to_embed:
|
|||
|
||||
/* Sync is a Good Thing. */
|
||||
sync ();
|
||||
|
||||
|
||||
free (core_path);
|
||||
free (core_img);
|
||||
free (boot_img);
|
||||
|
@ -591,7 +591,7 @@ static char *
|
|||
get_device_name (char *dev)
|
||||
{
|
||||
size_t len = strlen (dev);
|
||||
|
||||
|
||||
if (dev[0] != '(' || dev[len - 1] != ')')
|
||||
return 0;
|
||||
|
||||
|
@ -609,7 +609,7 @@ main (int argc, char *argv[])
|
|||
char *root_dev = 0;
|
||||
char *dest_dev;
|
||||
int must_embed = 0, force = 0;
|
||||
|
||||
|
||||
progname = "grub-setup";
|
||||
|
||||
/* Check for options. */
|
||||
|
@ -642,7 +642,7 @@ main (int argc, char *argv[])
|
|||
|
||||
dir = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
|
||||
case 'm':
|
||||
if (dev_map)
|
||||
free (dev_map);
|
||||
|
@ -656,7 +656,7 @@ main (int argc, char *argv[])
|
|||
|
||||
root_dev = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
|
||||
case 'f':
|
||||
force = 1;
|
||||
break;
|
||||
|
@ -700,7 +700,7 @@ main (int argc, char *argv[])
|
|||
|
||||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
|
||||
|
||||
dest_dev = get_device_name (argv[optind]);
|
||||
if (! dest_dev)
|
||||
{
|
||||
|
@ -722,7 +722,7 @@ main (int argc, char *argv[])
|
|||
|
||||
if (! tmp)
|
||||
grub_util_error ("Invalid root device `%s'", root_dev);
|
||||
|
||||
|
||||
tmp = xstrdup (tmp);
|
||||
free (root_dev);
|
||||
root_dev = tmp;
|
||||
|
@ -741,7 +741,7 @@ main (int argc, char *argv[])
|
|||
#ifdef __linux__
|
||||
if (grub_util_lvm_isvolume (root_dev))
|
||||
must_embed = 1;
|
||||
|
||||
|
||||
if (root_dev[0] == 'm' && root_dev[1] == 'd'
|
||||
&& root_dev[2] >= '0' && root_dev[2] <= '9')
|
||||
{
|
||||
|
@ -776,13 +776,13 @@ main (int argc, char *argv[])
|
|||
/* Free resources. */
|
||||
grub_fini_all ();
|
||||
grub_util_biosdisk_fini ();
|
||||
|
||||
|
||||
free (boot_file);
|
||||
free (core_file);
|
||||
free (dir);
|
||||
free (dev_map);
|
||||
free (root_dev);
|
||||
free (dest_dev);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue