QRTR is built in to the kernel now, the other packages (such as rmtfs) have since removed qrtr-ns as a service dependency
Signed-off-by: Nicola Guerrera <guerrera.nicola@gmail.com>
Currently we pre-allocate around 128K of zstd state ahead of time,
keeping if for the whole daemon lifetime... Even if we don't need to
decompress any files. As mentioned by Dmitry:
Granted that tqftpserv handles only few files during the whole
lifetime and most of devices don't have swap, I think it's fine to
use non-context versions of the functions. Let's free the memory for
other software.
Swap ZSTD_decompressDCtx() for ZSTD_decompress() which will allocate and
free the state when needed.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
We need this to load compressed files from linux-firmware.
Closes https://github.com/linux-msm/tqftpserv/issues/19
Signed-off-by: Stefan Hansson <newbyte@postmarketos.org>
Tested-by: Nikita Travkin <nikita@trvn.ru>
Some distros still don't use SystemD (yet), make it optional.
It is not required to build the binary, just to install systemd
unit file.
Signed-off-by: Alexey Minnekhanov <alexey.min@gmail.com>
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.
The rsize (number of bytes the client wants to receive) and offset (the
offset in bytes from the start of file) are used on newer modems (such
as SM7225 or QCM6490), so let's support them properly.
Some examples to illustrate the usage:
* rsize=160 seek=52: we should send 160 bytes starting at byte 52 in the
requested file. With blksize=7680 this is a single 160(+4) sized
packet.
* rsize=313028 seek=81920: we should send in total 313028 bytes,
starting at byte 81920. With blksize=7680 and wsize=10 this spans
multiple windows of 10 packets each, that example would be packed into
41 packets with an ACK between every 10 windows - and a final ACK at
the end.
* rsize=53760 blksize=7680: We send 7 packets of 7680 bytes each, then
we send 1 packet with 0 bytes of data (only 4 bytes header) and then
get an ACK on packet 8.
If the client requests a file that's completely empty, it makes sense to
send a response to that request with - well - 0 bytes of data and just
the 4-byte header.
But also if the client requests for example a file of rsize=53760 and
blksize=7680, then will send 7 full packets of data in the window, but
afterwards we still need to send an empty packet (just the 4 bytes of
header) to make sure the client understands that we've sent all the
requested data. Otherwise it's going to time out and re-request the
blocks and we're stuck in a loop.
So consider pread return value of 0 to not be an error and send a
response packet back.
The dirname() function can and will modify the parameter, so if we call
dirname() twice on the same firmware_value parameter we will get
separate results messing up our names.
Copy the firmware_value value before passing it to dirname(). Also let's
just do this operation once to save copy-pasting some code.
Fixes: a4c755d ("Use firmware path from sysfs")
Some linux distributions adjust path fro kernel to load
firmware from using /sys/module/firmware_class/parameters/path.
Kernel supports it, teach tqftpserv to respect it too.
Signed-off-by: Alexey Minnekhanov <alexeymin@postmarketos.org>
After calling fdopendir "the file descriptor is under the control of the
system" and calling closedir(class_dir) already closes class_fd, so
let's not try to close it again.
Just close class_fd when fdopendir fails and remove the close call from
the regular exit path.
Null terminate firmware_value string to prevent
strlen() read past the end of buffer.
Change-Id: I57cd01c4d0c58c6057872bc4b36129f09bc034a3
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
On AOSP, /tmp is not available. Use /data/vendor instead
for temporary files.
Change-Id: I1d6ebd669573b3c3134e6da943ea9355ed83a3fe
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
The tftp clients in the modem requests files from either /readwrite or
/readonly/firmware/image, but as the wlanmdsp.mbn file requested is
signed with a vendor specific key these paths needs to be translated.
/readwrite is translated to /tmp/tqftpserv for now and the
/readonly/firmware/image is translated to a search for the requested
file alongside any of the remoteproc firmware files. The result is that
the wlanmdsp.mbn can be stored in linux-firmware alongside it's
device/vendor specific modem firmware.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Some mechanism for toggling the verbosity of the prints should be
introduced, but for now just comment out all the debug prints.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
When during a read we close the socket as we send the last block the
remote will be notified about the closure and consider the transfer
incomplete. Leave the socket open until we receive a EOF error from the
remote side.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The two include files was dropped during development but lingered in my
repository, remove the include of them - and define MAX(x, y).
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Introduce a prototype of the tqftpserv, a server implementing trivial
file transfer protocol over AF_QIPCRTR.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>