Commit ad022c87 authored by Richard Weinberger's avatar Richard Weinberger

Revert "mtd: switch ubi_open_volume_path() to vfs_stat()"

This reverts commit 322ea0bb.

vfs_stat() can only be used on user supplied buffers.
UBI's kapi.c is the API to the kernel and therefore vfs_stat()
is inappropriate.

This solves the problem that mounting any UBIFS will immediately
fail with -EINVAL.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent db06d759
...@@ -301,24 +301,27 @@ EXPORT_SYMBOL_GPL(ubi_open_volume_nm); ...@@ -301,24 +301,27 @@ EXPORT_SYMBOL_GPL(ubi_open_volume_nm);
*/ */
struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode) struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode)
{ {
int error, ubi_num, vol_id; int error, ubi_num, vol_id, mod;
struct kstat stat; struct inode *inode;
struct path path;
dbg_gen("open volume %s, mode %d", pathname, mode); dbg_gen("open volume %s, mode %d", pathname, mode);
if (!pathname || !*pathname) if (!pathname || !*pathname)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
error = vfs_stat(pathname, &stat); error = kern_path(pathname, LOOKUP_FOLLOW, &path);
if (error) if (error)
return ERR_PTR(error); return ERR_PTR(error);
if (!S_ISCHR(stat.mode)) inode = d_backing_inode(path.dentry);
return ERR_PTR(-EINVAL); mod = inode->i_mode;
ubi_num = ubi_major2num(imajor(inode));
ubi_num = ubi_major2num(MAJOR(stat.rdev)); vol_id = iminor(inode) - 1;
vol_id = MINOR(stat.rdev) - 1; path_put(&path);
if (!S_ISCHR(mod))
return ERR_PTR(-EINVAL);
if (vol_id >= 0 && ubi_num >= 0) if (vol_id >= 0 && ubi_num >= 0)
return ubi_open_volume(ubi_num, vol_id, mode); return ubi_open_volume(ubi_num, vol_id, mode);
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment