mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] nfs: forward filesystem options to the kernel command line
@ 2016-02-05 15:09 Juergen Borleis
  2016-02-05 15:09 ` Juergen Borleis
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Borleis @ 2016-02-05 15:09 UTC (permalink / raw)
  To: barebox

This is v3 of this patch. v2 suffers from there is no real default port and
mountport number to check for. These portnumbers can be manually setup or will
be negotiated with the portmapper at the host's side. But we must honor these
special mount options only for the case where a user sets them up manually. By
using two new flags we can now be sure the portnumbers were set manually or
negotiated.

jb


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] nfs: forward filesystem options to the kernel command line
  2016-02-05 15:09 [PATCH] nfs: forward filesystem options to the kernel command line Juergen Borleis
@ 2016-02-05 15:09 ` Juergen Borleis
  2016-02-08  7:02   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Borleis @ 2016-02-05 15:09 UTC (permalink / raw)
  To: barebox

Using NFS in conjunction with boot spec and the feature to let Barebox
auto generate a kernel command line must keep the options the NFS filesystem
was mounted in Barebox. This patch extends the kernel command line parameter
on demand if something different than the defaults are used.

The command:

barebox:/ boot nfs://myhost//root

expands to the kernel command line:

nfsroot=myhost:/root,v3,tcp

while the command:

barebox:/ boot nfs://myhost:2049//root

expands now to the kernel command line:

nfsroot=myhost:/root,v3,tcp,mountport=2049,port=2049

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
 Documentation/user/booting-linux.rst |  2 +-
 fs/nfs.c                             | 21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst
index 39084e5..5b021f0 100644
--- a/Documentation/user/booting-linux.rst
+++ b/Documentation/user/booting-linux.rst
@@ -203,7 +203,7 @@ compatible NFS URI string must be passed to the boot command:
 
 .. code-block:: sh
 
-  boot nfs://nfshost//path/
+  boot nfs://nfshost[:port]//path/
 
 Additionally to the options defined in the original spec barebox understands the
 ``linux-appendroot`` option. This is a boolean value and if set to ``true`` barebox
diff --git a/fs/nfs.c b/fs/nfs.c
index 3824752..87828fc 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -133,7 +133,9 @@ struct nfs_priv {
 	IPaddr_t server;
 	char *path;
 	uint16_t mount_port;
+	unsigned manual_mount_port:1;
 	uint16_t nfs_port;
+	unsigned manual_nfs_port:1;
 	uint32_t rpc_id;
 	uint32_t rootfh_len;
 	char rootfh[NFS3_FHSIZE];
@@ -1311,7 +1313,7 @@ static char *rootnfsopts;
 
 static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
 {
-	char *str;
+	char *str, *tmp;
 	const char *ip;
 
 	ip = ip_to_string(npriv->server);
@@ -1319,6 +1321,19 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
 			ip, npriv->path, rootnfsopts[0] ? "," : "",
 			rootnfsopts);
 
+	/* forward specific mount options on demand */
+	if (npriv->manual_nfs_port == 1) {
+		tmp = asprintf("%s,port=%hu", str, npriv->nfs_port);
+		free(str);
+		str = tmp;
+	}
+
+	if (npriv->manual_mount_port == 1) {
+		tmp = asprintf("%s,mountport=%hu", str, npriv->mount_port);
+		free(str);
+		str = tmp;
+	}
+
 	fsdev_set_linux_rootarg(fsdev, str);
 
 	free(str);
@@ -1367,6 +1382,8 @@ static int nfs_probe(struct device_d *dev)
 			goto err2;
 		}
 		npriv->mount_port = ret;
+	} else {
+		npriv->manual_mount_port = 1;
 	}
 	debug("mount port: %hu\n", npriv->mount_port);
 
@@ -1378,6 +1395,8 @@ static int nfs_probe(struct device_d *dev)
 			goto err2;
 		}
 		npriv->nfs_port = ret;
+	} else {
+		npriv->manual_nfs_port = 1;
 	}
 	debug("nfs port: %d\n", npriv->nfs_port);
 
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nfs: forward filesystem options to the kernel command line
  2016-02-05 15:09 ` Juergen Borleis
@ 2016-02-08  7:02   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2016-02-08  7:02 UTC (permalink / raw)
  To: Juergen Borleis; +Cc: barebox

On Fri, Feb 05, 2016 at 04:09:47PM +0100, Juergen Borleis wrote:
> Using NFS in conjunction with boot spec and the feature to let Barebox
> auto generate a kernel command line must keep the options the NFS filesystem
> was mounted in Barebox. This patch extends the kernel command line parameter
> on demand if something different than the defaults are used.
> 
> The command:
> 
> barebox:/ boot nfs://myhost//root
> 
> expands to the kernel command line:
> 
> nfsroot=myhost:/root,v3,tcp
> 
> while the command:
> 
> barebox:/ boot nfs://myhost:2049//root
> 
> expands now to the kernel command line:
> 
> nfsroot=myhost:/root,v3,tcp,mountport=2049,port=2049
> 
> Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
> ---
>  Documentation/user/booting-linux.rst |  2 +-
>  fs/nfs.c                             | 21 ++++++++++++++++++++-
>  2 files changed, 21 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-08  7:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-05 15:09 [PATCH] nfs: forward filesystem options to the kernel command line Juergen Borleis
2016-02-05 15:09 ` Juergen Borleis
2016-02-08  7:02   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox