pmaports/modem/tqftpserv/0005-tqftpserv-don-t-print-End-of-Transfer-as-an-error.patch
Luca Weiss d7c64500ee
modem/tqftpserv: upgrade and add patches for rsize & seek option handling (MR 4747)
Makes modem work on fairphone-fp4 (sm6350/sm7225) and fairphone-fp5
(sc7280/qcm6490)

Patches are submitted upstream:
https://github.com/andersson/tqftpserv/pull/13
[ci:skip-build]: already built successfully in CI
2024-03-06 01:50:52 +01:00

40 lines
1.5 KiB
Diff

From 0ae406219bce1c93e63f6892efd2e34306131428 Mon Sep 17 00:00:00 2001
From: Luca Weiss <luca.weiss@fairphone.com>
Date: Fri, 19 Jan 2024 14:25:34 +0100
Subject: [PATCH 5/5] tqftpserv: don't print "End of Transfer" as an error
On newer modems, the firmware seems to use a stat-like operation
relatively often which end the transfer with error 9 "End of Transfer".
In practise we're getting a RRQ with the tsize option set, we'll query
the file size from the filesystem, respond with the updated tsize in
OACK, then the modem will send us OP_ERROR with code 9 "End of
Transfer".
Since that's expected in this operation, let's not make it look like an
error to not confuse users/developers trying to debug the modem.
---
tqftpserv.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tqftpserv.c b/tqftpserv.c
index 95b4824..4a1bd30 100644
--- a/tqftpserv.c
+++ b/tqftpserv.c
@@ -467,7 +467,12 @@ static int handle_reader(struct tftp_client *client)
opcode = buf[0] << 8 | buf[1];
if (opcode == OP_ERROR) {
buf[len] = '\0';
- printf("[TQFTP] Remote returned an error: %d - %s\n", buf[2] << 8 | buf[3], buf + 4);
+ int err = buf[2] << 8 | buf[3];
+ /* "End of Transfer" is not an error, used with stat(2)-like calls */
+ if (err == 9)
+ printf("[TQFTP] Remote returned END OF TRANSFER: %d - %s\n", err, buf + 4);
+ else
+ printf("[TQFTP] Remote returned an error: %d - %s\n", err, buf + 4);
return -1;
} else if (opcode != OP_ACK) {
printf("[TQFTP] Expected ACK, got %d\n", opcode);
--
2.44.0