From 1284773363034e3afaf6d55b983e5aeeff44d59c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 27 Jan 2009 15:47:00 +0000 Subject: [tftp] Temporary fix for conveying TFTP block size to callers pxe_tftp.c assumes that the first seek on its data-transfer interface represents the block size. Apart from being an ugly hack, this will also screw up file size calculation for files smaller than one block. The proper solution would be to extend the data-transfer interface to support the reporting of stat()-like data. This is not going to happen until the cost of adding interface methods is reduced (a fix I have planned since June 2008). In the meantime, abuse the xfer_window() method to return the block size, since it is not being used for anything else and is vaguely justifiable. Astonishingly, having returned the incorrect TFTP blocksize via PXENV_TFTP_OPEN for almost a year seems not to have affected any of the test cases run during that time; this bug was found only when someone tried running the heavily-patched version of pxegrub found in OpenSolaris. --- src/net/udp/tftp.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/net/udp/tftp.c') diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index b262b108..889362a1 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -986,11 +986,29 @@ static void tftp_xfer_close ( struct xfer_interface *xfer, int rc ) { tftp_done ( tftp, rc ); } +/** + * Check flow control window + * + * @v xfer Data transfer interface + * @ret len Length of window + */ +static size_t tftp_xfer_window ( struct xfer_interface *xfer ) { + struct tftp_request *tftp = + container_of ( xfer, struct tftp_request, xfer ); + + /* We abuse this data-xfer method to convey the blocksize to + * the caller. This really should be done using some kind of + * stat() method, but we don't yet have the facility to do + * that. + */ + return tftp->blksize; +} + /** TFTP data transfer interface operations */ static struct xfer_interface_operations tftp_xfer_operations = { .close = tftp_xfer_close, .vredirect = ignore_xfer_vredirect, - .window = unlimited_xfer_window, + .window = tftp_xfer_window, .alloc_iob = default_xfer_alloc_iob, .deliver_iob = xfer_deliver_as_raw, .deliver_raw = ignore_xfer_deliver_raw, -- cgit