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>
Cc: Enrico Jorns <ejo@pengutronix.de>
Subject: [PATCH 5/6] fs: squashfs: append linux rootarg for ubi volume
Date: Mon, 24 Oct 2016 08:28:42 +0200	[thread overview]
Message-ID: <20161024062843.2796-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20161024062843.2796-1-s.hauer@pengutronix.de>

From: Enrico Jorns <ejo@pengutronix.de>

If squashfs runs from an ubi volume, append appropriate root kernel
options.

Note that ubiblock support is required in the kernel for that.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/squashfs/squashfs.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index 6d04681..c4d0bac 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -9,12 +9,16 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <linux/pagemap.h>
+#include <linux/mtd/ubi.h>
+#include <linux/mtd/mtd.h>
 
 #include "squashfs_fs.h"
 #include "squashfs_fs_sb.h"
 #include "squashfs_fs_i.h"
 #include "squashfs.h"
 
+struct ubi_volume_desc;
+
 char *squashfs_devread(struct squashfs_sb_info *fs, int byte_offset,
 		int byte_len)
 {
@@ -108,6 +112,31 @@ static struct inode *squashfs_findfile(struct super_block *sb,
 	return NULL;
 }
 
+void squashfs_set_rootarg(struct squashfs_priv *priv, struct fs_device_d *fsdev)
+{
+	struct ubi_volume_desc *ubi_vol;
+	struct ubi_volume_info vi = {};
+	struct ubi_device_info di = {};
+	struct mtd_info *mtd;
+	char *str;
+
+	ubi_vol = ubi_open_volume_cdev(fsdev->cdev, UBI_READONLY);
+
+	if (IS_ERR(ubi_vol))
+		return;
+
+	ubi_get_volume_info(ubi_vol, &vi);
+	ubi_get_device_info(vi.ubi_num, &di);
+	mtd = di.mtd;
+
+	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
+
+	fsdev_set_linux_rootarg(fsdev, str);
+
+	free(str);
+}
+
 static int squashfs_probe(struct device_d *dev)
 {
 	struct fs_device_d *fsdev;
@@ -130,6 +159,8 @@ static int squashfs_probe(struct device_d *dev)
 		goto err_out;
 	}
 
+	squashfs_set_rootarg(priv, fsdev);
+
 	return 0;
 
 err_out:
-- 
2.9.3


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

  parent reply	other threads:[~2016-10-24  6:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24  6:28 [PATCH v2] squashfs additional decompressors Sascha Hauer
2016-10-24  6:28 ` [PATCH 1/6] fs: squashfs: port lzo compression support from kernel Sascha Hauer
2016-10-24  6:28 ` [PATCH 2/6] fs: squashfs: port lz4 " Sascha Hauer
2016-10-24  6:28 ` [PATCH 3/6] fs: squashfs: port zlib " Sascha Hauer
2016-10-24  6:28 ` [PATCH 4/6] Add filetype and detection for squashfs images Sascha Hauer
2016-10-24  6:28 ` Sascha Hauer [this message]
2016-10-24  6:28 ` [PATCH 6/6] fs: squashfs: Enable squashfs XZ support when XZ is enabled Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2016-10-21  6:51 [PATCH 1/6] fs: squashfs: port lzo compression support from kernel Sascha Hauer
2016-10-21  6:51 ` [PATCH 5/6] fs: squashfs: append linux rootarg for ubi volume 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=20161024062843.2796-6-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=ejo@pengutronix.de \
    /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