diff --git a/ChangeLog b/ChangeLog index 83f63f935..b243ea10f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +1999-12-30 OKUJI Yoshinori + + * 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 * grub/asmstub.c (check_device) [__linux__]: Check if DEVICE is diff --git a/docs/grub.texi b/docs/grub.texi index b3765342e..8130f1260 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -17,15 +17,7 @@ @dircategory Kernel @direntry * GRUB: (grub). The GRand Unified Bootloader -@end direntry - -@dircategory Kernel -@direntry * 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 @end direntry diff --git a/stage2/boot.c b/stage2/boot.c index 01923d762..97147bf7e 100644 --- a/stage2/boot.c +++ b/stage2/boot.c @@ -123,7 +123,7 @@ load_image (char *kernel, char *arg) entry_addr = (entry_func) pu.mb->entry_addr; cur_addr = pu.mb->load_addr; /* 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; data_len = 0; 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 */ - filepos = N_TXTOFF ((*(pu.aout))); + grub_seek (N_TXTOFF (*(pu.aout))); text_len = pu.aout->a_text; data_len = pu.aout->a_data; bss_len = pu.aout->a_bss; @@ -280,7 +280,7 @@ load_image (char *kernel, char *arg) } /* offset into file */ - filepos = data_len + SECTOR_SIZE; + grub_seek (data_len + SECTOR_SIZE); cur_addr = 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) { /* offset into file */ - filepos = phdr->p_offset; + grub_seek (phdr->p_offset); filesiz = phdr->p_filesz; if (type == KERNEL_TYPE_FREEBSD) diff --git a/stage2/builtins.c b/stage2/builtins.c index f30c51f30..c90871e6c 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -1325,7 +1325,8 @@ install_func (char *arg, int flags) installaddr += SECTOR_SIZE; /* Read the whole of Stage2 except for the first sector. */ - filepos = SECTOR_SIZE; + grub_seek (SECTOR_SIZE); + disk_read_hook = disk_read_blocklist_func; if (! grub_read (dummy, -1)) goto fail; @@ -1408,7 +1409,7 @@ install_func (char *arg, int flags) goto fail; /* Skip the first sector. */ - filepos = SECTOR_SIZE; + grub_seek (SECTOR_SIZE); disk_read_hook = disk_read_savesect_func; if (grub_read ((char *) SCRATCHADDR, SECTOR_SIZE) != SECTOR_SIZE) @@ -2341,7 +2342,7 @@ setup_func (char *arg, int flags) int len; /* Need to know the size of the Stage 1.5. */ - filepos = 0; + grub_seek (0); len = grub_read (buffer, -1); /* Construct the blocklist representation. */ grub_sprintf (stage2, "%s1+%d", @@ -2440,7 +2441,7 @@ testload_func (char *arg, int flags) /* First partial read. */ grub_printf ("\nPartial read 1: "); - filepos = 0; + grub_seek (0); grub_read ((char *) RAW_ADDR (0x200000), 0x7); grub_read ((char *) RAW_ADDR (0x200007), 0x100); grub_read ((char *) RAW_ADDR (0x200107), 0x10); @@ -2451,7 +2452,7 @@ testload_func (char *arg, int flags) /* Second partial read. */ grub_printf ("\nPartial read 2: "); - filepos = 0; + grub_seek (0); grub_read ((char *) RAW_ADDR (0x300000), 0x10000); grub_read ((char *) RAW_ADDR (0x310000), 0x10); grub_read ((char *) RAW_ADDR (0x310010), 0x7); diff --git a/stage2/disk_io.c b/stage2/disk_io.c index f7e91ceb6..4b0441954 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -1419,8 +1419,18 @@ grub_read (char *buf, int len) return (*(fsys_table[fsys_type].read_func)) (buf, len); } - #ifndef STAGE1_5 +/* Reposition a file offset. */ +int +grub_seek (int offset) +{ + if (offset > filemax || offset < 0) + return -1; + + filepos = offset; + return offset; +} + int dir (char *dirname) { diff --git a/stage2/shared.h b/stage2/shared.h index 7070d0b1b..91ac2a8f6 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -659,7 +659,8 @@ typedef enum KERNEL_TYPE_FREEBSD, /* FreeBSD. */ KERNEL_TYPE_NETBSD, /* NetBSD. */ KERNEL_TYPE_CHAINLOADER /* Chainloader. */ -} kernel_t; +} +kernel_t; extern kernel_t kernel_type; extern int grub_timeout; @@ -726,9 +727,12 @@ int set_partition_hidden_flag (int hidden); int grub_open (char *filename); /* 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); +/* Reposition a file offset. */ +int grub_seek (int offset); + /* Close a file. */ void grub_close (void);