linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Joakim Tjernlund (Nokia)" <joakim.tjernlund@nokia.com>
To: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"Johannes.Thumshirn@wdc.com" <Johannes.Thumshirn@wdc.com>
Subject: Re: [PATCH v4] block: support mtd:<name> syntax for block devices
Date: Tue, 27 May 2025 15:12:52 +0000	[thread overview]
Message-ID: <ff1cbf3fa92e70214a107793952e2788b906b27c.camel@nokia.com> (raw)
In-Reply-To: <20250519150449.283536-1-joakim.tjernlund@infinera.com>

Please disregard <=v4
I have just sent v5

 Joakim
On Mon, 2025-05-19 at 17:03 +0200, Joakim Tjernlund wrote:
> This enables mounting, like JFFS2, MTD devices by "label":
>    mount -t squashfs mtd:appfs /tmp
> where mtd:appfs comes from:
>  # >  cat /proc/mtd
> dev:    size   erasesize  name
> ...
> mtd22: 00750000 00010000 "appfs"
> 
> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> ---
>  fs/super.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/fs/super.c b/fs/super.c
> index 97a17f9d9023..df7a6cfa34d3 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -37,6 +37,7 @@
>  #include <linux/user_namespace.h>
>  #include <linux/fs_context.h>
>  #include <uapi/linux/mount.h>
> +#include <linux/mtd/mtd.h>
>  #include "internal.h"
>  
>  static int thaw_super_locked(struct super_block *sb, enum freeze_holder who);
> @@ -1595,6 +1596,32 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
>  }
>  EXPORT_SYMBOL_GPL(setup_bdev_super);
>  
> +static int translate_mtd_name(struct fs_context *fc)
> +{
> +#ifdef CONFIG_MTD_BLOCK
> +	if (!strncmp(fc->source, "mtd:", 4)) {
> +		struct mtd_info *mtd;
> +		char *blk_source;
> +
> +		/* mount by MTD device name */
> +		pr_debug("Block SB: name \"%s\"\n", fc->source);
> +
> +		mtd = get_mtd_device_nm(fc->source + 4);
> +		if (IS_ERR(mtd))
> +			return -EINVAL;
> +		blk_source = kmalloc(20, GFP_KERNEL);
> +		if (!blk_source)
> +			return -ENOMEM;
> +		sprintf(blk_source, "/dev/mtdblock%d", mtd->index);
> +		kfree(fc->source);
> +		fc->source = blk_source;
> +		pr_debug("MTD device:%s found\n", fc->source);
> +		return 0;
> +	}
> +#endif
> +	return 0;
> +}
> +
>  /**
>   * get_tree_bdev_flags - Get a superblock based on a single block device
>   * @fc: The filesystem context holding the parameters
> @@ -1612,6 +1639,9 @@ int get_tree_bdev_flags(struct fs_context *fc,
>  	if (!fc->source)
>  		return invalf(fc, "No source specified");
>  
> +	error = translate_mtd_name(fc);
> +	if (error)
> +		return error;
>  	error = lookup_bdev(fc->source, &dev);
>  	if (error) {
>  		if (!(flags & GET_TREE_BDEV_QUIET_LOOKUP))

      parent reply	other threads:[~2025-05-27 15:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16  6:51 [PATCH] block: support mtd:<name> syntax for block devices Joakim Tjernlund
2025-05-16  7:14 ` Christoph Hellwig
2025-05-16  7:37   ` Joakim Tjernlund (Nokia)
2025-05-16  7:47     ` [PATCH v2] " Joakim Tjernlund
2025-05-19  8:12       ` Johannes Thumshirn
2025-05-19 13:11         ` [PATCH v3] " Joakim Tjernlund
2025-05-19 14:37           ` Johannes Thumshirn
2025-05-19 14:39             ` Joakim Tjernlund (Nokia)
2025-05-19 15:03             ` [PATCH v4] " Joakim Tjernlund
2025-05-27 15:10               ` [PATCH v5] " Joakim Tjernlund
2025-05-28 13:09                 ` kernel test robot
2025-06-02  7:50                   ` [PATCH v6] " Joakim Tjernlund
2025-06-14 12:43                     ` Joakim Tjernlund (Nokia)
2025-05-27 15:12               ` Joakim Tjernlund (Nokia) [this message]

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=ff1cbf3fa92e70214a107793952e2788b906b27c.camel@nokia.com \
    --to=joakim.tjernlund@nokia.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).