summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-07-06 12:43:29 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-07-06 12:43:29 +0200
commitd297851b1a79997b19d9c816ca737f0f48e768dd (patch)
tree9a787a757a463dd5de7a65ae8b2ff205707fc938 /fs
parent735c570e5ad87a562dd9a50208a087e105eaecf6 (diff)
parent716fdbf18ca12feb81e26df729a5b8969e394e96 (diff)
downloadbarebox-d297851b1a79997b19d9c816ca737f0f48e768dd.tar.gz
barebox-d297851b1a79997b19d9c816ca737f0f48e768dd.tar.xz
Merge branch 'for-next/blspec'
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c37
-rw-r--r--fs/nfs.c24
-rw-r--r--fs/ubifs/ubifs.c23
3 files changed, 84 insertions, 0 deletions
diff --git a/fs/fs.c b/fs/fs.c
index c249f843bf..67c78cd111 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1298,6 +1298,12 @@ int mount(const char *device, const char *fsname, const char *_path,
goto err_no_driver;
}
+ if (!fsdev->linux_rootarg && fsdev->cdev && fsdev->cdev->partuuid[0] != 0) {
+ char *str = asprintf("root=PARTUUID=%s", fsdev->cdev->partuuid);
+
+ fsdev_set_linux_rootarg(fsdev, str);
+ }
+
return 0;
err_no_driver:
@@ -1708,3 +1714,34 @@ void mount_all(void)
cdev_mount_default(cdev, NULL);
}
}
+
+void fsdev_set_linux_rootarg(struct fs_device_d *fsdev, const char *str)
+{
+ fsdev->linux_rootarg = xstrdup(str);
+
+ dev_add_param_fixed(&fsdev->dev, "linux.bootargs", fsdev->linux_rootarg);
+}
+
+/**
+ * path_get_linux_rootarg() - Given a path return a suitable root= option for
+ * Linux
+ * @path: The path
+ *
+ * Return: A string containing the root= option or an ERR_PTR. the returned
+ * string must be freed by the caller.
+ */
+char *path_get_linux_rootarg(const char *path)
+{
+ struct fs_device_d *fsdev;
+ const char *str;
+
+ fsdev = get_fsdevice_by_path(path);
+ if (!fsdev)
+ return ERR_PTR(-EINVAL);
+
+ str = dev_get_param(&fsdev->dev, "linux.bootargs");
+ if (!str)
+ return ERR_PTR(-ENOSYS);
+
+ return xstrdup(str);
+}
diff --git a/fs/nfs.c b/fs/nfs.c
index 2738c781d7..5bff54a4dd 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);
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 68d90b36e7..a9189f76b5 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -36,6 +36,7 @@
#include <linux/zlib.h>
#include <xfuncs.h>
#include <fcntl.h>
+#include <linux/mtd/mtd.h>
#include "ubifs.h"
@@ -584,6 +585,26 @@ static int ubifs_readlink(struct device_d *dev, const char *pathname, char *buf,
return 0;
}
+static void ubifs_set_rootarg(struct ubifs_priv *priv, struct fs_device_d *fsdev)
+{
+ struct ubi_volume_info vi = {};
+ struct ubi_device_info di = {};
+ struct mtd_info *mtd;
+ char *str;
+
+ ubi_get_volume_info(priv->ubi, &vi);
+ ubi_get_device_info(vi.ubi_num, &di);
+
+ mtd = di.mtd;
+
+ str = asprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
+ vi.name, mtd->cdev.partname);
+
+ fsdev_set_linux_rootarg(fsdev, str);
+
+ free(str);
+}
+
static int ubifs_probe(struct device_d *dev)
{
struct fs_device_d *fsdev = dev_to_fs_device(dev);
@@ -612,6 +633,8 @@ static int ubifs_probe(struct device_d *dev)
goto err;
}
+ ubifs_set_rootarg(priv, fsdev);
+
return 0;
err:
ubi_close_volume(priv->ubi);