diff --git a/ChangeLog b/ChangeLog index b8321c54d..a4194b20d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-02-25 OKUJI Yoshinori + + * netboot/fsys_tftp.c (tftp_read): Set BUF_READ to zero if + FILEPOS is less than SAVED_FILEPOS, before calling buf_fill. + Don't discard all of the copied data so that we can move FILEPOS + backwards cheaply. Now SAVED_FILEPOS indicates the file position + corresponding to the first byte of BUF. If (FILEPOS - + SAVED_FILEPOS) is greater than (FSYS_BUFLEN / 2), move the data + forwards and add (FSYS_BUFLEN / 2) into SAVED_FILEPOS and + subtract the same value from BUF_READ. + 2000-02-24 OKUJI Yoshinori * stage2/disk_io.c [!STAGE1_5] (print_fsys_type): Mask diff --git a/netboot/fsys_tftp.c b/netboot/fsys_tftp.c index a3748e67b..3a7bb57e9 100644 --- a/netboot/fsys_tftp.c +++ b/netboot/fsys_tftp.c @@ -290,6 +290,7 @@ tftp_read (char *addr, int size) if (filepos < saved_filepos) { /* Uggh.. FILEPOS has been moved backwards. So reopen the file. */ + buf_read = 0; buf_fill (1); grub_memmove ((char *) &tp, (char *) &saved_tp, saved_len); len = saved_len; @@ -331,18 +332,16 @@ tftp_read (char *addr, int size) size -= amt; addr += amt; filepos += amt; - saved_filepos = filepos; ret += amt; - - /* Move the unused data forwards. */ - grub_memmove (buf, buf + amt, buf_read - amt); - buf_read -= amt; } - else + + /* If the size of the empty space becomes small, move the unused + data forwards. */ + if (filepos - saved_filepos > FSYS_BUFLEN / 2) { - /* Reset the reading offset. */ - saved_filepos += buf_read; - buf_read = 0; + grub_memmove (buf, buf + FSYS_BUFLEN / 2, FSYS_BUFLEN / 2); + buf_read -= FSYS_BUFLEN / 2; + saved_filepos += FSYS_BUFLEN / 2; } /* Read the data. */