mirror of
https://github.com/torvalds/linux.git
synced 2024-10-24 06:01:01 +00:00
mtd: switch ubi_open_volume_path() to vfs_stat()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
87f15d4add
commit
322ea0bbf3
|
@ -301,27 +301,24 @@ 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, mod;
|
int error, ubi_num, vol_id;
|
||||||
struct inode *inode;
|
struct kstat stat;
|
||||||
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 = kern_path(pathname, LOOKUP_FOLLOW, &path);
|
error = vfs_stat(pathname, &stat);
|
||||||
if (error)
|
if (error)
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
|
|
||||||
inode = d_backing_inode(path.dentry);
|
if (!S_ISCHR(stat.mode))
|
||||||
mod = inode->i_mode;
|
|
||||||
ubi_num = ubi_major2num(imajor(inode));
|
|
||||||
vol_id = iminor(inode) - 1;
|
|
||||||
path_put(&path);
|
|
||||||
|
|
||||||
if (!S_ISCHR(mod))
|
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
|
ubi_num = ubi_major2num(MAJOR(stat.rdev));
|
||||||
|
vol_id = MINOR(stat.rdev) - 1;
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user