remove all trailing whitespace

This commit is contained in:
fzielcke 2009-06-10 21:04:23 +00:00
parent d2d4966571
commit b39f9d20a9
222 changed files with 3286 additions and 3286 deletions

View File

@ -124,7 +124,7 @@ PROGRAMS = $(bin_UTILITIES) $(sbin_UTILITIES)
SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS) $(grub-mkconfig_SCRIPTS)
CLEANFILES =
MOSTLYCLEANFILES =
MOSTLYCLEANFILES =
DISTCLEANFILES = config.status config.cache config.log config.h \
Makefile stamp-h include/grub/cpu include/grub/machine \
gensymlist.sh genkernsyms.sh build_env.mk

2
aclocal.m4 vendored
View File

@ -232,7 +232,7 @@ AC_MSG_CHECKING(dnl
[whether an absolute indirect call/jump must not be prefixed with an asterisk])
AC_CACHE_VAL(grub_cv_i386_asm_absolute_without_asterisk,
[cat > conftest.s <<\EOF
lcall *(offset)
lcall *(offset)
offset:
.long 0
.word 0

View File

@ -19,7 +19,7 @@
#include <grub/boot.h>
#include <grub/machine/boot.h>
/*
* defines for the code go here
*/
@ -44,7 +44,7 @@
in real mode. */
.code16
.globl _start, start;
.globl _start, start;
_start:
start:
/*
@ -70,7 +70,7 @@ start:
/* scratch space */
mode:
.byte 0
disk_address_packet:
disk_address_packet:
sectors:
.long 0
heads:
@ -91,7 +91,7 @@ cylinder_start:
* End of BIOS parameter block.
*/
boot_version:
boot_version:
.byte GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
kernel_address:
.word GRUB_BOOT_MACHINE_KERNEL_ADDR
@ -99,7 +99,7 @@ kernel_segment:
.word GRUB_BOOT_MACHINE_KERNEL_SEG
kernel_sector:
.long 1, 0
boot_drive:
boot_drive:
.byte 0xff /* the disk to load kernel from */
/* 0xff means use the boot drive */
root_drive:
@ -124,7 +124,7 @@ boot_drive_check:
jnz 1f
movb $0x80, %dl
1:
/*
* ljmp to the next instruction because some bogus BIOSes
* jump to 07C0:0000 instead of 0000:7C00.
@ -136,7 +136,7 @@ boot_drive_check:
ljmp $0, $ABS(real_start)
#endif
real_start:
real_start:
/* set up %ds and %ss as offset from 0 */
xorw %ax, %ax
@ -176,17 +176,17 @@ real_start:
#else
movw $ABS(disk_address_packet), %si
#endif
/* do not probe LBA if the drive is a floppy */
testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
jz chs_mode
/* check if LBA is supported */
movb $0x41, %ah
movw $0x55aa, %bx
int $0x13
/*
/*
* %dl may have been clobbered by INT 13, AH=41H.
* This happens, for example, with AST BIOS 1.04.
*/
@ -200,15 +200,15 @@ real_start:
andw $1, %cx
jz chs_mode
lba_mode:
xorw %ax, %ax
movw %ax, 4(%si)
incw %ax
incw %ax
/* set the mode to non-zero */
movb %al, -1(%si)
/* the blocks */
movw %ax, 2(%si)
@ -249,8 +249,8 @@ lba_mode:
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
jmp copy_buffer
chs_mode:
chs_mode:
/*
* Determine the hard disk geometry from the BIOS!
* We do this first, so that LS-120 IDE floppies work correctly.
@ -272,7 +272,7 @@ final_init:
/* set the mode to zero */
movzbl %dh, %eax
movb %ah, -1(%si)
/* save number of heads */
incw %ax
movl %eax, 4(%si)
@ -303,7 +303,7 @@ setup_sectors:
orl %eax, %eax
jnz geometry_error
/* load logical sector start (bottom half) */
#ifdef APPLE_CC
movl (kernel_sector_abs), %eax
@ -371,7 +371,7 @@ setup_sectors:
jc read_error
movw %es, %bx
copy_buffer:
#ifdef APPLE_CC
kernel_segment_abs = ABS (kernel_segment)
@ -386,14 +386,14 @@ copy_buffer:
*/
pusha
pushw %ds
movw $0x100, %cx
movw %bx, %ds
xorw %si, %si
xorw %di, %di
cld
rep
movsw
@ -472,7 +472,7 @@ message:
*/
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic:
nt_magic:
.long 0
.word 0
@ -482,7 +482,7 @@ nt_magic:
* sneaky, huh?
*/
part_start:
part_start:
. = _start + GRUB_BOOT_MACHINE_PART_START
probe_values:

View File

@ -88,7 +88,7 @@ bi_reserved:
/* Root drive will default to boot drive */
movb $0xFF, %dh
ljmp $(DATA_ADDR >> 4), $0
/*

View File

@ -17,7 +17,7 @@
*/
#include <grub/machine/boot.h>
/*
* defines for the code go here
*/
@ -26,7 +26,7 @@
This makes the assembler generate the address without support
from the linker. (ELF can't relocate 16-bit addresses!) */
#define ABS(x) (x-_start+GRUB_BOOT_MACHINE_KERNEL_ADDR)
/* Print message string */
#ifdef APPLE_CC
#define MSG(x) x ## _abs = ABS(x); mov $x ## _abs, %esi; call message
@ -44,18 +44,18 @@
.globl start, _start
start:
_start:
_start:
/*
* _start is loaded at 0x2000 and is jumped to with
* CS:IP 0:0x2000 in kernel.
*/
/*
/*
* we continue to use the stack for boot.img and assume that
* some registers are set to correct values. See boot.S
* for more information.
*/
/* save drive reference first thing! */
pushw %dx
@ -63,7 +63,7 @@ _start:
pushw %si
MSG(notification_string)
popw %si
/* this sets up for the first run through "bootloop" */
#ifdef APPLE_CC
firstlist_off_abs = ABS (firstlist - GRUB_BOOT_MACHINE_LIST_SIZE)
@ -84,14 +84,14 @@ bootloop:
/* if zero, go to the start function */
je bootit
setup_sectors:
setup_sectors:
/* check if we use LBA or CHS */
cmpb $0, -1(%si)
/* jump to chs_mode if zero */
je chs_mode
lba_mode:
lba_mode:
/* load logical sector start */
movl (%di), %ebx
movl 4(%di), %ecx
@ -109,7 +109,7 @@ lba_mode:
/* if less than, set to total */
movw 8(%di), %ax
1:
1:
/* subtract from total */
subw %ax, 8(%di)
@ -154,8 +154,8 @@ lba_mode:
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
jmp copy_buffer
chs_mode:
chs_mode:
/* load logical sector start (top half) */
movl 4(%di), %eax
orl %eax, %eax
@ -202,7 +202,7 @@ chs_mode:
/* if less than, set to total */
movw 8(%di), %ax
2:
2:
/* subtract from total */
subw %ax, 8(%di)
@ -258,8 +258,8 @@ chs_mode:
/* save source segment */
movw %es, %bx
copy_buffer:
copy_buffer:
/* load addresses for copy from disk buffer to destination */
movw 10(%di), %es /* load destination segment */
@ -291,7 +291,7 @@ copy_buffer:
rep /* sets a repeat */
movsw /* this runs the actual copy */
/* restore addressing regs and print a dot with correct DS
/* restore addressing regs and print a dot with correct DS
(MSG modifies SI, which is saved, and unused AX and BX) */
popw %ds
MSG(notification_step)
@ -339,7 +339,7 @@ notification_string: .asciz "loading"
notification_step: .asciz "."
notification_done: .asciz "\r\n"
geometry_error_string: .asciz "Geom"
read_error_string: .asciz "Read"
general_error_string: .asciz " Error"
@ -379,7 +379,7 @@ lastlist:
.word 0
. = _start + 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE
/* fill the first data listing with the default */
blocklist_default_start:
/* this is the sector start parameter, in logical sectors from
@ -392,5 +392,5 @@ blocklist_default_len:
blocklist_default_seg:
/* this is the segment of the starting address to load the data into */
.word (GRUB_BOOT_MACHINE_KERNEL_SEG + 0x20)
firstlist: /* this label has to be after the list data!!! */

View File

@ -24,7 +24,7 @@
#include <multiboot.h>
.file "lnxboot.S"
#ifdef APPLE_CC
#error Building lnxboot.img with Apple's as results in an unusable image
#endif
@ -50,7 +50,7 @@ data_start:
. = data_start + 0x1F1
setup_sects:
/* Apple's cc can't fill this value. */
/* Apple's cc can't fill this value. */
#ifdef APPLE_CC
.byte 0
#else
@ -135,8 +135,8 @@ data_leng:
linux_init:
#ifdef APPLE_CC
reg_edx_rel = reg_edx - start
code32_start_rel = code32_start - start
reg_edx_rel = reg_edx - start
code32_start_rel = code32_start - start
movw %cs:(reg_edx_rel), %dx
movl %cs:(code32_start_rel), %ebp
#else

View File

@ -21,16 +21,16 @@
/* Start with the prehistoric environment... */
.code16
/* Let's go */
.globl start, _start;
.globl start, _start;
_start:
start:
start:
/* Root drive will default to boot drive */
movb $0xFF, %dh
movb $0x7F, %dl
/* Jump to the real world */
ljmp $0, $0x8200

View File

@ -180,13 +180,13 @@ grub_ohci_pci_iter (int bus, int device, int func,
/* Setup the HCCA. */
grub_ohci_writereg32 (o, GRUB_OHCI_REG_HCCA, (grub_uint32_t) o->hcca);
grub_dprintf ("ohci", "OHCI HCCA\n");
/* Enable the OHCI. */
grub_ohci_writereg32 (o, GRUB_OHCI_REG_CONTROL,
(2 << 6));
grub_dprintf ("ohci", "OHCI enable: 0x%02x\n",
(grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL) >> 6) & 3);
/* Link to ohci now that initialisation is successful. */
o->next = ohci;
ohci = o;
@ -227,7 +227,7 @@ grub_ohci_iterate (int (*hook) (grub_usb_controller_t dev))
}
static void
grub_ohci_transaction (grub_ohci_td_t td,
grub_ohci_transaction (grub_ohci_td_t td,
grub_transfer_type_t type, unsigned int toggle,
grub_size_t size, char *data)
{
@ -305,7 +305,7 @@ grub_ohci_transfer (grub_usb_controller_t dev,
grub_usb_transaction_t tr = &transfer->transactions[i];
grub_ohci_transaction (&td_list[i], tr->pid, tr->toggle,
tr->size, tr->data);
tr->size, tr->data);
td_list[i].next_td = grub_cpu_to_le32 (&td_list[i + 1]);
}
@ -607,5 +607,5 @@ GRUB_MOD_INIT(ohci)
GRUB_MOD_FINI(ohci)
{
grub_usb_controller_dev_unregister (&usb_controller);
grub_usb_controller_dev_unregister (&usb_controller);
}

View File

@ -450,7 +450,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
td = grub_uhci_transaction (u, transfer->endpoint, tr->pid,
transfer->devaddr, tr->toggle,
tr->size, tr->data);
tr->size, tr->data);
if (! td)
{
/* Terminate and free. */
@ -517,7 +517,7 @@ grub_uhci_transfer (grub_usb_controller_t dev,
/* Check if a babble error occurred. */
if (errtd->ctrl_status & (1 << 20))
err = GRUB_USB_ERR_BABBLE;
/* Check if a NAK occurred. */
if (errtd->ctrl_status & (1 << 19))
err = GRUB_USB_ERR_NAK;

View File

@ -236,7 +236,7 @@ grub_usb_device_initialize (grub_usb_device_t dev)
/* Skip the configuration descriptor. */
pos = sizeof (struct grub_usb_desc_config);
/* Read all interfaces. */
for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
{

View File

@ -54,7 +54,7 @@ grub_usb_control_msg (grub_usb_device_t dev,
max = 64;
datablocks = (size + max - 1) / max;
/* XXX: Discriminate between different types of control
messages. */
transfer->transcnt = datablocks + 2;
@ -110,7 +110,7 @@ grub_usb_control_msg (grub_usb_device_t dev,
transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_OUT;
else
transfer->transactions[datablocks + 1].pid = GRUB_USB_TRANSFER_TYPE_IN;
transfer->transactions[datablocks + 1].toggle = 1;
err = dev->controller.dev->transfer (&dev->controller, transfer);
@ -184,7 +184,7 @@ grub_usb_bulk_readwrite (grub_usb_device_t dev,
tr->data = &data[i * max];
size -= tr->size;
}
err = dev->controller.dev->transfer (&dev->controller, transfer);
grub_dprintf ("usb", "toggle=%d\n", toggle);
dev->toggle[endpoint] = toggle;

View File

@ -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);
}

View File

@ -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;

View File

@ -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 ();

View File

@ -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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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 "

View File

@ -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;
}

View File

@ -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

View File

@ -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
);

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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)

View File

@ -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");
}

View File

@ -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],

View File

@ -162,7 +162,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
commands/parttool.c parttool/pcpart.c \
grub_emu_init.c
grub_emu_LDFLAGS = $(LIBCURSES)
grub_emu_LDFLAGS = $(LIBCURSES)
ifeq ($(enable_grub_emu_usb), yes)
grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \

View File

@ -33,7 +33,7 @@ sbin_UTILITIES = grub-mkdevicemap
ifeq ($(enable_grub_emu), yes)
sbin_UTILITIES += grub-emu
endif
# For grub-mkdevicemap.
grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/deviceiter.c \
util/devicemap.c util/misc.c
@ -144,7 +144,7 @@ multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
loader/multiboot2.c \
loader/multiboot_loader.c
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For memdisk.mod.
memdisk_mod_SOURCES = disk/memdisk.c

View File

@ -66,7 +66,7 @@ endif
# For grub-mkimage.
grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
util/resolve.c
util/resolve.c
# For grub-setup.
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h

View File

