Lines Matching +full:mtd +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* MTD-based superblock management
4 * Copyright © 2001-2007 Red Hat, Inc. All Rights Reserved.
5 * Copyright © 2001-2010 David Woodhouse <dwmw2@infradead.org>
11 #include <linux/mtd/super.h>
17 #include <linux/backing-dev.h>
23 * get a superblock on an MTD-backed filesystem
26 struct mtd_info *mtd, in mtd_get_sb() argument
33 sb = sget_dev(fc, MKDEV(MTD_BLOCK_MAJOR, mtd->index)); in mtd_get_sb()
37 if (sb->s_root) { in mtd_get_sb()
40 mtd->index, mtd->name); in mtd_get_sb()
41 put_mtd_device(mtd); in mtd_get_sb()
45 mtd->index, mtd->name); in mtd_get_sb()
49 * contrast to sb->s_bdev that's checked with only in mtd_get_sb()
50 * @sb_lock held, nothing checks sb->s_mtd without also in mtd_get_sb()
51 * holding sb->s_umount and we're holding sb->s_umount in mtd_get_sb()
54 sb->s_mtd = mtd; in mtd_get_sb()
55 sb->s_bdi = bdi_get(mtd_bdi); in mtd_get_sb()
61 sb->s_flags |= SB_ACTIVE; in mtd_get_sb()
64 BUG_ON(fc->root); in mtd_get_sb()
65 fc->root = dget(sb->s_root); in mtd_get_sb()
74 * get a superblock on an MTD-backed filesystem by MTD device number
80 struct mtd_info *mtd; in mtd_get_sb_by_nr() local
82 mtd = get_mtd_device(NULL, mtdnr); in mtd_get_sb_by_nr()
83 if (IS_ERR(mtd)) { in mtd_get_sb_by_nr()
85 return PTR_ERR(mtd); in mtd_get_sb_by_nr()
88 return mtd_get_sb(fc, mtd, fill_super); in mtd_get_sb_by_nr()
92 * get_tree_mtd - Get a superblock based on a single MTD device
106 if (!fc->source) in get_tree_mtd()
109 pr_debug("MTDSB: dev_name \"%s\"\n", fc->source); in get_tree_mtd()
112 * CONFIG_BLOCK=n - we specify the underlying MTD device by number or in get_tree_mtd()
113 * by name, so that we don't require block device support to be present in get_tree_mtd()
116 if (fc->source[0] == 'm' && in get_tree_mtd()
117 fc->source[1] == 't' && in get_tree_mtd()
118 fc->source[2] == 'd') { in get_tree_mtd()
119 if (fc->source[3] == ':') { in get_tree_mtd()
120 struct mtd_info *mtd; in get_tree_mtd() local
122 /* mount by MTD device name */ in get_tree_mtd()
123 pr_debug("MTDSB: mtd:%%s, name \"%s\"\n", in get_tree_mtd()
124 fc->source + 4); in get_tree_mtd()
126 mtd = get_mtd_device_nm(fc->source + 4); in get_tree_mtd()
127 if (!IS_ERR(mtd)) in get_tree_mtd()
128 return mtd_get_sb(fc, mtd, fill_super); in get_tree_mtd()
130 errorf(fc, "MTD: MTD device with name \"%s\" not found", in get_tree_mtd()
131 fc->source + 4); in get_tree_mtd()
133 } else if (isdigit(fc->source[3])) { in get_tree_mtd()
134 /* mount by MTD device number name */ in get_tree_mtd()
137 mtdnr = simple_strtoul(fc->source + 3, &endptr, 0); in get_tree_mtd()
140 pr_debug("MTDSB: mtd%%d, mtdnr %d\n", mtdnr); in get_tree_mtd()
147 /* try the old way - the hack where we allowed users to mount in get_tree_mtd()
150 ret = lookup_bdev(fc->source, &dev); in get_tree_mtd()
152 errorf(fc, "MTD: Couldn't look up '%s': %d", fc->source, ret); in get_tree_mtd()
162 if (!(fc->sb_flags & SB_SILENT)) in get_tree_mtd()
163 errorf(fc, "MTD: Attempt to mount non-MTD device \"%s\"", in get_tree_mtd()
164 fc->source); in get_tree_mtd()
165 return -EINVAL; in get_tree_mtd()
170 * destroy an MTD-based superblock
175 put_mtd_device(sb->s_mtd); in kill_mtd_super()
176 sb->s_mtd = NULL; in kill_mtd_super()