new function grub_seek, fix a bug in the doc.

This commit is contained in:
okuji 1999-12-30 06:32:02 +00:00
parent 2745c43fd4
commit 161b9f4dde
6 changed files with 39 additions and 20 deletions

View file

@ -1,3 +1,15 @@
1999-12-30 OKUJI Yoshinori <okuji@gnu.org>
* stage2/disk_io.c (grub_seek): New function.
* stage2/shared.h (grub_seek): Declared.
* stage2/boot.c (load_image): Use grub_seek instead of setting
FILEPOS to a new value directly.
* stage2/builtins.c (install_func): Likewise.
(testload_func): Likewise.
* docs/grub.texi: Use a single direntry command for all the
entries instead of one per entry.
1999-12-29 OKUJI Yoshinori <okuji@gnu.org> 1999-12-29 OKUJI Yoshinori <okuji@gnu.org>
* grub/asmstub.c (check_device) [__linux__]: Check if DEVICE is * grub/asmstub.c (check_device) [__linux__]: Check if DEVICE is

View file

@ -17,15 +17,7 @@
@dircategory Kernel @dircategory Kernel
@direntry @direntry
* GRUB: (grub). The GRand Unified Bootloader * GRUB: (grub). The GRand Unified Bootloader
@end direntry
@dircategory Kernel
@direntry
* grub-install: (grub)Invoking grub-install. Install GRUB on your drive * grub-install: (grub)Invoking grub-install. Install GRUB on your drive
@end direntry
@dircategory Kernel
@direntry
* mbchk: (grub)Invoking mbchk. Check for the format of a Multiboot kernel * mbchk: (grub)Invoking mbchk. Check for the format of a Multiboot kernel
@end direntry @end direntry

View file

