summaryrefslogtreecommitdiffstats
path: root/fs/tftp.c
Commit message (Collapse)AuthorAgeFilesLines
* fs: tftp: Use pr_debug for errorsSascha Hauer2018-09-101-1/+1
| | | | | | | This has been debug output before for good reasons. The users will usually print the error messages when they want to. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: improve file size handlingSascha Hauer2018-08-301-2/+8
| | | | | | | | Previously we used FILE_SIZE_STREAM unconditionally. Instead, fill the inode size with a valid filesize if we have one and only if not fall back to FILE_SIZE_STREAM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: hide files which are actually not present on the serverSascha Hauer2018-08-301-8/+25
| | | | | | | | | | In tftp_lookup we claimed that every desired file is there. This leads to problems when a user only tests if a file is present and makes decisions upon this information. Rather than claiming that all files are present do a tftp_do_open() on the files and see if it is really there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: fix return valueSascha Hauer2018-08-301-1/+1
| | | | | | | | When tftp_get_inode() fails it is a sign for a out of memory situtation rather than an indicator for no space left on the filesystem, so return -ENOMEM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: fix memory holeSascha Hauer2018-08-301-10/+7
| | | | | | | dpath() returns a pointer to an allocated string, so we have to free it. Put the pointer into our file private data and free it on close time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: overhaul debuggingSascha Hauer2018-08-301-10/+25
| | | | | | | | | - use pr_* instead of debug() - use pr_vdebug for the less interesting messages - use pr_err for error messages - print state as clear text and not as number Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: Switch to dentry cache implementationSascha Hauer2018-07-131-42/+55
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* tftp: implement forward seekingUwe Kleine-König2017-03-031-1/+26
| | | | | | | Just abuse tftp_read to step forward. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* tftp: trivial code simplificationUwe Kleine-König2017-03-031-6/+4
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs/tftp.c: drop unused server_port variableAntony Pavlov2015-07-201-3/+0
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* tftp_recv(): handle opcode field in a more natural wayAntony Pavlov2015-06-291-8/+7
| | | | | | | | | | | | RFC1350 uses the 'opcode' term for the first 2-bytes field of TFTP packet. But the U-boot tftp code uses the 'proto' term for the same thing. The patch takes back original term and makes opcode calculation more clear. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* tftp_recv(): according to RFC1350 minimal tftp packet length is 4 bytesAntony Pavlov2015-06-291-3/+2
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs/tftp: handle incoming packets in the separate tftp_recv() functionAntony Pavlov2015-06-291-10/+17
| | | | | | | | The separation of incoming packets handling makes it much easier to run barebox tftp client on top of picotcp network stack in the future. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: rename inode member of struct filep to privSascha Hauer2015-03-091-4/+4
| | | | | | | Because that's what it is. 'inode' will become confusing once we support real inodes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sizes.h: move include/sizes.h to include/linux/sizes.hMasahiro Yamada2015-01-081-1/+1
| | | | | | | | | | | | | | This file originates in Linux. Linux has it under include/linux/ directory since commit dccd2304cc90. Let's move it to the same place as well in barebox. This commit was generated by the following commands: find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:' git mv include/sizes.h include/linux/ Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* tftp: add timeframe when remote server is retransmittingChristoph Fritz2014-05-051-3/+5
| | | | | | | | | | | | | If there's packet loss and the remote server needs to retransmit, there is falsely no timeframe left because TIMEOUT (server wait time) and TFTP_TIMEOUT (abort timer) are the same. This patch increases TFTP_TIMEOUT. See RFC2349 for more info: http://tools.ietf.org/html/rfc2349 Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: Fix writing files to tftpSascha Hauer2014-02-261-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | Copying files to tftp is broken since: | commit d4f5bb1e011ac653a167031554f0ac9e028e9e36 | Author: Sascha Hauer <s.hauer@pengutronix.de> | Date: Sat Sep 28 13:12:50 2013 +0200 | | copy_file: Add missing O_TRUNC | | Without it, when copying a smaller file over a larger file the | resulting file still has the remaining space from the larger file. | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Since this commit copy_file passes O_TRUNC to open(). This results in the fs layer calling fsdrv->truncate. tftp returns -ENOSYS here and open returns with an error. To fix this return 0 for the truncate callback in tftp. Also enforce the O_TRUNC flag when opening a file for writing on tftp as the files are always truncated on tftp anyway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: andreas.willig@rafi.de
* fs: tftp: don't duplicate timeout informationBaruch Siach2013-08-121-1/+1
| | | | | Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* read_file: Make it work on tftp servers which do not pass sizeSascha Hauer2013-06-201-1/+4
| | | | | | | | Some tftp servers (for example netkit-tftp) do not pass the filesize. Add a workaround for read_file which reads the file into a temporary file which then is copied to a buffer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2013-02-041-10/+11
|\
| * tftp: reset timer on progressSascha Hauer2013-01-201-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | When during tftp receive operation a ACK packet can't successfully be sent the timer was resetted directly after send resulting in a deadlock. This patch changes the timer reset operation in a way that it is only resetted when the actually is progress, namely in the TFTP_ACK/TFTP_DATA pathes in the tftp handler. Reported-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Antony Pavlov <antonynpavlov@gmail.com>
* | treewide: fix format specifiersSascha Hauer2013-01-271-2/+2
|/ | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mem: add the swab (swap bytes) option to memory_display()Antony Pavlov2012-11-261-1/+1
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs tftp: Fix possible fifo overflowSascha Hauer2012-10-241-1/+5
| | | | | | | | | | In tftp_read we send a request for a new packet without checking if we have enough space in the FIFO. This can lead to a FIFO overflow and a corrupt file. Add a check for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
* fs tftp: Only request a block onceSascha Hauer2012-10-241-0/+6
| | | | | | | | | tftp_send is called often. Each time, when in STATE_RDATA, a packet is requested from the tftp server, even if we requested the same packet already. Stop this by tracking which packet we requested. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-3/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* use loff_t for file offsetsSascha Hauer2012-06-301-1/+1
| | | | | | | This is a first step for 64bit file support: Make the file sizes/offsets 64bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs tftp: Fix short file transfersSascha Hauer2012-06-241-1/+2
| | | | | | | | | With files smaller than the tftp block size the whole transfer is done in tftp_do_open already. In this case we are in STATE_DONE, but there is no error. Set priv->err to 0 and check for it to be able to transfer small files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs tftp: use resolv to resolv ip addressSascha Hauer2012-04-151-1/+1
| | | | | | | instead of assuming the backingstore is a ip address, use resolv() to make it possible to pass in a hostname. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: get fs device using container_ofSascha Hauer2012-02-251-2/+1
| | | | | | This reduces the usage of dev->type_data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add suport for tftp as a filesystemSascha Hauer2012-02-191-0/+644
This adds tftp filesystem support. It currently duplicates significant amounts of the tftp (command) support. This is ok since we can eventually drop the original tftp command later. tftp is not really suitable to be handled as a filesystem. It lacks support for stat, reading directories and other things. Handling it as a filesystem has one big advantage though: tftp is no special case for boot scripts and/or commands anymore which makes them simpler. This implementation has some improvements to the original tftp command. It supports blocksize negotiation which speeds up transfers if the tftp server supports it. Also we can determine the filesize to transfer if the remote end supports it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>