fix and improve tftp_read.
This commit is contained in:
parent
b9ff0c2f81
commit
ab6cc80541
2 changed files with 19 additions and 9 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2000-02-25 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
|
* 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 <okuji@gnu.org>
|
2000-02-24 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
* stage2/disk_io.c [!STAGE1_5] (print_fsys_type): Mask
|
* stage2/disk_io.c [!STAGE1_5] (print_fsys_type): Mask
|
||||||
|
|
|
@ -290,6 +290,7 @@ tftp_read (char *addr, int size)
|
||||||
if (filepos < saved_filepos)
|
if (filepos < saved_filepos)
|
||||||
{
|
{
|
||||||
/* Uggh.. FILEPOS has been moved backwards. So reopen the file. */
|
/* Uggh.. FILEPOS has been moved backwards. So reopen the file. */
|
||||||
|
buf_read = 0;
|
||||||
buf_fill (1);
|
buf_fill (1);
|
||||||
grub_memmove ((char *) &tp, (char *) &saved_tp, saved_len);
|
grub_memmove ((char *) &tp, (char *) &saved_tp, saved_len);
|
||||||
len = saved_len;
|
len = saved_len;
|
||||||
|
@ -331,18 +332,16 @@ tftp_read (char *addr, int size)
|
||||||
size -= amt;
|
size -= amt;
|
||||||
addr += amt;
|
addr += amt;
|
||||||
filepos += amt;
|
filepos += amt;
|
||||||
saved_filepos = filepos;
|
|
||||||
ret += amt;
|
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. */
|
grub_memmove (buf, buf + FSYS_BUFLEN / 2, FSYS_BUFLEN / 2);
|
||||||
saved_filepos += buf_read;
|
buf_read -= FSYS_BUFLEN / 2;
|
||||||
buf_read = 0;
|
saved_filepos += FSYS_BUFLEN / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the data. */
|
/* Read the data. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue