[PATCH v4 02/21] tftp: allow to change tftp port
Enrico Scholz
enrico.scholz at sigma-chemnitz.de
Tue Aug 30 00:37:57 PDT 2022
This adds a 'port=<port>' mount option for tftp filesystems.
Useful e.g. when working with a local, non-privileged tftp server
Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
fs/tftp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/tftp.c b/fs/tftp.c
index c26204ae76e6..913ca1df6e42 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -30,6 +30,7 @@
#include <linux/stat.h>
#include <linux/err.h>
#include <kfifo.h>
+#include <parseopt.h>
#include <linux/sizes.h>
#define TFTP_PORT 69 /* Well known TFTP port number */
@@ -376,6 +377,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
struct file_priv *priv;
struct tftp_priv *tpriv = dev->priv;
int ret;
+ unsigned short port = TFTP_PORT;
priv = xzalloc(sizeof(*priv));
@@ -405,8 +407,9 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
goto out;
}
- priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
- priv);
+ parseopt_hu(fsdev->options, "port", &port);
+
+ priv->tftp_con = net_udp_new(tpriv->server, port, tftp_handler, priv);
if (IS_ERR(priv->tftp_con)) {
ret = PTR_ERR(priv->tftp_con);
goto out1;
--
2.37.2
More information about the barebox
mailing list