summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
...
| * commands: stat: remove code duplication for type infoAhmad Fatoum2023-06-081-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | stat prints a line with partitioning/type info for cdevs, but not all cdevs have these, so we want to skip printing when it's empty. Instead of duplicating the check, just utilize printf returning the number of characters written. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-9-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * driver: add new cdev_is_partition helperAhmad Fatoum2023-06-081-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Partitions will have cdev->master != NULL, so often code will just do if (cdev->master) to check if a cdev is a partition. This is suboptimal as it may be misinterpreted by readers as meaning that the cdev is the master device, while it's the other way round. Let's define cdev_is_partition instead and use it everywhere, where cdev->master is only checked, but not dereferenced. Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230607120714.3083182-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2023-06-222-5/+29
|\ \
| * | commands: stat: add basic handling for cdev linksAhmad Fatoum2023-06-012-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cdev links are not symlinks and cdev_by_name will always resolve them. As the barebox stat command is a convenience for VFS developers, it's useful to have the command identify links, so let's teach it just that. There's no behavior difference between specifying -L and not. This should be rather achieved by removing the concept of cdev links and using symlinks instead, but that's some refactoring for another time. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230531132331.2152268-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: stat: print symlink destination when called without -LAhmad Fatoum2023-06-011-2/+15
| |/ | | | | | | | | | | | | | | This aligns behavior with usual implementations of stat. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230531132331.2152268-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / treewide: add MODULE_DEVICE_TABLE markersAhmad Fatoum2023-06-131-0/+1
|/ | | | | | | | | | | | | | | | Syncing device trees with Linux upstream can lead to breakage, when the device trees are switched to newer bindings, which are not yet supported in barebox. To make it easier to spot such issues, we want to start applying some heuristics to flag possibly problematic DT changes. One step towards being able to do that is to know what nodes barebox actually consumes. Most of the nodes have a compatible entry, which is matched by an array of of_device_id, so let's have MODULE_DEVICE_TABLE point at it for future extraction. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125908.1087340-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: fail gracefully in get_mounted_path/get_cdev_by_mountpathAhmad Fatoum2023-05-081-0/+4
| | | | | | | | | | get_fsdevice_by_path will return NULL if no file system was mounted at location. Returned pointer was dereferenced unconditionally, potentially leading to null pointer dereference. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230508074612.3313870-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/arm' into nextSascha Hauer2023-03-161-2/+3
|\
| * ARM: omap: usbboot: Enable USB communication when neededSascha Hauer2023-03-071-1/+2
| | | | | | | | | | | | | | | | Instead of activating USB communication unconditionally in an initcall, let the users activate it once they need it. This gets us rid of an initcall that is not protected against running on foreign SoCs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ARM: omap: Move mach header files to include/mach/omapSascha Hauer2023-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | Currently arch specific headers can be included with longer possible as there won't be a single mach anymore. Move all omap specific header files to include/mach/omap/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: tftp: Fix NULL pointer deref in file uploadSascha Hauer2023-03-151-2/+2
| | | | | | | | | | | | | | | | | | | | With TFTP upload the window cache is unused, but still freed in tftp_do_close(). To avoid iterating on the uninitialized list, initialize it unconditionally and not only for the download case. Fixes: 3f1ea0ffcf8b ("tftp: implement UDP reorder cache using lists") Link: https://lore.barebox.org/20230315095300.2914980-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: stat: fix UUID printAhmad Fatoum2023-03-141-6/+3
|/ | | | | | cdev->uuid is an already formatted string, not a binary UUID. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2023-02-234-3/+29
|\
| * treewide: rename leftover device_dAhmad Fatoum2023-02-211-1/+1
| | | | | | | | | | | | | | | | | | We have some instances of device_d and driver_d still lingering in documentation and commented out code. Let's drop these as well. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230221070758.1130869-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: nfs: Error if a port is unregisteredJohn Watts2023-02-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If a server doesn't provide a service the port lookup will return 0. Check for this, return an appropriate error code and give a hint as to why this might be happening. This was tested by running NFS with UDP disabled, which seems to be the default in Arch at least. Signed-off-by: John Watts <contact@jookia.org> Link: https://lore.barebox.org/20230202112024.2458085-1-contact@jookia.org Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: remove unused members of struct statAhmad Fatoum2023-02-031-2/+2
| | | | | | | | | | | | | | | | Some members in struct stat are never written, so drop them. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230202142512.3551195-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: devfs: implement cdev_fdopenAhmad Fatoum2023-01-311-0/+20
| | | | | | | | | | | | | | | | | | | | | | As an alternative to cdev_open and using cdev_read/write, we define a new cdev_fdopen function that returns a file descriptor. The benefit of this is that code using it may use all the more high level helpers we have for reading/writing file descriptors. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230130072707.2423294-2-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: align write return codes with POSIXAhmad Fatoum2023-02-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Writing past end of a file results in a cryptic error code: barebox@board:/ cp /dev/zero /dev/mmc0.part write: Operation not permitted cp: Operation not permitted Because the cdev's truncate is not implemented and as such partition can't be increased in size. POSIX specifies EPERM as the correct return code for truncate(2) in such a situation, but for write(2) it is ENOSPC. Thus most truncate callbacks in barebox instead return ENOSPC, when according to POSIX, EPERM would have been the correct error code to propagate. Switching all truncate drivers is a bit more involved, so for now let's treat EPERM and ENOSPC instead when truncate fails to enlarge a file. Reported-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230202132734.314110-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: tftp: print message when stack can't keep us with TFTP windowsizeAhmad Fatoum2023-02-031-0/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | When the NIC driver doesn't configure enough buffers to keep up with a big TFTP windowsize, error reporting is less than optimal, e.g. on AX88x72A T BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBT T BBBBBBBBBBBBT BBBBBBBBBBBBBBBBBBBBBBBBBT or on older DWMAC1000 (non-EQOS): WARNING: eth0: Rx error status (8800) T BBBBBBWARNING: eth0: Rx error status (8800) While we probably want to: - decrease rate limit in __net_poll() - increase ring buffer depth for affected drivers For now, at least print a helpful warning. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230202133415.319020-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct fs_driver_d to fs_driverSascha Hauer2023-01-1020-35/+35
| | | | | | | | | Remove the meaningless '_d' suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-6-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct fs_device_d to fs_deviceSascha Hauer2023-01-1022-75/+79
| | | | | | | | | Remove the meaningless '_d' suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-102-4/+4
| | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-1026-214/+233
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-102-3/+3
| | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Remove unused struct partitionSascha Hauer2022-11-231-1/+0
| | | | | | | | struct partition from include/partition.h is entirely unused. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20221117120604.3840211-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: avoid uninitialized var warningSascha Hauer2022-11-081-1/+1
| | | | | | | | | | | | | | | | | | | With gcc-12.2.1-clang-15.0.2-glibc-2.36-binutils-2.39-kernel-6.0.5-sanitized we get a warning about path.dentry being used uninitialized: fs/fs.c:1978:43: warning: 'path.dentry' may be used uninitialized -Wmaybe-uninitialized] I can't see how this can really happen. gcc seems to think that this sequence used in lookup_fast() can result in returning 0: if (IS_ERR(dentry)) return PTR_ERR(dentry); This shouldn't happen. Silence the warning by initializing 'path'. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20221107102800.3669168-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: add new stat commandAhmad Fatoum2022-10-271-1/+104
| | | | | | | | | | | | | We have a couple of commands to help with debugging the VFS: ll, devinfo, devlookup, but we lack a command that can just dump all information we have in a struct stat or struct cdev. Add stat as such a command. For most uses, it's not needed, but it can come in handy for development. The stat_print and cdev_print functions underlying it are exported, so they can called for debugging purposes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221026063819.2355568-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/selftest'Sascha Hauer2022-10-131-0/+15
|\
| * fs: implement unreaddirAhmad Fatoum2022-10-111-0/+15
| | | | | | | | | | | | | | | | | | | | When iterating over a directory, it can be useful to put back the just read directory entry, so it can be retried at a later time. This will be needed for the EFI loader variable support. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061437.2085412-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/net'Sascha Hauer2022-10-132-325/+36
|\ \
| * | tftp: implement UDP reorder cache using listsSascha Hauer2022-09-222-223/+36
| | | | | | | | | | | | | | | | | | | | | | | | The UDP reorder cache can be much easier implemented using lists. As a bonus the cache grows and shrinks on demand and no fixed size has to be configured at compile time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | tftp: remove selftestSascha Hauer2022-09-221-102/+0
| | | | | | | | | | | | | | | | | | | | | | | | The out-of-order packet caching will be reworked in the next commit and most of the functions the self test tests will vanish, so nothing to test anymore. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/misc'Sascha Hauer2022-10-133-7/+26
|\ \ \ | |_|/ |/| |
| * | treewide: replace errno_str() with %m printf format specifierAhmad Fatoum2022-10-112-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both errno_str() and printf("%m" end up calling strerror(). %m is more convenient to use, so switch over all instances to it. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061122.2084009-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: export file system detection functionalityAhmad Fatoum2022-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This will come in handy when using barebox as EFI loader, so give it a more generic name and export it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220930154053.752237-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: implement cdev_mount()Ahmad Fatoum2022-10-041-0/+19
| |/ | | | | | | | | | | | | | | | | | | | | EFI loaders provide both block device and file system access to software running under it. For file system access, we will just want to get a mount if available and mount at a default location if not. Provide a helper that does just that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220930154017.750867-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / Revert "lib: zstd: sync with Linux"Sascha Hauer2022-09-302-4/+4
|/ | | | | | | | | | | | | | | | | This was part of a larger series that made it possible to use other compression algos than LZO for device tree and to use zstd more widely for barebox and kernel compression. The latter zstd-related parts needed rework and were not merged, but the zstd update was applied. It broken in turn the UBIFS zstd support. As we get nothing out of the update without the not applied commits that need rework anyway, revert this commit. This reverts commit b4a9782d4f56333e897dccc35c2c27e2605f6b93. Reported-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220929102537.1767458-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/tftp'Sascha Hauer2022-09-143-99/+779
|\
| * tftp: make read() fail in error caseEnrico Scholz2022-09-131-4/+10
| | | | | | | | | | | | | | | | | | | | | | when tftp transfer goes in error state e.g. due to error packets sent from the server or (unexpected) internal problems, let the read() fail instead of ignoring these errors silently and corrupting the output. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905085658.3854939-4-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: accept OACK + DATA datagrams only in certain statesEnrico Scholz2022-09-121-0/+12
| | | | | | | | | | | | | | | | | | | | | | These packets are valid in certain points of the transfer only and accepting them too early or too late can corrupt internal states. Reject them when they are unexpected. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-21-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: add selftestEnrico Scholz2022-09-122-1/+161
| | | | | | | | | | | | | | | | Unittest for window cache functions. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-20-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: reorder tftp packetsEnrico Scholz2022-09-122-6/+323
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the tftp "windowsize" option, reordering of udp datagrams becomes an issue. Depending on the network topology, this reordering occurs several times with large tftp transfers and will heavily reduce the transfer speed. This patch adds a packet cache so that datagrams can be reassembled in the correct order. Because it increases memory usage and barebox binary size, it is an Kconfig option. bloat-o-meter reports with a non-zero FS_TFTP_REORDER_CACHE_SIZE | add/remove: 3/0 grow/shrink: 4/0 up/down: 916/0 (916) | Function old new delta | tftp_handler 920 1244 +324 | tftp_put_data - 184 +184 | tftp_window_cache_remove - 124 +124 | tftp_window_cache_get_pos - 120 +120 | tftp_allocate_transfer 104 188 +84 | tftp_do_close 260 312 +52 | tftp_send 384 412 +28 | Total: Before=630104, After=631020, chg +0.15% After setting FS_TFTP_REORDER_CACHE_SIZE Kconfig option to 0, numbers are going down to | add/remove: 0/0 grow/shrink: 3/0 up/down: 152/0 (152) | Function old new delta | tftp_handler 920 1012 +92 | tftp_allocate_transfer 104 136 +32 | tftp_send 384 412 +28 | Total: Before=630104, After=630256, chg +0.02% Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-19-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: do not use 'priv->block' for RRQEnrico Scholz2022-09-121-3/+3
| | | | | | | | | | | | | | | | attribute is not used outside tftp_recv() for RRQ. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-18-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: implement 'windowsize' (RFC 7440) supportEnrico Scholz2022-09-122-13/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Results (with the reorder patch; numbers in bytes/s) on an iMX8MP are: | windowsize | VPN | 1 Gb/s | 100 Mb/s | |------------|-----------|------------|------------| | 128 | 3.869.284 | 98.643.085 | 11.434.852 | | 64 | 3.863.581 | 98.550.375 | 11.434.852 | | 48 | 3.431.580 | 94.211.680 | 11.275.010 | | 32 | 2.835.129 | 85.250.081 | 10.985.605 | | 24 | 2.344.858 | 77.787.537 | 10.765.667 | | 16 | 1.734.186 | 67.519.381 | 10.210.087 | | 12 | 1.403.340 | 61.972.576 | 9.915.612 | | 8 | 1.002.462 | 50.852.376 | 9.016.130 | | 6 | 775.573 | 42.781.558 | 8.422.297 | | 4 | 547.845 | 32.066.544 | 6.835.567 | | 3 | 412.987 | 26.526.081 | 6.322.435 | | 2 | 280.987 | 19.120.641 | 5.494.241 | | 1 | 141.699 | 10.431.516 | 2.967.224 | (VPN = OpenVPN on ADSL 50 Mb/s). The window size can be configured at runtime. This commit increases barebox size by | add/remove: 1/0 grow/shrink: 4/1 up/down: 148/-16 (132) | Function old new delta | tftp_send 336 384 +48 | tftp_handler 880 928 +48 | tftp_init 16 60 +44 | tftp_allocate_transfer 100 104 +4 | g_tftp_window_size - 4 +4 | tftp_poll 180 164 -16 | Total: Before=629980, After=630112, chg +0.02% Setting FS_TFTP_MAX_WINDOW_SIZE to zero reduces it to | add/remove: 1/0 grow/shrink: 3/2 up/down: 96/-52 (44) | Function old new delta | tftp_init 16 60 +44 | tftp_handler 880 924 +44 | tftp_allocate_transfer 100 104 +4 | g_tftp_window_size - 4 +4 | tftp_poll 180 164 -16 | tftp_send 336 300 -36 | Total: Before=629980, After=630024, chg +0.01% Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-17-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: detect out-of-memory situationsEnrico Scholz2022-09-121-2/+9
| | | | | | | | | | | | | | | | | | it should never happen due to the program logic; but detect a failed kfifo_put() just in case... Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-16-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: refactor data processingEnrico Scholz2022-08-311-16/+21
| | | | | | | | | | | | | | | | move block handling into dedicated function Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-15-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: reduce block size on lookup requestsEnrico Scholz2022-08-311-1/+3
| | | | | | | | | | | | | | | | | | Save some bytes on network traffic by reducing the server response for lookup requests. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-14-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: record whether tftp file is opened for lookup operation onlyEnrico Scholz2022-08-311-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opening a tftp is done in two steps: at first `tftp_lookup()` is called to get the filesize and then it is opened again and data are read. The `tftp_lookup()` call sends only a RRQ/WRQ, reads then the "tsize" from the response and closes the transfer by sending an error datagram. The tftp server will send a full data window. To prevent unneeded traffic, later patches set parameters to reduce the size of the server response. We need knowledge about type of operation which is recorded in an "is_getattr" attribute. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-13-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: add sanity check for OACK responseEnrico Scholz2022-08-311-3/+16
| | | | | | | | | | | | | | | | Catch bad 'blocksize' or 'windowsize' responses from the server. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-12-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: allocate buffers and fifo dynamicallyEnrico Scholz2022-08-311-50/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the actual blocksize for allocating buffers instead of assuming an hardcoded value. This requires to add an additional 'START' state which is entered after receiving (RRQ) or sending (WRQ) the OACK. Without it, the next state would be entered and the (not allocated yet) fifo be used. For non-rfc 2347 servers (which do not understand OACK and start with data transfer immediately after RRQ/WRQ), additional transitions in the state machine were implemented. Code adds some sanity checks in the new code paths. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-11-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>