mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Borleis <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [RFC] nfs: forward filesystem options to the kernel command line
Date: Tue, 2 Feb 2016 12:06:30 +0100	[thread overview]
Message-ID: <201602021206.30161.jbe@pengutronix.de> (raw)

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 were 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
    
now expands to the kernel command line:
   
nfsroot=myhost:/root,v3,tcp,mountport=2049,port=2049
    
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>

diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst
index 39084e5afe08..5b021f0662de 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 382475249fc8..14d7cb138e40 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1324,11 +1324,21 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
 	free(str);
 }
 
+static void nfs_extend_options(char **opts, const char *ext)
+{
+	size_t u;
+
+	u = strlen(*opts);
+	*opts = xrealloc(*opts, u + 1 + strlen(ext));
+	strcat(*opts + u, ext);
+}
+
 static int nfs_probe(struct device_d *dev)
 {
 	struct fs_device_d *fsdev = dev_to_fs_device(dev);
 	struct nfs_priv *npriv = xzalloc(sizeof(struct nfs_priv));
 	char *tmp = xstrdup(fsdev->backingstore);
+	char buf[20];
 	char *path;
 	int ret;
 
@@ -1367,6 +1377,9 @@ static int nfs_probe(struct device_d *dev)
 			goto err2;
 		}
 		npriv->mount_port = ret;
+	} else {
+		snprintf(buf, sizeof(buf), ",mountport=%d", npriv->mount_port);
+		nfs_extend_options(&rootnfsopts, buf);
 	}
 	debug("mount port: %hu\n", npriv->mount_port);
 
@@ -1378,6 +1391,9 @@ static int nfs_probe(struct device_d *dev)
 			goto err2;
 		}
 		npriv->nfs_port = ret;
+	} else {
+		snprintf(buf, sizeof(buf), ",port=%d", npriv->nfs_port);
+		nfs_extend_options(&rootnfsopts, buf);
 	}
 	debug("nfs port: %d\n", npriv->nfs_port);
 

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

             reply	other threads:[~2016-02-02 11:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02 11:06 Juergen Borleis [this message]
2016-02-02 13:49 ` [PATCH v2] " Juergen Borleis
2016-02-04  8:06   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201602021206.30161.jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox