Skip to content

Commit

Permalink
loader: tftp: Copy the first block into the cache
Browse files Browse the repository at this point in the history
tftp_open reads the first block so copy it in the cached data.
If we have more than one block (i.e. we called tftp_read before
tftp_preload) simply just reset the transfer.

Reported by:	mmel
Reviewed by:	mmel, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33697

(cherry picked from commit dfc9c1d)
  • Loading branch information
evadot committed Jan 13, 2022
1 parent 28d2b8b commit d37a33f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stand/libsa/tftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,13 @@ tftp_preload(struct open_file *f)
start = getsecs();
printf("Preloading %s ", tftpfile->path);
#endif
if (tftpfile->currblock == 1)
bcopy(tftpfile->tftp_hdr->th_data,
cache,
tftpfile->validsize);
else
tftpfile->currblock = 0;

while (tftpfile->islastblock == 0) {
twiddle(32);
rc = tftp_getnextblock(tftpfile);
Expand Down

0 comments on commit d37a33f

Please sign in to comment.