@ -354,7 +354,7 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
])
if test "x$grub_cv_cc_mcmodel" = xno; then
CFLAGS="$SAVED_CFLAGS -m64 -DMCMODEL_SMALL=1"
TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1"
TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1"
AC_MSG_WARN([-mcmodel=large not supported. You wan't be able to use the memory over 4GiB. Upgrade your gcc])
else
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
@ -451,7 +451,7 @@ LIBS="$tmp_LIBS"
#
# Memory manager debugging.
AC_ARG_ENABLE([mm-debug],
AC_ARG_ENABLE([mm-debug],
AS_HELP_STRING([--enable-mm-debug],
[include memory manager debugging]),
[AC_DEFINE([MM_DEBUG], [1],

View File

@ -357,7 +357,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
/* Try to detect if the port is in use by writing to it,
waiting for a while and reading it again. If the value
was preserved, there is a device connected. */
grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A);
grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A);
grub_ata_wait ();
grub_uint8_t sec = grub_ata_regget (dev, GRUB_ATA_REG_SECTORS);
grub_dprintf ("ata", "sectors=0x%x\n", sec);
@ -435,7 +435,7 @@ grub_ata_pciinit (int bus, int device, int func,
bar2 = grub_pci_read (addr);
/* Check if the BARs describe an IO region. */
if ((bar1 & 1) && (bar2 & 1))
if ((bar1 & 1) && (bar2 & 1))
{
rega = bar1 & ~3;
regb = bar2 & ~3;
@ -682,7 +682,7 @@ grub_ata_open (const char *name, grub_disk_t disk)
disk->total_sectors = dev->size;
disk->id = (unsigned long) dev;
disk->has_partitions = 1;
disk->data = dev;
@ -692,7 +692,7 @@ grub_ata_open (const char *name, grub_disk_t disk)
static void
grub_ata_close (grub_disk_t disk __attribute__((unused)))
{
}
static grub_err_t
@ -841,7 +841,7 @@ static struct grub_scsi_dev grub_atapi_dev =
.close = grub_atapi_close,
.read = grub_atapi_read,
.write = grub_atapi_write
};
};
@ -854,7 +854,7 @@ GRUB_MOD_INIT(ata)
grub_disk_firmware_fini ();
grub_disk_firmware_fini = NULL;
}
/* ATA initialization. */
grub_ata_initialize ();

View File

@ -51,7 +51,7 @@ duplicate_device_path (const grub_efi_device_path_t *dp)
{
grub_efi_device_path_t *p;
grub_size_t total_size = 0;
for (p = (grub_efi_device_path_t *) dp;
;
p = GRUB_EFI_NEXT_DEVICE_PATH (p))
@ -94,14 +94,14 @@ compare_device_paths (const grub_efi_device_path_t *dp1,
if (! dp1 || ! dp2)
/* Return non-zero. */
return 1;
while (1)
{
grub_efi_uint8_t type1, type2;
grub_efi_uint8_t subtype1, subtype2;
grub_efi_uint16_t len1, len2;
int ret;
type1 = GRUB_EFI_DEVICE_PATH_TYPE (dp1);
type2 = GRUB_EFI_DEVICE_PATH_TYPE (dp2);
@ -110,7 +110,7 @@ compare_device_paths (const grub_efi_device_path_t *dp1,
subtype1 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp1);
subtype2 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp2);
if (subtype1 != subtype2)
return (int) subtype1 - (int) subtype2;
@ -141,7 +141,7 @@ make_devices (void)
grub_efi_handle_t *handles;
grub_efi_handle_t *handle;
struct grub_efidisk_data *devices = 0;
/* Find handles which support the disk io interface. */
handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &disk_io_guid,
0, &num_handles);
@ -156,7 +156,7 @@ make_devices (void)
struct grub_efidisk_data *d;
grub_efi_block_io_t *bio;
grub_efi_disk_io_t *dio;
dp = grub_efi_get_device_path (*handle);
if (! dp)
continue;
@ -165,7 +165,7 @@ make_devices (void)
if (! ldp)
/* This is empty. Why? */
continue;
bio = grub_efi_open_protocol (*handle, &block_io_guid,
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
dio = grub_efi_open_protocol (*handle, &disk_io_guid,
@ -173,7 +173,7 @@ make_devices (void)
if (! bio || ! dio)
/* This should not happen... Why? */
continue;
d = grub_malloc (sizeof (*d));
if (! d)
{
@ -192,7 +192,7 @@ make_devices (void)
}
grub_free (handles);
return devices;
}
@ -203,7 +203,7 @@ find_parent_device (struct grub_efidisk_data *devices,
{
grub_efi_device_path_t *dp, *ldp;
struct grub_efidisk_data *parent;
dp = duplicate_device_path (d->device_path);
if (! dp)
return 0;
@ -219,13 +219,13 @@ find_parent_device (struct grub_efidisk_data *devices,
/* Ignore itself. */
if (parent == d)
continue;
if (compare_device_paths (parent->device_path, dp) == 0)
{
/* Found. */
if (! parent->last_device_path)
parent = 0;
break;
}
}
@ -240,7 +240,7 @@ iterate_child_devices (struct grub_efidisk_data *devices,
int (*hook) (struct grub_efidisk_data *child))
{
struct grub_efidisk_data *p;
for (p = devices; p; p = p->next)
{
grub_efi_device_path_t *dp, *ldp;
@ -248,13 +248,13 @@ iterate_child_devices (struct grub_efidisk_data *devices,
dp = duplicate_device_path (p->device_path);
if (! dp)
return 0;
ldp = find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length[0] = sizeof (*ldp);
ldp->length[1] = 0;
if (compare_device_paths (dp, d->device_path) == 0)
if (hook (p))
{
@ -304,7 +304,7 @@ static void
name_devices (struct grub_efidisk_data *devices)
{
struct grub_efidisk_data *d;
/* First, identify devices by media device paths. */
for (d = devices; d; d = d->next)
{
@ -313,11 +313,11 @@ name_devices (struct grub_efidisk_data *devices)
dp = d->last_device_path;
if (! dp)
continue;
if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
{
int is_hard_drive = 0;
switch (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp))
{
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
@ -346,7 +346,7 @@ name_devices (struct grub_efidisk_data *devices)
#endif
add_device (&cd_devices, parent);
}
/* Mark the parent as used. */
parent->last_device_path = 0;
}
@ -367,7 +367,7 @@ name_devices (struct grub_efidisk_data *devices)
{
grub_efi_device_path_t *dp;
grub_efi_block_io_media_t *m;
dp = d->last_device_path;
if (! dp)
continue;
@ -409,7 +409,7 @@ static void
free_devices (struct grub_efidisk_data *devices)
{
struct grub_efidisk_data *p, *q;
for (p = devices; p; p = q)
{
q = p->next;
@ -422,11 +422,11 @@ static void
enumerate_disks (void)
{
struct grub_efidisk_data *devices;
devices = make_devices ();
if (! devices)
return;
name_devices (devices);
free_devices (devices);
}
@ -437,7 +437,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
struct grub_efidisk_data *d;
char buf[16];
int count;
for (d = fd_devices, count = 0; d; d = d->next, count++)
{
grub_sprintf (buf, "fd%d", count);
@ -445,7 +445,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
if (hook (buf))
return 1;
}
for (d = hd_devices, count = 0; d; d = d->next, count++)
{
grub_sprintf (buf, "hd%d", count);
@ -453,7 +453,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
if (hook (buf))
return 1;
}
for (d = cd_devices, count = 0; d; d = d->next, count++)
{
grub_sprintf (buf, "cd%d", count);
@ -506,7 +506,7 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
grub_efi_block_io_media_t *m;
grub_dprintf ("efidisk", "opening %s\n", name);
num = get_drive_number (name);
if (num < 0)
return grub_errno;
@ -565,7 +565,7 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
grub_efi_disk_io_t *dio;
grub_efi_block_io_t *bio;
grub_efi_status_t status;
d = disk->data;
dio = d->disk_io;
bio = d->block_io;
@ -573,14 +573,14 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
grub_dprintf ("efidisk",
"reading 0x%lx sectors at the sector 0x%llx from %s\n",
(unsigned long) size, (unsigned long long) sector, disk->name);
status = efi_call_5 (dio->read, dio, bio->media->media_id,
(grub_efi_uint64_t) sector << GRUB_DISK_SECTOR_BITS,
(grub_efi_uintn_t) size << GRUB_DISK_SECTOR_BITS,
buf);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_READ_ERROR, "efidisk read error");
return GRUB_ERR_NONE;
}
@ -593,22 +593,22 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
grub_efi_disk_io_t *dio;
grub_efi_block_io_t *bio;
grub_efi_status_t status;
d = disk->data;
dio = d->disk_io;
bio = d->block_io;
grub_dprintf ("efidisk",
"writing 0x%lx sectors at the sector 0x%llx to %s\n",
(unsigned long) size, (unsigned long long) sector, disk->name);
status = efi_call_5 (dio->write, dio, bio->media->media_id,
(grub_efi_uint64_t) sector << GRUB_DISK_SECTOR_BITS,
(grub_efi_uintn_t) size << GRUB_DISK_SECTOR_BITS,
(void *) buf);
if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_WRITE_ERROR, "efidisk write error");
return GRUB_ERR_NONE;
}
@ -646,13 +646,13 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
{
struct grub_efidisk_data *d;
char type;
if (disk->dev->id != GRUB_DISK_DEVICE_EFIDISK_ID)
return 0;
d = disk->data;
type = disk->name[0];
switch (type)
{
case 'f':
@ -679,7 +679,7 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
grub_efi_hard_drive_device_path_t hd;
grub_memcpy (&hd, c->last_device_path, sizeof (hd));
if ((GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
== GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
@ -692,14 +692,14 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
handle = c->handle;
return 1;
}
return 0;
}
devices = make_devices ();
iterate_child_devices (devices, d, find_partition);
free_devices (devices);
if (handle != 0)
return handle;
}
@ -708,7 +708,7 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
default:
break;
}
return 0;
}
@ -750,7 +750,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (disk->dev->id == GRUB_DISK_DEVICE_EFIDISK_ID)
{
struct grub_efidisk_data *d;
d = disk->data;
if (compare_device_paths (d->device_path, dup_dp) == 0)
{
@ -798,7 +798,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
/* Find a partition which matches the hard drive device path. */
grub_memcpy (&hd, ldp, sizeof (hd));
grub_partition_iterate (parent, find_partition);
if (! partition_name)
{
grub_disk_close (parent);
@ -824,11 +824,11 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
/* This should be an entire disk. */
auto int find_disk (const char *name);
char *device_name = 0;
int find_disk (const char *name)
{
grub_disk_t disk;
disk = grub_disk_open (name);
if (! disk)
return 1;
@ -836,7 +836,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (disk->id == GRUB_DISK_DEVICE_EFIDISK_ID)
{
struct grub_efidisk_data *d;
d = disk->data;
if (compare_device_paths (d->device_path, dp) == 0)
{
@ -848,9 +848,9 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
grub_disk_close (disk);
return 0;
}
grub_efidisk_iterate (find_disk);
return device_name;
}

View File

@ -42,12 +42,12 @@ search_fs_uuid (const char *key, unsigned long *count)
if (dev)
{
grub_fs_t fs;
fs = grub_fs_probe (dev);
if (fs && fs->uuid)
{
char *uuid;
(fs->uuid) (dev, &uuid);
if (grub_errno == GRUB_ERR_NONE && uuid)
{
@ -62,16 +62,16 @@ search_fs_uuid (const char *key, unsigned long *count)
grub_free (uuid);
}
}
grub_device_close (dev);
}
grub_errno = GRUB_ERR_NONE;
return 0;
}
grub_device_iterate (iterate_device);
return ret;
}

View File

@ -42,7 +42,7 @@ grub_host_open (const char *name, grub_disk_t disk)
disk->total_sectors = 0;
disk->id = (unsigned long) "host";
disk->has_partitions = 0;
disk->data = 0;

View File

@ -36,14 +36,14 @@ grub_biosdisk_get_drive (const char *name)
if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd')
goto fail;
drive = grub_strtoul (name + 2, 0, 10);
if (grub_errno != GRUB_ERR_NONE)
goto fail;
if (name[0] == 'h')
drive += 0x80;
return (int) drive ;
fail:
@ -75,7 +75,7 @@ grub_biosdisk_iterate (int (*hook) (const char *name))
grub_dprintf ("disk", "Read error when probing drive 0x%2x\n", drive);
break;
}
if (grub_biosdisk_call_hook (hook, drive))
return 1;
}
@ -108,11 +108,11 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
disk->has_partitions = ((drive & 0x80) && (drive != cd_drive));
disk->id = drive;
data = (struct grub_biosdisk_data *) grub_malloc (sizeof (*data));
if (! data)
return grub_errno;
data->drive = drive;
data->flags = 0;
@ -126,7 +126,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
{
/* HDD */
int version;
version = grub_biosdisk_check_int13_extensions (drive);
if (version)
{
@ -162,9 +162,9 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
{
data->sectors = 63;
data->heads = 255;
data->cylinders
= grub_divmod64 (total_sectors
+ data->heads * data->sectors - 1,
data->cylinders
= grub_divmod64 (total_sectors
+ data->heads * data->sectors - 1,
data->heads * data->sectors, 0);
}
else
@ -180,7 +180,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
disk->total_sectors = total_sectors;
disk->data = data;
return GRUB_ERR_NONE;
}
@ -202,11 +202,11 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
unsigned segment)
{
struct grub_biosdisk_data *data = disk->data;
if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
{
struct grub_biosdisk_dap *dap;
dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
+ (data->sectors
<< GRUB_DISK_SECTOR_BITS));
@ -246,7 +246,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
{
unsigned coff, hoff, soff;
unsigned head;
/* It is impossible to reach over 8064 MiB (a bit less than LBA24) with
the traditional CHS access. */
if (sector >

View File

@ -251,7 +251,7 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
if (actual != actual)
return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %llu",
(long long) sector);
return 0;
}

View File

@ -32,7 +32,7 @@ struct grub_loopback
struct grub_loopback *next;
};
static struct grub_loopback *loopback_list;
static struct grub_loopback *loopback_list;
static const struct grub_arg_option options[] =
{
@ -54,17 +54,17 @@ delete_loopback (const char *name)
prev = &dev->next, dev = dev->next)
if (grub_strcmp (dev->devname, name) == 0)
break;
if (! dev)
return grub_error (GRUB_ERR_BAD_DEVICE, "Device not found");
/* Remove the device from the list. */
*prev = dev->next;
grub_free (dev->devname);
grub_free (dev->filename);
grub_free (dev);
return 0;
}
@ -75,56 +75,56 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
struct grub_arg_list *state = state = cmd->state;
grub_file_t file;
struct grub_loopback *newdev;
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
/* Check if `-d' was used. */
if (state[0].set)
return delete_loopback (args[0]);
if (argc < 2)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
file = grub_file_open (args[1]);
if (! file)
return grub_errno;
/* Close the file, the only reason for opening it is validation. */
grub_file_close (file);
/* First try to replace the old device. */
for (newdev = loopback_list; newdev; newdev = newdev->next)
if (grub_strcmp (newdev->devname, args[0]) == 0)
break;
if (newdev)
{
char *newname = grub_strdup (args[1]);
if (! newname)
return grub_errno;
grub_free (newdev->filename);
newdev->filename = newname;
/* Set has_partitions when `--partitions' was used. */
newdev->has_partitions = state[1].set;
return 0;
}
/* Unable to replace it, make a new entry. */
newdev = grub_malloc (sizeof (struct grub_loopback));
if (! newdev)
return grub_errno;
newdev->devname = grub_strdup (args[0]);
if (! newdev->devname)
{
grub_free (newdev);
return grub_errno;
}
newdev->filename = grub_strdup (args[1]);
if (! newdev->filename)
{
@ -132,14 +132,14 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
grub_free (newdev);
return grub_errno;
}
/* Set has_partitions when `--partitions' was used. */
newdev->has_partitions = state[1].set;
/* Add the new entry to the list. */
newdev->next = loopback_list;
loopback_list = newdev;
return 0;
}
@ -161,26 +161,26 @@ grub_loopback_open (const char *name, grub_disk_t disk)
{
grub_file_t file;
struct grub_loopback *dev;
for (dev = loopback_list; dev; dev = dev->next)
if (grub_strcmp (dev->devname, name) == 0)
break;
if (! dev)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
file = grub_file_open (dev->filename);
if (! file)
return grub_errno;
/* Use the filesize for the disk size, round up to a complete sector. */
disk->total_sectors = ((file->size + GRUB_DISK_SECTOR_SIZE - 1)
/ GRUB_DISK_SECTOR_SIZE);
disk->id = (unsigned long) dev;
disk->has_partitions = dev->has_partitions;
disk->data = file;
return 0;
}
@ -188,7 +188,7 @@ static void
grub_loopback_close (grub_disk_t disk)
{
grub_file_t file = (grub_file_t) disk->data;
grub_file_close (file);
}
@ -198,13 +198,13 @@ grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector,
{
grub_file_t file = (grub_file_t) disk->data;
grub_off_t pos;
grub_file_seek (file, sector << GRUB_DISK_SECTOR_BITS);
grub_file_read (file, buf, size << GRUB_DISK_SECTOR_BITS);
if (grub_errno)
return grub_errno;
/* In case there is more data read than there is available, in case
of files that are not a multiple of GRUB_DISK_SECTOR_SIZE, fill
the rest with zeros. */
@ -214,7 +214,7 @@ grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t amount = pos - file->size;
grub_memset (buf + (size << GRUB_DISK_SECTOR_BITS) - amount, 0, amount);
}
return 0;
}

View File

@ -101,7 +101,7 @@ grub_lvm_open (const char *name, grub_disk_t disk)
disk->id = lv->number;
disk->data = lv;
disk->total_sectors = lv->size;
return 0;
}
@ -174,7 +174,7 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector,
stripe += stripenr;
pv = stripe->pv;
seg_offset = ((grub_uint64_t) stripe->start
* (grub_uint64_t) vg->extent_size) + pv->start;
@ -189,7 +189,7 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector,
else
err = grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"Physical volume %s not found", pv->name);
return err;
}
@ -220,7 +220,7 @@ grub_lvm_scan_device (const char *name)
unsigned int i, j, vgname_len;
struct grub_lvm_vg *vg;
struct grub_lvm_pv *pv;
disk = grub_disk_open (name);
if (!disk)
return 0;
@ -231,7 +231,7 @@ grub_lvm_scan_device (const char *name)
err = grub_disk_read (disk, i, 0, sizeof(buf), buf);
if (err)
goto fail;
if ((! grub_strncmp ((char *)lh->id, GRUB_LVM_LABEL_ID,
sizeof (lh->id)))
&& (! grub_strncmp ((char *)lh->type, GRUB_LVM_LVM2_LABEL,
@ -242,7 +242,7 @@ grub_lvm_scan_device (const char *name)
/* Return if we didn't find a label. */
if (i == GRUB_LVM_LABEL_SCAN_SECTORS)
goto fail;
pvh = (struct grub_lvm_pv_header *) (buf + grub_le_to_cpu32(lh->offset_xl));
for (i = 0, j = 0; i < GRUB_LVM_ID_LEN; i++)
@ -264,7 +264,7 @@ grub_lvm_scan_device (const char *name)
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"We don't support multiple LVM data areas");
goto fail;
}
@ -272,12 +272,12 @@ grub_lvm_scan_device (const char *name)
mda_offset = grub_le_to_cpu64 (dlocn->offset);
mda_size = grub_le_to_cpu64 (dlocn->size);
dlocn++;
if (dlocn->offset)
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"We don't support multiple LVM metadata areas");
goto fail;
}
@ -361,39 +361,39 @@ grub_lvm_scan_device (const char *name)
if (p)
{
p += sizeof ("physical_volumes {") - 1;
/* Add all the pvs to the volume group. */
while (1)
{
int s;
while (grub_isspace (*p))
p++;
if (*p == '}')
break;
pv = grub_malloc (sizeof (*pv));
q = p;
while (*q != ' ')
q++;
s = q - p;
pv->name = grub_malloc (s + 1);
grub_memcpy (pv->name, p, s);
pv->name[s] = '\0';
p = grub_strstr (p, "id = \"");
if (p == NULL)
goto pvs_fail;
p += sizeof("id = \"") - 1;
grub_memcpy (pv->id, p, GRUB_LVM_ID_STRLEN);
pv->id[GRUB_LVM_ID_STRLEN] = '\0';
pv->start = grub_lvm_getvalue (&p, "pe_start = ");
if (p == NULL)
goto pvs_fail;
p = grub_strchr (p, '}');
if (p == NULL)
goto pvs_fail;
@ -402,7 +402,7 @@ grub_lvm_scan_device (const char *name)
pv->disk = NULL;
pv->next = vg->pvs;
vg->pvs = pv;
continue;
pvs_fail:
grub_free (pv->name);
@ -415,49 +415,49 @@ grub_lvm_scan_device (const char *name)
if (p)
{
p += 18;
/* And add all the lvs to the volume group. */
while (1)
{
int s;
struct grub_lvm_lv *lv;
struct grub_lvm_segment *seg;
while (grub_isspace (*p))
p++;
if (*p == '}')
break;
lv = grub_malloc (sizeof (*lv));
q = p;
while (*q != ' ')
q++;
s = q - p;
lv->name = grub_malloc (vgname_len + 1 + s + 1);
grub_memcpy (lv->name, vgname, vgname_len);
lv->name[vgname_len] = '-';
grub_memcpy (lv->name + vgname_len + 1, p, s);
lv->name[vgname_len + 1 + s] = '\0';
lv->size = 0;
lv->segment_count = grub_lvm_getvalue (&p, "segment_count = ");
if (p == NULL)
goto lvs_fail;
lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count);
seg = lv->segments;
for (i = 0; i < lv->segment_count; i++)
{
struct grub_lvm_stripe *stripe;
p = grub_strstr (p, "segment");
if (p == NULL)
goto lvs_segment_fail;
seg->start_extent = grub_lvm_getvalue (&p, "start_extent = ");
if (p == NULL)
goto lvs_segment_fail;
@ -467,25 +467,25 @@ grub_lvm_scan_device (const char *name)
seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = ");
if (p == NULL)
goto lvs_segment_fail;
lv->size += seg->extent_count * vg->extent_size;
if (seg->stripe_count != 1)
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
seg->stripes = grub_malloc (sizeof (*stripe)
* seg->stripe_count);
stripe = seg->stripes;
p = grub_strstr (p, "stripes = [");
if (p == NULL)
goto lvs_segment_fail2;
p += sizeof("stripes = [") - 1;
for (j = 0; j < seg->stripe_count; j++)
{
char *pvname;
p = grub_strchr (p, '"');
if (p == NULL)
continue;
@ -494,14 +494,14 @@ grub_lvm_scan_device (const char *name)
q++;
s = q - p;
pvname = grub_malloc (s + 1);
if (pvname == NULL)
goto lvs_segment_fail2;
grub_memcpy (pvname, p, s);
pvname[s] = '\0';
if (vg->pvs)
for (pv = vg->pvs; pv; pv = pv->next)
{
@ -511,16 +511,16 @@ grub_lvm_scan_device (const char *name)
break;
}
}
grub_free(pvname);
stripe->start = grub_lvm_getvalue (&p, ",");
if (p == NULL)
continue;
stripe++;
}
seg++;
continue;
@ -535,7 +535,7 @@ grub_lvm_scan_device (const char *name)
if (p == NULL)
goto lvs_fail;
p += 3;
lv->number = lv_count++;
lv->vg = vg;
lv->next = vg->lvs;

View File

@ -104,7 +104,7 @@ GRUB_MOD_INIT(memdisk)
return 0;
}
grub_module_iterate (hook);
}

View File

@ -77,7 +77,7 @@ static int
grub_raid_iterate (int (*hook) (const char *name))
{
struct grub_raid_array *array;
for (array = array_list; array != NULL; array = array->next)
{
if (grub_is_array_readable (array))
@ -95,7 +95,7 @@ grub_raid_memberlist (grub_disk_t disk)
struct grub_raid_array *array = disk->data;
grub_disk_memberlist_t list = NULL, tmp;
unsigned int i;
for (i = 0; i < array->total_devs; i++)
if (array->device[i])
{
@ -104,7 +104,7 @@ grub_raid_memberlist (grub_disk_t disk)
tmp->next = list;
list = tmp;
}
return list;
}
#endif
@ -114,7 +114,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
{
struct grub_raid_array *array;
unsigned n;
for (array = array_list; array != NULL; array = array->next)
{
if (!grub_strcmp (array->name, name))
@ -161,7 +161,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
grub_dprintf ("raid", "%s: level=%d, total_sectors=%lld\n", name,
array->level, (unsigned long long) disk->total_sectors);
return 0;
}
@ -348,7 +348,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
p = array->total_devs - n;
read_sector *= array->chunk_size;
while (1)
{
grub_size_t read_size;
@ -405,7 +405,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
if (err)
break;
}
buf += read_size << GRUB_DISK_SECTOR_BITS;
size -= read_size;
if (! size)
@ -460,7 +460,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
}
break;
}
return err;
}
@ -478,7 +478,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
const char *scanner_name)
{
struct grub_raid_array *array = 0, *p;
/* See whether the device is part of an array we have already seen a
device from. */
for (p = array_list; p != NULL; p = p->next)
@ -524,7 +524,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
*array = *new_array;
array->nr_devs = 0;
grub_memset (&array->device, 0, sizeof (array->device));
/* Check whether we don't have multiple arrays with the same number. */
for (p = array_list; p != NULL; p = p->next)
{
@ -635,7 +635,7 @@ grub_raid_scan_device (int head_only)
return 0;
}
grub_device_iterate (&hook);
}
@ -649,7 +649,7 @@ free_array (void)
{
struct grub_raid_array *p;
int i;
p = array;
array = array->next;
@ -664,7 +664,7 @@ free_array (void)
array_list = 0;
}
void
grub_raid_register (grub_raid_t raid)
{

View File

@ -301,7 +301,7 @@ grub_scsi_open (const char *name, grub_disk_t disk)
<< GRUB_DISK_SECTOR_BITS);
grub_dprintf ("scsi", "capacity=%llu, blksize=%d\n",
(unsigned long long) disk->total_sectors,
(unsigned long long) disk->total_sectors,
scsi->blocksize);
return GRUB_ERR_NONE;

View File

@ -267,7 +267,7 @@ grub_usbms_transfer (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
"can't read from USB Mass Storage device");
}
}
else
else
{
err = grub_usb_bulk_write (dev->dev, dev->in->endp_addr & 15, size, buf);
grub_dprintf ("usb", "write: %d %d\n", err, GRUB_USB_ERR_STALL);
@ -379,7 +379,7 @@ static struct grub_scsi_dev grub_usbms_dev =
.close = grub_usbms_close,
.read = grub_usbms_read,
.write = grub_usbms_write
};
};
GRUB_MOD_INIT(usbms)
{

View File

@ -664,7 +664,7 @@ from GRUB and you don't have to make a floppy or hard disk image file,
which can cause compatibility problems.
For booting from a CD-ROM, GRUB uses a special Stage 2 called
@file{stage2_eltorito}. The only GRUB files you need to have in your
@file{stage2_eltorito}. The only GRUB files you need to have in your
bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file
@file{menu.lst}. You don't need to use @file{stage1} or @file{stage2},
because El Torito is quite different from the standard boot process.
@ -702,13 +702,13 @@ $ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
This produces a file named @file{grub.iso}, which then can be burned
into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot
from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is
required for compatibility with the BIOS on many older machines.)
You can use the device @samp{(cd)} to access a CD-ROM in your
config file. This is not required; GRUB automatically sets the root device
to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
config file. This is not required; GRUB automatically sets the root device
to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
@samp{(cd)} if you want to access other drives as well.
@ -2414,7 +2414,7 @@ is to be found; if specified it takes precedence over @var{unit}.
be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data
bits and one stop bit. @var{parity} is one of @samp{no}, @samp{odd},
@samp{even} and defaults to @samp{no}. The option @option{--device}
can only be used in the grub shell and is used to specify the
can only be used in the grub shell and is used to specify the
tty device to be used in the host operating system (@pxref{Invoking the
grub shell}).
@ -2431,8 +2431,8 @@ support. See also @ref{Serial terminal}.
@deffn Command setkey [to_key from_key]
Change the keyboard map. The key @var{from_key} is mapped to the key
@var{to_key}. If no argument is specified, reset key mappings. Note that
this command @emph{does not} exchange the keys. If you want to exchange
@var{to_key}. If no argument is specified, reset key mappings. Note that
this command @emph{does not} exchange the keys. If you want to exchange
the keys, run this command again with the arguments exchanged, like this:
@example

View File

@ -354,7 +354,7 @@
% We don't want .vr (or whatever) entries like this:
% \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
% "\acronym" won't work when it's read back in;
% it needs to be
% it needs to be
% {\code {{\tt \backslashcurfont }acronym}
\shipout\vbox{%
% Do this early so pdf references go to the beginning of the page.
@ -705,7 +705,7 @@
\def\?{?\spacefactor=\endofsentencespacefactor\space}
% @frenchspacing on|off says whether to put extra space after punctuation.
%
%
\def\onword{on}
\def\offword{off}
%
@ -1260,7 +1260,7 @@ where each line of input produces a line of output.}
% that's what we do).
% double active backslashes.
%
%
{\catcode`\@=0 \catcode`\\=\active
@gdef@activebackslashdouble{%
@catcode`@\=@active
@ -1272,11 +1272,11 @@ where each line of input produces a line of output.}
% us) handles it with this amazing macro to replace tokens, with minor
% changes for Texinfo. It is included here under the GPL by permission
% from the author, Heiko Oberdiek.
%
%
% #1 is the tokens to replace.
% #2 is the replacement.
% #3 is the control sequence with the string.
%
%
\def\HyPsdSubst#1#2#3{%
\def\HyPsdReplace##1#1##2\END{%
##1%
@ -1542,7 +1542,7 @@ output) for that.)}
% tried to figure out what each command should do in the context
% of @url. for now, just make @/ a no-op, that's the only one
% people have actually reported a problem with.
%
%
\normalturnoffactive
\def\@{@}%
\let\/=\empty
@ -1939,7 +1939,7 @@ end
% Definitions for a main text size of 11pt. This is the default in
% Texinfo.
%
%
\def\definetextfontsizexi{%
% Text fonts (11.2pt, magstep1).
\def\textnominalsize{11pt}
@ -2072,7 +2072,7 @@ end
% section, chapter, etc., sizes following suit. This is for the GNU
% Press printing of the Emacs 22 manual. Maybe other manuals in the
% future. Used with @smallbook, which sets the leading to 12pt.
%
%
\def\definetextfontsizex{%
% Text fonts (10pt).
\def\textnominalsize{10pt}
@ -2163,7 +2163,7 @@ end
\setfont\secsf\sfbshape{12}{1000}{OT1}
\let\secbf\secrm
\setfont\secsc\scbshape{10}{\magstep1}{OT1}
\font\seci=cmmi12
\font\seci=cmmi12
\font\secsy=cmsy10 scaled \magstep1
\def\sececsize{1200}
@ -2207,7 +2207,7 @@ end
% We provide the user-level command
% @fonttextsize 10
% (or 11) to redefine the text font size. pt is assumed.
%
%
\def\xword{10}
\def\xiword{11}
%
@ -2217,7 +2217,7 @@ end
%
% Set \globaldefs so that documents can use this inside @tex, since
% makeinfo 4.8 does not support it, but we need it nonetheless.
%
%
\begingroup \globaldefs=1
\ifx\textsizearg\xword \definetextfontsizex
\else \ifx\textsizearg\xiword \definetextfontsizexi
@ -2503,7 +2503,7 @@ end
% each of the four underscores in __typeof__. This is undesirable in
% some manuals, especially if they don't have long identifiers in
% general. @allowcodebreaks provides a way to control this.
%
%
\newif\ifallowcodebreaks \allowcodebreakstrue
\def\keywordtrue{true}
@ -2634,7 +2634,7 @@ end
% @acronym for "FBI", "NATO", and the like.
% We print this one point size smaller, since it's intended for
% all-uppercase.
%
%
\def\acronym#1{\doacronym #1,,\finish}
\def\doacronym#1,#2,#3\finish{%
{\selectfonts\lsize #1}%
@ -2646,7 +2646,7 @@ end
% @abbr for "Comput. J." and the like.
% No font change, but don't do end-of-sentence spacing.
%
%
\def\abbr#1{\doabbr #1,,\finish}
\def\doabbr#1,#2,#3\finish{%
{\plainfrenchspacing #1}%
@ -2665,43 +2665,43 @@ end
% Theiling, which support regular, slanted, bold and bold slanted (and
% "outlined" (blackboard board, sort of) versions, which we don't need).
% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
%
%
% Although only regular is the truly official Euro symbol, we ignore
% that. The Euro is designed to be slightly taller than the regular
% font height.
%
%
% feymr - regular
% feymo - slanted
% feybr - bold
% feybo - bold slanted
%
%
% There is no good (free) typewriter version, to my knowledge.
% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
% Hmm.
%
%
% Also doesn't work in math. Do we need to do math with euro symbols?
% Hope not.
%
%
%
%
\def\euro{{\eurofont e}}
\def\eurofont{%
% We set the font at each command, rather than predefining it in
% \textfonts and the other font-switching commands, so that
% installations which never need the symbol don't have to have the
% font installed.
%
%
% There is only one designed size (nominal 10pt), so we always scale
% that to the current nominal size.
%
%
% By the way, simply using "at 1em" works for cmr10 and the like, but
% does not work for cmbx10 and other extended/shrunken fonts.
%
%
\def\eurosize{\csname\curfontsize nominalsize\endcsname}%
%
\ifx\curfontstyle\bfstylename
\ifx\curfontstyle\bfstylename
% bold:
\font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
\else
\else
% regular:
\font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
\fi
@ -2754,7 +2754,7 @@ end
% Laurent Siebenmann reports \Orb undefined with:
% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
% so we'll define it if necessary.
%
%
\ifx\Orb\undefined
\def\Orb{\mathhexbox20D}
\fi
@ -3102,7 +3102,7 @@ end
% cause the example and the item to crash together. So we use this
% bizarre value of 10001 as a signal to \aboveenvbreak to insert
% \parskip glue after all. Section titles are handled this way also.
%
%
\penalty 10001
\endgroup
\itemxneedsnegativevskipfalse
@ -3898,7 +3898,7 @@ end
% processing continues to some further point. On the other hand, it
% seems \endinput does not hurt in the printed index arg, since that
% is still getting written without apparent harm.
%
%
% Sample source (mac-idx3.tex, reported by Graham Percival to
% help-texinfo, 22may06):
% @macro funindex {WORD}
@ -3906,12 +3906,12 @@ end
% @end macro
% ...
% @funindex commtest
%
%
% The above is not enough to reproduce the bug, but it gives the flavor.
%
%
% Sample whatsit resulting:
% .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
%
%
% So:
\let\endinput = \empty
%
@ -4167,11 +4167,11 @@ end
% makeinfo does not expand macros in the argument to @deffn, which ends up
% writing an index entry, and texindex isn't prepared for an index sort entry
% that starts with \.
%
%
% Since macro invocations are followed by braces, we can just redefine them
% to take a single TeX argument. The case of a macro invocation that
% goes to end-of-line is not handled.
%
%
\macrolist
}
@ -4299,7 +4299,7 @@ end
% to re-insert the same penalty (values >10000 are used for various
% signals); since we just inserted a non-discardable item, any
% following glue (such as a \parskip) would be a breakpoint. For example:
%
%
% @deffn deffn-whatever
% @vindex index-whatever
% Description.
@ -5365,11 +5365,11 @@ end
% glue accumulate. (Not a breakpoint because it's preceded by a
% discardable item.)
\vskip-\parskip
%
%
% This is purely so the last item on the list is a known \penalty >
% 10000. This is so \startdefun can avoid allowing breakpoints after
% section headings. Otherwise, it would insert a valid breakpoint between:
%
%
% @section sec-whatever
% @deffn def-whatever
\penalty 10001
@ -5427,7 +5427,7 @@ end
% These characters do not print properly in the Computer Modern roman
% fonts, so we must take special care. This is more or less redundant
% with the Texinfo input format setup at the end of this file.
%
%
\def\activecatcodes{%
\catcode`\"=\active
\catcode`\$=\active
@ -5477,7 +5477,7 @@ end
% redefined for the two-volume lispref. We always output on
% \jobname.toc even if this is redefined.
%
%
\def\tocreadfilename{\jobname.toc}
% Normal (long) toc.
@ -6032,8 +6032,8 @@ end
% from cmtt (char 0x0d). The undirected quote is ugly, so don't make it
% the default, but it works for pasting with more pdf viewers (at least
% evince), the lilypond developers report. xpdf does work with the
% regular 0x27.
%
% regular 0x27.
%
\def\codequoteright{%
\expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
\expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
@ -6045,7 +6045,7 @@ end
% and a similar option for the left quote char vs. a grave accent.
% Modern fonts display ASCII 0x60 as a grave accent, so some people like
% the code environments to do likewise.
%
%
\def\codequoteleft{%
\expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
\expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
@ -6576,7 +6576,7 @@ end
% This does \let #1 = #2, with \csnames; that is,
% \let \csname#1\endcsname = \csname#2\endcsname
% (except of course we have to play expansion games).
%
%
\def\cslet#1#2{%
\expandafter\let
\csname#1\expandafter\endcsname
@ -7734,7 +7734,7 @@ end
%
% If they passed de_DE, and txi-de_DE.tex doesn't exist,
% try txi-de.tex.
%
%
\def\documentlanguagetrywithoutunderscore#1_#2\finish{%
\openin 1 txi-#1.tex
\ifeof 1
@ -7790,7 +7790,7 @@ should work if nowhere else does.}
\setnonasciicharscatcode\active
\lattwochardefs
%
\else \ifx \declaredencoding \latone
\else \ifx \declaredencoding \latone
\setnonasciicharscatcode\active
\latonechardefs
%
@ -7802,7 +7802,7 @@ should work if nowhere else does.}
\setnonasciicharscatcode\active
\utfeightchardefs
%
\else
\else
\message{Unknown document encoding #1, ignoring.}%
%
\fi % utfeight
@ -7814,7 +7814,7 @@ should work if nowhere else does.}
% A message to be logged when using a character that isn't available
% the default font encoding (OT1).
%
%
\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
% Take account of \c (plain) vs. \, (Texinfo) difference.
@ -7827,21 +7827,21 @@ should work if nowhere else does.}
%
% Latin1 (ISO-8859-1) character definitions.
\def\latonechardefs{%
\gdef^^a0{~}
\gdef^^a0{~}
\gdef^^a1{\exclamdown}
\gdef^^a2{\missingcharmsg{CENT SIGN}}
\gdef^^a2{\missingcharmsg{CENT SIGN}}
\gdef^^a3{{\pounds}}
\gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
\gdef^^a5{\missingcharmsg{YEN SIGN}}
\gdef^^a6{\missingcharmsg{BROKEN BAR}}
\gdef^^a6{\missingcharmsg{BROKEN BAR}}
\gdef^^a7{\S}
\gdef^^a8{\"{}}
\gdef^^a9{\copyright}
\gdef^^a8{\"{}}
\gdef^^a9{\copyright}
\gdef^^aa{\ordf}
\gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}}
\gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}}
\gdef^^ac{$\lnot$}
\gdef^^ad{\-}
\gdef^^ae{\registeredsymbol}
\gdef^^ad{\-}
\gdef^^ae{\registeredsymbol}
\gdef^^af{\={}}
%
\gdef^^b0{\textdegree}
@ -7868,7 +7868,7 @@ should work if nowhere else does.}
\gdef^^c2{\^A}
\gdef^^c3{\~A}
\gdef^^c4{\"A}
\gdef^^c5{\ringaccent A}
\gdef^^c5{\ringaccent A}
\gdef^^c6{\AE}
\gdef^^c7{\cedilla C}
\gdef^^c8{\`E}
@ -8009,7 +8009,7 @@ should work if nowhere else does.}
\gdef^^d6{\"O}
\gdef^^d7{$\times$}
\gdef^^d8{\v R}
\gdef^^d9{\ringaccent U}
\gdef^^d9{\ringaccent U}
\gdef^^da{\'U}
\gdef^^db{\H U}
\gdef^^dc{\"U}
@ -8053,11 +8053,11 @@ should work if nowhere else does.}
}
% UTF-8 character definitions.
%
%
% This code to support UTF-8 is based on LaTeX's utf8.def, with some
% changes for Texinfo conventions. It is included here under the GPL by
% permission from Frank Mittelbach and the LaTeX team.
%
%
\newcount\countUTFx
\newcount\countUTFy
\newcount\countUTFz
@ -8897,7 +8897,7 @@ should work if nowhere else does.}
% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
% the literal character `\'.
%
%
@def@normalturnoffactive{%
@let\=@normalbackslash
@let"=@normaldoublequote

View File

@ -38,7 +38,7 @@ grub_arch_efiemu_check_header32 (void *ehdr)
/* Relocate symbols. */
grub_err_t
grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
struct grub_efiemu_elf_sym *elfsyms,
void *ehdr)
{
@ -66,7 +66,7 @@ grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
if (seg)
{
Elf32_Rel *rel, *max;
for (rel = (Elf32_Rel *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
@ -77,31 +77,31 @@ grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr = (Elf32_Word *)
((char *) grub_efiemu_mm_obtain_request (seg->handle)
addr = (Elf32_Word *)
((char *) grub_efiemu_mm_obtain_request (seg->handle)
+ seg->off + rel->r_offset);
sym = elfsyms[ELF32_R_SYM (rel->r_info)];
switch (ELF32_R_TYPE (rel->r_info))
{
case R_386_32:
if ((err = grub_efiemu_write_value
(addr, sym.off + *addr, sym.handle, 0,
if ((err = grub_efiemu_write_value
(addr, sym.off + *addr, sym.handle, 0,
seg->ptv_rel_needed, sizeof (grub_uint32_t))))
return err;
break;
case R_386_PC32:
if ((err = grub_efiemu_write_value
(addr, sym.off + *addr - rel->r_offset
- seg->off, sym.handle, seg->handle,
(addr, sym.off + *addr - rel->r_offset
- seg->off, sym.handle, seg->handle,
seg->ptv_rel_needed, sizeof (grub_uint32_t))))
return err;
break;
default:
return grub_error (GRUB_ERR_BAD_OS,
return grub_error (GRUB_ERR_BAD_OS,
"unrecognised relocation");
}
}

View File

@ -37,7 +37,7 @@ grub_arch_efiemu_check_header64 (void *ehdr)
/* Relocate symbols. */
grub_err_t
grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
struct grub_efiemu_elf_sym *elfsyms,
void *ehdr)
{
@ -62,9 +62,9 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
if (seg)
{
Elf64_Rela *rel, *max;
for (rel = (Elf64_Rela *) ((char *) e + s->sh_offset),
max = rel + (unsigned long) s->sh_size
max = rel + (unsigned long) s->sh_size
/ (unsigned long)s->sh_entsize;
rel < max;
rel++)
@ -76,40 +76,40 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr =
((char *) grub_efiemu_mm_obtain_request (seg->handle)
((char *) grub_efiemu_mm_obtain_request (seg->handle)
+ seg->off + rel->r_offset);
addr32 = (grub_uint32_t *) addr;
addr64 = (grub_uint64_t *) addr;
sym = elfsyms[ELF64_R_SYM (rel->r_info)];
switch (ELF64_R_TYPE (rel->r_info))
{
case R_X86_64_64:
if ((err = grub_efiemu_write_value
(addr, *addr64 + rel->r_addend + sym.off, sym.handle,
if ((err = grub_efiemu_write_value
(addr, *addr64 + rel->r_addend + sym.off, sym.handle,
0, seg->ptv_rel_needed, sizeof (grub_uint64_t))))
return err;
break;
case R_X86_64_PC32:
if ((err = grub_efiemu_write_value
(addr, *addr32 + rel->r_addend + sym.off
- rel->r_offset - seg->off, sym.handle, seg->handle,
(addr, *addr32 + rel->r_addend + sym.off
- rel->r_offset - seg->off, sym.handle, seg->handle,
seg->ptv_rel_needed, sizeof (grub_uint32_t))))
return err;
break;
case R_X86_64_32:
case R_X86_64_32S:
if ((err = grub_efiemu_write_value
(addr, *addr32 + rel->r_addend + sym.off, sym.handle,
if ((err = grub_efiemu_write_value
(addr, *addr32 + rel->r_addend + sym.off, sym.handle,
0, seg->ptv_rel_needed, sizeof (grub_uint32_t))))
return err;
break;
default:
return grub_error (GRUB_ERR_BAD_OS,
return grub_error (GRUB_ERR_BAD_OS,
"unrecognised relocation");
}
}

View File

@ -59,7 +59,7 @@ grub_machine_efiemu_init_tables ()
return err;
}
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000;
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16)
if (grub_memcmp (ptr, "_SM_", 4) == 0
&& grub_byte_checksum (ptr, *(ptr + 5)) == 0)

View File

@ -40,7 +40,7 @@ grub_efiemu_get_section_addr (grub_efiemu_segment_t segs, unsigned n,
if (seg->section == n)
{
*handle = seg->handle;
*off = seg->off;
*off = seg->off;
return GRUB_ERR_NONE;
}
@ -86,7 +86,7 @@ grub_efiemu_load_segments (grub_efiemu_segment_t segs, const Elf_Ehdr *e)
grub_efiemu_segment_t cur;
grub_dprintf ("efiemu", "loading segments\n");
for (cur=segs; cur; cur = cur->next)
{
s = (Elf_Shdr *)cur->srcptr;
@ -94,10 +94,10 @@ grub_efiemu_load_segments (grub_efiemu_segment_t segs, const Elf_Ehdr *e)
if ((s->sh_flags & SHF_ALLOC) && s->sh_size)
{
void *addr;
addr = (grub_uint8_t *) grub_efiemu_mm_obtain_request (cur->handle)
addr = (grub_uint8_t *) grub_efiemu_mm_obtain_request (cur->handle)
+ cur->off;
switch (s->sh_type)
{
case SHT_PROGBITS:
@ -145,11 +145,11 @@ grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e)
seg = (grub_efiemu_segment_t) grub_malloc (sizeof (*seg));
if (! seg)
return grub_errno;
if (s->sh_size)
{
seg->handle
= grub_efiemu_request_memalign
seg->handle
= grub_efiemu_request_memalign
(s->sh_addralign, s->sh_size,
s->sh_flags & SHF_EXECINSTR ? GRUB_EFI_RUNTIME_SERVICES_CODE
: GRUB_EFI_RUNTIME_SERVICES_DATA);
@ -157,12 +157,12 @@ grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e)
return grub_errno;
seg->off = 0;
}
/*
/*
.text-physical doesn't need to be relocated when switching to
virtual mode
*/
if (!grub_strcmp (grub_efiemu_get_string (s->sh_name, e),
if (!grub_strcmp (grub_efiemu_get_string (s->sh_name, e),
".text-physical"))
seg->ptv_rel_needed = 0;
else
@ -174,7 +174,7 @@ grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e)
*segs = seg;
}
}
return GRUB_ERR_NONE;
}
@ -185,7 +185,7 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e)
unsigned i;
Elf_Shdr *s;
int num = 0;
/* Symbols */
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
@ -197,7 +197,7 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e)
return grub_error (GRUB_ERR_BAD_OS, "no symbol table");
grub_efiemu_nelfsyms = (unsigned) s->sh_size / (unsigned) s->sh_entsize;
grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
grub_malloc (sizeof (struct grub_efiemu_elf_sym) * grub_efiemu_nelfsyms);
/* Relocators */
@ -221,7 +221,7 @@ grub_efiemu_resolve_symbols (grub_efiemu_segment_t segs, Elf_Ehdr *e)
Elf_Sym *sym;
const char *str;
Elf_Word size, entsize;
grub_dprintf ("efiemu", "resolving symbols\n");
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
@ -267,7 +267,7 @@ grub_efiemu_resolve_symbols (grub_efiemu_segment_t segs, Elf_Ehdr *e)
break;
case STT_OBJECT:
if ((err = grub_efiemu_get_section_addr
if ((err = grub_efiemu_get_section_addr
(segs, sym->st_shndx, &handle, &off)))
return err;
@ -280,7 +280,7 @@ grub_efiemu_resolve_symbols (grub_efiemu_segment_t segs, Elf_Ehdr *e)
break;
case STT_FUNC:
if ((err = grub_efiemu_get_section_addr
if ((err = grub_efiemu_get_section_addr
(segs, sym->st_shndx, &handle, &off)))
return err;
@ -293,12 +293,12 @@ grub_efiemu_resolve_symbols (grub_efiemu_segment_t segs, Elf_Ehdr *e)
break;
case STT_SECTION:
if ((err = grub_efiemu_get_section_addr
if ((err = grub_efiemu_get_section_addr
(segs, sym->st_shndx, &handle, &off)))
{
grub_efiemu_elfsyms[i].handle = 0;
grub_efiemu_elfsyms[i].off = 0;
grub_errno = GRUB_ERR_NONE;
grub_errno = GRUB_ERR_NONE;
break;
}
@ -346,8 +346,8 @@ SUFFIX (grub_efiemu_loadcore_init) (void *core, grub_size_t core_size,
/* Load runtime definitively */
grub_err_t
SUFFIX (grub_efiemu_loadcore_load) (void *core,
grub_size_t core_size
SUFFIX (grub_efiemu_loadcore_load) (void *core,
grub_size_t core_size
__attribute__ ((unused)),
grub_efiemu_segment_t segments)
{
@ -356,10 +356,10 @@ SUFFIX (grub_efiemu_loadcore_load) (void *core,
return err;
if ((err = grub_efiemu_resolve_symbols (segments, core)))
return err;
if ((err = SUFFIX (grub_arch_efiemu_relocate_symbols) (segments,
if ((err = SUFFIX (grub_arch_efiemu_relocate_symbols) (segments,
grub_efiemu_elfsyms,
core)))
return err;
return GRUB_ERR_NONE;
}

View File

@ -45,7 +45,7 @@ grub_efiemu_sizeof_uintn_t (void)
/* Check the header and set mode */
static grub_err_t
grub_efiemu_check_header (void *ehdr, grub_size_t size,
grub_efiemu_check_header (void *ehdr, grub_size_t size,
grub_efiemu_mode_t *mode)
{
/* Check the magic numbers. */
@ -91,7 +91,7 @@ grub_efiemu_loadcore_unload(void)
case GRUB_EFIEMU64:
grub_efiemu_loadcore_unload64 ();
break;
default:
break;
}
@ -109,7 +109,7 @@ grub_efiemu_loadcore_unload(void)
return GRUB_ERR_NONE;
}
/* Load runtime file and do some initial preparations */
/* Load runtime file and do some initial preparations */
grub_err_t
grub_efiemu_loadcore_init (grub_file_t file)
{
@ -121,7 +121,7 @@ grub_efiemu_loadcore_init (grub_file_t file)
if (! efiemu_core)
return grub_errno;
if (grub_file_read (file, efiemu_core, efiemu_core_size)
if (grub_file_read (file, efiemu_core, efiemu_core_size)
!= (int) efiemu_core_size)
{
grub_free (efiemu_core);
@ -129,7 +129,7 @@ grub_efiemu_loadcore_init (grub_file_t file)
return grub_errno;
}
if (grub_efiemu_check_header (efiemu_core, efiemu_core_size,
if (grub_efiemu_check_header (efiemu_core, efiemu_core_size,
&grub_efiemu_mode))
{
grub_free (efiemu_core);
@ -160,7 +160,7 @@ grub_efiemu_loadcore_init (grub_file_t file)
return err;
}
break;
default:
return grub_error (GRUB_ERR_BAD_OS, "unknown EFI runtime");
}

View File

@ -17,8 +17,8 @@
*/
/* This is an emulation of EFI runtime services.
This allows a more uniform boot on i386 machines.
As it emulates only runtime service it isn't able
This allows a more uniform boot on i386 machines.
As it emulates only runtime service it isn't able
to chainload EFI bootloader on non-EFI system. */
@ -112,7 +112,7 @@ grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid)
grub_err_t
grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
void (*unload) (void *data),
void (*unload) (void *data),
void *data)
{
struct grub_efiemu_prepare_hook *nhook;
@ -129,20 +129,20 @@ grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
return GRUB_ERR_NONE;
}
/* Register a configuration table either supplying the address directly
/* Register a configuration table either supplying the address directly
or with a hook
*/
grub_err_t
grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
void * (*get_table) (void *data),
void (*unload) (void *data),
void (*unload) (void *data),
void *data)
{
struct grub_efiemu_configuration_table *tbl;
grub_err_t err;
if (! get_table && ! data)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"you must set at least get_table or data");
if ((err = grub_efiemu_unregister_configuration_table (guid)))
return err;
@ -163,7 +163,7 @@ grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
static grub_err_t
grub_cmd_efiemu_unload (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char *args[] __attribute__ ((unused)))
{
return grub_efiemu_unload ();
@ -171,7 +171,7 @@ grub_cmd_efiemu_unload (grub_command_t cmd __attribute__ ((unused)),
static grub_err_t
grub_cmd_efiemu_prepare (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char *args[] __attribute__ ((unused)))
{
return grub_efiemu_prepare ();
@ -180,15 +180,15 @@ grub_cmd_efiemu_prepare (grub_command_t cmd __attribute__ ((unused)),
int
grub_efiemu_exit_boot_services (grub_efi_uintn_t map_key
int
grub_efiemu_exit_boot_services (grub_efi_uintn_t map_key
__attribute__ ((unused)))
{
/* Nothing to do here yet */
return 1;
}
int
int
grub_efiemu_finish_boot_services (void)
{
/* Nothing to do here yet */
@ -201,11 +201,11 @@ grub_efiemu_load_file (const char *filename)
{
grub_file_t file;
grub_err_t err;
file = grub_file_open (filename);
if (! file)
return 0;
err = grub_efiemu_mm_init ();
if (err)
{
@ -244,19 +244,19 @@ grub_efiemu_autocore (void)
return GRUB_ERR_NONE;
prefix = grub_env_get ("prefix");
if (! prefix)
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
"couldn't find efiemu core because prefix "
"isn't set");
suffix = grub_efiemu_get_default_core_name ();
filename = grub_malloc (grub_strlen (prefix) + grub_strlen (suffix) + 2);
if (! filename)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"couldn't allocate temporary space");
grub_sprintf (filename, "%s/%s", prefix, suffix);
err = grub_efiemu_load_file (filename);
@ -277,7 +277,7 @@ grub_efiemu_prepare (void)
{
grub_err_t err;
grub_dprintf ("efiemu", "Preparing %d-bit efiemu\n",
grub_dprintf ("efiemu", "Preparing %d-bit efiemu\n",
8 * grub_efiemu_sizeof_uintn_t ());
err = grub_efiemu_autocore ();
@ -321,16 +321,16 @@ grub_efiemu_pnvram_cmd_register (void);
GRUB_MOD_INIT(efiemu)
{
cmd_loadcore = grub_register_command ("efiemu_loadcore",
grub_cmd_efiemu_load,
"efiemu_loadcore FILE",
cmd_loadcore = grub_register_command ("efiemu_loadcore",
grub_cmd_efiemu_load,
"efiemu_loadcore FILE",
"Load and initialize EFI emulator");
cmd_prepare = grub_register_command ("efiemu_prepare",
grub_cmd_efiemu_prepare,
"efiemu_prepare",
cmd_prepare = grub_register_command ("efiemu_prepare",
grub_cmd_efiemu_prepare,
"efiemu_prepare",
"Finalize loading of EFI emulator");
cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload,
"efiemu_unload",
cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload,
"efiemu_unload",
"Unload EFI emulator");
grub_efiemu_pnvram_cmd_register ();
}

View File

@ -17,10 +17,10 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/*
To keep efiemu runtime contiguous this mm is special.
To keep efiemu runtime contiguous this mm is special.
It uses deferred allocation.
In the first stage you may request memory with grub_efiemu_request_memalign
It will give you a handle with which in the second phase you can access your
It will give you a handle with which in the second phase you can access your
memory with grub_efiemu_mm_obtain_request (handle). It's guaranteed that
subsequent calls with the same handle return the same result. You can't request any additional memory once you're in the second phase
*/
@ -32,7 +32,7 @@
#include <grub/machine/memory.h>
#include <grub/efiemu/efiemu.h>
struct grub_efiemu_memrequest
struct grub_efiemu_memrequest
{
struct grub_efiemu_memrequest *next;
grub_efi_memory_type_t type;
@ -54,7 +54,7 @@ static int mmap_reserved_size = 0, mmap_num = 0;
/* Add a memory region to map*/
static grub_err_t
grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
grub_efi_memory_type_t type)
{
grub_uint64_t page_start, npages;
@ -63,10 +63,10 @@ grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
if (mmap_num >= mmap_reserved_size)
{
efiemu_mmap = (grub_efi_memory_descriptor_t *)
grub_realloc (efiemu_mmap, (++mmap_reserved_size)
grub_realloc (efiemu_mmap, (++mmap_reserved_size)
* sizeof (grub_efi_memory_descriptor_t));
if (!efiemu_mmap)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Not enough space for memory map");
}
@ -74,9 +74,9 @@ grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
page_start = start - (start % GRUB_EFIEMU_PAGESIZE);
npages = (size + (start % GRUB_EFIEMU_PAGESIZE) + GRUB_EFIEMU_PAGESIZE - 1)
/ GRUB_EFIEMU_PAGESIZE;
efiemu_mmap[mmap_num].physical_start = page_start;
efiemu_mmap[mmap_num].virtual_start = page_start;
efiemu_mmap[mmap_num].num_pages = npages;
efiemu_mmap[mmap_num].physical_start = page_start;
efiemu_mmap[mmap_num].virtual_start = page_start;
efiemu_mmap[mmap_num].num_pages = npages;
efiemu_mmap[mmap_num].type = type;
mmap_num++;
@ -84,11 +84,11 @@ grub_efiemu_add_to_mmap (grub_uint64_t start, grub_uint64_t size,
}
/* Request a resident memory of type TYPE of size SIZE aligned at ALIGN
ALIGN must be a divisor of page size (if it's a divisor of 4096
ALIGN must be a divisor of page size (if it's a divisor of 4096
it should be ok on all platforms)
*/
int
grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
grub_efi_memory_type_t type)
{
grub_size_t align_overhead;
@ -113,8 +113,8 @@ grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
ret->val = 0;
ret->next = 0;
prev = 0;
/* Add request to the end of the chain.
/* Add request to the end of the chain.
It should be at the end because otherwise alignment isn't guaranteed */
for (cur = memrequests; cur; prev = cur, cur = cur->next);
if (prev)
@ -155,20 +155,20 @@ efiemu_alloc_requests (void)
GRUB_EFI_RUNTIME_SERVICES_CODE,
GRUB_EFI_RUNTIME_SERVICES_DATA,
GRUB_EFI_ACPI_MEMORY_NVS,
/* And then unavailable memory types. This is more for a completeness.
/* And then unavailable memory types. This is more for a completeness.
You should double think before allocating memory of any of these types
*/
GRUB_EFI_UNUSABLE_MEMORY,
GRUB_EFI_MEMORY_MAPPED_IO,
GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
GRUB_EFI_PAL_CODE
GRUB_EFI_PAL_CODE
};
/* Compute total memory needed */
for (i = 0; i < sizeof (reqorder) / sizeof (reqorder[0]); i++)
{
align_overhead = GRUB_EFIEMU_PAGESIZE
align_overhead = GRUB_EFIEMU_PAGESIZE
- (requested_memory[reqorder[i]] % GRUB_EFIEMU_PAGESIZE);
if (align_overhead == GRUB_EFIEMU_PAGESIZE)
align_overhead = 0;
@ -178,7 +178,7 @@ efiemu_alloc_requests (void)
/* Allocate the whole memory in one block */
resident_memory = grub_memalign (GRUB_EFIEMU_PAGESIZE, total_alloc);
if (!resident_memory)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"couldn't allocate resident memory");
/* Split the memory into blocks by type */
@ -199,14 +199,14 @@ efiemu_alloc_requests (void)
}
/* Ensure that the regions are page-aligned */
align_overhead = GRUB_EFIEMU_PAGESIZE
align_overhead = GRUB_EFIEMU_PAGESIZE
- (requested_memory[reqorder[i]] % GRUB_EFIEMU_PAGESIZE);
if (align_overhead == GRUB_EFIEMU_PAGESIZE)
align_overhead = 0;
curptr = ((grub_uint8_t *)curptr) + align_overhead;
/* Add the region to memory map */
grub_efiemu_add_to_mmap (PTR_TO_UINT64 (typestart),
grub_efiemu_add_to_mmap (PTR_TO_UINT64 (typestart),
curptr - typestart, reqorder[i]);
}
@ -270,7 +270,7 @@ grub_efiemu_mm_return_request (int handle)
static grub_err_t
grub_efiemu_mmap_init (void)
{
auto int NESTED_FUNC_ATTR bounds_hook (grub_uint64_t, grub_uint64_t,
auto int NESTED_FUNC_ATTR bounds_hook (grub_uint64_t, grub_uint64_t,
grub_uint32_t);
int NESTED_FUNC_ATTR bounds_hook (grub_uint64_t addr __attribute__ ((unused)),
grub_uint64_t size __attribute__ ((unused)),
@ -302,7 +302,7 @@ grub_efiemu_get_memory_map (grub_efi_uintn_t *memory_map_size,
{
if (!efiemu_mmap)
{
grub_error (GRUB_ERR_INVALID_COMMAND,
grub_error (GRUB_ERR_INVALID_COMMAND,
"you need to first launch efiemu_prepare");
return -1;
}
@ -373,26 +373,26 @@ grub_efiemu_mmap_fill (void)
switch (type)
{
case GRUB_MACHINE_MEMORY_AVAILABLE:
return grub_efiemu_add_to_mmap (addr, size,
return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_CONVENTIONAL_MEMORY);
#ifdef GRUB_MACHINE_MEMORY_ACPI
case GRUB_MACHINE_MEMORY_ACPI:
return grub_efiemu_add_to_mmap (addr, size,
return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_ACPI_RECLAIM_MEMORY);
#endif
#ifdef GRUB_MACHINE_MEMORY_NVS
case GRUB_MACHINE_MEMORY_NVS:
return grub_efiemu_add_to_mmap (addr, size,
return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_ACPI_MEMORY_NVS);
#endif
default:
grub_printf ("Unknown memory type %d. Marking as unusable\n", type);
case GRUB_MACHINE_MEMORY_RESERVED:
return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_UNUSABLE_MEMORY);
return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_UNUSABLE_MEMORY);
}
}
@ -404,8 +404,8 @@ grub_efiemu_mmap_fill (void)
}
grub_err_t
grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
grub_uint64_t,
grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
grub_uint64_t,
grub_uint32_t))
{
unsigned i;
@ -414,10 +414,10 @@ grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
switch (efiemu_mmap[i].type)
{
case GRUB_EFI_RUNTIME_SERVICES_CODE:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_EFIEMU_MEMORY_CODE);
break;
case GRUB_EFI_RESERVED_MEMORY_TYPE:
case GRUB_EFI_RUNTIME_SERVICES_DATA:
case GRUB_EFI_UNUSABLE_MEMORY:
@ -425,30 +425,30 @@ grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
case GRUB_EFI_PAL_CODE:
case GRUB_EFI_MAX_MEMORY_TYPE:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_EFIEMU_MEMORY_RESERVED);
break;
case GRUB_EFI_LOADER_CODE:
case GRUB_EFI_LOADER_DATA:
case GRUB_EFI_BOOT_SERVICES_CODE:
case GRUB_EFI_BOOT_SERVICES_DATA:
case GRUB_EFI_CONVENTIONAL_MEMORY:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_EFIEMU_MEMORY_AVAILABLE);
break;
case GRUB_EFI_ACPI_RECLAIM_MEMORY:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_EFIEMU_MEMORY_ACPI);
break;
case GRUB_EFI_ACPI_MEMORY_NVS:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_EFIEMU_MEMORY_NVS);
break;
}
return 0;
}
@ -459,8 +459,8 @@ grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
static grub_err_t
grub_efiemu_mmap_sort_and_uniq (void)
{
/* If same page is used by multiple types it's resolved
according to priority
/* If same page is used by multiple types it's resolved
according to priority
0 - free memory
1 - memory immediately usable after ExitBootServices
2 - memory usable after loading ACPI tables
@ -512,20 +512,20 @@ grub_efiemu_mmap_sort_and_uniq (void)
/* Initialize variables*/
grub_memset (present, 0, sizeof (int) * GRUB_EFI_MAX_MEMORY_TYPE);
scanline_events = (struct grub_efiemu_mmap_scan *)
scanline_events = (struct grub_efiemu_mmap_scan *)
grub_malloc (sizeof (struct grub_efiemu_mmap_scan) * 2 * mmap_num);
/* Number of chunks can't increase more than by factor of 2 */
result = (grub_efi_memory_descriptor_t *)
result = (grub_efi_memory_descriptor_t *)
grub_malloc (sizeof (grub_efi_memory_descriptor_t) * 2 * mmap_num);
if (!result || !scanline_events)
{
grub_free (result);
grub_free (scanline_events);
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"couldn't allocate space for new memory map");
}
/* Register scanline events */
for (i = 0; i < mmap_num; i++)
{
@ -538,8 +538,8 @@ grub_efiemu_mmap_sort_and_uniq (void)
scanline_events[2 * i + 1].memtype = efiemu_mmap[i].type;
}
/* Primitive bubble sort. It has complexity O(n^2) but since we're
unlikely to have more than 100 chunks it's probably one of the
/* Primitive bubble sort. It has complexity O(n^2) but since we're
unlikely to have more than 100 chunks it's probably one of the
fastest for one purpose */
done = 1;
while (done)
@ -574,29 +574,29 @@ grub_efiemu_mmap_sort_and_uniq (void)
curtype = k;
/* Add memory region to resulting map if necessary */
if ((curtype == -1 || curtype != lasttype)
if ((curtype == -1 || curtype != lasttype)
&& lastaddr != scanline_events[i].pos
&& lasttype != -1)
{
result[j].virtual_start = result[j].physical_start = lastaddr;
result[j].num_pages = (scanline_events[i].pos - lastaddr)
result[j].num_pages = (scanline_events[i].pos - lastaddr)
/ GRUB_EFIEMU_PAGESIZE;
result[j].type = lasttype;
/* We set runtime attribute on pages we need to be mapped */
result[j].attribute
result[j].attribute
= (lasttype == GRUB_EFI_RUNTIME_SERVICES_CODE
|| lasttype == GRUB_EFI_RUNTIME_SERVICES_DATA)
? GRUB_EFI_MEMORY_RUNTIME : 0;
grub_dprintf ("efiemu",
"mmap entry: type %d start 0x%llx 0x%llx pages\n",
grub_dprintf ("efiemu",
"mmap entry: type %d start 0x%llx 0x%llx pages\n",
result[j].type,
result[j].physical_start, result[j].num_pages);
j++;
}
/* Update last values if necessary */
if (curtype == -1 || curtype != lasttype)
if (curtype == -1 || curtype != lasttype)
{
lasttype = curtype;
lastaddr = scanline_events[i].pos;
@ -605,7 +605,7 @@ grub_efiemu_mmap_sort_and_uniq (void)
grub_free (scanline_events);
/* Shrink resulting memory map to really used size and replace efiemu_mmap
/* Shrink resulting memory map to really used size and replace efiemu_mmap
by new value */
grub_free (efiemu_mmap);
efiemu_mmap = grub_realloc (result, j * sizeof (*result));
@ -619,7 +619,7 @@ grub_efiemu_mm_do_alloc (void)
grub_err_t err;
/* Preallocate mmap */
efiemu_mmap = (grub_efi_memory_descriptor_t *)
efiemu_mmap = (grub_efi_memory_descriptor_t *)
grub_malloc (mmap_reserved_size * sizeof (grub_efi_memory_descriptor_t));
if (!efiemu_mmap)
{
@ -632,4 +632,4 @@ grub_efiemu_mm_do_alloc (void)
if ((err = grub_efiemu_mmap_fill ()))
return err;
return grub_efiemu_mmap_sort_and_uniq ();
}
}

View File

@ -45,13 +45,13 @@ static grub_uint32_t accuracy;
static const struct grub_arg_option options[] = {
{"size", 's', 0, "number of bytes to reserve for pseudo NVRAM", 0,
ARG_TYPE_INT},
{"high-monotonic-count", 'm', 0,
{"high-monotonic-count", 'm', 0,
"Initial value of high monotonic count", 0, ARG_TYPE_INT},
{"timezone", 't', 0,
{"timezone", 't', 0,
"Timezone, offset in minutes from GMT", 0, ARG_TYPE_INT},
{"accuracy", 'a', 0,
{"accuracy", 'a', 0,
"Accuracy of clock, in 1e-12 units", 0, ARG_TYPE_INT},
{"daylight", 'd', 0,
{"daylight", 'd', 0,
"Daylight value, as per EFI specifications", 0, ARG_TYPE_INT},
{0, 0, 0, 0, 0, 0}
};
@ -68,14 +68,14 @@ grub_strtosl (char *arg, char **end, int base)
/* Export stuff for efiemu */
static grub_err_t
nvram_set (void * data __attribute__ ((unused)))
{
{
/* Take definitive pointers */
grub_uint8_t *nvram_def = grub_efiemu_mm_obtain_request (nvram_handle);
grub_uint32_t *nvramsize_def
grub_uint32_t *nvramsize_def
= grub_efiemu_mm_obtain_request (nvramsize_handle);
grub_uint32_t *high_monotonic_count_def
= grub_efiemu_mm_obtain_request (high_monotonic_count_handle);
grub_int16_t *timezone_def
grub_int16_t *timezone_def
= grub_efiemu_mm_obtain_request (timezone_handle);
grub_uint8_t *daylight_def
= grub_efiemu_mm_obtain_request (daylight_handle);
@ -94,11 +94,11 @@ nvram_set (void * data __attribute__ ((unused)))
/* Register symbols */
grub_efiemu_register_symbol ("efiemu_variables", nvram_handle, 0);
grub_efiemu_register_symbol ("efiemu_varsize", nvramsize_handle, 0);
grub_efiemu_register_symbol ("efiemu_high_monotonic_count",
grub_efiemu_register_symbol ("efiemu_high_monotonic_count",
high_monotonic_count_handle, 0);
grub_efiemu_register_symbol ("efiemu_time_zone", timezone_handle, 0);
grub_efiemu_register_symbol ("efiemu_time_daylight", daylight_handle, 0);
grub_efiemu_register_symbol ("efiemu_time_accuracy",
grub_efiemu_register_symbol ("efiemu_time_accuracy",
accuracy_handle, 0);
return GRUB_ERR_NONE;
@ -134,7 +134,7 @@ read_pnvram (char *filename)
struct efi_variable *efivar;
grub_size_t guidlen, datalen;
unsigned i, j;
file = grub_file_open (filename);
if (!file)
return grub_error (GRUB_ERR_BAD_OS, "couldn't read pnvram");
@ -157,17 +157,17 @@ read_pnvram (char *filename)
efivar = (struct efi_variable *) nvramptr;
if (nvramptr - nvram + sizeof (struct efi_variable) > nvramsize)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"file is too large for reserved variable space");
nvramptr += sizeof (struct efi_variable);
/* look ahow long guid field is*/
guidlen = 0;
for (ptr2 = ptr; (grub_isspace (*ptr2)
guidlen = 0;
for (ptr2 = ptr; (grub_isspace (*ptr2)
|| (*ptr2 >= '0' && *ptr2 <= '9')
|| (*ptr2 >= 'a' && *ptr2 <= 'f')
|| (*ptr2 >= 'A' && *ptr2 <= 'F'));
|| (*ptr2 >= 'A' && *ptr2 <= 'F'));
ptr2++)
if (!grub_isspace (*ptr2))
guidlen++;
@ -175,7 +175,7 @@ read_pnvram (char *filename)
/* Read guid */
if (guidlen != sizeof (efivar->guid))
{
{
grub_free (buf);
return grub_error (GRUB_ERR_BAD_OS, "can't parse %s", filename);
}
@ -190,14 +190,14 @@ read_pnvram (char *filename)
hex = *ptr - 'a' + 10;
if (*ptr >= 'A' && *ptr <= 'F')
hex = *ptr - 'A' + 10;
if (i%2 == 0)
((grub_uint8_t *)&(efivar->guid))[i/2] = hex << 4;
else
((grub_uint8_t *)&(efivar->guid))[i/2] |= hex;
ptr++;
}
while (grub_isspace (*ptr))
ptr++;
if (*ptr != ':')
@ -230,23 +230,23 @@ read_pnvram (char *filename)
{
/* Look the length */
datalen = 0;
for (ptr2 = ptr; *ptr2 && (grub_isspace (*ptr2)
for (ptr2 = ptr; *ptr2 && (grub_isspace (*ptr2)
|| (*ptr2 >= '0' && *ptr2 <= '9')
|| (*ptr2 >= 'a' && *ptr2 <= 'f')
|| (*ptr2 >= 'A' && *ptr2 <= 'F'));
|| (*ptr2 >= 'A' && *ptr2 <= 'F'));
ptr2++)
if (!grub_isspace (*ptr2))
datalen++;
datalen /= 2;
if (nvramptr - nvram + datalen > nvramsize)
{
grub_free (buf);
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"file is too large for reserved "
" variable space");
}
for (i = 0; i < 2 * datalen; i++)
{
int hex = 0;
@ -258,7 +258,7 @@ read_pnvram (char *filename)
hex = *ptr - 'a' + 10;
if (*ptr >= 'A' && *ptr <= 'F')
hex = *ptr - 'A' + 10;
if (i%2 == 0)
nvramptr[i/2] = hex << 4;
else
@ -278,7 +278,7 @@ read_pnvram (char *filename)
efivar->size = datalen;
else
efivar->namelen = datalen;
ptr++;
}
}
@ -304,23 +304,23 @@ grub_efiemu_make_nvram (void)
grub_free (nvram);
return err;
}
nvram_handle
= grub_efiemu_request_memalign (1, nvramsize,
nvram_handle
= grub_efiemu_request_memalign (1, nvramsize,
GRUB_EFI_RUNTIME_SERVICES_DATA);
nvramsize_handle
= grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
nvramsize_handle
= grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
GRUB_EFI_RUNTIME_SERVICES_DATA);
high_monotonic_count_handle
= grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
= grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
GRUB_EFI_RUNTIME_SERVICES_DATA);
timezone_handle
= grub_efiemu_request_memalign (1, sizeof (grub_uint16_t),
= grub_efiemu_request_memalign (1, sizeof (grub_uint16_t),
GRUB_EFI_RUNTIME_SERVICES_DATA);
daylight_handle
= grub_efiemu_request_memalign (1, sizeof (grub_uint8_t),
= grub_efiemu_request_memalign (1, sizeof (grub_uint8_t),
GRUB_EFI_RUNTIME_SERVICES_DATA);
accuracy_handle
= grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
= grub_efiemu_request_memalign (1, sizeof (grub_uint32_t),
GRUB_EFI_RUNTIME_SERVICES_DATA);
grub_efiemu_request_symbols (6);
@ -341,7 +341,7 @@ grub_efiemu_pnvram (void)
nvram = grub_malloc (nvramsize);
if (!nvram)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate space for temporary pnvram storage");
grub_memset (nvram, 0, nvramsize);
@ -360,16 +360,16 @@ grub_cmd_efiemu_pnvram (struct grub_extcmd *cmd,
nvramsize = state[0].set ? grub_strtoul (state[0].arg, 0, 0) : 2048;
high_monotonic_count = state[1].set ? grub_strtoul (state[1].arg, 0, 0) : 1;
timezone = state[2].set ? grub_strtosl (state[2].arg, 0, 0)
timezone = state[2].set ? grub_strtosl (state[2].arg, 0, 0)
: GRUB_EFI_UNSPECIFIED_TIMEZONE;
accuracy = state[3].set ? grub_strtoul (state[3].arg, 0, 0) : 50000000;
daylight = state[4].set ? grub_strtoul (state[4].arg, 0, 0) : 0;
nvram = grub_malloc (nvramsize);
if (!nvram)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"Couldn't allocate space for temporary pnvram storage");
grub_memset (nvram, 0, nvramsize);
grub_memset (nvram, 0, nvramsize);
if (argc == 1 && (err = read_pnvram (args[0])))
{
@ -387,11 +387,11 @@ void grub_efiemu_pnvram_cmd_unregister (void);
void
grub_efiemu_pnvram_cmd_register (void)
{
cmd = grub_register_extcmd ("efiemu_pnvram", grub_cmd_efiemu_pnvram,
cmd = grub_register_extcmd ("efiemu_pnvram", grub_cmd_efiemu_pnvram,
GRUB_COMMAND_FLAG_BOTH,
"efiemu_pnvram [FILENAME]",
"Initialise pseudo-NVRAM and load variables "
"from FILE",
"from FILE",
options);
}

View File

@ -1,4 +1,4 @@
/* Prepare efiemu. E.g. allocate memory, load the runtime
/* Prepare efiemu. E.g. allocate memory, load the runtime
to appropriate place, etc */
/*
* GRUB -- GRand Unified Bootloader
@ -26,7 +26,7 @@
grub_err_t
SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
struct grub_efiemu_configuration_table
struct grub_efiemu_configuration_table
*config_tables)
{
grub_err_t err;
@ -46,8 +46,8 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
/* Request space for the list of configuration tables */
for (cur = config_tables; cur; cur = cur->next)
cntconftables++;
conftable_handle
= grub_efiemu_request_memalign (GRUB_EFIEMU_PAGESIZE,
conftable_handle
= grub_efiemu_request_memalign (GRUB_EFIEMU_PAGESIZE,
cntconftables * sizeof (*conftables),
GRUB_EFI_RUNTIME_SERVICES_DATA);
@ -69,31 +69,31 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
return err;
}
if ((err = grub_efiemu_resolve_symbol ("efiemu_system_table",
if ((err = grub_efiemu_resolve_symbol ("efiemu_system_table",
&handle, &off)))
{
grub_efiemu_unload ();
return err;
}
SUFFIX (grub_efiemu_system_table)
= (TYPE (grub_efi_system_table) *)
SUFFIX (grub_efiemu_system_table)
= (TYPE (grub_efi_system_table) *)
((grub_uint8_t *)grub_efiemu_mm_obtain_request (handle) + off);
/* compute CRC32 of runtime_services */
if ((err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
if ((err = grub_efiemu_resolve_symbol ("efiemu_runtime_services",
&handle, &off)))
return err;
runtime_services = (TYPE (grub_efiemu_runtime_services) *)
((grub_uint8_t *)grub_efiemu_mm_obtain_request (handle) + off);
runtime_services->hdr.crc32 = 0;
runtime_services->hdr.crc32 = grub_getcrc32
runtime_services->hdr.crc32 = grub_getcrc32
(0, runtime_services, runtime_services->hdr.header_size);
/* Put pointer to the list of configuration tables in system table */
grub_efiemu_write_value
(&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
conftable_handle, 0, 1,
(&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
conftable_handle, 0, 1,
sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table));
SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables;
@ -103,7 +103,7 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
i = 0;
for (cur = config_tables; cur; cur = cur->next, i++)
{
grub_memcpy (&(conftables[i].vendor_guid), &(cur->guid),
grub_memcpy (&(conftables[i].vendor_guid), &(cur->guid),
sizeof (cur->guid));
if (cur->get_table)
conftables[i].vendor_table
@ -114,13 +114,13 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
/* compute CRC32 of system table */
SUFFIX (grub_efiemu_system_table)->hdr.crc32 = 0;
SUFFIX (grub_efiemu_system_table)->hdr.crc32
= grub_getcrc32 (0, SUFFIX (grub_efiemu_system_table),
SUFFIX (grub_efiemu_system_table)->hdr.crc32
= grub_getcrc32 (0, SUFFIX (grub_efiemu_system_table),
SUFFIX (grub_efiemu_system_table)->hdr.header_size);
grub_dprintf ("efiemu","system_table = %p, runtime_services = %p,"
" conftables = %p (%d entries)\n",
SUFFIX (grub_efiemu_system_table), runtime_services,
SUFFIX (grub_efiemu_system_table), runtime_services,
conftables, cntconftables);
return GRUB_ERR_NONE;

View File

@ -29,10 +29,10 @@
* %rcx, %rdx, %r8, %r9, 32(%rsp), 40(%rsp), 48(%rsp), ...
*
*/
.file "efiemu.S"
.text
FUNCTION (efiemu_get_time)
push %rdi
push %rsi
@ -104,7 +104,7 @@ FUNCTION (efiemu_set_variable)
mov %rcx, %rdi
mov %rdx, %rsi
mov %r8, %rdx
mov %r9, %rcx
mov %r9, %rcx
mov 56(%rsp), %r8
call efiemu_set_variable_real
pop %rsi
@ -133,8 +133,8 @@ FUNCTION (efiemu_reset_system)
ret
/* The following functions are always called in physical mode */
.section ".text-physical", "ax"
.section ".text-physical", "ax"
FUNCTION (efiemu_set_virtual_address_map)
push %rdi
push %rsi

View File

@ -17,8 +17,8 @@
*/
/* This is an emulation of EFI runtime services.
This allows a more uniform boot on i386 machines.
As it emulates only runtime serviceit isn't able
This allows a more uniform boot on i386 machines.
As it emulates only runtime serviceit isn't able
to chainload EFI bootloader on non-EFI system (TODO) */
#include <grub/symbol.h>
@ -26,7 +26,7 @@
#include <grub/efi/api.h>
#include <grub/efiemu/runtime.h>
grub_efi_status_t
grub_efi_status_t
efiemu_get_time (grub_efi_time_t *time,
grub_efi_time_capabilities_t *capabilities);
grub_efi_status_t
@ -54,7 +54,7 @@ efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
PHYSICAL_ATTRIBUTE;
grub_efi_status_t
efiemu_convert_pointer (grub_efi_uintn_t debug_disposition,
efiemu_convert_pointer (grub_efi_uintn_t debug_disposition,
void **address)
PHYSICAL_ATTRIBUTE;
@ -84,14 +84,14 @@ efiemu_reset_system (grub_efi_reset_type_t reset_type,
grub_efi_uintn_t data_size,
grub_efi_char16_t *reset_data);
grub_efi_status_t
grub_efi_status_t
EFI_FUNC (efiemu_set_virtual_address_map) (grub_efi_uintn_t,
grub_efi_uintn_t,
grub_efi_uint32_t,
grub_efi_memory_descriptor_t *)
PHYSICAL_ATTRIBUTE;
grub_efi_status_t
EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
void **address)
PHYSICAL_ATTRIBUTE;
static grub_uint32_t
@ -100,15 +100,15 @@ efiemu_getcrc32 (grub_uint32_t crc, void *buf, int size)
static void
init_crc32_table (void)
PHYSICAL_ATTRIBUTE;
static grub_uint32_t
static grub_uint32_t
reflect (grub_uint32_t ref, int len)
PHYSICAL_ATTRIBUTE;
/*
The log. It's used when examining memory dump
*/
*/
static grub_uint8_t loge[1000] = "EFIEMULOG";
static int logn = 9;
static int logn = 9;
#define LOG(x) { if (logn<900) loge[logn++]=x; }
static int ptv_relocated = 0;
@ -189,7 +189,7 @@ int __stack_chk_fail ()
return 0;
}
/* The function that implement runtime services as specified in
/* The function that implement runtime services as specified in
EFI specification */
static inline grub_uint8_t
bcd_to_hex (grub_uint8_t in)
@ -197,7 +197,7 @@ bcd_to_hex (grub_uint8_t in)
return 10 * ((in & 0xf0) >> 4) + (in & 0x0f);
}
grub_efi_status_t
grub_efi_status_t
EFI_FUNC (efiemu_get_time) (grub_efi_time_t *time,
grub_efi_time_capabilities_t *capabilities)
{
@ -279,19 +279,19 @@ EFI_FUNC (efiemu_set_wakeup_time) (grub_efi_boolean_t enabled,
static grub_uint32_t crc32_table [256];
static grub_uint32_t
static grub_uint32_t
reflect (grub_uint32_t ref, int len)
{
grub_uint32_t result = 0;
int i;
for (i = 1; i <= len; i++)
{
if (ref & 1)
result |= 1 << (len - i);
ref >>= 1;
}
return result;
}
@ -332,7 +332,7 @@ efiemu_getcrc32 (grub_uint32_t crc, void *buf, int size)
}
grub_efi_status_t EFI_FUNC
grub_efi_status_t EFI_FUNC
(efiemu_set_virtual_address_map) (grub_efi_uintn_t memory_map_size,
grub_efi_uintn_t descriptor_size,
grub_efi_uint32_t descriptor_version,
@ -341,12 +341,12 @@ grub_efi_status_t EFI_FUNC
struct grub_efiemu_ptv_rel *cur_relloc;
LOG ('e');
/* Ensure that we are called only once */
if (ptv_relocated)
return GRUB_EFI_UNSUPPORTED;
ptv_relocated = 1;
/* Correct addresses using information supplied by grub */
for (cur_relloc = efiemu_ptv_relloc; cur_relloc->size;cur_relloc++)
{
@ -354,8 +354,8 @@ grub_efi_status_t EFI_FUNC
grub_efi_memory_descriptor_t *descptr;
/* Compute correction */
for (descptr = virtual_map;
((grub_uint8_t *) descptr - (grub_uint8_t *) virtual_map)
for (descptr = virtual_map;
((grub_uint8_t *) descptr - (grub_uint8_t *) virtual_map)
< memory_map_size;
descptr = (grub_efi_memory_descriptor_t *)
((grub_uint8_t *) descptr + descriptor_size))
@ -386,27 +386,27 @@ grub_efi_status_t EFI_FUNC
/* Recompute crc32 of system table and runtime services */
efiemu_system_table.hdr.crc32 = 0;
efiemu_system_table.hdr.crc32 = efiemu_getcrc32
efiemu_system_table.hdr.crc32 = efiemu_getcrc32
(0, &efiemu_system_table, sizeof (efiemu_system_table));
efiemu_runtime_services.hdr.crc32 = 0;
efiemu_runtime_services.hdr.crc32 = efiemu_getcrc32
efiemu_runtime_services.hdr.crc32 = efiemu_getcrc32
(0, &efiemu_runtime_services, sizeof (efiemu_runtime_services));
return GRUB_EFI_SUCCESS;
}
/* since efiemu_set_virtual_address_map corrects all the pointers
/* since efiemu_set_virtual_address_map corrects all the pointers
we don't need efiemu_convert_pointer */
grub_efi_status_t
EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
EFI_FUNC (efiemu_convert_pointer) (grub_efi_uintn_t debug_disposition,
void **address)
{
LOG ('f');
return GRUB_EFI_UNSUPPORTED;
}
/* Next comes variable services. Because we have no vendor-independent
/* Next comes variable services. Because we have no vendor-independent
way to store these variables we have no non-volatility */
/* Find variable by name and GUID. */
@ -423,7 +423,7 @@ find_variable (grub_efi_guid_t *vendor_guid,
if (!efivar->namelen)
return 0;
if (efiemu_str16equal((grub_efi_char16_t *)(efivar + 1), variable_name)
&& efiemu_memequal (&(efivar->guid), vendor_guid,
&& efiemu_memequal (&(efivar->guid), vendor_guid,
sizeof (efivar->guid)))
return efivar;
ptr += efivar->namelen + efivar->size + sizeof (*efivar);
@ -452,11 +452,11 @@ EFI_FUNC (efiemu_get_variable) (grub_efi_char16_t *variable_name,
efiemu_memcpy (data, (grub_uint8_t *)(efivar + 1) + efivar->namelen,
efivar->size);
*attributes = efivar->attributes;
return GRUB_EFI_SUCCESS;
}
grub_efi_status_t EFI_FUNC
grub_efi_status_t EFI_FUNC
(efiemu_get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
grub_efi_char16_t *variable_name,
grub_efi_guid_t *vendor_guid)
@ -471,15 +471,15 @@ grub_efi_status_t EFI_FUNC
efivar = find_variable (vendor_guid, variable_name);
if (!efivar)
return GRUB_EFI_NOT_FOUND;
efivar = (struct efi_variable *)((grub_uint8_t *)efivar
+ efivar->namelen
efivar = (struct efi_variable *)((grub_uint8_t *)efivar
+ efivar->namelen
+ efivar->size + sizeof (*efivar));
}
else
efivar = (struct efi_variable *) (efiemu_variables);
LOG ('m');
if ((grub_uint8_t *)efivar >= efiemu_variables + efiemu_varsize
if ((grub_uint8_t *)efivar >= efiemu_variables + efiemu_varsize
|| !efivar->namelen)
return GRUB_EFI_NOT_FOUND;
if (*variable_name_size < efivar->namelen)
@ -489,7 +489,7 @@ grub_efi_status_t EFI_FUNC
}
efiemu_memcpy (variable_name, efivar + 1, efivar->namelen);
efiemu_memcpy (vendor_guid, &(efivar->guid),
efiemu_memcpy (vendor_guid, &(efivar->guid),
sizeof (efivar->guid));
LOG('h');
@ -513,12 +513,12 @@ EFI_FUNC (efiemu_set_variable) (grub_efi_char16_t *variable_name,
/* Delete variable if any */
if (efivar)
{
efiemu_memcpy (efivar, (grub_uint8_t *)(efivar + 1)
+ efivar->namelen + efivar->size,
efiemu_memcpy (efivar, (grub_uint8_t *)(efivar + 1)
+ efivar->namelen + efivar->size,
(efiemu_variables + efiemu_varsize)
- ((grub_uint8_t *)(efivar + 1)
- ((grub_uint8_t *)(efivar + 1)
+ efivar->namelen + efivar->size));
efiemu_memset (efiemu_variables + efiemu_varsize
efiemu_memset (efiemu_variables + efiemu_varsize
- (sizeof (*efivar) + efivar->namelen + efivar->size),
0, (sizeof (*efivar) + efivar->namelen + efivar->size));
}
@ -533,8 +533,8 @@ EFI_FUNC (efiemu_set_variable) (grub_efi_char16_t *variable_name,
if (!efivar->namelen)
break;
}
if ((grub_uint8_t *)(efivar + 1) + data_size
+ 2 * (efiemu_str16len (variable_name) + 1)
if ((grub_uint8_t *)(efivar + 1) + data_size
+ 2 * (efiemu_str16len (variable_name) + 1)
>= efiemu_variables + efiemu_varsize)
return GRUB_EFI_OUT_OF_RESOURCES;
@ -542,16 +542,16 @@ EFI_FUNC (efiemu_set_variable) (grub_efi_char16_t *variable_name,
efivar->namelen = 2 * (efiemu_str16len (variable_name) + 1);
efivar->size = data_size;
efivar->attributes = attributes;
efiemu_memcpy (efivar + 1, variable_name,
efiemu_memcpy (efivar + 1, variable_name,
2 * (efiemu_str16len (variable_name) + 1));
efiemu_memcpy ((grub_uint8_t *)(efivar + 1)
+ 2 * (efiemu_str16len (variable_name) + 1),
efiemu_memcpy ((grub_uint8_t *)(efivar + 1)
+ 2 * (efiemu_str16len (variable_name) + 1),
data, data_size);
return GRUB_EFI_SUCCESS;
}
grub_efi_status_t EFI_FUNC
grub_efi_status_t EFI_FUNC
(efiemu_get_next_high_monotonic_count) (grub_efi_uint32_t *high_count)
{
LOG ('j');
@ -574,9 +574,9 @@ EFI_FUNC (efiemu_reset_system) (grub_efi_reset_type_t reset_type,
LOG ('k');
}
struct grub_efi_runtime_services efiemu_runtime_services =
struct grub_efi_runtime_services efiemu_runtime_services =
{
.hdr =
.hdr =
{
.signature = GRUB_EFIEMU_RUNTIME_SERVICES_SIGNATURE,
.revision = 0x0001000a,
@ -596,18 +596,18 @@ struct grub_efi_runtime_services efiemu_runtime_services =
.get_next_variable_name = efiemu_get_next_variable_name,
.set_variable = efiemu_set_variable,
.get_next_high_monotonic_count = efiemu_get_next_high_monotonic_count,
.reset_system = efiemu_reset_system
};
static grub_uint16_t efiemu_vendor[] =
static grub_uint16_t efiemu_vendor[] =
{'G', 'R', 'U', 'B', ' ', 'E', 'F', 'I', ' ',
'R', 'U', 'N', 'T', 'I', 'M', 'E', 0};
struct grub_efi_system_table efiemu_system_table =
{
.hdr =
.hdr =
{
.signature = GRUB_EFIEMU_SYSTEM_TABLE_SIGNATURE,
.revision = 0x0001000a,

View File

@ -1,4 +1,4 @@
gcc -c -m32 -DELF32 -o efiemu32.o ./efiemu.c -Wall -Werror -nostdlib -O2 -I. -I../../include
gcc -c -m64 -DELF64 -o efiemu64_c.o ./efiemu.c -Wall -Werror -mcmodel=large -O2 -I. -I../../include
gcc -c -m64 -DELF64 -o efiemu64_s.o ./efiemu.S -Wall -Werror -mcmodel=large -O2 -I. -I../../include
ld -o efiemu64.o -r efiemu64_s.o efiemu64_c.o -nostdlib
ld -o efiemu64.o -r efiemu64_s.o efiemu64_c.o -nostdlib

View File

@ -57,16 +57,16 @@ grub_efiemu_free_syms (void)
}
/* Announce that the module will need NUM allocators */
/* Because of deferred memory allocation all the relocators have to be
/* Because of deferred memory allocation all the relocators have to be
announced during phase 1*/
grub_err_t
grub_efiemu_request_symbols (int num)
{
if (ptv_alloc)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"symbols have already been allocated");
if (num < 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"can't request negative symbols");
ptv_requested += num;
return GRUB_ERR_NONE;
@ -111,15 +111,15 @@ grub_err_t
grub_efiemu_alloc_syms (void)
{
ptv_alloc = ptv_requested;
ptv_handle = grub_efiemu_request_memalign
(1, (ptv_requested + 1) * sizeof (struct grub_efiemu_ptv_rel),
ptv_handle = grub_efiemu_request_memalign
(1, (ptv_requested + 1) * sizeof (struct grub_efiemu_ptv_rel),
GRUB_EFI_RUNTIME_SERVICES_DATA);
grub_efiemu_register_symbol ("efiemu_ptv_relloc", ptv_handle, 0);
return grub_errno;
}
/* Write value (pointer to memory PLUS_HANDLE)
- (pointer to memory MINUS_HANDLE) + VALUE to ADDR assuming that the
/* Write value (pointer to memory PLUS_HANDLE)
- (pointer to memory MINUS_HANDLE) + VALUE to ADDR assuming that the
size SIZE bytes. If PTV_NEEDED is 1 then announce it to runtime that this
value needs to be recomputed before going to virtual mode
*/
@ -130,22 +130,22 @@ grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
/* Announce relocator to runtime */
if (ptv_needed)
{
struct grub_efiemu_ptv_rel *ptv_rels
struct grub_efiemu_ptv_rel *ptv_rels
= grub_efiemu_mm_obtain_request (ptv_handle);
if (ptv_needed && ptv_written >= ptv_alloc)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"your module didn't declare efiemu "
" relocators correctly");
if (minus_handle)
ptv_rels[ptv_written].minustype
ptv_rels[ptv_written].minustype
= grub_efiemu_mm_get_type (minus_handle);
else
ptv_rels[ptv_written].minustype = 0;
if (plus_handle)
ptv_rels[ptv_written].plustype
ptv_rels[ptv_written].plustype
= grub_efiemu_mm_get_type (plus_handle);
else
ptv_rels[ptv_written].plustype = 0;
@ -153,7 +153,7 @@ grub_efiemu_write_value (void *addr, grub_uint32_t value, int plus_handle,
ptv_rels[ptv_written].addr = PTR_TO_UINT64 (addr);
ptv_rels[ptv_written].size = size;
ptv_written++;
/* memset next value to zero to mark the end */
grub_memset (&ptv_rels[ptv_written], 0, sizeof (ptv_rels[ptv_written]));
}

View File

@ -36,7 +36,7 @@ struct char_index_entry
grub_uint32_t code;
grub_uint8_t storage_flags;
grub_uint32_t offset;
/* Glyph if loaded, or NULL otherwise. */
struct grub_font_glyph *glyph;
};
@ -72,13 +72,13 @@ struct font_file_section
{
/* The file this section is in. */
grub_file_t file;
/* FOURCC name of the section. */
char name[4];
/* Length of the section contents. */
grub_uint32_t length;
/* Set by open_section() on EOF. */
int eof;
};
@ -170,10 +170,10 @@ font_init (grub_font_t font)
font->family = 0;
font->point_size = 0;
font->weight = 0;
/* Default leading value, not in font file yet. */
font->leading = 1;
font->max_char_width = 0;
font->max_char_height = 0;
font->ascent = 0;
@ -646,7 +646,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
if (! font->file)
/* No open file, can't load any glyphs. */
return 0;
return 0;
/* Make sure we can find glyphs for error messages. Push active
error message to error stack and reset error message. */
@ -900,7 +900,7 @@ get_font_diversity(grub_font_t a, grub_font_t b)
else
/* Penalty for missing attributes. */
d += 50;
/* Weight is a minor factor. */
d += (a->weight != b->weight) ? 5 : 0;
@ -991,13 +991,13 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
| GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
glyph_bitmap.mode_info.bpp = 1;
/* Really 1 bit per pixel. */
glyph_bitmap.mode_info.bytes_per_pixel = 0;
/* Packed densely as bits. */
glyph_bitmap.mode_info.pitch = glyph->width;
glyph_bitmap.mode_info.number_of_colors = 2;
glyph_bitmap.mode_info.bg_red = 0;
glyph_bitmap.mode_info.bg_green = 0;

View File

@ -71,7 +71,7 @@ GRUB_MOD_INIT(font_manager)
GRUB_MOD_FINI(font_manager)
{
/* TODO: Determine way to free allocated resources.
/* TODO: Determine way to free allocated resources.
Warning: possible pointer references could be in use. */
grub_unregister_command (cmd_loadfont);

View File

@ -127,7 +127,7 @@ grub_affs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
sizeof (file), &file);
if (grub_errno)
return 0;
block = grub_be_to_cpu32 (file.extension);
}
@ -139,7 +139,7 @@ grub_affs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
sizeof (pos), &pos);
if (grub_errno)
return 0;
return grub_be_to_cpu32 (pos);
}
@ -353,7 +353,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
sizeof (file), (char *) &file);
if (grub_errno)
goto fail;
file.name[file.namelen] = '\0';
if ((int) grub_be_to_cpu32 (file.type) == GRUB_AFFS_FILETYPE_DIR)
@ -370,7 +370,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
return 1;
next = grub_be_to_cpu32 (file.next);
}
}
}
grub_free (hashtable);
@ -389,18 +389,18 @@ grub_affs_open (struct grub_file *file, const char *name)
{
struct grub_affs_data *data;
struct grub_fshelp_node *fdiro = 0;
grub_dl_ref (my_mod);
data = grub_affs_mount (file->device->disk);
if (!data)
goto fail;
grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_affs_iterate_dir,
grub_affs_read_symlink, GRUB_FSHELP_REG);
if (grub_errno)
goto fail;
file->size = fdiro->size;
data->diropen = *fdiro;
grub_free (fdiro);
@ -414,7 +414,7 @@ grub_affs_open (struct grub_file *file, const char *name)
if (data && fdiro != &data->diropen)
grub_free (fdiro);
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
@ -436,7 +436,7 @@ grub_affs_close (grub_file_t file)
static grub_ssize_t
grub_affs_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_affs_data *data =
struct grub_affs_data *data =
(struct grub_affs_data *) file->data;
int size = grub_affs_read_file (&data->diropen, file->read_hook,
@ -447,13 +447,13 @@ grub_affs_read (grub_file_t file, char *buf, grub_size_t len)
static grub_err_t
grub_affs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_affs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_affs_data *data = 0;
struct grub_fshelp_node *fdiro = 0;
auto int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node);
@ -470,18 +470,18 @@ grub_affs_dir (grub_device_t device, const char *path,
}
grub_dl_ref (my_mod);
data = grub_affs_mount (device->disk);
if (!data)
goto fail;
grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_affs_iterate_dir,
grub_affs_read_symlink, GRUB_FSHELP_DIR);
if (grub_errno)
goto fail;
grub_affs_iterate_dir (fdiro, iterate);
fail:
if (data && fdiro != &data->diropen)
grub_free (fdiro);

View File

@ -554,7 +554,7 @@ grub_afs_close (grub_file_t file)
static grub_err_t
grub_afs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_afs_data *data = 0;;

View File

@ -181,7 +181,7 @@ fail:
static grub_err_t
grub_cpio_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_cpio_data *data;
@ -286,13 +286,13 @@ grub_cpio_open (grub_file_t file, const char *name)
{
if (name[i] != fn[j])
goto no_match;
if (name[i] == '\0')
break;
if (name[i] == '/' && name[i+1] == '/')
i++;
i++;
j++;
}
@ -304,7 +304,7 @@ grub_cpio_open (grub_file_t file, const char *name)
return GRUB_ERR_NONE;
no_match:
grub_free (fn);
data->hofs = ofs;
}

View File

@ -54,7 +54,7 @@
/* Log2 size of ext2 block in 512 blocks. */
#define LOG2_EXT2_BLOCK_SIZE(data) \
(grub_le_to_cpu32 (data->sblock.log2_block_size) + 1)
/* Log2 size of ext2 block in bytes. */
#define LOG2_BLOCK_SIZE(data) \
(grub_le_to_cpu32 (data->sblock.log2_block_size) + 10)
@ -324,7 +324,7 @@ static grub_dl_t my_mod;
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
the mounted filesystem DATA. */
inline static grub_err_t
grub_ext2_blockgroup (struct grub_ext2_data *data, int group,
grub_ext2_blockgroup (struct grub_ext2_data *data, int group,
struct grub_ext2_block_group *blkgrp)
{
return grub_disk_read (data->disk,
@ -382,7 +382,7 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
int blknr = -1;
unsigned int blksz = EXT2_BLOCK_SIZE (data);
int log2_blksz = LOG2_EXT2_BLOCK_SIZE (data);
if (grub_le_to_cpu32(inode->flags) & EXT4_EXTENTS_FLAG)
{
char buf[EXT2_BLOCK_SIZE(data)];
@ -440,14 +440,14 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
<< log2_blksz,
0, blksz, indir))
return grub_errno;
blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]);
}
/* Double indirect. */
else if (fileblock < INDIRECT_BLOCKS + blksz / 4 * (blksz / 4 + 1))
{
unsigned int perblock = blksz / 4;
unsigned int rblock = fileblock - (INDIRECT_BLOCKS
unsigned int rblock = fileblock - (INDIRECT_BLOCKS
+ blksz / 4);
grub_uint32_t indir[blksz / 4];
@ -463,7 +463,7 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
0, blksz, indir))
return grub_errno;
blknr = grub_le_to_cpu32 (indir[rblock % perblock]);
}
/* triple indirect. */
@ -488,7 +488,7 @@ grub_ext2_read_file (grub_fshelp_node_t node,
pos, len, buf, grub_ext2_read_block,
node->inode.size,
LOG2_EXT2_BLOCK_SIZE (node->data));
}
@ -505,7 +505,7 @@ grub_ext2_read_inode (struct grub_ext2_data *data,
/* It is easier to calculate if the first inode is 0. */
ino--;
grub_ext2_blockgroup (data,
ino / grub_le_to_cpu32 (sblock->inodes_per_group),
&blkgrp);
@ -525,7 +525,7 @@ grub_ext2_read_inode (struct grub_ext2_data *data,
EXT2_INODE_SIZE (data) * blkoff,
sizeof (struct grub_ext2_inode), inode))
return grub_errno;
return 0;
}
@ -550,7 +550,7 @@ grub_ext2_mount (grub_disk_t disk)
grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem");
goto fail;
}
/* Check the FS doesn't have feature bits enabled that we don't support. */
if (grub_le_to_cpu32 (data->sblock.feature_incompat)
& ~(EXT2_DRIVER_SUPPORTED_INCOMPAT | EXT2_DRIVER_IGNORED_INCOMPAT))
@ -558,8 +558,8 @@ grub_ext2_mount (grub_disk_t disk)
grub_error (GRUB_ERR_BAD_FS, "filesystem has unsupported incompatible features");
goto fail;
}
data->disk = disk;
data->diropen.data = data;
@ -571,7 +571,7 @@ grub_ext2_mount (grub_disk_t disk)
grub_ext2_read_inode (data, 2, data->inode);
if (grub_errno)
goto fail;
return data;
fail:
@ -587,23 +587,23 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
{
char *symlink;
struct grub_fshelp_node *diro = node;
if (! diro->inode_read)
{
grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
if (grub_errno)
return 0;
}
symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1);
if (! symlink)
return 0;
/* If the filesize of the symlink is bigger than
60 the symlink is stored in a separate block,
otherwise it is stored in the inode. */
if (grub_le_to_cpu32 (diro->inode.size) <= 60)
grub_strncpy (symlink,
grub_strncpy (symlink,
diro->inode.symlink,
grub_le_to_cpu32 (diro->inode.size));
else
@ -617,7 +617,7 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
return 0;
}
}
symlink[grub_le_to_cpu32 (diro->inode.size)] = '\0';
return symlink;
}
@ -631,14 +631,14 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
{
unsigned int fpos = 0;
struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
if (! diro->inode_read)
{
grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
if (grub_errno)
return 0;
}
/* Search the file. */
while (fpos < grub_le_to_cpu32 (diro->inode.size))
{
@ -648,25 +648,25 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
(char *) &dirent);
if (grub_errno)
return 0;
if (dirent.namelen != 0)
{
char filename[dirent.namelen + 1];
struct grub_fshelp_node *fdiro;
enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN;
grub_ext2_read_file (diro, 0, fpos + sizeof (struct ext2_dirent),
dirent.namelen, filename);
if (grub_errno)
return 0;
fdiro = grub_malloc (sizeof (struct grub_fshelp_node));
if (! fdiro)
return 0;
fdiro->data = diro->data;
fdiro->ino = grub_le_to_cpu32 (dirent.inode);
filename[dirent.namelen] = '\0';
if (dirent.filetype != FILETYPE_UNKNOWN)
@ -692,9 +692,9 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
grub_free (fdiro);
return 0;
}
fdiro->inode_read = 1;
if ((grub_le_to_cpu16 (fdiro->inode.mode)
& FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
type = GRUB_FSHELP_DIR;
@ -705,14 +705,14 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
& FILETYPE_INO_MASK) == FILETYPE_INO_REG)
type = GRUB_FSHELP_REG;
}
if (hook (filename, type, fdiro))
return 1;
}
fpos += grub_le_to_cpu16 (dirent.direntlen);
}
return 0;
}
@ -722,25 +722,25 @@ grub_ext2_open (struct grub_file *file, const char *name)
{
struct grub_ext2_data *data;
struct grub_fshelp_node *fdiro = 0;
grub_dl_ref (my_mod);
data = grub_ext2_mount (file->device->disk);
if (! data)
goto fail;
grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_ext2_iterate_dir,
grub_ext2_read_symlink, GRUB_FSHELP_REG);
if (grub_errno)
goto fail;
if (! fdiro->inode_read)
{
grub_ext2_read_inode (data, fdiro->ino, &fdiro->inode);
if (grub_errno)
goto fail;
}
grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_ext2_inode));
grub_free (fdiro);
@ -754,7 +754,7 @@ grub_ext2_open (struct grub_file *file, const char *name)
if (fdiro != &data->diropen)
grub_free (fdiro);
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
@ -775,20 +775,20 @@ static grub_ssize_t
grub_ext2_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_ext2_data *data = (struct grub_ext2_data *) file->data;
return grub_ext2_read_file (&data->diropen, file->read_hook,
file->offset, len, buf);
}
static grub_err_t
grub_ext2_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_ext2_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_ext2_data *data = 0;;
struct grub_fshelp_node *fdiro = 0;
auto int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node);
@ -818,18 +818,18 @@ grub_ext2_dir (grub_device_t device, const char *path,
}
grub_dl_ref (my_mod);
data = grub_ext2_mount (device->disk);
if (! data)
goto fail;
grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_ext2_iterate_dir,
grub_ext2_read_symlink, GRUB_FSHELP_DIR);
if (grub_errno)
goto fail;
grub_ext2_iterate_dir (fdiro, iterate);
fail:
if (fdiro != &data->diropen)
grub_free (fdiro);
@ -890,7 +890,7 @@ grub_ext2_uuid (grub_device_t device, char **uuid)
}
/* Get mtime. */
static grub_err_t
static grub_err_t
grub_ext2_mtime (grub_device_t device, grub_int32_t *tm)
{
struct grub_ext2_data *data;
@ -901,7 +901,7 @@ grub_ext2_mtime (grub_device_t device, grub_int32_t *tm)
data = grub_ext2_mount (disk);
if (!data)
*tm = 0;
else
else
*tm = grub_le_to_cpu32 (data->sblock.utime);
grub_dl_unref (my_mod);

View File

@ -126,15 +126,15 @@ struct grub_fat_data
{
int logical_sector_bits;
grub_uint32_t num_sectors;
grub_uint16_t fat_sector;
grub_uint32_t sectors_per_fat;
int fat_size;
grub_uint32_t root_cluster;
grub_uint32_t root_sector;
grub_uint32_t num_root_sectors;
int cluster_bits;
grub_uint32_t cluster_eof_mark;
grub_uint32_t cluster_sector;
@ -155,7 +155,7 @@ static int
fat_log2 (unsigned x)
{
int i;
if (x == 0)
return -1;
@ -190,14 +190,14 @@ grub_fat_mount (grub_disk_t disk)
&& grub_strncmp((const char *) bpb.version_specific.fat12_or_fat16.fstype, "FAT16", 5)
&& grub_strncmp((const char *) bpb.version_specific.fat32.fstype, "FAT32", 5))
goto fail;
/* Get the sizes of logical sectors and clusters. */
data->logical_sector_bits =
fat_log2 (grub_le_to_cpu16 (bpb.bytes_per_sector));
if (data->logical_sector_bits < GRUB_DISK_SECTOR_BITS)
goto fail;
data->logical_sector_bits -= GRUB_DISK_SECTOR_BITS;
data->cluster_bits = fat_log2 (bpb.sectors_per_cluster);
if (data->cluster_bits < 0)
goto fail;
@ -248,16 +248,16 @@ grub_fat_mount (grub_disk_t disk)
{
/* FAT32. */
grub_uint16_t flags = grub_le_to_cpu16 (bpb.version_specific.fat32.extended_flags);
data->root_cluster = grub_le_to_cpu32 (bpb.version_specific.fat32.root_cluster);
data->fat_size = 32;
data->cluster_eof_mark = 0x0ffffff8;
if (flags & 0x80)
{
/* Get an active FAT. */
unsigned active_fat = flags & 0xf;
if (active_fat > bpb.num_fats)
goto fail;
@ -320,7 +320,7 @@ grub_fat_mount (grub_disk_t disk)
data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat12_or_fat16.num_serial);
else
data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat32.num_serial);
/* Ignore the 3rd bit, because some BIOSes assigns 0xF0 to the media
descriptor, even if it is a so-called superfloppy (e.g. an USB key).
The check may be too strict for this kind of stupid BIOSes, as
@ -352,7 +352,7 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
unsigned logical_cluster_bits;
grub_ssize_t ret = 0;
unsigned long sector;
/* This is a special case. FAT12 and FAT16 doesn't have the root directory
in clusters. */
if (data->file_cluster == ~0U)
@ -417,7 +417,7 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
case 12:
if (data->cur_cluster & 1)
next_cluster >>= 4;
next_cluster &= 0x0FFF;
break;
}
@ -426,7 +426,7 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
grub_printf ("%s:%d: fat_size=%d, next_cluster=%u\n",
__FILE__, __LINE__, data->fat_size, next_cluster);
#endif
/* Check the end. */
if (next_cluster >= data->cluster_eof_mark)
return ret;
@ -468,7 +468,7 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
static grub_err_t
grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
struct grub_fat_dir_entry *dir))
{
struct grub_fat_dir_entry dir;
@ -477,10 +477,10 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
int slot = -1, slots = -1;
int checksum = -1;
grub_ssize_t offset = -sizeof(dir);
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
/* Allocate space enough to hold a long name. */
filename = grub_malloc (0x40 * 13 * 4 + 1);
unibuf = (grub_uint16_t *) grub_malloc (0x40 * 13 * 2);
@ -490,7 +490,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
grub_free (unibuf);
return 0;
}
while (1)
{
unsigned i;
@ -509,7 +509,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
struct grub_fat_long_name_entry *long_name
= (struct grub_fat_long_name_entry *) &dir;
grub_uint8_t id = long_name->id;
if (id & 0x40)
{
id &= 0x3f;
@ -537,11 +537,11 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
/* This is a workaround for Japanese. */
if (dir.name[0] == 0x05)
dir.name[0] = 0xe5;
if (checksum != -1 && slot == 0)
{
grub_uint8_t sum;
for (sum = 0, i = 0; i < sizeof (dir.name); i++)
sum = ((sum >> 1) | (sum << 7)) + dir.name[i];
@ -551,13 +551,13 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
for (u = 0; u < slots * 13; u++)
unibuf[u] = grub_le_to_cpu16 (unibuf[u]);
*grub_utf16_to_utf8 ((grub_uint8_t *) filename, unibuf,
slots * 13) = '\0';
if (hook (filename, &dir))
break;
checksum = -1;
continue;
}
@ -569,7 +569,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
filep = filename;
if (dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
{
for (i = 0; i < sizeof (dir.name) && dir.name[i]
for (i = 0; i < sizeof (dir.name) && dir.name[i]
&& ! grub_isspace (dir.name[i]); i++)
*filep++ = dir.name[i];
}
@ -577,9 +577,9 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
{
for (i = 0; i < 8 && dir.name[i] && ! grub_isspace (dir.name[i]); i++)
*filep++ = grub_tolower (dir.name[i]);
*filep = '.';
for (i = 8; i < 11 && dir.name[i] && ! grub_isspace (dir.name[i]); i++)
*++filep = grub_tolower (dir.name[i]);
@ -604,7 +604,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
static char *
grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
char *dirname, *dirp;
@ -636,18 +636,18 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
if (call_hook)
hook (filename, &info);
return 1;
}
return 0;
}
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
return 0;
}
/* Extract a directory name. */
while (*path == '/')
path++;
@ -656,7 +656,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
if (dirp)
{
unsigned len = dirp - path;
dirname = grub_malloc (len + 1);
if (! dirname)
return 0;
@ -669,7 +669,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
dirname = grub_strdup (path);
call_hook = (! dirp && hook);
grub_fat_iterate_dir (disk, data, iter_hook);
if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
@ -681,7 +681,7 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
static grub_err_t
grub_fat_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_fat_data *data = 0;
@ -691,7 +691,7 @@ grub_fat_dir (grub_device_t device, const char *path,
char *p;
grub_dl_ref (my_mod);
data = grub_fat_mount (disk);
if (! data)
goto fail;
@ -707,7 +707,7 @@ grub_fat_dir (grub_device_t device, const char *path,
*p++ = '/';
*p = '\0';
p = dirname;
do
{
p = grub_fat_find_dir (disk, data, p, hook);
@ -718,9 +718,9 @@ grub_fat_dir (grub_device_t device, const char *path,
grub_free (dirname);
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
}
@ -731,7 +731,7 @@ grub_fat_open (grub_file_t file, const char *name)
char *p = (char *) name;
grub_dl_ref (my_mod);
data = grub_fat_mount (file->device->disk);
if (! data)
goto fail;
@ -752,15 +752,15 @@ grub_fat_open (grub_file_t file, const char *name)
file->data = data;
file->size = data->file_size;
return GRUB_ERR_NONE;
fail:
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
}
@ -775,9 +775,9 @@ static grub_err_t
grub_fat_close (grub_file_t file)
{
grub_free (file->data);
grub_dl_unref (my_mod);
return grub_errno;
}
@ -799,7 +799,7 @@ grub_fat_label (grub_device_t device, char **label)
}
grub_dl_ref (my_mod);
data = grub_fat_mount (disk);
if (! data)
goto fail;
@ -811,7 +811,7 @@ grub_fat_label (grub_device_t device, char **label)
}
*label = 0;
grub_fat_iterate_dir (disk, data, iter_hook);
fail:

View File

@ -47,7 +47,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
grub_err_t err;
enum grub_fshelp_filetype foundtype = GRUB_FSHELP_DIR;
int symlinknest = 0;
auto grub_err_t NESTED_FUNC_ATTR find_file (const char *currpath,
grub_fshelp_node_t currroot,
grub_fshelp_node_t *currfound);
@ -69,13 +69,13 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
grub_fshelp_node_t node);
auto void free_node (grub_fshelp_node_t node);
void free_node (grub_fshelp_node_t node)
{
if (node != rootnode && node != currroot)
grub_free (node);
}
int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node)
@ -88,31 +88,31 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
grub_free (node);
return 0;
}
/* The node is found, stop iterating over the nodes. */
type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE;
oldnode = currnode;
currnode = node;
return 1;
}
grub_strncpy (fpath, currpath, grub_strlen (currpath) + 1);
/* Remove all leading slashes. */
while (*name == '/')
name++;
if (! *name)
{
*currfound = currnode;
return 0;
}
for (;;)
{
int found;
/* Extract the actual part from the pathname. */
next = grub_strchr (name, '/');
if (next)
@ -121,7 +121,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
while (*next == '/')
*(next++) = '\0';
}
/* At this point it is expected that the current node is a
directory, check if this is true. */
if (type != GRUB_FSHELP_DIR)
@ -129,22 +129,22 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
free_node (currnode);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
}
/* Iterate over the directory. */
found = iterate_dir (currnode, iterate);
if (! found)
{
if (grub_errno)
return grub_errno;
break;
}
/* Read in the symlink and follow it. */
if (type == GRUB_FSHELP_SYMLINK)
{
char *symlink;
/* Test if the symlink does not loop. */
if (++symlinknest == 8)
{
@ -153,37 +153,37 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
return grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks");
}
symlink = read_symlink (currnode);
free_node (currnode);
if (!symlink)
{
free_node (oldnode);
return grub_errno;
}
/* The symlink is an absolute path, go back to the root inode. */
if (symlink[0] == '/')
{
free_node (oldnode);
oldnode = rootnode;
}
}
/* Lookup the node the symlink points to. */
find_file (symlink, oldnode, &currnode);
type = foundtype;
grub_free (symlink);
if (grub_errno)
{
free_node (oldnode);
return grub_errno;
}
}
free_node (oldnode);
/* Found the node! */
if (! next || *next == '\0')
{
@ -191,10 +191,10 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
foundtype = type;
return 0;
}
name = next;
}
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
}
@ -203,17 +203,17 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename");
return grub_errno;
}
err = find_file (path, rootnode, foundnode);
if (err)
return err;
/* Check if the node that was found was of the expected type. */
if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a regular file");
else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
return 0;
}
@ -252,14 +252,14 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
blknr = get_block (node, i);
if (grub_errno)
return -1;
blknr = blknr << log2blocksize;
/* Last block. */
if (i == blockcnt - 1)
{
blockend = (len + pos) & (blocksize - 1);
/* The last portion is exactly blocksize. */
if (! blockend)
blockend = blocksize;
@ -271,12 +271,12 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
skipfirst = blockoff;
blockend -= skipfirst;
}
/* If the block number is 0 this block is not stored on disk but
is zero filled instead. */
if (blknr)
{
disk->read_hook = read_hook;
disk->read_hook = read_hook;
grub_disk_read (disk, blknr, skipfirst,
blockend, buf);
@ -297,7 +297,7 @@ unsigned int
grub_fshelp_log2blksize (unsigned int blksize, unsigned int *pow)
{
int mod;
*pow = 0;
while (blksize > 1)
{

200
fs/hfs.c
View File

@ -103,7 +103,7 @@ struct grub_hfs_catalog_key
{
grub_uint8_t unused;
grub_uint32_t parent_dir;
/* Filename length. */
grub_uint8_t strlen;
@ -174,28 +174,28 @@ grub_hfs_block (struct grub_hfs_data *data, grub_hfs_datarecord_t dat,
grub_hfs_datarecord_t dr;
int pos = 0;
struct grub_hfs_extent_key key;
int tree = 0;
static int cache_file = 0;
static int cache_pos = 0;
static int cache_pos = 0;
static grub_hfs_datarecord_t cache_dr;
grub_memcpy (dr, dat, sizeof (dr));
key.forktype = 0;
key.fileid = grub_cpu_to_be32 (file);
if (cache && cache_file == file && block > cache_pos)
{
pos = cache_pos;
key.first_block = grub_cpu_to_be16 (pos);
grub_memcpy (dr, cache_dr, sizeof (cache_dr));
}
for (;;)
{
int i;
/* Try all 3 extents. */
for (i = 0; i < 3; i++)
{
@ -203,7 +203,7 @@ grub_hfs_block (struct grub_hfs_data *data, grub_hfs_datarecord_t dat,
if (grub_be_to_cpu16 (dr[i].count) + pos > block)
{
int first = grub_be_to_cpu16 (dr[i].first_block);
/* If the cache is enabled, store the current position
in the tree. */
if (tree && cache)
@ -212,15 +212,15 @@ grub_hfs_block (struct grub_hfs_data *data, grub_hfs_datarecord_t dat,
cache_pos = pos;
grub_memcpy (cache_dr, dr, sizeof (cache_dr));
}
return (grub_be_to_cpu16 (data->sblock.first_block)
+ (first + block - pos) * GRUB_HFS_BLKS);
}
/* Try the next extent. */
pos += grub_be_to_cpu16 (dr[i].count);
}
/* Lookup the block in the extent overflow file. */
key.first_block = grub_cpu_to_be16 (pos);
tree = 1;
@ -247,7 +247,7 @@ grub_hfs_read_file (struct grub_hfs_data *data,
if (len > grub_le_to_cpu32 (data->size))
len = grub_le_to_cpu32 (data->size);
blockcnt = ((len + pos)
blockcnt = ((len + pos)
+ data->blksz - 1) / data->blksz;
for (i = pos / data->blksz; i < blockcnt; i++)
@ -257,16 +257,16 @@ grub_hfs_read_file (struct grub_hfs_data *data,
int blockend = data->blksz;
int skipfirst = 0;
blknr = grub_hfs_block (data, data->extents, data->fileid, i, 1);
if (grub_errno)
return -1;
/* Last block. */
if (i == blockcnt - 1)
{
blockend = (len + pos) % data->blksz;
/* The last portion is exactly EXT2_BLOCK_SIZE (data). */
if (! blockend)
blockend = data->blksz;
@ -283,17 +283,17 @@ grub_hfs_read_file (struct grub_hfs_data *data,
is zero filled instead. */
if (blknr)
{
data->disk->read_hook = read_hook;
data->disk->read_hook = read_hook;
grub_disk_read (data->disk, blknr, skipfirst,
blockend, buf);
data->disk->read_hook = 0;
if (grub_errno)
return -1;
}
buf += data->blksz - skipfirst;
}
return len;
}
@ -306,13 +306,13 @@ grub_hfs_mount (grub_disk_t disk)
struct grub_hfs_catalog_key key;
struct grub_hfs_dirrec dir;
int first_block;
struct
{
struct grub_hfs_node node;
struct grub_hfs_treeheader head;
} treehead;
data = grub_malloc (sizeof (struct grub_hfs_data));
if (!data)
return 0;
@ -321,7 +321,7 @@ grub_hfs_mount (grub_disk_t disk)
if (grub_disk_read (disk, GRUB_HFS_SBLOCK, 0,
sizeof (struct grub_hfs_sblock), &data->sblock))
goto fail;
/* Check if this is a HFS filesystem. */
if (grub_be_to_cpu16 (data->sblock.magic) != GRUB_HFS_MAGIC)
{
@ -335,23 +335,23 @@ grub_hfs_mount (grub_disk_t disk)
grub_error (GRUB_ERR_BAD_FS, "embedded HFS+ filesystem");
goto fail;
}
data->blksz = grub_be_to_cpu32 (data->sblock.blksz);
data->disk = disk;
/* Lookup the root node of the extent overflow tree. */
first_block = ((grub_be_to_cpu16 (data->sblock.extent_recs[0].first_block)
first_block = ((grub_be_to_cpu16 (data->sblock.extent_recs[0].first_block)
* GRUB_HFS_BLKS)
+ grub_be_to_cpu16 (data->sblock.first_block));
if (grub_disk_read (data->disk, first_block, 0,
sizeof (treehead), &treehead))
goto fail;
data->ext_root = grub_be_to_cpu32 (treehead.head.root_node);
data->ext_size = grub_be_to_cpu16 (treehead.head.node_size);
/* Lookup the root node of the catalog tree. */
first_block = ((grub_be_to_cpu16 (data->sblock.catalog_recs[0].first_block)
first_block = ((grub_be_to_cpu16 (data->sblock.catalog_recs[0].first_block)
* GRUB_HFS_BLKS)
+ grub_be_to_cpu16 (data->sblock.first_block));
if (grub_disk_read (data->disk, first_block, 0,
@ -359,32 +359,32 @@ grub_hfs_mount (grub_disk_t disk)
goto fail;
data->cat_root = grub_be_to_cpu32 (treehead.head.root_node);
data->cat_size = grub_be_to_cpu16 (treehead.head.node_size);
/* Lookup the root directory node in the catalog tree using the
volume name. */
key.parent_dir = grub_cpu_to_be32 (1);
key.strlen = data->sblock.volname[0];
grub_strcpy ((char *) key.str, (char *) (data->sblock.volname + 1));
if (grub_hfs_find_node (data, (char *) &key, data->cat_root,
0, (char *) &dir, sizeof (dir)) == 0)
{
grub_error (GRUB_ERR_BAD_FS, "can not find the hfs root directory");
goto fail;
}
if (grub_errno)
goto fail;
data->rootdir = grub_be_to_cpu32 (dir.dirid);
return data;
fail:
grub_free (data);
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a hfs filesystem");
return 0;
}
@ -641,7 +641,7 @@ grub_hfs_cmp_extkeys (struct grub_hfs_extent_key *k1,
if (cmp == 0)
cmp = grub_be_to_cpu32 (k1->fileid) - grub_be_to_cpu32 (k2->fileid);
if (cmp == 0)
cmp = (grub_be_to_cpu16 (k1->first_block)
cmp = (grub_be_to_cpu16 (k1->first_block)
- grub_be_to_cpu16 (k2->first_block));
return cmp;
}
@ -657,24 +657,24 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
struct grub_hfs_record *))
{
int nodesize = type == 0 ? data->cat_size : data->ext_size;
union
{
struct grub_hfs_node node;
char rawnode[nodesize];
grub_uint16_t offsets[nodesize / 2];
} node;
do
{
int i;
struct grub_hfs_extent *dat;
int blk;
dat = (struct grub_hfs_extent *) (type == 0
dat = (struct grub_hfs_extent *) (type == 0
? (&data->sblock.catalog_recs)
: (&data->sblock.extent_recs));
/* Read the node into memory. */
blk = grub_hfs_block (data, dat,
(type == 0) ? GRUB_HFS_CNID_CAT : GRUB_HFS_CNID_EXT,
@ -682,11 +682,11 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
blk += (idx % (data->blksz / nodesize));
if (grub_errno)
return grub_errno;
if (grub_disk_read (data->disk, blk, 0,
sizeof (node), &node))
return grub_errno;
/* Iterate over all records in this node. */
for (i = 0; i < grub_be_to_cpu16 (node.node.reccnt); i++)
{
@ -698,23 +698,23 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
} __attribute__ ((packed)) *pnt;
pnt = (struct pointer *) (grub_be_to_cpu16 (node.offsets[pos])
+ node.rawnode);
struct grub_hfs_record rec =
struct grub_hfs_record rec =
{
&pnt->key,
pnt->keylen,
&pnt->key + pnt->keylen +(pnt->keylen + 1) % 2,
nodesize - grub_be_to_cpu16 (node.offsets[pos])
nodesize - grub_be_to_cpu16 (node.offsets[pos])
- pnt->keylen - 1
};
if (node_hook (&node.node, &rec))
return 0;
}
idx = grub_be_to_cpu32 (node.node.next);
} while (idx && this);
return 0;
}
@ -730,18 +730,18 @@ grub_hfs_find_node (struct grub_hfs_data *data, char *key,
int found = -1;
int isleaf = 0;
int done = 0;
auto int node_found (struct grub_hfs_node *, struct grub_hfs_record *);
int node_found (struct grub_hfs_node *hnd, struct grub_hfs_record *rec)
{
int cmp = 1;
if (type == 0)
cmp = grub_hfs_cmp_catkeys (rec->key, (void *) key);
else
cmp = grub_hfs_cmp_extkeys (rec->key, (void *) key);
/* If the key is smaller or equal to the current node, mark the
entry. In case of a non-leaf mode it will be used to lookup
the rest of the tree. */
@ -752,12 +752,12 @@ grub_hfs_find_node (struct grub_hfs_data *data, char *key,
}
else /* The key can not be found in the tree. */
return 1;
/* Check if this node is a leaf node. */
if (hnd->type == GRUB_HFS_NODE_LEAF)
{
isleaf = 1;
/* Found it!!!! */
if (cmp == 0)
{
@ -768,23 +768,23 @@ grub_hfs_find_node (struct grub_hfs_data *data, char *key,
return 1;
}
}
return 0;
}
do
{
found = -1;
if (grub_hfs_iterate_records (data, type, idx, 0, node_found))
return 0;
if (found == -1)
return 0;
idx = found;
} while (! isleaf);
return done;
}
@ -799,7 +799,7 @@ grub_hfs_iterate_dir (struct grub_hfs_data *data, grub_uint32_t root_idx,
int found = -1;
int isleaf = 0;
int next = 0;
/* The lowest key possible with DIR as root directory. */
struct grub_hfs_catalog_key key = {0, grub_cpu_to_be32 (dir), 0, ""};
@ -807,51 +807,51 @@ grub_hfs_iterate_dir (struct grub_hfs_data *data, grub_uint32_t root_idx,
auto int it_dir (struct grub_hfs_node * __attribute ((unused)),
struct grub_hfs_record *);
int node_found (struct grub_hfs_node *hnd, struct grub_hfs_record *rec)
{
struct grub_hfs_catalog_key *ckey = rec->key;
if (grub_hfs_cmp_catkeys (rec->key, (void *) &key) <= 0)
found = grub_be_to_cpu32 (*(grub_uint32_t *) rec->data);
if (hnd->type == 0xFF && ckey->strlen > 0)
{
isleaf = 1;
next = grub_be_to_cpu32 (hnd->next);
/* An entry was found. */
if (grub_be_to_cpu32 (ckey->parent_dir) == dir)
return hook (rec);
}
return 0;
}
int it_dir (struct grub_hfs_node *hnd __attribute ((unused)),
struct grub_hfs_record *rec)
{
struct grub_hfs_catalog_key *ckey = rec->key;
struct grub_hfs_catalog_key *origkey = &key;
/* Stop when the entries do not match anymore. */
if (grub_be_to_cpu32 (ckey->parent_dir)
if (grub_be_to_cpu32 (ckey->parent_dir)
!= grub_be_to_cpu32 ((origkey)->parent_dir))
return 1;
return hook (rec);
}
do
{
found = -1;
if (grub_hfs_iterate_records (data, 0, root_idx, 0, node_found))
return grub_errno;
if (found == -1)
return 0;
root_idx = found;
} while (! isleaf);
@ -878,21 +878,21 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
} fdrec;
fdrec.frec.type = GRUB_HFS_FILETYPE_DIR;
if (path[0] != '/')
{
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename");
return 0;
}
origpath = grub_strdup (path);
if (!origpath)
return grub_errno;
path = origpath;
while (*path == '/')
path++;
while (path && grub_strlen (path))
{
if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR)
@ -900,7 +900,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
goto fail;
}
/* Isolate a part of the path. */
next = grub_strchr (path, '/');
if (next)
@ -908,13 +908,13 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
while (*next == '/')
*(next++) = '\0';
}
struct grub_hfs_catalog_key key;
key.parent_dir = grub_cpu_to_be32 (inode);
key.strlen = grub_strlen (path);
grub_strcpy ((char *) (key.str), path);
/* Lookup this node. */
if (! grub_hfs_find_node (data, (char *) &key, data->cat_root,
0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
@ -925,17 +925,17 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
if (grub_errno)
goto fail;
inode = grub_be_to_cpu32 (fdrec.dir.dirid);
path = next;
}
if (retdata)
grub_memcpy (retdata, &fdrec.frec, sizeof (fdrec.frec));
if (retinode)
*retinode = inode;
fail:
grub_free (origpath);
return grub_errno;
@ -944,7 +944,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
static grub_err_t
grub_hfs_dir (grub_device_t device, const char *path,
grub_hfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
@ -959,10 +959,10 @@ grub_hfs_dir (grub_device_t device, const char *path,
struct grub_hfs_catalog_key *ckey = rec->key;
struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
grub_strncpy (fname, (char *) (ckey->str), ckey->strlen);
if (*filetype == GRUB_HFS_FILETYPE_DIR
if (*filetype == GRUB_HFS_FILETYPE_DIR
|| *filetype == GRUB_HFS_FILETYPE_FILE)
{
info.dir = (*filetype == GRUB_HFS_FILETYPE_DIR);
@ -970,16 +970,16 @@ grub_hfs_dir (grub_device_t device, const char *path,
}
return 0;
}
struct grub_hfs_data *data;
struct grub_hfs_filerec frec;
grub_dl_ref (my_mod);
data = grub_hfs_mount (device->disk);
if (!data)
goto fail;
/* First the directory ID for the directory. */
if (grub_hfs_find_dir (data, path, &frec, &inode))
goto fail;
@ -989,14 +989,14 @@ grub_hfs_dir (grub_device_t device, const char *path,
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
goto fail;
}
grub_hfs_iterate_dir (data, data->cat_root, inode, dir_hook);
fail:
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
}
@ -1007,18 +1007,18 @@ grub_hfs_open (struct grub_file *file, const char *name)
{
struct grub_hfs_data *data;
struct grub_hfs_filerec frec;
grub_dl_ref (my_mod);
data = grub_hfs_mount (file->device->disk);
if (grub_hfs_find_dir (data, name, &frec, 0))
{
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
}
if (frec.type != GRUB_HFS_FILETYPE_FILE)
{
grub_free (data);
@ -1026,7 +1026,7 @@ grub_hfs_open (struct grub_file *file, const char *name)
grub_dl_unref (my_mod);
return grub_errno;
}
grub_memcpy (data->extents, frec.extents, sizeof (grub_hfs_datarecord_t));
file->size = grub_be_to_cpu32 (frec.size);
data->size = grub_be_to_cpu32 (frec.size);
@ -1034,16 +1034,16 @@ grub_hfs_open (struct grub_file *file, const char *name)
file->offset = 0;
file->data = data;
return 0;
}
static grub_ssize_t
grub_hfs_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_hfs_data *data =
struct grub_hfs_data *data =
(struct grub_hfs_data *) file->data;
return grub_hfs_read_file (data, file->read_hook, file->offset, len, buf);
}
@ -1065,7 +1065,7 @@ grub_hfs_label (grub_device_t device, char **label)
struct grub_hfs_data *data;
data = grub_hfs_mount (device->disk);
if (data)
*label = grub_strndup ((char *) (data->sblock.volname + 1),
*data->sblock.volname);

View File

@ -321,7 +321,7 @@ grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
code above used this memory, it can be freed now. */
grub_free (nnode);
nnode = 0;
if (blk != -1)
return (blk
+ (node->data->embedded_offset >> (node->data->log2blksize
@ -455,7 +455,7 @@ grub_hfsplus_mount (grub_disk_t disk)
grub_memcpy (&data->catalog_tree.file.extents,
data->volheader.catalog_file.extents,
sizeof data->volheader.catalog_file.extents);
data->catalog_tree.file.size =
data->catalog_tree.file.size =
grub_be_to_cpu64 (data->volheader.catalog_file.size);
/* Make a new node for the extent overflow file. */
@ -465,7 +465,7 @@ grub_hfsplus_mount (grub_disk_t disk)
data->volheader.extents_file.extents,
sizeof data->volheader.catalog_file.extents);
data->extoverflow_tree.file.size =
data->extoverflow_tree.file.size =
grub_be_to_cpu64 (data->volheader.extents_file.size);
/* Read the essential information about the trees. */
@ -518,10 +518,10 @@ grub_hfsplus_cmp_catkey (struct grub_hfsplus_key *keya,
char *filename;
int i;
int diff;
diff = grub_be_to_cpu32 (catkey_a->parent) - catkey_b->parent;
if (diff)
return diff;
return diff;
/* Change the filename in keya so the endianness is correct. */
for (i = 0; i < grub_be_to_cpu16 (catkey_a->namelen); i++)
@ -592,7 +592,7 @@ grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
int first_rec,
int (*hook) (void *record))
{
int rec;
int rec;
for (;;)
{
@ -661,8 +661,8 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
for (rec = 0; rec < grub_be_to_cpu16 (nodedesc->count); rec++)
{
struct grub_hfsplus_key *currkey;
currkey = grub_hfsplus_btree_recptr (btree, nodedesc, rec);
currkey = grub_hfsplus_btree_recptr (btree, nodedesc, rec);
/* The action that has to be taken depend on the type of
record. */
if (nodedesc->type == GRUB_HFSPLUS_BTNODE_TYPE_LEAF
@ -716,7 +716,7 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
grub_fshelp_node_t node))
{
int ret = 0;
auto int list_nodes (void *record);
int list_nodes (void *record)
{
@ -730,7 +730,7 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
catkey = (struct grub_hfsplus_catkey *) record;
fileinfo =
(struct grub_hfsplus_catfile *) ((char *) record
(struct grub_hfsplus_catfile *) ((char *) record
+ grub_be_to_cpu16 (catkey->keylen)
+ 2 + (grub_be_to_cpu16(catkey->keylen)
% 2));
@ -796,7 +796,7 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
callback function. */
node = grub_malloc (sizeof (*node));
node->data = dir->data;
grub_memcpy (node->extents, fileinfo->data.extents,
sizeof (node->extents));
node->mtime = grub_be_to_cpu32 (fileinfo->mtime) - 2082844800;
@ -839,9 +839,9 @@ grub_hfsplus_open (struct grub_file *file, const char *name)
{
struct grub_hfsplus_data *data;
struct grub_fshelp_node *fdiro = 0;
grub_dl_ref (my_mod);
data = grub_hfsplus_mount (file->device->disk);
if (!data)
goto fail;
@ -865,7 +865,7 @@ grub_hfsplus_open (struct grub_file *file, const char *name)
if (data && fdiro != &data->dirroot)
grub_free (fdiro);
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
@ -887,7 +887,7 @@ grub_hfsplus_close (grub_file_t file)
static grub_ssize_t
grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_hfsplus_data *data =
struct grub_hfsplus_data *data =
(struct grub_hfsplus_data *) file->data;
int size = grub_hfsplus_read_file (&data->opened_file, file->read_hook,
@ -898,13 +898,13 @@ grub_hfsplus_read (grub_file_t file, char *buf, grub_size_t len)
static grub_err_t
grub_hfsplus_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_hfsplus_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_hfsplus_data *data = 0;
struct grub_fshelp_node *fdiro = 0;
auto int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node);
@ -924,7 +924,7 @@ grub_hfsplus_dir (grub_device_t device, const char *path,
}
grub_dl_ref (my_mod);
data = grub_hfsplus_mount (device->disk);
if (!data)
goto fail;
@ -938,7 +938,7 @@ grub_hfsplus_dir (grub_device_t device, const char *path,
/* Iterate over all entries in this directory. */
grub_hfsplus_iterate_dir (fdiro, iterate);
fail:
if (data && fdiro != &data->dirroot)
grub_free (fdiro);
@ -961,7 +961,7 @@ grub_hfsplus_label (grub_device_t device __attribute__((unused))
}
/* Get mtime. */
static grub_err_t
static grub_err_t
grub_hfsplus_mtime (grub_device_t device, grub_int32_t *tm)
{
struct grub_hfsplus_data *data;
@ -972,7 +972,7 @@ grub_hfsplus_mtime (grub_device_t device, grub_int32_t *tm)
data = grub_hfsplus_mount (disk);
if (!data)
*tm = 0;
else
else
*tm = grub_be_to_cpu32 (data->volheader.utime) - 2082844800;
grub_dl_unref (my_mod);
@ -995,8 +995,8 @@ grub_hfsplus_uuid (grub_device_t device, char **uuid)
if (data)
{
*uuid = grub_malloc (16 + sizeof ('\0'));
grub_sprintf (*uuid, "%016llx",
(unsigned long long)
grub_sprintf (*uuid, "%016llx",
(unsigned long long)
grub_be_to_cpu64 (data->volheader.num_serial));
}
else

View File

@ -164,27 +164,27 @@ grub_iso9660_susp_iterate (struct grub_iso9660_data *data,
{
char *sua;
struct grub_iso9660_susp_entry *entry;
auto grub_err_t load_sua (void);
/* Load a part of the System Usage Area. */
grub_err_t load_sua (void)
{
sua = grub_malloc (sua_size);
if (!sua)
return grub_errno;
if (grub_disk_read (data->disk, sua_block, sua_pos,
sua_size, sua))
return grub_errno;
entry = (struct grub_iso9660_susp_entry *) sua;
return 0;
}
if (load_sua ())
return grub_errno;
for (; (char *) entry < (char *) sua + sua_size - 1;
entry = (struct grub_iso9660_susp_entry *)
((char *) entry + entry->len))
@ -192,29 +192,29 @@ grub_iso9660_susp_iterate (struct grub_iso9660_data *data,
/* The last entry. */
if (grub_strncmp ((char *) entry->sig, "ST", 2) == 0)
break;
/* Additional entries are stored elsewhere. */
if (grub_strncmp ((char *) entry->sig, "CE", 2) == 0)
{
struct grub_iso9660_susp_ce *ce;
ce = (struct grub_iso9660_susp_ce *) entry;
sua_size = grub_le_to_cpu32 (ce->len);
sua_pos = grub_le_to_cpu32 (ce->off);
sua_block = grub_le_to_cpu32 (ce->blk) << GRUB_ISO9660_LOG2_BLKSZ;
grub_free (sua);
if (load_sua ())
return grub_errno;
}
if (hook (entry))
{
grub_free (sua);
return 0;
}
}
grub_free (sua);
return 0;
}
@ -248,9 +248,9 @@ grub_iso9660_mount (grub_disk_t disk)
struct grub_iso9660_susp_entry *entry;
struct grub_iso9660_primary_voldesc voldesc;
int block;
auto grub_err_t susp_iterate (struct grub_iso9660_susp_entry *);
grub_err_t susp_iterate (struct grub_iso9660_susp_entry *susp_entry)
{
/* The "ER" entry is used to detect extensions. The
@ -262,11 +262,11 @@ grub_iso9660_mount (grub_disk_t disk)
}
return 0;
}
data = grub_malloc (sizeof (struct grub_iso9660_data));
if (! data)
return 0;
data->disk = disk;
data->rockridge = 0;
data->joliet = 0;
@ -319,7 +319,7 @@ grub_iso9660_mount (grub_disk_t disk)
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
goto fail;
}
sua_pos = (sizeof (rootdir) + rootdir.namelen
+ (rootdir.namelen % 2) - 1);
sua_size = rootdir.len - sua_pos;
@ -327,7 +327,7 @@ grub_iso9660_mount (grub_disk_t disk)
sua = grub_malloc (sua_size);
if (! sua)
goto fail;
if (grub_disk_read (disk, (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
<< GRUB_ISO9660_LOG2_BLKSZ), sua_pos,
sua_size, sua))
@ -335,9 +335,9 @@ grub_iso9660_mount (grub_disk_t disk)
grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem");
goto fail;
}
entry = (struct grub_iso9660_susp_entry *) sua;
/* Test if the SUSP protocol is used on this filesystem. */
if (grub_strncmp ((char *) entry->sig, "SP", 2) == 0)
{
@ -345,7 +345,7 @@ grub_iso9660_mount (grub_disk_t disk)
to get to the SUA (System Usage Area). */
data->susp_skip = entry->data[2];
entry = (struct grub_iso9660_susp_entry *) ((char *) entry + entry->len);
/* Iterate over the entries in the SUA area to detect
extensions. */
if (grub_iso9660_susp_iterate (data,
@ -354,9 +354,9 @@ grub_iso9660_mount (grub_disk_t disk)
sua_pos, sua_size, susp_iterate))
goto fail;
}
return data;
fail:
grub_free (data);
return 0;
@ -371,7 +371,7 @@ grub_iso9660_read_symlink (grub_fshelp_node_t node)
int sua_size;
char *symlink = 0;
int addslash = 0;
auto void add_part (const char *part, int len);
auto grub_err_t susp_iterate_sl (struct grub_iso9660_susp_entry *);
@ -379,14 +379,14 @@ grub_iso9660_read_symlink (grub_fshelp_node_t node)
void add_part (const char *part, int len)
{
int size = grub_strlen (symlink);
symlink = grub_realloc (symlink, size + len + 1);
if (! symlink)
return;
grub_strncat (symlink, part, len);
}
/* Read in a symlink. */
grub_err_t susp_iterate_sl (struct grub_iso9660_susp_entry *entry)
{
@ -402,7 +402,7 @@ grub_iso9660_read_symlink (grub_fshelp_node_t node)
add_part ("/", 1);
addslash = 0;
}
/* The current position is the `Component Flag'. */
switch (entry->data[pos] & 30)
{
@ -418,15 +418,15 @@ grub_iso9660_read_symlink (grub_fshelp_node_t node)
break;
}
case 2:
add_part ("./", 2);
break;
case 4:
add_part ("../", 3);
break;
case 8:
add_part ("/", 1);
break;
@ -435,29 +435,29 @@ grub_iso9660_read_symlink (grub_fshelp_node_t node)
stored. */
pos += entry->data[pos + 1] + 2;
}
/* Check if `grub_realloc' failed. */
if (grub_errno)
return grub_errno;
}
return 0;
}
if (grub_disk_read (node->data->disk, node->dir_blk, node->dir_off,
sizeof (dirent), (char *) &dirent))
return 0;
sua_off = (sizeof (dirent) + dirent.namelen + 1 - (dirent.namelen % 2)
+ node->data->susp_skip);
sua_size = dirent.len - sua_off;
symlink = grub_malloc (1);
if (!symlink)
return 0;
*symlink = '\0';
if (grub_iso9660_susp_iterate (node->data, node->dir_blk,
node->dir_off + sua_off,
sua_size, susp_iterate_sl))
@ -465,7 +465,7 @@ grub_iso9660_read_symlink (grub_fshelp_node_t node)
grub_free (symlink);
return 0;
}
return symlink;
}
@ -482,7 +482,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
char *filename;
int filename_alloc = 0;
enum grub_fshelp_filetype type;
auto grub_err_t susp_iterate_dir (struct grub_iso9660_susp_entry *);
grub_err_t susp_iterate_dir (struct grub_iso9660_susp_entry *entry)
@ -540,7 +540,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
type = GRUB_FSHELP_UNKNOWN;
}
}
return 0;
}
@ -552,14 +552,14 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
offset % GRUB_DISK_SECTOR_SIZE,
sizeof (dirent), (char *) &dirent))
return 0;
/* The end of the block, skip to the next one. */
if (!dirent.len)
{
offset = (offset / GRUB_ISO9660_BLKSZ + 1) * GRUB_ISO9660_BLKSZ;
continue;
}
{
char name[dirent.namelen + 1];
int nameoffset = offset + sizeof (dirent);
@ -567,9 +567,9 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
int sua_off = (sizeof (dirent) + dirent.namelen + 1
- (dirent.namelen % 2));;
int sua_size = dirent.len - sua_off;
sua_off += offset + dir->data->susp_skip;
filename = 0;
filename_alloc = 0;
type = GRUB_FSHELP_UNKNOWN;
@ -582,7 +582,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
sua_off % GRUB_DISK_SECTOR_SIZE,
sua_size, susp_iterate_dir))
return 0;
/* Read the name. */
if (grub_disk_read (dir->data->disk,
(dir->blk << GRUB_ISO9660_LOG2_BLKSZ)
@ -590,11 +590,11 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
nameoffset % GRUB_DISK_SECTOR_SIZE,
dirent.namelen, (char *) name))
return 0;
node = grub_malloc (sizeof (struct grub_fshelp_node));
if (!node)
return 0;
/* Setup a new node. */
node->data = dir->data;
node->size = grub_le_to_cpu32 (dirent.size);
@ -602,7 +602,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
node->dir_blk = ((dir->blk << GRUB_ISO9660_LOG2_BLKSZ)
+ offset / GRUB_DISK_SECTOR_SIZE);
node->dir_off = offset % GRUB_DISK_SECTOR_SIZE;
/* If the filetype was not stored using rockridge, use
whatever is stored in the iso9660 filesystem. */
if (type == GRUB_FSHELP_UNKNOWN)
@ -612,7 +612,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
else
type = GRUB_FSHELP_REG;
}
/* The filename was not stored in a rock ridge entry. Read it
from the iso9660 filesystem. */
if (!filename)
@ -621,7 +621,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
filename = grub_strrchr (name, ';');
if (filename)
*filename = '\0';
if (dirent.namelen == 1 && name[0] == 0)
filename = ".";
else if (dirent.namelen == 1 && name[0] == 1)
@ -629,7 +629,7 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
else
filename = name;
}
if (dir->data->joliet)
{
char *oldname;
@ -653,24 +653,24 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
if (filename_alloc)
grub_free (filename);
}
offset += dirent.len;
}
return 0;
}
static grub_err_t
grub_iso9660_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_iso9660_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_iso9660_data *data = 0;
struct grub_fshelp_node rootnode;
struct grub_fshelp_node *foundnode;
auto int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node);
@ -691,11 +691,11 @@ grub_iso9660_dir (grub_device_t device, const char *path,
data = grub_iso9660_mount (device->disk);
if (! data)
goto fail;
rootnode.data = data;
rootnode.blk = grub_le_to_cpu32 (data->voldesc.rootdir.first_sector);
rootnode.size = grub_le_to_cpu32 (data->voldesc.rootdir.size);
/* Use the fshelp function to traverse the path. */
if (grub_fshelp_find_file (path, &rootnode,
&foundnode,
@ -703,13 +703,13 @@ grub_iso9660_dir (grub_device_t device, const char *path,
grub_iso9660_read_symlink,
GRUB_FSHELP_DIR))
goto fail;
/* List the files in the directory. */
grub_iso9660_iterate_dir (foundnode, iterate);
if (foundnode != &rootnode)
grub_free (foundnode);
fail:
grub_free (data);
@ -726,17 +726,17 @@ grub_iso9660_open (struct grub_file *file, const char *name)
struct grub_iso9660_data *data;
struct grub_fshelp_node rootnode;
struct grub_fshelp_node *foundnode;
grub_dl_ref (my_mod);
data = grub_iso9660_mount (file->device->disk);
if (!data)
goto fail;
rootnode.data = data;
rootnode.blk = grub_le_to_cpu32 (data->voldesc.rootdir.first_sector);
rootnode.size = grub_le_to_cpu32 (data->voldesc.rootdir.size);
/* Use the fshelp function to traverse the path. */
if (grub_fshelp_find_file (name, &rootnode,
&foundnode,
@ -744,21 +744,21 @@ grub_iso9660_open (struct grub_file *file, const char *name)
grub_iso9660_read_symlink,
GRUB_FSHELP_REG))
goto fail;
data->first_sector = foundnode->blk;
data->length = foundnode->size;
file->data = data;
file->size = foundnode->size;
file->offset = 0;
return 0;
fail:
grub_dl_unref (my_mod);
grub_free (data);
return grub_errno;;
}
@ -766,17 +766,17 @@ grub_iso9660_open (struct grub_file *file, const char *name)
static grub_ssize_t
grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_iso9660_data *data =
struct grub_iso9660_data *data =
(struct grub_iso9660_data *) file->data;
/* XXX: The file is stored in as a single extent. */
data->disk->read_hook = file->read_hook;
data->disk->read_hook = file->read_hook;
grub_disk_read (data->disk,
data->first_sector << GRUB_ISO9660_LOG2_BLKSZ,
file->offset,
len, buf);
data->disk->read_hook = 0;
return len;
}
@ -785,9 +785,9 @@ static grub_err_t
grub_iso9660_close (grub_file_t file)
{
grub_free (file->data);
grub_dl_unref (my_mod);
return GRUB_ERR_NONE;
}
@ -797,7 +797,7 @@ grub_iso9660_label (grub_device_t device, char **label)
{
struct grub_iso9660_data *data;
data = grub_iso9660_mount (device->disk);
if (data)
{
if (data->joliet)
@ -837,11 +837,11 @@ grub_iso9660_uuid (grub_device_t device, char **uuid)
grub_error (GRUB_ERR_BAD_NUMBER, "No creation date in filesystem to generate UUID.");
*uuid = NULL;
}
else
else
{
*uuid = grub_malloc (sizeof ("YYYY-MM-DD-HH-mm-ss-hh"));
grub_sprintf (*uuid, "%c%c%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c",
data->voldesc.modified.year[0], data->voldesc.modified.year[1],
data->voldesc.modified.year[0], data->voldesc.modified.year[1],
data->voldesc.modified.year[2], data->voldesc.modified.year[3],
data->voldesc.modified.month[0], data->voldesc.modified.month[1],
data->voldesc.modified.day[0], data->voldesc.modified.day[1],

186
fs/jfs.c
View File

@ -43,14 +43,14 @@ struct grub_jfs_sblock
grub_uint8_t magic[4];
grub_uint32_t version;
grub_uint64_t ag_size;
/* The size of a filesystem block in bytes. XXX: currently only
4096 was tested. */
grub_uint32_t blksz;
grub_uint16_t log2_blksz;
grub_uint8_t unused[71];
grub_uint8_t volname[11];
grub_uint8_t volname[11];
};
struct grub_jfs_extent
@ -58,7 +58,7 @@ struct grub_jfs_extent
/* The length of the extent in filesystem blocks. */
grub_uint16_t length;
grub_uint8_t length2;
/* The physical offset of the first block on the disk. */
grub_uint8_t blk1;
grub_uint32_t blk2;
@ -76,10 +76,10 @@ struct grub_jfs_treehead
{
grub_uint64_t next;
grub_uint64_t prev;
grub_uint8_t flags;
grub_uint8_t flags;
grub_uint8_t unused;
grub_uint16_t count;
grub_uint16_t max;
grub_uint8_t unused2[10];
@ -94,7 +94,7 @@ struct grub_jfs_tree_extent
/* The offset is the key used to lookup an extent. */
grub_uint8_t offset1;
grub_uint32_t offset2;
struct grub_jfs_extent extent;
} __attribute__ ((packed));
@ -105,15 +105,15 @@ struct grub_jfs_tree_dir
this level. */
grub_uint64_t nextb;
grub_uint64_t prevb;
grub_uint8_t flags;
/* The amount of dirents in this node. */
grub_uint8_t count;
grub_uint8_t freecnt;
grub_uint8_t freelist;
grub_uint8_t maxslot;
/* The location of the sorted array of pointers to dirents. */
grub_uint8_t sindex;
grub_uint8_t unused[10];
@ -161,7 +161,7 @@ struct grub_jfs_inode
grub_uint32_t mode;
grub_uint8_t unused3[72];
grub_uint8_t unused4[96];
union
{
/* The tree describing the extents of the file. */
@ -177,7 +177,7 @@ struct grub_jfs_inode
{
grub_uint8_t unused[16];
grub_uint8_t flags;
/* Amount of dirents in this node. */
grub_uint8_t count;
grub_uint8_t freecnt;
@ -222,7 +222,7 @@ struct grub_jfs_diropen
char *sorted;
struct grub_jfs_leaf_dirent *leaf;
struct grub_jfs_leaf_next_dirent *next_leaf;
/* The filename and inode of the last read dirent. */
char name[255];
grub_uint32_t ino;
@ -241,19 +241,19 @@ grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode,
{
auto int getblk (struct grub_jfs_treehead *treehead,
struct grub_jfs_tree_extent *extents);
int getblk (struct grub_jfs_treehead *treehead,
struct grub_jfs_tree_extent *extents)
{
int found = -1;
int i;
for (i = 0; i < grub_le_to_cpu16 (treehead->count) - 2; i++)
{
if (treehead->flags & GRUB_JFS_TREE_LEAF)
{
/* Read the leafnode. */
if (grub_le_to_cpu32 (extents[i].offset2) <= blk
if (grub_le_to_cpu32 (extents[i].offset2) <= blk
&& ((grub_le_to_cpu16 (extents[i].extent.length))
+ (extents[i].extent.length2 << 8)
+ grub_le_to_cpu32 (extents[i].offset2)) > blk)
@ -264,7 +264,7 @@ grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode,
if (blk >= grub_le_to_cpu32 (extents[i].offset2))
found = i;
}
if (found != -1)
{
struct
@ -272,20 +272,20 @@ grub_jfs_blkno (struct grub_jfs_data *data, struct grub_jfs_inode *inode,
struct grub_jfs_treehead treehead;
struct grub_jfs_tree_extent extents[254];
} tree;
if (grub_disk_read (data->disk,
grub_le_to_cpu32 (extents[found].extent.blk2)
<< (grub_le_to_cpu16 (data->sblock.log2_blksz)
- GRUB_DISK_SECTOR_BITS), 0,
sizeof (tree), (char *) &tree))
return -1;
return getblk (&tree.treehead, &tree.extents[0]);
}
return -1;
}
return getblk (&inode->file.tree, &inode->file.extents[0]);
}
@ -311,12 +311,12 @@ grub_jfs_read_inode (struct grub_jfs_data *data, int ino,
- GRUB_DISK_SECTOR_BITS), 0,
sizeof (struct grub_jfs_iag), &iag))
return grub_errno;
inoblk = grub_le_to_cpu32 (iag.inodes[inoext].blk2);
inoblk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz)
- GRUB_DISK_SECTOR_BITS);
inoblk += inonum;
if (grub_disk_read (data->disk, inoblk, 0,
sizeof (struct grub_jfs_inode), inode))
return grub_errno;
@ -338,13 +338,13 @@ grub_jfs_mount (grub_disk_t disk)
if (grub_disk_read (disk, GRUB_JFS_SBLOCK, 0,
sizeof (struct grub_jfs_sblock), &data->sblock))
goto fail;
if (grub_strncmp ((char *) (data->sblock.magic), "JFS1", 4))
{
grub_error (GRUB_ERR_BAD_FS, "not a jfs filesystem");
goto fail;
}
data->disk = disk;
data->pos = 0;
data->linknest = 0;
@ -353,15 +353,15 @@ grub_jfs_mount (grub_disk_t disk)
if (grub_disk_read (data->disk, GRUB_JFS_FS1_INODE_BLK, 0,
sizeof (struct grub_jfs_inode), &data->fileset))
goto fail;
return data;
fail:
grub_free (data);
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a jfs filesystem");
return 0;
}
@ -372,20 +372,20 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode)
struct grub_jfs_internal_dirent *de;
struct grub_jfs_diropen *diro;
int blk;
de = (struct grub_jfs_internal_dirent *) inode->dir.dirents;
if (!((grub_le_to_cpu32 (inode->mode)
& GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_DIR))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
return 0;
}
diro = grub_malloc (sizeof (struct grub_jfs_diropen));
if (!diro)
return 0;
diro->index = 0;
diro->data = data;
diro->inode = inode;
@ -408,10 +408,10 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode)
grub_free (diro);
return 0;
}
blk = grub_le_to_cpu32 (de[inode->dir.header.sorted[0]].ex.blk2);
blk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz) - GRUB_DISK_SECTOR_BITS);
/* Read in the nodes until we are on the leaf node level. */
do
{
@ -436,7 +436,7 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode)
diro->next_leaf = diro->dirpage->next_dirent;
diro->sorted = &diro->dirpage->sorted[diro->dirpage->header.sindex * 32];
diro->count = diro->dirpage->header.count;
return diro;
}
@ -461,31 +461,31 @@ grub_jfs_getent (struct grub_jfs_diropen *diro)
int len;
int nextent;
grub_uint16_t filename[255];
auto void addstr (grub_uint16_t *uname, int ulen);
/* Add the unicode string to the utf16 filename buffer. */
void addstr (grub_uint16_t *name, int ulen)
{
while (ulen--)
filename[strpos++] = *(name++);
}
/* The last node, read in more. */
if (diro->index == diro->count)
{
unsigned int next;
/* If the inode contains the entry tree or if this was the last
node, there is nothing to read. */
if ((diro->inode->file.tree.flags & GRUB_JFS_TREE_LEAF)
|| !grub_le_to_cpu64 (diro->dirpage->header.nextb))
return GRUB_ERR_OUT_OF_RANGE;
next = grub_le_to_cpu64 (diro->dirpage->header.nextb);
next <<= (grub_le_to_cpu16 (diro->data->sblock.log2_blksz)
- GRUB_DISK_SECTOR_BITS);
if (grub_disk_read (diro->data->disk, next, 0,
grub_le_to_cpu32 (diro->data->sblock.blksz),
diro->dirpage->sorted))
@ -500,18 +500,18 @@ grub_jfs_getent (struct grub_jfs_diropen *diro)
leaf = &diro->leaf[(int) diro->sorted[diro->index]];
next_leaf = &diro->next_leaf[diro->index];
len = leaf->len;
if (!len)
{
diro->index++;
return grub_jfs_getent (diro);
}
addstr (leaf->namepart, len < 11 ? len : 11);
diro->ino = grub_le_to_cpu32 (leaf->inode);
len -= 11;
/* Move down to the leaf level. */
nextent = leaf->next;
if (leaf->next != 255)
@ -519,7 +519,7 @@ grub_jfs_getent (struct grub_jfs_diropen *diro)
{
next_leaf = &diro->next_leaf[nextent];
addstr (next_leaf->namepart, len < 15 ? len : 15 );
len -= 15;
nextent = next_leaf->next;
} while (next_leaf->next != 255 && len > 0);
@ -528,7 +528,7 @@ grub_jfs_getent (struct grub_jfs_diropen *diro)
/* Convert the temporary UTF16 filename to UTF8. */
*grub_utf16_to_utf8 ((grub_uint8_t *) (diro->name), filename, strpos) = '\0';
return 0;
}
@ -550,15 +550,15 @@ grub_jfs_read_file (struct grub_jfs_data *data,
blockcnt = ((len + pos + grub_le_to_cpu32 (data->sblock.blksz) - 1)
/ grub_le_to_cpu32 (data->sblock.blksz));
for (i = pos / grub_le_to_cpu32 (data->sblock.blksz); i < blockcnt; i++)
{
int blknr;
int blockoff = pos % grub_le_to_cpu32 (data->sblock.blksz);
int blockend = grub_le_to_cpu32 (data->sblock.blksz);
int skipfirst = 0;
blknr = grub_jfs_blkno (data, &data->currinode, i);
if (grub_errno)
return -1;
@ -567,31 +567,31 @@ grub_jfs_read_file (struct grub_jfs_data *data,
if (i == blockcnt - 1)
{
blockend = (len + pos) % grub_le_to_cpu32 (data->sblock.blksz);
if (!blockend)
blockend = grub_le_to_cpu32 (data->sblock.blksz);
}
/* First block. */
if (i == (pos / (int) grub_le_to_cpu32 (data->sblock.blksz)))
{
skipfirst = blockoff;
blockend -= skipfirst;
}
data->disk->read_hook = read_hook;
grub_disk_read (data->disk,
blknr << (grub_le_to_cpu16 (data->sblock.log2_blksz)
- GRUB_DISK_SECTOR_BITS),
skipfirst, blockend, buf);
data->disk->read_hook = 0;
if (grub_errno)
return -1;
buf += grub_le_to_cpu32 (data->sblock.blksz) - skipfirst;
}
return len;
}
@ -606,9 +606,9 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path)
char *next;
unsigned int pos = 0;
struct grub_jfs_diropen *diro;
grub_strncpy (fpath, path, grub_strlen (path) + 1);
if (grub_jfs_read_inode (data, GRUB_JFS_AGGR_INODE, &data->currinode))
return grub_errno;
@ -633,28 +633,28 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path)
diro = grub_jfs_opendir (data, &data->currinode);
if (!diro)
return grub_errno;
for (;;)
{
if (grub_strlen (name) == 0)
return GRUB_ERR_NONE;
if (grub_jfs_getent (diro) == GRUB_ERR_OUT_OF_RANGE)
break;
/* Check if the current direntry matches the current part of the
pathname. */
if (!grub_strcmp (name, diro->name))
{
int ino = diro->ino;
int dirino = grub_le_to_cpu32 (data->currinode.inode);
grub_jfs_closedir (diro);
diro = 0;
if (grub_jfs_read_inode (data, ino, &data->currinode))
break;
/* Check if this is a symlink. */
if ((grub_le_to_cpu32 (data->currinode.mode)
& GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_LNK)
@ -663,12 +663,12 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path)
if (grub_errno)
return grub_errno;
}
if (!next)
return 0;
pos = 0;
name = next;
next = grub_strchr (name, '/');
if (next)
@ -676,12 +676,12 @@ grub_jfs_find_file (struct grub_jfs_data *data, const char *path)
next[0] = '\0';
next++;
}
/* Open this directory for reading dirents. */
diro = grub_jfs_opendir (data, &data->currinode);
if (!diro)
return grub_errno;
continue;
}
}
@ -700,33 +700,33 @@ grub_jfs_lookup_symlink (struct grub_jfs_data *data, int ino)
if (++data->linknest > GRUB_JFS_MAX_SYMLNK_CNT)
return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of symlinks");
if (size <= 128)
grub_strncpy (symlink, (char *) (data->currinode.symlink.path), 128);
else if (grub_jfs_read_file (data, 0, 0, size, symlink) < 0)
return grub_errno;
symlink[size] = '\0';
/* The symlink is an absolute path, go back to the root inode. */
if (symlink[0] == '/')
ino = 2;
/* Now load in the old inode. */
if (grub_jfs_read_inode (data, ino, &data->currinode))
return grub_errno;
grub_jfs_find_file (data, symlink);
if (grub_errno)
grub_error (grub_errno, "Can not follow symlink `%s'.", symlink);
return grub_errno;
}
static grub_err_t
grub_jfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_jfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_jfs_data *data = 0;
@ -740,7 +740,7 @@ grub_jfs_dir (grub_device_t device, const char *path,
if (grub_jfs_find_file (data, path))
goto fail;
diro = grub_jfs_opendir (data, &data->currinode);
if (!diro)
goto fail;
@ -751,16 +751,16 @@ grub_jfs_dir (grub_device_t device, const char *path,
struct grub_jfs_inode inode;
struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
if (grub_jfs_read_inode (data, diro->ino, &inode))
goto fail;
info.dir = (grub_le_to_cpu32 (inode.mode)
& GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_DIR;
if (hook (diro->name, &info))
goto fail;
}
/* XXX: GRUB_ERR_OUT_OF_RANGE is used for the last dirent. */
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_errno = 0;
@ -786,11 +786,11 @@ grub_jfs_open (struct grub_file *file, const char *name)
data = grub_jfs_mount (file->device->disk);
if (!data)
goto fail;
grub_jfs_find_file (data, name);
if (grub_errno)
goto fail;
/* It is only possible for open regular files. */
if (! ((grub_le_to_cpu32 (data->currinode.mode)
& GRUB_JFS_FILETYPE_MASK) == GRUB_JFS_FILETYPE_REG))
@ -798,18 +798,18 @@ grub_jfs_open (struct grub_file *file, const char *name)
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a regular file");
goto fail;
}
file->data = data;
file->size = grub_le_to_cpu64 (data->currinode.size);
return 0;
fail:
grub_dl_unref (my_mod);
grub_free (data);
return grub_errno;;
}
@ -817,9 +817,9 @@ grub_jfs_open (struct grub_file *file, const char *name)
static grub_ssize_t
grub_jfs_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_jfs_data *data =
struct grub_jfs_data *data =
(struct grub_jfs_data *) file->data;
return grub_jfs_read_file (data, file->read_hook, file->offset, len, buf);
}
@ -828,9 +828,9 @@ static grub_err_t
grub_jfs_close (grub_file_t file)
{
grub_free (file->data);
grub_dl_unref (my_mod);
return GRUB_ERR_NONE;
}
@ -840,12 +840,12 @@ grub_jfs_label (grub_device_t device, char **label)
{
struct grub_jfs_data *data;
data = grub_jfs_mount (device->disk);
if (data)
*label = grub_strndup ((char *) (data->sblock.volname), 11);
else
*label = 0;
return grub_errno;
}

View File

@ -96,7 +96,7 @@ struct grub_minix2_inode
grub_uint32_t indir_zone;
grub_uint32_t double_indir_zone;
grub_uint32_t unused;
};
/* Information about a "mounted" minix filesystem. */
@ -147,11 +147,11 @@ grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
return grub_le_to_cpu32 (indir32);
}
}
/* Direct block. */
if (blk < 7)
return GRUB_MINIX_INODE_DIR_ZONES (data, blk);
/* Indirect block. */
blk -= 7;
if (blk < GRUB_MINIX_ZONESZ / GRUB_MINIX_INODE_BLKSZ (data))
@ -159,23 +159,23 @@ grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
indir = grub_get_indir (GRUB_MINIX_INODE_INDIR_ZONE (data), blk);
return indir;
}
/* Double indirect block. */
blk -= GRUB_MINIX_ZONESZ / GRUB_MINIX_INODE_BLKSZ (data);
if (blk < (GRUB_MINIX_ZONESZ / GRUB_MINIX_INODE_BLKSZ (data))
* (GRUB_MINIX_ZONESZ / GRUB_MINIX_INODE_BLKSZ (data)))
{
indir = grub_get_indir (GRUB_MINIX_INODE_DINDIR_ZONE (data),
indir = grub_get_indir (GRUB_MINIX_INODE_DINDIR_ZONE (data),
blk / GRUB_MINIX_ZONESZ);
indir = grub_get_indir (indir, blk % GRUB_MINIX_ZONESZ);
return indir;
}
/* This should never happen. */
grub_error (GRUB_ERR_OUT_OF_RANGE, "file bigger than maximum size");
return 0;
}
@ -197,46 +197,46 @@ grub_minix_read_file (struct grub_minix_data *data,
len = GRUB_MINIX_INODE_SIZE (data);
blockcnt = (len + pos + GRUB_MINIX_BSIZE - 1) / GRUB_MINIX_BSIZE;
for (i = pos / GRUB_MINIX_BSIZE; i < blockcnt; i++)
{
int blknr;
int blockoff = pos % GRUB_MINIX_BSIZE;
int blockend = GRUB_MINIX_BSIZE;
int skipfirst = 0;
blknr = grub_minix_get_file_block (data, i);
if (grub_errno)
return -1;
/* Last block. */
if (i == blockcnt - 1)
{
blockend = (len + pos) % GRUB_MINIX_BSIZE;
if (!blockend)
blockend = GRUB_MINIX_BSIZE;
}
/* First block. */
if (i == (pos / (int) GRUB_MINIX_BSIZE))
{
skipfirst = blockoff;
blockend -= skipfirst;
}
data->disk->read_hook = read_hook;
grub_disk_read (data->disk, blknr << GRUB_MINIX_LOG2_ZONESZ,
skipfirst, blockend, buf);
data->disk->read_hook = 0;
if (grub_errno)
return -1;
buf += GRUB_MINIX_BSIZE - skipfirst;
}
return len;
}
@ -254,33 +254,33 @@ grub_minix_read_inode (struct grub_minix_data *data, int ino)
/* The first inode in minix is inode 1. */
ino--;
block = ((2 + grub_le_to_cpu16 (sblock->inode_bmap_size)
+ grub_le_to_cpu16 (sblock->zone_bmap_size))
<< GRUB_MINIX_LOG2_BSIZE);
if (data->version == 1)
{
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
/ sizeof (struct grub_minix_inode))
* sizeof (struct grub_minix_inode));
grub_disk_read (data->disk, block, offs,
sizeof (struct grub_minix_inode), &data->inode);
}
else
{
block += ino / (GRUB_DISK_SECTOR_SIZE
block += ino / (GRUB_DISK_SECTOR_SIZE
/ sizeof (struct grub_minix2_inode));
int offs = (ino
int offs = (ino
% (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix2_inode))
* sizeof (struct grub_minix2_inode));
grub_disk_read (data->disk, block, offs,
sizeof (struct grub_minix2_inode),&data->inode2);
}
return GRUB_ERR_NONE;
}
@ -291,28 +291,28 @@ static grub_err_t
grub_minix_lookup_symlink (struct grub_minix_data *data, int ino)
{
char symlink[GRUB_MINIX_INODE_SIZE (data) + 1];
if (++data->linknest > GRUB_MINIX_MAX_SYMLNK_CNT)
return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of symlinks");
if (grub_minix_read_file (data, 0, 0,
GRUB_MINIX_INODE_SIZE (data), symlink) < 0)
return grub_errno;
symlink[GRUB_MINIX_INODE_SIZE (data)] = '\0';
/* The symlink is an absolute path, go back to the root inode. */
if (symlink[0] == '/')
ino = GRUB_MINIX_ROOT_INODE;
/* Now load in the old inode. */
if (grub_minix_read_inode (data, ino))
return grub_errno;
grub_minix_find_file (data, symlink);
if (grub_errno)
grub_error (grub_errno, "Can not follow symlink `%s'.", symlink);
return grub_errno;
}
@ -327,9 +327,9 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
char *next;
unsigned int pos = 0;
int dirino;
grub_strcpy (fpath, path);
/* Skip the first slash. */
if (name[0] == '/')
{
@ -345,15 +345,15 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
next[0] = '\0';
next++;
}
do
{
grub_uint16_t ino;
char filename[data->filename_size + 1];
if (grub_strlen (name) == 0)
return GRUB_ERR_NONE;
if (grub_minix_read_file (data, 0, pos, sizeof (ino),
(char *) &ino) < 0)
return grub_errno;
@ -362,28 +362,28 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
return grub_errno;
filename[data->filename_size] = '\0';
/* Check if the current direntry matches the current part of the
pathname. */
if (!grub_strcmp (name, filename))
{
dirino = data->ino;
grub_minix_read_inode (data, grub_le_to_cpu16 (ino));
/* Follow the symlink. */
if ((GRUB_MINIX_INODE_MODE (data)
if ((GRUB_MINIX_INODE_MODE (data)
& GRUB_MINIX_IFLNK) == GRUB_MINIX_IFLNK)
{
grub_minix_lookup_symlink (data, dirino);
if (grub_errno)
return grub_errno;
}
if (!next)
return 0;
pos = 0;
name = next;
next = grub_strchr (name, '/');
if (next)
@ -391,17 +391,17 @@ grub_minix_find_file (struct grub_minix_data *data, const char *path)
next[0] = '\0';
next++;
}
if ((GRUB_MINIX_INODE_MODE (data)
& GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
continue;
}
pos += sizeof (ino) + data->filename_size;
} while (pos < GRUB_MINIX_INODE_SIZE (data));
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
return grub_errno;
}
@ -412,11 +412,11 @@ static struct grub_minix_data *
grub_minix_mount (grub_disk_t disk)
{
struct grub_minix_data *data;
data = grub_malloc (sizeof (struct grub_minix_data));
if (!data)
return 0;
/* Read the superblock. */
grub_disk_read (disk, GRUB_MINIX_SBLOCK, 0,
sizeof (struct grub_minix_sblock),&data->sblock);
@ -458,34 +458,34 @@ grub_minix_mount (grub_disk_t disk)
}
static grub_err_t
grub_minix_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_minix_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_minix_data *data = 0;
struct grub_minix_sblock *sblock;
unsigned int pos = 0;
data = grub_minix_mount (device->disk);
if (!data)
return grub_errno;
grub_minix_read_inode (data, GRUB_MINIX_ROOT_INODE);
if (grub_errno)
goto fail;
sblock = &data->sblock;
grub_minix_find_file (data, path);
if (grub_errno)
goto fail;
if ((GRUB_MINIX_INODE_MODE (data) & GRUB_MINIX_IFDIR) != GRUB_MINIX_IFDIR)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
goto fail;
}
while (pos < GRUB_MINIX_INODE_SIZE (data))
{
grub_uint16_t ino;
@ -494,31 +494,31 @@ grub_minix_dir (grub_device_t device, const char *path,
struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
if (grub_minix_read_file (data, 0, pos, sizeof (ino),
(char *) &ino) < 0)
return grub_errno;
if (grub_minix_read_file (data, 0, pos + sizeof (ino),
data->filename_size,
(char *) filename) < 0)
return grub_errno;
filename[data->filename_size] = '\0';
/* The filetype is not stored in the dirent. Read the inode to
find out the filetype. This *REALLY* sucks. */
grub_minix_read_inode (data, grub_le_to_cpu16 (ino));
info.dir = ((GRUB_MINIX_INODE_MODE (data)
info.dir = ((GRUB_MINIX_INODE_MODE (data)
& GRUB_MINIX_IFDIR) == GRUB_MINIX_IFDIR);
if (hook (filename, &info) ? 1 : 0)
break;
/* Load the old inode back in. */
grub_minix_read_inode (data, dirino);
pos += sizeof (ino) + data->filename_size;
}
fail:
grub_free (data);
return grub_errno;
@ -541,13 +541,13 @@ grub_minix_open (struct grub_file *file, const char *name)
grub_free (data);
return grub_errno;
}
if (!name || name[0] != '/')
{
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename");
return grub_errno;
}
/* Traverse the directory tree to the node that should be
opened. */
grub_minix_find_file (data, name);
@ -556,10 +556,10 @@ grub_minix_open (struct grub_file *file, const char *name)
grub_free (data);
return grub_errno;
}
file->data = data;
file->size = GRUB_MINIX_INODE_SIZE (data);
return GRUB_ERR_NONE;
}
@ -567,9 +567,9 @@ grub_minix_open (struct grub_file *file, const char *name)
static grub_ssize_t
grub_minix_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_minix_data *data =
struct grub_minix_data *data =
(struct grub_minix_data *) file->data;
return grub_minix_read_file (data, file->read_hook, file->offset, len, buf);
}
@ -578,7 +578,7 @@ static grub_err_t
grub_minix_close (grub_file_t file)
{
grub_free (file->data);
return GRUB_ERR_NONE;
}

View File

@ -862,7 +862,7 @@ fail:
static grub_err_t
grub_ntfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_ntfs_data *data = 0;

View File

@ -319,7 +319,7 @@ grub_reiserfs_print_key (const struct grub_reiserfs_key *key)
"any ",
"unknown "
};
for (a = 0; a < sizeof (struct grub_reiserfs_key); a++)
grub_printf ("%02x ", ((unsigned int) ((unsigned char *) key)[a]) & 0xFF);
grub_printf ("parent id = 0x%08x, self id = 0x%08x, type = %s, offset = ",
@ -376,7 +376,7 @@ grub_reiserfs_set_key_type (struct grub_reiserfs_key *key,
int version)
{
grub_uint32_t type;
switch (grub_type)
{
case GRUB_REISERFS_STAT:
@ -397,14 +397,14 @@ grub_reiserfs_set_key_type (struct grub_reiserfs_key *key,
default:
return;
}
if (version == 1)
key->u.v1.type = grub_cpu_to_le32 (type);
else
key->u.v2.offset_type
= ((key->u.v2.offset_type & grub_cpu_to_le64 (~0ULL >> 4))
| grub_cpu_to_le64 ((grub_uint64_t) type << 60));
assert (grub_reiserfs_get_key_type (key) == grub_type);
}
@ -418,31 +418,31 @@ grub_reiserfs_compare_keys (const struct grub_reiserfs_key *key1,
grub_uint64_t offset1, offset2;
enum grub_reiserfs_item_type type1, type2;
grub_uint32_t id1, id2;
if (! key1 || ! key2)
return -2;
id1 = grub_le_to_cpu32 (key1->directory_id);
id2 = grub_le_to_cpu32 (key2->directory_id);
if (id1 < id2)
return -1;
if (id1 > id2)
return 1;
id1 = grub_le_to_cpu32 (key1->object_id);
id2 = grub_le_to_cpu32 (key2->object_id);
if (id1 < id2)
return -1;
if (id1 > id2)
return 1;
offset1 = grub_reiserfs_get_key_offset (key1);
offset2 = grub_reiserfs_get_key_offset (key2);
if (offset1 < offset2)
return -1;
if (offset1 > offset2)
return 1;
type1 = grub_reiserfs_get_key_type (key1);
type2 = grub_reiserfs_get_key_type (key2);
if ((type1 == GRUB_REISERFS_ANY
@ -456,7 +456,7 @@ grub_reiserfs_compare_keys (const struct grub_reiserfs_key *key1,
return -1;
if (type1 > type2)
return 1;
return 0;
}
@ -474,7 +474,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
grub_uint16_t i;
grub_uint16_t previous_level = ~0;
struct grub_reiserfs_item_header *item_headers = 0;
if (! data)
{
grub_error (GRUB_ERR_TEST_FAILURE, "data is NULL");
@ -492,7 +492,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
grub_error (GRUB_ERR_TEST_FAILURE, "item is NULL");
goto fail;
}
block_size = grub_le_to_cpu16 (data->superblock.block_size);
block_number = grub_le_to_cpu32 (data->superblock.root_block);
#ifdef GRUB_REISERFS_DEBUG
@ -502,7 +502,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
block_header = grub_malloc (block_size);
if (! block_header)
goto fail;
item->next_offset = 0;
do
{
@ -534,7 +534,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
struct grub_reiserfs_disk_child *children
= ((struct grub_reiserfs_disk_child *)
(keys + item_count));
for (i = 0;
i < item_count
&& grub_reiserfs_compare_keys (key, &(keys[i])) >= 0;
@ -620,7 +620,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
grub_reiserfs_print_key (block_key);
#endif
}
assert (grub_errno == GRUB_ERR_NONE);
grub_free (block_header);
return GRUB_ERR_NONE;
@ -740,7 +740,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
struct grub_fshelp_node directory_item;
grub_uint16_t entry_count, entry_number;
struct grub_reiserfs_item_header *item_headers;
grub_disk_read (data->disk,
block_number * (block_size >> GRUB_DISK_SECTOR_BITS),
(((grub_off_t) block_number * block_size)
@ -758,7 +758,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
goto fail;
}
#endif
item_headers = (struct grub_reiserfs_item_header *) (block_header + 1);
directory_headers
= ((struct grub_reiserfs_directory_header *)
@ -772,7 +772,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
= &directory_headers[entry_number];
grub_uint16_t entry_state
= grub_le_to_cpu16 (directory_header->state);
if (entry_state & GRUB_REISERFS_VISIBLE_MASK)
{
grub_fshelp_node_t entry_item;
@ -792,14 +792,14 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
entry_item = grub_malloc (sizeof (*entry_item));
if (! entry_item)
goto fail;
if (grub_reiserfs_get_item (data, &entry_key, entry_item)
!= GRUB_ERR_NONE)
{
grub_free (entry_item);
goto fail;
}
if (entry_item->type == GRUB_REISERFS_DIRECTORY)
entry_type = GRUB_FSHELP_DIR;
else
@ -945,7 +945,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
the current one. */
}
}
if (next_offset == 0)
break;
@ -1096,7 +1096,7 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
while (current_position < final_position)
{
grub_reiserfs_set_key_offset (&key, current_key_offset);
if (grub_reiserfs_get_item (data, &key, &found) != GRUB_ERR_NONE)
goto fail;
if (found.block_number == 0)
@ -1186,7 +1186,7 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
}
current_key_offset = current_position + 1;
}
grub_dprintf ("reiserfs",
"Have successfully read %lld bytes (%ld requested)\n",
(unsigned long long) (current_position - initial_position),
@ -1258,7 +1258,7 @@ grub_reiserfs_close (grub_file_t file)
/* Call HOOK with each file under DIR. */
static grub_err_t
grub_reiserfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_reiserfs_data *data = 0;

View File

@ -194,7 +194,7 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
/* We found a correct leaf. */
*size = grub_be_to_cpu16 (extent->size);
*nextext = grub_be_to_cpu32 (extent->next);
grub_free (treeblock);
return 0;
}
@ -370,7 +370,7 @@ grub_sfs_iterate_dir (grub_fshelp_node_t dir,
node->data = data;
node->size = size;
node->block = block;
return hook (name, type, node);
}
@ -451,18 +451,18 @@ grub_sfs_open (struct grub_file *file, const char *name)
{
struct grub_sfs_data *data;
struct grub_fshelp_node *fdiro = 0;
grub_dl_ref (my_mod);
data = grub_sfs_mount (file->device->disk);
if (!data)
goto fail;
grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_sfs_iterate_dir,
grub_sfs_read_symlink, GRUB_FSHELP_REG);
if (grub_errno)
goto fail;
file->size = fdiro->size;
data->diropen = *fdiro;
grub_free (fdiro);
@ -478,7 +478,7 @@ grub_sfs_open (struct grub_file *file, const char *name)
if (data)
grub_free (data->label);
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
@ -510,13 +510,13 @@ grub_sfs_read (grub_file_t file, char *buf, grub_size_t len)
static grub_err_t
grub_sfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_sfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_sfs_data *data = 0;
struct grub_fshelp_node *fdiro = 0;
auto int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node);
@ -533,7 +533,7 @@ grub_sfs_dir (grub_device_t device, const char *path,
}
grub_dl_ref (my_mod);
data = grub_sfs_mount (device->disk);
if (!data)
goto fail;
@ -544,7 +544,7 @@ grub_sfs_dir (grub_device_t device, const char *path,
goto fail;
grub_sfs_iterate_dir (fdiro, iterate);
fail:
if (data && fdiro != &data->diropen)
grub_free (fdiro);

View File

@ -766,7 +766,7 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
static grub_err_t
grub_udf_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_udf_data *data = 0;

154
fs/ufs.c
View File

@ -71,30 +71,30 @@ struct grub_ufs_sblock
grub_uint8_t unused[16];
/* The offset of the inodes in the cylinder group. */
grub_uint32_t inoblk_offs;
grub_uint8_t unused2[4];
/* The start of the cylinder group. */
grub_uint32_t cylg_offset;
grub_uint8_t unused3[4];
grub_uint32_t mtime;
grub_uint8_t unused4[12];
/* The size of a block in bytes. */
grub_int32_t bsize;
grub_uint8_t unused5[48];
/* The size of filesystem blocks to disk blocks. */
grub_uint32_t log2_blksz;
grub_uint8_t unused6[80];
/* Inodes stored per cylinder group. */
grub_uint32_t ino_per_group;
/* The frags per cylinder group. */
grub_uint32_t frags_per_group;
grub_uint8_t unused7[488];
/* Volume name for UFS2. */
@ -103,7 +103,7 @@ struct grub_ufs_sblock
grub_uint64_t mtime2;
grub_uint8_t unused9[420];
/* Magic value to check if this is really a UFS filesystem. */
grub_uint32_t magic;
};
@ -182,7 +182,7 @@ struct grub_ufs_dirent
struct
{
grub_uint8_t filetype_bsd;
grub_uint8_t namelen_bsd;
grub_uint8_t namelen_bsd;
};
};
} __attribute__ ((packed));
@ -219,16 +219,16 @@ grub_ufs_get_file_block (struct grub_ufs_data *data, unsigned int blk)
{
struct grub_ufs_sblock *sblock = &data->sblock;
unsigned int indirsz;
int log2_blksz;
int log2_blksz;
/* Direct. */
if (blk < GRUB_UFS_DIRBLKS)
return INODE_DIRBLOCKS (data, blk);
log2_blksz = grub_le_to_cpu32 (data->sblock.log2_blksz);
blk -= GRUB_UFS_DIRBLKS;
indirsz = UFS_BLKSZ (sblock) / INODE_BLKSZ (data);
/* Single indirect block. */
if (blk < indirsz)
@ -239,20 +239,20 @@ grub_ufs_get_file_block (struct grub_ufs_data *data, unsigned int blk)
return (data->ufs_type == UFS1) ? indir[blk] : indir[blk << 1];
}
blk -= indirsz;
/* Double indirect block. */
if (blk < indirsz * indirsz)
{
grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2];
grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1) << log2_blksz,
0, sizeof (indir), indir);
grub_disk_read (data->disk,
((data->ufs_type == UFS1) ?
indir[blk / indirsz] : indir [(blk / indirsz) << 1])
indir[blk / indirsz] : indir [(blk / indirsz) << 1])
<< log2_blksz,
0, sizeof (indir), indir);
return (data->ufs_type == UFS1) ?
indir[blk % indirsz] : indir[(blk % indirsz) << 1];
}
@ -281,35 +281,35 @@ grub_ufs_read_file (struct grub_ufs_data *data,
len = INODE_SIZE (data);
blockcnt = (len + pos + UFS_BLKSZ (sblock) - 1) / UFS_BLKSZ (sblock);
for (i = pos / UFS_BLKSZ (sblock); i < blockcnt; i++)
{
int blknr;
int blockoff = pos % UFS_BLKSZ (sblock);
int blockend = UFS_BLKSZ (sblock);
int skipfirst = 0;
blknr = grub_ufs_get_file_block (data, i);
if (grub_errno)
return -1;
/* Last block. */
if (i == blockcnt - 1)
{
blockend = (len + pos) % UFS_BLKSZ (sblock);
if (!blockend)
blockend = UFS_BLKSZ (sblock);
}
/* First block. */
if (i == (pos / (int) UFS_BLKSZ (sblock)))
{
skipfirst = blockoff;
blockend -= skipfirst;
}
/* XXX: If the block number is 0 this block is not stored on
disk but is zero filled instead. */
if (blknr)
@ -327,7 +327,7 @@ grub_ufs_read_file (struct grub_ufs_data *data,
buf += UFS_BLKSZ (sblock) - skipfirst;
}
return len;
}
@ -338,16 +338,16 @@ static grub_err_t
grub_ufs_read_inode (struct grub_ufs_data *data, int ino, char *inode)
{
struct grub_ufs_sblock *sblock = &data->sblock;
/* Determine the group the inode is in. */
int group = ino / grub_le_to_cpu32 (sblock->ino_per_group);
/* Determine the inode within the group. */
int grpino = ino % grub_le_to_cpu32 (sblock->ino_per_group);
/* The first block of the group. */
int grpblk = group * (grub_le_to_cpu32 (sblock->frags_per_group));
if (data->ufs_type == UFS1)
{
if (!inode)
@ -380,7 +380,7 @@ grub_ufs_read_inode (struct grub_ufs_data *data, int ino, char *inode)
sizeof (struct grub_ufs2_inode),
inode);
}
return grub_errno;
}
@ -391,16 +391,16 @@ static grub_err_t
grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
{
char symlink[INODE_SIZE (data)];
if (++data->linknest > GRUB_UFS_MAX_SYMLNK_CNT)
return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of symlinks");
if (INODE_NBLOCKS (data) == 0)
grub_strcpy (symlink, (char *) INODE (data, symlink));
else
{
grub_disk_read (data->disk,
(INODE_DIRBLOCKS (data, 0)
grub_disk_read (data->disk,
(INODE_DIRBLOCKS (data, 0)
<< grub_le_to_cpu32 (data->sblock.log2_blksz)),
0, INODE_SIZE (data), symlink);
symlink[INODE_SIZE (data)] = '\0';
@ -409,15 +409,15 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
/* The symlink is an absolute path, go back to the root inode. */
if (symlink[0] == '/')
ino = GRUB_UFS_INODE;
/* Now load in the old inode. */
if (grub_ufs_read_inode (data, ino, 0))
return grub_errno;
grub_ufs_find_file (data, symlink);
if (grub_errno)
grub_error (grub_errno, "Can not follow symlink `%s'.", symlink);
return grub_errno;
}
@ -432,9 +432,9 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
char *next;
unsigned int pos = 0;
int dirino;
grub_strcpy (fpath, path);
/* Skip the first slash. */
if (name[0] == '/')
{
@ -450,31 +450,31 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
next[0] = '\0';
next++;
}
do
{
struct grub_ufs_dirent dirent;
int namelen;
if (grub_strlen (name) == 0)
return GRUB_ERR_NONE;
if (grub_ufs_read_file (data, 0, pos, sizeof (dirent),
(char *) &dirent) < 0)
return grub_errno;
namelen = (data->ufs_type == UFS2)
? dirent.namelen_bsd : grub_le_to_cpu16 (dirent.namelen);
{
char filename[namelen + 1];
if (grub_ufs_read_file (data, 0, pos + sizeof (dirent),
namelen, filename) < 0)
return grub_errno;
filename[namelen] = '\0';
if (!grub_strcmp (name, filename))
{
dirino = data->ino;
@ -500,17 +500,17 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
next[0] = '\0';
next++;
}
if ((INODE_MODE(data) & GRUB_UFS_ATTR_TYPE) != GRUB_UFS_ATTR_DIR)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
continue;
}
}
pos += grub_le_to_cpu16 (dirent.direntlen);
} while (pos < INODE_SIZE (data));
grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
return grub_errno;
}
@ -522,11 +522,11 @@ grub_ufs_mount (grub_disk_t disk)
{
struct grub_ufs_data *data;
int *sblklist = sblocklist;
data = grub_malloc (sizeof (struct grub_ufs_data));
if (!data)
return 0;
/* Find a UFS1 or UFS2 sblock. */
data->ufs_type = UNKNOWN;
while (*sblklist != -1)
@ -535,7 +535,7 @@ grub_ufs_mount (grub_disk_t disk)
&data->sblock);
if (grub_errno)
goto fail;
if (grub_le_to_cpu32 (data->sblock.magic) == GRUB_UFS_MAGIC)
{
data->ufs_type = UFS1;
@ -560,17 +560,17 @@ grub_ufs_mount (grub_disk_t disk)
fail:
grub_free (data);
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a ufs filesystem");
return 0;
}
static grub_err_t
grub_ufs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_ufs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_ufs_data *data;
@ -580,50 +580,50 @@ grub_ufs_dir (grub_device_t device, const char *path,
data = grub_ufs_mount (device->disk);
if (!data)
return grub_errno;
grub_ufs_read_inode (data, GRUB_UFS_INODE, 0);
if (grub_errno)
return grub_errno;
sblock = &data->sblock;
if (!path || path[0] != '/')
{
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename");
return grub_errno;
}
grub_ufs_find_file (data, path);
if (grub_errno)
goto fail;
goto fail;
if ((INODE_MODE (data) & GRUB_UFS_ATTR_TYPE) != GRUB_UFS_ATTR_DIR)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
goto fail;
}
while (pos < INODE_SIZE (data))
{
struct grub_ufs_dirent dirent;
int namelen;
if (grub_ufs_read_file (data, 0, pos, sizeof (dirent),
(char *) &dirent) < 0)
break;
namelen = (data->ufs_type == UFS2)
? dirent.namelen_bsd : grub_le_to_cpu16 (dirent.namelen);
{
char filename[namelen + 1];
struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
if (grub_ufs_read_file (data, 0, pos + sizeof (dirent),
namelen, filename) < 0)
break;
filename[namelen] = '\0';
if (data->ufs_type == UFS1)
{
@ -647,7 +647,7 @@ grub_ufs_dir (grub_device_t device, const char *path,
if (hook (filename, &info))
break;
}
pos += grub_le_to_cpu16 (dirent.direntlen);
}
@ -666,27 +666,27 @@ grub_ufs_open (struct grub_file *file, const char *name)
data = grub_ufs_mount (file->device->disk);
if (!data)
return grub_errno;
grub_ufs_read_inode (data, 2, 0);
if (grub_errno)
{
grub_free (data);
return grub_errno;
}
if (!name || name[0] != '/')
{
grub_error (GRUB_ERR_BAD_FILENAME, "bad filename");
return grub_errno;
}
grub_ufs_find_file (data, name);
if (grub_errno)
{
grub_free (data);
return grub_errno;
}
file->data = data;
file->size = INODE_SIZE (data);
@ -697,9 +697,9 @@ grub_ufs_open (struct grub_file *file, const char *name)
static grub_ssize_t
grub_ufs_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_ufs_data *data =
struct grub_ufs_data *data =
(struct grub_ufs_data *) file->data;
return grub_ufs_read_file (data, file->read_hook, file->offset, len, buf);
}
@ -708,7 +708,7 @@ static grub_err_t
grub_ufs_close (grub_file_t file)
{
grub_free (file->data);
return GRUB_ERR_NONE;
}
@ -737,7 +737,7 @@ grub_ufs_label (grub_device_t device, char **label)
}
/* Get mtime. */
static grub_err_t
static grub_err_t
grub_ufs_mtime (grub_device_t device, grub_int32_t *tm)
{
struct grub_ufs_data *data = 0;

View File

@ -42,7 +42,7 @@ struct grub_xfs_sblock
grub_uint8_t unused2[8];
grub_uint64_t rootino;
grub_uint8_t unused3[20];
grub_uint32_t agsize;
grub_uint32_t agsize;
grub_uint8_t unused4[20];
grub_uint8_t label[12];
grub_uint8_t log2_bsize;
@ -395,7 +395,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
{
struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
auto int NESTED_FUNC_ATTR call_hook (grub_uint64_t ino, char *filename);
int NESTED_FUNC_ATTR call_hook (grub_uint64_t ino, char *filename)
{
struct grub_fshelp_node *fdiro;
@ -403,7 +403,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
fdiro = grub_malloc (sizeof (struct grub_fshelp_node));
if (!fdiro)
return 0;
/* The inode should be read, otherwise the filetype can
not be determined. */
fdiro->ino = ino;
@ -415,7 +415,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
grub_xfs_mode_to_filetype (fdiro->inode.mode),
fdiro);
}
switch (diro->inode.format)
{
case XFS_INODE_FORMAT_INO:
@ -453,7 +453,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
+ sizeof (struct grub_xfs_dir_entry)
+ de->len - 1);
char name[de->len + 1];
if (smallino)
{
ino = grub_be_to_cpu32 (*(grub_uint32_t *) inopos);
@ -467,7 +467,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
if (call_hook (ino, name))
return 1;
de = ((struct grub_xfs_dir_entry *)
de = ((struct grub_xfs_dir_entry *)
(((char *) de)+ sizeof (struct grub_xfs_dir_entry) + de->len
+ ((smallino ? sizeof (grub_uint32_t)
: sizeof (grub_uint64_t))) - 1));
@ -493,7 +493,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
/* Iterate over every block the directory has. */
for (blk = 0;
blk < (grub_be_to_cpu64 (dir->inode.size)
blk < (grub_be_to_cpu64 (dir->inode.size)
>> dirblk_log2);
blk++)
{
@ -585,7 +585,7 @@ grub_xfs_mount (grub_disk_t disk)
if (grub_disk_read (disk, 0, 0,
sizeof (struct grub_xfs_sblock), &data->sblock))
goto fail;
if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4))
{
grub_error (GRUB_ERR_BAD_FS, "not a xfs filesystem");
@ -606,24 +606,24 @@ grub_xfs_mount (grub_disk_t disk)
return data;
fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not an xfs filesystem");
grub_free (data);
return 0;
}
static grub_err_t
grub_xfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
grub_xfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info))
{
struct grub_xfs_data *data = 0;;
struct grub_fshelp_node *fdiro = 0;
auto int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node);
@ -640,18 +640,18 @@ grub_xfs_dir (grub_device_t device, const char *path,
}
grub_dl_ref (my_mod);
data = grub_xfs_mount (device->disk);
if (!data)
goto fail;
grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_xfs_iterate_dir,
grub_xfs_read_symlink, GRUB_FSHELP_DIR);
if (grub_errno)
goto fail;
grub_xfs_iterate_dir (fdiro, iterate);
fail:
if (fdiro != &data->diropen)
grub_free (fdiro);
@ -671,25 +671,25 @@ grub_xfs_open (struct grub_file *file, const char *name)
{
struct grub_xfs_data *data;
struct grub_fshelp_node *fdiro = 0;
grub_dl_ref (my_mod);
data = grub_xfs_mount (file->device->disk);
if (!data)
goto fail;
grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_xfs_iterate_dir,
grub_xfs_read_symlink, GRUB_FSHELP_REG);
if (grub_errno)
goto fail;
if (!fdiro->inode_read)
{
grub_xfs_read_inode (data, fdiro->ino, &fdiro->inode);
if (grub_errno)
goto fail;
}
grub_memcpy (data->inode,
&fdiro->inode,
sizeof (struct grub_xfs_inode));
@ -705,7 +705,7 @@ grub_xfs_open (struct grub_file *file, const char *name)
if (fdiro != &data->diropen)
grub_free (fdiro);
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
@ -715,7 +715,7 @@ grub_xfs_open (struct grub_file *file, const char *name)
static grub_ssize_t
grub_xfs_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_xfs_data *data =
struct grub_xfs_data *data =
(struct grub_xfs_data *) file->data;
return grub_xfs_read_file (&data->diropen, file->read_hook,

View File

@ -52,7 +52,7 @@ class Image
objs_str = objs.join(' ')
deps = objs.collect {|obj| obj.suffix('d')}
deps_str = deps.join(' ')
"CLEANFILES += #{@name} #{exe} #{objs_str}
MOSTLYCLEANFILES += #{deps_str}
@ -79,7 +79,7 @@ endif
flag = if /\.c$/ =~ src then 'CFLAGS' else 'ASFLAGS' end
extra_flags = if /\.S$/ =~ src then '-DASM_FILE=1' else '' end
dir = File.dirname(src)
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
-include #{dep}
@ -113,7 +113,7 @@ class PModule
undsym = 'und-' + @name.suffix('lst')
mod_name = File.basename(@name, '.mod')
symbolic_name = mod_name.sub(/\.[^\.]*$/, '')
"CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym}
ifneq ($(#{prefix}_EXPORTS),no)
CLEANFILES += #{defsym}
@ -304,7 +304,7 @@ class Script
end
src = sources[0]
if /\.in$/ !~ src
raise "unknown source file `#{src}'"
raise "unknown source file `#{src}'"
end
"CLEANFILES += #{@name}
@ -340,7 +340,7 @@ while l = gets
cont = (/\\$/ =~ l)
unless cont
str.gsub!(/\\\n/, ' ')
if /^([a-zA-Z0-9_]+)\s*\+?=\s*(.*?)\s*$/ =~ str
var, args = $1, $2
@ -357,7 +357,7 @@ while l = gets
pmodules += args.split(/\s+/).collect do |pmod|
PModule.new(prefix, pmod)
end
when 'UTILITIES'
utils += args.split(/\s+/).collect do |util|
Utility.new(prefix, util)
@ -387,10 +387,10 @@ while l = gets
end
end
end
end
end
end

View File

@ -40,7 +40,7 @@ FNR == 1 {
END {
if (error == 1)
exit 1;
for (mod in modtab) {
# Remove duplications.
split(modtab[mod], depmods, " ");

View File

@ -50,7 +50,7 @@ struct grub_acpi_table_header
grub_uint8_t oemtable[8];
grub_uint32_t oemrev;
grub_uint8_t creator_id[4];
grub_uint32_t creator_rev;
grub_uint32_t creator_rev;
} __attribute__ ((packed));
struct grub_acpi_fadt

View File

@ -65,8 +65,8 @@ static inline grub_err_t grub_autoefi_prepare (void)
# define SYSTEM_TABLE_SIZEOF GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF
# define SYSTEM_TABLE_VAR GRUB_EFIEMU_SYSTEM_TABLE_VAR
# define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR
# define SIZEOF_OF_UINTN GRUB_EFIEMU_SIZEOF_OF_UINTN
# define SYSTEM_TABLE GRUB_EFIEMU_SYSTEM_TABLE
# define SIZEOF_OF_UINTN GRUB_EFIEMU_SIZEOF_OF_UINTN
# define SYSTEM_TABLE GRUB_EFIEMU_SYSTEM_TABLE
# define grub_efi_allocate_pages(x,y) (x)
# define grub_efi_free_pages(x,y) GRUB_EFI_SUCCESS
# define EFI_PRESENT 1

View File

@ -41,7 +41,7 @@ grub_err_t grub_set_datetime (struct grub_datetime *datetime);
int grub_get_weekday (struct grub_datetime *datetime);
char *grub_get_weekday_name (struct grub_datetime *datetime);
void grub_unixtime2datetime (grub_int32_t nix,
void grub_unixtime2datetime (grub_int32_t nix,
struct grub_datetime *datetime);

View File

@ -56,7 +56,7 @@ struct grub_disk_dev
/* The device id used by the cache manager. */
unsigned long id;
/* Call HOOK with each device name, until HOOK returns non-zero. */
int (*iterate) (int (*hook) (const char *name));
@ -102,7 +102,7 @@ struct grub_disk
/* The id used by the disk cache manager. */
unsigned long id;
/* The partition information. This is machine-specific. */
struct grub_partition *partition;

View File

@ -662,38 +662,38 @@ typedef struct grub_efi_table_header grub_efi_table_header_t;
struct grub_efi_boot_services
{
grub_efi_table_header_t hdr;
grub_efi_tpl_t
(*raise_tpl) (grub_efi_tpl_t new_tpl);
void
(*restore_tpl) (grub_efi_tpl_t old_tpl);
grub_efi_status_t
(*allocate_pages) (grub_efi_allocate_type_t type,
grub_efi_memory_type_t memory_type,
grub_efi_uintn_t pages,
grub_efi_physical_address_t *memory);
grub_efi_status_t
(*free_pages) (grub_efi_physical_address_t memory,
grub_efi_uintn_t pages);
grub_efi_status_t
(*get_memory_map) (grub_efi_uintn_t *memory_map_size,
grub_efi_memory_descriptor_t *memory_map,
grub_efi_uintn_t *map_key,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version);
grub_efi_status_t
(*allocate_pool) (grub_efi_memory_type_t pool_type,
grub_efi_uintn_t size,
void **buffer);
grub_efi_status_t
(*free_pool) (void *buffer);
grub_efi_status_t
(*create_event) (grub_efi_uint32_t type,
grub_efi_tpl_t notify_tpl,
@ -706,7 +706,7 @@ struct grub_efi_boot_services
(*set_timer) (grub_efi_event_t event,
grub_efi_timer_delay_t type,
grub_efi_uint64_t trigger_time);
grub_efi_status_t
(*wait_for_event) (grub_efi_uintn_t num_events,
grub_efi_event_t *event,
@ -714,10 +714,10 @@ struct grub_efi_boot_services
grub_efi_status_t
(*signal_event) (grub_efi_event_t event);
grub_efi_status_t
(*close_event) (grub_efi_event_t event);
grub_efi_status_t
(*check_event) (grub_efi_event_t event);
@ -726,13 +726,13 @@ struct grub_efi_boot_services
grub_efi_guid_t *protocol,
grub_efi_interface_type_t interface_type,
void *interface);
grub_efi_status_t
(*reinstall_protocol_interface) (grub_efi_handle_t handle,
grub_efi_guid_t *protocol,
void *old_interface,
void *new_interface);
grub_efi_status_t
(*uninstall_protocol_interface) (grub_efi_handle_t handle,
grub_efi_guid_t *protocol,
@ -742,9 +742,9 @@ struct grub_efi_boot_services
(*handle_protocol) (grub_efi_handle_t handle,
grub_efi_guid_t *protocol,
void **interface);
void *reserved;
grub_efi_status_t
(*register_protocol_notify) (grub_efi_guid_t *protocol,
grub_efi_event_t event,
@ -874,7 +874,7 @@ struct grub_efi_runtime_services
{
grub_efi_table_header_t hdr;
grub_efi_status_t
grub_efi_status_t
(*get_time) (grub_efi_time_t *time,
grub_efi_time_capabilities_t *capabilities);
@ -944,11 +944,11 @@ struct grub_efi_simple_input_interface
grub_efi_status_t
(*reset) (struct grub_efi_simple_input_interface *this,
grub_efi_boolean_t extended_verification);
grub_efi_status_t
(*read_key_stroke) (struct grub_efi_simple_input_interface *this,
grub_efi_input_key_t *key);
grub_efi_event_t wait_for_key;
};
typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t;
@ -973,7 +973,7 @@ struct grub_efi_simple_text_output_interface
grub_efi_uintn_t *columns,
grub_efi_uintn_t *rows);
grub_efi_status_t
grub_efi_status_t
(*set_mode) (struct grub_efi_simple_text_output_interface *this,
grub_efi_uintn_t mode_number);
@ -992,7 +992,7 @@ struct grub_efi_simple_text_output_interface
grub_efi_status_t
(*enable_cursor) (struct grub_efi_simple_text_output_interface *this,
grub_efi_boolean_t visible);
grub_efi_simple_text_output_mode_t *mode;
};
typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t;

View File

@ -30,14 +30,14 @@
#define GRUB_MACHINE_MEMORY_NVS 4
#define GRUB_MACHINE_MEMORY_CODE 5
#define GRUB_MACHINE_MEMORY_MAX_TYPE 5
/* This one is special: it's used internally but is never reported
/* This one is special: it's used internally but is never reported
by firmware. */
#define GRUB_MACHINE_MEMORY_HOLE 6
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
int type, int handle);
grub_err_t grub_machine_mmap_unregister (int handle);

View File

@ -98,7 +98,7 @@ struct grub_pe32_optional_header
grub_uint32_t bss_size;
grub_uint32_t entry_addr;
grub_uint32_t code_base;
#if GRUB_TARGET_SIZEOF_VOID_P == 4
grub_uint32_t data_base;
grub_uint32_t image_base;
@ -139,7 +139,7 @@ struct grub_pe32_optional_header
grub_uint32_t loader_flags;
grub_uint32_t num_data_directories;
/* Data directories. */
struct grub_pe32_data_directory export_table;
struct grub_pe32_data_directory import_table;
@ -210,7 +210,7 @@ struct grub_pe32_header
{
/* This should be filled in with GRUB_PE32_MSDOS_STUB. */
grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE];
/* This is always PE\0\0. */
char signature[4];

View File

@ -155,10 +155,10 @@ grub_err_t grub_efiemu_loadcore_init32 (void *core, grub_size_t core_size,
grub_efiemu_segment_t *segments);
grub_err_t grub_efiemu_loadcore_init64 (void *core, grub_size_t core_size,
grub_efiemu_segment_t *segments);
grub_err_t grub_efiemu_loadcore_load32 (void *core,
grub_err_t grub_efiemu_loadcore_load32 (void *core,
grub_size_t core_size,
grub_efiemu_segment_t segments);
grub_err_t grub_efiemu_loadcore_load64 (void *core,
grub_err_t grub_efiemu_loadcore_load64 (void *core,
grub_size_t core_size,
grub_efiemu_segment_t segments);
grub_err_t grub_efiemu_loadcore_unload32 (void);
@ -189,14 +189,14 @@ struct grub_efiemu_configuration_table64
} __attribute__ ((packed));
typedef struct grub_efiemu_configuration_table32 grub_efiemu_configuration_table64_t;
grub_err_t grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid);
grub_err_t
grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
grub_err_t
grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
void * (*get_table) (void *data),
void (*unload) (void *data),
void (*unload) (void *data),
void *data);
/* Memory management functions */
int grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
int grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
grub_efi_memory_type_t type);
void *grub_efiemu_mm_obtain_request (int handle);
int grub_efiemu_get_memory_map (grub_efi_uintn_t *memory_map_size,
@ -218,8 +218,8 @@ int grub_efiemu_get_memory_map (grub_efi_uintn_t *memory_map_size,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version);
grub_err_t
grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
grub_uint64_t,
grub_efiemu_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
grub_uint64_t,
grub_uint32_t));
int grub_efiemu_sizeof_uintn_t (void);
int grub_efiemu_exit_boot_services (grub_efi_uintn_t map_key);
@ -242,30 +242,30 @@ struct grub_efiemu_prepare_hook
void (*unload) (void *data);
void *data;
};
grub_err_t grub_efiemu_prepare32 (struct grub_efiemu_prepare_hook
grub_err_t grub_efiemu_prepare32 (struct grub_efiemu_prepare_hook
*prepare_hooks,
struct grub_efiemu_configuration_table
struct grub_efiemu_configuration_table
*config_tables);
grub_err_t grub_efiemu_prepare64 (struct grub_efiemu_prepare_hook
grub_err_t grub_efiemu_prepare64 (struct grub_efiemu_prepare_hook
*prepare_hooks,
struct grub_efiemu_configuration_table
struct grub_efiemu_configuration_table
*config_tables);
grub_err_t grub_efiemu_unload (void);
grub_err_t grub_efiemu_prepare (void);
grub_err_t
grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
void (*unload) (void *data),
void (*unload) (void *data),
void *data);
/* symbols and pointers */
grub_err_t grub_efiemu_alloc_syms (void);
grub_err_t grub_efiemu_request_symbols (int num);
grub_err_t grub_efiemu_resolve_symbol (const char *name,
grub_err_t grub_efiemu_resolve_symbol (const char *name,
int *handle, grub_off_t *off);
grub_err_t grub_efiemu_register_symbol (const char *name,
grub_err_t grub_efiemu_register_symbol (const char *name,
int handle, grub_off_t off);
void grub_efiemu_free_syms (void);
grub_err_t grub_efiemu_write_value (void * addr, grub_uint32_t value,
grub_err_t grub_efiemu_write_value (void * addr, grub_uint32_t value,
int plus_handle,
int minus_handle, int ptv_needed, int size);
grub_err_t grub_efiemu_pnvram (void);

View File

@ -43,18 +43,18 @@ struct grub_fs
/* Call HOOK with each file under DIR. */
grub_err_t (*dir) (grub_device_t device, const char *path,
int (*hook) (const char *filename,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info));
/* Open a file named NAME and initialize FILE. */
grub_err_t (*open) (struct grub_file *file, const char *name);
/* Read LEN bytes data from FILE into BUF. */
grub_ssize_t (*read) (struct grub_file *file, char *buf, grub_size_t len);
/* Close the file FILE. */
grub_err_t (*close) (struct grub_file *file);
/* Return the label of the device DEVICE in LABEL. The label is
returned in a grub_malloc'ed buffer and should be freed by the
caller. */

View File

@ -47,7 +47,7 @@ struct grub_hfs_sblock
/* A pascal style string that holds the volumename. */
grub_uint8_t volname[28];
grub_uint8_t unused5[60];
grub_uint16_t embed_sig;
struct grub_hfs_extent embed_extent;

View File

@ -20,11 +20,11 @@
#define GRUB_ARCH_EFI_EMU_HEADER 1
grub_err_t
grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
struct grub_efiemu_elf_sym *elfsyms,
void *ehdr);
grub_err_t
grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
struct grub_efiemu_elf_sym *elfsyms,
void *ehdr);

View File

@ -83,7 +83,7 @@ struct grub_e820_mmap
/* For the Linux/i386 boot protocol version 2.03. */
struct linux_kernel_header
{
{
grub_uint8_t code1[0x0020];
grub_uint16_t cl_magic; /* Magic number 0xA33F */
grub_uint16_t cl_offset; /* The offset of command line */
@ -135,21 +135,21 @@ struct linux_kernel_params
grub_uint8_t video_cursor_y;
grub_uint16_t ext_mem; /* 2 */
grub_uint16_t video_page; /* 4 */
grub_uint8_t video_mode; /* 6 */
grub_uint8_t video_width; /* 7 */
grub_uint8_t padding1[0xa - 0x8];
grub_uint16_t video_ega_bx; /* a */
grub_uint8_t padding2[0xe - 0xc];
grub_uint8_t video_height; /* e */
grub_uint8_t have_vga; /* f */
grub_uint16_t font_size; /* 10 */
grub_uint16_t lfb_width; /* 12 */
grub_uint16_t lfb_height; /* 14 */
grub_uint16_t lfb_depth; /* 16 */
@ -183,16 +183,16 @@ struct linux_kernel_params
grub_uint16_t apm_flags; /* 4c */
grub_uint32_t apm_code_len; /* 4e */
grub_uint16_t apm_data_len; /* 52 */
grub_uint8_t padding4[0x60 - 0x54];
grub_uint32_t ist_signature; /* 60 */
grub_uint32_t ist_command; /* 64 */
grub_uint32_t ist_event; /* 68 */
grub_uint32_t ist_perf_level; /* 6c */
grub_uint8_t padding5[0x80 - 0x70];
grub_uint8_t hd0_drive_info[0x10]; /* 80 */
grub_uint8_t hd1_drive_info[0x10]; /* 90 */
grub_uint16_t rom_config_len; /* a0 */
@ -232,15 +232,15 @@ struct linux_kernel_params
grub_uint32_t efi_mmap_hi; /* 1dc */
} v0206;
};
grub_uint32_t alt_mem; /* 1e0 */
grub_uint8_t padding8[0x1e8 - 0x1e4];
grub_uint32_t mmap_size; /* 1e8 */
grub_uint8_t padding9[0x1f1 - 0x1ec];
grub_uint8_t setup_sects; /* The size of the setup in sectors */
grub_uint16_t root_flags; /* If the root is mounted readonly */
grub_uint16_t syssize; /* obsolete */

View File

@ -72,7 +72,7 @@ struct grub_biosdisk_drp
grub_uint8_t device_path[8];
grub_uint8_t reserved2;
grub_uint8_t checksum;
/* XXX: This is necessary, because the BIOS of Thinkpad X20
writes a garbage to the tail of drive parameters,
regardless of a size specified in a caller. */

View File

@ -90,7 +90,7 @@ struct grub_machine_mmap_entry
#define GRUB_MACHINE_MEMORY_ACPI 3
#define GRUB_MACHINE_MEMORY_NVS 4
#define GRUB_MACHINE_MEMORY_MAX_TYPE 4
/* This one is special: it's used internally but is never reported
/* This one is special: it's used internally but is never reported
by firmware. */
#define GRUB_MACHINE_MEMORY_HOLE 5
@ -107,19 +107,19 @@ grub_uint64_t grub_mmap_get_lower (void);
#define GRUB_MMAP_MALLOC_LOW 1
#ifdef GRUB_MACHINE_PCBIOS
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
int type, int handle);
grub_err_t grub_machine_mmap_unregister (int handle);
#else
static inline grub_err_t
grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
grub_uint64_t size __attribute__ ((unused)),
int type __attribute__ ((unused)),
static inline grub_err_t
grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
grub_uint64_t size __attribute__ ((unused)),
int type __attribute__ ((unused)),
int handle __attribute__ ((unused)))
{
return GRUB_ERR_NONE;
}
static inline grub_err_t
static inline grub_err_t
grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
{
return GRUB_ERR_NONE;

View File

@ -143,9 +143,9 @@ struct grub_vbe_mode_info_block
grub_uint8_t lin_rsvd_field_position;
grub_uint32_t max_pixel_clock;
/* Reserved field to make structure to be 256 bytes long, VESA BIOS
Extension 3.0 Specification says to reserve 189 bytes here but
that doesn't make structure to be 256 bytes. So additional one is
/* Reserved field to make structure to be 256 bytes long, VESA BIOS
Extension 3.0 Specification says to reserve 189 bytes here but
that doesn't make structure to be 256 bytes. So additional one is
added here. */
grub_uint8_t reserved4[189 + 1];
} __attribute__ ((packed));

View File

@ -41,7 +41,7 @@ grub_get_tsc (void)
"pop %%rbx\n"
#else
"pop %%ebx\n"
#endif
#endif
:::"%rax", "%rcx", "%rdx");
#else
__asm__ __volatile__ ("xorl %%eax, %%eax\n\t"

View File

@ -6,22 +6,22 @@ typedef grub_uint32_t grub_xnu_ptr_t;
struct grub_xnu_boot_params
{
grub_uint16_t verminor;
grub_uint16_t vermajor;
grub_uint16_t verminor;
grub_uint16_t vermajor;
/* Command line passed to xnu. */
grub_uint8_t cmdline[1024];
grub_uint8_t cmdline[1024];
/* Later are the same as EFI's get_memory_map (). */
grub_xnu_ptr_t efi_mmap;
grub_uint32_t efi_mmap_size;
grub_uint32_t efi_mem_desc_size;
grub_uint32_t efi_mem_desc_version;
grub_xnu_ptr_t efi_mmap;
grub_uint32_t efi_mmap_size;
grub_uint32_t efi_mem_desc_size;
grub_uint32_t efi_mem_desc_version;
/* Later are video parameters. */
grub_xnu_ptr_t lfb_base;
#define GRUB_XNU_VIDEO_SPLASH 1
#define GRUB_XNU_VIDEO_TEXT_IN_VIDEO 2
grub_uint32_t lfb_mode;
grub_uint32_t lfb_mode;
grub_uint32_t lfb_line_len;
grub_uint32_t lfb_width;
grub_uint32_t lfb_height;
@ -30,12 +30,12 @@ struct grub_xnu_boot_params
/* Pointer to device tree and its len. */
grub_xnu_ptr_t devtree;
grub_uint32_t devtreelen;
/* First used address by kernel or boot structures. */
grub_xnu_ptr_t heap_start;
/* Last used address by kernel or boot structures minus previous value. */
/* Last used address by kernel or boot structures minus previous value. */
grub_uint32_t heap_size;
/* First memory page containing runtime code or data. */
grub_uint32_t efi_runtime_first_page;
/* First memory page containing runtime code or data minus previous value. */

Some files were not shown because too many files have changed in this diff Show More