remove all trailing whitespace
This commit is contained in:
parent
d2d4966571
commit
b39f9d20a9
222 changed files with 3286 additions and 3286 deletions
134
commands/acpi.c
134
commands/acpi.c
|
@ -36,22 +36,22 @@
|
|||
#endif
|
||||
|
||||
static const struct grub_arg_option options[] = {
|
||||
{"exclude", 'x', 0,
|
||||
"Don't load host tables specified by comma-separated list",
|
||||
{"exclude", 'x', 0,
|
||||
"Don't load host tables specified by comma-separated list",
|
||||
0, ARG_TYPE_STRING},
|
||||
{"load-only", 'n', 0,
|
||||
{"load-only", 'n', 0,
|
||||
"Load only tables specified by comma-separated list", 0, ARG_TYPE_STRING},
|
||||
{"v1", '1', 0, "Expose v1 tables", 0, ARG_TYPE_NONE},
|
||||
{"v2", '2', 0, "Expose v2 and v3 tables", 0, ARG_TYPE_NONE},
|
||||
{"oemid", 'o', 0, "Set OEMID of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
|
||||
{"oemtable", 't', 0,
|
||||
"Set OEMTABLE ID of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
|
||||
{"oemtablerev", 'r', 0,
|
||||
"Set OEMTABLE revision of RSDP, XSDT and RSDT", 0, ARG_TYPE_INT},
|
||||
{"oemtablecreator", 'c', 0,
|
||||
"Set creator field of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
|
||||
{"oemtablecreatorrev", 'd', 0,
|
||||
"Set creator revision of RSDP, XSDT and RSDT", 0, ARG_TYPE_INT},
|
||||
{"oemtable", 't', 0,
|
||||
"Set OEMTABLE ID of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
|
||||
{"oemtablerev", 'r', 0,
|
||||
"Set OEMTABLE revision of RSDP, XSDT and RSDT", 0, ARG_TYPE_INT},
|
||||
{"oemtablecreator", 'c', 0,
|
||||
"Set creator field of RSDP, XSDT and RSDT", 0, ARG_TYPE_STRING},
|
||||
{"oemtablecreatorrev", 'd', 0,
|
||||
"Set creator revision of RSDP, XSDT and RSDT", 0, ARG_TYPE_INT},
|
||||
{"no-ebda", 'e', 0, "Don't update EBDA. May fix failures or hangs on some"
|
||||
" BIOSes but makes it ineffective with OS not receiving RSDP from GRUB",
|
||||
0, ARG_TYPE_NONE},
|
||||
|
@ -59,7 +59,7 @@ static const struct grub_arg_option options[] = {
|
|||
};
|
||||
|
||||
/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */
|
||||
grub_uint8_t
|
||||
grub_uint8_t
|
||||
grub_byte_checksum (void *base, grub_size_t size)
|
||||
{
|
||||
grub_uint8_t *ptr;
|
||||
|
@ -70,7 +70,7 @@ grub_byte_checksum (void *base, grub_size_t size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise.
|
||||
/* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise.
|
||||
rev2 contains the revision of ACPIv2+ to generate or 0 if none. */
|
||||
static int rev1, rev2;
|
||||
/* OEMID of RSDP, RSDT and XSDT. */
|
||||
|
@ -128,7 +128,7 @@ grub_acpi_get_rsdpv1 (void)
|
|||
return grub_machine_acpi_get_rsdpv1 ();
|
||||
}
|
||||
|
||||
static inline int
|
||||
static inline int
|
||||
iszero (grub_uint8_t *reg, int size)
|
||||
{
|
||||
int i;
|
||||
|
@ -138,7 +138,7 @@ iszero (grub_uint8_t *reg, int size)
|
|||
return 1;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_err_t
|
||||
grub_acpi_create_ebda (void)
|
||||
{
|
||||
int ebda_kb_len;
|
||||
|
@ -149,9 +149,9 @@ grub_acpi_create_ebda (void)
|
|||
grub_uint8_t *targetebda, *target;
|
||||
struct grub_acpi_rsdp_v10 *v1;
|
||||
struct grub_acpi_rsdp_v20 *v2;
|
||||
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
|
||||
auto int NESTED_FUNC_ATTR find_hook (grub_uint64_t, grub_uint64_t,
|
||||
grub_uint32_t);
|
||||
int NESTED_FUNC_ATTR find_hook (grub_uint64_t start, grub_uint64_t size,
|
||||
int NESTED_FUNC_ATTR find_hook (grub_uint64_t start, grub_uint64_t size,
|
||||
grub_uint32_t type)
|
||||
{
|
||||
grub_uint64_t end = start + size;
|
||||
|
@ -164,7 +164,7 @@ grub_acpi_create_ebda (void)
|
|||
highestlow = (end - ebda_len) & (~0xf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ebda = (grub_uint8_t *) UINT_TO_PTR ((*((grub_uint16_t *)0x40e)) << 4);
|
||||
ebda_kb_len = *(grub_uint16_t *) ebda;
|
||||
if (! ebda || ebda_kb_len > 16)
|
||||
|
@ -177,10 +177,10 @@ grub_acpi_create_ebda (void)
|
|||
grub_dprintf ("acpi", "creating ebda @%llx\n",
|
||||
(unsigned long long) highestlow);
|
||||
if (! highestlow)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't find space for the new EBDA");
|
||||
|
||||
mmapregion = grub_mmap_register (PTR_TO_UINT64 (targetebda), ebda_len,
|
||||
mmapregion = grub_mmap_register (PTR_TO_UINT64 (targetebda), ebda_len,
|
||||
GRUB_MACHINE_MEMORY_RESERVED);
|
||||
if (! mmapregion)
|
||||
return grub_errno;
|
||||
|
@ -198,13 +198,13 @@ grub_acpi_create_ebda (void)
|
|||
if (v2 && v2->length > 40)
|
||||
v2 = 0;
|
||||
|
||||
/* First try to replace already existing rsdp. */
|
||||
/* First try to replace already existing rsdp. */
|
||||
if (v2)
|
||||
{
|
||||
grub_dprintf ("acpi", "Scanning EBDA for old rsdpv2\n");
|
||||
for (; target < targetebda + 0x400 - v2->length; target += 0x10)
|
||||
if (grub_memcmp (target, "RSD PTR ", 8) == 0
|
||||
&& grub_byte_checksum (target,
|
||||
&& grub_byte_checksum (target,
|
||||
sizeof (struct grub_acpi_rsdp_v10)) == 0
|
||||
&& ((struct grub_acpi_rsdp_v10 *) target)->revision != 0
|
||||
&& ((struct grub_acpi_rsdp_v20 *) target)->length <= v2->length)
|
||||
|
@ -222,10 +222,10 @@ grub_acpi_create_ebda (void)
|
|||
if (v1)
|
||||
{
|
||||
grub_dprintf ("acpi", "Scanning EBDA for old rsdpv1\n");
|
||||
for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
|
||||
for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
|
||||
target += 0x10)
|
||||
if (grub_memcmp (target, "RSD PTR ", 8) == 0
|
||||
&& grub_byte_checksum (target,
|
||||
&& grub_byte_checksum (target,
|
||||
sizeof (struct grub_acpi_rsdp_v10)) == 0)
|
||||
{
|
||||
grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
|
||||
|
@ -260,7 +260,7 @@ grub_acpi_create_ebda (void)
|
|||
if (v1)
|
||||
{
|
||||
grub_dprintf ("acpi", "Scanning EBDA for block of zeros\n");
|
||||
for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
|
||||
for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
|
||||
target += 0x10)
|
||||
if (iszero (target, sizeof (struct grub_acpi_rsdp_v10)))
|
||||
{
|
||||
|
@ -277,16 +277,16 @@ grub_acpi_create_ebda (void)
|
|||
if (v1 || v2)
|
||||
{
|
||||
grub_mmap_unregister (mmapregion);
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"Couldn't find suitable spot in EBDA");
|
||||
}
|
||||
|
||||
/* Remove any other RSDT. */
|
||||
for (target = targetebda;
|
||||
target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
|
||||
for (target = targetebda;
|
||||
target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
|
||||
target += 0x10)
|
||||
if (grub_memcmp (target, "RSD PTR ", 8) == 0
|
||||
&& grub_byte_checksum (target,
|
||||
&& grub_byte_checksum (target,
|
||||
sizeof (struct grub_acpi_rsdp_v10)) == 0
|
||||
&& target != v1inebda && target != v2inebda)
|
||||
*target = 0;
|
||||
|
@ -312,7 +312,7 @@ setup_common_tables (void)
|
|||
grub_free (table_dsdt);
|
||||
table_dsdt = playground_ptr;
|
||||
playground_ptr += dsdt_size;
|
||||
|
||||
|
||||
/* Treat other tables. */
|
||||
for (cur = acpi_tables; cur; cur = cur->next)
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ setup_common_tables (void)
|
|||
fadt->hdr.checksum = 1 + ~grub_byte_checksum (fadt, fadt->hdr.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Fill RSDT entries. */
|
||||
numoftables = 0;
|
||||
for (cur = acpi_tables; cur; cur = cur->next)
|
||||
|
@ -365,7 +365,7 @@ setup_common_tables (void)
|
|||
|
||||
for (cur = acpi_tables; cur; cur = cur->next)
|
||||
*(rsdt_entry++) = PTR_TO_UINT32 (cur->addr);
|
||||
|
||||
|
||||
/* Recompute checksum. */
|
||||
rsdt->checksum = 0;
|
||||
rsdt->checksum = 1 + ~grub_byte_checksum (rsdt, rsdt->length);
|
||||
|
@ -383,8 +383,8 @@ setv1table (void)
|
|||
rsdpv1_new->revision = 0;
|
||||
rsdpv1_new->rsdt_addr = PTR_TO_UINT32 (rsdt_addr);
|
||||
rsdpv1_new->checksum = 0;
|
||||
rsdpv1_new->checksum = 1 + ~grub_byte_checksum (rsdpv1_new,
|
||||
sizeof (*rsdpv1_new));
|
||||
rsdpv1_new->checksum = 1 + ~grub_byte_checksum (rsdpv1_new,
|
||||
sizeof (*rsdpv1_new));
|
||||
grub_dprintf ("acpi", "Generated ACPIv1 tables\n");
|
||||
}
|
||||
|
||||
|
@ -421,19 +421,19 @@ setv2table (void)
|
|||
/* Create RSDPv2. */
|
||||
rsdpv2_new = (struct grub_acpi_rsdp_v20 *) playground_ptr;
|
||||
playground_ptr += sizeof (struct grub_acpi_rsdp_v20);
|
||||
grub_memcpy (&(rsdpv2_new->rsdpv1.signature), "RSD PTR ",
|
||||
grub_memcpy (&(rsdpv2_new->rsdpv1.signature), "RSD PTR ",
|
||||
sizeof (rsdpv2_new->rsdpv1.signature));
|
||||
grub_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid,
|
||||
grub_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid,
|
||||
sizeof (rsdpv2_new->rsdpv1.oemid));
|
||||
rsdpv2_new->rsdpv1.revision = rev2;
|
||||
rsdpv2_new->rsdpv1.rsdt_addr = PTR_TO_UINT32 (rsdt_addr);
|
||||
rsdpv2_new->rsdpv1.checksum = 0;
|
||||
rsdpv2_new->rsdpv1.checksum = 1 + ~grub_byte_checksum
|
||||
rsdpv2_new->rsdpv1.checksum = 1 + ~grub_byte_checksum
|
||||
(&(rsdpv2_new->rsdpv1), sizeof (rsdpv2_new->rsdpv1));
|
||||
rsdpv2_new->length = sizeof (*rsdpv2_new);
|
||||
rsdpv2_new->xsdt_addr = PTR_TO_UINT64 (xsdt);
|
||||
rsdpv2_new->checksum = 0;
|
||||
rsdpv2_new->checksum = 1 + ~grub_byte_checksum (rsdpv2_new,
|
||||
rsdpv2_new->checksum = 1 + ~grub_byte_checksum (rsdpv2_new,
|
||||
rsdpv2_new->length);
|
||||
grub_dprintf ("acpi", "Generated ACPIv2 tables\n");
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
grub_err_t err;
|
||||
int i, mmapregion;
|
||||
int numoftables;
|
||||
|
||||
|
||||
/* Default values if no RSDP is found. */
|
||||
rev1 = 1;
|
||||
rev2 = 3;
|
||||
|
@ -473,7 +473,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
facs_addr = 0;
|
||||
playground = playground_ptr = 0;
|
||||
playground_size = 0;
|
||||
|
||||
|
||||
rsdp = (struct grub_acpi_rsdp_v10 *) grub_machine_acpi_get_rsdpv2 ();
|
||||
|
||||
if (! rsdp)
|
||||
|
@ -508,37 +508,37 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
rsdt = (struct grub_acpi_table_header *) UINT_TO_PTR (rsdp->rsdt_addr);
|
||||
/* Load host tables. */
|
||||
for (entry_ptr = (grub_uint32_t *) (rsdt + 1);
|
||||
entry_ptr < (grub_uint32_t *) (((grub_uint8_t *) rsdt)
|
||||
entry_ptr < (grub_uint32_t *) (((grub_uint8_t *) rsdt)
|
||||
+ rsdt->length);
|
||||
entry_ptr++)
|
||||
{
|
||||
char signature[5];
|
||||
struct efiemu_acpi_table *table;
|
||||
struct grub_acpi_table_header *curtable
|
||||
struct grub_acpi_table_header *curtable
|
||||
= (struct grub_acpi_table_header *) UINT_TO_PTR (*entry_ptr);
|
||||
signature[4] = 0;
|
||||
for (i = 0; i < 4;i++)
|
||||
signature[i] = grub_tolower (curtable->signature[i]);
|
||||
|
||||
|
||||
/* If it's FADT it contains addresses of DSDT and FACS. */
|
||||
if (grub_strcmp (signature, "facp") == 0)
|
||||
{
|
||||
struct grub_acpi_table_header *dsdt;
|
||||
struct grub_acpi_fadt *fadt = (struct grub_acpi_fadt *) curtable;
|
||||
|
||||
/* Set root header variables to the same values
|
||||
/* Set root header variables to the same values
|
||||
as FACP by default. */
|
||||
grub_memcpy (&root_oemid, &(fadt->hdr.oemid),
|
||||
grub_memcpy (&root_oemid, &(fadt->hdr.oemid),
|
||||
sizeof (root_oemid));
|
||||
grub_memcpy (&root_oemtable, &(fadt->hdr.oemtable),
|
||||
grub_memcpy (&root_oemtable, &(fadt->hdr.oemtable),
|
||||
sizeof (root_oemtable));
|
||||
root_oemrev = fadt->hdr.oemrev;
|
||||
grub_memcpy (&root_creator_id, &(fadt->hdr.creator_id),
|
||||
grub_memcpy (&root_creator_id, &(fadt->hdr.creator_id),
|
||||
sizeof (root_creator_id));
|
||||
root_creator_rev = fadt->hdr.creator_rev;
|
||||
|
||||
/* Load DSDT if not excluded. */
|
||||
dsdt = (struct grub_acpi_table_header *)
|
||||
dsdt = (struct grub_acpi_table_header *)
|
||||
UINT_TO_PTR (fadt->dsdt_addr);
|
||||
if (dsdt && (! exclude || ! grub_strword (exclude, "dsdt"))
|
||||
&& (! load_only || grub_strword (load_only, "dsdt"))
|
||||
|
@ -551,7 +551,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
free_tables ();
|
||||
grub_free (exclude);
|
||||
grub_free (load_only);
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"Could allocate table");
|
||||
}
|
||||
grub_memcpy (table_dsdt, dsdt, dsdt->length);
|
||||
|
@ -560,7 +560,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
/* Save FACS address. FACS shouldn't be overridden. */
|
||||
facs_addr = fadt->facs_addr;
|
||||
}
|
||||
|
||||
|
||||
/* Skip excluded tables. */
|
||||
if (exclude && grub_strword (exclude, signature))
|
||||
continue;
|
||||
|
@ -570,15 +570,15 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
/* Sanity check. */
|
||||
if (curtable->length < sizeof (*curtable))
|
||||
continue;
|
||||
|
||||
table = (struct efiemu_acpi_table *) grub_malloc
|
||||
|
||||
table = (struct efiemu_acpi_table *) grub_malloc
|
||||
(sizeof (struct efiemu_acpi_table));
|
||||
if (! table)
|
||||
{
|
||||
free_tables ();
|
||||
grub_free (exclude);
|
||||
grub_free (load_only);
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"Could allocate table structure");
|
||||
}
|
||||
table->size = curtable->length;
|
||||
|
@ -587,7 +587,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
if (! table->addr)
|
||||
{
|
||||
free_tables ();
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"Could allocate table");
|
||||
}
|
||||
table->next = acpi_tables;
|
||||
|
@ -595,7 +595,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
grub_memcpy (table->addr, curtable, table->size);
|
||||
}
|
||||
grub_free (exclude);
|
||||
grub_free (load_only);
|
||||
grub_free (load_only);
|
||||
}
|
||||
|
||||
/* Does user specify versions to generate? */
|
||||
|
@ -647,7 +647,7 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
{
|
||||
grub_file_close (file);
|
||||
free_tables ();
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"couldn't read file %s", args[i]);
|
||||
}
|
||||
|
||||
|
@ -657,9 +657,9 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
free_tables ();
|
||||
return grub_error (GRUB_ERR_BAD_OS, "couldn't read file %s", args[i]);
|
||||
}
|
||||
grub_file_close (file);
|
||||
grub_file_close (file);
|
||||
|
||||
if (grub_memcmp (((struct grub_acpi_table_header *) buf)->signature,
|
||||
if (grub_memcmp (((struct grub_acpi_table_header *) buf)->signature,
|
||||
"DSDT", 4) == 0)
|
||||
{
|
||||
grub_free (table_dsdt);
|
||||
|
@ -669,12 +669,12 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
else
|
||||
{
|
||||
struct efiemu_acpi_table *table;
|
||||
table = (struct efiemu_acpi_table *) grub_malloc
|
||||
table = (struct efiemu_acpi_table *) grub_malloc
|
||||
(sizeof (struct efiemu_acpi_table));
|
||||
if (! table)
|
||||
{
|
||||
free_tables ();
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"Could allocate table structure");
|
||||
}
|
||||
|
||||
|
@ -698,15 +698,15 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
playground_size += sizeof (struct grub_acpi_table_header) + 8 * numoftables;
|
||||
/* RSDPv2. */
|
||||
playground_size += sizeof (struct grub_acpi_rsdp_v20);
|
||||
|
||||
playground = playground_ptr
|
||||
|
||||
playground = playground_ptr
|
||||
= grub_mmap_malign_and_register (1, playground_size, &mmapregion,
|
||||
GRUB_MACHINE_MEMORY_ACPI, 0);
|
||||
|
||||
if (! playground)
|
||||
{
|
||||
free_tables ();
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
"Couldn't allocate space for ACPI tables");
|
||||
}
|
||||
|
||||
|
@ -741,9 +741,9 @@ grub_cmd_acpi (struct grub_extcmd *cmd,
|
|||
struct grub_efi_guid acpi = GRUB_EFI_ACPI_TABLE_GUID;
|
||||
struct grub_efi_guid acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
|
||||
|
||||
grub_efi_system_table->boot_services->install_configuration_table
|
||||
grub_efi_system_table->boot_services->install_configuration_table
|
||||
(&acpi20, grub_acpi_get_rsdpv2 ());
|
||||
grub_efi_system_table->boot_services->install_configuration_table
|
||||
grub_efi_system_table->boot_services->install_configuration_table
|
||||
(&acpi, grub_acpi_get_rsdpv1 ());
|
||||
}
|
||||
#endif
|
||||
|
@ -755,13 +755,13 @@ static grub_extcmd_t cmd;
|
|||
|
||||
GRUB_MOD_INIT(acpi)
|
||||
{
|
||||
cmd = grub_register_extcmd ("acpi", grub_cmd_acpi,
|
||||
cmd = grub_register_extcmd ("acpi", grub_cmd_acpi,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"acpi [-1|-2] [--exclude=table1,table2|"
|
||||
"--load-only=table1,table2] filename1 "
|
||||
" [filename2] [...]",
|
||||
"Load host acpi tables and tables "
|
||||
"specified by arguments",
|
||||
"specified by arguments",
|
||||
options);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
|||
unsigned length);
|
||||
auto void NESTED_FUNC_ATTR print_blocklist (grub_disk_addr_t sector, unsigned num,
|
||||
unsigned offset, unsigned length);
|
||||
|
||||
|
||||
void NESTED_FUNC_ATTR read_blocklist (grub_disk_addr_t sector, unsigned offset,
|
||||
unsigned length)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
|||
num_sectors++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
print_blocklist (start_sector, num_sectors, 0, 0);
|
||||
num_sectors = 0;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
|||
else
|
||||
print_blocklist (sector, 0, offset, length);
|
||||
}
|
||||
|
||||
|
||||
void NESTED_FUNC_ATTR print_blocklist (grub_disk_addr_t sector, unsigned num,
|
||||
unsigned offset, unsigned length)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (offset != 0 || length != 0)
|
||||
grub_printf ("[%u-%u]", offset, offset + length);
|
||||
}
|
||||
|
||||
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
|
||||
|
||||
|
@ -91,7 +91,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
if (file->device->disk->partition)
|
||||
part_start = grub_partition_get_start (file->device->disk->partition);
|
||||
|
||||
|
||||
file->read_hook = read_blocklist;
|
||||
|
||||
while (grub_file_read (file, buf, sizeof (buf)) > 0)
|
||||
|
@ -99,7 +99,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
if (num_sectors > 0)
|
||||
print_blocklist (start_sector, num_sectors, 0, 0);
|
||||
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
return grub_errno;
|
||||
|
|
|
@ -38,7 +38,7 @@ struct grub_preboot_t
|
|||
};
|
||||
|
||||
static int grub_loader_loaded;
|
||||
static struct grub_preboot_t *preboots_head = 0,
|
||||
static struct grub_preboot_t *preboots_head = 0,
|
||||
*preboots_tail = 0;
|
||||
|
||||
int
|
||||
|
@ -58,7 +58,7 @@ grub_loader_register_preboot_hook (grub_err_t (*preboot_func) (int noreturn),
|
|||
if (! preboot_func && ! preboot_rest_func)
|
||||
return 0;
|
||||
|
||||
new_preboot = (struct grub_preboot_t *)
|
||||
new_preboot = (struct grub_preboot_t *)
|
||||
grub_malloc (sizeof (struct grub_preboot_t));
|
||||
if (! new_preboot)
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ grub_loader_register_preboot_hook (grub_err_t (*preboot_func) (int noreturn),
|
|||
return new_preboot;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
grub_loader_unregister_preboot_hook (void *hnd)
|
||||
{
|
||||
struct grub_preboot_t *preb = hnd;
|
||||
|
@ -116,11 +116,11 @@ grub_loader_set (grub_err_t (*boot) (void),
|
|||
{
|
||||
if (grub_loader_loaded && grub_loader_unload_func)
|
||||
grub_loader_unload_func ();
|
||||
|
||||
|
||||
grub_loader_boot_func = boot;
|
||||
grub_loader_unload_func = unload;
|
||||
grub_loader_noreturn = noreturn;
|
||||
|
||||
|
||||
grub_loader_loaded = 1;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ grub_loader_unset(void)
|
|||
{
|
||||
if (grub_loader_loaded && grub_loader_unload_func)
|
||||
grub_loader_unload_func ();
|
||||
|
||||
|
||||
grub_loader_boot_func = 0;
|
||||
grub_loader_unload_func = 0;
|
||||
|
||||
|
@ -161,7 +161,7 @@ grub_loader_boot (void)
|
|||
err = (grub_loader_boot_func) ();
|
||||
|
||||
for (cur = preboots_tail; cur; cur = cur->prev)
|
||||
if (! err)
|
||||
if (! err)
|
||||
err = cur->preboot_rest_func ();
|
||||
else
|
||||
cur->preboot_rest_func ();
|
||||
|
|
|
@ -41,16 +41,16 @@ grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
|
|||
file = grub_gzfile_open (args[0], 1);
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
|
||||
while ((size = grub_file_read (file, buf, sizeof (buf))) > 0
|
||||
&& key != GRUB_TERM_ESC)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
unsigned char c = buf[i];
|
||||
|
||||
|
||||
if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
|
||||
grub_putchar (c);
|
||||
else
|
||||
|
@ -69,7 +69,7 @@ grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_putchar ('\n');
|
||||
grub_refresh ();
|
||||
grub_file_close (file);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto cleanup;
|
||||
|
||||
if (grub_file_size (file1) != grub_file_size (file2))
|
||||
grub_printf ("Differ in size: %llu [%s], %llu [%s]\n",
|
||||
grub_printf ("Differ in size: %llu [%s], %llu [%s]\n",
|
||||
(unsigned long long) grub_file_size (file1), args[0],
|
||||
(unsigned long long) grub_file_size (file2), args[1]);
|
||||
else
|
||||
|
@ -58,14 +58,14 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
buf1 = grub_malloc (BUFFER_SIZE);
|
||||
buf2 = grub_malloc (BUFFER_SIZE);
|
||||
|
||||
|
||||
if (! buf1 || ! buf2)
|
||||
goto cleanup;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
rd1 = grub_file_read (file1, buf1, BUFFER_SIZE);
|
||||
rd2 = grub_file_read (file2, buf2, BUFFER_SIZE);
|
||||
|
||||
|
@ -83,15 +83,15 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
}
|
||||
pos += BUFFER_SIZE;
|
||||
|
||||
|
||||
}
|
||||
while (rd2);
|
||||
|
||||
|
||||
grub_printf ("The files are identical.\n");
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
|
||||
if (buf1)
|
||||
grub_free (buf1);
|
||||
if (buf2)
|
||||
|
|
|
@ -90,7 +90,7 @@ grub_cmd_echo (grub_extcmd_t cmd, int argc, char **args)
|
|||
arg++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* This was not an escaped character, or escaping is not
|
||||
enabled. */
|
||||
grub_printf ("%c", *arg);
|
||||
|
|
|
@ -34,7 +34,7 @@ grub_machine_acpi_get_rsdpv1 (void)
|
|||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||
|
||||
if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
|
||||
return (struct grub_acpi_rsdp_v10 *)
|
||||
return (struct grub_acpi_rsdp_v10 *)
|
||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
}
|
||||
return 0;
|
||||
|
@ -52,7 +52,7 @@ grub_machine_acpi_get_rsdpv2 (void)
|
|||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||
|
||||
if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_guid_t)))
|
||||
return (struct grub_acpi_rsdp_v20 *)
|
||||
return (struct grub_acpi_rsdp_v20 *)
|
||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -30,33 +30,33 @@
|
|||
|
||||
/* 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.
|
||||
/* XXX: use hardcoded geometry of C = 1024, H = 255, S = 63.
|
||||
Is it a problem?
|
||||
*/
|
||||
static void
|
||||
lba_to_chs (int lba, grub_uint8_t *cl, grub_uint8_t *ch,
|
||||
static void
|
||||
lba_to_chs (int lba, grub_uint8_t *cl, grub_uint8_t *ch,
|
||||
grub_uint8_t *dh)
|
||||
{
|
||||
int cylinder, head, sector;
|
||||
int sectors = 63, heads = 255, cylinders = 1024;
|
||||
|
||||
|
||||
sector = lba % sectors + 1;
|
||||
head = (lba / sectors) % heads;
|
||||
cylinder = lba / (sectors * heads);
|
||||
|
||||
|
||||
if (cylinder >= cylinders)
|
||||
{
|
||||
*cl = *ch = *dh = 0xff;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*cl = sector | ((cylinder & 0x300) >> 2);
|
||||
*ch = cylinder & 0xFF;
|
||||
*dh = head;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_device_t dev;
|
||||
|
@ -74,11 +74,11 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')')
|
||||
{
|
||||
args[0][grub_strlen (args[0]) - 1] = 0;
|
||||
dev = grub_device_open (args[0] + 1);
|
||||
dev = grub_device_open (args[0] + 1);
|
||||
args[0][grub_strlen (args[0])] = ')';
|
||||
}
|
||||
else
|
||||
dev = grub_device_open (args[0]);
|
||||
dev = grub_device_open (args[0]);
|
||||
|
||||
if (! dev)
|
||||
return grub_errno;
|
||||
|
@ -99,7 +99,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
|||
/* Check if it is valid. */
|
||||
if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE))
|
||||
{
|
||||
grub_device_close (dev);
|
||||
grub_device_close (dev);
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_device_close (dev);
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no GPT partition map found");
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
first_sector = dev->disk->total_sectors;
|
||||
for (i = 1; i < argc; i++)
|
||||
|
@ -128,19 +128,19 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (separator)
|
||||
*separator = csep;
|
||||
if (! partition)
|
||||
{
|
||||
{
|
||||
grub_device_close (dev);
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such partition");
|
||||
}
|
||||
|
||||
if (partition->start + partition->len > 0xffffffff)
|
||||
{
|
||||
{
|
||||
grub_device_close (dev);
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
"only partitions resding in the first 2TB "
|
||||
"can be presen in hybrid MBR");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (first_sector > partition->start)
|
||||
first_sector = partition->start;
|
||||
|
@ -182,17 +182,17 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (numactive == 2)
|
||||
{
|
||||
grub_device_close (dev);
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"only one partition can be active");
|
||||
}
|
||||
}
|
||||
mbr.entries[i].type = type;
|
||||
mbr.entries[i].start = grub_cpu_to_le32 (partition->start);
|
||||
lba_to_chs (partition->start,
|
||||
lba_to_chs (partition->start,
|
||||
&(mbr.entries[i].start_sector),
|
||||
&(mbr.entries[i].start_cylinder),
|
||||
&(mbr.entries[i].start_head));
|
||||
lba_to_chs (partition->start + partition->len - 1,
|
||||
lba_to_chs (partition->start + partition->len - 1,
|
||||
&(mbr.entries[i].end_sector),
|
||||
&(mbr.entries[i].end_cylinder),
|
||||
&(mbr.entries[i].end_head));
|
||||
|
@ -210,11 +210,11 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
|
|||
mbr.entries[0].flag = 0;
|
||||
mbr.entries[0].type = GRUB_PC_PARTITION_TYPE_GPT_DISK;
|
||||
mbr.entries[0].start = grub_cpu_to_le32 (1);
|
||||
lba_to_chs (1,
|
||||
lba_to_chs (1,
|
||||
&(mbr.entries[0].start_sector),
|
||||
&(mbr.entries[0].start_cylinder),
|
||||
&(mbr.entries[0].start_head));
|
||||
lba_to_chs (first_sector,
|
||||
lba_to_chs (first_sector,
|
||||
&(mbr.entries[0].end_sector),
|
||||
&(mbr.entries[0].end_cylinder),
|
||||
&(mbr.entries[0].end_head));
|
||||
|
@ -239,8 +239,8 @@ static grub_command_t cmd;
|
|||
GRUB_MOD_INIT(gptsync)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
cmd = grub_register_command ("gptsync", grub_cmd_gptsync,
|
||||
"gptsync DEVICE [PARTITION[+/-[TYPE]]] ...",
|
||||
cmd = grub_register_command ("gptsync", grub_cmd_gptsync,
|
||||
"gptsync DEVICE [PARTITION[+/-[TYPE]]] ...",
|
||||
"Fill hybrid MBR of GPT drive DEVICE. "
|
||||
"specified partitions will be a part "
|
||||
"of hybrid mbr. Up to 3 partitions are "
|
||||
|
|
|
@ -28,7 +28,7 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
|||
{
|
||||
int cnt = 0;
|
||||
char *currarg;
|
||||
|
||||
|
||||
auto int print_command_info (grub_command_t cmd);
|
||||
auto int print_command_help (grub_command_t cmd);
|
||||
|
||||
|
@ -61,7 +61,7 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
|||
{
|
||||
if (cnt++ > 0)
|
||||
grub_printf ("\n\n");
|
||||
|
||||
|
||||
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
|
||||
grub_arg_show_help ((grub_extcmd_t) cmd->data);
|
||||
else
|
||||
|
@ -71,20 +71,20 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
grub_command_iterate (print_command_info);
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
currarg = args[i];
|
||||
grub_command_iterate (print_command_help);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ grub_machine_acpi_get_rsdpv1 (void)
|
|||
int ebda_len;
|
||||
grub_uint8_t *ebda, *ptr;
|
||||
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
|
||||
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
|
||||
ebda_len = * (grub_uint16_t *) ebda;
|
||||
if (! ebda_len)
|
||||
|
@ -37,7 +37,7 @@ grub_machine_acpi_get_rsdpv1 (void)
|
|||
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
|
||||
return (struct grub_acpi_rsdp_v10 *) ptr;
|
||||
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
|
||||
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
|
||||
ptr += 16)
|
||||
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
|
||||
|
@ -53,7 +53,7 @@ grub_machine_acpi_get_rsdpv2 (void)
|
|||
int ebda_len;
|
||||
grub_uint8_t *ebda, *ptr;
|
||||
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
|
||||
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
|
||||
ebda_len = * (grub_uint16_t *) ebda;
|
||||
if (! ebda_len)
|
||||
|
@ -67,7 +67,7 @@ grub_machine_acpi_get_rsdpv2 (void)
|
|||
== 0)
|
||||
return (struct grub_acpi_rsdp_v20 *) ptr;
|
||||
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
|
||||
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
|
||||
ptr += 16)
|
||||
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
|
||||
|
|
|
@ -184,7 +184,7 @@ list_mappings (void)
|
|||
{
|
||||
grub_printf ("%cD #%-3u (0x%02x) %cd%d\n",
|
||||
(curnode->newdrive & 0x80) ? 'H' : 'F',
|
||||
curnode->newdrive & 0x7F, curnode->newdrive,
|
||||
curnode->newdrive & 0x7F, curnode->newdrive,
|
||||
(curnode->redirto & 0x80) ? 'h' : 'f',
|
||||
curnode->redirto & 0x7F
|
||||
);
|
||||
|
|
|
@ -171,7 +171,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
|||
sizeof (struct note)) == sizeof (struct note)
|
||||
&& buf.pitch != T_FINE && grub_checkkey () < 0)
|
||||
{
|
||||
|
||||
|
||||
grub_dprintf ("play", "pitch = %d, duration = %d\n", buf.pitch,
|
||||
buf.duration);
|
||||
|
||||
|
|
|
@ -66,14 +66,14 @@ grub_cmd_vbeinfo (grub_command_t cmd __attribute__ ((unused)),
|
|||
p = video_mode_list = real2pm (controller_info.video_mode_ptr);
|
||||
while (*p++ != 0xFFFF)
|
||||
;
|
||||
|
||||
|
||||
video_mode_list_size = (grub_addr_t) p - (grub_addr_t) video_mode_list;
|
||||
saved_video_mode_list = grub_malloc (video_mode_list_size);
|
||||
if (! saved_video_mode_list)
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (saved_video_mode_list, video_mode_list, video_mode_list_size);
|
||||
|
||||
|
||||
grub_printf ("List of compatible video modes:\n");
|
||||
grub_printf ("Legend: P=Packed pixel, D=Direct color, "
|
||||
"mask/pos=R/G/B/reserved\n");
|
||||
|
@ -83,7 +83,7 @@ grub_cmd_vbeinfo (grub_command_t cmd __attribute__ ((unused)),
|
|||
{
|
||||
const char *memory_model = 0;
|
||||
grub_uint32_t mode = (grub_uint32_t) *p;
|
||||
|
||||
|
||||
err = grub_vbe_get_video_mode_info (mode, &mode_info_tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ grub_cmd_vbeinfo (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (! memory_model)
|
||||
continue;
|
||||
|
||||
grub_printf ("0x%03x: %4d x %4d x %2d %s",
|
||||
grub_printf ("0x%03x: %4d x %4d x %2d %s",
|
||||
mode,
|
||||
mode_info_tmp.x_resolution,
|
||||
mode_info_tmp.y_resolution,
|
||||
|
@ -149,7 +149,7 @@ grub_cmd_vbeinfo (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
grub_free (saved_video_mode_list);
|
||||
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_printf ("Old video mode = %04x\n", old_mode);
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
if (modevar != 0)
|
||||
|
@ -90,7 +90,7 @@ grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)),
|
|||
err = grub_vbe_get_video_mode_info (use_mode, &mode_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
|
||||
/* Dump out details about the mode being tested. */
|
||||
grub_printf ("mode: 0x%03x\n",
|
||||
use_mode);
|
||||
|
|
|
@ -51,7 +51,7 @@ open_envblk_file (char *filename)
|
|||
filename = grub_malloc (len + 1 + sizeof (GRUB_ENVBLK_DEFCFG));
|
||||
if (! filename)
|
||||
return 0;
|
||||
|
||||
|
||||
grub_strcpy (filename, prefix);
|
||||
filename[len] = '/';
|
||||
grub_strcpy (filename + len + 1, GRUB_ENVBLK_DEFCFG);
|
||||
|
@ -80,7 +80,7 @@ read_envblk_file (grub_file_t file)
|
|||
buf = grub_malloc (size);
|
||||
if (! buf)
|
||||
return 0;
|
||||
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
grub_ssize_t ret;
|
||||
|
@ -124,7 +124,7 @@ grub_cmd_load_env (grub_extcmd_t cmd,
|
|||
grub_env_set (name, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
@ -135,7 +135,7 @@ grub_cmd_load_env (grub_extcmd_t cmd,
|
|||
|
||||
grub_envblk_iterate (envblk, set_var);
|
||||
grub_envblk_close (envblk);
|
||||
|
||||
|
||||
fail:
|
||||
grub_file_close (file);
|
||||
return grub_errno;
|
||||
|
@ -157,7 +157,7 @@ grub_cmd_list_env (grub_extcmd_t cmd,
|
|||
grub_printf ("%s=%s\n", name, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
@ -168,7 +168,7 @@ grub_cmd_list_env (grub_extcmd_t cmd,
|
|||
|
||||
grub_envblk_iterate (envblk, print_var);
|
||||
grub_envblk_close (envblk);
|
||||
|
||||
|
||||
fail:
|
||||
grub_file_close (file);
|
||||
return grub_errno;
|
||||
|
@ -205,7 +205,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
|||
grub_disk_addr_t part_start;
|
||||
struct blocklist *p;
|
||||
char *buf;
|
||||
|
||||
|
||||
/* Sanity checks. */
|
||||
total_length = 0;
|
||||
for (p = blocklists; p; p = p->next)
|
||||
|
@ -222,10 +222,10 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
total_length += p->length;
|
||||
}
|
||||
|
||||
|
||||
if (total_length != grub_file_size (file))
|
||||
{
|
||||
/* Maybe sparse, unallocated sectors. No way in GRUB. */
|
||||
|
@ -245,7 +245,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
|||
for (p = blocklists, index = 0; p; p = p->next, index += p->length)
|
||||
{
|
||||
char blockbuf[GRUB_DISK_SECTOR_SIZE];
|
||||
|
||||
|
||||
if (grub_disk_read (disk, p->sector - part_start,
|
||||
p->offset, p->length, blockbuf))
|
||||
return 0;
|
||||
|
@ -269,7 +269,7 @@ write_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
|||
grub_disk_addr_t part_start;
|
||||
struct blocklist *p;
|
||||
grub_size_t index;
|
||||
|
||||
|
||||
buf = grub_envblk_buffer (envblk);
|
||||
disk = file->device->disk;
|
||||
if (disk->partition)
|
||||
|
@ -296,7 +296,7 @@ grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args)
|
|||
grub_envblk_t envblk;
|
||||
struct blocklist *head = 0;
|
||||
struct blocklist *tail = 0;
|
||||
|
||||
|
||||
/* Store blocklists in a linked list. */
|
||||
auto void NESTED_FUNC_ATTR read_hook (grub_disk_addr_t sector,
|
||||
unsigned offset,
|
||||
|
@ -309,7 +309,7 @@ grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args)
|
|||
if (offset + length > GRUB_DISK_SECTOR_SIZE)
|
||||
/* Seemingly a bug. */
|
||||
return;
|
||||
|
||||
|
||||
block = grub_malloc (sizeof (*block));
|
||||
if (! block)
|
||||
return;
|
||||
|
@ -348,7 +348,7 @@ grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args)
|
|||
|
||||
if (! check_blocklists (envblk, head, file))
|
||||
goto fail;
|
||||
|
||||
|
||||
while (argc)
|
||||
{
|
||||
char *value;
|
||||
|
@ -368,7 +368,7 @@ grub_cmd_save_env (grub_extcmd_t cmd, int argc, char **args)
|
|||
}
|
||||
|
||||
write_blocklists (envblk, head, file);
|
||||
|
||||
|
||||
fail:
|
||||
if (envblk)
|
||||
grub_envblk_close (envblk);
|
||||
|
|
|
@ -51,10 +51,10 @@ grub_ls_list_devices (int longlist)
|
|||
grub_normal_print_device_info (name);
|
||||
else
|
||||
grub_printf ("(%s) ", name);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_device_iterate (grub_ls_print_devices);
|
||||
grub_putchar ('\n');
|
||||
grub_refresh ();
|
||||
|
@ -70,20 +70,20 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
const char *path;
|
||||
grub_device_t dev;
|
||||
|
||||
auto int print_files (const char *filename,
|
||||
auto int print_files (const char *filename,
|
||||
const struct grub_dirhook_info *info);
|
||||
auto int print_files_long (const char *filename,
|
||||
auto int print_files_long (const char *filename,
|
||||
const struct grub_dirhook_info *info);
|
||||
|
||||
|
||||
int print_files (const char *filename, const struct grub_dirhook_info *info)
|
||||
{
|
||||
if (all || filename[0] != '.')
|
||||
grub_printf ("%s%s ", filename, info->dir ? "/" : "");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int print_files_long (const char *filename,
|
||||
|
||||
int print_files_long (const char *filename,
|
||||
const struct grub_dirhook_info *info)
|
||||
{
|
||||
char pathname[grub_strlen (dirname) + grub_strlen (filename) + 1];
|
||||
|
@ -94,7 +94,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
if (! info->dir)
|
||||
{
|
||||
grub_file_t file;
|
||||
|
||||
|
||||
if (dirname[grub_strlen (dirname) - 1] == '/')
|
||||
grub_sprintf (pathname, "%s%s", dirname, filename);
|
||||
else
|
||||
|
@ -117,7 +117,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
int fsz = file->size;
|
||||
int units = 0;
|
||||
char buf[20];
|
||||
|
||||
|
||||
while (fsz / 1024)
|
||||
{
|
||||
fsize = (fsize + 512) / 1024;
|
||||
|
@ -136,7 +136,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
}
|
||||
else
|
||||
grub_printf ("%-12llu", (unsigned long long) file->size);
|
||||
|
||||
|
||||
}
|
||||
grub_file_close (file);
|
||||
}
|
||||
|
@ -150,13 +150,13 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
if (human)
|
||||
grub_printf (" %d-%02d-%02d %02d:%02d:%02d %-11s ",
|
||||
datetime.year, datetime.month, datetime.day,
|
||||
datetime.hour, datetime.minute,
|
||||
datetime.hour, datetime.minute,
|
||||
datetime.second,
|
||||
grub_get_weekday_name (&datetime));
|
||||
else
|
||||
grub_printf (" %04d%02d%02d%02d%02d%02d ",
|
||||
datetime.year, datetime.month,
|
||||
datetime.day, datetime.hour,
|
||||
datetime.year, datetime.month,
|
||||
datetime.day, datetime.hour,
|
||||
datetime.minute, datetime.second);
|
||||
}
|
||||
grub_printf ("%s%s\n", filename, info->dir ? "/" : "");
|
||||
|
@ -175,13 +175,13 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
path = dirname;
|
||||
else
|
||||
path++;
|
||||
|
||||
|
||||
if (! path && ! device_name)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if (! *path)
|
||||
{
|
||||
if (grub_errno == GRUB_ERR_UNKNOWN_FS)
|
||||
|
@ -204,13 +204,13 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
grub_file_t file;
|
||||
struct grub_dirhook_info info;
|
||||
grub_errno = 0;
|
||||
|
||||
|
||||
file = grub_file_open (dirname);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
|
||||
p = grub_strrchr (dirname, '/') + 1;
|
||||
dirname = grub_strndup (dirname, p - dirname);
|
||||
if (! dirname)
|
||||
|
@ -228,14 +228,14 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
|
|||
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
grub_putchar ('\n');
|
||||
|
||||
|
||||
grub_refresh ();
|
||||
}
|
||||
|
||||
fail:
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
|
||||
|
||||
grub_free (device_name);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -38,8 +38,8 @@ static char helpmsg[] =
|
|||
"Use \"parttool PARTITION help\" for the list "
|
||||
"of available commands";
|
||||
|
||||
int
|
||||
grub_parttool_register(const char *part_name,
|
||||
int
|
||||
grub_parttool_register(const char *part_name,
|
||||
const grub_parttool_function_t func,
|
||||
const struct grub_parttool_argdesc *args)
|
||||
{
|
||||
|
@ -55,11 +55,11 @@ grub_parttool_register(const char *part_name,
|
|||
cur->handle = curhandle++;
|
||||
for (nargs = 0; args[nargs].name != 0; nargs++);
|
||||
cur->nargs = nargs;
|
||||
cur->args = (struct grub_parttool_argdesc *)
|
||||
cur->args = (struct grub_parttool_argdesc *)
|
||||
grub_malloc ((nargs + 1) * sizeof (struct grub_parttool_argdesc));
|
||||
grub_memcpy (cur->args, args,
|
||||
grub_memcpy (cur->args, args,
|
||||
(nargs + 1) * sizeof (struct grub_parttool_argdesc));
|
||||
|
||||
|
||||
cur->func = func;
|
||||
parts = cur;
|
||||
return cur->handle;
|
||||
|
@ -113,22 +113,22 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
for (curarg = cur->args; curarg->name; curarg++)
|
||||
{
|
||||
int spacing = 20;
|
||||
|
||||
|
||||
spacing -= grub_strlen (curarg->name);
|
||||
grub_printf ("%s", curarg->name);
|
||||
|
||||
|
||||
switch (curarg->type)
|
||||
{
|
||||
case GRUB_PARTTOOL_ARG_BOOL:
|
||||
grub_printf ("+/-");
|
||||
spacing -= 3;
|
||||
break;
|
||||
|
||||
case GRUB_PARTTOOL_ARG_VAL:
|
||||
|
||||
case GRUB_PARTTOOL_ARG_VAL:
|
||||
grub_printf ("=VAL");
|
||||
spacing -= 4;
|
||||
break;
|
||||
|
||||
|
||||
case GRUB_PARTTOOL_ARG_END:
|
||||
break;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
}
|
||||
if (! found)
|
||||
grub_printf ("Sorry no parttool is available for %s\n",
|
||||
grub_printf ("Sorry no parttool is available for %s\n",
|
||||
dev->disk->partition->partmap->name);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -152,11 +152,11 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')')
|
||||
{
|
||||
args[0][grub_strlen (args[0]) - 1] = 0;
|
||||
dev = grub_device_open (args[0] + 1);
|
||||
dev = grub_device_open (args[0] + 1);
|
||||
args[0][grub_strlen (args[0]) - 1] = ')';
|
||||
}
|
||||
else
|
||||
dev = grub_device_open (args[0]);
|
||||
dev = grub_device_open (args[0]);
|
||||
|
||||
if (! dev)
|
||||
return grub_errno;
|
||||
|
@ -186,7 +186,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (filename)
|
||||
{
|
||||
grub_file_t file;
|
||||
|
||||
|
||||
grub_sprintf (filename, "%s/parttool.lst", prefix);
|
||||
file = grub_file_open (filename);
|
||||
if (file)
|
||||
|
@ -197,36 +197,36 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
char *p, *name;
|
||||
|
||||
buf = grub_file_getline (file);
|
||||
|
||||
|
||||
if (! buf)
|
||||
break;
|
||||
|
||||
|
||||
name = buf;
|
||||
|
||||
if (! grub_isgraph (name[0]))
|
||||
continue;
|
||||
|
||||
|
||||
p = grub_strchr (name, ':');
|
||||
if (! p)
|
||||
continue;
|
||||
|
||||
|
||||
*p = '\0';
|
||||
while (*++p == ' ')
|
||||
;
|
||||
|
||||
if (! grub_isgraph (*p))
|
||||
continue;
|
||||
|
||||
|
||||
if (grub_strcmp (name, dev->disk->partition->partmap->name)
|
||||
!= 0)
|
||||
continue;
|
||||
|
||||
|
||||
grub_dl_load (p);
|
||||
}
|
||||
|
||||
|
||||
grub_file_close (file);
|
||||
}
|
||||
|
||||
|
||||
grub_free (filename);
|
||||
}
|
||||
}
|
||||
|
@ -254,15 +254,15 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (grub_strcmp (dev->disk->partition->partmap->name, cur->name) == 0)
|
||||
{
|
||||
for (curarg = cur->args; curarg->name; curarg++)
|
||||
if (grub_strncmp (curarg->name, args[i],
|
||||
if (grub_strncmp (curarg->name, args[i],
|
||||
grub_strlen (curarg->name)) == 0
|
||||
&& ((curarg->type == GRUB_PARTTOOL_ARG_BOOL
|
||||
&& (args[i][grub_strlen (curarg->name)] == '+'
|
||||
&& ((curarg->type == GRUB_PARTTOOL_ARG_BOOL
|
||||
&& (args[i][grub_strlen (curarg->name)] == '+'
|
||||
|| args[i][grub_strlen (curarg->name)] == '-'
|
||||
|| args[i][grub_strlen (curarg->name)] == 0))
|
||||
|| (curarg->type == GRUB_PARTTOOL_ARG_VAL
|
||||
&& args[i][grub_strlen (curarg->name)] == '=')))
|
||||
|
||||
|
||||
break;
|
||||
if (curarg->name)
|
||||
break;
|
||||
|
@ -271,18 +271,18 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unrecognised argument %s",
|
||||
args[i]);
|
||||
ptool = cur;
|
||||
pargs = (struct grub_parttool_args *)
|
||||
pargs = (struct grub_parttool_args *)
|
||||
grub_malloc (ptool->nargs * sizeof (struct grub_parttool_args));
|
||||
grub_memset (pargs, 0,
|
||||
grub_memset (pargs, 0,
|
||||
ptool->nargs * sizeof (struct grub_parttool_args));
|
||||
for (j = i; j < argc; j++)
|
||||
if (! parsed[j])
|
||||
{
|
||||
for (curarg = ptool->args; curarg->name; curarg++)
|
||||
if (grub_strncmp (curarg->name, args[i],
|
||||
if (grub_strncmp (curarg->name, args[i],
|
||||
grub_strlen (curarg->name)) == 0
|
||||
&& ((curarg->type == GRUB_PARTTOOL_ARG_BOOL
|
||||
&& (args[j][grub_strlen (curarg->name)] == '+'
|
||||
&& ((curarg->type == GRUB_PARTTOOL_ARG_BOOL
|
||||
&& (args[j][grub_strlen (curarg->name)] == '+'
|
||||
|| args[j][grub_strlen (curarg->name)] == '-'
|
||||
|| args[j][grub_strlen (curarg->name)] == 0))
|
||||
|| (curarg->type == GRUB_PARTTOOL_ARG_VAL
|
||||
|
@ -293,15 +293,15 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
|||
switch (curarg->type)
|
||||
{
|
||||
case GRUB_PARTTOOL_ARG_BOOL:
|
||||
pargs[curarg - ptool->args].bool
|
||||
pargs[curarg - ptool->args].bool
|
||||
= (args[j][grub_strlen (curarg->name)] != '-');
|
||||
break;
|
||||
|
||||
case GRUB_PARTTOOL_ARG_VAL:
|
||||
pargs[curarg - ptool->args].str
|
||||
pargs[curarg - ptool->args].str
|
||||
= (args[j] + grub_strlen (curarg->name) + 1);
|
||||
break;
|
||||
|
||||
|
||||
case GRUB_PARTTOOL_ARG_END:
|
||||
break;
|
||||
}
|
||||
|
@ -324,8 +324,8 @@ static grub_command_t cmd;
|
|||
GRUB_MOD_INIT(parttool)
|
||||
{
|
||||
mymod = mod;
|
||||
cmd = grub_register_command ("parttool", grub_cmd_parttool,
|
||||
"parttool PARTITION COMMANDS",
|
||||
cmd = grub_register_command ("parttool", grub_cmd_parttool,
|
||||
"parttool PARTITION COMMANDS",
|
||||
helpmsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
|
|||
{
|
||||
int count = 0;
|
||||
auto int iterate_device (const char *name);
|
||||
|
||||
|
||||
int iterate_device (const char *name)
|
||||
{
|
||||
grub_device_t dev;
|
||||
|
@ -53,12 +53,12 @@ search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
|
|||
name[0] == 'f' && name[1] == 'd' &&
|
||||
name[2] >= '0' && name[2] <= '9')
|
||||
return 0;
|
||||
|
||||
|
||||
dev = grub_device_open (name);
|
||||
if (dev)
|
||||
{
|
||||
grub_fs_t fs;
|
||||
|
||||
|
||||
fs = grub_fs_probe (dev);
|
||||
|
||||
#define QUID(x) (is_uuid ? (x)->uuid : (x)->label)
|
||||
|
@ -66,7 +66,7 @@ search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
|
|||
if (fs && QUID(fs))
|
||||
{
|
||||
char *quid;
|
||||
|
||||
|
||||
(QUID(fs)) (dev, &quid);
|
||||
if (grub_errno == GRUB_ERR_NONE && quid)
|
||||
{
|
||||
|
@ -82,20 +82,20 @@ search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
|
|||
else
|
||||
grub_printf (" %s", name);
|
||||
}
|
||||
|
||||
|
||||
grub_free (quid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return abort;
|
||||
}
|
||||
|
||||
|
||||
grub_device_iterate (iterate_device);
|
||||
|
||||
|
||||
if (count == 0)
|
||||
grub_error (GRUB_ERR_FILE_NOT_FOUND, "no such device: %s", key);
|
||||
}
|
||||
|
@ -113,13 +113,13 @@ search_file (const char *key, const char *var, int no_floppy)
|
|||
char *p;
|
||||
grub_file_t file;
|
||||
int abort = 0;
|
||||
|
||||
|
||||
/* Skip floppy drives when requested. */
|
||||
if (no_floppy &&
|
||||
name[0] == 'f' && name[1] == 'd' &&
|
||||
name[2] >= '0' && name[2] <= '9')
|
||||
return 0;
|
||||
|
||||
|
||||
len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
|
||||
p = grub_realloc (buf, len);
|
||||
if (! p)
|
||||
|
@ -127,7 +127,7 @@ search_file (const char *key, const char *var, int no_floppy)
|
|||
|
||||
buf = p;
|
||||
grub_sprintf (buf, "(%s)%s", name, key);
|
||||
|
||||
|
||||
file = grub_file_open (buf);
|
||||
if (file)
|
||||
{
|
||||
|
@ -143,15 +143,15 @@ search_file (const char *key, const char *var, int no_floppy)
|
|||
|
||||
grub_file_close (file);
|
||||
}
|
||||
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return abort;
|
||||
}
|
||||
|
||||
|
||||
grub_device_iterate (iterate_device);
|
||||
|
||||
|
||||
grub_free (buf);
|
||||
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE && count == 0)
|
||||
grub_error (GRUB_ERR_FILE_NOT_FOUND, "no such device");
|
||||
}
|
||||
|
@ -161,13 +161,13 @@ grub_cmd_search (grub_extcmd_t cmd, int argc, char **args)
|
|||
{
|
||||
struct grub_arg_list *state = cmd->state;
|
||||
const char *var = 0;
|
||||
|
||||
|
||||
if (argc == 0)
|
||||
return grub_error (GRUB_ERR_INVALID_COMMAND, "no argument specified");
|
||||
|
||||
if (state[3].set)
|
||||
var = state[3].arg ? state[3].arg : "root";
|
||||
|
||||
|
||||
if (state[1].set)
|
||||
search_fs (args[0], var, state[4].set, 0);
|
||||
else if (state[2].set)
|
||||
|
|
|
@ -63,9 +63,9 @@ test_parse (char **args, int *argn, int argc)
|
|||
grub_device_t dev;
|
||||
|
||||
/* A hook for iterating directories. */
|
||||
auto int find_file (const char *cur_filename,
|
||||
auto int find_file (const char *cur_filename,
|
||||
const struct grub_dirhook_info *info);
|
||||
int find_file (const char *cur_filename,
|
||||
int find_file (const char *cur_filename,
|
||||
const struct grub_dirhook_info *info)
|
||||
{
|
||||
if ((info->case_insensitive ? grub_strcasecmp (cur_filename, filename)
|
||||
|
@ -77,7 +77,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
file_exists = 0;
|
||||
device_name = grub_file_get_device_name (path);
|
||||
dev = grub_device_open (device_name);
|
||||
|
@ -93,7 +93,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
pathname = path;
|
||||
else
|
||||
pathname++;
|
||||
|
||||
|
||||
/* Remove trailing '/'. */
|
||||
while (*pathname && pathname[grub_strlen (pathname) - 1] == '/')
|
||||
pathname[grub_strlen (pathname) - 1] = 0;
|
||||
|
@ -132,7 +132,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
else
|
||||
(fs->dir) (dev, path, find_file);
|
||||
|
||||
grub_device_close (dev);
|
||||
grub_device_close (dev);
|
||||
grub_free (path);
|
||||
grub_free (device_name);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* GRUB extension: lexicographical sorting. */
|
||||
if (grub_strcmp (args[*argn + 1], "<") == 0)
|
||||
{
|
||||
|
@ -166,21 +166,21 @@ test_parse (char **args, int *argn, int argc)
|
|||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn + 1], "<=") == 0)
|
||||
{
|
||||
update_val (grub_strcmp (args[*argn], args[*argn + 2]) <= 0);
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn + 1], ">") == 0)
|
||||
{
|
||||
update_val (grub_strcmp (args[*argn], args[*argn + 2]) > 0);
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn + 1], ">=") == 0)
|
||||
{
|
||||
update_val (grub_strcmp (args[*argn], args[*argn + 2]) >= 0);
|
||||
|
@ -191,7 +191,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
/* Number tests. */
|
||||
if (grub_strcmp (args[*argn + 1], "-eq") == 0)
|
||||
{
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
== grub_strtosl (args[*argn + 2], 0, 0));
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
|
@ -199,15 +199,15 @@ test_parse (char **args, int *argn, int argc)
|
|||
|
||||
if (grub_strcmp (args[*argn + 1], "-ge") == 0)
|
||||
{
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
>= grub_strtosl (args[*argn + 2], 0, 0));
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn + 1], "-gt") == 0)
|
||||
{
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
> grub_strtosl (args[*argn + 2], 0, 0));
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
|
@ -215,55 +215,55 @@ test_parse (char **args, int *argn, int argc)
|
|||
|
||||
if (grub_strcmp (args[*argn + 1], "-le") == 0)
|
||||
{
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
<= grub_strtosl (args[*argn + 2], 0, 0));
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn + 1], "-lt") == 0)
|
||||
{
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
< grub_strtosl (args[*argn + 2], 0, 0));
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn + 1], "-ne") == 0)
|
||||
{
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
update_val (grub_strtosl (args[*argn], 0, 0)
|
||||
!= grub_strtosl (args[*argn + 2], 0, 0));
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* GRUB extension: compare numbers skipping prefixes.
|
||||
/* GRUB extension: compare numbers skipping prefixes.
|
||||
Useful for comparing versions. E.g. vmlinuz-2 -plt vmlinuz-11. */
|
||||
if (grub_strcmp (args[*argn + 1], "-pgt") == 0
|
||||
|| grub_strcmp (args[*argn + 1], "-plt") == 0)
|
||||
{
|
||||
int i;
|
||||
/* Skip common prefix. */
|
||||
for (i = 0; args[*argn][i] == args[*argn + 2][i]
|
||||
for (i = 0; args[*argn][i] == args[*argn + 2][i]
|
||||
&& args[*argn][i]; i++);
|
||||
|
||||
|
||||
/* Go the digits back. */
|
||||
i--;
|
||||
while (grub_isdigit (args[*argn][i]) && i > 0)
|
||||
i--;
|
||||
i++;
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn + 1], "-pgt") == 0)
|
||||
update_val (grub_strtoul (args[*argn] + i, 0, 0)
|
||||
update_val (grub_strtoul (args[*argn] + i, 0, 0)
|
||||
> grub_strtoul (args[*argn + 2] + i, 0, 0));
|
||||
else
|
||||
update_val (grub_strtoul (args[*argn] + i, 0, 0)
|
||||
update_val (grub_strtoul (args[*argn] + i, 0, 0)
|
||||
< grub_strtoul (args[*argn + 2] + i, 0, 0));
|
||||
(*argn) += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* -nt and -ot tests. GRUB extension: when doing -?t<bias> bias
|
||||
/* -nt and -ot tests. GRUB extension: when doing -?t<bias> bias
|
||||
will be added to the first mtime. */
|
||||
if (grub_memcmp (args[*argn + 1], "-nt", 3) == 0
|
||||
|| grub_memcmp (args[*argn + 1], "-ot", 3) == 0)
|
||||
|
@ -271,16 +271,16 @@ test_parse (char **args, int *argn, int argc)
|
|||
struct grub_dirhook_info file1;
|
||||
int file1exists;
|
||||
int bias = 0;
|
||||
|
||||
|
||||
/* Fetch fileinfo. */
|
||||
get_fileinfo (args[*argn]);
|
||||
file1 = file_info;
|
||||
file1exists = file_exists;
|
||||
get_fileinfo (args[*argn + 2]);
|
||||
|
||||
|
||||
if (args[*argn + 1][3])
|
||||
bias = grub_strtosl (args[*argn + 1] + 3, 0, 0);
|
||||
|
||||
|
||||
if (grub_memcmp (args[*argn + 1], "-nt", 3) == 0)
|
||||
update_val ((file1exists && ! file_exists)
|
||||
|| (file1.mtimeset && file_info.mtimeset
|
||||
|
@ -305,7 +305,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
(*argn) += 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn], "-e") == 0)
|
||||
{
|
||||
get_fileinfo (args[*argn + 1]);
|
||||
|
@ -322,7 +322,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
(*argn) += 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn], "-s") == 0)
|
||||
{
|
||||
grub_file_t file;
|
||||
|
@ -334,12 +334,12 @@ test_parse (char **args, int *argn, int argc)
|
|||
(*argn) += 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* String tests. */
|
||||
if (grub_strcmp (args[*argn], "-n") == 0)
|
||||
{
|
||||
update_val (args[*argn + 1][0]);
|
||||
|
||||
|
||||
(*argn) += 2;
|
||||
continue;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
}
|
||||
|
||||
/* Special modifiers. */
|
||||
|
||||
|
||||
/* End of expression. return to parent. */
|
||||
if (grub_strcmp (args[*argn], ")") == 0)
|
||||
{
|
||||
|
@ -366,7 +366,7 @@ test_parse (char **args, int *argn, int argc)
|
|||
update_val (test_parse (args, argn, argc));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (grub_strcmp (args[*argn], "!") == 0)
|
||||
{
|
||||
invert = ! invert;
|
||||
|
@ -404,7 +404,7 @@ grub_cmd_test (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (argc >= 1 && grub_strcmp (args[argc - 1], "]") == 0)
|
||||
argc--;
|
||||
|
||||
return test_parse (args, &argn, argc) ? GRUB_ERR_NONE
|
||||
return test_parse (args, &argn, argc) ? GRUB_ERR_NONE
|
||||
: grub_error (GRUB_ERR_TEST_FAILURE, "false");
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ static const char *usb_endp_type[] =
|
|||
"Interrupt"
|
||||
};
|
||||
|
||||
static const char *usb_devspeed[] =
|
||||
static const char *usb_devspeed[] =
|
||||
{
|
||||
"",
|
||||
"Low",
|
||||
|
@ -84,7 +84,7 @@ usb_iterate (grub_usb_device_t dev)
|
|||
usb_print_str ("Product", dev, descdev->strprod);
|
||||
usb_print_str ("Vendor", dev, descdev->strvendor);
|
||||
usb_print_str ("Serial", dev, descdev->strserial);
|
||||
|
||||
|
||||
if (descdev->class > 0 && descdev->class <= 0x0E)
|
||||
grub_printf ("Class: (0x%02x) %s, Subclass: 0x%02x, Protocol: 0x%02x\n",
|
||||
descdev->class, usb_classes[descdev->class],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue