From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 5/6] fs: nfs: Implement Linux rootarg
Date: Thu, 18 Jun 2015 09:43:43 +0200 [thread overview]
Message-ID: <1434613424-19989-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1434613424-19989-1-git-send-email-s.hauer@pengutronix.de>
Add the root= parameter for NFS filesystems. We currently hardcode
v3 and tcp which probably needs to become configurable at some point.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Documentation/filesystems/nfs.rst | 13 +++++++++++++
fs/nfs.c | 24 ++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/Documentation/filesystems/nfs.rst b/Documentation/filesystems/nfs.rst
index f4eda5d..4469ac1 100644
--- a/Documentation/filesystems/nfs.rst
+++ b/Documentation/filesystems/nfs.rst
@@ -10,3 +10,16 @@ barebox has readonly support for NFSv3 in UDP mode.
Example::
mount -t nfs 192.168.23.4:/home/user/nfsroot /mnt/nfs
+
+The barebox NFS driver adds a ``linux.bootargs`` device parameter to the NFS device.
+This parameter holds a Linux kernel commandline snippet containing a suitable root=
+option for booting from exactly that NFS share.
+
+Example::
+
+ devinfo nfs0
+ ...
+ linux.bootargs: root=/dev/nfs nfsroot=192.168.23.4:/home/sha/nfsroot/generic-v7,v3,tcp
+
+The options default to ``v3,tcp`` but can be adjusted before mounting the NFS share with
+the ``global.linux.rootnfsopts`` variable
diff --git a/fs/nfs.c b/fs/nfs.c
index 2738c78..5bff54a 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -35,6 +35,7 @@
#include <kfifo.h>
#include <linux/sizes.h>
#include <byteorder.h>
+#include <globalvar.h>
#include "parseopt.h"
@@ -1306,6 +1307,23 @@ static int nfs_stat(struct device_d *dev, const char *filename, struct stat *s)
}
}
+static char *rootnfsopts;
+
+static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
+{
+ char *str;
+ const char *ip;
+
+ ip = ip_to_string(npriv->server);
+ str = asprintf("root=/dev/nfs nfsroot=%s:%s%s%s",
+ ip, npriv->path, rootnfsopts[0] ? "," : "",
+ rootnfsopts);
+
+ fsdev_set_linux_rootarg(fsdev, str);
+
+ free(str);
+}
+
static int nfs_probe(struct device_d *dev)
{
struct fs_device_d *fsdev = dev_to_fs_device(dev);
@@ -1369,6 +1387,8 @@ static int nfs_probe(struct device_d *dev)
goto err2;
}
+ nfs_set_rootarg(npriv, fsdev);
+
free(tmp);
return 0;
@@ -1421,6 +1441,10 @@ static struct fs_driver_d nfs_driver = {
static int nfs_init(void)
{
+ rootnfsopts = xstrdup("v3,tcp");
+
+ globalvar_add_simple_string("linux.rootnfsopts", &rootnfsopts);
+
return register_fs_driver(&nfs_driver);
}
coredevice_initcall(nfs_init);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-06-18 7:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-18 7:43 Bootspec: Allow to automatically append root= option Sascha Hauer
2015-06-18 7:43 ` [PATCH 1/6] Add globalvar_add_simple_string function Sascha Hauer
2015-06-18 7:43 ` [PATCH 2/6] cdev: Add partuuid string to struct cdev Sascha Hauer
2015-06-18 7:43 ` [PATCH 3/6] fs: Add device parameter for Linux root= option Sascha Hauer
2015-06-18 7:43 ` [PATCH 4/6] fs: ubifs: Implement Linux rootarg Sascha Hauer
2015-06-18 7:43 ` Sascha Hauer [this message]
2015-06-18 7:43 ` [PATCH 6/6] blspec: Automatically append rootarg Sascha Hauer
2015-06-30 7:26 ` Marc Kleine-Budde
2015-07-01 6:58 ` Sascha Hauer
2015-07-01 7:22 ` Marc Kleine-Budde
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=1434613424-19989-6-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@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