mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 4/6] fs: ubifs: Implement Linux rootarg
Date: Thu, 18 Jun 2015 09:43:42 +0200	[thread overview]
Message-ID: <1434613424-19989-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1434613424-19989-1-git-send-email-s.hauer@pengutronix.de>

Add the parameter to boot from ubifs fileystems. This assumes that
there will be only one UBI device registered in the kernel, otherwise
there is no way to predict the ubi number.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/ubi/kapi.c  |  1 +
 fs/ubifs/ubifs.c        | 23 +++++++++++++++++++++++
 include/linux/mtd/ubi.h |  1 +
 3 files changed, 25 insertions(+)

diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 08cb8dd..7fc1aa8 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -36,6 +36,7 @@ void ubi_do_get_device_info(struct ubi_device *ubi, struct ubi_device_info *di)
 	di->min_io_size = ubi->min_io_size;
 	di->max_write_size = ubi->max_write_size;
 	di->ro_mode = ubi->ro_mode;
+	di->mtd = ubi->mtd;
 }
 EXPORT_SYMBOL_GPL(ubi_do_get_device_info);
 
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 68d90b3..a9189f7 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);
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h
index 274ec4e..0614681 100644
--- a/include/linux/mtd/ubi.h
+++ b/include/linux/mtd/ubi.h
@@ -154,6 +154,7 @@ struct ubi_device_info {
 	int max_write_size;
 	int ro_mode;
 	dev_t cdev;
+	struct mtd_info *mtd;
 };
 
 /*
-- 
2.1.4


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

  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 ` Sascha Hauer [this message]
2015-06-18  7:43 ` [PATCH 5/6] fs: nfs: Implement Linux rootarg Sascha Hauer
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-5-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