Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Jan 2022 09:49:10 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: d37a33f52c36 - stable/13 - loader: tftp: Copy the first block into the cache
Message-ID:  <202201130949.20D9nAC6096027@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=d37a33f52c369f071d036d3cf8940215f682c636

commit d37a33f52c369f071d036d3cf8940215f682c636
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-12-30 08:47:06 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-01-13 07:59:03 +0000

    loader: tftp: Copy the first block into the cache
    
    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 dfc9c1d4937d0e2eab2910665069faba814bca1e)
---
 stand/libsa/tftp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/stand/libsa/tftp.c b/stand/libsa/tftp.c
index f91974fbff5d..d3f3048e0257 100644
--- a/stand/libsa/tftp.c
+++ b/stand/libsa/tftp.c
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201130949.20D9nAC6096027>