Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
Revert "mtd: switch open_mtd_by_chdev() to use of vfs_stat()"
Browse files Browse the repository at this point in the history
This reverts commit 87f15d4.

vfs_stat() can only be used on user supplied buffers.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
richardweinberger committed Jun 14, 2016
1 parent ad022c8 commit 1a498ec
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/mtd/ubi/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,19 +1147,22 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
*/
static struct mtd_info * __init open_mtd_by_chdev(const char *mtd_dev)
{
struct kstat stat;
int err, minor;
int err, major, minor, mode;
struct path path;

/* Probably this is an MTD character device node path */
err = vfs_stat(mtd_dev, &stat);
err = kern_path(mtd_dev, LOOKUP_FOLLOW, &path);
if (err)
return ERR_PTR(err);

/* MTD device number is defined by the major / minor numbers */
if (MAJOR(stat.rdev) != MTD_CHAR_MAJOR || !S_ISCHR(stat.mode))
major = imajor(d_backing_inode(path.dentry));
minor = iminor(d_backing_inode(path.dentry));
mode = d_backing_inode(path.dentry)->i_mode;
path_put(&path);
if (major != MTD_CHAR_MAJOR || !S_ISCHR(mode))
return ERR_PTR(-EINVAL);

minor = MINOR(stat.rdev);
if (minor & 1)
/*
* Just do not think the "/dev/mtdrX" devices support is need,
Expand Down

0 comments on commit 1a498ec

Please sign in to comment.