|
| 1 | +From c2622fd4e03d3f79ce341c3b417992831c9d785d Mon Sep 17 00:00:00 2001 |
| 2 | +From: Varadarajan Narayanan <varada@codeaurora.org> |
| 3 | +Date: Fri, 3 Jan 2014 13:05:56 +0530 |
| 4 | +Subject: Squashfs: Accept mtd names for mounting |
| 5 | + |
| 6 | +Enable SquashFS to mount using MTD partition names |
| 7 | +instead of device number. |
| 8 | + |
| 9 | +Signed-off-by: Varadarajan Narayanan <varada@codeaurora.org> |
| 10 | +(cherry picked from commit 4e9850b2e9ce7cdaaca70fc78a426f366f33655c) |
| 11 | + |
| 12 | +Change-Id: I49093c5139caa8d9e7a80fa8cce91b24f53f47e9 |
| 13 | +Signed-off-by: Abhishek Sahu <absahu@codeaurora.org> |
| 14 | +(cherry picked from commit 247c68acccbd646522dcf5b5d823f216806cace6) |
| 15 | +Signed-off-by: Rajkumar Ayyasamy <arajkuma@codeaurora.org> |
| 16 | +Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com> |
| 17 | +Signed-off-by: Saravanan Jaganathan <quic_sjaganat@quicinc.com> |
| 18 | +--- |
| 19 | + fs/squashfs/super.c | 40 ++++++++++++++++++++++++++++++++++++++++ |
| 20 | + 1 file changed, 40 insertions(+) |
| 21 | + |
| 22 | +diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c |
| 23 | +index 22e812808e5c..1e2bb05fd279 100644 |
| 24 | +--- a/fs/squashfs/super.c |
| 25 | ++++ b/fs/squashfs/super.c |
| 26 | +@@ -29,6 +29,10 @@ |
| 27 | + #include <linux/module.h> |
| 28 | + #include <linux/magic.h> |
| 29 | + #include <linux/xattr.h> |
| 30 | ++#include <linux/root_dev.h> |
| 31 | ++#include <linux/syscalls.h> |
| 32 | ++#include <linux/mtd/mtd.h> |
| 33 | ++#include <linux/init_syscalls.h> |
| 34 | + |
| 35 | + #include "squashfs_fs.h" |
| 36 | + #include "squashfs_fs_sb.h" |
| 37 | +@@ -485,8 +489,43 @@ failed_mount: |
| 38 | + return err; |
| 39 | + } |
| 40 | + |
| 41 | ++/* copy from init/do_mounts.h */ |
| 42 | ++static inline int create_dev(char *name, dev_t dev) |
| 43 | ++{ |
| 44 | ++ init_unlink(name); |
| 45 | ++ return init_mknod(name, S_IFBLK|0600, new_encode_dev(dev)); |
| 46 | ++} |
| 47 | ++ |
| 48 | ++static void squashfs_mount(struct fs_context *fc) |
| 49 | ++{ |
| 50 | ++ if (!strncmp(fc->source, "mtd:", 4) || !strncmp(fc->source, "ubi:", 4)) { |
| 51 | ++ struct mtd_info *mtd = get_mtd_device_nm("ubi_rootfs"); |
| 52 | ++ |
| 53 | ++ if (!IS_ERR(mtd)) { |
| 54 | ++ void *bdev; |
| 55 | ++ char *dev; |
| 56 | ++ dev = kmalloc(32, GFP_KERNEL); |
| 57 | ++ |
| 58 | ++ scnprintf(dev, 32, "/dev/mtdblock%d", mtd->index); |
| 59 | ++ bdev = bdev_file_open_by_path(dev, FMODE_READ, fc->fs_type, &fs_holder_ops); |
| 60 | ++ |
| 61 | ++ if (!IS_ERR(bdev)) { |
| 62 | ++ kfree(fc->source); |
| 63 | ++ fc->source = dev; |
| 64 | ++ } else if (PTR_ERR(bdev) == -ENOENT) { |
| 65 | ++ create_dev(dev, |
| 66 | ++ MKDEV(MTD_BLOCK_MAJOR, mtd->index)); |
| 67 | ++ kfree(fc->source); |
| 68 | ++ fc->source = dev; |
| 69 | ++ } else |
| 70 | ++ kfree(dev); |
| 71 | ++ } |
| 72 | ++ } |
| 73 | ++} |
| 74 | ++ |
| 75 | + static int squashfs_get_tree(struct fs_context *fc) |
| 76 | + { |
| 77 | ++ squashfs_mount(fc); |
| 78 | + return get_tree_bdev(fc, squashfs_fill_super); |
| 79 | + } |
| 80 | + |
| 81 | +diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c |
| 82 | +=================================================================== |
| 83 | +--- a/drivers/mtd/mtd_blkdevs.c |
| 84 | ++++ b/drivers/mtd/mtd_blkdevs.c |
| 85 | +@@ -474,7 +474,7 @@ static void blktrans_notify_add(struct m |
| 86 | + { |
| 87 | + struct mtd_blktrans_ops *tr; |
| 88 | + |
| 89 | +- if (mtd->type == MTD_ABSENT || mtd->type == MTD_UBIVOLUME) |
| 90 | ++ if (mtd->type == MTD_ABSENT) |
| 91 | + return; |
| 92 | + |
| 93 | + list_for_each_entry(tr, &blktrans_majors, list) |
| 94 | +@@ -514,7 +514,7 @@ int register_mtd_blktrans(struct mtd_blk |
| 95 | + mutex_lock(&mtd_table_mutex); |
| 96 | + list_add(&tr->list, &blktrans_majors); |
| 97 | + mtd_for_each_device(mtd) |
| 98 | +- if (mtd->type != MTD_ABSENT && mtd->type != MTD_UBIVOLUME) |
| 99 | ++ if (mtd->type != MTD_ABSENT) |
| 100 | + tr->add_mtd(tr, mtd); |
| 101 | + mutex_unlock(&mtd_table_mutex); |
| 102 | + return 0; |
0 commit comments