summaryrefslogtreecommitdiffstats
path: root/fs/nfs.c
diff options
context:
space:
mode:
authorJuergen Borleis <jbe@pengutronix.de>2016-02-05 16:09:47 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-02-08 08:02:33 +0100
commitb5778f9773df9e749158e43976a4d88e84ef79f8 (patch)
tree39c7e44418bf3c1cf297dd2f52d5a3b177ba7a1d /fs/nfs.c
parenta4cee7207a14ec5445f4fe755fda0d1d28372bc5 (diff)
downloadbarebox-b5778f9773df9e749158e43976a4d88e84ef79f8.tar.gz
barebox-b5778f9773df9e749158e43976a4d88e84ef79f8.tar.xz
nfs: forward filesystem options to the kernel command line
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs/nfs.c')
-rw-r--r--fs/nfs.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/fs/nfs.c b/fs/nfs.c
index 382475249f..87828fce13 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);