@ -123,7 +123,7 @@ load_image (char *kernel, char *arg)
entry_addr = (entry_func) pu.mb->entry_addr; entry_addr = (entry_func) pu.mb->entry_addr;
cur_addr = pu.mb->load_addr; cur_addr = pu.mb->load_addr;
/* first offset into file */ /* first offset into file */
filepos = i - (pu.mb->header_addr - cur_addr); grub_seek (i - (pu.mb->header_addr - cur_addr));
text_len = pu.mb->load_end_addr - cur_addr; text_len = pu.mb->load_end_addr - cur_addr;
data_len = 0; data_len = 0;
bss_len = pu.mb->bss_end_addr - pu.mb->load_end_addr; bss_len = pu.mb->bss_end_addr - pu.mb->load_end_addr;
@ -177,7 +177,7 @@ load_image (char *kernel, char *arg)
} }
/* first offset into file */ /* first offset into file */
filepos = N_TXTOFF ((*(pu.aout))); grub_seek (N_TXTOFF (*(pu.aout)));
text_len = pu.aout->a_text; text_len = pu.aout->a_text;
data_len = pu.aout->a_data; data_len = pu.aout->a_data;
bss_len = pu.aout->a_bss; bss_len = pu.aout->a_bss;
@ -280,7 +280,7 @@ load_image (char *kernel, char *arg)
} }
/* offset into file */ /* offset into file */
filepos = data_len + SECTOR_SIZE; grub_seek (data_len + SECTOR_SIZE);
cur_addr = LINUX_STAGING_AREA + text_len; cur_addr = LINUX_STAGING_AREA + text_len;
if (grub_read ((char *) LINUX_STAGING_AREA, text_len) if (grub_read ((char *) LINUX_STAGING_AREA, text_len)
@ -433,7 +433,7 @@ load_image (char *kernel, char *arg)
if (phdr->p_type == PT_LOAD) if (phdr->p_type == PT_LOAD)
{ {
/* offset into file */ /* offset into file */
filepos = phdr->p_offset; grub_seek (phdr->p_offset);
filesiz = phdr->p_filesz; filesiz = phdr->p_filesz;
if (type == KERNEL_TYPE_FREEBSD) if (type == KERNEL_TYPE_FREEBSD)

View file

@ -1325,7 +1325,8 @@ install_func (char *arg, int flags)
installaddr += SECTOR_SIZE; installaddr += SECTOR_SIZE;
/* Read the whole of Stage2 except for the first sector. */ /* Read the whole of Stage2 except for the first sector. */
filepos = SECTOR_SIZE; grub_seek (SECTOR_SIZE);
disk_read_hook = disk_read_blocklist_func; disk_read_hook = disk_read_blocklist_func;
if (! grub_read (dummy, -1)) if (! grub_read (dummy, -1))
goto fail; goto fail;
@ -1408,7 +1409,7 @@ install_func (char *arg, int flags)
goto fail; goto fail;
/* Skip the first sector. */ /* Skip the first sector. */
filepos = SECTOR_SIZE; grub_seek (SECTOR_SIZE);
disk_read_hook = disk_read_savesect_func; disk_read_hook = disk_read_savesect_func;
if (grub_read ((char *) SCRATCHADDR, SECTOR_SIZE) != SECTOR_SIZE) if (grub_read ((char *) SCRATCHADDR, SECTOR_SIZE) != SECTOR_SIZE)
@ -2341,7 +2342,7 @@ setup_func (char *arg, int flags)
int len; int len;
/* Need to know the size of the Stage 1.5. */ /* Need to know the size of the Stage 1.5. */
filepos = 0; grub_seek (0);
len = grub_read (buffer, -1); len = grub_read (buffer, -1);
/* Construct the blocklist representation. */ /* Construct the blocklist representation. */
grub_sprintf (stage2, "%s1+%d", grub_sprintf (stage2, "%s1+%d",
@ -2440,7 +2441,7 @@ testload_func (char *arg, int flags)
/* First partial read. */ /* First partial read. */
grub_printf ("\nPartial read 1: "); grub_printf ("\nPartial read 1: ");
filepos = 0; grub_seek (0);
grub_read ((char *) RAW_ADDR (0x200000), 0x7); grub_read ((char *) RAW_ADDR (0x200000), 0x7);
grub_read ((char *) RAW_ADDR (0x200007), 0x100); grub_read ((char *) RAW_ADDR (0x200007), 0x100);
grub_read ((char *) RAW_ADDR (0x200107), 0x10); grub_read ((char *) RAW_ADDR (0x200107), 0x10);
@ -2451,7 +2452,7 @@ testload_func (char *arg, int flags)
/* Second partial read. */ /* Second partial read. */
grub_printf ("\nPartial read 2: "); grub_printf ("\nPartial read 2: ");
filepos = 0; grub_seek (0);
grub_read ((char *) RAW_ADDR (0x300000), 0x10000); grub_read ((char *) RAW_ADDR (0x300000), 0x10000);
grub_read ((char *) RAW_ADDR (0x310000), 0x10); grub_read ((char *) RAW_ADDR (0x310000), 0x10);
grub_read ((char *) RAW_ADDR (0x310010), 0x7); grub_read ((char *) RAW_ADDR (0x310010), 0x7);

View file

@ -1419,8 +1419,18 @@ grub_read (char *buf, int len)
return (*(fsys_table[fsys_type].read_func)) (buf, len); return (*(fsys_table[fsys_type].read_func)) (buf, len);
} }
#ifndef STAGE1_5 #ifndef STAGE1_5
/* Reposition a file offset. */
int
grub_seek (int offset)
{
if (offset > filemax || offset < 0)
return -1;
filepos = offset;
return offset;
}
int int
dir (char *dirname) dir (char *dirname)
{ {

View file

@ -659,7 +659,8 @@ typedef enum
KERNEL_TYPE_FREEBSD, /* FreeBSD. */ KERNEL_TYPE_FREEBSD, /* FreeBSD. */
KERNEL_TYPE_NETBSD, /* NetBSD. */ KERNEL_TYPE_NETBSD, /* NetBSD. */
KERNEL_TYPE_CHAINLOADER /* Chainloader. */ KERNEL_TYPE_CHAINLOADER /* Chainloader. */
} kernel_t; }
kernel_t;
extern kernel_t kernel_type; extern kernel_t kernel_type;
extern int grub_timeout; extern int grub_timeout;
@ -726,9 +727,12 @@ int set_partition_hidden_flag (int hidden);
int grub_open (char *filename); int grub_open (char *filename);
/* Read LEN bytes into BUF from the file that was opened with /* Read LEN bytes into BUF from the file that was opened with
GRUB_OPEN. If LEN is -1, read all the remaining data in the file */ GRUB_OPEN. If LEN is -1, read all the remaining data in the file. */
int grub_read (char *buf, int len); int grub_read (char *buf, int len);
/* Reposition a file offset. */
int grub_seek (int offset);
/* Close a file. */ /* Close a file. */
void grub_close (void); void grub_close (void);