diff --git a/ChangeLog b/ChangeLog index 175dbe68f..1b3faf81d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +1999-09-06 OKUJI Yoshinori + + * stage2/builtins.c (testload_func): Fix the typos: 0x2000000 -> + 0x200000 and 0x3000000 -> 0x300000. + +1999-09-06 OKUJI Yoshinori + + From Hisazumi Kenji : + * stage2/fsys_ffs.c (mapblock_offset): New variable. + (mapblock_bsize): Likewise. + (MAPBUF): New macro. + (MAPBUF_LEN): Likewise. + (ffs_mount): Set MAPBLOCK_OFFSET to -1. + (block_map): Added partial read support. + 1999-09-06 OKUJI Yoshinori * stage2/cmdline.c (find_command): If COMMAND is less than diff --git a/THANKS b/THANKS index 0ad69e5d6..05c979896 100644 --- a/THANKS +++ b/THANKS @@ -14,6 +14,7 @@ Dan J. Walters Edward Killips Eric Hanchrow Heiko Schroeder +Hisazumi Kenji Jochen Hoenicke Klaus Reichl Kunihiro Ishiguro diff --git a/stage2/builtins.c b/stage2/builtins.c index 5186e2c1a..f734d94e0 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -1244,8 +1244,8 @@ testload_func (char *arg, int flags) *((int *) RAW_ADDR (0x30000c))); for (i = 0; i < 0x10ac0; i++) - if (*((unsigned char *) RAW_ADDR (0x2000000 + i)) - != *((unsigned char *) RAW_ADDR (0x3000000 + i))) + if (*((unsigned char *) RAW_ADDR (0x200000 + i)) + != *((unsigned char *) RAW_ADDR (0x300000 + i))) break; grub_printf ("Max is 0x10ac0: i=0x%x, filepos=0x%x\n", i, filepos); diff --git a/stage2/fsys_ffs.c b/stage2/fsys_ffs.c index f56217b9d..af8842a01 100644 --- a/stage2/fsys_ffs.c +++ b/stage2/fsys_ffs.c @@ -67,11 +67,14 @@ /* used for filesystem map blocks */ static int mapblock; +static int mapblock_offset; +static int mapblock_bsize; /* pointer to superblock */ #define SUPERBLOCK ((struct fs *) ( FSYS_BUF + 8192 )) #define INODE ((struct icommon *) ( FSYS_BUF + 16384 )) #define MAPBUF ( FSYS_BUF + 24576 ) +#define MAPBUF_LEN 8192 int @@ -87,31 +90,54 @@ ffs_mount (void) retval = 0; mapblock = -1; - + mapblock_offset = -1; + return retval; } static int block_map (int file_block) { - int bnum; - + int bnum, offset, bsize; + if (file_block < NDADDR) return (INODE->i_db[file_block]); - - if ((bnum = fsbtodb (SUPERBLOCK, INODE->i_ib[0])) != mapblock) + + /* If the blockmap loaded does not include FILE_BLOCK, + load a new blockmap. */ + if ((bnum = fsbtodb (SUPERBLOCK, INODE->i_ib[0])) != mapblock + || (mapblock_offset <= bnum && bnum <= mapblock_offset + mapblock_bsize)) { - if (!devread (bnum, 0, SUPERBLOCK->fs_bsize, (char *)MAPBUF)) + if (MAPBUF_LEN < SUPERBLOCK->fs_bsize) + { + offset = ((file_block - NDADDR) % NINDIR (SUPERBLOCK)); + bsize = MAPBUF_LEN; + + if (offset + MAPBUF_LEN > SUPERBLOCK->fs_bsize) + offset = (SUPERBLOCK->fs_bsize - MAPBUF_LEN) / sizeof (int); + } + else + { + bsize = SUPERBLOCK->fs_bsize; + offset = 0; + } + + if (! devread (bnum, offset * sizeof (int), bsize, (char *) MAPBUF)) { mapblock = -1; + mapblock_bsize = -1; + mapblock_offset = -1; errnum = ERR_FSYS_CORRUPT; return -1; } - + mapblock = bnum; + mapblock_bsize = bsize; + mapblock_offset = offset; } - - return (((int *) MAPBUF)[(file_block - NDADDR) % NINDIR (SUPERBLOCK)]); + + return (((int *) MAPBUF)[((file_block - NDADDR) % NINDIR (SUPERBLOCK)) + - mapblock_offset]); } @@ -119,7 +145,7 @@ int ffs_read (char *buf, int len) { int logno, off, size, map, ret = 0; - + while (len && !errnum) { off = blkoff (SUPERBLOCK, filepos); @@ -169,13 +195,10 @@ loop: /* load current inode (defaults to the root inode) */ - if (!devread (fsbtodb (SUPERBLOCK, itod (SUPERBLOCK, ino)), - 0, SUPERBLOCK->fs_bsize, (char *) FSYS_BUF)) - return 0; /* XXX what return value? */ - - memmove ((void *) INODE, - (void *) &(((struct dinode *) FSYS_BUF)[ino % (SUPERBLOCK->fs_inopb)]), - sizeof (struct dinode)); + if (!devread (fsbtodb (SUPERBLOCK, itod (SUPERBLOCK, ino)), + ino % (SUPERBLOCK->fs_inopb) * sizeof (struct dinode), + sizeof (struct dinode), (char *) INODE)) + return 0; /* XXX what return value? */ /* if we have a real file (and we're not just printing possibilities), then this is where we want to exit */