diff options
Diffstat (limited to 'drivers/mtd/mtdsuper.c')
-rw-r--r-- | drivers/mtd/mtdsuper.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c index 28cc6787a800..00d46e137b2a 100644 --- a/drivers/mtd/mtdsuper.c +++ b/drivers/mtd/mtdsuper.c | |||
@@ -125,8 +125,11 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags, | |||
125 | int (*fill_super)(struct super_block *, void *, int), | 125 | int (*fill_super)(struct super_block *, void *, int), |
126 | struct vfsmount *mnt) | 126 | struct vfsmount *mnt) |
127 | { | 127 | { |
128 | struct nameidata nd; | 128 | #ifdef CONFIG_BLOCK |
129 | int mtdnr, ret; | 129 | struct block_device *bdev; |
130 | int ret, major; | ||
131 | #endif | ||
132 | int mtdnr; | ||
130 | 133 | ||
131 | if (!dev_name) | 134 | if (!dev_name) |
132 | return -EINVAL; | 135 | return -EINVAL; |
@@ -178,45 +181,38 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags, | |||
178 | } | 181 | } |
179 | } | 182 | } |
180 | 183 | ||
184 | #ifdef CONFIG_BLOCK | ||
181 | /* try the old way - the hack where we allowed users to mount | 185 | /* try the old way - the hack where we allowed users to mount |
182 | * /dev/mtdblock$(n) but didn't actually _use_ the blockdev | 186 | * /dev/mtdblock$(n) but didn't actually _use_ the blockdev |
183 | */ | 187 | */ |
184 | ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); | 188 | bdev = lookup_bdev(dev_name); |
185 | 189 | if (IS_ERR(bdev)) { | |
186 | DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n", | 190 | ret = PTR_ERR(bdev); |
187 | ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL); | 191 | DEBUG(1, "MTDSB: lookup_bdev() returned %d\n", ret); |
188 | |||
189 | if (ret) | ||
190 | return ret; | 192 | return ret; |
193 | } | ||
194 | DEBUG(1, "MTDSB: lookup_bdev() returned 0\n"); | ||
191 | 195 | ||
192 | ret = -EINVAL; | 196 | ret = -EINVAL; |
193 | 197 | ||
194 | if (!S_ISBLK(nd.path.dentry->d_inode->i_mode)) | 198 | major = MAJOR(bdev->bd_dev); |
195 | goto out; | 199 | mtdnr = MINOR(bdev->bd_dev); |
196 | 200 | bdput(bdev); | |
197 | if (nd.path.mnt->mnt_flags & MNT_NODEV) { | ||
198 | ret = -EACCES; | ||
199 | goto out; | ||
200 | } | ||
201 | 201 | ||
202 | if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR) | 202 | if (major != MTD_BLOCK_MAJOR) |
203 | goto not_an_MTD_device; | 203 | goto not_an_MTD_device; |
204 | 204 | ||
205 | mtdnr = iminor(nd.path.dentry->d_inode); | ||
206 | path_put(&nd.path); | ||
207 | |||
208 | return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, | 205 | return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, |
209 | mnt); | 206 | mnt); |
210 | 207 | ||
211 | not_an_MTD_device: | 208 | not_an_MTD_device: |
209 | #endif /* CONFIG_BLOCK */ | ||
210 | |||
212 | if (!(flags & MS_SILENT)) | 211 | if (!(flags & MS_SILENT)) |
213 | printk(KERN_NOTICE | 212 | printk(KERN_NOTICE |
214 | "MTD: Attempt to mount non-MTD device \"%s\"\n", | 213 | "MTD: Attempt to mount non-MTD device \"%s\"\n", |
215 | dev_name); | 214 | dev_name); |
216 | out: | 215 | return -EINVAL; |
217 | path_put(&nd.path); | ||
218 | return ret; | ||
219 | |||
220 | } | 216 | } |
221 | 217 | ||
222 | EXPORT_SYMBOL_GPL(get_sb_mtd); | 218 | EXPORT_SYMBOL_GPL(get_sb_mtd); |